Skip to contentSkip to conversation

rockchip: Add initial RK3582 support

PATCH In review Jonas Karlman 4 participants 16 messages Jan 7 – Mar 9

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

v4 cover rockchip: Add initial RK3582 support

This series add initial support for RK3582 support. The RK3582 is a variant of the RK3588S with a few ip blocks disabled. What blocks are disabled/non-working is indicated by the ip-state in OTP.

Compared to the vendor U-Boot variant, this mark cpu, the gpu and vdec/venc with status=fail instead of removing nodes during DT fixup. Linux skip cpu cores marked as failed staring from v5.17-rc1, however the GIC driver will generate a harmless WARN_ON that safely can be ignored. A patch for Linux will be sent to skip the WARN_ON for failed/disabled cpu cores once this lands.

It is recommended to use rk3588_ddr_lp4_1848MHz_lp5_2112MHz_v1.19.bin as DRAM init blob RK3582, listed in latest RKBOOT/RK3582MINIALL.ini.

Changes in v4:
- Update policy to always fail gpu for RK3582
- Drop code and comment related to RK3583
- Update rkvdec node name to match latest mainline Linux DT patches
- Update commit message to reflect updated policy

Changes in v3:
- Apply same policy for RK3582/RK3583 to match vendor U-Boot linux-6.1-stan-rkr6 tag, allow use of the GPU and one vdec core.
- Update rkvdec node name to match latest mainline Linux DT patches.
- Update commit message to reflect updated policy

Changes in v2:
- Refactor code to first apply policy to ip-state and then fail cores based on the updated ip-state
- Add support for failing rkvdec and rkvenc cores
- Append soc compatible to board model
- Add patch to add support for ROCK 5C Lite variant

Jonas Karlman (3):
rockchip: Add initial RK3582 support
rockchip: rk3588-generic: Enable support for RK3582
rockchip: rk3588s-rock-5c: Add support for ROCK 5C Lite variant

 arch/arm/dts/rk3588-generic.dts        |   4 +-
 arch/arm/mach-rockchip/rk3588/Kconfig  |   9 +-
 arch/arm/mach-rockchip/rk3588/rk3588.c | 215 +++++++++++++++++++++++++
 configs/generic-rk3588_defconfig       |   1 +
 configs/rock-5c-rk3588s_defconfig      |   1 +
 doc/board/rockchip/rockchip.rst        |   4 +-
 6 files changed, 226 insertions(+), 8 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH v4 1/3 rockchip: Add initial RK3582 support

The RK3582 SoC is a variant of the RK3588S with some IP blocks disabled. What blocks are disabled/non-working is indicated by ip-state in OTP.

This add initial support for RK3582 by using ft_system_setup() to mark any cpu, gpu and/or vdec/venc node with status=fail as indicated by ip-state.

This apply same policy as vendor U-Boot for RK3582, i.e. two big cpu cores, the gpu and one vdec/venc core is always failed/disabled.

Enable Kconfig option OF_SYSTEM_SETUP in board defconfig to make use of the required DT fixups for RK3582 board variants.

---
Changes in v4:
- Update policy to always fail gpu for RK3582
- Drop code and comment related to RK3583
- Update rkvdec node name to match latest mainline Linux DT patches

Changes in v3:
- Apply same policy for RK3582/RK3583 to match vendor U-Boot linux-6.1-stan-rkr6 tag, allow use of the GPU and one vdec core.
- Update rkvdec node name to match latest mainline Linux DT patches.

Changes in v2:
- Refactor code to first apply policy to ip-state and then fail cores based on the updated ip-state
- Add support for failing rkvdec and rkvenc cores
- Append soc compatible to board model
- Not picking up t-b tag due to significant changes to patch

---
 arch/arm/mach-rockchip/rk3588/rk3588.c | 215 +++++++++++++++++++++++++
 1 file changed, 215 insertions(+)
arch/arm/mach-rockchip/rk3588/rk3588.c +215 -0
index 6324c6f12867..c1138ffcb87f 100644
@@ -7,6 +7,7 @@
 #define LOG_CATEGORY LOGC_ARCH
 
 #include <dm.h>
+#include <fdt_support.h>
 #include <misc.h>
 #include <spl.h>
 #include <asm/armv8/mmu.h>
@@ -240,6 +241,16 @@ int rockchip_dram_init_banksize_fixup(struct bd_info *bd)
 
 #define RK3588_OTP_CPU_CODE_OFFSET		0x02
 #define RK3588_OTP_SPECIFICATION_OFFSET		0x06
+#define RK3588_OTP_IP_STATE_OFFSET		0x1d
+
+#define FAIL_CPU_CLUSTER0		GENMASK(3, 0)
+#define FAIL_CPU_CLUSTER1		GENMASK(5, 4)
+#define FAIL_CPU_CLUSTER2		GENMASK(7, 6)
+#define FAIL_GPU			GENMASK(4, 1)
+#define FAIL_RKVDEC0			BIT(6)
+#define FAIL_RKVDEC1			BIT(7)
+#define FAIL_RKVENC0			BIT(0)
+#define FAIL_RKVENC1			BIT(2)
 
 int checkboard(void)
 {
@@ -285,3 +296,207 @@ int checkboard(void)
 
 	return 0;
 }
