Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fast charge support

Thanks to Chad Froebel
  • Loading branch information...
commit 2c050b03c9bdf311588391573c1973fb37a6ffbf 1 parent 9af3c22
stratosk authored
View
8 arch/arm/mach-s5pv210/Kconfig
@@ -375,4 +375,12 @@ config WIFI_CONTROL_FUNC
bool "Enable WiFi control function abstraction"
help
Enables Power/Reset/Carddetect function abstraction
+
+config FORCE_FAST_CHARGE
+ tristate "Force AC charge mode at will"
+ default m
+ help
+ A simple sysfs interface to force adapters that
+ are detected as USB to charge as AC.
+
endif
View
2  arch/arm/mach-s5pv210/Makefile
@@ -47,6 +47,8 @@ obj-$(CONFIG_PHONE_ARIES_CDMA) += dev-s1-phone.o
obj-$(CONFIG_PHONE_ARIES_CDMA) += level.o
obj-$(CONFIG_PHONE_CRESPO) += dev-aries-phone.o
+obj-$(CONFIG_FORCE_FAST_CHARGE) += fastchg.o
+
# device support
obj-y += dev-audio.o
View
80 arch/arm/mach-s5pv210/fastchg.c
@@ -0,0 +1,80 @@
+/*
+ * Author: Chad Froebel <chadfroebel@gmail.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
+#include <linux/fastchg.h>
+
+int force_fast_charge;
+extern int aries_force_fast_charge;
+
+/* sysfs interface */
+static ssize_t force_fast_charge_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", force_fast_charge);
+}
+
+static ssize_t force_fast_charge_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
+{
+ sscanf(buf, "%du", &force_fast_charge);
+ aries_force_fast_charge = force_fast_charge;
+ return count;
+}
+
+static struct kobj_attribute force_fast_charge_attribute =
+ __ATTR(force_fast_charge, 0666, force_fast_charge_show, force_fast_charge_store);
+
+static struct attribute *attrs[] = {
+ &force_fast_charge_attribute.attr,
+ NULL,
+};
+
+static struct attribute_group attr_group = {
+ .attrs = attrs,
+};
+
+static struct kobject *force_fast_charge_kobj;
+
+static int __init force_fast_charge_init(void)
+{
+ int retval;
+
+ force_fast_charge = 0;
+ aries_force_fast_charge = force_fast_charge;
+
+ force_fast_charge_kobj = kobject_create_and_add("fast_charge", kernel_kobj);
+ if (!force_fast_charge_kobj) {
+ return -ENOMEM;
+ }
+ retval = sysfs_create_group(force_fast_charge_kobj, &attr_group);
+ if (retval)
+ kobject_put(force_fast_charge_kobj);
+ return retval;
+}
+/* end sysfs interface */
+
+static void __exit force_fast_charge_exit(void)
+{
+ force_fast_charge = 0;
+ aries_force_fast_charge = force_fast_charge;
+ kobject_put(force_fast_charge_kobj);
+}
+
+MODULE_AUTHOR("Chad Froebel <chadfroebel@gmail.com>");
+MODULE_DESCRIPTION("Fast charge");
+MODULE_LICENSE("GPL");
+
+module_init(force_fast_charge_init);
+module_exit(force_fast_charge_exit);
View
93 arch/arm/mach-s5pv210/mach-aries.c
@@ -2475,27 +2475,42 @@ static struct i2c_board_info i2c_devs8[] __initdata = {
},
};
-static void fsa9480_usb_cb(bool attached)
-{
- struct usb_gadget *gadget = platform_get_drvdata(&s3c_device_usbgadget);
-
- if (gadget) {
- if (attached)
- usb_gadget_vbus_connect(gadget);
- else
- usb_gadget_vbus_disconnect(gadget);
- }
- set_cable_status = attached ? CABLE_TYPE_USB : CABLE_TYPE_NONE;
- if (charger_callbacks && charger_callbacks->set_cable)
- charger_callbacks->set_cable(charger_callbacks, set_cable_status);
+int aries_force_fast_charge = 0;
+EXPORT_SYMBOL(aries_force_fast_charge);
+
+static void fsa9480_charger_cb(bool attached)
+{
+ set_cable_status = attached ? CABLE_TYPE_AC : CABLE_TYPE_NONE;
+ if (charger_callbacks && charger_callbacks->set_cable)
+ charger_callbacks->set_cable(charger_callbacks, set_cable_status);
}
-static void fsa9480_charger_cb(bool attached)
+
+static void fsa9480_usb_cb(bool attached)
{
- set_cable_status = attached ? CABLE_TYPE_AC : CABLE_TYPE_NONE;
- if (charger_callbacks && charger_callbacks->set_cable)
- charger_callbacks->set_cable(charger_callbacks, set_cable_status);
+//#ifdef CONFIG_FORCE_FAST_CHARGE_MODULE
+ pr_info("%s: force_fast_charge: %d\n", __func__, aries_force_fast_charge);
+
+ if (aries_force_fast_charge != 0) {
+ fsa9480_charger_cb(attached);
+ } else {
+//#endif
+ struct usb_gadget *gadget = platform_get_drvdata(&s3c_device_usbgadget);
+
+ if (gadget) {
+ if (attached)
+ usb_gadget_vbus_connect(gadget);
+ else
+ usb_gadget_vbus_disconnect(gadget);
+ }
+
+ set_cable_status = attached ? CABLE_TYPE_USB : CABLE_TYPE_NONE;
+ if (charger_callbacks && charger_callbacks->set_cable)
+ charger_callbacks->set_cable(charger_callbacks, set_cable_status);
+//#ifdef CONFIG_FORCE_FAST_CHARGE_MODULE
+ }
+//#endif
}
static struct switch_dev switch_dock = {
@@ -2504,23 +2519,33 @@ static struct switch_dev switch_dock = {
static void fsa9480_deskdock_cb(bool attached)
{
- struct usb_gadget *gadget = platform_get_drvdata(&s3c_device_usbgadget);
-
- if (attached)
- switch_set_state(&switch_dock, 1);
- else
- switch_set_state(&switch_dock, 0);
-
- if (gadget) {
- if (attached)
- usb_gadget_vbus_connect(gadget);
- else
- usb_gadget_vbus_disconnect(gadget);
- }
-
- set_cable_status = attached ? CABLE_TYPE_USB : CABLE_TYPE_NONE;
- if (charger_callbacks && charger_callbacks->set_cable)
- charger_callbacks->set_cable(charger_callbacks, set_cable_status);
+ pr_info("%s: force_fast_charge: %d\n", __func__, aries_force_fast_charge);
+
+ //#ifdef CONFIG_FORCE_FAST_CHARGE_MODULE
+ if (aries_force_fast_charge != 0) {
+ fsa9480_charger_cb(attached);
+ } else {
+//#endif
+ struct usb_gadget *gadget = platform_get_drvdata(&s3c_device_usbgadget);
+
+ if (attached)
+ switch_set_state(&switch_dock, 1);
+ else
+ switch_set_state(&switch_dock, 0);
+
+ if (gadget) {
+ if (attached)
+ usb_gadget_vbus_connect(gadget);
+ else
+ usb_gadget_vbus_disconnect(gadget);
+ }
+
+ set_cable_status = attached ? CABLE_TYPE_USB : CABLE_TYPE_NONE;
+ if (charger_callbacks && charger_callbacks->set_cable)
+ charger_callbacks->set_cable(charger_callbacks, set_cable_status);
+//#ifdef CONFIG_FORCE_FAST_CHARGE_MODULE
+ }
+//#endif
}
static void fsa9480_cardock_cb(bool attached)
View
22 include/linux/fastchg.h
@@ -0,0 +1,22 @@
+/*
+ * Author: Chad Froebel <chadfroebel@gmail.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+
+#ifndef _LINUX_FASTCHG_H
+#define _LINUX_FASTCHG_H
+
+//extern int force_fast_charge;
+
+
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.