linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] STM32 USBPHYC vbus-supply property support
@ 2021-03-17 16:09 Amelie Delaunay
  2021-03-17 16:09 ` [PATCH 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc Amelie Delaunay
  2021-03-17 16:09 ` [PATCH 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off Amelie Delaunay
  0 siblings, 2 replies; 5+ messages in thread
From: Amelie Delaunay @ 2021-03-17 16:09 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.

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       |  3 ++
 drivers/phy/st/phy-stm32-usbphyc.c            | 31 +++++++++++++++++++
 2 files changed, 34 insertions(+)

-- 
2.17.1


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

* [PATCH 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc
  2021-03-17 16:09 [PATCH 0/2] STM32 USBPHYC vbus-supply property support Amelie Delaunay
@ 2021-03-17 16:09 ` Amelie Delaunay
  2021-03-26  0:28   ` Rob Herring
  2021-03-17 16:09 ` [PATCH 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off Amelie Delaunay
  1 sibling, 1 reply; 5+ messages in thread
From: Amelie Delaunay @ 2021-03-17 16:09 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.
A regulator for USB VBUS may be needed for host mode.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
---
 Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml b/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
index 018cc1246ee1..ad2378c30334 100644
--- a/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
+++ b/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
@@ -71,6 +71,9 @@ patternProperties:
       phy-supply:
         description: regulator providing 3V3 power supply to the PHY.
 
+      vbus-supply:
+        description: regulator providing 5V Vbus to the USB connector.
+
       "#phy-cells":
         enum: [ 0x0, 0x1 ]
 
-- 
2.17.1


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

* [PATCH 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off
  2021-03-17 16:09 [PATCH 0/2] STM32 USBPHYC vbus-supply property support Amelie Delaunay
  2021-03-17 16:09 ` [PATCH 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc Amelie Delaunay
@ 2021-03-17 16:09 ` Amelie Delaunay
  1 sibling, 0 replies; 5+ messages in thread
From: Amelie Delaunay @ 2021-03-17 16:09 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>
---
 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] 5+ messages in thread

* Re: [PATCH 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc
  2021-03-17 16:09 ` [PATCH 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc Amelie Delaunay
@ 2021-03-26  0:28   ` Rob Herring
  2021-03-26  9:05     ` Amelie DELAUNAY
  0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring @ 2021-03-26  0:28 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Kishon Vijay Abraham I, Vinod Koul, Alexandre Torgue,
	Maxime Coquelin, linux-phy, linux-kernel, devicetree,
	linux-arm-kernel, linux-stm32

On Wed, Mar 17, 2021 at 05:09:53PM +0100, Amelie Delaunay wrote:
> This patch adds vbus-supply optional property to phy sub-nodes.
> A regulator for USB VBUS may be needed for host mode.
> 
> Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
> ---
>  Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml b/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
> index 018cc1246ee1..ad2378c30334 100644
> --- a/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
> +++ b/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
> @@ -71,6 +71,9 @@ patternProperties:
>        phy-supply:
>          description: regulator providing 3V3 power supply to the PHY.
>  
> +      vbus-supply:
> +        description: regulator providing 5V Vbus to the USB connector.

Unless Vbus is powering the phy, then this only belongs in the USB 
connector node.

> +
>        "#phy-cells":
>          enum: [ 0x0, 0x1 ]
>  
> -- 
> 2.17.1
> 

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

* Re: [PATCH 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc
  2021-03-26  0:28   ` Rob Herring
@ 2021-03-26  9:05     ` Amelie DELAUNAY
  0 siblings, 0 replies; 5+ messages in thread
From: Amelie DELAUNAY @ 2021-03-26  9:05 UTC (permalink / raw)
  To: Rob Herring
  Cc: Kishon Vijay Abraham I, Vinod Koul, Alexandre Torgue,
	Maxime Coquelin, linux-phy, linux-kernel, devicetree,
	linux-arm-kernel, linux-stm32

Hi Rob,

On 3/26/21 1:28 AM, Rob Herring wrote:
> On Wed, Mar 17, 2021 at 05:09:53PM +0100, Amelie Delaunay wrote:
>> This patch adds vbus-supply optional property to phy sub-nodes.
>> A regulator for USB VBUS may be needed for host mode.
>>
>> Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
>> ---
>>   Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml b/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
>> index 018cc1246ee1..ad2378c30334 100644
>> --- a/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
>> +++ b/Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
>> @@ -71,6 +71,9 @@ patternProperties:
>>         phy-supply:
>>           description: regulator providing 3V3 power supply to the PHY.
>>   
>> +      vbus-supply:
>> +        description: regulator providing 5V Vbus to the USB connector.
> 
> Unless Vbus is powering the phy, then this only belongs in the USB
> connector node.
> 

Do you mean I should declare a connector node as a child of the phy node 
and get the vbus-supply property from this connector node ?

In case of a on-board autonomous hub between the phy and the connectors, 
so no driver to drive it nor to get the vbus-supply property to provide 
VBUS to the hub, then the connectors, how to use connector ?

[USB controller]===[USB PHY]===[(USB HUB)]===|> USB A connector
                               /              |> USB A connector
                             VBUS             |> USB A connector
                                              |> USB A connector

Please advise.

Regards,
Amelie

>> +
>>         "#phy-cells":
>>           enum: [ 0x0, 0x1 ]
>>   
>> -- 
>> 2.17.1
>>

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

end of thread, other threads:[~2021-03-26  9:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 16:09 [PATCH 0/2] STM32 USBPHYC vbus-supply property support Amelie Delaunay
2021-03-17 16:09 ` [PATCH 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc Amelie Delaunay
2021-03-26  0:28   ` Rob Herring
2021-03-26  9:05     ` Amelie DELAUNAY
2021-03-17 16:09 ` [PATCH 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off Amelie Delaunay

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).