blob: b0686ed2035c3e8905c701de50e179ce16937b9d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsu4fb44e22012-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 Iwamatsu4fb44e22012-06-13 16:29:47 +09005 */
6#include <common.h>
7#include <asm/io.h>
Marek Vasut00e4b572018-12-03 13:28:25 +01008#include <linux/ctype.h>
Nobuhiro Iwamatsu4fb44e22012-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 Kihara5055a4e2018-12-04 11:53:24 +090018/* R-Car Gen3 D-cache is enabled in memmap-gen3.c */
19#ifndef CONFIG_RCAR_GEN3
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090020#ifndef CONFIG_SYS_DCACHE_OFF
21void enable_caches(void)
22{
23 dcache_enable();
24}
25#endif
Marek Vasute5cb6bd2018-10-31 15:06:50 +010026#endif
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090027
28#ifdef CONFIG_DISPLAY_CPUINFO
Chris Brandt35295962017-08-23 14:53:59 -050029#ifndef CONFIG_RZA1
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000030static u32 __rmobile_get_cpu_type(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090031{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000032 return 0x0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090033}
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000034u32 rmobile_get_cpu_type(void)
35 __attribute__((weak, alias("__rmobile_get_cpu_type")));
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090036
Tetsuyuki Kobayashi4f007b82012-07-25 18:24:21 +000037static u32 __rmobile_get_cpu_rev_integer(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090038{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000039 return 0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090040}
Tetsuyuki Kobayashi4f007b82012-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 Iwamatsu4fb44e22012-06-13 16:29:47 +090050
Nobuhiro Iwamatsu73ff6802014-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 Vasut262e9152017-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 Vasutf295a562018-02-26 10:35:15 +010065 { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
Marek Vasut5cb19e72017-10-09 20:39:47 +020066 { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
Marek Vasuta0410a62018-04-26 10:09:06 +020067 { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
Marek Vasut11545412017-10-08 20:52:52 +020068 { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090069 { 0x0, "CPU" },
70};
71
Marek Vasut00e4b572018-12-03 13:28:25 +010072static int rmobile_cpuinfo_idx(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090073{
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090074 int i = 0;
75 u32 cpu_type = rmobile_get_cpu_type();
Marek Vasut00e4b572018-12-03 13:28:25 +010076
77 for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
78 if (rmobile_cpuinfo[i].cpu_type == cpu_type)
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090079 break;
Marek Vasut00e4b572018-12-03 13:28:25 +010080
81 return i;
82}
83
84#ifdef CONFIG_ARCH_MISC_INIT
85int arch_misc_init(void)
86{
87 int i, idx = rmobile_cpuinfo_idx();
88 char cpu[10] = { 0 };
89
90 for (i = 0; i < sizeof(cpu); i++)
91 cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
92
93 env_set("platform", cpu);
94
95 return 0;
96}
97#endif
98
99int print_cpuinfo(void)
100{
101 int i = rmobile_cpuinfo_idx();
102
103 printf("CPU: Renesas Electronics %s rev %d.%d\n",
104 rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
105 rmobile_get_cpu_rev_fraction());
106
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +0900107 return 0;
108}
Chris Brandt35295962017-08-23 14:53:59 -0500109#else
110int print_cpuinfo(void)
111{
112 printf("CPU: Renesas Electronics RZ/A1\n");
113 return 0;
114}
115#endif
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +0000116#endif /* CONFIG_DISPLAY_CPUINFO */