Skip to contentSkip to conversation

rockchip: Fixes and updates for RK3528

PATCH In review Jonas Karlman 2 participants 17 messages Jul 30, 2025 – Aug 30, 2025

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover rockchip: Fixes and updates for RK3528

This series fixes a boot loop caused by recent dts/upstream v6.16-dts sync, include cleanup of sdmmc nodes and add needed init-microvolt props for pwm-regulatore, changes needed thanks to the same v6.16-dts sync.

It also adds more preparation to support USB features in U-Boot once pending Linux USB DT nodes lands in a future sync of dts/upstream.

Patch 1-3 includes device tree changes for recent dts/upstream sync.

Patch 4-8 prepare U-Boot for USB host/gadget support on RK3528 after a future dts/upstream sync.

Jianwei Zheng (1):
phy: rockchip: naneng-combphy: Add support for RK3528

Jonas Karlman (7):
rockchip: rk3528-generic: Fix boot after dts/upstream v6.16-dts merge
arm: dts: rockchip: Use sdmmc node from dts/upstream on RK3528
arm: dts: rockchip: Set init-microvolt for pwm-regulators on Radxa

    E20C

rockchip: rk3528: Disable USB3OTG U3 port early
rockchip: clk: clk_rk3528: Add dummy CLK_REF_PCIE_INNER_PHY support
usb: dwc3-generic: Use combined glue and ctrl node for RK3528
rockchip: rk3528-radxa-e20c: Enable USB gadget Kconfig options

 arch/arm/dts/rk3528-generic-u-boot.dtsi       |   9 --
 arch/arm/dts/rk3528-generic.dts               |  17 ++-
 arch/arm/dts/rk3528-radxa-e20c-u-boot.dtsi    |  13 ++-
 arch/arm/dts/rk3528-u-boot.dtsi               |  18 ----
 arch/arm/mach-rockchip/rk3528/rk3528.c        |   6 ++
 configs/radxa-e20c-rk3528_defconfig           |  10 ++
 drivers/clk/rockchip/clk_rk3528.c             |   1 +
 .../rockchip/phy-rockchip-naneng-combphy.c    | 102 ++++++++++++++++++
 drivers/usb/dwc3/dwc3-generic.c               |   1 +
 9 files changed, 142 insertions(+), 35 deletions(-)
Signature · 1 line
2.50.1
#1 lore raw

PATCH 1/8 rockchip: rk3528-generic: Fix boot after dts/upstream v6.16-dts merge

The rk3528-generic target can no longer boot after v6.16-dts was merged into dts/upstream, and instead end up in a boot loop:

No serial driver found
resetting ...

After Linux commit 34d2730fbbdd ("arm64: dts: rockchip: move rk3528 i2c+uart aliases to board files") there is no longer an alias for serial0 defined for the U-Boot only rk3528-generic device tree.

Add a board specific aliases node that include the missing serial0 alias to resolve the boot issue and ensure that stdout-path = "serial0:..." can be resolved by U-Boot.

---
 arch/arm/dts/rk3528-generic.dts | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/dts/rk3528-generic.dts +5 -0
index 3f6f0bed108d..fe9e72c41cd7 100644
@@ -10,6 +10,11 @@
 	model = "Generic RK3528";
 	compatible = "rockchip,rk3528";
 
+	aliases {
+		mmc0 = &sdhci;
+		serial0 = &uart0;
+	};
+
 	chosen {
 		stdout-path = "serial0:1500000n8";
 	};
Signature · 1 line
2.50.1
Reviewed-by on v1 1/8
#2 lore raw

Re: [PATCH 1/8] rockchip: rk3528-generic: Fix boot after dts/upstream v6.16-dts merge

Quoted 10 lines · Jonas Karlman

The rk3528-generic target can no longer boot after v6.16-dts was merged into dts/upstream, and instead end up in a boot loop:

No serial driver found
resetting ...

After Linux commit 34d2730fbbdd ("arm64: dts: rockchip: move rk3528 i2c+uart aliases to board files") there is no longer an alias for serial0 defined for the U-Boot only rk3528-generic device tree.

Quoted 5 lines

Add a board specific aliases node that include the missing serial0 alias to resolve the boot issue and ensure that stdout-path = "serial0:..." can be resolved by U-Boot.

Thanks,
- Kever

Quoted 20 lines
---
  arch/arm/dts/rk3528-generic.dts | 5 +++++
  1 file changed, 5 insertions(+)
arch/arm/dts/rk3528-generic.dts +5 -0
index 3f6f0bed108d..fe9e72c41cd7 100644
@@ -10,6 +10,11 @@
  	model = "Generic RK3528";
  	compatible = "rockchip,rk3528";
 
+	aliases {
+		mmc0 = &sdhci;
+		serial0 = &uart0;
+	};
+
  	chosen {
  		stdout-path = "serial0:1500000n8";
  	};
#3 lore raw

PATCH 2/8 arm: dts: rockchip: Use sdmmc node from dts/upstream on RK3528

In reply to Jonas Karlman

Drop the sdmmc node from soc u-boot.dtsi and instead use the sdmmc node from rk3528.dtsi with v6.16-dts now merged to dts/upstream.

