arm: rmobile: Add RZ/G2M SoC
Subsystems (2)
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
Add CPU and PRR IDs for R8A774A1(a.k.a RZ/G2M) SoC.
RZ/Gx SoC's are identical to R-Car SoC's apart from some automotive peripherals and they also share the same PRR CPU ID's.
For example the RZ/G2M SoC has the same PRR ID 0x52 as R-Car M3W SoC.
To differentiate RZ/G SoC's from R-Car SoC's add a member family_type in struct rmobile_cpuinfo and compare the compatible string from device tree for SoC identification of RZ/G SoC.
Also sorted the header alphabetically.
---
V1-->V2
Add comments in the code for SoC identification logic for RZ/G SoC's
--- arch/arm/mach-rmobile/cpu_info.c | 83 +++++++++++++++----- arch/arm/mach-rmobile/include/mach/rmobile.h | 1 + 2 files changed, 65 insertions(+), 19 deletions(-)
arch/arm/mach-rmobile/cpu_info.c +64 -19
@@ -3,13 +3,23 @@* (C) Copyright 2012 Nobuhiro Iwamatsu <[email protected]> * (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 <dm/device.h> #include <env.h> +#include <init.h> #include <linux/ctype.h> +#include <linux/libfdt.h> + +enum soc_family_type { +SOC_SHMOBILE =0 , +SOC_RMOBILE , +SOC_RZG2 , +SOC_RCAR_GEN2 , +SOC_RCAR_GEN3 , +};#ifdef CONFIG_ARCH_CPU_INIT int arch_cpu_init (void )
@@ -31,6 +41,7 @@ void enable_caches(void) #ifdef CONFIG_DISPLAY_CPUINFO #ifndef CONFIG_RZA1 +DECLARE_GLOBAL_DATA_PTR; static u32 __rmobile_get_cpu_type(void) { return 0x0;
@@ -52,36 +63,70 @@ static u32 __rmobile_get_cpu_rev_fraction(void)u32 rmobile_get_cpu_rev_fraction (void ) __attribute__((weak,alias ("__rmobile_get_cpu_rev_fraction" ))); +static const struct udevice_id soc_ids[] = { + { .compatible ="renesas,r8a774a1" , .data =SOC_RZG2 }, + { }, +}; +/* CPU infomation table */ static const struct {u16 cpu_type;u8 cpu_name[10 ]; +enum soc_family_type family_type; } rmobile_cpuinfo[] = { - {RMOBILE_CPU_TYPE_SH73A0 ,"SH73A0" }, - {RMOBILE_CPU_TYPE_R8A7740 ,"R8A7740" }, - {RMOBILE_CPU_TYPE_R8A7790 ,"R8A7790" }, - {RMOBILE_CPU_TYPE_R8A7791 ,"R8A7791" }, - {RMOBILE_CPU_TYPE_R8A7792 ,"R8A7792" }, - {RMOBILE_CPU_TYPE_R8A7793 ,"R8A7793" }, - {RMOBILE_CPU_TYPE_R8A7794 ,"R8A7794" }, - {RMOBILE_CPU_TYPE_R8A7795 ,"R8A7795" }, - {RMOBILE_CPU_TYPE_R8A7796 ,"R8A7796" }, - {RMOBILE_CPU_TYPE_R8A77965 ,"R8A77965" }, - {RMOBILE_CPU_TYPE_R8A77970 ,"R8A77970" }, - {RMOBILE_CPU_TYPE_R8A77980 ,"R8A77980" }, - {RMOBILE_CPU_TYPE_R8A77990 ,"R8A77990" }, - {RMOBILE_CPU_TYPE_R8A77995 ,"R8A77995" }, + {RMOBILE_CPU_TYPE_SH73A0 ,"SH73A0" ,SOC_SHMOBILE }, + {RMOBILE_CPU_TYPE_R8A7740 ,"R8A7740" ,SOC_RMOBILE }, + {RMOBILE_CPU_TYPE_R8A774A1 ,"R8A774A1" ,SOC_RZG2 }, + {RMOBILE_CPU_TYPE_R8A7790 ,"R8A7790" ,SOC_RCAR_GEN2 }, + {RMOBILE_CPU_TYPE_R8A7791 ,"R8A7791" ,SOC_RCAR_GEN2 }, + {RMOBILE_CPU_TYPE_R8A7792 ,"R8A7792" ,SOC_RCAR_GEN2 }, + {RMOBILE_CPU_TYPE_R8A7793 ,"R8A7793" ,SOC_RCAR_GEN2 }, + {RMOBILE_CPU_TYPE_R8A7794 ,"R8A7794" ,SOC_RCAR_GEN2 }, + {RMOBILE_CPU_TYPE_R8A7795 ,"R8A7795" ,SOC_RCAR_GEN3 }, + {RMOBILE_CPU_TYPE_R8A7796 ,"R8A7796" ,SOC_RCAR_GEN3 }, + {RMOBILE_CPU_TYPE_R8A77965 ,"R8A77965" ,SOC_RCAR_GEN3 }, + {RMOBILE_CPU_TYPE_R8A77970 ,"R8A77970" ,SOC_RCAR_GEN3 }, + {RMOBILE_CPU_TYPE_R8A77980 ,"R8A77980" ,SOC_RCAR_GEN3 }, + {RMOBILE_CPU_TYPE_R8A77990 ,"R8A77990" ,SOC_RCAR_GEN3 }, + {RMOBILE_CPU_TYPE_R8A77995 ,"R8A77995" ,SOC_RCAR_GEN3 }, {0x0 ,"CPU" }, }; +static const struct udevice_id *of_soc_match_compatible (void ) +{ +const struct udevice_id *of_match = soc_ids; +int i; + +for (i =0 ; i <ARRAY_SIZE (soc_ids); i++) { +if (!fdt_node_check_compatible (gd->fdt_blob,0 , + of_match->compatible)) +return of_match; + of_match++; + } + +return NULL ; +} +static int rmobile_cpuinfo_idx (void ) {int i =0 ;u32 cpu_type =rmobile_get_cpu_type (); +const struct udevice_id *match =of_soc_match_compatible (); +/* +* This loop identifies CPU based on PRR register, it differentiates +* RZ/G SoC's from R-Car SoC's by matching RZ/G SoC compatible string +* from DT against the family_type. +*/ for (; i <ARRAY_SIZE (rmobile_cpuinfo); i++) -if (rmobile_cpuinfo[i].cpu_type == cpu_type) -break ; +if (rmobile_cpuinfo[i].cpu_type == cpu_type) { +if (match && + rmobile_cpuinfo[i].family_type == match->data) +break ; +else if (!match && + rmobile_cpuinfo[i].family_type !=SOC_RZG2 ) +break ; + }return i; }
arch/arm/mach-rmobile/include/mach/rmobile.h +1 -0
@@ -27,6 +27,7 @@/* PRR CPU IDs */ #define RMOBILE_CPU_TYPE_SH73A0 0x37#define RMOBILE_CPU_TYPE_R8A7740 0x40 +#define RMOBILE_CPU_TYPE_R8A774A1 0x52#define RMOBILE_CPU_TYPE_R8A7790 0x45#define RMOBILE_CPU_TYPE_R8A7791 0x47#define RMOBILE_CPU_TYPE_R8A7792 0x4A
Signature · 1 line
2.17.1
PATCH 2/2 arm: rmobile: Add HopeRun HiHope RZ/G2M board support
The HiHope RZ/G2M board from HopeRun consists of main board (HopeRun HiHope RZ/G2M main board) and sub board(HopeRun HiHope RZ/G2M sub board). The HiHope RZ/G2M sub board sits below the HiHope RZ/G2M main board.
DTS files apart from r8a774a1-hihope-rzg2m-u-boot.dts and r8a774a1-u-boot.dtsi have been imported from Linux kernel 5.9-rc4 commit f4d51dffc6c0 ("Linux 5.9-rc4")
This patch adds the required board support to boot HopeRun HiHope RZ/G2M board.
---
V1-->V2
* Fixed indentation for R8A774A1 config
* Used GPIO hog for setting WLAN/BT REG ON
* Removed USB related initialization
--- arch/arm/dts/Makefile | 1 + arch/arm/dts/hihope-common.dtsi | 377 ++++++++++++++++++ arch/arm/dts/hihope-rev4.dtsi | 124 ++++++ arch/arm/dts/hihope-rzg2-ex.dtsi | 93 +++++ arch/arm/dts/r8a774a1-hihope-rzg2m-ex.dts | 21 + arch/arm/dts/r8a774a1-hihope-rzg2m-u-boot.dts | 27 ++ arch/arm/dts/r8a774a1-hihope-rzg2m.dts | 37 ++ arch/arm/dts/r8a774a1-u-boot.dtsi | 55 +++ arch/arm/mach-rmobile/Kconfig.64 | 16 +- board/hoperun/hihope-rzg2/Kconfig | 15 + board/hoperun/hihope-rzg2/MAINTAINERS | 6 + board/hoperun/hihope-rzg2/Makefile | 9 + board/hoperun/hihope-rzg2/hihope-rzg2.c | 80 ++++ configs/hihope_rzg2_defconfig | 74 ++++ include/configs/hihope-rzg2.h | 20 + 15 files changed, 954 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/hihope-common.dtsi create mode 100644 arch/arm/dts/hihope-rev4.dtsi create mode 100644 arch/arm/dts/hihope-rzg2-ex.dtsi create mode 100644 arch/arm/dts/r8a774a1-hihope-rzg2m-ex.dts create mode 100644 arch/arm/dts/r8a774a1-hihope-rzg2m-u-boot.dts create mode 100644 arch/arm/dts/r8a774a1-hihope-rzg2m.dts create mode 100644 arch/arm/dts/r8a774a1-u-boot.dtsi create mode 100644 board/hoperun/hihope-rzg2/Kconfig create mode 100644 board/hoperun/hihope-rzg2/MAINTAINERS create mode 100644 board/hoperun/hihope-rzg2/Makefile create mode 100644 board/hoperun/hihope-rzg2/hihope-rzg2.c create mode 100644 configs/hihope_rzg2_defconfig create mode 100644 include/configs/hihope-rzg2.h
arch/arm/dts/Makefile +1 -0
@@ -784,6 +784,7 @@ dtb-$(CONFIG_RCAR_GEN2) += \ dtb-$(CONFIG_RCAR_GEN3) += \ r8a774a1-beacon-rzg2m-kit.dtb \ + r8a774a1-hihope-rzg2m-u-boot.dtb \ r8a77950-ulcb-u-boot.dtb \ r8a77950-salvator-x-u-boot.dtb \ r8a77960-ulcb-u-boot.dtb \
arch/arm/dts/hihope-common.dtsi new file +377 -0
377 lines not on this page · raw message
arch/arm/dts/hihope-rev4.dtsi new file +124 -0
124 lines not on this page · raw message
arch/arm/dts/hihope-rzg2-ex.dtsi new file +93 -0
93 lines not on this page · raw message
arch/arm/dts/r8a774a1-hihope-rzg2m-ex.dts new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device Tree Source for the HiHope RZ/G2M Rev.3.0/4.0 connected to + * sub board + * + * Copyright (C) 2020 Renesas Electronics Corp. + */ + +#include "r8a774a1-hihope-rzg2m.dts" +#include "hihope-rzg2-ex.dtsi" + +/ { + model = "HopeRun HiHope RZ/G2M with sub board"; + compatible = "hoperun,hihope-rzg2-ex", "hoperun,hihope-rzg2m", + "renesas,r8a774a1"; +}; + +/* SW43 should be OFF, if in ON state SATA port will be activated */ +&pciec1 { + status = "okay"; +};
arch/arm/dts/r8a774a1-hihope-rzg2m-u-boot.dts new file +27 -0
@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device Tree Source extras for U-Boot for the Hihope RZ/G2M board + * + * Copyright (C) 2020 Renesas Electronics Corporation + */ + +#include "r8a774a1-hihope-rzg2m-ex.dts" +#include "r8a774a1-u-boot.dtsi" + +&gpio3 { + bt_reg_on{ + gpio-hog; + gpios = <13 GPIO_ACTIVE_HIGH>; + output-low; + line-name = "bt-reg-on"; + }; +}; + +&gpio4 { + wlan_reg_on{ + gpio-hog; + gpios = <6 GPIO_ACTIVE_HIGH>; + output-low; + line-name = "wlan-reg-on"; + }; +};
arch/arm/dts/r8a774a1-hihope-rzg2m.dts new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device Tree Source for the HiHope RZ/G2M Rev.3.0/4.0 main board + * + * Copyright (C) 2020 Renesas Electronics Corp. + */ + +/dts-v1/; +#include "r8a774a1.dtsi" +#include "hihope-rev4.dtsi" + +/ { + model = "HopeRun HiHope RZ/G2M main board based on r8a774a1"; + compatible = "hoperun,hihope-rzg2m", "renesas,r8a774a1"; + + memory at 48000000 { + device_type = "memory"; + /* first 128MB is reserved for secure area. */ + reg = <0x0 0x48000000 0x0 0x78000000>; + }; + + memory at 600000000 { + device_type = "memory"; + reg = <0x6 0x00000000 0x0 0x80000000>; + }; +}; + +&du { + clocks = <&cpg CPG_MOD 724>, + <&cpg CPG_MOD 723>, + <&cpg CPG_MOD 722>, + <&versaclock5 1>, + <&x302_clk>, + <&versaclock5 2>; + clock-names = "du.0", "du.1", "du.2", + "dclkin.0", "dclkin.1", "dclkin.2"; +};
arch/arm/dts/r8a774a1-u-boot.dtsi new file +55 -0
55 lines not on this page · raw message
arch/arm/mach-rmobile/Kconfig.64 +15 -1
@@ -3,7 +3,9 @@ if RCAR_GEN3 menu "Select Target SoC" config R8A774A1 - bool "Renesas SoC R8A774A1" + bool "Renesas SoC R8A774A1" + imply CLK_R8A774A1 + imply PINCTRL_PFC_R8A774A1 config R8A7795 bool "Renesas SoC R8A7795"
@@ -75,6 +77,15 @@ config TARGET_EBISU help Support for Renesas R-Car Gen3 Ebisu platform +config TARGET_HIHOPE_RZG2 + bool "HiHope RZ/G2 board" + imply R8A774A1 + imply SYS_MALLOC_F + imply MULTI_DTB_FIT + imply MULTI_DTB_FIT_USER_DEFINED_AREA + help + Support for RZG2 HiHope platform + config TARGET_SALVATOR_X bool "Salvator-X board" imply R8A7795
@@ -109,12 +120,15 @@ source "board/renesas/ebisu/Kconfig" source "board/renesas/salvator-x/Kconfig" source "board/renesas/ulcb/Kconfig" source "board/beacon/beacon-rzg2m/Kconfig" +source "board/hoperun/hihope-rzg2/Kconfig" config MULTI_DTB_FIT_UNCOMPRESS_SZ + default 0x80000 if TARGET_HIHOPE_RZG2 default 0x80000 if TARGET_SALVATOR_X default 0x80000 if TARGET_ULCB config MULTI_DTB_FIT_USER_DEF_ADDR + default 0x49000000 if TARGET_HIHOPE_RZG2 default 0x49000000 if TARGET_SALVATOR_X default 0x49000000 if TARGET_ULCB
board/hoperun/hihope-rzg2/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +if TARGET_HIHOPE_RZG2 + +config SYS_SOC + default "rmobile" + +config SYS_BOARD + default "hihope-rzg2" + +config SYS_VENDOR + default "hoperun" + +config SYS_CONFIG_NAME + default "hihope-rzg2" + +endif
board/hoperun/hihope-rzg2/MAINTAINERS new file +6 -0
@@ -0,0 +1,6 @@ +HIHOPE_RZG2 BOARD +M: Biju Das <[email protected]> +S: Maintained +F: board/hoperun/hihope-rzg2/ +F: include/configs/hihope-rzg2.h +F: configs/hihope_rzg2_defconfig
board/hoperun/hihope-rzg2/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# +# board/hoperun/hihope-rzg2/Makefile +# +# Copyright (C) 2020 Renesas Electronics Corporation +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y := hihope-rzg2.o
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +80 -0
80 lines not on this page · raw message
configs/hihope_rzg2_defconfig new file +74 -0
74 lines not on this page · raw message
include/configs/hihope-rzg2.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* include/configs/hihope-rzg2.h +* This file is HOPERUN HiHope RZ/G2 board configuration. +* +* Copyright (C) 2020 Renesas Electronics Corporation +*/ + +#ifndef __HIHOPE_RZG2_H +#define __HIHOPE_RZG2_H + +#include "rcar-gen3-common.h" + +/* Ethernet RAVB */ +#define CONFIG_BITBANGMII_MULTI + +/* Generic Timer Definitions (use in assembler source) */ +#define COUNTER_FREQUENCY 0xFE502A/* 16.66MHz from CPclk */ + +#endif /* __HIHOPE_RZG2_H */
Signature · 1 line
2.17.1
PATCH 2/2 arm: rmobile: Add HopeRun HiHope RZ/G2M board support
On 9/18/20 6:03 PM, Biju Das wrote:
[...]
Quoted 2 lines
+++
b/board/hoperun/hihope-rzg2/hihope-rzg2.c(quoted diff) +0
-0@@ -0,0 +1,80 @@
[...]
board/hoperun/hihope-rzg2/hihope-rzg2.c line 25
Quoted 12 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +12
-0+#define RST_BASE 0xE6160000 +#define RST_CA57RESCNT (RST_BASE + 0x40) +#define RST_CODE 0xA5A5000F + +/* If the firmware passed a device tree use it for U-Boot DRAM setup. */ +extern u64 rcar_atf_boot_args[]; + +DECLARE_GLOBAL_DATA_PTR ; + +void s_init (void ) +{ +}
Is this empty function needed ?
board/hoperun/hihope-rzg2/hihope-rzg2.c line 28
Quoted 2 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +2
-0+#ifdef CONFIG_BOARD_EARLY_INIT_F +/* Kconfig forces this on, so just return 0 */
I think BOARD_EARLY_INIT_F should really be disabled in Kconfig rather than implementing empty function here.
Quoted 5 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +5
-0+int board_early_init_f (void ) +{ +return 0 ; +} +#endif
[...]
board/hoperun/hihope-rzg2/hihope-rzg2.c line 51
Quoted 9 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +9
-0+int fdtdec_board_setup (const void *fdt_blob) +{ +void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1 ]); + +if (fdt_magic (atf_fdt_blob) ==FDT_MAGIC ) +fdt_overlay_apply_node ((void *)fdt_blob,0 , atf_fdt_blob,0 ); + +return 0 ; +}
Please use board/renesas/rcar-common/common.c , no need to duplicate the code.
Quoted 4 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +4
-0+int dram_init (void ) +{ +return fdtdec_setup_mem_size_base (); +}
board/hoperun/hihope-rzg2/hihope-rzg2.c line 66
Quoted 10 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +10
-0+ +int dram_init_banksize (void ) +{ +return fdtdec_setup_memory_banksize (); +} + +void reset_cpu (ulong addr) +{ +writel (RST_CODE ,RST_CA57RESCNT ); +}
Isn't there CA53 core in the RZG2 too ?
[...]
PATCH 2/2 arm: rmobile: Add HopeRun HiHope RZ/G2M board support
Hi Marek,
Thanks for the feedback.
Quoted 10 lines
Subject: Re: [PATCH 2/2] arm: rmobile: Add HopeRun HiHope RZ/G2M board support
On 9/18/20 6:03 PM, Biju Das wrote:
[...]
Quoted 2 lines
+++
b/board/hoperun/hihope-rzg2/hihope-rzg2.c(quoted diff) +0
-0@@ -0,0 +1,80 @@[...]
Quoted 14 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 25
Quoted 12 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +12
-0+#define RST_BASE0xE6160000 +#define RST_CA57RESCNT(RST_BASE + 0x40) +#define RST_CODE0xA5A5000F + +/* If the firmware passed a device tree use it for U-Boot DRAM setup. +*/ extern u64 rcar_atf_boot_args[]; + +DECLARE_GLOBAL_DATA_PTR ; + +void s_init (void ) +{ +}Is this empty function needed ?
Yes Compilation error otherwise. This function is called from lowlevel_init_gen3.S. I believe it is place holder for doing some early initialisation such as watchdog That could be the reason all rcar gen3 boards have this empty function for eg:-[1], please correct me if you think otherwise.
[1] board/renesas/salvator-x/Salvator-x.c
Quoted 6 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 28
Quoted 2 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +2
-0+#ifdef CONFIG_BOARD_EARLY_INIT_F +/* Kconfig forces this on, so just return 0 */ I think
BOARD_EARLY_INIT_Fshould really be disabled inKconfigrather than implementing empty function here.
Ok, will fix in v2.
For eg:- file arch/arm/Kconfig
Select BOARD_EARLY_INIT_FUNCTION if !(RZA1 || TARGET_HIHOPE_RZG2)
I also noticed other boards in board/renesas directory with empty function(for eg:- ebisu,condor etc). For completeness, do you want me to fix that as well in separate patch and removing empty functions. Select BOARD_EARLY_INIT_FUNCTION if !(RZA1 || TARGET_HIHOPE_RZG2|| TARGET_EBISU || TARGET_CONDOR)
Quoted 15 lines
Quoted 5 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +5
-0+int board_early_init_f (void ) +{ +return 0 ; +} +#endif [...]
board/hoperun/hihope-rzg2/hihope-rzg2.c
Quoted 5 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +5
-0+int fdtdec_board_setup (const void *fdt_blob) { +void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1 ]); + +if (fdt_magic (atf_fdt_blob) ==FDT_MAGIC ) +fdt_overlay_apply_node((void *)fdt_blob, 0, atf_fdt_blob,0);
Quoted 6 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 32
Quoted 3 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +3
-0+ +return 0 ; +}Please use
board/renesas/rcar-common/common.c, no need to duplicate the code.
OK will fix in V3.
Quoted 6 lines
Quoted 6 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +6
-0+int dram_init (void ) +{ +return fdtdec_setup_mem_size_base (); } + +int dram_init_banksize (void ) +{
Quoted 8 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 66
Quoted 6 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +6
-0+return fdtdec_setup_memory_banksize (); } + +void reset_cpu (ulong addr) +{ +writel (RST_CODE ,RST_CA57RESCNT ); +}Isn't there CA53 core in the RZG2 too ?
Yes, big little CPU 2xCA57 + 4 xCA53. Do you want me to add reset code for in case of CA53 boot mode???
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 2/2 arm: rmobile: Add HopeRun HiHope RZ/G2M board support
On 9/19/20 2:18 PM, Biju Das wrote:
Hi,
[...]
Quoted 18 lines
Quoted 17 lines
Quoted 2 lines
+++
b/board/hoperun/hihope-rzg2/hihope-rzg2.c(quoted diff) +0
-0@@ -0,0 +1,80 @@[...]
board/hoperun/hihope-rzg2/hihope-rzg2.c line 25
Quoted 12 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +12
-0+#define RST_BASE0xE6160000 +#define RST_CA57RESCNT(RST_BASE + 0x40) +#define RST_CODE0xA5A5000F + +/* If the firmware passed a device tree use it for U-Boot DRAM setup. +*/ extern u64 rcar_atf_boot_args[]; + +DECLARE_GLOBAL_DATA_PTR ; + +void s_init (void ) +{ +}Is this empty function needed ?
Quoted 3 lines
Yes Compilation error otherwise. This function is called from
lowlevel_init_gen3.S. I believe it is place holder for doing some early initialisation such as watchdog That could be the reason all rcar gen3 boards have this empty function for eg:-[1], please correct me if you think otherwise.
[1]board/renesas/salvator-x/Salvator-x.c
Can you try fixing that with WEAK(s_init) in the lowlevel_init_gen3.S ? I think that would be much better, if anyone needs to override the function, then they can, otherwise empty WEAK function would be used.
Quoted 11 lines
Quoted 6 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 28
Quoted 2 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +2
-0+#ifdef CONFIG_BOARD_EARLY_INIT_F +/* Kconfig forces this on, so just return 0 */ I think
BOARD_EARLY_INIT_Fshould really be disabled inKconfigrather than implementing empty function here.Ok, will fix in v2.
For eg:- file
arch/arm/Kconfig
SelectBOARD_EARLY_INIT_FUNCTIONif !(RZA1 ||TARGET_HIHOPE_RZG2)
Maybe it would be better to use imply BOARD_EARLY_INIT_F , and then disable it on boards which don't need it (RZA1 and RZG2)
Quoted 3 lines
I also noticed other boards in board/renesas directory with empty
function(for eg:- ebisu,condor etc). For completeness, do you want me to fix that as well in separate patch and removing empty functions. SelectBOARD_EARLY_INIT_FUNCTIONif !(RZA1 || TARGET_HIHOPE_RZG2||TARGET_EBISU||TARGET_CONDOR)
Look at the 'imply' keyword, that might be even better.
[...]
Quoted 6 lines
Quoted 6 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c
Quoted 5 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +5
-0+int fdtdec_board_setup (const void *fdt_blob) { +void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1 ]); + +if (fdt_magic (atf_fdt_blob) ==FDT_MAGIC ) +fdt_overlay_apply_node((void *)fdt_blob, 0, atf_fdt_blob,0);
Quoted 8 lines
Quoted 6 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 32
Quoted 3 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +3
-0+ +return 0 ; +}Please use
board/renesas/rcar-common/common.c, no need to duplicate the code.OK will fix in V3.
Thanks
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +6
-0+int dram_init (void ) +{ +return fdtdec_setup_mem_size_base (); } + +int dram_init_banksize (void ) +{Quoted 8 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 66
Quoted 6 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +6
-0+return fdtdec_setup_memory_banksize (); } + +void reset_cpu (ulong addr) +{ +writel (RST_CODE ,RST_CA57RESCNT ); +}Isn't there CA53 core in the RZG2 too ?
Quoted 1 line
Yes, big little CPU 2xCA57 + 4 xCA53. Do you want me to add reset code for in case of CA53 boot mode???
I think if you can start U-Boot on either core, then the reset function should handle both, yes.
PATCH 2/2 arm: rmobile: Add HopeRun HiHope RZ/G2M board support
Hi Marek,
Thanks for the feedback.
Quoted 29 lines
Subject: Re: [PATCH 2/2] arm: rmobile: Add HopeRun HiHope RZ/G2M board support
On 9/19/20 2:18 PM, Biju Das wrote:
Hi,
[...]
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
+++
b/board/hoperun/hihope-rzg2/hihope-rzg2.c(quoted diff) +0
-0@@ -0,0 +1,80 @@[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+#define RST_BASE0xE6160000 +#define RST_CA57RESCNT(RST_BASE + 0x40) #define
RST_CODE0xA5A5000FQuoted 12 lines
Quoted 11 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 25
Quoted 9 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +9
-0+ +/* If the firmware passed a device tree use it for U-Boot DRAM setup. +*/ extern u64 rcar_atf_boot_args[]; + +DECLARE_GLOBAL_DATA_PTR ; + +void s_init (void ) +{ +}Is this empty function needed ?
Quoted 2 lines
Yes Compilation error otherwise. This function is called from
lowlevel_init_gen3.S. I believe it is place holder for doing some early
Quoted 8 lines
initialisation such as watchdog That could be the reason all rcar gen3 boards have this empty function for eg:-[1], please correct me if you think otherwise.
Quoted 1 line
[1]
board/renesas/salvator-x/Salvator-x.cCan you try fixing that with
WEAK(s_init)in thelowlevel_init_gen3.S? I think that would be much better, if anyone needs to override the function, then they can, otherwise empty WEAK function would be used.
OK. Will add weak function in lowlevel_init_gen3.S.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
+#ifdef
CONFIG_BOARD_EARLY_INIT_FQuoted 1 line
+/*
Kconfigforces this on, so just return 0 */I think
BOARD_EARLY_INIT_Fshould really be disabled inKconfigrather than implementing empty function here.
Quoted 8 lines
Quoted 4 lines
Ok, will fix in v2.
For eg:- file
arch/arm/Kconfig
SelectBOARD_EARLY_INIT_FUNCTIONif !(RZA1 ||
TARGET_HIHOPE_RZG2)Maybe it would be better to use imply
BOARD_EARLY_INIT_F, and then disable it on boards which don't need it (RZA1 and RZG2)
OK Will fix this in V3.
Quoted 9 lines
Quoted 1 line
I also noticed other boards in board/renesas directory with empty
function(for eg:- ebisu,condor etc).Quoted 1 line
For completeness, do you want me to fix that as well in separate patch and
removing empty functions.
Quoted 1 line
Select
BOARD_EARLY_INIT_FUNCTIONif !(RZA1 ||TARGET_HIHOPE_RZG2||
Quoted 1 line
TARGET_EBISU||TARGET_CONDOR)Look at the 'imply' keyword, that might be even better.
Will send separate patch for this.
Quoted 35 lines
[...]
Quoted 11 lines
Quoted 11 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+int fdtdec_board_setup(const void *fdt_blob) { void *atf_fdt_blob = +(void *)(rcar_atf_boot_args[1]); + +if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) +fdt_overlay_apply_node((void *)fdt_blob, 0, atf_fdt_blob,0);
board/hoperun/hihope-rzg2/hihope-rzg2.c line 32
Quoted 3 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +3
-0+ +return 0 ; +}Please use
board/renesas/rcar-common/common.c, no need toduplicate
Quoted 3 lines
Quoted 1 line
the code.
OK will fix in V3.
Thanks
Quoted 15 lines
Quoted 14 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 66
Quoted 12 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +12
-0+int dram_init (void ) +{ +return fdtdec_setup_mem_size_base (); } + +int dram_init_banksize (void ) +{ +return fdtdec_setup_memory_banksize (); } + +void reset_cpu (ulong addr) +{ +writel (RST_CODE ,RST_CA57RESCNT ); +}Isn't there CA53 core in the RZG2 too ?
Quoted 5 lines
Quoted 1 line
Yes, big little CPU 2xCA57 + 4 xCA53. Do you want me to add reset code for
in case of CA53 boot mode???
I think if you can start U-Boot on either core, then the reset function should handle both, yes.
OK. Will fix this in V3.
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 2/2 arm: rmobile: Add HopeRun HiHope RZ/G2M board support
On 9/19/20 8:38 PM, Biju Das wrote:
[...]
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c line 66
Quoted 12 lines
board/hoperun/hihope-rzg2/hihope-rzg2.c new file +12
-0+int dram_init (void ) +{ +return fdtdec_setup_mem_size_base (); } + +int dram_init_banksize (void ) +{ +return fdtdec_setup_memory_banksize (); } + +void reset_cpu (ulong addr) +{ +writel (RST_CODE ,RST_CA57RESCNT ); +}Isn't there CA53 core in the RZG2 too ?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Yes, big little CPU 2xCA57 + 4 xCA53. Do you want me to add reset code for
in case of CA53 boot mode???
I think if you can start U-Boot on either core, then the reset function should handle both, yes.
OK. Will fix this in V3.
Thanks
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
In reply to Biju DasQuoted 1 line · Biju Das
Add CPU and PRR IDs for R8A774A1(a.k.a RZ/G2M) SoC.
[...]
Quoted 4 lines
arch/arm/mach-rmobile/cpu_info.c +4
-0+static const struct udevice_id *of_soc_match_compatible (void ) +{ +const struct udevice_id *of_match = soc_ids; +int i;
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void) · line 108
Quoted 10 lines
arch/arm/mach-rmobile/cpu_info.c +10
-0+ +for (i =0 ; i <ARRAY_SIZE (soc_ids); i++) { +if (!fdt_node_check_compatible (gd->fdt_blob,0 , + of_match->compatible)) +return of_match; + of_match++; + } + +return NULL ; +}
This should rather be a generic function, I think this is something that already exists in Linux common code too, right ?
Quoted 12 lines
static int
rmobile_cpuinfo_idx(void)
{arch/arm/mach-rmobile/cpu_info.c +6
-0int i =0 ;u32 cpu_type =rmobile_get_cpu_type (); +const struct udevice_id *match =of_soc_match_compatible (); +/* +* This loop identifies CPU based on PRR register, it differentiates +* RZ/G SoC's from R-Car SoC's by matching RZ/G SoC compatible string +* from DT against the family_type. +*/ for (; i <ARRAY_SIZE (rmobile_cpuinfo); i++)
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void) · line 129
Quoted 10 lines
arch/arm/mach-rmobile/cpu_info.c +8
-2-if (rmobile_cpuinfo[i].cpu_type == cpu_type) -break ; +if (rmobile_cpuinfo[i].cpu_type == cpu_type) { +if (match && + rmobile_cpuinfo[i].family_type == match->data) +break ; +else if (!match && + rmobile_cpuinfo[i].family_type !=SOC_RZG2 ) +break ; + }
I still don't understand this, so if cpu_type == RMOBILE_CPU_TYPE_R8A7796 , then it can be either RZG2 or R8A7796, right? And there is no PRR bit or any other bit to tell those two chips apart ?
I would like to avoid using the OF match here, because that fails if you use MULTI_DTB_FIT , does it not ? So can you please check whether there might be some way to tell the two SoCs apart ?
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
Hi Marek,
Thanks for the feedback.
Quoted 7 lines
Subject: Re: [PATCH 1/2] arm: rmobile: Add RZ/G2M SoC
Quoted 1 line · Biju Das
Add CPU and PRR IDs for R8A774A1(a.k.a RZ/G2M) SoC.
[...]
Quoted 16 lines
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void) · line 108
Quoted 13 lines
arch/arm/mach-rmobile/cpu_info.c +13
-0+static const struct udevice_id *of_soc_match_compatible (void ) { +const struct udevice_id *of_match = soc_ids; +int i; + +for (i =0 ; i <ARRAY_SIZE (soc_ids); i++) { +if (!fdt_node_check_compatible (gd->fdt_blob,0 , + of_match->compatible)) +return of_match; +of_match++; +} + +return NULL ; +}This should rather be a generic function, I think this is something that already exists in Linux common code too, right ?
No. I have seen some other SoC's uses similar logic [1]& [2] .
[1] https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/board/samsung/common/exynos5-dt-types.c#L246
[2] https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/arch/arm/mach-uniphier/boards.c#L156
Quoted 22 lines
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void)
Quoted 9 lines
static int
rmobile_cpuinfo_idx(void)
{
int i = 0;
u32cpu_type=rmobile_get_cpu_type();arch/arm/mach-rmobile/cpu_info.c +4
-0+const struct udevice_id *match =of_soc_match_compatible (); +/* +* This loop identifies CPU based on PRR register, it differentiates +* RZ/G SoC's from R-Car SoC's by matching RZ/G SoC compatible string
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void)
Quoted 11 lines
+ * from DT against the
family_type.
+ */
for (; i <ARRAY_SIZE(rmobile_cpuinfo); i++)arch/arm/mach-rmobile/cpu_info.c +6
-2-if (rmobile_cpuinfo[i].cpu_type == cpu_type) -break ; +if (rmobile_cpuinfo[i].cpu_type == cpu_type) { +if (match && + rmobile_cpuinfo[i].family_type == match->data) +break; +else if (!match && + rmobile_cpuinfo[i].family_type !=
SOC_RZG2)
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+break; +}I still don't understand this, so if
cpu_type==RMOBILE_CPU_TYPE_R8A7796, then it can be either RZG2 or R8A7796, right?
Yep you are right.
Quoted 1 line
And there is no PRR bit or any other bit to tell those two chips apart ?
No. Currently only way you can distinguish is by SoC compatible string and family type.
See [3] for SoC identification logic used to differentiate RCar and RZ/G2
[3]:- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/soc/renesas/renesas-soc.c?h=v5.9-rc5#n311
Quoted 2 lines
I would like to avoid using the OF match here, because that fails if you use
MULTI_DTB_FIT, does it not ?
No. It works OK on both RZ/G2SoC's[4] and RCar[5]
[4] MULTI_DTB_FIT logs for RZG2[HMN] boards
CPU: Renesas Electronics R8A774E1 rev 3.0
Model: HopeRun HiHope RZ/G2H with sub board
DRAM: 3.9 GiB
CPU: Renesas Electronics R8A774A1 rev 1.3
Model: HopeRun HiHope RZ/G2M with sub board
DRAM: 3.9 GiB
CPU: Renesas Electronics R8A774B1 rev 1.1
Model: HopeRun HiHope RZ/G2N with sub board
DRAM: 3.9 GiB
[5] u-boot based on R-Car M3N using rcar3_salvator-x_defconfig, it reports proper SoC.
CPU: Renesas Electronics R8A77965 rev 1.1
Model: Renesas Salvator-XS board based on r8a77965
DRAM: 1.9 GiB
Bank #0: 0x048000000 - 0x0bfffffff, 1.9 GiB
MMC: sd at ee100000: 0, sd at ee140000: 1, sd at ee160000: 2 Loading Environment from MMC... OK
In: serial at e6e88000
Out: serial at e6e88000
Err: serial at e6e88000
Net: eth0: ethernet at e6800000
Hit any key to stop autoboot: 0
=>
So can you please check whether there might
Quoted 1 line
be some way to tell the two SoCs apart ?
At present there is no way other than matching the SoC compatible string.
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
On 9/19/20 1:37 PM, Biju Das wrote:
[...]
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-rmobile/cpu_info.c +8
-0+static const struct udevice_id *of_soc_match_compatible (void ) { +const struct udevice_id *of_match = soc_ids; +int i; + +for (i =0 ; i <ARRAY_SIZE (soc_ids); i++) { +if (!fdt_node_check_compatible (gd->fdt_blob,0 , + of_match->compatible)) +return of_match;Quoted 8 lines
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void) · line 108
Quoted 5 lines
arch/arm/mach-rmobile/cpu_info.c +5
-0+of_match++; +} + +return NULL ; +}This should rather be a generic function, I think this is something that already exists in Linux common code too, right ?
Quoted 1 line
No. I have seen some other SoC's uses similar logic [1]& [2] .
I mean, this looks like Linux's soc_device_match() , so such a function is likely generic code, there is nothing platform specific to it, is there ?
Quoted 32 lines
[1] https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/board/samsung/common/exynos5-dt-types.c#L246
[2] https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/arch/arm/mach-uniphier/boards.c#L156Quoted 22 lines
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void)
Quoted 9 lines
static int
rmobile_cpuinfo_idx(void)
{
int i = 0;
u32cpu_type=rmobile_get_cpu_type();arch/arm/mach-rmobile/cpu_info.c +4
-0+const struct udevice_id *match =of_soc_match_compatible (); +/* +* This loop identifies CPU based on PRR register, it differentiates +* RZ/G SoC's from R-Car SoC's by matching RZ/G SoC compatible string
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void)
Quoted 11 lines
+ * from DT against the
family_type.
+ */
for (; i <ARRAY_SIZE(rmobile_cpuinfo); i++)arch/arm/mach-rmobile/cpu_info.c +6
-2-if (rmobile_cpuinfo[i].cpu_type == cpu_type) -break ; +if (rmobile_cpuinfo[i].cpu_type == cpu_type) { +if (match && + rmobile_cpuinfo[i].family_type == match->data) +break; +else if (!match && + rmobile_cpuinfo[i].family_type !=
SOC_RZG2)Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+break; +}I still don't understand this, so if
cpu_type==RMOBILE_CPU_TYPE_R8A7796, then it can be either RZG2 or R8A7796, right?
Quoted 6 lines
Yep you are right.
Quoted 1 line
And there is no PRR bit or any other bit to tell those two chips apart ?
No. Currently only way you can distinguish is by SoC compatible string and family type.
See [3] for SoC identification logic used to differentiate RCar and RZ/G2
[3]:- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/soc/renesas/renesas-soc.c?h=v5.9-rc5#n311
So Linux is matching on the compatible string of DT passed from U-Boot , right ? Linux has it easier then.
But where does U-Boot get that compatible string from, in case there are multiple DTs passed to U-Boot and U-Boot needs to find out on which SoC it is running on ?
Maybe you can pass the compatible from TFA, which is already happening.
Quoted 35 lines
Quoted 2 lines
I would like to avoid using the OF match here, because that fails if you use
MULTI_DTB_FIT, does it not ?No. It works OK on both RZ/G2SoC's[4] and RCar[5]
[4]
MULTI_DTB_FITlogs for RZG2[HMN] boardsCPU: Renesas Electronics R8A774E1 rev 3.0
Model: HopeRun HiHope RZ/G2H with sub board
DRAM: 3.9 GiBCPU: Renesas Electronics R8A774A1 rev 1.3
Model: HopeRun HiHope RZ/G2M with sub board
DRAM: 3.9 GiBCPU: Renesas Electronics R8A774B1 rev 1.1
Model: HopeRun HiHope RZ/G2N with sub board
DRAM: 3.9 GiB[5] u-boot based on R-Car M3N using rcar3_salvator-x_defconfig, it reports proper SoC.
CPU: Renesas Electronics R8A77965 rev 1.1
Model: Renesas Salvator-XS board based on r8a77965
DRAM: 1.9 GiB
Bank #0:0x048000000-0x0bfffffff, 1.9 GiBMMC: sd at
ee100000: 0, sd atee140000: 1, sd atee160000: 2 Loading Environment from MMC... OK
In: serial ate6e88000
Out: serial ate6e88000
Err: serial ate6e88000
Net: eth0: ethernet ate6800000
Hit any key to stop autoboot: 0
=>
Quoted 4 lines
So can you please check whether there might
Quoted 1 line
be some way to tell the two SoCs apart ?
At present there is no way other than matching the SoC compatible string.
Thinking about it a bit more, if you were to use the compatible string psssed from TFA in the / node, you could iterate over soc_ids[] array and return RMOBILE_CPU_TYPE_x , which could be stored there as .data . Then you won't even need the SOC_RZG2 and it would all be faster, as all you would need is a single pass over a smaller array.
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
Hi Marek,
Thanks for the feedback.
Quoted 20 lines
Subject: Re: [PATCH 1/2] arm: rmobile: Add RZ/G2M SoC
On 9/19/20 1:37 PM, Biju Das wrote:
[...]Quoted 16 lines
Quoted 15 lines
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void) · line 108
Quoted 12 lines
arch/arm/mach-rmobile/cpu_info.c +12
-0+static const struct udevice_id *of_soc_match_compatible (void ) { +const struct udevice_id *of_match = soc_ids;int i; + +for (i =0 ; i <ARRAY_SIZE (soc_ids); i++) {if +(!fdt_node_check_compatible (gd->fdt_blob,0 , + of_match->compatible)) +return of_match; +of_match++; +} + +return NULL ; +}This should rather be a generic function, I think this is something that already exists in Linux common code too, right ?
Quoted 4 lines
Quoted 1 line
No. I have seen some other SoC's uses similar logic [1]& [2] .
I mean, this looks like Linux's
soc_device_match(), so such a function is likely generic code, there is nothing platform specific to it, is there ?
I agree, we need to have a new generic api for such purpose. The Linux/U-boot soc_device_match is for adding quirks with in different ES version of same SoC.
What we here need is similar to of_match_compatible for array of different SoC's. Can you please confirm [1] drivers/soc/soc-uclass.c is the right place for such generic api?
[1] https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/drivers/soc/soc-uclass.c
Quoted 90 lines
Quoted 29 lines
[1]
https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/board/samsung/co
mmon/exynos5-dt-types.c#L246 [2]
https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/arch/arm/mach-un
iphier/boards.c#L156Quoted 22 lines
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void)
Quoted 8 lines
static int
rmobile_cpuinfo_idx(void){ int i = 0; u32cpu_type=rmobile_get_cpu_type();arch/arm/mach-rmobile/cpu_info.c +5
-0+const struct udevice_id *match =of_soc_match_compatible (); +/* +* This loop identifies CPU based on PRR register, it +differentiates +* RZ/G SoC's from R-Car SoC's by matching RZ/G SoC compatible string
Review
Quoted 7 lines
+ * from DT against the
family_type.
+ */
for (; i <ARRAY_SIZE(rmobile_cpuinfo); i++) -if
(rmobile_cpuinfo[i].cpu_type ==cpu_type) -break;(quoted diff) +3
-0+if (rmobile_cpuinfo[i].cpu_type == cpu_type) { if (match && + rmobile_cpuinfo[i].family_type == match->data) break; else if +(!match && rmobile_cpuinfo[i].family_type !=
SOC_RZG2)Review
Quoted 2 lines
(quoted diff) +2
-0+break; +}I still don't understand this, so if
cpu_type==RMOBILE_CPU_TYPE_R8A7796, then it can be either RZG2 or R8A7796,right?
Quoted 5 lines
Yep you are right.
Quoted 1 line
And there is no PRR bit or any other bit to tell those two chips apart ?
No. Currently only way you can distinguish is by SoC compatible string and
family type.
Quoted 5 lines
See [3] for SoC identification logic used to differentiate RCar and RZ/G2
[3]:-
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tre
e/drivers/soc/renesas/renesas-soc.c?h=v5.9-rc5#n311So Linux is matching on the compatible string of DT passed from U-Boot , right ? Linux has it easier then.
But where does U-Boot get that compatible string from, in case there are multiple DTs passed to U-Boot and U-Boot needs to find out on which SoC it is running on ?
Maybe you can pass the compatible from TFA, which is already happening.
Quoted 15 lines
Quoted 2 lines
I would like to avoid using the OF match here, because that fails if you use
MULTI_DTB_FIT, does it not ?No. It works OK on both RZ/G2SoC's[4] and RCar[5]
[4]
MULTI_DTB_FITlogs for RZG2[HMN] boardsCPU: Renesas Electronics R8A774E1 rev 3.0
Model: HopeRun HiHope RZ/G2H with sub board
DRAM: 3.9 GiBCPU: Renesas Electronics R8A774A1 rev 1.3
Model: HopeRun HiHope RZ/G2M with sub board
DRAM: 3.9 GiBQuoted 5 lines
CPU: Renesas Electronics R8A774B1 rev 1.1
Model: HopeRun HiHope RZ/G2N with sub board
DRAM: 3.9 GiB[5] u-boot based on R-Car M3N using rcar3_salvator-x_defconfig, it reports
proper SoC.
Quoted 18 lines
CPU: Renesas Electronics R8A77965 rev 1.1
Model: Renesas Salvator-XS board based on r8a77965
DRAM: 1.9 GiB
Bank #0:0x048000000-0x0bfffffff, 1.9 GiBMMC: sd at
ee100000: 0, sd atee140000: 1, sd atee160000: 2 Loading Environment from MMC... OK
In: serial ate6e88000
Out: serial ate6e88000
Err: serial ate6e88000
Net: eth0: ethernet ate6800000
Hit any key to stop autoboot: 0
=>So can you please check whether there might
Quoted 1 line
be some way to tell the two SoCs apart ?
Quoted 7 lines
Quoted 1 line
At present there is no way other than matching the SoC compatible string.
Thinking about it a bit more, if you were to use the compatible string psssed from TFA in the / node, you could iterate over soc_ids[] array and return
RMOBILE_CPU_TYPE_x, which could be stored there as .data .
Then you won't even need theSOC_RZG2and it would all be faster, as all you would need is a single pass over a smaller array.
Good point. Ok will get rid of SOC_RZG2, will use smaller array forRZG2.
Are you suggesting to modify "arch_misc_init" directly set "platform" environment variable using match logic, which use a smaller array Compared to rmobile_cpuinfo.
Basically we match the compatible string from TFA, .data from " RMOBILE_CPU_TYPE_x" matched against PRR values and set the platform type .
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
On 9/19/20 8:35 PM, Biju Das wrote:
Hi,
[...]
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +7
-0+static const struct udevice_id *of_soc_match_compatible(void) { +const struct udevice_id *of_match = soc_ids; int i; + +for (i = 0; i < ARRAY_SIZE(soc_ids); i++) { if +(!fdt_node_check_compatible(gd->fdt_blob, 0, + of_match->compatible)) +return of_match;Quoted 8 lines
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void) · line 108
Quoted 5 lines
arch/arm/mach-rmobile/cpu_info.c +5
-0+of_match++; +} + +return NULL ; +}This should rather be a generic function, I think this is something that already exists in Linux common code too, right ?
No. I have seen some other SoC's uses similar logic [1]& [2] .
Quoted 7 lines
Quoted 2 lines
I mean, this looks like Linux's
soc_device_match(), so such a function is likely generic code, there is nothing platform specific to it, is there ?I agree, we need to have a new generic api for such purpose. The Linux/U-boot
soc_device_matchis for adding quirks with in different ES version of same SoC.What we here need is similar to
of_match_compatiblefor array of different SoC's. Can you please confirm [1]drivers/soc/soc-uclass.cis the right place for such generic api?
Can you use of_machine_is_compatible() ?
[...]
Quoted 11 lines
Quoted 10 lines
Quoted 4 lines
So can you please check whether there might
Quoted 1 line
be some way to tell the two SoCs apart ?
At present there is no way other than matching the SoC compatible string.
Thinking about it a bit more, if you were to use the compatible string psssed from TFA in the / node, you could iterate over soc_ids[] array and return
RMOBILE_CPU_TYPE_x, which could be stored there as .data .
Then you won't even need theSOC_RZG2and it would all be faster, as all you would need is a single pass over a smaller array.
Quoted 6 lines
Good point. Ok will get rid of
SOC_RZG2, will use smaller array forRZG2.Are you suggesting to modify "
arch_misc_init" directly set "platform" environment variable using match logic, which use a smaller array Compared tormobile_cpuinfo.Basically we match the compatible string from TFA, .data from "
RMOBILE_CPU_TYPE_x" matched against PRR values and set the platform type .
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 ?
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
Hi Marek,
Thanks for the feedback.
Quoted 34 lines
Subject: Re: [PATCH 1/2] arm: rmobile: Add RZ/G2M SoC
On 9/19/20 8:35 PM, Biju Das wrote:
Hi,
[...]
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
arch/arm/mach-rmobile/cpu_info.c static u32 __rmobile_get_cpu_rev_fraction(void) · line 108
Quoted 12 lines
arch/arm/mach-rmobile/cpu_info.c +12
-0+static const struct udevice_id *of_soc_match_compatible (void ) { +const struct udevice_id *of_match = soc_ids;int i; + +for (i =0 ; i <ARRAY_SIZE (soc_ids); i++) {if +(!fdt_node_check_compatible (gd->fdt_blob,0 , + of_match->compatible)) +return of_match; +of_match++; +} + +return NULL ; +}This should rather be a generic function, I think this is something that already exists in Linux common code too, right ?
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
No. I have seen some other SoC's uses similar logic [1]& [2] .
I mean, this looks like Linux's
soc_device_match(), so such a function is likely generic code, there is nothing platform specific to it, isthere ?
Quoted 2 lines
I agree, we need to have a new generic api for such purpose. The Linux/U-
boot
soc_device_matchis for adding quirks with in different ES version of same SoC.Quoted 1 line
Quoted 6 lines
Quoted 1 line
What we here need is similar to
of_match_compatiblefor array ofdifferent SoC's.
Quoted 1 line
Can you please confirm [1]
drivers/soc/soc-uclass.cis the right place forsuch generic api?
Can you use
of_machine_is_compatible()?
Yes, will use that one.
Quoted 25 lines
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
So can you please check whether there might
Quoted 1 line
be some way to tell the two SoCs apart ?
At present there is no way other than matching the SoC compatible
string.
Quoted 4 lines
Quoted 4 lines
Thinking about it a bit more, if you were to use the compatible string psssed from TFA in the / node, you could iterate over soc_ids[] array and return
RMOBILE_CPU_TYPE_x, which could be storedthere as .data .
Quoted 7 lines
Quoted 2 lines
Then you won't even need the
SOC_RZG2and it would all be faster, as all you would need is a single pass over a smaller array.Good point. Ok will get rid of
SOC_RZG2, will use smaller array forRZG2.Are you suggesting to modify "
arch_misc_init" directly set "platform" environment variable using match logic, which use a smaller arrayCompared to
rmobile_cpuinfo.Quoted 2 lines
Basically we match the compatible string from TFA, .data from "
RMOBILE_CPU_TYPE_x" matched against PRR values and set the platform type .
Quoted 8 lines
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 useof_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;
+}
Cheers,
biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
On 9/21/20 12:30 PM, Biju Das wrote:
[...]
Quoted 32 lines
Quoted 8 lines
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 useof_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.(quoted diff) +19
-0+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; +} +
Review
Quoted 10 lines
(quoted diff) +10
-0+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 ?
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
Hi Marek,
Thanks for the feedback.
Quoted 52 lines
Subject: Re: [PATCH 1/2] arm: rmobile: Add RZ/G2M SoC
On 9/21/20 12:30 PM, Biju Das wrote:
[...]
Quoted 3 lines
Quoted 3 lines
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:
Quoted 8 lines
Quoted 5 lines
board/renesas/rcar-common/common.c
so all you would have to do is useof_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.Quoted 17 lines
(quoted diff) +15
-0+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; +}Review
Quoted 10 lines
(quoted diff) +10
-0+ +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 returnCPU_TYPE_RZG2_something; andrmobile_get_cpu_type()for RZG2 can be implemented using the match on /compatible string .
Quoted 2 lines
Take a look at how
arch/arm/mach-rmobile/cpu_info-rcar.cimplements it using PRR, you might needcpu_info-rzg.cI think.
As mentioned in the commit message PRR values of both R-Car M3-W and RZ/G2M are identical. So there is no need for separate cpu_info-rzg.c. I believe it is duplication of code.
We are matching PRR first (device binding) and then use TFA SoC compatible string to differentiate from R-Car family. Please see the diff below[3].
Quoted 7 lines
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 ?
Device binding is important use case, run time you need to match PRR, that is same for both RCar-M3W and RZ/G2E. In RZ/G2 case, we miss device binding if just go with TFA compatible Approach. So we need both.
What do you think?
[3]
+static const struct {
+char *compatible;
+u16 cpu_type;
+u8 cpu_name[10];
+} tfa_cpuinfo[] = {
+{ "renesas,r8a774a1", RMOBILE_CPU_TYPE_R8A774A1, "R8A774A1" }, +{ },
+};
+
+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;
+}
+
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+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;
+}
+#else
+static bool __is_tfa_soc_match(u32 cpu_type)
+{
+return false;
+}
+bool is_tfa_soc_match(u32 cpu_type) +__attribute__((weak, alias("__is_tfa_soc_match"))); +#endif
+
/* CPU infomation table */
static const struct {
u16 cpu_type;
@@ -74,10 +115,9 @@ static const struct {
{ 0x0, "CPU" },
};
-static int rmobile_cpuinfo_idx(void)
+static int rmobile_cpuinfo_idx(u32 cpu_type)
{
int i = 0;
-u32 cpu_type = rmobile_get_cpu_type();
for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
if (rmobile_cpuinfo[i].cpu_type == cpu_type)
@@ -86,14 +126,24 @@ static int rmobile_cpuinfo_idx(void)
return i;
}
+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; +}
+
#ifdef CONFIG_ARCH_MISC_INIT
int arch_misc_init(void)
{
-int i, idx = rmobile_cpuinfo_idx();
+const u8 *cpu_name = get_cpu_name();
char cpu[10] = { 0 };
+int i;
for (i = 0; i < sizeof(cpu); i++)
-cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]); +cpu[i] = tolower(cpu_name[i]);
env_set("platform", cpu);
@@ -103,10 +153,8 @@ int arch_misc_init(void)
int print_cpuinfo(void)
{
-int i = rmobile_cpuinfo_idx();
-
printf("CPU: Renesas Electronics %s rev %d.%d\n",
-rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(), +get_cpu_name(), rmobile_get_cpu_rev_integer(),
rmobile_get_cpu_rev_fraction());
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
Hi Marek,
Quoted 79 lines
-----Original Message-----
From: Biju Das
Sent: 21 September 2020 18:30
To: Marek Vasut <[email protected]>; Nobuhiro Iwamatsu <[email protected]>
Cc: u-boot at lists.denx.de; Chris Paterson <[email protected]>; Prabhakar Mahadev Lad <[email protected]>
Subject: RE: [PATCH 1/2] arm: rmobile: Add RZ/G2M SoCHi Marek,
Thanks for the feedback.
Quoted 44 lines
Subject: Re: [PATCH 1/2] arm: rmobile: Add RZ/G2M SoC
On 9/21/20 12:30 PM, Biju Das wrote:
[...]
Quoted 4 lines
Quoted 4 lines
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:
Quoted 9 lines
Quoted 5 lines
board/renesas/rcar-common/common.c
so all you would have to do is useof_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.Quoted 23 lines
(quoted diff) +21
-0+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;Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ +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 returnCPU_TYPE_RZG2_something; andrmobile_get_cpu_type()for RZG2 can be implemented using the match on/compatible string .
Quoted 3 lines
Take a look at how
arch/arm/mach-rmobile/cpu_info-rcar.cimplements it using PRR, you might needcpu_info-rzg.cI think.As mentioned in the commit message PRR values of both R-Car M3-W and RZ/G2M are identical. So there is no need for separate
cpu_info-rzg.c. I believe it is duplication of code.We are matching PRR first (device binding) and then use TFA SoC compatible string to differentiate from R-Car family.
Please see the diff below[3].
Quoted 9 lines
Quoted 5 lines
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 tablelook up again.
Quoted 2 lines
What do you think ?
Thinking further, we can define CPU_TYPE_RZG_MASK as 0x1000. The value CPU_TYPE_RZG_MASK | SOC_PR Is added into tfa_cpu_info table.
We just match PRR of the SoC and compatible string from TFA with smaller array table. If match found, we set cputype= CPU_TYPE_RZG_MASK | SOC_PR. Then the remaining logic in the code works as usual and changes are minimal.
I prefer this match function to be vendor specific, iterating cputype in smaller array(tfa_cpu_info ) is faster than iterating compatible string from device tree.
Please share your views on this.
Cheers,
Biju
Quoted 103 lines
Device binding is important use case, run time you need to match PRR, that is same for both RCar-M3W and RZ/G2E.
In RZ/G2 case, we miss device binding if just go with TFA compatible Approach. So we need both.What do you think?
[3]
(quoted diff) +45
-2+static const struct { +char *compatible; +u16 cpu_type; +u8 cpu_name[10]; +} tfa_cpuinfo[] = { +{ "renesas,r8a774a1", RMOBILE_CPU_TYPE_R8A774A1, "R8A774A1" }, +{ }, +}; + +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; +} + +#if CONFIG_IS_ENABLED(OF_CONTROL) +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; +} +#else +static bool __is_tfa_soc_match(u32 cpu_type) { +return false; +} +bool is_tfa_soc_match(u32 cpu_type) +__attribute__((weak, alias("__is_tfa_soc_match"))); #endif + /* CPU infomation table */ static const struct { u16 cpu_type;@@ -74,10 +115,9 @@ static const struct { { 0x0, "CPU" }, }; -static int rmobile_cpuinfo_idx(void) +static int rmobile_cpuinfo_idx(u32 cpu_type) { int i = 0; -u32 cpu_type = rmobile_get_cpu_type(); for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++) if (rmobile_cpuinfo[i].cpu_type == cpu_type) @@ -86,14 +126,24 @@ static int rmobile_cpuinfo_idx(void) return i; } +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;
(quoted diff) +6
-5+} + #ifdef CONFIG_ARCH_MISC_INIT int arch_misc_init(void) { -int i, idx = rmobile_cpuinfo_idx(); +const u8 *cpu_name = get_cpu_name(); char cpu[10] = { 0 }; +int i; for (i = 0; i < sizeof(cpu); i++) -cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]); +cpu[i] = tolower(cpu_name[i]); env_set("platform", cpu);@@ -103,10 +153,8 @@ int arch_misc_init(void) int print_cpuinfo(void) { -int i = rmobile_cpuinfo_idx(); - printf("CPU: Renesas Electronics %s rev %d.%d\n", -rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(), +get_cpu_name(), rmobile_get_cpu_rev_integer(), rmobile_get_cpu_rev_fraction());
Quoted 2 lines
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
Hi Marek,
Quoted 85 lines
Quoted 66 lines
Quoted 45 lines
Subject: Re: [PATCH 1/2] arm: rmobile: Add RZ/G2M SoC
On 9/21/20 12:30 PM, Biju Das wrote:
[...]
Quoted 4 lines
Quoted 4 lines
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:
Quoted 9 lines
Quoted 5 lines
board/renesas/rcar-common/common.c
so all you would have to do is useof_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.Quoted 24 lines
(quoted diff) +22
-0+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; +Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+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 returnCPU_TYPE_RZG2_something; andrmobile_get_cpu_type()for RZG2 can be implemented using the match on/compatible string .
Quoted 3 lines
Take a look at how
arch/arm/mach-rmobile/cpu_info-rcar.cimplements it using PRR, you might needcpu_info-rzg.cI think.As mentioned in the commit message PRR values of both R-Car M3-W and RZ/G2M are identical. So there is no need for separate
cpu_info-rzg.c. I believe it is duplication of code.We are matching PRR first (device binding) and then use TFA SoC compatible string to differentiate from R-Car family. Please see the diff below[3].
Quoted 10 lines
Quoted 6 lines
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 tablelook up again.
Quoted 2 lines
What do you think ?
Thinking further, we can define
CPU_TYPE_RZG_MASKas0x1000. The valueCPU_TYPE_RZG_MASK|SOC_PRIs added intotfa_cpu_infotable.We just match PRR of the SoC and compatible string from TFA with smaller array table. If match found, we set cputype=
CPU_TYPE_RZG_MASK|SOC_PR.
Then the remaining logic in the code works as usual and changes are minimal.
Quoted 5 lines
I prefer this match function to be vendor specific, iterating cputype in smaller
array(tfa_cpu_info )is faster than iterating compatible string from device tree.Please share your views on this.
The new diffs looks like this. I will send V3.
As you suggested, I have used match function which returns RZG2_CPU_ID.
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+static const struct udevice_id tfa_soc_ids[] = {
+{ .compatible = "renesas,r8a774a1", .data = RMOBILE_CPU_TYPE_R8A774A1 }, +{ },
+};
+
+static const u16 get_rzg_soc_cpu_type(void)
+{
+const struct udevice_id *of_match = tfa_soc_ids;
+u32 cpu_type = rmobile_get_cpu_type();
+int i;
+
+for (i = 0; i < ARRAY_SIZE(tfa_soc_ids); i++) {
+if (cpu_type == of_match->data &&
+ of_machine_is_compatible(of_match->compatible))
+return (cpu_type | RZG_CPU_MASK);
+of_match++;
+}
+
+return 0;
+}
+#else
+static const const u16 __get_rzg_soc_cpu_type(void)
+{
+return 0;
+}
+
+static const const u16 get_rzg_soc_cpu_type(void) +__attribute__((weak, alias("__get_rzg_soc_cpu_type"))); +#endif
+
/* CPU infomation table */
static const struct {
u16 cpu_type;
@@ -59,6 +91,7 @@ static const struct {
} rmobile_cpuinfo[] = {
{ RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
{ RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
+{ RMOBILE_CPU_TYPE_R8A774A1 | RZG_CPU_MASK, "R8A774A1" },
{ RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
{ RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
{ RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
@@ -77,7 +110,8 @@ static const struct {
static int rmobile_cpuinfo_idx(void)
{
int i = 0;
-u32 cpu_type = rmobile_get_cpu_type();
+u16 rzg2_cpu_type = get_rzg_soc_cpu_type();
+u32 cpu_type = rzg2_cpu_type ? rzg2_cpu_type : rmobile_get_cpu_type();
Quoted 5 lines
Quoted 5 lines
Device binding is important use case, run time you need to match PRR, that is same for both RCar-M3W and RZ/G2E.
In RZ/G2 case, we miss device binding if just go with TFA compatible Approach. So we need both.
Please look at the code above, looks like we don't need generic function. Since we need to compare both CPUID and Compatible string Iterating through CPU ID is much faster than iterating through compatible string.
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/2 arm: rmobile: Add RZ/G2M SoC
In reply to Biju DasOn 9/21/20 7:29 PM, Biju Das wrote:
[...]
Quoted 10 lines
Quoted 7 lines
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 returnCPU_TYPE_RZG2_something; andrmobile_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.cimplements it using PRR, you might needcpu_info-rzg.cI think.As mentioned in the commit message PRR values of both R-Car M3-W and RZ/G2M are identical. So there is no need for separate
cpu_info-rzg.c. I believe it is duplication of code.
I wonder whether it wouldn't be easier to simply ignore PRR on RZG altogether, and simply match on the /compatible string from the DT.
Quoted 2 lines
We are matching PRR first (device binding) and then use TFA SoC compatible string to differentiate from R-Car family. Please see the diff below[3].
I wonder whether we need the PRR matching at all ?
Quoted 14 lines
Quoted 7 lines
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 ?
Device binding is important use case, run time you need to match PRR, that is same for both RCar-M3W and RZ/G2E. In RZ/G2 case, we miss device binding if just go with TFA compatible Approach. So we need both.
What do you think?
[3]
Review
Quoted 8 lines
(quoted diff) +8
-0+static const struct { +char *compatible; +u16 cpu_type; +u8 cpu_name[10]; +} tfa_cpuinfo[] = { +{ "renesas,r8a774a1", RMOBILE_CPU_TYPE_R8A774A1, "R8A774A1" }, +{ }, +};
btw Can you please fix your mailer so it doesn't drop indent ? It's real hard to read the code.
[...]