]> git.ipfire.org Git - thirdparty/u-boot.git/blob - arch/arm/mach-rmobile/cpu_info.c
CONFIG_SPL_SYS_[DI]CACHE_OFF: add
[thirdparty/u-boot.git] / arch / arm / mach-rmobile / cpu_info.c
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 #include <linux/ctype.h>
9
10 #ifdef CONFIG_ARCH_CPU_INIT
11 int arch_cpu_init(void)
12 {
13 icache_enable();
14 return 0;
15 }
16 #endif
17
18 /* R-Car Gen3 D-cache is enabled in memmap-gen3.c */
19 #ifndef CONFIG_RCAR_GEN3
20 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
21 void enable_caches(void)
22 {
23 dcache_enable();
24 }
25 #endif
26 #endif
27
28 #ifdef CONFIG_DISPLAY_CPUINFO
29 #ifndef CONFIG_RZA1
30 static u32 __rmobile_get_cpu_type(void)
31 {
32 return 0x0;
33 }
34 u32 rmobile_get_cpu_type(void)
35 __attribute__((weak, alias("__rmobile_get_cpu_type")));
36
37 static u32 __rmobile_get_cpu_rev_integer(void)
38 {
39 return 0;
40 }
41 u32 rmobile_get_cpu_rev_integer(void)
42 __attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
43
44 static u32 __rmobile_get_cpu_rev_fraction(void)
45 {
46 return 0;
47 }
48 u32 rmobile_get_cpu_rev_fraction(void)
49 __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
50
51 /* CPU infomation table */
52 static const struct {
53 u16 cpu_type;
54 u8 cpu_name[10];
55 } rmobile_cpuinfo[] = {
56 { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
57 { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
58 { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
59 { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
60 { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
61 { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
62 { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
63 { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
64 { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
65 { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
66 { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
67 { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
68 { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
69 { 0x0, "CPU" },
70 };
71
72 static int rmobile_cpuinfo_idx(void)
73 {
74 int i = 0;
75 u32 cpu_type = rmobile_get_cpu_type();
76
77 for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
78 if (rmobile_cpuinfo[i].cpu_type == cpu_type)
79 break;
80
81 return i;
82 }
83
84 #ifdef CONFIG_ARCH_MISC_INIT
85 int arch_misc_init(void)
86 {
87 int i, idx = rmobile_cpuinfo_idx();
88 char cpu[10] = { 0 };
89
90 for (i = 0; i < sizeof(cpu); i++)
91 cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
92
93 env_set("platform", cpu);
94
95 return 0;
96 }
97 #endif
98
99 int print_cpuinfo(void)
100 {
101 int i = rmobile_cpuinfo_idx();
102
103 printf("CPU: Renesas Electronics %s rev %d.%d\n",
104 rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
105 rmobile_get_cpu_rev_fraction());
106
107 return 0;
108 }
109 #else
110 int print_cpuinfo(void)
111 {
112 printf("CPU: Renesas Electronics RZ/A1\n");
113 return 0;
114 }
115 #endif
116 #endif /* CONFIG_DISPLAY_CPUINFO */