FROMLIST: phy: rockchip-usb: use rockchip_usb_phy_reset to reset phy during wakeup
[firefly-linux-kernel-4.4.55.git] / drivers / phy / phy-rockchip-usb.c
index 39f419d6d4844c684ba5d04d75182617c5cb14c0..898683414f47a09b86ae68348b3827802326dd9e 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/reset.h>
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
+#include <linux/delay.h>
 
 /*
  * The higher 16-bit of this register is used for write protection
@@ -74,6 +75,7 @@ struct rockchip_usb_phy {
        struct clk      *clk480m;
        struct clk_hw   clk480m_hw;
        struct phy      *phy;
+       struct reset_control *reset;
 };
 
 static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
@@ -172,9 +174,23 @@ static int rockchip_usb_phy_power_on(struct phy *_phy)
        return ret;
 }
 
+static int rockchip_usb_phy_reset(struct phy *_phy)
+{
+       struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
+
+       if (phy->reset) {
+               reset_control_assert(phy->reset);
+               udelay(10);
+               reset_control_deassert(phy->reset);
+       }
+
+       return 0;
+}
+
 static const struct phy_ops ops = {
        .power_on       = rockchip_usb_phy_power_on,
        .power_off      = rockchip_usb_phy_power_off,
+       .reset          = rockchip_usb_phy_reset,
        .owner          = THIS_MODULE,
 };
 
@@ -211,6 +227,10 @@ static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base,
                return -EINVAL;
        }
 
+       rk_phy->reset = of_reset_control_get(child, "phy-reset");
+       if (IS_ERR(rk_phy->reset))
+               rk_phy->reset = NULL;
+
        rk_phy->reg_offset = reg_offset;
 
        rk_phy->clk = of_clk_get_by_name(child, "phyclk");