Skip to contentSkip to conversation

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

PATCH Superseded Marek Vasut 5 participants 39 messages Aug 22 – Aug 28

Subsystems (5)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 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   |  24 +-
 .../bindings/phy/st,stm32-usb2phy.yaml        |  67 +++
 .../devicetree/bindings/usb/generic-ehci.yaml |   3 +
 .../devicetree/bindings/usb/generic-ohci.yaml |   3 +
 .../bindings/usb/st,stm32mp25-dwc3.yaml       |  97 +++++
 arch/arm64/boot/dts/st/stm32mp231.dtsi        |  67 ++-
 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            | 406 ++++++++++++++++++
 drivers/usb/dwc3/dwc3-generic-plat.c          |  44 ++
 11 files changed, 781 insertions(+), 6 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 v3 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
V3: - Move clock-cells next to PHY cells
- Fix the bindings
- Fix up Sob/Cdb lines further

---
 .../bindings/phy/st,stm32-usb2phy.yaml        | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +67 -0
new file mode 100644
index 0000000000000..cc5044790beea
@@ -0,0 +1,67 @@
+# 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
+
+  "#clock-cells":
+    const: 1
+
+  "#phy-cells":
+    const: 0
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  vdd33-supply:
+    description: Phandle to regulator providing 3V3 power supply to the USB2 HS PHY
+
+required:
+  - compatible
+  - "#clock-cells"
+  - "#phy-cells"
+  - clocks
+  - resets
+  - vdd33-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/st,stm32mp25-rcc.h>
+    #include <dt-bindings/reset/st,stm32mp25-rcc.h>
+
+    usb-phy@2400 {
+        compatible = "st,stm32mp25-usb2phy1";
+        reg = <0x2400 0x24>;
+        #phy-cells = <0>;
+        #clock-cells = <1>;
+        clocks = <&rcc CK_KER_USB2PHY1>;
+        resets = <&rcc USB2PHY1_R>;
+        vdd33-supply = <&vdd33usb>;
+    };
Signature · 1 line
2.53.0
#2 lore raw

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

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Low] The `reg` property is defined in the schema and used in the example but is missing from the…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Low] The reg property is defined in the schema and used in the example but is missing from the required list.
- [Low] The example node name 'usb-phy@2400' violates the generic PHY schema pattern.
- [Low] The '#clock-cells' property lacks documentation for the clock indices.
--

--- Patch [1]: [PATCH v3 1/9] dt-bindings: phy: Document ST STM32MP25 USB2-FEMTO PHY --- commit fee849432713aad415e73ed872e6de622206bee8
Author: Pankaj Dev <[email protected]>

dt-bindings: phy: Document ST STM32MP25 USB2-FEMTO PHY

This commit documents the USB2 phy for STM32MP25 USB2 controllers. It introduces bindings for two slightly different phys present in the STM32MP25 SoC using separate compatible strings.

Quoted 9 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +3 -0
new file mode 100644
index 0000000000000..cc5044790beea
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---

[ ... ]

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 28

Quoted 9 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +9 -0
+properties:
+  compatible:
+    enum:
+      - st,stm32mp25-usb2phy1
+      - st,stm32mp25-usb2phy2
+
+  "#clock-cells":
+    const: 1
+

[Severity: Low]
This sets #clock-cells to 1, meaning consumers will need to pass an index, but there doesn't appear to be any documentation of the valid indices (e.g., 0 for PLL, 1 for CMN) in the binding or a dt-bindings header file.

Could this be updated to document what index corresponds to which clock so device tree authors aren't forced to rely on undocumented magic numbers?

Quoted 5 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +5 -0
+  "#phy-cells":
+    const: 0
+
+  reg:
+    maxItems: 1

[ ... ]

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 50

Quoted 7 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +7 -0
+required:
+  - compatible
+  - "#clock-cells"
+  - "#phy-cells"
+  - clocks
+  - resets
+  - vdd33-supply

[Severity: Low]
The reg property is defined in the schema and used in the example below, but it is missing from this list.

If it is omitted here, device tree nodes without a register offset can silently pass schema validation, even though the driver will fail to probe.

Should the reg property be included in this required list?

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 59

Quoted 9 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +9 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/st,stm32mp25-rcc.h>
+    #include <dt-bindings/reset/st,stm32mp25-rcc.h>
+
+    usb-phy@2400 {

[Severity: Low]
Generic phy schema patterns in dtschema restrict node names for phy providers to match the regular expression ^phy(@.*)?$.

Will this node name trigger warnings when validating the example during a dt_binding_check?

Quoted 8 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +8 -0
+        compatible = "st,stm32mp25-usb2phy1";
+        reg = <0x2400 0x24>;
+        #phy-cells = <0>;
+        #clock-cells = <1>;
+        clocks = <&rcc CK_KER_USB2PHY1>;
+        resets = <&rcc USB2PHY1_R>;
+        vdd33-supply = <&vdd33usb>;
+    };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

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

In reply to Marek Vasut
Quoted 10 lines · Marek Vasut
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +10 -0
+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]>

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 28

Quoted 10 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +10 -0
+
+properties:
+  compatible:
+    enum:
+      - st,stm32mp25-usb2phy1
+      - st,stm32mp25-usb2phy2
+
+  "#clock-cells":
+    const: 1
+

As pointed out by different patchset built on top of it, this is wrong.

I do not understand why Fabrice Gasnier cannot reply HERE that this is wrong and instead another patch is sent for in-flight code. That's not your Marek problem, but lack of responsible review from ST...

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#4 lore raw

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

Quoted 15 lines · Krzysztof Kozlowski
Quoted 14 lines · Marek Vasut
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +14 -0
+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:
Quoted 8 lines

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 28

Quoted 6 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +6 -0
+      - st,stm32mp25-usb2phy1
+      - st,stm32mp25-usb2phy2
+
+  "#clock-cells":
+    const: 1
+

As pointed out by different patchset built on top of it, this is wrong.

What is wrong in this (V3) of the patchset ? I think the ST patches were fixing up V2 and what they were fixing up is already fixed here in V3.

Quoted 3 lines

I do not understand why Fabrice Gasnier cannot reply HERE that this is wrong and instead another patch is sent for in-flight code. That's not your Marek problem, but lack of responsible review from ST...

ACK

#5 lore raw

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

Quoted 25 lines · Marek Vasut
Quoted 15 lines · Krzysztof Kozlowski
Quoted 14 lines · Marek Vasut
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +14 -0
+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:
Quoted 8 lines

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 28