+
+static int fdt_path_del_node(void *fdt, const char *path)
+{
+	int nodeoffset;
+
+	nodeoffset = fdt_path_offset(fdt, path);
+	if (nodeoffset < 0)
+		return nodeoffset;
+
+	return fdt_del_node(fdt, nodeoffset);
+}
+
+static int fdt_path_set_name(void *fdt, const char *path, const char *name)
+{
+	int nodeoffset;
+
+	nodeoffset = fdt_path_offset(fdt, path);
+	if (nodeoffset < 0)
+		return nodeoffset;
+
+	return fdt_set_name(fdt, nodeoffset, name);
+}
+
+/*
+ * RK3582 is a variant of the RK3588S with some IP blocks disabled. What blocks
+ * are disabled/non-working is indicated by ip-state in OTP. ft_system_setup()
+ * is used to mark any cpu, gpu and/or vdec/venc node with status=fail as
+ * indicated by ip-state. Apply same policy as vendor U-Boot for RK3582, i.e.
+ * two big cpu cores, the gpu and one vdec/venc core is always failed. Enable
+ * OF_SYSTEM_SETUP to use the required DT fixups for RK3582 board variants.
+ */
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+	static const char * const cpu_node_names[] = {
+		"cpu@0", "cpu@100", "cpu@200", "cpu@300",
+		"cpu@400", "cpu@500", "cpu@600", "cpu@700",
+	};
+	int parent, node, i, comp_len, len, ret;
+	bool cluster1_removed = false;
+	u8 cpu_code[2], ip_state[3];
+	struct udevice *dev;
+	char soc_comp[16];
+	const char *comp;
+	void *data;
+
+	if (!IS_ENABLED(CONFIG_OF_SYSTEM_SETUP))
+		return 0;
+
+	if (!IS_ENABLED(CONFIG_ROCKCHIP_OTP) || !CONFIG_IS_ENABLED(MISC))
+		return -ENOSYS;
+
+	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 ret;
+	}
+
+	/* cpu-code: SoC model, e.g. 0x35 0x82 or 0x35 0x88 */
+	ret = misc_read(dev, RK3588_OTP_CPU_CODE_OFFSET, cpu_code, 2);
+	if (ret < 0) {
+		log_debug("Could not read cpu-code, ret=%d\n", ret);
+		return ret;
+	}
+
+	log_debug("cpu-code: %02x %02x\n", cpu_code[0], cpu_code[1]);
+
+	/* only fail cores on rk3582 */
+	if (!(cpu_code[0] == 0x35 && cpu_code[1] == 0x82))
+		return 0;
+
+	ret = misc_read(dev, RK3588_OTP_IP_STATE_OFFSET, &ip_state, 3);
+	if (ret < 0) {
+		log_err("Could not read ip-state, ret=%d\n", ret);
+		return ret;
+	}
+
+	log_debug("ip-state: %02x %02x %02x (otp)\n",
+		  ip_state[0], ip_state[1], ip_state[2]);
+
+	/* policy: fail entire big core cluster when one or more core is bad */
+	if (ip_state[0] & FAIL_CPU_CLUSTER1)
+		ip_state[0] |= FAIL_CPU_CLUSTER1;
+	if (ip_state[0] & FAIL_CPU_CLUSTER2)
+		ip_state[0] |= FAIL_CPU_CLUSTER2;
+
+	/* policy: always fail one big core cluster on rk3582 */
+	if (!(ip_state[0] & (FAIL_CPU_CLUSTER1 | FAIL_CPU_CLUSTER2)))
+		ip_state[0] |= FAIL_CPU_CLUSTER2;
+
+	/* policy: always fail gpu on rk3582 */
+	ip_state[1] |= FAIL_GPU;
+
+	/* policy: always fail one rkvdec core on rk3582 */
+	if (!(ip_state[1] & (FAIL_RKVDEC0 | FAIL_RKVDEC1)))
+		ip_state[1] |= FAIL_RKVDEC1;
+
+	/* policy: always fail one rkvenc core on rk3582 */
+	if (!(ip_state[2] & (FAIL_RKVENC0 | FAIL_RKVENC1)))
+		ip_state[2] |= FAIL_RKVENC1;
+
+	log_debug("ip-state: %02x %02x %02x (policy)\n",
+		  ip_state[0], ip_state[1], ip_state[2]);
+
+	/* cpu cluster1: ip_state[0]: bit4~5 */
+	if ((ip_state[0] & FAIL_CPU_CLUSTER1) == FAIL_CPU_CLUSTER1) {
+		log_debug("remove cpu-map cluster1\n");
+		fdt_path_del_node(blob, "/cpus/cpu-map/cluster1");
+		cluster1_removed = true;
+	}
+
+	/* cpu cluster2: ip_state[0]: bit6~7 */
+	if ((ip_state[0] & FAIL_CPU_CLUSTER2) == FAIL_CPU_CLUSTER2) {
+		log_debug("remove cpu-map cluster2\n");
+		fdt_path_del_node(blob, "/cpus/cpu-map/cluster2");
+	} else if (cluster1_removed) {
+		/* cluster nodes must be named in a continuous series */
+		log_debug("rename cpu-map cluster2\n");
+		fdt_path_set_name(blob, "/cpus/cpu-map/cluster2", "cluster1");
+	}
+
+	/* gpu: ip_state[1]: bit1~4 */
+	if (ip_state[1] & FAIL_GPU) {
+		log_debug("fail gpu\n");
+		fdt_status_fail_by_pathf(blob, "/gpu@fb000000");
+	}
+
+	/* rkvdec: ip_state[1]: bit6,7 */
+	if (ip_state[1] & FAIL_RKVDEC0) {
+		log_debug("fail rkvdec0\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdc38000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdc38700");
+	}
+	if (ip_state[1] & FAIL_RKVDEC1) {
+		log_debug("fail rkvdec1\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdc40000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdc40700");
+	}
+
+	/* rkvenc: ip_state[2]: bit0,2 */
+	if (ip_state[2] & FAIL_RKVENC0) {
+		log_debug("fail rkvenc0\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdbd0000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdbdf000");
+	}
+	if (ip_state[2] & FAIL_RKVENC1) {
+		log_debug("fail rkvenc1\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdbe0000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdbef000");
+	}
+
+	parent = fdt_path_offset(blob, "/cpus");
+	if (parent < 0) {
+		log_err("Could not find /cpus, parent=%d\n", parent);
+		return parent;
+	}
+
+	/* cpu: ip_state[0]: bit0~7 */
+	for (i = 0; i < 8; i++) {
+		/* fail any bad cpu core */
+		if (!(ip_state[0] & BIT(i)))
+			continue;
+
+		node = fdt_subnode_offset(blob, parent, cpu_node_names[i]);
+		if (node >= 0) {
+			log_debug("fail cpu %s\n", cpu_node_names[i]);
+			fdt_status_fail(blob, node);
+		} else {
+			log_err("Could not find %s, node=%d\n",
+				cpu_node_names[i], node);
+			return node;
+		}
+	}
+
+	node = fdt_path_offset(blob, "/");
+	if (node < 0) {
+		log_err("Could not find /, node=%d\n", node);
+		return node;
+	}
+
+	snprintf(soc_comp, sizeof(soc_comp), "rockchip,rk35%x", cpu_code[1]);
+
+	for (i = 0, comp_len = 0;
+	     (comp = fdt_stringlist_get(blob, node, "compatible", i, &len));
+	     i++) {
+		/* stop at soc compatible */
+		if (!strcmp(comp, soc_comp) ||
+		    !strcmp(comp, "rockchip,rk3588s") ||
+		    !strcmp(comp, "rockchip,rk3588"))
+			break;
+
+		log_debug("compatible[%d]: %s\n", i, comp);
+		comp_len += len + 1;
+	}
+
+	/* truncate to only include board compatible */
+	fdt_setprop_placeholder(blob, node, "compatible", comp_len, &data);
+
+	/* append soc compatible */
+	fdt_appendprop_string(blob, node, "compatible", soc_comp);
+	fdt_appendprop_string(blob, node, "compatible", "rockchip,rk3588s");
+
+	return 0;
+}
Signature · 1 line
2.52.0
#2 lore raw

Hi Jonas,

Quoted 13 lines · Jonas Karlman

The RK3582 SoC is a variant of the RK3588S with some IP blocks disabled. What blocks are disabled/non-working is indicated by ip-state in OTP.

This add initial support for RK3582 by using ft_system_setup() to mark any cpu, gpu and/or vdec/venc node with status=fail as indicated by ip-state.

This apply same policy as vendor U-Boot for RK3582, i.e. two big cpu cores, the gpu and one vdec/venc core is always failed/disabled.

Enable Kconfig option OF_SYSTEM_SETUP in board defconfig to make use of the required DT fixups for RK3582 board variants.

Quoted 7 lines

---
Changes in v4:
- Update policy to always fail gpu for RK3582
- Drop code and comment related to RK3583
- Update rkvdec node name to match latest mainline Linux DT patches

Should we really patch the rkvdec nodes if they aren't stable yet? But I see this is something I already reported on v3 and said it's up to Kever :) Should we support booting downstream kernel with (I assume) its different paths?

Quoted 61 lines

Changes in v3:
- Apply same policy for RK3582/RK3583 to match vendor U-Boot linux-6.1-stan-rkr6 tag, allow use of the GPU and one vdec core.
- Update rkvdec node name to match latest mainline Linux DT patches.

Changes in v2:
- Refactor code to first apply policy to ip-state and then fail cores based on the updated ip-state
- Add support for failing rkvdec and rkvenc cores
- Append soc compatible to board model
- Not picking up t-b tag due to significant changes to patch

---
  arch/arm/mach-rockchip/rk3588/rk3588.c | 215 +++++++++++++++++++++++++
  1 file changed, 215 insertions(+)
arch/arm/mach-rockchip/rk3588/rk3588.c +24 -0
index 6324c6f12867..c1138ffcb87f 100644
@@ -7,6 +7,7 @@
  #define LOG_CATEGORY LOGC_ARCH
 
  #include <dm.h>
+#include <fdt_support.h>
  #include <misc.h>
  #include <spl.h>
  #include <asm/armv8/mmu.h>
@@ -240,6 +241,16 @@ int rockchip_dram_init_banksize_fixup(struct bd_info *bd)
 
  #define RK3588_OTP_CPU_CODE_OFFSET		0x02
  #define RK3588_OTP_SPECIFICATION_OFFSET		0x06
+#define RK3588_OTP_IP_STATE_OFFSET		0x1d
+
+#define FAIL_CPU_CLUSTER0		GENMASK(3, 0)
+#define FAIL_CPU_CLUSTER1		GENMASK(5, 4)
+#define FAIL_CPU_CLUSTER2		GENMASK(7, 6)
+#define FAIL_GPU			GENMASK(4, 1)
+#define FAIL_RKVDEC0			BIT(6)
+#define FAIL_RKVDEC1			BIT(7)
+#define FAIL_RKVENC0			BIT(0)
+#define FAIL_RKVENC1			BIT(2)
 
  int checkboard(void)
  {
@@ -285,3 +296,207 @@ int checkboard(void)
 
  	return 0;
  }
+
+static int fdt_path_del_node(void *fdt, const char *path)
+{
+	int nodeoffset;
+
+	nodeoffset = fdt_path_offset(fdt, path);
+	if (nodeoffset < 0)
+		return nodeoffset;
+
+	return fdt_del_node(fdt, nodeoffset);
+}
+
+static int fdt_path_set_name(void *fdt, const char *path, const char *name)

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 321

Quoted 10 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +10 -0
+{
+	int nodeoffset;
+
+	nodeoffset = fdt_path_offset(fdt, path);
+	if (nodeoffset < 0)
+		return nodeoffset;
+
+	return fdt_set_name(fdt, nodeoffset, name);
+}
+

