Skip to contentSkip to conversation

configs: rzg2_beacon: Disable the ability to remove devices

PATCH In review Adam Ford 3 participants 10 messages Oct 25, 2023 – Nov 19, 2023

lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH 1/3 configs: rzg2_beacon: Disable the ability to remove devices

In order to save some space, disable the ability to dynamically remove devices. Without this, U-Boot is too large to load without recompiling TF-A.

configs/rzg2_beacon_defconfig +1 -0
index 73abe966b8..7b14d225b5 100644
@@ -48,6 +48,7 @@ CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_MMC_ENV_PART=2
 CONFIG_VERSION_VARIABLE=y
+# CONFIG_DM_DEVICE_REMOVE is not set
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_CLK=y
Signature · 1 line
2.40.1
author
#1 lore raw

PATCH 2/3 configs: rzg2_beacon: Realign ENV location and offset

The ENV size and offset were changed to different values in Beacon's downstream release. Change them to the same values as the downstream for consistent behavior.

configs/rzg2_beacon_defconfig +2 -1
index 7b14d225b5..534f641e84 100644
@@ -3,7 +3,8 @@ CONFIG_ARCH_RMOBILE=y
 CONFIG_TEXT_BASE=0x50000000
 CONFIG_SYS_MALLOC_LEN=0x4000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
-CONFIG_ENV_OFFSET=0x0
+CONFIG_ENV_SIZE=0x2000
+CONFIG_ENV_OFFSET=0xFFFFE000
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="r8a774a1-beacon-rzg2m-kit"
 CONFIG_RCAR_GEN3=y
Signature · 1 line
2.40.1
author
#2 lore raw

Re: [PATCH 2/3] configs: rzg2_beacon: Realign ENV location and offset

Quoted 6 lines · Adam Ford

The ENV size and offset were changed to different values in Beacon's downstream release. Change them to the same values as the downstream for consistent behavior.

Marek,

I know you had some feedback on other patches in this series. I'll drop one, and refactor another, but is this one ok to merge as-is or should I re-post without the other patches?

adam

Quoted 18 lines
configs/rzg2_beacon_defconfig +2 -2
index 7b14d225b5..534f641e84 100644
@@ -3,7 +3,8 @@ CONFIG_ARCH_RMOBILE=y
 CONFIG_TEXT_BASE=0x50000000
 CONFIG_SYS_MALLOC_LEN=0x4000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
-CONFIG_ENV_OFFSET=0x0
+CONFIG_ENV_SIZE=0x2000
+CONFIG_ENV_OFFSET=0xFFFFE000
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="r8a774a1-beacon-rzg2m-kit"
 CONFIG_RCAR_GEN3=y
--

2.40.1

#3 lore raw

Re: [PATCH 2/3] configs: rzg2_beacon: Realign ENV location and offset

Quoted 6 lines · Adam Ford
Quoted 5 lines · Adam Ford

The ENV size and offset were changed to different values in Beacon's downstream release. Change them to the same values as the downstream for consistent behavior.

Quoted 7 lines
Quoted 1 line

Marek,

I know you had some feedback on other patches in this series. I'll drop one, and refactor another, but is this one ok to merge as-is or should I re-post without the other patches?

Please repost, and use the right To: address (+renesas@mailbox) , I'll pick it up shortly.

author
#4 lore raw

PATCH 3/3 arm: rmobile: rzg2_beacon: Auto select Linux device tree by SoC

In reply to Adam Ford

There is a function inside the board file to autodetect which device tree is needed by U-Boot to properly load its own device tree, but it currently defaults to always loading RZ/G2M for Linux. This is not correct for other SoC variants. Add board_late_init function to query the SoC name and use that to determine which device tree is loaded for booting Linux.

