Skip to contentSkip to conversation

rockchip: Add initial support for RK3506

PATCH Superseded Jonas Karlman 3 participants 14 messages Jan 9 – Jan 12

Subsystems (10)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover rockchip: Add initial support for RK3506

This series add initial support for the Rockchip RK3506 SoC.

Clk and pinctrl drivers have been imported from vendor U-Boot with some adjustments and fixes.

Upstream DT is currently not existing for RK3506, so this series does not add support for any new boards, it only add initial arch support.

Please see my U-Boot rk3506 branch at [1] for a few more commits that add DTs and defconfig for e.g. Luckfox Lyra variants and ArmSoM Forge1.

With this series, board DTs and defconfigs it should be possible to boot into U-Boot proper (without OP-TEE) and still have support for MMC, Ethernet, OTP, RNG, LEDs, buttons and USB gadget/host.

[1] https://source.denx.de/u-boot/contributors/kwiboo/u-boot/-/commits/rk3506

Finley Xiao (2):
dt-bindings: clock: rockchip: Add RK3506 clock and reset unit
clk: rockchip: Add support for RK3506

Jonas Karlman (6):
ram: rockchip: Add basic support for RK3506
pinctrl: rockchip: Use syscon_regmap_lookup_by_phandle()
rockchip: otp: Add support for RK3506
phy: rockchip-inno-usb2: Add support for RK3506
net: dwc_eth_qos_rockchip: Add support for RK3506
arch: arm: rockchip: Add initial support for RK3506

Xuhui Lin (1):
rockchip: mkimage: Add support for RK3506

Ye Zhang (1):
pinctrl: rockchip: Add support for RK3506

 arch/arm/include/asm/arch-rk3506/boot0.h      |    9 +
 arch/arm/include/asm/arch-rk3506/gpio.h       |    9 +
 arch/arm/include/asm/arch-rockchip/clock.h    |   10 +
 .../include/asm/arch-rockchip/cru_rk3506.h    |  220 +++
 arch/arm/mach-rockchip/Kconfig                |   43 +
 arch/arm/mach-rockchip/Makefile               |    1 +
 arch/arm/mach-rockchip/rk3506/Kconfig         |   15 +
 arch/arm/mach-rockchip/rk3506/Makefile        |    5 +
 arch/arm/mach-rockchip/rk3506/clk_rk3506.c    |   16 +
 arch/arm/mach-rockchip/rk3506/rk3506.c        |  130 ++
 arch/arm/mach-rockchip/rk3506/syscon_rk3506.c |   19 +
 drivers/clk/rockchip/Makefile                 |    1 +
 drivers/clk/rockchip/clk_rk3506.c             | 1212 +++++++++++++++++
 drivers/misc/rockchip-otp.c                   |    4 +
 drivers/net/dwc_eth_qos.c                     |    4 +
 drivers/net/dwc_eth_qos_rockchip.c            |   86 ++
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c |   20 +
 drivers/pinctrl/rockchip/Makefile             |    1 +
 drivers/pinctrl/rockchip/pinctrl-rk3506.c     |  462 +++++++
 .../pinctrl/rockchip/pinctrl-rockchip-core.c  |   46 +-
 drivers/pinctrl/rockchip/pinctrl-rockchip.h   |    1 +
 drivers/ram/rockchip/Makefile                 |    1 +
 drivers/ram/rockchip/sdram_rk3506.c           |   33 +
 drivers/reset/Makefile                        |    2 +-
 drivers/reset/rst-rk3506.c                    |  222 +++
 drivers/usb/gadget/Kconfig                    |    1 +
 .../Bindings/clock/rockchip,rk3506-cru.yaml   |   55 +
 .../dt-bindings/clock/rockchip,rk3506-cru.h   |  285 ++++
 .../dt-bindings/reset/rockchip,rk3506-cru.h   |  211 +++
 include/configs/rk3506_common.h               |   38 +
 tools/rkcommon.c                              |    1 +
 31 files changed, 3136 insertions(+), 27 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-rk3506/boot0.h
 create mode 100644 arch/arm/include/asm/arch-rk3506/gpio.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3506.h
 create mode 100644 arch/arm/mach-rockchip/rk3506/Kconfig
 create mode 100644 arch/arm/mach-rockchip/rk3506/Makefile
 create mode 100644 arch/arm/mach-rockchip/rk3506/clk_rk3506.c
 create mode 100644 arch/arm/mach-rockchip/rk3506/rk3506.c
 create mode 100644 arch/arm/mach-rockchip/rk3506/syscon_rk3506.c
 create mode 100644 drivers/clk/rockchip/clk_rk3506.c
 create mode 100644 drivers/pinctrl/rockchip/pinctrl-rk3506.c
 create mode 100644 drivers/ram/rockchip/sdram_rk3506.c
 create mode 100644 drivers/reset/rst-rk3506.c
 create mode 100644 dts/upstream/Bindings/clock/rockchip,rk3506-cru.yaml
 create mode 100644 dts/upstream/include/dt-bindings/clock/rockchip,rk3506-cru.h
 create mode 100644 dts/upstream/include/dt-bindings/reset/rockchip,rk3506-cru.h
 create mode 100644 include/configs/rk3506_common.h
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/10 rockchip: mkimage: Add support for RK3506