Wondering if we shouldn't have a name that is a bit less close to what you would find as API in include/fdt_support.h or libfdt? SO there's no confusion when reading the code where there are callers to this function?

Quoted 15 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +15 -0
+/*
+ * RK3582 is a variant of the RK3588S with some IP blocks disabled. What blocks
+ * are disabled/non-working is indicated by ip-state in OTP. ft_system_setup()
+ * is used to mark any cpu, gpu and/or vdec/venc node with status=fail as
+ * indicated by ip-state. Apply same policy as vendor U-Boot for RK3582, i.e.
+ * two big cpu cores, the gpu and one vdec/venc core is always failed. Enable
+ * OF_SYSTEM_SETUP to use the required DT fixups for RK3582 board variants.
+ */
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+	static const char * const cpu_node_names[] = {
+		"cpu@0", "cpu@100", "cpu@200", "cpu@300",
+		"cpu@400", "cpu@500", "cpu@600", "cpu@700",
+	};
+	int parent, node, i, comp_len, len, ret;

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 346

Quoted 10 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +10 -0
+	bool cluster1_removed = false;
+	u8 cpu_code[2], ip_state[3];
+	struct udevice *dev;
+	char soc_comp[16];
+	const char *comp;
+	void *data;
+
+	if (!IS_ENABLED(CONFIG_OF_SYSTEM_SETUP))
+		return 0;
+

Isn't that guaranteed to be the case as ft_system_setup is only called when CONFIG_OF_SYSTEM_SETUP is set? What are you trying to prevent (e.g. compilation warnings?).

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 349

Quoted 3 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +3 -0
+	if (!IS_ENABLED(CONFIG_ROCKCHIP_OTP) || !CONFIG_IS_ENABLED(MISC))
+		return -ENOSYS;
+

This means that if one enables OF_SYSTEM_SETUP but not ROCKCHIP_OTP or MISC, then this will fail the boot even on RK3588(s), correct?

Should we add a select/depends on in Kconfig somewhere so this cannot happen?

Quoted 47 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +47 -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 ret;
+	}
+
+	/* cpu-code: SoC model, e.g. 0x35 0x82 or 0x35 0x88 */
+	ret = misc_read(dev, RK3588_OTP_CPU_CODE_OFFSET, cpu_code, 2);
+	if (ret < 0) {
+		log_debug("Could not read cpu-code, ret=%d\n", ret);
+		return ret;
+	}
+
+	log_debug("cpu-code: %02x %02x\n", cpu_code[0], cpu_code[1]);
+
+	/* only fail cores on rk3582 */
+	if (!(cpu_code[0] == 0x35 && cpu_code[1] == 0x82))
+		return 0;
+
+	ret = misc_read(dev, RK3588_OTP_IP_STATE_OFFSET, &ip_state, 3);
+	if (ret < 0) {
+		log_err("Could not read ip-state, ret=%d\n", ret);
+		return ret;
+	}
+
+	log_debug("ip-state: %02x %02x %02x (otp)\n",
+		  ip_state[0], ip_state[1], ip_state[2]);
+
+	/* policy: fail entire big core cluster when one or more core is bad */
+	if (ip_state[0] & FAIL_CPU_CLUSTER1)
+		ip_state[0] |= FAIL_CPU_CLUSTER1;
+	if (ip_state[0] & FAIL_CPU_CLUSTER2)
+		ip_state[0] |= FAIL_CPU_CLUSTER2;
+
+	/* policy: always fail one big core cluster on rk3582 */
+	if (!(ip_state[0] & (FAIL_CPU_CLUSTER1 | FAIL_CPU_CLUSTER2)))
+		ip_state[0] |= FAIL_CPU_CLUSTER2;
+
+	/* policy: always fail gpu on rk3582 */
+	ip_state[1] |= FAIL_GPU;
+
+	/* policy: always fail one rkvdec core on rk3582 */
+	if (!(ip_state[1] & (FAIL_RKVDEC0 | FAIL_RKVDEC1)))
+		ip_state[1] |= FAIL_RKVDEC1;
+
+	/* policy: always fail one rkvenc core on rk3582 */

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 406

Quoted 10 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +10 -0
+	if (!(ip_state[2] & (FAIL_RKVENC0 | FAIL_RKVENC1)))
+		ip_state[2] |= FAIL_RKVENC1;
+
+	log_debug("ip-state: %02x %02x %02x (policy)\n",
+		  ip_state[0], ip_state[1], ip_state[2]);
+
+	/* cpu cluster1: ip_state[0]: bit4~5 */
+	if ((ip_state[0] & FAIL_CPU_CLUSTER1) == FAIL_CPU_CLUSTER1) {
+		log_debug("remove cpu-map cluster1\n");
+		fdt_path_del_node(blob, "/cpus/cpu-map/cluster1");

Check the return code and log (+error out?) if there's an error.

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 413

Quoted 7 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +7 -0
+		cluster1_removed = true;
+	}
+
+	/* cpu cluster2: ip_state[0]: bit6~7 */
+	if ((ip_state[0] & FAIL_CPU_CLUSTER2) == FAIL_CPU_CLUSTER2) {
+		log_debug("remove cpu-map cluster2\n");
+		fdt_path_del_node(blob, "/cpus/cpu-map/cluster2");

Check the return code and log (+error out?) if there's an error.

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 417

Quoted 4 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +4 -0
+	} else if (cluster1_removed) {
+		/* cluster nodes must be named in a continuous series */
+		log_debug("rename cpu-map cluster2\n");
+		fdt_path_set_name(blob, "/cpus/cpu-map/cluster2", "cluster1");

Check the return code and log (+error out?) if there's an error.

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 423

Quoted 6 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +6 -0
+	}
+
+	/* gpu: ip_state[1]: bit1~4 */
+	if (ip_state[1] & FAIL_GPU) {
+		log_debug("fail gpu\n");
+		fdt_status_fail_by_pathf(blob, "/gpu@fb000000");

Check the return code and log (+error out?) if there's an error.

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 430

Quoted 7 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +7 -0
+	}
+
+	/* rkvdec: ip_state[1]: bit6,7 */
+	if (ip_state[1] & FAIL_RKVDEC0) {
+		log_debug("fail rkvdec0\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdc38000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdc38700");

Check the return code and log (+error out?) if there's an error.

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 435

Quoted 5 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +5 -0
+	}
+	if (ip_state[1] & FAIL_RKVDEC1) {
+		log_debug("fail rkvdec1\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdc40000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdc40700");

Check the return code and log (+error out?) if there's an error.

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 442

Quoted 7 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +7 -0
+	}
+
+	/* rkvenc: ip_state[2]: bit0,2 */
+	if (ip_state[2] & FAIL_RKVENC0) {
+		log_debug("fail rkvenc0\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdbd0000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdbdf000");

Check the return code and log (+error out?) if there's an error.

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 447

Quoted 5 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +5 -0
+	}
+	if (ip_state[2] & FAIL_RKVENC1) {
+		log_debug("fail rkvenc1\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdbe0000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdbef000");

Check the return code and log (+error out?) if there's an error.

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 459

Quoted 12 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +12 -0
+	}
+
+	parent = fdt_path_offset(blob, "/cpus");
+	if (parent < 0) {
+		log_err("Could not find /cpus, parent=%d\n", parent);
+		return parent;
+	}
+
+	/* cpu: ip_state[0]: bit0~7 */
+	for (i = 0; i < 8; i++) {
+		/* fail any bad cpu core */
+		if (!(ip_state[0] & BIT(i)))

Is this guaranteed to be properly set in sync with FAIL_CPU_CLUSTERx? E.g. can I have a FAIL_CPU_CLUSTER2 but none (or only one) of the big cores in the cluster not marked as bad in the ip-state OTP?

Shouldn't we check also for FAIL_CPU_CLUSTERx here and disable all cores in bad clusters since we are removing the clusters anyway?

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 465

Quoted 6 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +6 -0
+			continue;
+
+		node = fdt_subnode_offset(blob, parent, cpu_node_names[i]);
+		if (node >= 0) {
+			log_debug("fail cpu %s\n", cpu_node_names[i]);
+			fdt_status_fail(blob, node);

Check the return code and log (+error out?) if there's an error.

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 470

Quoted 5 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +5 -0
+		} else {
+			log_err("Could not find %s, node=%d\n",
+				cpu_node_names[i], node);
+			return node;
+		}

suggestion: Flatten this into

if (node < 0) {
    log_err();
    return node;
}

log_debug();
fdt_status_fail(blob, node);

arch/arm/mach-rockchip/rk3588/rk3588.c int checkboard(void) · line 472

Quoted 2 lines
arch/arm/mach-rockchip/rk3588/rk3588.c +2 -0
+	}
+

