2022-10-14 14:35:30

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 00/10] Add support for USB on STM32MP13

Add support for USBPHYC, USB Host and USB OTG on STM32MP13.
Enable all these interfaces on STM32MP135F-DK board.
Enable the STM32G0 UCSI driver as module.
Dependency on PWR and PMIC regulator is tempoarily managed by using
fixed regulators (resp in the SoC dtsi and the board dts files).
The USB support is functional when these regulators gets enabled at
boot time before entering the kernel.

Changes in v2:
Adopt "usb" and "typec" generic node names

Amelie Delaunay (5):
ARM: dts: stm32: add USBPHYC and dual USB HS PHY support on stm32mp131
ARM: dts: stm32: add UBSH EHCI and OHCI support on stm32mp131
ARM: dts: stm32: add USB OTG HS support on stm32mp131
ARM: dts: stm32: enable USB HS phys on stm32mp135f-dk
ARM: dts: stm32: enable USB Host EHCI on stm32mp135f-dk

Fabrice Gasnier (5):
ARM: dts: stm32: add PWR fixed regulators on stm32mp131
ARM: dts: stm32: add fixed regulators to support usb on stm32mp135f-dk
ARM: dts: stm32: add pins for stm32g0 typec controller on stm32mp13
ARM: dts: stm32: enable USB OTG in dual role mode on stm32mp135f-dk
ARM: multi_v7_defconfig: enable Type-C UCSI and STM32G0 as modules

arch/arm/boot/dts/stm32mp13-pinctrl.dtsi | 7 ++
arch/arm/boot/dts/stm32mp131.dtsi | 81 ++++++++++++++++++++
arch/arm/boot/dts/stm32mp135f-dk.dts | 95 ++++++++++++++++++++++++
arch/arm/configs/multi_v7_defconfig | 2 +
4 files changed, 185 insertions(+)

--
2.25.1


2022-10-14 14:35:42

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 02/10] ARM: dts: stm32: add USBPHYC and dual USB HS PHY support on stm32mp131

From: Amelie Delaunay <[email protected]>

This patch adds support for USBPHYC and its two USB HS PHY on stm32mp131.

Signed-off-by: Amelie Delaunay <[email protected]>
Signed-off-by: Fabrice Gasnier <[email protected]>
---
arch/arm/boot/dts/stm32mp131.dtsi | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp131.dtsi b/arch/arm/boot/dts/stm32mp131.dtsi
index e0e0e27a9221..cd31fdd47536 100644
--- a/arch/arm/boot/dts/stm32mp131.dtsi
+++ b/arch/arm/boot/dts/stm32mp131.dtsi
@@ -409,6 +409,29 @@ iwdg2: watchdog@5a002000 {
status = "disabled";
};

+ usbphyc: usbphyc@5a006000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ #clock-cells = <0>;
+ compatible = "st,stm32mp1-usbphyc";
+ reg = <0x5a006000 0x1000>;
+ clocks = <&rcc USBPHY_K>;
+ resets = <&rcc USBPHY_R>;
+ vdda1v1-supply = <&reg11>;
+ vdda1v8-supply = <&reg18>;
+ status = "disabled";
+
+ usbphyc_port0: usb-phy@0 {
+ #phy-cells = <0>;
+ reg = <0>;
+ };
+
+ usbphyc_port1: usb-phy@1 {
+ #phy-cells = <1>;
+ reg = <1>;
+ };
+ };
+
rtc: rtc@5c004000 {
compatible = "st,stm32mp1-rtc";
reg = <0x5c004000 0x400>;
--
2.25.1

2022-10-14 14:36:02

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 01/10] ARM: dts: stm32: add PWR fixed regulators on stm32mp131

Add 1v1, 1v8 and 3v3 PWR regulators on stm32mp131. Temporary add them
as fixed regulators, waiting for full SCMI regulators support.

This is a precursor patch to enable USB support on STM32MP13.
Note: USB support requires these regulators to be enabled before
entering kernel.

