2021-05-17 18:07:15

by Amelie Delaunay

[permalink] [raw]
Subject: [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support

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



2021-05-17 19:05:56

by Amelie Delaunay

[permalink] [raw]
Subject: [RESEND PATCH v2 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off

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 <[email protected]>
---
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


2021-05-17 19:06:10

by Amelie Delaunay

[permalink] [raw]
Subject: [RESEND PATCH v2 1/2] dt-bindings: phy: add vbus-supply optional property to phy-stm32-usbphyc

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 <[email protected]>
Signed-off-by: Amelie Delaunay <[email protected]>
---
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


2021-05-31 08:24:02

by Vinod Koul

[permalink] [raw]
Subject: Re: [RESEND PATCH v2 0/2] STM32 USBPHYC vbus-supply property support

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