USB: orion ehci patches for 2.6.35
Subsystems (5)
cover USB: orion ehci patches for 2.6.35
Saeed Bishara (5):
USB: add support for phy init for the Dove SoC
ARM: use the Dove USB phy setup
USB: add clk structure for systems that support clkdev framework
USB: manage the orion ehci clock using the clkdev
USB: add power management support for orion ehci
arch/arm/mach-dove/common.c | 2 arch/arm/plat-orion/include/plat/ehci-orion.h | 1 drivers/usb/core/hcd.h | 4 drivers/usb/host/ehci-orion.c | 139 ++++++++++++++++++++---- drivers/usb/host/ehci-orion.c | 108 ++++++++++++++++++ 5 files changed, 233 insertions(+), 21 deletions(-)
PATCH 1/5 USB: add support for phy init for the Dove SoC
This patch adds support for initializing the USB phy of the Marvell's Dove SoC.
--- arch/arm/plat-orion/include/plat/ehci-orion.h | 1 + drivers/usb/host/ehci-orion.c | 139 +++++++++++++++++++++---- 2 files changed, 120 insertions(+), 20 deletions(-)
arch/arm/plat-orion/include/plat/ehci-orion.h +1 -0
@@ -13,6 +13,7 @@enum orion_ehci_phy_ver {EHCI_PHY_ORION , +EHCI_PHY_DOVE ,EHCI_PHY_DD ,EHCI_PHY_KW ,EHCI_PHY_NA ,
drivers/usb/host/ehci-orion.c +119 -20
163 lines not on this page · raw message
Signature · 1 line
1.6.0.4
PATCH 2/5 ARM: use the Dove USB phy setup
The patch makes the dove SoC use the proper USB phy setup.
--- arch/arm/mach-dove/common.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-dove/common.c +1 -1
@@ -74,7 +74,7 @@ void __init dove_map_io(void)****************************************************************************/ static struct orion_ehci_data dove_ehci_data = { .dram = &dove_mbus_dram_info, - .phy_version =EHCI_PHY_NA , + .phy_version =EHCI_PHY_DOVE , };static u64 ehci_dmamask =DMA_BIT_MASK (32 );
Signature · 1 line
1.6.0.4
PATCH 3/5 USB: add clk structure for systems that support clkdev framework
--- drivers/usb/core/hcd.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/usb/core/hcd.h +4 -0
@@ -22,6 +22,7 @@#ifdef __KERNEL__#include <linux/rwsem.h> +#include <linux/clk.h> #define MAX_TOPO_LEVEL 6
@@ -110,6 +111,9 @@ struct usb_hcd {u64 rsrc_start;/* memory/io resource start */ u64 rsrc_len;/* memory/io resource length */ unsigned power_budget;/* in mA, 0 = no limit */ +#if defined(CONFIG_HAVE_CLK ) +struct clk *clk; +#endif /* bandwidth_mutex should be taken before adding or removing * any new bus bandwidth constraints:
Signature · 1 line
1.6.0.4
PATCH 4/5 USB: manage the orion ehci clock using the clkdev
This patch will enable the ehci controller's clock when needed.
--- drivers/usb/host/ehci-orion.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
drivers/usb/host/ehci-orion.c +21 -0
@@ -361,6 +361,14 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) goto err3; } +#if defined(CONFIG_HAVE_CLK ) + hcd->clk =clk_get (&pdev->dev,NULL ); +if (IS_ERR (hcd->clk)) +dev_notice (&pdev->dev,"cannot get clkdev\n" ); +else +clk_enable (hcd->clk); +#endif + hcd->rsrc_start = res->start; hcd->rsrc_len =resource_size (res); hcd->regs = regs;
@@ -382,6 +390,13 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev)return 0 ; err4: +#if defined(CONFIG_HAVE_CLK ) +if (!IS_ERR (hcd->clk)) { +clk_disable (hcd->clk); +clk_put (hcd->clk); + } +#endif +usb_put_hcd (hcd); err3:iounmap (regs);
@@ -402,6 +417,12 @@ static int __exit ehci_orion_drv_remove(struct platform_device *pdev)iounmap (hcd->regs);release_mem_region (hcd->rsrc_start, hcd->rsrc_len);usb_put_hcd (hcd); +#if defined(CONFIG_HAVE_CLK ) +if (!IS_ERR (hcd->clk)) { +clk_disable (hcd->clk); +clk_put (hcd->clk); + } +#endif return 0 ; }
Signature · 1 line
1.6.0.4
PATCH 5/5 USB: add power management support for orion ehci
--- drivers/usb/host/ehci-orion.c | 87 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 87 insertions(+), 0 deletions(-)
drivers/usb/host/ehci-orion.c +87 -0
@@ -427,11 +427,98 @@ static int __exit ehci_orion_drv_remove(struct platform_device *pdev)return 0 ; } +#ifdef CONFIG_PM +static int ehci_orion_suspend (struct platform_device *pdev, +pm_message_t state) +{ +struct usb_hcd *hcd =platform_get_drvdata (pdev); +struct ehci_hcd *ehci =hcd_to_ehci (hcd); +unsigned long flags; +int rc =0 ; + +if (time_before (jiffies, ehci->next_statechange)) +msleep (10 ); + +/* Root hub was already suspended. Disable irq emission and +* mark HW unaccessible, bail out if RH has been resumed. Use +* the spinlock to properly synchronize with possible pending +* RH suspend or resume activity. +* +* This is still racy as hcd->state is manipulated outside of +* any locks =P But that will be a different fix. +*/ +spin_lock_irqsave (&ehci->lock, flags); +if (hcd->state !=HC_STATE_SUSPENDED ) { + rc = -EINVAL ; + goto bail; + } +ehci_writel (ehci,0 , &ehci->regs->intr_enable); + (void )ehci_readl (ehci, &ehci->regs->intr_enable); + +/* make sure snapshot being resumed re-enumerates everything */ +if (state.event ==PM_EVENT_PRETHAW ) { +ehci_halt (ehci); +ehci_reset (ehci); + } + +clear_bit (HCD_FLAG_HW_ACCESSIBLE , &hcd->flags); +bail: +spin_unlock_irqrestore (&ehci->lock, flags); + +return rc; +} +static int ehci_orion_resume (struct platform_device *pdev) +{ +struct orion_ehci_data *pd = pdev->dev.platform_data; +struct usb_hcd *hcd =platform_get_drvdata (pdev); +struct ehci_hcd *ehci =hcd_to_ehci (hcd); + +if (time_before (jiffies, ehci->next_statechange)) +msleep (100 ); + +/* Mark hardware accessible again as we are out of D3 state by now */ +set_bit (HCD_FLAG_HW_ACCESSIBLE , &hcd->flags); + +ehci_dbg (ehci,"lost power, restarting\n" ); +usb_root_hub_lost_power (hcd->self.root_hub); + +/* Else reset, to cope with power loss or flush-to-storage +* style "resume" having let BIOS kick in during reboot. +*/ + (void )ehci_halt (ehci); + (void )ehci_reset (ehci); +ehci_orion_hw_init (hcd, pd); + +/* emptying the schedule aborts any urbs */ +spin_lock_irq (&ehci->lock); +if (ehci->reclaim) +end_unlink_async (ehci); +ehci_work (ehci); +spin_unlock_irq (&ehci->lock); + +ehci_writel (ehci, ehci->command, &ehci->regs->command); +ehci_writel (ehci,FLAG_CF , &ehci->regs->configured_flag); +ehci_readl (ehci, &ehci->regs->command);/* unblock posted writes */ + +/* here we "know" root ports should always stay powered */ +ehci_port_power (ehci,1 ); + + hcd->state =HC_STATE_SUSPENDED ; +return 0 ; +} + +#else +#define ehci_orion_suspend NULL +#define ehci_orion_resume NULL +#endif +MODULE_ALIAS ("platform:orion-ehci" );static struct platform_driver ehci_orion_driver = { .probe = ehci_orion_drv_probe, .remove =__exit_p (ehci_orion_drv_remove), + .suspend = ehci_orion_suspend, + .resume = ehci_orion_resume, .shutdown = usb_hcd_platform_shutdown, .driver.name ="orion-ehci" , };
Signature · 1 line
1.6.0.4
PATCH 3/5 USB: add clk structure for systems that support clkdev framework
In reply to Saeed Bisharadrivers/usb/core/hcd.h struct usb_hcd { · line 116
Quoted 7 lines · Saeed Bishara
drivers/usb/core/hcd.h +3
-0@@ -110,6 +111,9 @@ struct usb_hcd {u64 rsrc_start;/* memory/io resource start */ u64 rsrc_len;/* memory/io resource length */ unsigned power_budget;/* in mA, 0 = no limit */ +#if defined(CONFIG_HAVE_CLK ) +struct clk *clk; +#endif
We have other hci's using the clk API, why do we need to add this for them too? In other words, why can't the orion HCI driver work like the other HCI drivers such as ohci-pxa27x.c or ehci-omap.c ?
PATCH 3/5 USB: add clk structure for systems that support clkdev framework
Quoted 13 lines · Russell King - ARM Linux
drivers/usb/core/hcd.h struct usb_hcd { · line 116
Quoted 7 lines · Saeed Bishara
(quoted diff) +0
-0@@ -110,6 +111,9 @@ struct usb_hcd {? ? ? u64 ? ? ? ? ? ? ? ? ? ?
rsrc_start; ? ? /* memory/io resource start */ ? ? ? u64 ? ? ? ? ? ? ? ? ? ?rsrc_len; ? ? ? /* memory/io resource length */ ? ? ? unsigned ? ? ? ? ? ? ? ?power_budget; ? /* in mA, 0 = no limit */drivers/usb/core/hcd.h +3
-0+#if defined(CONFIG_HAVE_CLK ) + ? ? struct clk ? ? ? ? ? ? ?*clk; +#endif We have other hci's using the clk API, why do we need to add this for them too? ?In other words, why can't the orion HCI driver work like the other HCI drivers such as
ohci-pxa27x.corehci-omap.c?
if most of those drivers need clk structure then why not to add it to the usb_hcd which hold the common stuff?
if I get approval for this then we can change the other drivers to use this clk instead of each one having its own variable.
saeed
PATCH 3/5 USB: add clk structure for systems that support clkdev framework
Quoted 15 lines · saeed bishara
Quoted 13 lines · Russell King - ARM Linux
drivers/usb/core/hcd.h struct usb_hcd { · line 116
Quoted 7 lines · Saeed Bishara
(quoted diff) +0
-0@@ -110,6 +111,9 @@ struct usb_hcd {? ? ? u64 ? ? ? ? ? ? ? ? ? ?
rsrc_start; ? ? /* memory/io resource start */ ? ? ? u64 ? ? ? ? ? ? ? ? ? ?rsrc_len; ? ? ? /* memory/io resource length */ ? ? ? unsigned ? ? ? ? ? ? ? ?power_budget; ? /* in mA, 0 = no limit */drivers/usb/core/hcd.h +3
-0+#if defined(CONFIG_HAVE_CLK ) + ? ? struct clk ? ? ? ? ? ? ?*clk; +#endif We have other hci's using the clk API, why do we need to add this for them too? ?In other words, why can't the orion HCI driver work like the other HCI drivers such as
ohci-pxa27x.corehci-omap.c?
Quoted 2 lines
if most of those drivers need clk structure then why not to add it to the
usb_hcdwhich hold the common stuff?
drivers/usb/host/ohci-s3c2410.c: 2drivers/usb/host/ohci-omap.c: 2drivers/usb/host/r8a66597-hcd.c: 1drivers/usb/host/ehci-mxc.c: 2drivers/usb/host/ohci-da8xx.c: 2drivers/usb/host/ohci-pxa27x.c: 1drivers/usb/host/ohci-pnx4008.c: 1drivers/usb/host/imx21-hcd.c: 1drivers/usb/host/ohci-ep93xx.c: 1drivers/usb/host/ehci-atmel.c: 2drivers/usb/host/ehci-omap.c: 5drivers/usb/host/ohci-at91.c: 2
So, five drivers need one clock, six drivers need two clocks, and one driver needs five clocks. So maybe you should be catering for the common case by providing two struct clk's, or maybe catering for the maximal case of five clocks?
Quoted 2 lines
if I get approval for this then we can change the other drivers to use this clk instead of each one having its own variable.
That wasn't covered in the original patch - who gets to create these patches, and how soon will they be created after 'approval' ?
Having these patches with this patch submission may actually help your case by showing the benefits of such a cleanup - eg, if it eliminates private driver data structures entirely, it's definitely worth it.
However, if it results in one clk structure in one structure and a bunch of other clk structures elsewhere, imho it makes very little sense - I'd go as far as to suggest that it creates confusion.
PATCH 3/5 USB: add clk structure for systems that support clkdev framework
Quoted 32 lines · Russell King - ARM Linux
Quoted 15 lines · saeed bishara
Quoted 13 lines · Russell King - ARM Linux
drivers/usb/core/hcd.h struct usb_hcd { · line 116
Quoted 7 lines · Saeed Bishara
(quoted diff) +0
-0@@ -110,6 +111,9 @@ struct usb_hcd {? ? ? u64 ? ? ? ? ? ? ? ? ? ?
rsrc_start; ? ? /* memory/io resource start */ ? ? ? u64 ? ? ? ? ? ? ? ? ? ?rsrc_len; ? ? ? /* memory/io resource length */ ? ? ? unsigned ? ? ? ? ? ? ? ?power_budget; ? /* in mA, 0 = no limit */drivers/usb/core/hcd.h +3
-0+#if defined(CONFIG_HAVE_CLK ) + ? ? struct clk ? ? ? ? ? ? ?*clk; +#endif We have other hci's using the clk API, why do we need to add this for them too? ?In other words, why can't the orion HCI driver work like the other HCI drivers such as
ohci-pxa27x.corehci-omap.c?Quoted 2 lines
if most of those drivers need clk structure then why not to add it to the
usb_hcdwhich hold the common stuff?
drivers/usb/host/ohci-s3c2410.c: ? ? ? ?2drivers/usb/host/ohci-omap.c: ? ? ? ? ? 2drivers/usb/host/r8a66597-hcd.c: ? ? ? ?1drivers/usb/host/ehci-mxc.c: ? ? ? ? ? ?2drivers/usb/host/ohci-da8xx.c: ? ? ? ? ?2drivers/usb/host/ohci-pxa27x.c: ? ? ? ? 1drivers/usb/host/ohci-pnx4008.c: ? ? ? ?1drivers/usb/host/imx21-hcd.c: ? ? ? ? ? 1drivers/usb/host/ohci-ep93xx.c: ? ? ? ? 1drivers/usb/host/ehci-atmel.c: ? ? ? ? ?2drivers/usb/host/ehci-omap.c: ? ? ? ? ? 5drivers/usb/host/ohci-at91.c: ? ? ? ? ? 2
Quoted 4 lines
So, five drivers need one clock, six drivers need two clocks, and one driver needs five clocks. ?So maybe you should be catering for the common case by providing two struct clk's, or maybe catering for the maximal case of five clocks?
well, I think that those drivers that have more than one clk can be redesigned by adding virtual clk for the the usb host, and the clk implementation for that soc should manage all the underlying physical clocks. I've looked at the omap,at91 and atmel, and it looks to me that this is doable. you see can see that the clk stuff in those driver has nothing to do with usb itself. what do you think?
Quoted 4 lines
Having these patches with this patch submission may actually help your case by showing the benefits of such a cleanup - eg, if it eliminates private driver data structures entirely, it's definitely worth it.
your right, I have had to send kind of RFC for this issue.
Quoted 1 line
PATCH 3/5 USB: add clk structure for systems that support clkdev framework
Quoted 19 lines · saeed bishara
Quoted 13 lines · Russell King - ARM Linux
drivers/usb/host/ohci-s3c2410.c: ? ? ? ?2drivers/usb/host/ohci-omap.c: ? ? ? ? ? 2drivers/usb/host/r8a66597-hcd.c: ? ? ? ?1drivers/usb/host/ehci-mxc.c: ? ? ? ? ? ?2drivers/usb/host/ohci-da8xx.c: ? ? ? ? ?2drivers/usb/host/ohci-pxa27x.c: ? ? ? ? 1drivers/usb/host/ohci-pnx4008.c: ? ? ? ?1drivers/usb/host/imx21-hcd.c: ? ? ? ? ? 1drivers/usb/host/ohci-ep93xx.c: ? ? ? ? 1drivers/usb/host/ehci-atmel.c: ? ? ? ? ?2drivers/usb/host/ehci-omap.c: ? ? ? ? ? 5drivers/usb/host/ohci-at91.c: ? ? ? ? ? 2Quoted 4 lines
So, five drivers need one clock, six drivers need two clocks, and one driver needs five clocks. ?So maybe you should be catering for the common case by providing two struct clk's, or maybe catering for the maximal case of five clocks?
Quoted 6 lines
well, I think that those drivers that have more than one clk can be redesigned by adding virtual clk for the the usb host, and the clk implementation for that soc should manage all the underlying physical clocks. I've looked at the omap,at91 and atmel, and it looks to me that this is doable. you see can see that the clk stuff in those driver has nothing to do with usb itself. what do you think?
Not happy with this for two reasons:
1. You're assuming that they can be managed as one entity; that doesn't seem true for some of the drivers.
2. I don't see any reason to force this complication into the clk layer for these platforms when they don't actually need it.
Due to (1), using your current approach will result in those drivers scattering their clks across two structures, which as I've said in my previous email would be confusing.
So I don't think this approach makes much sense.
PATCH 3/5 USB: add clk structure for systems that support clkdev framework
Quoted 10 lines
Quoted 6 lines
well, I think that those drivers that have more than one clk can be redesigned by adding virtual clk for the the usb host, and the clk implementation for that soc should manage all the underlying physical clocks. I've looked at the omap,at91 and atmel, and it looks to me that this is doable. you see can see that the clk stuff in those driver has nothing to do with usb itself. what do you think?
Not happy with this for two reasons:
1. You're assuming that they can be managed as one entity; that doesn't seem ? true for some of the drivers.
can you please give an example?
saeed
PATCH 3/5 USB: add clk structure for systems that support clkdev framework
Quoted 11 lines · saeed bishara
Quoted 10 lines
Quoted 6 lines
well, I think that those drivers that have more than one clk can be redesigned by adding virtual clk for the the usb host, and the clk implementation for that soc should manage all the underlying physical clocks. I've looked at the omap,at91 and atmel, and it looks to me that this is doable. you see can see that the clk stuff in those driver has nothing to do with usb itself. what do you think?
Not happy with this for two reasons:
1. You're assuming that they can be managed as one entity; that doesn't seem ? true for some of the drivers.can you please give an example?
drivers/usb/host/ohci-da8xx.c has two clocks, and needs to know the configuration of the USB block to know whether to manage the USB2.0 clock:
cfgchip2 = __raw_readl(CFGCHIP2);
if (on) {
clk_enable(usb11_clk);
/*
* If USB 1.1 reference clock is sourced from USB 2.0 PHY, we
* need to enable the USB 2.0 module clocking, start its PHY,
* and not allow it to stop the clock during USB 2.0 suspend.
*/
if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX)) {
clk_enable(usb20_clk);PATCH 3/5 USB: add clk structure for systems that support clkdev framework
Quoted 21 lines · Russell King - ARM Linux
Quoted 11 lines · saeed bishara
Quoted 10 lines
Quoted 6 lines
well, I think that those drivers that have more than one clk can be redesigned by adding virtual clk for the the usb host, and the clk implementation for that soc should manage all the underlying physical clocks. I've looked at the omap,at91 and atmel, and it looks to me that this is doable. you see can see that the clk stuff in those driver has nothing to do with usb itself. what do you think?
Not happy with this for two reasons:
1. You're assuming that they can be managed as one entity; that doesn't seem ? true for some of the drivers.can you please give an example?
drivers/usb/host/ohci-da8xx.chas two clocks, and needs to know the configuration of the USB block to know whether to manage the USB2.0 clock:? ? ? ?cfgchip2 =
__raw_readl(CFGCHIP2);
? ? ? ?if (on) {
? ? ? ? ? ? ? ?clk_enable(usb11_clk);
Quoted 8 lines
? ? ? ? ? ? ? ?/*
? ? ? ? ? ? ? ? * If USB 1.1 reference clock is sourced from USB 2.0 PHY, we ? ? ? ? ? ? ? ? * need to enable the USB 2.0 module clocking, start its PHY, ? ? ? ? ? ? ? ? * and not allow it to stop the clock during USB 2.0 suspend. ? ? ? ? ? ? ? ? */
? ? ? ? ? ? ? ?if (!(cfgchip2 &CFGCHIP2_USB1PHYCLKMUX)) {
? ? ? ? ? ? ? ? ? ? ? ?clk_enable(usb20_clk);
David, can I've your opinion about this patch? adding the clk struct to the hcd struct will save the orion-ehci driver from having private data structure.
PATCH 3/5 USB: add clk structure for systems that support clkdev framework
In reply to Russell King - ARM LinuxQuoted 21 lines · Russell King - ARM Linux
Quoted 11 lines · saeed bishara
Quoted 10 lines
Quoted 6 lines
well, I think that those drivers that have more than one clk can be redesigned by adding virtual clk for the the usb host, and the clk implementation for that soc should manage all the underlying physical clocks. I've looked at the omap,at91 and atmel, and it looks to me that this is doable. you see can see that the clk stuff in those driver has nothing to do with usb itself. what do you think?
Not happy with this for two reasons:
1. You're assuming that they can be managed as one entity; that doesn't seem ? true for some of the drivers.can you please give an example?
drivers/usb/host/ohci-da8xx.chas two clocks, and needs to know the configuration of the USB block to know whether to manage the USB2.0 clock:? ? ? ?cfgchip2 =
__raw_readl(CFGCHIP2);
? ? ? ?if (on) {
? ? ? ? ? ? ? ?clk_enable(usb11_clk);
Quoted 8 lines
? ? ? ? ? ? ? ?/*
? ? ? ? ? ? ? ? * If USB 1.1 reference clock is sourced from USB 2.0 PHY, we ? ? ? ? ? ? ? ? * need to enable the USB 2.0 module clocking, start its PHY, ? ? ? ? ? ? ? ? * and not allow it to stop the clock during USB 2.0 suspend. ? ? ? ? ? ? ? ? */
? ? ? ? ? ? ? ?if (!(cfgchip2 &CFGCHIP2_USB1PHYCLKMUX)) {
? ? ? ? ? ? ? ? ? ? ? ?clk_enable(usb20_clk);
guys, can I've your opinion about this patch? adding the clk struct to the hcd struct will save the orion-ehci driver from having private data structure.
saeed