Signed-off-by: Fabrice Gasnier <[email protected]>
---
arch/arm/boot/dts/stm32mp131.dtsi | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp131.dtsi b/arch/arm/boot/dts/stm32mp131.dtsi
index dd35a607073d..e0e0e27a9221 100644
--- a/arch/arm/boot/dts/stm32mp131.dtsi
+++ b/arch/arm/boot/dts/stm32mp131.dtsi
@@ -77,6 +77,28 @@ timer {
always-on;
};

+ /* PWR 1v1, 1v8 and 3v3 regulators defined as fixed, waiting for SCMI */
+ reg11: reg11 {
+ compatible = "regulator-fixed";
+ regulator-name = "reg11";
+ regulator-min-microvolt = <1100000>;
+ regulator-max-microvolt = <1100000>;
+ };
+
+ reg18: reg18 {
+ compatible = "regulator-fixed";
+ regulator-name = "reg18";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ };
+
+ usb33: usb33 {
+ compatible = "regulator-fixed";
+ regulator-name = "usb33";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
soc {
compatible = "simple-bus";
#address-cells = <1>;
--
2.25.1

2022-10-14 14:36:24

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 04/10] ARM: dts: stm32: add USB OTG HS support on stm32mp131

From: Amelie Delaunay <[email protected]>

This patch adds USB OTG HS support on stm32mp131.

Signed-off-by: Amelie Delaunay <[email protected]>
Signed-off-by: Fabrice Gasnier <[email protected]>
---
Changes in v2: adopt "usb" generic node name
---
arch/arm/boot/dts/stm32mp131.dtsi | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp131.dtsi b/arch/arm/boot/dts/stm32mp131.dtsi
index e6129e11660b..6cf930d7721a 100644
--- a/arch/arm/boot/dts/stm32mp131.dtsi
+++ b/arch/arm/boot/dts/stm32mp131.dtsi
@@ -253,6 +253,23 @@ dmamux1: dma-router@48002000 {
dma-channels = <16>;
};

+ usbotg_hs: usb@49000000 {
+ compatible = "st,stm32mp15-hsotg", "snps,dwc2";
+ reg = <0x49000000 0x40000>;
+ clocks = <&rcc USBO_K>;
+ clock-names = "otg";
+ resets = <&rcc USBO_R>;
+ reset-names = "dwc2";
+ interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
+ g-rx-fifo-size = <512>;
+ g-np-tx-fifo-size = <32>;
+ g-tx-fifo-size = <256 16 16 16 16 16 16 16>;
+ dr_mode = "otg";
+ otg-rev = <0x200>;
+ usb33d-supply = <&usb33>;
+ status = "disabled";
+ };
+
spi4: spi@4c002000 {
compatible = "st,stm32h7-spi";
reg = <0x4c002000 0x400>;
--
2.25.1

2022-10-14 14:36:30

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 03/10] ARM: dts: stm32: add UBSH EHCI and OHCI support on stm32mp131

From: Amelie Delaunay <[email protected]>

This patch adds USB Host EHCI and OHCI support on stm32mp131.

Signed-off-by: Amelie Delaunay <[email protected]>
Signed-off-by: Fabrice Gasnier <[email protected]>
---
Changes in v2: adopt "usb" generic node names
---
arch/arm/boot/dts/stm32mp131.dtsi | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp131.dtsi b/arch/arm/boot/dts/stm32mp131.dtsi
index cd31fdd47536..e6129e11660b 100644
--- a/arch/arm/boot/dts/stm32mp131.dtsi
+++ b/arch/arm/boot/dts/stm32mp131.dtsi
@@ -401,6 +401,25 @@ sdmmc2: mmc@58007000 {
status = "disabled";
};

+ usbh_ohci: usb@5800c000 {
+ compatible = "generic-ohci";
+ reg = <0x5800c000 0x1000>;
+ clocks = <&usbphyc>, <&rcc USBH>;
+ resets = <&rcc USBH_R>;
+ interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
+ status = "disabled";
+ };
+
+ usbh_ehci: usb@5800d000 {
+ compatible = "generic-ehci";
+ reg = <0x5800d000 0x1000>;
+ clocks = <&usbphyc>, <&rcc USBH>;
+ resets = <&rcc USBH_R>;
+ interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
+ companion = <&usbh_ohci>;
+ status = "disabled";
+ };
+
iwdg2: watchdog@5a002000 {
compatible = "st,stm32mp1-iwdg";
reg = <0x5a002000 0x400>;
--
2.25.1

2022-10-14 14:36:39

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 08/10] ARM: dts: stm32: add pins for stm32g0 typec controller on stm32mp13

Add gpio pin configuration to be used with stm32g0 typec controller. Define
the PI2 to enable internal pull-up on stm32mp13, used as interrupt pin on
stm32mp135f-dk board.

Signed-off-by: Fabrice Gasnier <[email protected]>
---
arch/arm/boot/dts/stm32mp13-pinctrl.dtsi | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp13-pinctrl.dtsi b/arch/arm/boot/dts/stm32mp13-pinctrl.dtsi
index efdd163eba30..5c85c9fc583c 100644
--- a/arch/arm/boot/dts/stm32mp13-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stm32mp13-pinctrl.dtsi
@@ -165,6 +165,13 @@ pins {
};
};

