phy: exynos-usb2: add vbus regulator support
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 21 Aug 2015 12:38:37 +0000 (14:38 +0200)
committerKishon Vijay Abraham I <kishon@ti.com>
Tue, 6 Oct 2015 14:51:47 +0000 (20:21 +0530)
Exynos USB2 PHY has separate power supply, which is usually provided by
VBUS regulator. This patch adds support for it. VBUS regulator is
optional, to keep compatibility with boards, which have VBUS provided
from some always-on power source.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Documentation/devicetree/bindings/phy/samsung-phy.txt
drivers/phy/phy-samsung-usb2.c
drivers/phy/phy-samsung-usb2.h

index 60c6f2a633e02d7b7179ec45c7b31bcda378f802..0289d3b07853e73f494106aca13780899a508abc 100644 (file)
@@ -44,6 +44,9 @@ Required properties:
        - the "ref" clock is used to get the rate of the clock provided to the
          PHY module
 
+Optional properties:
+- vbus-supply: power-supply phandle for vbus power source
+
 The first phandle argument in the PHY specifier identifies the PHY, its
 meaning is compatible dependent. For the currently supported SoCs (Exynos 4210
 and Exynos 4212) it is as follows:
index f278a9c547e199c6228081f3445133dcdd9cda46..1d22d93b552d759df577a26228f0e7c7464c83c9 100644 (file)
@@ -27,6 +27,13 @@ static int samsung_usb2_phy_power_on(struct phy *phy)
 
        dev_dbg(drv->dev, "Request to power_on \"%s\" usb phy\n",
                inst->cfg->label);
+
+       if (drv->vbus) {
+               ret = regulator_enable(drv->vbus);
+               if (ret)
+                       goto err_regulator;
+       }
+
        ret = clk_prepare_enable(drv->clk);
        if (ret)
                goto err_main_clk;
@@ -48,6 +55,9 @@ err_power_on:
 err_instance_clk:
        clk_disable_unprepare(drv->clk);
 err_main_clk:
+       if (drv->vbus)
+               regulator_disable(drv->vbus);
+err_regulator:
        return ret;
 }
 
@@ -55,7 +65,7 @@ static int samsung_usb2_phy_power_off(struct phy *phy)
 {
        struct samsung_usb2_phy_instance *inst = phy_get_drvdata(phy);
        struct samsung_usb2_phy_driver *drv = inst->drv;
-       int ret;
+       int ret = 0;
 
        dev_dbg(drv->dev, "Request to power_off \"%s\" usb phy\n",
                inst->cfg->label);
@@ -68,7 +78,10 @@ static int samsung_usb2_phy_power_off(struct phy *phy)
        }
        clk_disable_unprepare(drv->ref_clk);
        clk_disable_unprepare(drv->clk);
-       return 0;
+       if (drv->vbus)
+               ret = regulator_disable(drv->vbus);
+
+       return ret;
 }
 
 static const struct phy_ops samsung_usb2_phy_ops = {
@@ -203,6 +216,14 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
                        return ret;
        }
 
+       drv->vbus = devm_regulator_get(dev, "vbus");
+       if (IS_ERR(drv->vbus)) {
+               ret = PTR_ERR(drv->vbus);
+               if (ret == -EPROBE_DEFER)
+                       return ret;
+               drv->vbus = NULL;
+       }
+
        for (i = 0; i < drv->cfg->num_phys; i++) {
                char *label = drv->cfg->phys[i].label;
                struct samsung_usb2_phy_instance *p = &drv->instances[i];
index 44bead9b8f34bb426440431217fa989a0f839734..6563e7ca0ac444824f4185277a33c1a5fee6a1bd 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/device.h>
 #include <linux/regmap.h>
 #include <linux/spinlock.h>
+#include <linux/regulator/consumer.h>
 
 #define KHZ 1000
 #define MHZ (KHZ * KHZ)
@@ -37,6 +38,7 @@ struct samsung_usb2_phy_driver {
        const struct samsung_usb2_phy_config *cfg;
        struct clk *clk;
        struct clk *ref_clk;
+       struct regulator *vbus;
        unsigned long ref_rate;
        u32 ref_reg_val;
        struct device *dev;
This page took 0.027108 seconds and 5 git commands to generate.