blob: fdbbd72e2857acbc54092499c4de7b670f04536f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsuf3db9da2012-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 Iwamatsuf3db9da2012-06-13 16:29:47 +09005 */
6#include <common.h>
Simon Glass1d91ba72019-11-14 12:57:37 -07007#include <cpu_func.h>
Simon Glass274e0b02020-05-10 11:39:56 -06008#include <asm/cache.h>
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090010#include <asm/io.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060011#include <env.h>
Marek Vasutb90dc692018-12-03 13:28:25 +010012#include <linux/ctype.h>
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090013
14#ifdef CONFIG_ARCH_CPU_INIT
15int arch_cpu_init(void)
16{
17 icache_enable();
18 return 0;
19}
20#endif
21
Takeshi Kiharacb048902018-12-04 11:53:24 +090022/* R-Car Gen3 D-cache is enabled in memmap-gen3.c */
23#ifndef CONFIG_RCAR_GEN3
Trevor Woerner43ec7e02019-05-03 09:41:00 -040024#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090025void enable_caches(void)
26{
27 dcache_enable();
28}
29#endif
Marek Vasut970fd8c2018-10-31 15:06:50 +010030#endif
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090031
32#ifdef CONFIG_DISPLAY_CPUINFO
Chris Brandt43b11d92017-08-23 14:53:59 -050033#ifndef CONFIG_RZA1
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000034static u32 __rmobile_get_cpu_type(void)
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090035{
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000036 return 0x0;
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090037}
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000038u32 rmobile_get_cpu_type(void)
39 __attribute__((weak, alias("__rmobile_get_cpu_type")));
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090040
Tetsuyuki Kobayashi7811e542012-07-25 18:24:21 +000041static u32 __rmobile_get_cpu_rev_integer(void)
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090042{
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000043 return 0;
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090044}
Tetsuyuki Kobayashi7811e542012-07-25 18:24:21 +000045u32 rmobile_get_cpu_rev_integer(void)
46 __attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
47
48static u32 __rmobile_get_cpu_rev_fraction(void)
49{
50 return 0;
51}
52u32 rmobile_get_cpu_rev_fraction(void)
53 __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090054
Nobuhiro Iwamatsu524ed8b2014-03-28 11:54:22 +090055/* CPU infomation table */
56static const struct {
57 u16 cpu_type;
58 u8 cpu_name[10];
59} rmobile_cpuinfo[] = {
Marek Vasutb8f814b2017-11-25 23:54:10 +010060 { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
61 { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
62 { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
63 { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
64 { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
65 { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
66 { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
67 { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
68 { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
Marek Vasut1ecc0bd2018-02-26 10:35:15 +010069 { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
Marek Vasut46175fc2017-10-09 20:39:47 +020070 { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
Marek Vasutcf567852019-07-29 19:59:44 +020071 { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" },
Marek Vasut001dbf32018-04-26 10:09:06 +020072 { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
Marek Vasut04cd2e22017-10-08 20:52:52 +020073 { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
Nobuhiro Iwamatsu524ed8b2014-03-28 11:54:22 +090074 { 0x0, "CPU" },
75};
76
Marek Vasutb90dc692018-12-03 13:28:25 +010077static int rmobile_cpuinfo_idx(void)
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +090078{
Nobuhiro Iwamatsu524ed8b2014-03-28 11:54:22 +090079 int i = 0;
80 u32 cpu_type = rmobile_get_cpu_type();
Marek Vasutb90dc692018-12-03 13:28:25 +010081
82 for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
83 if (rmobile_cpuinfo[i].cpu_type == cpu_type)
Nobuhiro Iwamatsu524ed8b2014-03-28 11:54:22 +090084 break;
Marek Vasutb90dc692018-12-03 13:28:25 +010085
86 return i;
87}
88
89#ifdef CONFIG_ARCH_MISC_INIT
90int arch_misc_init(void)
91{
92 int i, idx = rmobile_cpuinfo_idx();
93 char cpu[10] = { 0 };
94
95 for (i = 0; i < sizeof(cpu); i++)
96 cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
97
98 env_set("platform", cpu);
99
100 return 0;
101}
102#endif
103
104int print_cpuinfo(void)
105{
106 int i = rmobile_cpuinfo_idx();
107
108 printf("CPU: Renesas Electronics %s rev %d.%d\n",
109 rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
110 rmobile_get_cpu_rev_fraction());
111
Nobuhiro Iwamatsuf3db9da2012-06-13 16:29:47 +0900112 return 0;
113}
Chris Brandt43b11d92017-08-23 14:53:59 -0500114#else
115int print_cpuinfo(void)
116{
117 printf("CPU: Renesas Electronics RZ/A1\n");
118 return 0;
119}
120#endif
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +0000121#endif /* CONFIG_DISPLAY_CPUINFO */