* [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series
@ 2009-02-23 18:52 Felipe Balbi
2009-02-24 22:13 ` Grazvydas Ignotas
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:52 UTC (permalink / raw)
To: linux-omap
Cc: Steve Sakoman, Anand Gadiyar, Syed Mohammed Khasim, Felipe Balbi
Hi all,
Please give the following patches a good test. I don't have
hw to test them so any comments will be really welcome.
We still have lots to do before getting this driver upstream,
let's try to keep track of our TODO list and get this driver in
mainline for 2.6.31 merge window (2.6.30 is too close already).
Let's not try to push this driver until ES2.x and ES3.x are fully
supported, that will probably have to be done by an omap_rev
check in ehci-omap driver, also, this driver doesn't really
enumerate any attached devices, but that's old problem as Tony
told me off list.
Anyways, I guess this driver is finally walking. Me and Anand (and anyone
interested) will be discussing how to get EHCI and OHCI working fine, I'm
guessing we won't have really big issues with OHCI but you never know.
Again, please give it a good test, see if you don't have any clock issues,
NULL pointers, check if the error path is really fine, see if VBUS turns on
or not, as I said, *I HAVE NO HW TO TEST THESE*
thanks in advance for those who will read/test/comment these patches
Felipe Balbi (22):
usb: host: ehci: make checkpatch.pl happy with ehci-omap
usb: host: ehci: use dev_name
usb: host: ehci: standardize variables
usb: host: ehci: tabify structures
usb: host: ehci: use resource helpers
usb: host: ehci: sanitize error path
usb: host: ehci: get rid of pm functions
usb: host: ehci: reorganize structures
usb: host: ehci: better function names
usb: host: ehci: move some comments
usb: host: ehci: add MODULE_AUTHOR
usb: host: ehci: include <linux/gpio.h> instead
usb: host: ehci: remove ehci-omap.h
usb: host: ehci: get rid of infinite loops
usb: host: ehci: disable clocks on error
usb: host: ehci: add platform_data
usb: host: ehci: fix register definitions
arm: omap: make usb base defines follow trm
usb: host: ehci: ioremap all usb bases
usb: host: ehci: align defines
usb: host: ehci: don't ensure register write
usb: host: ehci: add few comments and todo
Tony Lindgren (1):
ehci-omap: Remove defines for clock names
arch/arm/mach-omap2/board-3430sdp.c | 2 +-
arch/arm/mach-omap2/board-omap3beagle.c | 2 +-
arch/arm/mach-omap2/board-omap3evm.c | 2 +-
arch/arm/mach-omap2/board-omap3pandora.c | 2 +-
arch/arm/mach-omap2/board-overo.c | 2 +-
arch/arm/mach-omap2/usb-ehci.c | 34 +-
arch/arm/plat-omap/include/mach/omap34xx.h | 4 +-
arch/arm/plat-omap/include/mach/usb.h | 24 +-
drivers/usb/host/Kconfig | 19 -
drivers/usb/host/ehci-omap.c | 890 +++++++++++++++++-----------
drivers/usb/host/ehci-omap.h | 125 ----
11 files changed, 591 insertions(+), 515 deletions(-)
delete mode 100644 drivers/usb/host/ehci-omap.h
^ permalink raw reply [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series
@ 2009-02-23 18:55 Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 01/23] usb: host: ehci: make checkpatch.pl happy with ehci-omap Felipe Balbi
` (2 more replies)
0 siblings, 3 replies; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Hi all,
Please give the following patches a good test. I don't have
hw to test them so any comments will be really welcome.
We still have lots to do before getting this driver upstream,
let's try to keep track of our TODO list and get this driver in
mainline for 2.6.31 merge window (2.6.30 is too close already).
Let's not try to push this driver until ES2.x and ES3.x are fully
supported, that will probably have to be done by an omap_rev
check in ehci-omap driver, also, this driver doesn't really
enumerate any attached devices, but that's old problem as Tony
told me off list.
Anyways, I guess this driver is finally walking. Me and Anand (and anyone
interested) will be discussing how to get EHCI and OHCI working fine, I'm
guessing we won't have really big issues with OHCI but you never know.
Again, please give it a good test, see if you don't have any clock issues,
NULL pointers, check if the error path is really fine, see if VBUS turns on
or not, as I said, *I HAVE NO HW TO TEST THESE*
thanks in advance for those who will read/test/comment these patches
Felipe Balbi (22):
usb: host: ehci: make checkpatch.pl happy with ehci-omap
usb: host: ehci: use dev_name
usb: host: ehci: standardize variables
usb: host: ehci: tabify structures
usb: host: ehci: use resource helpers
usb: host: ehci: sanitize error path
usb: host: ehci: get rid of pm functions
usb: host: ehci: reorganize structures
usb: host: ehci: better function names
usb: host: ehci: move some comments
usb: host: ehci: add MODULE_AUTHOR
usb: host: ehci: include <linux/gpio.h> instead
usb: host: ehci: remove ehci-omap.h
usb: host: ehci: get rid of infinite loops
usb: host: ehci: disable clocks on error
usb: host: ehci: add platform_data
usb: host: ehci: fix register definitions
arm: omap: make usb base defines follow trm
usb: host: ehci: ioremap all usb bases
usb: host: ehci: align defines
usb: host: ehci: don't ensure register write
usb: host: ehci: add few comments and todo
Tony Lindgren (1):
ehci-omap: Remove defines for clock names
arch/arm/mach-omap2/board-3430sdp.c | 2 +-
arch/arm/mach-omap2/board-omap3beagle.c | 2 +-
arch/arm/mach-omap2/board-omap3evm.c | 2 +-
arch/arm/mach-omap2/board-omap3pandora.c | 2 +-
arch/arm/mach-omap2/board-overo.c | 2 +-
arch/arm/mach-omap2/usb-ehci.c | 34 +-
arch/arm/plat-omap/include/mach/omap34xx.h | 4 +-
arch/arm/plat-omap/include/mach/usb.h | 24 +-
drivers/usb/host/Kconfig | 19 -
drivers/usb/host/ehci-omap.c | 890 +++++++++++++++++-----------
drivers/usb/host/ehci-omap.h | 125 ----
11 files changed, 591 insertions(+), 515 deletions(-)
delete mode 100644 drivers/usb/host/ehci-omap.h
^ permalink raw reply [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 01/23] usb: host: ehci: make checkpatch.pl happy with ehci-omap
2009-02-23 18:55 [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 02/23] usb: host: ehci: use dev_name Felipe Balbi
2009-02-23 19:32 ` [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series Felipe Balbi
2009-04-27 9:18 ` Grazvydas Ignotas
2 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Trivial cleanup patch, no functional changes. Just
adding a few spaces here and there.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 50 +++++++++++++++++++----------------------
1 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 1b3266c..88ed500 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -31,7 +31,6 @@
#include "ehci-omap.h"
-
#ifdef CONFIG_OMAP_EHCI_PHY_MODE
/* EHCI connected to External PHY */
@@ -80,7 +79,6 @@ 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)
@@ -89,17 +87,17 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
/* Use UTMI Ports of TLL */
omap_writel((1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)|
- (1<<OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT)|
- (1<<OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT)|
- (1<<OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT)|
- (0<<OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT),
+ (1 << OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT)|
+ (1 << OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT)|
+ (1 << OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT)|
+ (0 << OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT),
OMAP_UHH_HOSTCONFIG);
/* Enusre bit is set */
while (!(omap_readl(OMAP_UHH_HOSTCONFIG)
& (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)))
cpu_relax();
- dev_dbg(hcd->self.controller, "\nEntered UTMI MODE: success\n");
+ dev_dbg(hcd->self.controller, "Entered UTMI MODE: success\n");
/* Program the 3 TLL channels upfront */
@@ -107,15 +105,15 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
/* Disable AutoIdle */
omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) &
- ~(1<<OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT),
+ ~(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),
+ ~(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),
+ ~(1 << OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE_SHIFT),
OMAP_TLL_CHANNEL_CONF(i));
}
@@ -135,11 +133,11 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
continue;
omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) |
- (1<<OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT),
+ (1 << OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT),
OMAP_TLL_CHANNEL_CONF(i));
omap_writeb(0xBE, OMAP_TLL_ULPI_SCRATCH_REGISTER(i));
- dev_dbg(hcd->self.controller, "\nULPI_SCRATCH_REG[ch=%d]"
+ dev_dbg(hcd->self.controller, "ULPI_SCRATCH_REG[ch=%d]"
"= 0x%02x\n",
i+1, omap_readb(OMAP_TLL_ULPI_SCRATCH_REGISTER(i)));
}
@@ -209,7 +207,6 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
return PTR_ERR(ehci_clocks->usbhost_ick_clk);
clk_enable(ehci_clocks->usbhost_ick_clk);
-
ehci_clocks->usbhost2_120m_fck_clk = clk_get(&dev->dev,
USBHOST_120M_FCLK);
if (IS_ERR(ehci_clocks->usbhost2_120m_fck_clk))
@@ -281,10 +278,10 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
#ifdef CONFIG_OMAP_EHCI_PHY_MODE
/* Bypass the TLL module for PHY mode operation */
omap_writel((0 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)|
- (1<<OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT)|
- (1<<OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT)|
- (1<<OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT)|
- (0<<OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT),
+ (1 << OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT)|
+ (1 << OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT)|
+ (1 << OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT)|
+ (0 << OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT),
OMAP_UHH_HOSTCONFIG);
/* Ensure that BYPASS is set */
while (omap_readl(OMAP_UHH_HOSTCONFIG)
@@ -325,7 +322,7 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
EHCI_INSNREG05_ULPI);
while (!(omap_readl(EHCI_INSNREG05_ULPI)
- & (1<<EHCI_INSNREG05_ULPI_CONTROL_SHIFT)))
+ & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT)))
cpu_relax();
#endif
@@ -345,19 +342,19 @@ static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
dev_dbg(hcd->self.controller, "stopping TI EHCI USB Controller\n");
/* Reset OMAP modules for insmod/rmmod to work */
- omap_writel((1<<1), OMAP_UHH_SYSCONFIG);
- while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1<<0)))
+ omap_writel((1 << 1), OMAP_UHH_SYSCONFIG);
+ while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 0)))
cpu_relax();
- while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1<<1)))
+ while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 1)))
cpu_relax();
- while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1<<2)))
+ while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 2)))
cpu_relax();
dev_dbg(hcd->self.controller,
"UHH RESET DONE OMAP_UHH_SYSSTATUS %x !!\n",
omap_readl(OMAP_UHH_SYSSTATUS));
- omap_writel((1<<1), OMAP_USBTLL_SYSCONFIG);
- while (!(omap_readl(OMAP_USBTLL_SYSSTATUS) & (1<<0)))
+ omap_writel((1 << 1), OMAP_USBTLL_SYSCONFIG);
+ while (!(omap_readl(OMAP_USBTLL_SYSSTATUS) & (1 << 0)))
cpu_relax();
dev_dbg(hcd->self.controller, "TLL RESET DONE\n");
@@ -391,7 +388,6 @@ static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
ehci_clocks->usbtll_ick_clk = NULL;
}
-
#ifdef EXTERNAL_PHY_RESET
gpio_free(EXT_PHY_RESET_GPIO_PORT1);
gpio_free(EXT_PHY_RESET_GPIO_PORT2);
@@ -461,7 +457,7 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *dev)
ehci->hcs_params = readl(&ehci->caps->hcs_params);
/* SET 1 micro-frame Interrupt interval */
- writel(readl(&ehci->regs->command) | (1<<16), &ehci->regs->command);
+ writel(readl(&ehci->regs->command) | (1 << 16), &ehci->regs->command);
retval = usb_add_hcd(hcd, dev->resource[1].start,
IRQF_DISABLED | IRQF_SHARED);
@@ -562,8 +558,8 @@ static const struct hc_driver ehci_omap_hc_driver = {
#endif
};
-/*-------------------------------------------------------------------------*/
MODULE_ALIAS("platform:omap-ehci");
+
static struct platform_driver ehci_hcd_omap_driver = {
.probe = ehci_hcd_omap_drv_probe,
.remove = ehci_hcd_omap_drv_remove,
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 02/23] usb: host: ehci: use dev_name
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 01/23] usb: host: ehci: make checkpatch.pl happy with ehci-omap Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 03/23] usb: host: ehci: standardize variables Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
We should stop using bus_id to pass the device
name, dev_name() should be used instead.
Cleanup only.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 88ed500..3dd4a68 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -428,7 +428,8 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *dev)
retval = -ENOMEM;
}
- hcd = usb_create_hcd(&ehci_omap_hc_driver, &dev->dev, dev->dev.bus_id);
+ hcd = usb_create_hcd(&ehci_omap_hc_driver, &dev->dev,
+ dev_name(&dev->dev));
if (!hcd)
return -ENOMEM;
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 03/23] usb: host: ehci: standardize variables
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 02/23] usb: host: ehci: use dev_name Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 04/23] usb: host: ehci: tabify structures Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Style only, normally we use pdev as the platform_device's
pointer name.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 3dd4a68..a4f5f16 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -412,39 +412,39 @@ static const struct hc_driver ehci_omap_hc_driver;
* through the hotplug entry's driver_data.
*
*/
-static int ehci_hcd_omap_drv_probe(struct platform_device *dev)
+static int ehci_hcd_omap_drv_probe(struct platform_device *pdev)
{
int retval = 0;
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
- dev_dbg(&dev->dev, "ehci_hcd_omap_drv_probe()\n");
+ dev_dbg(&pdev->dev, "ehci_hcd_omap_drv_probe()\n");
if (usb_disabled())
return -ENODEV;
- if (dev->resource[1].flags != IORESOURCE_IRQ) {
- dev_dbg(&dev->dev, "resource[1] is not IORESOURCE_IRQ\n");
+ if (pdev->resource[1].flags != IORESOURCE_IRQ) {
+ dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n");
retval = -ENOMEM;
}
- hcd = usb_create_hcd(&ehci_omap_hc_driver, &dev->dev,
- dev_name(&dev->dev));
+ hcd = usb_create_hcd(&ehci_omap_hc_driver, &pdev->dev,
+ dev_name(&pdev->dev));
if (!hcd)
return -ENOMEM;
- retval = omap_start_ehc(dev, hcd);
+ retval = omap_start_ehc(pdev, hcd);
if (retval)
return retval;
hcd->rsrc_start = 0;
hcd->rsrc_len = 0;
- hcd->rsrc_start = dev->resource[0].start;
- hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
+ hcd->rsrc_start = pdev->resource[0].start;
+ hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
if (!hcd->regs) {
- dev_err(&dev->dev, "ioremap failed\n");
+ dev_err(&pdev->dev, "ioremap failed\n");
return -ENOMEM;
}
@@ -460,13 +460,13 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *dev)
/* SET 1 micro-frame Interrupt interval */
writel(readl(&ehci->regs->command) | (1 << 16), &ehci->regs->command);
- retval = usb_add_hcd(hcd, dev->resource[1].start,
+ retval = usb_add_hcd(hcd, pdev->resource[1].start,
IRQF_DISABLED | IRQF_SHARED);
if (retval == 0)
return retval;
- dev_dbg(hcd->self.controller, "ERR: add_hcd\n");
- omap_stop_ehc(dev, hcd);
+ dev_dbg(&pdev->dev, "ERR: add_hcd\n");
+ omap_stop_ehc(pdev, hcd);
iounmap(hcd->regs);
usb_put_hcd(hcd);
@@ -480,7 +480,7 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *dev)
/**
* ehci_hcd_omap_drv_remove - shutdown processing for EHCI HCDs
- * @dev: USB Host Controller being removed
+ * @pdev: USB Host Controller being removed
* Context: !in_interrupt()
*
* Reverses the effect of usb_ehci_hcd_omap_probe(), first invoking
@@ -488,16 +488,16 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *dev)
* context, normally "rmmod", "apmd", or something similar.
*
*/
-static int ehci_hcd_omap_drv_remove(struct platform_device *dev)
+static int ehci_hcd_omap_drv_remove(struct platform_device *pdev)
{
- struct usb_hcd *hcd = platform_get_drvdata(dev);
+ struct usb_hcd *hcd = platform_get_drvdata(pdev);
- dev_dbg(&dev->dev, "ehci_hcd_omap_drv_remove()\n");
+ dev_dbg(&pdev->dev, "ehci_hcd_omap_drv_remove()\n");
iounmap(hcd->regs);
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
- omap_stop_ehc(dev, hcd);
+ omap_stop_ehc(pdev, hcd);
return 0;
}
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 04/23] usb: host: ehci: tabify structures
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 03/23] usb: host: ehci: standardize variables Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 05/23] usb: host: ehci: use resource helpers Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Style only, no functional changes.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 46 +++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index a4f5f16..e050795 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -518,57 +518,57 @@ static int omap_ehci_bus_resume(struct usb_hcd *hcd)
static const struct hc_driver ehci_omap_hc_driver = {
.description = hcd_name,
- .product_desc = "OMAP-EHCI Host Controller",
- .hcd_priv_size = sizeof(struct ehci_hcd)
+ .product_desc = "OMAP-EHCI Host Controller",
+ .hcd_priv_size = sizeof(struct ehci_hcd)
+ sizeof(struct ehci_omap_clock_defs),
/*
* generic hardware linkage
*/
- .irq = ehci_irq,
- .flags = HCD_MEMORY | HCD_USB2,
+ .irq = ehci_irq,
+ .flags = HCD_MEMORY | HCD_USB2,
/*
* basic lifecycle operations
*/
- .reset = ehci_init,
- .start = ehci_run,
- .stop = ehci_stop,
- .shutdown = ehci_shutdown,
+ .reset = ehci_init,
+ .start = ehci_run,
+ .stop = ehci_stop,
+ .shutdown = ehci_shutdown,
/*
* managing i/o requests and associated device resources
*/
- .urb_enqueue = ehci_urb_enqueue,
- .urb_dequeue = ehci_urb_dequeue,
- .endpoint_disable = ehci_endpoint_disable,
+ .urb_enqueue = ehci_urb_enqueue,
+ .urb_dequeue = ehci_urb_dequeue,
+ .endpoint_disable = ehci_endpoint_disable,
/*
* scheduling support
*/
- .get_frame_number = ehci_get_frame,
+ .get_frame_number = ehci_get_frame,
/*
* root hub support
*/
- .hub_status_data = ehci_hub_status_data,
- .hub_control = ehci_hub_control,
+ .hub_status_data = ehci_hub_status_data,
+ .hub_control = ehci_hub_control,
#ifdef CONFIG_PM
- .bus_suspend = omap_ehci_bus_suspend,
- .bus_resume = omap_ehci_bus_resume,
+ .bus_suspend = omap_ehci_bus_suspend,
+ .bus_resume = omap_ehci_bus_resume,
#endif
};
MODULE_ALIAS("platform:omap-ehci");
static struct platform_driver ehci_hcd_omap_driver = {
- .probe = ehci_hcd_omap_drv_probe,
- .remove = ehci_hcd_omap_drv_remove,
- .shutdown = usb_hcd_platform_shutdown,
- /*.suspend = ehci_hcd_omap_drv_suspend, */
- /*.resume = ehci_hcd_omap_drv_resume, */
+ .probe = ehci_hcd_omap_drv_probe,
+ .remove = ehci_hcd_omap_drv_remove,
+ .shutdown = usb_hcd_platform_shutdown,
+ /*.suspend = ehci_hcd_omap_drv_suspend, */
+ /*.resume = ehci_hcd_omap_drv_resume, */
.driver = {
- .name = "ehci-omap",
- .bus = &platform_bus_type
+ .name = "ehci-omap",
+ .bus = &platform_bus_type
}
};
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 05/23] usb: host: ehci: use resource helpers
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 04/23] usb: host: ehci: tabify structures Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 06/23] usb: host: ehci: sanitize error path Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Don't access pdev->resource[n].start directly, we
can use the resource helpers for that, makes the
code more readable.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index e050795..d994392 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -410,24 +410,21 @@ static const struct hc_driver ehci_omap_hc_driver;
* Allocates basic resources for this USB host controller, and
* then invokes the start() method for the HCD associated with it
* through the hotplug entry's driver_data.
- *
*/
static int ehci_hcd_omap_drv_probe(struct platform_device *pdev)
{
- int retval = 0;
- struct usb_hcd *hcd;
struct ehci_hcd *ehci;
+ struct resource *res;
+ struct usb_hcd *hcd;
+
+ int irq = platform_get_irq(pdev, 0);
+ int retval = 0;
dev_dbg(&pdev->dev, "ehci_hcd_omap_drv_probe()\n");
if (usb_disabled())
return -ENODEV;
- if (pdev->resource[1].flags != IORESOURCE_IRQ) {
- dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n");
- retval = -ENOMEM;
- }
-
hcd = usb_create_hcd(&ehci_omap_hc_driver, &pdev->dev,
dev_name(&pdev->dev));
if (!hcd)
@@ -437,10 +434,12 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *pdev)
if (retval)
return retval;
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
hcd->rsrc_start = 0;
hcd->rsrc_len = 0;
- hcd->rsrc_start = pdev->resource[0].start;
- hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
+ hcd->rsrc_start = res->start;
+ hcd->rsrc_len = resource_size(res);
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
if (!hcd->regs) {
@@ -460,8 +459,7 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *pdev)
/* SET 1 micro-frame Interrupt interval */
writel(readl(&ehci->regs->command) | (1 << 16), &ehci->regs->command);
- retval = usb_add_hcd(hcd, pdev->resource[1].start,
- IRQF_DISABLED | IRQF_SHARED);
+ retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
if (retval == 0)
return retval;
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 06/23] usb: host: ehci: sanitize error path
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 05/23] usb: host: ehci: use resource helpers Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 07/23] usb: host: ehci: get rid of pm functions Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
This patch:
- sanitizes error path in ehci_hcd_omap_drv_probe();
- removes two unnecessary debugging messages, we only need
debugging in the failing case generally;
- fix a memory leak when omap_start_ehc() fails: the recently
created hcd was never put in that case;
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 53 +++++++++++++++++++++++++----------------
1 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index d994392..db4576d 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -418,21 +418,24 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *pdev)
struct usb_hcd *hcd;
int irq = platform_get_irq(pdev, 0);
- int retval = 0;
-
- dev_dbg(&pdev->dev, "ehci_hcd_omap_drv_probe()\n");
+ int ret = -ENODEV;
if (usb_disabled())
- return -ENODEV;
+ goto err_disabled;
hcd = usb_create_hcd(&ehci_omap_hc_driver, &pdev->dev,
dev_name(&pdev->dev));
- if (!hcd)
- return -ENOMEM;
+ if (!hcd) {
+ dev_dbg(&pdev->dev, "failed to create hcd with err %d\n", ret);
+ ret = -ENOMEM;
+ goto err_create_hcd;
+ }
- retval = omap_start_ehc(pdev, hcd);
- if (retval)
- return retval;
+ ret = omap_start_ehc(pdev, hcd);
+ if (ret) {
+ dev_dbg(&pdev->dev, "failed to start ehci\n");
+ goto err_start;
+ }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -444,12 +447,12 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *pdev)
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
if (!hcd->regs) {
dev_err(&pdev->dev, "ioremap failed\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto err_ioremap;
}
ehci = hcd_to_ehci(hcd);
ehci->caps = hcd->regs;
-
ehci->sbrn = 0x20;
ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase));
@@ -459,16 +462,26 @@ static int ehci_hcd_omap_drv_probe(struct platform_device *pdev)
/* SET 1 micro-frame Interrupt interval */
writel(readl(&ehci->regs->command) | (1 << 16), &ehci->regs->command);
- retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
- if (retval == 0)
- return retval;
+ ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
+ if (ret) {
+ dev_dbg(&pdev->dev, "failed to add hcd with err %d\n", ret);
+ goto err_add_hcd;
+ }
- dev_dbg(&pdev->dev, "ERR: add_hcd\n");
- omap_stop_ehc(pdev, hcd);
+ return 0;
+
+err_add_hcd:
iounmap(hcd->regs);
+
+err_ioremap:
+ omap_stop_ehc(pdev, hcd);
+
+err_start:
usb_put_hcd(hcd);
- return retval;
+err_create_hcd:
+err_disabled:
+ return ret;
}
/*-------------------------------------------------------------------------*/
@@ -490,12 +503,10 @@ static int ehci_hcd_omap_drv_remove(struct platform_device *pdev)
{
struct usb_hcd *hcd = platform_get_drvdata(pdev);
- dev_dbg(&pdev->dev, "ehci_hcd_omap_drv_remove()\n");
-
- iounmap(hcd->regs);
usb_remove_hcd(hcd);
- usb_put_hcd(hcd);
+ iounmap(hcd->regs);
omap_stop_ehc(pdev, hcd);
+ usb_put_hcd(hcd);
return 0;
}
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 07/23] usb: host: ehci: get rid of pm functions
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 06/23] usb: host: ehci: sanitize error path Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 08/23] usb: host: ehci: reorganize structures Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
That was just a useless function call, completely
unneeded. Remove it.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 20 ++------------------
1 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index db4576d..1b387cc 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -511,20 +511,6 @@ static int ehci_hcd_omap_drv_remove(struct platform_device *pdev)
return 0;
}
-/*-------------------------------------------------------------------------*/
-#ifdef CONFIG_PM
-static int omap_ehci_bus_suspend(struct usb_hcd *hcd)
-{
- return ehci_bus_suspend(hcd);
-}
-
-static int omap_ehci_bus_resume(struct usb_hcd *hcd)
-{
- return ehci_bus_resume(hcd);
-}
-#endif
-/*-------------------------------------------------------------------------*/
-
static const struct hc_driver ehci_omap_hc_driver = {
.description = hcd_name,
.product_desc = "OMAP-EHCI Host Controller",
@@ -562,10 +548,8 @@ static const struct hc_driver ehci_omap_hc_driver = {
*/
.hub_status_data = ehci_hub_status_data,
.hub_control = ehci_hub_control,
-#ifdef CONFIG_PM
- .bus_suspend = omap_ehci_bus_suspend,
- .bus_resume = omap_ehci_bus_resume,
-#endif
+ .bus_suspend = ehci_bus_suspend,
+ .bus_resume = ehci_bus_resume,
};
MODULE_ALIAS("platform:omap-ehci");
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 08/23] usb: host: ehci: reorganize structures
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 07/23] usb: host: ehci: get rid of pm functions Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 09/23] usb: host: ehci: better function names Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Move the platform_driver closer to its functions.
No functional changes.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 1b387cc..e66f5f9 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -511,6 +511,18 @@ static int ehci_hcd_omap_drv_remove(struct platform_device *pdev)
return 0;
}
+static struct platform_driver ehci_hcd_omap_driver = {
+ .probe = ehci_hcd_omap_drv_probe,
+ .remove = ehci_hcd_omap_drv_remove,
+ .shutdown = usb_hcd_platform_shutdown,
+ /*.suspend = ehci_hcd_omap_drv_suspend, */
+ /*.resume = ehci_hcd_omap_drv_resume, */
+ .driver = {
+ .name = "ehci-omap",
+ .bus = &platform_bus_type
+ }
+};
+
static const struct hc_driver ehci_omap_hc_driver = {
.description = hcd_name,
.product_desc = "OMAP-EHCI Host Controller",
@@ -554,14 +566,3 @@ static const struct hc_driver ehci_omap_hc_driver = {
MODULE_ALIAS("platform:omap-ehci");
-static struct platform_driver ehci_hcd_omap_driver = {
- .probe = ehci_hcd_omap_drv_probe,
- .remove = ehci_hcd_omap_drv_remove,
- .shutdown = usb_hcd_platform_shutdown,
- /*.suspend = ehci_hcd_omap_drv_suspend, */
- /*.resume = ehci_hcd_omap_drv_resume, */
- .driver = {
- .name = "ehci-omap",
- .bus = &platform_bus_type
- }
-};
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 09/23] usb: host: ehci: better function names
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 08/23] usb: host: ehci: reorganize structures Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 10/23] usb: host: ehci: move some comments Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
The "drv" in the function names was there just to make
it bigger, remove it so we have 4 characters smaller
lines. Also remove the platform_bus_type from platform_driver
since platform_driver_register() already does that.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index e66f5f9..f5ffc5b 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -404,14 +404,13 @@ static const struct hc_driver ehci_omap_hc_driver;
/* always called with process context; sleeping is OK */
/**
- * ehci_hcd_omap_drv_probe - initialize TI-based HCDs
- * Context: !in_interrupt()
+ * ehci_hcd_omap_probe - initialize TI-based HCDs
*
* Allocates basic resources for this USB host controller, and
* then invokes the start() method for the HCD associated with it
* through the hotplug entry's driver_data.
*/
-static int ehci_hcd_omap_drv_probe(struct platform_device *pdev)
+static int ehci_hcd_omap_probe(struct platform_device *pdev)
{
struct ehci_hcd *ehci;
struct resource *res;
@@ -484,22 +483,18 @@ err_disabled:
return ret;
}
-/*-------------------------------------------------------------------------*/
-
/* may be called without controller electrically present */
/* may be called with controller, bus, and devices active */
/**
- * ehci_hcd_omap_drv_remove - shutdown processing for EHCI HCDs
+ * ehci_hcd_omap_remove - shutdown processing for EHCI HCDs
* @pdev: USB Host Controller being removed
- * Context: !in_interrupt()
*
* Reverses the effect of usb_ehci_hcd_omap_probe(), first invoking
* the HCD's stop() method. It is always called from a thread
* context, normally "rmmod", "apmd", or something similar.
- *
*/
-static int ehci_hcd_omap_drv_remove(struct platform_device *pdev)
+static int ehci_hcd_omap_remove(struct platform_device *pdev)
{
struct usb_hcd *hcd = platform_get_drvdata(pdev);
@@ -512,17 +507,18 @@ static int ehci_hcd_omap_drv_remove(struct platform_device *pdev)
}
static struct platform_driver ehci_hcd_omap_driver = {
- .probe = ehci_hcd_omap_drv_probe,
- .remove = ehci_hcd_omap_drv_remove,
+ .probe = ehci_hcd_omap_probe,
+ .remove = ehci_hcd_omap_remove,
.shutdown = usb_hcd_platform_shutdown,
- /*.suspend = ehci_hcd_omap_drv_suspend, */
- /*.resume = ehci_hcd_omap_drv_resume, */
+ /*.suspend = ehci_hcd_omap_suspend, */
+ /*.resume = ehci_hcd_omap_resume, */
.driver = {
.name = "ehci-omap",
- .bus = &platform_bus_type
}
};
+/*-------------------------------------------------------------------------*/
+
static const struct hc_driver ehci_omap_hc_driver = {
.description = hcd_name,
.product_desc = "OMAP-EHCI Host Controller",
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 10/23] usb: host: ehci: move some comments
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 09/23] usb: host: ehci: better function names Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 11/23] usb: host: ehci: add MODULE_AUTHOR Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Move some of the comments used to separate the code
to more logical places. No functional changes.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index f5ffc5b..b7f02f6 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -77,6 +77,7 @@ struct ehci_omap_clock_defs {
#define USBHOST_48M_FCLK "usbhost_48m_fck"
#define USBHOST_TLL_ICKL "usbtll_ick"
#define USBHOST_TLL_FCLK "usbtll_fck"
+
/*-------------------------------------------------------------------------*/
#ifndef CONFIG_OMAP_EHCI_PHY_MODE
@@ -147,6 +148,7 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
# define omap_usb_utmi_init(x, y) 0
#endif
+/*-------------------------------------------------------------------------*/
/* omap_start_ehc
* - Start the TI USBHOST controller
@@ -330,8 +332,6 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
return 0;
}
-/*-------------------------------------------------------------------------*/
-
static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
{
struct ehci_omap_clock_defs *ehci_clocks;
@@ -397,9 +397,10 @@ static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
"Clock to USB host has been disabled\n");
}
+/*-------------------------------------------------------------------------*/
+
static const struct hc_driver ehci_omap_hc_driver;
-/*-------------------------------------------------------------------------*/
/* configure so an HC device and id are always provided */
/* always called with process context; sleeping is OK */
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 11/23] usb: host: ehci: add MODULE_AUTHOR
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 10/23] usb: host: ehci: move some comments Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 12/23] usb: host: ehci: include <linux/gpio.h> instead Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
add missing MODULE_AUTHOR(). No functional changes.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index b7f02f6..2fbf377 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -562,4 +562,5 @@ static const struct hc_driver ehci_omap_hc_driver = {
};
MODULE_ALIAS("platform:omap-ehci");
+MODULE_AUTHOR("Texas Instruments, Inc.");
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 12/23] usb: host: ehci: include <linux/gpio.h> instead
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 11/23] usb: host: ehci: add MODULE_AUTHOR Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 13/23] usb: host: ehci: remove ehci-omap.h Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
include <linux/gpio.h> instead of <mach/gpio.h>
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 2fbf377..7f37b5f 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -27,7 +27,7 @@
#include <linux/platform_device.h>
#include <linux/clk.h>
-#include <mach/gpio.h>
+#include <linux/gpio.h>
#include "ehci-omap.h"
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 13/23] usb: host: ehci: remove ehci-omap.h
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 12/23] usb: host: ehci: include <linux/gpio.h> instead Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 14/23] usb: host: ehci: get rid of infinite loops Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
That header is only used by ehci-omap.c for register
definitions and indirectly include some other headers.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 100 +++++++++++++++++++++++++++++++++-
drivers/usb/host/ehci-omap.h | 125 ------------------------------------------
2 files changed, 99 insertions(+), 126 deletions(-)
delete mode 100644 drivers/usb/host/ehci-omap.h
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 7f37b5f..2bdc978 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -29,7 +29,105 @@
#include <linux/clk.h>
#include <linux/gpio.h>
-#include "ehci-omap.h"
+/* FIXME remove platform-specific code */
+#include <mach/hardware.h>
+#include "../../../arch/arm/mach-omap2/cm.h"
+#include "../../../arch/arm/mach-omap2/cm-regbits-34xx.h"
+
+/*
+ * OMAP USBHOST Register addresses: PHYSICAL ADDRESSES
+ * Use omap_readl()/omap_writel() functions
+ */
+
+/* USBHOST: TLL, UUH, OHCI, EHCI */
+#define OMAP_USBHOST_BASE (L4_34XX_BASE + 0x60000)
+
+/* TLL Register Set */
+#define OMAP_USBHOST_TLL_BASE (OMAP_USBHOST_BASE + 0x2000)
+#define OMAP_USBTLL_REVISION (OMAP_USBHOST_TLL_BASE + 0x00)
+#define OMAP_USBTLL_SYSCONFIG (OMAP_USBHOST_TLL_BASE + 0x10)
+ #define OMAP_USBTLL_SYSCONFIG_CACTIVITY_SHIFT 8
+ #define OMAP_USBTLL_SYSCONFIG_SIDLEMODE_SHIFT 3
+ #define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP_SHIFT 2
+ #define OMAP_USBTLL_SYSCONFIG_SOFTRESET_SHIFT 1
+ #define OMAP_USBTLL_SYSCONFIG_AUTOIDLE_SHIFT 0
+#define OMAP_USBTLL_SYSSTATUS (OMAP_USBHOST_TLL_BASE + 0x14)
+ #define OMAP_USBTLL_SYSSTATUS_RESETDONE_SHIFT 0
+#define OMAP_USBTLL_IRQSTATUS (OMAP_USBHOST_TLL_BASE + 0x18)
+#define OMAP_USBTLL_IRQENABLE (OMAP_USBHOST_TLL_BASE + 0x1C)
+
+#define OMAP_TLL_SHARED_CONF (OMAP_USBHOST_TLL_BASE + 0x30)
+ #define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN_SHFT 6
+ #define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN_SHIFT 5
+ #define OMAP_TLL_SHARED_CONF_USB_DIVRATION_SHIFT 2
+ #define OMAP_TLL_SHARED_CONF_FCLK_REQ_SHIFT 1
+ #define OMAP_TLL_SHARED_CONF_FCLK_IS_ON_SHIFT 0
+
+#define OMAP_TLL_CHANNEL_CONF(num)\
+ (OMAP_USBHOST_TLL_BASE + (0x040 + 0x004 * num))
+ #define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF_SHIFT 11
+ #define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE_SHIFT 10
+ #define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT 9
+ #define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE_SHIFT 8
+ #define OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT 0
+
+#define OMAP_TLL_ULPI_FUNCTION_CTRL(num)\
+ (OMAP_USBHOST_TLL_BASE + (0x804 + 0x100 * num))
+#define OMAP_TLL_ULPI_INTERFACE_CTRL(num)\
+ (OMAP_USBHOST_TLL_BASE + (0x807 + 0x100 * num))
+#define OMAP_TLL_ULPI_OTG_CTRL(num)\
+ (OMAP_USBHOST_TLL_BASE + (0x80A + 0x100 * num))
+#define OMAP_TLL_ULPI_INT_EN_RISE(num)\
+ (OMAP_USBHOST_TLL_BASE + (0x80D + 0x100 * num))
+#define OMAP_TLL_ULPI_INT_EN_FALL(num)\
+ (OMAP_USBHOST_TLL_BASE + (0x810 + 0x100 * num))
+#define OMAP_TLL_ULPI_INT_STATUS(num)\
+ (OMAP_USBHOST_TLL_BASE + (0x813 + 0x100 * num))
+#define OMAP_TLL_ULPI_INT_LATCH(num)\
+ (OMAP_USBHOST_TLL_BASE + (0x814 + 0x100 * num))
+#define OMAP_TLL_ULPI_DEBUG(num)\
+ (OMAP_USBHOST_TLL_BASE + (0x815 + 0x100 * num))
+#define OMAP_TLL_ULPI_SCRATCH_REGISTER(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)
+#define OMAP_UHH_REVISION (OMAP_USBHOST_UHH_BASE + 0x00)
+#define OMAP_UHH_SYSCONFIG (OMAP_USBHOST_UHH_BASE + 0x10)
+ #define OMAP_UHH_SYSCONFIG_MIDLEMODE_SHIFT 12
+ #define OMAP_UHH_SYSCONFIG_CACTIVITY_SHIFT 8
+ #define OMAP_UHH_SYSCONFIG_SIDLEMODE_SHIFT 3
+ #define OMAP_UHH_SYSCONFIG_ENAWAKEUP_SHIFT 2
+ #define OMAP_UHH_SYSCONFIG_SOFTRESET_SHIFT 1
+ #define OMAP_UHH_SYSCONFIG_AUTOIDLE_SHIFT 0
+
+#define OMAP_UHH_SYSSTATUS (OMAP_USBHOST_UHH_BASE + 0x14)
+#define OMAP_UHH_HOSTCONFIG (OMAP_USBHOST_UHH_BASE + 0x40)
+ #define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT 0
+ #define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT 2
+ #define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT 3
+ #define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT 4
+ #define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT 5
+
+#define OMAP_UHH_DEBUG_CSR (OMAP_USBHOST_UHH_BASE + 0x44)
+
+/* EHCI Register Set */
+#define OMAP_USBHOST_EHCI_BASE (OMAP_USBHOST_BASE + 0x4800)
+#define EHCI_INSNREG05_ULPI (OMAP_USBHOST_EHCI_BASE + 0xA4)
+ #define EHCI_INSNREG05_ULPI_CONTROL_SHIFT 31
+ #define EHCI_INSNREG05_ULPI_PORTSEL_SHIFT 24
+ #define EHCI_INSNREG05_ULPI_OPSEL_SHIFT 22
+ #define EHCI_INSNREG05_ULPI_REGADD_SHIFT 16
+ #define EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT 8
+ #define EHCI_INSNREG05_ULPI_WRDATA_SHIFT 0
+
+/* OHCI Register Set */
+#define OMAP_USBHOST_OHCI_BASE (OMAP_USBHOST_BASE + 0x4400)
#ifdef CONFIG_OMAP_EHCI_PHY_MODE
/* EHCI connected to External PHY */
diff --git a/drivers/usb/host/ehci-omap.h b/drivers/usb/host/ehci-omap.h
deleted file mode 100644
index 9e4378f..0000000
--- a/drivers/usb/host/ehci-omap.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * ehci-omap.h - register definitions for USBHOST in OMAP 34xx
- *
- * Copyright (C) 2007-2008 Texas Instruments, Inc.
- * Author: Vikram Pandita <vikram.pandita@ti.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#ifndef __EHCI_OMAP_H
-#define __EHCI_OMAP_H
-
-#include <mach/hardware.h>
-#include "../../../arch/arm/mach-omap2/cm.h"
-#include "../../../arch/arm/mach-omap2/cm-regbits-34xx.h"
-
-/*
- * OMAP USBHOST Register addresses: PHYSICAL ADDRESSES
- * Use omap_readl()/omap_writel() functions
- */
-
-/* USBHOST: TLL, UUH, OHCI, EHCI */
-#define OMAP_USBHOST_BASE (L4_34XX_BASE + 0x60000)
-
-/* TLL Register Set */
-#define OMAP_USBHOST_TLL_BASE (OMAP_USBHOST_BASE + 0x2000)
-#define OMAP_USBTLL_REVISION (OMAP_USBHOST_TLL_BASE + 0x00)
-#define OMAP_USBTLL_SYSCONFIG (OMAP_USBHOST_TLL_BASE + 0x10)
- #define OMAP_USBTLL_SYSCONFIG_CACTIVITY_SHIFT 8
- #define OMAP_USBTLL_SYSCONFIG_SIDLEMODE_SHIFT 3
- #define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP_SHIFT 2
- #define OMAP_USBTLL_SYSCONFIG_SOFTRESET_SHIFT 1
- #define OMAP_USBTLL_SYSCONFIG_AUTOIDLE_SHIFT 0
-#define OMAP_USBTLL_SYSSTATUS (OMAP_USBHOST_TLL_BASE + 0x14)
- #define OMAP_USBTLL_SYSSTATUS_RESETDONE_SHIFT 0
-#define OMAP_USBTLL_IRQSTATUS (OMAP_USBHOST_TLL_BASE + 0x18)
-#define OMAP_USBTLL_IRQENABLE (OMAP_USBHOST_TLL_BASE + 0x1C)
-
-#define OMAP_TLL_SHARED_CONF (OMAP_USBHOST_TLL_BASE + 0x30)
- #define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN_SHFT 6
- #define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN_SHIFT 5
- #define OMAP_TLL_SHARED_CONF_USB_DIVRATION_SHIFT 2
- #define OMAP_TLL_SHARED_CONF_FCLK_REQ_SHIFT 1
- #define OMAP_TLL_SHARED_CONF_FCLK_IS_ON_SHIFT 0
-
-#define OMAP_TLL_CHANNEL_CONF(num)\
- (OMAP_USBHOST_TLL_BASE + (0x040 + 0x004 * num))
- #define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF_SHIFT 11
- #define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE_SHIFT 10
- #define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT 9
- #define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE_SHIFT 8
- #define OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT 0
-
-#define OMAP_TLL_ULPI_FUNCTION_CTRL(num)\
- (OMAP_USBHOST_TLL_BASE + (0x804 + 0x100 * num))
-#define OMAP_TLL_ULPI_INTERFACE_CTRL(num)\
- (OMAP_USBHOST_TLL_BASE + (0x807 + 0x100 * num))
-#define OMAP_TLL_ULPI_OTG_CTRL(num)\
- (OMAP_USBHOST_TLL_BASE + (0x80A + 0x100 * num))
-#define OMAP_TLL_ULPI_INT_EN_RISE(num)\
- (OMAP_USBHOST_TLL_BASE + (0x80D + 0x100 * num))
-#define OMAP_TLL_ULPI_INT_EN_FALL(num)\
- (OMAP_USBHOST_TLL_BASE + (0x810 + 0x100 * num))
-#define OMAP_TLL_ULPI_INT_STATUS(num)\
- (OMAP_USBHOST_TLL_BASE + (0x813 + 0x100 * num))
-#define OMAP_TLL_ULPI_INT_LATCH(num)\
- (OMAP_USBHOST_TLL_BASE + (0x814 + 0x100 * num))
-#define OMAP_TLL_ULPI_DEBUG(num)\
- (OMAP_USBHOST_TLL_BASE + (0x815 + 0x100 * num))
-#define OMAP_TLL_ULPI_SCRATCH_REGISTER(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)
-#define OMAP_UHH_REVISION (OMAP_USBHOST_UHH_BASE + 0x00)
-#define OMAP_UHH_SYSCONFIG (OMAP_USBHOST_UHH_BASE + 0x10)
- #define OMAP_UHH_SYSCONFIG_MIDLEMODE_SHIFT 12
- #define OMAP_UHH_SYSCONFIG_CACTIVITY_SHIFT 8
- #define OMAP_UHH_SYSCONFIG_SIDLEMODE_SHIFT 3
- #define OMAP_UHH_SYSCONFIG_ENAWAKEUP_SHIFT 2
- #define OMAP_UHH_SYSCONFIG_SOFTRESET_SHIFT 1
- #define OMAP_UHH_SYSCONFIG_AUTOIDLE_SHIFT 0
-
-#define OMAP_UHH_SYSSTATUS (OMAP_USBHOST_UHH_BASE + 0x14)
-#define OMAP_UHH_HOSTCONFIG (OMAP_USBHOST_UHH_BASE + 0x40)
- #define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT 0
- #define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT 2
- #define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT 3
- #define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT 4
- #define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT 5
-
-#define OMAP_UHH_DEBUG_CSR (OMAP_USBHOST_UHH_BASE + 0x44)
-
-/* EHCI Register Set */
-#define OMAP_USBHOST_EHCI_BASE (OMAP_USBHOST_BASE + 0x4800)
-#define EHCI_INSNREG05_ULPI (OMAP_USBHOST_EHCI_BASE + 0xA4)
- #define EHCI_INSNREG05_ULPI_CONTROL_SHIFT 31
- #define EHCI_INSNREG05_ULPI_PORTSEL_SHIFT 24
- #define EHCI_INSNREG05_ULPI_OPSEL_SHIFT 22
- #define EHCI_INSNREG05_ULPI_REGADD_SHIFT 16
- #define EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT 8
- #define EHCI_INSNREG05_ULPI_WRDATA_SHIFT 0
-
-/* OHCI Register Set */
-#define OMAP_USBHOST_OHCI_BASE (OMAP_USBHOST_BASE + 0x4400)
-
-#endif/* __EHCI_OMAP_H*/
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 14/23] usb: host: ehci: get rid of infinite loops
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 13/23] usb: host: ehci: remove ehci-omap.h Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 15/23] usb: host: ehci: disable clocks on error Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Use time_after() to avoid looping forever.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 87 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 77 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 2bdc978..35c645d 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -182,6 +182,7 @@ struct ehci_omap_clock_defs {
static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
{
+ unsigned long timeout = jiffies + msecs_to_jiffies(100);
int i;
/* Use UTMI Ports of TLL */
@@ -193,9 +194,15 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
OMAP_UHH_HOSTCONFIG);
/* Enusre bit is set */
while (!(omap_readl(OMAP_UHH_HOSTCONFIG)
- & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)))
+ & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT))) {
cpu_relax();
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return;
+ }
+ }
+
dev_dbg(hcd->self.controller, "Entered UTMI MODE: success\n");
/* Program the 3 TLL channels upfront */
@@ -254,6 +261,7 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
{
struct ehci_omap_clock_defs *ehci_clocks;
+ unsigned long timeout = jiffies + msecs_to_jiffies(100);
dev_dbg(hcd->self.controller, "starting TI EHCI USB Controller\n");
@@ -278,10 +286,16 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
PLL_MOD, OMAP3430ES2_CM_CLKEN2);
while (!(cm_read_mod_reg(PLL_MOD, CM_IDLEST2) &
- OMAP3430ES2_ST_PERIPH2_CLK_MASK))
+ OMAP3430ES2_ST_PERIPH2_CLK_MASK)) {
dev_dbg(hcd->self.controller,
"idlest2 = 0x%x\n",
cm_read_mod_reg(PLL_MOD, CM_IDLEST2));
+
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return -EINVAL;
+ }
+ }
/* End DPLL5 programming */
@@ -347,17 +361,30 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
/* Wait for TLL to be Active */
while ((cm_read_mod_reg(CORE_MOD, OMAP2430_CM_IDLEST3)
- & (1 << OMAP3430ES2_ST_USBTLL_SHIFT)))
+ & (1 << OMAP3430ES2_ST_USBTLL_SHIFT))) {
cpu_relax();
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return -EINVAL;
+ }
+ }
+
/* perform TLL soft reset, and wait until reset is complete */
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)))
+ & (1 << OMAP_USBTLL_SYSSTATUS_RESETDONE_SHIFT))) {
cpu_relax();
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return -EINVAL;
+ }
+ }
+
dev_dbg(hcd->self.controller, "TLL RESET DONE\n");
/* (1<<3) = no idle mode only for initial debugging */
@@ -383,11 +410,18 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
(1 << OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT)|
(0 << OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT),
OMAP_UHH_HOSTCONFIG);
+
/* Ensure that BYPASS is set */
while (omap_readl(OMAP_UHH_HOSTCONFIG)
- & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT))
+ & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)) {
cpu_relax();
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return -EINVAL;
+ }
+ }
+
dev_dbg(hcd->self.controller, "Entered ULPI PHY MODE: success\n");
#else
@@ -422,9 +456,15 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
EHCI_INSNREG05_ULPI);
while (!(omap_readl(EHCI_INSNREG05_ULPI)
- & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT)))
+ & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) {
cpu_relax();
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return -EINVAL;
+ }
+ }
+
#endif
return 0;
@@ -433,6 +473,7 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
{
struct ehci_omap_clock_defs *ehci_clocks;
+ unsigned long timeout = jiffies + msecs_to_jiffies(100);
ehci_clocks = (struct ehci_omap_clock_defs *)
(((char *)hcd_to_ehci(hcd)) + sizeof(struct ehci_hcd));
@@ -441,19 +482,45 @@ static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
/* Reset OMAP modules for insmod/rmmod to work */
omap_writel((1 << 1), OMAP_UHH_SYSCONFIG);
- while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 0)))
+ while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 0))) {
cpu_relax();
- while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 1)))
+
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return;
+ }
+ }
+
+ while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 1))) {
cpu_relax();
- while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 2)))
+
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return;
+ }
+ }
+
+ while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 2))) {
cpu_relax();
+
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return;
+ }
+ }
dev_dbg(hcd->self.controller,
"UHH RESET DONE OMAP_UHH_SYSSTATUS %x !!\n",
omap_readl(OMAP_UHH_SYSSTATUS));
omap_writel((1 << 1), OMAP_USBTLL_SYSCONFIG);
- while (!(omap_readl(OMAP_USBTLL_SYSSTATUS) & (1 << 0)))
+ while (!(omap_readl(OMAP_USBTLL_SYSSTATUS) & (1 << 0))) {
cpu_relax();
+
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller, "operation timed out\n");
+ return;
+ }
+ }
dev_dbg(hcd->self.controller, "TLL RESET DONE\n");
if (ehci_clocks->usbtll_fck_clk != NULL) {
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 15/23] usb: host: ehci: disable clocks on error
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 14/23] usb: host: ehci: get rid of infinite loops Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
The driver wasn't releasing the requested resources
on error, so make that work.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 82 ++++++++++++++++++++++++++++++++++--------
1 files changed, 67 insertions(+), 15 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 35c645d..b058ada 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -262,6 +262,7 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
{
struct ehci_omap_clock_defs *ehci_clocks;
unsigned long timeout = jiffies + msecs_to_jiffies(100);
+ int ret = 0;
dev_dbg(hcd->self.controller, "starting TI EHCI USB Controller\n");
@@ -293,7 +294,8 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
if (time_after(timeout, jiffies)) {
dev_dbg(hcd->self.controller, "operation timed out\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_idlest2;
}
}
/* End DPLL5 programming */
@@ -317,20 +319,26 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
/* Enable Clocks for USBHOST */
ehci_clocks->usbhost_ick_clk = clk_get(&dev->dev,
USBHOST_ICKL);
- if (IS_ERR(ehci_clocks->usbhost_ick_clk))
- return PTR_ERR(ehci_clocks->usbhost_ick_clk);
+ if (IS_ERR(ehci_clocks->usbhost_ick_clk)) {
+ ret = PTR_ERR(ehci_clocks->usbhost_ick_clk);
+ goto err_host_ick;
+ }
clk_enable(ehci_clocks->usbhost_ick_clk);
ehci_clocks->usbhost2_120m_fck_clk = clk_get(&dev->dev,
USBHOST_120M_FCLK);
- if (IS_ERR(ehci_clocks->usbhost2_120m_fck_clk))
- return PTR_ERR(ehci_clocks->usbhost2_120m_fck_clk);
+ if (IS_ERR(ehci_clocks->usbhost2_120m_fck_clk)) {
+ ret = PTR_ERR(ehci_clocks->usbhost2_120m_fck_clk);
+ goto err_host_120m_fck;
+ }
clk_enable(ehci_clocks->usbhost2_120m_fck_clk);
ehci_clocks->usbhost1_48m_fck_clk = clk_get(&dev->dev,
USBHOST_48M_FCLK);
- if (IS_ERR(ehci_clocks->usbhost1_48m_fck_clk))
- return PTR_ERR(ehci_clocks->usbhost1_48m_fck_clk);
+ if (IS_ERR(ehci_clocks->usbhost1_48m_fck_clk)) {
+ ret = PTR_ERR(ehci_clocks->usbhost1_48m_fck_clk);
+ goto err_host_48m_fck;
+ }
clk_enable(ehci_clocks->usbhost1_48m_fck_clk);
@@ -346,13 +354,17 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
/* 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))
- return PTR_ERR(ehci_clocks->usbtll_fck_clk);
+ if (IS_ERR(ehci_clocks->usbtll_fck_clk)) {
+ ret = PTR_ERR(ehci_clocks->usbtll_fck_clk);
+ goto err_tll_fck;
+ }
clk_enable(ehci_clocks->usbtll_fck_clk);
ehci_clocks->usbtll_ick_clk = clk_get(&dev->dev, USBHOST_TLL_ICKL);
- if (IS_ERR(ehci_clocks->usbtll_ick_clk))
- return PTR_ERR(ehci_clocks->usbtll_ick_clk);
+ if (IS_ERR(ehci_clocks->usbtll_ick_clk)) {
+ ret = PTR_ERR(ehci_clocks->usbtll_ick_clk);
+ goto err_tll_ick;
+ }
clk_enable(ehci_clocks->usbtll_ick_clk);
/* Disable Auto Idle of USBTLL */
@@ -366,7 +378,8 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
if (time_after(timeout, jiffies)) {
dev_dbg(hcd->self.controller, "operation timed out\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_idlest3;
}
}
@@ -381,7 +394,8 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
if (time_after(timeout, jiffies)) {
dev_dbg(hcd->self.controller, "operation timed out\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_sys_status;
}
}
@@ -418,7 +432,8 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
if (time_after(timeout, jiffies)) {
dev_dbg(hcd->self.controller, "operation timed out\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_ulpi_bypass;
}
}
@@ -461,13 +476,50 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
if (time_after(timeout, jiffies)) {
dev_dbg(hcd->self.controller, "operation timed out\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_ulpi_control;
}
}
#endif
return 0;
+
+#ifdef VBUS_INTERNAL_CHARGEPUMP_HACK
+err_ulpi_control:
+#endif
+#ifdef CONFIG_OMAP_EHCI_PHY_MODE
+err_ulpi_bypass:
+#endif
+err_sys_status:
+err_idlest3:
+ clk_disable(ehci_clocks->usbtll_ick_clk);
+ clk_put(ehci_clocks->usbtll_ick_clk);
+
+err_tll_ick:
+ clk_disable(ehci_clocks->usbtll_fck_clk);
+ clk_put(ehci_clocks->usbtll_fck_clk);
+
+err_tll_fck:
+ clk_disable(ehci_clocks->usbhost1_48m_fck_clk);
+ clk_put(ehci_clocks->usbhost1_48m_fck_clk);
+
+#ifdef EXTERNAL_PHY_RESET
+ gpio_free(EXT_PHY_RESET_GPIO_PORT1);
+ gpio_free(EXT_PHY_RESET_GPIO_PORT2);
+#endif
+
+err_host_48m_fck:
+ clk_disable(ehci_clocks->usbhost2_120m_fck_clk);
+ clk_put(ehci_clocks->usbhost2_120m_fck_clk);
+
+err_host_120m_fck:
+ clk_disable(ehci_clocks->usbhost_ick_clk);
+ clk_put(ehci_clocks->usbhost_ick_clk);
+
+err_host_ick:
+err_idlest2:
+ return ret;
}
static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 15/23] usb: host: ehci: disable clocks on error Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions Felipe Balbi
2009-02-24 22:35 ` [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data Grazvydas Ignotas
0 siblings, 2 replies; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Adding a platform_data to the driver allow us
to remove some of the ifdeferry in the code.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
arch/arm/mach-omap2/board-3430sdp.c | 2 +-
arch/arm/mach-omap2/board-omap3beagle.c | 2 +-
arch/arm/mach-omap2/board-omap3evm.c | 2 +-
arch/arm/mach-omap2/board-omap3pandora.c | 2 +-
arch/arm/mach-omap2/board-overo.c | 2 +-
arch/arm/mach-omap2/usb-ehci.c | 14 +-
arch/arm/plat-omap/include/mach/usb.h | 24 ++-
drivers/usb/host/Kconfig | 19 --
drivers/usb/host/ehci-omap.c | 401 +++++++++++++++---------------
9 files changed, 241 insertions(+), 227 deletions(-)
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 758183c..3f85c6e 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -643,7 +643,7 @@ static void __init omap_3430sdp_init(void)
msecure_init();
omap_serial_init();
usb_musb_init();
- usb_ehci_init();
+ usb_ehci_init(EHCI_HCD_OMAP_MODE_PHY, true, true, 57, 61);
}
static void __init omap_3430sdp_map_io(void)
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 5f5cc39..18d9a86 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -380,7 +380,7 @@ static void __init omap3_beagle_init(void)
gpio_direction_output(170, true);
usb_musb_init();
- usb_ehci_init();
+ usb_ehci_init(EHCI_HCD_OMAP_MODE_PHY, true, true, 57, 61);
omap3beagle_flash_init();
}
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 6577726..514058f 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -255,7 +255,7 @@ static void __init omap3_evm_init(void)
omap_serial_init();
twl4030_mmc_init(mmc);
usb_musb_init();
- usb_ehci_init();
+ usb_ehci_init(EHCI_HCD_OMAP_MODE_PHY, true, true, 57, 61);
omap3evm_flash_init();
ads7846_dev_init();
}
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index b8a78c0..08215c0 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -297,7 +297,7 @@ static void __init omap3pandora_init(void)
spi_register_board_info(omap3pandora_spi_board_info,
ARRAY_SIZE(omap3pandora_spi_board_info));
usb_musb_init();
- usb_ehci_init();
+ usb_ehci_init(EHCI_HCD_OMAP_MODE_PHY, true, true, 57, 61);
omap3pandora_flash_init();
omap3pandora_ads7846_init();
}
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index e5a3412..b51c835 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -246,7 +246,7 @@ static void __init overo_init(void)
omap_serial_init();
twl4030_mmc_init(mmc);
usb_musb_init();
- usb_ehci_init();
+ usb_ehci_init(EHCI_HCD_OMAP_MODE_PHY, true, true, 57, 61);
overo_flash_init();
if ((gpio_request(OVERO_GPIO_W2W_NRESET,
diff --git a/arch/arm/mach-omap2/usb-ehci.c b/arch/arm/mach-omap2/usb-ehci.c
index 23fe857..30e1ad6 100644
--- a/arch/arm/mach-omap2/usb-ehci.c
+++ b/arch/arm/mach-omap2/usb-ehci.c
@@ -145,8 +145,20 @@ static void setup_ehci_io_mux(void)
return;
}
-void __init usb_ehci_init(void)
+void __init usb_ehci_init(enum ehci_hcd_omap_mode phy_mode,
+ int chargepump, int phy_reset, int reset_gpio_port1,
+ int reset_gpio_port2)
{
+ struct ehci_hcd_omap_platform_data pdata = {
+ .phy_mode = phy_mode,
+ .chargepump = chargepump,
+ .phy_reset = phy_reset,
+ .reset_gpio_port1 = reset_gpio_port1,
+ .reset_gpio_port2 = reset_gpio_port2,
+ };
+
+ ehci_device.dev.platform_data = &pdata;
+
/* Setup Pin IO MUX for EHCI */
if (cpu_is_omap34xx())
setup_ehci_io_mux();
diff --git a/arch/arm/plat-omap/include/mach/usb.h b/arch/arm/plat-omap/include/mach/usb.h
index 47aba6b..8a341ca 100644
--- a/arch/arm/plat-omap/include/mach/usb.h
+++ b/arch/arm/plat-omap/include/mach/usb.h
@@ -5,6 +5,22 @@
#include <mach/board.h>
+enum ehci_hcd_omap_mode {
+ EHCI_HCD_OMAP_MODE_UNKNOWN,
+ EHCI_HCD_OMAP_MODE_PHY,
+ EHCI_HCD_OMAP_MODE_TLL,
+};
+
+struct ehci_hcd_omap_platform_data {
+ enum ehci_hcd_omap_mode phy_mode;
+ unsigned chargepump:1;
+ unsigned phy_reset:1;
+
+ /* have to be valid if phy_reset is true */
+ int reset_gpio_port1;
+ int reset_gpio_port2;
+};
+
/*-------------------------------------------------------------------------*/
#define OMAP1_OTG_BASE 0xfffb0400
@@ -36,9 +52,13 @@ static inline void usb_musb_init(void)
#endif
#if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
-extern void usb_ehci_init(void);
+extern void usb_ehci_init(enum ehci_hcd_omap_mode phy_mode,
+ int chargepump, int phy_reset, int reset_gpio_port1,
+ int reset_gpio_port2);
#else
-static inline void usb_ehci_init(void)
+static inline void usb_ehci_init(enum ehci_hcd_omap_mode phy_mode,
+ int chargepump, int phy_reset, int reset_gpio_port1,
+ int reset_gpio_port2)
{
}
#endif
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 02df795..2c63bfb 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -41,25 +41,6 @@ config USB_EHCI_HCD
To compile this driver as a module, choose M here: the
module will be called ehci-hcd.
-choice
- prompt "PHY/TLL mode"
- depends on USB_EHCI_HCD && EXPERIMENTAL && ARCH_OMAP34XX
- ---help---
- Choose PHY or TLL mode of operation
-
-config OMAP_EHCI_PHY_MODE
- bool "PHY mode: ISP1504 on Port1/2 (NEW 3430ES2.0)"
- depends on USB_EHCI_HCD && EXPERIMENTAL && ARCH_OMAP34XX
- ---help---
- EHCI PHY mode. Port1 and Port2 are connected to ISP1504 transcievers
-
-config OMAP_EHCI_TLL_MODE
- bool "TLL mode: (EXPERIMENTAL)"
- depends on USB_EHCI_HCD && EXPERIMENTAL && ARCH_OMAP34XX
- ---help---
- OMAP EHCI controller has TLL mode of operation for all 3 ports.
- Use this mode when no transciever is present
-endchoice
config USB_EHCI_ROOT_HUB_TT
bool "Root Hub Transaction Translators"
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index b058ada..cd891cc 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -29,6 +29,9 @@
#include <linux/clk.h>
#include <linux/gpio.h>
+/* platform_data lives here */
+#include <mach/usb.h>
+
/* FIXME remove platform-specific code */
#include <mach/hardware.h>
#include "../../../arch/arm/mach-omap2/cm.h"
@@ -129,44 +132,30 @@
/* OHCI Register Set */
#define OMAP_USBHOST_OHCI_BASE (OMAP_USBHOST_BASE + 0x4400)
-#ifdef CONFIG_OMAP_EHCI_PHY_MODE
-/* EHCI connected to External PHY */
+/*-------------------------------------------------------------------------*/
-/* External USB connectivity board: 750-2083-001
- * Connected to OMAP3430 SDP
- * The board has Port1 and Port2 connected to ISP1504 in 12-pin ULPI mode
- */
+struct ehci_hcd_omap {
+ struct ehci_hcd *ehci;
+ struct device *dev;
-/* ISSUE1:
- * ISP1504 for input clocking mode needs special reset handling
- * Hold the PHY in reset by asserting RESET_N signal
- * Then start the 60Mhz clock input to PHY
- * Release the reset after a delay -
- * to get the PHY state machine in working state
- */
-#define EXTERNAL_PHY_RESET
-#define EXT_PHY_RESET_GPIO_PORT1 (57)
-#define EXT_PHY_RESET_GPIO_PORT2 (61)
-#define EXT_PHY_RESET_DELAY (10)
-
-/* ISSUE2:
- * USBHOST supports External charge pump PHYs only
- * Use the VBUS from Port1 to power VBUS of Port2 externally
- * So use Port2 as the working ULPI port
- */
-#define VBUS_INTERNAL_CHARGEPUMP_HACK
+ struct clk *usbhost_ick;
+ struct clk *usbhost2_120m_fck;
+ struct clk *usbhost1_48m_fck;
+ struct clk *usbtll_fck;
+ struct clk *usbtll_ick;
-#endif /* CONFIG_OMAP_EHCI_PHY_MODE */
+ /* gpio for resetting phy */
+ int reset_gpio_port1;
+ int reset_gpio_port2;
-/*-------------------------------------------------------------------------*/
+ /* phy reset workaround */
+ int phy_reset;
-/* Define USBHOST clocks for clock management */
-struct ehci_omap_clock_defs {
- struct clk *usbhost_ick_clk;
- struct clk *usbhost2_120m_fck_clk;
- struct clk *usbhost1_48m_fck_clk;
- struct clk *usbtll_fck_clk;
- struct clk *usbtll_ick_clk;
+ /* vbus internal chargepump workaround */
+ int chargepump;
+
+ /* desired phy_mode: TLL, PHY */
+ enum ehci_hcd_omap_mode phy_mode;
};
/* Clock names as per clock framework: May change so keep as #defs */
@@ -178,8 +167,6 @@ struct ehci_omap_clock_defs {
/*-------------------------------------------------------------------------*/
-#ifndef CONFIG_OMAP_EHCI_PHY_MODE
-
static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
{
unsigned long timeout = jiffies + msecs_to_jiffies(100);
@@ -211,16 +198,16 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
/* Disable AutoIdle */
omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) &
- ~(1 << OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT),
- 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));
+ ~(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));
+ ~(1 << OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE_SHIFT),
+ OMAP_TLL_CHANNEL_CONF(i));
}
@@ -239,8 +226,8 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
continue;
omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) |
- (1 << OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT),
- OMAP_TLL_CHANNEL_CONF(i));
+ (1 << OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT),
+ OMAP_TLL_CHANNEL_CONF(i));
omap_writeb(0xBE, OMAP_TLL_ULPI_SCRATCH_REGISTER(i));
dev_dbg(hcd->self.controller, "ULPI_SCRATCH_REG[ch=%d]"
@@ -249,27 +236,18 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
}
}
-#else
-# define omap_usb_utmi_init(x, y) 0
-#endif
-
/*-------------------------------------------------------------------------*/
/* omap_start_ehc
* - Start the TI USBHOST controller
*/
-static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
+static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
{
- struct ehci_omap_clock_defs *ehci_clocks;
unsigned long timeout = jiffies + msecs_to_jiffies(100);
int ret = 0;
dev_dbg(hcd->self.controller, "starting TI EHCI USB Controller\n");
- ehci_clocks = (struct ehci_omap_clock_defs *)(
- ((char *)hcd_to_ehci(hcd)) +
- sizeof(struct ehci_hcd));
-
/* Start DPLL5 Programming:
* Clock Framework is not doing this now:
* This will be done in clock framework later
@@ -317,55 +295,52 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
OMAP3430ES2_USBHOST_MOD, CM_CLKSTCTRL);
/* Enable Clocks for USBHOST */
- ehci_clocks->usbhost_ick_clk = clk_get(&dev->dev,
- USBHOST_ICKL);
- if (IS_ERR(ehci_clocks->usbhost_ick_clk)) {
- ret = PTR_ERR(ehci_clocks->usbhost_ick_clk);
+ omap->usbhost_ick = clk_get(omap->dev, USBHOST_ICKL);
+ if (IS_ERR(omap->usbhost_ick)) {
+ ret = PTR_ERR(omap->usbhost_ick);
goto err_host_ick;
}
- clk_enable(ehci_clocks->usbhost_ick_clk);
+ clk_enable(omap->usbhost_ick);
- ehci_clocks->usbhost2_120m_fck_clk = clk_get(&dev->dev,
- USBHOST_120M_FCLK);
- if (IS_ERR(ehci_clocks->usbhost2_120m_fck_clk)) {
- ret = PTR_ERR(ehci_clocks->usbhost2_120m_fck_clk);
+ omap->usbhost2_120m_fck = clk_get(omap->dev, USBHOST_120M_FCLK);
+ if (IS_ERR(omap->usbhost2_120m_fck)) {
+ ret = PTR_ERR(omap->usbhost2_120m_fck);
goto err_host_120m_fck;
}
- clk_enable(ehci_clocks->usbhost2_120m_fck_clk);
+ clk_enable(omap->usbhost2_120m_fck);
- ehci_clocks->usbhost1_48m_fck_clk = clk_get(&dev->dev,
- USBHOST_48M_FCLK);
- if (IS_ERR(ehci_clocks->usbhost1_48m_fck_clk)) {
- ret = PTR_ERR(ehci_clocks->usbhost1_48m_fck_clk);
+ omap->usbhost1_48m_fck = clk_get(omap->dev, USBHOST_48M_FCLK);
+ if (IS_ERR(omap->usbhost1_48m_fck)) {
+ ret = PTR_ERR(omap->usbhost1_48m_fck);
goto err_host_48m_fck;
}
- clk_enable(ehci_clocks->usbhost1_48m_fck_clk);
+ clk_enable(omap->usbhost1_48m_fck);
-#ifdef EXTERNAL_PHY_RESET
- /* Refer: ISSUE1 */
- gpio_request(EXT_PHY_RESET_GPIO_PORT1, "USB1 PHY reset");
- gpio_direction_output(EXT_PHY_RESET_GPIO_PORT1, 0);
- gpio_request(EXT_PHY_RESET_GPIO_PORT2, "USB2 PHY reset");
- gpio_direction_output(EXT_PHY_RESET_GPIO_PORT2, 0);
- /* Hold the PHY in RESET for enough time till DIR is high */
- udelay(EXT_PHY_RESET_DELAY);
-#endif
+ if (omap->phy_reset) {
+ /* Refer: ISSUE1 */
+ gpio_request(omap->reset_gpio_port1, "USB1 PHY reset");
+ gpio_direction_output(omap->reset_gpio_port1, 0);
+ gpio_request(omap->reset_gpio_port2, "USB2 PHY reset");
+ gpio_direction_output(omap->reset_gpio_port2, 0);
+ /* Hold the PHY in RESET for enough time till DIR is high */
+ udelay(10);
+ }
/* 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)) {
- ret = PTR_ERR(ehci_clocks->usbtll_fck_clk);
+ omap->usbtll_fck = clk_get(omap->dev, USBHOST_TLL_FCLK);
+ if (IS_ERR(omap->usbtll_fck)) {
+ ret = PTR_ERR(omap->usbtll_fck);
goto err_tll_fck;
}
- clk_enable(ehci_clocks->usbtll_fck_clk);
+ clk_enable(omap->usbtll_fck);
- ehci_clocks->usbtll_ick_clk = clk_get(&dev->dev, USBHOST_TLL_ICKL);
- if (IS_ERR(ehci_clocks->usbtll_ick_clk)) {
- ret = PTR_ERR(ehci_clocks->usbtll_ick_clk);
+ omap->usbtll_ick = clk_get(omap->dev, USBHOST_TLL_ICKL);
+ if (IS_ERR(omap->usbtll_ick)) {
+ ret = PTR_ERR(omap->usbtll_ick);
goto err_tll_ick;
}
- clk_enable(ehci_clocks->usbtll_ick_clk);
+ clk_enable(omap->usbtll_ick);
/* Disable Auto Idle of USBTLL */
cm_write_mod_reg((0 << OMAP3430ES2_AUTO_USBTLL_SHIFT),
@@ -416,120 +391,124 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
(1 << OMAP_UHH_SYSCONFIG_MIDLEMODE_SHIFT),
OMAP_UHH_SYSCONFIG);
-#ifdef CONFIG_OMAP_EHCI_PHY_MODE
- /* Bypass the TLL module for PHY mode operation */
- omap_writel((0 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)|
+ if (omap->phy_mode == EHCI_HCD_OMAP_MODE_PHY) {
+
+ /* Bypass the TLL module for PHY mode operation */
+ omap_writel((0 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)|
(1 << OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT)|
(1 << OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT)|
(1 << OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT)|
(0 << OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT),
- OMAP_UHH_HOSTCONFIG);
+ OMAP_UHH_HOSTCONFIG);
- /* Ensure that BYPASS is set */
- while (omap_readl(OMAP_UHH_HOSTCONFIG)
+ /* Ensure that BYPASS is set */
+ while (omap_readl(OMAP_UHH_HOSTCONFIG)
& (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)) {
- cpu_relax();
-
- if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
- ret = -EINVAL;
- goto err_ulpi_bypass;
+ cpu_relax();
+
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller,
+ "operation timed out\n");
+ ret = -EINVAL;
+ goto err_ulpi_bypass;
+ }
}
- }
-
- dev_dbg(hcd->self.controller, "Entered ULPI PHY MODE: success\n");
-
-#else
- /* 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
- /* Refer ISSUE1:
- * Hold the PHY in RESET for enough time till PHY is settled and ready
- */
- udelay(EXT_PHY_RESET_DELAY);
- gpio_set_value(EXT_PHY_RESET_GPIO_PORT1, 1);
- gpio_set_value(EXT_PHY_RESET_GPIO_PORT2, 1);
-#endif
-
-#ifdef VBUS_INTERNAL_CHARGEPUMP_HACK
- /* Refer ISSUE2: LINK assumes external charge pump */
+ dev_dbg(hcd->self.controller,
+ "Entered ULPI PHY MODE: success\n");
+
+ } else if (omap->phy_mode == EHCI_HCD_OMAP_MODE_TLL) {
+
+ /* 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
+ );
+ } else {
+ dev_err(hcd->self.controller,
+ "UNKOWN mode requested\n");
+ ret = -EINVAL;
+ goto err_unknown_mode;
+ }
- /* use Port1 VBUS to charge externally Port2:
- * So for PHY mode operation use Port2 only
- */
- omap_writel((0xA << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |/* OTG ctrl reg*/
- (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) |/* Write */
- (1 << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) |/* Port1 */
- (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |/* Start */
- (0x26),
- EHCI_INSNREG05_ULPI);
-
- while (!(omap_readl(EHCI_INSNREG05_ULPI)
- & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) {
- cpu_relax();
+ if (omap->phy_reset) {
+ /* Refer ISSUE1:
+ * Hold the PHY in RESET for enough time till
+ * PHY is settled and ready
+ */
+ udelay(10);
+ gpio_set_value(omap->reset_gpio_port1, 1);
+ gpio_set_value(omap->reset_gpio_port2, 1);
+ }
- if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
- ret = -EINVAL;
- goto err_ulpi_control;
+ if (omap->chargepump) {
+
+ /* Refer ISSUE2: LINK assumes external charge pump */
+
+ /* use Port1 VBUS to charge externally Port2:
+ * So for PHY mode operation use Port2 only
+ */
+ omap_writel((0xA << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |/* OTG ctrl reg*/
+ (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) |/* Write */
+ (1 << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) |/* Port1 */
+ (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |/* Start */
+ (0x26),
+ EHCI_INSNREG05_ULPI);
+
+ while (!(omap_readl(EHCI_INSNREG05_ULPI)
+ & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) {
+ cpu_relax();
+
+ if (time_after(timeout, jiffies)) {
+ dev_dbg(hcd->self.controller,
+ "operation timed out\n");
+ ret = -EINVAL;
+ goto err_ulpi_control;
+ }
}
}
-#endif
-
return 0;
-#ifdef VBUS_INTERNAL_CHARGEPUMP_HACK
err_ulpi_control:
-#endif
-#ifdef CONFIG_OMAP_EHCI_PHY_MODE
+err_unknown_mode:
err_ulpi_bypass:
-#endif
err_sys_status:
err_idlest3:
- clk_disable(ehci_clocks->usbtll_ick_clk);
- clk_put(ehci_clocks->usbtll_ick_clk);
+ clk_disable(omap->usbtll_ick);
+ clk_put(omap->usbtll_ick);
err_tll_ick:
- clk_disable(ehci_clocks->usbtll_fck_clk);
- clk_put(ehci_clocks->usbtll_fck_clk);
+ clk_disable(omap->usbtll_fck);
+ clk_put(omap->usbtll_fck);
err_tll_fck:
- clk_disable(ehci_clocks->usbhost1_48m_fck_clk);
- clk_put(ehci_clocks->usbhost1_48m_fck_clk);
+ clk_disable(omap->usbhost1_48m_fck);
+ clk_put(omap->usbhost1_48m_fck);
-#ifdef EXTERNAL_PHY_RESET
- gpio_free(EXT_PHY_RESET_GPIO_PORT1);
- gpio_free(EXT_PHY_RESET_GPIO_PORT2);
-#endif
+ if (omap->phy_reset) {
+ gpio_free(omap->reset_gpio_port1);
+ gpio_free(omap->reset_gpio_port2);
+ }
err_host_48m_fck:
- clk_disable(ehci_clocks->usbhost2_120m_fck_clk);
- clk_put(ehci_clocks->usbhost2_120m_fck_clk);
+ clk_disable(omap->usbhost2_120m_fck);
+ clk_put(omap->usbhost2_120m_fck);
err_host_120m_fck:
- clk_disable(ehci_clocks->usbhost_ick_clk);
- clk_put(ehci_clocks->usbhost_ick_clk);
+ clk_disable(omap->usbhost_ick);
+ clk_put(omap->usbhost_ick);
err_host_ick:
err_idlest2:
return ret;
}
-static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
+static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
{
- struct ehci_omap_clock_defs *ehci_clocks;
unsigned long timeout = jiffies + msecs_to_jiffies(100);
- ehci_clocks = (struct ehci_omap_clock_defs *)
- (((char *)hcd_to_ehci(hcd)) + sizeof(struct ehci_hcd));
-
dev_dbg(hcd->self.controller, "stopping TI EHCI USB Controller\n");
/* Reset OMAP modules for insmod/rmmod to work */
@@ -575,40 +554,40 @@ static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
}
dev_dbg(hcd->self.controller, "TLL RESET DONE\n");
- if (ehci_clocks->usbtll_fck_clk != NULL) {
- clk_disable(ehci_clocks->usbtll_fck_clk);
- clk_put(ehci_clocks->usbtll_fck_clk);
- ehci_clocks->usbtll_fck_clk = NULL;
+ if (omap->usbtll_fck != NULL) {
+ clk_disable(omap->usbtll_fck);
+ clk_put(omap->usbtll_fck);
+ omap->usbtll_fck = NULL;
}
- if (ehci_clocks->usbhost_ick_clk != NULL) {
- clk_disable(ehci_clocks->usbhost_ick_clk);
- clk_put(ehci_clocks->usbhost_ick_clk);
- ehci_clocks->usbhost_ick_clk = NULL;
+ if (omap->usbhost_ick != NULL) {
+ clk_disable(omap->usbhost_ick);
+ clk_put(omap->usbhost_ick);
+ omap->usbhost_ick = NULL;
}
- if (ehci_clocks->usbhost1_48m_fck_clk != NULL) {
- clk_disable(ehci_clocks->usbhost1_48m_fck_clk);
- clk_put(ehci_clocks->usbhost1_48m_fck_clk);
- ehci_clocks->usbhost1_48m_fck_clk = NULL;
+ if (omap->usbhost1_48m_fck != NULL) {
+ clk_disable(omap->usbhost1_48m_fck);
+ clk_put(omap->usbhost1_48m_fck);
+ omap->usbhost1_48m_fck = NULL;
}
- if (ehci_clocks->usbhost2_120m_fck_clk != NULL) {
- clk_disable(ehci_clocks->usbhost2_120m_fck_clk);
- clk_put(ehci_clocks->usbhost2_120m_fck_clk);
- ehci_clocks->usbhost2_120m_fck_clk = NULL;
+ if (omap->usbhost2_120m_fck != NULL) {
+ clk_disable(omap->usbhost2_120m_fck);
+ clk_put(omap->usbhost2_120m_fck);
+ omap->usbhost2_120m_fck = NULL;
}
- if (ehci_clocks->usbtll_ick_clk != NULL) {
- clk_disable(ehci_clocks->usbtll_ick_clk);
- clk_put(ehci_clocks->usbtll_ick_clk);
- ehci_clocks->usbtll_ick_clk = NULL;
+ if (omap->usbtll_ick != NULL) {
+ clk_disable(omap->usbtll_ick);
+ clk_put(omap->usbtll_ick);
+ omap->usbtll_ick = NULL;
}
-#ifdef EXTERNAL_PHY_RESET
- gpio_free(EXT_PHY_RESET_GPIO_PORT1);
- gpio_free(EXT_PHY_RESET_GPIO_PORT2);
-#endif
+ if (omap->phy_reset) {
+ gpio_free(omap->reset_gpio_port1);
+ gpio_free(omap->reset_gpio_port2);
+ }
dev_dbg(hcd->self.controller,
"Clock to USB host has been disabled\n");
@@ -630,16 +609,28 @@ static const struct hc_driver ehci_omap_hc_driver;
*/
static int ehci_hcd_omap_probe(struct platform_device *pdev)
{
- struct ehci_hcd *ehci;
+ struct ehci_hcd_omap_platform_data *pdata = pdev->dev.platform_data;
+ struct ehci_hcd_omap *omap;
struct resource *res;
struct usb_hcd *hcd;
int irq = platform_get_irq(pdev, 0);
int ret = -ENODEV;
+ if (!pdata) {
+ dev_dbg(&pdev->dev, "missing platform_data\n");
+ goto err_pdata;
+ }
+
if (usb_disabled())
goto err_disabled;
+ omap = kzalloc(sizeof(*omap), GFP_KERNEL);
+ if (!omap) {
+ ret = -ENOMEM;
+ goto err_create_hcd;
+ }
+
hcd = usb_create_hcd(&ehci_omap_hc_driver, &pdev->dev,
dev_name(&pdev->dev));
if (!hcd) {
@@ -648,7 +639,17 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
goto err_create_hcd;
}
- ret = omap_start_ehc(pdev, hcd);
+ platform_set_drvdata(pdev, omap);
+ omap->dev = &pdev->dev;
+ omap->reset_gpio_port1 = pdata->reset_gpio_port1;
+ omap->reset_gpio_port2 = pdata->reset_gpio_port2;
+ omap->phy_mode = pdata->phy_mode;
+ omap->chargepump = pdata->chargepump;
+ omap->ehci = hcd_to_ehci(hcd);
+ omap->ehci->caps = hcd->regs;
+ omap->ehci->sbrn = 0x20;
+
+ ret = omap_start_ehc(omap, hcd);
if (ret) {
dev_dbg(&pdev->dev, "failed to start ehci\n");
goto err_start;
@@ -668,16 +669,15 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
goto err_ioremap;
}
- ehci = hcd_to_ehci(hcd);
- ehci->caps = hcd->regs;
- ehci->sbrn = 0x20;
+ omap->ehci->regs = hcd->regs
+ + HC_LENGTH(readl(&omap->ehci->caps->hc_capbase));
- ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase));
/* cache this readonly data; minimize chip reads */
- ehci->hcs_params = readl(&ehci->caps->hcs_params);
+ omap->ehci->hcs_params = readl(&omap->ehci->caps->hcs_params);
/* SET 1 micro-frame Interrupt interval */
- writel(readl(&ehci->regs->command) | (1 << 16), &ehci->regs->command);
+ writel(readl(&omap->ehci->regs->command) | (1 << 16),
+ &omap->ehci->regs->command);
ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
if (ret) {
@@ -691,13 +691,14 @@ err_add_hcd:
iounmap(hcd->regs);
err_ioremap:
- omap_stop_ehc(pdev, hcd);
+ omap_stop_ehc(omap, hcd);
err_start:
usb_put_hcd(hcd);
err_create_hcd:
err_disabled:
+err_pdata:
return ret;
}
@@ -714,11 +715,12 @@ err_disabled:
*/
static int ehci_hcd_omap_remove(struct platform_device *pdev)
{
- struct usb_hcd *hcd = platform_get_drvdata(pdev);
+ struct ehci_hcd_omap *omap = platform_get_drvdata(pdev);
+ struct usb_hcd *hcd = ehci_to_hcd(omap->ehci);
usb_remove_hcd(hcd);
iounmap(hcd->regs);
- omap_stop_ehc(pdev, hcd);
+ omap_stop_ehc(omap, hcd);
usb_put_hcd(hcd);
return 0;
@@ -738,10 +740,9 @@ static struct platform_driver ehci_hcd_omap_driver = {
/*-------------------------------------------------------------------------*/
static const struct hc_driver ehci_omap_hc_driver = {
- .description = hcd_name,
+ .description = hcd_name,
.product_desc = "OMAP-EHCI Host Controller",
- .hcd_priv_size = sizeof(struct ehci_hcd)
- + sizeof(struct ehci_omap_clock_defs),
+ .hcd_priv_size = sizeof(struct ehci_hcd_omap),
/*
* generic hardware linkage
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 18/23] arm: omap: make usb base defines follow trm Felipe Balbi
2009-02-24 22:42 ` [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions Grazvydas Ignotas
2009-02-24 22:35 ` [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data Grazvydas Ignotas
1 sibling, 2 replies; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Make the register definitions in ehci-omap.c more sane.
Also change the parameter passed omap_start/stop_ehc().
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 219 +++++++++++++++++++++---------------------
1 files changed, 111 insertions(+), 108 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index cd891cc..c9305a3 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -49,30 +49,30 @@
#define OMAP_USBHOST_TLL_BASE (OMAP_USBHOST_BASE + 0x2000)
#define OMAP_USBTLL_REVISION (OMAP_USBHOST_TLL_BASE + 0x00)
#define OMAP_USBTLL_SYSCONFIG (OMAP_USBHOST_TLL_BASE + 0x10)
- #define OMAP_USBTLL_SYSCONFIG_CACTIVITY_SHIFT 8
- #define OMAP_USBTLL_SYSCONFIG_SIDLEMODE_SHIFT 3
- #define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP_SHIFT 2
- #define OMAP_USBTLL_SYSCONFIG_SOFTRESET_SHIFT 1
- #define OMAP_USBTLL_SYSCONFIG_AUTOIDLE_SHIFT 0
+ #define OMAP_USBTLL_SYSCONFIG_CACTIVITY (1 << 8)
+ #define OMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3)
+ #define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2)
+ #define OMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1)
+ #define OMAP_USBTLL_SYSCONFIG_AUTOIDLE (1 << 0)
#define OMAP_USBTLL_SYSSTATUS (OMAP_USBHOST_TLL_BASE + 0x14)
- #define OMAP_USBTLL_SYSSTATUS_RESETDONE_SHIFT 0
+ #define OMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0)
#define OMAP_USBTLL_IRQSTATUS (OMAP_USBHOST_TLL_BASE + 0x18)
#define OMAP_USBTLL_IRQENABLE (OMAP_USBHOST_TLL_BASE + 0x1C)
#define OMAP_TLL_SHARED_CONF (OMAP_USBHOST_TLL_BASE + 0x30)
- #define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN_SHFT 6
- #define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN_SHIFT 5
- #define OMAP_TLL_SHARED_CONF_USB_DIVRATION_SHIFT 2
- #define OMAP_TLL_SHARED_CONF_FCLK_REQ_SHIFT 1
- #define OMAP_TLL_SHARED_CONF_FCLK_IS_ON_SHIFT 0
+ #define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN (1 << 6)
+ #define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN (1 << 5)
+ #define OMAP_TLL_SHARED_CONF_USB_DIVRATION (1 << 2)
+ #define OMAP_TLL_SHARED_CONF_FCLK_REQ (1 << 1)
+ #define OMAP_TLL_SHARED_CONF_FCLK_IS_ON (1 << 0)
#define OMAP_TLL_CHANNEL_CONF(num)\
(OMAP_USBHOST_TLL_BASE + (0x040 + 0x004 * num))
- #define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF_SHIFT 11
- #define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE_SHIFT 10
- #define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT 9
- #define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE_SHIFT 8
- #define OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT 0
+ #define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF (1 << 11)
+ #define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10)
+ #define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE (1 << 9)
+ #define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE (1 << 8)
+ #define OMAP_TLL_CHANNEL_CONF_CHANEN (1 << 0)
#define OMAP_TLL_ULPI_FUNCTION_CTRL(num)\
(OMAP_USBHOST_TLL_BASE + (0x804 + 0x100 * num))
@@ -94,28 +94,28 @@
(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
+ #define OMAP_TLL_CHANNEL_1_EN_MASK (1 << 1)
+ #define OMAP_TLL_CHANNEL_2_EN_MASK (1 << 2)
+ #define OMAP_TLL_CHANNEL_3_EN_MASK (1 << 4)
/* UHH Register Set */
#define OMAP_USBHOST_UHH_BASE (OMAP_USBHOST_BASE + 0x4000)
#define OMAP_UHH_REVISION (OMAP_USBHOST_UHH_BASE + 0x00)
#define OMAP_UHH_SYSCONFIG (OMAP_USBHOST_UHH_BASE + 0x10)
- #define OMAP_UHH_SYSCONFIG_MIDLEMODE_SHIFT 12
- #define OMAP_UHH_SYSCONFIG_CACTIVITY_SHIFT 8
- #define OMAP_UHH_SYSCONFIG_SIDLEMODE_SHIFT 3
- #define OMAP_UHH_SYSCONFIG_ENAWAKEUP_SHIFT 2
- #define OMAP_UHH_SYSCONFIG_SOFTRESET_SHIFT 1
- #define OMAP_UHH_SYSCONFIG_AUTOIDLE_SHIFT 0
+ #define OMAP_UHH_SYSCONFIG_MIDLEMODE (1 << 12)
+ #define OMAP_UHH_SYSCONFIG_CACTIVITY (1 << 8)
+ #define OMAP_UHH_SYSCONFIG_SIDLEMODE (1 << 3)
+ #define OMAP_UHH_SYSCONFIG_ENAWAKEUP (1 << 2)
+ #define OMAP_UHH_SYSCONFIG_SOFTRESET (1 << 1)
+ #define OMAP_UHH_SYSCONFIG_AUTOIDLE (1 << 0)
#define OMAP_UHH_SYSSTATUS (OMAP_USBHOST_UHH_BASE + 0x14)
#define OMAP_UHH_HOSTCONFIG (OMAP_USBHOST_UHH_BASE + 0x40)
- #define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT 0
- #define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT 2
- #define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT 3
- #define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT 4
- #define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT 5
+ #define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1 << 0)
+ #define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN (1 << 2)
+ #define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN (1 << 3)
+ #define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN (1 << 4)
+ #define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN (1 << 5)
#define OMAP_UHH_DEBUG_CSR (OMAP_USBHOST_UHH_BASE + 0x44)
@@ -167,71 +167,75 @@ struct ehci_hcd_omap {
/*-------------------------------------------------------------------------*/
-static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
+static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask)
{
unsigned long timeout = jiffies + msecs_to_jiffies(100);
+ unsigned reg;
int i;
+ reg = omap_readl(OMAP_UHH_HOSTCONFIG);
+ reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS
+ | OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
+ | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
+ | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN;
+ reg &= ~OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN;
+
/* Use UTMI Ports of TLL */
- omap_writel((1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)|
- (1 << OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT)|
- (1 << OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT)|
- (1 << OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT)|
- (0 << OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT),
- OMAP_UHH_HOSTCONFIG);
- /* Enusre bit is set */
+ omap_writel(reg, OMAP_UHH_HOSTCONFIG);
+
+ /* Ensure bit is set */
while (!(omap_readl(OMAP_UHH_HOSTCONFIG)
- & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT))) {
+ & OMAP_UHH_HOSTCONFIG_ULPI_BYPASS)) {
cpu_relax();
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
+ dev_dbg(omap->dev, "operation timed out\n");
return;
}
}
- dev_dbg(hcd->self.controller, "Entered UTMI MODE: success\n");
+ dev_dbg(omap->dev, "Entered UTMI MODE: success\n");
/* Program the 3 TLL channels upfront */
for (i = 0; i < OMAP_TLL_CHANNEL_COUNT; i++) {
+ reg = omap_readl(OMAP_TLL_CHANNEL_CONF(i));
/* Disable AutoIdle */
- omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) &
- ~(1 << OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE_SHIFT),
- OMAP_TLL_CHANNEL_CONF(i));
+ reg &= ~OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE;
+ omap_writel(reg, 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));
+ reg &= ~OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF;
+ omap_writel(reg, OMAP_TLL_CHANNEL_CONF(i));
+ /* SDR Mode */
+ reg &= ~OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE;
+ omap_writel(reg, 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) |
- (0 << OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN_SHIFT) |
- (0 << OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN_SHFT),
- OMAP_TLL_SHARED_CONF);
+ reg = omap_readl(OMAP_TLL_SHARED_CONF);
+ reg |= (OMAP_TLL_SHARED_CONF_FCLK_IS_ON
+ | OMAP_TLL_SHARED_CONF_USB_DIVRATION
+ | OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN);
+ reg &= ~OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN;
+
+ omap_writel(reg, OMAP_TLL_SHARED_CONF);
/* Enable channels now */
for (i = 0; i < OMAP_TLL_CHANNEL_COUNT; i++) {
+ reg = omap_readl(OMAP_TLL_CHANNEL_CONF(i));
- /* Enable only the channel that is needed */
+ /* Enable only the reg that is needed */
if (!(tll_channel_mask & 1<<i))
continue;
- omap_writel(omap_readl(OMAP_TLL_CHANNEL_CONF(i)) |
- (1 << OMAP_TLL_CHANNEL_CONF_CHANEN_SHIFT),
- OMAP_TLL_CHANNEL_CONF(i));
+ reg |= OMAP_TLL_CHANNEL_CONF_CHANEN;
+ omap_writel(reg, OMAP_TLL_CHANNEL_CONF(i));
- omap_writeb(0xBE, OMAP_TLL_ULPI_SCRATCH_REGISTER(i));
- dev_dbg(hcd->self.controller, "ULPI_SCRATCH_REG[ch=%d]"
- "= 0x%02x\n",
+ omap_writeb(0xbe, OMAP_TLL_ULPI_SCRATCH_REGISTER(i));
+ dev_dbg(omap->dev, "ULPI_SCRATCH_REG[ch=%d]= 0x%02x\n",
i+1, omap_readb(OMAP_TLL_ULPI_SCRATCH_REGISTER(i)));
}
}
@@ -244,9 +248,10 @@ static void omap_usb_utmi_init(struct usb_hcd *hcd, u8 tll_channel_mask)
static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
{
unsigned long timeout = jiffies + msecs_to_jiffies(100);
+ unsigned reg = 0;
int ret = 0;
- dev_dbg(hcd->self.controller, "starting TI EHCI USB Controller\n");
+ dev_dbg(omap->dev, "starting TI EHCI USB Controller\n");
/* Start DPLL5 Programming:
* Clock Framework is not doing this now:
@@ -266,19 +271,17 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
while (!(cm_read_mod_reg(PLL_MOD, CM_IDLEST2) &
OMAP3430ES2_ST_PERIPH2_CLK_MASK)) {
- dev_dbg(hcd->self.controller,
- "idlest2 = 0x%x\n",
+ dev_dbg(omap->dev, "idlest2 = 0x%x\n",
cm_read_mod_reg(PLL_MOD, CM_IDLEST2));
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
+ dev_dbg(omap->dev, "operation timed out\n");
ret = -EINVAL;
goto err_idlest2;
}
}
/* End DPLL5 programming */
-
/* PRCM settings for USBHOST:
* Interface clk un-related to domain transition
*/
@@ -343,84 +346,87 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
clk_enable(omap->usbtll_ick);
/* Disable Auto Idle of USBTLL */
- cm_write_mod_reg((0 << OMAP3430ES2_AUTO_USBTLL_SHIFT),
+ cm_write_mod_reg((0 << OMAP3430ES2_AUTO_USBTLL),
CORE_MOD, CM_AUTOIDLE3);
/* Wait for TLL to be Active */
while ((cm_read_mod_reg(CORE_MOD, OMAP2430_CM_IDLEST3)
- & (1 << OMAP3430ES2_ST_USBTLL_SHIFT))) {
+ & (0 << OMAP3430ES2_ST_USBTLL_SHIFT))) {
cpu_relax();
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
+ dev_dbg(omap->dev, "operation timed out\n");
ret = -EINVAL;
goto err_idlest3;
}
}
/* perform TLL soft reset, and wait until reset is complete */
- omap_writel(1 << OMAP_USBTLL_SYSCONFIG_SOFTRESET_SHIFT,
+ omap_writel(1 << OMAP_USBTLL_SYSCONFIG_SOFTRESET,
OMAP_USBTLL_SYSCONFIG);
/* Wait for TLL reset to complete */
while (!(omap_readl(OMAP_USBTLL_SYSSTATUS)
- & (1 << OMAP_USBTLL_SYSSTATUS_RESETDONE_SHIFT))) {
+ & (1 << OMAP_USBTLL_SYSSTATUS_RESETDONE))) {
cpu_relax();
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
+ dev_dbg(omap->dev, "operation timed out\n");
ret = -EINVAL;
goto err_sys_status;
}
}
- dev_dbg(hcd->self.controller, "TLL RESET DONE\n");
+ dev_dbg(omap->dev, "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_writel(OMAP_USBTLL_SYSCONFIG_ENAWAKEUP |
+ OMAP_USBTLL_SYSCONFIG_SIDLEMODE |
+ OMAP_USBTLL_SYSCONFIG_CACTIVITY,
OMAP_USBTLL_SYSCONFIG);
/* Put UHH in NoIdle/NoStandby mode */
- omap_writel((0 << OMAP_UHH_SYSCONFIG_AUTOIDLE_SHIFT) |
- (1 << OMAP_UHH_SYSCONFIG_ENAWAKEUP_SHIFT) |
- (1 << OMAP_UHH_SYSCONFIG_SIDLEMODE_SHIFT) |
- (1 << OMAP_UHH_SYSCONFIG_CACTIVITY_SHIFT) |
- (1 << OMAP_UHH_SYSCONFIG_MIDLEMODE_SHIFT),
- OMAP_UHH_SYSCONFIG);
+ reg = omap_readl(OMAP_UHH_SYSCONFIG);
+ reg |= (OMAP_UHH_SYSCONFIG_ENAWAKEUP
+ | OMAP_UHH_SYSCONFIG_SIDLEMODE
+ | OMAP_UHH_SYSCONFIG_CACTIVITY
+ | OMAP_UHH_SYSCONFIG_MIDLEMODE);
+ reg &= ~OMAP_UHH_SYSCONFIG_AUTOIDLE;
+
+ omap_writel(reg, OMAP_UHH_SYSCONFIG);
if (omap->phy_mode == EHCI_HCD_OMAP_MODE_PHY) {
+ reg = omap_readl(OMAP_UHH_HOSTCONFIG);
+
+ reg |= (OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
+ | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
+ | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN);
+ reg &= ~(OMAP_UHH_HOSTCONFIG_ULPI_BYPASS
+ | OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN);
/* Bypass the TLL module for PHY mode operation */
- omap_writel((0 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)|
- (1 << OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT)|
- (1 << OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT)|
- (1 << OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT)|
- (0 << OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT),
- OMAP_UHH_HOSTCONFIG);
+ omap_writel(reg, OMAP_UHH_HOSTCONFIG);
/* Ensure that BYPASS is set */
while (omap_readl(OMAP_UHH_HOSTCONFIG)
- & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)) {
+ & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS)) {
cpu_relax();
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller,
+ dev_dbg(omap->dev,
"operation timed out\n");
ret = -EINVAL;
goto err_ulpi_bypass;
}
}
- dev_dbg(hcd->self.controller,
- "Entered ULPI PHY MODE: success\n");
+ dev_dbg(omap->dev, "Entered ULPI PHY MODE: success\n");
} else if (omap->phy_mode == EHCI_HCD_OMAP_MODE_TLL) {
/* Enable UTMI mode for all 3 TLL channels */
- omap_usb_utmi_init(hcd,
+ omap_usb_utmi_init(omap,
OMAP_TLL_CHANNEL_1_EN_MASK |
OMAP_TLL_CHANNEL_2_EN_MASK |
OMAP_TLL_CHANNEL_3_EN_MASK
@@ -449,7 +455,7 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
/* use Port1 VBUS to charge externally Port2:
* So for PHY mode operation use Port2 only
*/
- omap_writel((0xA << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |/* OTG ctrl reg*/
+ omap_writel((0xa << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |/* OTG ctrl reg*/
(2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) |/* Write */
(1 << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) |/* Port1 */
(1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |/* Start */
@@ -461,8 +467,7 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
cpu_relax();
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller,
- "operation timed out\n");
+ dev_dbg(omap->dev, "operation timed out\n");
ret = -EINVAL;
goto err_ulpi_control;
}
@@ -509,7 +514,7 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
{
unsigned long timeout = jiffies + msecs_to_jiffies(100);
- dev_dbg(hcd->self.controller, "stopping TI EHCI USB Controller\n");
+ dev_dbg(omap->dev, "stopping TI EHCI USB Controller\n");
/* Reset OMAP modules for insmod/rmmod to work */
omap_writel((1 << 1), OMAP_UHH_SYSCONFIG);
@@ -517,7 +522,7 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
cpu_relax();
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
+ dev_dbg(omap->dev, "operation timed out\n");
return;
}
}
@@ -526,7 +531,7 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
cpu_relax();
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
+ dev_dbg(omap->dev, "operation timed out\n");
return;
}
}
@@ -535,12 +540,11 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
cpu_relax();
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
+ dev_dbg(omap->dev, "operation timed out\n");
return;
}
}
- dev_dbg(hcd->self.controller,
- "UHH RESET DONE OMAP_UHH_SYSSTATUS %x !!\n",
+ dev_dbg(omap->dev, "UHH RESET DONE OMAP_UHH_SYSSTATUS %x\n",
omap_readl(OMAP_UHH_SYSSTATUS));
omap_writel((1 << 1), OMAP_USBTLL_SYSCONFIG);
@@ -548,11 +552,11 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
cpu_relax();
if (time_after(timeout, jiffies)) {
- dev_dbg(hcd->self.controller, "operation timed out\n");
+ dev_dbg(omap->dev, "operation timed out\n");
return;
}
}
- dev_dbg(hcd->self.controller, "TLL RESET DONE\n");
+ dev_dbg(omap->dev, "TLL RESET DONE\n");
if (omap->usbtll_fck != NULL) {
clk_disable(omap->usbtll_fck);
@@ -589,8 +593,7 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
gpio_free(omap->reset_gpio_port2);
}
- dev_dbg(hcd->self.controller,
- "Clock to USB host has been disabled\n");
+ dev_dbg(omap->dev, "Clock to USB host has been disabled\n");
}
/*-------------------------------------------------------------------------*/
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 18/23] arm: omap: make usb base defines follow trm
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 19/23] usb: host: ehci: ioremap all usb bases Felipe Balbi
2009-02-24 22:42 ` [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions Grazvydas Ignotas
1 sibling, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Use names closer to what TRM says and define each
block separately so we don't have to use magic constants
anylonger.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
arch/arm/mach-omap2/usb-ehci.c | 4 ++--
arch/arm/plat-omap/include/mach/omap34xx.h | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-omap2/usb-ehci.c b/arch/arm/mach-omap2/usb-ehci.c
index 30e1ad6..6c1a46f 100644
--- a/arch/arm/mach-omap2/usb-ehci.c
+++ b/arch/arm/mach-omap2/usb-ehci.c
@@ -30,8 +30,8 @@
static struct resource ehci_resources[] = {
[0] = {
- .start = OMAP34XX_HSUSB_HOST_BASE + 0x800,
- .end = OMAP34XX_HSUSB_HOST_BASE + 0x800 + SZ_1K - 1,
+ .start = OMAP34XX_EHCI_BASE,
+ .end = OMAP34XX_EHCI_BASE + SZ_1K - 1,
.flags = IORESOURCE_MEM,
},
[1] = { /* general IRQ */
diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-omap/include/mach/omap34xx.h
index 27a1e45..53630dc 100644
--- a/arch/arm/plat-omap/include/mach/omap34xx.h
+++ b/arch/arm/plat-omap/include/mach/omap34xx.h
@@ -51,8 +51,10 @@
#define OMAP34XX_IC_BASE 0x48200000
#define OMAP34XX_IVA_INTC_BASE 0x40000000
#define OMAP34XX_HSUSB_OTG_BASE (L4_34XX_BASE + 0xAB000)
-#define OMAP34XX_HSUSB_HOST_BASE (L4_34XX_BASE + 0x64000)
#define OMAP34XX_USBTLL_BASE (L4_34XX_BASE + 0x62000)
+#define OMAP34XX_UHH_CONFIG_BASE (L4_34XX_BASE + 0x64000)
+#define OMAP34XX_OHCI_BASE (L4_34XX_BASE + 0x64400)
+#define OMAP34XX_EHCI_BASE (L4_34XX_BASE + 0x64800)
#define OMAP34XX_SR1_BASE 0x480C9000
#define OMAP34XX_SR2_BASE 0x480CB000
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 19/23] usb: host: ehci: ioremap all usb bases
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 18/23] arm: omap: make usb base defines follow trm Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 20/23] usb: host: ehci: align defines Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi, Tony Lindgren
doing that will allow us to use standarnd __raw_read/write
calls and stop using omap_read/write ones.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
One patch from Tony ensuring register read only after clocks
where on, was melded into this one.
arch/arm/mach-omap2/usb-ehci.c | 20 +++-
drivers/usb/host/ehci-omap.c | 241 +++++++++++++++++++++++-----------------
2 files changed, 155 insertions(+), 106 deletions(-)
diff --git a/arch/arm/mach-omap2/usb-ehci.c b/arch/arm/mach-omap2/usb-ehci.c
index 6c1a46f..7f7b844 100644
--- a/arch/arm/mach-omap2/usb-ehci.c
+++ b/arch/arm/mach-omap2/usb-ehci.c
@@ -29,12 +29,22 @@
#include <mach/usb.h>
static struct resource ehci_resources[] = {
- [0] = {
- .start = OMAP34XX_EHCI_BASE,
- .end = OMAP34XX_EHCI_BASE + SZ_1K - 1,
- .flags = IORESOURCE_MEM,
+ {
+ .start = OMAP34XX_EHCI_BASE,
+ .end = OMAP34XX_EHCI_BASE + SZ_1K - 1,
+ .flags = IORESOURCE_MEM,
},
- [1] = { /* general IRQ */
+ {
+ .start = OMAP34XX_UHH_CONFIG_BASE,
+ .end = OMAP34XX_UHH_CONFIG_BASE + SZ_1K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = OMAP34XX_USBTLL_BASE,
+ .end = OMAP34XX_USBTLL_BASE + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ { /* general IRQ */
.start = INT_34XX_EHCI_IRQ,
.flags = IORESOURCE_IRQ,
}
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index c9305a3..48ced8f 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -38,28 +38,24 @@
#include "../../../arch/arm/mach-omap2/cm-regbits-34xx.h"
/*
- * OMAP USBHOST Register addresses: PHYSICAL ADDRESSES
- * Use omap_readl()/omap_writel() functions
+ * OMAP USBHOST Register addresses: VIRTUAL ADDRESSES
+ * Use ehci_omap_readl()/ehci_omap_writel() functions
*/
-/* USBHOST: TLL, UUH, OHCI, EHCI */
-#define OMAP_USBHOST_BASE (L4_34XX_BASE + 0x60000)
-
/* TLL Register Set */
-#define OMAP_USBHOST_TLL_BASE (OMAP_USBHOST_BASE + 0x2000)
-#define OMAP_USBTLL_REVISION (OMAP_USBHOST_TLL_BASE + 0x00)
-#define OMAP_USBTLL_SYSCONFIG (OMAP_USBHOST_TLL_BASE + 0x10)
+#define OMAP_USBTLL_REVISION (0x00)
+#define OMAP_USBTLL_SYSCONFIG (0x10)
#define OMAP_USBTLL_SYSCONFIG_CACTIVITY (1 << 8)
#define OMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3)
#define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2)
#define OMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1)
#define OMAP_USBTLL_SYSCONFIG_AUTOIDLE (1 << 0)
-#define OMAP_USBTLL_SYSSTATUS (OMAP_USBHOST_TLL_BASE + 0x14)
+#define OMAP_USBTLL_SYSSTATUS (0x14)
#define OMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0)
-#define OMAP_USBTLL_IRQSTATUS (OMAP_USBHOST_TLL_BASE + 0x18)
-#define OMAP_USBTLL_IRQENABLE (OMAP_USBHOST_TLL_BASE + 0x1C)
+#define OMAP_USBTLL_IRQSTATUS (0x18)
+#define OMAP_USBTLL_IRQENABLE (0x1C)
-#define OMAP_TLL_SHARED_CONF (OMAP_USBHOST_TLL_BASE + 0x30)
+#define OMAP_TLL_SHARED_CONF (0x30)
#define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN (1 << 6)
#define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN (1 << 5)
#define OMAP_TLL_SHARED_CONF_USB_DIVRATION (1 << 2)
@@ -67,31 +63,22 @@
#define OMAP_TLL_SHARED_CONF_FCLK_IS_ON (1 << 0)
#define OMAP_TLL_CHANNEL_CONF(num)\
- (OMAP_USBHOST_TLL_BASE + (0x040 + 0x004 * num))
+ (0x040 + 0x004 * num)
#define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF (1 << 11)
#define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10)
#define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE (1 << 9)
#define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE (1 << 8)
#define OMAP_TLL_CHANNEL_CONF_CHANEN (1 << 0)
-#define OMAP_TLL_ULPI_FUNCTION_CTRL(num)\
- (OMAP_USBHOST_TLL_BASE + (0x804 + 0x100 * num))
-#define OMAP_TLL_ULPI_INTERFACE_CTRL(num)\
- (OMAP_USBHOST_TLL_BASE + (0x807 + 0x100 * num))
-#define OMAP_TLL_ULPI_OTG_CTRL(num)\
- (OMAP_USBHOST_TLL_BASE + (0x80A + 0x100 * num))
-#define OMAP_TLL_ULPI_INT_EN_RISE(num)\
- (OMAP_USBHOST_TLL_BASE + (0x80D + 0x100 * num))
-#define OMAP_TLL_ULPI_INT_EN_FALL(num)\
- (OMAP_USBHOST_TLL_BASE + (0x810 + 0x100 * num))
-#define OMAP_TLL_ULPI_INT_STATUS(num)\
- (OMAP_USBHOST_TLL_BASE + (0x813 + 0x100 * num))
-#define OMAP_TLL_ULPI_INT_LATCH(num)\
- (OMAP_USBHOST_TLL_BASE + (0x814 + 0x100 * num))
-#define OMAP_TLL_ULPI_DEBUG(num)\
- (OMAP_USBHOST_TLL_BASE + (0x815 + 0x100 * num))
-#define OMAP_TLL_ULPI_SCRATCH_REGISTER(num)\
- (OMAP_USBHOST_TLL_BASE + (0x816 + 0x100 * num))
+#define OMAP_TLL_ULPI_FUNCTION_CTRL(num) (0x804 + 0x100 * num)
+#define OMAP_TLL_ULPI_INTERFACE_CTRL(num) (0x807 + 0x100 * num)
+#define OMAP_TLL_ULPI_OTG_CTRL(num) (0x80A + 0x100 * num)
+#define OMAP_TLL_ULPI_INT_EN_RISE(num) (0x80D + 0x100 * num)
+#define OMAP_TLL_ULPI_INT_EN_FALL(num) (0x810 + 0x100 * num)
+#define OMAP_TLL_ULPI_INT_STATUS(num) (0x813 + 0x100 * num)
+#define OMAP_TLL_ULPI_INT_LATCH(num) (0x814 + 0x100 * num)
+#define OMAP_TLL_ULPI_DEBUG(num) (0x815 + 0x100 * num)
+#define OMAP_TLL_ULPI_SCRATCH_REGISTER(num) (0x816 + 0x100 * num)
#define OMAP_TLL_CHANNEL_COUNT 3
#define OMAP_TLL_CHANNEL_1_EN_MASK (1 << 1)
@@ -99,9 +86,8 @@
#define OMAP_TLL_CHANNEL_3_EN_MASK (1 << 4)
/* UHH Register Set */
-#define OMAP_USBHOST_UHH_BASE (OMAP_USBHOST_BASE + 0x4000)
-#define OMAP_UHH_REVISION (OMAP_USBHOST_UHH_BASE + 0x00)
-#define OMAP_UHH_SYSCONFIG (OMAP_USBHOST_UHH_BASE + 0x10)
+#define OMAP_UHH_REVISION (0x00)
+#define OMAP_UHH_SYSCONFIG (0x10)
#define OMAP_UHH_SYSCONFIG_MIDLEMODE (1 << 12)
#define OMAP_UHH_SYSCONFIG_CACTIVITY (1 << 8)
#define OMAP_UHH_SYSCONFIG_SIDLEMODE (1 << 3)
@@ -109,19 +95,18 @@
#define OMAP_UHH_SYSCONFIG_SOFTRESET (1 << 1)
#define OMAP_UHH_SYSCONFIG_AUTOIDLE (1 << 0)
-#define OMAP_UHH_SYSSTATUS (OMAP_USBHOST_UHH_BASE + 0x14)
-#define OMAP_UHH_HOSTCONFIG (OMAP_USBHOST_UHH_BASE + 0x40)
+#define OMAP_UHH_SYSSTATUS (0x14)
+#define OMAP_UHH_HOSTCONFIG (0x40)
#define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1 << 0)
#define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN (1 << 2)
#define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN (1 << 3)
#define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN (1 << 4)
#define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN (1 << 5)
-#define OMAP_UHH_DEBUG_CSR (OMAP_USBHOST_UHH_BASE + 0x44)
+#define OMAP_UHH_DEBUG_CSR (0x44)
/* EHCI Register Set */
-#define OMAP_USBHOST_EHCI_BASE (OMAP_USBHOST_BASE + 0x4800)
-#define EHCI_INSNREG05_ULPI (OMAP_USBHOST_EHCI_BASE + 0xA4)
+#define EHCI_INSNREG05_ULPI (0xA4)
#define EHCI_INSNREG05_ULPI_CONTROL_SHIFT 31
#define EHCI_INSNREG05_ULPI_PORTSEL_SHIFT 24
#define EHCI_INSNREG05_ULPI_OPSEL_SHIFT 22
@@ -134,6 +119,28 @@
/*-------------------------------------------------------------------------*/
+static inline void ehci_omap_writel(void __iomem *base, u32 reg, u32 val)
+{
+ __raw_writel(val, base + reg);
+}
+
+static inline u32 ehci_omap_readl(void __iomem *base, u32 reg)
+{
+ return __raw_readl(base + reg);
+}
+
+static inline void ehci_omap_writeb(void __iomem *base, u8 reg, u8 val)
+{
+ __raw_writeb(val, base + reg);
+}
+
+static inline u8 ehci_omap_readb(void __iomem *base, u8 reg)
+{
+ return __raw_readb(base + reg);
+}
+
+/*-------------------------------------------------------------------------*/
+
struct ehci_hcd_omap {
struct ehci_hcd *ehci;
struct device *dev;
@@ -156,6 +163,10 @@ struct ehci_hcd_omap {
/* desired phy_mode: TLL, PHY */
enum ehci_hcd_omap_mode phy_mode;
+
+ void __iomem *uhh_base;
+ void __iomem *tll_base;
+ void __iomem *ehci_base;
};
/* Clock names as per clock framework: May change so keep as #defs */
@@ -173,7 +184,7 @@ static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask)
unsigned reg;
int i;
- reg = omap_readl(OMAP_UHH_HOSTCONFIG);
+ reg = ehci_omap_readl(omap->uhh_base, OMAP_UHH_HOSTCONFIG);
reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS
| OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
| OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
@@ -181,10 +192,10 @@ static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask)
reg &= ~OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN;
/* Use UTMI Ports of TLL */
- omap_writel(reg, OMAP_UHH_HOSTCONFIG);
+ ehci_omap_writel(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg);
/* Ensure bit is set */
- while (!(omap_readl(OMAP_UHH_HOSTCONFIG)
+ while (!(ehci_omap_readl(omap->uhh_base, OMAP_UHH_HOSTCONFIG)
& OMAP_UHH_HOSTCONFIG_ULPI_BYPASS)) {
cpu_relax();
@@ -197,46 +208,41 @@ static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask)
dev_dbg(omap->dev, "Entered UTMI MODE: success\n");
/* Program the 3 TLL channels upfront */
-
for (i = 0; i < OMAP_TLL_CHANNEL_COUNT; i++) {
- reg = omap_readl(OMAP_TLL_CHANNEL_CONF(i));
-
- /* Disable AutoIdle */
- reg &= ~OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE;
- omap_writel(reg, OMAP_TLL_CHANNEL_CONF(i));
-
- /* Disable BitStuffing */
- reg &= ~OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF;
- omap_writel(reg, OMAP_TLL_CHANNEL_CONF(i));
+ reg = ehci_omap_readl(omap->tll_base, OMAP_TLL_CHANNEL_CONF(i));
- /* SDR Mode */
- reg &= ~OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE;
- omap_writel(reg, OMAP_TLL_CHANNEL_CONF(i));
+ /* Disable AutoIdle, BitStuffing and use SDR Mode */
+ reg &= ~(OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE
+ | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF
+ | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE);
+ ehci_omap_writel(omap->tll_base, OMAP_TLL_CHANNEL_CONF(i), reg);
}
/* Program Common TLL register */
- reg = omap_readl(OMAP_TLL_SHARED_CONF);
+ reg = ehci_omap_readl(omap->tll_base, OMAP_TLL_SHARED_CONF);
reg |= (OMAP_TLL_SHARED_CONF_FCLK_IS_ON
| OMAP_TLL_SHARED_CONF_USB_DIVRATION
| OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN);
reg &= ~OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN;
- omap_writel(reg, OMAP_TLL_SHARED_CONF);
+ ehci_omap_writel(omap->tll_base, OMAP_TLL_SHARED_CONF, reg);
/* Enable channels now */
for (i = 0; i < OMAP_TLL_CHANNEL_COUNT; i++) {
- reg = omap_readl(OMAP_TLL_CHANNEL_CONF(i));
+ reg = ehci_omap_readl(omap->tll_base, OMAP_TLL_CHANNEL_CONF(i));
/* Enable only the reg that is needed */
if (!(tll_channel_mask & 1<<i))
continue;
reg |= OMAP_TLL_CHANNEL_CONF_CHANEN;
- omap_writel(reg, OMAP_TLL_CHANNEL_CONF(i));
+ ehci_omap_writel(omap->tll_base, OMAP_TLL_CHANNEL_CONF(i), reg);
- omap_writeb(0xbe, OMAP_TLL_ULPI_SCRATCH_REGISTER(i));
+ ehci_omap_writeb(omap->tll_base,
+ OMAP_TLL_ULPI_SCRATCH_REGISTER(i), 0xbe);
dev_dbg(omap->dev, "ULPI_SCRATCH_REG[ch=%d]= 0x%02x\n",
- i+1, omap_readb(OMAP_TLL_ULPI_SCRATCH_REGISTER(i)));
+ i+1, ehci_omap_readb(omap->tll_base,
+ OMAP_TLL_ULPI_SCRATCH_REGISTER(i)));
}
}
@@ -319,7 +325,6 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
}
clk_enable(omap->usbhost1_48m_fck);
-
if (omap->phy_reset) {
/* Refer: ISSUE1 */
gpio_request(omap->reset_gpio_port1, "USB1 PHY reset");
@@ -362,11 +367,11 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
}
/* perform TLL soft reset, and wait until reset is complete */
- omap_writel(1 << OMAP_USBTLL_SYSCONFIG_SOFTRESET,
- OMAP_USBTLL_SYSCONFIG);
+ ehci_omap_writel(omap->tll_base, OMAP_USBTLL_SYSCONFIG,
+ OMAP_USBTLL_SYSCONFIG_SOFTRESET);
/* Wait for TLL reset to complete */
- while (!(omap_readl(OMAP_USBTLL_SYSSTATUS)
+ while (!(ehci_omap_readl(omap->tll_base, OMAP_USBTLL_SYSSTATUS)
& (1 << OMAP_USBTLL_SYSSTATUS_RESETDONE))) {
cpu_relax();
@@ -380,24 +385,24 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
dev_dbg(omap->dev, "TLL RESET DONE\n");
/* (1<<3) = no idle mode only for initial debugging */
- omap_writel(OMAP_USBTLL_SYSCONFIG_ENAWAKEUP |
+ ehci_omap_writel(omap->tll_base, OMAP_USBTLL_SYSCONFIG,
+ OMAP_USBTLL_SYSCONFIG_ENAWAKEUP |
OMAP_USBTLL_SYSCONFIG_SIDLEMODE |
- OMAP_USBTLL_SYSCONFIG_CACTIVITY,
- OMAP_USBTLL_SYSCONFIG);
+ OMAP_USBTLL_SYSCONFIG_CACTIVITY);
/* Put UHH in NoIdle/NoStandby mode */
- reg = omap_readl(OMAP_UHH_SYSCONFIG);
+ reg = ehci_omap_readl(omap->uhh_base, OMAP_UHH_SYSCONFIG);
reg |= (OMAP_UHH_SYSCONFIG_ENAWAKEUP
| OMAP_UHH_SYSCONFIG_SIDLEMODE
| OMAP_UHH_SYSCONFIG_CACTIVITY
| OMAP_UHH_SYSCONFIG_MIDLEMODE);
reg &= ~OMAP_UHH_SYSCONFIG_AUTOIDLE;
- omap_writel(reg, OMAP_UHH_SYSCONFIG);
+ ehci_omap_writel(omap->uhh_base, OMAP_UHH_SYSCONFIG, reg);
if (omap->phy_mode == EHCI_HCD_OMAP_MODE_PHY) {
- reg = omap_readl(OMAP_UHH_HOSTCONFIG);
+ reg = ehci_omap_readl(omap->uhh_base, OMAP_UHH_HOSTCONFIG);
reg |= (OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
| OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
@@ -406,10 +411,10 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
| OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN);
/* Bypass the TLL module for PHY mode operation */
- omap_writel(reg, OMAP_UHH_HOSTCONFIG);
+ ehci_omap_writel(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg);
/* Ensure that BYPASS is set */
- while (omap_readl(OMAP_UHH_HOSTCONFIG)
+ while (ehci_omap_readl(omap->uhh_base, OMAP_UHH_HOSTCONFIG)
& (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS)) {
cpu_relax();
@@ -455,14 +460,18 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
/* use Port1 VBUS to charge externally Port2:
* So for PHY mode operation use Port2 only
*/
- omap_writel((0xa << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |/* OTG ctrl reg*/
- (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) |/* Write */
- (1 << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) |/* Port1 */
- (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |/* Start */
- (0x26),
- EHCI_INSNREG05_ULPI);
-
- while (!(omap_readl(EHCI_INSNREG05_ULPI)
+ ehci_omap_writel(omap->ehci_base, EHCI_INSNREG05_ULPI,
+ /* OTG ctrl reg*/
+ (0xa << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |
+ /* Write */
+ (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) |
+ /* Port1 */
+ (1 << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) |
+ /* Start */
+ (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |
+ (0x26));
+
+ while (!(ehci_omap_readl(omap->ehci_base, EHCI_INSNREG05_ULPI)
& (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) {
cpu_relax();
@@ -517,8 +526,10 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
dev_dbg(omap->dev, "stopping TI EHCI USB Controller\n");
/* Reset OMAP modules for insmod/rmmod to work */
- omap_writel((1 << 1), OMAP_UHH_SYSCONFIG);
- while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 0))) {
+ ehci_omap_writel(omap->uhh_base, OMAP_UHH_SYSCONFIG,
+ OMAP_UHH_SYSCONFIG_SOFTRESET);
+ while (!(ehci_omap_readl(omap->uhh_base, OMAP_UHH_SYSSTATUS)
+ & (1 << 0))) {
cpu_relax();
if (time_after(timeout, jiffies)) {
@@ -527,7 +538,8 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
}
}
- while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 1))) {
+ while (!(ehci_omap_readl(omap->uhh_base, OMAP_UHH_SYSSTATUS)
+ & (1 << 1))) {
cpu_relax();
if (time_after(timeout, jiffies)) {
@@ -536,7 +548,8 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
}
}
- while (!(omap_readl(OMAP_UHH_SYSSTATUS) & (1 << 2))) {
+ while (!(ehci_omap_readl(omap->uhh_base, OMAP_UHH_SYSSTATUS)
+ & (1 << 2))) {
cpu_relax();
if (time_after(timeout, jiffies)) {
@@ -545,10 +558,11 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
}
}
dev_dbg(omap->dev, "UHH RESET DONE OMAP_UHH_SYSSTATUS %x\n",
- omap_readl(OMAP_UHH_SYSSTATUS));
+ ehci_omap_readl(omap->uhh_base, OMAP_UHH_SYSSTATUS));
- omap_writel((1 << 1), OMAP_USBTLL_SYSCONFIG);
- while (!(omap_readl(OMAP_USBTLL_SYSSTATUS) & (1 << 0))) {
+ ehci_omap_writel(omap->tll_base, OMAP_USBTLL_SYSCONFIG, (1 << 1));
+ while (!(ehci_omap_readl(omap->tll_base, OMAP_USBTLL_SYSSTATUS)
+ & (1 << 0))) {
cpu_relax();
if (time_after(timeout, jiffies)) {
@@ -652,26 +666,43 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
omap->ehci->caps = hcd->regs;
omap->ehci->sbrn = 0x20;
- ret = omap_start_ehc(omap, hcd);
- if (ret) {
- dev_dbg(&pdev->dev, "failed to start ehci\n");
- goto err_start;
- }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- hcd->rsrc_start = 0;
- hcd->rsrc_len = 0;
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
if (!hcd->regs) {
- dev_err(&pdev->dev, "ioremap failed\n");
+ dev_err(&pdev->dev, "EHCI ioremap failed\n");
ret = -ENOMEM;
goto err_ioremap;
}
+ /* we know this is the memory we want, no need to ioremap again */
+ omap->ehci_base = hcd->regs;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ omap->uhh_base = ioremap(res->start, resource_size(res));
+ if (!omap->uhh_base) {
+ dev_err(&pdev->dev, "UHH ioremap failed\n");
+ ret = -ENOMEM;
+ goto err_uhh_ioremap;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+ omap->tll_base = ioremap(res->start, resource_size(res));
+ if (!omap->tll_base) {
+ dev_err(&pdev->dev, "TLL ioremap failed\n");
+ ret = -ENOMEM;
+ goto err_tll_ioremap;
+ }
+
+ ret = omap_start_ehc(omap, hcd);
+ if (ret) {
+ dev_dbg(&pdev->dev, "failed to start ehci\n");
+ goto err_start;
+ }
+
omap->ehci->regs = hcd->regs
+ HC_LENGTH(readl(&omap->ehci->caps->hc_capbase));
@@ -691,12 +722,18 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
return 0;
err_add_hcd:
- iounmap(hcd->regs);
-
-err_ioremap:
omap_stop_ehc(omap, hcd);
err_start:
+ iounmap(omap->tll_base);
+
+err_tll_ioremap:
+ iounmap(omap->uhh_base);
+
+err_uhh_ioremap:
+ iounmap(hcd->regs);
+
+err_ioremap:
usb_put_hcd(hcd);
err_create_hcd:
@@ -722,8 +759,10 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
struct usb_hcd *hcd = ehci_to_hcd(omap->ehci);
usb_remove_hcd(hcd);
- iounmap(hcd->regs);
omap_stop_ehc(omap, hcd);
+ iounmap(hcd->regs);
+ iounmap(omap->tll_base);
+ iounmap(omap->uhh_base);
usb_put_hcd(hcd);
return 0;
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 20/23] usb: host: ehci: align defines
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 19/23] usb: host: ehci: ioremap all usb bases Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 21/23] usb: host: ehci: don't ensure register write Felipe Balbi
0 siblings, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Just making it better for my bad eyes. Style only, no
functional changes.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 114 ++++++++++++++++++++---------------------
1 files changed, 56 insertions(+), 58 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 48ced8f..c2b592f 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -43,32 +43,33 @@
*/
/* TLL Register Set */
-#define OMAP_USBTLL_REVISION (0x00)
-#define OMAP_USBTLL_SYSCONFIG (0x10)
- #define OMAP_USBTLL_SYSCONFIG_CACTIVITY (1 << 8)
- #define OMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3)
- #define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2)
- #define OMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1)
- #define OMAP_USBTLL_SYSCONFIG_AUTOIDLE (1 << 0)
-#define OMAP_USBTLL_SYSSTATUS (0x14)
- #define OMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0)
-#define OMAP_USBTLL_IRQSTATUS (0x18)
-#define OMAP_USBTLL_IRQENABLE (0x1C)
-
-#define OMAP_TLL_SHARED_CONF (0x30)
- #define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN (1 << 6)
- #define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN (1 << 5)
- #define OMAP_TLL_SHARED_CONF_USB_DIVRATION (1 << 2)
- #define OMAP_TLL_SHARED_CONF_FCLK_REQ (1 << 1)
- #define OMAP_TLL_SHARED_CONF_FCLK_IS_ON (1 << 0)
-
-#define OMAP_TLL_CHANNEL_CONF(num)\
- (0x040 + 0x004 * num)
- #define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF (1 << 11)
- #define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10)
- #define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE (1 << 9)
- #define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE (1 << 8)
- #define OMAP_TLL_CHANNEL_CONF_CHANEN (1 << 0)
+#define OMAP_USBTLL_REVISION (0x00)
+#define OMAP_USBTLL_SYSCONFIG (0x10)
+#define OMAP_USBTLL_SYSCONFIG_CACTIVITY (1 << 8)
+#define OMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3)
+#define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2)
+#define OMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1)
+#define OMAP_USBTLL_SYSCONFIG_AUTOIDLE (1 << 0)
+
+#define OMAP_USBTLL_SYSSTATUS (0x14)
+#define OMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0)
+
+#define OMAP_USBTLL_IRQSTATUS (0x18)
+#define OMAP_USBTLL_IRQENABLE (0x1C)
+
+#define OMAP_TLL_SHARED_CONF (0x30)
+#define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN (1 << 6)
+#define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN (1 << 5)
+#define OMAP_TLL_SHARED_CONF_USB_DIVRATION (1 << 2)
+#define OMAP_TLL_SHARED_CONF_FCLK_REQ (1 << 1)
+#define OMAP_TLL_SHARED_CONF_FCLK_IS_ON (1 << 0)
+
+#define OMAP_TLL_CHANNEL_CONF(num) (0x040 + 0x004 * num)
+#define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF (1 << 11)
+#define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10)
+#define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE (1 << 9)
+#define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE (1 << 8)
+#define OMAP_TLL_CHANNEL_CONF_CHANEN (1 << 0)
#define OMAP_TLL_ULPI_FUNCTION_CTRL(num) (0x804 + 0x100 * num)
#define OMAP_TLL_ULPI_INTERFACE_CTRL(num) (0x807 + 0x100 * num)
@@ -80,42 +81,39 @@
#define OMAP_TLL_ULPI_DEBUG(num) (0x815 + 0x100 * num)
#define OMAP_TLL_ULPI_SCRATCH_REGISTER(num) (0x816 + 0x100 * num)
-#define OMAP_TLL_CHANNEL_COUNT 3
- #define OMAP_TLL_CHANNEL_1_EN_MASK (1 << 1)
- #define OMAP_TLL_CHANNEL_2_EN_MASK (1 << 2)
- #define OMAP_TLL_CHANNEL_3_EN_MASK (1 << 4)
+#define OMAP_TLL_CHANNEL_COUNT 3
+#define OMAP_TLL_CHANNEL_1_EN_MASK (1 << 1)
+#define OMAP_TLL_CHANNEL_2_EN_MASK (1 << 2)
+#define OMAP_TLL_CHANNEL_3_EN_MASK (1 << 4)
/* UHH Register Set */
-#define OMAP_UHH_REVISION (0x00)
-#define OMAP_UHH_SYSCONFIG (0x10)
- #define OMAP_UHH_SYSCONFIG_MIDLEMODE (1 << 12)
- #define OMAP_UHH_SYSCONFIG_CACTIVITY (1 << 8)
- #define OMAP_UHH_SYSCONFIG_SIDLEMODE (1 << 3)
- #define OMAP_UHH_SYSCONFIG_ENAWAKEUP (1 << 2)
- #define OMAP_UHH_SYSCONFIG_SOFTRESET (1 << 1)
- #define OMAP_UHH_SYSCONFIG_AUTOIDLE (1 << 0)
-
-#define OMAP_UHH_SYSSTATUS (0x14)
-#define OMAP_UHH_HOSTCONFIG (0x40)
- #define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1 << 0)
- #define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN (1 << 2)
- #define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN (1 << 3)
- #define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN (1 << 4)
- #define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN (1 << 5)
-
-#define OMAP_UHH_DEBUG_CSR (0x44)
+#define OMAP_UHH_REVISION (0x00)
+#define OMAP_UHH_SYSCONFIG (0x10)
+#define OMAP_UHH_SYSCONFIG_MIDLEMODE (1 << 12)
+#define OMAP_UHH_SYSCONFIG_CACTIVITY (1 << 8)
+#define OMAP_UHH_SYSCONFIG_SIDLEMODE (1 << 3)
+#define OMAP_UHH_SYSCONFIG_ENAWAKEUP (1 << 2)
+#define OMAP_UHH_SYSCONFIG_SOFTRESET (1 << 1)
+#define OMAP_UHH_SYSCONFIG_AUTOIDLE (1 << 0)
+
+#define OMAP_UHH_SYSSTATUS (0x14)
+#define OMAP_UHH_HOSTCONFIG (0x40)
+#define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1 << 0)
+#define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN (1 << 2)
+#define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN (1 << 3)
+#define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN (1 << 4)
+#define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN (1 << 5)
+
+#define OMAP_UHH_DEBUG_CSR (0x44)
/* EHCI Register Set */
-#define EHCI_INSNREG05_ULPI (0xA4)
- #define EHCI_INSNREG05_ULPI_CONTROL_SHIFT 31
- #define EHCI_INSNREG05_ULPI_PORTSEL_SHIFT 24
- #define EHCI_INSNREG05_ULPI_OPSEL_SHIFT 22
- #define EHCI_INSNREG05_ULPI_REGADD_SHIFT 16
- #define EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT 8
- #define EHCI_INSNREG05_ULPI_WRDATA_SHIFT 0
-
-/* OHCI Register Set */
-#define OMAP_USBHOST_OHCI_BASE (OMAP_USBHOST_BASE + 0x4400)
+#define EHCI_INSNREG05_ULPI (0xA4)
+#define EHCI_INSNREG05_ULPI_CONTROL_SHIFT 31
+#define EHCI_INSNREG05_ULPI_PORTSEL_SHIFT 24
+#define EHCI_INSNREG05_ULPI_OPSEL_SHIFT 22
+#define EHCI_INSNREG05_ULPI_REGADD_SHIFT 16
+#define EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT 8
+#define EHCI_INSNREG05_ULPI_WRDATA_SHIFT 0
/*-------------------------------------------------------------------------*/
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 21/23] usb: host: ehci: don't ensure register write
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 20/23] usb: host: ehci: align defines Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 22/23] ehci-omap: Remove defines for clock names Felipe Balbi
2009-02-23 19:08 ` [rft/rfc/patch-v2.6.29-rc5+ 21/23] usb: host: ehci: don't ensure register write Felipe Balbi
0 siblings, 2 replies; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
There's no reason to think register writes would fail so remove
all unnecessary while() loops keeping only the ones checking
whether reset is done or not.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 185 ++++++++++++------------------------------
1 files changed, 52 insertions(+), 133 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index c2b592f..e413601 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -7,6 +7,9 @@
* Copyright (C) 2007-2008 Texas Instruments, Inc.
* Author: Vikram Pandita <vikram.pandita@ti.com>
*
+ * Copyright (C) 2009 Nokia Corporation
+ * Contact: Felipe Balbi <felipe.balbi@nokia.com>
+ *
* Based on "ehci-fsl.c" and "ehci-au1xxx.c" ehci glue layers
*
* This program is free software; you can redistribute it and/or modify
@@ -28,15 +31,8 @@
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/gpio.h>
-
-/* platform_data lives here */
#include <mach/usb.h>
-/* FIXME remove platform-specific code */
-#include <mach/hardware.h>
-#include "../../../arch/arm/mach-omap2/cm.h"
-#include "../../../arch/arm/mach-omap2/cm-regbits-34xx.h"
-
/*
* OMAP USBHOST Register addresses: VIRTUAL ADDRESSES
* Use ehci_omap_readl()/ehci_omap_writel() functions
@@ -178,7 +174,6 @@ struct ehci_hcd_omap {
static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask)
{
- unsigned long timeout = jiffies + msecs_to_jiffies(100);
unsigned reg;
int i;
@@ -192,19 +187,6 @@ static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask)
/* Use UTMI Ports of TLL */
ehci_omap_writel(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg);
- /* Ensure bit is set */
- while (!(ehci_omap_readl(omap->uhh_base, OMAP_UHH_HOSTCONFIG)
- & OMAP_UHH_HOSTCONFIG_ULPI_BYPASS)) {
- cpu_relax();
-
- if (time_after(timeout, jiffies)) {
- dev_dbg(omap->dev, "operation timed out\n");
- return;
- }
- }
-
- dev_dbg(omap->dev, "Entered UTMI MODE: success\n");
-
/* Program the 3 TLL channels upfront */
for (i = 0; i < OMAP_TLL_CHANNEL_COUNT; i++) {
reg = ehci_omap_readl(omap->tll_base, OMAP_TLL_CHANNEL_CONF(i));
@@ -246,6 +228,8 @@ static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask)
/*-------------------------------------------------------------------------*/
+#include "../../../arch/arm/mach-omap2/cm-regbits-34xx.h"
+
/* omap_start_ehc
* - Start the TI USBHOST controller
*/
@@ -274,32 +258,11 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
PLL_MOD, OMAP3430ES2_CM_CLKEN2);
while (!(cm_read_mod_reg(PLL_MOD, CM_IDLEST2) &
- OMAP3430ES2_ST_PERIPH2_CLK_MASK)) {
+ OMAP3430ES2_ST_PERIPH2_CLK_MASK))
dev_dbg(omap->dev, "idlest2 = 0x%x\n",
cm_read_mod_reg(PLL_MOD, CM_IDLEST2));
-
- if (time_after(timeout, jiffies)) {
- dev_dbg(omap->dev, "operation timed out\n");
- ret = -EINVAL;
- goto err_idlest2;
- }
- }
/* End DPLL5 programming */
- /* PRCM settings for USBHOST:
- * Interface clk un-related to domain transition
- */
- cm_write_mod_reg(0 << OMAP3430ES2_AUTO_USBHOST_SHIFT,
- OMAP3430ES2_USBHOST_MOD, CM_AUTOIDLE);
-
- /* Disable sleep dependency with MPU and IVA */
- cm_write_mod_reg((0 << OMAP3430ES2_EN_MPU_SHIFT) |
- (0 << OMAP3430ES2_EN_IVA2_SHIFT),
- OMAP3430ES2_USBHOST_MOD, OMAP3430_CM_SLEEPDEP);
-
- /* Disable Automatic transition of clock */
- cm_write_mod_reg(0 << OMAP3430ES2_CLKTRCTRL_USBHOST_SHIFT,
- OMAP3430ES2_USBHOST_MOD, CM_CLKSTCTRL);
/* Enable Clocks for USBHOST */
omap->usbhost_ick = clk_get(omap->dev, USBHOST_ICKL);
@@ -348,22 +311,6 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
}
clk_enable(omap->usbtll_ick);
- /* Disable Auto Idle of USBTLL */
- cm_write_mod_reg((0 << OMAP3430ES2_AUTO_USBTLL),
- CORE_MOD, CM_AUTOIDLE3);
-
- /* Wait for TLL to be Active */
- while ((cm_read_mod_reg(CORE_MOD, OMAP2430_CM_IDLEST3)
- & (0 << OMAP3430ES2_ST_USBTLL_SHIFT))) {
- cpu_relax();
-
- if (time_after(timeout, jiffies)) {
- dev_dbg(omap->dev, "operation timed out\n");
- ret = -EINVAL;
- goto err_idlest3;
- }
- }
-
/* perform TLL soft reset, and wait until reset is complete */
ehci_omap_writel(omap->tll_base, OMAP_USBTLL_SYSCONFIG,
OMAP_USBTLL_SYSCONFIG_SOFTRESET);
@@ -410,20 +357,6 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
/* Bypass the TLL module for PHY mode operation */
ehci_omap_writel(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg);
-
- /* Ensure that BYPASS is set */
- while (ehci_omap_readl(omap->uhh_base, OMAP_UHH_HOSTCONFIG)
- & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS)) {
- cpu_relax();
-
- if (time_after(timeout, jiffies)) {
- dev_dbg(omap->dev,
- "operation timed out\n");
- ret = -EINVAL;
- goto err_ulpi_bypass;
- }
- }
-
dev_dbg(omap->dev, "Entered ULPI PHY MODE: success\n");
} else if (omap->phy_mode == EHCI_HCD_OMAP_MODE_TLL) {
@@ -468,61 +401,8 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
/* Start */
(1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |
(0x26));
-
- while (!(ehci_omap_readl(omap->ehci_base, EHCI_INSNREG05_ULPI)
- & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) {
- cpu_relax();
-
- if (time_after(timeout, jiffies)) {
- dev_dbg(omap->dev, "operation timed out\n");
- ret = -EINVAL;
- goto err_ulpi_control;
- }
- }
- }
-
- return 0;
-
-err_ulpi_control:
-err_unknown_mode:
-err_ulpi_bypass:
-err_sys_status:
-err_idlest3:
- clk_disable(omap->usbtll_ick);
- clk_put(omap->usbtll_ick);
-
-err_tll_ick:
- clk_disable(omap->usbtll_fck);
- clk_put(omap->usbtll_fck);
-
-err_tll_fck:
- clk_disable(omap->usbhost1_48m_fck);
- clk_put(omap->usbhost1_48m_fck);
-
- if (omap->phy_reset) {
- gpio_free(omap->reset_gpio_port1);
- gpio_free(omap->reset_gpio_port2);
}
-err_host_48m_fck:
- clk_disable(omap->usbhost2_120m_fck);
- clk_put(omap->usbhost2_120m_fck);
-
-err_host_120m_fck:
- clk_disable(omap->usbhost_ick);
- clk_put(omap->usbhost_ick);
-
-err_host_ick:
-err_idlest2:
- return ret;
-}
-
-static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
-{
- unsigned long timeout = jiffies + msecs_to_jiffies(100);
-
- dev_dbg(omap->dev, "stopping TI EHCI USB Controller\n");
-
/* Reset OMAP modules for insmod/rmmod to work */
ehci_omap_writel(omap->uhh_base, OMAP_UHH_SYSCONFIG,
OMAP_UHH_SYSCONFIG_SOFTRESET);
@@ -532,7 +412,8 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
if (time_after(timeout, jiffies)) {
dev_dbg(omap->dev, "operation timed out\n");
- return;
+ ret = -ETIMEDOUT;
+ goto err_timeout;
}
}
@@ -542,7 +423,8 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
if (time_after(timeout, jiffies)) {
dev_dbg(omap->dev, "operation timed out\n");
- return;
+ ret = -ETIMEDOUT;
+ goto err_timeout;
}
}
@@ -552,11 +434,10 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
if (time_after(timeout, jiffies)) {
dev_dbg(omap->dev, "operation timed out\n");
- return;
+ ret = -ETIMEDOUT;
+ goto err_timeout;
}
}
- dev_dbg(omap->dev, "UHH RESET DONE OMAP_UHH_SYSSTATUS %x\n",
- ehci_omap_readl(omap->uhh_base, OMAP_UHH_SYSSTATUS));
ehci_omap_writel(omap->tll_base, OMAP_USBTLL_SYSCONFIG, (1 << 1));
while (!(ehci_omap_readl(omap->tll_base, OMAP_USBTLL_SYSSTATUS)
@@ -565,10 +446,47 @@ static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
if (time_after(timeout, jiffies)) {
dev_dbg(omap->dev, "operation timed out\n");
- return;
+ ret = -ETIMEDOUT;
+ goto err_timeout;
}
}
- dev_dbg(omap->dev, "TLL RESET DONE\n");
+
+ return 0;
+
+err_timeout:
+err_unknown_mode:
+err_sys_status:
+ clk_disable(omap->usbtll_ick);
+ clk_put(omap->usbtll_ick);
+
+err_tll_ick:
+ clk_disable(omap->usbtll_fck);
+ clk_put(omap->usbtll_fck);
+
+err_tll_fck:
+ clk_disable(omap->usbhost1_48m_fck);
+ clk_put(omap->usbhost1_48m_fck);
+
+ if (omap->phy_reset) {
+ gpio_free(omap->reset_gpio_port1);
+ gpio_free(omap->reset_gpio_port2);
+ }
+
+err_host_48m_fck:
+ clk_disable(omap->usbhost2_120m_fck);
+ clk_put(omap->usbhost2_120m_fck);
+
+err_host_120m_fck:
+ clk_disable(omap->usbhost_ick);
+ clk_put(omap->usbhost_ick);
+
+err_host_ick:
+ return ret;
+}
+
+static void omap_stop_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
+{
+ dev_dbg(omap->dev, "stopping TI EHCI USB Controller\n");
if (omap->usbtll_fck != NULL) {
clk_disable(omap->usbtll_fck);
@@ -821,4 +739,5 @@ static const struct hc_driver ehci_omap_hc_driver = {
MODULE_ALIAS("platform:omap-ehci");
MODULE_AUTHOR("Texas Instruments, Inc.");
+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 22/23] ehci-omap: Remove defines for clock names
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 21/23] usb: host: ehci: don't ensure register write Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 23/23] usb: host: ehci: add few comments and todo Felipe Balbi
2009-02-23 19:08 ` [rft/rfc/patch-v2.6.29-rc5+ 21/23] usb: host: ehci: don't ensure register write Felipe Balbi
1 sibling, 1 reply; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Tony Lindgren
From: Tony Lindgren <tony@atomide.com>
This just makes it harder to figure out the clock names
when reading the code. If the clock change, they should
get set dynamically.
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/usb/host/ehci-omap.c | 17 +++++------------
1 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index e413601..ebfed95 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -163,13 +163,6 @@ struct ehci_hcd_omap {
void __iomem *ehci_base;
};
-/* Clock names as per clock framework: May change so keep as #defs */
-#define USBHOST_ICKL "usbhost_ick"
-#define USBHOST_120M_FCLK "usbhost_120m_fck"
-#define USBHOST_48M_FCLK "usbhost_48m_fck"
-#define USBHOST_TLL_ICKL "usbtll_ick"
-#define USBHOST_TLL_FCLK "usbtll_fck"
-
/*-------------------------------------------------------------------------*/
static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask)
@@ -265,21 +258,21 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
/* Enable Clocks for USBHOST */
- omap->usbhost_ick = clk_get(omap->dev, USBHOST_ICKL);
+ omap->usbhost_ick = clk_get(omap->dev, "usbhost_ick");
if (IS_ERR(omap->usbhost_ick)) {
ret = PTR_ERR(omap->usbhost_ick);
goto err_host_ick;
}
clk_enable(omap->usbhost_ick);
- omap->usbhost2_120m_fck = clk_get(omap->dev, USBHOST_120M_FCLK);
+ omap->usbhost2_120m_fck = clk_get(omap->dev, "usbhost_120m_fck");
if (IS_ERR(omap->usbhost2_120m_fck)) {
ret = PTR_ERR(omap->usbhost2_120m_fck);
goto err_host_120m_fck;
}
clk_enable(omap->usbhost2_120m_fck);
- omap->usbhost1_48m_fck = clk_get(omap->dev, USBHOST_48M_FCLK);
+ omap->usbhost1_48m_fck = clk_get(omap->dev, "usbhost_48m_fck");
if (IS_ERR(omap->usbhost1_48m_fck)) {
ret = PTR_ERR(omap->usbhost1_48m_fck);
goto err_host_48m_fck;
@@ -297,14 +290,14 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
}
/* Configure TLL for 60Mhz clk for ULPI */
- omap->usbtll_fck = clk_get(omap->dev, USBHOST_TLL_FCLK);
+ omap->usbtll_fck = clk_get(omap->dev, "usbtll_fck");
if (IS_ERR(omap->usbtll_fck)) {
ret = PTR_ERR(omap->usbtll_fck);
goto err_tll_fck;
}
clk_enable(omap->usbtll_fck);
- omap->usbtll_ick = clk_get(omap->dev, USBHOST_TLL_ICKL);
+ omap->usbtll_ick = clk_get(omap->dev, "usbtll_ick");
if (IS_ERR(omap->usbtll_ick)) {
ret = PTR_ERR(omap->usbtll_ick);
goto err_tll_ick;
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [rft/rfc/patch-v2.6.29-rc5+ 23/23] usb: host: ehci: add few comments and todo
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 22/23] ehci-omap: Remove defines for clock names Felipe Balbi
@ 2009-02-23 18:55 ` Felipe Balbi
0 siblings, 0 replies; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 18:55 UTC (permalink / raw)
To: linux-omap; +Cc: Steve Sakoman, Anand Gadiyar, Felipe Balbi
Still a few stuff to be done with this driver, so add TODO
for us to keep track of what has to be done still.
Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/usb/host/ehci-omap.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index ebfed95..ad2a353 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -26,6 +26,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
+ * TODO (last updated Feb 23rd, 2009):
+ * - add kernel-doc
+ * - enable AUTOIDLE
+ * - move DPLL5 programming to clock fw
+ * - add suspend/resume
+ * - move workarounds to board-files
+ * - differentiate between ES2.x and ES3.x
+ * - make it enumerate devices
*/
#include <linux/platform_device.h>
@@ -145,6 +153,15 @@ struct ehci_hcd_omap {
struct clk *usbtll_fck;
struct clk *usbtll_ick;
+ /* FIXME the following two workarounds are
+ * board specific not silicon-specific so these
+ * should be moved to board-file instead.
+ *
+ * Maybe someone from TI will know better which
+ * board is affected and needs the workarounds
+ * to be applied
+ */
+
/* gpio for resetting phy */
int reset_gpio_port1;
int reset_gpio_port2;
--
1.6.1.3
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [rft/rfc/patch-v2.6.29-rc5+ 21/23] usb: host: ehci: don't ensure register write
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 21/23] usb: host: ehci: don't ensure register write Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 22/23] ehci-omap: Remove defines for clock names Felipe Balbi
@ 2009-02-23 19:08 ` Felipe Balbi
1 sibling, 0 replies; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 19:08 UTC (permalink / raw)
To: Felipe Balbi; +Cc: linux-omap, Steve Sakoman, Anand Gadiyar, paul
On Mon, Feb 23, 2009 at 08:55:33PM +0200, Felipe Balbi wrote:
> +#include "../../../arch/arm/mach-omap2/cm-regbits-34xx.h"
> +
> /* omap_start_ehc
> * - Start the TI USBHOST controller
> */
> @@ -274,32 +258,11 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
> PLL_MOD, OMAP3430ES2_CM_CLKEN2);
>
> while (!(cm_read_mod_reg(PLL_MOD, CM_IDLEST2) &
> - OMAP3430ES2_ST_PERIPH2_CLK_MASK)) {
> + OMAP3430ES2_ST_PERIPH2_CLK_MASK))
> dev_dbg(omap->dev, "idlest2 = 0x%x\n",
> cm_read_mod_reg(PLL_MOD, CM_IDLEST2));
> -
> - if (time_after(timeout, jiffies)) {
> - dev_dbg(omap->dev, "operation timed out\n");
> - ret = -EINVAL;
> - goto err_idlest2;
> - }
> - }
> /* End DPLL5 programming */
Hi Paul, could you look at how could we move dpll5 programming to clk
fw? This driver shouldn't have such code. Also, I guess this programming
is not right since I hear this driver doesn't enumerate anything.
--
balbi
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series
2009-02-23 18:55 [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 01/23] usb: host: ehci: make checkpatch.pl happy with ehci-omap Felipe Balbi
@ 2009-02-23 19:32 ` Felipe Balbi
2009-04-27 9:18 ` Grazvydas Ignotas
2 siblings, 0 replies; 33+ messages in thread
From: Felipe Balbi @ 2009-02-23 19:32 UTC (permalink / raw)
To: Felipe Balbi; +Cc: linux-omap, Steve Sakoman, Anand Gadiyar
On Mon, Feb 23, 2009 at 08:55:12PM +0200, Felipe Balbi wrote:
> Hi all,
>
> Please give the following patches a good test. I don't have
> hw to test them so any comments will be really welcome.
>
> We still have lots to do before getting this driver upstream,
> let's try to keep track of our TODO list and get this driver in
> mainline for 2.6.31 merge window (2.6.30 is too close already).
>
> Let's not try to push this driver until ES2.x and ES3.x are fully
> supported, that will probably have to be done by an omap_rev
> check in ehci-omap driver, also, this driver doesn't really
> enumerate any attached devices, but that's old problem as Tony
> told me off list.
>
> Anyways, I guess this driver is finally walking. Me and Anand (and anyone
> interested) will be discussing how to get EHCI and OHCI working fine, I'm
> guessing we won't have really big issues with OHCI but you never know.
>
> Again, please give it a good test, see if you don't have any clock issues,
> NULL pointers, check if the error path is really fine, see if VBUS turns on
> or not, as I said, *I HAVE NO HW TO TEST THESE*
>
> thanks in advance for those who will read/test/comment these patches
btw, rebase version of these patches are at:
git://gitorious.org/musb/mainline.git branch ehci
--
balbi
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series
2009-02-23 18:52 Felipe Balbi
@ 2009-02-24 22:13 ` Grazvydas Ignotas
0 siblings, 0 replies; 33+ messages in thread
From: Grazvydas Ignotas @ 2009-02-24 22:13 UTC (permalink / raw)
To: Felipe Balbi
Cc: linux-omap, Steve Sakoman, Anand Gadiyar, Syed Mohammed Khasim
hi,
On Mon, Feb 23, 2009 at 8:52 PM, Felipe Balbi <me@felipebalbi.com> wrote:
> Hi all,
>
> Please give the following patches a good test. I don't have
> hw to test them so any comments will be really welcome.
>
> We still have lots to do before getting this driver upstream,
> let's try to keep track of our TODO list and get this driver in
> mainline for 2.6.31 merge window (2.6.30 is too close already).
>
> Let's not try to push this driver until ES2.x and ES3.x are fully
> supported, that will probably have to be done by an omap_rev
> check in ehci-omap driver, also, this driver doesn't really
> enumerate any attached devices, but that's old problem as Tony
> told me off list.
It enumerates for me on current l-o head if I define
EXT_PHY_RESET_GPIO_PORT1 correctly in host-ehci.c. However it doesn't
work with your patches applied, it looks like you are using
time_after() wrong:
if (time_after(timeout, jiffies)) {
dev_dbg(omap->dev, "operation timed out\n");
ret = -EINVAL;
goto err_sys_status;
}
* time_after(a,b) returns true if the time a is after time b.
[ 15.280487] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 15.287139] ehci_hcd: block sizes: qh 128 qtd 96 itd 160 sitd 96
[ 15.293273] ehci-omap ehci-omap.0: starting TI EHCI USB Controller
[ 15.299499] ehci-omap ehci-omap.0: idlest2 = 0x0
[ 15.304168] ehci-omap ehci-omap.0: operation timed out
[ 15.309387] ehci-omap ehci-omap.0: failed to start ehci
[ 15.314666] ehci-omap: probe of ehci-omap.0 failed with error -22
after fixing that it locks up, I'll comment about that more later.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions Felipe Balbi
@ 2009-02-24 22:35 ` Grazvydas Ignotas
2009-02-24 22:39 ` Felipe Balbi
1 sibling, 1 reply; 33+ messages in thread
From: Grazvydas Ignotas @ 2009-02-24 22:35 UTC (permalink / raw)
To: Felipe Balbi; +Cc: linux-omap, Steve Sakoman, Anand Gadiyar
On Mon, Feb 23, 2009 at 8:55 PM, Felipe Balbi <me@felipebalbi.com> wrote:
> Adding a platform_data to the driver allow us
> to remove some of the ifdeferry in the code.
>
<snip>
> diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
> index b8a78c0..08215c0 100644
> --- a/arch/arm/mach-omap2/board-omap3pandora.c
> +++ b/arch/arm/mach-omap2/board-omap3pandora.c
> @@ -297,7 +297,7 @@ static void __init omap3pandora_init(void)
> spi_register_board_info(omap3pandora_spi_board_info,
> ARRAY_SIZE(omap3pandora_spi_board_info));
> usb_musb_init();
> - usb_ehci_init();
> + usb_ehci_init(EHCI_HCD_OMAP_MODE_PHY, true, true, 57, 61);
Perhaps it would be better to have .chargepump and .phy_reset set to
false by default, as pandora doesn't need that chargepump thing (I
guess some other boards too), and phy reset GPIO is wrong not only for
pandora I think. Board maintainers can then send patches as needed.
There also should be a way to specify only one reset GPIO, most boards
have only one EHCI port I think. Note that .phy_reset is required for
EHCI to work on pandora (in case you have thoughts of removing that
code later).
> diff --git a/arch/arm/mach-omap2/usb-ehci.c b/arch/arm/mach-omap2/usb-ehci.c
> index 23fe857..30e1ad6 100644
> --- a/arch/arm/mach-omap2/usb-ehci.c
> +++ b/arch/arm/mach-omap2/usb-ehci.c
> @@ -145,8 +145,20 @@ static void setup_ehci_io_mux(void)
> return;
> }
>
> -void __init usb_ehci_init(void)
> +void __init usb_ehci_init(enum ehci_hcd_omap_mode phy_mode,
> + int chargepump, int phy_reset, int reset_gpio_port1,
> + int reset_gpio_port2)
> {
> + struct ehci_hcd_omap_platform_data pdata = {
> + .phy_mode = phy_mode,
> + .chargepump = chargepump,
> + .phy_reset = phy_reset,
> + .reset_gpio_port1 = reset_gpio_port1,
> + .reset_gpio_port2 = reset_gpio_port2,
> + };
> +
> + ehci_device.dev.platform_data = &pdata;
> +
hmm, doesn't pdata end up on stack here? platform_device_register()
doesn't seem to make a copy of that structure.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data
2009-02-24 22:35 ` [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data Grazvydas Ignotas
@ 2009-02-24 22:39 ` Felipe Balbi
0 siblings, 0 replies; 33+ messages in thread
From: Felipe Balbi @ 2009-02-24 22:39 UTC (permalink / raw)
To: Grazvydas Ignotas; +Cc: Felipe Balbi, linux-omap, Steve Sakoman, Anand Gadiyar
On Wed, Feb 25, 2009 at 12:35:05AM +0200, Grazvydas Ignotas wrote:
> On Mon, Feb 23, 2009 at 8:55 PM, Felipe Balbi <me@felipebalbi.com> wrote:
> > Adding a platform_data to the driver allow us
> > to remove some of the ifdeferry in the code.
> >
>
> <snip>
>
> > diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
> > index b8a78c0..08215c0 100644
> > --- a/arch/arm/mach-omap2/board-omap3pandora.c
> > +++ b/arch/arm/mach-omap2/board-omap3pandora.c
> > @@ -297,7 +297,7 @@ static void __init omap3pandora_init(void)
> > spi_register_board_info(omap3pandora_spi_board_info,
> > ARRAY_SIZE(omap3pandora_spi_board_info));
> > usb_musb_init();
> > - usb_ehci_init();
> > + usb_ehci_init(EHCI_HCD_OMAP_MODE_PHY, true, true, 57, 61);
>
> Perhaps it would be better to have .chargepump and .phy_reset set to
> false by default, as pandora doesn't need that chargepump thing (I
> guess some other boards too), and phy reset GPIO is wrong not only for
> pandora I think. Board maintainers can then send patches as needed.
> There also should be a way to specify only one reset GPIO, most boards
> have only one EHCI port I think. Note that .phy_reset is required for
> EHCI to work on pandora (in case you have thoughts of removing that
> code later).
I made it true by default because those where always true in PHY mode as
of current driver. The correct way to do it, would be to move both to
board-file since those workarounds are board-specific.
We need a list of the boards that need the workarounds and a list of
those which don't need so we can move the workarounds to the
board-files.
>
> > diff --git a/arch/arm/mach-omap2/usb-ehci.c b/arch/arm/mach-omap2/usb-ehci.c
> > index 23fe857..30e1ad6 100644
> > --- a/arch/arm/mach-omap2/usb-ehci.c
> > +++ b/arch/arm/mach-omap2/usb-ehci.c
> > @@ -145,8 +145,20 @@ static void setup_ehci_io_mux(void)
> > return;
> > }
> >
> > -void __init usb_ehci_init(void)
> > +void __init usb_ehci_init(enum ehci_hcd_omap_mode phy_mode,
> > + int chargepump, int phy_reset, int reset_gpio_port1,
> > + int reset_gpio_port2)
> > {
> > + struct ehci_hcd_omap_platform_data pdata = {
> > + .phy_mode = phy_mode,
> > + .chargepump = chargepump,
> > + .phy_reset = phy_reset,
> > + .reset_gpio_port1 = reset_gpio_port1,
> > + .reset_gpio_port2 = reset_gpio_port2,
> > + };
> > +
> > + ehci_device.dev.platform_data = &pdata;
> > +
>
> hmm, doesn't pdata end up on stack here? platform_device_register()
> doesn't seem to make a copy of that structure.
hmm... should make that __initconst and use
platform_device_add_data();
Will fix, thanks a lot
--
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 18/23] arm: omap: make usb base defines follow trm Felipe Balbi
@ 2009-02-24 22:42 ` Grazvydas Ignotas
1 sibling, 0 replies; 33+ messages in thread
From: Grazvydas Ignotas @ 2009-02-24 22:42 UTC (permalink / raw)
To: Felipe Balbi; +Cc: linux-omap, Steve Sakoman, Anand Gadiyar
On Mon, Feb 23, 2009 at 8:55 PM, Felipe Balbi <me@felipebalbi.com> wrote:
> Make the register definitions in ehci-omap.c more sane.
> Also change the parameter passed omap_start/stop_ehc().
>
> Signed-off-by: Felipe Balbi <me@felipebalbi.com>
> ---
> drivers/usb/host/ehci-omap.c | 219 +++++++++++++++++++++---------------------
> 1 files changed, 111 insertions(+), 108 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
> index cd891cc..c9305a3 100644
> --- a/drivers/usb/host/ehci-omap.c
> +++ b/drivers/usb/host/ehci-omap.c
<snip>
> @@ -343,84 +346,87 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd)
> clk_enable(omap->usbtll_ick);
>
> /* Disable Auto Idle of USBTLL */
> - cm_write_mod_reg((0 << OMAP3430ES2_AUTO_USBTLL_SHIFT),
> + cm_write_mod_reg((0 << OMAP3430ES2_AUTO_USBTLL),
> CORE_MOD, CM_AUTOIDLE3);
>
> /* Wait for TLL to be Active */
> while ((cm_read_mod_reg(CORE_MOD, OMAP2430_CM_IDLEST3)
> - & (1 << OMAP3430ES2_ST_USBTLL_SHIFT))) {
> + & (0 << OMAP3430ES2_ST_USBTLL_SHIFT))) {
> cpu_relax();
>
> if (time_after(timeout, jiffies)) {
> - dev_dbg(hcd->self.controller, "operation timed out\n");
> + dev_dbg(omap->dev, "operation timed out\n");
> ret = -EINVAL;
> goto err_idlest3;
> }
> }
>
> /* perform TLL soft reset, and wait until reset is complete */
> - omap_writel(1 << OMAP_USBTLL_SYSCONFIG_SOFTRESET_SHIFT,
> + omap_writel(1 << OMAP_USBTLL_SYSCONFIG_SOFTRESET,
> OMAP_USBTLL_SYSCONFIG);
You forgot to remove the actual shift here
>
> /* Wait for TLL reset to complete */
> while (!(omap_readl(OMAP_USBTLL_SYSSTATUS)
> - & (1 << OMAP_USBTLL_SYSSTATUS_RESETDONE_SHIFT))) {
> + & (1 << OMAP_USBTLL_SYSSTATUS_RESETDONE))) {
> cpu_relax();
and here, that's why it locks up.
>
> if (time_after(timeout, jiffies)) {
> - dev_dbg(hcd->self.controller, "operation timed out\n");
> + dev_dbg(omap->dev, "operation timed out\n");
> ret = -EINVAL;
> goto err_sys_status;
> }
> }
>
> - dev_dbg(hcd->self.controller, "TLL RESET DONE\n");
> + dev_dbg(omap->dev, "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_writel(OMAP_USBTLL_SYSCONFIG_ENAWAKEUP |
> + OMAP_USBTLL_SYSCONFIG_SIDLEMODE |
> + OMAP_USBTLL_SYSCONFIG_CACTIVITY,
> OMAP_USBTLL_SYSCONFIG);
>
>
> /* Put UHH in NoIdle/NoStandby mode */
> - omap_writel((0 << OMAP_UHH_SYSCONFIG_AUTOIDLE_SHIFT) |
> - (1 << OMAP_UHH_SYSCONFIG_ENAWAKEUP_SHIFT) |
> - (1 << OMAP_UHH_SYSCONFIG_SIDLEMODE_SHIFT) |
> - (1 << OMAP_UHH_SYSCONFIG_CACTIVITY_SHIFT) |
> - (1 << OMAP_UHH_SYSCONFIG_MIDLEMODE_SHIFT),
> - OMAP_UHH_SYSCONFIG);
> + reg = omap_readl(OMAP_UHH_SYSCONFIG);
> + reg |= (OMAP_UHH_SYSCONFIG_ENAWAKEUP
> + | OMAP_UHH_SYSCONFIG_SIDLEMODE
> + | OMAP_UHH_SYSCONFIG_CACTIVITY
> + | OMAP_UHH_SYSCONFIG_MIDLEMODE);
> + reg &= ~OMAP_UHH_SYSCONFIG_AUTOIDLE;
> +
> + omap_writel(reg, OMAP_UHH_SYSCONFIG);
>
> if (omap->phy_mode == EHCI_HCD_OMAP_MODE_PHY) {
> + reg = omap_readl(OMAP_UHH_HOSTCONFIG);
> +
> + reg |= (OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
> + | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
> + | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN);
> + reg &= ~(OMAP_UHH_HOSTCONFIG_ULPI_BYPASS
> + | OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN);
>
> /* Bypass the TLL module for PHY mode operation */
> - omap_writel((0 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)|
> - (1 << OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN_SHIFT)|
> - (1 << OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN_SHIFT)|
> - (1 << OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN_SHIFT)|
> - (0 << OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN_SHIFT),
> - OMAP_UHH_HOSTCONFIG);
> + omap_writel(reg, OMAP_UHH_HOSTCONFIG);
>
> /* Ensure that BYPASS is set */
> while (omap_readl(OMAP_UHH_HOSTCONFIG)
> - & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS_SHIFT)) {
> + & (1 << OMAP_UHH_HOSTCONFIG_ULPI_BYPASS)) {
> cpu_relax();
here too..
building now a kernel with these fixed..
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series
2009-04-27 9:18 ` Grazvydas Ignotas
@ 2009-04-27 9:18 ` Felipe Balbi
0 siblings, 0 replies; 33+ messages in thread
From: Felipe Balbi @ 2009-04-27 9:18 UTC (permalink / raw)
To: ext Grazvydas Ignotas
Cc: Felipe Balbi, linux-omap@vger.kernel.org, Steve Sakoman,
Anand Gadiyar
On Mon, Apr 27, 2009 at 11:18:32AM +0200, ext Grazvydas Ignotas wrote:
> On Mon, Feb 23, 2009 at 9:55 PM, Felipe Balbi <me@felipebalbi.com> wrote:
> > Hi all,
> >
> > Please give the following patches a good test. I don't have
> > hw to test them so any comments will be really welcome.
> >
> > We still have lots to do before getting this driver upstream,
> > let's try to keep track of our TODO list and get this driver in
> > mainline for 2.6.31 merge window (2.6.30 is too close already).
> >
> > Let's not try to push this driver until ES2.x and ES3.x are fully
> > supported, that will probably have to be done by an omap_rev
> > check in ehci-omap driver, also, this driver doesn't really
> > enumerate any attached devices, but that's old problem as Tony
> > told me off list.
> >
> > Anyways, I guess this driver is finally walking. Me and Anand (and anyone
> > interested) will be discussing how to get EHCI and OHCI working fine, I'm
> > guessing we won't have really big issues with OHCI but you never know.
>
> Any news on this? Hope this hasn't been abandoned.
Quite busy with some nokia stuff, but I'll get back to this maybe next
week.
--
balbi
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series
2009-02-23 18:55 [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 01/23] usb: host: ehci: make checkpatch.pl happy with ehci-omap Felipe Balbi
2009-02-23 19:32 ` [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series Felipe Balbi
@ 2009-04-27 9:18 ` Grazvydas Ignotas
2009-04-27 9:18 ` Felipe Balbi
2 siblings, 1 reply; 33+ messages in thread
From: Grazvydas Ignotas @ 2009-04-27 9:18 UTC (permalink / raw)
To: Felipe Balbi; +Cc: linux-omap, Steve Sakoman, Anand Gadiyar
On Mon, Feb 23, 2009 at 9:55 PM, Felipe Balbi <me@felipebalbi.com> wrote:
> Hi all,
>
> Please give the following patches a good test. I don't have
> hw to test them so any comments will be really welcome.
>
> We still have lots to do before getting this driver upstream,
> let's try to keep track of our TODO list and get this driver in
> mainline for 2.6.31 merge window (2.6.30 is too close already).
>
> Let's not try to push this driver until ES2.x and ES3.x are fully
> supported, that will probably have to be done by an omap_rev
> check in ehci-omap driver, also, this driver doesn't really
> enumerate any attached devices, but that's old problem as Tony
> told me off list.
>
> Anyways, I guess this driver is finally walking. Me and Anand (and anyone
> interested) will be discussing how to get EHCI and OHCI working fine, I'm
> guessing we won't have really big issues with OHCI but you never know.
Any news on this? Hope this hasn't been abandoned.
^ permalink raw reply [flat|nested] 33+ messages in thread
end of thread, other threads:[~2009-04-27 9:23 UTC | newest]
Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-23 18:55 [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 01/23] usb: host: ehci: make checkpatch.pl happy with ehci-omap Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 02/23] usb: host: ehci: use dev_name Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 03/23] usb: host: ehci: standardize variables Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 04/23] usb: host: ehci: tabify structures Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 05/23] usb: host: ehci: use resource helpers Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 06/23] usb: host: ehci: sanitize error path Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 07/23] usb: host: ehci: get rid of pm functions Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 08/23] usb: host: ehci: reorganize structures Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 09/23] usb: host: ehci: better function names Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 10/23] usb: host: ehci: move some comments Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 11/23] usb: host: ehci: add MODULE_AUTHOR Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 12/23] usb: host: ehci: include <linux/gpio.h> instead Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 13/23] usb: host: ehci: remove ehci-omap.h Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 14/23] usb: host: ehci: get rid of infinite loops Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 15/23] usb: host: ehci: disable clocks on error Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 18/23] arm: omap: make usb base defines follow trm Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 19/23] usb: host: ehci: ioremap all usb bases Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 20/23] usb: host: ehci: align defines Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 21/23] usb: host: ehci: don't ensure register write Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 22/23] ehci-omap: Remove defines for clock names Felipe Balbi
2009-02-23 18:55 ` [rft/rfc/patch-v2.6.29-rc5+ 23/23] usb: host: ehci: add few comments and todo Felipe Balbi
2009-02-23 19:08 ` [rft/rfc/patch-v2.6.29-rc5+ 21/23] usb: host: ehci: don't ensure register write Felipe Balbi
2009-02-24 22:42 ` [rft/rfc/patch-v2.6.29-rc5+ 17/23] usb: host: ehci: fix register definitions Grazvydas Ignotas
2009-02-24 22:35 ` [rft/rfc/patch-v2.6.29-rc5+ 16/23] usb: host: ehci: add platform_data Grazvydas Ignotas
2009-02-24 22:39 ` Felipe Balbi
2009-02-23 19:32 ` [rft/rfc/patch-v2.6.29-rc5+ 00/23] ehci cleanup series Felipe Balbi
2009-04-27 9:18 ` Grazvydas Ignotas
2009-04-27 9:18 ` Felipe Balbi
-- strict thread matches above, loose matches on Subject: below --
2009-02-23 18:52 Felipe Balbi
2009-02-24 22:13 ` Grazvydas Ignotas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox