Skip to contentSkip to conversation

PHY: ti-pipe3: Manage 3.3V PHY regulator

PATCH In review Roger Quadros 6 participants 11 messages Jun 30, 2014 – Jul 9, 2014 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover PHY: ti-pipe3: Manage 3.3V PHY regulator

Hi,

On some SoCs e.g. J6 the 3.3V supply to the USB2 PHY can be powered down when the PHY is not in use. Add regulator management code to control this power line.

cheers,
-roger
---

Roger Quadros (3):
phy: omap-usb2: Manage PHY 3.3V supply regulator
phy: omap-usb2: Add PHY regulator to DT binding documentation
ARM: dts: dra7-evm: Add regulator information to USB2 PHYs

 Documentation/devicetree/bindings/phy/ti-phy.txt |  1 +
 arch/arm/boot/dts/dra7-evm.dts                   |  8 ++++++++
 drivers/phy/phy-omap-usb2.c                      | 25 ++++++++++++++++++++++++
 include/linux/phy/omap_usb.h                     |  1 +
 4 files changed, 35 insertions(+)
Signature · 6 lines
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH 1/3 phy: omap-usb2: Manage PHY 3.3V supply regulator

In reply to a message not in the archive

On some SoCs e.g. J6 the 3.3V supply to the USB2 PHY can be powered down when the PHY is not in use. Add regulator management code to control this power line.

---
 drivers/phy/phy-omap-usb2.c  | 25 +++++++++++++++++++++++++
 include/linux/phy/omap_usb.h |  1 +
 2 files changed, 26 insertions(+)
drivers/phy/phy-omap-usb2.c +25 -0
index 7007c11..2afc79c 100644
@@ -30,6 +30,7 @@
 #include <linux/phy/omap_control_phy.h>
 #include <linux/phy/phy.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
 #define USB2PHY_ANA_CONFIG1 0x4c
@@ -107,6 +108,14 @@ static int omap_usb_power_off(struct phy *x)
 
 	omap_control_phy_power(phy->control_dev, 0);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_disable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -114,6 +123,14 @@ static int omap_usb_power_on(struct phy *x)
 {
 	struct omap_usb *phy = phy_get_drvdata(x);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_enable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+
 	omap_control_phy_power(phy->control_dev, 1);
 
 	return 0;
@@ -253,6 +270,14 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	phy->control_dev = &control_pdev->dev;
 	omap_control_phy_power(phy->control_dev, 0);
 
+	/* phy-supply */
+	phy->pwr = devm_regulator_get_optional(phy->dev, "phy");
+	if (IS_ERR(phy->pwr)) {
+		if (PTR_ERR(phy->pwr) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		phy->pwr = NULL;
+	}
+
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
 	if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
include/linux/phy/omap_usb.h +1 -0
index dc2c541..e2c46df 100644
@@ -40,6 +40,7 @@ struct omap_usb {
 	struct clk		*wkupclk;
 	struct clk		*optclk;
 	u8			flags;
+	struct regulator	*pwr;
 };
 
 struct usb_phy_data {
Signature · 6 lines
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw

PATCH 2/3 phy: omap-usb2: Add PHY regulator to DT binding documentation

In reply to a message not in the archive

The PHY driver can manage a regulator that supplies power to the USB2 PHY. Add DT binding information for that.

---
 Documentation/devicetree/bindings/phy/ti-phy.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/phy/ti-phy.txt +1 -0
index 9ce458f..a6acd99 100644
@@ -41,6 +41,7 @@ Required properties:
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
    the PHY.
+ - phy-supply: phandle of the regulator that supplies power to the PHY.
 
 This is usually a subnode of ocp2scp to which it is connected.
 
Signature · 6 lines
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw

PATCH 3/3 ARM: dts: dra7-evm: Add regulator information to USB2 PHYs

In reply to Roger Quadros

The ldousb_reg regulator provides power to the USB1 and USB2 High Speed PHYs.

---
 arch/arm/boot/dts/dra7-evm.dts | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/dra7-evm.dts +8 -0
index 4adc280..fd96ced 100644
@@ -495,3 +495,11 @@
 		};
 	};
 };
+
+&usb2_phy1 {
+	phy-supply = <&ldousb_reg>;
+};
+
+&usb2_phy2 {
+	phy-supply = <&ldousb_reg>;
+};
Signature · 1 line
1.8.3.2
Reviewed-by
#4 lore raw

Re: [PATCH 1/3] phy: omap-usb2: Manage PHY 3.3V supply regulator

In reply to a message not in the archive

Hi,

