uboot-rockchip: backport RK3576 support
Backport core support for RK3576 SoCs. Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org> Link: https://github.com/openwrt/openwrt/pull/20041 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
3c8f6e33df
commit
355528e427
@ -0,0 +1,73 @@
|
||||
From 1848a504379531eb726d29b355f9038d194e8430 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Shumsky <alexthreed@gmail.com>
|
||||
Date: Thu, 3 Jul 2025 09:04:48 +0300
|
||||
Subject: [PATCH] rockchip: rockchip-inno-usb2: Fix Synchronous Abort on usb
|
||||
start
|
||||
|
||||
Fix NULL pointer dereference that happen when rockchip-inno-usb2 clock
|
||||
enabled before device probe. This early clock enable call happen in process
|
||||
of parent clock activation added in ac30d90f3367.
|
||||
|
||||
Fixes: 229218373c22 ("phy: rockchip-inno-usb2: Add support for clkout_ctl_phy").
|
||||
Fixes: ac30d90f3367 ("clk: Ensure the parent clocks are enabled while reparenting")
|
||||
Co-authored-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Signed-off-by: Alex Shumsky <alexthreed@gmail.com>
|
||||
Reviewed-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 19 ++++++++++++++-----
|
||||
1 file changed, 14 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
@@ -167,20 +167,27 @@ static struct phy_ops rockchip_usb2phy_o
|
||||
.of_xlate = rockchip_usb2phy_of_xlate,
|
||||
};
|
||||
|
||||
-static void rockchip_usb2phy_clkout_ctl(struct clk *clk, struct regmap **base,
|
||||
- const struct usb2phy_reg **clkout_ctl)
|
||||
+static int rockchip_usb2phy_clkout_ctl(struct clk *clk, struct regmap **base,
|
||||
+ const struct usb2phy_reg **clkout_ctl)
|
||||
{
|
||||
struct udevice *parent = dev_get_parent(clk->dev);
|
||||
struct rockchip_usb2phy *priv = dev_get_priv(parent);
|
||||
const struct rockchip_usb2phy_cfg *phy_cfg = priv->phy_cfg;
|
||||
|
||||
- if (priv->phy_cfg->clkout_ctl_phy.enable) {
|
||||
+ // phy_cfg can be NULL if this function called before probe (when parent
|
||||
+ // clocks are enabled)
|
||||
+ if (!phy_cfg)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (phy_cfg->clkout_ctl_phy.enable) {
|
||||
*base = priv->phy_base;
|
||||
*clkout_ctl = &phy_cfg->clkout_ctl_phy;
|
||||
} else {
|
||||
*base = priv->reg_base;
|
||||
*clkout_ctl = &phy_cfg->clkout_ctl;
|
||||
}
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +213,8 @@ int rockchip_usb2phy_clk_enable(struct c
|
||||
const struct usb2phy_reg *clkout_ctl;
|
||||
struct regmap *base;
|
||||
|
||||
- rockchip_usb2phy_clkout_ctl(clk, &base, &clkout_ctl);
|
||||
+ if (rockchip_usb2phy_clkout_ctl(clk, &base, &clkout_ctl))
|
||||
+ return -ENOSYS;
|
||||
|
||||
/* turn on 480m clk output if it is off */
|
||||
if (!property_enabled(base, clkout_ctl)) {
|
||||
@@ -230,7 +238,8 @@ int rockchip_usb2phy_clk_disable(struct
|
||||
const struct usb2phy_reg *clkout_ctl;
|
||||
struct regmap *base;
|
||||
|
||||
- rockchip_usb2phy_clkout_ctl(clk, &base, &clkout_ctl);
|
||||
+ if (rockchip_usb2phy_clkout_ctl(clk, &base, &clkout_ctl))
|
||||
+ return -ENOSYS;
|
||||
|
||||
/* turn off 480m clk output */
|
||||
property_enable(base, clkout_ctl, false);
|
||||
@ -0,0 +1,38 @@
|
||||
From d079cdbc53026dca2c4209ee71c883de7fe0cc14 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Fri, 1 Aug 2025 20:32:37 +0000
|
||||
Subject: [PATCH] rng: rockchip_rng: Add compatible for RK3576
|
||||
|
||||
The RK3576 SoC contains a RKRNG block that can be used to generate
|
||||
random numbers using the rockchip_rng driver.
|
||||
|
||||
Add compatible for RK3576 to support random numbers:
|
||||
|
||||
=> rng list
|
||||
RNG #0 - rng@2a410000
|
||||
|
||||
=> rng
|
||||
00000000: 36 dd ab 98 ec fb fe d1 cf 36 b3 e1 9b 3d 00 90 6........6...=..
|
||||
00000010: f5 84 de 75 6b 27 48 9e 13 62 12 6c 50 ca 47 1a ...uk'H..b.lP.G.
|
||||
00000020: b3 4d fc 43 c5 b5 2d be 07 27 03 26 bb 69 61 2a .M.C..-..'.&.ia*
|
||||
00000030: 6f 70 01 83 4e ce 91 7a 5a 6c 7c 00 43 87 3e c5 op..N..zZl|.C.>.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/rng/rockchip_rng.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/drivers/rng/rockchip_rng.c
|
||||
+++ b/drivers/rng/rockchip_rng.c
|
||||
@@ -394,6 +394,10 @@ static const struct udevice_id rockchip_
|
||||
.data = (ulong)&rk_trngv1_soc_data,
|
||||
},
|
||||
{
|
||||
+ .compatible = "rockchip,rk3576-rng",
|
||||
+ .data = (ulong)&rkrng_soc_data,
|
||||
+ },
|
||||
+ {
|
||||
.compatible = "rockchip,rkrng",
|
||||
.data = (ulong)&rkrng_soc_data,
|
||||
},
|
||||
@ -0,0 +1,25 @@
|
||||
From dd2c7df419ae8a5cc5f7ee0480218b0ae28d4926 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Fri, 1 Aug 2025 20:32:38 +0000
|
||||
Subject: [PATCH] rockchip: Add default USB_GADGET_PRODUCT_NUM for RK3576
|
||||
|
||||
Use 0x350e as the default USB Product ID for Rockchip RK3576, same PID
|
||||
being used by the BootROM when the device is in MASKROM mode.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/usb/gadget/Kconfig | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/usb/gadget/Kconfig
|
||||
+++ b/drivers/usb/gadget/Kconfig
|
||||
@@ -86,6 +86,7 @@ config USB_GADGET_PRODUCT_NUM
|
||||
default 0x350a if ROCKCHIP_RK3568
|
||||
default 0x350b if ROCKCHIP_RK3588
|
||||
default 0x350c if ROCKCHIP_RK3528
|
||||
+ default 0x350e if ROCKCHIP_RK3576
|
||||
default 0x0
|
||||
help
|
||||
Product ID of the USB device emulated, reported to the host device.
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,83 @@
|
||||
From a72e8feaca46ed41a8d6bb4e8c5961a29fe7a39e Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Fri, 1 Aug 2025 20:32:40 +0000
|
||||
Subject: [PATCH] rockchip: rk3576: Implement checkboard() to print SoC variant
|
||||
|
||||
Implement checkboard() to print current SoC model used by a board when
|
||||
U-Boot proper is running.
|
||||
|
||||
U-Boot 2025.04 (Apr 22 2025 - 20:43:17 +0000)
|
||||
|
||||
Model: Generic RK3576
|
||||
SoC: RK3576
|
||||
DRAM: 8 GiB
|
||||
|
||||
Information about the SoC model and variant is read from OTP.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
arch/arm/mach-rockchip/rk3576/rk3576.c | 48 ++++++++++++++++++++++++++
|
||||
1 file changed, 48 insertions(+)
|
||||
|
||||
--- a/arch/arm/mach-rockchip/rk3576/rk3576.c
|
||||
+++ b/arch/arm/mach-rockchip/rk3576/rk3576.c
|
||||
@@ -3,6 +3,10 @@
|
||||
* Copyright (c) 2024 Rockchip Electronics Co., Ltd
|
||||
*/
|
||||
|
||||
+#define LOG_CATEGORY LOGC_ARCH
|
||||
+
|
||||
+#include <dm.h>
|
||||
+#include <misc.h>
|
||||
#include <asm/armv8/mmu.h>
|
||||
#include <asm/arch-rockchip/bootrom.h>
|
||||
#include <asm/arch-rockchip/hardware.h>
|
||||
@@ -153,3 +157,47 @@ int arch_cpu_init(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+#define RK3576_OTP_CPU_CODE_OFFSET 0x02
|
||||
+#define RK3576_OTP_SPECIFICATION_OFFSET 0x08
|
||||
+
|
||||
+int checkboard(void)
|
||||
+{
|
||||
+ u8 cpu_code[2], specification;
|
||||
+ struct udevice *dev;
|
||||
+ char suffix[2];
|
||||
+ int ret;
|
||||
+
|
||||
+ if (!IS_ENABLED(CONFIG_ROCKCHIP_OTP) || !CONFIG_IS_ENABLED(MISC))
|
||||
+ return 0;
|
||||
+
|
||||
+ ret = uclass_get_device_by_driver(UCLASS_MISC,
|
||||
+ DM_DRIVER_GET(rockchip_otp), &dev);
|
||||
+ if (ret) {
|
||||
+ log_debug("Could not find otp device, ret=%d\n", ret);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* cpu-code: SoC model, e.g. 0x35 0x76 */
|
||||
+ ret = misc_read(dev, RK3576_OTP_CPU_CODE_OFFSET, cpu_code, 2);
|
||||
+ if (ret < 0) {
|
||||
+ log_debug("Could not read cpu-code, ret=%d\n", ret);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* specification: SoC variant, e.g. 0xA for RK3576J */
|
||||
+ ret = misc_read(dev, RK3576_OTP_SPECIFICATION_OFFSET, &specification, 1);
|
||||
+ if (ret < 0) {
|
||||
+ log_debug("Could not read specification, ret=%d\n", ret);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ specification &= 0x1f;
|
||||
+
|
||||
+ /* for RK3576J i.e. '@' + 0xA = 'J' */
|
||||
+ suffix[0] = specification > 1 ? '@' + specification : '\0';
|
||||
+ suffix[1] = '\0';
|
||||
+
|
||||
+ printf("SoC: RK%02x%02x%s\n", cpu_code[0], cpu_code[1], suffix);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
@ -0,0 +1,35 @@
|
||||
From bdcda6be27b69a6e7ced1d59f5d6ceb07c5414ac Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Fri, 1 Aug 2025 20:32:41 +0000
|
||||
Subject: [PATCH] arm: dts: rockchip: Include OTP in U-Boot pre-reloc phase for
|
||||
RK3576
|
||||
|
||||
Update rk3576-u-boot.dtsi to include OTP in U-Boot pre-reloc phase for
|
||||
checkboard() to be able to read information about the running SoC model
|
||||
and variant from OTP and print it during boot:
|
||||
|
||||
U-Boot 2025.04 (Apr 22 2025 - 20:43:17 +0000)
|
||||
|
||||
Model: Generic RK3576
|
||||
SoC: RK3576
|
||||
DRAM: 8 GiB
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
arch/arm/dts/rk3576-u-boot.dtsi | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/arch/arm/dts/rk3576-u-boot.dtsi
|
||||
+++ b/arch/arm/dts/rk3576-u-boot.dtsi
|
||||
@@ -49,6 +49,10 @@
|
||||
bootph-all;
|
||||
};
|
||||
|
||||
+&otp {
|
||||
+ bootph-some-ram;
|
||||
+};
|
||||
+
|
||||
&pcfg_pull_none {
|
||||
bootph-all;
|
||||
};
|
||||
@ -0,0 +1,26 @@
|
||||
From 2d87afba58b95487f88717df33e16a909f90592a Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Fri, 1 Aug 2025 20:32:42 +0000
|
||||
Subject: [PATCH] usb: dwc3-generic: Use combined glue and ctrl node for RK3576
|
||||
|
||||
Like Rockchip RK3328, RK3568 and RK3588, the RK3576 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 RK3576 DWC3.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/usb/dwc3/dwc3-generic.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/usb/dwc3/dwc3-generic.c
|
||||
+++ b/drivers/usb/dwc3/dwc3-generic.c
|
||||
@@ -699,6 +699,7 @@ static const struct udevice_id dwc3_glue
|
||||
{ .compatible = "rockchip,rk3328-dwc3", .data = (ulong)&rk_ops },
|
||||
{ .compatible = "rockchip,rk3399-dwc3" },
|
||||
{ .compatible = "rockchip,rk3568-dwc3", .data = (ulong)&rk_ops },
|
||||
+ { .compatible = "rockchip,rk3576-dwc3", .data = (ulong)&rk_ops },
|
||||
{ .compatible = "rockchip,rk3588-dwc3", .data = (ulong)&rk_ops },
|
||||
{ .compatible = "qcom,dwc3", .data = (ulong)&qcom_ops },
|
||||
{ .compatible = "fsl,imx8mp-dwc3", .data = (ulong)&imx8mp_ops },
|
||||
@ -0,0 +1,58 @@
|
||||
From b518886f6d7061c127628c1e12f3921c49ffeaee Mon Sep 17 00:00:00 2001
|
||||
From: Frank Wang <frank.wang@rock-chips.com>
|
||||
Date: Fri, 1 Aug 2025 20:32:43 +0000
|
||||
Subject: [PATCH] phy: rockchip-inno-usb2: Add support for RK3576
|
||||
|
||||
Add support for the USB2.0 PHYs used in the RK3576 SoC.
|
||||
|
||||
Config values are taken from vendor U-Boot linux-6.1-stan-rkr5 tag.
|
||||
|
||||
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 26 +++++++++++++++++++
|
||||
1 file changed, 26 insertions(+)
|
||||
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
@@ -465,6 +465,28 @@ static const struct rockchip_usb2phy_cfg
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
+static const struct rockchip_usb2phy_cfg rk3576_phy_cfgs[] = {
|
||||
+ {
|
||||
+ .reg = 0x0000,
|
||||
+ .clkout_ctl = { 0x0008, 0, 0, 1, 0 },
|
||||
+ .port_cfgs = {
|
||||
+ [USB2PHY_PORT_OTG] = {
|
||||
+ .phy_sus = { 0x0000, 1, 0, 2, 1 },
|
||||
+ }
|
||||
+ },
|
||||
+ },
|
||||
+ {
|
||||
+ .reg = 0x2000,
|
||||
+ .clkout_ctl = { 0x2008, 0, 0, 1, 0 },
|
||||
+ .port_cfgs = {
|
||||
+ [USB2PHY_PORT_OTG] = {
|
||||
+ .phy_sus = { 0x2000, 1, 0, 2, 1 },
|
||||
+ }
|
||||
+ },
|
||||
+ },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+
|
||||
static const struct rockchip_usb2phy_cfg rk3588_phy_cfgs[] = {
|
||||
{
|
||||
.reg = 0x0000,
|
||||
@@ -527,6 +549,10 @@ static const struct udevice_id rockchip_
|
||||
.data = (ulong)&rk3568_phy_cfgs,
|
||||
},
|
||||
{
|
||||
+ .compatible = "rockchip,rk3576-usb2phy",
|
||||
+ .data = (ulong)&rk3576_phy_cfgs,
|
||||
+ },
|
||||
+ {
|
||||
.compatible = "rockchip,rk3588-usb2phy",
|
||||
.data = (ulong)&rk3588_phy_cfgs,
|
||||
},
|
||||
@ -0,0 +1,58 @@
|
||||
From 0d966d3932e2e5e7d14301da9ced0d7a62fce367 Mon Sep 17 00:00:00 2001
|
||||
From: Frank Wang <frank.wang@rock-chips.com>
|
||||
Date: Fri, 1 Aug 2025 20:32:44 +0000
|
||||
Subject: [PATCH] phy: rockchip: usbdp: Add support for RK3576
|
||||
|
||||
Add support for the USB3.0+DP PHY used in the RK3576 SoC.
|
||||
|
||||
Config values are taken from vendor U-Boot linux-6.1-stan-rkr5 tag.
|
||||
|
||||
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/phy/rockchip/phy-rockchip-usbdp.c | 26 +++++++++++++++++++++++
|
||||
1 file changed, 26 insertions(+)
|
||||
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
|
||||
@@ -813,6 +813,28 @@ static const char * const rk3588_udphy_r
|
||||
"init", "cmn", "lane", "pcs_apb", "pma_apb"
|
||||
};
|
||||
|
||||
+static const struct rockchip_udphy_cfg rk3576_udphy_cfgs = {
|
||||
+ .num_phys = 1,
|
||||
+ .phy_ids = {
|
||||
+ 0x2b010000,
|
||||
+ },
|
||||
+ .num_rsts = ARRAY_SIZE(rk3588_udphy_rst_l),
|
||||
+ .rst_list = rk3588_udphy_rst_l,
|
||||
+ .grfcfg = {
|
||||
+ /* u2phy-grf */
|
||||
+ .bvalid_phy_con = { 0x0010, 1, 0, 0x2, 0x3 },
|
||||
+ .bvalid_grf_con = { 0x0000, 15, 14, 0x1, 0x3 },
|
||||
+
|
||||
+ /* usb-grf */
|
||||
+ .usb3otg0_cfg = { 0x0030, 15, 0, 0x1100, 0x0188 },
|
||||
+
|
||||
+ /* usbdpphy-grf */
|
||||
+ .low_pwrn = { 0x0004, 13, 13, 0, 1 },
|
||||
+ .rx_lfps = { 0x0004, 14, 14, 0, 1 },
|
||||
+ },
|
||||
+ .combophy_init = rk3588_udphy_init,
|
||||
+};
|
||||
+
|
||||
static const struct rockchip_udphy_cfg rk3588_udphy_cfgs = {
|
||||
.num_phys = 2,
|
||||
.phy_ids = {
|
||||
@@ -839,6 +861,10 @@ static const struct rockchip_udphy_cfg r
|
||||
|
||||
static const struct udevice_id rockchip_udphy_dt_match[] = {
|
||||
{
|
||||
+ .compatible = "rockchip,rk3576-usbdp-phy",
|
||||
+ .data = (ulong)&rk3576_udphy_cfgs
|
||||
+ },
|
||||
+ {
|
||||
.compatible = "rockchip,rk3588-usbdp-phy",
|
||||
.data = (ulong)&rk3588_udphy_cfgs
|
||||
},
|
||||
@ -0,0 +1,26 @@
|
||||
From 2a6039a20994c192edb6786fa97714180bd663cf Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Fri, 1 Aug 2025 20:43:37 +0000
|
||||
Subject: [PATCH] rockchip: clk: clk_rk3576: Add dummy CLK_REF_PCIEx_PHY
|
||||
support
|
||||
|
||||
Add dummy support for the CLK_REF_PCIEx_PHY clocks to allow probe of the
|
||||
phy-rockchip-naneng-combphy driver on RK3576.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/clk/rockchip/clk_rk3576.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
--- a/drivers/clk/rockchip/clk_rk3576.c
|
||||
+++ b/drivers/clk/rockchip/clk_rk3576.c
|
||||
@@ -2168,6 +2168,8 @@ static ulong rk3576_clk_set_rate(struct
|
||||
case CLK_CPLL_DIV10:
|
||||
case FCLK_DDR_CM0_CORE:
|
||||
case ACLK_PHP_ROOT:
|
||||
+ case CLK_REF_PCIE0_PHY:
|
||||
+ case CLK_REF_PCIE1_PHY:
|
||||
ret = 0;
|
||||
break;
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
@ -0,0 +1,179 @@
|
||||
From cca7e79c7a42067fd8e65f4d2d2c73a98e42cd2e Mon Sep 17 00:00:00 2001
|
||||
From: Jon Lin <jon.lin@rock-chips.com>
|
||||
Date: Fri, 1 Aug 2025 20:43:38 +0000
|
||||
Subject: [PATCH] phy: rockchip: naneng-combphy: Add support for RK3576
|
||||
|
||||
Add support for the PCIe/USB3/SATA combo PHYs used in the RK3576 SoC.
|
||||
|
||||
Config values are taken from vendor U-Boot linux-6.1-stan-rkr5 tag.
|
||||
|
||||
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
.../rockchip/phy-rockchip-naneng-combphy.c | 147 ++++++++++++++++++
|
||||
1 file changed, 147 insertions(+)
|
||||
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c
|
||||
@@ -453,6 +453,149 @@ static const struct rockchip_combphy_cfg
|
||||
.combphy_cfg = rk3568_combphy_cfg,
|
||||
};
|
||||
|
||||
+static int rk3576_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:
|
||||
+ 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 + (0x1f << 2));
|
||||
+ val &= ~GENMASK(5, 4);
|
||||
+ val |= 0x01 << 4;
|
||||
+ writel(val, priv->mmio + 0x7c);
|
||||
+
|
||||
+ /* Enable adaptive CTLE for USB3.0 Rx */
|
||||
+ val = readl(priv->mmio + (0x0e << 2));
|
||||
+ val &= ~GENMASK(0, 0);
|
||||
+ val |= 0x01;
|
||||
+ writel(val, priv->mmio + (0x0e << 2));
|
||||
+
|
||||
+ /* Set PLL KVCO fine tuning signals */
|
||||
+ val = readl(priv->mmio + (0x20 << 2));
|
||||
+ val &= ~(0x7 << 2);
|
||||
+ val |= 0x2 << 2;
|
||||
+ writel(val, priv->mmio + (0x20 << 2));
|
||||
+
|
||||
+ /* Set PLL LPF R1 to su_trim[10:7]=1001 */
|
||||
+ writel(0x4, priv->mmio + (0xb << 2));
|
||||
+
|
||||
+ /* Set PLL input clock divider 1/2 */
|
||||
+ val = readl(priv->mmio + (0x5 << 2));
|
||||
+ val &= ~(0x3 << 6);
|
||||
+ val |= 0x1 << 6;
|
||||
+ writel(val, priv->mmio + (0x5 << 2));
|
||||
+
|
||||
+ /* Set PLL loop divider */
|
||||
+ writel(0x32, priv->mmio + (0x11 << 2));
|
||||
+
|
||||
+ /* Set PLL KVCO to min and set PLL charge pump current to max */
|
||||
+ writel(0xf0, priv->mmio + (0xa << 2));
|
||||
+
|
||||
+ /* Set Rx squelch input filler bandwidth */
|
||||
+ writel(0x0d, priv->mmio + (0x14 << 2));
|
||||
+
|
||||
+ 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->u3otg1_port_en, true);
|
||||
+ break;
|
||||
+ case PHY_TYPE_SATA:
|
||||
+ /* Enable adaptive CTLE for SATA Rx */
|
||||
+ val = readl(priv->mmio + (0x0e << 2));
|
||||
+ val &= ~GENMASK(0, 0);
|
||||
+ val |= 0x01;
|
||||
+ writel(val, priv->mmio + (0x0e << 2));
|
||||
+ /* Set tx_rterm = 50 ohm and rx_rterm = 43.5 ohm */
|
||||
+ writel(0x8F, priv->mmio + (0x06 << 2));
|
||||
+
|
||||
+ param_write(priv->phy_grf, &cfg->con0_for_sata, true);
|
||||
+ param_write(priv->phy_grf, &cfg->con1_for_sata, true);
|
||||
+ param_write(priv->phy_grf, &cfg->con2_for_sata, true);
|
||||
+ param_write(priv->phy_grf, &cfg->con3_for_sata, true);
|
||||
+ param_write(priv->pipe_grf, &cfg->pipe_con0_for_sata, true);
|
||||
+ param_write(priv->pipe_grf, &cfg->pipe_con1_for_sata, true);
|
||||
+ break;
|
||||
+ case PHY_TYPE_SGMII:
|
||||
+ case PHY_TYPE_QSGMII:
|
||||
+ default:
|
||||
+ dev_err(priv->dev, "incompatible PHY type\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ /* 100MHz refclock signal is good */
|
||||
+ clk_set_rate(&priv->ref_clk, 100000000);
|
||||
+ param_write(priv->phy_grf, &cfg->pipe_clk_100m, true);
|
||||
+ if (priv->mode == PHY_TYPE_PCIE) {
|
||||
+ /* gate_tx_pck_sel length select work for L1SS */
|
||||
+ writel(0xc0, priv->mmio + 0x74);
|
||||
+
|
||||
+ /* PLL KVCO tuning fine */
|
||||
+ val = readl(priv->mmio + (0x20 << 2));
|
||||
+ val &= ~(0x7 << 2);
|
||||
+ val |= 0x2 << 2;
|
||||
+ writel(val, priv->mmio + (0x20 << 2));
|
||||
+
|
||||
+ /* Set up rx_trim: PLL LPF C1 85pf R1 1.25kohm */
|
||||
+ writel(0x4c, priv->mmio + (0x1b << 2));
|
||||
+
|
||||
+ /* Set up su_trim: T3_P1 650mv */
|
||||
+ writel(0x90, priv->mmio + (0xa << 2));
|
||||
+ writel(0x43, priv->mmio + (0xb << 2));
|
||||
+ writel(0x88, priv->mmio + (0xc << 2));
|
||||
+ writel(0x56, priv->mmio + (0xd << 2));
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct rockchip_combphy_grfcfg rk3576_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_25m = { 0x0004, 14, 13, 0x00, 0x01 },
|
||||
+ .pipe_clk_100m = { 0x0004, 14, 13, 0x00, 0x02 },
|
||||
+ .pipe_phymode_sel = { 0x0008, 1, 1, 0x00, 0x01 },
|
||||
+ .pipe_rate_sel = { 0x0008, 2, 2, 0x00, 0x01 },
|
||||
+ .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, 0x1000 },
|
||||
+ .con1_for_pcie = { 0x0004, 15, 0, 0x00, 0x0000 },
|
||||
+ .con2_for_pcie = { 0x0008, 15, 0, 0x00, 0x0101 },
|
||||
+ .con3_for_pcie = { 0x000c, 15, 0, 0x00, 0x0200 },
|
||||
+ .con0_for_sata = { 0x0000, 15, 0, 0x00, 0x0129 },
|
||||
+ .con1_for_sata = { 0x0004, 15, 0, 0x00, 0x0000 },
|
||||
+ .con2_for_sata = { 0x0008, 15, 0, 0x00, 0x80c1 },
|
||||
+ .con3_for_sata = { 0x000c, 15, 0, 0x00, 0x0407 },
|
||||
+ /* php-grf */
|
||||
+ .pipe_con0_for_sata = { 0x001C, 2, 0, 0x00, 0x2 },
|
||||
+ .pipe_con1_for_sata = { 0x0020, 2, 0, 0x00, 0x2 },
|
||||
+ .u3otg1_port_en = { 0x0038, 15, 0, 0x0181, 0x1100 },
|
||||
+};
|
||||
+
|
||||
+static const struct rockchip_combphy_cfg rk3576_combphy_cfgs = {
|
||||
+ .num_phys = 2,
|
||||
+ .phy_ids = {
|
||||
+ 0x2b050000,
|
||||
+ 0x2b060000,
|
||||
+ },
|
||||
+ .grfcfg = &rk3576_combphy_grfcfgs,
|
||||
+ .combphy_cfg = rk3576_combphy_cfg,
|
||||
+};
|
||||
+
|
||||
static int rk3588_combphy_cfg(struct rockchip_combphy_priv *priv)
|
||||
{
|
||||
const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
|
||||
@@ -565,6 +708,10 @@ static const struct udevice_id rockchip_
|
||||
.data = (ulong)&rk3568_combphy_cfgs
|
||||
},
|
||||
{
|
||||
+ .compatible = "rockchip,rk3576-naneng-combphy",
|
||||
+ .data = (ulong)&rk3576_combphy_cfgs
|
||||
+ },
|
||||
+ {
|
||||
.compatible = "rockchip,rk3588-naneng-combphy",
|
||||
.data = (ulong)&rk3588_combphy_cfgs
|
||||
},
|
||||
@ -0,0 +1,67 @@
|
||||
From 0336e97b1187f7f54e11c6cb9f3fa938cc11204e Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Mon, 21 Jul 2025 22:07:10 +0000
|
||||
Subject: [PATCH] phy: rockchip: usbdp: Fix Generic PHY reference counting
|
||||
|
||||
Generic PHY reference counting helps ensure driver ops for init/exit and
|
||||
power on/off are called at correct state. For this to work the PHY
|
||||
driver must initialize PHY-id to a persistent value in of_xlate ops.
|
||||
|
||||
The Rockchip USBDP PHY driver does not initialize the PHY-id field, this
|
||||
typically lead to use of unshared reference counting among different
|
||||
struct phy instances.
|
||||
|
||||
Initialize the PHY-id in of_xlate ops to ensure use of shared reference
|
||||
counting among all struct phy instances.
|
||||
|
||||
E.g. on a ROCK 5B following could be observed:
|
||||
|
||||
=> usb start
|
||||
starting USB...
|
||||
[...]
|
||||
Bus usb@fc400000: 2 USB Device(s) found
|
||||
scanning usb for storage devices... 1 Storage Device(s) found
|
||||
|
||||
=> usb reset
|
||||
resetting USB...
|
||||
[...]
|
||||
rockchip_udphy phy@fed90000: cmn ana lcpll lock timeout
|
||||
rockchip_udphy phy@fed90000: failed to init usbdp combophy
|
||||
rockchip_udphy phy@fed90000: PHY: Failed to init phy@fed90000: -110.
|
||||
Can't init PHY1
|
||||
Bus usb@fc400000: probe failed, error -110
|
||||
scanning usb for storage devices... 0 Storage Device(s) found
|
||||
|
||||
With shared reference counting this is fixed:
|
||||
|
||||
=> usb reset
|
||||
resetting USB...
|
||||
[...]
|
||||
Bus usb@fc400000: 2 USB Device(s) found
|
||||
scanning usb for storage devices... 1 Storage Device(s) found
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/phy/rockchip/phy-rockchip-usbdp.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
|
||||
@@ -587,12 +587,16 @@ static int udphy_power_off(struct rockch
|
||||
static int rockchip_u3phy_of_xlate(struct phy *phy,
|
||||
struct ofnode_phandle_args *args)
|
||||
{
|
||||
+ struct rockchip_udphy *udphy = dev_get_priv(phy->dev);
|
||||
+
|
||||
if (args->args_count == 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (args->args[0] != PHY_TYPE_USB3)
|
||||
return -EINVAL;
|
||||
|
||||
+ phy->id = udphy->id;
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -0,0 +1,155 @@
|
||||
From 8a3d377d4ccd409b56b9a6eef20613472e4471fd Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Mon, 21 Jul 2025 22:07:13 +0000
|
||||
Subject: [PATCH] phy: rockchip: naneng-combphy: Simplify init ops
|
||||
|
||||
The init ops for Rockchip COMBPHY driver is more complex than it needs
|
||||
to be, e.g. declaring multiple init functions that only differ in the
|
||||
error message.
|
||||
|
||||
Simplify the init ops based on code from the Linux mainline driver.
|
||||
|
||||
This change also ensure that errors returned from combphy_cfg() and
|
||||
reset_deassert_bulk() is propertly propagated to the caller. No other
|
||||
runtime change is expected with this simplication.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
.../rockchip/phy-rockchip-naneng-combphy.c | 101 ++++--------------
|
||||
1 file changed, 19 insertions(+), 82 deletions(-)
|
||||
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c
|
||||
@@ -98,104 +98,41 @@ static int param_write(struct regmap *ba
|
||||
return regmap_write(base, reg->offset, val);
|
||||
}
|
||||
|
||||
-static int rockchip_combphy_pcie_init(struct rockchip_combphy_priv *priv)
|
||||
-{
|
||||
- int ret = 0;
|
||||
-
|
||||
- if (priv->cfg->combphy_cfg) {
|
||||
- ret = priv->cfg->combphy_cfg(priv);
|
||||
- if (ret) {
|
||||
- dev_err(priv->dev, "failed to init phy for pcie\n");
|
||||
- return ret;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
-static int rockchip_combphy_usb3_init(struct rockchip_combphy_priv *priv)
|
||||
-{
|
||||
- int ret = 0;
|
||||
-
|
||||
- if (priv->cfg->combphy_cfg) {
|
||||
- ret = priv->cfg->combphy_cfg(priv);
|
||||
- if (ret) {
|
||||
- dev_err(priv->dev, "failed to init phy for usb3\n");
|
||||
- return ret;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
-static int rockchip_combphy_sata_init(struct rockchip_combphy_priv *priv)
|
||||
-{
|
||||
- int ret = 0;
|
||||
-
|
||||
- if (priv->cfg->combphy_cfg) {
|
||||
- ret = priv->cfg->combphy_cfg(priv);
|
||||
- if (ret) {
|
||||
- dev_err(priv->dev, "failed to init phy for sata\n");
|
||||
- return ret;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
-static int rockchip_combphy_sgmii_init(struct rockchip_combphy_priv *priv)
|
||||
+static int rockchip_combphy_init(struct phy *phy)
|
||||
{
|
||||
- int ret = 0;
|
||||
-
|
||||
- if (priv->cfg->combphy_cfg) {
|
||||
- ret = priv->cfg->combphy_cfg(priv);
|
||||
- if (ret) {
|
||||
- dev_err(priv->dev, "failed to init phy for sgmii\n");
|
||||
- return ret;
|
||||
- }
|
||||
- }
|
||||
+ struct rockchip_combphy_priv *priv = dev_get_priv(phy->dev);
|
||||
+ int ret;
|
||||
|
||||
- return ret;
|
||||
-}
|
||||
+ ret = clk_enable(&priv->ref_clk);
|
||||
+ if (ret < 0 && ret != -ENOSYS)
|
||||
+ return ret;
|
||||
|
||||
-static int rockchip_combphy_set_mode(struct rockchip_combphy_priv *priv)
|
||||
-{
|
||||
switch (priv->mode) {
|
||||
case PHY_TYPE_PCIE:
|
||||
- rockchip_combphy_pcie_init(priv);
|
||||
- break;
|
||||
case PHY_TYPE_USB3:
|
||||
- rockchip_combphy_usb3_init(priv);
|
||||
- break;
|
||||
case PHY_TYPE_SATA:
|
||||
- rockchip_combphy_sata_init(priv);
|
||||
- break;
|
||||
case PHY_TYPE_SGMII:
|
||||
case PHY_TYPE_QSGMII:
|
||||
- return rockchip_combphy_sgmii_init(priv);
|
||||
+ if (priv->cfg->combphy_cfg)
|
||||
+ ret = priv->cfg->combphy_cfg(priv);
|
||||
+ else
|
||||
+ ret = 0;
|
||||
+ break;
|
||||
default:
|
||||
dev_err(priv->dev, "incompatible PHY type\n");
|
||||
- return -EINVAL;
|
||||
+ ret = -EINVAL;
|
||||
+ break;
|
||||
}
|
||||
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-static int rockchip_combphy_init(struct phy *phy)
|
||||
-{
|
||||
- struct rockchip_combphy_priv *priv = dev_get_priv(phy->dev);
|
||||
- int ret;
|
||||
-
|
||||
- ret = clk_enable(&priv->ref_clk);
|
||||
- if (ret < 0 && ret != -ENOSYS)
|
||||
- return ret;
|
||||
+ if (ret) {
|
||||
+ dev_err(priv->dev, "failed to init phy for phy type %x\n", priv->mode);
|
||||
+ goto err_clk;
|
||||
+ }
|
||||
|
||||
- ret = rockchip_combphy_set_mode(priv);
|
||||
+ ret = reset_deassert_bulk(&priv->phy_rsts);
|
||||
if (ret)
|
||||
goto err_clk;
|
||||
|
||||
- reset_deassert_bulk(&priv->phy_rsts);
|
||||
-
|
||||
return 0;
|
||||
|
||||
err_clk:
|
||||
@@ -304,7 +241,7 @@ static int rockchip_combphy_probe(struct
|
||||
}
|
||||
|
||||
priv->dev = udev;
|
||||
- priv->mode = PHY_TYPE_SATA;
|
||||
+ priv->mode = PHY_NONE;
|
||||
priv->cfg = phy_cfg;
|
||||
|
||||
return rockchip_combphy_parse_dt(udev, priv);
|
||||
@ -0,0 +1,49 @@
|
||||
From 12dd645914a4e5e65d92a4754d0dacbdbf1e4a55 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Mon, 21 Jul 2025 22:07:14 +0000
|
||||
Subject: [PATCH] phy: rockchip: naneng-combphy: Use
|
||||
syscon_regmap_lookup_by_phandle
|
||||
|
||||
Change to use syscon_regmap_lookup_by_phandle() helper instead of
|
||||
finding the syscon udevice and making a call to syscon_get_regmap().
|
||||
|
||||
No runtime change is expected with this simplication.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
.../phy/rockchip/phy-rockchip-naneng-combphy.c | 17 +++++++----------
|
||||
1 file changed, 7 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c
|
||||
@@ -174,22 +174,19 @@ static const struct phy_ops rockchip_com
|
||||
static int rockchip_combphy_parse_dt(struct udevice *dev,
|
||||
struct rockchip_combphy_priv *priv)
|
||||
{
|
||||
- struct udevice *syscon;
|
||||
int ret;
|
||||
|
||||
- ret = uclass_get_device_by_phandle(UCLASS_SYSCON, dev, "rockchip,pipe-grf", &syscon);
|
||||
- if (ret) {
|
||||
- dev_err(dev, "failed to find peri_ctrl pipe-grf regmap");
|
||||
- return ret;
|
||||
+ priv->pipe_grf = syscon_regmap_lookup_by_phandle(dev, "rockchip,pipe-grf");
|
||||
+ if (IS_ERR(priv->pipe_grf)) {
|
||||
+ dev_err(dev, "failed to find peri_ctrl pipe-grf regmap\n");
|
||||
+ return PTR_ERR(priv->pipe_grf);
|
||||
}
|
||||
- priv->pipe_grf = syscon_get_regmap(syscon);
|
||||
|
||||
- ret = uclass_get_device_by_phandle(UCLASS_SYSCON, dev, "rockchip,pipe-phy-grf", &syscon);
|
||||
- if (ret) {
|
||||
+ priv->phy_grf = syscon_regmap_lookup_by_phandle(dev, "rockchip,pipe-phy-grf");
|
||||
+ if (IS_ERR(priv->phy_grf)) {
|
||||
dev_err(dev, "failed to find peri_ctrl pipe-phy-grf regmap\n");
|
||||
- return ret;
|
||||
+ return PTR_ERR(priv->phy_grf);
|
||||
}
|
||||
- priv->phy_grf = syscon_get_regmap(syscon);
|
||||
|
||||
ret = clk_get_by_index(dev, 0, &priv->ref_clk);
|
||||
if (ret) {
|
||||
@ -0,0 +1,30 @@
|
||||
From c8e6a7131d58511129cdec16f269600b51f0a45a Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Mon, 21 Jul 2025 22:07:15 +0000
|
||||
Subject: [PATCH] phy: rockchip: inno-usb2: Fix improper use of UCLASS_PHY
|
||||
|
||||
The Rockchip USB2PHY glue driver improperly present itself as a
|
||||
UCLASS_PHY driver, without ever implementing the required phy_ops.
|
||||
|
||||
This is something that in special circumstances can lead to a NULL
|
||||
pointer dereference followed by a SError crash.
|
||||
|
||||
Change the glue driver to use UCLASS_NOP to fix this.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
@@ -573,7 +573,7 @@ U_BOOT_DRIVER(rockchip_usb2phy_clock) =
|
||||
|
||||
U_BOOT_DRIVER(rockchip_usb2phy) = {
|
||||
.name = "rockchip_usb2phy",
|
||||
- .id = UCLASS_PHY,
|
||||
+ .id = UCLASS_NOP,
|
||||
.of_match = rockchip_usb2phy_ids,
|
||||
.probe = rockchip_usb2phy_probe,
|
||||
.bind = rockchip_usb2phy_bind,
|
||||
@ -0,0 +1,30 @@
|
||||
From fca01a8792e6ed48a00e08124d55f4f74e47b11d Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Mon, 21 Jul 2025 22:07:16 +0000
|
||||
Subject: [PATCH] phy: rockchip: typec: Fix improper use of UCLASS_PHY
|
||||
|
||||
The Rockchip TypeC glue driver improperly present itself as a UCLASS_PHY
|
||||
driver, without ever implementing the required phy_ops.
|
||||
|
||||
This is something that in special circumstances can lead to a NULL
|
||||
pointer dereference followed by a SError crash.
|
||||
|
||||
Change the glue driver to use UCLASS_NOP to fix this.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
drivers/phy/rockchip/phy-rockchip-typec.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-typec.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-typec.c
|
||||
@@ -788,7 +788,7 @@ U_BOOT_DRIVER(rockchip_tcphy_usb3_port)
|
||||
|
||||
U_BOOT_DRIVER(rockchip_typec_phy) = {
|
||||
.name = "rockchip_typec_phy",
|
||||
- .id = UCLASS_PHY,
|
||||
+ .id = UCLASS_NOP,
|
||||
.of_match = rockchip_typec_phy_ids,
|
||||
.probe = rockchip_tcphy_probe,
|
||||
.bind = rockchip_tcphy_bind,
|
||||
@ -0,0 +1,46 @@
|
||||
From 9d39a56922878562b263e45f45523021cf5e7789 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Mon, 21 Jul 2025 22:07:17 +0000
|
||||
Subject: [PATCH] rockchip: rk3588: Disable USB3OTG U3 ports early
|
||||
|
||||
The RK3588 SoC comes with USB OTG support using a DWC3 controller with
|
||||
a USB2 PHY and a USB3 PHY (USBDP PHY).
|
||||
|
||||
Some board designs may not use the USBDP PHY 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 ports early and leave it to the
|
||||
USBDP PHY driver to re-enable the U3 port when a usb3-phy is described
|
||||
in the board device tree.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
arch/arm/mach-rockchip/rk3588/rk3588.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
--- a/arch/arm/mach-rockchip/rk3588/rk3588.c
|
||||
+++ b/arch/arm/mach-rockchip/rk3588/rk3588.c
|
||||
@@ -15,6 +15,10 @@
|
||||
#include <asm/arch-rockchip/hardware.h>
|
||||
#include <asm/arch-rockchip/ioc_rk3588.h>
|
||||
|
||||
+#define USB_GRF_BASE 0xfd5ac000
|
||||
+#define USB3OTG0_CON1 0x001c
|
||||
+#define USB3OTG1_CON1 0x0034
|
||||
+
|
||||
#define FIREWALL_DDR_BASE 0xfe030000
|
||||
#define FW_DDR_MST5_REG 0x54
|
||||
#define FW_DDR_MST13_REG 0x74
|
||||
@@ -184,6 +188,10 @@ int arch_cpu_init(void)
|
||||
/* Disable JTAG exposed on SDMMC */
|
||||
rk_clrreg(&sys_grf->soc_con[6], SYS_GRF_FORCE_JTAG);
|
||||
#endif
|
||||
+
|
||||
+ /* Disable USB3OTG U3 ports, later enabled by USBDP PHY driver */
|
||||
+ writel(0xffff0188, USB_GRF_BASE + USB3OTG0_CON1);
|
||||
+ writel(0xffff0188, USB_GRF_BASE + USB3OTG1_CON1);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@ -0,0 +1,44 @@
|
||||
From be585d4916864387c53c82b4bde7f04093aac440 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Mon, 21 Jul 2025 22:07:18 +0000
|
||||
Subject: [PATCH] rockchip: rk3576: Disable USB3OTG0 U3 port early
|
||||
|
||||
The RK3576 SoC comes with USB OTG support using a DWC3 controller with
|
||||
a USB2 PHY and a USB3 PHY (USBDP PHY).
|
||||
|
||||
Some board designs may not use the USBDP PHY 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 USB3OTG0 U3 port early and leave it to the
|
||||
USBDP PHY driver to re-enable the U3 port when a usb3-phy is described
|
||||
in the board device tree.
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
|
||||
---
|
||||
arch/arm/mach-rockchip/rk3576/rk3576.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
--- a/arch/arm/mach-rockchip/rk3576/rk3576.c
|
||||
+++ b/arch/arm/mach-rockchip/rk3576/rk3576.c
|
||||
@@ -33,6 +33,9 @@
|
||||
#define SGRF_DOMAIN_CON4 0x10
|
||||
#define SGRF_DOMAIN_CON5 0x14
|
||||
|
||||
+#define USB_GRF_BASE 0x2601E000
|
||||
+#define USB3OTG0_CON1 0x0030
|
||||
+
|
||||
const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
|
||||
[BROM_BOOTSOURCE_EMMC] = "/soc/mmc@2a330000",
|
||||
[BROM_BOOTSOURCE_SD] = "/soc/mmc@2a310000",
|
||||
@@ -155,6 +158,9 @@ int arch_cpu_init(void)
|
||||
*/
|
||||
writel(0xffffff00, SYS_SGRF_BASE + SYS_SGRF_SOC_CON20);
|
||||
|
||||
+ /* Disable USB3OTG0 U3 port, later enabled by USBDP PHY driver */
|
||||
+ writel(0xffff0188, USB_GRF_BASE + USB3OTG0_CON1);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
#include <misc.h>
|
||||
#include <spl.h>
|
||||
#include <asm/armv8/mmu.h>
|
||||
@@ -192,6 +193,15 @@ int arch_cpu_init(void)
|
||||
@@ -200,6 +201,15 @@ int arch_cpu_init(void)
|
||||
|
||||
#define RK3588_OTP_CPU_CODE_OFFSET 0x02
|
||||
#define RK3588_OTP_SPECIFICATION_OFFSET 0x06
|
||||
@ -43,7 +43,7 @@ Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
|
||||
int checkboard(void)
|
||||
{
|
||||
@@ -237,3 +247,199 @@ int checkboard(void)
|
||||
@@ -245,3 +255,199 @@ int checkboard(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -61,7 +61,7 @@ Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
CONFIG_SPL_MAX_SIZE=0x40000
|
||||
--- a/doc/board/rockchip/rockchip.rst
|
||||
+++ b/doc/board/rockchip/rockchip.rst
|
||||
@@ -146,7 +146,7 @@ List of mainline supported Rockchip boar
|
||||
@@ -147,7 +147,7 @@ List of mainline supported Rockchip boar
|
||||
- FriendlyElec NanoPC-T6 (nanopc-t6-rk3588)
|
||||
- FriendlyElec NanoPi R6C (nanopi-r6c-rk3588s)
|
||||
- FriendlyElec NanoPi R6S (nanopi-r6s-rk3588s)
|
||||
Loading…
Reference in New Issue
Block a user