[PATCH 17/21] usb: core: add runtime pm support for Intel Medfield platform

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andy Luo <yifei.luo@xxxxxxxxx>

This patch enables runtime pm support for usb host driver

Signed-off-by: Andy Luo <yifei.luo@xxxxxxxxx>
Signed-off-by: Hao Wu <hao.wu@xxxxxxxxx>
---
 drivers/usb/core/hcd-pci.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 3799573..efa388c 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -339,7 +339,7 @@ EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown);
 #ifdef	CONFIG_PM_OPS
 
 #ifdef	CONFIG_PPC_PMAC
-static void powermac_set_asic(struct pci_dev *pci_dev, int enable)
+static void hcd_pci_set_platform_config(struct pci_dev *pci_dev, int enable)
 {
 	/* Enanble or disable ASIC clocks for USB */
 	if (machine_is(powermac)) {
@@ -352,9 +352,25 @@ static void powermac_set_asic(struct pci_dev *pci_dev, int enable)
 	}
 }
 
-#else
+#elif defined(CONFIG_X86_MRST)
+static void hcd_pci_set_platform_config(struct pci_dev *pci_dev, int enable)
+{
+	/* Check if it is Intel Medfield platform */
+	if (pci_dev->vendor == PCI_VENDOR_ID_INTEL &&
+				pci_dev->device == 0x0829) {
+		if (enable) {
+			pci_restore_state(pci_dev);
+			pci_set_power_state(pci_dev, PCI_D0);
+		} else {
+			pci_save_state(pci_dev);
+			pci_set_power_state(pci_dev, PCI_D3hot);
+		}
+	}
+}
 
-static inline void powermac_set_asic(struct pci_dev *pci_dev, int enable)
+#else
+static inline void hcd_pci_set_platform_config(struct pci_dev *pci_dev,
+						int enable)
 {}
 
 #endif	/* CONFIG_PPC_PMAC */
@@ -493,7 +509,7 @@ static int hcd_pci_suspend_noirq(struct device *dev)
 		return retval;
 	}
 
-	powermac_set_asic(pci_dev, 0);
+	hcd_pci_set_platform_config(pci_dev, 0);
 	return retval;
 }
 
@@ -501,7 +517,7 @@ static int hcd_pci_resume_noirq(struct device *dev)
 {
 	struct pci_dev		*pci_dev = to_pci_dev(dev);
 
-	powermac_set_asic(pci_dev, 1);
+	hcd_pci_set_platform_config(pci_dev, 1);
 
 	/* Go back to D0 and disable remote wakeup */
 	pci_back_from_sleep(pci_dev);
@@ -536,7 +552,7 @@ static int hcd_pci_runtime_suspend(struct device *dev)
 
 	retval = suspend_common(dev, true);
 	if (retval == 0)
-		powermac_set_asic(to_pci_dev(dev), 0);
+		hcd_pci_set_platform_config(to_pci_dev(dev), 0);
 	dev_dbg(dev, "hcd_pci_runtime_suspend: %d\n", retval);
 	return retval;
 }
@@ -545,7 +561,7 @@ static int hcd_pci_runtime_resume(struct device *dev)
 {
 	int	retval;
 
-	powermac_set_asic(to_pci_dev(dev), 1);
+	hcd_pci_set_platform_config(to_pci_dev(dev), 1);
 	retval = resume_common(dev, PM_EVENT_AUTO_RESUME);
 	dev_dbg(dev, "hcd_pci_runtime_resume: %d\n", retval);
 	return retval;
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux