Skip to contentSkip to conversation

Add Additional Boards and Features to RGxx3

PATCH In review Chris Morgan 3 participants 17 messages Jan 2, 2024 – Feb 6, 2024 1 message not in the archive

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

v4 cover Add Additional Boards and Features to RGxx3

From: Chris Morgan <[email protected]>

The RGxx3 is a pseudo-device for U-Boot that works for every Anbernic RGxx3 series device on the market. Add support for another series of very similar devices from Powkiddy.

Changes since V3:
- Fixed a bug with else/else if logic for board detection (changed a second incorrect "if" to the proper "else if").

Changes since V2:
- Modify the mach-rockchip level rockchip_dnl_key_pressed() so that we can also call it in SPL mode and eliminate the board specific function. This requires adding ADC support to SPL. Additionally, I had to change the regulator for the saradc to a fixed regulator and add GPIO and regulator support to SPL.
- Move the board specific board_rng_seed to the mach-rockchip level board file so that other rockchip boards with a hardware RNG can benefit. This should only be called if both the Rockchip hardware RNG as well as the rng seed functions are enabled.
- Add two new boards (the RG-ARC-D and RG-ARC-S). I removed the previous code review due to the extensive changes made.

Changes since V1:
- Update verbiage around function button to say "recovery" mode instead of calling it "maskrom" mode, which has a specific meaning. Also note that recovery function was done in a board specific manner to ensure it can run early.
- Update board level documentation for the RGxx3.

Chris Morgan (7):
board: rockchip: Refactor panel auto-detect code
spl: Add Kconfig options for ADC
rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL
board: rockchip: Add Recovery Button for Anbernic RGxx3
rockchip: board: Add board_rng_seed() for all Rockchip devices
board: rockchip: Add support for new boards to RGxx3
doc: board: anbernic: Update rgxx3 to add new boards

 .../arm/dts/rk3566-anbernic-rgxx3-u-boot.dtsi |  11 +
 arch/arm/mach-rockchip/Makefile               |   4 +-
 arch/arm/mach-rockchip/board.c                |  32 +++
 arch/arm/mach-rockchip/boot_mode.c            |  11 +-
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c    | 194 +++++++++++-------
 common/spl/Kconfig                            |   7 +
 configs/anbernic-rgxx3-rk3566_defconfig       |  16 +-
 doc/board/anbernic/rgxx3.rst                  |  20 +-
 drivers/Makefile                              |   1 +
 drivers/adc/Makefile                          |   2 +-
 include/configs/anbernic-rgxx3-rk3566.h       |   2 +
 11 files changed, 210 insertions(+), 90 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/7 board: rockchip: Refactor panel auto-detect code

From: Chris Morgan <[email protected]>

Make the inability to detect a panel using the auto detection code not fail the entire boot process. This means that if the panel ID cannot be read we don't set an environment variable for the panel, and if an environment variable for the panel is not set we don't attempt to update the compatible string. Changes to the code also ensure that when there are multiple compatible strings required for the panel we use them both, which solves some issues that will pop up soon for the Linux driver.

---
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 115 +++++++++++++--------
 1 file changed, 74 insertions(+), 41 deletions(-)
board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c +74 -41
index 3f1a42d184..3d0c614623 100644
@@ -40,6 +40,7 @@ struct rg3xx_model {
 	const char *board;
 	const char *board_name;
 	const char *fdtfile;
+	const bool detect_panel;
 };
 
 enum rgxx3_device_id {
@@ -54,52 +55,67 @@ enum rgxx3_device_id {
 
 static const struct rg3xx_model rg3xx_model_details[] = {
 	[RG353M] = {
-		517, /* Observed average from device */
-		"rk3566-anbernic-rg353m",
-		"RG353M",
-		DTB_DIR "rk3566-anbernic-rg353p.dtb", /* Identical devices */
+		.adc_value = 517, /* Observed average from device */
+		.board = "rk3566-anbernic-rg353m",
+		.board_name = "RG353M",
+		/* Device is identical to RG353P. */
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353p.dtb",
+		.detect_panel = 1,
 	},
 	[RG353P] = {
-		860, /* Documented value of 860 */
-		"rk3566-anbernic-rg353p",
-		"RG353P",
-		DTB_DIR "rk3566-anbernic-rg353p.dtb",
+		.adc_value = 860, /* Documented value of 860 */
+		.board = "rk3566-anbernic-rg353p",
+		.board_name = "RG353P",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353p.dtb",
+		.detect_panel = 1,
 	},
 	[RG353V] = {
-		695, /* Observed average from device */
-		"rk3566-anbernic-rg353v",
-		"RG353V",
-		DTB_DIR "rk3566-anbernic-rg353v.dtb",
+		.adc_value = 695, /* Observed average from device */
+		.board = "rk3566-anbernic-rg353v",
+		.board_name = "RG353V",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353v.dtb",
+		.detect_panel = 1,
 	},
 	[RG503] = {
-		1023, /* Observed average from device */
-		"rk3566-anbernic-rg503",
-		"RG503",
-		DTB_DIR "rk3566-anbernic-rg503.dtb",
+		.adc_value = 1023, /* Observed average from device */
+		.board = "rk3566-anbernic-rg503",
+		.board_name = "RG503",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg503.dtb",
+		.detect_panel = 0,
 	},
 	/* Devices with duplicate ADC value */
 	[RG353PS] = {
-		860, /* Observed average from device */
-		"rk3566-anbernic-rg353ps",
-		"RG353PS",
-		DTB_DIR "rk3566-anbernic-rg353ps.dtb",
+		.adc_value = 860, /* Observed average from device */
+		.board = "rk3566-anbernic-rg353ps",
+		.board_name = "RG353PS",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353ps.dtb",
+		.detect_panel = 1,
 	},
 	[RG353VS] = {
-		695, /* Gathered from second hand information */
-		"rk3566-anbernic-rg353vs",
-		"RG353VS",
-		DTB_DIR "rk3566-anbernic-rg353vs.dtb",
+		.adc_value = 695, /* Gathered from second hand information */
+		.board = "rk3566-anbernic-rg353vs",
+		.board_name = "RG353VS",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353vs.dtb",
+		.detect_panel = 1,
 	},
 };
 
 struct rg353_panel {
 	const u16 id;
-	const char *panel_compat;
+	const char *panel_compat[2];
 };
 
 static const struct rg353_panel rg353_panel_details[] = {
-	{ .id = 0x3052, .panel_compat = "newvision,nv3051d"},
-	{ .id = 0x3821, .panel_compat = "anbernic,rg353v-panel-v2"},
+	{
+		.id = 0x3052,
+		.panel_compat[0] = "anbernic,rg353p-panel",
+		.panel_compat[1] = "newvision,nv3051d",
+	},
+	{
+		.id = 0x3821,
+		.panel_compat[0] = "anbernic,rg353v-panel-v2",
+		.panel_compat[1] = NULL,
+	},
 };
 
 /*
@@ -298,11 +314,10 @@ int rgxx3_detect_display(void)
 	if (!panel) {
 		printf("Unable to identify panel_id %x\n",
 		       (panel_id[0] << 8) | panel_id[1]);
-		env_set("panel", "unknown");
 		return -EINVAL;
 	}
 
-	env_set("panel", panel->panel_compat);
+	env_set("panel", panel->panel_compat[0]);
 
 	return 0;
 }
@@ -367,13 +382,14 @@ int rgxx3_detect_device(void)
 		rg3xx_model_details[board_id].board_name);
 	env_set("fdtfile", rg3xx_model_details[board_id].fdtfile);
 
-	/* Detect the panel type for any device that isn't a 503. */
-	if (board_id == RG503)
+	/* Skip panel detection for when it is not needed. */
+	if (!rg3xx_model_details[board_id].detect_panel)
 		return 0;
 
+	/* Warn but don't fail for errors in auto-detection of the panel. */
 	ret = rgxx3_detect_display();
 	if (ret)
-		return ret;
+		printf("Failed to detect panel type\n");
 
 	return 0;
 }
@@ -400,7 +416,8 @@ int rk_board_late_init(void)
 
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
-	int node, ret;
+	const struct rg353_panel *panel = NULL;
+	int node, ret, i;
 	char *env;
 
 	/* No fixups necessary for the RG503 */
@@ -414,6 +431,12 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 			    rg3xx_model_details[RG353M].board_name,
 			    sizeof(rg3xx_model_details[RG353M].board_name));
 
