Skip to contentSkip to conversation

arm64: dts: phy: st: usb: Add STM32MP2 USB support

PATCH Superseded Marek Vasut 4 participants 31 messages Aug 16 – Aug 19

Subsystems (5)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover arm64: dts: phy: st: usb: Add STM32MP2 USB support

Add USB support for STM32MP23xx/STM32MP25xx SoCs. This includes USB 2.0 FEMTO-PHY driver, DWC3 glue code and DT adjustments. Parts of this are taken from ST downstream kernel fork, reduced, or rewritten, since not all of the content there was useful and bits which might be missing and are useful can be added later.

Unlike the downstream implementation, the DWC3 glue code is using plain dwc3-generic-plat, the EHCI and OHCI controllers are instantiated as plain generic controllers without any wrapper glue driver, and the USB2 PHY driver is simplified.

Both USB 2.0 Host controller and DWC3 super-speed controller are tested.

Marek Vasut (6):
dt-bindings: usb: generic-ehci: Document access-controllers property
dt-bindings: usb: generic-ohci: Document access-controllers property
dt-bindings: usb: dwc3: Document ST STM32MP2 DWC3 xHCI USB controller
usb: dwc3: dwc3-generic-plat: Add ST STM32MP2 DWC3 xHCI USB controller
glue
dt-bindings: arm: stm32: Switch st,stm32mp23/25-syscfg into simple-mfd
arm64: dts: st: Add USB nodes on stm32mp231

Pankaj Dev (3):
dt-bindings: phy: Document ST STM32MP25 USB2-FEMTO PHY
phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY
arm64: dts: st: Add USB nodes on stm32mp251

 .../bindings/arm/stm32/st,stm32-syscon.yaml   |   7 +-
 .../bindings/phy/st,stm32-usb2phy.yaml        |  73 ++++
 .../devicetree/bindings/usb/generic-ehci.yaml |   3 +
 .../devicetree/bindings/usb/generic-ohci.yaml |   3 +
 .../bindings/usb/st,stm32mp25-dwc3.yaml       | 108 ++++++
 arch/arm64/boot/dts/st/stm32mp231.dtsi        |  81 +++-
 arch/arm64/boot/dts/st/stm32mp251.dtsi        |  65 +++-
 drivers/phy/st/Kconfig                        |  10 +
 drivers/phy/st/Makefile                       |   1 +
 drivers/phy/st/phy-stm32-usb2phy.c            | 361 ++++++++++++++++++
 drivers/usb/dwc3/dwc3-generic-plat.c          |  44 +++
 11 files changed, 751 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml
 create mode 100644 Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml
 create mode 100644 drivers/phy/st/phy-stm32-usb2phy.c
Cc Alexandre Torgue <[email protected]>
Cc Christian Bruel <[email protected]>
Cc Conor Dooley <[email protected]>
Cc Fabrice Gasnier <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Coquelin <[email protected]>
Cc Neil Armstrong <[email protected]>
Cc Pankaj Dev <[email protected]>
Cc Rahul Kumar <[email protected]>
Cc Rob Herring <[email protected]>
Cc Rosen Penev <[email protected]>
Cc Thinh Nguyen <[email protected]>
Cc Vinod Koul <[email protected]>
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/9 dt-bindings: phy: Document ST STM32MP25 USB2-FEMTO PHY

From: Pankaj Dev <[email protected]>

Document USB2 PHY for STM32MP25 USB2 controllers, which includes the USB2.0 host-only controller and USB 2.0 part of the DWC3 controller. Two such PHYs in total are present in STM32MP25 SoC, they both are slightly different, therefore they use different compatible string to discern them.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: - Fix up Sob/Cdb lines
- Fix up compatible string in example
- Use additionalProperties: false
- Expand description:
- Use clock-cells = <1> to discern OSC and future PLL clock from the PHY

---
 .../bindings/phy/st,stm32-usb2phy.yaml        | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +73 -0
new file mode 100644
index 0000000000000..ab6c943af9a25
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/st,stm32-usb2phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STMicroelectronics STM32 MPU High-Speed USB PHY
+
+description:
+  USB2 PHY block in STM32 is attached to USB 2.0 Host controller and
+  USB 2.0 side of DWC3 DRD controller, and provides the USB LS/FS/HS
+  connectivity. Both PHYs are the FEMTO-PHY, but their configuration
+  bits in the system control register are different for each variant.
+
+maintainers:
+  - Fabrice Gasnier <[email protected]>
+  - Marek Vasut <[email protected]>
+  - Pankaj Dev <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - st,stm32mp25-usb2phy1
+      - st,stm32mp25-usb2phy2
+
+  "#phy-cells":
+    const: 0
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  vdd33-supply:
+    description: Phandle to regulator providing 3V3 power supply to the USB2 HS PHY
+
+  st,syscfg:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    description: Phandle to system configuration controller.
+    items:
+      - items:
+          - description: phandle to syscfg
+          - description: USB2PHY control offset within syscfg
+
+  "#clock-cells":
+    const: 1
+
+required:
+  - compatible
+  - "#clock-cells"
+  - "#phy-cells"
+  - clocks
+  - resets
+  - st,syscfg
+  - vdd33-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/st,stm32mp25-rcc.h>
+    #include <dt-bindings/reset/st,stm32mp25-rcc.h>
+
+    usb2_phy2: usb-phy {
+        compatible = "st,stm32mp25-usb2phy1";
+        #clock-cells = <1>;
+        #phy-cells = <0>;
+        clocks = <&rcc CK_KER_USB2PHY2>;
+        resets = <&rcc USB2PHY2_R>;
+        st,syscfg = <&syscfg 0x2800>;
+        vdd33-supply = <&vdd33usb>;
+    };
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v2 1/9] dt-bindings: phy: Document ST STM32MP25 USB2-FEMTO PHY

Quoted 10 lines · Marek Vasut

From: Pankaj Dev <[email protected]>

Document USB2 PHY for STM32MP25 USB2 controllers, which includes the USB2.0 host-only controller and USB 2.0 part of the DWC3 controller. Two such PHYs in total are present in STM32MP25 SoC, they both are slightly different, therefore they use different compatible string to discern them.

Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

Quoted 35 lines

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: - Fix up Sob/Cdb lines
- Fix up compatible string in example
- Use additionalProperties: false
- Expand description:
- Use clock-cells = <1> to discern OSC and future PLL clock from the PHY

Quoted 2 lines
---
 .../bindings/phy/st,stm32-usb2phy.yaml        | 73 +++++++++++++++++++

I do not see any changes/improvements from previous review.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v2 1/9] dt-bindings: phy: Document ST STM32MP25 USB2-FEMTO PHY

Quoted 9 lines · Krzysztof Kozlowski
Quoted 8 lines · Marek Vasut

From: Pankaj Dev <[email protected]>

Document USB2 PHY for STM32MP25 USB2 controllers, which includes the USB2.0 host-only controller and USB 2.0 part of the DWC3 controller. Two such PHYs in total are present in STM32MP25 SoC, they both are slightly different, therefore they use different compatible string to discern them.

Quoted 8 lines
Quoted 2 lines

Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

I think I managed to fix that up in V3, thanks.

#4 lore raw

PATCH v2 2/9 phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY

In reply to Marek Vasut

From: Pankaj Dev <[email protected]>

Add USB2 PHY driver for STM32MP25 USB2 controllers, which includes the USB2.0 host-only controller and USB 2.0 part of the DWC3 controller. Two such PHYs in total are present in STM32MP25 SoC, they both are slightly different, therefore they use different compatible string to discern them.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: - Fix up Sob/Cdb lines
- Operate PHY as a syscon subnode

---
 drivers/phy/st/Kconfig             |  10 +
 drivers/phy/st/Makefile            |   1 +
 drivers/phy/st/phy-stm32-usb2phy.c | 361 +++++++++++++++++++++++++++++
 3 files changed, 372 insertions(+)
 create mode 100644 drivers/phy/st/phy-stm32-usb2phy.c
drivers/phy/st/Kconfig +10 -0
index 49206185e5633..2835bb67bca9e 100644
@@ -58,3 +58,13 @@ config PHY_STM32_USBPHYC
 	  used by an HS USB Host controller, and the second one is shared
 	  between an HS USB OTG controller and an HS USB Host controller,
 	  selected by a USB switch.
+
+config PHY_STM32_USB2PHY
+	tristate "STMicroelectronics STM32MP25 USB2.0 PHY Controller driver"
+	depends on ARCH_STM32 || COMPILE_TEST
+	depends on COMMON_CLK
+	select GENERIC_PHY
+	help
+	  Enable this to support the High-Speed USB 2.0 transceivers that are
+	  part of the STMicroelectronics STM32MP25 SoCs. The PHY itself is a
+	  Synopsys FEMTO-PHY.
drivers/phy/st/Makefile +1 -0
index cb80e954ea9f0..4945df5ed78a8 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY)	+= phy-spear1340-miphy.o
 obj-$(CONFIG_PHY_STIH407_USB)		+= phy-stih407-usb.o
 obj-$(CONFIG_PHY_STM32_COMBOPHY)	+= phy-stm32-combophy.o
 obj-$(CONFIG_PHY_STM32_USBPHYC) 	+= phy-stm32-usbphyc.o
+obj-$(CONFIG_PHY_STM32_USB2PHY) 	+= phy-stm32-usb2phy.o
drivers/phy/st/phy-stm32-usb2phy.c new file +361 -0

361 lines not on this page · raw message

Signature · 1 line
2.53.0
#5 lore raw

Re: [PATCH v2 2/9] phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] Error paths in `stm32_usb2phy_enable()` and `stm32_usb2phy_disable()` fail to unwind the…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Error paths in stm32_usb2phy_enable() and stm32_usb2phy_disable() fail to unwind the en_refcnt atomic counter, leading to state corruption and leaked resources.
- [High] Incorrect handling of devm_regulator_get_optional() return value unconditionally fails probe on systems without the regulator.
- [High] Lockless en_refcnt check introduces a TOCTOU race condition allowing concurrent callers to bypass hardware initialization.
- [Medium] Unchecked dereferences of dev->of_node and phy_dev->hw_data during probe allow a local Denial of Service (Oops) if bound without a Device Tree node. --

--- Patch [2]: [PATCH v2 2/9] phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY --- commit e1cc42ded5599cd15a5c991b72a87e2e909f244d
Author: Pankaj Dev <[email protected]>

phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY

Add USB2 PHY driver for STM32MP25 USB2 controllers, which includes the USB2.0 host-only controller and USB 2.0 part of the DWC3 controller. Two such PHYs in total are present in STM32MP25 SoC.

Quoted 6 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +0 -0
new file mode 100644
index 0000000000000..a5cc7b855c61f
@@ -0,0 +1,361 @@

[ ... ]

drivers/phy/st/phy-stm32-usb2phy.c line 58

