blob: 2cc701c4f5f601aaebda81d3dfbb9e48baab8d79 [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>
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +09008#include <asm/io.h>
Simon Glass9fb625c2019-08-01 09:46:51 -06009#include <env.h>
Marek Vasut00e4b572018-12-03 13:28:25 +010010#include <linux/ctype.h>
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090011
12#ifdef CONFIG_ARCH_CPU_INIT
13int arch_cpu_init(void)
14{
15 icache_enable();
16 return 0;
17}
18#endif
19
Takeshi Kihara5055a4e2018-12-04 11:53:24 +090020/* R-Car Gen3 D-cache is enabled in memmap-gen3.c */
21#ifndef CONFIG_RCAR_GEN3
Trevor Woerner10015022019-05-03 09:41:00 -040022#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090023void enable_caches(void)
24{
25 dcache_enable();
26}
27#endif
Marek Vasute5cb6bd2018-10-31 15:06:50 +010028#endif
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090029
30#ifdef CONFIG_DISPLAY_CPUINFO
Chris Brandt35295962017-08-23 14:53:59 -050031#ifndef CONFIG_RZA1
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000032static u32 __rmobile_get_cpu_type(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090033{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000034 return 0x0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090035}
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000036u32 rmobile_get_cpu_type(void)
37 __attribute__((weak, alias("__rmobile_get_cpu_type")));
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090038
Tetsuyuki Kobayashi4f007b82012-07-25 18:24:21 +000039static u32 __rmobile_get_cpu_rev_integer(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090040{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000041 return 0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090042}
Tetsuyuki Kobayashi4f007b82012-07-25 18:24:21 +000043u32 rmobile_get_cpu_rev_integer(void)
44 __attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
45
46static u32 __rmobile_get_cpu_rev_fraction(void)
47{
48 return 0;
49}
50u32 rmobile_get_cpu_rev_fraction(void)
51 __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090052
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090053/* CPU infomation table */
54static const struct {
55 u16 cpu_type;
56 u8 cpu_name[10];
57} rmobile_cpuinfo[] = {
Marek Vasut262e9152017-11-25 23:54:10 +010058 { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
59 { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
60 { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
61 { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
62 { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
63 { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
64 { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
65 { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
66 { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
Marek Vasutf295a562018-02-26 10:35:15 +010067 { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
Marek Vasut5cb19e72017-10-09 20:39:47 +020068 { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
Marek Vasut57ede1a2019-07-29 19:59:44 +020069 { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" },
Marek Vasuta0410a62018-04-26 10:09:06 +020070 { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
Marek Vasut11545412017-10-08 20:52:52 +020071 { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090072 { 0x0, "CPU" },
73};
74
Marek Vasut00e4b572018-12-03 13:28:25 +010075static int rmobile_cpuinfo_idx(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090076{
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090077 int i = 0;
78 u32 cpu_type = rmobile_get_cpu_type();
Marek Vasut00e4b572018-12-03 13:28:25 +010079
80 for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
81 if (rmobile_cpuinfo[i].cpu_type == cpu_type)
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090082 break;
Marek Vasut00e4b572018-12-03 13:28:25 +010083
84 return i;
85}
86
87#ifdef CONFIG_ARCH_MISC_INIT
88int arch_misc_init(void)
89{
90 int i, idx = rmobile_cpuinfo_idx();
91 char cpu[10] = { 0 };
92
93 for (i = 0; i < sizeof(cpu); i++)
94 cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
95
96 env_set("platform", cpu);
97
98 return 0;
99}
100#endif
101
102int print_cpuinfo(void)
103{
104 int i = rmobile_cpuinfo_idx();
105
106 printf("CPU: Renesas Electronics %s rev %d.%d\n",
107 rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
108 rmobile_get_cpu_rev_fraction());
109
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +0900110 return 0;
111}
Chris Brandt35295962017-08-23 14:53:59 -0500112#else
113int print_cpuinfo(void)
114{
115 printf("CPU: Renesas Electronics RZ/A1\n");
116 return 0;
117}
118#endif
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +0000119#endif /* CONFIG_DISPLAY_CPUINFO */