Please add a big comment here explaining what the below is for, so we don't have to guess what the intent is based on the code :)

Cheers,
Quentin

Reviewed-by on v4 1/3
#3 lore raw
In reply to Jonas Karlman
Quoted 7 lines · Jonas Karlman

The RK3582 SoC is a variant of the RK3588S with some IP blocks disabled. What blocks are disabled/non-working is indicated by ip-state in OTP.

This add initial support for RK3582 by using ft_system_setup() to mark any cpu, gpu and/or vdec/venc node with status=fail as indicated by ip-state.

Quoted 7 lines

This apply same policy as vendor U-Boot for RK3582, i.e. two big cpu cores, the gpu and one vdec/venc core is always failed/disabled.

Enable Kconfig option OF_SYSTEM_SETUP in board defconfig to make use of the required DT fixups for RK3582 board variants.

Thanks,
- Kever

Quoted 258 lines

---
Changes in v4:
- Update policy to always fail gpu for RK3582
- Drop code and comment related to RK3583
- Update rkvdec node name to match latest mainline Linux DT patches

Changes in v3:
- Apply same policy for RK3582/RK3583 to match vendor U-Boot linux-6.1-stan-rkr6 tag, allow use of the GPU and one vdec core.
- Update rkvdec node name to match latest mainline Linux DT patches.

Changes in v2:
- Refactor code to first apply policy to ip-state and then fail cores based on the updated ip-state
- Add support for failing rkvdec and rkvenc cores
- Append soc compatible to board model
- Not picking up t-b tag due to significant changes to patch

---
  arch/arm/mach-rockchip/rk3588/rk3588.c | 215 +++++++++++++++++++++++++
  1 file changed, 215 insertions(+)
arch/arm/mach-rockchip/rk3588/rk3588.c +215 -0
index 6324c6f12867..c1138ffcb87f 100644
@@ -7,6 +7,7 @@
  #define LOG_CATEGORY LOGC_ARCH
 
  #include <dm.h>
+#include <fdt_support.h>
  #include <misc.h>
  #include <spl.h>
  #include <asm/armv8/mmu.h>
@@ -240,6 +241,16 @@ int rockchip_dram_init_banksize_fixup(struct bd_info *bd)
 
  #define RK3588_OTP_CPU_CODE_OFFSET		0x02
  #define RK3588_OTP_SPECIFICATION_OFFSET		0x06
+#define RK3588_OTP_IP_STATE_OFFSET		0x1d
+
+#define FAIL_CPU_CLUSTER0		GENMASK(3, 0)
+#define FAIL_CPU_CLUSTER1		GENMASK(5, 4)
+#define FAIL_CPU_CLUSTER2		GENMASK(7, 6)
+#define FAIL_GPU			GENMASK(4, 1)
+#define FAIL_RKVDEC0			BIT(6)
+#define FAIL_RKVDEC1			BIT(7)
+#define FAIL_RKVENC0			BIT(0)
+#define FAIL_RKVENC1			BIT(2)
 
  int checkboard(void)
  {
@@ -285,3 +296,207 @@ int checkboard(void)
 
  	return 0;
  }
+
+static int fdt_path_del_node(void *fdt, const char *path)
+{
+	int nodeoffset;
+
+	nodeoffset = fdt_path_offset(fdt, path);
+	if (nodeoffset < 0)
+		return nodeoffset;
+
+	return fdt_del_node(fdt, nodeoffset);
+}
+
+static int fdt_path_set_name(void *fdt, const char *path, const char *name)
+{
+	int nodeoffset;
+
+	nodeoffset = fdt_path_offset(fdt, path);
+	if (nodeoffset < 0)
+		return nodeoffset;
+
+	return fdt_set_name(fdt, nodeoffset, name);
+}
+
+/*
+ * RK3582 is a variant of the RK3588S with some IP blocks disabled. What blocks
+ * are disabled/non-working is indicated by ip-state in OTP. ft_system_setup()
+ * is used to mark any cpu, gpu and/or vdec/venc node with status=fail as
+ * indicated by ip-state. Apply same policy as vendor U-Boot for RK3582, i.e.
+ * two big cpu cores, the gpu and one vdec/venc core is always failed. Enable
+ * OF_SYSTEM_SETUP to use the required DT fixups for RK3582 board variants.
+ */
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+	static const char * const cpu_node_names[] = {
+		"cpu@0", "cpu@100", "cpu@200", "cpu@300",
+		"cpu@400", "cpu@500", "cpu@600", "cpu@700",
+	};
+	int parent, node, i, comp_len, len, ret;
+	bool cluster1_removed = false;
+	u8 cpu_code[2], ip_state[3];
+	struct udevice *dev;
+	char soc_comp[16];
+	const char *comp;
+	void *data;
+
+	if (!IS_ENABLED(CONFIG_OF_SYSTEM_SETUP))
+		return 0;
+
+	if (!IS_ENABLED(CONFIG_ROCKCHIP_OTP) || !CONFIG_IS_ENABLED(MISC))
+		return -ENOSYS;
+
+	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 ret;
+	}
+
+	/* cpu-code: SoC model, e.g. 0x35 0x82 or 0x35 0x88 */
+	ret = misc_read(dev, RK3588_OTP_CPU_CODE_OFFSET, cpu_code, 2);
+	if (ret < 0) {
+		log_debug("Could not read cpu-code, ret=%d\n", ret);
+		return ret;
+	}
+
+	log_debug("cpu-code: %02x %02x\n", cpu_code[0], cpu_code[1]);
+
+	/* only fail cores on rk3582 */
+	if (!(cpu_code[0] == 0x35 && cpu_code[1] == 0x82))
+		return 0;
+
+	ret = misc_read(dev, RK3588_OTP_IP_STATE_OFFSET, &ip_state, 3);
+	if (ret < 0) {
+		log_err("Could not read ip-state, ret=%d\n", ret);
+		return ret;
+	}
+
+	log_debug("ip-state: %02x %02x %02x (otp)\n",
+		  ip_state[0], ip_state[1], ip_state[2]);
+
+	/* policy: fail entire big core cluster when one or more core is bad */
+	if (ip_state[0] & FAIL_CPU_CLUSTER1)
+		ip_state[0] |= FAIL_CPU_CLUSTER1;
+	if (ip_state[0] & FAIL_CPU_CLUSTER2)
+		ip_state[0] |= FAIL_CPU_CLUSTER2;
+
+	/* policy: always fail one big core cluster on rk3582 */
+	if (!(ip_state[0] & (FAIL_CPU_CLUSTER1 | FAIL_CPU_CLUSTER2)))
+		ip_state[0] |= FAIL_CPU_CLUSTER2;
+
+	/* policy: always fail gpu on rk3582 */
+	ip_state[1] |= FAIL_GPU;
+
+	/* policy: always fail one rkvdec core on rk3582 */
+	if (!(ip_state[1] & (FAIL_RKVDEC0 | FAIL_RKVDEC1)))
+		ip_state[1] |= FAIL_RKVDEC1;
+
+	/* policy: always fail one rkvenc core on rk3582 */
+	if (!(ip_state[2] & (FAIL_RKVENC0 | FAIL_RKVENC1)))
+		ip_state[2] |= FAIL_RKVENC1;
+
+	log_debug("ip-state: %02x %02x %02x (policy)\n",
+		  ip_state[0], ip_state[1], ip_state[2]);
+
+	/* cpu cluster1: ip_state[0]: bit4~5 */
+	if ((ip_state[0] & FAIL_CPU_CLUSTER1) == FAIL_CPU_CLUSTER1) {
+		log_debug("remove cpu-map cluster1\n");
+		fdt_path_del_node(blob, "/cpus/cpu-map/cluster1");
+		cluster1_removed = true;
+	}
+
+	/* cpu cluster2: ip_state[0]: bit6~7 */
+	if ((ip_state[0] & FAIL_CPU_CLUSTER2) == FAIL_CPU_CLUSTER2) {
+		log_debug("remove cpu-map cluster2\n");
+		fdt_path_del_node(blob, "/cpus/cpu-map/cluster2");
+	} else if (cluster1_removed) {
+		/* cluster nodes must be named in a continuous series */
+		log_debug("rename cpu-map cluster2\n");
+		fdt_path_set_name(blob, "/cpus/cpu-map/cluster2", "cluster1");
+	}
+
+	/* gpu: ip_state[1]: bit1~4 */
+	if (ip_state[1] & FAIL_GPU) {
+		log_debug("fail gpu\n");
+		fdt_status_fail_by_pathf(blob, "/gpu@fb000000");
+	}
+
+	/* rkvdec: ip_state[1]: bit6,7 */
+	if (ip_state[1] & FAIL_RKVDEC0) {
+		log_debug("fail rkvdec0\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdc38000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdc38700");
+	}
+	if (ip_state[1] & FAIL_RKVDEC1) {
+		log_debug("fail rkvdec1\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdc40000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdc40700");
+	}
+
+	/* rkvenc: ip_state[2]: bit0,2 */
+	if (ip_state[2] & FAIL_RKVENC0) {
+		log_debug("fail rkvenc0\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdbd0000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdbdf000");
+	}
+	if (ip_state[2] & FAIL_RKVENC1) {
+		log_debug("fail rkvenc1\n");
+		fdt_status_fail_by_pathf(blob, "/video-codec@fdbe0000");
+		fdt_status_fail_by_pathf(blob, "/iommu@fdbef000");
+	}
+
+	parent = fdt_path_offset(blob, "/cpus");
+	if (parent < 0) {
+		log_err("Could not find /cpus, parent=%d\n", parent);
+		return parent;
+	}
+
+	/* cpu: ip_state[0]: bit0~7 */
+	for (i = 0; i < 8; i++) {
+		/* fail any bad cpu core */
+		if (!(ip_state[0] & BIT(i)))
+			continue;
+
+		node = fdt_subnode_offset(blob, parent, cpu_node_names[i]);
+		if (node >= 0) {
+			log_debug("fail cpu %s\n", cpu_node_names[i]);
+			fdt_status_fail(blob, node);
+		} else {
+			log_err("Could not find %s, node=%d\n",
+				cpu_node_names[i], node);
+			return node;
+		}
+	}
+
+	node = fdt_path_offset(blob, "/");
+	if (node < 0) {
+		log_err("Could not find /, node=%d\n", node);
+		return node;
+	}
+
+	snprintf(soc_comp, sizeof(soc_comp), "rockchip,rk35%x", cpu_code[1]);
+
+	for (i = 0, comp_len = 0;
+	     (comp = fdt_stringlist_get(blob, node, "compatible", i, &len));
+	     i++) {
+		/* stop at soc compatible */
+		if (!strcmp(comp, soc_comp) ||
+		    !strcmp(comp, "rockchip,rk3588s") ||
+		    !strcmp(comp, "rockchip,rk3588"))
+			break;
+
+		log_debug("compatible[%d]: %s\n", i, comp);
+		comp_len += len + 1;
+	}
+
+	/* truncate to only include board compatible */
+	fdt_setprop_placeholder(blob, node, "compatible", comp_len, &data);
+
+	/* append soc compatible */
+	fdt_appendprop_string(blob, node, "compatible", soc_comp);
+	fdt_appendprop_string(blob, node, "compatible", "rockchip,rk3588s");
+
+	return 0;
+}
#4 lore raw

