blob: 9ef94a489935c0796437bb3d71fab290c2d797c9 [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>
Simon Glass9fb625c2019-08-01 09:46:51 -06008#include <env.h>
Marek Vasut00e4b572018-12-03 13:28:25 +01009#include <linux/ctype.h>
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090010
11#ifdef CONFIG_ARCH_CPU_INIT
12int arch_cpu_init(void)
13{
14 icache_enable();
15 return 0;
16}
17#endif
18
Takeshi Kihara5055a4e2018-12-04 11:53:24 +090019/* R-Car Gen3 D-cache is enabled in memmap-gen3.c */
20#ifndef CONFIG_RCAR_GEN3
Trevor Woerner10015022019-05-03 09:41:00 -040021#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090022void enable_caches(void)
23{
24 dcache_enable();
25}
26#endif
Marek Vasute5cb6bd2018-10-31 15:06:50 +010027#endif
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090028
29#ifdef CONFIG_DISPLAY_CPUINFO
Chris Brandt35295962017-08-23 14:53:59 -050030#ifndef CONFIG_RZA1
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000031static u32 __rmobile_get_cpu_type(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090032{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000033 return 0x0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090034}
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000035u32 rmobile_get_cpu_type(void)
36 __attribute__((weak, alias("__rmobile_get_cpu_type")));
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090037
Tetsuyuki Kobayashi4f007b82012-07-25 18:24:21 +000038static u32 __rmobile_get_cpu_rev_integer(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090039{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000040 return 0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090041}
Tetsuyuki Kobayashi4f007b82012-07-25 18:24:21 +000042u32 rmobile_get_cpu_rev_integer(void)
43 __attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
44
45static u32 __rmobile_get_cpu_rev_fraction(void)
46{
47 return 0;
48}
49u32 rmobile_get_cpu_rev_fraction(void)
50 __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090051
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090052/* CPU infomation table */
53static const struct {
54 u16 cpu_type;
55 u8 cpu_name[10];
56} rmobile_cpuinfo[] = {
Marek Vasut262e9152017-11-25 23:54:10 +010057 { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
58 { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
59 { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
60 { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
61 { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
62 { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
63 { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
64 { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
65 { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
Marek Vasutf295a562018-02-26 10:35:15 +010066 { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
Marek Vasut5cb19e72017-10-09 20:39:47 +020067 { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
Marek Vasut57ede1a2019-07-29 19:59:44 +020068 { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" },
Marek Vasuta0410a62018-04-26 10:09:06 +020069 { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
Marek Vasut11545412017-10-08 20:52:52 +020070 { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090071 { 0x0, "CPU" },
72};
73
Marek Vasut00e4b572018-12-03 13:28:25 +010074static int rmobile_cpuinfo_idx(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090075{
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090076 int i = 0;
77 u32 cpu_type = rmobile_get_cpu_type();
Marek Vasut00e4b572018-12-03 13:28:25 +010078
79 for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
80 if (rmobile_cpuinfo[i].cpu_type == cpu_type)
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090081 break;
Marek Vasut00e4b572018-12-03 13:28:25 +010082
83 return i;
84}
85
86#ifdef CONFIG_ARCH_MISC_INIT
87int arch_misc_init(void)
88{
89 int i, idx = rmobile_cpuinfo_idx();
90 char cpu[10] = { 0 };
91
92 for (i = 0; i < sizeof(cpu); i++)
93 cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
94
95 env_set("platform", cpu);
96
97 return 0;
98}
99#endif
100
101int print_cpuinfo(void)
102{
103 int i = rmobile_cpuinfo_idx();
104
105 printf("CPU: Renesas Electronics %s rev %d.%d\n",
106 rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
107 rmobile_get_cpu_rev_fraction());
108
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +0900109 return 0;
110}
Chris Brandt35295962017-08-23 14:53:59 -0500111#else
112int print_cpuinfo(void)
113{
114 printf("CPU: Renesas Electronics RZ/A1\n");
115 return 0;
116}
117#endif
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +0000118#endif /* CONFIG_DISPLAY_CPUINFO */