* [PATCH 1/2] usb: mxs-phy: add set_suspend API @ 2013-01-18 2:50 Peter Chen 2013-01-18 2:50 ` [PATCH 2/2] usb: chipidea: imx: Add system suspend/resume API Peter Chen 0 siblings, 1 reply; 5+ messages in thread From: Peter Chen @ 2013-01-18 2:50 UTC (permalink / raw) To: linux-arm-kernel It needs to call set_suspend during USB suspend/resume Signed-off-by: Peter Chen <peter.chen@freescale.com> --- drivers/usb/otg/mxs-phy.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c index 7630272..5158332 100644 --- a/drivers/usb/otg/mxs-phy.c +++ b/drivers/usb/otg/mxs-phy.c @@ -76,6 +76,25 @@ static void mxs_phy_shutdown(struct usb_phy *phy) clk_disable_unprepare(mxs_phy->clk); } +static int mxs_phy_suspend(struct usb_phy *x, int suspend) +{ + struct mxs_phy *mxs_phy = to_mxs_phy(x); + + if (suspend) { + writel_relaxed(0xffffffff, x->io_priv + HW_USBPHY_PWD); + writel_relaxed(BM_USBPHY_CTRL_CLKGATE, + x->io_priv + HW_USBPHY_CTRL_SET); + clk_disable_unprepare(mxs_phy->clk); + } else { + clk_prepare_enable(mxs_phy->clk); + writel_relaxed(BM_USBPHY_CTRL_CLKGATE, + x->io_priv + HW_USBPHY_CTRL_CLR); + writel_relaxed(0, x->io_priv + HW_USBPHY_PWD); + } + + return 0; +} + static int mxs_phy_on_connect(struct usb_phy *phy, enum usb_device_speed speed) { @@ -137,6 +156,7 @@ static int mxs_phy_probe(struct platform_device *pdev) mxs_phy->phy.label = DRIVER_NAME; mxs_phy->phy.init = mxs_phy_init; mxs_phy->phy.shutdown = mxs_phy_shutdown; + mxs_phy->phy.set_suspend = mxs_phy_suspend; mxs_phy->phy.notify_connect = mxs_phy_on_connect; mxs_phy->phy.notify_disconnect = mxs_phy_on_disconnect; -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] usb: chipidea: imx: Add system suspend/resume API 2013-01-18 2:50 [PATCH 1/2] usb: mxs-phy: add set_suspend API Peter Chen @ 2013-01-18 2:50 ` Peter Chen 2013-01-18 3:35 ` Shawn Guo 2013-01-18 10:59 ` Russell King - ARM Linux 0 siblings, 2 replies; 5+ messages in thread From: Peter Chen @ 2013-01-18 2:50 UTC (permalink / raw) To: linux-arm-kernel During the system suspend/resume procedure, the USB also needs to go suspend/resume procedure, this patch adds related APIs. It is tested at i.mx6q sabrelite. Meanwhile, it fixes the bug that the USB will out of work after system suspend/resume. Signed-off-by: Peter Chen <peter.chen@freescale.com> --- drivers/usb/chipidea/bits.h | 1 + drivers/usb/chipidea/ci13xxx_imx.c | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 0 deletions(-) diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h index ba9c6ef..d1467bb 100644 --- a/drivers/usb/chipidea/bits.h +++ b/drivers/usb/chipidea/bits.h @@ -47,6 +47,7 @@ #define PORTSC_FPR BIT(6) #define PORTSC_SUSP BIT(7) #define PORTSC_HSP BIT(9) +#define PORTSC_PHCD BIT(23) /* phy suspend mode */ #define PORTSC_PTC (0x0FUL << 16) /* DEVLC */ diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index 342eab0..e892874 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -25,6 +25,7 @@ #include <linux/mfd/syscon.h> #include "ci.h" +#include "bits.h" #include "ci13xxx_imx.h" #define pdev_to_phy(pdev) \ @@ -321,6 +322,63 @@ static int ci13xxx_imx_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int ci13xxx_imx_suspend(struct device *dev) +{ + struct ci13xxx_imx_data *data = + platform_get_drvdata(to_platform_device(dev)); + struct platform_device *plat_ci; + struct ci13xxx *ci; + + plat_ci = data->ci_pdev; + ci = platform_get_drvdata(plat_ci); + + hw_write(ci, OP_PORTSC, PORTSC_PHCD, PORTSC_PHCD); + + if (data->phy) + usb_phy_set_suspend(data->phy, 1); + + clk_disable_unprepare(data->clk); + + return 0; +} + +static int ci13xxx_imx_resume(struct device *dev) +{ + int ret; + struct ci13xxx_imx_data *data = + platform_get_drvdata(to_platform_device(dev)); + struct platform_device *plat_ci; + struct ci13xxx *ci; + + plat_ci = data->ci_pdev; + ci = platform_get_drvdata(plat_ci); + + ret = clk_prepare_enable(data->clk); + if (ret) { + dev_err(dev, + "Failed to prepare or enable clock, err=%d\n", ret); + return ret; + } + + if (hw_read(ci, OP_PORTSC, PORTSC_PHCD)) { + hw_write(ci, OP_PORTSC, PORTSC_PHCD, 0); + /* Some clks sync between Controller and USB PHY */ + mdelay(1); + } + + if (data->phy) + usb_phy_set_suspend(data->phy, 0); + + return ret; +} + +static const struct dev_pm_ops ci13xxx_imx_pm_ops = { + .suspend = ci13xxx_imx_suspend, + .resume = ci13xxx_imx_resume, +}; +#endif + static const struct of_device_id ci13xxx_imx_dt_ids[] = { { .compatible = "fsl,imx27-usb", }, { /* sentinel */ } @@ -334,6 +392,9 @@ static struct platform_driver ci13xxx_imx_driver = { .name = "imx_usb", .owner = THIS_MODULE, .of_match_table = ci13xxx_imx_dt_ids, +#ifdef CONFIG_PM + .pm = &ci13xxx_imx_pm_ops, +#endif }, }; -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] usb: chipidea: imx: Add system suspend/resume API 2013-01-18 2:50 ` [PATCH 2/2] usb: chipidea: imx: Add system suspend/resume API Peter Chen @ 2013-01-18 3:35 ` Shawn Guo 2013-01-18 10:59 ` Russell King - ARM Linux 1 sibling, 0 replies; 5+ messages in thread From: Shawn Guo @ 2013-01-18 3:35 UTC (permalink / raw) To: linux-arm-kernel On Fri, Jan 18, 2013 at 10:50:28AM +0800, Peter Chen wrote: > During the system suspend/resume procedure, the USB also > needs to go suspend/resume procedure, this patch adds > related APIs. It is tested at i.mx6q sabrelite. Meanwhile, > it fixes the bug that the USB will out of work after > system suspend/resume. > > Signed-off-by: Peter Chen <peter.chen@freescale.com> Haven't reviewed the patches, but I've seen the series fix an imx6q USB issue - the USB will be broken after system suspend/resume operation as below. So for both patches, Tested-by: Shawn Guo <shawn.guo@linaro.org> Shawn $ echo mem > /sys/power/state PM: Syncing filesystems ... done. PM: Preparing system for mem sleep mmc0: card a8a5 removed mmc1: card b368 removed Freezing user space processes ... (elapsed 0.01 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done. PM: Entering mem sleep fec_stop : Graceful transmit stop did not complete ! PM: suspend of devices complete after 14.490 msecs PM: suspend devices took 0.020 seconds PM: late suspend of devices complete after 1.645 msecs PM: noirq suspend of devices complete after 2.432 msecs Disabling non-boot CPUs ... CPU1: shutdown CPU2: shutdown CPU3: shutdown Enabling non-boot CPUs ... CPU1: Booted secondary processor CPU1 is up CPU2: Booted secondary processor CPU2 is up CPU3: Booted secondary processor CPU3 is up PM: noirq resume of devices complete after 1.217 msecs PM: early resume of devices complete after 1.590 msecs hub 2-1:1.0: hub_port_status failed (err = -71) hub 2-1:1.0: hub_port_status failed (err = -71) hub 2-1:1.0: hub_port_status failed (err = -71) PM: resume of devices complete after 70.677 msecs PM: resume devices took 0.080 seconds PM: Finishing wakeup. Restarting tasks ... done. mmc0: new high speed SDHC card at address a8a5 mmcblk0: mmc0:a8a5 SD04G 3.69 GiB mmcblk0: p1 p2 p3 mmc1: SD Status: Invalid Allocation Unit size. mmc1: card lacks mandatory switch function, performance might suffer. mmc1: new SD card at address b368 mmcblk1: mmc1:b368 MS 121 MiB mmcblk1: p1 root at freescale ~$ ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 hub 2-0:1.0: Cannot enable port 1. Maybe the USB cable is bad? ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 hub 2-0:1.0: Cannot enable port 1. Maybe the USB cable is bad? ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 hub 2-0:1.0: Cannot enable port 1. Maybe the USB cable is bad? ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 ci_hdrc ci_hdrc.1: port 1 reset error -110 hub 2-0:1.0: Cannot enable port 1. Maybe the USB cable is bad? hub 2-1:1.0: hub_port_status failed (err = -19) hub 2-1:1.0: hub_port_status failed (err = -19) hub 2-1:1.0: hub_port_status failed (err = -19) hub 2-1:1.0: activate --> -19 usb 2-1: USB disconnect, device number 2 ... ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] usb: chipidea: imx: Add system suspend/resume API 2013-01-18 2:50 ` [PATCH 2/2] usb: chipidea: imx: Add system suspend/resume API Peter Chen 2013-01-18 3:35 ` Shawn Guo @ 2013-01-18 10:59 ` Russell King - ARM Linux 2013-01-18 12:12 ` Chen Peter-B29397 1 sibling, 1 reply; 5+ messages in thread From: Russell King - ARM Linux @ 2013-01-18 10:59 UTC (permalink / raw) To: linux-arm-kernel On Fri, Jan 18, 2013 at 10:50:28AM +0800, Peter Chen wrote: > +#ifdef CONFIG_PM > +static int ci13xxx_imx_suspend(struct device *dev) > +{ > + struct ci13xxx_imx_data *data = > + platform_get_drvdata(to_platform_device(dev)); Is there a reason not to use dev_get_drvdata() here? Hint: #define to_platform_device(x) container_of((x), struct platform_device, dev) static inline void *platform_get_drvdata(const struct platform_device *pdev) { return dev_get_drvdata(&pdev->dev); } So, you're going from a dev => platform device => the same dev again. It's perfectly valid to use dev_get_drvdata() here because we're not going to separate these two (it makes absolutely no sense to.) ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] usb: chipidea: imx: Add system suspend/resume API 2013-01-18 10:59 ` Russell King - ARM Linux @ 2013-01-18 12:12 ` Chen Peter-B29397 0 siblings, 0 replies; 5+ messages in thread From: Chen Peter-B29397 @ 2013-01-18 12:12 UTC (permalink / raw) To: linux-arm-kernel > > On Fri, Jan 18, 2013 at 10:50:28AM +0800, Peter Chen wrote: > > +#ifdef CONFIG_PM > > +static int ci13xxx_imx_suspend(struct device *dev) > > +{ > > + struct ci13xxx_imx_data *data = > > + platform_get_drvdata(to_platform_device(dev)); > > Is there a reason not to use dev_get_drvdata() here? Hint: > It is my careless, I will change. Thanks. > #define to_platform_device(x) container_of((x), struct platform_device, > dev) > > static inline void *platform_get_drvdata(const struct platform_device > *pdev) > { > return dev_get_drvdata(&pdev->dev); > } > > So, you're going from a dev => platform device => the same dev again. > > It's perfectly valid to use dev_get_drvdata() here because we're not > going > to separate these two (it makes absolutely no sense to.) ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-01-18 12:12 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-01-18 2:50 [PATCH 1/2] usb: mxs-phy: add set_suspend API Peter Chen 2013-01-18 2:50 ` [PATCH 2/2] usb: chipidea: imx: Add system suspend/resume API Peter Chen 2013-01-18 3:35 ` Shawn Guo 2013-01-18 10:59 ` Russell King - ARM Linux 2013-01-18 12:12 ` Chen Peter-B29397
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).