diff mbox series

[v5,1/2] arm: rmobile: Add RZ/G2[HMNE] SoC support

Message ID 20201008085941.3600-1-biju.das.jz@bp.renesas.com
State Superseded
Delegated to: Marek Vasut
Headers show
Series [v5,1/2] arm: rmobile: Add RZ/G2[HMNE] SoC support | expand

Commit Message

Biju Das Oct. 8, 2020, 8:59 a.m. UTC
RZ/G2 SoC's are identical to R-Car Gen3 SoC's apart from some
automotive peripherals.

RZ/G2H (R8A774E1) = R-Car H3-N (R8A77951).
RZ/G2M (R8A774A1) = R-Car M3-W (R8A77960).
RZ/G2N (R8A774B1) = R-Car M3-N (R8A77965).
RZ/G2E (R8A774C0) = R-Car E3 (R8A77990).

As the devices are the same they also have the same SoC PRR
register values. This means we cannot rely upon the PRODUCT
field to tell us whether an R-Car or RZ/G device is being used.

For RZ/G2 SoC identification the compatible string from TFA is
matched against the list of compatible strings in struct
tfa_cpuinfo.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 v4->v5
   * Add support for unique identification of RZ/G2 CPU types

 v3->v4
   * Dropped CPU info reporting logic for RZ/G2. Will address this later.
   * Added PRRID's for RZG2[HMNE]
   (Ref: https://patchwork.ozlabs.org/project/uboot/patch/20201001103658.4835-1-biju.das.jz@bp.renesas.com/)

 v2->v3  
   * Reworked as per Marek's suggestion
   * Added rzg2_get_cpu_type function to get cpu_type by matching TFA compatible string
   * Removed SoC family type Enum
   (Ref: https://patchwork.ozlabs.org/project/uboot/patch/20200922160317.16296-2-biju.das.jz@bp.renesas.com/)

 v1->v2:
  * Add comment's related to loop logic
   (ref: https://patchwork.ozlabs.org/project/uboot/patch/20200918160307.14323-1-biju.das.jz@bp.renesas.com/)

 v1:
  * New patch
  (ref:https://patchwork.ozlabs.org/project/uboot/patch/20200915143630.7678-4-biju.das.jz@bp.renesas.com/)
---
 arch/arm/mach-rmobile/cpu_info-rcar.c        | 29 +++++++++-
 arch/arm/mach-rmobile/cpu_info.c             | 10 ++--
 arch/arm/mach-rmobile/include/mach/rmobile.h | 57 ++++++++++++++------
 3 files changed, 77 insertions(+), 19 deletions(-)

Comments

Marek Vasut Oct. 25, 2020, 3:50 p.m. UTC | #1
On 10/8/20 10:59 AM, Biju Das wrote:

[...]

> +static const struct udevice_id tfa_cpu_info[] = {
> +	{ .compatible = "renesas,r8a774a1", .data = RMOBILE_CPU_TYPE_R8A774A1 },
> +	{ .compatible = "renesas,r8a774b1", .data = RMOBILE_CPU_TYPE_R8A774B1 },
> +	{ .compatible = "renesas,r8a774c0", .data = RMOBILE_CPU_TYPE_R8A774C0 },
> +	{ .compatible = "renesas,r8a774e1", .data = RMOBILE_CPU_TYPE_R8A774E1 },
> +	{ },
> +};
> +
> +static const u32 get_cpu_type(u32 soc_id)
> +{
> +	const struct udevice_id *of_match = tfa_cpu_info;
> +	int i;

Isn't there already a function in U-Boot which can match on a table of
OF compatible strings ? I suspect when drivers match on their table of
OF compatible strings, somesuch function must be used.

> +	for (i = 0; i < ARRAY_SIZE(tfa_cpu_info); i++) {
> +		if (soc_id == (of_match->data & PRODUCT_MASK) &&
> +		    of_machine_is_compatible(of_match->compatible))
> +			return of_match->data;
> +		of_match++;
> +	}
> +
> +	return soc_id;
> +}
> +
>  static u32 rmobile_get_prr(void)
>  {
>  #ifdef CONFIG_RCAR_GEN3
> @@ -23,7 +48,9 @@ static u32 rmobile_get_prr(void)
>  
>  u32 rmobile_get_cpu_type(void)
>  {
> -	return (rmobile_get_prr() & 0x00007F00) >> 8;
> +	const u32 soc_id = (rmobile_get_prr() & 0x00007F00) >> 8;

The soc_id = ... can be inlined into get_cpu_type().

However, you might want to cache the result of rmobile_get_cpu_type() ,
because doing OF match every time this is called is expensive.

> +
> +	return get_cpu_type(soc_id);
>  }

[...]

> +/* CPU IDs */
> +#define RMOBILE_CPU_TYPE_SH73A0		(SOC_ID_SH73A0)
> +#define RMOBILE_CPU_TYPE_R8A7740	(SOC_ID_R8A7740)
> +#define RMOBILE_CPU_TYPE_R8A774A1	(SOC_ID_R8A774A1 | RZG_CPU_MASK)
> +#define RMOBILE_CPU_TYPE_R8A774B1	(SOC_ID_R8A774B1 | RZG_CPU_MASK)
> +#define RMOBILE_CPU_TYPE_R8A774C0	(SOC_ID_R8A774C0 | RZG_CPU_MASK)
> +#define RMOBILE_CPU_TYPE_R8A774E1	(SOC_ID_R8A774E1 | RZG_CPU_MASK)
> +#define RMOBILE_CPU_TYPE_R8A7790	(SOC_ID_R8A7790)
> +#define RMOBILE_CPU_TYPE_R8A7791	(SOC_ID_R8A7791)
> +#define RMOBILE_CPU_TYPE_R8A7792	(SOC_ID_R8A7792)
> +#define RMOBILE_CPU_TYPE_R8A7793	(SOC_ID_R8A7793)
> +#define RMOBILE_CPU_TYPE_R8A7794	(SOC_ID_R8A7794)
> +#define RMOBILE_CPU_TYPE_R8A7795	(SOC_ID_R8A7795)
> +#define RMOBILE_CPU_TYPE_R8A7796	(SOC_ID_R8A7796)
> +#define RMOBILE_CPU_TYPE_R8A77965	(SOC_ID_R8A77965)
> +#define RMOBILE_CPU_TYPE_R8A77970	(SOC_ID_R8A77970)
> +#define RMOBILE_CPU_TYPE_R8A77980	(SOC_ID_R8A77980)
> +#define RMOBILE_CPU_TYPE_R8A77990	(SOC_ID_R8A77990)
> +#define RMOBILE_CPU_TYPE_R8A77995	(SOC_ID_R8A77995)

The () parentheses are not needed. Also, is there any need for this
renaming of SOC_ID_R8... to RMOBILE_CPU... ?

> +/* RZ/G CPU Identification Mask */
> +#define RZG_CPU_MASK 0x1000

This mask should have a comment which explicitly states that it is not
related to the PRR register content.
Biju Das Nov. 1, 2020, 7:26 p.m. UTC | #2
Hi Marek,

> Subject: Re: [PATCH v5 1/2] arm: rmobile: Add RZ/G2[HMNE] SoC support
> 
> On 10/8/20 10:59 AM, Biju Das wrote:
> 
> [...]
> 
> > +static const struct udevice_id tfa_cpu_info[] = {
> > +	{ .compatible = "renesas,r8a774a1", .data =
> RMOBILE_CPU_TYPE_R8A774A1 },
> > +	{ .compatible = "renesas,r8a774b1", .data =
> RMOBILE_CPU_TYPE_R8A774B1 },
> > +	{ .compatible = "renesas,r8a774c0", .data =
> RMOBILE_CPU_TYPE_R8A774C0 },
> > +	{ .compatible = "renesas,r8a774e1", .data =
> RMOBILE_CPU_TYPE_R8A774E1 },
> > +	{ },
> > +};
> > +
> > +static const u32 get_cpu_type(u32 soc_id) {
> > +	const struct udevice_id *of_match = tfa_cpu_info;
> > +	int i;
> 
> Isn't there already a function in U-Boot which can match on a table of OF
> compatible strings ? I suspect when drivers match on their table of OF
> compatible strings, somesuch function must be used.

of_match function for matching device compatible string. But it doesn't match SoC compatible string.
So I added a helper function  is of_match_node[1] to search from rootnode to find the soc compatible string.

[1] http://patchwork.ozlabs.org/project/uboot/patch/20201030140303.11773-1-biju.das.jz@bp.renesas.com/

Apart from this, This helper function can be used to replace the below codes in u-boot tree [2] [3]

[2] https://elixir.bootlin.com/u-boot/latest/source/drivers/serial/serial_uniphier.c#L129

[3] https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/phy/rockchip_usb2_phy.c#L77


> > +	for (i = 0; i < ARRAY_SIZE(tfa_cpu_info); i++) {
> > +		if (soc_id == (of_match->data & PRODUCT_MASK) &&
> > +		    of_machine_is_compatible(of_match->compatible))
> > +			return of_match->data;
> > +		of_match++;
> > +	}
> > +
> > +	return soc_id;
> > +}
> > +
> >  static u32 rmobile_get_prr(void)
> >  {
> >  #ifdef CONFIG_RCAR_GEN3
> > @@ -23,7 +48,9 @@ static u32 rmobile_get_prr(void)
> >
> >  u32 rmobile_get_cpu_type(void)
> >  {
> > -	return (rmobile_get_prr() & 0x00007F00) >> 8;
> > +	const u32 soc_id = (rmobile_get_prr() & 0x00007F00) >> 8;
> 
> The soc_id = ... can be inlined into get_cpu_type().
> 
> However, you might want to cache the result of rmobile_get_cpu_type() ,
> because doing OF match every time this is called is expensive.

I agree calling OF match is expensive. So I have ported Renesas SoC identification driver  from Linux to u-boot 
which will cache the family type, soc_id and revision. I already sent a patch for supporting soc_id in UCLASS_SOC in ML[4]
[4]  http://patchwork.ozlabs.org/project/uboot/patch/20201030140724.12773-1-biju.das.jz@bp.renesas.com/

On the next version, I will send Renesas SoC identification driver, which supports caching family type which
can be used to provide unique identification for CPU type.

> > +
> > +	return get_cpu_type(soc_id);
> >  }
> 
> [...]
> 
> > +/* CPU IDs */
> > +#define RMOBILE_CPU_TYPE_SH73A0		(SOC_ID_SH73A0)
> > +#define RMOBILE_CPU_TYPE_R8A7740	(SOC_ID_R8A7740)
> > +#define RMOBILE_CPU_TYPE_R8A774A1	(SOC_ID_R8A774A1 |
> RZG_CPU_MASK)
> > +#define RMOBILE_CPU_TYPE_R8A774B1	(SOC_ID_R8A774B1 |
> RZG_CPU_MASK)
> > +#define RMOBILE_CPU_TYPE_R8A774C0	(SOC_ID_R8A774C0 |
> RZG_CPU_MASK)
> > +#define RMOBILE_CPU_TYPE_R8A774E1	(SOC_ID_R8A774E1 |
> RZG_CPU_MASK)
> > +#define RMOBILE_CPU_TYPE_R8A7790	(SOC_ID_R8A7790)
> > +#define RMOBILE_CPU_TYPE_R8A7791	(SOC_ID_R8A7791)
> > +#define RMOBILE_CPU_TYPE_R8A7792	(SOC_ID_R8A7792)
> > +#define RMOBILE_CPU_TYPE_R8A7793	(SOC_ID_R8A7793)
> > +#define RMOBILE_CPU_TYPE_R8A7794	(SOC_ID_R8A7794)
> > +#define RMOBILE_CPU_TYPE_R8A7795	(SOC_ID_R8A7795)
> > +#define RMOBILE_CPU_TYPE_R8A7796	(SOC_ID_R8A7796)
> > +#define RMOBILE_CPU_TYPE_R8A77965	(SOC_ID_R8A77965)
> > +#define RMOBILE_CPU_TYPE_R8A77970	(SOC_ID_R8A77970)
> > +#define RMOBILE_CPU_TYPE_R8A77980	(SOC_ID_R8A77980)
> > +#define RMOBILE_CPU_TYPE_R8A77990	(SOC_ID_R8A77990)
> > +#define RMOBILE_CPU_TYPE_R8A77995	(SOC_ID_R8A77995)
> 
> The () parentheses are not needed. Also, is there any need for this renaming
> of SOC_ID_R8... to RMOBILE_CPU... ?

OK, will take out parenthesis. RMOBILE_CPU_TYPE is unique, where SOC_ID_XXXX is not unique.

> > +/* RZ/G CPU Identification Mask */
> > +#define RZG_CPU_MASK 0x1000
> 
> This mask should have a comment which explicitly states that it is not related
> to the PRR register content.

Ok. Agreed.

Thanks and regards,
Biju
Marek Vasut Nov. 2, 2020, 7:23 p.m. UTC | #3
On 11/1/20 8:26 PM, Biju Das wrote:
> Hi Marek,

Hi,

[...]

>>> @@ -23,7 +48,9 @@ static u32 rmobile_get_prr(void)
>>>
>>>   u32 rmobile_get_cpu_type(void)
>>>   {
>>> -	return (rmobile_get_prr() & 0x00007F00) >> 8;
>>> +	const u32 soc_id = (rmobile_get_prr() & 0x00007F00) >> 8;
>>
>> The soc_id = ... can be inlined into get_cpu_type().
>>
>> However, you might want to cache the result of rmobile_get_cpu_type() ,
>> because doing OF match every time this is called is expensive.
> 
> I agree calling OF match is expensive. So I have ported Renesas SoC identification driver  from Linux to u-boot
> which will cache the family type, soc_id and revision. I already sent a patch for supporting soc_id in UCLASS_SOC in ML[4]
> [4]  http://patchwork.ozlabs.org/project/uboot/patch/20201030140724.12773-1-biju.das.jz@bp.renesas.com/
> 
> On the next version, I will send Renesas SoC identification driver, which supports caching family type which
> can be used to provide unique identification for CPU type.

Please make sure to check it on RCar2 as well, those use SPL and the SPL 
size is quite limited.

[...]
Biju Das Nov. 3, 2020, 10:06 a.m. UTC | #4
Hi Marek,

> Subject: Re: [PATCH v5 1/2] arm: rmobile: Add RZ/G2[HMNE] SoC support
> 
> On 11/1/20 8:26 PM, Biju Das wrote:
> > Hi Marek,
> 
> Hi,
> 
> [...]
> 
> >>> @@ -23,7 +48,9 @@ static u32 rmobile_get_prr(void)
> >>>
> >>>   u32 rmobile_get_cpu_type(void)
> >>>   {
> >>> -	return (rmobile_get_prr() & 0x00007F00) >> 8;
> >>> +	const u32 soc_id = (rmobile_get_prr() & 0x00007F00) >> 8;
> >>
> >> The soc_id = ... can be inlined into get_cpu_type().
> >>
> >> However, you might want to cache the result of rmobile_get_cpu_type()
> >> , because doing OF match every time this is called is expensive.
> >
> > I agree calling OF match is expensive. So I have ported Renesas SoC
> > identification driver  from Linux to u-boot which will cache the
> > family type, soc_id and revision. I already sent a patch for
> > supporting soc_id in UCLASS_SOC in ML[4] [4]
> >
> https://jpn01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
> > work.ozlabs.org%2Fproject%2Fuboot%2Fpatch%2F20201030140724.12773-
> 1-bij
> >
> u.das.jz%40bp.renesas.com%2F&amp;data=04%7C01%7Cbiju.das.jz%40bp.r
> enes
> >
> as.com%7C23804e7d89d0437047b308d87f654edd%7C53d82571da1947e49cb4
> 625a16
> >
> 6a4a2a%7C0%7C1%7C637399420383910105%7CUnknown%7CTWFpbGZsb3d8
> eyJWIjoiMC
> >
> 4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&
> amp;sd
> >
> ata=%2Bu6HZyimz2%2Froy%2FEfTAzAxXupL0hDSBGUqT4%2B%2F2lVJ8%3D&
> amp;reser
> > ved=0
> >
> > On the next version, I will send Renesas SoC identification driver,
> > which supports caching family type which can be used to provide unique
> identification for CPU type.
> 
> Please make sure to check it on RCar2 as well, those use SPL and the SPL size
> is quite limited.

Currently SoC identification driver is enabled only for RZ/G2 boards and support is added to both R-Car Gen3 and RZ/G2 devices.

For the disabled case, the UCLASS-SOC class functions are inlined to "NULL"  for soc_device_match and rest of the api's it is "-ENOSYS".

I agree, in future we need to add support for RCar2 as well, since we are going to add u-boot support for RZ/G1 devices.
Please find the size details related to R-Car Gen2(by adding support for R-Car M2-W and RZ/G1M SoC).

There is increase of 944 bytes, for R-Car Gen2 device, if we enable Renesas SoC identification driver for Gen2 devices.

Current u-boot-sh/master
-----------------------------------
$ ls -al u-boot.bin 
-rw-r--r-- 1 biju biju 523001 Nov  3 09:16 u-boot.bin

Current u-boot-sh/master + SoC renesas driver (R-Car M2-W enabled only case)
--------------------------------------------------------------------------------------------
$ ls -al u-boot.bin 
-rw-r--r-- 1 biju biju 523945 Nov  3 09:47 u-boot.bin

If you agree, we will add support for Gen2 to SoC identification driver later. Currently there is no users for using it.
Please let me know.

Regards,
Biju
Marek Vasut Nov. 4, 2020, 7:24 p.m. UTC | #5
On 11/3/20 11:06 AM, Biju Das wrote:
> Hi Marek,

Hi,

[...]

>>> On the next version, I will send Renesas SoC identification driver,
>>> which supports caching family type which can be used to provide unique
>> identification for CPU type.
>>
>> Please make sure to check it on RCar2 as well, those use SPL and the SPL size
>> is quite limited.
> 
> Currently SoC identification driver is enabled only for RZ/G2 boards and support is added to both R-Car Gen3 and RZ/G2 devices.
> 
> For the disabled case, the UCLASS-SOC class functions are inlined to "NULL"  for soc_device_match and rest of the api's it is "-ENOSYS".
> 
> I agree, in future we need to add support for RCar2 as well, since we are going to add u-boot support for RZ/G1 devices.
> Please find the size details related to R-Car Gen2(by adding support for R-Car M2-W and RZ/G1M SoC).
> 
> There is increase of 944 bytes, for R-Car Gen2 device, if we enable Renesas SoC identification driver for Gen2 devices.
> 
> Current u-boot-sh/master
> -----------------------------------
> $ ls -al u-boot.bin
> -rw-r--r-- 1 biju biju 523001 Nov  3 09:16 u-boot.bin
> 
> Current u-boot-sh/master + SoC renesas driver (R-Car M2-W enabled only case)
> --------------------------------------------------------------------------------------------
> $ ls -al u-boot.bin
> -rw-r--r-- 1 biju biju 523945 Nov  3 09:47 u-boot.bin
> 
> If you agree, we will add support for Gen2 to SoC identification driver later. Currently there is no users for using it.
> Please let me know.

The problem on Gen2 isn't the size of u-boot.bin , but of 
spl/u-boot-spl.bin . That one is severely limited and I don't think it's 
realistic to add any sort of SoC identification driver into it. In fact, 
I think even the DM is somehow reduced in there.
Biju Das Nov. 4, 2020, 7:55 p.m. UTC | #6
Hi Marek,


> On 11/3/20 11:06 AM, Biju Das wrote:
> > Hi Marek,
> 
> Hi,
> 
> [...]
> 
> >>> On the next version, I will send Renesas SoC identification driver,
> >>> which supports caching family type which can be used to provide
> >>> unique
> >> identification for CPU type.
> >>
> >> Please make sure to check it on RCar2 as well, those use SPL and the
> >> SPL size is quite limited.
> >
> > Currently SoC identification driver is enabled only for RZ/G2 boards and
> support is added to both R-Car Gen3 and RZ/G2 devices.
> >
> > For the disabled case, the UCLASS-SOC class functions are inlined to "NULL"
> for soc_device_match and rest of the api's it is "-ENOSYS".
> >
> > I agree, in future we need to add support for RCar2 as well, since we are
> going to add u-boot support for RZ/G1 devices.
> > Please find the size details related to R-Car Gen2(by adding support for R-
> Car M2-W and RZ/G1M SoC).
> >
> > There is increase of 944 bytes, for R-Car Gen2 device, if we enable Renesas
> SoC identification driver for Gen2 devices.
> >
> > Current u-boot-sh/master
> > -----------------------------------
> > $ ls -al u-boot.bin
> > -rw-r--r-- 1 biju biju 523001 Nov  3 09:16 u-boot.bin
> >
> > Current u-boot-sh/master + SoC renesas driver (R-Car M2-W enabled only
> > case)
> > ----------------------------------------------------------------------
> > ----------------------
> > $ ls -al u-boot.bin
> > -rw-r--r-- 1 biju biju 523945 Nov  3 09:47 u-boot.bin
> >
> > If you agree, we will add support for Gen2 to SoC identification driver later.
> Currently there is no users for using it.
> > Please let me know.
> 
> The problem on Gen2 isn't the size of u-boot.bin , but of spl/u-boot-spl.bin .
> That one is severely limited and I don't think it's realistic to add any sort of
> SoC identification driver into it. In fact, I think even the DM is somehow
> reduced in there.

Yes, I agree there is size constraint for Gen2 for spl/u-boot-spl.bin. Even in Gen3, we don't compile core/pinctrl driver for SPL.
See, from drivers/Makefile. 

obj-$(CONFIG_$(SPL_TPL_)DM)
obj-$(CONFIG_$(SPL_TPL_)PINCTRL) += pinctrl/

if we enable this, then we get linker error related to region .sram overflow messages.

Please let me know, shall I post a patch series with SoC Identification and SDHI quirks or still have some open points?

Regards,
Biju
Biju Das Nov. 27, 2020, 5:03 p.m. UTC | #7
Hi Marek,

> -----Original Message-----
> From: Marek Vasut <marek.vasut@gmail.com>
> Sent: 04 November 2020 19:24
> To: Biju Das <biju.das.jz@bp.renesas.com>; Nobuhiro Iwamatsu
> <iwamatsu@nigauri.org>
> Cc: u-boot@lists.denx.de; Chris Paterson <Chris.Paterson2@renesas.com>;
> Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Subject: Re: [PATCH v5 1/2] arm: rmobile: Add RZ/G2[HMNE] SoC support
> 
> On 11/3/20 11:06 AM, Biju Das wrote:
> > Hi Marek,
> 
> Hi,
> 
> [...]
> 
> >>> On the next version, I will send Renesas SoC identification driver,
> >>> which supports caching family type which can be used to provide
> >>> unique
> >> identification for CPU type.
> >>
> >> Please make sure to check it on RCar2 as well, those use SPL and the
> >> SPL size is quite limited.
> >
> > Currently SoC identification driver is enabled only for RZ/G2 boards and
> support is added to both R-Car Gen3 and RZ/G2 devices.
> >
> > For the disabled case, the UCLASS-SOC class functions are inlined to
> "NULL"  for soc_device_match and rest of the api's it is "-ENOSYS".
> >
> > I agree, in future we need to add support for RCar2 as well, since we
> are going to add u-boot support for RZ/G1 devices.
> > Please find the size details related to R-Car Gen2(by adding support for
> R-Car M2-W and RZ/G1M SoC).
> >
> > There is increase of 944 bytes, for R-Car Gen2 device, if we enable
> Renesas SoC identification driver for Gen2 devices.
> >
> > Current u-boot-sh/master
> > -----------------------------------
> > $ ls -al u-boot.bin
> > -rw-r--r-- 1 biju biju 523001 Nov  3 09:16 u-boot.bin
> >
> > Current u-boot-sh/master + SoC renesas driver (R-Car M2-W enabled only
> > case)
> > ----------------------------------------------------------------------
> > ----------------------
> > $ ls -al u-boot.bin
> > -rw-r--r-- 1 biju biju 523945 Nov  3 09:47 u-boot.bin
> >
> > If you agree, we will add support for Gen2 to SoC identification driver
> later. Currently there is no users for using it.
> > Please let me know.
> 
> The problem on Gen2 isn't the size of u-boot.bin , but of spl/u-boot-
> spl.bin . That one is severely limited and I don't think it's realistic to
> add any sort of SoC identification driver into it. In fact, I think even
> the DM is somehow reduced in there.

If you see the make file , soc identification driver is disabled for spl/u-boot.

obj-$(CONFIG_$(SPL_)SOC_DEVICE_RENESAS) += soc_renesas.o

So I think we are having same understanding not to add soc identification driver for spl/uboot.
Please let me know, if you think other wise.

Regards,
Biju
diff mbox series

Patch

diff --git a/arch/arm/mach-rmobile/cpu_info-rcar.c b/arch/arm/mach-rmobile/cpu_info-rcar.c
index 5bde24ae0e..ee56864b61 100644
--- a/arch/arm/mach-rmobile/cpu_info-rcar.c
+++ b/arch/arm/mach-rmobile/cpu_info-rcar.c
@@ -6,12 +6,37 @@ 
  */
 #include <common.h>
 #include <asm/io.h>
+#include <dm/device.h>
 
+#define PRODUCT_MASK		0xff
 #define PRR_MASK		0x7fff
 #define R8A7796_REV_1_0		0x5200
 #define R8A7796_REV_1_1		0x5210
 #define R8A7796_REV_1_3		0x5211
 
+static const struct udevice_id tfa_cpu_info[] = {
+	{ .compatible = "renesas,r8a774a1", .data = RMOBILE_CPU_TYPE_R8A774A1 },
+	{ .compatible = "renesas,r8a774b1", .data = RMOBILE_CPU_TYPE_R8A774B1 },
+	{ .compatible = "renesas,r8a774c0", .data = RMOBILE_CPU_TYPE_R8A774C0 },
+	{ .compatible = "renesas,r8a774e1", .data = RMOBILE_CPU_TYPE_R8A774E1 },
+	{ },
+};
+
+static const u32 get_cpu_type(u32 soc_id)
+{
+	const struct udevice_id *of_match = tfa_cpu_info;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(tfa_cpu_info); i++) {
+		if (soc_id == (of_match->data & PRODUCT_MASK) &&
+		    of_machine_is_compatible(of_match->compatible))
+			return of_match->data;
+		of_match++;
+	}
+
+	return soc_id;
+}
+
 static u32 rmobile_get_prr(void)
 {
 #ifdef CONFIG_RCAR_GEN3
@@ -23,7 +48,9 @@  static u32 rmobile_get_prr(void)
 
 u32 rmobile_get_cpu_type(void)
 {
-	return (rmobile_get_prr() & 0x00007F00) >> 8;
+	const u32 soc_id = (rmobile_get_prr() & 0x00007F00) >> 8;
+
+	return get_cpu_type(soc_id);
 }
 
 u32 rmobile_get_cpu_rev_integer(void)
diff --git a/arch/arm/mach-rmobile/cpu_info.c b/arch/arm/mach-rmobile/cpu_info.c
index fdbbd72e28..b19b7e3044 100644
--- a/arch/arm/mach-rmobile/cpu_info.c
+++ b/arch/arm/mach-rmobile/cpu_info.c
@@ -3,12 +3,12 @@ 
  * (C) Copyright 2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
  * (C) Copyright 2012 Renesas Solutions Corp.
  */
-#include <common.h>
-#include <cpu_func.h>
 #include <asm/cache.h>
-#include <init.h>
 #include <asm/io.h>
+#include <common.h>
+#include <cpu_func.h>
 #include <env.h>
+#include <init.h>
 #include <linux/ctype.h>
 
 #ifdef CONFIG_ARCH_CPU_INIT
@@ -59,6 +59,10 @@  static const struct {
 } rmobile_cpuinfo[] = {
 	{ RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
 	{ RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
+	{ RMOBILE_CPU_TYPE_R8A774A1, "R8A774A1" },
+	{ RMOBILE_CPU_TYPE_R8A774B1, "R8A774B1" },
+	{ RMOBILE_CPU_TYPE_R8A774C0, "R8A774C0" },
+	{ RMOBILE_CPU_TYPE_R8A774E1, "R8A774E1" },
 	{ RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
 	{ RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
 	{ RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
diff --git a/arch/arm/mach-rmobile/include/mach/rmobile.h b/arch/arm/mach-rmobile/include/mach/rmobile.h
index a50249dc96..6d638466e9 100644
--- a/arch/arm/mach-rmobile/include/mach/rmobile.h
+++ b/arch/arm/mach-rmobile/include/mach/rmobile.h
@@ -24,21 +24,48 @@ 
 #endif
 #endif /* CONFIG_ARCH_RMOBILE */
 
-/* PRR CPU IDs */
-#define RMOBILE_CPU_TYPE_SH73A0		0x37
-#define RMOBILE_CPU_TYPE_R8A7740	0x40
-#define RMOBILE_CPU_TYPE_R8A7790	0x45
-#define RMOBILE_CPU_TYPE_R8A7791	0x47
-#define RMOBILE_CPU_TYPE_R8A7792	0x4A
-#define RMOBILE_CPU_TYPE_R8A7793	0x4B
-#define RMOBILE_CPU_TYPE_R8A7794	0x4C
-#define RMOBILE_CPU_TYPE_R8A7795	0x4F
-#define RMOBILE_CPU_TYPE_R8A7796	0x52
-#define RMOBILE_CPU_TYPE_R8A77965	0x55
-#define RMOBILE_CPU_TYPE_R8A77970	0x54
-#define RMOBILE_CPU_TYPE_R8A77980	0x56
-#define RMOBILE_CPU_TYPE_R8A77990	0x57
-#define RMOBILE_CPU_TYPE_R8A77995	0x58
+/* PRR IDs */
+#define SOC_ID_SH73A0		0x37
+#define SOC_ID_R8A7740		0x40
+#define SOC_ID_R8A774A1		0x52
+#define SOC_ID_R8A774B1		0x55
+#define SOC_ID_R8A774C0		0x57
+#define SOC_ID_R8A774E1		0x4F
+#define SOC_ID_R8A7790		0x45
+#define SOC_ID_R8A7791		0x47
+#define SOC_ID_R8A7792		0x4A
+#define SOC_ID_R8A7793		0x4B
+#define SOC_ID_R8A7794		0x4C
+#define SOC_ID_R8A7795		0x4F
+#define SOC_ID_R8A7796		0x52
+#define SOC_ID_R8A77965		0x55
+#define SOC_ID_R8A77970		0x54
+#define SOC_ID_R8A77980		0x56
+#define SOC_ID_R8A77990		0x57
+#define SOC_ID_R8A77995		0x58
+
+/* CPU IDs */
+#define RMOBILE_CPU_TYPE_SH73A0		(SOC_ID_SH73A0)
+#define RMOBILE_CPU_TYPE_R8A7740	(SOC_ID_R8A7740)
+#define RMOBILE_CPU_TYPE_R8A774A1	(SOC_ID_R8A774A1 | RZG_CPU_MASK)
+#define RMOBILE_CPU_TYPE_R8A774B1	(SOC_ID_R8A774B1 | RZG_CPU_MASK)
+#define RMOBILE_CPU_TYPE_R8A774C0	(SOC_ID_R8A774C0 | RZG_CPU_MASK)
+#define RMOBILE_CPU_TYPE_R8A774E1	(SOC_ID_R8A774E1 | RZG_CPU_MASK)
+#define RMOBILE_CPU_TYPE_R8A7790	(SOC_ID_R8A7790)
+#define RMOBILE_CPU_TYPE_R8A7791	(SOC_ID_R8A7791)
+#define RMOBILE_CPU_TYPE_R8A7792	(SOC_ID_R8A7792)
+#define RMOBILE_CPU_TYPE_R8A7793	(SOC_ID_R8A7793)
+#define RMOBILE_CPU_TYPE_R8A7794	(SOC_ID_R8A7794)
+#define RMOBILE_CPU_TYPE_R8A7795	(SOC_ID_R8A7795)
+#define RMOBILE_CPU_TYPE_R8A7796	(SOC_ID_R8A7796)
+#define RMOBILE_CPU_TYPE_R8A77965	(SOC_ID_R8A77965)
+#define RMOBILE_CPU_TYPE_R8A77970	(SOC_ID_R8A77970)
+#define RMOBILE_CPU_TYPE_R8A77980	(SOC_ID_R8A77980)
+#define RMOBILE_CPU_TYPE_R8A77990	(SOC_ID_R8A77990)
+#define RMOBILE_CPU_TYPE_R8A77995	(SOC_ID_R8A77995)
+
+/* RZ/G CPU Identification Mask */
+#define RZG_CPU_MASK 0x1000
 
 #ifndef __ASSEMBLY__
 u32 rmobile_get_cpu_type(void);