Skip to contentSkip to conversation

Introduce the sysinfo command

PATCH Superseded Detlev Casanova 2 participants 17 messages Jun 16, 2023 – Jun 21, 2023 Arm/RISC-V/Renesas architecture

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Introduce the sysinfo command

The command can be used to show various information that can be used to identify the running system.

Currently supported subcommands are:
* model: A string representing the model
* id: The id of the board
* revision: The revision of this board id.

I'm not sure about the last commit, if it needs to be here upstream or if it chould be something done by packagers.

I'm also not sure if a test should be added and where to start to test this kind of command.

Detlev Casanova (4):
sysinfo: Add IDs for board id and revision
cmd: Add a sysinfo command
sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
configs: rcar3: Add shell function to select the linux devicetree

 cmd/Kconfig                        |   6 ++
 cmd/Makefile                       |   1 +
 cmd/sysinfo.c                      | 124 +++++++++++++++++++++++++++++
 configs/rcar3_ulcb_defconfig       |   1 +
 drivers/sysinfo/rcar3.c            |  46 ++++++++---
 include/configs/rcar-gen3-common.h |   9 ++-
 include/sysinfo.h                  |   4 +
 7 files changed, 180 insertions(+), 11 deletions(-)
 create mode 100644 cmd/sysinfo.c
Signature · 1 line
2.39.3
#1 lore raw

PATCH 1/4 sysinfo: Add IDs for board id and revision

These IDs will be used by the sysinfo command. The new IDs are:
* SYSINFO_ID_BOARD_ID: The board ID as an integer
* SYSINFO_ID_BOARD_REVISION: The board revision as a string

---
 include/sysinfo.h | 4 ++++
 1 file changed, 4 insertions(+)
include/sysinfo.h +4 -0
index b140d742e93..e2a7b10b6f6 100644
@@ -47,6 +47,10 @@ enum sysinfo_id {
 	/* For show_board_info() */
 	SYSINFO_ID_BOARD_MODEL,
 
+	/* For sysinfo command */
+	SYSINFO_ID_BOARD_ID,
+	SYSINFO_ID_BOARD_REVISION,
+
 	/* First value available for downstream/board used */
 	SYSINFO_ID_USER = 0x1000,
 };
Signature · 1 line
2.39.3
#2 lore raw

PATCH 2/4 cmd: Add a sysinfo command

In reply to Detlev Casanova

The command is able to show different information for the running system:
* Model name
* Board ID
* Revision

This command can be used by boot shell scripts to select configurations depending on the specific running system.

---
 cmd/Kconfig   |   6 +++
 cmd/Makefile  |   1 +
 cmd/sysinfo.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 131 insertions(+)
 create mode 100644 cmd/sysinfo.c
cmd/Kconfig +6 -0
index 365371fb511..ba4844853a1 100644
@@ -210,6 +210,12 @@ config CMD_SBI
 	help
 	  Display information about the SBI implementation.
 
+config CMD_SYSINFO
+	bool "sysinfo"
+	depends on SYSINFO
+	help
+	  Display information about the system.
+
 endmenu
 
 menu "Boot commands"
cmd/Makefile +1 -0
index 6c37521b4e2..ba4d6de9a1b 100644
@@ -165,6 +165,7 @@ obj-$(CONFIG_CMD_SPI) += spi.o
 obj-$(CONFIG_CMD_STRINGS) += strings.o
 obj-$(CONFIG_CMD_SMC) += smccc.o
 obj-$(CONFIG_CMD_SYSBOOT) += sysboot.o
+obj-$(CONFIG_CMD_SYSINFO) += sysinfo.o
 obj-$(CONFIG_CMD_STACKPROTECTOR_TEST) += stackprot_test.o
 obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o
 obj-$(CONFIG_CMD_TERMINAL) += terminal.o
cmd/sysinfo.c new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
2.39.3
#3 lore raw

Re: [PATCH v1 2/4] cmd: Add a sysinfo command

On 6/16/23 17:21, Detlev Casanova wrote:

[...]