From: Xuhui Lin <[email protected]>

Add support for generating Rockchip Boot Image for RK3506.

The RK3506 has 48 KiB SRAM and 4 KiB is reserved for BootROM.

---
 tools/rkcommon.c | 1 +
 1 file changed, 1 insertion(+)
tools/rkcommon.c +1 -0
index e7e78ef7e5b7..784e542ea27c 100644
@@ -150,6 +150,7 @@ static struct spl_info spl_infos[] = {
 	{ "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1 },
 	{ "rv1108", "RK11", 0x1800, false, RK_HEADER_V1 },
 	{ "rv1126", "110B", 0x10000 - 0x1000, false, RK_HEADER_V1 },
+	{ "rk3506", "RK35", 0xC000 - 0x1000, false, RK_HEADER_V2 },
 	{ "rk3528", "RK35", 0x10000 - 0x1000, false, RK_HEADER_V2 },
 	{ "rk3568", "RK35", 0x10000 - 0x1000, false, RK_HEADER_V2 },
 	{ "rk3576", "RK35", 0x80000 - 0x1000, false, RK_HEADER_V2 },
Signature · 1 line
2.52.0
#2 lore raw

PATCH 2/10 ram: rockchip: Add basic support for RK3506

In reply to Jonas Karlman

Add support for reading DRAM size information from PMUGRF os_reg2 reg.

---
 drivers/ram/rockchip/Makefile       |  1 +
 drivers/ram/rockchip/sdram_rk3506.c | 33 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 drivers/ram/rockchip/sdram_rk3506.c
drivers/ram/rockchip/Makefile +1 -0
index fd94aad0cd49..27921ae4921a 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_ROCKCHIP_RK3288) = sdram_rk3288.o
 obj-$(CONFIG_ROCKCHIP_RK3308) = sdram_rk3308.o
 obj-$(CONFIG_ROCKCHIP_RK3328) = sdram_rk3328.o sdram_pctl_px30.o sdram_phy_px30.o
 obj-$(CONFIG_ROCKCHIP_RK3399) += sdram_rk3399.o
+obj-$(CONFIG_ROCKCHIP_RK3506) += sdram_rk3506.o
 obj-$(CONFIG_ROCKCHIP_RK3528) += sdram_rk3528.o
 obj-$(CONFIG_ROCKCHIP_RK3568) += sdram_rk3568.o
 obj-$(CONFIG_ROCKCHIP_RK3576) += sdram_rk3576.o
drivers/ram/rockchip/sdram_rk3506.c new file +33 -0
new file mode 100644
index 000000000000..a8396ea88883
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// Copyright Contributors to the U-Boot project.
+
+#include <dm.h>
+#include <ram.h>
+#include <asm/arch-rockchip/sdram.h>
+
+#define PMUGRF_BASE			0xff910000
+#define OS_REG2_REG			0x208
+
+static int rk3506_dmc_get_info(struct udevice *dev, struct ram_info *info)
+{
+	info->base = CFG_SYS_SDRAM_BASE;
+	info->size = rockchip_sdram_size(PMUGRF_BASE + OS_REG2_REG);
+
+	return 0;
+}
+
+static struct ram_ops rk3506_dmc_ops = {
+	.get_info = rk3506_dmc_get_info,
+};
+
+static const struct udevice_id rk3506_dmc_ids[] = {
+	{ .compatible = "rockchip,rk3506-dmc" },
+	{ }
+};
+
+U_BOOT_DRIVER(rockchip_rk3506_dmc) = {
+	.name = "rockchip_rk3506_dmc",
+	.id = UCLASS_RAM,
+	.of_match = rk3506_dmc_ids,
+	.ops = &rk3506_dmc_ops,
+};
Signature · 1 line
2.52.0
#3 lore raw

PATCH 3/10 dt-bindings: clock: rockchip: Add RK3506 clock and reset unit

In reply to Jonas Karlman

From: Finley Xiao <[email protected]>

Add device tree bindings for clock and reset unit on RK3506 SoC. Add clock and reset IDs for RK3506 SoC.

[ upstream commit: 84898f8e9cea06f8178fc5ca53f068180f7bfba0 ]

(cherry picked from commit 516951213a82094f7f49f149cbf3c66dfb14c65d)
---
 .../Bindings/clock/rockchip,rk3506-cru.yaml   |  55 ++++
 .../dt-bindings/clock/rockchip,rk3506-cru.h   | 285 ++++++++++++++++++
 .../dt-bindings/reset/rockchip,rk3506-cru.h   | 211 +++++++++++++
 3 files changed, 551 insertions(+)
 create mode 100644 dts/upstream/Bindings/clock/rockchip,rk3506-cru.yaml
 create mode 100644 dts/upstream/include/dt-bindings/clock/rockchip,rk3506-cru.h
 create mode 100644 dts/upstream/include/dt-bindings/reset/rockchip,rk3506-cru.h
dts/upstream/Bindings/clock/rockchip,rk3506-cru.yaml new file +55 -0
new file mode 100644
index 000000000000..ca940475336c
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/rockchip,rk3506-cru.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Rockchip RK3506 Clock and Reset Unit (CRU)
+
+maintainers:
+  - Finley Xiao <[email protected]>
+  - Heiko Stuebner <[email protected]>
+
+description:
+  The RK3506 CRU generates the clock and also implements reset for SoC
+  peripherals.
+
+properties:
+  compatible:
+    const: rockchip,rk3506-cru
+
+  reg:
+    maxItems: 1
+
+  "#clock-cells":
+    const: 1
+
+  "#reset-cells":
+    const: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    const: xin
+
+required:
+  - compatible
+  - reg
+  - "#clock-cells"
+  - "#reset-cells"
+  - clocks
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@ff9a0000 {
+      compatible = "rockchip,rk3506-cru";
+      reg = <0xff9a0000 0x20000>;
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+      clocks = <&xin24m>;
+      clock-names = "xin";
+    };
dts/upstream/include/dt-bindings/clock/rockchip,rk3506-cru.h new file +285 -0

285 lines not on this page · raw message

dts/upstream/include/dt-bindings/reset/rockchip,rk3506-cru.h new file +211 -0

211 lines not on this page · raw message

Signature · 1 line
2.52.0
#4 lore raw

PATCH 4/10 clk: rockchip: Add support for RK3506

In reply to Jonas Karlman

From: Finley Xiao <[email protected]>

Add clock driver for RK3506.

Imported from vendor U-Boot linux-6.1-stan-rkr6 tag with minor adjustments and fixes for mainline.

---
 arch/arm/include/asm/arch-rockchip/clock.h    |   10 +
 .../include/asm/arch-rockchip/cru_rk3506.h    |  220 +++
 drivers/clk/rockchip/Makefile                 |    1 +
 drivers/clk/rockchip/clk_rk3506.c             | 1212 +++++++++++++++++
 drivers/reset/Makefile                        |    2 +-
 drivers/reset/rst-rk3506.c                    |  222 +++
 6 files changed, 1666 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3506.h
 create mode 100644 drivers/clk/rockchip/clk_rk3506.c
 create mode 100644 drivers/reset/rst-rk3506.c
arch/arm/include/asm/arch-rockchip/clock.h +10 -0
index 3c204501f709..95b08bfd046f 100644
@@ -214,6 +214,16 @@ int rockchip_reset_bind(struct udevice *pdev, u32 reg_offset, u32 reg_number);
  */
 int rockchip_reset_bind_lut(struct udevice *pdev, const int *lookup_table,
 			    u32 reg_offset, u32 reg_number);
+/*
+ * rk3506_reset_bind_lut() - Bind soft reset device as child of clock device
+ *			     using dedicated RK3506 lookup table
+ *
+ * @pdev: clock udevice
+ * @reg_offset: the first offset in cru for softreset registers
+ * @reg_number: the reg numbers of softreset registers
+ * Return: 0 success, or error value
+ */
+int rk3506_reset_bind_lut(struct udevice *pdev, u32 reg_offset, u32 reg_number);
 /*
  * rk3528_reset_bind_lut() - Bind soft reset device as child of clock device
  *			     using dedicated RK3528 lookup table
arch/arm/include/asm/arch-rockchip/cru_rk3506.h new file +220 -0

220 lines not on this page · raw message

drivers/clk/rockchip/Makefile +1 -0
index 34b63d4df34a..07525c364326 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_ROCKCHIP_RK3308) += clk_rk3308.o
 obj-$(CONFIG_ROCKCHIP_RK3328) += clk_rk3328.o
 obj-$(CONFIG_ROCKCHIP_RK3368) += clk_rk3368.o
 obj-$(CONFIG_ROCKCHIP_RK3399) += clk_rk3399.o
+obj-$(CONFIG_ROCKCHIP_RK3506) += clk_rk3506.o
 obj-$(CONFIG_ROCKCHIP_RK3528) += clk_rk3528.o
 obj-$(CONFIG_ROCKCHIP_RK3568) += clk_rk3568.o
 obj-$(CONFIG_ROCKCHIP_RK3576) += clk_rk3576.o
drivers/clk/rockchip/clk_rk3506.c new file +1212 -0

1,212 lines not on this page · raw message

drivers/reset/Makefile +1 -1
index ee5b009d1341..088545c64733 100644
@@ -16,7 +16,7 @@ obj-$(CONFIG_RESET_BCM6345) += reset-bcm6345.o
 obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o
 obj-$(CONFIG_RESET_AST2500) += reset-ast2500.o
 obj-$(CONFIG_RESET_AST2600) += reset-ast2600.o
-obj-$(CONFIG_RESET_ROCKCHIP) += reset-rockchip.o rst-rk3528.o rst-rk3576.o rst-rk3588.o
+obj-$(CONFIG_RESET_ROCKCHIP) += reset-rockchip.o rst-rk3506.o rst-rk3528.o rst-rk3576.o rst-rk3588.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
 obj-$(CONFIG_RESET_MEDIATEK) += reset-mediatek.o
drivers/reset/rst-rk3506.c new file +222 -0

222 lines not on this page · raw message

Signature · 1 line
2.52.0
#5 lore raw

PATCH 5/10 pinctrl: rockchip: Use syscon_regmap_lookup_by_phandle()

In reply to Jonas Karlman

Use syscon_regmap_lookup_by_phandle() to simplify the code.

---
 .../pinctrl/rockchip/pinctrl-rockchip-core.c  | 39 ++++++-------------
 1 file changed, 12 insertions(+), 27 deletions(-)
drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +12 -27
index 4de67aba1c34..273e356e7c02 100644
@@ -10,6 +10,7 @@
 #include <syscon.h>
 #include <fdtdec.h>
 #include <linux/bitops.h>
+#include <linux/err.h>
 #include <linux/libfdt.h>
 
 #include "pinctrl-rockchip.h"
@@ -641,37 +642,21 @@ int rockchip_pinctrl_probe(struct udevice *dev)
 {
 	struct rockchip_pinctrl_priv *priv = dev_get_priv(dev);
 	struct rockchip_pin_ctrl *ctrl;
-	struct udevice *syscon;
-	struct regmap *regmap;
-	int ret = 0;
 
-	/* get rockchip grf syscon phandle */
-	ret = uclass_get_device_by_phandle(UCLASS_SYSCON, dev, "rockchip,grf",
-					   &syscon);
-	if (ret) {
-		debug("unable to find rockchip,grf syscon device (%d)\n", ret);
-		return ret;
+	priv->regmap_base =
+			syscon_regmap_lookup_by_phandle(dev, "rockchip,grf");
+	if (IS_ERR(priv->regmap_base)) {
+		debug("unable to find rockchip,grf regmap\n");
+		return PTR_ERR(priv->regmap_base);
 	}
 
-	/* get grf-reg base address */
-	regmap = syscon_get_regmap(syscon);
-	if (!regmap) {
-		debug("unable to find rockchip grf regmap\n");
-		return -ENODEV;
-	}
-	priv->regmap_base = regmap;
-
-	/* option: get pmu-reg base address */
-	ret = uclass_get_device_by_phandle(UCLASS_SYSCON, dev, "rockchip,pmu",
-					   &syscon);
-	if (!ret) {
-		/* get pmugrf-reg base address */
-		regmap = syscon_get_regmap(syscon);
-		if (!regmap) {
-			debug("unable to find rockchip pmu regmap\n");
-			return -ENODEV;
+	if (dev_read_bool(dev, "rockchip,pmu")) {
+		priv->regmap_pmu =
+			syscon_regmap_lookup_by_phandle(dev, "rockchip,pmu");
+		if (IS_ERR(priv->regmap_pmu)) {
+			debug("unable to find rockchip,pmu regmap\n");
+			return PTR_ERR(priv->regmap_pmu);
 		}
-		priv->regmap_pmu = regmap;
 	}
 
 	ctrl = rockchip_pinctrl_get_soc_data(dev);
Signature · 1 line
2.52.0
#6 lore raw

PATCH 6/10 pinctrl: rockchip: Add support for RK3506

In reply to Jonas Karlman

From: Ye Zhang <[email protected]>

Add pinctrl driver for RK3506.

Imported from vendor U-Boot linux-6.1-stan-rkr6 tag with adjustments to use regmap_update_bits().

---
 drivers/pinctrl/rockchip/Makefile             |   1 +
 drivers/pinctrl/rockchip/pinctrl-rk3506.c     | 462 ++++++++++++++++++
 .../pinctrl/rockchip/pinctrl-rockchip-core.c  |   9 +
 drivers/pinctrl/rockchip/pinctrl-rockchip.h   |   1 +
 4 files changed, 473 insertions(+)
 create mode 100644 drivers/pinctrl/rockchip/pinctrl-rk3506.c
drivers/pinctrl/rockchip/Makefile +1 -0
index e17415e1ca68..0405df128dfa 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_ROCKCHIP_RK3308) += pinctrl-rk3308.o
 obj-$(CONFIG_ROCKCHIP_RK3328) += pinctrl-rk3328.o
 obj-$(CONFIG_ROCKCHIP_RK3368) += pinctrl-rk3368.o
 obj-$(CONFIG_ROCKCHIP_RK3399) += pinctrl-rk3399.o
+obj-$(CONFIG_ROCKCHIP_RK3506) += pinctrl-rk3506.o
 obj-$(CONFIG_ROCKCHIP_RK3528) += pinctrl-rk3528.o
 obj-$(CONFIG_ROCKCHIP_RK3568) += pinctrl-rk3568.o
 obj-$(CONFIG_ROCKCHIP_RK3576) += pinctrl-rk3576.o
drivers/pinctrl/rockchip/pinctrl-rk3506.c new file +462 -0

462 lines not on this page · raw message

drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +9 -0
index 273e356e7c02..957dcb520591 100644
@@ -659,6 +659,15 @@ int rockchip_pinctrl_probe(struct udevice *dev)
 		}
 	}
 
+	if (dev_read_bool(dev, "rockchip,ioc1")) {
+		priv->regmap_ioc1 =
+			syscon_regmap_lookup_by_phandle(dev, "rockchip,ioc1");
+		if (IS_ERR(priv->regmap_ioc1)) {
+			debug("unable to find rockchip,ioc1 regmap\n");
+			return PTR_ERR(priv->regmap_ioc1);
+		}
+	}
+
 	ctrl = rockchip_pinctrl_get_soc_data(dev);
 	if (!ctrl) {
 		debug("driver data not available\n");
drivers/pinctrl/rockchip/pinctrl-rockchip.h +1 -0
index ba684baed24d..568e6024b78c 100644
@@ -528,6 +528,7 @@ struct rockchip_pinctrl_priv {
 	struct rockchip_pin_ctrl	*ctrl;
 	struct regmap			*regmap_base;
 	struct regmap			*regmap_pmu;
+	struct regmap			*regmap_ioc1;
 };
 
 extern const struct pinctrl_ops rockchip_pinctrl_ops;
Signature · 1 line
2.52.0
#7 lore raw

PATCH 7/10 rockchip: otp: Add support for RK3506

In reply to Jonas Karlman

Add support for the OTP controller in RK3506. The OTPC is similar to the OTPC in RK3568 and can use the same ops for reading OTP data.

---
 drivers/misc/rockchip-otp.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/misc/rockchip-otp.c +4 -0
index 46820425a84d..64b6238981b8 100644
@@ -390,6 +390,10 @@ static const struct udevice_id rockchip_otp_ids[] = {
 		.compatible = "rockchip,rk3308-otp",
 		.data = (ulong)&px30_data,
 	},
+	{
+		.compatible = "rockchip,rk3506-otp",
+		.data = (ulong)&rk3568_data,
+	},
 	{
 		.compatible = "rockchip,rk3528-otp",
 		.data = (ulong)&rk3568_data,
Signature · 1 line
2.52.0
#8 lore raw

PATCH 8/10 phy: rockchip-inno-usb2: Add support for RK3506

In reply to Jonas Karlman

Add support for the two USB2.0 PHYs use in the RK3506 SoC.

---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +20 -0
index 4ea6600ce7f5..f80b2789333d 100644
@@ -421,6 +421,22 @@ static const struct rockchip_usb2phy_cfg rk3399_usb2phy_cfgs[] = {
 	{ /* sentinel */ }
 };
 
+static const struct rockchip_usb2phy_cfg rk3506_phy_cfgs[] = {
+	{
+		.reg		= 0xff2b0000,
+		.clkout_ctl_phy = { 0x041c, 7, 2, 0, 0x27 },
+		.port_cfgs	= {
+			[USB2PHY_PORT_OTG] = {
+				.phy_sus	= { 0x0060, 1, 0, 2, 1 },
+			},
+			[USB2PHY_PORT_HOST] = {
+				.phy_sus	= { 0x0070, 1, 0, 2, 1 },
+			}
+		},
+	},
+	{ /* sentinel */ }
+};
+
 static const struct rockchip_usb2phy_cfg rk3528_phy_cfgs[] = {
 	{
 		.reg		= 0xffdf0000,
@@ -540,6 +556,10 @@ static const struct udevice_id rockchip_usb2phy_ids[] = {
 		.compatible = "rockchip,rk3399-usb2phy",
 		.data = (ulong)&rk3399_usb2phy_cfgs,
 	},
+	{
+		.compatible = "rockchip,rk3506-usb2phy",
+		.data = (ulong)&rk3506_phy_cfgs,
+	},
 	{
 		.compatible = "rockchip,rk3528-usb2phy",
 		.data = (ulong)&rk3528_phy_cfgs,
Signature · 1 line
2.52.0
#9 lore raw

PATCH 9/10 net: dwc_eth_qos_rockchip: Add support for RK3506

In reply to Jonas Karlman

Rockchip RK3506 has two Ethernet controllers based on Synopsys DWC Ethernet QoS IP.

Add initial support for the RK3506 GMAC variant.

---
 drivers/net/dwc_eth_qos.c          |  4 ++
 drivers/net/dwc_eth_qos_rockchip.c | 86 ++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
drivers/net/dwc_eth_qos.c +4 -0
index 551ee0ea6a02..d320646b57f5 100644
@@ -1615,6 +1615,10 @@ static const struct udevice_id eqos_ids[] = {
 	},
 #endif
 #if IS_ENABLED(CONFIG_DWC_ETH_QOS_ROCKCHIP)
+	{
+		.compatible = "rockchip,rk3506-gmac",
+		.data = (ulong)&eqos_rockchip_config
+	},
 	{
 		.compatible = "rockchip,rk3528-gmac",
 		.data = (ulong)&eqos_rockchip_config
drivers/net/dwc_eth_qos_rockchip.c +86 -0

98 lines not on this page · raw message

Signature · 1 line
2.52.0
#10 lore raw

PATCH 10/10 arch: arm: rockchip: Add initial support for RK3506

In reply to Jonas Karlman

Rockchip RK3506 is a ARM-based SoC with tri-core Cortex-A7.

Add initial arch support for the RK3506 SoC.

---
 arch/arm/include/asm/arch-rk3506/boot0.h      |   9 ++
 arch/arm/include/asm/arch-rk3506/gpio.h       |   9 ++
 arch/arm/mach-rockchip/Kconfig                |  43 ++++++
 arch/arm/mach-rockchip/Makefile               |   1 +
 arch/arm/mach-rockchip/rk3506/Kconfig         |  15 ++
 arch/arm/mach-rockchip/rk3506/Makefile        |   5 +
 arch/arm/mach-rockchip/rk3506/clk_rk3506.c    |  16 +++
 arch/arm/mach-rockchip/rk3506/rk3506.c        | 130 ++++++++++++++++++
 arch/arm/mach-rockchip/rk3506/syscon_rk3506.c |  19 +++
 drivers/usb/gadget/Kconfig                    |   1 +
 include/configs/rk3506_common.h               |  38 +++++
 11 files changed, 286 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rk3506/boot0.h
 create mode 100644 arch/arm/include/asm/arch-rk3506/gpio.h
 create mode 100644 arch/arm/mach-rockchip/rk3506/Kconfig
 create mode 100644 arch/arm/mach-rockchip/rk3506/Makefile
 create mode 100644 arch/arm/mach-rockchip/rk3506/clk_rk3506.c
 create mode 100644 arch/arm/mach-rockchip/rk3506/rk3506.c
 create mode 100644 arch/arm/mach-rockchip/rk3506/syscon_rk3506.c
 create mode 100644 include/configs/rk3506_common.h
arch/arm/include/asm/arch-rk3506/boot0.h new file +9 -0
new file mode 100644
index 000000000000..8ae46f25a87a
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright Contributors to the U-Boot project. */
+
+#ifndef __ASM_ARCH_BOOT0_H__
+#define __ASM_ARCH_BOOT0_H__
+
+#include <asm/arch-rockchip/boot0.h>
+
+#endif
arch/arm/include/asm/arch-rk3506/gpio.h new file +9 -0
new file mode 100644
index 000000000000..5516e649b80b
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright Contributors to the U-Boot project. */
+
+#ifndef __ASM_ARCH_GPIO_H__
+#define __ASM_ARCH_GPIO_H__
+
+#include <asm/arch-rockchip/gpio.h>
+
+#endif
arch/arm/mach-rockchip/Kconfig +43 -0

55 lines not on this page · raw message

arch/arm/mach-rockchip/Makefile +1 -0
index 06fb527b21a0..d3bc0689f893 100644
@@ -42,6 +42,7 @@ obj-$(CONFIG_ROCKCHIP_RK3308) += rk3308/
 obj-$(CONFIG_ROCKCHIP_RK3328) += rk3328/
 obj-$(CONFIG_ROCKCHIP_RK3368) += rk3368/
 obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399/
+obj-$(CONFIG_ROCKCHIP_RK3506) += rk3506/
 obj-$(CONFIG_ROCKCHIP_RK3528) += rk3528/
 obj-$(CONFIG_ROCKCHIP_RK3568) += rk3568/
 obj-$(CONFIG_ROCKCHIP_RK3576) += rk3576/
arch/arm/mach-rockchip/rk3506/Kconfig new file +15 -0
new file mode 100644
index 000000000000..92f187458c66
@@ -0,0 +1,15 @@
+if ROCKCHIP_RK3506
+
+config ROCKCHIP_BOOT_MODE_REG
+	default 0xff910200
+
+config ROCKCHIP_STIMER_BASE
+	default 0xff980000
+
+config SYS_SOC
+	default "rk3506"
+
+config SYS_CONFIG_NAME
+	default "rk3506_common"
+
+endif
arch/arm/mach-rockchip/rk3506/Makefile new file +5 -0
new file mode 100644
index 000000000000..a1760bd0f0a3
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+obj-y += rk3506.o
+obj-y += clk_rk3506.o
+obj-y += syscon_rk3506.o
arch/arm/mach-rockchip/rk3506/clk_rk3506.c new file +16 -0
new file mode 100644
index 000000000000..ee40e108886c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// Copyright Contributors to the U-Boot project.
+
+#include <dm.h>
+#include <asm/arch-rockchip/cru_rk3506.h>
+
+int rockchip_get_clk(struct udevice **devp)
+{
+	return uclass_get_device_by_driver(UCLASS_CLK,
+				DM_DRIVER_GET(rockchip_rk3506_cru), devp);
+}
+
+void *rockchip_get_cru(void)
+{
+	return RK3506_CRU_BASE;
+}
arch/arm/mach-rockchip/rk3506/rk3506.c new file +130 -0

130 lines not on this page · raw message

arch/arm/mach-rockchip/rk3506/syscon_rk3506.c new file +19 -0
new file mode 100644
index 000000000000..2548b0fa2d3a
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// Copyright Contributors to the U-Boot project.
+
+#include <dm.h>
+#include <asm/arch-rockchip/clock.h>
+
+static const struct udevice_id rk3506_syscon_ids[] = {
+	{ .compatible = "rockchip,rk3506-grf", .data = ROCKCHIP_SYSCON_GRF },
+	{ }
+};
+
+U_BOOT_DRIVER(rockchip_rk3506_syscon) = {
+	.name = "rockchip_rk3506_syscon",
+	.id = UCLASS_SYSCON,
+	.of_match = rk3506_syscon_ids,
+#if CONFIG_IS_ENABLED(OF_REAL)
+	.bind = dm_scan_fdt_dev,
+#endif
+};
drivers/usb/gadget/Kconfig +1 -0
index 7e08aeab9043..82a784d2fb00 100644
@@ -89,6 +89,7 @@ config USB_GADGET_PRODUCT_NUM
 	default 0x350b if ROCKCHIP_RK3588
 	default 0x350c if ROCKCHIP_RK3528
 	default 0x350e if ROCKCHIP_RK3576
+	default 0x350f if ROCKCHIP_RK3506
 	default 0x4ee0 if ARCH_QCOM
 	default 0x0
 	help
include/configs/rk3506_common.h new file +38 -0
new file mode 100644
index 000000000000..5e4ef67289f0
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright Contributors to the U-Boot project. */
+
+#ifndef __CONFIG_RK3506_COMMON_H
+#define __CONFIG_RK3506_COMMON_H
+
+#define CFG_CPUID_OFFSET		0xa
+
+#include "rockchip-common.h"
+
+#define CFG_IRAM_BASE			0xfff80000
+
+#define CFG_SYS_SDRAM_BASE		0
+#define SDRAM_MAX_SIZE			0xc0000000
+
+#ifndef ROCKCHIP_DEVICE_SETTINGS
+#define ROCKCHIP_DEVICE_SETTINGS
+#endif
+
+#define ENV_MEM_LAYOUT_SETTINGS			\
+	"scriptaddr=0x00500000\0"		\
+	"script_offset_f=0xffe000\0"		\
+	"script_size_f=0x2000\0"		\
+	"pxefile_addr_r=0x00600000\0"		\
+	"kernel_addr_r=0x02080000\0"		\
+	"kernel_comp_addr_r=0x08000000\0"	\
+	"fdt_addr_r=0x01e00000\0"		\
+	"fdtoverlay_addr_r=0x01f00000\0"	\
+	"ramdisk_addr_r=0x06000000\0"		\
+	"kernel_comp_size=0x2000000\0"
+
+#define CFG_EXTRA_ENV_SETTINGS			\
+	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"	\
+	ENV_MEM_LAYOUT_SETTINGS			\
+	ROCKCHIP_DEVICE_SETTINGS		\
+	"boot_targets=" BOOT_TARGETS "\0"
+
+#endif /* __CONFIG_RK3506_COMMON_H */
Signature · 1 line
2.52.0
Tested-by on the v1 series
#12 lore raw
In reply to Jonas Karlman

Hello Jonas,

Quoted 3 lines · Jonas Karlman

This series add initial support for the Rockchip RK3506 SoC.

[..]

#

Quoted 3 lines

With this series, board DTs and defconfigs it should be possible to boot into U-Boot proper (without OP-TEE) and still have support for MMC, Ethernet, OTP, RNG, LEDs, buttons and USB gadget/host.

I have a Luckfox Lyra Pi W board (with RK3506B) and a Luckfox Lyra (with RK3506G). I've been using the earlier version of this patchset for about two weeks to successfully boot Linux on both of these boards. I'm excited to see this support heading upstream.

Using these patches specifically, I can verify that the RNG and LEDs work, that it is able to read data from the MMC and USB storage, and that it successfully loads and runs a Linux kernel.

I was not able to get the Ethernet port to work on my Lyra Pi board, but that uses your device tree information that is not part of these patches (and may be incomplete). The specific failure U-boot reports is:

ethernet@ff4d0000 Waiting for PHY auto negotiation to complete......... TIMEOUT !

So, for what it's worth,

Thanks,
-Aaron

#13 lore raw

Hi Aaron,

Quoted 20 lines · Aaron Griffith

Hello Jonas,

Quoted 3 lines · Jonas Karlman

This series add initial support for the Rockchip RK3506 SoC.

[..]

#

Quoted 3 lines

With this series, board DTs and defconfigs it should be possible to boot into U-Boot proper (without OP-TEE) and still have support for MMC, Ethernet, OTP, RNG, LEDs, buttons and USB gadget/host.

I have a Luckfox Lyra Pi W board (with RK3506B) and a Luckfox Lyra (with RK3506G). I've been using the earlier version of this patchset for about two weeks to successfully boot Linux on both of these boards. I'm excited to see this support heading upstream.

Using these patches specifically, I can verify that the RNG and LEDs work, that it is able to read data from the MMC and USB storage, and that it successfully loads and runs a Linux kernel.

Quoted 6 lines

I was not able to get the Ethernet port to work on my Lyra Pi board, but that uses your device tree information that is not part of these patches (and may be incomplete). The specific failure U-boot reports is:

ethernet@ff4d0000 Waiting for PHY auto negotiation to complete......... TIMEOUT !

Thanks for testing these patches!

I did some testing on my Luckfox Lyra Pi W (eMMC) board and also found similar issues that you report.

These issues mostly seem to be related to firewall for USB OTG1 and MAC1 (ff4d0000) or DT issues related to Ethernet clocks and pinctrl.

The firewall values before we update them in arch_cpu_init():

=> md.l ff5f0020 5
ff5f0020: ffffffff ffffffff ffffffff ffffff00 ................
ff5f0030: ffffffff ....

The following firewall values seem to help fix MAC0/1 and USB OTG1:

=> md.l ff5f0020 5
ff5f0020: ffffffff f00000ff fffffff0 fff0ff00 ................
ff5f0030: ffffffff ....

We could possible set all these to 0 to allow all masters to access memory, will send a v2 that configures the firewall like above.

Adding something like following to the ethernet-phy nodes seem to solve the Ethernet issues in U-Boot on my Lyra Pi:

  assigned-clocks = <&cru CLK_MAC_OUT>;
  assigned-clock-rates = <50000000>;
  clocks = <&cru CLK_MAC_OUT>;
  pinctrl-names = "default";
  pinctrl-0 = <&eth_clk0_25m_out>;
    or
  pinctrl-0 = <&eth_clk1_25m_out>;

Vendor DT for Lyra Pi seem to set CLK_MAC_OUT to 25 MHz, but this does not seem to work in U-Boot and I can not see anything wrong in the clk driver, so maybe it is meant to be set to 50 MHz.

Will update my rk3506 branch to include these changes and later also send out a v2 of this series including the firewall fix.

Regards,
Jonas

Quoted 7 lines

So, for what it's worth,

Thanks,
-Aaron