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