1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
4  * (C) Copyright 2012 Renesas Solutions Corp.
5  */
6 #include <common.h>
7 #include <asm/io.h>
8 
9 /* R-Car Gen3 caches are enabled in memmap-gen3.c */
10 #ifndef CONFIG_RCAR_GEN3
11 #ifdef CONFIG_ARCH_CPU_INIT
12 int arch_cpu_init(void)
13 {
14 	icache_enable();
15 	return 0;
16 }
17 #endif
18 
19 #ifndef CONFIG_SYS_DCACHE_OFF
20 void enable_caches(void)
21 {
22 	dcache_enable();
23 }
24 #endif
25 #endif
26 
27 #ifdef CONFIG_DISPLAY_CPUINFO
28 static u32 __rmobile_get_cpu_type(void)
29 {
30 	return 0x0;
31 }
32 u32 rmobile_get_cpu_type(void)
33 		__attribute__((weak, alias("__rmobile_get_cpu_type")));
34 
35 static u32 __rmobile_get_cpu_rev_integer(void)
36 {
37 	return 0;
38 }
39 u32 rmobile_get_cpu_rev_integer(void)
40 		__attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
41 
42 static u32 __rmobile_get_cpu_rev_fraction(void)
43 {
44 	return 0;
45 }
46 u32 rmobile_get_cpu_rev_fraction(void)
47 		__attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
48 
49 /* CPU infomation table */
50 static const struct {
51 	u16 cpu_type;
52 	u8 cpu_name[10];
53 } rmobile_cpuinfo[] = {
54 	{ RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
55 	{ RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
56 	{ RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
57 	{ RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
58 	{ RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
59 	{ RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
60 	{ RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
61 	{ RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
62 	{ RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
63 	{ RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
64 	{ RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
65 	{ RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
66 	{ RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
67 	{ 0x0, "CPU" },
68 };
69 
70 int print_cpuinfo(void)
71 {
72 	int i = 0;
73 	u32 cpu_type = rmobile_get_cpu_type();
74 	for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++) {
75 		if (rmobile_cpuinfo[i].cpu_type == cpu_type) {
76 			printf("CPU: Renesas Electronics %s rev %d.%d\n",
77 			       rmobile_cpuinfo[i].cpu_name,
78 			       rmobile_get_cpu_rev_integer(),
79 			       rmobile_get_cpu_rev_fraction());
80 			break;
81 		}
82 	}
83 	return 0;
84 }
85 #endif /* CONFIG_DISPLAY_CPUINFO */
86