From db63a7500a9a0e4c38799819592ac594b77e49eb Mon Sep 17 00:00:00 2001 From: Ramneek Mehresh Date: Tue, 24 Mar 2015 17:53:15 +0530 Subject: drivers:usb:pm: Fix usb pm support for deep-sleep Make sure that saving and restoration of usb phy registers only happen in case of deep-sleep, and not for any other feature like sleep, etc. Also export pm_suspend_state() and set_pm_suspend_state() Signed-off-by: Ramneek Mehresh Change-Id: I2e08208c975ec7aee7ed42e7d424aaa8d14899e3 Reviewed-on: http://git.am.freescale.net:8181/33384 Reviewed-by: Nikhil Badola Tested-by: Honghua Yin Reviewed-by: Honghua Yin diff --git a/arch/powerpc/kernel/fsl_pm.c b/arch/powerpc/kernel/fsl_pm.c index 1d19b85..dd68054 100644 --- a/arch/powerpc/kernel/fsl_pm.c +++ b/arch/powerpc/kernel/fsl_pm.c @@ -19,8 +19,10 @@ void set_pm_suspend_state(suspend_state_t state) { pm_state = state; } +EXPORT_SYMBOL_GPL(set_pm_suspend_state); suspend_state_t pm_suspend_state(void) { return pm_state; } +EXPORT_SYMBOL_GPL(pm_suspend_state); diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 07bdd3a..c19ddd6 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -31,8 +31,11 @@ #include #include #include + #ifdef CONFIG_PPC #include +#include +#include #endif #include "ehci-fsl.h" @@ -534,6 +537,7 @@ static int ehci_fsl_setup(struct usb_hcd *hcd) #ifdef CONFIG_PM void __iomem *phy_reg; +#ifdef CONFIG_PPC /* save usb registers */ static int ehci_fsl_save_context(struct usb_hcd *hcd) { @@ -578,6 +582,7 @@ static int ehci_fsl_restore_context(struct usb_hcd *hcd) iowrite32be(ehci_fsl->usb_ctrl, non_ehci + FSL_SOC_USB_CTRL); return 0; } +#endif #ifdef CONFIG_PPC_MPC512x static int ehci_fsl_mpc512x_drv_suspend(struct device *dev) @@ -729,13 +734,18 @@ static int ehci_fsl_drv_suspend(struct device *dev) struct usb_hcd *hcd = dev_get_drvdata(dev); struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd); void __iomem *non_ehci = hcd->regs; - - ehci_fsl_save_context(hcd); - #if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE) struct usb_bus host = hcd->self; #endif +#ifdef CONFIG_PPC + suspend_state_t pm_state; + pm_state = pm_suspend_state(); + + if (pm_state == PM_SUSPEND_MEM) + ehci_fsl_save_context(hcd); +#endif + if (of_device_is_compatible(dev->parent->of_node, "fsl,mpc5121-usb2-dr")) { return ehci_fsl_mpc512x_drv_suspend(dev); @@ -772,13 +782,18 @@ static int ehci_fsl_drv_resume(struct device *dev) struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd); struct ehci_hcd *ehci = hcd_to_ehci(hcd); void __iomem *non_ehci = hcd->regs; - - ehci_fsl_restore_context(hcd); - #if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE) struct usb_bus host = hcd->self; #endif +#ifdef CONFIG_PPC + suspend_state_t pm_state; + pm_state = pm_suspend_state(); + + if (pm_state == PM_SUSPEND_MEM) + ehci_fsl_restore_context(hcd); +#endif + if (of_device_is_compatible(dev->parent->of_node, "fsl,mpc5121-usb2-dr")) { return ehci_fsl_mpc512x_drv_resume(dev); -- cgit v0.10.2