PATCH v4 2/3 rockchip: rk3588-generic: Enable support for RK3582

In reply to Jonas Karlman

Add Kconfig option OF_SYSTEM_SETUP=y to support booting boards with a RK3582 SoC. CPU and GPU cores are failed based on ip-state and policy.

Tested on a ROCK 5C Lite v1.1:

cpu-code: 35 82
ip-state: 10 00 00 (otp)
ip-state: 30 9e 04 (policy)
remove cpu-map cluster1
rename cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@400
fail cpu cpu@500

and on a Radxa E52C:

cpu-code: 35 82
ip-state: 00 04 00 (otp)
ip-state: c0 9e 04 (policy)
remove cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@600
fail cpu cpu@700

---
v4: Update commit message to reflect updated policy
v3: Update commit message to reflect updated policy
v2: Mention RK3582 in generic board device tree and documentation

---
 arch/arm/dts/rk3588-generic.dts  | 4 ++--
 configs/generic-rk3588_defconfig | 1 +
 doc/board/rockchip/rockchip.rst  | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
arch/arm/dts/rk3588-generic.dts +2 -2
index 6740f9866f17..04144e2ad128 100644
@@ -1,13 +1,13 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 /*
- * Minimal generic DT for RK3588S/RK3588 with eMMC, SD-card and USB OTG enabled
+ * Minimal generic DT for RK3582/RK3588S/RK3588 with eMMC, SD-card and USB OTG enabled
  */
 
 /dts-v1/;
 #include "rk3588s.dtsi"
 
 / {
-	model = "Generic RK3588S/RK3588";
+	model = "Generic RK3582/RK3588S/RK3588";
 	compatible = "rockchip,rk3588";
 
 	aliases {
configs/generic-rk3588_defconfig +1 -0
index dfa8efabe6be..7a8c176912e1 100644
@@ -16,6 +16,7 @@ CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_SPL_LOAD_FIT=y
 # CONFIG_BOOTMETH_VBE is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-generic.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL_MAX_SIZE=0x40000
doc/board/rockchip/rockchip.rst +1 -1
index 6ae4d4371ff6..886df1c39cbc 100644
@@ -154,7 +154,7 @@ List of mainline supported Rockchip boards:
      - FriendlyElec NanoPi R6C (nanopi-r6c-rk3588s)
      - FriendlyElec NanoPi R6S (nanopi-r6s-rk3588s)
      - GameForce Ace (gameforce-ace-rk3588s)
-     - Generic RK3588S/RK3588 (generic-rk3588)
+     - Generic RK3582/RK3588S/RK3588 (generic-rk3588)
      - Hardkernel ODROID-M2 (odroid-m2-rk3588s)
      - Indiedroid Nova (nova-rk3588s)
      - Khadas Edge2 (khadas-edge2-rk3588s)
Signature · 1 line
2.52.0
Reviewed-by on v4 2/3
#5 lore raw

Re: [PATCH v4 2/3] rockchip: rk3588-generic: Enable support for RK3582

Hi Jonas,

Quoted 18 lines · Jonas Karlman

Add Kconfig option OF_SYSTEM_SETUP=y to support booting boards with a RK3582 SoC. CPU and GPU cores are failed based on ip-state and policy.

Tested on a ROCK 5C Lite v1.1:

cpu-code: 35 82
ip-state: 10 00 00 (otp)
ip-state: 30 9e 04 (policy)
remove cpu-map cluster1
rename cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@400
fail cpu cpu@500

and on a Radxa E52C:

Quoted 10 lines

cpu-code: 35 82
ip-state: 00 04 00 (otp)
ip-state: c0 9e 04 (policy)
remove cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@600
fail cpu cpu@700

Thanks!
Quentin

Reviewed-by on v4 2/3
#6 lore raw

Re: [PATCH v4 2/3] rockchip: rk3588-generic: Enable support for RK3582

In reply to Jonas Karlman
Quoted 28 lines · Jonas Karlman

Add Kconfig option OF_SYSTEM_SETUP=y to support booting boards with a RK3582 SoC. CPU and GPU cores are failed based on ip-state and policy.

Tested on a ROCK 5C Lite v1.1:

cpu-code: 35 82
ip-state: 10 00 00 (otp)
ip-state: 30 9e 04 (policy)
remove cpu-map cluster1
rename cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@400
fail cpu cpu@500

and on a Radxa E52C:

cpu-code: 35 82
ip-state: 00 04 00 (otp)
ip-state: c0 9e 04 (policy)
remove cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@600
fail cpu cpu@700

Quoted 1 line

Thanks,
- Kever

Quoted 55 lines

---
v4: Update commit message to reflect updated policy
v3: Update commit message to reflect updated policy
v2: Mention RK3582 in generic board device tree and documentation

---
  arch/arm/dts/rk3588-generic.dts  | 4 ++--
  configs/generic-rk3588_defconfig | 1 +
  doc/board/rockchip/rockchip.rst  | 2 +-
  3 files changed, 4 insertions(+), 3 deletions(-)
arch/arm/dts/rk3588-generic.dts +2 -2
index 6740f9866f17..04144e2ad128 100644
@@ -1,13 +1,13 @@
  // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  /*
- * Minimal generic DT for RK3588S/RK3588 with eMMC, SD-card and USB OTG enabled
+ * Minimal generic DT for RK3582/RK3588S/RK3588 with eMMC, SD-card and USB OTG enabled
   */
 
  /dts-v1/;
  #include "rk3588s.dtsi"
 
  / {
-	model = "Generic RK3588S/RK3588";
+	model = "Generic RK3582/RK3588S/RK3588";
  	compatible = "rockchip,rk3588";
 
  	aliases {
configs/generic-rk3588_defconfig +1 -0
index dfa8efabe6be..7a8c176912e1 100644
@@ -16,6 +16,7 @@ CONFIG_SPL_FIT_SIGNATURE=y
  CONFIG_SPL_LOAD_FIT=y
  # CONFIG_BOOTMETH_VBE is not set
  CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_OF_SYSTEM_SETUP=y
  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-generic.dtb"
  # CONFIG_DISPLAY_CPUINFO is not set
  CONFIG_SPL_MAX_SIZE=0x40000
doc/board/rockchip/rockchip.rst +1 -1
index 6ae4d4371ff6..886df1c39cbc 100644
@@ -154,7 +154,7 @@ List of mainline supported Rockchip boards:
       - FriendlyElec NanoPi R6C (nanopi-r6c-rk3588s)
       - FriendlyElec NanoPi R6S (nanopi-r6s-rk3588s)
       - GameForce Ace (gameforce-ace-rk3588s)
-     - Generic RK3588S/RK3588 (generic-rk3588)
+     - Generic RK3582/RK3588S/RK3588 (generic-rk3588)
       - Hardkernel ODROID-M2 (odroid-m2-rk3588s)
       - Indiedroid Nova (nova-rk3588s)
       - Khadas Edge2 (khadas-edge2-rk3588s)
#7 lore raw

PATCH v4 3/3 rockchip: rk3588s-rock-5c: Add support for ROCK 5C Lite variant

In reply to Jonas Karlman

Add Kconfig option OF_SYSTEM_SETUP=y to support booting ROCK 5C Lite boards with a RK3582 SoC. CPU and GPU cores are failed based on ip-state and policy.

Tested on a ROCK 5C Lite v1.1:

cpu-code: 35 82
ip-state: 00 80 00 (otp)
ip-state: c0 9e 04 (policy)
remove cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@600
fail cpu cpu@700

---
v4: Update commit message to reflect updated policy
v3: Update commit message to reflect updated policy
v2: New patch

---
 arch/arm/mach-rockchip/rk3588/Kconfig | 9 +++++----
 configs/rock-5c-rk3588s_defconfig     | 1 +
 doc/board/rockchip/rockchip.rst       | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)
arch/arm/mach-rockchip/rk3588/Kconfig +5 -4
index 60c16d2f32d2..675f13ab66d7 100644
@@ -286,14 +286,15 @@ config TARGET_ROCK_5_ITX_RK3588
 	  Powered by either 12V, ATX power-supply or PoE
 
 config TARGET_ROCK_5C_RK3588S
-	bool "Radxa ROCK 5C RK3588S2 board"
+	bool "Radxa ROCK 5C/5C Lite"
 	help
-	  Radxa ROCK 5C is a Rockchip RK3588S2 based single board computer.
+	  Radxa ROCK 5C/5C Lite is a Rockchip RK3588S2/RK3582 based SBC (Single
+	  Board Computer) by Radxa.
 
 	  Specification:
 
-	  Quad A76 and Quad A55 CPU
-	  6 TOPS NPU
+	  Quad/Dual A76 and Quad A55 CPU
+	  6/5 TOPS NPU
 	  up to 32GB LPDDR4x RAM
 	  eMMC / SPI flash connector
 	  Micro SD Card slot
configs/rock-5c-rk3588s_defconfig +1 -0
index 2748fb488c2d..f83d3f6d6c92 100644
@@ -18,6 +18,7 @@ CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588s-rock-5c.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL_MAX_SIZE=0x40000
doc/board/rockchip/rockchip.rst +1 -1
index 886df1c39cbc..7a8532b49fc5 100644
@@ -163,7 +163,7 @@ List of mainline supported Rockchip boards:
      - Radxa ROCK 5 ITX (rock-5-itx-rk3588)
      - Radxa ROCK 5A (rock5a-rk3588s)
      - Radxa ROCK 5B/5B+/5T (rock5b-rk3588)
-     - Radxa ROCK 5C (rock-5c-rk3588s)
+     - Radxa ROCK 5C/5C Lite (rock-5c-rk3588s)
      - Rockchip Toybrick TB-RK3588X (toybrick-rk3588)
      - Theobroma Systems RK3588-SBC Jaguar (jaguar-rk3588)
      - Theobroma Systems SOM-RK3588-Q7 - Tiger (tiger-rk3588)
Signature · 1 line
2.52.0
Reviewed-by on v4 3/3
#8 lore raw

Re: [PATCH v4 3/3] rockchip: rk3588s-rock-5c: Add support for ROCK 5C Lite variant

Hi Jonas,

Quoted 37 lines · Jonas Karlman

Add Kconfig option OF_SYSTEM_SETUP=y to support booting ROCK 5C Lite boards with a RK3582 SoC. CPU and GPU cores are failed based on ip-state and policy.

Tested on a ROCK 5C Lite v1.1:

cpu-code: 35 82
ip-state: 00 80 00 (otp)
ip-state: c0 9e 04 (policy)
remove cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@600
fail cpu cpu@700

---
v4: Update commit message to reflect updated policy
v3: Update commit message to reflect updated policy
v2: New patch

---
  arch/arm/mach-rockchip/rk3588/Kconfig | 9 +++++----
  configs/rock-5c-rk3588s_defconfig     | 1 +
  doc/board/rockchip/rockchip.rst       | 2 +-
  3 files changed, 7 insertions(+), 5 deletions(-)
arch/arm/mach-rockchip/rk3588/Kconfig +1 -1
index 60c16d2f32d2..675f13ab66d7 100644
@@ -286,14 +286,15 @@ config TARGET_ROCK_5_ITX_RK3588
  	  Powered by either 12V, ATX power-supply or PoE
 
  config TARGET_ROCK_5C_RK3588S
-	bool "Radxa ROCK 5C RK3588S2 board"
+	bool "Radxa ROCK 5C/5C Lite"

arch/arm/mach-rockchip/rk3588/Kconfig config TARGET_ROCK_5_ITX_RK3588 · line 296

Quoted 10 lines
arch/arm/mach-rockchip/rk3588/Kconfig +3 -3
  	help
-	  Radxa ROCK 5C is a Rockchip RK3588S2 based single board computer.
+	  Radxa ROCK 5C/5C Lite is a Rockchip RK3588S2/RK3582 based SBC (Single
+	  Board Computer) by Radxa.
 
  	  Specification:
 
-	  Quad A76 and Quad A55 CPU
-	  6 TOPS NPU
+	  Quad/Dual A76 and Quad A55 CPU

Considering the code seems to handle removal of little cores too as well as all big cores, is this something we should be mentioning?

Thanks!
Quentin

#9 lore raw

Re: [PATCH v4 3/3] rockchip: rk3588s-rock-5c: Add support for ROCK 5C Lite variant

Hi Quentin,

Quoted 45 lines · Quentin Schulz

Hi Jonas,

Quoted 42 lines · Jonas Karlman

Add Kconfig option OF_SYSTEM_SETUP=y to support booting ROCK 5C Lite boards with a RK3582 SoC. CPU and GPU cores are failed based on ip-state and policy.

Tested on a ROCK 5C Lite v1.1:

cpu-code: 35 82
ip-state: 00 80 00 (otp)
ip-state: c0 9e 04 (policy)
remove cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@600
fail cpu cpu@700

---
v4: Update commit message to reflect updated policy
v3: Update commit message to reflect updated policy
v2: New patch

---
  arch/arm/mach-rockchip/rk3588/Kconfig | 9 +++++----
  configs/rock-5c-rk3588s_defconfig     | 1 +
  doc/board/rockchip/rockchip.rst       | 2 +-
  3 files changed, 7 insertions(+), 5 deletions(-)
arch/arm/mach-rockchip/rk3588/Kconfig +3 -2
index 60c16d2f32d2..675f13ab66d7 100644
@@ -286,14 +286,15 @@ config TARGET_ROCK_5_ITX_RK3588
  	  Powered by either 12V, ATX power-supply or PoE
 
  config TARGET_ROCK_5C_RK3588S
-	bool "Radxa ROCK 5C RK3588S2 board"
+	bool "Radxa ROCK 5C/5C Lite"
  	help
-	  Radxa ROCK 5C is a Rockchip RK3588S2 based single board computer.
+	  Radxa ROCK 5C/5C Lite is a Rockchip RK3588S2/RK3582 based SBC (Single
+	  Board Computer) by Radxa.
 
Quoted 8 lines

arch/arm/mach-rockchip/rk3588/Kconfig config TARGET_ROCK_5_ITX_RK3588 · line 296

Quoted 5 lines
arch/arm/mach-rockchip/rk3588/Kconfig +1 -2
  	  Specification:
 
-	  Quad A76 and Quad A55 CPU
-	  6 TOPS NPU
+	  Quad/Dual A76 and Quad A55 CPU

Considering the code seems to handle removal of little cores too as well as all big cores, is this something we should be mentioning?

The code is trying to be as dynamic as possible, however if I understand correctly a RK3528 should at most have one A76 cluster in bad/failed state, and if all cpu cores is fine there is a policy to disable one of the A76 cluster anyway. So this text change is correct in that the Lite version have Dual A76 and Quad A55.

Regards,
Jonas

Quoted 5 lines

Thanks!
Quentin

Reviewed-by
#10 lore raw

Re: [PATCH v4 3/3] rockchip: rk3588s-rock-5c: Add support for ROCK 5C Lite variant

Quoted 6 lines · Jonas Karlman

Hi Quentin,

Quoted 3 lines · Quentin Schulz

Hi Jonas,

On 1/8/26 12:07 AM, Jonas Karlman wrote:

[...]

Thanks!
Quentin

Reviewed-by on v4 3/3
#11 lore raw

Re: [PATCH v4 3/3] rockchip: rk3588s-rock-5c: Add support for ROCK 5C Lite variant

In reply to Jonas Karlman
Quoted 16 lines · Jonas Karlman

Add Kconfig option OF_SYSTEM_SETUP=y to support booting ROCK 5C Lite boards with a RK3582 SoC. CPU and GPU cores are failed based on ip-state and policy.

Tested on a ROCK 5C Lite v1.1:

cpu-code: 35 82
ip-state: 00 80 00 (otp)
ip-state: c0 9e 04 (policy)
remove cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@600
fail cpu cpu@700

Quoted 1 line

Thanks,
- Kever

Quoted 59 lines

---
v4: Update commit message to reflect updated policy
v3: Update commit message to reflect updated policy
v2: New patch

---
  arch/arm/mach-rockchip/rk3588/Kconfig | 9 +++++----
  configs/rock-5c-rk3588s_defconfig     | 1 +
  doc/board/rockchip/rockchip.rst       | 2 +-
  3 files changed, 7 insertions(+), 5 deletions(-)
arch/arm/mach-rockchip/rk3588/Kconfig +5 -4
index 60c16d2f32d2..675f13ab66d7 100644
@@ -286,14 +286,15 @@ config TARGET_ROCK_5_ITX_RK3588
  	  Powered by either 12V, ATX power-supply or PoE
 
  config TARGET_ROCK_5C_RK3588S
-	bool "Radxa ROCK 5C RK3588S2 board"
+	bool "Radxa ROCK 5C/5C Lite"
  	help
-	  Radxa ROCK 5C is a Rockchip RK3588S2 based single board computer.
+	  Radxa ROCK 5C/5C Lite is a Rockchip RK3588S2/RK3582 based SBC (Single
+	  Board Computer) by Radxa.
 
  	  Specification:
 
-	  Quad A76 and Quad A55 CPU
-	  6 TOPS NPU
+	  Quad/Dual A76 and Quad A55 CPU
+	  6/5 TOPS NPU
  	  up to 32GB LPDDR4x RAM
  	  eMMC / SPI flash connector
  	  Micro SD Card slot
configs/rock-5c-rk3588s_defconfig +1 -0
index 2748fb488c2d..f83d3f6d6c92 100644
@@ -18,6 +18,7 @@ CONFIG_FIT_VERBOSE=y
  CONFIG_SPL_FIT_SIGNATURE=y
  CONFIG_SPL_LOAD_FIT=y
  CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_OF_SYSTEM_SETUP=y
  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588s-rock-5c.dtb"
  # CONFIG_DISPLAY_CPUINFO is not set
  CONFIG_SPL_MAX_SIZE=0x40000
doc/board/rockchip/rockchip.rst +1 -1
index 886df1c39cbc..7a8532b49fc5 100644
@@ -163,7 +163,7 @@ List of mainline supported Rockchip boards:
       - Radxa ROCK 5 ITX (rock-5-itx-rk3588)
       - Radxa ROCK 5A (rock5a-rk3588s)
       - Radxa ROCK 5B/5B+/5T (rock5b-rk3588)
-     - Radxa ROCK 5C (rock-5c-rk3588s)
+     - Radxa ROCK 5C/5C Lite (rock-5c-rk3588s)
       - Rockchip Toybrick TB-RK3588X (toybrick-rk3588)
       - Theobroma Systems RK3588-SBC Jaguar (jaguar-rk3588)
       - Theobroma Systems SOM-RK3588-Q7 - Tiger (tiger-rk3588)
Tested-by on the v4 series
#12 lore raw
In reply to Jonas Karlman

Hi Jonas,

Thank you very much for your work!

Quoted 38 lines · Jonas Karlman

This series add initial support for RK3582 support. The RK3582 is a variant of the RK3588S with a few ip blocks disabled. What blocks are disabled/non-working is indicated by the ip-state in OTP.

Compared to the vendor U-Boot variant, this mark cpu, the gpu and vdec/venc with status=fail instead of removing nodes during DT fixup. Linux skip cpu cores marked as failed staring from v5.17-rc1, however the GIC driver will generate a harmless WARN_ON that safely can be ignored. A patch for Linux will be sent to skip the WARN_ON for failed/disabled cpu cores once this lands.

It is recommended to use rk3588_ddr_lp4_1848MHz_lp5_2112MHz_v1.19.bin as DRAM init blob RK3582, listed in latest RKBOOT/RK3582MINIALL.ini.

Changes in v4:
- Update policy to always fail gpu for RK3582
- Drop code and comment related to RK3583
- Update rkvdec node name to match latest mainline Linux DT patches
- Update commit message to reflect updated policy

Changes in v3:
- Apply same policy for RK3582/RK3583 to match vendor U-Boot linux-6.1-stan-rkr6 tag, allow use of the GPU and one vdec core.
- Update rkvdec node name to match latest mainline Linux DT patches.
- Update commit message to reflect updated policy

Changes in v2:
- Refactor code to first apply policy to ip-state and then fail cores based on the updated ip-state
- Add support for failing rkvdec and rkvenc cores
- Append soc compatible to board model
- Add patch to add support for ROCK 5C Lite variant

Jonas Karlman (3):
rockchip: Add initial RK3582 support
rockchip: rk3588-generic: Enable support for RK3582
rockchip: rk3588s-rock-5c: Add support for ROCK 5C Lite variant

Quoted 7 lines
  arch/arm/dts/rk3588-generic.dts        |   4 +-
  arch/arm/mach-rockchip/rk3588/Kconfig  |   9 +-
  arch/arm/mach-rockchip/rk3588/rk3588.c | 215 +++++++++++++++++++++++++
  configs/generic-rk3588_defconfig       |   1 +
  configs/rock-5c-rk3588s_defconfig      |   1 +
  doc/board/rockchip/rockchip.rst        |   4 +-
  6 files changed, 226 insertions(+), 8 deletions(-)

Tested on Radxa E52C:

cpu-code: 35 82
ip-state: 00 04 00 (otp)
ip-state: c0 9e 04 (policy)
remove cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@600
fail cpu cpu@700

and on Radxa ROCK 5C Lite:

cpu-code: 35 82
ip-state: 10 00 00 (otp)
ip-state: 30 9e 04 (policy)
remove cpu-map cluster1
rename cpu-map cluster2
fail gpu
fail rkvdec1
fail rkvenc1
fail cpu cpu@400
fail cpu cpu@500

For the whole series,

Best regards,

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

#13 lore raw
In reply to Jonas Karlman

Hi Jonas,

Quoted 11 lines · Jonas Karlman

This series add initial support for RK3582 support. The RK3582 is a variant of the RK3588S with a few ip blocks disabled. What blocks are disabled/non-working is indicated by the ip-state in OTP.

Compared to the vendor U-Boot variant, this mark cpu, the gpu and vdec/venc with status=fail instead of removing nodes during DT fixup. Linux skip cpu cores marked as failed staring from v5.17-rc1, however the GIC driver will generate a harmless WARN_ON that safely can be ignored. A patch for Linux will be sent to skip the WARN_ON for failed/disabled cpu cores once this lands.

Quoted 3 lines

It is recommended to use rk3588_ddr_lp4_1848MHz_lp5_2112MHz_v1.19.bin as DRAM init blob RK3582, listed in latest RKBOOT/RK3582MINIALL.ini.

As opposed to what?

I see there are 2 DDR bin and 2 eyescan DDR bin in rkbin, but I'm assuming at some point there'll be a newer release so we need to know which to use.

I'm assuming what matters is to match what's inside RKBOOT/RK3582MINIALL.ini? Can you add this to doc/board/rockchip/rockchip.rst maybe?

Cheers,
Quentin

#14 lore raw

Hi Quentin,

Quoted 14 lines · Quentin Schulz

Hi Jonas,

Quoted 11 lines · Jonas Karlman

This series add initial support for RK3582 support. The RK3582 is a variant of the RK3588S with a few ip blocks disabled. What blocks are disabled/non-working is indicated by the ip-state in OTP.

Compared to the vendor U-Boot variant, this mark cpu, the gpu and vdec/venc with status=fail instead of removing nodes during DT fixup. Linux skip cpu cores marked as failed staring from v5.17-rc1, however the GIC driver will generate a harmless WARN_ON that safely can be ignored. A patch for Linux will be sent to skip the WARN_ON for failed/disabled cpu cores once this lands.

Quoted 5 lines
Quoted 3 lines

It is recommended to use rk3588_ddr_lp4_1848MHz_lp5_2112MHz_v1.19.bin as DRAM init blob RK3582, listed in latest RKBOOT/RK3582MINIALL.ini.

As opposed to what?

The release note for rk3588 rkbin blobs [1] list this DRAM init blob version with:

New
- Add RK3582 support.

So this remark was a hint that users should use a DRAM init blob that has proper support for RK3582 when testing this series.

[1] https://github.com/rockchip-linux/rkbin/blob/master/doc/release/RK3588_EN.md

Quoted 7 lines

I see there are 2 DDR bin and 2 eyescan DDR bin in rkbin, but I'm assuming at some point there'll be a newer release so we need to know which to use.

I'm assuming what matters is to match what's inside RKBOOT/RK3582MINIALL.ini? Can you add this to doc/board/rockchip/rockchip.rst maybe?

That is something that is true for all SoCs using BL31 or ROCKCHIP_TPL blobs from rkbin repo and a topic I think is better suited for a separate documentation improvement series.

Something like following could possible be added.

When BL31 and ROCKCHIP_TPL blobs from rkbin is used it is recommended to select the blob referenced in RKTRUST/<soc>TRUST.ini and RKBOOT/<soc>MINIALL.ini.

Something like following can be used to set the environment variables:

.. code-block:: bash

        export BL31=../rkbin/$(confget -f ../rkbin/RKTRUST/<soc>TRUST.ini -s BL31_OPTION PATH)
        export ROCKCHIP_TPL=../rkbin/$(confget -f ../rkbin/RKBOOT/<soc>MINIALL.ini -s LOADER_OPTION FlashData)

That is similar to what I use in my build scripts :-)

For this series I will however include something like below in a v5.

doc/board/rockchip/rockchip.rst +6 -4
index 217694de0c92..022f8f2f20c0 100644
@@ -329,13 +329,15 @@ To build rk3576 boards:
         make roc-pc-rk3576_defconfig
         make CROSS_COMPILE=aarch64-linux-gnu-
 
-To build rk3588 boards:
+To build rk3588 (or rk3582) boards:
 
 .. code-block:: bash
 
-        export BL31=../rkbin/bin/rk35/rk3588_bl31_v1.33.elf
-        export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.09.bin
-        make evb-rk3588_defconfig
+        export BL31=../trusted-firmware-a/build/rk3588/release/bl31/bl31.elf
+        [or]export BL31=../rkbin/bin/rk35/rk3588_bl31_v1.51.elf
+        export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.19.bin
+        [or]export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_1848MHz_lp5_2112MHz_v1.19.bin
+        make generic-rk3588_defconfig
         make CROSS_COMPILE=aarch64-linux-gnu-
 
 Flashing

---

Regards,
Jonas

Quoted 2 lines

Cheers,
Quentin

#15 lore raw

Hi Jonas,

Quoted 23 lines · Jonas Karlman

Hi Quentin,

Quoted 14 lines · Quentin Schulz

Hi Jonas,

Quoted 11 lines · Jonas Karlman

This series add initial support for RK3582 support. The RK3582 is a variant of the RK3588S with a few ip blocks disabled. What blocks are disabled/non-working is indicated by the ip-state in OTP.

Compared to the vendor U-Boot variant, this mark cpu, the gpu and vdec/venc with status=fail instead of removing nodes during DT fixup. Linux skip cpu cores marked as failed staring from v5.17-rc1, however the GIC driver will generate a harmless WARN_ON that safely can be ignored. A patch for Linux will be sent to skip the WARN_ON for failed/disabled cpu cores once this lands.

Quoted 5 lines
Quoted 3 lines

It is recommended to use rk3588_ddr_lp4_1848MHz_lp5_2112MHz_v1.19.bin as DRAM init blob RK3582, listed in latest RKBOOT/RK3582MINIALL.ini.

As opposed to what?

Quoted 9 lines

The release note for rk3588 rkbin blobs [1] list this DRAM init blob version with:

New
- Add RK3582 support.

So this remark was a hint that users should use a DRAM init blob that has proper support for RK3582 when testing this series.

Ah, then something like "or later" or "since this is the first version with official support for RK3582" in the commit log (and doc/board) would work for me, what do you think?

Quoted 19 lines

[1] https://github.com/rockchip-linux/rkbin/blob/master/doc/release/RK3588_EN.md

Quoted 7 lines

I see there are 2 DDR bin and 2 eyescan DDR bin in rkbin, but I'm assuming at some point there'll be a newer release so we need to know which to use.

I'm assuming what matters is to match what's inside RKBOOT/RK3582MINIALL.ini? Can you add this to doc/board/rockchip/rockchip.rst maybe?

That is something that is true for all SoCs using BL31 or ROCKCHIP_TPL blobs from rkbin repo and a topic I think is better suited for a separate documentation improvement series.

Something like following could possible be added.

When BL31 and ROCKCHIP_TPL blobs from rkbin is used it is recommended to select the blob referenced in RKTRUST/<soc>TRUST.ini and RKBOOT/<soc>MINIALL.ini.

Quoted 7 lines

Something like following can be used to set the environment variables:

   .. code-block:: bash

         export BL31=../rkbin/$(confget -f ../rkbin/RKTRUST/<soc>TRUST.ini -s BL31_OPTION PATH)
         export ROCKCHIP_TPL=../rkbin/$(confget -f ../rkbin/RKBOOT/<soc>MINIALL.ini -s LOADER_OPTION FlashData)

Oooh never heard of confget before :)

Quoted 17 lines

That is similar to what I use in my build scripts :-)