+	env = env_get("panel");
+	if (!env) {
+		printf("Can't get panel env\n");
+		return 0;
+	}
+
 	/*
 	 * Check if the environment variable doesn't equal the panel.
 	 * If it doesn't, update the devicetree to the correct panel.
@@ -424,12 +447,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 		return -ENODEV;
 	}
 
-	env = env_get("panel");
-	if (!env) {
-		printf("Can't get panel env\n");
-		return -ENODEV;
-	}
-
 	ret = fdt_node_check_compatible(blob, node, env);
 	if (ret < 0)
 		return -ENODEV;
@@ -438,8 +455,24 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 	if (!ret)
 		return 0;
 
-	do_fixup_by_path_string(blob, "/dsi@fe060000/panel@0",
-				"compatible", env);
+	/* Panels don't match, search by first compatible value. */
+	for (i = 0; i < ARRAY_SIZE(rg353_panel_details); i++) {
+		if (!strcmp(env, rg353_panel_details[i].panel_compat[0])) {
+			panel = &rg353_panel_details[i];
+			break;
+		}
+	}
+
+	if (!panel) {
+		printf("Unable to identify panel by compat string\n");
+		return -ENODEV;
+	}
+
+	/* Set the compatible with the auto-detected values */
+	fdt_setprop_string(blob, node, "compatible", panel->panel_compat[0]);
+	if (panel->panel_compat[1])
+		fdt_appendprop_string(blob, node, "compatible",
+				      panel->panel_compat[1]);
 
 	return 0;
 }
Signature · 1 line
2.34.1
Reviewed-by on v4 1/7
#2 lore raw

Re: [PATCH V4 1/7] board: rockchip: Refactor panel auto-detect code

Quoted 11 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Make the inability to detect a panel using the auto detection code not fail the entire boot process. This means that if the panel ID cannot be read we don't set an environment variable for the panel, and if an environment variable for the panel is not set we don't attempt to update the compatible string. Changes to the code also ensure that when there are multiple compatible strings required for the panel we use them both, which solves some issues that will pop up soon for the Linux driver.

Quoted 1 line

Thanks,
- Kever

Quoted 205 lines
---
  board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 115 +++++++++++++--------
  1 file changed, 74 insertions(+), 41 deletions(-)
board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c +74 -41
index 3f1a42d184..3d0c614623 100644
@@ -40,6 +40,7 @@ struct rg3xx_model {
  	const char *board;
  	const char *board_name;
  	const char *fdtfile;
+	const bool detect_panel;
  };
 
  enum rgxx3_device_id {
@@ -54,52 +55,67 @@ enum rgxx3_device_id {
 
  static const struct rg3xx_model rg3xx_model_details[] = {
  	[RG353M] = {
-		517, /* Observed average from device */
-		"rk3566-anbernic-rg353m",
-		"RG353M",
-		DTB_DIR "rk3566-anbernic-rg353p.dtb", /* Identical devices */
+		.adc_value = 517, /* Observed average from device */
+		.board = "rk3566-anbernic-rg353m",
+		.board_name = "RG353M",
+		/* Device is identical to RG353P. */
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353p.dtb",
+		.detect_panel = 1,
  	},
  	[RG353P] = {
-		860, /* Documented value of 860 */
-		"rk3566-anbernic-rg353p",
-		"RG353P",
-		DTB_DIR "rk3566-anbernic-rg353p.dtb",
+		.adc_value = 860, /* Documented value of 860 */
+		.board = "rk3566-anbernic-rg353p",
+		.board_name = "RG353P",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353p.dtb",
+		.detect_panel = 1,
  	},
  	[RG353V] = {
-		695, /* Observed average from device */
-		"rk3566-anbernic-rg353v",
-		"RG353V",
-		DTB_DIR "rk3566-anbernic-rg353v.dtb",
+		.adc_value = 695, /* Observed average from device */
+		.board = "rk3566-anbernic-rg353v",
+		.board_name = "RG353V",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353v.dtb",
+		.detect_panel = 1,
  	},
  	[RG503] = {
-		1023, /* Observed average from device */
-		"rk3566-anbernic-rg503",
-		"RG503",
-		DTB_DIR "rk3566-anbernic-rg503.dtb",
+		.adc_value = 1023, /* Observed average from device */
+		.board = "rk3566-anbernic-rg503",
+		.board_name = "RG503",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg503.dtb",
+		.detect_panel = 0,
  	},
  	/* Devices with duplicate ADC value */
  	[RG353PS] = {
-		860, /* Observed average from device */
-		"rk3566-anbernic-rg353ps",
-		"RG353PS",
-		DTB_DIR "rk3566-anbernic-rg353ps.dtb",
+		.adc_value = 860, /* Observed average from device */
+		.board = "rk3566-anbernic-rg353ps",
+		.board_name = "RG353PS",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353ps.dtb",
+		.detect_panel = 1,
  	},
  	[RG353VS] = {
-		695, /* Gathered from second hand information */
-		"rk3566-anbernic-rg353vs",
-		"RG353VS",
-		DTB_DIR "rk3566-anbernic-rg353vs.dtb",
+		.adc_value = 695, /* Gathered from second hand information */
+		.board = "rk3566-anbernic-rg353vs",
+		.board_name = "RG353VS",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg353vs.dtb",
+		.detect_panel = 1,
  	},
  };
 
  struct rg353_panel {
  	const u16 id;
-	const char *panel_compat;
+	const char *panel_compat[2];
  };
 
  static const struct rg353_panel rg353_panel_details[] = {
-	{ .id = 0x3052, .panel_compat = "newvision,nv3051d"},
-	{ .id = 0x3821, .panel_compat = "anbernic,rg353v-panel-v2"},
+	{
+		.id = 0x3052,
+		.panel_compat[0] = "anbernic,rg353p-panel",
+		.panel_compat[1] = "newvision,nv3051d",
+	},
+	{
+		.id = 0x3821,
+		.panel_compat[0] = "anbernic,rg353v-panel-v2",
+		.panel_compat[1] = NULL,
+	},
  };
 
  /*
@@ -298,11 +314,10 @@ int rgxx3_detect_display(void)
  	if (!panel) {
  		printf("Unable to identify panel_id %x\n",
  		       (panel_id[0] << 8) | panel_id[1]);
-		env_set("panel", "unknown");
  		return -EINVAL;
  	}
 
-	env_set("panel", panel->panel_compat);
+	env_set("panel", panel->panel_compat[0]);
 
  	return 0;
  }
@@ -367,13 +382,14 @@ int rgxx3_detect_device(void)
  		rg3xx_model_details[board_id].board_name);
  	env_set("fdtfile", rg3xx_model_details[board_id].fdtfile);
 
-	/* Detect the panel type for any device that isn't a 503. */
-	if (board_id == RG503)
+	/* Skip panel detection for when it is not needed. */
+	if (!rg3xx_model_details[board_id].detect_panel)
  		return 0;
 
+	/* Warn but don't fail for errors in auto-detection of the panel. */
  	ret = rgxx3_detect_display();
  	if (ret)
-		return ret;
+		printf("Failed to detect panel type\n");
 
  	return 0;
  }
@@ -400,7 +416,8 @@ int rk_board_late_init(void)
 
  int ft_board_setup(void *blob, struct bd_info *bd)
  {
-	int node, ret;
+	const struct rg353_panel *panel = NULL;
+	int node, ret, i;
  	char *env;
 
  	/* No fixups necessary for the RG503 */
@@ -414,6 +431,12 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  			    rg3xx_model_details[RG353M].board_name,
  			    sizeof(rg3xx_model_details[RG353M].board_name));
 
+	env = env_get("panel");
+	if (!env) {
+		printf("Can't get panel env\n");
+		return 0;
+	}
+
  	/*
  	 * Check if the environment variable doesn't equal the panel.
  	 * If it doesn't, update the devicetree to the correct panel.
@@ -424,12 +447,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  		return -ENODEV;
  	}
 
-	env = env_get("panel");
-	if (!env) {
-		printf("Can't get panel env\n");
-		return -ENODEV;
-	}
-
  	ret = fdt_node_check_compatible(blob, node, env);
  	if (ret < 0)
  		return -ENODEV;
@@ -438,8 +455,24 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  	if (!ret)
  		return 0;
 
-	do_fixup_by_path_string(blob, "/dsi@fe060000/panel@0",
-				"compatible", env);
+	/* Panels don't match, search by first compatible value. */
+	for (i = 0; i < ARRAY_SIZE(rg353_panel_details); i++) {
+		if (!strcmp(env, rg353_panel_details[i].panel_compat[0])) {
+			panel = &rg353_panel_details[i];
+			break;
+		}
+	}
+
+	if (!panel) {
+		printf("Unable to identify panel by compat string\n");
+		return -ENODEV;
+	}
+
+	/* Set the compatible with the auto-detected values */
+	fdt_setprop_string(blob, node, "compatible", panel->panel_compat[0]);
+	if (panel->panel_compat[1])
+		fdt_appendprop_string(blob, node, "compatible",
+				      panel->panel_compat[1]);
 
  	return 0;
  }
#3 lore raw

PATCH v4 2/7 spl: Add Kconfig options for ADC

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add kconfig options to enable ADC in SPL

---
 common/spl/Kconfig   | 7 +++++++
 drivers/Makefile     | 1 +
 drivers/adc/Makefile | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)
