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 53ebd0e06fSLad Prabhakar static const struct renesas_family fam_rzfive __initconst __maybe_unused = { 54ebd0e06fSLad Prabhakar .name = "RZ/Five", 55ebd0e06fSLad Prabhakar }; 56ebd0e06fSLad Prabhakar 572a4056a7SBiju Das static const struct renesas_family fam_rzg1 __initconst __maybe_unused = { 582a4056a7SBiju Das .name = "RZ/G1", 598d6799a9SGeert Uytterhoeven .reg = 0xff000044, /* PRR (Product Register) */ 608d6799a9SGeert Uytterhoeven }; 618d6799a9SGeert Uytterhoeven 622a4056a7SBiju Das static const struct renesas_family fam_rzg2 __initconst __maybe_unused = { 632a4056a7SBiju Das .name = "RZ/G2", 642a4056a7SBiju Das .reg = 0xfff00044, /* PRR (Product Register) */ 652a4056a7SBiju Das }; 662a4056a7SBiju Das 67187cd57dSLad Prabhakar static const struct renesas_family fam_rzg2l __initconst __maybe_unused = { 68187cd57dSLad Prabhakar .name = "RZ/G2L", 69187cd57dSLad Prabhakar }; 70187cd57dSLad Prabhakar 712f89bef9SBiju Das static const struct renesas_family fam_rzg2ul __initconst __maybe_unused = { 722f89bef9SBiju Das .name = "RZ/G2UL", 732f89bef9SBiju Das }; 742f89bef9SBiju Das 75860122d8SBiju Das static const struct renesas_family fam_rzv2l __initconst __maybe_unused = { 76860122d8SBiju Das .name = "RZ/V2L", 77860122d8SBiju Das }; 78860122d8SBiju Das 79*7e200440SPhil Edworthy static const struct renesas_family fam_rzv2m __initconst __maybe_unused = { 80*7e200440SPhil Edworthy .name = "RZ/V2M", 81*7e200440SPhil Edworthy }; 82*7e200440SPhil Edworthy 838d6799a9SGeert Uytterhoeven static const struct renesas_family fam_shmobile __initconst __maybe_unused = { 848d6799a9SGeert Uytterhoeven .name = "SH-Mobile", 858d6799a9SGeert Uytterhoeven .reg = 0xe600101c, /* CCCR (Common Chip Code Register) */ 868d6799a9SGeert Uytterhoeven }; 878d6799a9SGeert Uytterhoeven 888d6799a9SGeert Uytterhoeven 898d6799a9SGeert Uytterhoeven struct renesas_soc { 908d6799a9SGeert Uytterhoeven const struct renesas_family *family; 91187cd57dSLad Prabhakar u32 id; 928d6799a9SGeert Uytterhoeven }; 938d6799a9SGeert Uytterhoeven 948d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rz_a1h __initconst __maybe_unused = { 95175f435fSChris Brandt .family = &fam_rza1, 96175f435fSChris Brandt }; 97175f435fSChris Brandt 98175f435fSChris Brandt static const struct renesas_soc soc_rz_a2m __initconst __maybe_unused = { 99175f435fSChris Brandt .family = &fam_rza2, 100175f435fSChris Brandt .id = 0x3b, 1018d6799a9SGeert Uytterhoeven }; 1028d6799a9SGeert Uytterhoeven 1038d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rmobile_ape6 __initconst __maybe_unused = { 1048d6799a9SGeert Uytterhoeven .family = &fam_rmobile, 1058d6799a9SGeert Uytterhoeven .id = 0x3f, 1068d6799a9SGeert Uytterhoeven }; 1078d6799a9SGeert Uytterhoeven 1088d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rmobile_a1 __initconst __maybe_unused = { 1098d6799a9SGeert Uytterhoeven .family = &fam_rmobile, 1108d6799a9SGeert Uytterhoeven .id = 0x40, 1118d6799a9SGeert Uytterhoeven }; 1128d6799a9SGeert Uytterhoeven 113ebd0e06fSLad Prabhakar static const struct renesas_soc soc_rz_five __initconst __maybe_unused = { 114ebd0e06fSLad Prabhakar .family = &fam_rzfive, 115ebd0e06fSLad Prabhakar .id = 0x847c447, 116ebd0e06fSLad Prabhakar }; 117ebd0e06fSLad Prabhakar 1188848e1b1SGeert Uytterhoeven static const struct renesas_soc soc_rz_g1h __initconst __maybe_unused = { 1192a4056a7SBiju Das .family = &fam_rzg1, 1208848e1b1SGeert Uytterhoeven .id = 0x45, 1218848e1b1SGeert Uytterhoeven }; 1228848e1b1SGeert Uytterhoeven 1238d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rz_g1m __initconst __maybe_unused = { 1242a4056a7SBiju Das .family = &fam_rzg1, 1258d6799a9SGeert Uytterhoeven .id = 0x47, 1268d6799a9SGeert Uytterhoeven }; 1278d6799a9SGeert Uytterhoeven 128cd59de80SGeert Uytterhoeven static const struct renesas_soc soc_rz_g1n __initconst __maybe_unused = { 1292a4056a7SBiju Das .family = &fam_rzg1, 130cd59de80SGeert Uytterhoeven .id = 0x4b, 131cd59de80SGeert Uytterhoeven }; 132cd59de80SGeert Uytterhoeven 1338d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rz_g1e __initconst __maybe_unused = { 1342a4056a7SBiju Das .family = &fam_rzg1, 1358d6799a9SGeert Uytterhoeven .id = 0x4c, 1368d6799a9SGeert Uytterhoeven }; 1378d6799a9SGeert Uytterhoeven 1381daf13baSBiju Das static const struct renesas_soc soc_rz_g1c __initconst __maybe_unused = { 1392a4056a7SBiju Das .family = &fam_rzg1, 1401daf13baSBiju Das .id = 0x53, 1411daf13baSBiju Das }; 1421daf13baSBiju Das 1432a4056a7SBiju Das static const struct renesas_soc soc_rz_g2m __initconst __maybe_unused = { 1442a4056a7SBiju Das .family = &fam_rzg2, 1452a4056a7SBiju Das .id = 0x52, 1462a4056a7SBiju Das }; 1472a4056a7SBiju Das 148574cb721SBiju Das static const struct renesas_soc soc_rz_g2n __initconst __maybe_unused = { 149574cb721SBiju Das .family = &fam_rzg2, 150574cb721SBiju Das .id = 0x55, 151574cb721SBiju Das }; 152574cb721SBiju Das 1532bab3d80SFabrizio Castro static const struct renesas_soc soc_rz_g2e __initconst __maybe_unused = { 1542bab3d80SFabrizio Castro .family = &fam_rzg2, 1552bab3d80SFabrizio Castro .id = 0x57, 1562bab3d80SFabrizio Castro }; 1572bab3d80SFabrizio Castro 1585b83cc42SMarian-Cristian Rotariu static const struct renesas_soc soc_rz_g2h __initconst __maybe_unused = { 1595b83cc42SMarian-Cristian Rotariu .family = &fam_rzg2, 1605b83cc42SMarian-Cristian Rotariu .id = 0x4f, 1615b83cc42SMarian-Cristian Rotariu }; 1625b83cc42SMarian-Cristian Rotariu 163187cd57dSLad Prabhakar static const struct renesas_soc soc_rz_g2l __initconst __maybe_unused = { 164187cd57dSLad Prabhakar .family = &fam_rzg2l, 165187cd57dSLad Prabhakar .id = 0x841c447, 166187cd57dSLad Prabhakar }; 167187cd57dSLad Prabhakar 1682f89bef9SBiju Das static const struct renesas_soc soc_rz_g2ul __initconst __maybe_unused = { 1692f89bef9SBiju Das .family = &fam_rzg2ul, 1702f89bef9SBiju Das .id = 0x8450447, 1712f89bef9SBiju Das }; 1722f89bef9SBiju Das 173860122d8SBiju Das static const struct renesas_soc soc_rz_v2l __initconst __maybe_unused = { 174860122d8SBiju Das .family = &fam_rzv2l, 175860122d8SBiju Das .id = 0x8447447, 176860122d8SBiju Das }; 177860122d8SBiju Das 178*7e200440SPhil Edworthy static const struct renesas_soc soc_rz_v2m __initconst __maybe_unused = { 179*7e200440SPhil Edworthy .family = &fam_rzv2m, 180*7e200440SPhil Edworthy }; 181*7e200440SPhil Edworthy 1828d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_m1a __initconst __maybe_unused = { 1838d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen1, 1848d6799a9SGeert Uytterhoeven }; 1858d6799a9SGeert Uytterhoeven 1868d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_h1 __initconst __maybe_unused = { 1878d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen1, 1888d6799a9SGeert Uytterhoeven .id = 0x3b, 1898d6799a9SGeert Uytterhoeven }; 1908d6799a9SGeert Uytterhoeven 1918d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_h2 __initconst __maybe_unused = { 1928d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 1938d6799a9SGeert Uytterhoeven .id = 0x45, 1948d6799a9SGeert Uytterhoeven }; 1958d6799a9SGeert Uytterhoeven 1968d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_m2_w __initconst __maybe_unused = { 1978d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 1988d6799a9SGeert Uytterhoeven .id = 0x47, 1998d6799a9SGeert Uytterhoeven }; 2008d6799a9SGeert Uytterhoeven 2018d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_v2h __initconst __maybe_unused = { 2028d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 2038d6799a9SGeert Uytterhoeven .id = 0x4a, 2048d6799a9SGeert Uytterhoeven }; 2058d6799a9SGeert Uytterhoeven 2068d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_m2_n __initconst __maybe_unused = { 2078d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 2088d6799a9SGeert Uytterhoeven .id = 0x4b, 2098d6799a9SGeert Uytterhoeven }; 2108d6799a9SGeert Uytterhoeven 2118d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_e2 __initconst __maybe_unused = { 2128d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen2, 2138d6799a9SGeert Uytterhoeven .id = 0x4c, 2148d6799a9SGeert Uytterhoeven }; 2158d6799a9SGeert Uytterhoeven 2168d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_h3 __initconst __maybe_unused = { 2178d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen3, 2188d6799a9SGeert Uytterhoeven .id = 0x4f, 2198d6799a9SGeert Uytterhoeven }; 2208d6799a9SGeert Uytterhoeven 2218d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_rcar_m3_w __initconst __maybe_unused = { 2228d6799a9SGeert Uytterhoeven .family = &fam_rcar_gen3, 2238d6799a9SGeert Uytterhoeven .id = 0x52, 2248d6799a9SGeert Uytterhoeven }; 2258d6799a9SGeert Uytterhoeven 226bfd83983SJacopo Mondi static const struct renesas_soc soc_rcar_m3_n __initconst __maybe_unused = { 227bfd83983SJacopo Mondi .family = &fam_rcar_gen3, 228bfd83983SJacopo Mondi .id = 0x55, 229bfd83983SJacopo Mondi }; 230bfd83983SJacopo Mondi 231bb003075SSergei Shtylyov static const struct renesas_soc soc_rcar_v3m __initconst __maybe_unused = { 232bb003075SSergei Shtylyov .family = &fam_rcar_gen3, 233bb003075SSergei Shtylyov .id = 0x54, 234bb003075SSergei Shtylyov }; 235bb003075SSergei Shtylyov 2368447756dSSergei Shtylyov static const struct renesas_soc soc_rcar_v3h __initconst __maybe_unused = { 2378447756dSSergei Shtylyov .family = &fam_rcar_gen3, 2388447756dSSergei Shtylyov .id = 0x56, 2398447756dSSergei Shtylyov }; 2408447756dSSergei Shtylyov 24144842d45STakeshi Kihara static const struct renesas_soc soc_rcar_e3 __initconst __maybe_unused = { 24244842d45STakeshi Kihara .family = &fam_rcar_gen3, 24344842d45STakeshi Kihara .id = 0x57, 24444842d45STakeshi Kihara }; 24544842d45STakeshi Kihara 2461b954784SGeert Uytterhoeven static const struct renesas_soc soc_rcar_d3 __initconst __maybe_unused = { 2471b954784SGeert Uytterhoeven .family = &fam_rcar_gen3, 2481b954784SGeert Uytterhoeven .id = 0x58, 2491b954784SGeert Uytterhoeven }; 2501b954784SGeert Uytterhoeven 251090e87e7SYoshihiro Shimoda static const struct renesas_soc soc_rcar_v3u __initconst __maybe_unused = { 25227e7657aSGeert Uytterhoeven .family = &fam_rcar_gen4, 253090e87e7SYoshihiro Shimoda .id = 0x59, 254090e87e7SYoshihiro Shimoda }; 255090e87e7SYoshihiro Shimoda 25697116335SYoshihiro Shimoda static const struct renesas_soc soc_rcar_s4 __initconst __maybe_unused = { 25797116335SYoshihiro Shimoda .family = &fam_rcar_gen4, 25897116335SYoshihiro Shimoda .id = 0x5a, 25997116335SYoshihiro Shimoda }; 26097116335SYoshihiro Shimoda 26187ab58e1SYoshihiro Shimoda static const struct renesas_soc soc_rcar_v4h __initconst __maybe_unused = { 26287ab58e1SYoshihiro Shimoda .family = &fam_rcar_gen4, 26387ab58e1SYoshihiro Shimoda .id = 0x5c, 26487ab58e1SYoshihiro Shimoda }; 26587ab58e1SYoshihiro Shimoda 2668d6799a9SGeert Uytterhoeven static const struct renesas_soc soc_shmobile_ag5 __initconst __maybe_unused = { 2678d6799a9SGeert Uytterhoeven .family = &fam_shmobile, 2688d6799a9SGeert Uytterhoeven .id = 0x37, 2698d6799a9SGeert Uytterhoeven }; 2708d6799a9SGeert Uytterhoeven 2718d6799a9SGeert Uytterhoeven 2728d6799a9SGeert Uytterhoeven static const struct of_device_id renesas_socs[] __initconst = { 2738d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R7S72100 2748d6799a9SGeert Uytterhoeven { .compatible = "renesas,r7s72100", .data = &soc_rz_a1h }, 2758d6799a9SGeert Uytterhoeven #endif 276175f435fSChris Brandt #ifdef CONFIG_ARCH_R7S9210 277175f435fSChris Brandt { .compatible = "renesas,r7s9210", .data = &soc_rz_a2m }, 278175f435fSChris Brandt #endif 2798d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A73A4 2808d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a73a4", .data = &soc_rmobile_ape6 }, 2818d6799a9SGeert Uytterhoeven #endif 2828d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7740 2838d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7740", .data = &soc_rmobile_a1 }, 2848d6799a9SGeert Uytterhoeven #endif 2858848e1b1SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7742 2868848e1b1SGeert Uytterhoeven { .compatible = "renesas,r8a7742", .data = &soc_rz_g1h }, 2878848e1b1SGeert Uytterhoeven #endif 2888d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7743 2898d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7743", .data = &soc_rz_g1m }, 2908d6799a9SGeert Uytterhoeven #endif 291cd59de80SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7744 292cd59de80SGeert Uytterhoeven { .compatible = "renesas,r8a7744", .data = &soc_rz_g1n }, 293cd59de80SGeert Uytterhoeven #endif 2948d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7745 2958d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7745", .data = &soc_rz_g1e }, 2968d6799a9SGeert Uytterhoeven #endif 2971daf13baSBiju Das #ifdef CONFIG_ARCH_R8A77470 2981daf13baSBiju Das { .compatible = "renesas,r8a77470", .data = &soc_rz_g1c }, 2991daf13baSBiju Das #endif 3002a4056a7SBiju Das #ifdef CONFIG_ARCH_R8A774A1 3012a4056a7SBiju Das { .compatible = "renesas,r8a774a1", .data = &soc_rz_g2m }, 3022a4056a7SBiju Das #endif 303574cb721SBiju Das #ifdef CONFIG_ARCH_R8A774B1 304574cb721SBiju Das { .compatible = "renesas,r8a774b1", .data = &soc_rz_g2n }, 305574cb721SBiju Das #endif 3062bab3d80SFabrizio Castro #ifdef CONFIG_ARCH_R8A774C0 3072bab3d80SFabrizio Castro { .compatible = "renesas,r8a774c0", .data = &soc_rz_g2e }, 3082bab3d80SFabrizio Castro #endif 3095b83cc42SMarian-Cristian Rotariu #ifdef CONFIG_ARCH_R8A774E1 3105b83cc42SMarian-Cristian Rotariu { .compatible = "renesas,r8a774e1", .data = &soc_rz_g2h }, 3115b83cc42SMarian-Cristian Rotariu #endif 3128d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7778 3138d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7778", .data = &soc_rcar_m1a }, 3148d6799a9SGeert Uytterhoeven #endif 3158d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7779 3168d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7779", .data = &soc_rcar_h1 }, 3178d6799a9SGeert Uytterhoeven #endif 3188d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7790 3198d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7790", .data = &soc_rcar_h2 }, 3208d6799a9SGeert Uytterhoeven #endif 3218d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7791 3228d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7791", .data = &soc_rcar_m2_w }, 3238d6799a9SGeert Uytterhoeven #endif 3248d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7792 3258d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7792", .data = &soc_rcar_v2h }, 3268d6799a9SGeert Uytterhoeven #endif 3278d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7793 3288d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7793", .data = &soc_rcar_m2_n }, 3298d6799a9SGeert Uytterhoeven #endif 3308d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A7794 3318d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7794", .data = &soc_rcar_e2 }, 3328d6799a9SGeert Uytterhoeven #endif 3334ff27112SGeert Uytterhoeven #if defined(CONFIG_ARCH_R8A77950) || defined(CONFIG_ARCH_R8A77951) 3348d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7795", .data = &soc_rcar_h3 }, 3358d6799a9SGeert Uytterhoeven #endif 336bfe6b559SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A77951 3372ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m0", .data = &soc_rcar_h3 }, 338bfe6b559SGeert Uytterhoeven { .compatible = "renesas,r8a779m1", .data = &soc_rcar_h3 }, 3392ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m8", .data = &soc_rcar_h3 }, 3401b37236dSGeert Uytterhoeven { .compatible = "renesas,r8a779mb", .data = &soc_rcar_h3 }, 341bfe6b559SGeert Uytterhoeven #endif 34239e57e14SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A77960 3438d6799a9SGeert Uytterhoeven { .compatible = "renesas,r8a7796", .data = &soc_rcar_m3_w }, 3448d6799a9SGeert Uytterhoeven #endif 3459c9f7891SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A77961 3469c9f7891SGeert Uytterhoeven { .compatible = "renesas,r8a77961", .data = &soc_rcar_m3_w }, 3472ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m2", .data = &soc_rcar_m3_w }, 348bfe6b559SGeert Uytterhoeven { .compatible = "renesas,r8a779m3", .data = &soc_rcar_m3_w }, 3499c9f7891SGeert Uytterhoeven #endif 350bfd83983SJacopo Mondi #ifdef CONFIG_ARCH_R8A77965 351bfd83983SJacopo Mondi { .compatible = "renesas,r8a77965", .data = &soc_rcar_m3_n }, 3522ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m4", .data = &soc_rcar_m3_n }, 3532ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m5", .data = &soc_rcar_m3_n }, 354bfd83983SJacopo Mondi #endif 355bb003075SSergei Shtylyov #ifdef CONFIG_ARCH_R8A77970 356bb003075SSergei Shtylyov { .compatible = "renesas,r8a77970", .data = &soc_rcar_v3m }, 357bb003075SSergei Shtylyov #endif 3588447756dSSergei Shtylyov #ifdef CONFIG_ARCH_R8A77980 3598447756dSSergei Shtylyov { .compatible = "renesas,r8a77980", .data = &soc_rcar_v3h }, 3608447756dSSergei Shtylyov #endif 36144842d45STakeshi Kihara #ifdef CONFIG_ARCH_R8A77990 36244842d45STakeshi Kihara { .compatible = "renesas,r8a77990", .data = &soc_rcar_e3 }, 3632ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m6", .data = &soc_rcar_e3 }, 36444842d45STakeshi Kihara #endif 3651b954784SGeert Uytterhoeven #ifdef CONFIG_ARCH_R8A77995 3661b954784SGeert Uytterhoeven { .compatible = "renesas,r8a77995", .data = &soc_rcar_d3 }, 3672ed1e481SGeert Uytterhoeven { .compatible = "renesas,r8a779m7", .data = &soc_rcar_d3 }, 3681b954784SGeert Uytterhoeven #endif 369090e87e7SYoshihiro Shimoda #ifdef CONFIG_ARCH_R8A779A0 370090e87e7SYoshihiro Shimoda { .compatible = "renesas,r8a779a0", .data = &soc_rcar_v3u }, 371090e87e7SYoshihiro Shimoda #endif 37297116335SYoshihiro Shimoda #ifdef CONFIG_ARCH_R8A779F0 37397116335SYoshihiro Shimoda { .compatible = "renesas,r8a779f0", .data = &soc_rcar_s4 }, 37497116335SYoshihiro Shimoda #endif 37587ab58e1SYoshihiro Shimoda #ifdef CONFIG_ARCH_R8A779G0 37687ab58e1SYoshihiro Shimoda { .compatible = "renesas,r8a779g0", .data = &soc_rcar_v4h }, 37787ab58e1SYoshihiro Shimoda #endif 3782f89bef9SBiju Das #if defined(CONFIG_ARCH_R9A07G043) 379ebd0e06fSLad Prabhakar #ifdef CONFIG_RISCV 380ebd0e06fSLad Prabhakar { .compatible = "renesas,r9a07g043", .data = &soc_rz_five }, 381ebd0e06fSLad Prabhakar #else 3822f89bef9SBiju Das { .compatible = "renesas,r9a07g043", .data = &soc_rz_g2ul }, 3832f89bef9SBiju Das #endif 384ebd0e06fSLad Prabhakar #endif 385187cd57dSLad Prabhakar #if defined(CONFIG_ARCH_R9A07G044) 386187cd57dSLad Prabhakar { .compatible = "renesas,r9a07g044", .data = &soc_rz_g2l }, 387187cd57dSLad Prabhakar #endif 388860122d8SBiju Das #if defined(CONFIG_ARCH_R9A07G054) 389860122d8SBiju Das { .compatible = "renesas,r9a07g054", .data = &soc_rz_v2l }, 390860122d8SBiju Das #endif 391*7e200440SPhil Edworthy #if defined(CONFIG_ARCH_R9A09G011) 392*7e200440SPhil Edworthy { .compatible = "renesas,r9a09g011", .data = &soc_rz_v2m }, 393*7e200440SPhil Edworthy #endif 3948d6799a9SGeert Uytterhoeven #ifdef CONFIG_ARCH_SH73A0 3958d6799a9SGeert Uytterhoeven { .compatible = "renesas,sh73a0", .data = &soc_shmobile_ag5 }, 3968d6799a9SGeert Uytterhoeven #endif 3978d6799a9SGeert Uytterhoeven { /* sentinel */ } 3988d6799a9SGeert Uytterhoeven }; 3998d6799a9SGeert Uytterhoeven 40005b22caaSGeert Uytterhoeven struct renesas_id { 40105b22caaSGeert Uytterhoeven unsigned int offset; 40205b22caaSGeert Uytterhoeven u32 mask; 40305b22caaSGeert Uytterhoeven }; 40405b22caaSGeert Uytterhoeven 40505b22caaSGeert Uytterhoeven static const struct renesas_id id_bsid __initconst = { 40605b22caaSGeert Uytterhoeven .offset = 0, 40705b22caaSGeert Uytterhoeven .mask = 0xff0000, 40805b22caaSGeert Uytterhoeven /* 40905b22caaSGeert Uytterhoeven * TODO: Upper 4 bits of BSID are for chip version, but the format is 41005b22caaSGeert Uytterhoeven * not known at this time so we don't know how to specify eshi and eslo 41105b22caaSGeert Uytterhoeven */ 41205b22caaSGeert Uytterhoeven }; 41305b22caaSGeert Uytterhoeven 41405b22caaSGeert Uytterhoeven static const struct renesas_id id_rzg2l __initconst = { 41505b22caaSGeert Uytterhoeven .offset = 0xa04, 41605b22caaSGeert Uytterhoeven .mask = 0xfffffff, 41705b22caaSGeert Uytterhoeven }; 41805b22caaSGeert Uytterhoeven 419*7e200440SPhil Edworthy static const struct renesas_id id_rzv2m __initconst = { 420*7e200440SPhil Edworthy .offset = 0x104, 421*7e200440SPhil Edworthy .mask = 0xff, 422*7e200440SPhil Edworthy }; 423*7e200440SPhil Edworthy 42405b22caaSGeert Uytterhoeven static const struct renesas_id id_prr __initconst = { 42505b22caaSGeert Uytterhoeven .offset = 0, 42605b22caaSGeert Uytterhoeven .mask = 0xff00, 42705b22caaSGeert Uytterhoeven }; 42805b22caaSGeert Uytterhoeven 42905b22caaSGeert Uytterhoeven static const struct of_device_id renesas_ids[] __initconst = { 43005b22caaSGeert Uytterhoeven { .compatible = "renesas,bsid", .data = &id_bsid }, 4312f89bef9SBiju Das { .compatible = "renesas,r9a07g043-sysc", .data = &id_rzg2l }, 43205b22caaSGeert Uytterhoeven { .compatible = "renesas,r9a07g044-sysc", .data = &id_rzg2l }, 433860122d8SBiju Das { .compatible = "renesas,r9a07g054-sysc", .data = &id_rzg2l }, 434*7e200440SPhil Edworthy { .compatible = "renesas,r9a09g011-sys", .data = &id_rzv2m }, 43505b22caaSGeert Uytterhoeven { .compatible = "renesas,prr", .data = &id_prr }, 43605b22caaSGeert Uytterhoeven { /* sentinel */ } 43705b22caaSGeert Uytterhoeven }; 43805b22caaSGeert Uytterhoeven 4398d6799a9SGeert Uytterhoeven static int __init renesas_soc_init(void) 4408d6799a9SGeert Uytterhoeven { 4418d6799a9SGeert Uytterhoeven struct soc_device_attribute *soc_dev_attr; 44205b22caaSGeert Uytterhoeven unsigned int product, eshi = 0, eslo; 4438d6799a9SGeert Uytterhoeven const struct renesas_family *family; 4448d6799a9SGeert Uytterhoeven const struct of_device_id *match; 4458d6799a9SGeert Uytterhoeven const struct renesas_soc *soc; 44605b22caaSGeert Uytterhoeven const struct renesas_id *id; 4478d6799a9SGeert Uytterhoeven void __iomem *chipid = NULL; 448cb5508e4SBiju Das const char *rev_prefix = ""; 4498d6799a9SGeert Uytterhoeven struct soc_device *soc_dev; 4508d6799a9SGeert Uytterhoeven struct device_node *np; 45105b22caaSGeert Uytterhoeven const char *soc_id; 452cb5508e4SBiju Das int ret; 4538d6799a9SGeert Uytterhoeven 4548d6799a9SGeert Uytterhoeven match = of_match_node(renesas_socs, of_root); 4558d6799a9SGeert Uytterhoeven if (!match) 4568d6799a9SGeert Uytterhoeven return -ENODEV; 4578d6799a9SGeert Uytterhoeven 45805b22caaSGeert Uytterhoeven soc_id = strchr(match->compatible, ',') + 1; 4598d6799a9SGeert Uytterhoeven soc = match->data; 4608d6799a9SGeert Uytterhoeven family = soc->family; 4618d6799a9SGeert Uytterhoeven 46205b22caaSGeert Uytterhoeven np = of_find_matching_node_and_match(NULL, renesas_ids, &match); 463175f435fSChris Brandt if (np) { 46405b22caaSGeert Uytterhoeven id = match->data; 4658d6799a9SGeert Uytterhoeven chipid = of_iomap(np, 0); 4668d6799a9SGeert Uytterhoeven of_node_put(np); 4674194b583SGeert Uytterhoeven } else if (soc->id && family->reg) { 46805b22caaSGeert Uytterhoeven /* Try hardcoded CCCR/PRR fallback */ 46905b22caaSGeert Uytterhoeven id = &id_prr; 4708d6799a9SGeert Uytterhoeven chipid = ioremap(family->reg, 4); 4718d6799a9SGeert Uytterhoeven } 47205b22caaSGeert Uytterhoeven 473cb5508e4SBiju Das soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); 474cb5508e4SBiju Das if (!soc_dev_attr) 475cb5508e4SBiju Das return -ENOMEM; 476cb5508e4SBiju Das 477cb5508e4SBiju Das np = of_find_node_by_path("/"); 478cb5508e4SBiju Das of_property_read_string(np, "model", &soc_dev_attr->machine); 479cb5508e4SBiju Das of_node_put(np); 480cb5508e4SBiju Das 481cb5508e4SBiju Das soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL); 482cb5508e4SBiju Das soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL); 483cb5508e4SBiju Das 4848d6799a9SGeert Uytterhoeven if (chipid) { 48505b22caaSGeert Uytterhoeven product = readl(chipid + id->offset); 4868d6799a9SGeert Uytterhoeven iounmap(chipid); 48705b22caaSGeert Uytterhoeven 48805b22caaSGeert Uytterhoeven if (id == &id_prr) { 48990f0d2b3SGeert Uytterhoeven /* R-Car M3-W ES1.1 incorrectly identifies as ES2.0 */ 49090f0d2b3SGeert Uytterhoeven if ((product & 0x7fff) == 0x5210) 49190f0d2b3SGeert Uytterhoeven product ^= 0x11; 49215160f6dSTakeshi Kihara /* R-Car M3-W ES1.3 incorrectly identifies as ES2.1 */ 49315160f6dSTakeshi Kihara if ((product & 0x7fff) == 0x5211) 49415160f6dSTakeshi Kihara product ^= 0x12; 49505b22caaSGeert Uytterhoeven 496175f435fSChris Brandt eshi = ((product >> 4) & 0x0f) + 1; 497175f435fSChris Brandt eslo = product & 0xf; 498cb5508e4SBiju Das soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", 499cb5508e4SBiju Das eshi, eslo); 500cb5508e4SBiju Das } else if (id == &id_rzg2l) { 501cb5508e4SBiju Das eshi = ((product >> 28) & 0x0f); 502cb5508e4SBiju Das soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%u", 503cb5508e4SBiju Das eshi); 504cb5508e4SBiju Das rev_prefix = "Rev "; 505*7e200440SPhil Edworthy } else if (id == &id_rzv2m) { 506*7e200440SPhil Edworthy eshi = ((product >> 4) & 0x0f); 507*7e200440SPhil Edworthy eslo = product & 0xf; 508*7e200440SPhil Edworthy soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%u.%u", 509*7e200440SPhil Edworthy eshi, eslo); 5108d6799a9SGeert Uytterhoeven } 5118d6799a9SGeert Uytterhoeven 51205b22caaSGeert Uytterhoeven if (soc->id && 51305b22caaSGeert Uytterhoeven ((product & id->mask) >> __ffs(id->mask)) != soc->id) { 51405b22caaSGeert Uytterhoeven pr_warn("SoC mismatch (product = 0x%x)\n", product); 515cb5508e4SBiju Das ret = -ENODEV; 516cb5508e4SBiju Das goto free_soc_dev_attr; 51705b22caaSGeert Uytterhoeven } 51805b22caaSGeert Uytterhoeven } 51905b22caaSGeert Uytterhoeven 520cb5508e4SBiju Das pr_info("Detected Renesas %s %s %s%s\n", soc_dev_attr->family, 521cb5508e4SBiju Das soc_dev_attr->soc_id, rev_prefix, soc_dev_attr->revision ?: ""); 5228d6799a9SGeert Uytterhoeven 5238d6799a9SGeert Uytterhoeven soc_dev = soc_device_register(soc_dev_attr); 5248d6799a9SGeert Uytterhoeven if (IS_ERR(soc_dev)) { 525cb5508e4SBiju Das ret = PTR_ERR(soc_dev); 526cb5508e4SBiju Das goto free_soc_dev_attr; 527cb5508e4SBiju Das } 528cb5508e4SBiju Das 529cb5508e4SBiju Das return 0; 530cb5508e4SBiju Das 531cb5508e4SBiju Das free_soc_dev_attr: 5328d6799a9SGeert Uytterhoeven kfree(soc_dev_attr->revision); 5338d6799a9SGeert Uytterhoeven kfree_const(soc_dev_attr->soc_id); 5348d6799a9SGeert Uytterhoeven kfree_const(soc_dev_attr->family); 5358d6799a9SGeert Uytterhoeven kfree(soc_dev_attr); 536cb5508e4SBiju Das return ret; 5378d6799a9SGeert Uytterhoeven } 538b1d134baSGeert Uytterhoeven early_initcall(renesas_soc_init); 539