From patchwork Tue Mar 2 12:09:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 1445994 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DqbXf12NQz9sVt for ; Tue, 2 Mar 2021 23:09:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 88DB181FFE; Tue, 2 Mar 2021 13:09:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id E811582047; Tue, 2 Mar 2021 13:09:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, KHOP_HELO_FCRDNS,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by phobos.denx.de (Postfix) with ESMTP id 2DDEF81F9E for ; Tue, 2 Mar 2021 13:09:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=biju.das.jz@bp.renesas.com X-IronPort-AV: E=Sophos;i="5.81,216,1610377200"; d="scan'208";a="73612827" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Mar 2021 21:09:21 +0900 Received: from localhost.localdomain (unknown [172.29.52.27]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id B0E9A4212EFF; Tue, 2 Mar 2021 21:09:19 +0900 (JST) From: Biju Das To: Nobuhiro Iwamatsu , Marek Vasut Cc: Biju Das , u-boot@lists.denx.de, Chris Paterson , Adam Ford , Prabhakar Mahadev Lad Subject: [PATCH] arm: mach-rmobile: Add CPU info support for RZ/G2 Date: Tue, 2 Mar 2021 12:09:16 +0000 Message-Id: <20210302120916.11326-1-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean Add CPU info support for RZ/G2 SoC's. Signed-off-by: Biju Das --- RZ/G2M Logs:- U-Boot 2021.04-rc2-00245-g9bfc7862e4 (Mar 02 2021 - 09:56:38 +0000) CPU: Renesas Electronics R8A774A1 rev 1.3 Model: HopeRun HiHope RZ/G2M with sub board DRAM: 3.9 GiB MMC: mmc@ee100000: 0, mmc@ee160000: 1 Loading Environment from MMC... OK In: serial@e6e88000 Out: serial@e6e88000 Err: serial@e6e88000 Net: eth0: ethernet@e6800000 Hit any key to stop autoboot: 0 RZ/G2N Logs:- U-Boot 2021.04-rc2-00245-g9bfc7862e4 (Mar 02 2021 - 09:56:38 +0000) CPU: Renesas Electronics R8A774B1 rev 1.1 Model: HopeRun HiHope RZ/G2N with sub board DRAM: 3.9 GiB MMC: mmc@ee100000: 0, mmc@ee160000: 1 Loading Environment from MMC... OK In: serial@e6e88000 Out: serial@e6e88000 Err: serial@e6e88000 Net: eth0: ethernet@e6800000 Hit any key to stop autoboot: 0 RZ/G2H logs:- U-Boot 2021.04-rc2-00245-g9bfc7862e4 (Mar 02 2021 - 09:56:38 +0000) CPU: Renesas Electronics R8A774E1 rev 3.0 Model: HopeRun HiHope RZ/G2H with sub board DRAM: 3.9 GiB MMC: mmc@ee100000: 0, mmc@ee160000: 1 Loading Environment from MMC... OK In: serial@e6e88000 Out: serial@e6e88000 Err: serial@e6e88000 Net: eth0: ethernet@e6800000 Hit any key to stop autoboot: 0 --- arch/arm/mach-rmobile/Makefile | 1 + arch/arm/mach-rmobile/cpu_info-rzg.c | 41 ++++++++++++++++++++ arch/arm/mach-rmobile/cpu_info.c | 21 ++++++++-- arch/arm/mach-rmobile/include/mach/rmobile.h | 1 + 4 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 arch/arm/mach-rmobile/cpu_info-rzg.c diff --git a/arch/arm/mach-rmobile/Makefile b/arch/arm/mach-rmobile/Makefile index 3206bce722..da425afddd 100644 --- a/arch/arm/mach-rmobile/Makefile +++ b/arch/arm/mach-rmobile/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_SH73A0) += lowlevel_init.o cpu_info-sh73a0.o pfc-sh73a0.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_GEN3) += cpu_info-rzg.o OBJCOPYFLAGS_u-boot-spl.srec := -O srec quiet_cmd_objcopy = OBJCOPY $@ diff --git a/arch/arm/mach-rmobile/cpu_info-rzg.c b/arch/arm/mach-rmobile/cpu_info-rzg.c new file mode 100644 index 0000000000..1c18fd06f0 --- /dev/null +++ b/arch/arm/mach-rmobile/cpu_info-rzg.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Renesas Electronics Corporation + * + */ +#include +#include + +/* If the firmware passed a device tree, use it for soc identification. */ +extern u64 rcar_atf_boot_args[]; + +/* CPU information table */ +static const struct { + char *soc_name; + u8 cpu_name[10]; +} tfa_info[] = { + { "renesas,r8a774a1", "R8A774A1" }, + { "renesas,r8a774b1", "R8A774B1" }, + { "renesas,r8a774c0", "R8A774C0" }, + { "renesas,r8a774e1", "R8A774E1" } +}; + +const u8 *rzg_get_cpu_name(void) +{ + void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]); + bool ret = false; + int i; + + if (fdt_magic(atf_fdt_blob) != FDT_MAGIC) + return NULL; + + for (i = 0; i < ARRAY_SIZE(tfa_info); i++) { + if (fdt_node_check_compatible(atf_fdt_blob, 0, + tfa_info[i].soc_name) == 0) { + ret = true; + break; + } + } + + return ret ? tfa_info[i].cpu_name : NULL; +} diff --git a/arch/arm/mach-rmobile/cpu_info.c b/arch/arm/mach-rmobile/cpu_info.c index fdbbd72e28..9ec622bdb5 100644 --- a/arch/arm/mach-rmobile/cpu_info.c +++ b/arch/arm/mach-rmobile/cpu_info.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2012 Nobuhiro Iwamatsu - * (C) Copyright 2012 Renesas Solutions Corp. + * (C) Copyright 2012-2021 Renesas Solutions Corp. */ #include #include @@ -31,6 +31,11 @@ void enable_caches(void) #ifdef CONFIG_DISPLAY_CPUINFO #ifndef CONFIG_RZA1 +__weak const u8 *rzg_get_cpu_name(void) +{ + return 0; +} + static u32 __rmobile_get_cpu_type(void) { return 0x0; @@ -52,7 +57,7 @@ static u32 __rmobile_get_cpu_rev_fraction(void) u32 rmobile_get_cpu_rev_fraction(void) __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction"))); -/* CPU infomation table */ +/* CPU information table */ static const struct { u16 cpu_type; u8 cpu_name[10]; @@ -86,14 +91,22 @@ static int rmobile_cpuinfo_idx(void) return i; } +static const u8 *get_cpu_name(int idx) +{ + const u8 *cpu_name = rzg_get_cpu_name(); + + return cpu_name ? cpu_name : rmobile_cpuinfo[idx].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(idx); char cpu[10] = { 0 }; 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); @@ -106,7 +119,7 @@ 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(i), rmobile_get_cpu_rev_integer(), rmobile_get_cpu_rev_fraction()); return 0; diff --git a/arch/arm/mach-rmobile/include/mach/rmobile.h b/arch/arm/mach-rmobile/include/mach/rmobile.h index a50249dc96..a688636141 100644 --- a/arch/arm/mach-rmobile/include/mach/rmobile.h +++ b/arch/arm/mach-rmobile/include/mach/rmobile.h @@ -41,6 +41,7 @@ #define RMOBILE_CPU_TYPE_R8A77995 0x58 #ifndef __ASSEMBLY__ +const u8 *rzg_get_cpu_name(void); u32 rmobile_get_cpu_type(void); u32 rmobile_get_cpu_rev_integer(void); u32 rmobile_get_cpu_rev_fraction(void);