common/spl/Kconfig +7 -0
index c521b02f4a..ada9dcea5c 100644
@@ -579,6 +579,13 @@ config SPL_FIT_IMAGE_TINY
 	  ensure this information is available to the next image
 	  invoked).
 
+config SPL_ADC
+	bool "Support ADC drivers"
+	help
+	  Enable ADC drivers in SPL. These drivers can allow the reading of
+	  analog values from one or more channels. Enable this option to
+	  build the drivers in drivers/adc as part of an SPL build.
+
 config SPL_CACHE
 	bool "Support CACHE drivers"
 	help
drivers/Makefile +1 -0
index bf73b7718c..81ba2c534e 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+obj-$(CONFIG_$(SPL_)ADC) += adc/
 obj-$(CONFIG_$(SPL_TPL_)BIOSEMU) += bios_emulator/
 obj-$(CONFIG_$(SPL_TPL_)BLK) += block/
 obj-$(CONFIG_$(SPL_TPL_)BOOTCOUNT_LIMIT) += bootcount/
drivers/adc/Makefile +1 -1
index 5336c82097..9eb07769b0 100644
@@ -4,7 +4,7 @@
 # Przemyslaw Marczak <[email protected]>
 #
 
-obj-$(CONFIG_ADC) += adc-uclass.o
+obj-$(CONFIG_$(SPL_)ADC) += adc-uclass.o
 obj-$(CONFIG_ADC_EXYNOS) += exynos-adc.o
 obj-$(CONFIG_ADC_SANDBOX) += sandbox.o
 obj-$(CONFIG_SARADC_ROCKCHIP) += rockchip-saradc.o
Signature · 1 line
2.34.1
#4 lore raw

PATCH v4 3/7 rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Update the rockchip_dnl_key_pressed() so that it can run in SPL. Also change the ADC channel to a define that can be overridden by a board specific option.

---
 arch/arm/mach-rockchip/Makefile    |  4 ++--
 arch/arm/mach-rockchip/boot_mode.c | 11 ++++++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)
arch/arm/mach-rockchip/Makefile +2 -2
index 1dc92066bb..ff089ae949 100644
@@ -15,13 +15,13 @@ obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o
 
 obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
 
-ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
-
 # Always include boot_mode.o, as we bypass it (i.e. turn it off)
 # inside of boot_mode.c when CONFIG_ROCKCHIP_BOOT_MODE_REG is 0.  This way,
 # we can have the preprocessor correctly recognise both 0x0 and 0
 # meaning "turn it off".
 obj-y += boot_mode.o
+
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
 obj-$(CONFIG_MISC_INIT_R) += misc.o
 endif
arch/arm/mach-rockchip/boot_mode.c +10 -1
index eb8f65ae4e..d2308768be 100644
@@ -38,6 +38,10 @@ void set_back_to_bootrom_dnl_flag(void)
 #define KEY_DOWN_MIN_VAL	0
 #define KEY_DOWN_MAX_VAL	30
 
+#ifndef RK_DNL_ADC_CHAN
+#define RK_DNL_ADC_CHAN		1
+#endif
+
 __weak int rockchip_dnl_key_pressed(void)
 {
 	unsigned int val;
@@ -52,7 +56,8 @@ __weak int rockchip_dnl_key_pressed(void)
 	ret = -ENODEV;
 	uclass_foreach_dev(dev, uc) {
 		if (!strncmp(dev->name, "saradc", 6)) {
-			ret = adc_channel_single_shot(dev->name, 1, &val);
+			ret = adc_channel_single_shot(dev->name,
+						      RK_DNL_ADC_CHAN, &val);
 			break;
 		}
 	}
@@ -73,11 +78,13 @@ __weak int rockchip_dnl_key_pressed(void)
 
 void rockchip_dnl_mode_check(void)
 {
+#if CONFIG_IS_ENABLED(ADC)
 	if (rockchip_dnl_key_pressed()) {
 		printf("download key pressed, entering download mode...");
 		set_back_to_bootrom_dnl_flag();
 		do_reset(NULL, 0, 0, NULL);
 	}
+#endif
 }
 
 int setup_boot_mode(void)
@@ -90,6 +97,7 @@ int setup_boot_mode(void)
 	boot_mode = readl(reg);
 	debug("%s: boot mode 0x%08x\n", __func__, boot_mode);
 
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
 	/* Clear boot mode */
 	writel(BOOT_NORMAL, reg);
 
@@ -103,6 +111,7 @@ int setup_boot_mode(void)
 		env_set("preboot", "setenv preboot; ums mmc 0");
 		break;
 	}
+#endif
 
 	return 0;
 }
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH V4 3/7] rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL

Hi Chris,

Quoted 5 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Update the rockchip_dnl_key_pressed() so that it can run in SPL. Also change the ADC channel to a define that can be overridden by a board specific option.

I should ask this earlier.

Why you have to enable the download key in SPL?

This works for a long time in U-Boot proper, both mainline and downstream vendor U-Boot,

no one is detect this download key in SPL.

In theory the SPL can implement all the feature which is available in U-Boot proper,

but it would be better to make the SPL focus on the job it should be done and keep as small as possible.

Thanks,

- Kever

Quoted 82 lines
---
  arch/arm/mach-rockchip/Makefile    |  4 ++--
  arch/arm/mach-rockchip/boot_mode.c | 11 ++++++++++-
  2 files changed, 12 insertions(+), 3 deletions(-)
arch/arm/mach-rockchip/Makefile +2 -2
index 1dc92066bb..ff089ae949 100644
@@ -15,13 +15,13 @@ obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o
 
  obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
 
-ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
-
  # Always include boot_mode.o, as we bypass it (i.e. turn it off)
  # inside of boot_mode.c when CONFIG_ROCKCHIP_BOOT_MODE_REG is 0.  This way,
  # we can have the preprocessor correctly recognise both 0x0 and 0
  # meaning "turn it off".
  obj-y += boot_mode.o
+
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
  obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
  obj-$(CONFIG_MISC_INIT_R) += misc.o
  endif
arch/arm/mach-rockchip/boot_mode.c +10 -1
index eb8f65ae4e..d2308768be 100644
@@ -38,6 +38,10 @@ void set_back_to_bootrom_dnl_flag(void)
  #define KEY_DOWN_MIN_VAL	0
  #define KEY_DOWN_MAX_VAL	30
 
+#ifndef RK_DNL_ADC_CHAN
+#define RK_DNL_ADC_CHAN		1
+#endif
+
  __weak int rockchip_dnl_key_pressed(void)
  {
  	unsigned int val;
@@ -52,7 +56,8 @@ __weak int rockchip_dnl_key_pressed(void)
  	ret = -ENODEV;
  	uclass_foreach_dev(dev, uc) {
  		if (!strncmp(dev->name, "saradc", 6)) {
-			ret = adc_channel_single_shot(dev->name, 1, &val);
+			ret = adc_channel_single_shot(dev->name,
+						      RK_DNL_ADC_CHAN, &val);
  			break;
  		}
  	}
@@ -73,11 +78,13 @@ __weak int rockchip_dnl_key_pressed(void)
 
  void rockchip_dnl_mode_check(void)
  {
+#if CONFIG_IS_ENABLED(ADC)
  	if (rockchip_dnl_key_pressed()) {
  		printf("download key pressed, entering download mode...");
  		set_back_to_bootrom_dnl_flag();
  		do_reset(NULL, 0, 0, NULL);
  	}
+#endif
  }
 
  int setup_boot_mode(void)
@@ -90,6 +97,7 @@ int setup_boot_mode(void)
  	boot_mode = readl(reg);
  	debug("%s: boot mode 0x%08x\n", __func__, boot_mode);
 
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
  	/* Clear boot mode */
  	writel(BOOT_NORMAL, reg);
 
@@ -103,6 +111,7 @@ int setup_boot_mode(void)
  		env_set("preboot", "setenv preboot; ums mmc 0");
  		break;
  	}
+#endif
 
  	return 0;
  }
#6 lore raw

Re: [PATCH V4 3/7] rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL

Quoted 16 lines · Kever Yang

Hi Chris,

Quoted 5 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Update the rockchip_dnl_key_pressed() so that it can run in SPL. Also change the ADC channel to a define that can be overridden by a board specific option.

I should ask this earlier.

Why you have to enable the download key in SPL?

This works for a long time in U-Boot proper, both mainline and downstream vendor U-Boot,

Quoted 8 lines

no one is detect this download key in SPL.

In theory the SPL can implement all the feature which is available in U-Boot proper,

but it would be better to make the SPL focus on the job it should be done and keep as small as possible.

