Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> |
| 4 | * (C) Copyright 2012 Renesas Solutions Corp. |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 5 | */ |
| 6 | #include <common.h> |
| 7 | #include <asm/io.h> |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 8 | #include <linux/ctype.h> |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 9 | |
| 10 | #ifdef CONFIG_ARCH_CPU_INIT |
| 11 | int arch_cpu_init(void) |
| 12 | { |
| 13 | icache_enable(); |
| 14 | return 0; |
| 15 | } |
| 16 | #endif |
| 17 | |
Takeshi Kihara | cb04890 | 2018-12-04 11:53:24 +0900 | [diff] [blame] | 18 | /* R-Car Gen3 D-cache is enabled in memmap-gen3.c */ |
| 19 | #ifndef CONFIG_RCAR_GEN3 |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 20 | #ifndef CONFIG_SYS_DCACHE_OFF |
| 21 | void enable_caches(void) |
| 22 | { |
| 23 | dcache_enable(); |
| 24 | } |
| 25 | #endif |
Marek Vasut | 970fd8c | 2018-10-31 15:06:50 +0100 | [diff] [blame] | 26 | #endif |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 27 | |
| 28 | #ifdef CONFIG_DISPLAY_CPUINFO |
Chris Brandt | 43b11d9 | 2017-08-23 14:53:59 -0500 | [diff] [blame^] | 29 | #ifndef CONFIG_RZA1 |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 30 | static u32 __rmobile_get_cpu_type(void) |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 31 | { |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 32 | return 0x0; |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 33 | } |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 34 | u32 rmobile_get_cpu_type(void) |
| 35 | __attribute__((weak, alias("__rmobile_get_cpu_type"))); |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 36 | |
Tetsuyuki Kobayashi | 7811e54 | 2012-07-25 18:24:21 +0000 | [diff] [blame] | 37 | static u32 __rmobile_get_cpu_rev_integer(void) |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 38 | { |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 39 | return 0; |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 40 | } |
Tetsuyuki Kobayashi | 7811e54 | 2012-07-25 18:24:21 +0000 | [diff] [blame] | 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"))); |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 50 | |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 51 | /* CPU infomation table */ |
| 52 | static const struct { |
| 53 | u16 cpu_type; |
| 54 | u8 cpu_name[10]; |
| 55 | } rmobile_cpuinfo[] = { |
Marek Vasut | b8f814b | 2017-11-25 23:54:10 +0100 | [diff] [blame] | 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" }, |
Marek Vasut | 1ecc0bd | 2018-02-26 10:35:15 +0100 | [diff] [blame] | 65 | { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" }, |
Marek Vasut | 46175fc | 2017-10-09 20:39:47 +0200 | [diff] [blame] | 66 | { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" }, |
Marek Vasut | 001dbf3 | 2018-04-26 10:09:06 +0200 | [diff] [blame] | 67 | { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" }, |
Marek Vasut | 04cd2e2 | 2017-10-08 20:52:52 +0200 | [diff] [blame] | 68 | { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" }, |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 69 | { 0x0, "CPU" }, |
| 70 | }; |
| 71 | |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 72 | static int rmobile_cpuinfo_idx(void) |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 73 | { |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 74 | int i = 0; |
| 75 | u32 cpu_type = rmobile_get_cpu_type(); |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 76 | |
| 77 | for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++) |
| 78 | if (rmobile_cpuinfo[i].cpu_type == cpu_type) |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 79 | break; |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 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 | |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 107 | return 0; |
| 108 | } |
Chris Brandt | 43b11d9 | 2017-08-23 14:53:59 -0500 | [diff] [blame^] | 109 | #else |
| 110 | int print_cpuinfo(void) |
| 111 | { |
| 112 | printf("CPU: Renesas Electronics RZ/A1\n"); |
| 113 | return 0; |
| 114 | } |
| 115 | #endif |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 116 | #endif /* CONFIG_DISPLAY_CPUINFO */ |