+ stm32g0_intn_pins_a: stm32g0-intn-0 {
+ pins {
+ pinmux = <STM32_PINMUX('I', 2, GPIO)>;
+ bias-pull-up;
+ };
+ };
+
uart4_pins_a: uart4-0 {
pins1 {
pinmux = <STM32_PINMUX('D', 6, AF8)>; /* UART4_TX */
--
2.25.1

2022-10-14 14:37:05

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 07/10] ARM: dts: stm32: enable USB Host EHCI on stm32mp135f-dk

From: Amelie Delaunay <[email protected]>

USBH Host EHCI controller manages the USB High-Speed hub controller IC
offering Type-A CN5 & CN6 connectors available on stm32mp135f-dk.
USB Host OHCI controller doesn't need to be enabled as Full-Speed and
Low-Speed traffic will be managed by the hub.
This USB2514B onboard hub is supplied by a 3v3 PMIC regulator.

Signed-off-by: Amelie Delaunay <[email protected]>
Signed-off-by: Fabrice Gasnier <[email protected]>
---
arch/arm/boot/dts/stm32mp135f-dk.dts | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp135f-dk.dts b/arch/arm/boot/dts/stm32mp135f-dk.dts
index af87fb36eabc..02ff2bc664da 100644
--- a/arch/arm/boot/dts/stm32mp135f-dk.dts
+++ b/arch/arm/boot/dts/stm32mp135f-dk.dts
@@ -145,6 +145,19 @@ &uart4 {
status = "okay";
};

+&usbh_ehci {
+ phys = <&usbphyc_port0>;
+ status = "okay";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ /* onboard HUB */
+ hub@1 {
+ compatible = "usb424,2514";
+ reg = <1>;
+ vdd-supply = <&v3v3_sw>;
+ };
+};
+
&usbphyc {
status = "okay";
};
--
2.25.1

2022-10-14 14:37:10

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 06/10] ARM: dts: stm32: enable USB HS phys on stm32mp135f-dk

From: Amelie Delaunay <[email protected]>

USBPHYC manages the two USB High-Speed phys. port0 is used by USBH and
port1 is used by USBOTG.
Enable and tune both PHYs on stm32mp135f-dk.