For this series I will however include something like below in a v5.

doc/board/rockchip/rockchip.rst +1 -1
index 217694de0c92..022f8f2f20c0 100644
@@ -329,13 +329,15 @@ To build rk3576 boards:
          make roc-pc-rk3576_defconfig
          make CROSS_COMPILE=aarch64-linux-gnu-
 
-To build rk3588 boards:
+To build rk3588 (or rk3582) boards:
 
  .. code-block:: bash
 

doc/board/rockchip/rockchip.rst To build rk3576 boards: · line 342

Quoted 10 lines
doc/board/rockchip/rockchip.rst +5 -3
-        export BL31=../rkbin/bin/rk35/rk3588_bl31_v1.33.elf
-        export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.09.bin
-        make evb-rk3588_defconfig
+        export BL31=../trusted-firmware-a/build/rk3588/release/bl31/bl31.elf
+        [or]export BL31=../rkbin/bin/rk35/rk3588_bl31_v1.51.elf
+        export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.19.bin
+        [or]export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_1848MHz_lp5_2112MHz_v1.19.bin
+        make generic-rk3588_defconfig
          make CROSS_COMPILE=aarch64-linux-gnu-
 

It'd be so much better if we used your confget command line so we don't have to keep updating this documentation (which we fail to do most of the time I believe?) whenever a new blob version is available, don't you think? Can be in another series or commit, I don't mind.

Replace [or] with # or
to make it a shell comment so that one can simply copy the whole line and paste it in their terminal.

Cheers,
Quentin