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

Biju Das biju.das.jz at bp.renesas.com
Thu Oct 8 10:59:40 CEST 2020


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 at bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj at 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(-)

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 at 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);
-- 
2.17.1



More information about the U-Boot mailing list