I wanted this code to run as soon as possible in the event of a bad write. I have some devices which lack a way to bypass the eMMC in the boot path; the fear is that if an SPL stage is written with a good header but a bad payload (or if the A-TF does something wrong) the device will become unbootable. If we can't do it this way for all Rockchip boards that's fine, but I REALLY want to at least do it this way for the Powkiddy X55 board and the Anbernic RGxx3 board.

While I have you, I have a related question I hope you can help with. Is there any way to utilize the boot partitions of an eMMC device? I don't know if the BROM of an RK3568 or RK3588 is capable, but I'd love to have the SPL and U-Boot stages written to the eMMC boot partitions instead of the user partition if I can.

Thank you.

Quoted 79 lines

Thanks,

- Kever

Quoted 74 lines
---
  arch/arm/mach-rockchip/Makefile    |  4 ++--
  arch/arm/mach-rockchip/boot_mode.c | 11 ++++++++++-
  2 files changed, 12 insertions(+), 3 deletions(-)
arch/arm/mach-rockchip/Makefile +2 -2
index 1dc92066bb..ff089ae949 100644
@@ -15,13 +15,13 @@ obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o
  obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
-ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
-
  # Always include boot_mode.o, as we bypass it (i.e. turn it off)
  # inside of boot_mode.c when CONFIG_ROCKCHIP_BOOT_MODE_REG is 0.  This way,
  # we can have the preprocessor correctly recognise both 0x0 and 0
  # meaning "turn it off".
  obj-y += boot_mode.o
+
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
  obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
  obj-$(CONFIG_MISC_INIT_R) += misc.o
  endif
arch/arm/mach-rockchip/boot_mode.c +10 -1
index eb8f65ae4e..d2308768be 100644
@@ -38,6 +38,10 @@ void set_back_to_bootrom_dnl_flag(void)
  #define KEY_DOWN_MIN_VAL	0
  #define KEY_DOWN_MAX_VAL	30
+#ifndef RK_DNL_ADC_CHAN
+#define RK_DNL_ADC_CHAN		1
+#endif
+
  __weak int rockchip_dnl_key_pressed(void)
  {
  	unsigned int val;
@@ -52,7 +56,8 @@ __weak int rockchip_dnl_key_pressed(void)
  	ret = -ENODEV;
  	uclass_foreach_dev(dev, uc) {
  		if (!strncmp(dev->name, "saradc", 6)) {
-			ret = adc_channel_single_shot(dev->name, 1, &val);
+			ret = adc_channel_single_shot(dev->name,
+						      RK_DNL_ADC_CHAN, &val);
  			break;
  		}
  	}
@@ -73,11 +78,13 @@ __weak int rockchip_dnl_key_pressed(void)
  void rockchip_dnl_mode_check(void)
  {
+#if CONFIG_IS_ENABLED(ADC)
  	if (rockchip_dnl_key_pressed()) {
  		printf("download key pressed, entering download mode...");
  		set_back_to_bootrom_dnl_flag();
  		do_reset(NULL, 0, 0, NULL);
  	}
+#endif
  }
  int setup_boot_mode(void)
@@ -90,6 +97,7 @@ int setup_boot_mode(void)
  	boot_mode = readl(reg);
  	debug("%s: boot mode 0x%08x\n", __func__, boot_mode);
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
  	/* Clear boot mode */
  	writel(BOOT_NORMAL, reg);
@@ -103,6 +111,7 @@ int setup_boot_mode(void)
  		env_set("preboot", "setenv preboot; ums mmc 0");
  		break;
  	}
+#endif
  	return 0;
  }
#7 lore raw

Re: [PATCH V4 3/7] rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL

Hi Chris,

Quoted 24 lines · Chris Morgan
Quoted 15 lines · Kever Yang

Hi Chris,

Quoted 5 lines · Chris Morgan

From: Chris Morgan<[email protected]>

Update the rockchip_dnl_key_pressed() so that it can run in SPL. Also change the ADC channel to a define that can be overridden by a board specific option.

I should ask this earlier.

Why you have to enable the download key in SPL?

This works for a long time in U-Boot proper, both mainline and downstream vendor U-Boot,

Quoted 8 lines

no one is detect this download key in SPL.

In theory the SPL can implement all the feature which is available in U-Boot proper,

but it would be better to make the SPL focus on the job it should be done and keep as small as possible.

Quoted 7 lines

I wanted this code to run as soon as possible in the event of a bad write. I have some devices which lack a way to bypass the eMMC in the boot path; the fear is that if an SPL stage is written with a good header but a bad payload (or if the A-TF does something wrong) the device will become unbootable. If we can't do it this way for all Rockchip boards that's fine, but I REALLY want to at least do it this way for the Powkiddy X55 board and the Anbernic RGxx3 board.

That's why rockchip platform has two download mode, loader mode(in U-Boot)

and maskRom mode, any error happen before U-Boot should get into maksRom mode.

Most of user/developer only use loader mode because the modules before U-Boot should

be more stable and have very little chance to update, for the module owners before U-Boot,

they are the users of maskRom mode.

If you enable this feature in SPL, the error still have chance to happen during dram init to SPL key detect.

Does these two board has no way to get into eMMC event with hardware rework? any hardware

signal of eMMC CMD/CLK/DATA is OK.

And another way to bypass eMMC is to use SDcard which has higher priority then eMMC in BootRom.

For SPL itself debug, I would suggest to RESET into bootrom download mode if any error happen

and a reset will need.

I pick up patches other than 2,3,4 in this patchset for now.

Quoted 5 lines

While I have you, I have a related question I hope you can help with. Is there any way to utilize the boot partitions of an eMMC device? I don't know if the BROM of an RK3568 or RK3588 is capable, but I'd love to have the SPL and U-Boot stages written to the eMMC boot partitions instead of the user partition if I can.

No, Rockchip SoCs does not use the boot partitions of eMMC, only use the user data partition.

Thanks,

- Kever

Quoted 80 lines

Thank you.

Quoted 77 lines

Thanks,

- Kever

Quoted 73 lines
---
   arch/arm/mach-rockchip/Makefile    |  4 ++--
   arch/arm/mach-rockchip/boot_mode.c | 11 ++++++++++-
   2 files changed, 12 insertions(+), 3 deletions(-)
arch/arm/mach-rockchip/Makefile +2 -2
index 1dc92066bb..ff089ae949 100644
@@ -15,13 +15,13 @@ obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o
   obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
-ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
-
   # Always include boot_mode.o, as we bypass it (i.e. turn it off)
   # inside of boot_mode.c when CONFIG_ROCKCHIP_BOOT_MODE_REG is 0.  This way,
   # we can have the preprocessor correctly recognise both 0x0 and 0
   # meaning "turn it off".
   obj-y += boot_mode.o
+
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
   obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
   obj-$(CONFIG_MISC_INIT_R) += misc.o
   endif
arch/arm/mach-rockchip/boot_mode.c +10 -1
index eb8f65ae4e..d2308768be 100644
@@ -38,6 +38,10 @@ void set_back_to_bootrom_dnl_flag(void)
   #define KEY_DOWN_MIN_VAL	0
   #define KEY_DOWN_MAX_VAL	30
+#ifndef RK_DNL_ADC_CHAN
+#define RK_DNL_ADC_CHAN		1
+#endif
+
   __weak int rockchip_dnl_key_pressed(void)
   {
   	unsigned int val;
@@ -52,7 +56,8 @@ __weak int rockchip_dnl_key_pressed(void)
   	ret = -ENODEV;
   	uclass_foreach_dev(dev, uc) {
   		if (!strncmp(dev->name, "saradc", 6)) {
-			ret = adc_channel_single_shot(dev->name, 1, &val);
+			ret = adc_channel_single_shot(dev->name,
+						      RK_DNL_ADC_CHAN, &val);
   			break;
   		}
   	}
@@ -73,11 +78,13 @@ __weak int rockchip_dnl_key_pressed(void)
   void rockchip_dnl_mode_check(void)
   {
+#if CONFIG_IS_ENABLED(ADC)
   	if (rockchip_dnl_key_pressed()) {
   		printf("download key pressed, entering download mode...");
   		set_back_to_bootrom_dnl_flag();
   		do_reset(NULL, 0, 0, NULL);
   	}
+#endif
   }
   int setup_boot_mode(void)
@@ -90,6 +97,7 @@ int setup_boot_mode(void)
   	boot_mode = readl(reg);
   	debug("%s: boot mode 0x%08x\n", __func__, boot_mode);
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
   	/* Clear boot mode */
   	writel(BOOT_NORMAL, reg);
@@ -103,6 +111,7 @@ int setup_boot_mode(void)
   		env_set("preboot", "setenv preboot; ums mmc 0");
   		break;
   	}
+#endif
   	return 0;
   }
#8 lore raw

Re: [PATCH V4 3/7] rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL

Quoted 48 lines · Kever Yang

Hi Chris,

Quoted 24 lines · Chris Morgan
Quoted 15 lines · Kever Yang

Hi Chris,

Quoted 5 lines · Chris Morgan

