.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * Renesas SoC Identification |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2014-2016 Glider bvba |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; version 2 of the License. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | 6 | */ |
---|
15 | 7 | |
---|
16 | 8 | #include <linux/io.h> |
---|
.. | .. |
---|
46 | 38 | .reg = 0xe600101c, /* CCCR (Common Chip Code Register) */ |
---|
47 | 39 | }; |
---|
48 | 40 | |
---|
49 | | -static const struct renesas_family fam_rza __initconst __maybe_unused = { |
---|
50 | | - .name = "RZ/A", |
---|
| 41 | +static const struct renesas_family fam_rza1 __initconst __maybe_unused = { |
---|
| 42 | + .name = "RZ/A1", |
---|
51 | 43 | }; |
---|
52 | 44 | |
---|
53 | | -static const struct renesas_family fam_rzg __initconst __maybe_unused = { |
---|
54 | | - .name = "RZ/G", |
---|
| 45 | +static const struct renesas_family fam_rza2 __initconst __maybe_unused = { |
---|
| 46 | + .name = "RZ/A2", |
---|
| 47 | +}; |
---|
| 48 | + |
---|
| 49 | +static const struct renesas_family fam_rzg1 __initconst __maybe_unused = { |
---|
| 50 | + .name = "RZ/G1", |
---|
55 | 51 | .reg = 0xff000044, /* PRR (Product Register) */ |
---|
| 52 | +}; |
---|
| 53 | + |
---|
| 54 | +static const struct renesas_family fam_rzg2 __initconst __maybe_unused = { |
---|
| 55 | + .name = "RZ/G2", |
---|
| 56 | + .reg = 0xfff00044, /* PRR (Product Register) */ |
---|
56 | 57 | }; |
---|
57 | 58 | |
---|
58 | 59 | static const struct renesas_family fam_shmobile __initconst __maybe_unused = { |
---|
.. | .. |
---|
67 | 68 | }; |
---|
68 | 69 | |
---|
69 | 70 | static const struct renesas_soc soc_rz_a1h __initconst __maybe_unused = { |
---|
70 | | - .family = &fam_rza, |
---|
| 71 | + .family = &fam_rza1, |
---|
| 72 | +}; |
---|
| 73 | + |
---|
| 74 | +static const struct renesas_soc soc_rz_a2m __initconst __maybe_unused = { |
---|
| 75 | + .family = &fam_rza2, |
---|
| 76 | + .id = 0x3b, |
---|
71 | 77 | }; |
---|
72 | 78 | |
---|
73 | 79 | static const struct renesas_soc soc_rmobile_ape6 __initconst __maybe_unused = { |
---|
.. | .. |
---|
81 | 87 | }; |
---|
82 | 88 | |
---|
83 | 89 | static const struct renesas_soc soc_rz_g1h __initconst __maybe_unused = { |
---|
84 | | - .family = &fam_rzg, |
---|
| 90 | + .family = &fam_rzg1, |
---|
85 | 91 | .id = 0x45, |
---|
86 | 92 | }; |
---|
87 | 93 | |
---|
88 | 94 | static const struct renesas_soc soc_rz_g1m __initconst __maybe_unused = { |
---|
89 | | - .family = &fam_rzg, |
---|
| 95 | + .family = &fam_rzg1, |
---|
90 | 96 | .id = 0x47, |
---|
91 | 97 | }; |
---|
92 | 98 | |
---|
93 | 99 | static const struct renesas_soc soc_rz_g1n __initconst __maybe_unused = { |
---|
94 | | - .family = &fam_rzg, |
---|
| 100 | + .family = &fam_rzg1, |
---|
95 | 101 | .id = 0x4b, |
---|
96 | 102 | }; |
---|
97 | 103 | |
---|
98 | 104 | static const struct renesas_soc soc_rz_g1e __initconst __maybe_unused = { |
---|
99 | | - .family = &fam_rzg, |
---|
| 105 | + .family = &fam_rzg1, |
---|
100 | 106 | .id = 0x4c, |
---|
101 | 107 | }; |
---|
102 | 108 | |
---|
103 | 109 | static const struct renesas_soc soc_rz_g1c __initconst __maybe_unused = { |
---|
104 | | - .family = &fam_rzg, |
---|
| 110 | + .family = &fam_rzg1, |
---|
105 | 111 | .id = 0x53, |
---|
| 112 | +}; |
---|
| 113 | + |
---|
| 114 | +static const struct renesas_soc soc_rz_g2m __initconst __maybe_unused = { |
---|
| 115 | + .family = &fam_rzg2, |
---|
| 116 | + .id = 0x52, |
---|
| 117 | +}; |
---|
| 118 | + |
---|
| 119 | +static const struct renesas_soc soc_rz_g2n __initconst __maybe_unused = { |
---|
| 120 | + .family = &fam_rzg2, |
---|
| 121 | + .id = 0x55, |
---|
| 122 | +}; |
---|
| 123 | + |
---|
| 124 | +static const struct renesas_soc soc_rz_g2e __initconst __maybe_unused = { |
---|
| 125 | + .family = &fam_rzg2, |
---|
| 126 | + .id = 0x57, |
---|
| 127 | +}; |
---|
| 128 | + |
---|
| 129 | +static const struct renesas_soc soc_rz_g2h __initconst __maybe_unused = { |
---|
| 130 | + .family = &fam_rzg2, |
---|
| 131 | + .id = 0x4f, |
---|
106 | 132 | }; |
---|
107 | 133 | |
---|
108 | 134 | static const struct renesas_soc soc_rcar_m1a __initconst __maybe_unused = { |
---|
.. | .. |
---|
174 | 200 | .id = 0x58, |
---|
175 | 201 | }; |
---|
176 | 202 | |
---|
| 203 | +static const struct renesas_soc soc_rcar_v3u __initconst __maybe_unused = { |
---|
| 204 | + .family = &fam_rcar_gen3, |
---|
| 205 | + .id = 0x59, |
---|
| 206 | +}; |
---|
| 207 | + |
---|
177 | 208 | static const struct renesas_soc soc_shmobile_ag5 __initconst __maybe_unused = { |
---|
178 | 209 | .family = &fam_shmobile, |
---|
179 | 210 | .id = 0x37, |
---|
.. | .. |
---|
183 | 214 | static const struct of_device_id renesas_socs[] __initconst = { |
---|
184 | 215 | #ifdef CONFIG_ARCH_R7S72100 |
---|
185 | 216 | { .compatible = "renesas,r7s72100", .data = &soc_rz_a1h }, |
---|
| 217 | +#endif |
---|
| 218 | +#ifdef CONFIG_ARCH_R7S9210 |
---|
| 219 | + { .compatible = "renesas,r7s9210", .data = &soc_rz_a2m }, |
---|
186 | 220 | #endif |
---|
187 | 221 | #ifdef CONFIG_ARCH_R8A73A4 |
---|
188 | 222 | { .compatible = "renesas,r8a73a4", .data = &soc_rmobile_ape6 }, |
---|
.. | .. |
---|
205 | 239 | #ifdef CONFIG_ARCH_R8A77470 |
---|
206 | 240 | { .compatible = "renesas,r8a77470", .data = &soc_rz_g1c }, |
---|
207 | 241 | #endif |
---|
| 242 | +#ifdef CONFIG_ARCH_R8A774A1 |
---|
| 243 | + { .compatible = "renesas,r8a774a1", .data = &soc_rz_g2m }, |
---|
| 244 | +#endif |
---|
| 245 | +#ifdef CONFIG_ARCH_R8A774B1 |
---|
| 246 | + { .compatible = "renesas,r8a774b1", .data = &soc_rz_g2n }, |
---|
| 247 | +#endif |
---|
| 248 | +#ifdef CONFIG_ARCH_R8A774C0 |
---|
| 249 | + { .compatible = "renesas,r8a774c0", .data = &soc_rz_g2e }, |
---|
| 250 | +#endif |
---|
| 251 | +#ifdef CONFIG_ARCH_R8A774E1 |
---|
| 252 | + { .compatible = "renesas,r8a774e1", .data = &soc_rz_g2h }, |
---|
| 253 | +#endif |
---|
208 | 254 | #ifdef CONFIG_ARCH_R8A7778 |
---|
209 | 255 | { .compatible = "renesas,r8a7778", .data = &soc_rcar_m1a }, |
---|
210 | 256 | #endif |
---|
.. | .. |
---|
226 | 272 | #ifdef CONFIG_ARCH_R8A7794 |
---|
227 | 273 | { .compatible = "renesas,r8a7794", .data = &soc_rcar_e2 }, |
---|
228 | 274 | #endif |
---|
229 | | -#ifdef CONFIG_ARCH_R8A7795 |
---|
| 275 | +#if defined(CONFIG_ARCH_R8A77950) || defined(CONFIG_ARCH_R8A77951) |
---|
230 | 276 | { .compatible = "renesas,r8a7795", .data = &soc_rcar_h3 }, |
---|
231 | 277 | #endif |
---|
232 | | -#ifdef CONFIG_ARCH_R8A7796 |
---|
| 278 | +#ifdef CONFIG_ARCH_R8A77960 |
---|
233 | 279 | { .compatible = "renesas,r8a7796", .data = &soc_rcar_m3_w }, |
---|
| 280 | +#endif |
---|
| 281 | +#ifdef CONFIG_ARCH_R8A77961 |
---|
| 282 | + { .compatible = "renesas,r8a77961", .data = &soc_rcar_m3_w }, |
---|
234 | 283 | #endif |
---|
235 | 284 | #ifdef CONFIG_ARCH_R8A77965 |
---|
236 | 285 | { .compatible = "renesas,r8a77965", .data = &soc_rcar_m3_n }, |
---|
.. | .. |
---|
247 | 296 | #ifdef CONFIG_ARCH_R8A77995 |
---|
248 | 297 | { .compatible = "renesas,r8a77995", .data = &soc_rcar_d3 }, |
---|
249 | 298 | #endif |
---|
| 299 | +#ifdef CONFIG_ARCH_R8A779A0 |
---|
| 300 | + { .compatible = "renesas,r8a779a0", .data = &soc_rcar_v3u }, |
---|
| 301 | +#endif |
---|
250 | 302 | #ifdef CONFIG_ARCH_SH73A0 |
---|
251 | 303 | { .compatible = "renesas,sh73a0", .data = &soc_shmobile_ag5 }, |
---|
252 | 304 | #endif |
---|
.. | .. |
---|
262 | 314 | void __iomem *chipid = NULL; |
---|
263 | 315 | struct soc_device *soc_dev; |
---|
264 | 316 | struct device_node *np; |
---|
265 | | - unsigned int product; |
---|
| 317 | + unsigned int product, eshi = 0, eslo; |
---|
266 | 318 | |
---|
267 | 319 | match = of_match_node(renesas_socs, of_root); |
---|
268 | 320 | if (!match) |
---|
.. | .. |
---|
271 | 323 | soc = match->data; |
---|
272 | 324 | family = soc->family; |
---|
273 | 325 | |
---|
| 326 | + np = of_find_compatible_node(NULL, NULL, "renesas,bsid"); |
---|
| 327 | + if (np) { |
---|
| 328 | + chipid = of_iomap(np, 0); |
---|
| 329 | + of_node_put(np); |
---|
| 330 | + |
---|
| 331 | + if (chipid) { |
---|
| 332 | + product = readl(chipid); |
---|
| 333 | + iounmap(chipid); |
---|
| 334 | + |
---|
| 335 | + if (soc->id && ((product >> 16) & 0xff) != soc->id) { |
---|
| 336 | + pr_warn("SoC mismatch (product = 0x%x)\n", |
---|
| 337 | + product); |
---|
| 338 | + return -ENODEV; |
---|
| 339 | + } |
---|
| 340 | + } |
---|
| 341 | + |
---|
| 342 | + /* |
---|
| 343 | + * TODO: Upper 4 bits of BSID are for chip version, but the |
---|
| 344 | + * format is not known at this time so we don't know how to |
---|
| 345 | + * specify eshi and eslo |
---|
| 346 | + */ |
---|
| 347 | + |
---|
| 348 | + goto done; |
---|
| 349 | + } |
---|
| 350 | + |
---|
274 | 351 | /* Try PRR first, then hardcoded fallback */ |
---|
275 | 352 | np = of_find_compatible_node(NULL, NULL, "renesas,prr"); |
---|
276 | 353 | if (np) { |
---|
277 | 354 | chipid = of_iomap(np, 0); |
---|
278 | 355 | of_node_put(np); |
---|
279 | | - } else if (soc->id) { |
---|
| 356 | + } else if (soc->id && family->reg) { |
---|
280 | 357 | chipid = ioremap(family->reg, 4); |
---|
281 | 358 | } |
---|
282 | 359 | if (chipid) { |
---|
.. | .. |
---|
292 | 369 | pr_warn("SoC mismatch (product = 0x%x)\n", product); |
---|
293 | 370 | return -ENODEV; |
---|
294 | 371 | } |
---|
| 372 | + eshi = ((product >> 4) & 0x0f) + 1; |
---|
| 373 | + eslo = product & 0xf; |
---|
295 | 374 | } |
---|
296 | 375 | |
---|
| 376 | +done: |
---|
297 | 377 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); |
---|
298 | 378 | if (!soc_dev_attr) |
---|
299 | 379 | return -ENOMEM; |
---|
.. | .. |
---|
305 | 385 | soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL); |
---|
306 | 386 | soc_dev_attr->soc_id = kstrdup_const(strchr(match->compatible, ',') + 1, |
---|
307 | 387 | GFP_KERNEL); |
---|
308 | | - if (chipid) |
---|
309 | | - soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", |
---|
310 | | - ((product >> 4) & 0x0f) + 1, |
---|
311 | | - product & 0xf); |
---|
| 388 | + if (eshi) |
---|
| 389 | + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", eshi, |
---|
| 390 | + eslo); |
---|
312 | 391 | |
---|
313 | 392 | pr_info("Detected Renesas %s %s %s\n", soc_dev_attr->family, |
---|
314 | 393 | soc_dev_attr->soc_id, soc_dev_attr->revision ?: ""); |
---|