Quoted 6 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +6 -0
+      - st,stm32mp25-usb2phy1
+      - st,stm32mp25-usb2phy2
+
+  "#clock-cells":
+    const: 1
+

As pointed out by different patchset built on top of it, this is wrong.

Quoted 2 lines

What is wrong in this (V3) of the patchset ? I think the ST patches were fixing up V2 and what they were fixing up is already fixed here in V3.

Probably I got confused... but I had impression the ST patches were adding here "reg" property, no?

Best regards,
Krzysztof

#6 lore raw

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

Quoted 26 lines · Krzysztof Kozlowski
Quoted 25 lines · Marek Vasut
Quoted 23 lines · Krzysztof Kozlowski
Quoted 10 lines · Marek Vasut
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +10 -0
+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]>

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 28

Quoted 10 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +10 -0
+
+properties:
+  compatible:
+    enum:
+      - st,stm32mp25-usb2phy1
+      - st,stm32mp25-usb2phy2
+
+  "#clock-cells":
+    const: 1
+

As pointed out by different patchset built on top of it, this is wrong.

Quoted 5 lines
Quoted 2 lines

What is wrong in this (V3) of the patchset ? I think the ST patches were fixing up V2 and what they were fixing up is already fixed here in V3.

Probably I got confused... but I had impression the ST patches were adding here "reg" property, no?

It is there in V3:

"
+ "#clock-cells":
+ const: 1
+
+ "#phy-cells":
+ const: 0
+
+ reg: <------------------ HERE
+ maxItems: 1
+
+ clocks:
+ maxItems: 1
+
+ resets:
+ maxItems: 1
"

#7 lore raw

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

Quoted 35 lines · Marek Vasut
Quoted 26 lines · Krzysztof Kozlowski
Quoted 25 lines · Marek Vasut
Quoted 23 lines · Krzysztof Kozlowski
Quoted 10 lines · Marek Vasut
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +10 -0
+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]>

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 28

Quoted 10 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +10 -0
+
+properties:
+  compatible:
+    enum:
+      - st,stm32mp25-usb2phy1
+      - st,stm32mp25-usb2phy2
+
+  "#clock-cells":
+    const: 1
+

As pointed out by different patchset built on top of it, this is wrong.

Quoted 5 lines
Quoted 2 lines

What is wrong in this (V3) of the patchset ? I think the ST patches were fixing up V2 and what they were fixing up is already fixed here in V3.

Probably I got confused... but I had impression the ST patches were adding here "reg" property, no?

It is there in V3:

"

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 34

Quoted 9 lines
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +9 -0
+  "#clock-cells":
+    const: 1
+
+  "#phy-cells":
+    const: 0
+
+  reg: <------------------ HERE
+    maxItems: 1
+

Ah, indeed. BTW, reg usually follows compatible.

Best regards,
Krzysztof

#8 lore raw

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

In reply to Marek Vasut

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 47

Quoted 10 lines · Marek Vasut
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +10 -0
+  resets:
+    maxItems: 1
+
+  vdd33-supply:
+    description: Phandle to regulator providing 3V3 power supply to the USB2 HS PHY
+
+required:
+  - compatible
+  - "#clock-cells"
+  - "#phy-cells"

reg should be required, usually. If it is not, please explain why in the commit msg.

Best regards,
Krzysztof

#9 lore raw

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

Quoted 14 lines · Krzysztof Kozlowski

Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml line 47

Quoted 10 lines · Marek Vasut
Documentation/devicetree/bindings/phy/st,stm32-usb2phy.yaml new file +10 -0
+  resets:
+    maxItems: 1
+
+  vdd33-supply:
+    description: Phandle to regulator providing 3V3 power supply to the USB2 HS PHY
+
+required:
+  - compatible
+  - "#clock-cells"
+  - "#phy-cells"

reg should be required, usually. If it is not, please explain why in the commit msg.

Fixed in V4, thanks !

#10 lore raw

PATCH v3 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
V3: - Update copyright years
- Register two sets of clock, one 480 MHz PLL and one CMN
- Split PHY ops per PHY, since the PHY2 does not have set mode ops
- Fix up Sob/Cdb lines further

---
 drivers/phy/st/Kconfig             |  10 +
 drivers/phy/st/Makefile            |   1 +
 drivers/phy/st/phy-stm32-usb2phy.c | 406 +++++++++++++++++++++++++++++
 3 files changed, 417 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 +406 -0

406 lines not on this page · raw message

Signature · 1 line
2.53.0
#11 lore raw

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

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

Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] Error paths in stm32_usb2phy_enable and stm32_usb2phy_disable fail to correctly rollback the en_refcnt atomic counter, leading to permanent state lockup or leaked resources.
- [High] Lack of serialization in hardware initialization allows concurrent callers to bypass initialization and access unready hardware.
- [High] stm32_usb2phy_set_mode() fails to clear SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL when switching from device mode to host mode.
- [High] The driver inappropriately treats an optional regulator as mandatory by unconditionally failing probe on -ENODEV.
- [Medium] stm32_usb2phy2_init hardcodes USB_ROLE_NONE, erasing submode state across re-init cycles.
- [Medium] Uncoordinated access to the SYSCFG_USB2PHY2CR_USB2PHY2CMN bit between the PHY mode setting and the Clock prepare/unprepare operations.
--

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

This commit adds the USB2 PHY driver for STM32MP25 USB2 controllers. It supports the USB 2.0 host-only controller and the USB 2.0 part of the DWC3 controller.

Quoted 4 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +0 -0
new file mode 100644

[ ... ]

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

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

[Severity: High]
Can concurrent callers bypass hardware initialization here? If two threads call stm32_usb2phy_enable() at the same time, it seems the second caller will observe the incremented counter and return immediately, while the first thread is still executing the setup sequence. Would it be safer to use a driver-level mutex to serialize initialization instead of an atomic check?

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

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]
If stm32_usb2phy_enable() returns -EINVAL for an unsupported clock rate, does en_refcnt remain incremented? It looks like subsequent calls might see an inflated count and return success without doing any hardware initialization.

Quoted 2 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +2 -0
+
+	ret = regmap_update_bits(phy_dev->regmap,

[ ... ]

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

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 clkpll 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]
If reset_control_assert() fails, does the early return leave en_refcnt decremented while resources are still enabled? This might lead to a state mismatch and resource leaks if the hardware is out of sync with the reference count.

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

