blob: 9b34cba047558bbf88c52b2f16315882bc984e5f [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>
Simon Glass9edefc22019-11-14 12:57:37 -07007#include <cpu_func.h>
Simon Glass90526e92020-05-10 11:39:56 -06008#include <asm/cache.h>
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +09009#include <asm/io.h>
Simon Glass9fb625c2019-08-01 09:46:51 -060010#include <env.h>
Marek Vasut00e4b572018-12-03 13:28:25 +010011#include <linux/ctype.h>
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090012
13#ifdef CONFIG_ARCH_CPU_INIT
14int arch_cpu_init(void)
15{
16 icache_enable();
17 return 0;
18}
19#endif
20
Takeshi Kihara5055a4e2018-12-04 11:53:24 +090021/* R-Car Gen3 D-cache is enabled in memmap-gen3.c */
22#ifndef CONFIG_RCAR_GEN3
Trevor Woerner10015022019-05-03 09:41:00 -040023#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090024void enable_caches(void)
25{
26 dcache_enable();
27}
28#endif
Marek Vasute5cb6bd2018-10-31 15:06:50 +010029#endif
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090030
31#ifdef CONFIG_DISPLAY_CPUINFO
Chris Brandt35295962017-08-23 14:53:59 -050032#ifndef CONFIG_RZA1
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000033static u32 __rmobile_get_cpu_type(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090034{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000035 return 0x0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090036}
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000037u32 rmobile_get_cpu_type(void)
38 __attribute__((weak, alias("__rmobile_get_cpu_type")));
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090039
Tetsuyuki Kobayashi4f007b82012-07-25 18:24:21 +000040static u32 __rmobile_get_cpu_rev_integer(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090041{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000042 return 0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090043}
Tetsuyuki Kobayashi4f007b82012-07-25 18:24:21 +000044u32 rmobile_get_cpu_rev_integer(void)
45 __attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
46
47static u32 __rmobile_get_cpu_rev_fraction(void)
48{
49 return 0;
50}
51u32 rmobile_get_cpu_rev_fraction(void)
52 __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090053
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090054/* CPU infomation table */
55static const struct {
56 u16 cpu_type;
57 u8 cpu_name[10];
58} rmobile_cpuinfo[] = {
Marek Vasut262e9152017-11-25 23:54:10 +010059 { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
60 { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
61 { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
62 { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
63 { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
64 { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
65 { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
66 { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
67 { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
Marek Vasutf295a562018-02-26 10:35:15 +010068 { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
Marek Vasut5cb19e72017-10-09 20:39:47 +020069 { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
Marek Vasut57ede1a2019-07-29 19:59:44 +020070 { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" },
Marek Vasuta0410a62018-04-26 10:09:06 +020071 { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
Marek Vasut11545412017-10-08 20:52:52 +020072 { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090073 { 0x0, "CPU" },
74};
75
Marek Vasut00e4b572018-12-03 13:28:25 +010076static int rmobile_cpuinfo_idx(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090077{
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090078 int i = 0;
79 u32 cpu_type = rmobile_get_cpu_type();
Marek Vasut00e4b572018-12-03 13:28:25 +010080
81 for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
82 if (rmobile_cpuinfo[i].cpu_type == cpu_type)
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090083 break;
Marek Vasut00e4b572018-12-03 13:28:25 +010084
85 return i;
86}
87
88#ifdef CONFIG_ARCH_MISC_INIT
89int arch_misc_init(void)
90{
91 int i, idx = rmobile_cpuinfo_idx();
92 char cpu[10] = { 0 };
93
94 for (i = 0; i < sizeof(cpu); i++)
95 cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
96
97 env_set("platform", cpu);
98
99 return 0;
100}
101#endif
102
103int print_cpuinfo(void)
104{
105 int i = rmobile_cpuinfo_idx();
106
107 printf("CPU: Renesas Electronics %s rev %d.%d\n",
108 rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
109 rmobile_get_cpu_rev_fraction());
110
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +0900111 return 0;
112}
Chris Brandt35295962017-08-23 14:53:59 -0500113#else
114int print_cpuinfo(void)
115{
116 printf("CPU: Renesas Electronics RZ/A1\n");
117 return 0;
118}
119#endif
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +0000120#endif /* CONFIG_DISPLAY_CPUINFO */