From 7e36af784c0b606eaf1ea1bfa79746c444d44ef3 Mon Sep 17 00:00:00 2001
From: hedwin <hedwin.koning@gmail.com>
Date: Mon, 8 Nov 2010 23:39:47 +0100
Subject: [PATCH] Enable ADB on IGEPv2 board

---
 arch/arm/configs/igep0020_android_defconfig |    9 ++--
 arch/arm/mach-omap2/board-igep0020.c        |   74 ++++++++++++++++++++++++---
 2 files changed, 70 insertions(+), 13 deletions(-)

diff --git a/arch/arm/configs/igep0020_android_defconfig b/arch/arm/configs/igep0020_android_defconfig
index 519533d..d71326c 100644
--- a/arch/arm/configs/igep0020_android_defconfig
+++ b/arch/arm/configs/igep0020_android_defconfig
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.32
-# Sun Nov  7 01:02:06 2010
+# Mon Nov  8 22:22:13 2010
 #
 CONFIG_ARM=y
 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -755,7 +755,7 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
 CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
 CONFIG_INPUT_JOYDEV=y
 CONFIG_INPUT_EVDEV=y
-CONFIG_INPUT_EVBUG=y
+# CONFIG_INPUT_EVBUG is not set
 # CONFIG_INPUT_KEYRESET is not set
 
 #
@@ -1478,11 +1478,10 @@ CONFIG_USB_GADGET_DUALSPEED=y
 # CONFIG_USB_MIDI_GADGET is not set
 # CONFIG_USB_G_PRINTER is not set
 CONFIG_USB_ANDROID=y
-CONFIG_USB_ANDROID_ACM=y
+# CONFIG_USB_ANDROID_ACM is not set
 CONFIG_USB_ANDROID_ADB=y
 CONFIG_USB_ANDROID_MASS_STORAGE=y
-CONFIG_USB_ANDROID_RNDIS=y
-# CONFIG_USB_ANDROID_RNDIS_WCEIS is not set
+# CONFIG_USB_ANDROID_RNDIS is not set
 # CONFIG_USB_CDC_COMPOSITE is not set
 # CONFIG_USB_G_MULTI is not set
 
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index ad0c497..7c76fe6 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -18,35 +18,86 @@
 #include <linux/gpio.h>
 #include <linux/interrupt.h>
 
-#include <linux/regulator/machine.h>
 #include <linux/i2c/twl.h>
+#include <linux/usb/otg.h>
+#include <linux/smsc911x.h>
+#include <linux/usb/android_composite.h>
+
+#include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
 #include <plat/board.h>
-#include <plat/common.h>
 #include <plat/gpmc.h>
 #include <plat/usb.h>
+#include <plat/common.h>
 #include <plat/display.h>
 
-
 #include "mux.h"
 #include "mmc-twl4030.h"
 
+
 #define IGEP2_SMSC911X_CS	5
 #define IGEP2_SMSC911X_GPIO	176
-#define IGEP2_GPIO_USBH_NRESET 24
+#define IGEP2_GPIO_USBH_NRESET 	24
 #define IGEP2_GPIO_LED0_GREEN	26
 #define IGEP2_GPIO_LED0_RED	27
 #define IGEP2_GPIO_LED1_RED	28
 #define IGEP2_GPIO_DVI_PUP	170
 #define IGEP2_GPIO_WIFI_NPD	94
-#define IGEP2_GPIO_WIFI_NRESET 95
+#define IGEP2_GPIO_WIFI_NRESET 	95
 
-#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
+#ifdef CONFIG_USB_ANDROID
 
-#include <linux/smsc911x.h>
+#define GOOGLE_VENDOR_ID		0x18d1
+#define GOOGLE_PRODUCT_ID		0x9018
+#define GOOGLE_ADB_PRODUCT_ID		0x9015
+
+static char *usb_functions_adb[] = {
+	"adb",
+};
+
+static char *usb_functions_all[] = {
+	"adb",
+};
+
+static struct android_usb_product usb_products[] = {
+	{
+		.product_id	= GOOGLE_PRODUCT_ID,
+		.num_functions	= ARRAY_SIZE(usb_functions_adb),
+		.functions	= usb_functions_adb,
+	},
+};
+
+static struct android_usb_platform_data android_usb_pdata = {
+	.vendor_id		= GOOGLE_VENDOR_ID,
+	.product_id		= GOOGLE_PRODUCT_ID,
+	.functions		= usb_functions_all,
+	.products		= usb_products,
+	.version		= 0x0100,
+	.product_name		= "rowboat gadget",
+	.manufacturer_name	= "rowboat",
+	.serial_number		= "IGEP-ROWBOAT-20101108",
+	.num_functions		= ARRAY_SIZE(usb_functions_all),
+};
+
+static struct platform_device androidusb_device = {
+	.name	= "android_usb",
+	.id	= -1,
+	.dev	= {
+		.platform_data = &android_usb_pdata,
+	},
+};
+
+static void igep2_android_gadget_init(void)
+{
+	platform_device_register(&androidusb_device);
+}
+
+#endif
+
+#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 
 static struct smsc911x_platform_config igep2_smsc911x_config = {
 	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
@@ -289,7 +340,7 @@ static struct twl4030_platform_data igep2_twldata = {
 	.gpio		= &igep2_gpio_data,
 	.codec		= &igep2_codec_data,
 	.madc		= &igep2_madc_data,
-	.vmmc1          = &igep2_vmmc1,
+	.vmmc1      	= &igep2_vmmc1,
 	.vdac 		= &igep2_vdac,
 	.vpll2		= &igep2_vpll2,
 };
@@ -316,11 +367,14 @@ static int __init igep2_i2c_init(void)
 static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
 
 	.port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
+//	.port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
 	.port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
 	.port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
 
+
 	.phy_reset = true,
 	.reset_gpio_port[0] = IGEP2_GPIO_USBH_NRESET,
+	//.reset_gpio_port[1] = IGEP2_GPIO_USBH_NRESET,
 	.reset_gpio_port[1] = -EINVAL,
 	.reset_gpio_port[2] = -EINVAL,
 };
@@ -342,6 +396,10 @@ static void __init igep2_init(void)
 	usb_musb_init();
 	usb_ehci_init(&ehci_pdata);
 
+#ifdef CONFIG_USB_ANDROID
+	igep2_android_gadget_init();
+#endif
+
 	igep2_display_init();
 	igep2_init_smsc911x();
 
-- 
1.7.0.4