This cleanup has no intended functional change.

---
 arch/arm/dts/rk3528-generic-u-boot.dtsi    |  9 ---------
 arch/arm/dts/rk3528-generic.dts            | 12 +++++++++++-
 arch/arm/dts/rk3528-radxa-e20c-u-boot.dtsi |  9 ---------
 arch/arm/dts/rk3528-u-boot.dtsi            | 18 ------------------
 4 files changed, 11 insertions(+), 37 deletions(-)
arch/arm/dts/rk3528-generic-u-boot.dtsi +0 -9
index cc830b514567..9e1fb2a7eef6 100644
@@ -1,12 +1,3 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 
 #include "rk3528-u-boot.dtsi"
-
-&sdmmc {
-	bus-width = <4>;
-	cap-sd-highspeed;
-	disable-wp;
-	no-mmc;
-	no-sdio;
-	status = "okay";
-};
arch/arm/dts/rk3528-generic.dts +11 -1
index fe9e72c41cd7..637ca03325ed 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 /*
- * Minimal generic DT for RK3528 with eMMC enabled
+ * Minimal generic DT for RK3528 with eMMC and SD-card enabled
  */
 
 /dts-v1/;
@@ -12,6 +12,7 @@
 
 	aliases {
 		mmc0 = &sdhci;
+		mmc1 = &sdmmc;
 		serial0 = &uart0;
 	};
 
@@ -30,6 +31,15 @@
 	status = "okay";
 };
 
+&sdmmc {
+	bus-width = <4>;
+	cap-sd-highspeed;
+	disable-wp;
+	no-mmc;
+	no-sdio;
+	status = "okay";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0m0_xfer>;
arch/arm/dts/rk3528-radxa-e20c-u-boot.dtsi +0 -9
index 1372d8f1e38a..05a58c136bcd 100644
@@ -5,12 +5,3 @@
 &sdhci {
 	mmc-hs200-1_8v;
 };
-
-&sdmmc {
-	bus-width = <4>;
-	cap-mmc-highspeed;
-	cap-sd-highspeed;
-	disable-wp;
-	vmmc-supply = <&vcc_3v3>;
-	status = "okay";
-};
arch/arm/dts/rk3528-u-boot.dtsi +0 -18
index eb6a55cd5c93..a18d33b3d369 100644
@@ -27,24 +27,6 @@
 			compatible = "rockchip,rk3528-otp";
 			reg = <0x0 0xffce0000 0x0 0x4000>;
 		};
-
-		sdmmc: mmc@ffc30000 {
-			compatible = "rockchip,rk3528-dw-mshc",
-				     "rockchip,rk3288-dw-mshc";
-			reg = <0x0 0xffc30000 0x0 0x4000>;
-			clocks = <&cru HCLK_SDMMC0>, <&cru CCLK_SRC_SDMMC0>;
-			clock-names = "biu", "ciu";
-			fifo-depth = <0x100>;
-			interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>;
-			max-frequency = <150000000>;
-			pinctrl-names = "default";
-			pinctrl-0 = <&sdmmc_bus4>, <&sdmmc_clk>, <&sdmmc_cmd>,
-				    <&sdmmc_det>;
-			resets = <&cru SRST_H_SDMMC0>;
-			reset-names = "reset";
-			rockchip,default-sample-phase = <90>;
-			status = "disabled";
-		};
 	};
 };
 
Signature · 1 line
2.50.1
Reviewed-by on v1 2/8
#4 lore raw

Re: [PATCH 2/8] arm: dts: rockchip: Use sdmmc node from dts/upstream on RK3528

Quoted 6 lines · Jonas Karlman

Drop the sdmmc node from soc u-boot.dtsi and instead use the sdmmc node from rk3528.dtsi with v6.16-dts now merged to dts/upstream.

This cleanup has no intended functional change.

Thanks,
- Kever

Quoted 106 lines
---
  arch/arm/dts/rk3528-generic-u-boot.dtsi    |  9 ---------
  arch/arm/dts/rk3528-generic.dts            | 12 +++++++++++-
  arch/arm/dts/rk3528-radxa-e20c-u-boot.dtsi |  9 ---------
  arch/arm/dts/rk3528-u-boot.dtsi            | 18 ------------------
  4 files changed, 11 insertions(+), 37 deletions(-)
arch/arm/dts/rk3528-generic-u-boot.dtsi +0 -9
index cc830b514567..9e1fb2a7eef6 100644
@@ -1,12 +1,3 @@
  // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 
  #include "rk3528-u-boot.dtsi"
-
-&sdmmc {
-	bus-width = <4>;
-	cap-sd-highspeed;
-	disable-wp;
-	no-mmc;
-	no-sdio;
-	status = "okay";
-};
arch/arm/dts/rk3528-generic.dts +11 -1
index fe9e72c41cd7..637ca03325ed 100644
@@ -1,6 +1,6 @@
  // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  /*
- * Minimal generic DT for RK3528 with eMMC enabled
+ * Minimal generic DT for RK3528 with eMMC and SD-card enabled
   */
 
  /dts-v1/;
