141c4567cSKuninori Morimoto // SPDX-License-Identifier: GPL-2.0 28d6799a9SGeert Uytterhoeven /* 38d6799a9SGeert Uytterhoeven * Renesas SoC Identification 48d6799a9SGeert Uytterhoeven * 58d6799a9SGeert Uytterhoeven * Copyright (C) 2014-2016 Glider bvba 68d6799a9SGeert Uytterhoeven */ 78d6799a9SGeert Uytterhoeven 88d6799a9SGeert Uytterhoeven #include <linux/io.h> 98d6799a9SGeert Uytterhoeven #include <linux/of.h> 108d6799a9SGeert Uytterhoeven #include <linux/of_address.h> 118d6799a9SGeert Uytterhoeven #include <linux/slab.h> 128d6799a9SGeert Uytterhoeven #include <linux/string.h> 138d6799a9SGeert Uytterhoeven #include <linux/sys_soc.h> 148d6799a9SGeert Uytterhoeven 158d6799a9SGeert Uytterhoeven 168d6799a9SGeert Uytterhoeven struct renesas_family { 178d6799a9SGeert Uytterhoeven const char name[16]; 188d6799a9SGeert Uytterhoeven u32 reg; /* CCCR or PRR, if not in DT */ 198d6799a9SGeert Uytterhoeven }; 208d6799a9SGeert Uytterhoeven 218d6799a9SGeert Uytterhoeven static const struct renesas_family fam_rcar_gen1 __initconst __maybe_unused = { 228d6799a9SGeert Uytterhoeven .name = "R-Car Gen1", 238d6799a9SGeert Uytterhoeven .reg = 0xff000044, /* PRR (Product Register) */ 248d6799a9SGeert Uytterhoeven }; 258d6799a9SGeert Uytterhoeven 268d6799a9SGeert Uytterhoeven static const struct renesas_family fam_rcar_gen2 __initconst __maybe_unused = { 278d6799a9SGeert Uytterhoeven .name = "R-Car Gen2", 288d6799a9SGeert Uytterhoeven .reg = 0xff000044, /* PRR (Product Register) */ 298d6799a9SGeert Uytterhoeven }; 308d6799a9SGeert Uytterhoeven 318d6799a9SGeert Uytterhoeven static const struct renesas_family fam_rcar_gen3 __initconst __maybe_unused = { 328d6799a9SGeert Uytterhoeven .name = "R-Car Gen3", 338d6799a9SGeert Uytterhoeven .reg = 0xfff00044, /* PRR (Product Register) */ 348d6799a9SGeert Uytterhoeven }; 358d6799a9SGeert Uytterhoeven 3697116335SYoshihiro Shimoda static const struct renesas_family fam_rcar_gen4 __initconst __maybe_unused = { 3797116335SYoshihiro Shimoda .name = "R-Car Gen4", 3897116335SYoshihiro Shimoda }; 3997116335SYoshihiro Shimoda 408d6799a9SGeert Uytterhoeven static const struct renesas_family fam_rmobile __initconst __maybe_unused = { 418d6799a9SGeert Uytterhoeven .name = "R-Mobile", 428d6799a9SGeert Uytterhoeven .reg = 0xe600101c, /* CCCR (Common Chip Code Register) */ 438d6799a9SGeert Uytterhoeven }; 448d6799a9SGeert Uytterhoeven 45175f435fSChris Brandt static const struct renesas_family fam_rza1 __initconst __maybe_unused = { 46175f435fSChris Brandt .name = "RZ/A1", 47175f435fSChris Brandt }; 48175f435fSChris Brandt 49175f435fSChris Brandt static const struct renesas_family fam_rza2 __initconst __maybe_unused = { 50175f435fSChris Brandt .name = "RZ/A2", 518d6799a9SGeert Uytterhoeven }; 528d6799a9SGeert Uytterhoeven 532a4056a7SBiju Das static const struct renesas_family fam_rzg1 __initconst __maybe_unused = { 542a4056a7SBiju Das .name = "RZ/G1", 558d6799a9SGeert Uytterhoeven .reg = 0xff000044, /* PRR (Product Register) */ 568d6799a9SGeert Uytterhoeven }; 578d6799a9SGeert Uytterhoeven 582a4056a7SBiju Das static const struct renesas_family fam_rzg2 __initconst __maybe_unused = { 592a4056a7SBiju Das .name = "RZ/G2", 602a4056a7SBiju Das .reg = 0xfff00044, /* PRR (Product Register) */ 612a4056a7SBiju Das }; 622a4056a7SBiju Das 63187cd57dSLad Prabhakar static const struct renesas_family fam_rzg2l __initconst __maybe_unused = { 64187cd57dSLad Prabhakar .name = "RZ/G2L", 65187cd57dSLad Prabhakar }; 66187cd57dSLad Prabhakar 67860122d8SBiju Das static const struct renesas_family fam_rzv2l __initconst __maybe_unused = { 68860122d8SBiju Das .name = "RZ/V2L", 69860122d8SBiju Das }; 70860122d8SBiju Das 718d6799a9SGeert Uytterhoeven static const struct renesas_family fam_shmobile __initconst __maybe_unused = { 728d6799a9SGeert Uytterhoeven .name = "SH-Mobile", 738d6799a9SGeert Uytterhoeven .reg = 0xe600101c, /* CCCR (Common Chip Code Register) */ 748d6799a9SGeert Uytterhoeven }; 758d6799a9SGeert Uytterhoeven 768d6799a9SGeert Uytterhoeven 778d6799a9SGeert Uytterhoeven struct renesas_soc { 788d6799a9SGeert Uytterhoeven const struct renesas_family *family; 79187cd57dSLad Prabhakar u32 id; 808d6799a9SGeert Uytterhoeven }; 818d6799a9SGeert Uytterhoeven 828d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rz_a1h __initconst __maybe_unused = { 83175f435fSChris Brandt .family = &fam_rza1, 84175f435fSChris Brandt }; 85175f435fSChris Brandt 86175f435fSChris Brandt static const struct renesas_soc soc_rz_a2m __initconst __maybe_unused = { 87175f435fSChris Brandt .family = &fam_rza2, 88175f435fSChris Brandt .id = 0x3b, 898d6799a9SGeert Uytterhoeven }; 908d6799a9SGeert Uytterhoeven 918d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rmobile_ape6 __initconst __maybe_unused = { 928d6799a9SGeert Uytterhoeven .family = &fam_rmobile, 938d6799a9SGeert Uytterhoeven .id = 0x3f, 948d6799a9SGeert Uytterhoeven }; 958d6799a9SGeert Uytterhoeven 968d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rmobile_a1 __initconst __maybe_unused = { 978d6799a9SGeert Uytterhoeven .family = &fam_rmobile, 988d6799a9SGeert Uytterhoeven .id = 0x40, 998d6799a9SGeert Uytterhoeven }; 1008d6799a9SGeert Uytterhoeven 1018848e1b1SGeert Uytterhoeven static const struct renesas_soc soc_rz_g1h __initconst __maybe_unused = { 1022a4056a7SBiju Das .family = &fam_rzg1, 1038848e1b1SGeert Uytterhoeven .id = 0x45, 1048848e1b1SGeert Uytterhoeven }; 1058848e1b1SGeert Uytterhoeven 1068d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rz_g1m __initconst __maybe_unused = { 1072a4056a7SBiju Das .family = &fam_rzg1, 1088d6799a9SGeert Uytterhoeven .id = 0x47, 1098d6799a9SGeert Uytterhoeven }; 1108d6799a9SGeert Uytterhoeven 111cd59de80SGeert Uytterhoeven static const struct renesas_soc soc_rz_g1n __initconst __maybe_unused = { 1122a4056a7SBiju Das .family = &fam_rzg1, 113cd59de80SGeert Uytterhoeven .id = 0x4b, 114cd59de80SGeert Uytterhoeven }; 115cd59de80SGeert Uytterhoeven 1168d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rz_g1e __initconst __maybe_unused = { 1172a4056a7SBiju Das .family = &fam_rzg1, 1188d6799a9SGeert Uytterhoeven .id = 0x4c, 1198d6799a9SGeert Uytterhoeven }; 1208d6799a9SGeert Uytterhoeven 1211daf13baSBiju Das static const struct renesas_soc soc_rz_g1c __initconst __maybe_unused = { 1222a4056a7SBiju Das .family = &fam_rzg1, 1231daf13baSBiju Das .id = 0x53, 1241daf13baSBiju Das }; 1251daf13baSBiju Das 1262a4056a7SBiju Das static const struct renesas_soc soc_rz_g2m __initconst __maybe_unused = { 1272a4056a7SBiju Das .family = &fam_rzg2, 1282a4056a7SBiju Das .id = 0x52, 1292a4056a7SBiju Das }; 1302a4056a7SBiju Das 131574cb721SBiju Das static const struct renesas_soc soc_rz_g2n __initconst __maybe_unused = { 132574cb721SBiju Das .family = &fam_rzg2, 133574cb721SBiju Das .id = 0x55, 134574cb721SBiju Das }; 135574cb721SBiju Das 1362bab3d80SFabrizio Castro static const struct renesas_soc soc_rz_g2e __initconst __maybe_unused = { 1372bab3d80SFabrizio Castro .family = &fam_rzg2, 1382bab3d80SFabrizio Castro .id = 0x57, 1392bab3d80SFabrizio Castro }; 1402bab3d80SFabrizio Castro 1415b83cc42SMarian-Cristian Rotariu static const struct renesas_soc soc_rz_g2h __initconst __maybe_unused = { 1425b83cc42SMarian-Cristian Rotariu .family = &fam_rzg2, 1435b83cc42SMarian-Cristian Rotariu .id = 0x4f, 1445b83cc42SMarian-Cristian Rotariu }; 1455b83cc42SMarian-Cristian Rotariu 146187cd57dSLad Prabhakar static const struct renesas_soc soc_rz_g2l __initconst __maybe_unused = { 147187cd57dSLad Prabhakar .family = &fam_rzg2l, 148187cd57dSLad Prabhakar .id = 0x841c447, 149187cd57dSLad Prabhakar }; 150187cd57dSLad Prabhakar 151860122d8SBiju Das static const struct renesas_soc soc_rz_v2l __initconst __maybe_unused = { 152860122d8SBiju Das .family = &fam_rzv2l, 153860122d8SBiju Das .id = 0x8447447, 154860122d8SBiju Das }; 155860122d8SBiju Das 1568d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_m1a __initconst __maybe_unused = { 1578d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen1, 1588d6799a9SGeert Uytterhoeven }; 1598d6799a9SGeert Uytterhoeven 1608d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_h1 __initconst __maybe_unused = { 1618d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen1, 1628d6799a9SGeert Uytterhoeven .id = 0x3b, 1638d6799a9SGeert Uytterhoeven }; 1648d6799a9SGeert Uytterhoeven 1658d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_h2 __initconst __maybe_unused = { 1668d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 1678d6799a9SGeert Uytterhoeven .id = 0x45, 1688d6799a9SGeert Uytterhoeven }; 1698d6799a9SGeert Uytterhoeven 1708d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_m2_w __initconst __maybe_unused = { 1718d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 1728d6799a9SGeert Uytterhoeven .id = 0x47, 1738d6799a9SGeert Uytterhoeven }; 1748d6799a9SGeert Uytterhoeven 1758d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_v2h __initconst __maybe_unused = { 1768d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 1778d6799a9SGeert Uytterhoeven .id = 0x4a, 1788d6799a9SGeert Uytterhoeven }; 1798d6799a9SGeert Uytterhoeven 1808d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_m2_n __initconst __maybe_unused = { 1818d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 1828d6799a9SGeert Uytterhoeven .id = 0x4b, 1838d6799a9SGeert Uytterhoeven }; 1848d6799a9SGeert Uytterhoeven 1858d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_e2 __initconst __maybe_unused = { 1868d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 1878d6799a9SGeert Uytterhoeven .id = 0x4c, 1888d6799a9SGeert Uytterhoeven }; 1898d6799a9SGeert Uytterhoeven 1908d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_h3 __initconst __maybe_unused = { 1918d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen3, 1928d6799a9SGeert Uytterhoeven .id = 0x4f, 1938d6799a9SGeert Uytterhoeven }; 1948d6799a9SGeert Uytterhoeven 1958d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_m3_w __initconst __maybe_unused = { 1968d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen3, 1978d6799a9SGeert Uytterhoeven .id = 0x52, 1988d6799a9SGeert Uytterhoeven }; 1998d6799a9SGeert Uytterhoeven 200bfd83983SJacopo Mondi static const struct renesas_soc soc_rcar_m3_n __initconst __maybe_unused = { 201bfd83983SJacopo Mondi .family = &fam_rcar_gen3, 202bfd83983SJacopo Mondi .id = 0x55, 203bfd83983SJacopo Mondi }; 204bfd83983SJacopo Mondi 205bb003075SSergei Shtylyov static const struct renesas_soc soc_rcar_v3m __initconst __maybe_unused = { 206bb003075SSergei Shtylyov .family = &fam_rcar_gen3, 207bb003075SSergei Shtylyov .id = 0x54, 208bb003075SSergei Shtylyov }; 209bb003075SSergei Shtylyov 2108447756dSSergei Shtylyov static const struct renesas_soc soc_rcar_v3h __initconst __maybe_unused = { 2118447756dSSergei Shtylyov .family = &fam_rcar_gen3, 2128447756dSSergei Shtylyov .id = 0x56, 2138447756dSSergei Shtylyov }; 2148447756dSSergei Shtylyov 21544842d45STakeshi Kihara static const struct renesas_soc soc_rcar_e3 __initconst __maybe_unused = { 21644842d45STakeshi Kihara .family = &fam_rcar_gen3, 21744842d45STakeshi Kihara .id = 0x57, 21844842d45STakeshi Kihara }; 21944842d45STakeshi Kihara 2201b954784SGeert Uytterhoeven static const struct renesas_soc soc_rcar_d3 __initconst __maybe_unused = { 2211b954784SGeert Uytterhoeven .family = &fam_rcar_gen3, 2221b954784SGeert Uytterhoeven .id = 0x58, 2231b954784SGeert Uytterhoeven }; 2241b954784SGeert Uytterhoeven 225090e87e7SYoshihiro Shimoda static const struct renesas_soc soc_rcar_v3u __initconst __maybe_unused = { 226090e87e7SYoshihiro Shimoda .family = &fam_rcar_gen3, 227090e87e7SYoshihiro Shimoda .id = 0x59, 228090e87e7SYoshihiro Shimoda }; 229090e87e7SYoshihiro Shimoda 23097116335SYoshihiro Shimoda static const struct renesas_soc soc_rcar_s4 __initconst __maybe_unused = { 23197116335SYoshihiro Shimoda .family = &fam_rcar_gen4, 23297116335SYoshihiro Shimoda .id = 0x5a, 23397116335SYoshihiro Shimoda }; 23497116335SYoshihiro Shimoda 2358d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_shmobile_ag5 __initconst __maybe_unused = { 2368d6799a9SGeert Uytterhoeven .family = &fam_shmobile, 2378d6799a9SGeert Uytterhoeven .id = 0x37, 2388d6799a9SGeert Uytterhoeven }; 2398d6799a9SGeert Uytterhoeven 2408d6799a9SGeert Uytterhoeven 2418d6799a9SGeert Uytterhoeven static const struct of_device_id renesas_socs[] __initconst = { 2428d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R7S72100 2438d6799a9SGeert Uytterhoeven { .compatible = "renesas,r7s72100", .data = &soc_rz_a1h }, 2448d6799a9SGeert Uytterhoeven #endif 245175f435fSChris Brandt #ifdef CONFIG_ARCH_R7S9210 246175f435fSChris Brandt { .compatible = "renesas,r7s9210", .data = &soc_rz_a2m }, 247175f435fSChris Brandt #endif 2488d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A73A4 2498d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a73a4", .data = &soc_rmobile_ape6 }, 2508d6799a9SGeert Uytterhoeven #endif 2518d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7740 2528d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7740", .data = &soc_rmobile_a1 }, 2538d6799a9SGeert Uytterhoeven #endif 2548848e1b1SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7742 2558848e1b1SGeert Uytterhoeven { .compatible = "renesas,r8a7742", .data = &soc_rz_g1h }, 2568848e1b1SGeert Uytterhoeven #endif 2578d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7743 2588d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7743", .data = &soc_rz_g1m }, 2598d6799a9SGeert Uytterhoeven #endif 260cd59de80SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7744 261cd59de80SGeert Uytterhoeven { .compatible = "renesas,r8a7744", .data = &soc_rz_g1n }, 262cd59de80SGeert Uytterhoeven #endif 2638d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7745 2648d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7745", .data = &soc_rz_g1e }, 2658d6799a9SGeert Uytterhoeven #endif 2661daf13baSBiju Das #ifdef CONFIG_ARCH_R8A77470 2671daf13baSBiju Das { .compatible = "renesas,r8a77470", .data = &soc_rz_g1c }, 2681daf13baSBiju Das #endif 2692a4056a7SBiju Das #ifdef CONFIG_ARCH_R8A774A1 2702a4056a7SBiju Das { .compatible = "renesas,r8a774a1", .data = &soc_rz_g2m }, 2712a4056a7SBiju Das #endif 272574cb721SBiju Das #ifdef CONFIG_ARCH_R8A774B1 273574cb721SBiju Das { .compatible = "renesas,r8a774b1", .data = &soc_rz_g2n }, 274574cb721SBiju Das #endif 2752bab3d80SFabrizio Castro #ifdef CONFIG_ARCH_R8A774C0 2762bab3d80SFabrizio Castro { .compatible = "renesas,r8a774c0", .data = &soc_rz_g2e }, 2772bab3d80SFabrizio Castro #endif 2785b83cc42SMarian-Cristian Rotariu #ifdef CONFIG_ARCH_R8A774E1 2795b83cc42SMarian-Cristian Rotariu { .compatible = "renesas,r8a774e1", .data = &soc_rz_g2h }, 2805b83cc42SMarian-Cristian Rotariu #endif 2818d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7778 2828d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7778", .data = &soc_rcar_m1a }, 2838d6799a9SGeert Uytterhoeven #endif 2848d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7779 2858d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7779", .data = &soc_rcar_h1 }, 2868d6799a9SGeert Uytterhoeven #endif 2878d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7790 2888d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7790", .data = &soc_rcar_h2 }, 2898d6799a9SGeert Uytterhoeven #endif 2908d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7791 2918d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7791", .data = &soc_rcar_m2_w }, 2928d6799a9SGeert Uytterhoeven #endif 2938d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7792 2948d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7792", .data = &soc_rcar_v2h }, 2958d6799a9SGeert Uytterhoeven #endif 2968d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7793 2978d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7793", .data = &soc_rcar_m2_n }, 2988d6799a9SGeert Uytterhoeven #endif 2998d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7794 3008d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7794", .data = &soc_rcar_e2 }, 3018d6799a9SGeert Uytterhoeven #endif 3024ff27112SGeert Uytterhoeven #if defined(CONFIG_ARCH_R8A77950) || defined(CONFIG_ARCH_R8A77951) 3038d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7795", .data = &soc_rcar_h3 }, 3048d6799a9SGeert Uytterhoeven #endif 305bfe6b559SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A77951 3062ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m0", .data = &soc_rcar_h3 }, 307bfe6b559SGeert Uytterhoeven { .compatible = "renesas,r8a779m1", .data = &soc_rcar_h3 }, 3082ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m8", .data = &soc_rcar_h3 }, 309bfe6b559SGeert Uytterhoeven #endif 31039e57e14SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A77960 3118d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7796", .data = &soc_rcar_m3_w }, 3128d6799a9SGeert Uytterhoeven #endif 3139c9f7891SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A77961 3149c9f7891SGeert Uytterhoeven { .compatible = "renesas,r8a77961", .data = &soc_rcar_m3_w }, 3152ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m2", .data = &soc_rcar_m3_w }, 316bfe6b559SGeert Uytterhoeven { .compatible = "renesas,r8a779m3", .data = &soc_rcar_m3_w }, 3179c9f7891SGeert Uytterhoeven #endif 318bfd83983SJacopo Mondi #ifdef CONFIG_ARCH_R8A77965 319bfd83983SJacopo Mondi { .compatible = "renesas,r8a77965", .data = &soc_rcar_m3_n }, 3202ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m4", .data = &soc_rcar_m3_n }, 3212ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m5", .data = &soc_rcar_m3_n }, 322bfd83983SJacopo Mondi #endif 323bb003075SSergei Shtylyov #ifdef CONFIG_ARCH_R8A77970 324bb003075SSergei Shtylyov { .compatible = "renesas,r8a77970", .data = &soc_rcar_v3m }, 325bb003075SSergei Shtylyov #endif 3268447756dSSergei Shtylyov #ifdef CONFIG_ARCH_R8A77980 3278447756dSSergei Shtylyov { .compatible = "renesas,r8a77980", .data = &soc_rcar_v3h }, 3288447756dSSergei Shtylyov #endif 32944842d45STakeshi Kihara #ifdef CONFIG_ARCH_R8A77990 33044842d45STakeshi Kihara { .compatible = "renesas,r8a77990", .data = &soc_rcar_e3 }, 3312ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m6", .data = &soc_rcar_e3 }, 33244842d45STakeshi Kihara #endif 3331b954784SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A77995 3341b954784SGeert Uytterhoeven { .compatible = "renesas,r8a77995", .data = &soc_rcar_d3 }, 3352ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m7", .data = &soc_rcar_d3 }, 3361b954784SGeert Uytterhoeven #endif 337090e87e7SYoshihiro Shimoda #ifdef CONFIG_ARCH_R8A779A0 338090e87e7SYoshihiro Shimoda { .compatible = "renesas,r8a779a0", .data = &soc_rcar_v3u }, 339090e87e7SYoshihiro Shimoda #endif 34097116335SYoshihiro Shimoda #ifdef CONFIG_ARCH_R8A779F0 34197116335SYoshihiro Shimoda { .compatible = "renesas,r8a779f0", .data = &soc_rcar_s4 }, 34297116335SYoshihiro Shimoda #endif 343187cd57dSLad Prabhakar #if defined(CONFIG_ARCH_R9A07G044) 344187cd57dSLad Prabhakar { .compatible = "renesas,r9a07g044", .data = &soc_rz_g2l }, 345187cd57dSLad Prabhakar #endif 346860122d8SBiju Das #if defined(CONFIG_ARCH_R9A07G054) 347860122d8SBiju Das { .compatible = "renesas,r9a07g054", .data = &soc_rz_v2l }, 348860122d8SBiju Das #endif 3498d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_SH73A0 3508d6799a9SGeert Uytterhoeven { .compatible = "renesas,sh73a0", .data = &soc_shmobile_ag5 }, 3518d6799a9SGeert Uytterhoeven #endif 3528d6799a9SGeert Uytterhoeven { /* sentinel */ } 3538d6799a9SGeert Uytterhoeven }; 3548d6799a9SGeert Uytterhoeven 35505b22caaSGeert Uytterhoeven struct renesas_id { 35605b22caaSGeert Uytterhoeven unsigned int offset; 35705b22caaSGeert Uytterhoeven u32 mask; 35805b22caaSGeert Uytterhoeven }; 35905b22caaSGeert Uytterhoeven 36005b22caaSGeert Uytterhoeven static const struct renesas_id id_bsid __initconst = { 36105b22caaSGeert Uytterhoeven .offset = 0, 36205b22caaSGeert Uytterhoeven .mask = 0xff0000, 36305b22caaSGeert Uytterhoeven /* 36405b22caaSGeert Uytterhoeven * TODO: Upper 4 bits of BSID are for chip version, but the format is 36505b22caaSGeert Uytterhoeven * not known at this time so we don't know how to specify eshi and eslo 36605b22caaSGeert Uytterhoeven */ 36705b22caaSGeert Uytterhoeven }; 36805b22caaSGeert Uytterhoeven 36905b22caaSGeert Uytterhoeven static const struct renesas_id id_rzg2l __initconst = { 37005b22caaSGeert Uytterhoeven .offset = 0xa04, 37105b22caaSGeert Uytterhoeven .mask = 0xfffffff, 37205b22caaSGeert Uytterhoeven }; 37305b22caaSGeert Uytterhoeven 37405b22caaSGeert Uytterhoeven static const struct renesas_id id_prr __initconst = { 37505b22caaSGeert Uytterhoeven .offset = 0, 37605b22caaSGeert Uytterhoeven .mask = 0xff00, 37705b22caaSGeert Uytterhoeven }; 37805b22caaSGeert Uytterhoeven 37905b22caaSGeert Uytterhoeven static const struct of_device_id renesas_ids[] __initconst = { 38005b22caaSGeert Uytterhoeven { .compatible = "renesas,bsid", .data = &id_bsid }, 38105b22caaSGeert Uytterhoeven { .compatible = "renesas,r9a07g044-sysc", .data = &id_rzg2l }, 382860122d8SBiju Das { .compatible = "renesas,r9a07g054-sysc", .data = &id_rzg2l }, 38305b22caaSGeert Uytterhoeven { .compatible = "renesas,prr", .data = &id_prr }, 38405b22caaSGeert Uytterhoeven { /* sentinel */ } 38505b22caaSGeert Uytterhoeven }; 38605b22caaSGeert Uytterhoeven 3878d6799a9SGeert Uytterhoeven static int __init renesas_soc_init(void) 3888d6799a9SGeert Uytterhoeven { 3898d6799a9SGeert Uytterhoeven struct soc_device_attribute *soc_dev_attr; 39005b22caaSGeert Uytterhoeven unsigned int product, eshi = 0, eslo; 3918d6799a9SGeert Uytterhoeven const struct renesas_family *family; 3928d6799a9SGeert Uytterhoeven const struct of_device_id *match; 3938d6799a9SGeert Uytterhoeven const struct renesas_soc *soc; 39405b22caaSGeert Uytterhoeven const struct renesas_id *id; 3958d6799a9SGeert Uytterhoeven void __iomem *chipid = NULL; 396*cb5508e4SBiju Das const char *rev_prefix = ""; 3978d6799a9SGeert Uytterhoeven struct soc_device *soc_dev; 3988d6799a9SGeert Uytterhoeven struct device_node *np; 39905b22caaSGeert Uytterhoeven const char *soc_id; 400*cb5508e4SBiju Das int ret; 4018d6799a9SGeert Uytterhoeven 4028d6799a9SGeert Uytterhoeven match = of_match_node(renesas_socs, of_root); 4038d6799a9SGeert Uytterhoeven if (!match) 4048d6799a9SGeert Uytterhoeven return -ENODEV; 4058d6799a9SGeert Uytterhoeven 40605b22caaSGeert Uytterhoeven soc_id = strchr(match->compatible, ',') + 1; 4078d6799a9SGeert Uytterhoeven soc = match->data; 4088d6799a9SGeert Uytterhoeven family = soc->family; 4098d6799a9SGeert Uytterhoeven 41005b22caaSGeert Uytterhoeven np = of_find_matching_node_and_match(NULL, renesas_ids, &match); 411175f435fSChris Brandt if (np) { 41205b22caaSGeert Uytterhoeven id = match->data; 4138d6799a9SGeert Uytterhoeven chipid = of_iomap(np, 0); 4148d6799a9SGeert Uytterhoeven of_node_put(np); 4154194b583SGeert Uytterhoeven } else if (soc->id && family->reg) { 41605b22caaSGeert Uytterhoeven /* Try hardcoded CCCR/PRR fallback */ 41705b22caaSGeert Uytterhoeven id = &id_prr; 4188d6799a9SGeert Uytterhoeven chipid = ioremap(family->reg, 4); 4198d6799a9SGeert Uytterhoeven } 42005b22caaSGeert Uytterhoeven 421*cb5508e4SBiju Das soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); 422*cb5508e4SBiju Das if (!soc_dev_attr) 423*cb5508e4SBiju Das return -ENOMEM; 424*cb5508e4SBiju Das 425*cb5508e4SBiju Das np = of_find_node_by_path("/"); 426*cb5508e4SBiju Das of_property_read_string(np, "model", &soc_dev_attr->machine); 427*cb5508e4SBiju Das of_node_put(np); 428*cb5508e4SBiju Das 429*cb5508e4SBiju Das soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL); 430*cb5508e4SBiju Das soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL); 431*cb5508e4SBiju Das 4328d6799a9SGeert Uytterhoeven if (chipid) { 43305b22caaSGeert Uytterhoeven product = readl(chipid + id->offset); 4348d6799a9SGeert Uytterhoeven iounmap(chipid); 43505b22caaSGeert Uytterhoeven 43605b22caaSGeert Uytterhoeven if (id == &id_prr) { 43790f0d2b3SGeert Uytterhoeven /* R-Car M3-W ES1.1 incorrectly identifies as ES2.0 */ 43890f0d2b3SGeert Uytterhoeven if ((product & 0x7fff) == 0x5210) 43990f0d2b3SGeert Uytterhoeven product ^= 0x11; 44015160f6dSTakeshi Kihara /* R-Car M3-W ES1.3 incorrectly identifies as ES2.1 */ 44115160f6dSTakeshi Kihara if ((product & 0x7fff) == 0x5211) 44215160f6dSTakeshi Kihara product ^= 0x12; 44305b22caaSGeert Uytterhoeven 444175f435fSChris Brandt eshi = ((product >> 4) & 0x0f) + 1; 445175f435fSChris Brandt eslo = product & 0xf; 446*cb5508e4SBiju Das soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", 447*cb5508e4SBiju Das eshi, eslo); 448*cb5508e4SBiju Das } else if (id == &id_rzg2l) { 449*cb5508e4SBiju Das eshi = ((product >> 28) & 0x0f); 450*cb5508e4SBiju Das soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%u", 451*cb5508e4SBiju Das eshi); 452*cb5508e4SBiju Das rev_prefix = "Rev "; 4538d6799a9SGeert Uytterhoeven } 4548d6799a9SGeert Uytterhoeven 45505b22caaSGeert Uytterhoeven if (soc->id && 45605b22caaSGeert Uytterhoeven ((product & id->mask) >> __ffs(id->mask)) != soc->id) { 45705b22caaSGeert Uytterhoeven pr_warn("SoC mismatch (product = 0x%x)\n", product); 458*cb5508e4SBiju Das ret = -ENODEV; 459*cb5508e4SBiju Das goto free_soc_dev_attr; 46005b22caaSGeert Uytterhoeven } 46105b22caaSGeert Uytterhoeven } 46205b22caaSGeert Uytterhoeven 463*cb5508e4SBiju Das pr_info("Detected Renesas %s %s %s%s\n", soc_dev_attr->family, 464*cb5508e4SBiju Das soc_dev_attr->soc_id, rev_prefix, soc_dev_attr->revision ?: ""); 4658d6799a9SGeert Uytterhoeven 4668d6799a9SGeert Uytterhoeven soc_dev = soc_device_register(soc_dev_attr); 4678d6799a9SGeert Uytterhoeven if (IS_ERR(soc_dev)) { 468*cb5508e4SBiju Das ret = PTR_ERR(soc_dev); 469*cb5508e4SBiju Das goto free_soc_dev_attr; 470*cb5508e4SBiju Das } 471*cb5508e4SBiju Das 472*cb5508e4SBiju Das return 0; 473*cb5508e4SBiju Das 474*cb5508e4SBiju Das free_soc_dev_attr: 4758d6799a9SGeert Uytterhoeven kfree(soc_dev_attr->revision); 4768d6799a9SGeert Uytterhoeven kfree_const(soc_dev_attr->soc_id); 4778d6799a9SGeert Uytterhoeven kfree_const(soc_dev_attr->family); 4788d6799a9SGeert Uytterhoeven kfree(soc_dev_attr); 479*cb5508e4SBiju Das return ret; 4808d6799a9SGeert Uytterhoeven } 481b1d134baSGeert Uytterhoeven early_initcall(renesas_soc_init); 482