From 5a3b074255df037c10e02ce1134a1b605cf7611f Mon Sep 17 00:00:00 2001 From: Hai Pham Date: Tue, 28 Feb 2023 22:22:03 +0100 Subject: [PATCH] ARM: rmobile: Add R-Car Generation 4 support This adds R-Car Generation 4 (Gen4) support as Renesas ARM64 SoC. In this version, reusing R-Car Gen3 lowlevel initialize routine [1] and R-Car Gen3 memory map tables [2] . [1] arch/arm/mach-rmobile/lowlevel_init_gen3.S [2] arch/arm/mach-rmobile/memmap-gen3.c Reviewed-by: Marek Vasut Signed-off-by: Hai Pham Signed-off-by: Marek Vasut [Marek: - Enable DTO support by default - Sort the Kconfig lists - Select RCAR_64 Kconfig option to pull in all the shared Kconfig options with Gen3, and use where applicable to deduplicate entries. - Fix reference [2] typo in commit message - Drop config options moved to Kconfig, rename rest to CFG_ accordingly to synchronize with upstream changes. Drop removed CONFIG_VERY_BIG_RAM. - Move board size limit to arch/Kconfig - Move GICR_BASE to headers instead of common config] --- Kconfig | 6 +- arch/arm/mach-rmobile/Kconfig | 4 + arch/arm/mach-rmobile/Kconfig.64 | 1 + arch/arm/mach-rmobile/Kconfig.rcar4 | 8 ++ arch/arm/mach-rmobile/Makefile | 2 +- arch/arm/mach-rmobile/cpu_info-rcar.c | 2 +- arch/arm/mach-rmobile/cpu_info.c | 4 +- .../include/mach/rcar-gen4-base.h | 75 +++++++++++++++++++ arch/arm/mach-rmobile/include/mach/rmobile.h | 2 + board/renesas/rcar-common/common.c | 2 +- common/Kconfig | 2 +- include/configs/rcar-gen4-common.h | 30 ++++++++ 12 files changed, 129 insertions(+), 9 deletions(-) create mode 100644 arch/arm/mach-rmobile/Kconfig.rcar4 create mode 100644 arch/arm/mach-rmobile/include/mach/rcar-gen4-base.h create mode 100644 include/configs/rcar-gen4-common.h diff --git a/Kconfig b/Kconfig index 7a8c190a7b..f24e4f0a33 100644 --- a/Kconfig +++ b/Kconfig @@ -427,7 +427,7 @@ config REMAKE_ELF config BUILD_TARGET string "Build target special images" - default "u-boot-elf.srec" if RCAR_GEN3 + default "u-boot-elf.srec" if RCAR_64 default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT default "u-boot-with-spl.bin" if MPC85xx && !E500MC && !E5500 && !E6500 && SPL default "u-boot-with-spl.imx" if ARCH_MX6 && SPL @@ -446,14 +446,14 @@ config BUILD_TARGET config HAS_BOARD_SIZE_LIMIT bool "Define a maximum size for the U-Boot image" - default y if RCAR_GEN3 + default y if RCAR_64 help In some cases, we need to enforce a hard limit on how big the U-Boot image itself can be. config BOARD_SIZE_LIMIT int "Maximum size of the U-Boot image in bytes" - default 1048576 if RCAR_GEN3 + default 1048576 if RCAR_64 depends on HAS_BOARD_SIZE_LIMIT help Maximum size of the U-Boot image. When defined, the build system diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig index 921153a8d9..1ef7d68bdf 100644 --- a/arch/arm/mach-rmobile/Kconfig +++ b/arch/arm/mach-rmobile/Kconfig @@ -40,6 +40,10 @@ config RCAR_GEN3 imply SPL_USE_TINY_PRINTF imply SPL_YMODEM_SUPPORT +config RCAR_GEN4 + bool "Renesas ARM SoCs R-Car Gen4 (64bit)" + select RCAR_64 + config RZA1 prompt "Renesas ARM SoCs RZ/A1 (32bit)" select CPU_V7A diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64 index 3b14721dab..57ed1d6c50 100644 --- a/arch/arm/mach-rmobile/Kconfig.64 +++ b/arch/arm/mach-rmobile/Kconfig.64 @@ -7,5 +7,6 @@ config OF_LIBFDT_OVERLAY default y if RCAR_64 source "arch/arm/mach-rmobile/Kconfig.rcar3" +source "arch/arm/mach-rmobile/Kconfig.rcar4" endif diff --git a/arch/arm/mach-rmobile/Kconfig.rcar4 b/arch/arm/mach-rmobile/Kconfig.rcar4 new file mode 100644 index 0000000000..6d9e16586d --- /dev/null +++ b/arch/arm/mach-rmobile/Kconfig.rcar4 @@ -0,0 +1,8 @@ +if RCAR_GEN4 + +choice + prompt "Renesas ARM64 SoCs board select" + optional +endchoice + +endif diff --git a/arch/arm/mach-rmobile/Makefile b/arch/arm/mach-rmobile/Makefile index 5b86221bc2..fadb6eb0ab 100644 --- a/arch/arm/mach-rmobile/Makefile +++ b/arch/arm/mach-rmobile/Makefile @@ -10,7 +10,7 @@ obj-$(CONFIG_DISPLAY_BOARDINFO) += board.o obj-$(CONFIG_TMU_TIMER) += ../../sh/lib/time.o obj-$(CONFIG_R8A7740) += lowlevel_init.o cpu_info-r8a7740.o pfc-r8a7740.o obj-$(CONFIG_RCAR_GEN2) += lowlevel_init_ca15.o cpu_info-rcar.o -obj-$(CONFIG_RCAR_GEN3) += lowlevel_init_gen3.o cpu_info-rcar.o memmap-gen3.o +obj-$(CONFIG_RCAR_64) += lowlevel_init_gen3.o cpu_info-rcar.o memmap-gen3.o obj-$(CONFIG_RZ_G2) += cpu_info-rzg.o ifneq ($(CONFIG_R8A779A0),) diff --git a/arch/arm/mach-rmobile/cpu_info-rcar.c b/arch/arm/mach-rmobile/cpu_info-rcar.c index ac9c623eda..62017f52c3 100644 --- a/arch/arm/mach-rmobile/cpu_info-rcar.c +++ b/arch/arm/mach-rmobile/cpu_info-rcar.c @@ -14,7 +14,7 @@ static u32 rmobile_get_prr(void) { - if (IS_ENABLED(CONFIG_RCAR_GEN3)) + if (IS_ENABLED(CONFIG_RCAR_64)) return readl(0xFFF00044); return readl(0xFF000044); diff --git a/arch/arm/mach-rmobile/cpu_info.c b/arch/arm/mach-rmobile/cpu_info.c index 246029ac29..07f7c2286a 100644 --- a/arch/arm/mach-rmobile/cpu_info.c +++ b/arch/arm/mach-rmobile/cpu_info.c @@ -19,8 +19,8 @@ int arch_cpu_init(void) } #endif -/* R-Car Gen3 D-cache is enabled in memmap-gen3.c */ -#ifndef CONFIG_RCAR_GEN3 +/* R-Car Gen3 and Gen4 D-cache is enabled in memmap-gen3.c */ +#ifndef CONFIG_RCAR_64 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) void enable_caches(void) { diff --git a/arch/arm/mach-rmobile/include/mach/rcar-gen4-base.h b/arch/arm/mach-rmobile/include/mach/rcar-gen4-base.h new file mode 100644 index 0000000000..ac57698849 --- /dev/null +++ b/arch/arm/mach-rmobile/include/mach/rcar-gen4-base.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * ./arch/arm/mach-rmobile/include/mach/rcar-gen4-base.h + * + * Copyright (C) 2021 Renesas Electronics Corp. + */ + +#ifndef __ASM_ARCH_RCAR_GEN4_BASE_H +#define __ASM_ARCH_RCAR_GEN4_BASE_H + +/* + * R-Car (R8A779F0) I/O Addresses + */ +#define RWDT_BASE 0xE6020000 +#define SWDT_BASE 0xE6030000 +#define TMU_BASE 0xE61E0000 + +/* SCIF */ +#define SCIF0_BASE 0xE6E60000 +#define SCIF1_BASE 0xE6E68000 +#define SCIF2_BASE 0xE6E88000 +#define SCIF3_BASE 0xE6C50000 +#define SCIF4_BASE 0xE6C40000 +#define SCIF5_BASE 0xE6F30000 + +/* CPG */ +#define CPGWPR 0xE6150000 +#define CPGWPCR 0xE6150004 + +/* Reset */ +#define RST_BASE 0xE6160000 /* Domain0 */ +#define RST_SRESCR0 (RST_BASE + 0x18) +#define RST_SPRES 0x5AA58000 + +/* Arm Generic Timer */ +#define CNTCR_BASE 0xE6080000 +#define CNTFID0 (CNTCR_BASE + 0x020) +#define CNTCR_EN BIT(0) + +/* GICv3 */ +/* Distributor Registers */ +#define GICD_BASE 0xF1000000 +#define GICR_BASE (GICR_LPI_BASE) + +/* ReDistributor Registers for Control and Physical LPIs */ +#define GICR_LPI_BASE 0xF1060000 +#define GICR_WAKER 0x0014 +#define GICR_PWRR 0x0024 +#define GICR_LPI_WAKER (GICR_LPI_BASE + GICR_WAKER) +#define GICR_LPI_PWRR (GICR_LPI_BASE + GICR_PWRR) + +/* ReDistributor Registers for SGIs and PPIs */ +#define GICR_SGI_BASE 0xF1070000 +#define GICR_IGROUPR0 0x0080 + +#ifndef __ASSEMBLY__ +#include +#include + +/* RWDT */ +struct rcar_rwdt { + u32 rwtcnt; + u32 rwtcsra; + u32 rwtcsrb; +}; + +/* SWDT */ +struct rcar_swdt { + u32 swtcnt; + u32 swtcsra; + u32 swtcsrb; +}; +#endif + +#endif /* __ASM_ARCH_RCAR_GEN4_BASE_H */ diff --git a/arch/arm/mach-rmobile/include/mach/rmobile.h b/arch/arm/mach-rmobile/include/mach/rmobile.h index 53f9a80ecf..af5db5c3fd 100644 --- a/arch/arm/mach-rmobile/include/mach/rmobile.h +++ b/arch/arm/mach-rmobile/include/mach/rmobile.h @@ -16,6 +16,8 @@ #include #elif defined(CONFIG_RCAR_GEN3) #include +#elif defined(CONFIG_RCAR_GEN4) +#include #elif defined(CONFIG_R7S72100) #else #error "SOC Name not defined" diff --git a/board/renesas/rcar-common/common.c b/board/renesas/rcar-common/common.c index 0ddae95e23..f38453af82 100644 --- a/board/renesas/rcar-common/common.c +++ b/board/renesas/rcar-common/common.c @@ -16,7 +16,7 @@ #include #include -#ifdef CONFIG_RCAR_GEN3 +#ifdef CONFIG_RCAR_64 DECLARE_GLOBAL_DATA_PTR; diff --git a/common/Kconfig b/common/Kconfig index 7ff62552cb..f2783ee65d 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -742,7 +742,7 @@ config SYS_MALLOC_BOOTPARAMS config SYS_BOOTPARAMS_LEN hex "Size of the bootparam buffer to malloc in bytes" depends on SYS_MALLOC_BOOTPARAMS - default 0x20000 if MIPS || RCAR_GEN3 + default 0x20000 if MIPS || RCAR_64 default 0x10000 config ID_EEPROM diff --git a/include/configs/rcar-gen4-common.h b/include/configs/rcar-gen4-common.h new file mode 100644 index 0000000000..c4f506df62 --- /dev/null +++ b/include/configs/rcar-gen4-common.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * include/configs/rcar-gen4-common.h + * This file is R-Car Gen4 common configuration file. + * + * Copyright (C) 2021 Renesas Electronics Corporation + */ + +#ifndef __RCAR_GEN4_COMMON_H +#define __RCAR_GEN4_COMMON_H + +#include + +/* Console */ +#define CFG_SYS_BAUDRATE_TABLE { 38400, 115200, 921600, 1843200 } + +/* Memory */ +#define DRAM_RSV_SIZE 0x08000000 +#define CFG_SYS_SDRAM_BASE (0x40000000 + DRAM_RSV_SIZE) +#define CFG_SYS_SDRAM_SIZE (0x80000000u - DRAM_RSV_SIZE) +#define CFG_MAX_MEM_MAPPED (0x80000000u - DRAM_RSV_SIZE) + +/* PHY needs a longer autoneg timeout */ +#define PHY_ANEG_TIMEOUT 20000 + +/* Environment setting */ +#define CFG_EXTRA_ENV_SETTINGS \ + "bootm_size=0x10000000\0" + +#endif /* __RCAR_GEN4_COMMON_H */ -- 2.39.5