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> |
| 7 | #include <asm/io.h> |
Marek Vasut | 00e4b57 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 8 | #include <linux/ctype.h> |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 9 | |
Marek Vasut | e5cb6bd | 2018-10-31 15:06:50 +0100 | [diff] [blame] | 10 | /* R-Car Gen3 caches are enabled in memmap-gen3.c */ |
| 11 | #ifndef CONFIG_RCAR_GEN3 |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 12 | #ifdef CONFIG_ARCH_CPU_INIT |
| 13 | int arch_cpu_init(void) |
| 14 | { |
| 15 | icache_enable(); |
| 16 | return 0; |
| 17 | } |
| 18 | #endif |
| 19 | |
| 20 | #ifndef CONFIG_SYS_DCACHE_OFF |
| 21 | void enable_caches(void) |
| 22 | { |
| 23 | dcache_enable(); |
| 24 | } |
| 25 | #endif |
Marek Vasut | e5cb6bd | 2018-10-31 15:06:50 +0100 | [diff] [blame] | 26 | #endif |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 27 | |
| 28 | #ifdef CONFIG_DISPLAY_CPUINFO |
Nobuhiro Iwamatsu | 1cdf248 | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 29 | static u32 __rmobile_get_cpu_type(void) |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 30 | { |
Nobuhiro Iwamatsu | 1cdf248 | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 31 | return 0x0; |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 32 | } |
Nobuhiro Iwamatsu | 1cdf248 | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 33 | u32 rmobile_get_cpu_type(void) |
| 34 | __attribute__((weak, alias("__rmobile_get_cpu_type"))); |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 35 | |
Tetsuyuki Kobayashi | 4f007b8 | 2012-07-25 18:24:21 +0000 | [diff] [blame] | 36 | static u32 __rmobile_get_cpu_rev_integer(void) |
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 | return 0; |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 39 | } |
Tetsuyuki Kobayashi | 4f007b8 | 2012-07-25 18:24:21 +0000 | [diff] [blame] | 40 | u32 rmobile_get_cpu_rev_integer(void) |
| 41 | __attribute__((weak, alias("__rmobile_get_cpu_rev_integer"))); |
| 42 | |
| 43 | static u32 __rmobile_get_cpu_rev_fraction(void) |
| 44 | { |
| 45 | return 0; |
| 46 | } |
| 47 | u32 rmobile_get_cpu_rev_fraction(void) |
| 48 | __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction"))); |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 49 | |
Nobuhiro Iwamatsu | 73ff680 | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 50 | /* CPU infomation table */ |
| 51 | static const struct { |
| 52 | u16 cpu_type; |
| 53 | u8 cpu_name[10]; |
| 54 | } rmobile_cpuinfo[] = { |
Marek Vasut | 262e915 | 2017-11-25 23:54:10 +0100 | [diff] [blame] | 55 | { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" }, |
| 56 | { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" }, |
| 57 | { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" }, |
| 58 | { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" }, |
| 59 | { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" }, |
| 60 | { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" }, |
| 61 | { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" }, |
| 62 | { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" }, |
| 63 | { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" }, |
Marek Vasut | f295a56 | 2018-02-26 10:35:15 +0100 | [diff] [blame] | 64 | { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" }, |
Marek Vasut | 5cb19e7 | 2017-10-09 20:39:47 +0200 | [diff] [blame] | 65 | { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" }, |
Marek Vasut | a0410a6 | 2018-04-26 10:09:06 +0200 | [diff] [blame] | 66 | { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" }, |
Marek Vasut | 1154541 | 2017-10-08 20:52:52 +0200 | [diff] [blame] | 67 | { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" }, |
Nobuhiro Iwamatsu | 73ff680 | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 68 | { 0x0, "CPU" }, |
| 69 | }; |
| 70 | |
Marek Vasut | 00e4b57 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 71 | static int rmobile_cpuinfo_idx(void) |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 72 | { |
Nobuhiro Iwamatsu | 73ff680 | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 73 | int i = 0; |
| 74 | u32 cpu_type = rmobile_get_cpu_type(); |
Marek Vasut | 00e4b57 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 75 | |
| 76 | for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++) |
| 77 | if (rmobile_cpuinfo[i].cpu_type == cpu_type) |
Nobuhiro Iwamatsu | 73ff680 | 2014-03-28 11:54:22 +0900 | [diff] [blame] | 78 | break; |
Marek Vasut | 00e4b57 | 2018-12-03 13:28:25 +0100 | [diff] [blame] | 79 | |
| 80 | return i; |
| 81 | } |
| 82 | |
| 83 | #ifdef CONFIG_ARCH_MISC_INIT |
| 84 | int arch_misc_init(void) |
| 85 | { |
| 86 | int i, idx = rmobile_cpuinfo_idx(); |
| 87 | char cpu[10] = { 0 }; |
| 88 | |
| 89 | for (i = 0; i < sizeof(cpu); i++) |
| 90 | cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]); |
| 91 | |
| 92 | env_set("platform", cpu); |
| 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | #endif |
| 97 | |
| 98 | int print_cpuinfo(void) |
| 99 | { |
| 100 | int i = rmobile_cpuinfo_idx(); |
| 101 | |
| 102 | printf("CPU: Renesas Electronics %s rev %d.%d\n", |
| 103 | rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(), |
| 104 | rmobile_get_cpu_rev_fraction()); |
| 105 | |
Nobuhiro Iwamatsu | 4fb44e2 | 2012-06-13 16:29:47 +0900 | [diff] [blame] | 106 | return 0; |
| 107 | } |
Nobuhiro Iwamatsu | 1cdf248 | 2012-08-19 04:40:05 +0000 | [diff] [blame] | 108 | #endif /* CONFIG_DISPLAY_CPUINFO */ |