Re: [PATCH v2 2/3] renesas: rcar3: Expose the board revision in sysinfo

2023-06-14 Thread Marek Vasut

On 6/12/23 21:51, Detlev Casanova wrote:

The board revision is needed to determine which linux device tree to
load.

Signed-off-by: Detlev Casanova 
---
  .../arm/mach-rmobile/include/mach/sys_proto.h |  6 ++
  drivers/sysinfo/rcar3.c   | 60 +++
  2 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-rmobile/include/mach/sys_proto.h 
b/arch/arm/mach-rmobile/include/mach/sys_proto.h
index e020b24f7c2..1f204f06c17 100644
--- a/arch/arm/mach-rmobile/include/mach/sys_proto.h
+++ b/arch/arm/mach-rmobile/include/mach/sys_proto.h
@@ -22,4 +22,10 @@
  #define BOARD_EBISU_4D0xD
  #define BOARD_CONDOR_I0x10
  
+/*

+ * 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.



  #endif
diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
index b8b837341a2..3223875a99c 100644
--- a/drivers/sysinfo/rcar3.c
+++ b/drivers/sysinfo/rcar3.c
@@ -22,6 +22,8 @@
  struct sysinfo_rcar_priv {
charboardmodel[64];
u8  board_id;
+   u8  rev_major;
+   u8  rev_minor;
u8  val;
  };


[...]


[PATCH v2 2/3] renesas: rcar3: Expose the board revision in sysinfo

2023-06-12 Thread Detlev Casanova
The board revision is needed to determine which linux device tree to
load.

Signed-off-by: Detlev Casanova 
---
 .../arm/mach-rmobile/include/mach/sys_proto.h |  6 ++
 drivers/sysinfo/rcar3.c   | 60 +++
 2 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-rmobile/include/mach/sys_proto.h 
b/arch/arm/mach-rmobile/include/mach/sys_proto.h
index e020b24f7c2..1f204f06c17 100644
--- a/arch/arm/mach-rmobile/include/mach/sys_proto.h
+++ b/arch/arm/mach-rmobile/include/mach/sys_proto.h
@@ -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
diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
index b8b837341a2..3223875a99c 100644
--- a/drivers/sysinfo/rcar3.c
+++ b/drivers/sysinfo/rcar3.c
@@ -22,6 +22,8 @@
 struct sysinfo_rcar_priv {
charboardmodel[64];
u8  board_id;
+   u8  rev_major;
+   u8  rev_minor;
u8  val;
 };
 
@@ -40,6 +42,12 @@ static int sysinfo_rcar_get_int(struct udevice *dev, int id, 
int *val)
case SYSINFO_ID_BOARD_MODEL:
*val = priv->board_id;
return 0;
+   case RCAR_SYSINFO_REV_MAJOR:
+   *val = priv->rev_major;
+   return 0;
+   case RCAR_SYSINFO_REV_MINOR:
+   *val = priv->rev_minor;
+   return 0;
default:
return -EINVAL;
};
@@ -74,8 +82,8 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
bool condor_i = false;
 
priv->board_id = board_id;
-   char rev_major = '?';
-   char rev_minor = '?';
+   priv->rev_major = '?';
+   priv->rev_minor = '?';
 
switch (board_id) {
case BOARD_SALVATOR_XS:
@@ -83,81 +91,81 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv 
*priv)
fallthrough;
case BOARD_SALVATOR_X:
if (!(board_rev & ~1)) { /* Only rev 0 and 1 is valid */
-   rev_major = '1';
-   rev_minor = '0' + (board_rev & BIT(0));
+   priv->rev_major = '1';
+   priv->rev_minor = '0' + (board_rev & BIT(0));
}
snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 "Renesas Salvator-X%s board rev %c.%c",
-salvator_xs ? "S" : "", rev_major, rev_minor);
+salvator_xs ? "S" : "", priv->rev_major, 
priv->rev_minor);
return;
case BOARD_STARTER_KIT:
if (!(board_rev & ~1)) { /* Only rev 0 and 1 is valid */
-   rev_major = (board_rev & BIT(0)) ? '3' : '1';
-   rev_minor = '0';
+   priv->rev_major = (board_rev & BIT(0)) ? '3' : '1';
+   priv->rev_minor = '0';
}
snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 "Renesas Starter Kit board rev %c.%c",
-rev_major, rev_minor);
+priv->rev_major, priv->rev_minor);
return;
case BOARD_STARTER_KIT_PRE:
if (!(board_rev & ~3)) { /* Only rev 0..3 is valid */
-   rev_major = (board_rev & BIT(1)) ? '2' : '1';
-   rev_minor = (board_rev == 3) ? '1' : '0';
+   priv->rev_major = (board_rev & BIT(1)) ? '2' : '1';
+   priv->rev_minor = (board_rev == 3) ? '1' : '0';
}
snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 "Renesas Starter Kit Premier board rev %c.%c",
-rev_major, rev_minor);
+priv->rev_major, priv->rev_minor);
return;
case BOARD_EAGLE:
if (!board_rev) { /* Only rev 0 is valid */
-   rev_major = '1';
-   rev_minor = '0';
+   priv->rev_major = '1';
+   priv->rev_minor = '0';
}
snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 "Renesas Eagle board rev %c.%c",
-rev_major, rev_minor);
+priv->rev_major, priv->rev_minor);
return;
case BOARD_EBISU_4D:
ebisu_4d = true;
fallthrough;
case BOARD_EBISU:
if (!board_rev) { /* Only rev 0 is valid */
-   rev_major = '1';
-   rev_minor = '0';
+   priv->rev_major = '1';
+   priv->rev_minor = '0';
}
snprintf(priv->boardmodel, sizeof(priv->boardmodel),