From f8f10f496bce396416d7156da876222c6ce8c341 Mon Sep 17 00:00:00 2001
From: Jason Kridner <jkridner@beagleboard.org>
Date: Wed, 7 Jan 2009 12:01:11 -0600
Subject: [PATCH-USB] This merges Steve Kipisz' USB EHCI support.  He started from a 3 week or so old kernel.

Merge branch 'steve1' into try-steve1

Conflicts:
	Documentation/kernel-parameters.txt
	Documentation/sound/alsa/ALSA-Configuration.txt
	MAINTAINERS
	Makefile
	arch/arm/mach-omap1/board-h2.c
	arch/arm/mach-omap1/board-sx1.c
	arch/arm/mach-omap1/board-voiceblue.c
	arch/arm/mach-omap1/devices.c
	arch/arm/mach-omap1/mailbox.c
	arch/arm/mach-omap2/board-2430sdp.c
	arch/arm/mach-omap2/board-apollon.c
	arch/arm/mach-omap2/board-ldp.c
	arch/arm/mach-omap2/board-omap3beagle.c
	arch/arm/mach-omap2/devices.c
	arch/arm/mach-omap2/mailbox.c
	arch/arm/mach-omap2/usb-ehci.c
	arch/arm/plat-omap/Kconfig
	arch/arm/plat-omap/include/mach/gpio.h
	arch/arm/plat-omap/include/mach/mailbox.h
	arch/arm/plat-omap/include/mach/omap34xx.h
	arch/arm/plat-omap/mailbox.c
	arch/mips/include/asm/byteorder.h
	arch/mips/include/asm/elf.h
	arch/parisc/include/asm/tlbflush.h
	arch/x86/Kconfig.cpu
	arch/x86/kernel/amd_iommu.c
	arch/x86/kernel/amd_iommu_init.c
	arch/x86/kernel/cpu/mcheck/mce_64.c
	arch/x86/kernel/microcode_core.c
	arch/x86/kernel/microcode_intel.c
	arch/x86/kernel/pci-gart_64.c
	drivers/acpi/bus.c
	drivers/acpi/utilities/utglobal.c
	drivers/block/cciss.c
	drivers/edac/edac_device.c
	drivers/gpu/drm/i915/i915_dma.c
	drivers/gpu/drm/i915/i915_drv.h
	drivers/gpu/drm/i915/i915_gem.c
	drivers/gpu/drm/radeon/radeon_irq.c
	drivers/ide/cs5530.c
	drivers/ide/sc1200.c
	drivers/md/bitmap.c
	drivers/media/dvb/b2c2/Kconfig
	drivers/media/dvb/b2c2/flexcop-fe-tuner.c
	drivers/media/dvb/b2c2/flexcop-i2c.c
	drivers/media/dvb/bt8xx/Kconfig
	drivers/media/dvb/dvb-usb/Kconfig
	drivers/media/dvb/dvb-usb/dib0700_devices.c
	drivers/media/dvb/ttpci/Kconfig
	drivers/media/video/compat_ioctl32.c
	drivers/media/video/cx18/Kconfig
	drivers/media/video/cx23885/Kconfig
	drivers/media/video/cx88/Kconfig
	drivers/media/video/em28xx/em28xx-video.c
	drivers/media/video/gspca/gspca.c
	drivers/media/video/pvrusb2/Kconfig
	drivers/media/video/saa7134/Kconfig
	drivers/message/fusion/mptscsih.c
	drivers/mmc/host/Kconfig
	drivers/mmc/host/omap_hsmmc.c
	drivers/mtd/onenand/omap2.c
	drivers/net/ppp_generic.c
	drivers/pci/hotplug/acpiphp.h
	drivers/pci/hotplug/acpiphp_core.c
	drivers/pci/hotplug/acpiphp_glue.c
	drivers/pci/hotplug/ibmphp_core.c
	drivers/pci/hotplug/pciehp_core.c
	drivers/pci/pcie/aer/aerdrv_core.c
	drivers/rtc/rtc-isl1208.c
	drivers/scsi/aacraid/linit.c
	drivers/scsi/ibmvscsi/ibmvstgt.c
	drivers/scsi/libiscsi.c
	drivers/scsi/scsi_lib.c
	drivers/usb/host/ehci-omap.c
	drivers/usb/otg/twl4030-usb.c
	drivers/video/omap/lcd_ldp.c
	drivers/w1/w1_io.c
	fs/9p/fid.c
	fs/9p/v9fs.c
	fs/9p/vfs_dentry.c
	fs/9p/vfs_inode.c
	include/acpi/acoutput.h
	include/acpi/platform/aclinux.h
	kernel/cgroup.c
	kernel/posix-timers.c
	net/bluetooth/rfcomm/core.c
	net/socket.c
	sound/pci/hda/patch_sigmatel.c
	sound/soc/omap/omap-pcm.c