@@ -12,6 +12,7 @@
 
  	aliases {
  		mmc0 = &sdhci;
+		mmc1 = &sdmmc;
  		serial0 = &uart0;
  	};
 
@@ -30,6 +31,15 @@
  	status = "okay";
  };
 
+&sdmmc {
+	bus-width = <4>;
+	cap-sd-highspeed;
+	disable-wp;
+	no-mmc;
+	no-sdio;
+	status = "okay";
+};
+
  &uart0 {
  	pinctrl-names = "default";
  	pinctrl-0 = <&uart0m0_xfer>;
arch/arm/dts/rk3528-radxa-e20c-u-boot.dtsi +0 -9
index 1372d8f1e38a..05a58c136bcd 100644
@@ -5,12 +5,3 @@
  &sdhci {
  	mmc-hs200-1_8v;
  };
-
-&sdmmc {
-	bus-width = <4>;
-	cap-mmc-highspeed;
-	cap-sd-highspeed;
-	disable-wp;
-	vmmc-supply = <&vcc_3v3>;
-	status = "okay";
-};
arch/arm/dts/rk3528-u-boot.dtsi +0 -18
index eb6a55cd5c93..a18d33b3d369 100644
@@ -27,24 +27,6 @@
  			compatible = "rockchip,rk3528-otp";
  			reg = <0x0 0xffce0000 0x0 0x4000>;
  		};
-
-		sdmmc: mmc@ffc30000 {
-			compatible = "rockchip,rk3528-dw-mshc",
-				     "rockchip,rk3288-dw-mshc";
-			reg = <0x0 0xffc30000 0x0 0x4000>;
-			clocks = <&cru HCLK_SDMMC0>, <&cru CCLK_SRC_SDMMC0>;
-			clock-names = "biu", "ciu";
-			fifo-depth = <0x100>;
-			interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>;
-			max-frequency = <150000000>;
-			pinctrl-names = "default";
-			pinctrl-0 = <&sdmmc_bus4>, <&sdmmc_clk>, <&sdmmc_cmd>,
-				    <&sdmmc_det>;
-			resets = <&cru SRST_H_SDMMC0>;
-			reset-names = "reset";
-			rockchip,default-sample-phase = <90>;
-			status = "disabled";
-		};
  	};
  };
 
#5 lore raw

PATCH 3/8 arm: dts: rockchip: Set init-microvolt for pwm-regulators on Radxa E20C

In reply to Jonas Karlman

Radxa E20C has two main pwm-regulators, vdd_arm and vdd_logic.

Add init-microvolt props to ensure the regulators are initialized at the recommended power-on sequence voltage instead of at max voltage.

---
 arch/arm/dts/rk3528-radxa-e20c-u-boot.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/dts/rk3528-radxa-e20c-u-boot.dtsi +8 -0
index 05a58c136bcd..16c47e6b9a9e 100644
@@ -5,3 +5,11 @@
 &sdhci {
 	mmc-hs200-1_8v;
 };
+
+&vdd_arm {
+	regulator-init-microvolt = <953000>;
+};
+
+&vdd_logic {
+	regulator-init-microvolt = <900000>;
+};
Signature · 1 line
2.50.1
Reviewed-by on v1 3/8
#6 lore raw

Re: [PATCH 3/8] arm: dts: rockchip: Set init-microvolt for pwm-regulators on Radxa E20C

Quoted 6 lines · Jonas Karlman

Radxa E20C has two main pwm-regulators, vdd_arm and vdd_logic.

Add init-microvolt props to ensure the regulators are initialized at the recommended power-on sequence voltage instead of at max voltage.

Thanks,
- Kever

Quoted 20 lines
---
  arch/arm/dts/rk3528-radxa-e20c-u-boot.dtsi | 8 ++++++++
  1 file changed, 8 insertions(+)
arch/arm/dts/rk3528-radxa-e20c-u-boot.dtsi +8 -0
index 05a58c136bcd..16c47e6b9a9e 100644
@@ -5,3 +5,11 @@
  &sdhci {
  	mmc-hs200-1_8v;
  };
+
+&vdd_arm {
+	regulator-init-microvolt = <953000>;
+};
+
+&vdd_logic {
+	regulator-init-microvolt = <900000>;
+};
#7 lore raw

PATCH 4/8 rockchip: rk3528: Disable USB3OTG U3 port early

In reply to Jonas Karlman

The RK3528 SoC comes with USB OTG support using a DWC3 controller with a USB2 PHY and a USB3 PHY (COMBPHY).

Some board designs may not use the COMBPHY for USB3 purpose. For these board to use USB OTG the input clock source must change to use UTMI clk instead of PIPE clk.

Change to always disable the USB3OTG U3 port early and leave it to the COMBPHY driver to re-enable the U3 port when a usb3-phy is described in the board device tree.

---
 arch/arm/mach-rockchip/rk3528/rk3528.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-rockchip/rk3528/rk3528.c +6 -0
index 4892ff6ba9d2..f9bfc445b857 100644
@@ -9,6 +9,9 @@
 #include <asm/arch-rockchip/bootrom.h>
 #include <asm/arch-rockchip/hardware.h>
 
