[PATCH] sysinfo: rcar3: Add Renesas R-Car Gen3 sysinfo driver

Simon Glass sjg at chromium.org
Mon Jul 5 17:29:56 CEST 2021


Hi Marek,

On Sun, 4 Jul 2021 at 13:35, Marek Vasut <marek.vasut at gmail.com> wrote:
>
> 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.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
> Cc: Sean Anderson <sean.anderson at seco.com>
> Cc: Simon Glass <sjg at chromium.org>
> ---
>  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
>

Reviewed-by: Simon Glass <sjg at chromium.org>

> diff --git a/drivers/sysinfo/Kconfig b/drivers/sysinfo/Kconfig
> index 381dcd8844..e35f7cb179 100644
> --- a/drivers/sysinfo/Kconfig
> +++ b/drivers/sysinfo/Kconfig
> @@ -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
> diff --git a/drivers/sysinfo/Makefile b/drivers/sysinfo/Makefile
> index d9f708b7ea..680dde77fe 100644
> --- a/drivers/sysinfo/Makefile
> +++ b/drivers/sysinfo/Makefile
> @@ -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
> diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
> new file mode 100644
> index 0000000000..c2f4ddfbbe
> --- /dev/null
> +++ b/drivers/sysinfo/rcar3.c
> @@ -0,0 +1,197 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2021 Marek Vasut <marek.vasut+renesas at gmail.com>
> + */
> +
> +#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;
> +}
> +
> +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


More information about the U-Boot mailing list