[PATCH 0/2] 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, let's use this to set the correct device tree for that board when using pxe.
Detlev Casanova (2): renesas: rcar3: Expose the board id in sysinfo renesas: rcar3: Load the correct device tree
board/renesas/ulcb/ulcb.c | 34 ++++++++++++++++++++++++++++++++++ configs/rcar3_ulcb_defconfig | 1 + drivers/sysinfo/rcar3.c | 31 ++++++++++++++++++------------- drivers/sysinfo/rcar3.h | 21 +++++++++++++++++++++ 4 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 drivers/sysinfo/rcar3.h

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 detlev.casanova@collabora.com --- drivers/sysinfo/rcar3.c | 31 ++++++++++++++++++------------- drivers/sysinfo/rcar3.h | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 drivers/sysinfo/rcar3.h
diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c index 7b127986da7..4252f8d452c 100644 --- a/drivers/sysinfo/rcar3.c +++ b/drivers/sysinfo/rcar3.c @@ -7,24 +7,12 @@ #include <dm.h> #include <i2c_eeprom.h> #include <log.h> -#include <sysinfo.h> +#include "rcar3.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 +20,7 @@ */ struct sysinfo_rcar_priv { char boardmodel[64]; + u8 board_id; u8 val; };
@@ -42,6 +31,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 +61,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 +71,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 = '?';
diff --git a/drivers/sysinfo/rcar3.h b/drivers/sysinfo/rcar3.h new file mode 100644 index 00000000000..21ae918d9bb --- /dev/null +++ b/drivers/sysinfo/rcar3.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2023 Detlev Casanova detlev.casanova@collabora.com + */ + +#include <sysinfo.h> + +#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 + + +

On 6/9/23 18:00, Detlev Casanova wrote:
This is a preparation commit for selecting the correct device tree name to be loaded depending on the board id.
I am not opposed to this patch itself (with a few tweaks, see below), but please see 2/2, I suspect this method of selecting the DT is not gonna work.
Signed-off-by: Detlev Casanova detlev.casanova@collabora.com
drivers/sysinfo/rcar3.c | 31 ++++++++++++++++++------------- drivers/sysinfo/rcar3.h | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 drivers/sysinfo/rcar3.h
diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c index 7b127986da7..4252f8d452c 100644 --- a/drivers/sysinfo/rcar3.c +++ b/drivers/sysinfo/rcar3.c @@ -7,24 +7,12 @@ #include <dm.h> #include <i2c_eeprom.h> #include <log.h> -#include <sysinfo.h> +#include "rcar3.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 +20,7 @@ */ struct sysinfo_rcar_priv { char boardmodel[64];
- u8 board_id; u8 val; };
@@ -42,6 +31,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 +61,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 +71,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 = '?';
diff --git a/drivers/sysinfo/rcar3.h b/drivers/sysinfo/rcar3.h new file mode 100644 index 00000000000..21ae918d9bb --- /dev/null +++ b/drivers/sysinfo/rcar3.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- Copyright (C) 2023 Detlev Casanova detlev.casanova@collabora.com
- */
+#include <sysinfo.h>
This should not be here, the header is using nothing from sysinfo.h
Also, this rcar3.h header should be in arch/arm/mach-rmobile/include/mach/ and potentially just part of sys_proto.h .
+#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
Does ./scripts/checkpatch.pl complain about those three extra trailing newlines ?

The Renesas R-Car Gen3 H3e (Starter Kit Premier) uses a different device tree than the default one.
This uses the sysinfo's board id to determine if the board needs a specific device tree.
Signed-off-by: Detlev Casanova detlev.casanova@collabora.com --- board/renesas/ulcb/ulcb.c | 34 ++++++++++++++++++++++++++++++++++ configs/rcar3_ulcb_defconfig | 1 + 2 files changed, 35 insertions(+)
diff --git a/board/renesas/ulcb/ulcb.c b/board/renesas/ulcb/ulcb.c index 1477750f921..3e2fe3a3ca9 100644 --- a/board/renesas/ulcb/ulcb.c +++ b/board/renesas/ulcb/ulcb.c @@ -28,6 +28,8 @@ #include <i2c.h> #include <mmc.h>
+#include "../../../drivers/sysinfo/rcar3.h" + DECLARE_GLOBAL_DATA_PTR;
#define DVFS_MSTP926 BIT(26) @@ -65,6 +67,38 @@ int board_init(void) return 0; }
+int misc_init_r(void) +{ + struct udevice *dev; + int board_id; + 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; + } + + if (board_id == BOARD_STARTER_KIT_PRE) { + env_set("fdtfile", "renesas/r8a779m1-ulcb.dtb"); + } + + return 0; +} + #ifdef CONFIG_MULTI_DTB_FIT int board_fit_config_name_match(const char *name) { diff --git a/configs/rcar3_ulcb_defconfig b/configs/rcar3_ulcb_defconfig index b8fdb5e3826..752d33d77ec 100644 --- a/configs/rcar3_ulcb_defconfig +++ b/configs/rcar3_ulcb_defconfig @@ -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