Quoted 13 lines
cmd/sysinfo.c new file +13 -0
+static int do_sysinfo_id(struct cmd_tbl *cmdtp, int flag, int argc,
+			 char *const argv[])
+{
+	struct udevice *dev;
+	u32 board_id;
+	char board_id_str[5] = { '\0' };
+	int ret = get_sysinfo(&dev);
+
+	if (ret)
+		return ret;
+
+	ret = sysinfo_get_int(dev,
+			      SYSINFO_ID_BOARD_ID,

cmd/sysinfo.c line 80

Quoted 10 lines
cmd/sysinfo.c new file +10 -0
+			      &board_id);
+
+	if (ret) {
+		debug("Cannot get sysinfo int: %d\n", ret);
+		return ret;
+	}
+
+	sprintf(board_id_str, "0x%02x", board_id);
+	if (argc == 2)
+		env_set(argv[1], board_id_str);

env_set_hex()

Review

Quoted 2 lines
(quoted diff) +2 -0
+	else
+		printf("%s\n", board_id_str);

printf(...%02x...

Quoted 11 lines
cmd/sysinfo.c new file +11 -0
+	return 0;
+}
+
+static int do_sysinfo_revision(struct cmd_tbl *cmdtp, int flag, int argc,
+			       char *const argv[])
+{
+	struct udevice *dev;
+	char rev[4];
+	int ret = get_sysinfo(&dev);
+
+	if (ret)

cmd/sysinfo.c line 104

Quoted 10 lines
cmd/sysinfo.c new file +10 -0
+		return ret;
+
+	ret = sysinfo_get_str(dev,
+			      SYSINFO_ID_BOARD_REVISION,
+			      4,
+			      rev);
+
+	if (ret) {
+		debug("Cannot get sysinfo str: %d\n", ret);
+		return ret;

Commands always return CMD_RET_* , not errno .

#4 lore raw

PATCH 3/4 sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

In reply to Detlev Casanova

Expose that information to the command shell to let scripts select the correct devicetree name.

---
 drivers/sysinfo/rcar3.c | 46 ++++++++++++++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +36 -10
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
  */
 struct sysinfo_rcar_priv {
 	char	boardmodel[64];
+	u8	id;
+	char	revision[4];
 	u8	val;
 };
 
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice *dev, int id, size_t size, char *
 
 	switch (id) {
 	case SYSINFO_ID_BOARD_MODEL:
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;
+}
+
+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_ID:
+		*val = priv->id;
 		return 0;
 	default:
 		return -EINVAL;
 	};
+
 }
 
 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)
@@ -83,7 +105,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 			 "Renesas Salvator-X%s board rev %c.%c",
 			 salvator_xs ? "S" : "", rev_major, rev_minor);
-		return;
+		break;
 	case BOARD_STARTER_KIT:
 		if (!(board_rev & ~1)) { /* Only rev 0 and 1 is valid */
 			rev_major = (board_rev & BIT(0)) ? '3' : '1';
@@ -92,7 +114,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 			 "Renesas Starter Kit board rev %c.%c",
 			 rev_major, rev_minor);
-		return;
+		break;
 	case BOARD_STARTER_KIT_PRE:
 		if (!(board_rev & ~3)) { /* Only rev 0..3 is valid */
 			rev_major = (board_rev & BIT(1)) ? '2' : '1';
@@ -101,7 +123,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 			 "Renesas Starter Kit Premier board rev %c.%c",
 			 rev_major, rev_minor);
-		return;
+		break;
 	case BOARD_EAGLE:
 		if (!board_rev) { /* Only rev 0 is valid */
 			rev_major = '1';
@@ -110,7 +132,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 			 "Renesas Eagle board rev %c.%c",
 			 rev_major, rev_minor);
-		return;
+		break;
 	case BOARD_EBISU_4D:
 		ebisu_4d = true;
 		fallthrough;
@@ -122,7 +144,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 			 "Renesas Ebisu%s board rev %c.%c",
 			 ebisu_4d ? "-4D" : "", rev_major, rev_minor);
-		return;
+		break;
 	case BOARD_DRAAK:
 		if (!board_rev) { /* Only rev 0 is valid */
 			rev_major = '1';
@@ -131,7 +153,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 			 "Renesas Draak board rev %c.%c",
 			 rev_major, rev_minor);
-		return;
+		break;
 	case BOARD_KRIEK:
 		if (!board_rev) { /* Only rev 0 is valid */
 			rev_major = '1';
@@ -140,7 +162,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 			 "Renesas Kriek board rev %c.%c",
 			 rev_major, rev_minor);
