linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support
@ 2021-05-17 12:08 Amelie Delaunay
  2021-05-17 12:08 ` [RESEND PATCH v2 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc Amelie Delaunay
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Amelie Delaunay @ 2021-05-17 12:08 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring,
	Alexandre Torgue, Maxime Coquelin
  Cc: linux-phy, linux-kernel, devicetree, linux-arm-kernel,
	linux-stm32, Amelie Delaunay

STM32 USBPHYC provides two USB High-Speed ports which are used by controllers
with Host capabilities. That's why vbus-supply has to be supported on each
phy node.

---
Changes in v2:
- use connector node vbus-supply property as suggested by Rob
---
Amelie Delaunay (2):
  dt-bindings: phy: add vbus-supply optional property to
    phy-stm32-usbphyc
  phy: stm32: manage optional vbus regulator on phy_power_on/off

 .../bindings/phy/phy-stm32-usbphyc.yaml       | 11 +++++++
 drivers/phy/st/phy-stm32-usbphyc.c            | 31 +++++++++++++++++++
 2 files changed, 42 insertions(+)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RESEND PATCH v2 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc
  2021-05-17 12:08 [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support Amelie Delaunay
@ 2021-05-17 12:08 ` Amelie Delaunay
  2021-05-17 12:08 ` [RESEND PATCH v2 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off Amelie Delaunay
  2021-05-31  8:22 ` [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Amelie Delaunay @ 2021-05-17 12:08 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring,
	Alexandre Torgue, Maxime Coquelin
  Cc: linux-phy, linux-kernel, devicetree, linux-arm-kernel,
	linux-stm32, Amelie Delaunay

This patch adds vbus-supply optional property to phy sub-nodes using
connector node.
A regulator for USB VBUS may be needed for host mode.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
---
Changes in v2:
- add connector vbus-supply property as suggested by Rob
---
 .../devicetree/bindings/phy/phy-stm32-usbphyc.yaml    | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml b/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
index 018cc1246ee1..3329f1d33a4f 100644
--- a/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
+++ b/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
@@ -74,6 +74,13 @@ patternProperties:
       "#phy-cells":
         enum: [ 0x0, 0x1 ]
 
+      connector:
+        type: object
+        allOf:
+          - $ref: ../connector/usb-connector.yaml
+        properties:
+          vbus-supply: true
+
     allOf:
       - if:
           properties:
@@ -130,6 +137,10 @@ examples:
             reg = <0>;
             phy-supply = <&vdd_usb>;
             #phy-cells = <0>;
+            connector {
+                compatible = "usb-a-connector";
+                vbus-supply = <&vbus_sw>;
+            };
         };
 
         usbphyc_port1: usb-phy@1 {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RESEND PATCH v2 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off
  2021-05-17 12:08 [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support Amelie Delaunay
  2021-05-17 12:08 ` [RESEND PATCH v2 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc Amelie Delaunay
@ 2021-05-17 12:08 ` Amelie Delaunay
  2021-05-31  8:22 ` [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Amelie Delaunay @ 2021-05-17 12:08 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Rob Herring,
	Alexandre Torgue, Maxime Coquelin
  Cc: linux-phy, linux-kernel, devicetree, linux-arm-kernel,
	linux-stm32, Amelie Delaunay

This patch adds support for optional vbus regulator.
It is managed on phy_power_on/off calls and may be needed for host mode.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
---
No changes in v2.
---
 drivers/phy/st/phy-stm32-usbphyc.c | 31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/phy/st/phy-stm32-usbphyc.c b/drivers/phy/st/phy-stm32-usbphyc.c
index c184f4e34584..3e491dfb2525 100644
--- a/drivers/phy/st/phy-stm32-usbphyc.c
+++ b/drivers/phy/st/phy-stm32-usbphyc.c
@@ -57,6 +57,7 @@ struct pll_params {
 struct stm32_usbphyc_phy {
 	struct phy *phy;
 	struct stm32_usbphyc *usbphyc;
+	struct regulator *vbus;
 	u32 index;
 	bool active;
 };
@@ -291,9 +292,31 @@ static int stm32_usbphyc_phy_exit(struct phy *phy)
 	return stm32_usbphyc_pll_disable(usbphyc);
 }
 
+static int stm32_usbphyc_phy_power_on(struct phy *phy)
+{
+	struct stm32_usbphyc_phy *usbphyc_phy = phy_get_drvdata(phy);
+
+	if (usbphyc_phy->vbus)
+		return regulator_enable(usbphyc_phy->vbus);
+
+	return 0;
+}
+
+static int stm32_usbphyc_phy_power_off(struct phy *phy)
+{
+	struct stm32_usbphyc_phy *usbphyc_phy = phy_get_drvdata(phy);
+
+	if (usbphyc_phy->vbus)
+		return regulator_disable(usbphyc_phy->vbus);
+
+	return 0;
+}
+
 static const struct phy_ops stm32_usbphyc_phy_ops = {
 	.init = stm32_usbphyc_phy_init,
 	.exit = stm32_usbphyc_phy_exit,
+	.power_on = stm32_usbphyc_phy_power_on,
+	.power_off = stm32_usbphyc_phy_power_off,
 	.owner = THIS_MODULE,
 };
 
@@ -519,6 +542,14 @@ static int stm32_usbphyc_probe(struct platform_device *pdev)
 		usbphyc->phys[port]->index = index;
 		usbphyc->phys[port]->active = false;
 
+		usbphyc->phys[port]->vbus = devm_regulator_get_optional(&phy->dev, "vbus");
+		if (IS_ERR(usbphyc->phys[port]->vbus)) {
+			ret = PTR_ERR(usbphyc->phys[port]->vbus);
+			if (ret == -EPROBE_DEFER)
+				goto put_child;
+			usbphyc->phys[port]->vbus = NULL;
+		}
+
 		port++;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support
  2021-05-17 12:08 [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support Amelie Delaunay
  2021-05-17 12:08 ` [RESEND PATCH v2 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc Amelie Delaunay
  2021-05-17 12:08 ` [RESEND PATCH v2 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off Amelie Delaunay
@ 2021-05-31  8:22 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2021-05-31  8:22 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Kishon Vijay Abraham I, Rob Herring, Alexandre Torgue,
	Maxime Coquelin, linux-phy, linux-kernel, devicetree,
	linux-arm-kernel, linux-stm32

On 17-05-21, 14:08, Amelie Delaunay wrote:
> STM32 USBPHYC provides two USB High-Speed ports which are used by controllers
> with Host capabilities. That's why vbus-supply has to be supported on each
> phy node.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-31  8:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 12:08 [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support Amelie Delaunay
2021-05-17 12:08 ` [RESEND PATCH v2 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc Amelie Delaunay
2021-05-17 12:08 ` [RESEND PATCH v2 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off Amelie Delaunay
2021-05-31  8:22 ` [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).