On 6/9/23 18:00, Detlev Casanova wrote:
The Renesas R-Car Gen3 H3e (Starter Kit Premier) uses a different device tree than the default one.
This uses the sysinfo's board id to determine if the board needs a specific device tree.
Signed-off-by: Detlev Casanova detlev.casanova@collabora.com
board/renesas/ulcb/ulcb.c | 34 ++++++++++++++++++++++++++++++++++ configs/rcar3_ulcb_defconfig | 1 + 2 files changed, 35 insertions(+)
diff --git a/board/renesas/ulcb/ulcb.c b/board/renesas/ulcb/ulcb.c index 1477750f921..3e2fe3a3ca9 100644 --- a/board/renesas/ulcb/ulcb.c +++ b/board/renesas/ulcb/ulcb.c @@ -28,6 +28,8 @@ #include <i2c.h> #include <mmc.h>
+#include "../../../drivers/sysinfo/rcar3.h"
DECLARE_GLOBAL_DATA_PTR;
#define DVFS_MSTP926 BIT(26)
@@ -65,6 +67,38 @@ int board_init(void) return 0; }
+int misc_init_r(void) +{
- struct udevice *dev;
- int board_id;
- 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;
- }
- if (board_id == BOARD_STARTER_KIT_PRE) {
env_set("fdtfile", "renesas/r8a779m1-ulcb.dtb");
About this, BOARD_STARTER_KIT_PRE is just H3 ULCB . I suspect the ID is the same on H3e ULCB ? I think we need some other method to discern the two board variants. Here is the sysinfo EEPROM from H3 ULCB:
CPU: Renesas Electronics R8A7795 rev 2.0 Model: Renesas Starter Kit Premier board rev 2.0 DRAM: 896 MiB (effective 3.9 GiB) ... => i2c dev 7 ; i2c md 0x50 0 0x80 Setting bus to 7 0000: 8e 17 52 5d e6 e6 b1 35 e4 e4 e4 e4 35 20 20 0a ..R]...5....5 . 0010: f4 f4 44 44 f4 f4 44 44 44 44 f4 f4 f4 4f 01 52 ..DD..DDDD...O.R 0020: 52 52 52 53 51 4f 4d 01 52 53 60 00 00 00 00 00 RRRSQOM.RS`..... 0030: 00 00 11 00 01 2d ff ff ff ff ff ff ff ff ff ff .....-.......... 0040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0070: 5a ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff Z...............
Can you dump and share the H3e ULCB EEPROM content ?

On Saturday, June 10, 2023 7:58:35 A.M. EDT Marek Vasut wrote:
On 6/9/23 18:00, Detlev Casanova wrote:
The Renesas R-Car Gen3 H3e (Starter Kit Premier) uses a different device tree than the default one.
This uses the sysinfo's board id to determine if the board needs a specific device tree.
Signed-off-by: Detlev Casanova detlev.casanova@collabora.com
board/renesas/ulcb/ulcb.c | 34 ++++++++++++++++++++++++++++++++++ configs/rcar3_ulcb_defconfig | 1 + 2 files changed, 35 insertions(+)
diff --git a/board/renesas/ulcb/ulcb.c b/board/renesas/ulcb/ulcb.c index 1477750f921..3e2fe3a3ca9 100644 --- a/board/renesas/ulcb/ulcb.c +++ b/board/renesas/ulcb/ulcb.c @@ -28,6 +28,8 @@
#include <i2c.h> #include <mmc.h>
+#include "../../../drivers/sysinfo/rcar3.h"
DECLARE_GLOBAL_DATA_PTR;
#define DVFS_MSTP926 BIT(26)
@@ -65,6 +67,38 @@ int board_init(void)
return 0;
}
+int misc_init_r(void) +{
- struct udevice *dev;
- int board_id;
- 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;
- }
- if (board_id == BOARD_STARTER_KIT_PRE) {
env_set("fdtfile", "renesas/r8a779m1-ulcb.dtb");
About this, BOARD_STARTER_KIT_PRE is just H3 ULCB . I suspect the ID is the same on H3e ULCB ? I think we need some other method to discern the two board variants. Here is the sysinfo EEPROM from H3 ULCB:
CPU: Renesas Electronics R8A7795 rev 2.0 Model: Renesas Starter Kit Premier board rev 2.0 DRAM: 896 MiB (effective 3.9 GiB) ... => i2c dev 7 ; i2c md 0x50 0 0x80 Setting bus to 7 0000: 8e 17 52 5d e6 e6 b1 35 e4 e4 e4 e4 35 20 20 0a ..R]...5....5 . 0010: f4 f4 44 44 f4 f4 44 44 44 44 f4 f4 f4 4f 01 52 ..DD..DDDD...O.R 0020: 52 52 52 53 51 4f 4d 01 52 53 60 00 00 00 00 00 RRRSQOM.RS`..... 0030: 00 00 11 00 01 2d ff ff ff ff ff ff ff ff ff ff .....-.......... 0040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0070: 5a ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff Z...............
Can you dump and share the H3e ULCB EEPROM content ?
Indeed, The board id will be the same for both H3 and H3e. The `val` changed from `5a` to `5b` at offset 0x70.
So I can probably also expose the rev_major and rev_minor through `sysinfo_get_int` to select the H3e specific device tree when rev_major == 3.
For reference:
CPU: Renesas Electronics R8A7795 rev 3.0 Model: Renesas Starter Kit Premier board rev 2.1 DRAM: 896 MiB (effective 3.9 GiB) [...] => i2c dev 7 ; i2c md 0x50 0 0x80 Setting bus to 7 0000: 8e 17 52 5d e6 e6 b1 35 e4 e4 e4 e4 35 20 20 0a ..R]...5....5 . 0010: f4 f4 44 44 f4 f4 44 44 44 44 f4 f4 f4 4f 01 52 ..DD..DDDD...O.R 0020: 52 52 52 53 51 4f 4d 01 52 53 60 00 00 00 00 00 RRRSQOM.RS`..... 0030: 00 00 11 00 01 2d ff ff ff ff ff ff ff ff ff ff .....-.......... 0040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 0070: 5b ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff [...............
Detlev.
participants (2)
-
Detlev Casanova
-
Marek Vasut