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> |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 8 | #include <asm/io.h> |
Simon Glass | 9fb625c | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 9 | #include <env.h> |
Marek Vasut | 00e4b57 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 10 | #include <linux/ctype.h> |
Nobuhiro Iwamatsu | 4fb44e2 | 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 | 5055a4e | 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 | 1001502 | 2019-05-03 09:41:00 -0400 | [diff] [blame] | 22 | #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 23 | void enable_caches(void) |
| 24 | { |
| 25 | dcache_enable(); |
| 26 | } |
| 27 | #endif |
Marek Vasut | e5cb6bd | 2018-10-31 15:06:50 +0100 | [diff] [blame] | 28 | #endif |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 29 | |
| 30 | #ifdef CONFIG_DISPLAY_CPUINFO |
Chris Brandt | 3529596 | 2017-08-23 14:53:59 -0500 | [diff] [blame] | 31 | #ifndef CONFIG_RZA1 |
Nobuhiro Iwamatsu | 1cdf248 | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 32 | static u32 __rmobile_get_cpu_type(void) |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 33 | { |
Nobuhiro Iwamatsu | 1cdf248 | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 34 | return 0x0; |
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 | u32 rmobile_get_cpu_type(void) |
| 37 | __attribute__((weak, alias("__rmobile_get_cpu_type"))); |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 38 | |
Tetsuyuki Kobayashi | 4f007b8 | 2012-07-25 18:24:21 +0000 | [diff] [blame] | 39 | static u32 __rmobile_get_cpu_rev_integer(void) |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 40 | { |
Nobuhiro Iwamatsu | 1cdf248 | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 41 | return 0; |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 42 | } |
Tetsuyuki Kobayashi | 4f007b8 | 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 | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 52 | |
Nobuhiro Iwamatsu | 73ff680 | 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 | 262e915 | 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 | f295a56 | 2018-02-26 10:35:15 +0100 | [diff] [blame] | 67 | { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" }, |
Marek Vasut | 5cb19e7 | 2017-10-09 20:39:47 +0200 | [diff] [blame] | 68 | { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" }, |
Marek Vasut | 57ede1a | 2019-07-29 19:59:44 +0200 | [diff] [blame] | 69 | { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" }, |
Marek Vasut | a0410a6 | 2018-04-26 10:09:06 +0200 | [diff] [blame] | 70 | { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" }, |
Marek Vasut | 1154541 | 2017-10-08 20:52:52 +0200 | [diff] [blame] | 71 | { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" }, |
Nobuhiro Iwamatsu | 73ff680 | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 72 | { 0x0, "CPU" }, |
| 73 | }; |
| 74 | |
Marek Vasut | 00e4b57 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 75 | static int rmobile_cpuinfo_idx(void) |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 76 | { |
Nobuhiro Iwamatsu | 73ff680 | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 77 | int i = 0; |
| 78 | u32 cpu_type = rmobile_get_cpu_type(); |
Marek Vasut | 00e4b57 | 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 | 73ff680 | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 82 | break; |
Marek Vasut | 00e4b57 | 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 | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 110 | return 0; |
| 111 | } |
Chris Brandt | 3529596 | 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 | 1cdf248 | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 119 | #endif /* CONFIG_DISPLAY_CPUINFO */ |