+#define VPU_GRF_BASE			0xff340000
+#define USB3OTG_CON1			0x44
+
 #define FIREWALL_DDR_BASE		0xff2e0000
 #define FW_DDR_MST6_REG			0x58
 #define FW_DDR_MST7_REG			0x5c
@@ -69,6 +72,9 @@ int arch_cpu_init(void)
 	val = readl(FIREWALL_DDR_BASE + FW_DDR_MST16_REG);
 	writel(val & 0xffff0000, FIREWALL_DDR_BASE + FW_DDR_MST16_REG);
 
+	/* Disable USB3OTG U3 port, later enabled in COMBPHY driver */
+	writel(0xffff0181, VPU_GRF_BASE + USB3OTG_CON1);
+
 	return 0;
 }
 
Signature · 1 line
2.50.1
Reviewed-by on v1 4/8
#8 lore raw

Re: [PATCH 4/8] rockchip: rk3528: Disable USB3OTG U3 port early

Quoted 7 lines · Jonas Karlman

The RK3528 SoC comes with USB OTG support using a DWC3 controller with a USB2 PHY and a USB3 PHY (COMBPHY).

Some board designs may not use the COMBPHY for USB3 purpose. For these board to use USB OTG the input clock source must change to use UTMI clk instead of PIPE clk.

Quoted 5 lines

Change to always disable the USB3OTG U3 port early and leave it to the COMBPHY driver to re-enable the U3 port when a usb3-phy is described in the board device tree.

Thanks,
- Kever

Quoted 28 lines
---
  arch/arm/mach-rockchip/rk3528/rk3528.c | 6 ++++++
  1 file changed, 6 insertions(+)
arch/arm/mach-rockchip/rk3528/rk3528.c +6 -0
index 4892ff6ba9d2..f9bfc445b857 100644
@@ -9,6 +9,9 @@
  #include <asm/arch-rockchip/bootrom.h>
  #include <asm/arch-rockchip/hardware.h>
 
+#define VPU_GRF_BASE			0xff340000
+#define USB3OTG_CON1			0x44
+
  #define FIREWALL_DDR_BASE		0xff2e0000
  #define FW_DDR_MST6_REG			0x58
  #define FW_DDR_MST7_REG			0x5c
@@ -69,6 +72,9 @@ int arch_cpu_init(void)
  	val = readl(FIREWALL_DDR_BASE + FW_DDR_MST16_REG);
  	writel(val & 0xffff0000, FIREWALL_DDR_BASE + FW_DDR_MST16_REG);
 
+	/* Disable USB3OTG U3 port, later enabled in COMBPHY driver */
+	writel(0xffff0181, VPU_GRF_BASE + USB3OTG_CON1);
+
  	return 0;
  }
 
#9 lore raw

PATCH 5/8 rockchip: clk: clk_rk3528: Add dummy CLK_REF_PCIE_INNER_PHY support

In reply to Jonas Karlman

Add dummy support for the CLK_REF_PCIE_INNER_PHY clock to allow probe of the phy-rockchip-naneng-combphy driver on RK3528.

---
 drivers/clk/rockchip/clk_rk3528.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/rockchip/clk_rk3528.c +1 -0
index 06f20895accf..d58557ff56de 100644
@@ -1535,6 +1535,7 @@ static ulong rk3528_clk_set_rate(struct clk *clk, ulong rate)
 	/* Might occur in cru assigned-clocks, can be ignored here */
 	case ACLK_BUS_VOPGL_ROOT:
 	case BCLK_EMMC:
+	case CLK_REF_PCIE_INNER_PHY:
 	case XIN_OSC0_DIV:
 		ret = 0;
 		break;
Signature · 1 line
2.50.1
Reviewed-by on v1 5/8
#10 lore raw

Re: [PATCH 5/8] rockchip: clk: clk_rk3528: Add dummy CLK_REF_PCIE_INNER_PHY support

Quoted 4 lines · Jonas Karlman

Add dummy support for the CLK_REF_PCIE_INNER_PHY clock to allow probe of the phy-rockchip-naneng-combphy driver on RK3528.

Thanks,
- Kever

Quoted 16 lines
---
  drivers/clk/rockchip/clk_rk3528.c | 1 +
  1 file changed, 1 insertion(+)
drivers/clk/rockchip/clk_rk3528.c +1 -0
index 06f20895accf..d58557ff56de 100644
@@ -1535,6 +1535,7 @@ static ulong rk3528_clk_set_rate(struct clk *clk, ulong rate)
  	/* Might occur in cru assigned-clocks, can be ignored here */
  	case ACLK_BUS_VOPGL_ROOT:
  	case BCLK_EMMC:
+	case CLK_REF_PCIE_INNER_PHY:
  	case XIN_OSC0_DIV:
  		ret = 0;
  		break;
#11 lore raw

PATCH 6/8 usb: dwc3-generic: Use combined glue and ctrl node for RK3528

In reply to Jonas Karlman

Like Rockchip RK3328, RK3568 and RK3588, the RK3528 also have a single node to represent the glue and ctrl for USB 3.0.

