This has been on my to-do list for sometime.
Until now the host controller (specifically ehci-exynos) is responsible
for enabling VBUS supply. This opens up one more issue which is, when
only ohci-exynos is enabled and ehci-exynosis disabled then VBUS was
never enabled (since ohci did not have the code to enabled the VBUS supply).
Rather it should be wise to move the VBUS related stuff to phy driver and
let phy take care of enabling it.
This patch series adds that VBUS regulator to phy-samsung-usb2 driver,
adds necessary binding information as well as vbus-supply properties
to phy nodes on exynos5250 systems.
Also we have removed the samsung,vbus-gpio property from usb2 (ehci) node
on exynos5250 systems.
**[The older code in ehci-exynos for vbus setting is left intact to keep
supporting older dt bindings].
Vivek Gautam (4):
Doc/devicetree: bindings: Update bindings information for USB3.0 DRD
PHY
phy: samsung-usb2: Add facility for VBUS supply
arm: dts: exynos5250: Use regulator for USB 2.0 VBUS supply
arm: dts: exynos5250: Remove vbus gpio property from usb 2.0 host
.../devicetree/bindings/phy/samsung-phy.txt | 12 ++++++++
arch/arm/boot/dts/exynos5250-smdk5250.dts | 22 ++++++++++++--
arch/arm/boot/dts/exynos5250-snow.dts | 22 ++++++++++++--
drivers/phy/phy-samsung-usb2.c | 30 ++++++++++++++++++++
drivers/phy/phy-samsung-usb2.h | 1 +
5 files changed, 83 insertions(+), 4 deletions(-)
--
1.7.10.4
Add missing VBUS-supply information and consumer usage information for
USB 3.0 DRD PHY.
Signed-off-by: Vivek Gautam <[email protected]>
---
Documentation/devicetree/bindings/phy/samsung-phy.txt | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index d5bad92..0090ad1 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -148,6 +148,9 @@ Required properties:
control pmu registers for power isolation.
- #phy-cells : from the generic PHY bindings, must be 1;
+Optional properties:
+- vbus-supply : Reference to regulator node which supplies VBUS on the PHY.
+
For "samsung,exynos5250-usbdrd-phy" and "samsung,exynos5420-usbdrd-phy"
compatible PHYs, the second cell in the PHY specifier identifies the
PHY id, which is interpreted as follows:
@@ -164,6 +167,12 @@ Example:
#phy-cells = <1>;
};
+Then the PHY can be used in other nodes such as:
+ phy-consumer@12340000 {
+ phys = <&usbdrd_phy 0>, <&usbdrd_phy 1>;
+ phy-names = "usb2-phy", "usb3-phy";
+ };
+
- aliases: For SoCs like Exynos5420 having multiple USB 3.0 DRD PHY controllers,
'usbdrd_phy' nodes should have numbered alias in the aliases node,
in the form of usbdrdphyN, N = 0, 1... (depending on number of
--
1.7.10.4
Adding support to enable/disable VBUS controlled by a regulator
on USB 2.0 port.
This is a part of moving vbus setting out of ehci-exynos.
Since vbus can be handled by USB 2.0 phy itself, so the host
need not care about it.
Moreover, setting VBUS in USB 2.0 phy helps both ehci as well
as ohci. This issue was not taken care of until now; when
ehci is not enabled and only ohci is enabled the VBUS was never
set.
Keeping the vbus setting code in ehci-exynos intact for now
to keep supporting older dt bindings.
Signed-off-by: Vivek Gautam <[email protected]>
---
.../devicetree/bindings/phy/samsung-phy.txt | 3 ++
drivers/phy/phy-samsung-usb2.c | 30 ++++++++++++++++++++
drivers/phy/phy-samsung-usb2.h | 1 +
3 files changed, 34 insertions(+)
diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 0090ad1..44d82ba 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -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 : Reference to regulator node which supplies VBUS on the PHY.
+
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:
diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-samsung-usb2.c
index 4a12f66..7fe7c84 100644
--- a/drivers/phy/phy-samsung-usb2.c
+++ b/drivers/phy/phy-samsung-usb2.c
@@ -16,6 +16,7 @@
#include <linux/of_address.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
#include <linux/spinlock.h>
#include "phy-samsung-usb2.h"
@@ -33,6 +34,16 @@ static int samsung_usb2_phy_power_on(struct phy *phy)
ret = clk_prepare_enable(drv->ref_clk);
if (ret)
goto err_instance_clk;
+
+ /* Enable VBUS supply */
+ if (drv->vbus) {
+ ret = regulator_enable(drv->vbus);
+ if (ret) {
+ dev_err(drv->dev, "Failed to enable VBUS supply\n");
+ goto err_fail_vbus;
+ }
+ }
+
if (inst->cfg->power_on) {
spin_lock(&drv->lock);
ret = inst->cfg->power_on(inst);
@@ -41,6 +52,8 @@ static int samsung_usb2_phy_power_on(struct phy *phy)
return 0;
+err_fail_vbus:
+ clk_disable_unprepare(drv->ref_clk);
err_instance_clk:
clk_disable_unprepare(drv->clk);
err_main_clk:
@@ -60,8 +73,14 @@ static int samsung_usb2_phy_power_off(struct phy *phy)
ret = inst->cfg->power_off(inst);
spin_unlock(&drv->lock);
}
+
+ /* Disable VBUS supply */
+ if (drv->vbus)
+ regulator_disable(drv->vbus);
+
clk_disable_unprepare(drv->ref_clk);
clk_disable_unprepare(drv->clk);
+
return ret;
}
@@ -197,6 +216,17 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
return ret;
}
+ /* Get Vbus regulators */
+ drv->vbus = devm_regulator_get(dev, "vbus");
+ if (IS_ERR(drv->vbus)) {
+ ret = PTR_ERR(drv->vbus);
+ if (ret == -EPROBE_DEFER)
+ return ret;
+
+ dev_warn(dev, "Failed to get VBUS supply regulator\n");
+ 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];
diff --git a/drivers/phy/phy-samsung-usb2.h b/drivers/phy/phy-samsung-usb2.h
index 44bead9..cb92e3e 100644
--- a/drivers/phy/phy-samsung-usb2.h
+++ b/drivers/phy/phy-samsung-usb2.h
@@ -43,6 +43,7 @@ struct samsung_usb2_phy_driver {
void __iomem *reg_phy;
struct regmap *reg_pmu;
struct regmap *reg_sys;
+ struct regulator *vbus;
spinlock_t lock;
struct samsung_usb2_phy_instance instances[0];
};
--
1.7.10.4
Start using VBUS regulator for USB 2.0 phy, so that we can
remove the gpio property from host's node later.
Signed-off-by: Vivek Gautam <[email protected]>
---
arch/arm/boot/dts/exynos5250-smdk5250.dts | 22 ++++++++++++++++++++++
arch/arm/boot/dts/exynos5250-snow.dts | 22 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts b/arch/arm/boot/dts/exynos5250-smdk5250.dts
index a759100..85e74df 100644
--- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
+++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
@@ -361,6 +361,17 @@
samsung,audio-codec = <&wm8994>;
};
+ usb2_vbus_reg: regulator-usb2 {
+ compatible = "regulator-fixed";
+ regulator-name = "P5.0V_USB2";
+ regulator-min-microvolt = <5000000>;
+ regulator-max-microvolt = <5000000>;
+ gpio = <&gpx2 6 0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&usb2_vbus_en>;
+ enable-active-high;
+ };
+
usb@12110000 {
samsung,vbus-gpio = <&gpx2 6 0>;
};
@@ -418,4 +429,15 @@
samsung,pin-pud = <0>;
samsung,pin-drv = <0>;
};
+
+ usb2_vbus_en: usb2-vbus-en {
+ samsung,pins = "gpx2-6";
+ samsung,pin-function = <1>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+};
+
+&usb2_phy_gen {
+ vbus-supply = <&usb2_vbus_reg>;
};
diff --git a/arch/arm/boot/dts/exynos5250-snow.dts b/arch/arm/boot/dts/exynos5250-snow.dts
index 60429ad..8085750 100644
--- a/arch/arm/boot/dts/exynos5250-snow.dts
+++ b/arch/arm/boot/dts/exynos5250-snow.dts
@@ -285,6 +285,17 @@
vbus-supply = <&usb3_vbus_reg>;
};
+ usb2_vbus_reg: regulator-usb2 {
+ compatible = "regulator-fixed";
+ regulator-name = "P5.0V_USB2";
+ regulator-min-microvolt = <5000000>;
+ regulator-max-microvolt = <5000000>;
+ gpio = <&gpx1 1 0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&usb2_vbus_en>;
+ enable-active-high;
+ };
+
usb@12110000 {
samsung,vbus-gpio = <&gpx1 1 0>;
};
@@ -616,6 +627,13 @@
samsung,pin-pud = <0>;
samsung,pin-drv = <0>;
};
+
+ usb2_vbus_en: usb2-vbus-en {
+ samsung,pins = "gpx1-1";
+ samsung,pin-function = <1>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
};
&spi_1 {
@@ -628,4 +646,8 @@
dr_mode = "host";
};
+&usb2_phy_gen {
+ vbus-supply = <&usb2_vbus_reg>;
+};
+
#include "cros-ec-keyboard.dtsi"
--
1.7.10.4
Now that we can use the VBUS regulator for USB 2.0 phy, we can
remove the vbus-gpio property from usb 2.0 host to avoid
duplicate gpio settings.
Signed-off-by: Vivek Gautam <[email protected]>
---
arch/arm/boot/dts/exynos5250-smdk5250.dts | 4 ----
arch/arm/boot/dts/exynos5250-snow.dts | 4 ----
2 files changed, 8 deletions(-)
diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts b/arch/arm/boot/dts/exynos5250-smdk5250.dts
index 85e74df..281b962 100644
--- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
+++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
@@ -372,10 +372,6 @@
enable-active-high;
};
- usb@12110000 {
- samsung,vbus-gpio = <&gpx2 6 0>;
- };
-
dp-controller@145B0000 {
samsung,color-space = <0>;
samsung,dynamic-range = <0>;
diff --git a/arch/arm/boot/dts/exynos5250-snow.dts b/arch/arm/boot/dts/exynos5250-snow.dts
index 8085750..ee966c3 100644
--- a/arch/arm/boot/dts/exynos5250-snow.dts
+++ b/arch/arm/boot/dts/exynos5250-snow.dts
@@ -296,10 +296,6 @@
enable-active-high;
};
- usb@12110000 {
- samsung,vbus-gpio = <&gpx1 1 0>;
- };
-
fixed-rate-clocks {
xxti {
compatible = "samsung,clock-xxti";
--
1.7.10.4
From: Vivek Gautam
> This has been on my to-do list for sometime.
> Until now the host controller (specifically ehci-exynos) is responsible
> for enabling VBUS supply. This opens up one more issue which is, when
> only ohci-exynos is enabled and ehci-exynosis disabled then VBUS was
> never enabled (since ohci did not have the code to enabled the VBUS supply).
>
> Rather it should be wise to move the VBUS related stuff to phy driver and
> let phy take care of enabling it.
>
> This patch series adds that VBUS regulator to phy-samsung-usb2 driver,
> adds necessary binding information as well as vbus-supply properties
> to phy nodes on exynos5250 systems.
...
Does this go anyway to allowing devices to be powered from a micro-usb
connector while acting as a USB host (USB OTG).
ie when you want VBUS disabled even though it would normally
need to be enabled.
David
On Thu, Dec 11, 2014 at 5:52 PM, David Laight <[email protected]> wrote:
> From: Vivek Gautam
>> This has been on my to-do list for sometime.
>> Until now the host controller (specifically ehci-exynos) is responsible
>> for enabling VBUS supply. This opens up one more issue which is, when
>> only ohci-exynos is enabled and ehci-exynosis disabled then VBUS was
>> never enabled (since ohci did not have the code to enabled the VBUS supply).
>>
>> Rather it should be wise to move the VBUS related stuff to phy driver and
>> let phy take care of enabling it.
>>
>> This patch series adds that VBUS regulator to phy-samsung-usb2 driver,
>> adds necessary binding information as well as vbus-supply properties
>> to phy nodes on exynos5250 systems.
> ...
>
> Does this go anyway to allowing devices to be powered from a micro-usb
> connector while acting as a USB host (USB OTG).
> ie when you want VBUS disabled even though it would normally
> need to be enabled.
Sorry i didn't get your second line.
This change allows HOST and HSIC phys to enable VBUS for the devices
connected to it.
Although now i think there can be a flaw in this approach
when only in OTG mode, when DEVICE phy is being used, even then
the regulator will be turned on causing power unnecessary consumption.
--
Best Regards
Vivek Gautam
Samsung R&D Institute, Bangalore
India