[PATCH 1/2] renesas: rcar3: Expose the board id in sysinfo

Marek Vasut marek.vasut at mailbox.org
Sat Jun 10 13:55:24 CEST 2023


On 6/9/23 18:00, Detlev Casanova wrote:
> This is a preparation commit for selecting the correct device tree name
> to be loaded depending on the board id.

I am not opposed to this patch itself (with a few tweaks, see below), 
but please see 2/2, I suspect this method of selecting the DT is not 
gonna work.

> Signed-off-by: Detlev Casanova <detlev.casanova at collabora.com>
> ---
>   drivers/sysinfo/rcar3.c | 31 ++++++++++++++++++-------------
>   drivers/sysinfo/rcar3.h | 21 +++++++++++++++++++++
>   2 files changed, 39 insertions(+), 13 deletions(-)
>   create mode 100644 drivers/sysinfo/rcar3.h
> 
> diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
> index 7b127986da7..4252f8d452c 100644
> --- a/drivers/sysinfo/rcar3.c
> +++ b/drivers/sysinfo/rcar3.c
> @@ -7,24 +7,12 @@
>   #include <dm.h>
>   #include <i2c_eeprom.h>
>   #include <log.h>
> -#include <sysinfo.h>
> +#include "rcar3.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_EAGLE		0x3
> -#define BOARD_SALVATOR_XS	0x4
> -#define BOARD_CONDOR		0x6
> -#define BOARD_DRAAK		0x7
> -#define BOARD_EBISU		0x8
> -#define BOARD_STARTER_KIT_PRE	0xB
> -#define BOARD_EBISU_4D		0xD
> -#define BOARD_CONDOR_I		0x10
> -
>   /**
>    * struct sysinfo_rcar_priv - sysinfo private data
>    * @boardname: board model and revision
> @@ -32,6 +20,7 @@
>    */
>   struct sysinfo_rcar_priv {
>   	char	boardmodel[64];
> +	u8	board_id;
>   	u8	val;
>   };
>   
> @@ -42,6 +31,19 @@ static int sysinfo_rcar_detect(struct udevice *dev)
>   	return priv->val == 0xff;
>   }
>   
> +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_MODEL:
> +		*val = priv->board_id;
> +		return 0;
> +	default:
> +		return -EINVAL;
> +	};
> +}
> +
>   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);
> @@ -59,6 +61,7 @@ static int sysinfo_rcar_get_str(struct udevice *dev, int id, size_t size, char *
>   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)
> @@ -68,6 +71,8 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
>   	bool salvator_xs = false;
>   	bool ebisu_4d = false;
>   	bool condor_i = false;
> +
> +	priv->board_id = board_id;
>   	char rev_major = '?';
>   	char rev_minor = '?';
>   
> diff --git a/drivers/sysinfo/rcar3.h b/drivers/sysinfo/rcar3.h
> new file mode 100644
> index 00000000000..21ae918d9bb
> --- /dev/null
> +++ b/drivers/sysinfo/rcar3.h
> @@ -0,0 +1,21 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2023 Detlev Casanova <detlev.casanova at collabora.com>
> + */
> +
> +#include <sysinfo.h>

This should not be here, the header is using nothing from sysinfo.h

Also, this rcar3.h header should be in 
arch/arm/mach-rmobile/include/mach/ and potentially just part of 
sys_proto.h .

> +#define BOARD_SALVATOR_X	0x0
> +#define BOARD_KRIEK		0x1
> +#define BOARD_STARTER_KIT	0x2
> +#define BOARD_EAGLE		0x3
> +#define BOARD_SALVATOR_XS	0x4
> +#define BOARD_CONDOR		0x6
> +#define BOARD_DRAAK		0x7
> +#define BOARD_EBISU		0x8
> +#define BOARD_STARTER_KIT_PRE	0xB
> +#define BOARD_EBISU_4D		0xD
> +#define BOARD_CONDOR_I		0x10
> +
> +
> +

Does ./scripts/checkpatch.pl complain about those three extra trailing 
newlines ?


More information about the U-Boot mailing list