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 |
Trevor Woerner | 43ec7e0 | 2019-05-03 09:41:00 -0400 | [diff] [blame] | 20 | #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 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 | cf56785 | 2019-07-29 19:59:44 +0200 | [diff] [blame^] | 67 | { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" }, |
Marek Vasut | 001dbf3 | 2018-04-26 10:09:06 +0200 | [diff] [blame] | 68 | { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" }, |
Marek Vasut | 04cd2e2 | 2017-10-08 20:52:52 +0200 | [diff] [blame] | 69 | { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" }, |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 70 | { 0x0, "CPU" }, |
| 71 | }; |
| 72 | |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 73 | static int rmobile_cpuinfo_idx(void) |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 74 | { |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 75 | int i = 0; |
| 76 | u32 cpu_type = rmobile_get_cpu_type(); |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 77 | |
| 78 | for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++) |
| 79 | if (rmobile_cpuinfo[i].cpu_type == cpu_type) |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 80 | break; |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 81 | |
| 82 | return i; |
| 83 | } |
| 84 | |
| 85 | #ifdef CONFIG_ARCH_MISC_INIT |
| 86 | int arch_misc_init(void) |
| 87 | { |
| 88 | int i, idx = rmobile_cpuinfo_idx(); |
| 89 | char cpu[10] = { 0 }; |
| 90 | |
| 91 | for (i = 0; i < sizeof(cpu); i++) |
| 92 | cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]); |
| 93 | |
| 94 | env_set("platform", cpu); |
| 95 | |
| 96 | return 0; |
| 97 | } |
| 98 | #endif |
| 99 | |
| 100 | int print_cpuinfo(void) |
| 101 | { |
| 102 | int i = rmobile_cpuinfo_idx(); |
| 103 | |
| 104 | printf("CPU: Renesas Electronics %s rev %d.%d\n", |
| 105 | rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(), |
| 106 | rmobile_get_cpu_rev_fraction()); |
| 107 | |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 108 | return 0; |
| 109 | } |
Chris Brandt | 43b11d9 | 2017-08-23 14:53:59 -0500 | [diff] [blame] | 110 | #else |
| 111 | int print_cpuinfo(void) |
| 112 | { |
| 113 | printf("CPU: Renesas Electronics RZ/A1\n"); |
| 114 | return 0; |
| 115 | } |
| 116 | #endif |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 117 | #endif /* CONFIG_DISPLAY_CPUINFO */ |