Kuninori Morimoto | 41c4567 | 2018-09-07 02:04:19 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Renesas SoC Identification |
| 4 | * |
| 5 | * Copyright (C) 2014-2016 Glider bvba |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/io.h> |
| 9 | #include <linux/of.h> |
| 10 | #include <linux/of_address.h> |
| 11 | #include <linux/slab.h> |
| 12 | #include <linux/string.h> |
| 13 | #include <linux/sys_soc.h> |
| 14 | |
| 15 | |
| 16 | struct renesas_family { |
| 17 | const char name[16]; |
| 18 | u32 reg; /* CCCR or PRR, if not in DT */ |
| 19 | }; |
| 20 | |
| 21 | static const struct renesas_family fam_rcar_gen1 __initconst __maybe_unused = { |
| 22 | .name = "R-Car Gen1", |
| 23 | .reg = 0xff000044, /* PRR (Product Register) */ |
| 24 | }; |
| 25 | |
| 26 | static const struct renesas_family fam_rcar_gen2 __initconst __maybe_unused = { |
| 27 | .name = "R-Car Gen2", |
| 28 | .reg = 0xff000044, /* PRR (Product Register) */ |
| 29 | }; |
| 30 | |
| 31 | static const struct renesas_family fam_rcar_gen3 __initconst __maybe_unused = { |
| 32 | .name = "R-Car Gen3", |
| 33 | .reg = 0xfff00044, /* PRR (Product Register) */ |
| 34 | }; |
| 35 | |
Yoshihiro Shimoda | 9711633 | 2021-12-01 16:33:01 +0900 | [diff] [blame] | 36 | static const struct renesas_family fam_rcar_gen4 __initconst __maybe_unused = { |
| 37 | .name = "R-Car Gen4", |
| 38 | }; |
| 39 | |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 40 | static const struct renesas_family fam_rmobile __initconst __maybe_unused = { |
| 41 | .name = "R-Mobile", |
| 42 | .reg = 0xe600101c, /* CCCR (Common Chip Code Register) */ |
| 43 | }; |
| 44 | |
Chris Brandt | 175f435 | 2018-07-27 11:53:32 -0500 | [diff] [blame] | 45 | static const struct renesas_family fam_rza1 __initconst __maybe_unused = { |
| 46 | .name = "RZ/A1", |
| 47 | }; |
| 48 | |
| 49 | static const struct renesas_family fam_rza2 __initconst __maybe_unused = { |
| 50 | .name = "RZ/A2", |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 51 | }; |
| 52 | |
Biju Das | 2a4056a7 | 2018-07-24 16:47:18 +0100 | [diff] [blame] | 53 | static const struct renesas_family fam_rzg1 __initconst __maybe_unused = { |
| 54 | .name = "RZ/G1", |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 55 | .reg = 0xff000044, /* PRR (Product Register) */ |
| 56 | }; |
| 57 | |
Biju Das | 2a4056a7 | 2018-07-24 16:47:18 +0100 | [diff] [blame] | 58 | static const struct renesas_family fam_rzg2 __initconst __maybe_unused = { |
| 59 | .name = "RZ/G2", |
| 60 | .reg = 0xfff00044, /* PRR (Product Register) */ |
| 61 | }; |
| 62 | |
Lad Prabhakar | 187cd57 | 2021-06-09 17:37:16 +0100 | [diff] [blame] | 63 | static const struct renesas_family fam_rzg2l __initconst __maybe_unused = { |
| 64 | .name = "RZ/G2L", |
| 65 | }; |
| 66 | |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 67 | static const struct renesas_family fam_shmobile __initconst __maybe_unused = { |
| 68 | .name = "SH-Mobile", |
| 69 | .reg = 0xe600101c, /* CCCR (Common Chip Code Register) */ |
| 70 | }; |
| 71 | |
| 72 | |
| 73 | struct renesas_soc { |
| 74 | const struct renesas_family *family; |
Lad Prabhakar | 187cd57 | 2021-06-09 17:37:16 +0100 | [diff] [blame] | 75 | u32 id; |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | static const struct renesas_soc soc_rz_a1h __initconst __maybe_unused = { |
Chris Brandt | 175f435 | 2018-07-27 11:53:32 -0500 | [diff] [blame] | 79 | .family = &fam_rza1, |
| 80 | }; |
| 81 | |
| 82 | static const struct renesas_soc soc_rz_a2m __initconst __maybe_unused = { |
| 83 | .family = &fam_rza2, |
| 84 | .id = 0x3b, |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | static const struct renesas_soc soc_rmobile_ape6 __initconst __maybe_unused = { |
| 88 | .family = &fam_rmobile, |
| 89 | .id = 0x3f, |
| 90 | }; |
| 91 | |
| 92 | static const struct renesas_soc soc_rmobile_a1 __initconst __maybe_unused = { |
| 93 | .family = &fam_rmobile, |
| 94 | .id = 0x40, |
| 95 | }; |
| 96 | |
Geert Uytterhoeven | 8848e1b | 2017-03-10 14:48:29 +0100 | [diff] [blame] | 97 | static const struct renesas_soc soc_rz_g1h __initconst __maybe_unused = { |
Biju Das | 2a4056a7 | 2018-07-24 16:47:18 +0100 | [diff] [blame] | 98 | .family = &fam_rzg1, |
Geert Uytterhoeven | 8848e1b | 2017-03-10 14:48:29 +0100 | [diff] [blame] | 99 | .id = 0x45, |
| 100 | }; |
| 101 | |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 102 | static const struct renesas_soc soc_rz_g1m __initconst __maybe_unused = { |
Biju Das | 2a4056a7 | 2018-07-24 16:47:18 +0100 | [diff] [blame] | 103 | .family = &fam_rzg1, |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 104 | .id = 0x47, |
| 105 | }; |
| 106 | |
Geert Uytterhoeven | cd59de8 | 2017-03-10 14:48:30 +0100 | [diff] [blame] | 107 | static const struct renesas_soc soc_rz_g1n __initconst __maybe_unused = { |
Biju Das | 2a4056a7 | 2018-07-24 16:47:18 +0100 | [diff] [blame] | 108 | .family = &fam_rzg1, |
Geert Uytterhoeven | cd59de8 | 2017-03-10 14:48:30 +0100 | [diff] [blame] | 109 | .id = 0x4b, |
| 110 | }; |
| 111 | |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 112 | static const struct renesas_soc soc_rz_g1e __initconst __maybe_unused = { |
Biju Das | 2a4056a7 | 2018-07-24 16:47:18 +0100 | [diff] [blame] | 113 | .family = &fam_rzg1, |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 114 | .id = 0x4c, |
| 115 | }; |
| 116 | |
Biju Das | 1daf13b | 2018-03-27 15:37:13 +0100 | [diff] [blame] | 117 | static const struct renesas_soc soc_rz_g1c __initconst __maybe_unused = { |
Biju Das | 2a4056a7 | 2018-07-24 16:47:18 +0100 | [diff] [blame] | 118 | .family = &fam_rzg1, |
Biju Das | 1daf13b | 2018-03-27 15:37:13 +0100 | [diff] [blame] | 119 | .id = 0x53, |
| 120 | }; |
| 121 | |
Biju Das | 2a4056a7 | 2018-07-24 16:47:18 +0100 | [diff] [blame] | 122 | static const struct renesas_soc soc_rz_g2m __initconst __maybe_unused = { |
| 123 | .family = &fam_rzg2, |
| 124 | .id = 0x52, |
| 125 | }; |
| 126 | |
Biju Das | 574cb72 | 2019-09-05 10:30:42 +0100 | [diff] [blame] | 127 | static const struct renesas_soc soc_rz_g2n __initconst __maybe_unused = { |
| 128 | .family = &fam_rzg2, |
| 129 | .id = 0x55, |
| 130 | }; |
| 131 | |
Fabrizio Castro | 2bab3d8 | 2018-09-10 12:53:50 +0100 | [diff] [blame] | 132 | static const struct renesas_soc soc_rz_g2e __initconst __maybe_unused = { |
| 133 | .family = &fam_rzg2, |
| 134 | .id = 0x57, |
| 135 | }; |
| 136 | |
Marian-Cristian Rotariu | 5b83cc4 | 2020-07-07 17:18:01 +0100 | [diff] [blame] | 137 | static const struct renesas_soc soc_rz_g2h __initconst __maybe_unused = { |
| 138 | .family = &fam_rzg2, |
| 139 | .id = 0x4f, |
| 140 | }; |
| 141 | |
Lad Prabhakar | 187cd57 | 2021-06-09 17:37:16 +0100 | [diff] [blame] | 142 | static const struct renesas_soc soc_rz_g2l __initconst __maybe_unused = { |
| 143 | .family = &fam_rzg2l, |
| 144 | .id = 0x841c447, |
| 145 | }; |
| 146 | |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 147 | static const struct renesas_soc soc_rcar_m1a __initconst __maybe_unused = { |
| 148 | .family = &fam_rcar_gen1, |
| 149 | }; |
| 150 | |
| 151 | static const struct renesas_soc soc_rcar_h1 __initconst __maybe_unused = { |
| 152 | .family = &fam_rcar_gen1, |
| 153 | .id = 0x3b, |
| 154 | }; |
| 155 | |
| 156 | static const struct renesas_soc soc_rcar_h2 __initconst __maybe_unused = { |
| 157 | .family = &fam_rcar_gen2, |
| 158 | .id = 0x45, |
| 159 | }; |
| 160 | |
| 161 | static const struct renesas_soc soc_rcar_m2_w __initconst __maybe_unused = { |
| 162 | .family = &fam_rcar_gen2, |
| 163 | .id = 0x47, |
| 164 | }; |
| 165 | |
| 166 | static const struct renesas_soc soc_rcar_v2h __initconst __maybe_unused = { |
| 167 | .family = &fam_rcar_gen2, |
| 168 | .id = 0x4a, |
| 169 | }; |
| 170 | |
| 171 | static const struct renesas_soc soc_rcar_m2_n __initconst __maybe_unused = { |
| 172 | .family = &fam_rcar_gen2, |
| 173 | .id = 0x4b, |
| 174 | }; |
| 175 | |
| 176 | static const struct renesas_soc soc_rcar_e2 __initconst __maybe_unused = { |
| 177 | .family = &fam_rcar_gen2, |
| 178 | .id = 0x4c, |
| 179 | }; |
| 180 | |
| 181 | static const struct renesas_soc soc_rcar_h3 __initconst __maybe_unused = { |
| 182 | .family = &fam_rcar_gen3, |
| 183 | .id = 0x4f, |
| 184 | }; |
| 185 | |
| 186 | static const struct renesas_soc soc_rcar_m3_w __initconst __maybe_unused = { |
| 187 | .family = &fam_rcar_gen3, |
| 188 | .id = 0x52, |
| 189 | }; |
| 190 | |
Jacopo Mondi | bfd8398 | 2018-02-20 16:12:05 +0100 | [diff] [blame] | 191 | static const struct renesas_soc soc_rcar_m3_n __initconst __maybe_unused = { |
| 192 | .family = &fam_rcar_gen3, |
| 193 | .id = 0x55, |
| 194 | }; |
| 195 | |
Sergei Shtylyov | bb003075 | 2017-09-12 23:37:17 +0300 | [diff] [blame] | 196 | static const struct renesas_soc soc_rcar_v3m __initconst __maybe_unused = { |
| 197 | .family = &fam_rcar_gen3, |
| 198 | .id = 0x54, |
| 199 | }; |
| 200 | |
Sergei Shtylyov | 8447756 | 2018-02-02 21:22:14 +0300 | [diff] [blame] | 201 | static const struct renesas_soc soc_rcar_v3h __initconst __maybe_unused = { |
| 202 | .family = &fam_rcar_gen3, |
| 203 | .id = 0x56, |
| 204 | }; |
| 205 | |
Takeshi Kihara | 44842d4 | 2018-04-11 18:36:23 +0900 | [diff] [blame] | 206 | static const struct renesas_soc soc_rcar_e3 __initconst __maybe_unused = { |
| 207 | .family = &fam_rcar_gen3, |
| 208 | .id = 0x57, |
| 209 | }; |
| 210 | |
Geert Uytterhoeven | 1b95478 | 2017-07-20 14:34:51 +0200 | [diff] [blame] | 211 | static const struct renesas_soc soc_rcar_d3 __initconst __maybe_unused = { |
| 212 | .family = &fam_rcar_gen3, |
| 213 | .id = 0x58, |
| 214 | }; |
| 215 | |
Yoshihiro Shimoda | 090e87e | 2020-09-07 18:19:45 +0900 | [diff] [blame] | 216 | static const struct renesas_soc soc_rcar_v3u __initconst __maybe_unused = { |
| 217 | .family = &fam_rcar_gen3, |
| 218 | .id = 0x59, |
| 219 | }; |
| 220 | |
Yoshihiro Shimoda | 9711633 | 2021-12-01 16:33:01 +0900 | [diff] [blame] | 221 | static const struct renesas_soc soc_rcar_s4 __initconst __maybe_unused = { |
| 222 | .family = &fam_rcar_gen4, |
| 223 | .id = 0x5a, |
| 224 | }; |
| 225 | |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 226 | static const struct renesas_soc soc_shmobile_ag5 __initconst __maybe_unused = { |
| 227 | .family = &fam_shmobile, |
| 228 | .id = 0x37, |
| 229 | }; |
| 230 | |
| 231 | |
| 232 | static const struct of_device_id renesas_socs[] __initconst = { |
| 233 | #ifdef CONFIG_ARCH_R7S72100 |
| 234 | { .compatible = "renesas,r7s72100", .data = &soc_rz_a1h }, |
| 235 | #endif |
Chris Brandt | 175f435 | 2018-07-27 11:53:32 -0500 | [diff] [blame] | 236 | #ifdef CONFIG_ARCH_R7S9210 |
| 237 | { .compatible = "renesas,r7s9210", .data = &soc_rz_a2m }, |
| 238 | #endif |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 239 | #ifdef CONFIG_ARCH_R8A73A4 |
| 240 | { .compatible = "renesas,r8a73a4", .data = &soc_rmobile_ape6 }, |
| 241 | #endif |
| 242 | #ifdef CONFIG_ARCH_R8A7740 |
| 243 | { .compatible = "renesas,r8a7740", .data = &soc_rmobile_a1 }, |
| 244 | #endif |
Geert Uytterhoeven | 8848e1b | 2017-03-10 14:48:29 +0100 | [diff] [blame] | 245 | #ifdef CONFIG_ARCH_R8A7742 |
| 246 | { .compatible = "renesas,r8a7742", .data = &soc_rz_g1h }, |
| 247 | #endif |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 248 | #ifdef CONFIG_ARCH_R8A7743 |
| 249 | { .compatible = "renesas,r8a7743", .data = &soc_rz_g1m }, |
| 250 | #endif |
Geert Uytterhoeven | cd59de8 | 2017-03-10 14:48:30 +0100 | [diff] [blame] | 251 | #ifdef CONFIG_ARCH_R8A7744 |
| 252 | { .compatible = "renesas,r8a7744", .data = &soc_rz_g1n }, |
| 253 | #endif |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 254 | #ifdef CONFIG_ARCH_R8A7745 |
| 255 | { .compatible = "renesas,r8a7745", .data = &soc_rz_g1e }, |
| 256 | #endif |
Biju Das | 1daf13b | 2018-03-27 15:37:13 +0100 | [diff] [blame] | 257 | #ifdef CONFIG_ARCH_R8A77470 |
| 258 | { .compatible = "renesas,r8a77470", .data = &soc_rz_g1c }, |
| 259 | #endif |
Biju Das | 2a4056a7 | 2018-07-24 16:47:18 +0100 | [diff] [blame] | 260 | #ifdef CONFIG_ARCH_R8A774A1 |
| 261 | { .compatible = "renesas,r8a774a1", .data = &soc_rz_g2m }, |
| 262 | #endif |
Biju Das | 574cb72 | 2019-09-05 10:30:42 +0100 | [diff] [blame] | 263 | #ifdef CONFIG_ARCH_R8A774B1 |
| 264 | { .compatible = "renesas,r8a774b1", .data = &soc_rz_g2n }, |
| 265 | #endif |
Fabrizio Castro | 2bab3d8 | 2018-09-10 12:53:50 +0100 | [diff] [blame] | 266 | #ifdef CONFIG_ARCH_R8A774C0 |
| 267 | { .compatible = "renesas,r8a774c0", .data = &soc_rz_g2e }, |
| 268 | #endif |
Marian-Cristian Rotariu | 5b83cc4 | 2020-07-07 17:18:01 +0100 | [diff] [blame] | 269 | #ifdef CONFIG_ARCH_R8A774E1 |
| 270 | { .compatible = "renesas,r8a774e1", .data = &soc_rz_g2h }, |
| 271 | #endif |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 272 | #ifdef CONFIG_ARCH_R8A7778 |
| 273 | { .compatible = "renesas,r8a7778", .data = &soc_rcar_m1a }, |
| 274 | #endif |
| 275 | #ifdef CONFIG_ARCH_R8A7779 |
| 276 | { .compatible = "renesas,r8a7779", .data = &soc_rcar_h1 }, |
| 277 | #endif |
| 278 | #ifdef CONFIG_ARCH_R8A7790 |
| 279 | { .compatible = "renesas,r8a7790", .data = &soc_rcar_h2 }, |
| 280 | #endif |
| 281 | #ifdef CONFIG_ARCH_R8A7791 |
| 282 | { .compatible = "renesas,r8a7791", .data = &soc_rcar_m2_w }, |
| 283 | #endif |
| 284 | #ifdef CONFIG_ARCH_R8A7792 |
| 285 | { .compatible = "renesas,r8a7792", .data = &soc_rcar_v2h }, |
| 286 | #endif |
| 287 | #ifdef CONFIG_ARCH_R8A7793 |
| 288 | { .compatible = "renesas,r8a7793", .data = &soc_rcar_m2_n }, |
| 289 | #endif |
| 290 | #ifdef CONFIG_ARCH_R8A7794 |
| 291 | { .compatible = "renesas,r8a7794", .data = &soc_rcar_e2 }, |
| 292 | #endif |
Geert Uytterhoeven | 4ff2711 | 2020-02-18 12:24:49 +0100 | [diff] [blame] | 293 | #if defined(CONFIG_ARCH_R8A77950) || defined(CONFIG_ARCH_R8A77951) |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 294 | { .compatible = "renesas,r8a7795", .data = &soc_rcar_h3 }, |
| 295 | #endif |
Geert Uytterhoeven | bfe6b55 | 2021-07-19 17:38:33 +0200 | [diff] [blame] | 296 | #ifdef CONFIG_ARCH_R8A77951 |
Geert Uytterhoeven | 2ed1e48 | 2021-08-12 13:23:52 +0200 | [diff] [blame] | 297 | { .compatible = "renesas,r8a779m0", .data = &soc_rcar_h3 }, |
Geert Uytterhoeven | bfe6b55 | 2021-07-19 17:38:33 +0200 | [diff] [blame] | 298 | { .compatible = "renesas,r8a779m1", .data = &soc_rcar_h3 }, |
Geert Uytterhoeven | 2ed1e48 | 2021-08-12 13:23:52 +0200 | [diff] [blame] | 299 | { .compatible = "renesas,r8a779m8", .data = &soc_rcar_h3 }, |
Geert Uytterhoeven | bfe6b55 | 2021-07-19 17:38:33 +0200 | [diff] [blame] | 300 | #endif |
Geert Uytterhoeven | 39e57e1 | 2019-10-23 14:33:33 +0200 | [diff] [blame] | 301 | #ifdef CONFIG_ARCH_R8A77960 |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 302 | { .compatible = "renesas,r8a7796", .data = &soc_rcar_m3_w }, |
| 303 | #endif |
Geert Uytterhoeven | 9c9f789 | 2019-10-23 14:33:35 +0200 | [diff] [blame] | 304 | #ifdef CONFIG_ARCH_R8A77961 |
| 305 | { .compatible = "renesas,r8a77961", .data = &soc_rcar_m3_w }, |
Geert Uytterhoeven | 2ed1e48 | 2021-08-12 13:23:52 +0200 | [diff] [blame] | 306 | { .compatible = "renesas,r8a779m2", .data = &soc_rcar_m3_w }, |
Geert Uytterhoeven | bfe6b55 | 2021-07-19 17:38:33 +0200 | [diff] [blame] | 307 | { .compatible = "renesas,r8a779m3", .data = &soc_rcar_m3_w }, |
Geert Uytterhoeven | 9c9f789 | 2019-10-23 14:33:35 +0200 | [diff] [blame] | 308 | #endif |
Jacopo Mondi | bfd8398 | 2018-02-20 16:12:05 +0100 | [diff] [blame] | 309 | #ifdef CONFIG_ARCH_R8A77965 |
| 310 | { .compatible = "renesas,r8a77965", .data = &soc_rcar_m3_n }, |
Geert Uytterhoeven | 2ed1e48 | 2021-08-12 13:23:52 +0200 | [diff] [blame] | 311 | { .compatible = "renesas,r8a779m4", .data = &soc_rcar_m3_n }, |
| 312 | { .compatible = "renesas,r8a779m5", .data = &soc_rcar_m3_n }, |
Jacopo Mondi | bfd8398 | 2018-02-20 16:12:05 +0100 | [diff] [blame] | 313 | #endif |
Sergei Shtylyov | bb003075 | 2017-09-12 23:37:17 +0300 | [diff] [blame] | 314 | #ifdef CONFIG_ARCH_R8A77970 |
| 315 | { .compatible = "renesas,r8a77970", .data = &soc_rcar_v3m }, |
| 316 | #endif |
Sergei Shtylyov | 8447756 | 2018-02-02 21:22:14 +0300 | [diff] [blame] | 317 | #ifdef CONFIG_ARCH_R8A77980 |
| 318 | { .compatible = "renesas,r8a77980", .data = &soc_rcar_v3h }, |
| 319 | #endif |
Takeshi Kihara | 44842d4 | 2018-04-11 18:36:23 +0900 | [diff] [blame] | 320 | #ifdef CONFIG_ARCH_R8A77990 |
| 321 | { .compatible = "renesas,r8a77990", .data = &soc_rcar_e3 }, |
Geert Uytterhoeven | 2ed1e48 | 2021-08-12 13:23:52 +0200 | [diff] [blame] | 322 | { .compatible = "renesas,r8a779m6", .data = &soc_rcar_e3 }, |
Takeshi Kihara | 44842d4 | 2018-04-11 18:36:23 +0900 | [diff] [blame] | 323 | #endif |
Geert Uytterhoeven | 1b95478 | 2017-07-20 14:34:51 +0200 | [diff] [blame] | 324 | #ifdef CONFIG_ARCH_R8A77995 |
| 325 | { .compatible = "renesas,r8a77995", .data = &soc_rcar_d3 }, |
Geert Uytterhoeven | 2ed1e48 | 2021-08-12 13:23:52 +0200 | [diff] [blame] | 326 | { .compatible = "renesas,r8a779m7", .data = &soc_rcar_d3 }, |
Geert Uytterhoeven | 1b95478 | 2017-07-20 14:34:51 +0200 | [diff] [blame] | 327 | #endif |
Yoshihiro Shimoda | 090e87e | 2020-09-07 18:19:45 +0900 | [diff] [blame] | 328 | #ifdef CONFIG_ARCH_R8A779A0 |
| 329 | { .compatible = "renesas,r8a779a0", .data = &soc_rcar_v3u }, |
| 330 | #endif |
Yoshihiro Shimoda | 9711633 | 2021-12-01 16:33:01 +0900 | [diff] [blame] | 331 | #ifdef CONFIG_ARCH_R8A779F0 |
| 332 | { .compatible = "renesas,r8a779f0", .data = &soc_rcar_s4 }, |
| 333 | #endif |
Lad Prabhakar | 187cd57 | 2021-06-09 17:37:16 +0100 | [diff] [blame] | 334 | #if defined(CONFIG_ARCH_R9A07G044) |
| 335 | { .compatible = "renesas,r9a07g044", .data = &soc_rz_g2l }, |
| 336 | #endif |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 337 | #ifdef CONFIG_ARCH_SH73A0 |
| 338 | { .compatible = "renesas,sh73a0", .data = &soc_shmobile_ag5 }, |
| 339 | #endif |
| 340 | { /* sentinel */ } |
| 341 | }; |
| 342 | |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 343 | struct renesas_id { |
| 344 | unsigned int offset; |
| 345 | u32 mask; |
| 346 | }; |
| 347 | |
| 348 | static const struct renesas_id id_bsid __initconst = { |
| 349 | .offset = 0, |
| 350 | .mask = 0xff0000, |
| 351 | /* |
| 352 | * TODO: Upper 4 bits of BSID are for chip version, but the format is |
| 353 | * not known at this time so we don't know how to specify eshi and eslo |
| 354 | */ |
| 355 | }; |
| 356 | |
| 357 | static const struct renesas_id id_rzg2l __initconst = { |
| 358 | .offset = 0xa04, |
| 359 | .mask = 0xfffffff, |
| 360 | }; |
| 361 | |
| 362 | static const struct renesas_id id_prr __initconst = { |
| 363 | .offset = 0, |
| 364 | .mask = 0xff00, |
| 365 | }; |
| 366 | |
| 367 | static const struct of_device_id renesas_ids[] __initconst = { |
| 368 | { .compatible = "renesas,bsid", .data = &id_bsid }, |
| 369 | { .compatible = "renesas,r9a07g044-sysc", .data = &id_rzg2l }, |
| 370 | { .compatible = "renesas,prr", .data = &id_prr }, |
| 371 | { /* sentinel */ } |
| 372 | }; |
| 373 | |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 374 | static int __init renesas_soc_init(void) |
| 375 | { |
| 376 | struct soc_device_attribute *soc_dev_attr; |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 377 | unsigned int product, eshi = 0, eslo; |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 378 | const struct renesas_family *family; |
| 379 | const struct of_device_id *match; |
| 380 | const struct renesas_soc *soc; |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 381 | const struct renesas_id *id; |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 382 | void __iomem *chipid = NULL; |
| 383 | struct soc_device *soc_dev; |
| 384 | struct device_node *np; |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 385 | const char *soc_id; |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 386 | |
| 387 | match = of_match_node(renesas_socs, of_root); |
| 388 | if (!match) |
| 389 | return -ENODEV; |
| 390 | |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 391 | soc_id = strchr(match->compatible, ',') + 1; |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 392 | soc = match->data; |
| 393 | family = soc->family; |
| 394 | |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 395 | np = of_find_matching_node_and_match(NULL, renesas_ids, &match); |
Chris Brandt | 175f435 | 2018-07-27 11:53:32 -0500 | [diff] [blame] | 396 | if (np) { |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 397 | id = match->data; |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 398 | chipid = of_iomap(np, 0); |
| 399 | of_node_put(np); |
Geert Uytterhoeven | 4194b58 | 2019-10-16 16:33:06 +0200 | [diff] [blame] | 400 | } else if (soc->id && family->reg) { |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 401 | /* Try hardcoded CCCR/PRR fallback */ |
| 402 | id = &id_prr; |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 403 | chipid = ioremap(family->reg, 4); |
| 404 | } |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 405 | |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 406 | if (chipid) { |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 407 | product = readl(chipid + id->offset); |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 408 | iounmap(chipid); |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 409 | |
| 410 | if (id == &id_prr) { |
| 411 | /* R-Car M3-W ES1.1 incorrectly identifies as ES2.0 */ |
| 412 | if ((product & 0x7fff) == 0x5210) |
| 413 | product ^= 0x11; |
| 414 | /* R-Car M3-W ES1.3 incorrectly identifies as ES2.1 */ |
| 415 | if ((product & 0x7fff) == 0x5211) |
| 416 | product ^= 0x12; |
| 417 | |
| 418 | eshi = ((product >> 4) & 0x0f) + 1; |
| 419 | eslo = product & 0xf; |
| 420 | } |
| 421 | |
| 422 | if (soc->id && |
| 423 | ((product & id->mask) >> __ffs(id->mask)) != soc->id) { |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 424 | pr_warn("SoC mismatch (product = 0x%x)\n", product); |
| 425 | return -ENODEV; |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); |
| 430 | if (!soc_dev_attr) |
| 431 | return -ENOMEM; |
| 432 | |
| 433 | np = of_find_node_by_path("/"); |
| 434 | of_property_read_string(np, "model", &soc_dev_attr->machine); |
| 435 | of_node_put(np); |
| 436 | |
| 437 | soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL); |
Geert Uytterhoeven | 05b22ca | 2021-11-10 20:00:52 +0100 | [diff] [blame] | 438 | soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL); |
Chris Brandt | 175f435 | 2018-07-27 11:53:32 -0500 | [diff] [blame] | 439 | if (eshi) |
| 440 | soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", eshi, |
| 441 | eslo); |
Geert Uytterhoeven | 8d6799a | 2016-11-14 19:37:08 +0100 | [diff] [blame] | 442 | |
| 443 | pr_info("Detected Renesas %s %s %s\n", soc_dev_attr->family, |
| 444 | soc_dev_attr->soc_id, soc_dev_attr->revision ?: ""); |
| 445 | |
| 446 | soc_dev = soc_device_register(soc_dev_attr); |
| 447 | if (IS_ERR(soc_dev)) { |
| 448 | kfree(soc_dev_attr->revision); |
| 449 | kfree_const(soc_dev_attr->soc_id); |
| 450 | kfree_const(soc_dev_attr->family); |
| 451 | kfree(soc_dev_attr); |
| 452 | return PTR_ERR(soc_dev); |
| 453 | } |
| 454 | |
| 455 | return 0; |
| 456 | } |
Geert Uytterhoeven | b1d134b | 2017-03-31 11:01:54 +0200 | [diff] [blame] | 457 | early_initcall(renesas_soc_init); |