blob: 65a9ca8c01392fe6601ab46fb2517aeb27ca835a [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
Marek Vasute5cb6bd2018-10-31 15:06:50 +010010/* R-Car Gen3 caches are enabled in memmap-gen3.c */
11#ifndef CONFIG_RCAR_GEN3
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090012#ifdef CONFIG_ARCH_CPU_INIT
13int arch_cpu_init(void)
14{
15 icache_enable();
16 return 0;
17}
18#endif
19
20#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
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000029static u32 __rmobile_get_cpu_type(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090030{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000031 return 0x0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090032}
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000033u32 rmobile_get_cpu_type(void)
34 __attribute__((weak, alias("__rmobile_get_cpu_type")));
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090035
Tetsuyuki Kobayashi4f007b82012-07-25 18:24:21 +000036static u32 __rmobile_get_cpu_rev_integer(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090037{
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +000038 return 0;
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090039}
Tetsuyuki Kobayashi4f007b82012-07-25 18:24:21 +000040u32 rmobile_get_cpu_rev_integer(void)
41 __attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
42
43static u32 __rmobile_get_cpu_rev_fraction(void)
44{
45 return 0;
46}
47u32 rmobile_get_cpu_rev_fraction(void)
48 __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090049
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090050/* CPU infomation table */
51static const struct {
52 u16 cpu_type;
53 u8 cpu_name[10];
54} rmobile_cpuinfo[] = {
Marek Vasut262e9152017-11-25 23:54:10 +010055 { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
56 { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
57 { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
58 { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
59 { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
60 { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
61 { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
62 { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
63 { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
Marek Vasutf295a562018-02-26 10:35:15 +010064 { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
Marek Vasut5cb19e72017-10-09 20:39:47 +020065 { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
Marek Vasuta0410a62018-04-26 10:09:06 +020066 { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
Marek Vasut11545412017-10-08 20:52:52 +020067 { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090068 { 0x0, "CPU" },
69};
70
Marek Vasut00e4b572018-12-03 13:28:25 +010071static int rmobile_cpuinfo_idx(void)
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +090072{
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090073 int i = 0;
74 u32 cpu_type = rmobile_get_cpu_type();
Marek Vasut00e4b572018-12-03 13:28:25 +010075
76 for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
77 if (rmobile_cpuinfo[i].cpu_type == cpu_type)
Nobuhiro Iwamatsu73ff6802014-03-28 11:54:22 +090078 break;
Marek Vasut00e4b572018-12-03 13:28:25 +010079
80 return i;
81}
82
83#ifdef CONFIG_ARCH_MISC_INIT
84int arch_misc_init(void)
85{
86 int i, idx = rmobile_cpuinfo_idx();
87 char cpu[10] = { 0 };
88
89 for (i = 0; i < sizeof(cpu); i++)
90 cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
91
92 env_set("platform", cpu);
93
94 return 0;
95}
96#endif
97
98int print_cpuinfo(void)
99{
100 int i = rmobile_cpuinfo_idx();
101
102 printf("CPU: Renesas Electronics %s rev %d.%d\n",
103 rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
104 rmobile_get_cpu_rev_fraction());
105
Nobuhiro Iwamatsu4fb44e22012-06-13 16:29:47 +0900106 return 0;
107}
Nobuhiro Iwamatsu1cdf2482012-08-19 04:40:05 +0000108#endif /* CONFIG_DISPLAY_CPUINFO */