-		return;
+		break;
 	case BOARD_CONDOR_I:
 		condor_i = true;
 		fallthrough;
@@ -152,13 +174,17 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 			"Renesas Condor%s board rev %c.%c",
 			condor_i ? "-I" : "", rev_major, rev_minor);
-		return;
+		break;
 	default:
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 			 "Renesas -Unknown- board rev ?.?");
 		priv->val = 0xff;
 		return;
 	}
+
+	snprintf(priv->revision, sizeof(priv->revision), "%c.%c", rev_major,
+		 rev_minor);
+	priv->id = board_id;
 }
 
 static int sysinfo_rcar_probe(struct udevice *dev)
Signature · 1 line
2.39.3
#5 lore raw

Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

Quoted 38 lines · Detlev Casanova

Expose that information to the command shell to let scripts select the correct devicetree name.

---
  drivers/sysinfo/rcar3.c | 46 ++++++++++++++++++++++++++++++++---------
  1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +13 -2
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
   */
  struct sysinfo_rcar_priv {
  	char	boardmodel[64];
+	u8	id;
+	char	revision[4];
  	u8	val;
  };
 
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice *dev, int id, size_t size, char *
 
  	switch (id) {
  	case SYSINFO_ID_BOARD_MODEL:
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;

drivers/sysinfo/rcar3.c static int sysinfo_rcar_get_str(struct udevice *dev, int id, size_t size, char * · line 73

Quoted 10 lines
drivers/sysinfo/rcar3.c +9 -0
+}
+
+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_ID:
+		*val = priv->id;
  		return 0;

Why not return SYSINFO_ID_BOARD_REVISION as integer here ?

[...]

#6 lore raw

Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

Quoted 57 lines · On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote:
Quoted 56 lines · Detlev Casanova

Expose that information to the command shell to let scripts select the correct devicetree name.

---

  drivers/sysinfo/rcar3.c | 46 ++++++++++++++++++++++++++++++++---------
  1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +2 -0
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
 
   */
 
  struct sysinfo_rcar_priv {
 
  	char	boardmodel[64];
 
+	u8	id;
+	char	revision[4];
 
  	u8	val;
 
  };
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice *dev,

int id, size_t size, char *>
switch (id) {

case SYSINFO_ID_BOARD_MODEL:

drivers/sysinfo/rcar3.c +20 -2
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;
+}
+
+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_ID:
+		*val = priv->id;
Quoted 3 lines
Quoted 1 line

return 0;

Why not return SYSINFO_ID_BOARD_REVISION as integer here ?

Because the revision (on r-car3 boards at least) is in the format X.Y. It could be returned as "(X << 8) | Y" or split in major/minor. But different boards will use different revisions and I think that having a str is easier to deal with in a shell script.

Quoted 1 line

[...]

#7 lore raw

Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

Quoted 58 lines · Detlev Casanova
Quoted 57 lines · On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote:
Quoted 56 lines · Detlev Casanova

Expose that information to the command shell to let scripts select the correct devicetree name.

---

   drivers/sysinfo/rcar3.c | 46 ++++++++++++++++++++++++++++++++---------
   1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +2 -0
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
 
    */
 
   struct sysinfo_rcar_priv {
 
   	char	boardmodel[64];
 
+	u8	id;
+	char	revision[4];
 
   	u8	val;
 
   };
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice *dev,

int id, size_t size, char *>
switch (id) {

case SYSINFO_ID_BOARD_MODEL:

drivers/sysinfo/rcar3.c +20 -2
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;
+}
+
+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_ID:
+		*val = priv->id;
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
   		return 0;

Why not return SYSINFO_ID_BOARD_REVISION as integer here ?

Because the revision (on r-car3 boards at least) is in the format X.Y. It could be returned as "(X << 8) | Y" or split in major/minor. But different boards will use different revisions and I think that having a str is easier to deal with in a shell script.

With rcar they are numbers, so lets go with major/minor integers please.

#8 lore raw

Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

Quoted 65 lines · On Monday, June 19, 2023 12:11:18 P.M. EDT Marek Vasut wrote:
Quoted 64 lines · Detlev Casanova
Quoted 62 lines · On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote:
Quoted 49 lines · Detlev Casanova

Expose that information to the command shell to let scripts select the correct devicetree name.

---

   drivers/sysinfo/rcar3.c | 46
   ++++++++++++++++++++++++++++++++---------
   1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +2 -0
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
 
    */
 
   struct sysinfo_rcar_priv {
 
   	char	boardmodel[64];
 
+	u8	id;
+	char	revision[4];
 
   	u8	val;
 
   };
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice *dev,

int id, size_t size, char *>

   	switch (id) {

case SYSINFO_ID_BOARD_MODEL:

drivers/sysinfo/rcar3.c +12 -2
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;
+}

drivers/sysinfo/rcar3.c static int sysinfo_rcar_get_str(struct udevice *dev, int id, size_t size, char *

Quoted 10 lines
drivers/sysinfo/rcar3.c +8 -0
+
+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_ID:
+		*val = priv->id;
 
   		return 0;

Why not return SYSINFO_ID_BOARD_REVISION as integer here ?

Quoted 6 lines
Quoted 4 lines

Because the revision (on r-car3 boards at least) is in the format X.Y. It could be returned as "(X << 8) | Y" or split in major/minor. But different boards will use different revisions and I think that having a str is easier to deal with in a shell script.

With rcar they are numbers, so lets go with major/minor integers please.

Ok for this part, but shouldn't the sysinfo command use a common interface for all boards ? Or should it also have rev_major/rev_minor arguments ?

#9 lore raw

Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

Quoted 71 lines · Detlev Casanova
Quoted 70 lines · On Monday, June 19, 2023 12:11:18 P.M. EDT Marek Vasut wrote:
Quoted 68 lines · Detlev Casanova
Quoted 59 lines · On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote:
Quoted 58 lines · Detlev Casanova

Expose that information to the command shell to let scripts select the correct devicetree name.

---

    drivers/sysinfo/rcar3.c | 46
    ++++++++++++++++++++++++++++++++---------
    1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +2 -0
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
 
     */
 
    struct sysinfo_rcar_priv {
 
    	char	boardmodel[64];
 
+	u8	id;
+	char	revision[4];
 
    	u8	val;
 
    };
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice *dev,

int id, size_t size, char *>

    	switch (id) {

    	case SYSINFO_ID_BOARD_MODEL:
drivers/sysinfo/rcar3.c +20 -2
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;
+}
+
+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_ID:
+		*val = priv->id;
Quoted 3 lines
Quoted 1 line
    		return 0;

Why not return SYSINFO_ID_BOARD_REVISION as integer here ?

Because the revision (on r-car3 boards at least) is in the format X.Y. It could be returned as "(X << 8) | Y" or split in major/minor. But different boards will use different revisions and I think that having a str is easier to deal with in a shell script.

Quoted 4 lines
Quoted 1 line

With rcar they are numbers, so lets go with major/minor integers please.

Ok for this part, but shouldn't the sysinfo command use a common interface for all boards ? Or should it also have rev_major/rev_minor arguments ?

I would expect other boards to either report rev_major/rev_minor if implemented, or errno if those boards don't implement this property.

#10 lore raw

Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

Quoted 76 lines · On Monday, June 19, 2023 5:54:44 P.M. EDT Marek Vasut wrote:
Quoted 75 lines · Detlev Casanova
Quoted 74 lines · On Monday, June 19, 2023 12:11:18 P.M. EDT Marek Vasut wrote:
Quoted 72 lines · Detlev Casanova
Quoted 61 lines · On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote:
Quoted 60 lines · Detlev Casanova

Expose that information to the command shell to let scripts select the correct devicetree name.

---

    drivers/sysinfo/rcar3.c | 46
    ++++++++++++++++++++++++++++++++---------
    1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +2 -0
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
 
     */
 
    struct sysinfo_rcar_priv {
 
    	char	boardmodel[64];
 
+	u8	id;
+	char	revision[4];
 
    	u8	val;
 
    };
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice
 *dev,

int id, size_t size, char *>

    	switch (id) {

    	case SYSINFO_ID_BOARD_MODEL:
drivers/sysinfo/rcar3.c +14 -2
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;
+}
+
+static int sysinfo_rcar_get_int(struct udevice *dev, int id, int

*val)

drivers/sysinfo/rcar3.c +6 -0
+{
+	struct sysinfo_rcar_priv *priv = dev_get_priv(dev);
+
+	switch (id) {
+	case SYSINFO_ID_BOARD_ID:
+		*val = priv->id;
Quoted 3 lines
Quoted 1 line
    		return 0;

Why not return SYSINFO_ID_BOARD_REVISION as integer here ?

Because the revision (on r-car3 boards at least) is in the format X.Y. It
could be returned as "(X << 8) | Y" or split in major/minor. But different
boards will use different revisions and I think that having a str is easier to deal with in a shell script.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

With rcar they are numbers, so lets go with major/minor integers please.

Ok for this part, but shouldn't the sysinfo command use a common interface for all boards ? Or should it also have rev_major/rev_minor arguments ?

I would expect other boards to either report rev_major/rev_minor if implemented, or errno if those boards don't implement this property.

Another thing on rcar is that the revision is stored as 2 char values. Would you oppose a change form using a char (e.g. rev_major = '1') to using u8 values (e.g. rev_major = 1) instead ?

#11 lore raw

Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

Quoted 79 lines · Detlev Casanova
Quoted 78 lines · On Monday, June 19, 2023 5:54:44 P.M. EDT Marek Vasut wrote:
Quoted 77 lines · Detlev Casanova
Quoted 75 lines · On Monday, June 19, 2023 12:11:18 P.M. EDT Marek Vasut wrote:
Quoted 66 lines · Detlev Casanova
Quoted 61 lines · On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote:
Quoted 60 lines · Detlev Casanova

Expose that information to the command shell to let scripts select the correct devicetree name.

---

     drivers/sysinfo/rcar3.c | 46
     ++++++++++++++++++++++++++++++++---------
     1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +2 -0
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
 
      */
 
     struct sysinfo_rcar_priv {
 
     	char	boardmodel[64];
 
+	u8	id;
+	char	revision[4];
 
     	u8	val;
 
     };
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice
 *dev,

int id, size_t size, char *>

     	switch (id) {

     	case SYSINFO_ID_BOARD_MODEL:
drivers/sysinfo/rcar3.c +14 -2
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;
+}
+
+static int sysinfo_rcar_get_int(struct udevice *dev, int id, int

*val)

drivers/sysinfo/rcar3.c +6 -0
+{
+	struct sysinfo_rcar_priv *priv = dev_get_priv(dev);
+
+	switch (id) {
+	case SYSINFO_ID_BOARD_ID:
+		*val = priv->id;
Quoted 3 lines
Quoted 1 line
     		return 0;

Why not return SYSINFO_ID_BOARD_REVISION as integer here ?

Quoted 6 lines

Because the revision (on r-car3 boards at least) is in the format X.Y. It
could be returned as "(X << 8) | Y" or split in major/minor. But different
boards will use different revisions and I think that having a str is easier to deal with in a shell script.

With rcar they are numbers, so lets go with major/minor integers please.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Ok for this part, but shouldn't the sysinfo command use a common interface for all boards ? Or should it also have rev_major/rev_minor arguments ?

I would expect other boards to either report rev_major/rev_minor if implemented, or errno if those boards don't implement this property.

Another thing on rcar is that the revision is stored as 2 char values. Would you oppose a change form using a char (e.g. rev_major = '1') to using u8 values (e.g. rev_major = 1) instead ?

Shouldn't those rev fields just be integer(s) to cover the generic case?

#12 lore raw

Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

Quoted 86 lines · On Tuesday, June 20, 2023 4:03:18 P.M. EDT Marek Vasut wrote:
Quoted 85 lines · Detlev Casanova
Quoted 84 lines · On Monday, June 19, 2023 5:54:44 P.M. EDT Marek Vasut wrote:
Quoted 82 lines · Detlev Casanova
Quoted 75 lines · On Monday, June 19, 2023 12:11:18 P.M. EDT Marek Vasut wrote:
Quoted 67 lines · Detlev Casanova
Quoted 62 lines · On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote:
Quoted 61 lines · Detlev Casanova

Expose that information to the command shell to let scripts select the
correct devicetree name.

---

     drivers/sysinfo/rcar3.c | 46
     ++++++++++++++++++++++++++++++++---------
     1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +2 -0
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
 
      */
 
     struct sysinfo_rcar_priv {
 
     	char	boardmodel[64];
 
+	u8	id;
+	char	revision[4];
 
     	u8	val;
 
     };
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice
 *dev,

int id, size_t size, char *>

     	switch (id) {

     	case SYSINFO_ID_BOARD_MODEL:
drivers/sysinfo/rcar3.c +14 -2
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;
+}
+
+static int sysinfo_rcar_get_int(struct udevice *dev, int id, int

*val)

drivers/sysinfo/rcar3.c +6 -0
+{
+	struct sysinfo_rcar_priv *priv = dev_get_priv(dev);
+
+	switch (id) {
+	case SYSINFO_ID_BOARD_ID:
+		*val = priv->id;
Quoted 3 lines
Quoted 1 line
     		return 0;

Why not return SYSINFO_ID_BOARD_REVISION as integer here ?

Quoted 6 lines

Because the revision (on r-car3 boards at least) is in the format X.Y. It
could be returned as "(X << 8) | Y" or split in major/minor. But different
boards will use different revisions and I think that having a str is easier to deal with in a shell script.

Quoted 2 lines

With rcar they are numbers, so lets go with major/minor integers please.

Ok for this part, but shouldn't the sysinfo command use a common interface
for all boards ? Or should it also have rev_major/rev_minor arguments ?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I would expect other boards to either report rev_major/rev_minor if implemented, or errno if those boards don't implement this property.

Another thing on rcar is that the revision is stored as 2 char values. Would you oppose a change form using a char (e.g. rev_major = '1') to using u8 values (e.g. rev_major = 1) instead ?

Shouldn't those rev fields just be integer(s) to cover the generic case?

On rcar, they are chars. I don't really see a reason for this except to show the '?.?' on unknown board ids. But that can be managed in other ways.

#13 lore raw

Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION

Quoted 90 lines · Detlev Casanova
Quoted 89 lines · On Tuesday, June 20, 2023 4:03:18 P.M. EDT Marek Vasut wrote:
Quoted 88 lines · Detlev Casanova
Quoted 86 lines · On Monday, June 19, 2023 5:54:44 P.M. EDT Marek Vasut wrote:
Quoted 76 lines · Detlev Casanova
Quoted 75 lines · On Monday, June 19, 2023 12:11:18 P.M. EDT Marek Vasut wrote:
Quoted 73 lines · Detlev Casanova
Quoted 62 lines · On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote:
Quoted 61 lines · Detlev Casanova

Expose that information to the command shell to let scripts select the
correct devicetree name.

---

      drivers/sysinfo/rcar3.c | 46
      ++++++++++++++++++++++++++++++++---------
      1 file changed, 36 insertions(+), 10 deletions(-)
drivers/sysinfo/rcar3.c +2 -0
index 7b127986da7..89ad46c5422 100644
@@ -32,6 +32,8 @@
 
       */
 
      struct sysinfo_rcar_priv {
 
      	char	boardmodel[64];
 
+	u8	id;
+	char	revision[4];
 
      	u8	val;
 
      };
@@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice
 *dev,

int id, size_t size, char *>

      	switch (id) {

      	case SYSINFO_ID_BOARD_MODEL:
drivers/sysinfo/rcar3.c +14 -2
-		strncpy(val, priv->boardmodel, size);
-		val[size - 1] = '\0';
+		strlcpy(val, priv->boardmodel, size);
+		break;
+	case SYSINFO_ID_BOARD_REVISION:
+		strlcpy(val, priv->revision, size);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	val[size - 1] = '\0';
+	return 0;
+}
+
+static int sysinfo_rcar_get_int(struct udevice *dev, int id, int

*val)

drivers/sysinfo/rcar3.c +6 -0
+{
+	struct sysinfo_rcar_priv *priv = dev_get_priv(dev);
+
+	switch (id) {
+	case SYSINFO_ID_BOARD_ID:
+		*val = priv->id;
Quoted 3 lines
Quoted 1 line
      		return 0;

Why not return SYSINFO_ID_BOARD_REVISION as integer here ?

Because the revision (on r-car3 boards at least) is in the format X.Y. It
could be returned as "(X << 8) | Y" or split in major/minor. But different
boards will use different revisions and I think that having a str is easier to deal with in a shell script.

Quoted 6 lines
Quoted 2 lines

With rcar they are numbers, so lets go with major/minor integers please.

Ok for this part, but shouldn't the sysinfo command use a common interface
for all boards ? Or should it also have rev_major/rev_minor arguments ?

I would expect other boards to either report rev_major/rev_minor if implemented, or errno if those boards don't implement this property.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Another thing on rcar is that the revision is stored as 2 char values. Would you oppose a change form using a char (e.g. rev_major = '1') to using u8 values (e.g. rev_major = 1) instead ?

Shouldn't those rev fields just be integer(s) to cover the generic case?

On rcar, they are chars. I don't really see a reason for this except to show the '?.?' on unknown board ids. But that can be managed in other ways.

Yes I know, I am more concerned about other boards which might not have such short revision number, so why not just make the revision fields integer which covers very much anything ? Also, if you have those fields set to integer, then -EINVAL could be printed as '?' .

#14 lore raw

PATCH 4/4 configs: rcar3: Add shell function to select the linux devicetree

In reply to Detlev Casanova

This function uses the sysinfo command to determine which linux device tree is selected for the running board.

---
 configs/rcar3_ulcb_defconfig       | 1 +
 include/configs/rcar-gen3-common.h | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
configs/rcar3_ulcb_defconfig +1 -0
index b8fdb5e3826..bb5f8f742ea 100644
@@ -47,6 +47,7 @@ CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_SYSINFO=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="r8a77950-ulcb-u-boot r8a77960-ulcb-u-boot r8a77965-ulcb-u-boot"
 CONFIG_MULTI_DTB_FIT_LZO=y
include/configs/rcar-gen3-common.h +8 -1
index 213caa75238..b278eb85a81 100644
@@ -33,6 +33,13 @@
 /* ENV setting */
 
 #define CFG_EXTRA_ENV_SETTINGS	\
-	"bootm_size=0x10000000\0"
+	"bootm_size=0x10000000\0"					\
+	"set_board_fdt=sysinfo revision board_rev; "			\
+	"sysinfo id board_id; "						\
+	"if test ${board_rev} = 2.1 && test ${board_id} = 0x0b; then "	\
+		"setenv fdtfile renesas/r8a779m1-ulcb.dtb; "		\
+	"elif test ${board_rev} = 2.0 && test ${board_id} = 0x0b; then "\
+		"setenv fdtfile renesas/r8a77951-ulcb.dtb; "		\
+	"fi\0"								\
 
 #endif	/* __RCAR_GEN3_COMMON_H */
Signature · 1 line
2.39.3
#15 lore raw

Re: [PATCH v1 4/4] configs: rcar3: Add shell function to select the linux devicetree

Quoted 28 lines · Detlev Casanova

This function uses the sysinfo command to determine which linux device tree is selected for the running board.

---
  configs/rcar3_ulcb_defconfig       | 1 +
  include/configs/rcar-gen3-common.h | 9 ++++++++-
  2 files changed, 9 insertions(+), 1 deletion(-)
configs/rcar3_ulcb_defconfig +1 -0
index b8fdb5e3826..bb5f8f742ea 100644
@@ -47,6 +47,7 @@ CONFIG_CMD_EXT4=y
  CONFIG_CMD_EXT4_WRITE=y
  CONFIG_CMD_FAT=y
  CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_SYSINFO=y
  CONFIG_OF_CONTROL=y
  CONFIG_OF_LIST="r8a77950-ulcb-u-boot r8a77960-ulcb-u-boot r8a77965-ulcb-u-boot"
  CONFIG_MULTI_DTB_FIT_LZO=y
include/configs/rcar-gen3-common.h +0 -0
index 213caa75238..b278eb85a81 100644
@@ -33,6 +33,13 @@
  /* ENV setting */
 

include/configs/rcar-gen3-common.h line 43

Quoted 10 lines
include/configs/rcar-gen3-common.h +8 -1
  #define CFG_EXTRA_ENV_SETTINGS	\
-	"bootm_size=0x10000000\0"
+	"bootm_size=0x10000000\0"					\
+	"set_board_fdt=sysinfo revision board_rev; "			\
+	"sysinfo id board_id; "						\
+	"if test ${board_rev} = 2.1 && test ${board_id} = 0x0b; then "	\
+		"setenv fdtfile renesas/r8a779m1-ulcb.dtb; "		\
+	"elif test ${board_rev} = 2.0 && test ${board_id} = 0x0b; then "\
+		"setenv fdtfile renesas/r8a77951-ulcb.dtb; "		\
+	"fi\0"								\

You must also consider M3W and M3N ULCB, i.e. 77960/77965 ones.

You must also consider all the other boards which use this header file, salvator-xs comes to mind. That one also comes with M3W/M3N SoC. Also, all the other Gen3 boards use this header, E3 Ebise, V3* Condor/Eagle ...

#16 lore raw

Re: [PATCH v1 4/4] configs: rcar3: Add shell function to select the linux devicetree

Quoted 34 lines · On Friday, June 16, 2023 8:45:31 P.M. EDT Marek Vasut wrote:
Quoted 33 lines · Detlev Casanova

This function uses the sysinfo command to determine which linux device tree is selected for the running board.

---

  configs/rcar3_ulcb_defconfig       | 1 +
  include/configs/rcar-gen3-common.h | 9 ++++++++-
  2 files changed, 9 insertions(+), 1 deletion(-)
configs/rcar3_ulcb_defconfig +1 -0
index b8fdb5e3826..bb5f8f742ea 100644
@@ -47,6 +47,7 @@ CONFIG_CMD_EXT4=y
 
  CONFIG_CMD_EXT4_WRITE=y
  CONFIG_CMD_FAT=y
  CONFIG_CMD_FS_GENERIC=y
 
+CONFIG_CMD_SYSINFO=y
 

CONFIG_OF_CONTROL=y CONFIG_OF_LIST="r8a77950-ulcb-u-boot r8a77960-ulcb-u-boot r8a77965-ulcb-u-boot" CONFIG_MULTI_DTB_FIT_LZO=y

(quoted diff) +0 -0

b/include/configs/rcar-gen3-common.h index 213caa75238..b278eb85a81 100644

include/configs/rcar-gen3-common.h +0 -0
@@ -33,6 +33,13 @@
 
Quoted 6 lines

include/configs/rcar-gen3-common.h

Quoted 6 lines
include/configs/rcar-gen3-common.h +1 -1
  /* ENV setting */
 
  #define CFG_EXTRA_ENV_SETTINGS	\
 
-	"bootm_size=0x10000000\0"
+	"bootm_size=0x10000000\0"				
	\
Quoted 1 line

include/configs/rcar-gen3-common.h line 39

Quoted 1 line
include/configs/rcar-gen3-common.h +1 -0
+	"set_board_fdt=sysinfo revision board_rev; "			

\

Quoted 1 line

include/configs/rcar-gen3-common.h line 40

Quoted 1 line
include/configs/rcar-gen3-common.h +1 -0
+	"sysinfo id board_id; "					
	\
Quoted 1 line

include/configs/rcar-gen3-common.h line 41

Quoted 1 line
include/configs/rcar-gen3-common.h +1 -0
+	"if test ${board_rev} = 2.1 && test ${board_id} = 0x0b; then "	

\

Quoted 1 line

include/configs/rcar-gen3-common.h line 42

Quoted 1 line
include/configs/rcar-gen3-common.h +1 -0
+		"setenv fdtfile renesas/r8a779m1-ulcb.dtb; "		

\

Quoted 2 lines

include/configs/rcar-gen3-common.h line 44

Quoted 2 lines
include/configs/rcar-gen3-common.h +2 -0
+	"elif test ${board_rev} = 2.0 && test ${board_id} = 0x0b; then "\
+		"setenv fdtfile renesas/r8a77951-ulcb.dtb; "		

\

Quoted 1 line

include/configs/rcar-gen3-common.h line 45

Quoted 1 line
include/configs/rcar-gen3-common.h +1 -0
+	"fi\0"						
		\
Quoted 6 lines

You must also consider M3W and M3N ULCB, i.e. 77960/77965 ones.

You must also consider all the other boards which use this header file, salvator-xs comes to mind. That one also comes with M3W/M3N SoC. Also, all the other Gen3 boards use this header, E3 Ebise, V3* Condor/Eagle ...

Yeah, that's why I'm not sure this function should be here. I don't have the boards to check the revision values.