Signed-off-by: Amelie Delaunay <[email protected]>
Signed-off-by: Fabrice Gasnier <[email protected]>
---
arch/arm/boot/dts/stm32mp135f-dk.dts | 32 ++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp135f-dk.dts b/arch/arm/boot/dts/stm32mp135f-dk.dts
index 291f05a958fd..af87fb36eabc 100644
--- a/arch/arm/boot/dts/stm32mp135f-dk.dts
+++ b/arch/arm/boot/dts/stm32mp135f-dk.dts
@@ -144,3 +144,35 @@ &uart4 {
pinctrl-0 = <&uart4_pins_a>;
status = "okay";
};
+
+&usbphyc {
+ status = "okay";
+};
+
+&usbphyc_port0 {
+ phy-supply = <&vdd_usb>;
+ st,current-boost-microamp = <1000>;
+ st,decrease-hs-slew-rate;
+ st,tune-hs-dc-level = <2>;
+ st,enable-hs-rftime-reduction;
+ st,trim-hs-current = <11>;
+ st,trim-hs-impedance = <2>;
+ st,tune-squelch-level = <1>;
+ st,enable-hs-rx-gain-eq;
+ st,no-hs-ftime-ctrl;
+ st,no-lsfs-sc;
+};
+
+&usbphyc_port1 {
+ phy-supply = <&vdd_usb>;
+ st,current-boost-microamp = <1000>;
+ st,decrease-hs-slew-rate;
+ st,tune-hs-dc-level = <2>;
+ st,enable-hs-rftime-reduction;
+ st,trim-hs-current = <11>;
+ st,trim-hs-impedance = <2>;
+ st,tune-squelch-level = <1>;
+ st,enable-hs-rx-gain-eq;
+ st,no-hs-ftime-ctrl;
+ st,no-lsfs-sc;
+};
--
2.25.1

2022-10-14 14:37:27

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 09/10] ARM: dts: stm32: enable USB OTG in dual role mode on stm32mp135f-dk

The USB OTG controller provides the USB data available on stm32mp135f-dk,
on the Type-C connector. Data role is determined by "usb-role-switch".

A STM32G0 provides the USB Type-C and Power Delivery connectivity.
It controls dual role power and dual role data through UCSI protocol over
I2C. It's wired on I2C1, with an interrupt pin on PI2 GPIO.
Its firmware maybe updated over I2C, so use the optional firmware-name
to enable firmware update.

Signed-off-by: Amelie Delaunay <[email protected]>
Signed-off-by: Fabrice Gasnier <[email protected]>
---
Changes in v2: adopt "typec" generic node name
---
arch/arm/boot/dts/stm32mp135f-dk.dts | 34 ++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp135f-dk.dts b/arch/arm/boot/dts/stm32mp135f-dk.dts
index 02ff2bc664da..b8a4f1a8820d 100644
--- a/arch/arm/boot/dts/stm32mp135f-dk.dts
+++ b/arch/arm/boot/dts/stm32mp135f-dk.dts
@@ -95,6 +95,28 @@ &i2c1 {
/* spare dmas for other usage */
/delete-property/dmas;
/delete-property/dma-names;
+
+ typec@53 {
+ compatible = "st,stm32g0-typec";
+ reg = <0x53>;
+ /* Alert pin on PI2 */
+ interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
+ interrupt-parent = <&gpioi>;
+ /* Internal pull-up on PI2 */
+ pinctrl-names = "default";
+ pinctrl-0 = <&stm32g0_intn_pins_a>;
+ firmware-name = "stm32g0-ucsi.mp135f-dk.fw";
+ connector {
+ compatible = "usb-c-connector";
+ label = "USB-C";
+
+ port {
+ con_usb_c_g0_ep: endpoint {
+ remote-endpoint = <&usbotg_hs_ep>;
+ };
+ };
+ };
+ };
};

&i2c5 {
@@ -158,6 +180,18 @@ hub@1 {
};
};

+&usbotg_hs {
+ phys = <&usbphyc_port1 0>;
+ phy-names = "usb2-phy";
+ usb-role-switch;
+ status = "okay";
+ port {
+ usbotg_hs_ep: endpoint {
+ remote-endpoint = <&con_usb_c_g0_ep>;
+ };
+ };
+};
+
&usbphyc {
status = "okay";
};
--
2.25.1

2022-10-14 14:39:05

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 05/10] ARM: dts: stm32: add fixed regulators to support usb on stm32mp135f-dk

Add VDD_USB and 3V3_SW regulators on stm32mp135f-dk. Temporary add them
as fixed regulators, waiting for full SCMI regulators support.

This is a precursor patch to enable USB support on STM32MP13:
- VDD_USB supplies the STM32MP13 USB internals
- 3V3_SW supplies various peripherals, including the onboard HUB.
Note: USB support requires these regulators to be enabled before
entering the kernel.