Conflicts:

	arch/arm/mach-omap2/board-omap3beagle.c
	arch/arm/mach-omap2/usb-ehci.c
	arch/x86/kernel/amd_iommu_init.c
	drivers/usb/host/ehci-omap.c

Signed-off-by: Jason Kridner <jkridner@beagleboard.org>
---
 arch/arm/mach-omap2/board-omap3beagle.c |   10 +---------
 arch/arm/mach-omap2/usb-ehci.c          |    4 +---
 drivers/usb/host/ehci-omap.c            |   26 ++++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index fe97bab..de81153 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -140,15 +140,7 @@ static int beagle_twl_gpio_setup(struct device *dev,
 	 * power switch and overcurrent detect
 	 */
 
-	gpio_request(gpio + 1, "EHCI_nOC");
-	gpio_direction_input(gpio + 1);
-
-	/* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
-	gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
-	gpio_direction_output(gpio + TWL4030_GPIO_MAX, 1);
-
-	/* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
-	gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
+        /* TODO: This needs to be modified to not rely on u-boot */
 
 	return 0;
 }
diff --git a/arch/arm/mach-omap2/usb-ehci.c b/arch/arm/mach-omap2/usb-ehci.c
index 489439d..2c6305b 100644
--- a/arch/arm/mach-omap2/usb-ehci.c
+++ b/arch/arm/mach-omap2/usb-ehci.c
@@ -152,9 +152,7 @@ static void setup_ehci_io_mux(void)
 void __init usb_ehci_init(void)
 {
 #if     defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
-	/* Setup Pin IO MUX for EHCI */
-	if (cpu_is_omap34xx())
-		setup_ehci_io_mux();
+	/* TODO: Setup Pin IO MUX for EHCI - moved this temporarily to U-boot */
 
 	if (platform_device_register(&ehci_device) < 0) {
 		printk(KERN_ERR "Unable to register HS-USB (EHCI) device\n");
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 1b3266c..a7eaff5 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -233,6 +233,32 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
 	udelay(EXT_PHY_RESET_DELAY);
 #endif
 
+        /*
+         * The PHY register 0x7 - Interface Control register is
+         * configured to disable the integrated STP pull-up resistor
+         * used for interface protection.
+	 *
+	 * May not need to be here.
+         */
+        omap_writel((0x7 << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |/* interface reg */
+                (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) |/*   Write */
+                (1 << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) |/* Port1 */
+                (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |/* Start */
+                (PHY_STP_PULLUP_DISABLE),
+                EHCI_INSNREG05_ULPI);
+
+        while (!(omap_readl(EHCI_INSNREG05_ULPI) & (1<<EHCI_INSNREG05_ULPI_CONTROL_SHIFT)));
+
+        /* Force PHY to HS */
+        omap_writel((0x4 << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |/* function ctrl */
+                (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) |/*   Write */
+                (1 << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) |/* Port1 */
+                (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |/* Start */
+                (0x40),
+                EHCI_INSNREG05_ULPI);
+
+        while (!(omap_readl(EHCI_INSNREG05_ULPI) & (1<<EHCI_INSNREG05_ULPI_CONTROL_SHIFT)));
+
 	/* Configure TLL for 60Mhz clk for ULPI */
 	ehci_clocks->usbtll_fck_clk = clk_get(&dev->dev, USBHOST_TLL_FCLK);
 	if (IS_ERR(ehci_clocks->usbtll_fck_clk))
-- 
1.6.0.4.790.gaa14a