Quoted 12 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +12 -0
+
+	clk_disable_unprepare(phy_dev->phyref);
+
+	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);
+	u32 mask = SYSCFG_USB2PHY2CR_USB2PHY2CMN |
+		   SYSCFG_USB2PHY2CR_VBUSVALID |
+		   SYSCFG_USB2PHY2CR_VBUSVLDEXT;

[Severity: High]
When switching back to host mode, is the SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL bit left set? It appears omitted from this default mask.

If it was set during a switch to PHY_MODE_USB_DEVICE, it looks like it won't be cleared when returning to PHY_MODE_USB_HOST, which might leave the hardware multiplexer stuck on external VBUS sensing.

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

Quoted 9 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +9 -0
+	u32 val = 0;
+	int ret;
+
+	if (mode == PHY_MODE_USB_HOST) {
+		if (submode != USB_ROLE_NONE)
+			val = SYSCFG_USB2PHY2CR_VBUSVALID;
+	} else if (mode == PHY_MODE_USB_DEVICE) {
+		val = SYSCFG_USB2PHY2CR_USB2PHY2CMN |
+		      SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL;

[Severity: Medium]
Can toggling the CMN clock corrupt the mode configuration? The PHY framework sets the SYSCFG_USB2PHY2CR_USB2PHY2CMN bit here, but the clock framework clears this exact same bit in stm32_usb2phy_clkcmn_prepare(). This uncoordinated access might step on the PHY's expected state.

Quoted 6 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +6 -0
+		if (submode != USB_ROLE_NONE)
+			val |= SYSCFG_USB2PHY2CR_VBUSVLDEXT;
+		mask |= SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL;
+	} else {
+		return -EINVAL;
+	}

[ ... ]

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

Quoted 11 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +11 -0
+static int stm32_usb2phy2_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);

[Severity: Medium]
Does hardcoding USB_ROLE_NONE erase the previously configured submode state? If the PHY was previously configured with a valid submode, calling phy_init() again might explicitly clear the VBUSVALID and VBUSVLDEXT bits, leading to a silent loss of VBUS detection state.

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +10 -0
+		if (ret) {
+			stm32_usb2phy_disable(phy_dev);
+			return ret;
+		}
+	}
+
+	phy_dev->is_init = true;
+
+	return 0;
+}

[ ... ]

