hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/soc/renesas/renesas-soc.c
....@@ -1,16 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Renesas SoC Identification
34 *
45 * 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.
146 */
157
168 #include <linux/io.h>
....@@ -46,13 +38,22 @@
4638 .reg = 0xe600101c, /* CCCR (Common Chip Code Register) */
4739 };
4840
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",
5143 };
5244
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",
5551 .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) */
5657 };
5758
5859 static const struct renesas_family fam_shmobile __initconst __maybe_unused = {
....@@ -67,7 +68,12 @@
6768 };
6869
6970 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,
7177 };
7278
7379 static const struct renesas_soc soc_rmobile_ape6 __initconst __maybe_unused = {
....@@ -81,28 +87,48 @@
8187 };
8288
8389 static const struct renesas_soc soc_rz_g1h __initconst __maybe_unused = {
84
- .family = &fam_rzg,
90
+ .family = &fam_rzg1,
8591 .id = 0x45,
8692 };
8793
8894 static const struct renesas_soc soc_rz_g1m __initconst __maybe_unused = {
89
- .family = &fam_rzg,
95
+ .family = &fam_rzg1,
9096 .id = 0x47,
9197 };
9298
9399 static const struct renesas_soc soc_rz_g1n __initconst __maybe_unused = {
94
- .family = &fam_rzg,
100
+ .family = &fam_rzg1,
95101 .id = 0x4b,
96102 };
97103
98104 static const struct renesas_soc soc_rz_g1e __initconst __maybe_unused = {
99
- .family = &fam_rzg,
105
+ .family = &fam_rzg1,
100106 .id = 0x4c,
101107 };
102108
103109 static const struct renesas_soc soc_rz_g1c __initconst __maybe_unused = {
104
- .family = &fam_rzg,
110
+ .family = &fam_rzg1,
105111 .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,
106132 };
107133
108134 static const struct renesas_soc soc_rcar_m1a __initconst __maybe_unused = {
....@@ -174,6 +200,11 @@
174200 .id = 0x58,
175201 };
176202
203
+static const struct renesas_soc soc_rcar_v3u __initconst __maybe_unused = {
204
+ .family = &fam_rcar_gen3,
205
+ .id = 0x59,
206
+};
207
+
177208 static const struct renesas_soc soc_shmobile_ag5 __initconst __maybe_unused = {
178209 .family = &fam_shmobile,
179210 .id = 0x37,
....@@ -183,6 +214,9 @@
183214 static const struct of_device_id renesas_socs[] __initconst = {
184215 #ifdef CONFIG_ARCH_R7S72100
185216 { .compatible = "renesas,r7s72100", .data = &soc_rz_a1h },
217
+#endif
218
+#ifdef CONFIG_ARCH_R7S9210
219
+ { .compatible = "renesas,r7s9210", .data = &soc_rz_a2m },
186220 #endif
187221 #ifdef CONFIG_ARCH_R8A73A4
188222 { .compatible = "renesas,r8a73a4", .data = &soc_rmobile_ape6 },
....@@ -205,6 +239,18 @@
205239 #ifdef CONFIG_ARCH_R8A77470
206240 { .compatible = "renesas,r8a77470", .data = &soc_rz_g1c },
207241 #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
208254 #ifdef CONFIG_ARCH_R8A7778
209255 { .compatible = "renesas,r8a7778", .data = &soc_rcar_m1a },
210256 #endif
....@@ -226,11 +272,14 @@
226272 #ifdef CONFIG_ARCH_R8A7794
227273 { .compatible = "renesas,r8a7794", .data = &soc_rcar_e2 },
228274 #endif
229
-#ifdef CONFIG_ARCH_R8A7795
275
+#if defined(CONFIG_ARCH_R8A77950) || defined(CONFIG_ARCH_R8A77951)
230276 { .compatible = "renesas,r8a7795", .data = &soc_rcar_h3 },
231277 #endif
232
-#ifdef CONFIG_ARCH_R8A7796
278
+#ifdef CONFIG_ARCH_R8A77960
233279 { .compatible = "renesas,r8a7796", .data = &soc_rcar_m3_w },
280
+#endif
281
+#ifdef CONFIG_ARCH_R8A77961
282
+ { .compatible = "renesas,r8a77961", .data = &soc_rcar_m3_w },
234283 #endif
235284 #ifdef CONFIG_ARCH_R8A77965
236285 { .compatible = "renesas,r8a77965", .data = &soc_rcar_m3_n },
....@@ -247,6 +296,9 @@
247296 #ifdef CONFIG_ARCH_R8A77995
248297 { .compatible = "renesas,r8a77995", .data = &soc_rcar_d3 },
249298 #endif
299
+#ifdef CONFIG_ARCH_R8A779A0
300
+ { .compatible = "renesas,r8a779a0", .data = &soc_rcar_v3u },
301
+#endif
250302 #ifdef CONFIG_ARCH_SH73A0
251303 { .compatible = "renesas,sh73a0", .data = &soc_shmobile_ag5 },
252304 #endif
....@@ -262,7 +314,7 @@
262314 void __iomem *chipid = NULL;
263315 struct soc_device *soc_dev;
264316 struct device_node *np;
265
- unsigned int product;
317
+ unsigned int product, eshi = 0, eslo;
266318
267319 match = of_match_node(renesas_socs, of_root);
268320 if (!match)
....@@ -271,12 +323,37 @@
271323 soc = match->data;
272324 family = soc->family;
273325
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
+
274351 /* Try PRR first, then hardcoded fallback */
275352 np = of_find_compatible_node(NULL, NULL, "renesas,prr");
276353 if (np) {
277354 chipid = of_iomap(np, 0);
278355 of_node_put(np);
279
- } else if (soc->id) {
356
+ } else if (soc->id && family->reg) {
280357 chipid = ioremap(family->reg, 4);
281358 }
282359 if (chipid) {
....@@ -292,8 +369,11 @@
292369 pr_warn("SoC mismatch (product = 0x%x)\n", product);
293370 return -ENODEV;
294371 }
372
+ eshi = ((product >> 4) & 0x0f) + 1;
373
+ eslo = product & 0xf;
295374 }
296375
376
+done:
297377 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
298378 if (!soc_dev_attr)
299379 return -ENOMEM;
....@@ -305,10 +385,9 @@
305385 soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL);
306386 soc_dev_attr->soc_id = kstrdup_const(strchr(match->compatible, ',') + 1,
307387 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);
312391
313392 pr_info("Detected Renesas %s %s %s\n", soc_dev_attr->family,
314393 soc_dev_attr->soc_id, soc_dev_attr->revision ?: "");