Skip to contentSkip to conversation

sysinfo: rcar3: Add Renesas R-Car Gen3 sysinfo driver

PATCH In review Marek Vasut 2 participants 2 messages Jul 4, 2021 – Jul 5, 2021 Arm/RISC-V/Renesas architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysinfo: rcar3: Add Renesas R-Car Gen3 sysinfo driver

The Renesas R-Car Gen3 development kits contain board ID EEPROM. This driver parses out the board ID and revision out of that EEPROM and exports it e.g. for the board-info print on boot.

Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
---
 drivers/sysinfo/Kconfig  |   7 ++
 drivers/sysinfo/Makefile |   1 +
 drivers/sysinfo/rcar3.c  | 197 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 205 insertions(+)
 create mode 100644 drivers/sysinfo/rcar3.c
drivers/sysinfo/Kconfig +7 -0
index 381dcd8844..e35f7cb179 100644
@@ -17,6 +17,13 @@ config SYSINFO_GAZERBEAM
 	help
 	  Support querying device information for the gdsys Gazerbeam board.
 
+config SYSINFO_RCAR3
+	bool "Enable sysinfo driver for the Renesas R-Car Gen3"
+	depends on RCAR_GEN3 && I2C_EEPROM
+	default y if RCAR_GEN3
+	help
+	  Support querying SoC version information for Renesas R-Car Gen3.
+
 config SYSINFO_SANDBOX
 	bool "Enable sysinfo driver for the Sandbox board"
 	help
drivers/sysinfo/Makefile +1 -0
index d9f708b7ea..680dde77fe 100644
@@ -5,5 +5,6 @@
 obj-y += sysinfo-uclass.o
 obj-$(CONFIG_SYSINFO_GAZERBEAM) += gazerbeam.o
 obj-$(CONFIG_SYSINFO_GPIO) += gpio.o
+obj-$(CONFIG_SYSINFO_RCAR3) += rcar3.o
 obj-$(CONFIG_SYSINFO_SANDBOX) += sandbox.o
 obj-$(CONFIG_SYSINFO_SMBIOS) += smbios.o
drivers/sysinfo/rcar3.c new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw

Hi Marek,

Quoted 8 lines · Marek Vasut

The Renesas R-Car Gen3 development kits contain board ID EEPROM. This driver parses out the board ID and revision out of that EEPROM and exports it e.g. for the board-info print on boot.

Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Quoted 7 lines
---
 drivers/sysinfo/Kconfig  |   7 ++
 drivers/sysinfo/Makefile |   1 +
 drivers/sysinfo/rcar3.c  | 197 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 205 insertions(+)
 create mode 100644 drivers/sysinfo/rcar3.c
Quoted 75 lines
drivers/sysinfo/Kconfig +7 -0
index 381dcd8844..e35f7cb179 100644
@@ -17,6 +17,13 @@ config SYSINFO_GAZERBEAM
        help
          Support querying device information for the gdsys Gazerbeam board.
 
+config SYSINFO_RCAR3
+       bool "Enable sysinfo driver for the Renesas R-Car Gen3"
+       depends on RCAR_GEN3 && I2C_EEPROM
+       default y if RCAR_GEN3
+       help
+         Support querying SoC version information for Renesas R-Car Gen3.
+
 config SYSINFO_SANDBOX
        bool "Enable sysinfo driver for the Sandbox board"
        help
drivers/sysinfo/Makefile +1 -0
index d9f708b7ea..680dde77fe 100644
@@ -5,5 +5,6 @@
 obj-y += sysinfo-uclass.o
 obj-$(CONFIG_SYSINFO_GAZERBEAM) += gazerbeam.o
 obj-$(CONFIG_SYSINFO_GPIO) += gpio.o
+obj-$(CONFIG_SYSINFO_RCAR3) += rcar3.o
 obj-$(CONFIG_SYSINFO_SANDBOX) += sandbox.o
 obj-$(CONFIG_SYSINFO_SMBIOS) += smbios.o
drivers/sysinfo/rcar3.c new file +40 -0
new file mode 100644
index 0000000000..c2f4ddfbbe
@@ -0,0 +1,197 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Marek Vasut <[email protected]>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <i2c_eeprom.h>
+#include <log.h>
+#include <sysinfo.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_SALVATOR_XS      0x4
+#define BOARD_EBISU            0x8
+#define BOARD_STARTER_KIT_PRE  0xB
+#define BOARD_EBISU_4D         0xD
+#define BOARD_DRAAK            0xE
+#define BOARD_EAGLE            0xF
+
+/**
+ * struct sysinfo_rcar_priv - sysinfo private data
+ * @boardname: board model and revision
+ * @val: board ID value from eeprom
+ */
+struct sysinfo_rcar_priv {
+       char    boardmodel[64];
+       u8      val;
+};
+
+static int sysinfo_rcar_detect(struct udevice *dev)
+{
+       struct sysinfo_rcar_priv *priv = dev_get_priv(dev);
+
+       return priv->val == 0xff;

drivers/sysinfo/rcar3.c line 50

Quoted 10 lines
drivers/sysinfo/rcar3.c new file +10 -0
+}
+
+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);
+
+       switch (id) {
+       case SYSINFO_ID_BOARD_MODEL:
+               strncpy(val, priv->boardmodel, size);
+               val[size - 1] = '\0';

strlcpy()

[...\

You might consider using

return log_msg_ret("xxx", ret)

for errors.

Regards,
Simon