rcar_gen3: plat: Add R-Car V3M support
Add R-Car V3M support. This is based on the original
V3M support patch for Yocto v2.23.1 by Vladimir Barinov.
Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Signed-off-by: Valentine Barshak <valentine.barshak@cogentembedded.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
---
Marek: Update on top of mainline ATF/master
diff --git a/plat/renesas/rcar/bl2_cpg_init.c b/plat/renesas/rcar/bl2_cpg_init.c
index 6732172..ed9b772 100644
--- a/plat/renesas/rcar/bl2_cpg_init.c
+++ b/plat/renesas/rcar/bl2_cpg_init.c
@@ -28,6 +28,11 @@
static void bl2_system_cpg_init_m3n(void);
#endif
+#if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_V3M)
+static void bl2_realtime_cpg_init_v3m(void);
+static void bl2_system_cpg_init_v3m(void);
+#endif
+
#if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_E3)
static void bl2_realtime_cpg_init_e3(void);
static void bl2_system_cpg_init_e3(void);
@@ -216,6 +221,38 @@
}
#endif
+#if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_V3M)
+static void bl2_realtime_cpg_init_v3m(void)
+{
+ /* Realtime Module Stop Control Registers */
+ cpg_write(RMSTPCR0, 0x00230000U);
+ cpg_write(RMSTPCR1, 0xFFFFFFFFU);
+ cpg_write(RMSTPCR2, 0x14062FD8U);
+ cpg_write(RMSTPCR3, 0xFFFFFFDFU);
+ cpg_write(RMSTPCR4, 0x80000184U);
+ cpg_write(RMSTPCR5, 0x83FFFFFFU);
+ cpg_write(RMSTPCR6, 0xFFFFFFFFU);
+ cpg_write(RMSTPCR7, 0xFFFFFFFFU);
+ cpg_write(RMSTPCR8, 0x7FF3FFF4U);
+ cpg_write(RMSTPCR9, 0xFFFFFFFEU);
+}
+
+static void bl2_system_cpg_init_v3m(void)
+{
+ /* System Module Stop Control Registers */
+ cpg_write(SMSTPCR0, 0x00210000U);
+ cpg_write(SMSTPCR1, 0xFFFFFFFFU);
+ cpg_write(SMSTPCR2, 0x340E2FDCU);
+ cpg_write(SMSTPCR3, 0xFFFFFBDFU);
+ cpg_write(SMSTPCR4, 0x80000004U);
+ cpg_write(SMSTPCR5, 0xC3FFFFFFU);
+ cpg_write(SMSTPCR6, 0xFFFFFFFFU);
+ cpg_write(SMSTPCR7, 0xFFFFFFFFU);
+ cpg_write(SMSTPCR8, 0x01F1FFF5U);
+ cpg_write(SMSTPCR9, 0xFFFFFFFEU);
+}
+#endif
+
#if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_E3)
static void bl2_realtime_cpg_init_e3(void)
{
@@ -310,6 +347,9 @@
case RCAR_PRODUCT_M3N:
bl2_realtime_cpg_init_m3n();
break;
+ case RCAR_PRODUCT_V3M:
+ bl2_realtime_cpg_init_v3m();
+ break;
case RCAR_PRODUCT_E3:
bl2_realtime_cpg_init_e3();
break;
@@ -326,6 +366,8 @@
bl2_realtime_cpg_init_m3();
#elif RCAR_LSI == RCAR_M3N
bl2_realtime_cpg_init_m3n();
+#elif RCAR_LSI == RCAR_V3M
+ bl2_realtime_cpg_init_v3m();
#elif RCAR_LSI == RCAR_E3
bl2_realtime_cpg_init_e3();
#elif RCAR_LSI == RCAR_D3
@@ -351,6 +393,9 @@
case RCAR_PRODUCT_M3N:
bl2_system_cpg_init_m3n();
break;
+ case RCAR_PRODUCT_V3M:
+ bl2_system_cpg_init_v3m();
+ break;
case RCAR_PRODUCT_E3:
bl2_system_cpg_init_e3();
break;
@@ -367,6 +412,8 @@
bl2_system_cpg_init_m3();
#elif RCAR_LSI == RCAR_M3N
bl2_system_cpg_init_m3n();
+#elif RCAR_LSI == RCAR_V3M
+ bl2_system_cpg_init_v3m();
#elif RCAR_LSI == RCAR_E3
bl2_system_cpg_init_e3();
#elif RCAR_LSI == RCAR_D3
diff --git a/plat/renesas/rcar/bl2_plat_setup.c b/plat/renesas/rcar/bl2_plat_setup.c
index d21ddf5..a21d6ab 100644
--- a/plat/renesas/rcar/bl2_plat_setup.c
+++ b/plat/renesas/rcar/bl2_plat_setup.c
@@ -73,6 +73,9 @@
#elif RCAR_LSI == RCAR_M3N
#define TARGET_PRODUCT RCAR_PRODUCT_M3N
#define TARGET_NAME "R-Car M3N"
+#elif RCAR_LSI == RCAR_V3M
+#define TARGET_PRODUCT RCAR_PRODUCT_V3M
+#define TARGET_NAME "R-Car V3M"
#elif RCAR_LSI == RCAR_E3
#define TARGET_PRODUCT RCAR_PRODUCT_E3
#define TARGET_NAME "R-Car E3"
@@ -80,7 +83,7 @@
#define TARGET_PRODUCT RCAR_PRODUCT_D3
#define TARGET_NAME "R-Car D3"
#elif RCAR_LSI == RCAR_AUTO
-#define TARGET_NAME "R-Car H3/M3/M3N"
+#define TARGET_NAME "R-Car H3/M3/M3N/V3M"
#endif
#if (RCAR_LSI == RCAR_E3)
@@ -431,6 +434,10 @@
ret = fdt_setprop_string(fdt, 0, "compatible",
"renesas,h3ulcb");
break;
+ case BOARD_EAGLE:
+ ret = fdt_setprop_string(fdt, 0, "compatible",
+ "renesas,eagle");
+ break;
case BOARD_EBISU:
case BOARD_EBISU_4D:
ret = fdt_setprop_string(fdt, 0, "compatible",
@@ -464,6 +471,10 @@
ret = fdt_appendprop_string(fdt, 0, "compatible",
"renesas,r8a77965");
break;
+ case RCAR_PRODUCT_V3M:
+ ret = fdt_appendprop_string(fdt, 0, "compatible",
+ "renesas,r8a77970");
+ break;
case RCAR_PRODUCT_E3:
ret = fdt_appendprop_string(fdt, 0, "compatible",
"renesas,r8a77990");
@@ -600,6 +611,11 @@
dram_config[1] = 0x80000000ULL;
break;
+ case RCAR_PRODUCT_V3M:
+ /* 1GB(512MBx2) */
+ dram_config[1] = 0x40000000ULL;
+ break;
+
case RCAR_PRODUCT_E3:
#if (RCAR_DRAM_DDR3L_MEMCONF == 0)
/* 1GB(512MBx2) */
@@ -637,6 +653,7 @@
const char *product_m3 = "M3";
const char *product_e3 = "E3";
const char *product_d3 = "D3";
+ const char *product_v3m = "V3M";
const char *lcs_secure = "SE";
const char *lcs_cm = "CM";
const char *lcs_dm = "DM";
@@ -713,6 +730,9 @@
case RCAR_PRODUCT_M3N:
str = product_m3n;
break;
+ case RCAR_PRODUCT_V3M:
+ str = product_v3m;
+ break;
case RCAR_PRODUCT_E3:
str = product_e3;
break;
@@ -760,6 +780,7 @@
case BOARD_STARTER_KIT_PRE:
case BOARD_EBISU_4D:
case BOARD_DRAAK:
+ case BOARD_EAGLE:
break;
default:
type = BOARD_UNKNOWN;
@@ -972,6 +993,7 @@
static void bl2_init_generic_timer(void)
{
+/* FIXME: V3M 16.666 MHz ? */
#if RCAR_LSI == RCAR_D3
uint32_t reg_cntfid = EXTAL_DRAAK;
#elif RCAR_LSI == RCAR_E3
diff --git a/plat/renesas/rcar/include/platform_def.h b/plat/renesas/rcar/include/platform_def.h
index 9f071bc..bbe4a54 100644
--- a/plat/renesas/rcar/include/platform_def.h
+++ b/plat/renesas/rcar/include/platform_def.h
@@ -109,10 +109,14 @@
#define BL2_LIMIT U(0xE6360000)
#endif
-#define BL2_BASE U(0xE6304000)
#if (RCAR_LSI == RCAR_E3) || (RCAR_LSI == RCAR_D3)
+#define BL2_BASE U(0xE6304000)
#define BL2_IMAGE_LIMIT U(0xE6318000)
+#elif (RCAR_LSI == RCAR_V3M)
+#define BL2_BASE U(0xE6344000)
+#define BL2_IMAGE_LIMIT U(0xE636E800)
#else
+#define BL2_BASE U(0xE6304000)
#define BL2_IMAGE_LIMIT U(0xE632E800)
#endif
#define RCAR_SYSRAM_SIZE (BL2_BASE - RCAR_SYSRAM_BASE)
diff --git a/plat/renesas/rcar/include/rcar_def.h b/plat/renesas/rcar/include/rcar_def.h
index 9bf418f..ac7dc17 100644
--- a/plat/renesas/rcar/include/rcar_def.h
+++ b/plat/renesas/rcar/include/rcar_def.h
@@ -151,6 +151,7 @@
#define RCAR_CUT_MASK U(0x000000FF)
#define RCAR_PRODUCT_H3 U(0x00004F00)
#define RCAR_PRODUCT_M3 U(0x00005200)
+#define RCAR_PRODUCT_V3M U(0x00005400)
#define RCAR_PRODUCT_M3N U(0x00005500)
#define RCAR_PRODUCT_E3 U(0x00005700)
#define RCAR_PRODUCT_D3 U(0x00005800)
diff --git a/plat/renesas/rcar/platform.mk b/plat/renesas/rcar/platform.mk
index 5eb20fc..ca5623d 100644
--- a/plat/renesas/rcar/platform.mk
+++ b/plat/renesas/rcar/platform.mk
@@ -30,6 +30,7 @@
RCAR_E3:=3
RCAR_H3N:=4
RCAR_D3:=5
+RCAR_V3M:=6
RCAR_AUTO:=99
$(eval $(call add_define,RCAR_H3))
$(eval $(call add_define,RCAR_M3))
@@ -37,6 +38,7 @@
$(eval $(call add_define,RCAR_E3))
$(eval $(call add_define,RCAR_H3N))
$(eval $(call add_define,RCAR_D3))
+$(eval $(call add_define,RCAR_V3M))
$(eval $(call add_define,RCAR_AUTO))
RCAR_CUT_10:=0
RCAR_CUT_11:=1
@@ -160,6 +162,22 @@
endif
$(eval $(call add_define,RCAR_LSI_CUT))
endif
+ else ifeq (${LSI},V3M)
+ RCAR_LSI:=${RCAR_V3M}
+ ifndef LSI_CUT
+ # enable compatible function.
+ RCAR_LSI_CUT_COMPAT := 1
+ $(eval $(call add_define,RCAR_LSI_CUT_COMPAT))
+ else
+ # disable compatible function.
+ ifeq (${LSI_CUT},10)
+ RCAR_LSI_CUT:=0
+ endif
+ ifeq (${LSI_CUT},20)
+ RCAR_LSI_CUT:=10
+ endif
+ $(eval $(call add_define,RCAR_LSI_CUT))
+ endif
else
$(error "Error: ${LSI} is not supported.")
endif