linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: renesas: Add support for reading product revision for RZ/G2L family
@ 2021-12-20 17:03 Lad Prabhakar
  2022-01-20  8:45 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Lad Prabhakar @ 2021-12-20 17:03 UTC (permalink / raw)
  To: Geert Uytterhoeven, Magnus Damm, Biju Das, linux-renesas-soc
  Cc: linux-kernel, Lad Prabhakar

From: Biju Das <biju.das.jz@bp.renesas.com>

As per RZ/G2L HW manual (Rev.1.00 Sep, 2021) DEV_ID [31:28] indicates
product revision. Use this information to populate the revision info
for RZ/G2L family.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
Hi,

Below is the log from Renesas RZ/G2L SMARC EVK:

root@smarc-rzg2l:~#
at /sys/devices/soc0/$i; donemachine family soc_id revision; do echo -n "$i: ";ca
machine: Renesas SMARC EVK based on r9a07g044l2
family: RZ/G2L
soc_id: r9a07g044
revision: Rev 1
root@smarc-rzg2l:~#

Cheers,
Prabhakar
---
 drivers/soc/renesas/renesas-soc.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/soc/renesas/renesas-soc.c b/drivers/soc/renesas/renesas-soc.c
index 8f82749f182f..6ecd2763d100 100644
--- a/drivers/soc/renesas/renesas-soc.c
+++ b/drivers/soc/renesas/renesas-soc.c
@@ -416,6 +416,17 @@ static int __init renesas_soc_init(void)
 		chipid = ioremap(family->reg, 4);
 	}
 
+	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
+	if (!soc_dev_attr)
+		return -ENOMEM;
+
+	np = of_find_node_by_path("/");
+	of_property_read_string(np, "model", &soc_dev_attr->machine);
+	of_node_put(np);
+
+	soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
+	soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL);
+
 	if (chipid) {
 		product = readl(chipid + id->offset);
 		iounmap(chipid);
@@ -430,6 +441,12 @@ static int __init renesas_soc_init(void)
 
 			eshi = ((product >> 4) & 0x0f) + 1;
 			eslo = product & 0xf;
+			soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u",
+							   eshi, eslo);
+		}  else if (id == &id_rzg2l) {
+			eshi =  ((product >> 28) & 0x0f);
+			soc_dev_attr->revision = kasprintf(GFP_KERNEL, "Rev %u",
+							   eshi);
 		}
 
 		if (soc->id &&
@@ -439,20 +456,6 @@ static int __init renesas_soc_init(void)
 		}
 	}
 
-	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
-	if (!soc_dev_attr)
-		return -ENOMEM;
-
-	np = of_find_node_by_path("/");
-	of_property_read_string(np, "model", &soc_dev_attr->machine);
-	of_node_put(np);
-
-	soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
-	soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL);
-	if (eshi)
-		soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", eshi,
-						   eslo);
-
 	pr_info("Detected Renesas %s %s %s\n", soc_dev_attr->family,
 		soc_dev_attr->soc_id, soc_dev_attr->revision ?: "");
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] soc: renesas: Add support for reading product revision for RZ/G2L family
  2021-12-20 17:03 [PATCH] soc: renesas: Add support for reading product revision for RZ/G2L family Lad Prabhakar
@ 2022-01-20  8:45 ` Geert Uytterhoeven
  2022-01-20  9:40   ` Prabhakar Mahadev Lad
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2022-01-20  8:45 UTC (permalink / raw)
  To: Lad Prabhakar
  Cc: Magnus Damm, Biju Das, Linux-Renesas, Linux Kernel Mailing List

Hi Prabhakar,

On Mon, Dec 20, 2021 at 6:04 PM Lad Prabhakar
<prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:
> From: Biju Das <biju.das.jz@bp.renesas.com>
>
> As per RZ/G2L HW manual (Rev.1.00 Sep, 2021) DEV_ID [31:28] indicates
> product revision. Use this information to populate the revision info
> for RZ/G2L family.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Thanks for your patch!

> Below is the log from Renesas RZ/G2L SMARC EVK:
>
> root@smarc-rzg2l:~#
> at /sys/devices/soc0/$i; donemachine family soc_id revision; do echo -n "$i: ";ca

This looks a bit mangled ;-)

> machine: Renesas SMARC EVK based on r9a07g044l2
> family: RZ/G2L
> soc_id: r9a07g044
> revision: Rev 1
> root@smarc-rzg2l:~#
>
> Cheers,
> Prabhakar
> ---
>  drivers/soc/renesas/renesas-soc.c | 31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/soc/renesas/renesas-soc.c b/drivers/soc/renesas/renesas-soc.c
> index 8f82749f182f..6ecd2763d100 100644
> --- a/drivers/soc/renesas/renesas-soc.c
> +++ b/drivers/soc/renesas/renesas-soc.c
> @@ -416,6 +416,17 @@ static int __init renesas_soc_init(void)
>                 chipid = ioremap(family->reg, 4);
>         }
>
> +       soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);

This is not freed in case of SoC mismatch error below.