From: Chris Morgan<[email protected]>

Update the rockchip_dnl_key_pressed() so that it can run in SPL. Also change the ADC channel to a define that can be overridden by a board specific option.

I should ask this earlier.

Why you have to enable the download key in SPL?

This works for a long time in U-Boot proper, both mainline and downstream vendor U-Boot,

Quoted 8 lines

no one is detect this download key in SPL.

In theory the SPL can implement all the feature which is available in U-Boot proper,

but it would be better to make the SPL focus on the job it should be done and keep as small as possible.

Quoted 7 lines

I wanted this code to run as soon as possible in the event of a bad write. I have some devices which lack a way to bypass the eMMC in the boot path; the fear is that if an SPL stage is written with a good header but a bad payload (or if the A-TF does something wrong) the device will become unbootable. If we can't do it this way for all Rockchip boards that's fine, but I REALLY want to at least do it this way for the Powkiddy X55 board and the Anbernic RGxx3 board.

That's why rockchip platform has two download mode, loader mode(in U-Boot)

and maskRom mode, any error happen before U-Boot should get into maksRom mode.

Most of user/developer only use loader mode because the modules before U-Boot should

be more stable and have very little chance to update, for the module owners before U-Boot,

they are the users of maskRom mode.

Quoted 7 lines

If you enable this feature in SPL, the error still have chance to happen during dram init to SPL key detect.

Does these two board has no way to get into eMMC event with hardware rework? any hardware

signal of eMMC CMD/CLK/DATA is OK.

A few do not. The error is less likely to occur between RAM init and SPL key detect, but yes it's even possible at this stage.

From my testing using the latest BL31 file from the rockchip-linux/rkbin github repository I was unable to reboot into maskrom mode after A-TF loaded, the device would just straight reboot. Do you know if A-TF does something that makes reboot into maskrom mode no longer work?

Quoted 4 lines

And another way to bypass eMMC is to use SDcard which has higher priority then eMMC in BootRom.

I see in the TRM under section 1.2 that the eMMC is higher in the boot path than SDMMC, and that matches my experience as well. So this wouldn't be a solution sadly.

Quoted 7 lines

For SPL itself debug, I would suggest to RESET into bootrom download mode if any error happen

and a reset will need.

I pick up patches other than 2,3,4 in this patchset for now.

Quoted 8 lines
Quoted 5 lines

While I have you, I have a related question I hope you can help with. Is there any way to utilize the boot partitions of an eMMC device? I don't know if the BROM of an RK3568 or RK3588 is capable, but I'd love to have the SPL and U-Boot stages written to the eMMC boot partitions instead of the user partition if I can.

No, Rockchip SoCs does not use the boot partitions of eMMC, only use the user data partition.

That's unfortunate, but I appreciate the feedback.

Thank you,
Chris

Quoted 86 lines

Thanks,

- Kever

Quoted 80 lines

Thank you.

Quoted 77 lines

Thanks,

- Kever

Quoted 73 lines
---
   arch/arm/mach-rockchip/Makefile    |  4 ++--
   arch/arm/mach-rockchip/boot_mode.c | 11 ++++++++++-
   2 files changed, 12 insertions(+), 3 deletions(-)
arch/arm/mach-rockchip/Makefile +2 -2
index 1dc92066bb..ff089ae949 100644
@@ -15,13 +15,13 @@ obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o
   obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
-ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
-
   # Always include boot_mode.o, as we bypass it (i.e. turn it off)
   # inside of boot_mode.c when CONFIG_ROCKCHIP_BOOT_MODE_REG is 0.  This way,
   # we can have the preprocessor correctly recognise both 0x0 and 0
   # meaning "turn it off".
   obj-y += boot_mode.o
+
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
   obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
   obj-$(CONFIG_MISC_INIT_R) += misc.o
   endif
arch/arm/mach-rockchip/boot_mode.c +10 -1
index eb8f65ae4e..d2308768be 100644
@@ -38,6 +38,10 @@ void set_back_to_bootrom_dnl_flag(void)
   #define KEY_DOWN_MIN_VAL	0
   #define KEY_DOWN_MAX_VAL	30
+#ifndef RK_DNL_ADC_CHAN
+#define RK_DNL_ADC_CHAN		1
+#endif
+
   __weak int rockchip_dnl_key_pressed(void)
   {
   	unsigned int val;
@@ -52,7 +56,8 @@ __weak int rockchip_dnl_key_pressed(void)
   	ret = -ENODEV;
   	uclass_foreach_dev(dev, uc) {
   		if (!strncmp(dev->name, "saradc", 6)) {
-			ret = adc_channel_single_shot(dev->name, 1, &val);
+			ret = adc_channel_single_shot(dev->name,
+						      RK_DNL_ADC_CHAN, &val);
   			break;
   		}
   	}
@@ -73,11 +78,13 @@ __weak int rockchip_dnl_key_pressed(void)
   void rockchip_dnl_mode_check(void)
   {
+#if CONFIG_IS_ENABLED(ADC)
   	if (rockchip_dnl_key_pressed()) {
   		printf("download key pressed, entering download mode...");
   		set_back_to_bootrom_dnl_flag();
   		do_reset(NULL, 0, 0, NULL);
   	}
+#endif
   }
   int setup_boot_mode(void)
@@ -90,6 +97,7 @@ int setup_boot_mode(void)
   	boot_mode = readl(reg);
   	debug("%s: boot mode 0x%08x\n", __func__, boot_mode);
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
   	/* Clear boot mode */
   	writel(BOOT_NORMAL, reg);
@@ -103,6 +111,7 @@ int setup_boot_mode(void)
   		env_set("preboot", "setenv preboot; ums mmc 0");
   		break;
   	}
+#endif
   	return 0;
   }

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Re: [PATCH V4 3/7] rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL

Quoted 55 lines · Chris Morgan
Quoted 47 lines · Kever Yang

Hi Chris,

Quoted 24 lines · Chris Morgan
Quoted 15 lines · Kever Yang

Hi Chris,

Quoted 5 lines · Chris Morgan

From: Chris Morgan<[email protected]>

Update the rockchip_dnl_key_pressed() so that it can run in SPL. Also change the ADC channel to a define that can be overridden by a board specific option.

I should ask this earlier.

Why you have to enable the download key in SPL?

This works for a long time in U-Boot proper, both mainline and downstream vendor U-Boot,

Quoted 8 lines

no one is detect this download key in SPL.

In theory the SPL can implement all the feature which is available in U-Boot proper,

but it would be better to make the SPL focus on the job it should be done and keep as small as possible.

Quoted 7 lines

I wanted this code to run as soon as possible in the event of a bad write. I have some devices which lack a way to bypass the eMMC in the boot path; the fear is that if an SPL stage is written with a good header but a bad payload (or if the A-TF does something wrong) the device will become unbootable. If we can't do it this way for all Rockchip boards that's fine, but I REALLY want to at least do it this way for the Powkiddy X55 board and the Anbernic RGxx3 board.

That's why rockchip platform has two download mode, loader mode(in U-Boot)

and maskRom mode, any error happen before U-Boot should get into maksRom mode.

Most of user/developer only use loader mode because the modules before U-Boot should

be more stable and have very little chance to update, for the module owners before U-Boot,

they are the users of maskRom mode.

Quoted 7 lines

If you enable this feature in SPL, the error still have chance to happen during dram init to SPL key detect.

Does these two board has no way to get into eMMC event with hardware rework? any hardware

signal of eMMC CMD/CLK/DATA is OK.

Quoted 8 lines

A few do not. The error is less likely to occur between RAM init and SPL key detect, but yes it's even possible at this stage.

Quoted 1 line

From my testing using the latest BL31 file from the

rockchip-linux/rkbin github repository I was unable to reboot into maskrom mode after A-TF loaded, the device would just straight reboot. Do you know if A-TF does something that makes reboot into maskrom mode no longer work?

This is no reasonable, it should be able to reboot to maskrom mode any time we want, because

the vendor kernel also do this and the function works.

Quoted 6 lines
Quoted 4 lines

And another way to bypass eMMC is to use SDcard which has higher priority then eMMC in BootRom.

I see in the TRM under section 1.2 that the eMMC is higher in the boot path than SDMMC, and that matches my experience as well.

Yes, you are right about this, and I think rockchip vendor code is using SD card as  the first priority in the SPL instead of "same-as SPL", and make the SPL small and simple enough
to involve less bug, so that stable enough and no need to update.
This patch is OK when the check for key press entry is in the board level instead of platform common code.

Thanks,
- Kever

Quoted 106 lines

So this
wouldn't be a solution sadly.

Quoted 7 lines

For SPL itself debug, I would suggest to RESET into bootrom download mode if any error happen

and a reset will need.

I pick up patches other than 2,3,4 in this patchset for now.

Quoted 7 lines
Quoted 5 lines

