MLK-10196-4 usb: phy: mxs: Using regulator phy-3p0
authorPeter Chen <peter.chen@freescale.com>
Tue, 3 Feb 2015 02:10:53 +0000 (10:10 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:04 +0000 (14:47 -0500)
It is one of PHY's power, and we need to enable it to keep signal
quality good, and pass eye diagram test.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
(cherry picked from commit 3a8670ee7ff698521369e8292bba7ef288a12335)

drivers/usb/phy/phy-mxs-usb.c

index 4333ae3..8d79bcf 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
+#include <linux/regulator/consumer.h>
 
 #define DRIVER_NAME "mxs_phy"
 
@@ -177,6 +178,7 @@ struct mxs_phy {
        int port_id;
        u32 tx_reg_set;
        u32 tx_reg_mask;
+       struct regulator *phy_3p0;
 };
 
 static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
@@ -221,6 +223,16 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
        if (ret)
                return ret;
 
+       if (mxs_phy->phy_3p0) {
+               ret = regulator_enable(mxs_phy->phy_3p0);
+               if (ret) {
+                       dev_err(mxs_phy->phy.dev,
+                               "Failed to enable 3p0 regulator, ret=%d\n",
+                               ret);
+                       return ret;
+               }
+       }
+
        /* Power up the PHY */
        writel(0, base + HW_USBPHY_PWD);
 
@@ -365,6 +377,9 @@ static void mxs_phy_shutdown(struct usb_phy *phy)
        writel(BM_USBPHY_CTRL_CLKGATE,
               phy->io_priv + HW_USBPHY_CTRL_SET);
 
+       if (mxs_phy->phy_3p0)
+               regulator_disable(mxs_phy->phy_3p0);
+
        clk_disable_unprepare(mxs_phy->clk);
 }
 
@@ -616,6 +631,20 @@ static int mxs_phy_probe(struct platform_device *pdev)
                mxs_phy->phy.notify_resume = mxs_phy_on_resume;
        }
 
+       mxs_phy->phy_3p0 = devm_regulator_get(&pdev->dev, "phy-3p0");
+       if (PTR_ERR(mxs_phy->phy_3p0) == -EPROBE_DEFER) {
+               return -EPROBE_DEFER;
+       } else if (PTR_ERR(mxs_phy->phy_3p0) == -ENODEV) {
+               /* not exist */
+               mxs_phy->phy_3p0 = NULL;
+       } else if (IS_ERR(mxs_phy->phy_3p0)) {
+               dev_err(&pdev->dev, "Getting regulator error: %ld\n",
+                       PTR_ERR(mxs_phy->phy_3p0));
+               return PTR_ERR(mxs_phy->phy_3p0);
+       }
+       if (mxs_phy->phy_3p0)
+               regulator_set_voltage(mxs_phy->phy_3p0, 3200000, 3200000);
+
        platform_set_drvdata(pdev, mxs_phy);
 
        device_set_wakeup_capable(&pdev->dev, true);