> +       if (!soc_dev_attr)
> +               return -ENOMEM;
> +
> +       np = of_find_node_by_path("/");
> +       of_property_read_string(np, "model", &soc_dev_attr->machine);
> +       of_node_put(np);
> +
> +       soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
> +       soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL);
> +
>         if (chipid) {
>                 product = readl(chipid + id->offset);
>                 iounmap(chipid);
> @@ -430,6 +441,12 @@ static int __init renesas_soc_init(void)
>
>                         eshi = ((product >> 4) & 0x0f) + 1;
>                         eslo = product & 0xf;
> +                       soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u",
> +                                                          eshi, eslo);
> +               }  else if (id == &id_rzg2l) {
> +                       eshi =  ((product >> 28) & 0x0f);
> +                       soc_dev_attr->revision = kasprintf(GFP_KERNEL, "Rev %u",
> +                                                          eshi);

These are not freed in case of SoC mismatch error below.

>                 }
>
>                 if (soc->id &&
> @@ -439,20 +456,6 @@ static int __init renesas_soc_init(void)
>                 }
>         }
>
> -       soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
> -       if (!soc_dev_attr)
> -               return -ENOMEM;
> -
> -       np = of_find_node_by_path("/");
> -       of_property_read_string(np, "model", &soc_dev_attr->machine);
> -       of_node_put(np);
> -
> -       soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
> -       soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL);
> -       if (eshi)
> -               soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", eshi,
> -                                                  eslo);
> -
>         pr_info("Detected Renesas %s %s %s\n", soc_dev_attr->family,
>                 soc_dev_attr->soc_id, soc_dev_attr->revision ?: "");

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] soc: renesas: Add support for reading product revision for RZ/G2L family
  2022-01-20  8:45 ` Geert Uytterhoeven
@ 2022-01-20  9:40   ` Prabhakar Mahadev Lad
  0 siblings, 0 replies; 3+ messages in thread
From: Prabhakar Mahadev Lad @ 2022-01-20  9:40 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Magnus Damm, Biju Das, Linux-Renesas, Linux Kernel Mailing List

Hi Geert,

Thank you for the review.

> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: 20 January 2022 08:45
> To: Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Cc: Magnus Damm <magnus.damm@gmail.com>; Biju Das <biju.das.jz@bp.renesas.com>; Linux-Renesas <linux-
> renesas-soc@vger.kernel.org>; Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
> Subject: Re: [PATCH] soc: renesas: Add support for reading product revision for RZ/G2L family
> 
> Hi Prabhakar,
> 
> On Mon, Dec 20, 2021 at 6:04 PM Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:
> > From: Biju Das <biju.das.jz@bp.renesas.com>
> >
> > As per RZ/G2L HW manual (Rev.1.00 Sep, 2021) DEV_ID [31:28] indicates
> > product revision. Use this information to populate the revision info
> > for RZ/G2L family.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> Thanks for your patch!
> 
> > Below is the log from Renesas RZ/G2L SMARC EVK:
> >
> > root@smarc-rzg2l:~#
> > at /sys/devices/soc0/$i; donemachine family soc_id revision; do echo
> > -n "$i: ";ca
> 
> This looks a bit mangled ;-)
> 
Typical Tera Term.

> > machine: Renesas SMARC EVK based on r9a07g044l2
> > family: RZ/G2L
> > soc_id: r9a07g044
> > revision: Rev 1
> > root@smarc-rzg2l:~#
> >
> > Cheers,
> > Prabhakar
> > ---
> >  drivers/soc/renesas/renesas-soc.c | 31
> > +++++++++++++++++--------------
> >  1 file changed, 17 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/soc/renesas/renesas-soc.c
> > b/drivers/soc/renesas/renesas-soc.c
> > index 8f82749f182f..6ecd2763d100 100644
> > --- a/drivers/soc/renesas/renesas-soc.c
> > +++ b/drivers/soc/renesas/renesas-soc.c
> > @@ -416,6 +416,17 @@ static int __init renesas_soc_init(void)
> >                 chipid = ioremap(family->reg, 4);
> >         }
> >
> > +       soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
> 
> This is not freed in case of SoC mismatch error below.
> 
Ouch.

> > +       if (!soc_dev_attr)
> > +               return -ENOMEM;
> > +
> > +       np = of_find_node_by_path("/");
> > +       of_property_read_string(np, "model", &soc_dev_attr->machine);
> > +       of_node_put(np);
> > +
> > +       soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
> > +       soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL);
> > +
> >         if (chipid) {
> >                 product = readl(chipid + id->offset);
> >                 iounmap(chipid);
> > @@ -430,6 +441,12 @@ static int __init renesas_soc_init(void)
> >
> >                         eshi = ((product >> 4) & 0x0f) + 1;
> >                         eslo = product & 0xf;
> > +                       soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u",
> > +                                                          eshi, eslo);
> > +               }  else if (id == &id_rzg2l) {
> > +                       eshi =  ((product >> 28) & 0x0f);
> > +                       soc_dev_attr->revision = kasprintf(GFP_KERNEL, "Rev %u",
> > +                                                          eshi);
> 
> These are not freed in case of SoC mismatch error below.
> 
Will fix that.

Cheers,
Prabhakar


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-20  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 17:03 [PATCH] soc: renesas: Add support for reading product revision for RZ/G2L family Lad Prabhakar
2022-01-20  8:45 ` Geert Uytterhoeven
2022-01-20  9:40   ` Prabhakar Mahadev Lad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).