While I have you, I have a related question I hope you can help with. Is there any way to utilize the boot partitions of an eMMC device? I don't know if the BROM of an RK3568 or RK3588 is capable, but I'd love to have the SPL and U-Boot stages written to the eMMC boot partitions instead of the user partition if I can.

No, Rockchip SoCs does not use the boot partitions of eMMC, only use the user data partition.

That's unfortunate, but I appreciate the feedback.

Thank you,
Chris

Quoted 84 lines

Thanks,

- Kever

Quoted 79 lines

Thank you.

Quoted 77 lines

Thanks,

- Kever

Quoted 73 lines
---
    arch/arm/mach-rockchip/Makefile    |  4 ++--
    arch/arm/mach-rockchip/boot_mode.c | 11 ++++++++++-
    2 files changed, 12 insertions(+), 3 deletions(-)
arch/arm/mach-rockchip/Makefile +2 -2
index 1dc92066bb..ff089ae949 100644
@@ -15,13 +15,13 @@ obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o
    obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
-ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
-
    # Always include boot_mode.o, as we bypass it (i.e. turn it off)
    # inside of boot_mode.c when CONFIG_ROCKCHIP_BOOT_MODE_REG is 0.  This way,
    # we can have the preprocessor correctly recognise both 0x0 and 0
    # meaning "turn it off".
    obj-y += boot_mode.o
+
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
    obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
    obj-$(CONFIG_MISC_INIT_R) += misc.o
    endif
arch/arm/mach-rockchip/boot_mode.c +10 -1
index eb8f65ae4e..d2308768be 100644
@@ -38,6 +38,10 @@ void set_back_to_bootrom_dnl_flag(void)
    #define KEY_DOWN_MIN_VAL	0
    #define KEY_DOWN_MAX_VAL	30
+#ifndef RK_DNL_ADC_CHAN
+#define RK_DNL_ADC_CHAN		1
+#endif
+
    __weak int rockchip_dnl_key_pressed(void)
    {
    	unsigned int val;
@@ -52,7 +56,8 @@ __weak int rockchip_dnl_key_pressed(void)
    	ret = -ENODEV;
    	uclass_foreach_dev(dev, uc) {
    		if (!strncmp(dev->name, "saradc", 6)) {
-			ret = adc_channel_single_shot(dev->name, 1, &val);
+			ret = adc_channel_single_shot(dev->name,
+						      RK_DNL_ADC_CHAN, &val);
    			break;
    		}
    	}
@@ -73,11 +78,13 @@ __weak int rockchip_dnl_key_pressed(void)
    void rockchip_dnl_mode_check(void)
    {
+#if CONFIG_IS_ENABLED(ADC)
    	if (rockchip_dnl_key_pressed()) {
    		printf("download key pressed, entering download mode...");
    		set_back_to_bootrom_dnl_flag();
    		do_reset(NULL, 0, 0, NULL);
    	}
+#endif
    }
    int setup_boot_mode(void)
@@ -90,6 +97,7 @@ int setup_boot_mode(void)
    	boot_mode = readl(reg);
    	debug("%s: boot mode 0x%08x\n", __func__, boot_mode);
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
    	/* Clear boot mode */
    	writel(BOOT_NORMAL, reg);
@@ -103,6 +111,7 @@ int setup_boot_mode(void)
    		env_set("preboot", "setenv preboot; ums mmc 0");
    		break;
    	}
+#endif
    	return 0;
    }
#11 lore raw

PATCH v4 4/7 board: rockchip: Add Recovery Button for Anbernic RGxx3

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add support for users to enter recovery mode by holding the function button when they power up the device.

Since the device has soldered eMMC and sometimes does not expose a clk pin on the mainboard there is a small chance that a user who flashes a bad bootloader may not be able to recover if the headers themselves are valid. As a result this check is done during spl_early_init() to ensure that it runs as early as possible, and it does so by directly manipulating the ADC hardware in lieu of loading the ADC driver.

---
 arch/arm/dts/rk3566-anbernic-rgxx3-u-boot.dtsi | 11 +++++++++++
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c     |  6 +++++-
 configs/anbernic-rgxx3-rk3566_defconfig        | 16 ++++++++++++----
 include/configs/anbernic-rgxx3-rk3566.h        |  2 ++
 4 files changed, 30 insertions(+), 5 deletions(-)
arch/arm/dts/rk3566-anbernic-rgxx3-u-boot.dtsi +11 -0
index f986e1941e..e3ab196d22 100644
@@ -76,6 +76,12 @@
 	/delete-property/ clock-names;
 };
 
+&saradc {
+	bootph-all;
+	vref-supply = <&vcc_sys>;
+	status = "okay";
+};
+
 &sdhci {
 	pinctrl-0 = <&emmc_bus8>, <&emmc_clk>, <&emmc_cmd>,
 		    <&emmc_datastrobe>, <&emmc_rstnout>;
@@ -94,3 +100,8 @@
 	bootph-all;
 	status = "okay";
 };
+
+&vcc_sys {
+	bootph-all;
+	status = "okay";
+};
board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c +5 -1
index 3d0c614623..45854709f5 100644
@@ -5,6 +5,7 @@
 
 #include <abuf.h>
 #include <adc.h>
+#include <asm/arch-rockchip/boot_mode.h>
 #include <asm/io.h>
 #include <display.h>
 #include <dm.h>
@@ -119,11 +120,14 @@ static const struct rg353_panel rg353_panel_details[] = {
 };
 
 /*
- * Start LED very early so user knows device is on. Set color
+ * Check if rockchip_dnl button is pressed and reboot into rockusb if
+ * true. Start LED very early so user knows device is on. Set color
  * to red.
  */
 void spl_board_init(void)
 {
+	setup_boot_mode();
+
 	/* Set GPIO0_C5, GPIO0_C6, and GPIO0_C7 to output. */
 	writel(GPIO_WRITEMASK(GPIO_C7 | GPIO_C6 | GPIO_C5) | \
 	       (GPIO_C7 | GPIO_C6 | GPIO_C5),
configs/anbernic-rgxx3-rk3566_defconfig +12 -4
index ed6643d9d4..4e72f75815 100644
@@ -3,6 +3,7 @@ CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_TEXT_BASE=0x00a00000
+CONFIG_SPL_GPIO=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=2
@@ -24,7 +25,9 @@ CONFIG_SYS_LOAD_ADDR=0xc00800
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3566-anbernic-rgxx3.dtb"
@@ -32,7 +35,7 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3566-anbernic-rgxx3.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_BOARD_RNG_SEED=y
-CONFIG_SPL_MAX_SIZE=0x20000
+CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x4000000
@@ -41,6 +44,8 @@ CONFIG_SPL_BOARD_INIT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
 CONFIG_SPL_STACK_R=y
+CONFIG_SPL_ADC=y
+CONFIG_SPL_POWER=y
 CONFIG_SPL_ATF=y
 CONFIG_CMD_PWM=y
 CONFIG_CMD_GPT=y
@@ -50,8 +55,10 @@ CONFIG_CMD_MMC=y
 # CONFIG_SPL_DOS_PARTITION is not set
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIVE=y
+CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 # CONFIG_NET is not set
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
 CONFIG_SPL_CLK=y
@@ -67,13 +74,13 @@ CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_ROCKCHIP=y
 CONFIG_PHY_ROCKCHIP_INNO_DSIDPHY=y
+CONFIG_SPL_PINCTRL=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_FAN53555=y
 CONFIG_PMIC_RK8XX=y
-CONFIG_REGULATOR_PWM=y
-CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_SPL_DM_REGULATOR=y
+CONFIG_SPL_DM_REGULATOR_FIXED=y
 CONFIG_REGULATOR_RK8XX=y
-CONFIG_DM_REGULATOR_SCMI=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_SPL_RAM=y
 # CONFIG_RAM_ROCKCHIP_DEBUG is not set
@@ -89,5 +96,6 @@ CONFIG_VIDEO_ROCKCHIP=y
 CONFIG_DISPLAY_ROCKCHIP_DW_MIPI=y
 CONFIG_VIDEO_BRIDGE=y
 CONFIG_REGEX=y
+# CONFIG_RSA is not set
 CONFIG_ERRNO_STR=y
 # CONFIG_EFI_LOADER is not set
include/configs/anbernic-rgxx3-rk3566.h +2 -0
index 3c4ea4e7d8..2aaac55c06 100644
@@ -9,4 +9,6 @@
 			"stdout=serial,vidconsole\0" \
 			"stderr=serial,vidconsole\0"
 
+#define RK_DNL_ADC_CHAN		0
+
 #endif
Signature · 1 line
2.34.1
#12 lore raw

PATCH v4 5/7 rockchip: board: Add board_rng_seed() for all Rockchip devices

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Allow all rockchip devices to use the hardware RNG to seed Linux RNG.

---
 arch/arm/mach-rockchip/board.c             | 32 ++++++++++++++++++++++
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 29 --------------------
 2 files changed, 32 insertions(+), 29 deletions(-)
arch/arm/mach-rockchip/board.c +32 -0
index 57f08e0be0..77145524ea 100644
@@ -348,3 +348,35 @@ __weak int misc_init_r(void)
 	return ret;
 }
 #endif
+
+#if IS_ENABLED(CONFIG_BOARD_RNG_SEED) && IS_ENABLED(CONFIG_RNG_ROCKCHIP)
+#include <rng.h>
+
+/* Use hardware rng to seed Linux random. */
+__weak int board_rng_seed(struct abuf *buf)
+{
+	struct udevice *dev;
+	size_t len = 0x8;
+	u64 *data;
+
+	data = malloc(len);
+	if (!data) {
+		printf("Out of memory\n");
+		return -ENOMEM;
+	}
+
+	if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
+		printf("No RNG device\n");
+		return -ENODEV;
+	}
+
+	if (dm_rng_read(dev, data, len)) {
+		printf("Reading RNG failed\n");
+		return -EIO;
+	}
+
+	abuf_init_set(buf, data, len);
+
+	return 0;
+}
+#endif
board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c +0 -29
index 45854709f5..7bef5a53f0 100644
@@ -17,7 +17,6 @@
 #include <mmc.h>
 #include <panel.h>
 #include <pwm.h>