Signed-off-by: Fabrice Gasnier <[email protected]>
---
arch/arm/boot/dts/stm32mp135f-dk.dts | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp135f-dk.dts b/arch/arm/boot/dts/stm32mp135f-dk.dts
index de341d17e87d..291f05a958fd 100644
--- a/arch/arm/boot/dts/stm32mp135f-dk.dts
+++ b/arch/arm/boot/dts/stm32mp135f-dk.dts
@@ -66,6 +66,22 @@ vdd_sd: vdd-sd {
regulator-max-microvolt = <2900000>;
regulator-always-on;
};
+
+ vdd_usb: vdd-usb {
+ compatible = "regulator-fixed";
+ regulator-name = "vdd_usb";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ };
+
+ v3v3_sw: v3v3-sw {
+ compatible = "regulator-fixed";
+ regulator-name = "v3v3_sw";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ };
};

&i2c1 {
--
2.25.1

2022-10-14 14:47:45

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH v2 10/10] ARM: multi_v7_defconfig: enable Type-C UCSI and STM32G0 as modules

Enable the USB Type-C UCSI, and the STM32G0 UCSI drivers as modules, since
used on STM32MP13 board.

Signed-off-by: Fabrice Gasnier <[email protected]>
---
arch/arm/configs/multi_v7_defconfig | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 12b35008571f..d391f8216eea 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -899,6 +899,8 @@ CONFIG_USB_CONFIGFS_F_UVC=y
CONFIG_USB_CONFIGFS_F_PRINTER=y
CONFIG_USB_ETH=m
CONFIG_TYPEC=m
+CONFIG_TYPEC_UCSI=m
+CONFIG_UCSI_STM32G0=m
CONFIG_TYPEC_STUSB160X=m
CONFIG_MMC=y
CONFIG_MMC_BLOCK_MINORS=16
--
2.25.1

2022-10-24 10:07:16

by Alexandre TORGUE

[permalink] [raw]
Subject: Re: [PATCH v2 00/10] Add support for USB on STM32MP13

Hi Fabrice

On 10/14/22 16:14, Fabrice Gasnier wrote:
> Add support for USBPHYC, USB Host and USB OTG on STM32MP13.
> Enable all these interfaces on STM32MP135F-DK board.
> Enable the STM32G0 UCSI driver as module.
> Dependency on PWR and PMIC regulator is tempoarily managed by using
> fixed regulators (resp in the SoC dtsi and the board dts files).
> The USB support is functional when these regulators gets enabled at
> boot time before entering the kernel.
>
> Changes in v2:
> Adopt "usb" and "typec" generic node names
>
> Amelie Delaunay (5):
> ARM: dts: stm32: add USBPHYC and dual USB HS PHY support on stm32mp131
> ARM: dts: stm32: add UBSH EHCI and OHCI support on stm32mp131
> ARM: dts: stm32: add USB OTG HS support on stm32mp131
> ARM: dts: stm32: enable USB HS phys on stm32mp135f-dk
> ARM: dts: stm32: enable USB Host EHCI on stm32mp135f-dk
>
> Fabrice Gasnier (5):
> ARM: dts: stm32: add PWR fixed regulators on stm32mp131
> ARM: dts: stm32: add fixed regulators to support usb on stm32mp135f-dk
> ARM: dts: stm32: add pins for stm32g0 typec controller on stm32mp13
> ARM: dts: stm32: enable USB OTG in dual role mode on stm32mp135f-dk
> ARM: multi_v7_defconfig: enable Type-C UCSI and STM32G0 as modules
>
> arch/arm/boot/dts/stm32mp13-pinctrl.dtsi | 7 ++
> arch/arm/boot/dts/stm32mp131.dtsi | 81 ++++++++++++++++++++
> arch/arm/boot/dts/stm32mp135f-dk.dts | 95 ++++++++++++++++++++++++
> arch/arm/configs/multi_v7_defconfig | 2 +
> 4 files changed, 185 insertions(+)
>

Series applied on stm32-next.

Cheers
Alex