All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: Marek Vasut <marek.vasut@gmail.com>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
	Marek Vasut <marek.vasut+renesas@gmail.com>,
	 Sean Anderson <sean.anderson@seco.com>
Subject: Re: [PATCH] sysinfo: rcar3: Add Renesas R-Car Gen3 sysinfo driver
Date: Mon, 5 Jul 2021 09:29:56 -0600	[thread overview]
Message-ID: <CAPnjgZ1fGjdVSj7QF1nq29+y3Uu9oFOK5BQtSu5mj6yYqkivaw@mail.gmail.com> (raw)
In-Reply-To: <20210704193446.84776-1-marek.vasut+renesas@gmail.com>

Hi Marek,

On Sun, 4 Jul 2021 at 13:35, Marek Vasut <marek.vasut@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@gmail.com>
> Cc: Sean Anderson <sean.anderson@seco.com>
> Cc: Simon Glass <sjg@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@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@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

      reply	other threads:[~2021-07-05 15:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-04 19:34 [PATCH] sysinfo: rcar3: Add Renesas R-Car Gen3 sysinfo driver Marek Vasut
2021-07-05 15:29 ` Simon Glass [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPnjgZ1fGjdVSj7QF1nq29+y3Uu9oFOK5BQtSu5mj6yYqkivaw@mail.gmail.com \
    --to=sjg@chromium.org \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=marek.vasut@gmail.com \
    --cc=sean.anderson@seco.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.