usb: mxs-phy: add set_suspend API
PATCH 1/2 usb: mxs-phy: add set_suspend API
It needs to call set_suspend during USB suspend/resume
--- drivers/usb/otg/mxs-phy.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/usb/otg/mxs-phy.c +20 -0
@@ -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;
Signature · 1 line
1.7.0.4
PATCH 2/2 usb: chipidea: imx: Add system suspend/resume API
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.
--- drivers/usb/chipidea/bits.h | 1 + drivers/usb/chipidea/ci13xxx_imx.c | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 0 deletions(-)
drivers/usb/chipidea/bits.h +1 -0
@@ -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 */
drivers/usb/chipidea/ci13xxx_imx.c +61 -0
79 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 2/2 usb: chipidea: imx: Add system suspend/resume API
Quoted 7 lines · Peter Chen
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 <[email protected]>
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,
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 ...
PATCH 2/2 usb: chipidea: imx: Add system suspend/resume API
In reply to Peter Chendrivers/usb/chipidea/ci13xxx_imx.c static int ci13xxx_imx_remove(struct platform_device *pdev) · line 329
Quoted 5 lines · Peter Chen
drivers/usb/chipidea/ci13xxx_imx.c +5
-0+#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.)
PATCH 2/2 usb: chipidea: imx: Add system suspend/resume API
Quoted 11 lines · Peter Chen
drivers/usb/chipidea/ci13xxx_imx.c static int ci13xxx_imx_remove(struct platform_device *pdev) · line 329
Quoted 5 lines
drivers/usb/chipidea/ci13xxx_imx.c +5
-0+#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.
Quoted 14 lines
#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.)