Quoted 9 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +9 -0
+static int stm32_usb2phy_probe(struct platform_device *pdev)
+{
+	struct phy_provider *phy_provider;
+	struct device *dev = &pdev->dev;
+	struct stm32_usb2phy *phy_dev;
+	char *pllname, *cmnname;
+	const __be32 *offset;
+	struct phy *phy;
+	int ret;

[ ... ]

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

Quoted 7 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +7 -0
+	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");

[Severity: High]
Does returning PTR_ERR() unconditionally here defeat the purpose of using an optional regulator? devm_regulator_get_optional() returns -ENODEV if the regulator is absent in the device tree, which would cause the probe to fail unconditionally on platforms without it.

Quoted 4 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +4 -0
+
+	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");

[ ... ]

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

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

In reply to Marek Vasut
Quoted 229 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
V3: - Update copyright years
- Register two sets of clock, one 480 MHz PLL and one CMN
- Split PHY ops per PHY, since the PHY2 does not have set mode ops
- Fix up Sob/Cdb lines further

---
 drivers/phy/st/Kconfig             |  10 +
 drivers/phy/st/Makefile            |   1 +
 drivers/phy/st/phy-stm32-usb2phy.c | 406 +++++++++++++++++++++++++++++
 3 files changed, 417 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 +143 -0
new file mode 100644
index 0000000000000..8c68b2d208d73
@@ -0,0 +1,406 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * STMicroelectronics STM32 USB2 PHY Controller driver
+ * Currently Only supported for STM32MP25
+ *
+ * Copyright (C) 2022-2026 STMicroelectronics
+ * 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)
+
+#define USBH_NUM_CLK				2
+
+struct stm32_usb2phy {
+	struct phy				*phy;
+	struct regmap				*regmap;
+	struct device				*dev;
+	struct reset_control			*rstc;
+	struct clk				*phyref;
+	struct regulator			*vdd33;
+	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				clkpll_hw;
+	struct clk_hw				clkcmn_hw;
+	/* Must be last */
+	struct clk_hw_onecell_data		onecell;
+};
+
+struct stm32mp2_usb2phy_hw_data {
+	u32			phyrefsel_mask;
+	const struct phy_ops	*phy_ops;
+};
+
+static int stm32_usb2phy_enable(struct stm32_usb2phy *phy_dev)
+{
+	const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+	unsigned int refsel;
+	unsigned long rate;
+	int ret;
+
+	/* Check if a phy is already init or clkpll 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;
+
+	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;
+
+	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 clkpll 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);
+
+	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);
+	u32 mask = SYSCFG_USB2PHY2CR_USB2PHY2CMN |
+		   SYSCFG_USB2PHY2CR_VBUSVALID |
+		   SYSCFG_USB2PHY2CR_VBUSVLDEXT;
+	u32 val = 0;
+	int ret;
+
+	if (mode == PHY_MODE_USB_HOST) {
+		if (submode != USB_ROLE_NONE)
+			val = SYSCFG_USB2PHY2CR_VBUSVALID;
+	} else if (mode == PHY_MODE_USB_DEVICE) {
+		val = SYSCFG_USB2PHY2CR_USB2PHY2CMN |
+		      SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL;
+		if (submode != USB_ROLE_NONE)
+			val |= SYSCFG_USB2PHY2CR_VBUSVLDEXT;
+		mask |= SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL;
+	} else {
+		return -EINVAL;
+	}
+

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

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +10 -0
+	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_usb2phy1_init(struct phy *phy)

Hello Marek,

Could same init routine may be used for both PHYs ? See below comment.

Quoted 13 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +13 -0
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	int ret;
+
+	ret = stm32_usb2phy_enable(phy_dev);
+	if (ret)
+		return ret;
+
+	phy_dev->is_init = true;
+
+	return 0;
+}
+

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

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +10 -0
+static int stm32_usb2phy2_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) {

The only difference is here. On the PHY#1 the mode should never change e.g. mode == PHY_MODE_INVALID. So same routine may be used for both PHYs ?

Quoted 230 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +230 -0
+		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_usb2phy1_data = {
+	.init = stm32_usb2phy1_init,
+	.exit = stm32_usb2phy_exit,
+	.owner = THIS_MODULE,
+};
+
+static const struct phy_ops stm32_usb2phy2_data = {
+	.init = stm32_usb2phy2_init,
+	.exit = stm32_usb2phy_exit,
+	.set_mode = stm32_usb2phy_set_mode,
+	.owner = THIS_MODULE,
+};
+
+static int stm32_usb2phy_clkpll_prepare(struct clk_hw *hw)
+{
+	struct stm32_usb2phy *phy_dev = container_of(hw, struct stm32_usb2phy,
+						     clkpll_hw);
+
+	return stm32_usb2phy_enable(phy_dev);
+}
+
+static void stm32_usb2phy_clkpll_unprepare(struct clk_hw *hw)
+{
+	struct stm32_usb2phy *phy_dev = container_of(hw, struct stm32_usb2phy,
+						     clkpll_hw);
+
+	stm32_usb2phy_disable(phy_dev);
+}
+
+static unsigned long stm32_usb2phy_clkpll_recalc_rate(struct clk_hw *hw,
+						      unsigned long parent_rate)
+{
+	return 480000000;
+}
+
+static const struct clk_ops stm32_usb2phy_clkpll_ops = {
+	.prepare = stm32_usb2phy_clkpll_prepare,
+	.unprepare = stm32_usb2phy_clkpll_unprepare,
+	.recalc_rate = stm32_usb2phy_clkpll_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 = {
+	.prepare = stm32_usb2phy_clkcmn_prepare,
+	.unprepare = stm32_usb2phy_clkcmn_unprepare,
+};
+
+static int stm32_usb2phy_probe(struct platform_device *pdev)
+{
+	struct phy_provider *phy_provider;
+	struct device *dev = &pdev->dev;
+	struct stm32_usb2phy *phy_dev;
+	char *pllname, *cmnname;
+	const __be32 *offset;
+	struct phy *phy;
+	int ret;
+
+	phy_dev = devm_kzalloc(dev, struct_size(phy_dev, onecell.hws, USBH_NUM_CLK), 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, phy_dev->hw_data->phy_ops);
+	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);
+
+	pllname = devm_kasprintf(dev, GFP_KERNEL, "clk_%s_48m",
+				 of_node_full_name(dev->of_node));
+	if (!pllname)
+		return -ENOMEM;
+
+	cmnname = devm_kasprintf(dev, GFP_KERNEL, "clk_%s_cmn",
+				 of_node_full_name(dev->of_node));
+	if (!cmnname)
+		return -ENOMEM;
+
+	phy_dev->onecell.num = USBH_NUM_CLK;
+	phy_dev->onecell.hws[0] = &phy_dev->clkpll_hw;
+	phy_dev->onecell.hws[1] = &phy_dev->clkcmn_hw;
+
+	phy_dev->clkpll_hw.init = CLK_HW_INIT_NO_PARENT(pllname, &stm32_usb2phy_clkpll_ops, 0);
+	ret = devm_clk_hw_register(phy_dev->dev, &phy_dev->clkpll_hw);
+	if (ret)
+		return dev_err_probe(phy_dev->dev, ret, "Failed to register PLL clock\n");
+
+	phy_dev->clkcmn_hw.init = CLK_HW_INIT_HW(cmnname, &phy_dev->clkpll_hw,
+						 &stm32_usb2phy_clkcmn_ops, 0);
+	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 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),
+	.phy_ops = &stm32_usb2phy1_data,
+};
+
+/* 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),
+	.phy_ops = &stm32_usb2phy2_data,
+};
+
+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");
#13 lore raw

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

On 8/24/26 3:17 PM, Fabrice Gasnier wrote:

[...]

Hello Fabrice,

Quoted 25 lines
Quoted 1 line

+static int stm32_usb2phy1_init(struct phy *phy)

Hello Marek,

Could same init routine may be used for both PHYs ? See below comment.

Quoted 18 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +18 -0
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	int ret;
+
+	ret = stm32_usb2phy_enable(phy_dev);
+	if (ret)
+		return ret;
+
+	phy_dev->is_init = true;
+
+	return 0;
+}
+
+static int stm32_usb2phy2_init(struct phy *phy)
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	int ret;
+
Quoted 8 lines

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

Quoted 5 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +5 -0
+	ret = stm32_usb2phy_enable(phy_dev);
+	if (ret)
+		return ret;
+
+	if (phy_dev->mode != PHY_MODE_INVALID) {

The only difference is here. On the PHY#1 the mode should never change e.g. mode == PHY_MODE_INVALID. So same routine may be used for both PHYs ?

Since there are separate ops for each PHY, I opted for avoiding this conditional on a PHY where the conditional makes no sense, hence the two separate init functions.

Quoted 11 lines
Quoted 11 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +11 -0
+		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;
+}

[...]

maintainer
#14 lore raw

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

In reply to Marek Vasut
Quoted 150 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
V3: - Update copyright years
- Register two sets of clock, one 480 MHz PLL and one CMN
- Split PHY ops per PHY, since the PHY2 does not have set mode ops
- Fix up Sob/Cdb lines further

---
 drivers/phy/st/Kconfig             |  10 +
 drivers/phy/st/Makefile            |   1 +
 drivers/phy/st/phy-stm32-usb2phy.c | 406 +++++++++++++++++++++++++++++
 3 files changed, 417 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 +64 -0
new file mode 100644
index 0000000000000..8c68b2d208d73
@@ -0,0 +1,406 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * STMicroelectronics STM32 USB2 PHY Controller driver
+ * Currently Only supported for STM32MP25
+ *
+ * Copyright (C) 2022-2026 STMicroelectronics
+ * 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)
+
+#define USBH_NUM_CLK				2
+
+struct stm32_usb2phy {
+	struct phy				*phy;
+	struct regmap				*regmap;
+	struct device				*dev;
+	struct reset_control			*rstc;
+	struct clk				*phyref;
+	struct regulator			*vdd33;
+	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				clkpll_hw;
+	struct clk_hw				clkcmn_hw;
+	/* Must be last */
+	struct clk_hw_onecell_data		onecell;
+};
+
+struct stm32mp2_usb2phy_hw_data {
+	u32			phyrefsel_mask;
+	const struct phy_ops	*phy_ops;
+};
+
+static int stm32_usb2phy_enable(struct stm32_usb2phy *phy_dev)
+{
+	const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+	unsigned int refsel;
+	unsigned long rate;
+	int ret;
+
+	/* Check if a phy is already init or clkpll in use */
+	if (atomic_inc_return(&phy_dev->en_refcnt) > 1)
+		return 0;

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

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;

Would a switch not be better here?

Quoted 98 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +98 -0
+
+	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;
+
+	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 clkpll 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);
+
+	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);
+	u32 mask = SYSCFG_USB2PHY2CR_USB2PHY2CMN |
+		   SYSCFG_USB2PHY2CR_VBUSVALID |
+		   SYSCFG_USB2PHY2CR_VBUSVLDEXT;
+	u32 val = 0;
+	int ret;
+
+	if (mode == PHY_MODE_USB_HOST) {
+		if (submode != USB_ROLE_NONE)
+			val = SYSCFG_USB2PHY2CR_VBUSVALID;
+	} else if (mode == PHY_MODE_USB_DEVICE) {
+		val = SYSCFG_USB2PHY2CR_USB2PHY2CMN |
+		      SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL;
+		if (submode != USB_ROLE_NONE)
+			val |= SYSCFG_USB2PHY2CR_VBUSVLDEXT;
+		mask |= SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL;
+	} 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_usb2phy1_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;
+
+	phy_dev->is_init = true;
+
+	return 0;
+}
+
+static int stm32_usb2phy2_init(struct phy *phy)
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	int ret;
+
+	ret = stm32_usb2phy_enable(phy_dev);

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

