blob: dc407d2a6121f1ecf1bc11057ebd24883453494d [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +09002/*
3 * (C) Copyright 2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
4 * (C) Copyright 2012 Renesas Solutions Corp.
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +09005 */
6#include <common.h>
7#include <asm/io.h>
Marek Vasutb90dc692018-12-03 13:28:25 +01008#include <linux/ctype.h>
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +09009
10#ifdef CONFIG_ARCH_CPU_INIT
11int arch_cpu_init(void)
12{
13 icache_enable();
14 return 0;
15}
16#endif
17
Takeshi Kiharacb048902018-12-04 11:53:24 +090018/* R-Car Gen3 D-cache is enabled in memmap-gen3.c */
19#ifndef CONFIG_RCAR_GEN3
Trevor Woerner43ec7e02019-05-03 09:41:00 -040020#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090021void enable_caches(void)
22{
23 dcache_enable();
24}
25#endif
Marek Vasut970fd8c2018-10-31 15:06:50 +010026#endif
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090027
28#ifdef CONFIG_DISPLAY_CPUINFO
Chris Brandt43b11d92017-08-23 14:53:59 -050029#ifndef CONFIG_RZA1
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000030static u32 __rmobile_get_cpu_type(void)
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090031{
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000032 return 0x0;
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090033}
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000034u32 rmobile_get_cpu_type(void)
35 __attribute__((weak, alias("__rmobile_get_cpu_type")));
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090036
Tetsuyuki Kobayashi7811e542012-07-25 18:24:21 +000037static u32 __rmobile_get_cpu_rev_integer(void)
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090038{
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000039 return 0;
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090040}
Tetsuyuki Kobayashi7811e542012-07-25 18:24:21 +000041u32 rmobile_get_cpu_rev_integer(void)
42 __attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
43
44static u32 __rmobile_get_cpu_rev_fraction(void)
45{
46 return 0;
47}
48u32 rmobile_get_cpu_rev_fraction(void)
49 __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090050
Nobuhiro Iwamatsu524ed8b2014-03-28 11:54:22 +090051/* CPU infomation table */
52static const struct {
53 u16 cpu_type;
54 u8 cpu_name[10];
55} rmobile_cpuinfo[] = {
Marek Vasutb8f814b2017-11-25 23:54:10 +010056 { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
57 { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
58 { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
59 { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
60 { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
61 { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
62 { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
63 { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
64 { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
Marek Vasut1ecc0bd2018-02-26 10:35:15 +010065 { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
Marek Vasut46175fc2017-10-09 20:39:47 +020066 { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
Marek Vasutcf567852019-07-29 19:59:44 +020067 { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" },
Marek Vasut001dbf32018-04-26 10:09:06 +020068 { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
Marek Vasut04cd2e22017-10-08 20:52:52 +020069 { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
Nobuhiro Iwamatsu524ed8b2014-03-28 11:54:22 +090070 { 0x0, "CPU" },
71};
72
Marek Vasutb90dc692018-12-03 13:28:25 +010073static int rmobile_cpuinfo_idx(void)
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090074{
Nobuhiro Iwamatsu524ed8b2014-03-28 11:54:22 +090075 int i = 0;
76 u32 cpu_type = rmobile_get_cpu_type();
Marek Vasutb90dc692018-12-03 13:28:25 +010077
78 for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
79 if (rmobile_cpuinfo[i].cpu_type == cpu_type)
Nobuhiro Iwamatsu524ed8b2014-03-28 11:54:22 +090080 break;
Marek Vasutb90dc692018-12-03 13:28:25 +010081
82 return i;
83}
84
85#ifdef CONFIG_ARCH_MISC_INIT
86int arch_misc_init(void)
87{
88 int i, idx = rmobile_cpuinfo_idx();
89 char cpu[10] = { 0 };
90
91 for (i = 0; i < sizeof(cpu); i++)
92 cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
93
94 env_set("platform", cpu);
95
96 return 0;
97}
98#endif
99
100int print_cpuinfo(void)
101{
102 int i = rmobile_cpuinfo_idx();
103
104 printf("CPU: Renesas Electronics %s rev %d.%d\n",
105 rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
106 rmobile_get_cpu_rev_fraction());
107
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +0900108 return 0;
109}
Chris Brandt43b11d92017-08-23 14:53:59 -0500110#else
111int print_cpuinfo(void)
112{
113 printf("CPU: Renesas Electronics RZ/A1\n");
114 return 0;
115}
116#endif
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +0000117#endif /* CONFIG_DISPLAY_CPUINFO */