-#include <rng.h>
 #include <stdlib.h>
 #include <video_bridge.h>
 
@@ -137,34 +136,6 @@ void spl_board_init(void)
 	       (GPIO0_BASE + GPIO_SWPORT_DR_H));
 }
 
-/* Use hardware rng to seed Linux random. */
-int board_rng_seed(struct abuf *buf)
-{
-	struct udevice *dev;
-	size_t len = 0x8;
-	u64 *data;
-
-	data = malloc(len);
-	if (!data) {
-		printf("Out of memory\n");
-		return -ENOMEM;
-	}
-
-	if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
-		printf("No RNG device\n");
-		return -ENODEV;
-	}
-
-	if (dm_rng_read(dev, data, len)) {
-		printf("Reading RNG failed\n");
-		return -EIO;
-	}
-
-	abuf_init_set(buf, data, len);
-
-	return 0;
-}
-
 /*
  * Buzz the buzzer so the user knows something is going on. Make it
  * optional in case PWM is disabled.
Signature · 1 line
2.34.1
Reviewed-by on v4 5/7
#13 lore raw

Re: [PATCH V4 5/7] rockchip: board: Add board_rng_seed() for all Rockchip devices

Quoted 6 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Allow all rockchip devices to use the hardware RNG to seed Linux RNG.

Thanks,
- Kever

Quoted 92 lines
---
  arch/arm/mach-rockchip/board.c             | 32 ++++++++++++++++++++++
  board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 29 --------------------
  2 files changed, 32 insertions(+), 29 deletions(-)
arch/arm/mach-rockchip/board.c +32 -0
index 57f08e0be0..77145524ea 100644
@@ -348,3 +348,35 @@ __weak int misc_init_r(void)
  	return ret;
  }
  #endif
+
+#if IS_ENABLED(CONFIG_BOARD_RNG_SEED) && IS_ENABLED(CONFIG_RNG_ROCKCHIP)
+#include <rng.h>
+
+/* Use hardware rng to seed Linux random. */
+__weak int board_rng_seed(struct abuf *buf)
+{
+	struct udevice *dev;
+	size_t len = 0x8;
+	u64 *data;
+
+	data = malloc(len);
+	if (!data) {
+		printf("Out of memory\n");
+		return -ENOMEM;
+	}
+
+	if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
+		printf("No RNG device\n");
+		return -ENODEV;
+	}
+
+	if (dm_rng_read(dev, data, len)) {
+		printf("Reading RNG failed\n");
+		return -EIO;
+	}
+
+	abuf_init_set(buf, data, len);
+
+	return 0;
+}
+#endif
board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c +0 -29
index 45854709f5..7bef5a53f0 100644
@@ -17,7 +17,6 @@
  #include <mmc.h>
  #include <panel.h>
  #include <pwm.h>
-#include <rng.h>
  #include <stdlib.h>
  #include <video_bridge.h>
 
@@ -137,34 +136,6 @@ void spl_board_init(void)
  	       (GPIO0_BASE + GPIO_SWPORT_DR_H));
  }
 
-/* Use hardware rng to seed Linux random. */
-int board_rng_seed(struct abuf *buf)
-{
-	struct udevice *dev;
-	size_t len = 0x8;
-	u64 *data;
-
-	data = malloc(len);
-	if (!data) {
-		printf("Out of memory\n");
-		return -ENOMEM;
-	}
-
-	if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
-		printf("No RNG device\n");
-		return -ENODEV;
-	}
-
-	if (dm_rng_read(dev, data, len)) {
-		printf("Reading RNG failed\n");
-		return -EIO;
-	}
-
-	abuf_init_set(buf, data, len);
-
-	return 0;
-}
-
  /*
   * Buzz the buzzer so the user knows something is going on. Make it
   * optional in case PWM is disabled.
#14 lore raw

PATCH v4 6/7 board: rockchip: Add support for new boards to RGxx3

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add support for the Anbernic RG-ARC-D, Anbernic RG-ARC-S, Powkiddy RK2023, and Powkiddy RGB30 to the Anbernic RGxx3. While the Powkiddy devices are manufactured by Powkiddy instead of Anbernic, the hardware is so similar they can all use the same bootloader.

---
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 44 +++++++++++++++++++---
 1 file changed, 39 insertions(+), 5 deletions(-)
board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c +39 -5
index 7bef5a53f0..e12a85a02a 100644
@@ -48,9 +48,13 @@ enum rgxx3_device_id {
 	RG353P,
 	RG353V,
 	RG503,
+	RGB30,
+	RK2023,
+	RGARCD,
 	/* Devices with duplicate ADC value */
 	RG353PS,
 	RG353VS,