board/beacon/beacon-rzg2m/beacon-rzg2m.c +33 -0
index 99fe1edfb3..6d37ff6ac9 100644
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
+#include <env.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -17,6 +18,38 @@ int board_init(void)
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_BOARD_LATE_INIT)
+static u8 get_SoC_letter(void)
+{
+	const u8 *name = rzg_get_cpu_name();
+
+	if (*name)
+		return name[6];
+
+	return 0;
+}
+
+int board_late_init(void)
+{
+	/* If already defined, exit */
+	if (!env_get("fdt_file")) {
+		switch (get_SoC_letter()) {
+		case 'A':
+			env_set("fdt_file", "r8a774a1-beacon-rzg2m-kit.dtb");
+			break;
+		case 'B':
+			env_set("fdt_file", "r8a774b1-beacon-rzg2n-kit.dtb");
+			break;
+		case 'E':
+			env_set("fdt_file", "r8a774e1-beacon-rzg2h-kit.dtb");
+			break;
+		}
+	}
+
+	return 0;
+}
+#endif /* CONFIG_BOARD_LATE_INIT */
+
 #if IS_ENABLED(CONFIG_MULTI_DTB_FIT)
 int board_fit_config_name_match(const char *name)
 {
configs/rzg2_beacon_defconfig +1 -0
index 534f641e84..6894448b22 100644
@@ -21,6 +21,7 @@ CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; else run netboot; fi; fi; else booti ${loadaddr} - ${fdt_addr}; fi"
 CONFIG_DEFAULT_FDT_FILE="r8a774a1-beacon-rzg2m-kit.dtb"
 # CONFIG_BOARD_EARLY_INIT_F is not set
+CONFIG_BOARD_LATE_INIT=y
 CONFIG_SYS_MALLOC_BOOTPARAMS=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=64
include/configs/beacon-rzg2m.h +0 -1
index 65c01835cc..493b98fbdf 100644
@@ -18,7 +18,6 @@
 	"fdt_addr=0x48000000\0" \
 	"loadaddr=0x48080000\0" \
 	"boot_fdt=try\0" \
-	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
 	"initrd_addr=0x43800000\0"		\
 	"mmcdev=1\0" \
 	"mmcpart=1\0" \
Signature · 1 line
2.40.1
#5 lore raw

Re: [PATCH 3/3] arm: rmobile: rzg2_beacon: Auto select Linux device tree by SoC

Quoted 6 lines · Adam Ford

There is a function inside the board file to autodetect which device tree is needed by U-Boot to properly load its own device tree, but it currently defaults to always loading RZ/G2M for Linux. This is not correct for other SoC variants. Add board_late_init function to query the SoC name and use that to determine which device tree is loaded for booting Linux.

Can't this be scripted in environment instead ?

author
#6 lore raw

Re: [PATCH 3/3] arm: rmobile: rzg2_beacon: Auto select Linux device tree by SoC

Quoted 10 lines · Marek Vasut
Quoted 6 lines · Adam Ford

There is a function inside the board file to autodetect which device tree is needed by U-Boot to properly load its own device tree, but it currently defaults to always loading RZ/G2M for Linux. This is not correct for other SoC variants. Add board_late_init function to query the SoC name and use that to determine which device tree is loaded for booting Linux.

Can't this be scripted in environment instead ?

Do you have a recommendation for how to read the SoC type from a script?

adam

#7 lore raw

Re: [PATCH 3/3] arm: rmobile: rzg2_beacon: Auto select Linux device tree by SoC

Quoted 10 lines · Adam Ford
Quoted 9 lines · Marek Vasut
Quoted 6 lines · Adam Ford

There is a function inside the board file to autodetect which device tree is needed by U-Boot to properly load its own device tree, but it currently defaults to always loading RZ/G2M for Linux. This is not correct for other SoC variants. Add board_late_init function to query the SoC name and use that to determine which device tree is loaded for booting Linux.

Quoted 3 lines
Quoted 1 line

Can't this be scripted in environment instead ?

Do you have a recommendation for how to read the SoC type from a script?

If you want to read PRR from script:

$ setexpr prrcontent *0xFFF00044
$ printenv prrcontent
#8 lore raw
In reply to Adam Ford
Quoted 3 lines · Adam Ford

In order to save some space, disable the ability to dynamically remove devices. Without this, U-Boot is too large to load without recompiling TF-A.

Did you enable LTO yet ?

Striping DM_REMOVE seems like a really bad idea, doesn't that break 'usb reset' and its removal of devices ?

author
#9 lore raw
Quoted 7 lines · Marek Vasut
Quoted 3 lines · Adam Ford

In order to save some space, disable the ability to dynamically remove devices. Without this, U-Boot is too large to load without recompiling TF-A.

Did you enable LTO yet ?

Yes.

Quoted 3 lines

Striping DM_REMOVE seems like a really bad idea, doesn't that break 'usb reset' and its removal of devices ?

I did not, but we can drop this one, and I'll just have to re-compile TF-A to load a larger U-Boot.

adam