Quoted 5 lines · Roger Quadros

On some SoCs e.g. J6 the 3.3V supply to the USB2 PHY can be powered down when the PHY is not in use. Add regulator management code to control this power line.

Quoted 77 lines
---
 drivers/phy/phy-omap-usb2.c  | 25 +++++++++++++++++++++++++
 include/linux/phy/omap_usb.h |  1 +
 2 files changed, 26 insertions(+)
drivers/phy/phy-omap-usb2.c +25 -0
index 7007c11..2afc79c 100644
@@ -30,6 +30,7 @@
 #include <linux/phy/omap_control_phy.h>
 #include <linux/phy/phy.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
 #define USB2PHY_ANA_CONFIG1 0x4c
@@ -107,6 +108,14 @@ static int omap_usb_power_off(struct phy *x)
 
 	omap_control_phy_power(phy->control_dev, 0);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_disable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -114,6 +123,14 @@ static int omap_usb_power_on(struct phy *x)
 {
 	struct omap_usb *phy = phy_get_drvdata(x);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_enable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+
 	omap_control_phy_power(phy->control_dev, 1);
 
 	return 0;
@@ -253,6 +270,14 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	phy->control_dev = &control_pdev->dev;
 	omap_control_phy_power(phy->control_dev, 0);
 
+	/* phy-supply */
+	phy->pwr = devm_regulator_get_optional(phy->dev, "phy");
+	if (IS_ERR(phy->pwr)) {
+		if (PTR_ERR(phy->pwr) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		phy->pwr = NULL;
+	}
+
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
 	if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
include/linux/phy/omap_usb.h +1 -0
index dc2c541..e2c46df 100644
@@ -40,6 +40,7 @@ struct omap_usb {
 	struct clk		*wkupclk;
 	struct clk		*optclk;
 	u8			flags;
+	struct regulator	*pwr;
 };
 
 struct usb_phy_data {
Signature · 1 line
1.8.3.2
Signature · 1 line
balbi
#5 lore raw

Re: [PATCH 1/3] phy: omap-usb2: Manage PHY 3.3V supply regulator

In reply to a message not in the archive

Hi Roger,

Quoted 39 lines · Roger Quadros

On some SoCs e.g. J6 the 3.3V supply to the USB2 PHY can be powered down when the PHY is not in use. Add regulator management code to control this power line.

---
 drivers/phy/phy-omap-usb2.c  | 25 +++++++++++++++++++++++++
 include/linux/phy/omap_usb.h |  1 +
 2 files changed, 26 insertions(+)
drivers/phy/phy-omap-usb2.c +9 -0
index 7007c11..2afc79c 100644
@@ -30,6 +30,7 @@
 #include <linux/phy/omap_control_phy.h>
 #include <linux/phy/phy.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
 #define USB2PHY_ANA_CONFIG1 0x4c
@@ -107,6 +108,14 @@ static int omap_usb_power_off(struct phy *x)
 
 	omap_control_phy_power(phy->control_dev, 0);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_disable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -114,6 +123,14 @@ static int omap_usb_power_on(struct phy *x)
 {

drivers/phy/phy-omap-usb2.c static int omap_usb_power_on(struct phy *x) · line 133

Quoted 10 lines
drivers/phy/phy-omap-usb2.c +8 -0
 	struct omap_usb *phy = phy_get_drvdata(x);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_enable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+

Shouldn't we do this in phy_power_on/phy_power_off in phy-core?

Cheers
Kishon

Quoted 24 lines
drivers/phy/phy-omap-usb2.c +8 -0
 	omap_control_phy_power(phy->control_dev, 1);
 
 	return 0;
@@ -253,6 +270,14 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	phy->control_dev = &control_pdev->dev;
 	omap_control_phy_power(phy->control_dev, 0);
 
+	/* phy-supply */
+	phy->pwr = devm_regulator_get_optional(phy->dev, "phy");
+	if (IS_ERR(phy->pwr)) {
+		if (PTR_ERR(phy->pwr) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		phy->pwr = NULL;
+	}
+
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
 	if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
include/linux/phy/omap_usb.h +0 -0
index dc2c541..e2c46df 100644

include/linux/phy/omap_usb.h struct omap_usb { · line 46

Quoted 7 lines
include/linux/phy/omap_usb.h +1 -0
@@ -40,6 +40,7 @@ struct omap_usb {
 	struct clk		*wkupclk;
 	struct clk		*optclk;
 	u8			flags;
+	struct regulator	*pwr;
 };
 
 struct usb_phy_data {

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [PATCH 1/3] phy: omap-usb2: Manage PHY 3.3V supply regulator

In reply to a message not in the archive
Quoted 44 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 41 lines · Roger Quadros

On some SoCs e.g. J6 the 3.3V supply to the USB2 PHY can be powered down when the PHY is not in use. Add regulator management code to control this power line.

---
 drivers/phy/phy-omap-usb2.c  | 25 +++++++++++++++++++++++++
 include/linux/phy/omap_usb.h |  1 +
 2 files changed, 26 insertions(+)
drivers/phy/phy-omap-usb2.c +9 -0
index 7007c11..2afc79c 100644
@@ -30,6 +30,7 @@
 #include <linux/phy/omap_control_phy.h>
 #include <linux/phy/phy.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
 #define USB2PHY_ANA_CONFIG1 0x4c
@@ -107,6 +108,14 @@ static int omap_usb_power_off(struct phy *x)
 
 	omap_control_phy_power(phy->control_dev, 0);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_disable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -114,6 +123,14 @@ static int omap_usb_power_on(struct phy *x)
 {
 	struct omap_usb *phy = phy_get_drvdata(x);
 
Quoted 10 lines

drivers/phy/phy-omap-usb2.c static int omap_usb_power_on(struct phy *x) · line 133

Quoted 8 lines
drivers/phy/phy-omap-usb2.c +8 -0
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_enable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+

Shouldn't we do this in phy_power_on/phy_power_off in phy-core?

I thought about that earlier, but could not find a way to defer probing if the regulator is not-yet probed. Any clues how it could be done in phy-core?

cheers,
-roger

Quoted 30 lines
Quoted 30 lines
drivers/phy/phy-omap-usb2.c +8 -0
 	omap_control_phy_power(phy->control_dev, 1);
 
 	return 0;
@@ -253,6 +270,14 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	phy->control_dev = &control_pdev->dev;
 	omap_control_phy_power(phy->control_dev, 0);
 
+	/* phy-supply */
+	phy->pwr = devm_regulator_get_optional(phy->dev, "phy");
+	if (IS_ERR(phy->pwr)) {
+		if (PTR_ERR(phy->pwr) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		phy->pwr = NULL;
+	}
+
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
 	if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
include/linux/phy/omap_usb.h +1 -0
index dc2c541..e2c46df 100644
@@ -40,6 +40,7 @@ struct omap_usb {
 	struct clk		*wkupclk;
 	struct clk		*optclk;
 	u8			flags;
+	struct regulator	*pwr;
 };
 
Quoted 2 lines

include/linux/phy/omap_usb.h struct omap_usb { · line 46

Quoted 2 lines
include/linux/phy/omap_usb.h +0 -0
 struct usb_phy_data {

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

Re: [PATCH 1/3] phy: omap-usb2: Manage PHY 3.3V supply regulator

Hi,

Quoted 56 lines · Roger Quadros
Quoted 44 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 41 lines · Roger Quadros

On some SoCs e.g. J6 the 3.3V supply to the USB2 PHY can be powered down when the PHY is not in use. Add regulator management code to control this power line.

---
 drivers/phy/phy-omap-usb2.c  | 25 +++++++++++++++++++++++++
 include/linux/phy/omap_usb.h |  1 +
 2 files changed, 26 insertions(+)
drivers/phy/phy-omap-usb2.c +9 -0
index 7007c11..2afc79c 100644
@@ -30,6 +30,7 @@
 #include <linux/phy/omap_control_phy.h>
 #include <linux/phy/phy.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
 #define USB2PHY_ANA_CONFIG1 0x4c
@@ -107,6 +108,14 @@ static int omap_usb_power_off(struct phy *x)
 
 	omap_control_phy_power(phy->control_dev, 0);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_disable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -114,6 +123,14 @@ static int omap_usb_power_on(struct phy *x)
 {
 	struct omap_usb *phy = phy_get_drvdata(x);
 
Quoted 10 lines

drivers/phy/phy-omap-usb2.c static int omap_usb_power_on(struct phy *x) · line 133

Quoted 8 lines
drivers/phy/phy-omap-usb2.c +8 -0
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_enable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+

Shouldn't we do this in phy_power_on/phy_power_off in phy-core?

Quoted 2 lines

I thought about that earlier, but could not find a way to defer probing if the regulator is not-yet probed. Any clues how it could be done in phy-core?

We can try to do regulator_get in phy_create and return EPROBE_DEFER if the regulator_get returns EPROBE_DEFER no?

Cheers
Kishon

#9 lore raw

Re: [PATCH 1/3] phy: omap-usb2: Manage PHY 3.3V supply regulator

Quoted 59 lines · Kishon Vijay Abraham I

Hi,

Quoted 56 lines · Roger Quadros
Quoted 54 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 39 lines · Roger Quadros

On some SoCs e.g. J6 the 3.3V supply to the USB2 PHY can be powered down when the PHY is not in use. Add regulator management code to control this power line.

---
 drivers/phy/phy-omap-usb2.c  | 25 +++++++++++++++++++++++++
 include/linux/phy/omap_usb.h |  1 +
 2 files changed, 26 insertions(+)
drivers/phy/phy-omap-usb2.c +9 -0
index 7007c11..2afc79c 100644
@@ -30,6 +30,7 @@
 #include <linux/phy/omap_control_phy.h>
 #include <linux/phy/phy.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
 #define USB2PHY_ANA_CONFIG1 0x4c
@@ -107,6 +108,14 @@ static int omap_usb_power_off(struct phy *x)
 
 	omap_control_phy_power(phy->control_dev, 0);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_disable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -114,6 +123,14 @@ static int omap_usb_power_on(struct phy *x)
 {

drivers/phy/phy-omap-usb2.c static int omap_usb_power_on(struct phy *x) · line 133

Quoted 10 lines
drivers/phy/phy-omap-usb2.c +8 -0
 	struct omap_usb *phy = phy_get_drvdata(x);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_enable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+

Shouldn't we do this in phy_power_on/phy_power_off in phy-core?

Quoted 5 lines
Quoted 2 lines

I thought about that earlier, but could not find a way to defer probing if the regulator is not-yet probed. Any clues how it could be done in phy-core?

We can try to do regulator_get in phy_create and return EPROBE_DEFER if the regulator_get returns EPROBE_DEFER no?

Yes indeed, we can. I missed the phy_create() and was only looking at phy_init() and phy_power_*() :P. I'll post a v2 soon.

cheers,
-roger

#11 lore raw

Re: [PATCH 1/3] phy: omap-usb2: Manage PHY 3.3V supply regulator

In reply to a message not in the archive
Quoted 60 lines · Roger Quadros
Quoted 59 lines · Kishon Vijay Abraham I

Hi,

Quoted 56 lines · Roger Quadros
Quoted 54 lines · Kishon Vijay Abraham I

Hi Roger,

Quoted 39 lines · Roger Quadros

On some SoCs e.g. J6 the 3.3V supply to the USB2 PHY can be powered down when the PHY is not in use. Add regulator management code to control this power line.

---
 drivers/phy/phy-omap-usb2.c  | 25 +++++++++++++++++++++++++
 include/linux/phy/omap_usb.h |  1 +
 2 files changed, 26 insertions(+)
drivers/phy/phy-omap-usb2.c +9 -0
index 7007c11..2afc79c 100644
@@ -30,6 +30,7 @@
 #include <linux/phy/omap_control_phy.h>
 #include <linux/phy/phy.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
 #define USB2PHY_ANA_CONFIG1 0x4c
@@ -107,6 +108,14 @@ static int omap_usb_power_off(struct phy *x)
 
 	omap_control_phy_power(phy->control_dev, 0);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_disable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -114,6 +123,14 @@ static int omap_usb_power_on(struct phy *x)
 {

drivers/phy/phy-omap-usb2.c static int omap_usb_power_on(struct phy *x) · line 133

Quoted 10 lines
drivers/phy/phy-omap-usb2.c +8 -0
 	struct omap_usb *phy = phy_get_drvdata(x);
 
+	if (phy->pwr) {
+		int ret;
+
+		ret = regulator_enable(phy->pwr);
+		if (ret)
+			return ret;
+	}
+

Shouldn't we do this in phy_power_on/phy_power_off in phy-core?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I thought about that earlier, but could not find a way to defer probing if the regulator is not-yet probed. Any clues how it could be done in phy-core?

We can try to do regulator_get in phy_create and return EPROBE_DEFER if the regulator_get returns EPROBE_DEFER no?

Yes indeed, we can. I missed the phy_create() and was only looking at phy_init() and phy_power_*() :P. I'll post a v2 soon.

cool. Thanks :-)

-Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw

Re: [PATCH 3/3] ARM: dts: dra7-evm: Add regulator information to USB2 PHYs

In reply to Roger Quadros
Quoted 2 lines · Roger Quadros

The ldousb_reg regulator provides power to the USB1 and USB2 High Speed PHYs.

Applying this one into omap-for-v3.17/dt thanks.

Tony