[PATCH 1/2] arm: rmobile: Add RZ/G2M SoC

Marek Vasut marek.vasut at gmail.com
Mon Sep 21 18:23:44 CEST 2020


On 9/21/20 12:30 PM, Biju Das wrote:

[...]

>> I don't think you need to modify anything then, the DT passed from TFA
>> would contain the correct compatible string in / node, and that gets merged
>> into the U-Boot control DT early on in fdtdec_board_setup() in:
>> board/renesas/rcar-common/common.c
>> so all you would have to do is use
>> of_machine_is_compatible("renesas,r8a7-something-");
>>
>> Would that work ?
> 
> 
> Yes, I have added the below function to get cpu name from small array tfa_cpu_table. Will send V3 with this changes.
> 
> +static const u8* get_cpu_name(void)
> +{
> +u32 cpu_type = rmobile_get_cpu_type();
> +
> +return is_tfa_soc_match(cpu_type) ?
> +tfa_cpuinfo[tfa_cpuinfo_idx(cpu_type)].cpu_name :
> +rmobile_cpuinfo[rmobile_cpuinfo_idx(cpu_type)].cpu_name;
> +}
> 
> +static int tfa_cpuinfo_idx(u32 cpu_type)
> +{
> +int i = 0;
> +
> +for (; i < ARRAY_SIZE(tfa_cpuinfo); i++)
> +if (tfa_cpuinfo[i].cpu_type == cpu_type)
> +break;
> +
> +return i;
> +}
> +
> +static bool is_tfa_soc_match(u32 cpu_type)
> +{
> +int idx = tfa_cpuinfo_idx(cpu_type);
> +
> +if (idx != ARRAY_SIZE(tfa_cpuinfo) &&
> +    of_machine_is_compatible(tfa_cpuinfo[idx].compatible))
> +return true;
> +
> +return false;
> +}

There might be even better way. Look at rmobile_get_cpu_type() , that is
a weak function. So if you can implement one for RZG2 , then that
function can return CPU_TYPE_RZG2_something ; and rmobile_get_cpu_type()
for RZG2 can be implemented using the match on /compatible string .

Take a look at how arch/arm/mach-rmobile/cpu_info-rcar.c implements it
using PRR, you might need cpu_info-rzg.c I think.

Also, I hope there should already be some function to which you provide
a compatible string and a table of supported compatible strings (of
match table), from which it will return the .data field of the matching
entry in that table. And that .data field can already be the
CPU_TYPE_RZG_something , so you don't have to implement the table look
up again.

What do you think ?


More information about the U-Boot mailing list