Quoted 9 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +9 -0
+static int stm32_usb2phy_enable(struct stm32_usb2phy *phy_dev)
+{
+	const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+	unsigned long rate;
+	int refsel, ret;
+
+	/* Check if a phy is already init or clk48 in use */
+	if (atomic_inc_return(&phy_dev->en_refcnt) > 1)
+		return 0;

[Severity: High]
Is it safe to rely on this lockless check?

If two threads call stm32_usb2phy_enable() concurrently (for instance, via phy_init and clk_prepare), the second thread will increment en_refcnt to 2 and return success immediately.

Will the second thread then proceed to use the hardware before the first thread has actually finished enabling the regulators and clocks?

drivers/phy/st/phy-stm32-usb2phy.c line 68

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +10 -0
+
+	rate = clk_get_rate(phy_dev->phyref);
+	if (rate == 19200000)
+		refsel = 0;
+	else if (rate == 20000000)
+		refsel = 1;
+	else if (rate == 24000000)
+		refsel = 2;
+	else
+		return -EINVAL;

[Severity: High]
Does this error path leak the en_refcnt?

If we return here, the counter remains incremented. Subsequent calls to stm32_usb2phy_enable() will then see a value > 1 and instantly return success without initializing the hardware.

[ ... ]

drivers/phy/st/phy-stm32-usb2phy.c line 122

Quoted 11 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +11 -0
+static int stm32_usb2phy_disable(struct stm32_usb2phy *phy_dev)
+{
+	int ret;
+
+	/* Check if a phy is still init or clk48 in use */
+	if (atomic_dec_return(&phy_dev->en_refcnt) > 0)
+		return 0;
+
+	ret = reset_control_assert(phy_dev->rstc);
+	if (ret)
+		return ret;

[Severity: High]
Does this error path need to restore the en_refcnt?

If reset_control_assert() fails, we return without disabling the clock or regulator, and the counter remains decremented.

[ ... ]

Quoted 2 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +2 -0
+static int stm32_usb2phy_probe(struct platform_device *pdev)
+{

[ ... ]

drivers/phy/st/phy-stm32-usb2phy.c line 263

Quoted 3 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +3 -0
+	phy_dev->vdd33 = devm_regulator_get_optional(dev, "vdd33");
+	if (IS_ERR(phy_dev->vdd33))
+		return dev_err_probe(dev, PTR_ERR(phy_dev->vdd33), "Failed to get vdd3v3 supply\n");

[Severity: High]
If this regulator is truly optional, shouldn't we handle the -ENODEV return value gracefully instead of failing the probe unconditionally?

If it's missing from the Device Tree, devm_regulator_get_optional() will return -ENODEV and cause the probe to fail on valid hardware configurations.

drivers/phy/st/phy-stm32-usb2phy.c line 265

Quoted 2 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +2 -0
+
+	phy_dev->regmap = syscon_node_to_regmap(dev->of_node->parent);

[Severity: Medium]
Can dev->of_node be NULL here?

If a user manually instantiates the device via sysfs or software nodes without an associated Device Tree node, this will result in a NULL pointer dereference when accessing parent.

drivers/phy/st/phy-stm32-usb2phy.c line 275

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +10 -0
+	if (IS_ERR(phy_dev->regmap))
+		return dev_err_probe(dev, PTR_ERR(phy_dev->regmap), "Failed to get regmap\n");
+
+	offset = of_get_address(dev->of_node, 0, NULL, NULL);
+	if (!offset)
+		return dev_err_probe(dev, -EINVAL, "Failed to get regmap offset\n");
+
+	phy_dev->cr_offset = be32_to_cpu(*offset);
+
+	phy_dev->hw_data = device_get_match_data(dev);

[Severity: Medium]
Should we check if phy_dev->hw_data is NULL before proceeding?

In a scenario without a Device Tree node, device_get_match_data() will return NULL, which is later dereferenced in the enable and disable paths.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#6 lore raw

Re: [PATCH v2 2/9] phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY

In reply to Marek Vasut
Quoted 82 lines · Marek Vasut

From: Pankaj Dev <[email protected]>

Add USB2 PHY driver for STM32MP25 USB2 controllers, which includes the USB2.0 host-only controller and USB 2.0 part of the DWC3 controller. Two such PHYs in total are present in STM32MP25 SoC, they both are slightly different, therefore they use different compatible string to discern them.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: - Fix up Sob/Cdb lines
- Operate PHY as a syscon subnode

---
 drivers/phy/st/Kconfig             |  10 +
 drivers/phy/st/Makefile            |   1 +
 drivers/phy/st/phy-stm32-usb2phy.c | 361 +++++++++++++++++++++++++++++
 3 files changed, 372 insertions(+)
 create mode 100644 drivers/phy/st/phy-stm32-usb2phy.c
drivers/phy/st/Kconfig +10 -0
index 49206185e5633..2835bb67bca9e 100644
@@ -58,3 +58,13 @@ config PHY_STM32_USBPHYC
 	  used by an HS USB Host controller, and the second one is shared
 	  between an HS USB OTG controller and an HS USB Host controller,
 	  selected by a USB switch.
+
+config PHY_STM32_USB2PHY
+	tristate "STMicroelectronics STM32MP25 USB2.0 PHY Controller driver"
+	depends on ARCH_STM32 || COMPILE_TEST
+	depends on COMMON_CLK
+	select GENERIC_PHY
+	help
+	  Enable this to support the High-Speed USB 2.0 transceivers that are
+	  part of the STMicroelectronics STM32MP25 SoCs. The PHY itself is a
+	  Synopsys FEMTO-PHY.
drivers/phy/st/Makefile +1 -0
index cb80e954ea9f0..4945df5ed78a8 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY)	+= phy-spear1340-miphy.o
 obj-$(CONFIG_PHY_STIH407_USB)		+= phy-stih407-usb.o
 obj-$(CONFIG_PHY_STM32_COMBOPHY)	+= phy-stm32-combophy.o
 obj-$(CONFIG_PHY_STM32_USBPHYC) 	+= phy-stm32-usbphyc.o
+obj-$(CONFIG_PHY_STM32_USB2PHY) 	+= phy-stm32-usb2phy.o
drivers/phy/st/phy-stm32-usb2phy.c new file +0 -0
new file mode 100644
index 0000000000000..a5cc7b855c61f

drivers/phy/st/phy-stm32-usb2phy.c line 6

Quoted 6 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +6 -0
@@ -0,0 +1,361 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * STMicroelectronics STM32 USB2 PHY Controller driver
+ * Currently Only supported for STM32MP25
+ *
+ * Copyright (C) 2022 STMicroelectronics

Hi Marek,

Could update to 2026 ?

Quoted 60 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +60 -0
+ * Author(s): Pankaj Dev <[email protected]>.
+ */
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/reset.h>
+#include <linux/usb/role.h>
+#include <linux/mfd/syscon.h>
+
+#define SYSCFG_USB2PHY2CR_USB2PHY2CMN		BIT(2)
+#define SYSCFG_USB2PHY2CR_VBUSVALID		BIT(4)
+#define SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL		BIT(5)
+#define SYSCFG_USB2PHY2CR_VBUSVLDEXT		BIT(6)
+
+struct stm32_usb2phy {
+	struct phy				*phy;
+	struct regmap				*regmap;
+	struct device				*dev;
+	struct reset_control			*rstc;
+	struct clk				*phyref;
+	struct regulator			*vdd33;
+	struct clk_hw				clk48_hw;
+	const struct stm32mp2_usb2phy_hw_data	*hw_data;
+	atomic_t				en_refcnt;
+	enum phy_mode				mode;
+	u32					cr_offset;
+	bool					is_init;
+};
+
+struct stm32mp2_usb2phy_hw_data {
+	u32			phyrefsel_mask;
+	bool			is_usb2_host_only;
+};
+
+static int stm32_usb2phy_enable(struct stm32_usb2phy *phy_dev)
+{
+	const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+	unsigned long rate;
+	int refsel, ret;
+
+	/* Check if a phy is already init or clk48 in use */
+	if (atomic_inc_return(&phy_dev->en_refcnt) > 1)
+		return 0;
+
+	rate = clk_get_rate(phy_dev->phyref);
+	if (rate == 19200000)
+		refsel = 0;
+	else if (rate == 20000000)
+		refsel = 1;
+	else if (rate == 24000000)
+		refsel = 2;

drivers/phy/st/phy-stm32-usb2phy.c line 76

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +10 -0
+	else
+		return -EINVAL;
+
+	ret = regmap_update_bits(phy_dev->regmap,
+				 phy_dev->cr_offset,
+				 phy_data->phyrefsel_mask,
+				 field_prep(phy_data->phyrefsel_mask, refsel));
+	if (ret)
+		return ret;
+

Hi Marek,

Below condition

drivers/phy/st/phy-stm32-usb2phy.c line 88

Quoted 12 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +12 -0
+	if (phy_data->is_usb2_host_only) {
+		/*
+		 * The clock should default to active after standby, as it is
+		 * needed when resuming OHCI to access its registers.
+		 * CMN is default reset to 1, so enforce it is cleared, when the
+		 * clock enable request from OHCI driver comes at resume time.
+		 */
+		ret = regmap_clear_bits(phy_dev->regmap, phy_dev->cr_offset,
+					SYSCFG_USB2PHY2CR_USB2PHY2CMN);
+		if (ret)
+			return ret;
+	}

up to here, is a specific part to manage OHCI controller clock during suspend modes (either bus suspend, or system-wide platform low power PM).

This should be moved to the clock provider api. E.g. to register a 2nd clock.

Point here is the bit is always cleared, even if OHCI is unused/disabled, but EHCI is. EHCI can be enabled w/o OHCI when there's an on-board USB HUB (in such case only High Speed traffic is expected).

EHCI don't require to clear CMN for suspend states.

Quoted 36 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +36 -0
+
+	ret = regulator_enable(phy_dev->vdd33);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(phy_dev->phyref);
+	if (ret)
+		goto error_regdis;
+
+	ret = reset_control_deassert(phy_dev->rstc);
+	if (ret)
+		goto error_clkdis;
+
+	return 0;
+
+error_clkdis:
+	clk_disable_unprepare(phy_dev->phyref);
+error_regdis:
+	regulator_disable(phy_dev->vdd33);
+
+	return ret;
+}
+
+static int stm32_usb2phy_disable(struct stm32_usb2phy *phy_dev)
+{
+	int ret;
+
+	/* Check if a phy is still init or clk48 in use */
+	if (atomic_dec_return(&phy_dev->en_refcnt) > 0)
+		return 0;
+
+	ret = reset_control_assert(phy_dev->rstc);
+	if (ret)
+		return ret;
+
+	clk_disable_unprepare(phy_dev->phyref);

drivers/phy/st/phy-stm32-usb2phy.c line 134

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +10 -0
+
+	return regulator_disable(phy_dev->vdd33);
+}
+
+static int stm32_usb2phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+	u32 val, mask = SYSCFG_USB2PHY2CR_USB2PHY2CMN;
+	int ret;

Then could simplify here directly for host only PHY : there's no point in poking control register here.
(As mentioned above, control SYSCFG_USB2PHY2CR_USB2PHY2CMN with clock provider API for host-only configuration.)

	if (phy_data->is_usb2_host_only)
		return 0;
Quoted 153 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +153 -0
+
+	if (mode == PHY_MODE_USB_HOST) {
+		val = 0;
+		if (!phy_data->is_usb2_host_only) {
+			mask |= SYSCFG_USB2PHY2CR_VBUSVLDEXT |
+				SYSCFG_USB2PHY2CR_VBUSVALID;
+			if (submode != USB_ROLE_NONE)
+				val |= SYSCFG_USB2PHY2CR_VBUSVALID;
+		}
+	} else if (mode == PHY_MODE_USB_DEVICE) {
+		val = SYSCFG_USB2PHY2CR_USB2PHY2CMN |
+		      SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL;
+		mask |= SYSCFG_USB2PHY2CR_VBUSVALID |
+			SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL |
+			SYSCFG_USB2PHY2CR_VBUSVLDEXT;
+		if (submode != USB_ROLE_NONE)
+			val |= SYSCFG_USB2PHY2CR_VBUSVLDEXT;
+	} else {
+		return -EINVAL;
+	}
+
+	ret = regmap_update_bits(phy_dev->regmap, phy_dev->cr_offset, mask, val);
+	if (ret)
+		return ret;
+
+	phy_dev->mode = mode;
+
+	return 0;
+}
+
+static int stm32_usb2phy_init(struct phy *phy)
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	int ret;
+
+	ret = stm32_usb2phy_enable(phy_dev);
+	if (ret)
+		return ret;
+
+	if (phy_dev->mode != PHY_MODE_INVALID) {
+		ret = stm32_usb2phy_set_mode(phy, phy_dev->mode, USB_ROLE_NONE);
+		if (ret) {
+			stm32_usb2phy_disable(phy_dev);
+			return ret;
+		}
+	}
+
+	phy_dev->is_init = true;
+
+	return 0;
+}
+
+static int stm32_usb2phy_exit(struct phy *phy)
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	int ret;
+
+	ret = stm32_usb2phy_disable(phy_dev);
+	if (ret)
+		return ret;
+
+	phy_dev->is_init = false;
+
+	return 0;
+}
+
+static const struct phy_ops stm32_usb2phy_data = {
+	.init = stm32_usb2phy_init,
+	.exit = stm32_usb2phy_exit,
+	.set_mode = stm32_usb2phy_set_mode,
+	.owner = THIS_MODULE,
+};
+
+static int stm32_usb2phy_clk48_prepare(struct clk_hw *hw)
+{
+	struct stm32_usb2phy *phy_dev = container_of(hw, struct stm32_usb2phy,
+						     clk48_hw);
+
+	return stm32_usb2phy_enable(phy_dev);
+}
+
+static void stm32_usb2phy_clk48_unprepare(struct clk_hw *hw)
+{
+	struct stm32_usb2phy *phy_dev = container_of(hw, struct stm32_usb2phy,
+						     clk48_hw);
+
+	stm32_usb2phy_disable(phy_dev);
+}
+
+static unsigned long stm32_usb2phy_clk48_recalc_rate(struct clk_hw *hw,
+						     unsigned long parent_rate)
+{
+	return 48000000;
+}
+
+static const struct clk_ops stm32_usb2phy_clk48_ops = {
+	.prepare = stm32_usb2phy_clk48_prepare,
+	.unprepare = stm32_usb2phy_clk48_unprepare,
+	.recalc_rate = stm32_usb2phy_clk48_recalc_rate,
+};
+
+static int stm32_usb2phy_probe(struct platform_device *pdev)
+{
+	struct clk_init_data init = { .ops =  &stm32_usb2phy_clk48_ops };
+	struct phy_provider *phy_provider;
+	struct device *dev = &pdev->dev;
+	struct stm32_usb2phy *phy_dev;
+	const __be32 *offset;
+	struct phy *phy;
+	int ret;
+
+	phy_dev = devm_kzalloc(dev, sizeof(*phy_dev), GFP_KERNEL);
+	if (!phy_dev)
+		return -ENOMEM;
+
+	phy_dev->dev = dev;
+	dev_set_drvdata(dev, phy_dev);
+
+	phy_dev->rstc = devm_reset_control_get(dev, NULL);
+	if (IS_ERR(phy_dev->rstc))
+		return dev_err_probe(dev, PTR_ERR(phy_dev->rstc), "Failed to get USB2PHY reset\n");
+
+	phy_dev->phyref = devm_clk_get(dev, NULL);
+	if (IS_ERR(phy_dev->phyref))
+		return dev_err_probe(dev, PTR_ERR(phy_dev->phyref), "Failed to get phyref clk\n");
+
+	phy_dev->vdd33 = devm_regulator_get_optional(dev, "vdd33");
+	if (IS_ERR(phy_dev->vdd33))
+		return dev_err_probe(dev, PTR_ERR(phy_dev->vdd33), "Failed to get vdd3v3 supply\n");
+
+	phy_dev->regmap = syscon_node_to_regmap(dev->of_node->parent);
+	if (IS_ERR(phy_dev->regmap))
+		return dev_err_probe(dev, PTR_ERR(phy_dev->regmap), "Failed to get regmap\n");
+
+	offset = of_get_address(dev->of_node, 0, NULL, NULL);
+	if (!offset)
+		return dev_err_probe(dev, -EINVAL, "Failed to get regmap offset\n");
+
+	phy_dev->cr_offset = be32_to_cpu(*offset);
+
+	phy_dev->hw_data = device_get_match_data(dev);
+
+	phy = devm_phy_create(dev, NULL, &stm32_usb2phy_data);
+	if (IS_ERR(phy))
+		return dev_err_probe(dev, PTR_ERR(phy), "Failed to create PHY\n");
+
+	phy_dev->phy = phy;
+	phy_set_drvdata(phy, phy_dev);
+
+	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+	if (IS_ERR(phy_provider))
+		return PTR_ERR(phy_provider);
+

drivers/phy/st/phy-stm32-usb2phy.c line 297

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +10 -0
+	init.name = devm_kasprintf(dev, GFP_KERNEL, "clk_%s_48m",
+				   of_node_full_name(dev->of_node));
+	if (!init.name)
+		return -ENOMEM;
+
+	phy_dev->clk48_hw.init = &init;
+
+	ret = devm_clk_hw_register(phy_dev->dev, &phy_dev->clk48_hw);
+	if (ret)
+		return dev_err_probe(phy_dev->dev, ret, "Failed to register 48 MHz clock\n");

In v2, the #clock-cells has been updated to 1. This allow to manage separately the OHCI clock bit ("...CMN") as a child clock of the 48MHz clock.

Please register a 2nd clock, so the OHCI controller can take benefit of it.

As you mention the downstream driver, please see there a specific comment regarding the 2nd clock for OHCI:
/*
* USB2PHY provides several clocks used either by either USHB (EHCI/OHCI), OTG or USB3DR.
* In case of OHCI, CMN bit must be cleared (clkohci_hw). This clock is required to access
* the registers, to resume the controller from suspended state.
* So declare two clocks, the PLL used in all case, and the OHCI clocks used by OHCI
* controller.
*/

Thanks & BR,
Fabrice

Quoted 64 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +64 -0
+
+	ret = devm_of_clk_add_hw_provider(phy_dev->dev, of_clk_hw_simple_get, &phy_dev->clk48_hw);
+	if (ret)
+		return dev_err_probe(phy_dev->dev, ret, "Failed to add 48 MHz clock provider\n");
+
+	return 0;
+}
+
+static int stm32_usb2phy_suspend(struct device *dev)
+{
+	struct stm32_usb2phy *phy_dev = dev_get_drvdata(dev);
+
+	if (phy_dev->is_init)
+		return stm32_usb2phy_disable(phy_dev);
+
+	return 0;
+}
+
+static int stm32_usb2phy_resume(struct device *dev)
+{
+	struct stm32_usb2phy *phy_dev = dev_get_drvdata(dev);
+
+	if (phy_dev->is_init)
+		return stm32_usb2phy_enable(phy_dev);
+
+	return 0;
+}
+
+/* STM32MP25xx USB 2.0 PHY attached to USB 2.0 Host controller */
+static const struct stm32mp2_usb2phy_hw_data stm32mp25_usb2phy1_hwdata = {
+	.phyrefsel_mask = GENMASK(6, 4),
+	.is_usb2_host_only = true,
+};
+
+/* STM32MP25xx USB 2.0 PHY attached to USB 2.0 part of DWC3 controller */
+static const struct stm32mp2_usb2phy_hw_data stm32mp25_usb2phy2_hwdata = {
+	.phyrefsel_mask = GENMASK(14, 12),
+	.is_usb2_host_only = false,
+};
+
+static const struct of_device_id stm32_usb2phy_of_match[] = {
+	{ .compatible = "st,stm32mp25-usb2phy1", .data = &stm32mp25_usb2phy1_hwdata },
+	{ .compatible = "st,stm32mp25-usb2phy2", .data = &stm32mp25_usb2phy2_hwdata },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, stm32_usb2phy_of_match);
+
+static DEFINE_SIMPLE_DEV_PM_OPS(stm32_usb2phy_pm_ops,
+				stm32_usb2phy_suspend, stm32_usb2phy_resume);
+
+static struct platform_driver stm32_usb2phy_driver = {
+	.probe = stm32_usb2phy_probe,
+	.driver = {
+		.name = "stm32-usb2phy",
+		.of_match_table = stm32_usb2phy_of_match,
+		.pm = pm_sleep_ptr(&stm32_usb2phy_pm_ops)
+	}
+};
+
+module_platform_driver(stm32_usb2phy_driver);
+
+MODULE_AUTHOR("Pankaj Dev <[email protected]>");
+MODULE_DESCRIPTION("STMicroelectronics Generic USB2PHY driver for stm32");
+MODULE_LICENSE("GPL");
#7 lore raw

