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> |
Simon Glass | 1d91ba7 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 7 | #include <cpu_func.h> |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 8 | #include <asm/io.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 9 | #include <env.h> |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 10 | #include <linux/ctype.h> |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 11 | |
| 12 | #ifdef CONFIG_ARCH_CPU_INIT |
| 13 | int arch_cpu_init(void) |
| 14 | { |
| 15 | icache_enable(); |
| 16 | return 0; |
| 17 | } |
| 18 | #endif |
| 19 | |
Takeshi Kihara | cb04890 | 2018-12-04 11:53:24 +0900 | [diff] [blame] | 20 | /* R-Car Gen3 D-cache is enabled in memmap-gen3.c */ |
| 21 | #ifndef CONFIG_RCAR_GEN3 |
Trevor Woerner | 43ec7e0 | 2019-05-03 09:41:00 -0400 | [diff] [blame] | 22 | #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 23 | void enable_caches(void) |
| 24 | { |
| 25 | dcache_enable(); |
| 26 | } |
| 27 | #endif |
Marek Vasut | 970fd8c | 2018-10-31 15:06:50 +0100 | [diff] [blame] | 28 | #endif |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 29 | |
| 30 | #ifdef CONFIG_DISPLAY_CPUINFO |
Chris Brandt | 43b11d9 | 2017-08-23 14:53:59 -0500 | [diff] [blame] | 31 | #ifndef CONFIG_RZA1 |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 32 | static u32 __rmobile_get_cpu_type(void) |
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 | return 0x0; |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 35 | } |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 36 | u32 rmobile_get_cpu_type(void) |
| 37 | __attribute__((weak, alias("__rmobile_get_cpu_type"))); |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 38 | |
Tetsuyuki Kobayashi | 7811e54 | 2012-07-25 18:24:21 +0000 | [diff] [blame] | 39 | static u32 __rmobile_get_cpu_rev_integer(void) |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 40 | { |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 41 | return 0; |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 42 | } |
Tetsuyuki Kobayashi | 7811e54 | 2012-07-25 18:24:21 +0000 | [diff] [blame] | 43 | u32 rmobile_get_cpu_rev_integer(void) |
| 44 | __attribute__((weak, alias("__rmobile_get_cpu_rev_integer"))); |
| 45 | |
| 46 | static u32 __rmobile_get_cpu_rev_fraction(void) |
| 47 | { |
| 48 | return 0; |
| 49 | } |
| 50 | u32 rmobile_get_cpu_rev_fraction(void) |
| 51 | __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction"))); |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 52 | |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 53 | /* CPU infomation table */ |
| 54 | static const struct { |
| 55 | u16 cpu_type; |
| 56 | u8 cpu_name[10]; |
| 57 | } rmobile_cpuinfo[] = { |
Marek Vasut | b8f814b | 2017-11-25 23:54:10 +0100 | [diff] [blame] | 58 | { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" }, |
| 59 | { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" }, |
| 60 | { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" }, |
| 61 | { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" }, |
| 62 | { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" }, |
| 63 | { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" }, |
| 64 | { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" }, |
| 65 | { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" }, |
| 66 | { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" }, |
Marek Vasut | 1ecc0bd | 2018-02-26 10:35:15 +0100 | [diff] [blame] | 67 | { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" }, |
Marek Vasut | 46175fc | 2017-10-09 20:39:47 +0200 | [diff] [blame] | 68 | { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" }, |
Marek Vasut | cf56785 | 2019-07-29 19:59:44 +0200 | [diff] [blame] | 69 | { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" }, |
Marek Vasut | 001dbf3 | 2018-04-26 10:09:06 +0200 | [diff] [blame] | 70 | { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" }, |
Marek Vasut | 04cd2e2 | 2017-10-08 20:52:52 +0200 | [diff] [blame] | 71 | { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" }, |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 72 | { 0x0, "CPU" }, |
| 73 | }; |
| 74 | |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 75 | static int rmobile_cpuinfo_idx(void) |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 76 | { |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 77 | int i = 0; |
| 78 | u32 cpu_type = rmobile_get_cpu_type(); |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 79 | |
| 80 | for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++) |
| 81 | if (rmobile_cpuinfo[i].cpu_type == cpu_type) |
Nobuhiro Iwamatsu | 524ed8b | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 82 | break; |
Marek Vasut | b90dc69 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 83 | |
| 84 | return i; |
| 85 | } |
| 86 | |
| 87 | #ifdef CONFIG_ARCH_MISC_INIT |
| 88 | int arch_misc_init(void) |
| 89 | { |
| 90 | int i, idx = rmobile_cpuinfo_idx(); |
| 91 | char cpu[10] = { 0 }; |
| 92 | |
| 93 | for (i = 0; i < sizeof(cpu); i++) |
| 94 | cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]); |
| 95 | |
| 96 | env_set("platform", cpu); |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | #endif |
| 101 | |
| 102 | int print_cpuinfo(void) |
| 103 | { |
| 104 | int i = rmobile_cpuinfo_idx(); |
| 105 | |
| 106 | printf("CPU: Renesas Electronics %s rev %d.%d\n", |
| 107 | rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(), |
| 108 | rmobile_get_cpu_rev_fraction()); |
| 109 | |
Nobuhiro Iwamatsu | f3db9da | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 110 | return 0; |
| 111 | } |
Chris Brandt | 43b11d9 | 2017-08-23 14:53:59 -0500 | [diff] [blame] | 112 | #else |
| 113 | int print_cpuinfo(void) |
| 114 | { |
| 115 | printf("CPU: Renesas Electronics RZ/A1\n"); |
| 116 | return 0; |
| 117 | } |
| 118 | #endif |
Nobuhiro Iwamatsu | 940103d | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 119 | #endif /* CONFIG_DISPLAY_CPUINFO */ |