Use rk_ops as driver data to select correct ctrl node for RK3528 DWC3.

---
 drivers/usb/dwc3/dwc3-generic.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/dwc3/dwc3-generic.c +1 -0
index 3cda2b74b7e3..6b2016c0cd37 100644
@@ -698,6 +698,7 @@ static const struct udevice_id dwc3_glue_ids[] = {
 	{ .compatible = "ti,am654-dwc3" },
 	{ .compatible = "rockchip,rk3328-dwc3", .data = (ulong)&rk_ops },
 	{ .compatible = "rockchip,rk3399-dwc3" },
+	{ .compatible = "rockchip,rk3528-dwc3", .data = (ulong)&rk_ops },
 	{ .compatible = "rockchip,rk3568-dwc3", .data = (ulong)&rk_ops },
 	{ .compatible = "rockchip,rk3588-dwc3", .data = (ulong)&rk_ops },
 	{ .compatible = "qcom,dwc3", .data = (ulong)&qcom_ops },
Signature · 1 line
2.50.1
Reviewed-by on v1 6/8
#12 lore raw

Re: [PATCH 6/8] usb: dwc3-generic: Use combined glue and ctrl node for RK3528

Quoted 6 lines · Jonas Karlman

Like Rockchip RK3328, RK3568 and RK3588, the RK3528 also have a single node to represent the glue and ctrl for USB 3.0.

Use rk_ops as driver data to select correct ctrl node for RK3528 DWC3.

Thanks,
- Kever

Quoted 16 lines
---
  drivers/usb/dwc3/dwc3-generic.c | 1 +
  1 file changed, 1 insertion(+)
drivers/usb/dwc3/dwc3-generic.c +1 -0
index 3cda2b74b7e3..6b2016c0cd37 100644
@@ -698,6 +698,7 @@ static const struct udevice_id dwc3_glue_ids[] = {
  	{ .compatible = "ti,am654-dwc3" },
  	{ .compatible = "rockchip,rk3328-dwc3", .data = (ulong)&rk_ops },
  	{ .compatible = "rockchip,rk3399-dwc3" },
+	{ .compatible = "rockchip,rk3528-dwc3", .data = (ulong)&rk_ops },
  	{ .compatible = "rockchip,rk3568-dwc3", .data = (ulong)&rk_ops },
  	{ .compatible = "rockchip,rk3588-dwc3", .data = (ulong)&rk_ops },
  	{ .compatible = "qcom,dwc3", .data = (ulong)&qcom_ops },
#13 lore raw

PATCH 7/8 phy: rockchip: naneng-combphy: Add support for RK3528

In reply to Jonas Karlman

From: Jianwei Zheng <[email protected]>

Add support for the PCIe/USB3 combo PHY used in the RK3528 SoC.

Config values are taken from vendor U-Boot linux-6.1-stan-rkr5 tag.

---
 .../rockchip/phy-rockchip-naneng-combphy.c    | 102 ++++++++++++++++++
 1 file changed, 102 insertions(+)
drivers/phy/rockchip/phy-rockchip-naneng-combphy.c +102 -0
index 81195de60bc6..432a8f8e03a0 100644
@@ -37,6 +37,7 @@ struct rockchip_combphy_grfcfg {
 	struct combphy_reg pipe_rxterm_set;
 	struct combphy_reg pipe_txelec_set;
 	struct combphy_reg pipe_txcomp_set;
+	struct combphy_reg pipe_clk_24m;
 	struct combphy_reg pipe_clk_25m;
 	struct combphy_reg pipe_clk_100m;
 	struct combphy_reg pipe_phymode_sel;
@@ -245,6 +246,103 @@ static int rockchip_combphy_probe(struct udevice *udev)
 	return rockchip_combphy_parse_dt(udev, priv);
 }
 
+static int rk3528_combphy_cfg(struct rockchip_combphy_priv *priv)
+{
+	const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
+	u32 val;
+
+	switch (priv->mode) {
+	case PHY_TYPE_PCIE:
+		/* Set SSC downward spread spectrum */
+		val = readl(priv->mmio + 0x18);
+		val &= ~GENMASK(5, 4);
+		val |= 0x01 << 4;
+		writel(val, priv->mmio + 0x18);
+
+		param_write(priv->phy_grf, &cfg->con0_for_pcie, true);
+		param_write(priv->phy_grf, &cfg->con1_for_pcie, true);
+		param_write(priv->phy_grf, &cfg->con2_for_pcie, true);
+		param_write(priv->phy_grf, &cfg->con3_for_pcie, true);
+		break;
+	case PHY_TYPE_USB3:
+		/* Set SSC downward spread spectrum */
+		val = readl(priv->mmio + 0x18);
+		val &= ~GENMASK(5, 4);
+		val |= 0x01 << 4;
+		writel(val, priv->mmio + 0x18);
+
+		/* Enable adaptive CTLE for USB3.0 Rx */
+		val = readl(priv->mmio + 0x200);
+		val &= ~GENMASK(17, 17);
+		val |= 0x01 << 17;
+		writel(val, priv->mmio + 0x200);
+
+		/* Set Rx squelch input filler bandwidth */
+		val = readl(priv->mmio + 0x20c);
+		val &= ~GENMASK(2, 0);
+		val |= 0x06;
+		writel(val, priv->mmio + 0x20c);
+
+		param_write(priv->phy_grf, &cfg->pipe_txcomp_sel, false);
+		param_write(priv->phy_grf, &cfg->pipe_txelec_sel, false);
+		param_write(priv->phy_grf, &cfg->usb_mode_set, true);
+		param_write(priv->pipe_grf, &cfg->u3otg0_port_en, true);
+		break;
+	default:
+		dev_err(priv->dev, "incompatible PHY type\n");
+		return -EINVAL;
+	}
+
+	param_write(priv->phy_grf, &cfg->pipe_clk_100m, true);
+
+	if (priv->mode == PHY_TYPE_PCIE) {
+		/* PLL KVCO tuning fine */
+		val = readl(priv->mmio + 0x18);
+		val &= ~(0x7 << 10);
+		val |= 0x2 << 10;
+		writel(val, priv->mmio + 0x18);
+
+		/* su_trim[6:4]=111, [10:7]=1001, [2:0]=000 */
+		val = readl(priv->mmio + 0x108);
+		val &= ~(0x7f7);
+		val |= 0x4f0;
+		writel(val, priv->mmio + 0x108);
+	}
+
+	return 0;
+}
+
+static const struct rockchip_combphy_grfcfg rk3528_combphy_grfcfgs = {
+	/* pipe-phy-grf */
+	.pcie_mode_set		= { 0x0000, 5, 0, 0x00, 0x11 },
+	.usb_mode_set		= { 0x0000, 5, 0, 0x00, 0x04 },
+	.pipe_rxterm_set	= { 0x0000, 12, 12, 0x00, 0x01 },
+	.pipe_txelec_set	= { 0x0004, 1, 1, 0x00, 0x01 },
+	.pipe_txcomp_set	= { 0x0004, 4, 4, 0x00, 0x01 },
+	.pipe_clk_24m		= { 0x0004, 14, 13, 0x00, 0x00 },
+	.pipe_clk_100m		= { 0x0004, 14, 13, 0x00, 0x02 },
+	.pipe_rxterm_sel	= { 0x0008, 8, 8, 0x00, 0x01 },
+	.pipe_txelec_sel	= { 0x0008, 12, 12, 0x00, 0x01 },
+	.pipe_txcomp_sel	= { 0x0008, 15, 15, 0x00, 0x01 },
+	.pipe_clk_ext		= { 0x000c, 9, 8, 0x02, 0x01 },
+	.pipe_phy_status	= { 0x0034, 6, 6, 0x01, 0x00 },
+	.con0_for_pcie		= { 0x0000, 15, 0, 0x00, 0x110 },
+	.con1_for_pcie		= { 0x0004, 15, 0, 0x00, 0x00 },
+	.con2_for_pcie		= { 0x0008, 15, 0, 0x00, 0x101 },
+	.con3_for_pcie		= { 0x000c, 15, 0, 0x00, 0x0200 },
+	/* pipe-grf */
+	.u3otg0_port_en		= { 0x0044, 15, 0, 0x0181, 0x1100 },
+};
+
+static const struct rockchip_combphy_cfg rk3528_combphy_cfgs = {
+	.num_phys = 1,
+	.phy_ids = {
+		0xffdc0000,
+	},
+	.grfcfg		= &rk3528_combphy_grfcfgs,
+	.combphy_cfg	= rk3528_combphy_cfg,
+};
+
 static int rk3568_combphy_cfg(struct rockchip_combphy_priv *priv)
 {
 	const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
@@ -503,6 +601,10 @@ static const struct rockchip_combphy_cfg rk3588_combphy_cfgs = {
 };
 
 static const struct udevice_id rockchip_combphy_ids[] = {
+	{
+		.compatible = "rockchip,rk3528-naneng-combphy",
+		.data = (ulong)&rk3528_combphy_cfgs
+	},
 	{
 		.compatible = "rockchip,rk3568-naneng-combphy",
 		.data = (ulong)&rk3568_combphy_cfgs
Signature · 1 line
2.50.1
Reviewed-by on v1 7/8
#14 lore raw

Re: [PATCH 7/8] phy: rockchip: naneng-combphy: Add support for RK3528

Quoted 8 lines · Jonas Karlman

From: Jianwei Zheng <[email protected]>

Add support for the PCIe/USB3 combo PHY used in the RK3528 SoC.

Config values are taken from vendor U-Boot linux-6.1-stan-rkr5 tag.

Thanks,
- Kever

Quoted 131 lines
---
  .../rockchip/phy-rockchip-naneng-combphy.c    | 102 ++++++++++++++++++
  1 file changed, 102 insertions(+)
drivers/phy/rockchip/phy-rockchip-naneng-combphy.c +102 -0
index 81195de60bc6..432a8f8e03a0 100644
@@ -37,6 +37,7 @@ struct rockchip_combphy_grfcfg {
  	struct combphy_reg pipe_rxterm_set;
  	struct combphy_reg pipe_txelec_set;
  	struct combphy_reg pipe_txcomp_set;
+	struct combphy_reg pipe_clk_24m;
  	struct combphy_reg pipe_clk_25m;
  	struct combphy_reg pipe_clk_100m;
  	struct combphy_reg pipe_phymode_sel;
@@ -245,6 +246,103 @@ static int rockchip_combphy_probe(struct udevice *udev)
  	return rockchip_combphy_parse_dt(udev, priv);
  }
 
+static int rk3528_combphy_cfg(struct rockchip_combphy_priv *priv)
+{
+	const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
+	u32 val;
+
+	switch (priv->mode) {
+	case PHY_TYPE_PCIE:
+		/* Set SSC downward spread spectrum */
+		val = readl(priv->mmio + 0x18);
+		val &= ~GENMASK(5, 4);
+		val |= 0x01 << 4;
+		writel(val, priv->mmio + 0x18);
+
+		param_write(priv->phy_grf, &cfg->con0_for_pcie, true);
+		param_write(priv->phy_grf, &cfg->con1_for_pcie, true);
+		param_write(priv->phy_grf, &cfg->con2_for_pcie, true);
+		param_write(priv->phy_grf, &cfg->con3_for_pcie, true);
+		break;
+	case PHY_TYPE_USB3:
+		/* Set SSC downward spread spectrum */
+		val = readl(priv->mmio + 0x18);
+		val &= ~GENMASK(5, 4);
+		val |= 0x01 << 4;
+		writel(val, priv->mmio + 0x18);
+
+		/* Enable adaptive CTLE for USB3.0 Rx */
+		val = readl(priv->mmio + 0x200);
+		val &= ~GENMASK(17, 17);
+		val |= 0x01 << 17;
+		writel(val, priv->mmio + 0x200);
+
+		/* Set Rx squelch input filler bandwidth */
+		val = readl(priv->mmio + 0x20c);
+		val &= ~GENMASK(2, 0);
+		val |= 0x06;
+		writel(val, priv->mmio + 0x20c);
+
+		param_write(priv->phy_grf, &cfg->pipe_txcomp_sel, false);
+		param_write(priv->phy_grf, &cfg->pipe_txelec_sel, false);
+		param_write(priv->phy_grf, &cfg->usb_mode_set, true);
+		param_write(priv->pipe_grf, &cfg->u3otg0_port_en, true);
+		break;
+	default:
+		dev_err(priv->dev, "incompatible PHY type\n");
+		return -EINVAL;
+	}
+
+	param_write(priv->phy_grf, &cfg->pipe_clk_100m, true);
+
+	if (priv->mode == PHY_TYPE_PCIE) {
+		/* PLL KVCO tuning fine */
+		val = readl(priv->mmio + 0x18);
+		val &= ~(0x7 << 10);
+		val |= 0x2 << 10;
+		writel(val, priv->mmio + 0x18);
+
+		/* su_trim[6:4]=111, [10:7]=1001, [2:0]=000 */
+		val = readl(priv->mmio + 0x108);
+		val &= ~(0x7f7);
+		val |= 0x4f0;
+		writel(val, priv->mmio + 0x108);
+	}
+
+	return 0;
+}
+
+static const struct rockchip_combphy_grfcfg rk3528_combphy_grfcfgs = {
+	/* pipe-phy-grf */
+	.pcie_mode_set		= { 0x0000, 5, 0, 0x00, 0x11 },
+	.usb_mode_set		= { 0x0000, 5, 0, 0x00, 0x04 },
+	.pipe_rxterm_set	= { 0x0000, 12, 12, 0x00, 0x01 },
+	.pipe_txelec_set	= { 0x0004, 1, 1, 0x00, 0x01 },
+	.pipe_txcomp_set	= { 0x0004, 4, 4, 0x00, 0x01 },
+	.pipe_clk_24m		= { 0x0004, 14, 13, 0x00, 0x00 },
+	.pipe_clk_100m		= { 0x0004, 14, 13, 0x00, 0x02 },
+	.pipe_rxterm_sel	= { 0x0008, 8, 8, 0x00, 0x01 },
+	.pipe_txelec_sel	= { 0x0008, 12, 12, 0x00, 0x01 },
+	.pipe_txcomp_sel	= { 0x0008, 15, 15, 0x00, 0x01 },
+	.pipe_clk_ext		= { 0x000c, 9, 8, 0x02, 0x01 },
+	.pipe_phy_status	= { 0x0034, 6, 6, 0x01, 0x00 },
+	.con0_for_pcie		= { 0x0000, 15, 0, 0x00, 0x110 },
+	.con1_for_pcie		= { 0x0004, 15, 0, 0x00, 0x00 },
+	.con2_for_pcie		= { 0x0008, 15, 0, 0x00, 0x101 },
+	.con3_for_pcie		= { 0x000c, 15, 0, 0x00, 0x0200 },
+	/* pipe-grf */
+	.u3otg0_port_en		= { 0x0044, 15, 0, 0x0181, 0x1100 },
+};
+
+static const struct rockchip_combphy_cfg rk3528_combphy_cfgs = {
+	.num_phys = 1,
+	.phy_ids = {
+		0xffdc0000,
+	},
+	.grfcfg		= &rk3528_combphy_grfcfgs,
+	.combphy_cfg	= rk3528_combphy_cfg,
+};
+
  static int rk3568_combphy_cfg(struct rockchip_combphy_priv *priv)
  {
  	const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
@@ -503,6 +601,10 @@ static const struct rockchip_combphy_cfg rk3588_combphy_cfgs = {
  };
 
  static const struct udevice_id rockchip_combphy_ids[] = {
+	{
+		.compatible = "rockchip,rk3528-naneng-combphy",
+		.data = (ulong)&rk3528_combphy_cfgs
+	},
  	{
  		.compatible = "rockchip,rk3568-naneng-combphy",
  		.data = (ulong)&rk3568_combphy_cfgs
#15 lore raw

PATCH 8/8 rockchip: rk3528-radxa-e20c: Enable USB gadget Kconfig options

In reply to Jonas Karlman

Radxa E20C has a USB OTG Type-C port for Debug and Data.

Add required Kconfig options to use USB gadget features once pending USB nodes finally lands in dts/upstream by a future sync.

---
USB nodes for RK3528 has not yet landed in linux-rockchip maintainer tree, however USB features have been verified working in U-Boot using current pending DT patches.

---
 configs/radxa-e20c-rk3528_defconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)
configs/radxa-e20c-rk3528_defconfig +10 -0
index f5e097f3edf8..0941d1b9be81 100644
@@ -20,6 +20,8 @@ CONFIG_CMD_GPT=y
 CONFIG_CMD_MISC=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_ROCKUSB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_RNG=y
 CONFIG_CMD_REGULATOR=y
@@ -28,6 +30,7 @@ CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigne
 CONFIG_BUTTON=y
 CONFIG_BUTTON_ADC=y
 CONFIG_BUTTON_GPIO=y
+# CONFIG_USB_FUNCTION_FASTBOOT is not set
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
@@ -43,6 +46,7 @@ CONFIG_DM_MDIO=y
 CONFIG_DWC_ETH_QOS=y
 CONFIG_DWC_ETH_QOS_ROCKCHIP=y
 CONFIG_PHY_ROCKCHIP_INNO_USB2=y
+CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y
 CONFIG_REGULATOR_PWM=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_PWM_ROCKCHIP=y
@@ -50,6 +54,12 @@ CONFIG_BAUDRATE=1500000
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYS_NS16550_MEM32=y
 CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_USB_FUNCTION_ROCKUSB=y
 CONFIG_ERRNO_STR=y
Signature · 1 line
2.50.1
Reviewed-by on v1 8/8
#16 lore raw

Re: [PATCH 8/8] rockchip: rk3528-radxa-e20c: Enable USB gadget Kconfig options

Quoted 6 lines · Jonas Karlman

Radxa E20C has a USB OTG Type-C port for Debug and Data.

Add required Kconfig options to use USB gadget features once pending USB nodes finally lands in dts/upstream by a future sync.

Thanks,
- Kever

Quoted 50 lines

---
USB nodes for RK3528 has not yet landed in linux-rockchip maintainer tree, however USB features have been verified working in U-Boot using current pending DT patches.

---
  configs/radxa-e20c-rk3528_defconfig | 10 ++++++++++
  1 file changed, 10 insertions(+)
configs/radxa-e20c-rk3528_defconfig +10 -0
index f5e097f3edf8..0941d1b9be81 100644
@@ -20,6 +20,8 @@ CONFIG_CMD_GPT=y
  CONFIG_CMD_MISC=y
  CONFIG_CMD_MMC=y
  CONFIG_CMD_USB=y
+CONFIG_CMD_ROCKUSB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
  # CONFIG_CMD_SETEXPR is not set
  CONFIG_CMD_RNG=y
  CONFIG_CMD_REGULATOR=y
@@ -28,6 +30,7 @@ CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigne
  CONFIG_BUTTON=y
  CONFIG_BUTTON_ADC=y
  CONFIG_BUTTON_GPIO=y
+# CONFIG_USB_FUNCTION_FASTBOOT is not set
  CONFIG_ROCKCHIP_GPIO=y
  CONFIG_LED=y
  CONFIG_LED_GPIO=y
@@ -43,6 +46,7 @@ CONFIG_DM_MDIO=y
  CONFIG_DWC_ETH_QOS=y
  CONFIG_DWC_ETH_QOS_ROCKCHIP=y
  CONFIG_PHY_ROCKCHIP_INNO_USB2=y
+CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y
  CONFIG_REGULATOR_PWM=y
  CONFIG_DM_REGULATOR_GPIO=y
  CONFIG_PWM_ROCKCHIP=y
@@ -50,6 +54,12 @@ CONFIG_BAUDRATE=1500000
  CONFIG_DEBUG_UART_SHIFT=2
  CONFIG_SYS_NS16550_MEM32=y
  CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
  CONFIG_USB_EHCI_HCD=y
  CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_USB_FUNCTION_ROCKUSB=y
  CONFIG_ERRNO_STR=y