Re: [PATCH v2 2/9] phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY

On 8/17/26 6:22 PM, Fabrice Gasnier wrote:

Hello Fabrice,

Quoted 11 lines

Review line 6

Quoted 8 lines

+++ b/drivers/phy/st/phy-stm32-usb2phy.c

(quoted diff) +6 -0
@@ -0,0 +1,361 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * STMicroelectronics STM32 USB2 PHY Controller driver
+ * Currently Only supported for STM32MP25
+ *
+ * Copyright (C) 2022 STMicroelectronics

Hi Marek,

Quoted 1 line

Could update to 2026 ?

Fixed in V3.

[...]

Quoted 48 lines
Quoted 17 lines
(quoted diff) +17 -0
+static int stm32_usb2phy_enable(struct stm32_usb2phy *phy_dev)
+{
+	const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+	unsigned long rate;
+	int refsel, ret;
+
+	/* Check if a phy is already init or clk48 in use */
+	if (atomic_inc_return(&phy_dev->en_refcnt) > 1)
+		return 0;
+
+	rate = clk_get_rate(phy_dev->phyref);
+	if (rate == 19200000)
+		refsel = 0;
+	else if (rate == 20000000)
+		refsel = 1;
+	else if (rate == 24000000)
+		refsel = 2;

Review line 33

Quoted 10 lines
(quoted diff) +10 -0
+	else
+		return -EINVAL;
+
+	ret = regmap_update_bits(phy_dev->regmap,
+				 phy_dev->cr_offset,
+				 phy_data->phyrefsel_mask,
+				 field_prep(phy_data->phyrefsel_mask, refsel));
+	if (ret)
+		return ret;
+

Hi Marek,

Below condition

Review line 45

Quoted 12 lines
(quoted diff) +12 -0
+	if (phy_data->is_usb2_host_only) {
+		/*
+		 * The clock should default to active after standby, as it is
+		 * needed when resuming OHCI to access its registers.
+		 * CMN is default reset to 1, so enforce it is cleared, when the
+		 * clock enable request from OHCI driver comes at resume time.
+		 */
+		ret = regmap_clear_bits(phy_dev->regmap, phy_dev->cr_offset,
+					SYSCFG_USB2PHY2CR_USB2PHY2CMN);
+		if (ret)
+			return ret;
+	}

up to here, is a specific part to manage OHCI controller clock during suspend modes (either bus suspend, or system-wide platform low power PM).

Quoted 8 lines

This should be moved to the clock provider api. E.g. to register a 2nd clock.

Point here is the bit is always cleared, even if OHCI is unused/disabled, but EHCI is. EHCI can be enabled w/o OHCI when there's an on-board USB HUB (in such case only High Speed traffic is expected).

EHCI don't require to clear CMN for suspend states.

Please see at the end of this email.

Quoted 4 lines
Quoted 4 lines
(quoted diff) +4 -0
+
+	ret = regulator_enable(phy_dev->vdd33);
+	if (ret)
+		return ret;

[...]

Quoted 12 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+static int stm32_usb2phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+	u32 val, mask = SYSCFG_USB2PHY2CR_USB2PHY2CMN;
+	int ret;

Then could simplify here directly for host only PHY : there's no point in poking control register here.
(As mentioned above, control SYSCFG_USB2PHY2CR_USB2PHY2CMN with clock provider API for host-only configuration.)

Quoted 2 lines
	if (phy_data->is_usb2_host_only)
		return 0;

I think it would be even better at this point to register separate PHY ops for each PHY, one with and one without .set_mode .

[...]

Quoted 10 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+	ret = devm_clk_hw_register(phy_dev->dev, &phy_dev->clk48_hw);
+	if (ret)
+		return dev_err_probe(phy_dev->dev, ret, "Failed to register 48 MHz clock\n");

In v2, the #clock-cells has been updated to 1. This allow to manage separately the OHCI clock bit ("...CMN") as a child clock of the 48MHz clock.

Please register a 2nd clock, so the OHCI controller can take benefit of it.

Quoted 12 lines

As you mention the downstream driver, please see there a specific comment regarding the 2nd clock for OHCI:
/*
* USB2PHY provides several clocks used either by either USHB (EHCI/OHCI), OTG or USB3DR.
* In case of OHCI, CMN bit must be cleared (clkohci_hw). This clock is required to access
* the registers, to resume the controller from suspended state.
* So declare two clocks, the PLL used in all case, and the OHCI clocks used by OHCI
* controller.
*/

Is this what you have in mind ?

arch/arm64/boot/dts/st/stm32mp231.dtsi +1 -1
index e22bb53c9748b..2fa03b059c71b 100644
@@ -883,7 +883,7 @@ usbh_ohci: usb@482e0000 {
 				compatible = "generic-ohci";
 				reg = <0x482e0000 0x1000>;
 				access-controllers = <&rifsc 63>;
-				clocks = <&usb2_phy1 0>, <&rcc CK_BUS_USB2OHCI>;
+				clocks = <&usb2_phy1 1>, <&rcc CK_BUS_USB2OHCI>;
 				interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
 				phys = <&usb2_phy1>;
 				phy-names = "usb";
arch/arm64/boot/dts/st/stm32mp251.dtsi +1 -1
index dbaac8a930fda..6e0f25e33f05f 100644
@@ -1765,7 +1765,7 @@ usbh_ohci: usb@482e0000 {
 				compatible = "generic-ohci";
 				reg = <0x482e0000 0x1000>;
 				access-controllers = <&rifsc 63>;
-				clocks = <&usb2_phy1 0>, <&rcc CK_BUS_USB2OHCI>;
+				clocks = <&usb2_phy1 1>, <&rcc CK_BUS_USB2OHCI>;
 				interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
 				phys = <&usb2_phy1>;
 				phy-names = "usb";
drivers/phy/st/phy-stm32-usb2phy.c +43 -19

109 lines not on this page · raw message

clock\n");

- ret = devm_of_clk_add_hw_provider(phy_dev->dev, of_clk_hw_simple_get, &phy_dev->clk48_hw);
+ phy_dev->clkcmn_hw.init = &clkcmninit;
+ ret = devm_clk_hw_register(phy_dev->dev, &phy_dev->clkcmn_hw);
+ if (ret)
+ return dev_err_probe(phy_dev->dev, ret, "Failed to register CMN clock\n");
+
+ ret = devm_of_clk_add_hw_provider(phy_dev->dev, of_clk_hw_onecell_get, &phy_dev->onecell);
if (ret)
- return dev_err_probe(phy_dev->dev, ret, "Failed to add 48 MHz clock provider\n");
+ return dev_err_probe(phy_dev->dev, ret, "Failed to add clock provider\n");

return 0;
}

#8 lore raw

Re: [PATCH v2 2/9] phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY

Quoted 19 lines · Marek Vasut

On 8/17/26 6:22 PM, Fabrice Gasnier wrote:

Hello Fabrice,

Quoted 11 lines

Review line 6

Quoted 8 lines

+++ b/drivers/phy/st/phy-stm32-usb2phy.c

(quoted diff) +6 -0
@@ -0,0 +1,361 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * STMicroelectronics STM32 USB2 PHY Controller driver
+ * Currently Only supported for STM32MP25
+ *
+ * Copyright (C) 2022 STMicroelectronics

Hi Marek,

Quoted 1 line

Could update to 2026 ?

Fixed in V3.

Quoted 7 lines

[...]

Quoted 5 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+static int stm32_usb2phy_enable(struct stm32_usb2phy *phy_dev)
+{
+    const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+    unsigned long rate;
+    int refsel, ret;

Hello Marek,

Just noticed refsel should be unsigned ?

Quoted 75 lines
Quoted 44 lines
Quoted 12 lines
(quoted diff) +12 -0
+
+    /* Check if a phy is already init or clk48 in use */
+    if (atomic_inc_return(&phy_dev->en_refcnt) > 1)
+        return 0;
+
+    rate = clk_get_rate(phy_dev->phyref);
+    if (rate == 19200000)
+        refsel = 0;
+    else if (rate == 20000000)
+        refsel = 1;
+    else if (rate == 24000000)
+        refsel = 2;

Review

Quoted 10 lines
(quoted diff) +10 -0
+    else
+        return -EINVAL;
+
+    ret = regmap_update_bits(phy_dev->regmap,
+                 phy_dev->cr_offset,
+                 phy_data->phyrefsel_mask,
+                 field_prep(phy_data->phyrefsel_mask, refsel));
+    if (ret)
+        return ret;
+

Hi Marek,

Below condition

Quoted 5 lines

+    if (phy_data->is_usb2_host_only) {
+        /*
+         * The clock should default to active after standby, as it is +         * needed when resuming OHCI to access its registers. +         * CMN is default reset to 1, so enforce it is cleared, when

Quoted 8 lines

the
+         * clock enable request from OHCI driver comes at resume time. +         */
+        ret = regmap_clear_bits(phy_dev->regmap, phy_dev->cr_offset, +                    SYSCFG_USB2PHY2CR_USB2PHY2CMN);
+        if (ret)
+            return ret;
+    }

up to here, is a specific part to manage OHCI controller clock during suspend modes (either bus suspend, or system-wide platform low power PM).

Quoted 8 lines

This should be moved to the clock provider api. E.g. to register a 2nd clock.

Point here is the bit is always cleared, even if OHCI is unused/disabled, but EHCI is. EHCI can be enabled w/o OHCI when there's an on-board USB HUB (in such case only High Speed traffic is expected).

EHCI don't require to clear CMN for suspend states.

Please see at the end of this email.

Quoted 4 lines
Quoted 4 lines

+
+    ret = regulator_enable(phy_dev->vdd33);
+    if (ret)
+        return ret;

[...]

Quoted 13 lines
Quoted 7 lines

+static int stm32_usb2phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+    struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+    const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data; +    u32 val, mask = SYSCFG_USB2PHY2CR_USB2PHY2CMN;
+    int ret;

Then could simplify here directly for host only PHY : there's no point in poking control register here.
(As mentioned above, control SYSCFG_USB2PHY2CR_USB2PHY2CMN with clock provider API for host-only configuration.)

Quoted 5 lines
Quoted 2 lines

    if (phy_data->is_usb2_host_only)
        return 0;

I think it would be even better at this point to register separate PHY ops for each PHY, one with and one without .set_mode .

Indeed, nice thought

Quoted 27 lines

[...]

Quoted 12 lines
Quoted 4 lines

+    ret = devm_clk_hw_register(phy_dev->dev, &phy_dev->clk48_hw); +    if (ret)
+        return dev_err_probe(phy_dev->dev, ret, "Failed to register 48 MHz clock\n");

In v2, the #clock-cells has been updated to 1. This allow to manage separately the OHCI clock bit ("...CMN") as a child clock of the 48MHz clock.

Please register a 2nd clock, so the OHCI controller can take benefit of it.

Quoted 12 lines

As you mention the downstream driver, please see there a specific comment regarding the 2nd clock for OHCI:
/*
* USB2PHY provides several clocks used either by either USHB (EHCI/OHCI), OTG or USB3DR.
* In case of OHCI, CMN bit must be cleared (clkohci_hw). This clock is required to access
* the registers, to resume the controller from suspended state.
* So declare two clocks, the PLL used in all case, and the OHCI clocks used by OHCI
* controller.
*/

Quoted 1 line

Is this what you have in mind ?

Yes, with one addition, please see next comment

Quoted 105 lines
arch/arm64/boot/ renamed from arch/arm64/boot/dts/st/stm32mp231.dtsi +0 -0

dts/st/stm32mp231.dtsi
index e22bb53c9748b..2fa03b059c71b 100644

arch/arm64/boot/dts/st/stm32mp231.dtsi +1 -1
@@ -883,7 +883,7 @@ usbh_ohci: usb@482e0000 {
                  compatible = "generic-ohci";
                  reg = <0x482e0000 0x1000>;
                  access-controllers = <&rifsc 63>;
-                clocks = <&usb2_phy1 0>, <&rcc CK_BUS_USB2OHCI>;
+                clocks = <&usb2_phy1 1>, <&rcc CK_BUS_USB2OHCI>;
                  interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
                  phys = <&usb2_phy1>;
                  phy-names = "usb";
arch/arm64/boot/ renamed from arch/arm64/boot/dts/st/stm32mp251.dtsi +0 -0

dts/st/stm32mp251.dtsi
index dbaac8a930fda..6e0f25e33f05f 100644

arch/arm64/boot/dts/st/stm32mp251.dtsi +1 -1
@@ -1765,7 +1765,7 @@ usbh_ohci: usb@482e0000 {
                  compatible = "generic-ohci";
                  reg = <0x482e0000 0x1000>;
                  access-controllers = <&rifsc 63>;
-                clocks = <&usb2_phy1 0>, <&rcc CK_BUS_USB2OHCI>;
+                clocks = <&usb2_phy1 1>, <&rcc CK_BUS_USB2OHCI>;
                  interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
                  phys = <&usb2_phy1>;
                  phy-names = "usb";
drivers/phy/st/phy- renamed from drivers/phy/st/phy-stm32-usb2phy.c +0 -0

stm32-usb2phy.c
index 1daaf2f440d04..1c4b37094591c 100644

drivers/phy/st/phy-stm32-usb2phy.c +6 -14
@@ -27,6 +27,8 @@
  #define SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL        BIT(5)
  #define SYSCFG_USB2PHY2CR_VBUSVLDEXT        BIT(6)
 
+#define USBH_NUM_CLK                2
+
  struct stm32_usb2phy {
      struct phy                *phy;
      struct regmap                *regmap;
@@ -34,12 +36,15 @@ struct stm32_usb2phy {
      struct reset_control            *rstc;
      struct clk                *phyref;
      struct regulator            *vdd33;
-    struct clk_hw                clk48_hw;
      const struct stm32mp2_usb2phy_hw_data    *hw_data;
      atomic_t                en_refcnt;
      enum phy_mode                mode;
      u32                    cr_offset;
      bool                    is_init;
+    struct clk_hw                clk48_hw;
+    struct clk_hw                clkcmn_hw;
+    /* Must be last */
+    struct clk_hw_onecell_data        onecell;
  };
 
  struct stm32mp2_usb2phy_hw_data {
@@ -74,19 +79,6 @@ static int stm32_usb2phy_enable(struct stm32_usb2phy
 *phy_dev)
      if (ret)
          return ret;
 
-    if (phy_data->is_usb2_host_only) {
-        /*
-         * The clock should default to active after standby, as it is
-         * needed when resuming OHCI to access its registers.
-         * CMN is default reset to 1, so enforce it is cleared, when the
-         * clock enable request from OHCI driver comes at resume time.
-         */
-        ret = regmap_clear_bits(phy_dev->regmap, phy_dev->cr_offset,
-                    SYSCFG_USB2PHY2CR_USB2PHY2CMN);
-        if (ret)
-            return ret;
-    }
-
      ret = regulator_enable(phy_dev->vdd33);
      if (ret)

         return ret;

drivers/phy/st/phy-stm32-usb2phy.c +19 -0
@@ -233,9 +225,33 @@ static const struct clk_ops stm32_usb2phy_clk48_ops
 = {
      .recalc_rate = stm32_usb2phy_clk48_recalc_rate,
  };
 
+static int stm32_usb2phy_clkcmn_prepare(struct clk_hw *hw)
+{
+    struct stm32_usb2phy *phy_dev = container_of(hw, struct stm32_usb2phy,
+                             clkcmn_hw);
+
+    return regmap_clear_bits(phy_dev->regmap, phy_dev->cr_offset,
+                 SYSCFG_USB2PHY2CR_USB2PHY2CMN);
+}
+
+static void stm32_usb2phy_clkcmn_unprepare(struct clk_hw *hw)
+{
+    struct stm32_usb2phy *phy_dev = container_of(hw, struct stm32_usb2phy,
+                             clkcmn_hw);
+
+    regmap_set_bits(phy_dev->regmap, phy_dev->cr_offset,
+            SYSCFG_USB2PHY2CR_USB2PHY2CMN);
+}
+
+static const struct clk_ops stm32_usb2phy_clkcmn_ops = {

drivers/phy/st/phy-stm32-usb2phy.c static const struct clk_ops stm32_usb2phy_clk48_ops · line 256

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c +6 -1
+    .prepare = stm32_usb2phy_clkcmn_prepare,
+    .unprepare = stm32_usb2phy_clkcmn_unprepare,
+};
+
  static int stm32_usb2phy_probe(struct platform_device *pdev)
  {
-    struct clk_init_data init = { .ops =  &stm32_usb2phy_clk48_ops };
+    struct clk_init_data clk48init = { .ops =  &stm32_usb2phy_clk48_ops };
+    struct clk_init_data clkcmninit = { .ops = 
 &stm32_usb2phy_clkcmn_ops };

clkcmninit should be a child of clk48 which basically represent the PLL (480MHz) as it is still needed as parent. See below.

BTW, mainly a nit: could rename clk48 to clkpll and update frequency to 480M.

Quoted 42 lines
drivers/phy/st/phy-stm32-usb2phy.c +0 -0
      struct phy_provider *phy_provider;

     struct device *dev = &pdev->dev;
     struct stm32_usb2phy *phy_dev;

drivers/phy/st/phy-stm32-usb2phy.c +1 -1
@@ -243,7 +259,7 @@ static int stm32_usb2phy_probe(struct
 platform_device *pdev)
      struct phy *phy;
      int ret;
 
-    phy_dev = devm_kzalloc(dev, sizeof(*phy_dev), GFP_KERNEL);
+    phy_dev = devm_kzalloc(dev, struct_size(phy_dev, onecell.hws,
 USBH_NUM_CLK), GFP_KERNEL);
      if (!phy_dev)

         return -ENOMEM;

drivers/phy/st/phy-stm32-usb2phy.c +11 -3
@@ -285,20 +301,33 @@ static int stm32_usb2phy_probe(struct
 platform_device *pdev)
      if (IS_ERR(phy_provider))
          return PTR_ERR(phy_provider);
 
-    init.name = devm_kasprintf(dev, GFP_KERNEL, "clk_%s_48m",
+    clk48init.name = devm_kasprintf(dev, GFP_KERNEL, "clk_%s_48m",
                     of_node_full_name(dev->of_node));
-    if (!init.name)
+    if (!clk48init.name)
          return -ENOMEM;
 
-    phy_dev->clk48_hw.init = &init;
+    clkcmninit.name = devm_kasprintf(dev, GFP_KERNEL, "clk_%s_cmn",
+                   of_node_full_name(dev->of_node));
+    if (!clkcmninit.name)
+        return -ENOMEM;
+
+    phy_dev->onecell.num = USBH_NUM_CLK;
+    phy_dev->onecell.hws[0] = &phy_dev->clk48_hw;
+    phy_dev->onecell.hws[1] = &phy_dev->clkcmn_hw;
 
+    phy_dev->clk48_hw.init = &clk48init;
      ret = devm_clk_hw_register(phy_dev->dev, &phy_dev->clk48_hw);
      if (ret)

         return dev_err_probe(phy_dev->dev, ret, "Failed to register 48 MHz clock\n");

Quoted 3 lines

-    ret = devm_of_clk_add_hw_provider(phy_dev->dev, of_clk_hw_simple_get, &phy_dev->clk48_hw);
+    phy_dev->clkcmn_hw.init = &clkcmninit;

Would initialize with (to adapt) :

+ phy_dev->clkcmn_hw.init = CLK_HW_INIT_HW(name, &phy_dev->clk48_hw,
+ &stm32_usb2phy_clkcmn_ops, 0);
+

Thanks & BR,
Fabrice

Quoted 15 lines

+    ret = devm_clk_hw_register(phy_dev->dev, &phy_dev->clkcmn_hw); +    if (ret)
+        return dev_err_probe(phy_dev->dev, ret, "Failed to register CMN clock\n");
+
+    ret = devm_of_clk_add_hw_provider(phy_dev->dev, of_clk_hw_onecell_get, &phy_dev->onecell);
     if (ret)
-        return dev_err_probe(phy_dev->dev, ret, "Failed to add 48 MHz clock provider\n");
+        return dev_err_probe(phy_dev->dev, ret, "Failed to add clock provider\n");

     return 0;
 }

#9 lore raw

Re: [PATCH v2 2/9] phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY

On 8/18/26 11:28 AM, Fabrice Gasnier wrote:

Hello Fabrice,

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+static int stm32_usb2phy_enable(struct stm32_usb2phy *phy_dev)
+{
+    const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+    unsigned long rate;
+    int refsel, ret;

Hello Marek,

Just noticed refsel should be unsigned ?

It makes no difference in this case, since the value can be either 0/1/2, but fixed.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
(quoted diff) +14 -0
+
+    /* Check if a phy is already init or clk48 in use */
+    if (atomic_inc_return(&phy_dev->en_refcnt) > 1)
+        return 0;
+
+    rate = clk_get_rate(phy_dev->phyref);
+    if (rate == 19200000)
+        refsel = 0;
+    else if (rate == 20000000)
+        refsel = 1;
+    else if (rate == 24000000)
+        refsel = 2;
+    else
+        return -EINVAL;

[...]

Quoted 15 lines
Quoted 12 lines
Quoted 4 lines

As you mention the downstream driver, please see there a specific comment regarding the 2nd clock for OHCI:
/*
* USB2PHY provides several clocks used either by either USHB

Quoted 8 lines

(EHCI/OHCI), OTG or USB3DR.
* In case of OHCI, CMN bit must be cleared (clkohci_hw). This clock is required to access
* the registers, to resume the controller from suspended state.
* So declare two clocks, the PLL used in all case, and the OHCI clocks used by OHCI
* controller.
*/

Quoted 1 line

Is this what you have in mind ?

Yes, with one addition, please see next comment

[...]

Quoted 7 lines
Quoted 6 lines

 static int stm32_usb2phy_probe(struct platform_device *pdev) {
-    struct clk_init_data init = { .ops =  &stm32_usb2phy_clk48_ops }; +    struct clk_init_data clk48init = { .ops =  &stm32_usb2phy_clk48_ops }; +    struct clk_init_data clkcmninit = { .ops = &stm32_usb2phy_clkcmn_ops };

Quoted 5 lines

clkcmninit should be a child of clk48 which basically represent the PLL (480MHz) as it is still needed as parent. See below.

BTW, mainly a nit: could rename clk48 to clkpll and update frequency to 480M.

Fixed in V3.

Quoted 13 lines
Quoted 9 lines

+    phy_dev->clk48_hw.init = &clk48init;
     ret = devm_clk_hw_register(phy_dev->dev, &phy_dev->clk48_hw); if (ret)
         return dev_err_probe(phy_dev->dev, ret, "Failed to register 48
MHz clock\n");

-    ret = devm_of_clk_add_hw_provider(phy_dev->dev, of_clk_hw_simple_get, &phy_dev->clk48_hw);
+    phy_dev->clkcmn_hw.init = &clkcmninit;

Would initialize with (to adapt) :

+ phy_dev->clkcmn_hw.init = CLK_HW_INIT_HW(name, &phy_dev->clk48_hw,

Review

Quoted 2 lines
(quoted diff) +2 -0
+					 &stm32_usb2phy_clkcmn_ops, 0);
+

That's nice, also added to V3, thanks !

[...]

#10 lore raw

PATCH v2 3/9 dt-bindings: usb: generic-ehci: Document access-controllers property

In reply to Marek Vasut

Document the access-controllers for EHCI USB controllers in case access checks need to be performed to use them.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: No change

---
 Documentation/devicetree/bindings/usb/generic-ehci.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/usb/generic-ehci.yaml +3 -0
index ae9fb70d0212c..6bca56681cdfe 100644
@@ -80,6 +80,9 @@ properties:
     minItems: 1
     maxItems: 2
 
+  access-controllers:
+    maxItems: 1
+
   dma-coherent: true
 
   interrupts:
Signature · 1 line
2.53.0
#11 lore raw

Re: [PATCH v2 3/9] dt-bindings: usb: generic-ehci: Document access-controllers property

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The patch adds the `access-controllers` property to `generic-ehci.yaml` but fails to update the…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch adds the access-controllers property to generic-ehci.yaml but fails to update the companion generic-ohci.yaml binding schema. --

--- Patch [3]: [PATCH v2 3/9] dt-bindings: usb: generic-ehci: Document access-controllers property --- commit 53582485218bdac0220f3acaf5124a6d9549f7b3
Author: Marek Vasut <[email protected]>

dt-bindings: usb: generic-ehci: Document access-controllers property

This commit updates the generic EHCI device tree binding to document the access-controllers property for controllers that require access checks.

Documentation/devicetree/bindings/usb/generic-ehci.yaml properties: · line 85

Quoted 11 lines
Documentation/devicetree/bindings/usb/generic-ehci.yaml +3 -0
index 55a5aa7d7a54e..602241887d995 100644
@@ -80,6 +80,9 @@ properties:
     minItems: 1
     maxItems: 2
 
+  access-controllers:
+    maxItems: 1
+

[Severity: Medium]
Should Documentation/devicetree/bindings/usb/generic-ohci.yaml also be updated symmetrically?

When access-controllers are configured for the companion OHCI controller in the device tree (such as on STMicroelectronics SoCs where EHCI and OHCI operate as firewalled companions), wouldn't the dt_binding_check validation fail since generic-ohci.yaml enforces unevaluatedProperties: false?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#12 lore raw

PATCH v2 4/9 dt-bindings: usb: generic-ohci: Document access-controllers property

In reply to Marek Vasut

Document the access-controllers for OHCI USB controllers in case access checks need to be performed to use them.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: No change

---
 Documentation/devicetree/bindings/usb/generic-ohci.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/usb/generic-ohci.yaml +3 -0
index 322808aaa2839..8e3522a3faa76 100644
@@ -65,6 +65,9 @@ properties:
   reg:
     maxItems: 1
 
+  access-controllers:
+    maxItems: 1
+
   dma-coherent: true
 
   interrupts:
Signature · 1 line
2.53.0
#13 lore raw

PATCH v2 5/9 dt-bindings: usb: dwc3: Document ST STM32MP2 DWC3 xHCI USB controller

In reply to Marek Vasut

The ST STM32MP2 SoC contains single instance of DWC3 USB controller with glue logic wrapper around it controlled by syscon. Document the glue logic and DWC3 controller.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: Fix up Sob/Cdb lines

---
 .../bindings/usb/st,stm32mp25-dwc3.yaml       | 108 ++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +108 -0
new file mode 100644
index 0000000000000..e377efef43503
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/st,stm32mp25-dwc3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STMicroelectronics STM32 MPU DWC3 USB SoC controller
+
+description:
+  The STM32 MPU DWC3 USB SoC controller block supports both
+  Host(SS/HS/FS/LS) and Device(SS/HS/FS) mode operation
+
+maintainers:
+  - Fabrice Gasnier <[email protected]>
+  - Marek Vasut <[email protected]>
+
+properties:
+  compatible:
+    const: st,stm32mp25-dwc3
+
+  reg:
+    maxItems: 1
+
+  access-controllers:
+    maxItems: 1
+
+  clocks:
+    minItems: 3
+    maxItems: 3
+
+  clock-names:
+    items:
+      - const: ref
+      - const: bus_early
+      - const: suspend
+
+  dr_mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    enum: [host, peripheral, otg]
+
+  interrupts:
+    maxItems: 1
+
+  phys:
+    minItems: 1
+    maxItems: 2
+
+  phy-names:
+    minItems: 1
+    items:
+      - const: usb2-phy
+      - const: usb3-phy
+
+  resets:
+    minItems: 1
+
+  st,syscfg:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    description: Phandle to system configuration controller.
+    items:
+      - items:
+          - description: phandle to syscfg
+          - description: USB3DR control offset within syscfg
+
+  st,enable-port-power-control:
+    type: boolean
+    description: Enable Host-Mode Port Power Control (bit-3 of capability param HCCPARAMS)
+
+  st,ovrcur-active-low:
+    type: boolean
+    description: Over-Current signal polarity is active-low
+
+  st,vbusen-active-low:
+    type: boolean
+    description: VBUS-ENABLE signal polarity is active-low
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupts
+  - phys
+  - phy-names
+  - resets
+  - st,syscfg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/st,stm32mp25-rcc.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/st,stm32mp25-rcc.h>
+
+    usb3dr: usb@48300000 {
+        compatible = "st,stm32mp25-dwc3";
+        reg = <0x48300000 0x100000>;
+        clocks = <&rcc CK_KER_USB2PHY2>, <&rcc CK_BUS_USB3DR>, <&rcc CK_KER_USB2PHY2>;
+        clock-names = "ref", "bus_early", "suspend";
+        interrupts = <GIC_SPI 228 IRQ_TYPE_LEVEL_HIGH>;
+        phys = <&usb2_phy>, <&usb3_phy>;
+        phy-names = "usb2-phy", "usb3-phy";
+        resets = <&rcc USB3DR_R>;
+        st,ovrcur-active-low;
+        st,syscfg = <&syscfg 0x4800>;
+        st,vbusen-active-low;
+    };
Signature · 1 line
2.53.0
#14 lore raw

Re: [PATCH v2 5/9] dt-bindings: usb: dwc3: Document ST STM32MP2 DWC3 xHCI USB controller

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The st,stm32mp25-dwc3.yaml schema defines a flattened DWC3 controller node and sets…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The st,stm32mp25-dwc3.yaml schema defines a flattened DWC3 controller node and sets unevaluatedProperties: false, but omits the required $ref to the standard DWC3 common schema (snps,dwc3-common.yaml#). This causes all standard generic USB properties (e.g., usb-role-switch, maximum-speed) and DWC3 quirks (snps,*) to be improperly rejected during device tree validation. --

--- Patch [5]: [PATCH v2 5/9] dt-bindings: usb: dwc3: Document ST STM32MP2 DWC3 xHCI USB controller --- commit 1e1f5ec0770c94ae4e8d9d9545d561a05a898622
Author: Marek Vasut <[email protected]>

dt-bindings: usb: dwc3: Document ST STM32MP2 DWC3 xHCI USB controller

The ST STM32MP2 SoC contains a single instance of a DWC3 USB controller with a glue logic wrapper. This commit adds the device tree binding schema to document the controller and its syscon-controlled wrapper.

Quoted 5 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +0 -0
new file mode 100644
index 0000000000000..e377efef43503

[ ... ]

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml line 88

Quoted 12 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +12 -0
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupts
+  - phys
+  - phy-names
+  - resets
+  - st,syscfg
+
+unevaluatedProperties: false

[Severity: Medium]
Will setting unevaluatedProperties: false without a $ref to snps,dwc3-common.yaml# prevent the use of standard generic USB properties?

Because this block strictly restricts allowed properties to those defined locally, it appears standard DWC3 quirks and generic USB properties like usb-role-switch or maximum-speed might be improperly rejected during device tree validation.

Quoted 4 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +4 -0
+
+examples:
+  - |
+    #include <dt-bindings/clock/st,stm32mp25-rcc.h>
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
#15 lore raw

Re: [PATCH v2 5/9] dt-bindings: usb: dwc3: Document ST STM32MP2 DWC3 xHCI USB controller

In reply to Marek Vasut
Quoted 29 lines · Marek Vasut
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +29 -0
+properties:
+  compatible:
+    const: st,stm32mp25-dwc3
+
+  reg:
+    maxItems: 1
+
+  access-controllers:
+    maxItems: 1
+
+  clocks:
+    minItems: 3
+    maxItems: 3
+
+  clock-names:
+    items:
+      - const: ref
+      - const: bus_early
+      - const: suspend
+
+  dr_mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    enum: [host, peripheral, otg]
+
+  interrupts:
+    maxItems: 1
+
+  phys:
+    minItems: 1

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml line 55

Quoted 10 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +10 -0
+    maxItems: 2
+
+  phy-names:
+    minItems: 1
+    items:
+      - const: usb2-phy
+      - const: usb3-phy
+
+  resets:
+    minItems: 1

Hm? You keep coming with some odd style, not present in any other files. Where do you see such code - property followed by minItems alone? This applies to other places as well.

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml line 67

Quoted 12 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +12 -0
+
+  st,syscfg:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    description: Phandle to system configuration controller.
+    items:
+      - items:
+          - description: phandle to syscfg
+          - description: USB3DR control offset within syscfg
+
+  st,enable-port-power-control:
+    type: boolean
+    description: Enable Host-Mode Port Power Control (bit-3 of capability param HCCPARAMS)

Why wouldn't this be enavled always? Why is this a board-level property?

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+  st,ovrcur-active-low:

Don't re-invent stuff:
st,over-current-active-low

Quoted 9 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +9 -0
+    type: boolean
+    description: Over-Current signal polarity is active-low
+
+  st,vbusen-active-low:
+    type: boolean
+    description: VBUS-ENABLE signal polarity is active-low
+
+required:
+  - compatible

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml line 88

Quoted 10 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +10 -0
+  - reg
+  - clocks
+  - clock-names
+  - interrupts
+  - phys
+  - phy-names
+  - resets
+  - st,syscfg
+
+unevaluatedProperties: false

So where did you reference any other schema - for properties here and for this unevaluatedProps?

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml line 96

Quoted 8 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +8 -0
+
+examples:
+  - |
+    #include <dt-bindings/clock/st,stm32mp25-rcc.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/st,stm32mp25-rcc.h>
+
+    usb3dr: usb@48300000 {

Drop unused label

Quoted 15 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +12 -0
+        compatible = "st,stm32mp25-dwc3";
+        reg = <0x48300000 0x100000>;
+        clocks = <&rcc CK_KER_USB2PHY2>, <&rcc CK_BUS_USB3DR>, <&rcc CK_KER_USB2PHY2>;
+        clock-names = "ref", "bus_early", "suspend";
+        interrupts = <GIC_SPI 228 IRQ_TYPE_LEVEL_HIGH>;
+        phys = <&usb2_phy>, <&usb3_phy>;
+        phy-names = "usb2-phy", "usb3-phy";
+        resets = <&rcc USB3DR_R>;
+        st,ovrcur-active-low;
+        st,syscfg = <&syscfg 0x4800>;
+        st,vbusen-active-low;
+    };
Signature · 1 line
2.53.0
#16 lore raw

Re: [PATCH v2 5/9] dt-bindings: usb: dwc3: Document ST STM32MP2 DWC3 xHCI USB controller

Quoted 36 lines · Krzysztof Kozlowski
Quoted 35 lines · Marek Vasut
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +35 -0
+properties:
+  compatible:
+    const: st,stm32mp25-dwc3
+
+  reg:
+    maxItems: 1
+
+  access-controllers:
+    maxItems: 1
+
+  clocks:
+    minItems: 3
+    maxItems: 3
+
+  clock-names:
+    items:
+      - const: ref
+      - const: bus_early
+      - const: suspend
+
+  dr_mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    enum: [host, peripheral, otg]
+
+  interrupts:
+    maxItems: 1
+
+  phys:
+    minItems: 1
+    maxItems: 2
+
+  phy-names:
+    minItems: 1
+    items:
+      - const: usb2-phy
Quoted 8 lines

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml line 55

Quoted 4 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +4 -0
+      - const: usb3-phy
+
+  resets:
+    minItems: 1

Hm? You keep coming with some odd style, not present in any other files. Where do you see such code - property followed by minItems alone? This applies to other places as well.

This should clearly be maxItems: 1, fixed, thanks .

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +6 -0
+
+  st,syscfg:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    description: Phandle to system configuration controller.
+    items:
+      - items:
Quoted 8 lines

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml line 67

Quoted 6 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +6 -0
+          - description: phandle to syscfg
+          - description: USB3DR control offset within syscfg
+
+  st,enable-port-power-control:
+    type: boolean
+    description: Enable Host-Mode Port Power Control (bit-3 of capability param HCCPARAMS)

Why wouldn't this be enavled always? Why is this a board-level property?

A board can have external USB power controller chip like TCPP02/TCPP03 and the DWC3 IP does not control the port power directly. This seems to be common on the STM32MP2 . Hence this property, which disables the port power control functionality in DWC3 IP and lets the chip do it instead.

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+  st,ovrcur-active-low:

Don't re-invent stuff:
st,over-current-active-low

It seems I can even use generic "over-current-active-low" .

Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +14 -0
+    type: boolean
+    description: Over-Current signal polarity is active-low
+
+  st,vbusen-active-low:
+    type: boolean
+    description: VBUS-ENABLE signal polarity is active-low
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupts
+  - phys
Quoted 8 lines

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml line 88

Quoted 5 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +5 -0
+  - phy-names
+  - resets
+  - st,syscfg
+
+unevaluatedProperties: false

So where did you reference any other schema - for properties here and for this unevaluatedProps?

I seem to be getting this one wrong all the time, so let me ask -- when do I use unevaluatedProperties:false and when additionalProperties:false , what is the rule of thumb here ?

Quoted 10 lines

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml line 96

Quoted 8 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +8 -0
+
+examples:
+  - |
+    #include <dt-bindings/clock/st,stm32mp25-rcc.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/st,stm32mp25-rcc.h>
+
+    usb3dr: usb@48300000 {

Drop unused label

Done, thanks.

#17 lore raw

PATCH v2 6/9 usb: dwc3: dwc3-generic-plat: Add ST STM32MP2 DWC3 xHCI USB controller glue

In reply to Marek Vasut

The ST STM32MP2 SoC contains one instance of DWC3 USB controller with glue logic wrapper around it controlled by syscon. Extend the generic DWC3 platform driver with ST STM32MP2 glue logic specifics.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: No change

---
 drivers/usb/dwc3/dwc3-generic-plat.c | 44 ++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/usb/dwc3/dwc3-generic-plat.c +44 -0
index ca69ac0eb07ce..0946ed61647b6 100644
@@ -22,6 +22,12 @@
 #define EIC7700_HSP_AXI_LP_XM_CSYSREQ	BIT(0)
 #define EIC7700_HSP_AXI_LP_XS_CSYSREQ	BIT(16)
 
+#define STM32MP2_USB3DRCR_HOST_PORT_POWER_CONTROL_PRESENT	BIT(0)
+#define STM32MP2_USB3DRCR_OVRCUR_POLARITY			BIT(1)
+#define STM32MP2_USB3DRCR_VBUSEN_POLARITY			BIT(2)
+#define STM32MP2_USB3DRCR_USB2ONLYH				BIT(3)
+#define STM32MP2_USB3DRCR_USB2ONLYD				BIT(4)
+
 struct dwc3_generic {
 	struct device		*dev;
 	struct dwc3		dwc;
@@ -85,6 +91,38 @@ static int dwc3_spacemit_k1_init(struct dwc3_generic *dwc3g)
 	return 0;
 }
 
+static int dwc3_stm32mp25_init(struct dwc3_generic *dwc3g)
+{
+	struct device *dev = dwc3g->dev;
+	bool ovrcur_polarity_low = device_property_read_bool(dev, "st,ovrcur-active-low");
+	bool prt_pwr_ctrl = device_property_read_bool(dev, "st,enable-port-power-control");
+	bool usb2only_conf = device_property_match_string(dev, "phy-names", "usb3-phy") < 0;
+	bool vbusen_polarity_low = device_property_read_bool(dev, "st,vbusen-active-low");
+	struct regmap *regmap;
+	u32 drcr;
+
+	regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node, "st,syscfg", 1, &drcr);
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap), "No st,syscfg phandle specified\n");
+
+	return regmap_update_bits(regmap, drcr,
+				  STM32MP2_USB3DRCR_HOST_PORT_POWER_CONTROL_PRESENT |
+				  STM32MP2_USB3DRCR_OVRCUR_POLARITY |
+				  STM32MP2_USB3DRCR_VBUSEN_POLARITY |
+				  STM32MP2_USB3DRCR_USB2ONLYD |
+				  STM32MP2_USB3DRCR_USB2ONLYH,
+				  FIELD_PREP(STM32MP2_USB3DRCR_HOST_PORT_POWER_CONTROL_PRESENT,
+					     prt_pwr_ctrl) |
+				  FIELD_PREP(STM32MP2_USB3DRCR_OVRCUR_POLARITY,
+					     ovrcur_polarity_low) |
+				  FIELD_PREP(STM32MP2_USB3DRCR_VBUSEN_POLARITY,
+					     vbusen_polarity_low) |
+				  FIELD_PREP(STM32MP2_USB3DRCR_USB2ONLYD,
+					     !!usb2only_conf) |
+				  FIELD_PREP(STM32MP2_USB3DRCR_USB2ONLYH,
+					     !!usb2only_conf));
+}
+
 static int dwc3_generic_probe(struct platform_device *pdev)
 {
 	const struct dwc3_generic_config *plat_config;
@@ -231,12 +269,18 @@ static const struct dwc3_generic_config eic7700_dwc3 =  {
 	.properties = DWC3_DEFAULT_PROPERTIES,
 };
 
+static const struct dwc3_generic_config stm32mp25_dwc3 =  {
+	.init = dwc3_stm32mp25_init,
+	.properties = DWC3_DEFAULT_PROPERTIES,
+};
+
 static const struct of_device_id dwc3_generic_of_match[] = {
 	{ .compatible = "spacemit,k1-dwc3", &spacemit_k1_dwc3},
 	{ .compatible = "spacemit,k3-dwc3", },
 	{ .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3},
 	{ .compatible = "eswin,eic7700-dwc3", &eic7700_dwc3},
 	{ .compatible = "starfive,jhb100-dwc3", },
+	{ .compatible = "st,stm32mp25-dwc3", &stm32mp25_dwc3 },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, dwc3_generic_of_match);
Signature · 1 line
2.53.0
#18 lore raw

PATCH v2 7/9 dt-bindings: arm: stm32: Switch st,stm32mp23/25-syscfg into simple-mfd

In reply to Marek Vasut

The st,stm32mp23-syscfg and st,stm32mp25-syscfg can have subnodes, which represent the USB 2.0 FEMTO-PHY. Turn the syscfg into "simple-mfd" so the PHYs would get populated by the OS.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: New patch

---
 .../devicetree/bindings/arm/stm32/st,stm32-syscon.yaml     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +4 -3
index 95d2319afe235..ef640443dd239 100644
@@ -22,11 +22,12 @@ properties:
               - st,stm32mp151-pwr-mcu
               - st,stm32mp157-syscfg
               - st,stm32mp21-syscfg
-              - st,stm32mp23-syscfg
-              - st,stm32mp25-syscfg
           - const: syscon
       - items:
-          - const: st,stm32-tamp
+          - enum:
+              - st,stm32-tamp
+              - st,stm32mp23-syscfg
+              - st,stm32mp25-syscfg
           - const: syscon
           - const: simple-mfd
 
Signature · 1 line
2.53.0
#19 lore raw

Re: [PATCH v2 7/9] dt-bindings: arm: stm32: Switch st,stm32mp23/25-syscfg into simple-mfd

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [High] Moving `st,stm32mp23-syscfg` and `st,stm32mp25-syscfg` exclusively to the 3-item array makes the…

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] Moving st,stm32mp23-syscfg and st,stm32mp25-syscfg exclusively to the 3-item array makes the simple-mfd compatible string mandatory, breaking validation for existing device trees.
- [High] The st,stm32-usb2phy driver expects a 'reg' property and a syscon parent node, but the binding mandates 'st,syscfg' and forbids 'reg'.
- [Medium] The schema uses additionalProperties: false but fails to define the USB PHY subnodes, meaning any added subnodes will be rejected by dtbs_check.
- [Medium] Incomplete single-node DWC3 binding prevents the use of standard USB properties.
- [Medium] Mismatch between '#clock-cells' binding requirement and driver implementation.
--

--- Patch [7]: [PATCH v2 7/9] dt-bindings: arm: stm32: Switch st,stm32mp23/25-syscfg into simple-mfd --- commit 442df2b694ee72167d8a15b0750e1f6687add72a
Author: Marek Vasut <[email protected]>

dt-bindings: arm: stm32: Switch st,stm32mp23/25-syscfg into simple-mfd

The st,stm32mp23-syscfg and st,stm32mp25-syscfg can have subnodes, which represent the USB 2.0 FEMTO-PHY. Turn the syscfg into "simple-mfd" so the PHYs would get populated by the OS.

Quoted 9 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +0 -1
index 95d2319afe235..ef640443dd239 100644
@@ -22,11 +22,12 @@ properties:
               - st,stm32mp151-pwr-mcu
               - st,stm32mp157-syscfg
               - st,stm32mp21-syscfg
-              - st,stm32mp23-syscfg

Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml properties: · line 32

Quoted 10 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +4 -2
-              - st,stm32mp25-syscfg
           - const: syscon
       - items:
-          - const: st,stm32-tamp
+          - enum:
+              - st,stm32-tamp
+              - st,stm32mp23-syscfg
+              - st,stm32mp25-syscfg
           - const: syscon
           - const: simple-mfd

[Severity: High]
Does moving st,stm32mp23-syscfg and st,stm32mp25-syscfg exclusively to the 3-item array make the simple-mfd compatible string mandatory? It looks like this breaks backward compatibility, meaning existing valid device trees that only specify 'syscon' will suddenly fail schema validation.

[Severity: Medium]
Will this schema reject the new USB PHY subnodes mentioned in the commit message?

Looking at Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml, it uses additionalProperties: false without defining patternProperties for child nodes. Any added subnodes will likely be rejected by dtbs_check.

[Severity: High]
Can the USB2 PHY driver probe successfully with a device tree that conforms to the st,stm32-usb2phy binding?

The driver unconditionally requires a 'reg' property to extract the offset:

drivers/phy/st/phy-stm32-usb2phy.c:stm32_usb2phy_probe() {
    ...
    offset = of_get_address(dev->of_node, 0, NULL, NULL);
    if (!offset)
        return dev_err_probe(dev, -EINVAL, "Failed to get regmap offset\n");
    ...
}

However, the binding completely omits and implicitly forbids 'reg', requiring 'st,syscfg' instead:

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml:
st,syscfg:
$ref: /schemas/types.yaml#/definitions/phandle-array
description: Phandle to system configuration controller.

[Severity: Medium]
Is the single-node DWC3 binding complete enough to allow standard USB properties?

The schema is sealed with unevaluatedProperties: false without including a $ref to snps,dwc3.yaml#:

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml:
unevaluatedProperties: false

Would this unconditionally reject standard USB core properties?

[Severity: Medium]
Is there a mismatch between the '#clock-cells' binding requirement and the driver implementation?

The driver registers the clock provider with of_clk_hw_simple_get, which ignores arguments and acts as a 0-cell provider:

drivers/phy/st/phy-stm32-usb2phy.c:stm32_usb2phy_probe() {
    ...
    ret = devm_of_clk_add_hw_provider(phy_dev->dev, of_clk_hw_simple_get,
                                      &phy_dev->clk48_hw);
    ...
}

But the binding mandates #clock-cells = 1:

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml:
"#clock-cells":
const: 1

Does this force a dummy argument in the device tree that the driver ignores?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
#20 lore raw

Re: [PATCH v2 7/9] dt-bindings: arm: stm32: Switch st,stm32mp23/25-syscfg into simple-mfd

In reply to Marek Vasut
Quoted 40 lines · Marek Vasut

The st,stm32mp23-syscfg and st,stm32mp25-syscfg can have subnodes, which represent the USB 2.0 FEMTO-PHY. Turn the syscfg into "simple-mfd" so the PHYs would get populated by the OS.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: New patch

---
 .../devicetree/bindings/arm/stm32/st,stm32-syscon.yaml     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +0 -0
index 95d2319afe235..ef640443dd239 100644
@@ -22,11 +22,12 @@ properties:
               - st,stm32mp151-pwr-mcu
               - st,stm32mp157-syscfg

Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml properties: · line 30

Quoted 10 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +4 -3
               - st,stm32mp21-syscfg
-              - st,stm32mp23-syscfg
-              - st,stm32mp25-syscfg
           - const: syscon
       - items:
-          - const: st,stm32-tamp
+          - enum:
+              - st,stm32-tamp
+              - st,stm32mp23-syscfg
+              - st,stm32mp25-syscfg

You never tested your code - DTS in this case. This clearly generates warnings.

Best regards,
Krzysztof

#21 lore raw

Re: [PATCH v2 7/9] dt-bindings: arm: stm32: Switch st,stm32mp23/25-syscfg into simple-mfd

Quoted 12 lines · Krzysztof Kozlowski
Quoted 12 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +0 -2
index 95d2319afe235..ef640443dd239 100644
@@ -22,11 +22,12 @@ properties:
                - st,stm32mp151-pwr-mcu
                - st,stm32mp157-syscfg
                - st,stm32mp21-syscfg
-              - st,stm32mp23-syscfg
-              - st,stm32mp25-syscfg
            - const: syscon
        - items:
Quoted 8 lines

Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml properties: · line 30

Quoted 5 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +4 -1
-          - const: st,stm32-tamp
+          - enum:
+              - st,stm32-tamp
+              - st,stm32mp23-syscfg
+              - st,stm32mp25-syscfg

You never tested your code - DTS in this case. This clearly generates warnings.

I reran the checker and fixed them all now I hope, sorry.

#22 lore raw

PATCH v2 8/9 arm64: dts: st: Add USB nodes on stm32mp231

In reply to Marek Vasut

Add USB controller and PHY nodes to stm32mp231 DT. This includes two USB 2.0 FEMTO PHYs, USB 2.0 host controller and DWC3 DRD controller nodes. Include missing COMBOPHY for the USB 3.0 controller.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: - Fix up Sob/Cdb lines
- Move PHY into syscfg subnode
- Turn st,stm32mp23-syscfg into simple-mfd
- Use clock-cells = <1> to discern OSC and future PLL clock from the PHY

---
 arch/arm64/boot/dts/st/stm32mp231.dtsi | 81 +++++++++++++++++++++++++-
 1 file changed, 80 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/st/stm32mp231.dtsi +80 -1
index 4505fc0e3b537..fd232b4241125 100644
@@ -7,6 +7,7 @@
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/regulator/st,stm32mp25-regulator.h>
 #include <dt-bindings/reset/st,stm32mp25-rcc.h>
+#include <dt-bindings/phy/phy.h>
 
 / {
 	#address-cells = <2>;
@@ -769,6 +770,21 @@ dcmipp: dcmipp@48030000 {
 				status = "disabled";
 			};
 
+			combophy: phy@480c0000 {
+				compatible = "st,stm32mp25-combophy";
+				reg = <0x480c0000 0x1000>;
+				#phy-cells = <1>;
+				clocks = <&rcc CK_BUS_USB3PCIEPHY>, <&rcc CK_KER_USB3PCIEPHY>;
+				clock-names = "apb", "ker";
+				resets = <&rcc USB3PCIEPHY_R>;
+				reset-names = "phy";
+				access-controllers = <&rifsc 67>;
+				power-domains = <&cluster_pd>;
+				wakeup-source;
+				interrupts-extended = <&exti1 45 IRQ_TYPE_EDGE_FALLING>;
+				status = "disabled";
+			};
+
 			sdmmc1: mmc@48220000 {
 				compatible = "st,stm32mp25-sdmmc2", "arm,pl18x", "arm,primecell";
 				reg = <0x48220000 0x400>, <0x44230400 0x8>;
@@ -862,6 +878,47 @@ stmmac_axi_config_1: stmmac-axi-config {
 					snps,wr_osr_lmt = <0x7>;
 				};
 			};
+
+			usbh_ohci: usb@482e0000 {
+				compatible = "generic-ohci";
+				reg = <0x482e0000 0x1000>;
+				access-controllers = <&rifsc 63>;
+				clocks = <&usb2_phy1 0>, <&rcc CK_BUS_USB2OHCI>;
+				interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
+				phys = <&usb2_phy1>;
+				phy-names = "usb";
+				resets = <&rcc USBH_R>;
+				status = "disabled";
+			};
+
+			usbh_ehci: usb@482f0000 {
+				compatible = "generic-ehci";
+				reg = <0x482f0000 0x1000>;
+				access-controllers = <&rifsc 63>;
+				clocks = <&usb2_phy1 0>, <&rcc CK_BUS_USB2EHCI>;
+				companion = <&usbh_ohci>;
+				interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>;
+				phys = <&usb2_phy1>;
+				phy-names = "usb";
+				resets = <&rcc USBH_R>;
+				status = "disabled";
+			};
+
+			usb3dr: usb@48300000 {
+				compatible = "st,stm32mp25-dwc3";
+				reg = <0x48300000 0x100000>;
+				access-controllers = <&rifsc 66>;
+				clocks = <&rcc CK_KER_USB2PHY2>,
+					 <&rcc CK_BUS_USB3DR>,
+					 <&rcc CK_KER_USB2PHY2>;
+				clock-names = "ref", "bus_early", "suspend";
+				interrupts = <GIC_SPI 228 IRQ_TYPE_LEVEL_HIGH>;
+				phys = <&usb2_phy2>, <&combophy PHY_TYPE_USB3>;
+				phy-names = "usb2-phy", "usb3-phy";
+				resets = <&rcc USB3DR_R>;
+				st,syscfg = <&syscfg 0x4800>;
+				status = "disabled";
+			};
 		};
 
 		bsec: efuse@44000000 {
@@ -1062,9 +1119,31 @@ exti1: interrupt-controller@44220000 {
 		};
 
 		syscfg: syscon@44230000 {
-			compatible = "st,stm32mp23-syscfg", "syscon";
+			compatible = "st,stm32mp23-syscfg", "syscon", "simple-mfd";
 			reg = <0x44230000 0x10000>;
 			#clock-cells = <0>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			usb2_phy1: phy@2400 {
+				compatible = "st,stm32mp25-usb2phy1";
+				reg = <0x2400 0x24>;
+				#phy-cells = <0>;
+				#clock-cells = <1>;
+				clocks = <&rcc CK_KER_USB2PHY1>;
+				resets = <&rcc USB2PHY1_R>;
+				status = "disabled";
+			};
+
+			usb2_phy2: phy@2800 {
+				compatible = "st,stm32mp25-usb2phy2";
+				reg = <0x2800 0xc>;
+				#phy-cells = <0>;
+				#clock-cells = <1>;
+				clocks = <&rcc CK_KER_USB2PHY2EN>;
+				resets = <&rcc USB2PHY2_R>;
+				status = "disabled";
+			};
 		};
 
 		pinctrl: pinctrl@44240000 {
Signature · 1 line
2.53.0
#23 lore raw

Re: [PATCH v2 8/9] arm64: dts: st: Add USB nodes on stm32mp231

arch/arm64/boot/dts/st/stm32mp231.dtsi exti1: interrupt-controller@44220000 { · line 1122

Quoted 8 lines · Marek Vasut
arch/arm64/boot/dts/st/stm32mp231.dtsi +1 -1
 		bsec: efuse@44000000 {
@@ -1062,9 +1119,31 @@ exti1: interrupt-controller@44220000 {
 		};
 
 		syscfg: syscon@44230000 {
-			compatible = "st,stm32mp23-syscfg", "syscon";
+			compatible = "st,stm32mp23-syscfg", "syscon", "simple-mfd";

Obviously fails dtbs_check. Use tools, not humans, for this.

Best regards,
Krzysztof

#24 lore raw

PATCH v2 9/9 arm64: dts: st: Add USB nodes on stm32mp251

In reply to Marek Vasut

From: Pankaj Dev <[email protected]>

Add USB controller and PHY nodes to stm32mp251 DT. This includes two USB 2.0 FEMTO PHYs, USB 2.0 host controller and DWC3 DRD controller nodes.

---
Cc: Alexandre Torgue <[email protected]>
Cc: Christian Bruel <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabrice Gasnier <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pankaj Dev <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rosen Penev <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: - Fix up Sob/Cdb lines
- Move PHY into syscfg subnode
- Turn st,stm32mp25-syscfg into simple-mfd
- Use clock-cells = <1> to discern OSC and future PLL clock from the PHY

---
 arch/arm64/boot/dts/st/stm32mp251.dtsi | 65 +++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/st/stm32mp251.dtsi +64 -1
index 6e985f115b195..6b147ed0fd550 100644
@@ -1746,6 +1746,47 @@ stmmac_axi_config_1: stmmac-axi-config {
 				};
 			};
 
+			usbh_ohci: usb@482e0000 {
+				compatible = "generic-ohci";
+				reg = <0x482e0000 0x1000>;
+				access-controllers = <&rifsc 63>;
+				clocks = <&usb2_phy1 0>, <&rcc CK_BUS_USB2OHCI>;
+				interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
+				phys = <&usb2_phy1>;
+				phy-names = "usb";
+				resets = <&rcc USBH_R>;
+				status = "disabled";
+			};
+
+			usbh_ehci: usb@482f0000 {
+				compatible = "generic-ehci";
+				reg = <0x482f0000 0x1000>;
+				access-controllers = <&rifsc 63>;
+				clocks = <&usb2_phy1 0>, <&rcc CK_BUS_USB2EHCI>;
+				companion = <&usbh_ohci>;
+				interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>;
+				phys = <&usb2_phy1>;
+				phy-names = "usb";
+				resets = <&rcc USBH_R>;
+				status = "disabled";
+			};
+
+			usb3dr: usb@48300000 {
+				compatible = "st,stm32mp25-dwc3";
+				reg = <0x48300000 0x100000>;
+				access-controllers = <&rifsc 66>;
+				clocks = <&rcc CK_KER_USB2PHY2>,
+					 <&rcc CK_BUS_USB3DR>,
+					 <&rcc CK_KER_USB2PHY2>;
+				clock-names = "ref", "bus_early", "suspend";
+				interrupts = <GIC_SPI 228 IRQ_TYPE_LEVEL_HIGH>;
+				phys = <&usb2_phy2>, <&combophy PHY_TYPE_USB3>;
+				phy-names = "usb2-phy", "usb3-phy";
+				resets = <&rcc USB3DR_R>;
+				st,syscfg = <&syscfg 0x4800>;
+				status = "disabled";
+			};
+
 			pcie_ep: pcie-ep@48400000 {
 				compatible = "st,stm32mp25-pcie-ep";
 				reg = <0x48400000 0x100000>,
@@ -2002,9 +2043,31 @@ exti1: interrupt-controller@44220000 {
 		};
 
 		syscfg: syscon@44230000 {
-			compatible = "st,stm32mp25-syscfg", "syscon";
+			compatible = "st,stm32mp25-syscfg", "syscon", "simple-mfd";
 			reg = <0x44230000 0x10000>;
 			#clock-cells = <0>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			usb2_phy1: phy@2400 {
+				compatible = "st,stm32mp25-usb2phy1";
+				reg = <0x2400 0x24>;
+				#phy-cells = <0>;
+				#clock-cells = <1>;
+				clocks = <&rcc CK_KER_USB2PHY1>;
+				resets = <&rcc USB2PHY1_R>;
+				status = "disabled";
+			};
+
+			usb2_phy2: phy@2800 {
+				compatible = "st,stm32mp25-usb2phy2";
+				reg = <0x2800 0xc>;
+				#phy-cells = <0>;
+				#clock-cells = <1>;
+				clocks = <&rcc CK_KER_USB2PHY2EN>;
+				resets = <&rcc USB2PHY2_R>;
+				status = "disabled";
+			};
 		};
 
 		pinctrl: pinctrl@44240000 {
Signature · 1 line
2.53.0
#25 lore raw
In reply to Marek Vasut
Quoted 6 lines · Marek Vasut

Add USB support for STM32MP23xx/STM32MP25xx SoCs. This includes USB 2.0 FEMTO-PHY driver, DWC3 glue code and DT adjustments. Parts of this are taken from ST downstream kernel fork, reduced, or rewritten, since not all of the content there was useful and bits which might be missing and are useful can be added later.

Quoted 6 lines

Unlike the downstream implementation, the DWC3 glue code is using plain dwc3-generic-plat, the EHCI and OHCI controllers are instantiated as plain generic controllers without any wrapper glue driver, and the USB2 PHY driver is simplified.

Both USB 2.0 Host controller and DWC3 super-speed controller are tested.

Hi Marek,

Regarding dwc3, I've started to test and needed another patch from our downstream. I've posted it here:
https://lore.kernel.org/linux-usb/[email protected]/

Regarding USBH, there's a dedicated glue on STM32MP2x SoCs for the EHCI/OHCI controllers, similar to the dwc3. On dwc3, I see it can be managed.

There are:
- AFMUX signals out of EHCI/OHCI controllers, to manage a Vbus power switch (with polarity) control.
- AFMUX need pinctrl to be added, and managed during system PM
- On coming MP21 (not supported here), there's address translation control
- Common dedicated interrupt to manage wakeup

Using generic controller drivers, I don't see how to manage it, without describing it in the DT.

For sure, generic ehci/ochi drivers and bindings can/must be used. What would be the proper place for this glue to leave ? Why not adding the glue driver from the downstream ? That's supposed to address this.

Do you wish I send it upstream, so it can be properly reviewed, amended ?

I'd like to sort this glue management out before the DT for the USBH can land.

Best Regards,
Thanks,
Fabrice

Quoted 53 lines

Marek Vasut (6):
dt-bindings: usb: generic-ehci: Document access-controllers property
dt-bindings: usb: generic-ohci: Document access-controllers property
dt-bindings: usb: dwc3: Document ST STM32MP2 DWC3 xHCI USB controller
usb: dwc3: dwc3-generic-plat: Add ST STM32MP2 DWC3 xHCI USB controller
glue
dt-bindings: arm: stm32: Switch st,stm32mp23/25-syscfg into simple-mfd
arm64: dts: st: Add USB nodes on stm32mp231

Pankaj Dev (3):
dt-bindings: phy: Document ST STM32MP25 USB2-FEMTO PHY
phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY
arm64: dts: st: Add USB nodes on stm32mp251

 .../bindings/arm/stm32/st,stm32-syscon.yaml   |   7 +-
 .../bindings/phy/st,stm32-usb2phy.yaml        |  73 ++++
 .../devicetree/bindings/usb/generic-ehci.yaml |   3 +
 .../devicetree/bindings/usb/generic-ohci.yaml |   3 +
 .../bindings/usb/st,stm32mp25-dwc3.yaml       | 108 ++++++
 arch/arm64/boot/dts/st/stm32mp231.dtsi        |  81 +++-
 arch/arm64/boot/dts/st/stm32mp251.dtsi        |  65 +++-
 drivers/phy/st/Kconfig                        |  10 +
 drivers/phy/st/Makefile                       |   1 +
 drivers/phy/st/phy-stm32-usb2phy.c            | 361 ++++++++++++++++++
 drivers/usb/dwc3/dwc3-generic-plat.c          |  44 +++
 11 files changed, 751 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml
 create mode 100644 Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml
 create mode 100644 drivers/phy/st/phy-stm32-usb2phy.c
Cc Alexandre Torgue <[email protected]>
Cc Christian Bruel <[email protected]>
Cc Conor Dooley <[email protected]>
Cc Fabrice Gasnier <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Coquelin <[email protected]>
Cc Neil Armstrong <[email protected]>
Cc Pankaj Dev <[email protected]>
Cc Rahul Kumar <[email protected]>
Cc Rob Herring <[email protected]>
Cc Rosen Penev <[email protected]>
Cc Thinh Nguyen <[email protected]>
Cc Vinod Koul <[email protected]>
#26 lore raw
Quoted 8 lines · Fabrice Gasnier
Quoted 6 lines · Marek Vasut

Add USB support for STM32MP23xx/STM32MP25xx SoCs. This includes USB 2.0 FEMTO-PHY driver, DWC3 glue code and DT adjustments. Parts of this are taken from ST downstream kernel fork, reduced, or rewritten, since not all of the content there was useful and bits which might be missing and are useful can be added later.

Quoted 8 lines
Quoted 6 lines

Unlike the downstream implementation, the DWC3 glue code is using plain dwc3-generic-plat, the EHCI and OHCI controllers are instantiated as plain generic controllers without any wrapper glue driver, and the USB2 PHY driver is simplified.

Both USB 2.0 Host controller and DWC3 super-speed controller are tested.

Hi Marek,

Hello Fabrice,

Quoted 3 lines

Regarding dwc3, I've started to test and needed another patch from our downstream. I've posted it here:
https://lore.kernel.org/linux-usb/[email protected]/

Understood.

Quoted 8 lines

Regarding USBH, there's a dedicated glue on STM32MP2x SoCs for the EHCI/OHCI controllers, similar to the dwc3. On dwc3, I see it can be managed.

There are:
- AFMUX signals out of EHCI/OHCI controllers, to manage a Vbus power switch (with polarity) control.
- AFMUX need pinctrl to be added, and managed during system PM

This can be managed by the PHY instead, can it not ?

Quoted 1 line

- On coming MP21 (not supported here), there's address translation control

What kind of address translation ? IOMMU ?

Quoted 1 line

- Common dedicated interrupt to manage wakeup

This is EXTI configuration, is it not ?

Quoted 8 lines

Using generic controller drivers, I don't see how to manage it, without describing it in the DT.

For sure, generic ehci/ochi drivers and bindings can/must be used. What would be the proper place for this glue to leave ? Why not adding the glue driver from the downstream ? That's supposed to address this.

Do you wish I send it upstream, so it can be properly reviewed, amended ?

I would very much prefer to avoid the glue if that is at all possible.
Thus far, it seems this could be done (interrupts are generic interrupts managed by EXTI, Vbus detection polarity is likely a PHY thing since this is managed by SYSCFG anyway) ?

Quoted 2 lines

I'd like to sort this glue management out before the DT for the USBH can land.

ACK

[...]

#27 lore raw
Quoted 31 lines · Marek Vasut
Quoted 8 lines · Fabrice Gasnier
Quoted 6 lines · Marek Vasut

Add USB support for STM32MP23xx/STM32MP25xx SoCs. This includes USB 2.0 FEMTO-PHY driver, DWC3 glue code and DT adjustments. Parts of this are taken from ST downstream kernel fork, reduced, or rewritten, since not all of the content there was useful and bits which might be missing and are useful can be added later.

Quoted 8 lines
Quoted 6 lines

Unlike the downstream implementation, the DWC3 glue code is using plain dwc3-generic-plat, the EHCI and OHCI controllers are instantiated as plain generic controllers without any wrapper glue driver, and the USB2 PHY driver is simplified.

Both USB 2.0 Host controller and DWC3 super-speed controller are tested.

Hi Marek,

Hello Fabrice,

Quoted 4 lines

Regarding dwc3, I've started to test and needed another patch from our downstream. I've posted it here:
https://lore.kernel.org/linux-usb/20260817163101.6203-1-
[email protected]/

Understood.

Quoted 4 lines

Regarding USBH, there's a dedicated glue on STM32MP2x SoCs for the EHCI/OHCI controllers, similar to the dwc3. On dwc3, I see it can be managed.

Quoted 6 lines
Quoted 4 lines

There are:
- AFMUX signals out of EHCI/OHCI controllers, to manage a Vbus power switch (with polarity) control.
- AFMUX need pinctrl to be added, and managed during system PM

This can be managed by the PHY instead, can it not ?

Hello Marek,

Please see later comment.

Quoted 5 lines
Quoted 3 lines

- On coming MP21 (not supported here), there's address translation control

What kind of address translation ? IOMMU ?

This is much more "basic". The controller can address 4G of memory, e.g. it's 32bits. That feature is only for STM32MP21 that can address 4G of DDR which starts at 2G offset. So basically there's a SYSCFG bit (SYSCFG_USBHARCR AREN), that adds a 2G offset so the controller 'DMA' addresses directly the 4G of the DDR (instead of 2G lower memory map, that's not necessarily useful, and 2G of the 4G DDR, requiring swiotlb with perf penalty).

Current downstream glue driver checks the 'dma_range_map', (e.g. DT prop dma-ranges = <0x0 0x0 0x80000000 0x1 0x0>;) that represent this, to enable the syscon bit that adds offset in hardware (so 4G of DDR can be accessed by the controller, without swiotlb).
For USBH, there's nothing mode: set it at probe time, based on dma_range_map, restore it after resume from low power.

Quoted 12 lines
Quoted 2 lines

- Common dedicated interrupt to manage wakeup

This is EXTI configuration, is it not ?

Quoted 7 lines

Using generic controller drivers, I don't see how to manage it, without describing it in the DT.

For sure, generic ehci/ochi drivers and bindings can/must be used. What would be the proper place for this glue to leave ? Why not adding the glue driver from the downstream ? That's supposed to address this.

Quoted 6 lines
Quoted 1 line

Do you wish I send it upstream, so it can be properly reviewed, amended ?

I would very much prefer to avoid the glue if that is at all possible. Thus far, it seems this could be done (interrupts are generic interrupts managed by EXTI, Vbus detection polarity is likely a PHY thing since this is managed by SYSCFG anyway) ?

I better see your point, thanks for your explanation. This makes sense! For this part, the approach can be the same on all STM32MP2 SoCs (21/23/25).

Still for STM32MP21 address remapping feature (out of scope here) I think there will be not much choice to keep a minimal glue DT & driver (and parent to generic ehci/ohci). It seems totally out of the PHY driver purpose.
Maybe you have some thoughts about this ?

Please advise,
Best Regards,
Fabrice

Quoted 6 lines
Quoted 3 lines

I'd like to sort this glue management out before the DT for the USBH can land.

ACK

[...]

#28 lore raw

On 8/18/26 6:07 PM, Fabrice Gasnier wrote:

Hello Fabrice,

Quoted 13 lines
Quoted 4 lines
Quoted 2 lines

- On coming MP21 (not supported here), there's address translation control

What kind of address translation ? IOMMU ?

This is much more "basic". The controller can address 4G of memory, e.g. it's 32bits. That feature is only for STM32MP21 that can address 4G of DDR which starts at 2G offset. So basically there's a SYSCFG bit (SYSCFG_USBHARCR AREN), that adds a 2G offset so the controller 'DMA' addresses directly the 4G of the DDR (instead of 2G lower memory map, that's not necessarily useful, and 2G of the 4G DDR, requiring swiotlb with perf penalty).

Quoted 6 lines

Current downstream glue driver checks the 'dma_range_map', (e.g. DT prop dma-ranges = <0x0 0x0 0x80000000 0x1 0x0>;) that represent this, to enable the syscon bit that adds offset in hardware (so 4G of DDR can be accessed by the controller, without swiotlb).
For USBH, there's nothing mode: set it at probe time, based on dma_range_map, restore it after resume from low power.

Maybe the DT syscfg node shouldn't be a plain syscon , but rather there should be an actual driver which binds to the syscfg DT node and configures all these hardware details early on boot ? The USB controller drivers will start only later, when the syscfg configuration is already set in the hardware by this (future) driver, since they depend on the syscfg node and the PHY subnodes. Maybe that is the way to fix the MP21 without having USB controller glue ?

Quoted 22 lines
Quoted 11 lines
Quoted 1 line

- Common dedicated interrupt to manage wakeup

This is EXTI configuration, is it not ?

Quoted 7 lines

Using generic controller drivers, I don't see how to manage it, without describing it in the DT.

For sure, generic ehci/ochi drivers and bindings can/must be used. What would be the proper place for this glue to leave ? Why not adding the glue driver from the downstream ? That's supposed to address this.

Quoted 6 lines
Quoted 1 line

Do you wish I send it upstream, so it can be properly reviewed, amended ?

I would very much prefer to avoid the glue if that is at all possible. Thus far, it seems this could be done (interrupts are generic interrupts managed by EXTI, Vbus detection polarity is likely a PHY thing since this is managed by SYSCFG anyway) ?

I better see your point, thanks for your explanation. This makes sense! For this part, the approach can be the same on all STM32MP2 SoCs (21/23/25).

Quoted 5 lines

Still for STM32MP21 address remapping feature (out of scope here) I think there will be not much choice to keep a minimal glue DT & driver (and parent to generic ehci/ohci). It seems totally out of the PHY driver purpose.
Maybe you have some thoughts about this ?

Please see above.

#29 lore raw
Quoted 24 lines · Marek Vasut

On 8/18/26 6:07 PM, Fabrice Gasnier wrote:

Hello Fabrice,

Quoted 13 lines
Quoted 4 lines
Quoted 2 lines

- On coming MP21 (not supported here), there's address translation control

What kind of address translation ? IOMMU ?

This is much more "basic". The controller can address 4G of memory, e.g. it's 32bits. That feature is only for STM32MP21 that can address 4G of DDR which starts at 2G offset. So basically there's a SYSCFG bit (SYSCFG_USBHARCR AREN), that adds a 2G offset so the controller 'DMA' addresses directly the 4G of the DDR (instead of 2G lower memory map, that's not necessarily useful, and 2G of the 4G DDR, requiring swiotlb with perf penalty).

Quoted 6 lines

Current downstream glue driver checks the 'dma_range_map', (e.g. DT prop dma-ranges = <0x0 0x0 0x80000000 0x1 0x0>;) that represent this, to enable the syscon bit that adds offset in hardware (so 4G of DDR can be accessed by the controller, without swiotlb).
For USBH, there's nothing mode: set it at probe time, based on dma_range_map, restore it after resume from low power.

Quoted 7 lines

Maybe the DT syscfg node shouldn't be a plain syscon , but rather there should be an actual driver which binds to the syscfg DT node and configures all these hardware details early on boot ? The USB controller drivers will start only later, when the syscfg configuration is already set in the hardware by this (future) driver, since they depend on the syscfg node and the PHY subnodes. Maybe that is the way to fix the MP21 without having USB controller glue ?

Hello Marek,

Ok, I'll think more about it regarding MP21. Let's continue on current series without any additional glue driver for MP23/25.

Thanks,
Best Regards,
Fabrice

Quoted 30 lines
Quoted 24 lines
Quoted 12 lines
Quoted 2 lines

- Common dedicated interrupt to manage wakeup

This is EXTI configuration, is it not ?

Quoted 7 lines

Using generic controller drivers, I don't see how to manage it, without describing it in the DT.

For sure, generic ehci/ochi drivers and bindings can/must be used. What would be the proper place for this glue to leave ? Why not adding the glue driver from the downstream ? That's supposed to address this.

Quoted 7 lines
Quoted 2 lines

Do you wish I send it upstream, so it can be properly reviewed, amended ?

I would very much prefer to avoid the glue if that is at all possible. Thus far, it seems this could be done (interrupts are generic interrupts managed by EXTI, Vbus detection polarity is likely a PHY thing since this is managed by SYSCFG anyway) ?

I better see your point, thanks for your explanation. This makes sense! For this part, the approach can be the same on all STM32MP2 SoCs (21/23/25).

Quoted 5 lines

Still for STM32MP21 address remapping feature (out of scope here) I think there will be not much choice to keep a minimal glue DT & driver (and parent to generic ehci/ohci). It seems totally out of the PHY driver purpose.
Maybe you have some thoughts about this ?

Please see above.

#30 lore raw

On 8/19/26 5:19 PM, Fabrice Gasnier wrote:

Hello Fabrice,

Quoted 8 lines
Quoted 7 lines

Maybe the DT syscfg node shouldn't be a plain syscon , but rather there should be an actual driver which binds to the syscfg DT node and configures all these hardware details early on boot ? The USB controller drivers will start only later, when the syscfg configuration is already set in the hardware by this (future) driver, since they depend on the syscfg node and the PHY subnodes. Maybe that is the way to fix the MP21 without having USB controller glue ?

Quoted 4 lines

Hello Marek,

Ok, I'll think more about it regarding MP21. Let's continue on current series without any additional glue driver for MP23/25.

There is really no rush, if you can come up with something for MP21 that does not require the controller glue, that would be real nice.

Thank you for your help !