Author: Chad Froebel <chadfroebel@gmail.com>
Date:   Tue Feb 28 22:22:16 2012 -0500

    A simple sysfs interface to force adapters that
    are detected as USB to charge as AC.

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 66e5a88..dc3e8ec 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -374,4 +374,11 @@ config OMAP_FIQ_DEBUGGER
 
 endmenu
 
+config FORCE_FAST_CHARGE
+	bool "Force AC charge mode at will"
+	default y
+	help
+	  A simple sysfs interface to force adapters that
+	  are detected as USB to charge as AC.
+
 endif
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 6d72578..d01afaa 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -271,6 +271,8 @@ obj-$(CONFIG_MACH_TUNA)			+= board-tuna-connector.o
 obj-$(CONFIG_MACH_TUNA)			+= board-tuna-pogo.o
 obj-$(CONFIG_MACH_TUNA)			+= board-tuna-usbhost.o
 
+obj-$(CONFIG_FORCE_FAST_CHARGE)		+= fastchg.o
+
 obj-$(CONFIG_MACH_OMAP3517EVM)		+= board-am3517evm.o \
 					   omap_phy_internal.o \
 
diff --git a/arch/arm/mach-omap2/board-tuna-connector.c b/arch/arm/mach-omap2/board-tuna-connector.c
index 7c09aef..7288bb5 100644
--- a/arch/arm/mach-omap2/board-tuna-connector.c
+++ b/arch/arm/mach-omap2/board-tuna-connector.c
@@ -33,7 +33,7 @@
 #include <linux/i2c/twl.h>
 #include <linux/mutex.h>
 #include <linux/switch.h>
-
+#include <linux/fastchg.h>
 #include <plat/usb.h>
 
 #include "mux.h"
@@ -781,7 +781,11 @@ static void sii9234_connect(bool on, u8 *devcap)
 	int dock = 0;
 
 	if (on) {
+#ifdef CONFIG_FORCE_FAST_CHARGE
+		val = (force_fast_charge != 0) ? USB_EVENT_CHARGER : USB_EVENT_VBUS;
+#else
 		val = USB_EVENT_VBUS;
+#endif
 		if (devcap) {
 			u16 adopter_id =
 				(devcap[MHL_DEVCAP_ADOPTER_ID_H] << 8) |
diff --git a/arch/arm/mach-omap2/fastchg.c b/arch/arm/mach-omap2/fastchg.c
new file mode 100644
index 0000000..0e68e37
--- /dev/null
+++ b/arch/arm/mach-omap2/fastchg.c
@@ -0,0 +1,70 @@
+/*
+ * 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/kobject.h>
+#include <linux/sysfs.h>
+#include <linux/fastchg.h>
+
+int 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);
+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;
+
+int force_fast_charge_init(void)
+{
+	int retval;
+
+	force_fast_charge = 0;
+
+        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 */
+
+void force_fast_charge_exit(void)
+{
+	kobject_put(force_fast_charge_kobj);
+}
+
+module_init(force_fast_charge_init);
+module_exit(force_fast_charge_exit);
diff --git a/drivers/misc/fsa9480.c b/drivers/misc/fsa9480.c
index 7c9f7d4..ddc6910 100755
--- a/drivers/misc/fsa9480.c
+++ b/drivers/misc/fsa9480.c
@@ -36,6 +36,7 @@
 #include <linux/usb/otg_id.h>
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
+#include <linux/fastchg.h>
 
 #define DEBUG_DUMP_REGISTERS
 
@@ -516,7 +517,15 @@ static int fsa9480_detect_callback(struct otg_id_notifier_block *nb)
 		/* usb peripheral mode */
 		if (!(nb_info->detect_set->mask & FSA9480_DETECT_USB))
 			goto unhandled;
+#ifdef CONFIG_FORCE_FAST_CHARGE
+		if (force_fast_charge != 0) {
+		_detected(usbsw, FSA9480_DETECT_CHARGER);
+		} else {
+		_detected(usbsw, FSA9480_DETECT_USB);
+		}
+#else
 		_detected(usbsw, FSA9480_DETECT_USB);
+#endif
 		goto handled;
 	} else if (dev_type & DEV_UART_MASK) {
 		if (!(nb_info->detect_set->mask & FSA9480_DETECT_UART))
diff --git a/include/linux/fastchg.h b/include/linux/fastchg.h
new file mode 100644
index 0000000..ba459fc
--- /dev/null
+++ b/include/linux/fastchg.h
@@ -0,0 +1,21 @@
+/*
+ * 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
