[linux-yocto] [PATCH 10/29] usb: dwc3: pci: Enable/disable ulpi phy refclk
rebecca.swee.fun.chang at intel.com
rebecca.swee.fun.chang at intel.com
Mon Apr 7 08:18:01 PDT 2014
From: Maurice Petallo <mauricex.r.petallo at intel.com>
Due to power saving purpose, BIOS disabled ulpi phy refclk by default.
Hence, the refclk will only be enabled during device/driver probing.
and disabled during driver removal.
Signed-off-by: Maurice Petallo <mauricex.r.petallo at intel.com>
Signed-off-by: Chew, Chiau Ee <chiau.ee.chew at intel.com>
---
drivers/usb/dwc3/dwc3-pci.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 2357c4e..4ebe49a 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -51,6 +51,10 @@
#define PCI_DEVICE_ID_INTEL_BYT 0x0f37
#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e
+#define DWC3_PCI_GEN_REGRW1 0xa0
+#define DWC3_PCI_GEN_REGRW1_REFCLK_EN(n) (n & 0xfffdffff)
+#define DWC3_PCI_GEN_REGRW1_REFCLK_DIS(n) (n | 0x020000)
+
struct dwc3_pci {
struct device *dev;
struct platform_device *dwc3;
@@ -112,6 +116,19 @@ err1:
return ret;
}
+static void dwc3_pci_ulpiphy_refclk(struct pci_dev *pci, int enable)
+{
+ u32 val;
+
+ pci_read_config_dword(pci, DWC3_PCI_GEN_REGRW1, &val);
+ if (enable)
+ val = DWC3_PCI_GEN_REGRW1_REFCLK_EN(val);
+ else
+ val = DWC3_PCI_GEN_REGRW1_REFCLK_DIS(val);
+
+ pci_write_config_dword(pci, DWC3_PCI_GEN_REGRW1, val);
+}
+
static int dwc3_pci_probe(struct pci_dev *pci,
const struct pci_device_id *id)
{
@@ -183,6 +200,9 @@ static int dwc3_pci_probe(struct pci_dev *pci,
goto err3;
}
+ /* enable ulpi phy refclk */
+ dwc3_pci_ulpiphy_refclk(pci, 1);
+
return 0;
err3:
@@ -198,6 +218,9 @@ static void dwc3_pci_remove(struct pci_dev *pci)
{
struct dwc3_pci *glue = pci_get_drvdata(pci);
+ /* disable ulpi phy refclk */
+ dwc3_pci_ulpiphy_refclk(pci, 0);
+
platform_device_unregister(glue->dwc3);
platform_device_unregister(glue->usb2_phy);
platform_device_unregister(glue->usb3_phy);
--
1.7.10.4
More information about the linux-yocto
mailing list