From 626d2da444fe75676b9f5ce992c8720fc9eeffc8 Mon Sep 17 00:00:00 2001 From: Paul Walmsley Date: Wed, 20 Feb 2008 16:12:18 -0800 Subject: [PATCH] OMAP34xx USB: fix compile breakage in TLL mode drivers/usb/host/ehci-omap.c in the git tree doesn't compile when CONFIG_OMAP_EHCI_PHY_MODE is disabled; error message is enclosed below. Fix the bug, and while there, rearrange the source code to reduce code duplication and function size. Also some minor modifications as per David Brownell's comments. Signed-off-by: Paul Walmsley Acked-by: Vikram Pandita Signed-off-by: Tony Lindgren --- drivers/usb/host/ehci-omap.c | 164 +++++++++++++++++------------------ drivers/usb/host/ehci-omap.h | 7 +- 2 files changed, 86 insertions(+), 85 deletions(-) diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 21deda12bbb..24781263b28 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -80,6 +80,71 @@ struct ehci_omap_clock_defs { #define USBHOST_TLL_FCLK "usbtll_fck" /*-------------------------------------------------------------------------*/ + +#ifndef CONFIG_OMAP_EHCI_PHY_MODE + +static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask) +{ + int i; + + /* Use UTMI Ports of TLL */ + omap_writel((1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT), + OMAP_UHH_HOSTCONFIG); + /* Enusre bit is set */ + while (!(omap_readl(OMAP_UHH_HOSTCONFIG) & + (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT))); + + dev_dbg(hcd->self.controller, "\nEntered UTMI MODE: success\n"); + + /* Program the 3 TLL channels upfront */ + + for (i = 0; i < OMAP_TLL_CHANNEL_COUNT; i++) { + + /* Disable AutoIdle */ + omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) & + ~(1<self.controller, "\nULPI_SCRATCH_REG[ch=%d]" + "= 0x%02x\n", + i+1, omap_readb(OMAP_TLL_ULPI_SCRATCH_REGISTER(i))); + } +} + +#else +# define omap_usb_utmi_init(x, y) 0 +#endif + + /* omap_start_ehc * - Start the TI USBHOST controller */ @@ -185,17 +250,20 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd) (1 << OMAP3430_ST_USBTLL_SHIFT))); /* perform TLL soft reset, and wait until reset is complete */ - /* (1<<3) = no idle mode only for initial debugging */ - omap_writel((1 << OMAP_USBTLL_SYSCONFIG_SOFTRESET_SHIFT) | - (1 << OMAP_USBTLL_SYSCONFIG_ENAWAKEUP_SHIFT) | - (1 << OMAP_USBTLL_SYSCONFIG_SIDLEMODE_SHIFT) | - (1 << OMAP_USBTLL_SYSCONFIG_CACTIVITY_SHIFT), + omap_writel(1 << OMAP_USBTLL_SYSCONFIG_SOFTRESET_SHIFT, OMAP_USBTLL_SYSCONFIG); /* Wait for TLL reset to complete */ while (!(omap_readl(OMAP_USBTLL_SYSSTATUS) & (1 << OMAP_USBTLL_SYSSTATUS_RESETDONE_SHIFT))); - dev_dbg(hcd->self.controller, "\n TLL RESET DONE"); + dev_dbg(hcd->self.controller, "\n TLL RESET DONE\n"); + + /* (1<<3) = no idle mode only for initial debugging */ + omap_writel((1 << OMAP_USBTLL_SYSCONFIG_ENAWAKEUP_SHIFT) | + (1 << OMAP_USBTLL_SYSCONFIG_SIDLEMODE_SHIFT) | + (1 << OMAP_USBTLL_SYSCONFIG_CACTIVITY_SHIFT), + OMAP_USBTLL_SYSCONFIG); + /* Put UHH in NoIdle/NoStandby mode */ omap_writel((0 << OMAP_UHH_SYSCONFIG_AUTOIDLE_SHIFT) | @@ -216,84 +284,12 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd) dev_dbg(hcd->self.controller, "Entered ULPI PHY MODE: success"); #else - /* Use UTMI Ports of TLL */ - omap_writel((1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT), - OMAP_UHH_HOSTCONFIG); - /* Enusre bit is set */ - while (!(omap_readl(OMAP_UHH_HOSTCONFIG) & - (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT))); - - dev_dbg(hcd->self.controller, "Entered UTMI MODE: success"); - - /* Program the 3 TLL channels upfront */ - - /* CHANNEL-1 */ - /* Disable AutoIdle */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(0)) & - ~(1<self.controller, "\nULPI_SCRATCH_REG 0x%02x\n", - omap_readb(OMAP_TLL_ULPI_SCRATCH_REGISTER)); - + /* Enable UTMI mode for all 3 TLL channels */ + omap_usb_utmi_init(hcd, + OMAP_TLL_CHANNEL_1_EN_MASK | + OMAP_TLL_CHANNEL_2_EN_MASK | + OMAP_TLL_CHANNEL_3_EN_MASK + ); #endif #ifdef EXTERNAL_PHY_RESET diff --git a/drivers/usb/host/ehci-omap.h b/drivers/usb/host/ehci-omap.h index e9e64ddb9a7..2e29da1e96a 100644 --- a/drivers/usb/host/ehci-omap.h +++ b/drivers/usb/host/ehci-omap.h @@ -81,7 +81,12 @@ #define OMAP_TLL_ULPI_DEBUG(num)\ (OMAP_USBHOST_TLL_BASE + (0x815 + 0x100 * num)) #define OMAP_TLL_ULPI_SCRATCH_REGISTER(num)\ - (OMAP_USBHOST_TLL_BASE + (0x8165 + 0x100 * num)) + (OMAP_USBHOST_TLL_BASE + (0x816 + 0x100 * num)) + +#define OMAP_TLL_CHANNEL_COUNT 3 + #define OMAP_TLL_CHANNEL_1_EN_MASK 1 + #define OMAP_TLL_CHANNEL_2_EN_MASK 2 + #define OMAP_TLL_CHANNEL_3_EN_MASK 4 /* UHH Register Set */ #define OMAP_USBHOST_UHH_BASE (OMAP_USBHOST_BASE + 0x4000) -- 2.41.1