Quoted 10 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +10 -0
+	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;
+		}
+	}

so what is the diff b/w these two phys that we need to check invalid only here?

Signature · 1 line
~Vinod
#15 lore raw

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

On 8/27/26 6:00 PM, Vinod Koul wrote:

[...]

Quoted 14 lines
Quoted 14 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +14 -0
+static int stm32_usb2phy_enable(struct stm32_usb2phy *phy_dev)
+{
+	const struct stm32mp2_usb2phy_hw_data *phy_data = phy_dev->hw_data;
+	unsigned int refsel;
+	unsigned long rate;
+	int ret;
+
+	/* Check if a phy is already init or clkpll 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;
Quoted 8 lines

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

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

Would a switch not be better here?

I think here it is a matter of taste, switch would use a few more lines, so would a look up table. If you insist on a switch, I'll turn this into a switch.

[...]

Quoted 11 lines
Quoted 11 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +11 -0
+static int stm32_usb2phy2_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);
Quoted 8 lines

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

Quoted 5 lines
drivers/phy/st/phy-stm32-usb2phy.c new file +5 -0
+		if (ret) {
+			stm32_usb2phy_disable(phy_dev);
+			return ret;
+		}
+	}

so what is the diff b/w these two phys that we need to check invalid only here?

For this particular case -- One PHY is connected to host-only EHCI/OHCI controller, so it does not do mode set. The other PHY is connected to DWC3 DRD controller which can do either Host/Peripheral and does mode set, but that can only be done if a valid mode is already configured. Hence the conditional here.

[...]

#16 lore raw

PATCH v3 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
V3: 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
#17 lore raw

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

Quoted 2 lines · Marek Vasut

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

Please mention in the commit msg which compatible/device from this schema actually uses such access controllers. I see your work is for STM, but there is no STM compatible in generic-ehci/ohci.

Also, please send USB patches separately from DTS and other subsystems, because Greg takes entire set.

Best regards,
Krzysztof

#18 lore raw

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

Quoted 7 lines · Krzysztof Kozlowski
Quoted 2 lines · Marek Vasut

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

Please mention in the commit msg which compatible/device from this schema actually uses such access controllers. I see your work is for STM, but there is no STM compatible in generic-ehci/ohci.

Let me also add required: access-controllers for the STM32MP23xx and 25xx while at it.

Quoted 2 lines

Also, please send USB patches separately from DTS and other subsystems, because Greg takes entire set.

All right.

#19 lore raw

PATCH v3 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
V3: 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
#20 lore raw

PATCH v3 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
V3: - Document maximum-speed
- Switch resets to maxItems: 1
- Drop label from example
- Use generic over-current-active-low
- Use ref: snps,dwc3-common.yaml and drop generic dr_mode/maximum-speed/phys/phy-names

---
 .../bindings/usb/st,stm32mp25-dwc3.yaml       | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +97 -0
new file mode 100644
index 0000000000000..96bd557327252
@@ -0,0 +1,97 @@
+# 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]>
+
+allOf:
+  - $ref: snps,dwc3-common.yaml#
+
+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
+
+  interrupts:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  over-current-active-low:
+    type: boolean
+    description: Over-Current signal polarity is active-low
+
+  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,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>
+
+    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>;
+        over-current-active-low;
+        st,syscfg = <&syscfg 0x4800>;
+        st,vbusen-active-low;
+    };
Signature · 1 line
2.53.0
#21 lore raw

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

Quoted 59 lines · 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
V3: - Document maximum-speed
- Switch resets to maxItems: 1
- Drop label from example
- Use generic over-current-active-low
- Use ref: snps,dwc3-common.yaml and drop generic dr_mode/maximum-speed/phys/phy-names

---
 .../bindings/usb/st,stm32mp25-dwc3.yaml       | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +8 -0
new file mode 100644
index 0000000000000..96bd557327252
@@ -0,0 +1,97 @@
+# 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
+

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

Quoted 10 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +10 -0
+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]>
+
+allOf:
+  - $ref: snps,dwc3-common.yaml#

Honestly, I am lost. It seems this resolves my comment at v2, but now I went through patchset from Fabrice Gasnier which was ON TOP of this patch adding this line.

It is not your fault, although if there are pending comments expressed not via review but via patchses on top of things being reviewed, then can you check for them?

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#22 lore raw

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

On 8/27/26 2:59 PM, Krzysztof Kozlowski wrote:

[...]

Quoted 16 lines
Quoted 16 lines

+++ b/Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml

Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +14 -0
@@ -0,0 +1,97 @@
+# 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]>
Quoted 8 lines

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

Quoted 4 lines
Documentation/devicetree/bindings/usb/st,stm32mp25-dwc3.yaml new file +4 -0
+  - Marek Vasut <[email protected]>
+
+allOf:
+  - $ref: snps,dwc3-common.yaml#

Honestly, I am lost. It seems this resolves my comment at v2, but now I went through patchset from Fabrice Gasnier which was ON TOP of this patch adding this line.

I think the stuff Fabrice sent was on top of V2.

Quoted 3 lines

It is not your fault, although if there are pending comments expressed not via review but via patchses on top of things being reviewed, then can you check for them?

I did, while briefly reviewing that series.

#23 lore raw

PATCH v3 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
V3: - Use generic over-current-active-low

---
 drivers/usb/dwc3/dwc3-generic-plat.c | 44 ++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/usb/dwc3/dwc3-generic-plat.c +44 -0
index ca69ac0eb07ce..f670576511b59 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, "over-current-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
#24 lore raw

Re: [PATCH v3 6/9] usb: dwc3: dwc3-generic-plat: Add ST STM32MP2 DWC3 xHCI USB controller glue

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The file uses the FIELD_PREP macro without including its required header <linux/bitfield.h>. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The file uses the FIELD_PREP macro without including its required header <linux/bitfield.h>. --

--- Patch [6]: [PATCH v3 6/9] usb: dwc3: dwc3-generic-plat: Add ST STM32MP2 DWC3 xHCI USB controller glue --- commit 144f9fcc747a522925bb8e40158fa496caf2673c
Author: Marek Vasut <[email protected]>

usb: dwc3: dwc3-generic-plat: Add ST STM32MP2 DWC3 xHCI USB controller glue

This commit extends the generic DWC3 platform driver by adding glue logic support for the ST STM32MP2 SoC. It configures controller settings using syscon via device tree properties.

Quoted 4 lines
drivers/usb/dwc3/dwc3-generic-plat.c +0 -0
index ca69ac0eb07ce..f670576511b59 100644

[ ... ]

Quoted 1 line
drivers/usb/dwc3/dwc3-generic-plat.c +0 -0
@@ -85,6 +91,38 @@ static int dwc3_spacemit_k1_init(struct dwc3_generic *dwc3g)

[ ... ]

Quoted 2 lines
drivers/usb/dwc3/dwc3-generic-plat.c +2 -0
+static int dwc3_stm32mp25_init(struct dwc3_generic *dwc3g)
+{

[ ... ]

drivers/usb/dwc3/dwc3-generic-plat.c static int dwc3_spacemit_k1_init(struct dwc3_generic *dwc3g) · line 115

Quoted 8 lines
drivers/usb/dwc3/dwc3-generic-plat.c +8 -0
+	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) |

[Severity: Low]
This isn't a bug, but FIELD_PREP is used here without explicitly including linux/bitfield.h. Could this cause build failures on architectures or configurations where this header is not implicitly pulled in by other includes?

Quoted 9 lines
drivers/usb/dwc3/dwc3-generic-plat.c +9 -0
+				  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));
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
#25 lore raw

PATCH v3 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
V3: Fix the bindings

---
 .../bindings/arm/stm32/st,stm32-syscon.yaml   | 24 +++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +20 -4
index 95d2319afe235..4db4198c5dd7a 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
 
@@ -39,6 +40,17 @@ properties:
   "#clock-cells":
     const: 0
 
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 1
+
+patternProperties:
+  "^phy@[0-9a-f]+$":
+    type: object
+    $ref: /schemas/phy/st,stm32-usb2phy.yaml
+
 required:
   - compatible
   - reg
@@ -57,10 +69,14 @@ allOf:
   - if:
       properties:
         compatible:
-          const: st,stm32mp25-syscfg
+          enum:
+            - st,stm32mp23-syscfg
+            - st,stm32mp25-syscfg
     then:
       required:
         - "#clock-cells"
+        - "#address-cells"
+        - "#size-cells"
 
 additionalProperties: false
 
Signature · 1 line
2.53.0
#26 lore raw

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

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Critical] Strictly enforcing `simple-mfd` in the compatible array breaks backward compatibility with…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] Strictly enforcing simple-mfd in the compatible array breaks backward compatibility with existing device trees.
- [High] The en_refcnt atomic reference counter is leaked on error paths in stm32_usb2phy_enable(), permanently breaking the PHY.
- [Medium] The allOf:if condition for st,stm32mp23/25-syscfg uses enum directly on the compatible property array, bypassing the validation block.
- [Low] The patternProperties regex in the syscon parent binding rejects the usb-phy@ node name recommended by the child PHY binding. --

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

This commit updates the STM32 syscon binding to convert the st,stm32mp23-syscfg and st,stm32mp25-syscfg compatibles into "simple-mfd". This allows the OS to automatically populate the subnodes for the USB 2.0 FEMTO-PHY.

Quoted 9 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +0 -1
index 95d2319afe235..4db4198c5dd7a 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 +6 -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: Critical]
Does enforcing simple-mfd in this array break backward compatibility?

Older device trees define these syscfg nodes using only st,stm32mp25-syscfg and syscon. Moving them into a strict 3-item list requiring simple-mfd causes validation to fail for existing DTBs.

Quoted 4 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +0 -0
@@ -39,6 +40,17 @@ properties:
   "#clock-cells":
     const: 0
 

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

Quoted 10 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +10 -0
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 1
+
+patternProperties:
+  "^phy@[0-9a-f]+$":
+    type: object
+    $ref: /schemas/phy/st,stm32-usb2phy.yaml

[Severity: Low]
Will this regex reject the node names recommended by the child PHY binding?

The child binding example uses usb-phy@2400:

    usb-phy@2400 {
        compatible = "st,stm32mp25-usb2phy1";

which fails the stricter ^phy@[0-9a-f]+$ pattern defined here.

[ ... ]

Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml allOf: · line 74

Quoted 8 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +3 -1
@@ -57,10 +69,14 @@ allOf:
   - if:
       properties:
         compatible:
-          const: st,stm32mp25-syscfg
+          enum:
+            - st,stm32mp23-syscfg
+            - st,stm32mp25-syscfg

[Severity: Medium]
Does this conditional block bypass schema validation?

Applying enum directly to an array property checks if the array strictly equals the scalar string, which always evaluates to false. Should this use
contains: enum: instead?

Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml allOf: · line 79

Quoted 5 lines
Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +2 -0
     then:
       required:
         - "#clock-cells"
+        - "#address-cells"
+        - "#size-cells"

[Severity: High]
Is there a reference counter leak in stm32_usb2phy_enable() introduced earlier in this series?

If an unsupported clock rate is detected, the function returns without decrementing en_refcnt:

drivers/phy/st/phy-stm32-usb2phy.c:stm32_usb2phy_enable() {
    ...
    if (...)
        ...
    else
        return -EINVAL;
}

Additionally, the common error paths do not decrement en_refcnt after it was incremented:

drivers/phy/st/phy-stm32-usb2phy.c:stm32_usb2phy_enable() {
    ...
error_regdis:
    regulator_disable(phy_dev->vdd33);

    return ret;
}

Future calls will see en_refcnt > 1 and return success immediately, leaving the PHY disabled.

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

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

In reply to Marek Vasut
Quoted 3 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.

Sashiko comment is partially valid - you change the ABI in incompatible way, by requiring a new compatible. Commit msg should briefly explain the impact, e.g. that there is no impact because phy was not implemented by Linux and was not described in the binding.

OTOH, adding simple-mfd means children have no dependency on the parent, so this should be considered or even explicitly mentioned in commit msg (parent clock is irrelevant to child, right?)

OTOH2, you have now patchset dependency which is nowwhere explained. Merging constraints are the most important part of cover letter so must be clearly stated. IMO, should be stated also here, because many maintainers do not read cover letters. Or just decouple dependencies with using 'compatibles' pattern (see Qualcomm msm/mdss display bindings).

Best regards,
Krzysztof

#28 lore raw

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

Quoted 14 lines · Krzysztof Kozlowski
Quoted 3 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.

Sashiko comment is partially valid - you change the ABI in incompatible way, by requiring a new compatible. Commit msg should briefly explain the impact, e.g. that there is no impact because phy was not implemented by Linux and was not described in the binding.

OTOH, adding simple-mfd means children have no dependency on the parent, so this should be considered or even explicitly mentioned in commit msg (parent clock is irrelevant to child, right?)

Quoted 6 lines

OTOH2, you have now patchset dependency which is nowwhere explained. Merging constraints are the most important part of cover letter so must be clearly stated. IMO, should be stated also here, because many maintainers do not read cover letters. Or just decouple dependencies with using 'compatibles' pattern (see Qualcomm msm/mdss display bindings).

I wonder, wouldn't it be better to write a driver which binds to st,stm32mp25-syscfg , handles the SYSCFG clock, and does some of_platform_populate() to bring up the PHYs (DT subnodes) ?

I think that would resolve the ABI break problem, since we wouldn't need the simple-mfd compatible anymore. And it would also correctly handle the SYSCFG clock.

What do you think ?

#29 lore raw

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

Quoted 12 lines · Marek Vasut
Quoted 7 lines · Krzysztof Kozlowski

OTOH2, you have now patchset dependency which is nowwhere explained. Merging constraints are the most important part of cover letter so must be clearly stated. IMO, should be stated also here, because many maintainers do not read cover letters. Or just decouple dependencies with using 'compatibles' pattern (see Qualcomm msm/mdss display bindings).

I wonder, wouldn't it be better to write a driver which binds to st,stm32mp25-syscfg , handles the SYSCFG clock, and does some of_platform_populate() to bring up the PHYs (DT subnodes) ?

Quoted 5 lines

I think that would resolve the ABI break problem, since we wouldn't need the simple-mfd compatible anymore. And it would also correctly handle the SYSCFG clock.

What do you think ?

Yes, it is better and more flexible approach. Solves ABI impact.

Best regards,
Krzysztof

#30 lore raw

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

Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Marek Vasut
Quoted 7 lines · Krzysztof Kozlowski

OTOH2, you have now patchset dependency which is nowwhere explained. Merging constraints are the most important part of cover letter so must be clearly stated. IMO, should be stated also here, because many maintainers do not read cover letters. Or just decouple dependencies with using 'compatibles' pattern (see Qualcomm msm/mdss display bindings).

I wonder, wouldn't it be better to write a driver which binds to st,stm32mp25-syscfg , handles the SYSCFG clock, and does some of_platform_populate() to bring up the PHYs (DT subnodes) ?

Quoted 7 lines
Quoted 5 lines

I think that would resolve the ABI break problem, since we wouldn't need the simple-mfd compatible anymore. And it would also correctly handle the SYSCFG clock.

What do you think ?

Yes, it is better and more flexible approach. Solves ABI impact.

All right, let's do that.

#31 lore raw

PATCH v3 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.

---
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
V3: - Drop combophy which is not present on MP23
- Describe OHCI clock as the CMN clock

---
 arch/arm64/boot/dts/st/stm32mp231.dtsi | 67 +++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/st/stm32mp231.dtsi +66 -1
index 4505fc0e3b537..314a514f31024 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>;
@@ -862,6 +863,48 @@ 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 1>, <&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>;
+				maximum-speed = "high-speed";
+				phys = <&usb2_phy2>;
+				phy-names = "usb2-phy";
+				resets = <&rcc USB3DR_R>;
+				st,syscfg = <&syscfg 0x4800>;
+				status = "disabled";
+			};
 		};
 
 		bsec: efuse@44000000 {
@@ -1062,9 +1105,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
#32 lore raw

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

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Missing `ranges` property in the `simple-mfd` `syscfg` node causes a kernel WARN_ON during boot.…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing ranges property in the simple-mfd syscfg node causes a kernel WARN_ON during boot. --

--- Patch [8]: [PATCH v3 8/9] arm64: dts: st: Add USB nodes on stm32mp231 --- commit b21748ed09e5c154d11bfc7972df50b9735bfab9
Author: Marek Vasut <[email protected]>

arm64: dts: st: Add USB nodes on stm32mp231

This commit adds USB controller and PHY nodes to the stm32mp231 device tree. It also converts the syscfg node into a simple-mfd to contain the new PHY subnodes.

Quoted 4 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +0 -0
index 9e1d240888ff2..db66777a8c9a0 100644

[ ... ]

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

Quoted 7 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +3 -1
 		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>;

[Severity: Medium]
Is there a missing ranges property here?

Since the syscfg node is now a simple-mfd bus with children that have reg properties (usb2_phy1 and usb2_phy2), omitting the ranges property causes address translation to fail.

During boot, when of_platform_populate() tries to instantiate the children, of_address_to_resource() will fail to translate the child addresses. This triggers a WARN_ON() in drivers/of/platform.c:of_device_alloc() for each child device, which pollutes the boot log and could cause boot failures if panic_on_warn is enabled.

Quoted 4 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +4 -0
+
+			usb2_phy1: phy@2400 {
+				compatible = "st,stm32mp25-usb2phy1";
+				reg = <0x2400 0x24>;

[ ... ]

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

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

In reply to Marek Vasut
Quoted 107 lines · 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.

---
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
V3: - Drop combophy which is not present on MP23
- Describe OHCI clock as the CMN clock

---
 arch/arm64/boot/dts/st/stm32mp231.dtsi | 67 +++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/st/stm32mp231.dtsi +43 -0
index 4505fc0e3b537..314a514f31024 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>;
@@ -862,6 +863,48 @@ 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 1>, <&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>;
+				maximum-speed = "high-speed";
+				phys = <&usb2_phy2>;
+				phy-names = "usb2-phy";
+				resets = <&rcc USB3DR_R>;
+				st,syscfg = <&syscfg 0x4800>;
+				status = "disabled";
+			};
 		};
 
 		bsec: efuse@44000000 {
@@ -1062,9 +1105,31 @@ exti1: interrupt-controller@44220000 {
 		};
 
 		syscfg: syscon@44230000 {

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

Quoted 10 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +7 -1
-			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>;

Hello Marek,

The size 0x24, covers the PHY control, trimming and vbus control logic for PHY1 (USBH). So this allows to later extend the driver for that, right ?

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

Quoted 10 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +10 -0
+				#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>;

Then here, I guess the size should cover also trimming regs ? e.g. 0x10 ?

				reg = <0x2800 0x10>;

Thanks & BR,
Fabrice

Quoted 9 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +6 -0
+				#phy-cells = <0>;
+				#clock-cells = <1>;
+				clocks = <&rcc CK_KER_USB2PHY2EN>;
+				resets = <&rcc USB2PHY2_R>;
+				status = "disabled";
+			};
 		};
 
 		pinctrl: pinctrl@44240000 {
#34 lore raw

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

On 8/24/26 3:18 PM, Fabrice Gasnier wrote:

[...]

Quoted 5 lines
Quoted 5 lines
  		syscfg: syscon@44230000 {
arch/arm64/boot/dts/st/stm32mp231.dtsi +1 -1
-			compatible = "st,stm32mp23-syscfg", "syscon";
+			compatible = "st,stm32mp23-syscfg", "syscon", "simple-mfd";
  			reg = <0x44230000 0x10000>;
  			#clock-cells = <0>;
Quoted 8 lines

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

Quoted 6 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +6 -0
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			usb2_phy1: phy@2400 {
+				compatible = "st,stm32mp25-usb2phy1";
+				reg = <0x2400 0x24>;

Hello Marek,

Hello Fabrice,

Quoted 2 lines

The size 0x24, covers the PHY control, trimming and vbus control logic for PHY1 (USBH). So this allows to later extend the driver for that, right ?

Correct.

Quoted 12 lines

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

Quoted 10 lines
arch/arm64/boot/dts/st/stm32mp231.dtsi +10 -0
+				#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>;

Then here, I guess the size should cover also trimming regs ? e.g. 0x10 ?

Quoted 1 line
				reg = <0x2800 0x10>;

Uh, yes, fixed in V4, thanks !

#35 lore raw

PATCH v3 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
V3: - Describe OHCI clock as the CMN clock
- Fix up Sob/Cdb lines further

---
 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..dd2f7ddd9b634 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 1>, <&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
#36 lore raw

Re: [PATCH v3 9/9] arm64: dts: st: Add USB nodes on stm32mp251

Quoted 108 lines · 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
V3: - Describe OHCI clock as the CMN clock
- Fix up Sob/Cdb lines further

---
 arch/arm64/boot/dts/st/stm32mp251.dtsi | 65 +++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/st/stm32mp251.dtsi +48 -1
index 6e985f115b195..dd2f7ddd9b634 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 1>, <&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>;

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

Quoted 10 lines
arch/arm64/boot/dts/st/stm32mp251.dtsi +10 -0
+				#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>;

Hello Marek,

Similar to stm32mp231: should update size ?

				reg = <0x2800 0x10>;

Thanks & BR,
Fabrice

Quoted 9 lines
arch/arm64/boot/dts/st/stm32mp251.dtsi +6 -0
+				#phy-cells = <0>;
+				#clock-cells = <1>;
+				clocks = <&rcc CK_KER_USB2PHY2EN>;
+				resets = <&rcc USB2PHY2_R>;
+				status = "disabled";
+			};
 		};
 
 		pinctrl: pinctrl@44240000 {
#37 lore raw

Re: [PATCH v3 9/9] arm64: dts: st: Add USB nodes on stm32mp251

On 8/24/26 3:19 PM, Fabrice Gasnier wrote:

Hello Fabrice,

Quoted 9 lines

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

Quoted 3 lines
arch/arm64/boot/dts/st/stm32mp251.dtsi +3 -0
+			usb2_phy2: phy@2800 {
+				compatible = "st,stm32mp25-usb2phy2";
+				reg = <0x2800 0xc>;

Hello Marek,

Similar to stm32mp231: should update size ?

				reg = <0x2800 0x10>;

Fixed in V4, thanks !

#38 lore raw

Re: [PATCH v3 9/9] arm64: dts: st: Add USB nodes on stm32mp251

In reply to Marek Vasut
Quoted 5 lines · 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.

This looks early unwrapped.

Please wrap commit message according to Linux coding style / submission process (neither too early nor over the limit):
https://elixir.bootlin.com/linux/v6.4-rc1/source/Documentation/process/submitting-patches.rst#L597

Quoted 42 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
- 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
V3: - Describe OHCI clock as the CMN clock
- Fix up Sob/Cdb lines further

---
 arch/arm64/boot/dts/st/stm32mp251.dtsi | 65 +++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/st/stm32mp251.dtsi +0 -0
index 6e985f115b195..dd2f7ddd9b634 100644

arch/arm64/boot/dts/st/stm32mp251.dtsi stmmac_axi_config_1: stmmac-axi-config { · line 1750

Quoted 5 lines
arch/arm64/boot/dts/st/stm32mp251.dtsi +2 -0
@@ -1746,6 +1746,47 @@ stmmac_axi_config_1: stmmac-axi-config {
 				};
 			};
 
+			usbh_ohci: usb@482e0000 {
+				compatible = "generic-ohci";

So probably this answers my previous email about USB binding - you really should have a specific front compatible. That specific compatible also would narrow flexible properties, like clocks and reg.

Best regards,
Krzysztof