+	RGARCS,
 };
 
 static const struct rg3xx_model rg3xx_model_details[] = {
@@ -83,6 +87,27 @@ static const struct rg3xx_model rg3xx_model_details[] = {
 		.fdtfile = DTB_DIR "rk3566-anbernic-rg503.dtb",
 		.detect_panel = 0,
 	},
+	[RGB30] = {
+		.adc_value = 383, /* Gathered from second hand information */
+		.board = "rk3566-powkiddy-rgb30",
+		.board_name = "RGB30",
+		.fdtfile = DTB_DIR "rk3566-powkiddy-rgb30.dtb",
+		.detect_panel = 0,
+	},
+	[RK2023] = {
+		.adc_value = 635, /* Observed average from device */
+		.board = "rk3566-powkiddy-rk2023",
+		.board_name = "RK2023",
+		.fdtfile = DTB_DIR "rk3566-powkiddy-rk2023.dtb",
+		.detect_panel = 0,
+	},
+	[RGARCD] = {
+		.adc_value = 183, /* Observed average from device */
+		.board = "rk3566-anbernic-rg-arc-d",
+		.board_name = "Anbernic RG ARC-D",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg-arc-d.dtb",
+		.detect_panel = 0,
+	},
 	/* Devices with duplicate ADC value */
 	[RG353PS] = {
 		.adc_value = 860, /* Observed average from device */
@@ -98,6 +123,13 @@ static const struct rg3xx_model rg3xx_model_details[] = {
 		.fdtfile = DTB_DIR "rk3566-anbernic-rg353vs.dtb",
 		.detect_panel = 1,
 	},
+	[RGARCS] = {
+		.adc_value = 183, /* Observed average from device */
+		.board = "rk3566-anbernic-rg-arc-s",
+		.board_name = "Anbernic RG ARC-S",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg-arc-s.dtb",
+		.detect_panel = 0,
+	},
 };
 
 struct rg353_panel {
@@ -332,19 +364,21 @@ int rgxx3_detect_device(void)
 	}
 
 	/*
-	 * Try to access the eMMC on an RG353V or RG353P. If it's
-	 * missing, it's an RG353VS or RG353PS. Note we could also
-	 * check for a touchscreen at 0x1a on i2c2.
+	 * Try to access the eMMC on an RG353V, RG353P, or RG Arc D.
+	 * If it's missing, it's an RG353VS, RG353PS, or RG Arc S.
+	 * Note we could also check for a touchscreen at 0x1a on i2c2.
 	 */
-	if (board_id == RG353V || board_id == RG353P) {
+	if (board_id == RG353V || board_id == RG353P || board_id == RGARCD) {
 		mmc = find_mmc_device(0);
 		if (mmc) {
 			ret = mmc_init(mmc);
 			if (ret) {
 				if (board_id == RG353V)
 					board_id = RG353VS;
-				else
+				else if (board_id == RG353P)
 					board_id = RG353PS;
+				else
+					board_id = RGARCS;
 			}
 		}
 	}
Signature · 1 line
2.34.1
Reviewed-by on v4 6/7
#15 lore raw

Re: [PATCH V4 6/7] board: rockchip: Add support for new boards to RGxx3

Quoted 8 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add support for the Anbernic RG-ARC-D, Anbernic RG-ARC-S, Powkiddy RK2023, and Powkiddy RGB30 to the Anbernic RGxx3. While the Powkiddy devices are manufactured by Powkiddy instead of Anbernic, the hardware is so similar they can all use the same bootloader.

Thanks,
- Kever

Quoted 91 lines
---
  board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 44 +++++++++++++++++++---
  1 file changed, 39 insertions(+), 5 deletions(-)
board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c +39 -5
index 7bef5a53f0..e12a85a02a 100644
@@ -48,9 +48,13 @@ enum rgxx3_device_id {
  	RG353P,
  	RG353V,
  	RG503,
+	RGB30,
+	RK2023,
+	RGARCD,
  	/* Devices with duplicate ADC value */
  	RG353PS,
  	RG353VS,
+	RGARCS,
  };
 
  static const struct rg3xx_model rg3xx_model_details[] = {
@@ -83,6 +87,27 @@ static const struct rg3xx_model rg3xx_model_details[] = {
  		.fdtfile = DTB_DIR "rk3566-anbernic-rg503.dtb",
  		.detect_panel = 0,
  	},
+	[RGB30] = {
+		.adc_value = 383, /* Gathered from second hand information */
+		.board = "rk3566-powkiddy-rgb30",
+		.board_name = "RGB30",
+		.fdtfile = DTB_DIR "rk3566-powkiddy-rgb30.dtb",
+		.detect_panel = 0,
+	},
+	[RK2023] = {
+		.adc_value = 635, /* Observed average from device */
+		.board = "rk3566-powkiddy-rk2023",
+		.board_name = "RK2023",
+		.fdtfile = DTB_DIR "rk3566-powkiddy-rk2023.dtb",
+		.detect_panel = 0,
+	},
+	[RGARCD] = {
+		.adc_value = 183, /* Observed average from device */
+		.board = "rk3566-anbernic-rg-arc-d",
+		.board_name = "Anbernic RG ARC-D",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg-arc-d.dtb",
+		.detect_panel = 0,
+	},
  	/* Devices with duplicate ADC value */
  	[RG353PS] = {
  		.adc_value = 860, /* Observed average from device */
@@ -98,6 +123,13 @@ static const struct rg3xx_model rg3xx_model_details[] = {
  		.fdtfile = DTB_DIR "rk3566-anbernic-rg353vs.dtb",
  		.detect_panel = 1,
  	},
+	[RGARCS] = {
+		.adc_value = 183, /* Observed average from device */
+		.board = "rk3566-anbernic-rg-arc-s",
+		.board_name = "Anbernic RG ARC-S",
+		.fdtfile = DTB_DIR "rk3566-anbernic-rg-arc-s.dtb",
+		.detect_panel = 0,
+	},
  };
 
  struct rg353_panel {
@@ -332,19 +364,21 @@ int rgxx3_detect_device(void)
  	}
 
  	/*
-	 * Try to access the eMMC on an RG353V or RG353P. If it's
-	 * missing, it's an RG353VS or RG353PS. Note we could also
-	 * check for a touchscreen at 0x1a on i2c2.
+	 * Try to access the eMMC on an RG353V, RG353P, or RG Arc D.
+	 * If it's missing, it's an RG353VS, RG353PS, or RG Arc S.
+	 * Note we could also check for a touchscreen at 0x1a on i2c2.
  	 */
-	if (board_id == RG353V || board_id == RG353P) {
+	if (board_id == RG353V || board_id == RG353P || board_id == RGARCD) {
  		mmc = find_mmc_device(0);
  		if (mmc) {
  			ret = mmc_init(mmc);
  			if (ret) {
  				if (board_id == RG353V)
  					board_id = RG353VS;
-				else
+				else if (board_id == RG353P)
  					board_id = RG353PS;
+				else
+					board_id = RGARCS;
  			}
  		}
  	}
#16 lore raw

PATCH v4 7/7 doc: board: anbernic: Update rgxx3 to add new boards

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Update the RGxx3 documentation to note that it now supports the RG-ARC-D, RG-ARC-S, Powkiddy RK2023, and Powkiddy RGB30. Also update verbiage around panel detection to note that it is no longer hard coded to the RG503.

---
 doc/board/anbernic/rgxx3.rst | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
doc/board/anbernic/rgxx3.rst +14 -6
index 7d1beb423c..d159ed2f76 100644
@@ -5,6 +5,8 @@ U-Boot for Anbernic RGxx3 Devices
 
 This allows U-Boot to boot the following Anbernic devices:
 
+ - Anbernic RG-ARC-D
+ - Anbernic RG-ARC-S
  - Anbernic RG353M
  - Anbernic RG353P
  - Anbernic RG353PS
@@ -12,18 +14,24 @@ This allows U-Boot to boot the following Anbernic devices:
  - Anbernic RG353VS
  - Anbernic RG503
 
+Additionally, the following very similar non-Anbernic devices are also
+supported:
+
+ - Powkiddy RGB30
+ - Powkiddy RK2023
+
 The correct device is detected automatically by comparing ADC values
 from ADC channel 1. In the event of an RG353V or RG353P, an attempt
 is then made to probe for an eMMC and if it fails the device is assumed
 to be an RG353VS or RG353PS. Based on the detected device, the
 environment variables "board", "board_name", and "fdtfile" are set to
 the correct values corresponding to the board which can be read by a
-boot script to boot with the correct device tree. If the board detected
-is not of type RG503 (which currently has only 1 panel revision) a
-panel detect is then performed by probing a "dummy" display on the DSI
-bus and then querying the display ID. The display ID is then compared
-to a table to get the known compatible string for use in Linux, and
-this string is saved as an environment variable of "panel".
+boot script to boot with the correct device tree. If a board is defined
+as requiring panel detection, a panel detect is then performed by
+probing a "dummy" display on the DSI bus and then querying the display
+ID. The display ID is then compared to a table to get the known
+compatible string for use in Linux, and this string is saved as an
+environment variable of "panel".
 
 FDT fixups are performed in the event of an RG353M to change the device
 name, or in the event the panel detected does not match the devicetree.
Signature · 1 line
2.34.1
Reviewed-by on v4 7/7
#17 lore raw

Re: [PATCH V4 7/7] doc: board: anbernic: Update rgxx3 to add new boards

Quoted 8 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Update the RGxx3 documentation to note that it now supports the RG-ARC-D, RG-ARC-S, Powkiddy RK2023, and Powkiddy RGB30. Also update verbiage around panel detection to note that it is no longer hard coded to the RG503.

Thanks,
- Kever

Quoted 48 lines
---
  doc/board/anbernic/rgxx3.rst | 20 ++++++++++++++------
  1 file changed, 14 insertions(+), 6 deletions(-)
doc/board/anbernic/rgxx3.rst +14 -6
index 7d1beb423c..d159ed2f76 100644
@@ -5,6 +5,8 @@ U-Boot for Anbernic RGxx3 Devices
 
  This allows U-Boot to boot the following Anbernic devices:
 
+ - Anbernic RG-ARC-D
+ - Anbernic RG-ARC-S
   - Anbernic RG353M
   - Anbernic RG353P
   - Anbernic RG353PS
@@ -12,18 +14,24 @@ This allows U-Boot to boot the following Anbernic devices:
   - Anbernic RG353VS
   - Anbernic RG503
 
+Additionally, the following very similar non-Anbernic devices are also
+supported:
+
+ - Powkiddy RGB30
+ - Powkiddy RK2023
+
  The correct device is detected automatically by comparing ADC values
  from ADC channel 1. In the event of an RG353V or RG353P, an attempt
  is then made to probe for an eMMC and if it fails the device is assumed
  to be an RG353VS or RG353PS. Based on the detected device, the
  environment variables "board", "board_name", and "fdtfile" are set to
  the correct values corresponding to the board which can be read by a
-boot script to boot with the correct device tree. If the board detected
-is not of type RG503 (which currently has only 1 panel revision) a
-panel detect is then performed by probing a "dummy" display on the DSI
-bus and then querying the display ID. The display ID is then compared
-to a table to get the known compatible string for use in Linux, and
-this string is saved as an environment variable of "panel".
+boot script to boot with the correct device tree. If a board is defined
+as requiring panel detection, a panel detect is then performed by
+probing a "dummy" display on the DSI bus and then querying the display
+ID. The display ID is then compared to a table to get the known
+compatible string for use in Linux, and this string is saved as an
+environment variable of "panel".
 
  FDT fixups are performed in the event of an RG353M to change the device
  name, or in the event the panel detected does not match the devicetree.