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. Vikram, can you give this patch a look to see if it makes sense? It's been compile-tested only. CC [M] drivers/usb/host/ehci-hcd.o In file included from drivers/usb/host/ehci-hcd.c:958: drivers/usb/host/ehci-omap.c: In function 'omap_start_ehc': drivers/usb/host/ehci-omap.c:293: error: 'OMAP_TLL_ULPI_SCRATCH_REGISTER' undeclared (first use in this function) drivers/usb/host/ehci-omap.c:293: error: (Each undeclared identifier is reported only once drivers/usb/host/ehci-omap.c:293: error: for each function it appears in.) Signed-off-by: Paul Walmsley <paul@xxxxxxxxx> - Paul --- drivers/usb/host/ehci-omap.c | 141 +++++++++++++++++++------------------------ drivers/usb/host/ehci-omap.h | 2 2 files changed, 65 insertions(+), 78 deletions(-) Index: linux-omap/drivers/usb/host/ehci-omap.c =================================================================== --- linux-omap.orig/drivers/usb/host/ehci-omap.c 2008-02-11 16:19:47.000000000 -0700 +++ linux-omap/drivers/usb/host/ehci-omap.c 2008-02-11 16:25:09.000000000 -0700 @@ -80,6 +80,68 @@ #define USBHOST_TLL_FCLK "usbtll_fck" /*-------------------------------------------------------------------------*/ + +#ifndef CONFIG_OMAP_EHCI_PHY_MODE + +static void omap_usb_utmi_init(struct platform_device *dev, struct usb_hcd *hcd) +{ + 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, "Entered UTMI MODE: success"); + + /* 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<<OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT), + OMAP_TLL_CHANNEL_CONF(i)); + /* Disable BitStuffing */ + omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) & + ~(1<<OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF_SHIFT), + OMAP_TLL_CHANNEL_CONF(i)); + /* SDR Mode */ + omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) & + ~(1<<OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE_SHIFT), + OMAP_TLL_CHANNEL_CONF(i)); + + } + + /* Program Common TLL register */ + omap_writel((1 << OMAP_TLL_SHARED_CONF_FCLK_IS_ON_SHIFT) | + (1 << OMAP_TLL_SHARED_CONF_USB_DIVRATION_SHIFT) | + (1 << OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN_SHIFT) | + (1 << OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN_SHFT), + OMAP_TLL_SHARED_CONF); + + /* Enable All 3 channels now */ + for (i = 0; i < OMAP_TLL_CHANNEL_COUNT; i++) { + + omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) | + (1<<OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT), + OMAP_TLL_CHANNEL_CONF(i)); + + /* test writing to ulpi scratch register */ + omap_writeb(0xBE, OMAP_TLL_ULPI_SCRATCH_REGISTER(i)); + dev_dbg(hcd->self.controller, "\nULPI_SCRATCH_REG 0x%02x\n", + 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 */ @@ -216,84 +278,7 @@ 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<<OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT), - OMAP_TLL_CHANNEL_CONF(0)); - /* Disable BitStuffing */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(0)) & - ~(1<<OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF_SHIFT), - OMAP_TLL_CHANNEL_CONF(0)); - /* SDR Mode */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(0)) & - ~(1<<OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE_SHIFT), - OMAP_TLL_CHANNEL_CONF(0)); - - /* CHANNEL-2 */ - /* Disable AutoIdle */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(1)) & - ~(1<<OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT), - OMAP_TLL_CHANNEL_CONF(1)); - /* Disable BitStuffing */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(1)) & - ~(1<<OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF_SHIFT), - OMAP_TLL_CHANNEL_CONF(1)); - /* SDR Mode */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(1)) & - ~(1<<OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE_SHIFT), - OMAP_TLL_CHANNEL_CONF(1)); - - /* CHANNEL-3 */ - /* Disable AutoIdle */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(2)) & - ~(1<<OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT), - OMAP_TLL_CHANNEL_CONF(2)); - /* Disable BitStuffing */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(2)) & - ~(1<<OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF_SHIFT), - OMAP_TLL_CHANNEL_CONF(2)); - /* SDR Mode */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(2)) & - ~(1<<OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE_SHIFT), - OMAP_TLL_CHANNEL_CONF(2)); - - /* Program Common TLL register */ - omap_writel((1 << OMAP_TLL_SHARED_CONF_FCLK_IS_ON_SHIFT) | - (1 << OMAP_TLL_SHARED_CONF_USB_DIVRATION_SHIFT) | - (1 << OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN_SHIFT) | - (1 << OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN_SHFT), - OMAP_TLL_SHARED_CONF); - - /* Enable All 3 channels now */ - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(0)) | - (1<<OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT), - OMAP_TLL_CHANNEL_CONF(0)); - - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(1)) | - (1<<OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT), - OMAP_TLL_CHANNEL_CONF(1)); - - omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(2)) | - (1<<OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT), - OMAP_TLL_CHANNEL_CONF(2)); - - /* test writing to ulpi scratch register */ - omap_writeb(0xBE, OMAP_TLL_ULPI_SCRATCH_REGISTER); - dev_dbg(hcd->self.controller, "\nULPI_SCRATCH_REG 0x%02x\n", - omap_readb(OMAP_TLL_ULPI_SCRATCH_REGISTER)); - + omap_usb_utmi_init(dev, hcd); #endif #ifdef EXTERNAL_PHY_RESET Index: linux-omap/drivers/usb/host/ehci-omap.h =================================================================== --- linux-omap.orig/drivers/usb/host/ehci-omap.h 2008-02-11 16:19:47.000000000 -0700 +++ linux-omap/drivers/usb/host/ehci-omap.h 2008-02-11 16:19:47.000000000 -0700 @@ -83,6 +83,8 @@ #define OMAP_TLL_ULPI_SCRATCH_REGISTER(num)\ (OMAP_USBHOST_TLL_BASE + (0x8165 + 0x100 * num)) +#define OMAP_TLL_CHANNEL_COUNT 3 + /* UHH Register Set */ #define OMAP_USBHOST_UHH_BASE (OMAP_USBHOST_BASE + 0x4000) #define OMAP_UHH_REVISION (OMAP_USBHOST_UHH_BASE + 0x00) - To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html