usb: musb: Power management support
Subsystems (6)
v3 cover usb: musb: Power management support
This patch series supports the retention and offmode support in the idle path for musb driver using runtime pm APIs.
This is restricted to support offmode and retention only when device not connected.When device/cable connected with gadget driver loaded, configured to no idle/standby which will not allow the core transition to retention or off.
There is no context save/restore done by hardware for musb in OMAP3 and OMAP4,driver has to take care of saving and restoring the context during offmode.
Musb has a requirement of configuring sysconfig register to force idle/standby mode and set the ENABLE_FORCE bit in module STANDBY register for retention and offmode support.
Runtime pm and hwmod frameworks will take care of configuring to force idle/standby when pm_runtime_put_sync is called and back to no idle/standby when pm_runeime_get_sync is called.
Compile, boot tested and also tested the retention in the idle path on OMAP3630Zoom3. And tested the global suspend/resume with offmode enabled. Usb basic functionality tested on OMAP4430SDP.
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
V3 Vesion:
Fixed some minor comments from Felipe.
V2 version:
----------
Rebased patches on Felipe's musb-hwmod-pm-runtime branch. Fixed comments from Felipe.
Hema HK (5):
usb: otg: TWL4030: Update the last_event variable.
usb: musb: Remove platform context save/restore APIs
usb: musb: Idle path retention and offmode support for OMAP3
usb: musb: OMAP4430: Power down the PHY during board init
usb: otg: OMAP4430: Save/restore the context
arch/arm/mach-omap2/omap_phy_internal.c | 7 ++++ arch/arm/mach-omap2/usb-musb.c | 4 ++ drivers/usb/musb/musb_core.c | 40 +++++++++++++++++++++++ drivers/usb/musb/musb_core.h | 4 -- drivers/usb/musb/musb_gadget.c | 11 ++++++ drivers/usb/musb/omap2430.c | 54 ++++++++++++++---------------- drivers/usb/otg/twl4030-usb.c | 2 + 7 files changed, 89 insertions(+), 33 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 1/5 usb: otg: TWL4030: Update the last_event variable.
In reply to a message not in the archiveUpdate the last_event variable of otg_transceiver. This will be used in the musb platform glue driver for runtime idling the device.
--- drivers/usb/otg/twl4030-usb.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/usb/otg/twl4030-usb.c +2 -0
@@ -275,6 +275,8 @@ static enum usb_xceiv_events twl4030_usb_linkstat(struct twl4030_usb *twl)dev_dbg (twl->dev,"HW_CONDITIONS 0x%02x/%d; link %d\n" , status, status, linkstat); + twl->otg.last_event = linkstat; +/* REVISIT this assumes host and peripheral controllers * are registered, and that both are active... */
Signature · 6 lines
1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 5/5 usb: otg: OMAP4430: Save/restore the context
In reply to a message not in the archiveAdd the context save/restore for the control module register used for OMAP4430 musb with UTMI embedded PHY interface.
--- arch/arm/mach-omap2/omap_phy_internal.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_phy_internal.c +7 -0
@@ -44,6 +44,7 @@static struct clk *phyclk, *clk48m, *clk32k;static void __iomem *ctrl_base; +static int usbotghs_control;int omap4430_phy_init (struct device *dev) {
@@ -130,6 +131,9 @@ int omap4430_phy_suspend(struct device *dev, int suspend)omap4430_phy_set_clk (dev,0 );/* Power down the phy */ __raw_writel (PHY_PD , ctrl_base +CONTROL_DEV_CONF ); + +/* save the context */ + usbotghs_control =__raw_readl (ctrl_base +USBOTGHS_CONTROL ); }else {/* Enable the internel phy clcoks */ omap4430_phy_set_clk (dev,1 );
@@ -138,6 +142,9 @@ int omap4430_phy_suspend(struct device *dev, int suspend)__raw_writel (~PHY_PD , ctrl_base +CONTROL_DEV_CONF );mdelay (200 ); } + +/* restore the context */ +__raw_writel (usbotghs_control, ctrl_base +USBOTGHS_CONTROL ); }return 0 ;
Signature · 6 lines
1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 2/5 usb: musb: Remove platform context save/restore API
In reply to Hema HKFor OMAP3 and OMAP4 for offmode and retention support, musb sysconfig is configured to force idle and standby with ENABLE_FORCE bit of OTG_FORCESTNDBY set.
And on wakeup configure to no ilde/standby with resetting the ENABLE_FORCE bit. There is not need to save and restore of this register anymore so removed omap2430_save_context/omap2430_restore_context functions. and also removed otg_forcestandby member of musb_context_registers structure
--- drivers/usb/musb/musb_core.h | 4 ---- drivers/usb/musb/omap2430.c | 11 ----------- 2 files changed, 0 insertions(+), 15 deletions(-)
drivers/usb/musb/musb_core.h +0 -4
@@ -358,10 +358,6 @@ struct musb_csr_regs {struct musb_context_registers { -#if defined(CONFIG_ARCH_OMAP2430 ) || defined(CONFIG_ARCH_OMAP3 ) || \ - defined(CONFIG_ARCH_OMAP4 ) -u32 otg_forcestandby; -#endif u8 power;u16 intrtxe, intrrxe;u8 intrusbe;
drivers/usb/musb/omap2430.c +0 -11
@@ -488,15 +488,6 @@ static int __exit omap2430_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static void omap2430_save_context (struct musb *musb) -{ - musb->context.otg_forcestandby =musb_readl (musb->mregs,OTG_FORCESTDBY ); -} - -static void omap2430_restore_context (struct musb *musb) -{ -musb_writel (musb->mregs,OTG_FORCESTDBY , musb->context.otg_forcestandby); -}static int omap2430_suspend (struct device *dev) {
@@ -505,7 +496,6 @@ static int omap2430_suspend(struct device *dev)omap2430_low_level_exit (musb);otg_set_suspend (musb->xceiv,1 ); -omap2430_save_context (musb);if (!pm_runtime_suspended (dev) && dev->bus && dev->bus->pm && dev->bus->pm->runtime_suspend)
@@ -524,7 +514,6 @@ static int omap2430_resume(struct device *dev) dev->bus->pm->runtime_resume (dev);omap2430_low_level_init (musb); -omap2430_restore_context (musb);otg_set_suspend (musb->xceiv,0 );return 0 ;
Signature · 1 line
1.7.0.4
PATCH v3 3/5 usb: musb: Idle path retention and offmode support for OMAP3
In reply to Hema HKThis patch supports the retention and offmode support in the idle path for musb driver using runtime pm APIs.
This is restricted to support offmode and retention only when device not connected.When device/cable connected with gadget driver loaded,configured to no idle/standby which will not allow the core transition to retention or off.
There is no context save/restore done by hardware for musb in OMAP3 and OMAP4,driver has to take care of saving and restoring the context during offmode.
Musb has a requirement of configuring sysconfig register to force idle/standby mode and set the ENFORCE bit in module STANDBY register for retention and offmode support.
Runtime pm and hwmod frameworks will take care of configuring to force idle/standby when pm_runtime_put_sync is called and back to no idle/standby when pm_runeime_get_sync is called.
Compile, boot tested and also tested the retention in the idle path on OMAP3630Zoom3. And tested the global suspend/resume with offmode enabled. Usb basic functionality tested on OMAP4430SDP.
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
Removed .suspend/.resume fnction pointers and functions because there is no need of having these functions as all required work is done at runtime in the driver.
There is no need to call the runtime pm api with glue driver device as glue layer device is the parent of musb core device, when runtime apis are called for the child, parent device runtime functionality will be invoked.
Design overview:
pm_runtime_get_sync: When called with musb core device takes care of enabling the clock, calling runtime callback function of omap2430 glue layer, runtime call back of musb driver and configure the musb sysconfig to no idle/standby
pm_runtime_put: Takes care of calling runtime callback function of omap2430 glue layer, runtime call back of musb driver, Configure the musb sysconfig to force idle/standby and disable the clock.
During musb driver load: Call pm_runtime_get_sync.
End of musb driver load: Call pm_runtime_put
During gadget driver load: Call pm_runtime_get_sync,
End of gadget driver load: Call pm_runtime_put if there is no device or cable is connected.
During unload of the gadget driver:Call pm_runtime_get_sync if cable/device is not connected.
End of the gadget driver unload : pm_runtime_put
During unload of musb driver : Call pm_runtime_get_sync End of unload: Call pm_runtime_put
On connect of usb cable/device -> transceiver notification(VBUS and ID-GND):pm_runtime_get_sync only if the gadget driver loaded.
On disconnect of the cable/device -> Disconnect Notification:pm_runtime_put if the gadget driver is loaded.
--- drivers/usb/musb/musb_core.c | 40 ++++++++++++++++++++++++++++++++ drivers/usb/musb/musb_gadget.c | 11 +++++++++ drivers/usb/musb/omap2430.c | 49 ++++++++++++++++++++++------------------ 3 files changed, 78 insertions(+), 22 deletions(-)
drivers/usb/musb/musb_core.c +40 -0
@@ -1956,6 +1956,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) goto fail0; } +pm_runtime_use_autosuspend (musb->controller); +pm_runtime_set_autosuspend_delay (musb->controller,200 ); +pm_runtime_enable (musb->controller); +spin_lock_init (&musb->lock); musb->board_mode = plat->mode; musb->board_set_power = plat->set_power;
@@ -2091,6 +2095,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)if (status <0 ) goto fail3; +pm_runtime_put (musb->controller); + status =musb_init_debugfs (musb);if (status <0 ) goto fail4;
@@ -2190,9 +2196,11 @@ static int __exit musb_remove(struct platform_device *pdev)* - Peripheral mode: peripheral is deactivated (or never-activated) * - OTG mode: both roles are deactivated (or never-activated) */ +pm_runtime_get_sync (musb->controller);musb_exit_debugfs (musb);musb_shutdown (pdev); +pm_runtime_put (musb->controller);musb_free (musb);iounmap (ctrl_base);device_init_wakeup (&pdev->dev,0 );
@@ -2378,9 +2386,41 @@ static int musb_resume_noirq(struct device *dev)return 0 ; } +static int musb_runtime_suspend (struct device *dev) +{ +struct musb *musb =dev_to_musb (dev); + +musb_save_context (musb); + +return 0 ; +} + +static int musb_runtime_resume (struct device *dev) +{ +struct musb *musb =dev_to_musb (dev); +static int first =1 ; + +/* +* When pm_runtime_get_sync called for the first time in driver +* init, some of the structure is still not initialized which is +* used in restore function. But clock needs to be +* enabled before any register access, so +* pm_runtime_get_sync has to be called. +* Also context restore without save does not make +* any sense +*/ +if (!first) +musb_restore_context (musb); + first =0 ; + +return 0 ; +} +static const struct dev_pm_ops musb_dev_pm_ops = { .suspend = musb_suspend, .resume_noirq = musb_resume_noirq, + .runtime_suspend = musb_runtime_suspend, + .runtime_resume = musb_runtime_resume, };#define MUSB_DEV_PM_OPS (&musb_dev_pm_ops)
drivers/usb/musb/musb_gadget.c +11 -0
@@ -1820,6 +1820,8 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver, goto err0; } +pm_runtime_get_sync (musb->controller); +DBG (3 ,"registering driver %s\n" , driver->function);if (musb->gadget_driver) {
@@ -1884,6 +1886,10 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver, } hcd->self.uses_pio_for_control =1 ; + +if (musb->xceiv->last_event ==USB_EVENT_NONE ) +pm_runtime_put (musb->controller); + }return 0 ;
@@ -1960,6 +1966,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)if (!musb->gadget_driver)return -EINVAL ; +if (musb->xceiv->last_event ==USB_EVENT_NONE ) +pm_runtime_get_sync (musb->controller); +/* * REVISIT always use otg_set_peripheral() here too; * this needs to shut down the OTG engine.
@@ -2001,6 +2010,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)if (!is_otg_enabled (musb))musb_stop (musb); +pm_runtime_put (musb->controller); +return 0 ; }EXPORT_SYMBOL (usb_gadget_unregister_driver);
drivers/usb/musb/omap2430.c +27 -22
125 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v3 4/5 usb: musb: OMAP4430: Power down the PHY during board init
In reply to Hema HKPowerdown the internal PHY during board init for OMAP44xx. So that when musb is disabled core transition to retention/off is not blocked.
--- arch/arm/mach-omap2/usb-musb.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/usb-musb.c +4 -0
@@ -161,6 +161,10 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data) dev->dma_mask = &musb_dmamask; dev->coherent_dma_mask = musb_dmamask;put_device (dev); + +if (cpu_is_omap44xx ()) + omap4430_phy_init(dev); + }#else
Signature · 1 line
1.7.0.4
Hi,
Quoted 20 lines · Hema HK
This patch series supports the retention and offmode support in the idle path for musb driver using runtime pm APIs.
This is restricted to support offmode and retention only when device not connected.When device/cable connected with gadget driver loaded, configured to no idle/standby which will not allow the core transition to retention or off.
There is no context save/restore done by hardware for musb in OMAP3 and OMAP4,driver has to take care of saving and restoring the context during offmode.
Musb has a requirement of configuring sysconfig register to force idle/standby mode and set the
ENABLE_FORCEbit in module STANDBY register for retention and offmode support.Runtime pm and hwmod frameworks will take care of configuring to force idle/standby when
pm_runtime_put_syncis called and back to no idle/standby whenpm_runeime_get_syncis called.
Quoted 8 lines
Compile, boot tested and also tested the retention in the idle path on OMAP3630Zoom3. And tested the global suspend/resume with offmode enabled. Usb basic functionality tested on OMAP4430SDP.
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
Tony and Greg, how do we handle this one ? Who should take my pull request for this series ? I hope we still have a little time to get this into 2.6.39, but if we don't I can hold on to them until 2.6.40.
Signature · 5 lines
balbi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 27 lines · Felipe Balbi
Hi,
Quoted 24 lines · Hema HK
This patch series supports the retention and offmode support in the idle path for musb driver using runtime pm APIs.
This is restricted to support offmode and retention only when device not connected.When device/cable connected with gadget driver loaded, configured to no idle/standby which will not allow the core transition to retention or off.
There is no context save/restore done by hardware for musb in OMAP3 and OMAP4,driver has to take care of saving and restoring the context during offmode.
Musb has a requirement of configuring sysconfig register to force idle/standby mode and set the
ENABLE_FORCEbit in module STANDBY register for retention and offmode support.Runtime pm and hwmod frameworks will take care of configuring to force idle/standby when
pm_runtime_put_syncis called and back to no idle/standby whenpm_runeime_get_syncis called.Compile, boot tested and also tested the retention in the idle path on OMAP3630Zoom3. And tested the global suspend/resume with offmode enabled. Usb basic functionality tested on OMAP4430SDP.
Quoted 8 lines
Quoted 4 lines
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
Tony and Greg, how do we handle this one ? Who should take my pull request for this series ? I hope we still have a little time to get this into 2.6.39, but if we don't I can hold on to them until 2.6.40.
Doesn't bother me which tree they go through, I can take them, or, if it's easier due to omap merges, Tony can.
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Tony Lindgren
maintainerQuoted 8 lines · Greg KH
Quoted 7 lines · Felipe Balbi
Quoted 5 lines · Hema HK
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
Quoted 6 lines
Quoted 3 lines
Tony and Greg, how do we handle this one ? Who should take my pull request for this series ? I hope we still have a little time to get this into 2.6.39, but if we don't I can hold on to them until 2.6.40.
Doesn't bother me which tree they go through, I can take them, or, if it's easier due to omap merges, Tony can.
I prefer Greg's queue unless there's some dependency issue to the patches we have in omap-for-linus.
Tony
Quoted 13 lines · Tony Lindgren
Quoted 12 lines · Greg KH
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · Hema HK
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
Tony and Greg, how do we handle this one ? Who should take my pull request for this series ? I hope we still have a little time to get this into 2.6.39, but if we don't I can hold on to them until 2.6.40.
Quoted 5 lines
Quoted 2 lines
Doesn't bother me which tree they go through, I can take them, or, if it's easier due to omap merges, Tony can.
I prefer Greg's queue unless there's some dependency issue to the patches we have in omap-for-linus.
If not, Felipe, send them on to me :)
thanks,
greg k-h
Quoted 14 lines · Greg KH
Quoted 13 lines · Tony Lindgren
Quoted 12 lines · Greg KH
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · Hema HK
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
Tony and Greg, how do we handle this one ? Who should take my pull request for this series ? I hope we still have a little time to get this into 2.6.39, but if we don't I can hold on to them until 2.6.40.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Doesn't bother me which tree they go through, I can take them, or, if it's easier due to omap merges, Tony can.
I prefer Greg's queue unless there's some dependency issue to the patches we have in omap-for-linus.
If not, Felipe, send them on to me :)
I'll prepare it today and clear any dependencies if there are any :-)
Signature · 1 line
balbi
Quoted 13 lines · Tony Lindgren
Quoted 12 lines · Greg KH
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · Hema HK
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
Tony and Greg, how do we handle this one ? Who should take my pull request for this series ? I hope we still have a little time to get this into 2.6.39, but if we don't I can hold on to them until 2.6.40.
Quoted 5 lines
Quoted 2 lines
Doesn't bother me which tree they go through, I can take them, or, if it's easier due to omap merges, Tony can.
I prefer Greg's queue unless there's some dependency issue to the patches we have in omap-for-linus.
Turns out I can easily split what's supposed to go for you and what's supposed to go for Greg, so I'll do it. Tony which commit can I use for your tree ? Is mainline 2.6.38-rc6 ok ?
Signature · 5 lines
balbi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 17 lines · Felipe Balbi
Quoted 16 lines · Tony Lindgren
Quoted 14 lines · Greg KH
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · Hema HK
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
Tony and Greg, how do we handle this one ? Who should take my pull request for this series ? I hope we still have a little time to get this into 2.6.39, but if we don't I can hold on to them until 2.6.40.
Doesn't bother me which tree they go through, I can take them, or, if it's easier due to omap merges, Tony can.
Quoted 6 lines
Quoted 2 lines
I prefer Greg's queue unless there's some dependency issue to the patches we have in omap-for-linus.
Turns out I can easily split what's supposed to go for you and what's supposed to go for Greg, so I'll do it. Tony which commit can I use for your tree ? Is mainline 2.6.38-rc6 ok ?
Forget it, there's a dependency on a patch which is in Greg's queue, so I'll send them all through Greg.
Signature · 1 line
balbi
Felipe Balbi
AppliedQuoted 20 lines · Hema HK
This patch series supports the retention and offmode support in the idle path for musb driver using runtime pm APIs.
This is restricted to support offmode and retention only when device not connected.When device/cable connected with gadget driver loaded, configured to no idle/standby which will not allow the core transition to retention or off.
There is no context save/restore done by hardware for musb in OMAP3 and OMAP4,driver has to take care of saving and restoring the context during offmode.
Musb has a requirement of configuring sysconfig register to force idle/standby mode and set the
ENABLE_FORCEbit in module STANDBY register for retention and offmode support.Runtime pm and hwmod frameworks will take care of configuring to force idle/standby when
pm_runtime_put_syncis called and back to no idle/standby whenpm_runeime_get_syncis called.
Quoted 8 lines
Compile, boot tested and also tested the retention in the idle path on OMAP3630Zoom3. And tested the global suspend/resume with offmode enabled. Usb basic functionality tested on OMAP4430SDP.
There is some problem with idle path offmode in mainline, I could not test with offmode. But I have tested this patch with resetting the controller in the idle path when wakeup from retention just to make sure that the context is lost, and restore path is working fine.
applied, thanks
Signature · 5 lines
balbi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html