rcar: Select the correct device tree
Subsystems (3)
v2 cover rcar: Select the correct device tree
The R-Car Starter Kit Premier(H3e WS3.0) uses the r8a779m1-ulcb.dtb. As u-boot can detect the board id and revision, let's use this to set the correct device tree for that board when using pxe.
Changes since v1:
* Also expose the board revision in sysinfo
* Set the dtb depending on board revision
* Move RCar board IDs definitions to sys_proto.h
* fix checkpatch.pl warnings
Detlev Casanova (3):
renesas: rcar3: Expose the board id in sysinfo
renesas: rcar3: Expose the board revision in sysinfo
renesas: rcar3: Load the correct device tree
.../arm/mach-rmobile/include/mach/sys_proto.h | 21 +++++ board/renesas/ulcb/ulcb.c | 59 ++++++++++++ configs/rcar3_ulcb_defconfig | 1 + drivers/sysinfo/rcar3.c | 90 +++++++++++-------- 4 files changed, 133 insertions(+), 38 deletions(-)
Signature · 1 line
2.39.3
PATCH v2 1/3 renesas: rcar3: Expose the board id in sysinfo
This is a preparation commit for selecting the correct device tree name to be loaded depending on the board id.
--- .../arm/mach-rmobile/include/mach/sys_proto.h | 15 ++++++++++ drivers/sysinfo/rcar3.c | 30 +++++++++++-------- 2 files changed, 33 insertions(+), 12 deletions(-)
arch/arm/mach-rmobile/include/mach/sys_proto.h +15 -0
@@ -7,4 +7,19 @@#ifndef _SYS_PROTO_H_#define _SYS_PROTO_H_ +/* +* Renesas R-Car Board IDs +*/ +#define BOARD_SALVATOR_X 0x0 +#define BOARD_KRIEK 0x1 +#define BOARD_STARTER_KIT 0x2 +#define BOARD_EAGLE 0x3 +#define BOARD_SALVATOR_XS 0x4 +#define BOARD_CONDOR 0x6 +#define BOARD_DRAAK 0x7 +#define BOARD_EBISU 0x8 +#define BOARD_STARTER_KIT_PRE 0xB +#define BOARD_EBISU_4D 0xD +#define BOARD_CONDOR_I 0x10 +#endif
drivers/sysinfo/rcar3.c +18 -12
@@ -8,23 +8,12 @@#include <i2c_eeprom.h> #include <log.h> #include <sysinfo.h> +#include <asm/arch/sys_proto.h> #define BOARD_CODE_MASK 0xF8#define BOARD_REV_MASK 0x07#define BOARD_CODE_SHIFT 0x03 -#define BOARD_SALVATOR_X 0x0 -#define BOARD_KRIEK 0x1 -#define BOARD_STARTER_KIT 0x2 -#define BOARD_EAGLE 0x3 -#define BOARD_SALVATOR_XS 0x4 -#define BOARD_CONDOR 0x6 -#define BOARD_DRAAK 0x7 -#define BOARD_EBISU 0x8 -#define BOARD_STARTER_KIT_PRE 0xB -#define BOARD_EBISU_4D 0xD -#define BOARD_CONDOR_I 0x10 -/** * struct sysinfo_rcar_priv - sysinfo private data * @boardname: board model and revision
@@ -32,6 +21,7 @@*/ struct sysinfo_rcar_priv {char boardmodel[64 ]; +u8 board_id;u8 val; };
@@ -42,6 +32,19 @@ static int sysinfo_rcar_detect(struct udevice *dev)return priv->val ==0xff ; } +static int sysinfo_rcar_get_int (struct udevice *dev,int id,int *val) +{ +struct sysinfo_rcar_priv *priv =dev_get_priv (dev); + +switch (id) { +case SYSINFO_ID_BOARD_MODEL : + *val = priv->board_id; +return 0 ; +default : +return -EINVAL ; + }; +} +static int sysinfo_rcar_get_str (struct udevice *dev,int id,size_t size,char *val) {struct sysinfo_rcar_priv *priv =dev_get_priv (dev);
@@ -59,6 +62,7 @@ static int sysinfo_rcar_get_str(struct udevice *dev, int id, size_t size, char *static const struct sysinfo_ops sysinfo_rcar_ops = { .detect = sysinfo_rcar_detect, .get_str = sysinfo_rcar_get_str, + .get_int = sysinfo_rcar_get_int, };static void sysinfo_rcar_parse (struct sysinfo_rcar_priv *priv)
@@ -68,6 +72,8 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)bool salvator_xs = false;bool ebisu_4d = false;bool condor_i = false; + + priv->board_id = board_id;char rev_major ='?' ;char rev_minor ='?' ;
Signature · 1 line
2.39.3
Re: [PATCH v2 1/3] renesas: rcar3: Expose the board id in sysinfo
Quoted 49 lines · Detlev Casanova
This is a preparation commit for selecting the correct device tree name to be loaded depending on the board id.
Signed-off-by Detlev Casanova <[email protected]>--- .../arm/mach-rmobile/include/mach/sys_proto.h | 15 ++++++++++ drivers/sysinfo/rcar3.c | 30 +++++++++++-------- 2 files changed, 33 insertions(+), 12 deletions(-)arch/arm/mach-rmobile/include/mach/sys_proto.h +15
-0@@ -7,4 +7,19 @@#ifndef _SYS_PROTO_H_#define _SYS_PROTO_H_ +/* +* Renesas R-Car Board IDs +*/ +#define BOARD_SALVATOR_X 0x0 +#define BOARD_KRIEK 0x1 +#define BOARD_STARTER_KIT 0x2 +#define BOARD_EAGLE 0x3 +#define BOARD_SALVATOR_XS 0x4 +#define BOARD_CONDOR 0x6 +#define BOARD_DRAAK 0x7 +#define BOARD_EBISU 0x8 +#define BOARD_STARTER_KIT_PRE 0xB +#define BOARD_EBISU_4D 0xD +#define BOARD_CONDOR_I 0x10 +#endif drivers/sysinfo/rcar3.c +1
-2@@ -8,23 +8,12 @@#include <i2c_eeprom.h> #include <log.h> #include <sysinfo.h> +#include <asm/arch/sys_proto.h> #define BOARD_CODE_MASK 0xF8#define BOARD_REV_MASK 0x07#define BOARD_CODE_SHIFT 0x03 -#define BOARD_SALVATOR_X 0x0 -#define BOARD_KRIEK 0x1
drivers/sysinfo/rcar3.c line 27
Quoted 10 lines
drivers/sysinfo/rcar3.c +0
-10-#define BOARD_STARTER_KIT 0x2 -#define BOARD_EAGLE 0x3 -#define BOARD_SALVATOR_XS 0x4 -#define BOARD_CONDOR 0x6 -#define BOARD_DRAAK 0x7 -#define BOARD_EBISU 0x8 -#define BOARD_STARTER_KIT_PRE 0xB -#define BOARD_EBISU_4D 0xD -#define BOARD_CONDOR_I 0x10 -
This part ^ should not be in this patch .
All this patch should do is expose the board ID .
Please split that into separate patch.
Quoted 12 lines
drivers/sysinfo/rcar3.c +1
-0/** * struct sysinfo_rcar_priv - sysinfo private data * @boardname: board model and revision @@ -32,6 +21,7 @@*/ struct sysinfo_rcar_priv {char boardmodel[64 ]; +u8 board_id;u8 val; };
drivers/sysinfo/rcar3.c static int sysinfo_rcar_detect(struct udevice *dev) · line 40
Quoted 9 lines
drivers/sysinfo/rcar3.c +6
-0@@ -42,6 +32,19 @@ static int sysinfo_rcar_detect(struct udevice *dev)return priv->val ==0xff ; } +static int sysinfo_rcar_get_int (struct udevice *dev,int id,int *val) +{ +struct sysinfo_rcar_priv *priv =dev_get_priv (dev); + +switch (id) { +case SYSINFO_ID_BOARD_MODEL :
The BOARD_MODEL is a string, please add another 'BOARD_ID' into include/sysinfo.h to discern the properties.
Quoted 6 lines
drivers/sysinfo/rcar3.c +6
-0+ *val = priv->board_id; +return 0 ; +default : +return -EINVAL ; + }; +}
[...]
PATCH v2 2/3 renesas: rcar3: Expose the board revision in sysinfo
In reply to Detlev CasanovaThe board revision is needed to determine which linux device tree to load.
--- .../arm/mach-rmobile/include/mach/sys_proto.h | 6 ++ drivers/sysinfo/rcar3.c | 60 +++++++++++-------- 2 files changed, 40 insertions(+), 26 deletions(-)
arch/arm/mach-rmobile/include/mach/sys_proto.h +6 -0
@@ -22,4 +22,10 @@#define BOARD_EBISU_4D 0xD#define BOARD_CONDOR_I 0x10 +/* +* Renesas sysinfo board revision +*/ +#define RCAR_SYSINFO_REV_MAJOR SYSINFO_ID_USER +#define RCAR_SYSINFO_REV_MINOR (SYSINFO_ID_USER + 1) +#endif
drivers/sysinfo/rcar3.c +34 -26
135 lines not on this page · raw message
Signature · 1 line
2.39.3
Re: [PATCH v2 2/3] renesas: rcar3: Expose the board revision in sysinfo
Quoted 14 lines · Detlev Casanova
The board revision is needed to determine which linux device tree to load.
Signed-off-by Detlev Casanova <[email protected]>--- .../arm/mach-rmobile/include/mach/sys_proto.h | 6 ++ drivers/sysinfo/rcar3.c | 60 +++++++++++-------- 2 files changed, 40 insertions(+), 26 deletions(-)arch/arm/mach-rmobile/include/mach/sys_proto.h +0
-0
arch/arm/mach-rmobile/include/mach/sys_proto.h line 29
Quoted 8 lines
arch/arm/mach-rmobile/include/mach/sys_proto.h +5
-0@@ -22,4 +22,10 @@#define BOARD_EBISU_4D 0xD#define BOARD_CONDOR_I 0x10 +/* +* Renesas sysinfo board revision +*/ +#define RCAR_SYSINFO_REV_MAJOR SYSINFO_ID_USER +#define RCAR_SYSINFO_REV_MINOR (SYSINFO_ID_USER + 1)
Please just introduce regular include/sysinfo.h board revision properties for this, not custom stuff.
Quoted 13 lines
arch/arm/mach-rmobile/include/mach/sys_proto.h +0
-0#endif drivers/sysinfo/rcar3.c +2
-0@@ -22,6 +22,8 @@struct sysinfo_rcar_priv {char boardmodel[64 ];u8 board_id; +u8 rev_major; +u8 rev_minor;u8 val; };
[...]
PATCH v2 3/3 renesas: rcar3: Load the correct device tree
In reply to Detlev CasanovaThe Renesas R-Car Gen3 boards use different device trees than the default one.
This commit uses the sysinfo's board id and revision to determine which linux device tree to load:
* H3 (Starter Kit Premier v2.0): renesas/r8a77951-ulcb.dtb
* H3e (Starter Kit Premier v2.1): renesas/r8a779m1-ulcb.dtb
--- board/renesas/ulcb/ulcb.c | 59 ++++++++++++++++++++++++++++++++++++ configs/rcar3_ulcb_defconfig | 1 + 2 files changed, 60 insertions(+)
board/renesas/ulcb/ulcb.c +59 -0
@@ -27,6 +27,7 @@#include <asm/arch/sh_sdhi.h> #include <i2c.h> #include <mmc.h> +#include <sysinfo.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -65,6 +66,64 @@ int board_init(void)return 0 ; } +int misc_init_r (void ) +{ +struct udevice *dev; +int board_id; +int rev_major, rev_minor; +int ret =sysinfo_get (&dev); + +if (ret) { +debug ("Cannot get sysinfo: %d\n" , ret); +return 0 ; + } + + ret =sysinfo_detect (dev); +if (ret) { +debug ("Cannot detect sysinfo: %d\n" , ret); +return 0 ; + } + + ret =sysinfo_get_int (dev, +SYSINFO_ID_BOARD_MODEL , + &board_id); + +if (ret) { +debug ("Cannot get sysinfo int: %d\n" , ret); +return 0 ; + } + + ret =sysinfo_get_int (dev, +RCAR_SYSINFO_REV_MAJOR , + &rev_major); + +if (ret) { +debug ("Cannot get sysinfo int: %d\n" , ret); +return 0 ; + } + + ret =sysinfo_get_int (dev, +RCAR_SYSINFO_REV_MINOR , + &rev_minor); + +if (ret) { +debug ("Cannot get sysinfo int: %d\n" , ret); +return 0 ; + } + +if (board_id ==BOARD_STARTER_KIT_PRE && rev_major =='2' ) { +/* +* H3 and H3e boards +*/ +if (rev_minor =='0' ) +env_set ("fdtfile" ,"renesas/r8a77951-ulcb.dtb" ); +else if (rev_minor =='1' ) +env_set ("fdtfile" ,"renesas/r8a779m1-ulcb.dtb" ); + } + +return 0 ; +} +#ifdef CONFIG_MULTI_DTB_FIT int board_fit_config_name_match (const char *name) {
configs/rcar3_ulcb_defconfig +1 -0
@@ -111,3 +111,4 @@ CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_STORAGE=y +CONFIG_MISC_INIT_R=y
Signature · 1 line
2.39.3
Re: [PATCH v2 3/3] renesas: rcar3: Load the correct device tree
Quoted 7 lines · Detlev Casanova
The Renesas R-Car Gen3 boards use different device trees than the default one.
This commit uses the sysinfo's board id and revision to determine which linux device tree to load:
* H3 (Starter Kit Premier v2.0): renesas/r8a77951-ulcb.dtb
* H3e (Starter Kit Premier v2.1): renesas/r8a779m1-ulcb.dtb
This is not about loading DTs (as the subject would suggest), this is about setting the correct default DT name in environment.
Quoted 22 lines
Signed-off-by Detlev Casanova <[email protected]>--- board/renesas/ulcb/ulcb.c | 59 ++++++++++++++++++++++++++++++++++++ configs/rcar3_ulcb_defconfig | 1 + 2 files changed, 60 insertions(+)board/renesas/ulcb/ulcb.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/sh_sdhi.h> #include <i2c.h> #include <mmc.h> +#include <sysinfo.h> DECLARE_GLOBAL_DATA_PTR ;@@ -65,6 +66,64 @@ int board_init(void)return 0 ; }
board/renesas/ulcb/ulcb.c int board_init(void) · line 78
Quoted 10 lines
board/renesas/ulcb/ulcb.c +10
-0+int misc_init_r (void ) +{ +struct udevice *dev; +int board_id; +int rev_major, rev_minor; +int ret =sysinfo_get (&dev); + +if (ret) { +debug ("Cannot get sysinfo: %d\n" , ret); +return 0 ;
Why do we ignore errors here ?
board/renesas/ulcb/ulcb.c int board_init(void) · line 85
Quoted 7 lines
board/renesas/ulcb/ulcb.c +7
-0+ } + + ret =sysinfo_detect (dev); +if (ret) { +debug ("Cannot detect sysinfo: %d\n" , ret); +return 0 ; + }
Looking at all this, I really have to wonder, wouldn't it be nicer to introduce a 'sysinfo' command which provides interface to obtain the different properties (like board name, id, revision ...) from U-Boot command line, and then script the DT selection in U-Boot shell ?
Re: [PATCH v2 3/3] renesas: rcar3: Load the correct device tree
Quoted 53 lines · On Wednesday, June 14, 2023 9:53:14 A.M. EDT Marek Vasut wrote:
Quoted 8 lines · Detlev Casanova
The Renesas R-Car Gen3 boards use different device trees than the default one.
This commit uses the sysinfo's board id and revision
to determine which linux device tree to load:
* H3 (Starter Kit Premier v2.0): renesas/r8a77951-ulcb.dtb
* H3e (Starter Kit Premier v2.1): renesas/r8a779m1-ulcb.dtbThis is not about loading DTs (as the subject would suggest), this is about setting the correct default DT name in environment.
Quoted 27 lines
Signed-off-by Detlev Casanova <[email protected]>---
board/renesas/ulcb/ulcb.c | 59 ++++++++++++++++++++++++++++++++++++ configs/rcar3_ulcb_defconfig | 1 + 2 files changed, 60 insertions(+)board/renesas/ulcb/ulcb.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/sh_sdhi.h> #include <i2c.h> #include <mmc.h> +#include <sysinfo.h>
DECLARE_GLOBAL_DATA_PTR;board/renesas/ulcb/ulcb.c +0
-0@@ -65,6 +66,64 @@ int board_init(void)return 0 ; }board/renesas/ulcb/ulcb.c int board_init(void) · line 80
Quoted 10 lines
board/renesas/ulcb/ulcb.c +10
-0+int misc_init_r (void ) +{ +struct udevice *dev; +int board_id; +int rev_major, rev_minor; +int ret =sysinfo_get (&dev); + +if (ret) { +debug ("Cannot get sysinfo: %d\n" , ret); +return 0 ;Why do we ignore errors here ?
Quoted 12 lines
board/renesas/ulcb/ulcb.c int board_init(void) · line 85
Quoted 7 lines
board/renesas/ulcb/ulcb.c +7
-0+ } + + ret =sysinfo_detect (dev); +if (ret) { +debug ("Cannot detect sysinfo: %d\n" , ret); +return 0 ; + }Looking at all this, I really have to wonder, wouldn't it be nicer to introduce a 'sysinfo' command which provides interface to obtain the different properties (like board name, id, revision ...) from U-Boot command line, and then script the DT selection in U-Boot shell ?
Yes, that could be a good option. This is more based on how raspberry pis are selecting the correct devicetree in board/raspberrypi/rpi/rpi.c. It is either about having simple shell scripts that are similar between devices and the implementation is "hidden" in C for each platform (maybe easier to use but less flexible). Or more complex shell scripts with simpler C implementation (more flexible but having to modify a boot script can become complicated for users)
Has this direction choice been discussed in the past already ?
Re: [PATCH v2 3/3] renesas: rcar3: Load the correct device tree
Quoted 75 lines · Detlev Casanova
Quoted 53 lines · On Wednesday, June 14, 2023 9:53:14 A.M. EDT Marek Vasut wrote:
Quoted 8 lines · Detlev Casanova
The Renesas R-Car Gen3 boards use different device trees than the default one.
This commit uses the sysinfo's board id and revision
to determine which linux device tree to load:
* H3 (Starter Kit Premier v2.0): renesas/r8a77951-ulcb.dtb
* H3e (Starter Kit Premier v2.1): renesas/r8a779m1-ulcb.dtbThis is not about loading DTs (as the subject would suggest), this is about setting the correct default DT name in environment.
Quoted 27 lines
Signed-off-by Detlev Casanova <[email protected]>---
board/renesas/ulcb/ulcb.c | 59 ++++++++++++++++++++++++++++++++++++ configs/rcar3_ulcb_defconfig | 1 + 2 files changed, 60 insertions(+)board/renesas/ulcb/ulcb.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/sh_sdhi.h> #include <i2c.h> #include <mmc.h> +#include <sysinfo.h> DECLARE_GLOBAL_DATA_PTR;board/renesas/ulcb/ulcb.c +0
-0@@ -65,6 +66,64 @@ int board_init(void)return 0 ; }board/renesas/ulcb/ulcb.c int board_init(void) · line 80
Quoted 10 lines
board/renesas/ulcb/ulcb.c +10
-0+int misc_init_r (void ) +{ +struct udevice *dev; +int board_id; +int rev_major, rev_minor; +int ret =sysinfo_get (&dev); + +if (ret) { +debug ("Cannot get sysinfo: %d\n" , ret); +return 0 ;Why do we ignore errors here ?
Quoted 12 lines
board/renesas/ulcb/ulcb.c int board_init(void) · line 85
Quoted 7 lines
board/renesas/ulcb/ulcb.c +7
-0+ } + + ret =sysinfo_detect (dev); +if (ret) { +debug ("Cannot detect sysinfo: %d\n" , ret); +return 0 ; + }Looking at all this, I really have to wonder, wouldn't it be nicer to introduce a 'sysinfo' command which provides interface to obtain the different properties (like board name, id, revision ...) from U-Boot command line, and then script the DT selection in U-Boot shell ?
Yes, that could be a good option. This is more based on how raspberry pis are selecting the correct devicetree in
board/raspberrypi/rpi/rpi.c. It is either about having simple shell scripts that are similar between devices and the implementation is "hidden" in C for each platform (maybe easier to use but less flexible). Or more complex shell scripts with simpler C implementation (more flexible but having to modify a boot script can become complicated for users)
Quoted 1 line
Has this direction choice been discussed in the past already ?
The less hard-coded board code (which cannot be updated by the user easily), the better. Scripts can be updated in deployment far easier than the bootloader itself. Hence the push for scripts over custom C code.
Re: [PATCH v2 3/3] renesas: rcar3: Load the correct device tree
Quoted 77 lines · On Wednesday, June 14, 2023 11:32:31 A.M. EDT Marek Vasut wrote:
Quoted 76 lines · Detlev Casanova
Quoted 54 lines · On Wednesday, June 14, 2023 9:53:14 A.M. EDT Marek Vasut wrote:
Quoted 8 lines · Detlev Casanova
The Renesas R-Car Gen3 boards use different device trees than the default one.
This commit uses the sysinfo's board id and revision
to determine which linux device tree to load:
* H3 (Starter Kit Premier v2.0): renesas/r8a77951-ulcb.dtb
* H3e (Starter Kit Premier v2.1): renesas/r8a779m1-ulcb.dtbThis is not about loading DTs (as the subject would suggest), this is about setting the correct default DT name in environment.
Quoted 28 lines
Signed-off-by Detlev Casanova <[email protected]>---
board/renesas/ulcb/ulcb.c | 59 ++++++++++++++++++++++++++++++++++++ configs/rcar3_ulcb_defconfig | 1 + 2 files changed, 60 insertions(+)board/renesas/ulcb/ulcb.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/sh_sdhi.h> #include <i2c.h> #include <mmc.h> +#include <sysinfo.h> DECLARE_GLOBAL_DATA_PTR;board/renesas/ulcb/ulcb.c +0
-0@@ -65,6 +66,64 @@ int board_init(void)return 0 ; }board/renesas/ulcb/ulcb.c int board_init(void) · line 80
Quoted 10 lines
board/renesas/ulcb/ulcb.c +10
-0+int misc_init_r (void ) +{ +struct udevice *dev; +int board_id; +int rev_major, rev_minor; +int ret =sysinfo_get (&dev); + +if (ret) { +debug ("Cannot get sysinfo: %d\n" , ret); +return 0 ;Why do we ignore errors here ?
Quoted 12 lines
board/renesas/ulcb/ulcb.c int board_init(void) · line 85
Quoted 7 lines
board/renesas/ulcb/ulcb.c +7
-0+ } + + ret =sysinfo_detect (dev); +if (ret) { +debug ("Cannot detect sysinfo: %d\n" , ret); +return 0 ; + }Looking at all this, I really have to wonder, wouldn't it be nicer to introduce a 'sysinfo' command which provides interface to obtain the different properties (like board name, id, revision ...) from U-Boot command line, and then script the DT selection in U-Boot shell ?
Yes, that could be a good option. This is more based on how raspberry pis are selecting the correct devicetree in
board/raspberrypi/rpi/rpi.c. It is either about having simple shell scripts that are similar between devices and the implementation is "hidden" in C for each platform (maybe easier to use but less flexible). Or more complex shell scripts with simpler C implementation (more flexible but having to modify a boot script can become complicated for users)
Quoted 5 lines
Quoted 1 line
Has this direction choice been discussed in the past already ?
The less hard-coded board code (which cannot be updated by the user easily), the better. Scripts can be updated in deployment far easier than the bootloader itself. Hence the push for scripts over custom C code.
That makes sense. I'll create a new command for this then and use it to select the dtb in the ulcb boards script.
Re: [PATCH v2 3/3] renesas: rcar3: Load the correct device tree
Quoted 78 lines · Detlev Casanova
Quoted 77 lines · On Wednesday, June 14, 2023 11:32:31 A.M. EDT Marek Vasut wrote:
Quoted 76 lines · Detlev Casanova
Quoted 54 lines · On Wednesday, June 14, 2023 9:53:14 A.M. EDT Marek Vasut wrote:
Quoted 8 lines · Detlev Casanova
The Renesas R-Car Gen3 boards use different device trees than the default one.
This commit uses the sysinfo's board id and revision
to determine which linux device tree to load:
* H3 (Starter Kit Premier v2.0): renesas/r8a77951-ulcb.dtb
* H3e (Starter Kit Premier v2.1): renesas/r8a779m1-ulcb.dtbThis is not about loading DTs (as the subject would suggest), this is about setting the correct default DT name in environment.
Quoted 28 lines
Signed-off-by Detlev Casanova <[email protected]>---
board/renesas/ulcb/ulcb.c | 59++++++++++++++++++++++++++++++++++++
configs/rcar3_ulcb_defconfig | 1 +
2 files changed, 60 insertions(+)board/renesas/ulcb/ulcb.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/sh_sdhi.h> #include <i2c.h> #include <mmc.h> +#include <sysinfo.h> DECLARE_GLOBAL_DATA_PTR;board/renesas/ulcb/ulcb.c +0
-0@@ -65,6 +66,64 @@ int board_init(void)return 0 ; }board/renesas/ulcb/ulcb.c int board_init(void) · line 80
Quoted 10 lines
board/renesas/ulcb/ulcb.c +10
-0+int misc_init_r (void ) +{ +struct udevice *dev; +int board_id; +int rev_major, rev_minor; +int ret =sysinfo_get (&dev); + +if (ret) { +debug ("Cannot get sysinfo: %d\n" , ret); +return 0 ;Why do we ignore errors here ?
Quoted 12 lines
board/renesas/ulcb/ulcb.c int board_init(void) · line 85
Quoted 7 lines
board/renesas/ulcb/ulcb.c +7
-0+ } + + ret =sysinfo_detect (dev); +if (ret) { +debug ("Cannot detect sysinfo: %d\n" , ret); +return 0 ; + }Looking at all this, I really have to wonder, wouldn't it be nicer to introduce a 'sysinfo' command which provides interface to obtain the different properties (like board name, id, revision ...) from U-Boot command line, and then script the DT selection in U-Boot shell ?
Yes, that could be a good option. This is more based on how raspberry pis are selecting the correct devicetree in
board/raspberrypi/rpi/rpi.c. It is either about having simple shell scripts that are similar between devices and the implementation is "hidden" in C for each platform (maybe easier to use but less flexible). Or more complex shell scripts with simpler C implementation (more flexible but having to modify a boot script can become complicated for users)
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Has this direction choice been discussed in the past already ?
The less hard-coded board code (which cannot be updated by the user easily), the better. Scripts can be updated in deployment far easier than the bootloader itself. Hence the push for scripts over custom C code.
That makes sense. I'll create a new command for this then and use it to select the dtb in the ulcb boards script.
Thanks !