10ab55cf1SYoshihiro Shimoda // SPDX-License-Identifier: GPL-2.0 20ab55cf1SYoshihiro Shimoda /* 30ab55cf1SYoshihiro Shimoda * r8a779g0 Clock Pulse Generator / Module Standby and Software Reset 40ab55cf1SYoshihiro Shimoda * 50ab55cf1SYoshihiro Shimoda * Copyright (C) 2022 Renesas Electronics Corp. 60ab55cf1SYoshihiro Shimoda * 70ab55cf1SYoshihiro Shimoda * Based on r8a779f0-cpg-mssr.c 80ab55cf1SYoshihiro Shimoda */ 90ab55cf1SYoshihiro Shimoda 100ab55cf1SYoshihiro Shimoda #include <linux/bitfield.h> 110ab55cf1SYoshihiro Shimoda #include <linux/clk.h> 120ab55cf1SYoshihiro Shimoda #include <linux/clk-provider.h> 130ab55cf1SYoshihiro Shimoda #include <linux/device.h> 140ab55cf1SYoshihiro Shimoda #include <linux/err.h> 150ab55cf1SYoshihiro Shimoda #include <linux/kernel.h> 160ab55cf1SYoshihiro Shimoda #include <linux/soc/renesas/rcar-rst.h> 170ab55cf1SYoshihiro Shimoda 180ab55cf1SYoshihiro Shimoda #include <dt-bindings/clock/r8a779g0-cpg-mssr.h> 190ab55cf1SYoshihiro Shimoda 200ab55cf1SYoshihiro Shimoda #include "renesas-cpg-mssr.h" 210ab55cf1SYoshihiro Shimoda #include "rcar-gen4-cpg.h" 220ab55cf1SYoshihiro Shimoda 230ab55cf1SYoshihiro Shimoda enum clk_ids { 240ab55cf1SYoshihiro Shimoda /* Core Clock Outputs exported to DT */ 250ab55cf1SYoshihiro Shimoda LAST_DT_CORE_CLK = R8A779G0_CLK_R, 260ab55cf1SYoshihiro Shimoda 270ab55cf1SYoshihiro Shimoda /* External Input Clocks */ 280ab55cf1SYoshihiro Shimoda CLK_EXTAL, 290ab55cf1SYoshihiro Shimoda CLK_EXTALR, 300ab55cf1SYoshihiro Shimoda 310ab55cf1SYoshihiro Shimoda /* Internal Core Clocks */ 320ab55cf1SYoshihiro Shimoda CLK_MAIN, 330ab55cf1SYoshihiro Shimoda CLK_PLL1, 340ab55cf1SYoshihiro Shimoda CLK_PLL2, 350ab55cf1SYoshihiro Shimoda CLK_PLL3, 360ab55cf1SYoshihiro Shimoda CLK_PLL4, 370ab55cf1SYoshihiro Shimoda CLK_PLL5, 380ab55cf1SYoshihiro Shimoda CLK_PLL6, 390ab55cf1SYoshihiro Shimoda CLK_PLL1_DIV2, 400ab55cf1SYoshihiro Shimoda CLK_PLL2_DIV2, 410ab55cf1SYoshihiro Shimoda CLK_PLL3_DIV2, 420ab55cf1SYoshihiro Shimoda CLK_PLL4_DIV2, 430ab55cf1SYoshihiro Shimoda CLK_PLL5_DIV2, 440ab55cf1SYoshihiro Shimoda CLK_PLL5_DIV4, 450ab55cf1SYoshihiro Shimoda CLK_PLL6_DIV2, 460ab55cf1SYoshihiro Shimoda CLK_S0, 470ab55cf1SYoshihiro Shimoda CLK_S0_VIO, 480ab55cf1SYoshihiro Shimoda CLK_S0_VC, 490ab55cf1SYoshihiro Shimoda CLK_S0_HSC, 50ba5284ebSGeert Uytterhoeven CLK_SASYNCPER, 510ab55cf1SYoshihiro Shimoda CLK_SV_VIP, 520ab55cf1SYoshihiro Shimoda CLK_SV_IR, 530ab55cf1SYoshihiro Shimoda CLK_SDSRC, 540ab55cf1SYoshihiro Shimoda CLK_RPCSRC, 550ab55cf1SYoshihiro Shimoda CLK_VIO, 560ab55cf1SYoshihiro Shimoda CLK_VC, 570ab55cf1SYoshihiro Shimoda CLK_OCO, 580ab55cf1SYoshihiro Shimoda 590ab55cf1SYoshihiro Shimoda /* Module Clocks */ 600ab55cf1SYoshihiro Shimoda MOD_CLK_BASE 610ab55cf1SYoshihiro Shimoda }; 620ab55cf1SYoshihiro Shimoda 630ab55cf1SYoshihiro Shimoda static const struct cpg_core_clk r8a779g0_core_clks[] __initconst = { 640ab55cf1SYoshihiro Shimoda /* External Clock Inputs */ 650ab55cf1SYoshihiro Shimoda DEF_INPUT("extal", CLK_EXTAL), 660ab55cf1SYoshihiro Shimoda DEF_INPUT("extalr", CLK_EXTALR), 670ab55cf1SYoshihiro Shimoda 680ab55cf1SYoshihiro Shimoda /* Internal Core Clocks */ 690ab55cf1SYoshihiro Shimoda DEF_BASE(".main", CLK_MAIN, CLK_TYPE_GEN4_MAIN, CLK_EXTAL), 700ab55cf1SYoshihiro Shimoda DEF_BASE(".pll1", CLK_PLL1, CLK_TYPE_GEN4_PLL1, CLK_MAIN), 71584d2991SGeert Uytterhoeven DEF_BASE(".pll2", CLK_PLL2, CLK_TYPE_GEN4_PLL2_VAR, CLK_MAIN), 720ab55cf1SYoshihiro Shimoda DEF_BASE(".pll3", CLK_PLL3, CLK_TYPE_GEN4_PLL3, CLK_MAIN), 730ab55cf1SYoshihiro Shimoda DEF_BASE(".pll4", CLK_PLL4, CLK_TYPE_GEN4_PLL4, CLK_MAIN), 740ab55cf1SYoshihiro Shimoda DEF_BASE(".pll5", CLK_PLL5, CLK_TYPE_GEN4_PLL5, CLK_MAIN), 750ab55cf1SYoshihiro Shimoda DEF_BASE(".pll6", CLK_PLL6, CLK_TYPE_GEN4_PLL6, CLK_MAIN), 760ab55cf1SYoshihiro Shimoda 770ab55cf1SYoshihiro Shimoda DEF_FIXED(".pll1_div2", CLK_PLL1_DIV2, CLK_PLL1, 2, 1), 780ab55cf1SYoshihiro Shimoda DEF_FIXED(".pll2_div2", CLK_PLL2_DIV2, CLK_PLL2, 2, 1), 790ab55cf1SYoshihiro Shimoda DEF_FIXED(".pll3_div2", CLK_PLL3_DIV2, CLK_PLL3, 2, 1), 800ab55cf1SYoshihiro Shimoda DEF_FIXED(".pll4_div2", CLK_PLL4_DIV2, CLK_PLL4, 2, 1), 810ab55cf1SYoshihiro Shimoda DEF_FIXED(".pll5_div2", CLK_PLL5_DIV2, CLK_PLL5, 2, 1), 820ab55cf1SYoshihiro Shimoda DEF_FIXED(".pll5_div4", CLK_PLL5_DIV4, CLK_PLL5_DIV2, 2, 1), 830ab55cf1SYoshihiro Shimoda DEF_FIXED(".pll6_div2", CLK_PLL6_DIV2, CLK_PLL6, 2, 1), 840ab55cf1SYoshihiro Shimoda DEF_FIXED(".s0", CLK_S0, CLK_PLL1_DIV2, 2, 1), 850ab55cf1SYoshihiro Shimoda DEF_FIXED(".s0_vio", CLK_S0_VIO, CLK_PLL1_DIV2, 2, 1), 860ab55cf1SYoshihiro Shimoda DEF_FIXED(".s0_vc", CLK_S0_VC, CLK_PLL1_DIV2, 2, 1), 870ab55cf1SYoshihiro Shimoda DEF_FIXED(".s0_hsc", CLK_S0_HSC, CLK_PLL1_DIV2, 2, 1), 88ba5284ebSGeert Uytterhoeven DEF_FIXED(".sasyncper", CLK_SASYNCPER, CLK_PLL5_DIV4, 3, 1), 890ab55cf1SYoshihiro Shimoda DEF_FIXED(".sv_vip", CLK_SV_VIP, CLK_PLL1, 5, 1), 900ab55cf1SYoshihiro Shimoda DEF_FIXED(".sv_ir", CLK_SV_IR, CLK_PLL1, 5, 1), 910ab55cf1SYoshihiro Shimoda DEF_BASE(".sdsrc", CLK_SDSRC, CLK_TYPE_GEN4_SDSRC, CLK_PLL5), 920ab55cf1SYoshihiro Shimoda DEF_RATE(".oco", CLK_OCO, 32768), 930ab55cf1SYoshihiro Shimoda 940ab55cf1SYoshihiro Shimoda DEF_BASE(".rpcsrc", CLK_RPCSRC, CLK_TYPE_GEN4_RPCSRC, CLK_PLL5), 950ab55cf1SYoshihiro Shimoda DEF_FIXED(".vio", CLK_VIO, CLK_PLL5_DIV2, 3, 1), 960ab55cf1SYoshihiro Shimoda DEF_FIXED(".vc", CLK_VC, CLK_PLL5_DIV2, 3, 1), 970ab55cf1SYoshihiro Shimoda 980ab55cf1SYoshihiro Shimoda /* Core Clock Outputs */ 99b5f7c6a5SGeert Uytterhoeven DEF_GEN4_Z("z0", R8A779G0_CLK_Z0, CLK_TYPE_GEN4_Z, CLK_PLL2, 2, 0), 1000ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d2", R8A779G0_CLK_S0D2, CLK_S0, 2, 1), 1010ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d3", R8A779G0_CLK_S0D3, CLK_S0, 3, 1), 1020ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d4", R8A779G0_CLK_S0D4, CLK_S0, 4, 1), 1030ab55cf1SYoshihiro Shimoda DEF_FIXED("cl16m", R8A779G0_CLK_CL16M, CLK_S0, 48, 1), 1040ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d1_vio", R8A779G0_CLK_S0D1_VIO, CLK_S0_VIO, 1, 1), 1050ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d2_vio", R8A779G0_CLK_S0D2_VIO, CLK_S0_VIO, 2, 1), 1060ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d4_vio", R8A779G0_CLK_S0D4_VIO, CLK_S0_VIO, 4, 1), 1070ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d8_vio", R8A779G0_CLK_S0D8_VIO, CLK_S0_VIO, 8, 1), 1080ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d1_vc", R8A779G0_CLK_S0D1_VC, CLK_S0_VC, 1, 1), 1090ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d2_vc", R8A779G0_CLK_S0D2_VC, CLK_S0_VC, 2, 1), 1100ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d4_vc", R8A779G0_CLK_S0D4_VC, CLK_S0_VC, 4, 1), 1110ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d2_mm", R8A779G0_CLK_S0D2_MM, CLK_S0, 2, 1), 1120ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d4_mm", R8A779G0_CLK_S0D4_MM, CLK_S0, 4, 1), 1130ab55cf1SYoshihiro Shimoda DEF_FIXED("cl16m_mm", R8A779G0_CLK_CL16M_MM, CLK_S0, 48, 1), 1140ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d2_u3dg", R8A779G0_CLK_S0D2_U3DG, CLK_S0, 2, 1), 1150ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d4_u3dg", R8A779G0_CLK_S0D4_U3DG, CLK_S0, 4, 1), 1160ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d2_rt", R8A779G0_CLK_S0D2_RT, CLK_S0, 2, 1), 1170ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d3_rt", R8A779G0_CLK_S0D3_RT, CLK_S0, 3, 1), 1180ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d4_rt", R8A779G0_CLK_S0D4_RT, CLK_S0, 4, 1), 1190ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d6_rt", R8A779G0_CLK_S0D6_RT, CLK_S0, 6, 1), 1200ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d24_rt", R8A779G0_CLK_S0D24_RT, CLK_S0, 24, 1), 1210ab55cf1SYoshihiro Shimoda DEF_FIXED("cl16m_rt", R8A779G0_CLK_CL16M_RT, CLK_S0, 48, 1), 1220ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d2_per", R8A779G0_CLK_S0D2_PER, CLK_S0, 2, 1), 1230ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d3_per", R8A779G0_CLK_S0D3_PER, CLK_S0, 3, 1), 1240ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d4_per", R8A779G0_CLK_S0D4_PER, CLK_S0, 4, 1), 1250ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d6_per", R8A779G0_CLK_S0D6_PER, CLK_S0, 6, 1), 1260ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d12_per", R8A779G0_CLK_S0D12_PER, CLK_S0, 12, 1), 1270ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d24_per", R8A779G0_CLK_S0D24_PER, CLK_S0, 24, 1), 1280ab55cf1SYoshihiro Shimoda DEF_FIXED("cl16m_per", R8A779G0_CLK_CL16M_PER, CLK_S0, 48, 1), 1290ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d1_hsc", R8A779G0_CLK_S0D1_HSC, CLK_S0_HSC, 1, 1), 1300ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d2_hsc", R8A779G0_CLK_S0D2_HSC, CLK_S0_HSC, 2, 1), 1310ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d4_hsc", R8A779G0_CLK_S0D4_HSC, CLK_S0_HSC, 4, 1), 1320ab55cf1SYoshihiro Shimoda DEF_FIXED("cl16m_hsc", R8A779G0_CLK_CL16M_HSC, CLK_S0_HSC, 48, 1), 1330ab55cf1SYoshihiro Shimoda DEF_FIXED("s0d2_cc", R8A779G0_CLK_S0D2_CC, CLK_S0, 2, 1), 134106f51e9SWolfram Sang DEF_FIXED("sasyncrt", R8A779G0_CLK_SASYNCRT, CLK_PLL5_DIV4, 48, 1), 135ba5284ebSGeert Uytterhoeven DEF_FIXED("sasyncperd1",R8A779G0_CLK_SASYNCPERD1, CLK_SASYNCPER,1, 1), 136ba5284ebSGeert Uytterhoeven DEF_FIXED("sasyncperd2",R8A779G0_CLK_SASYNCPERD2, CLK_SASYNCPER,2, 1), 137ba5284ebSGeert Uytterhoeven DEF_FIXED("sasyncperd4",R8A779G0_CLK_SASYNCPERD4, CLK_SASYNCPER,4, 1), 1380ab55cf1SYoshihiro Shimoda DEF_FIXED("svd1_ir", R8A779G0_CLK_SVD1_IR, CLK_SV_IR, 1, 1), 1390ab55cf1SYoshihiro Shimoda DEF_FIXED("svd2_ir", R8A779G0_CLK_SVD2_IR, CLK_SV_IR, 2, 1), 1400ab55cf1SYoshihiro Shimoda DEF_FIXED("svd1_vip", R8A779G0_CLK_SVD1_VIP, CLK_SV_VIP, 1, 1), 1410ab55cf1SYoshihiro Shimoda DEF_FIXED("svd2_vip", R8A779G0_CLK_SVD2_VIP, CLK_SV_VIP, 2, 1), 1420ab55cf1SYoshihiro Shimoda DEF_FIXED("cbfusa", R8A779G0_CLK_CBFUSA, CLK_EXTAL, 2, 1), 1430ab55cf1SYoshihiro Shimoda DEF_FIXED("cpex", R8A779G0_CLK_CPEX, CLK_EXTAL, 2, 1), 1440ab55cf1SYoshihiro Shimoda DEF_FIXED("viobus", R8A779G0_CLK_VIOBUS, CLK_VIO, 1, 1), 1450ab55cf1SYoshihiro Shimoda DEF_FIXED("viobusd2", R8A779G0_CLK_VIOBUSD2, CLK_VIO, 2, 1), 1460ab55cf1SYoshihiro Shimoda DEF_FIXED("vcbus", R8A779G0_CLK_VCBUS, CLK_VC, 1, 1), 1470ab55cf1SYoshihiro Shimoda DEF_FIXED("vcbusd2", R8A779G0_CLK_VCBUSD2, CLK_VC, 2, 1), 148bd176e46SGeert Uytterhoeven DEF_DIV6P1("canfd", R8A779G0_CLK_CANFD, CLK_PLL5_DIV4, 0x878), 1498b406fd4SNiklas Söderlund DEF_DIV6P1("csi", R8A779G0_CLK_CSI, CLK_PLL5_DIV4, 0x880), 150ff1dd4a8STomi Valkeinen DEF_FIXED("dsiref", R8A779G0_CLK_DSIREF, CLK_PLL5_DIV4, 48, 1), 151ff1dd4a8STomi Valkeinen DEF_DIV6P1("dsiext", R8A779G0_CLK_DSIEXT, CLK_PLL5_DIV4, 0x884), 1520ab55cf1SYoshihiro Shimoda 1534ee04993SGeert Uytterhoeven DEF_GEN4_SDH("sd0h", R8A779G0_CLK_SD0H, CLK_SDSRC, 0x870), 1544ee04993SGeert Uytterhoeven DEF_GEN4_SD("sd0", R8A779G0_CLK_SD0, R8A779G0_CLK_SD0H, 0x870), 1550ab55cf1SYoshihiro Shimoda DEF_DIV6P1("mso", R8A779G0_CLK_MSO, CLK_PLL5_DIV4, 0x87c), 1560ab55cf1SYoshihiro Shimoda 1570ab55cf1SYoshihiro Shimoda DEF_BASE("rpc", R8A779G0_CLK_RPC, CLK_TYPE_GEN4_RPC, CLK_RPCSRC), 1580ab55cf1SYoshihiro Shimoda DEF_BASE("rpcd2", R8A779G0_CLK_RPCD2, CLK_TYPE_GEN4_RPCD2, R8A779G0_CLK_RPC), 1590ab55cf1SYoshihiro Shimoda 1600ab55cf1SYoshihiro Shimoda DEF_GEN4_OSC("osc", R8A779G0_CLK_OSC, CLK_EXTAL, 8), 1610ab55cf1SYoshihiro Shimoda DEF_GEN4_MDSEL("r", R8A779G0_CLK_R, 29, CLK_EXTALR, 1, CLK_OCO, 1), 1620ab55cf1SYoshihiro Shimoda }; 1630ab55cf1SYoshihiro Shimoda 1640ab55cf1SYoshihiro Shimoda static const struct mssr_mod_clk r8a779g0_mod_clks[] __initconst = { 165e46a1a99SGeert Uytterhoeven DEF_MOD("avb0", 211, R8A779G0_CLK_S0D4_HSC), 166e46a1a99SGeert Uytterhoeven DEF_MOD("avb1", 212, R8A779G0_CLK_S0D4_HSC), 167e46a1a99SGeert Uytterhoeven DEF_MOD("avb2", 213, R8A779G0_CLK_S0D4_HSC), 168bd176e46SGeert Uytterhoeven DEF_MOD("canfd0", 328, R8A779G0_CLK_SASYNCPERD2), 1698b406fd4SNiklas Söderlund DEF_MOD("csi40", 331, R8A779G0_CLK_CSI), 1708b406fd4SNiklas Söderlund DEF_MOD("csi41", 400, R8A779G0_CLK_CSI), 171ff1dd4a8STomi Valkeinen DEF_MOD("dis0", 411, R8A779G0_CLK_VIOBUSD2), 172ff1dd4a8STomi Valkeinen DEF_MOD("dsitxlink0", 415, R8A779G0_CLK_VIOBUSD2), 173ff1dd4a8STomi Valkeinen DEF_MOD("dsitxlink1", 416, R8A779G0_CLK_VIOBUSD2), 174ff1dd4a8STomi Valkeinen DEF_MOD("fcpvd0", 508, R8A779G0_CLK_VIOBUSD2), 175ff1dd4a8STomi Valkeinen DEF_MOD("fcpvd1", 509, R8A779G0_CLK_VIOBUSD2), 176a9003f74SGeert Uytterhoeven DEF_MOD("hscif0", 514, R8A779G0_CLK_SASYNCPERD1), 177a9003f74SGeert Uytterhoeven DEF_MOD("hscif1", 515, R8A779G0_CLK_SASYNCPERD1), 178a9003f74SGeert Uytterhoeven DEF_MOD("hscif2", 516, R8A779G0_CLK_SASYNCPERD1), 179a9003f74SGeert Uytterhoeven DEF_MOD("hscif3", 517, R8A779G0_CLK_SASYNCPERD1), 180e90eba2eSGeert Uytterhoeven DEF_MOD("i2c0", 518, R8A779G0_CLK_S0D6_PER), 181e90eba2eSGeert Uytterhoeven DEF_MOD("i2c1", 519, R8A779G0_CLK_S0D6_PER), 182e90eba2eSGeert Uytterhoeven DEF_MOD("i2c2", 520, R8A779G0_CLK_S0D6_PER), 183e90eba2eSGeert Uytterhoeven DEF_MOD("i2c3", 521, R8A779G0_CLK_S0D6_PER), 184e90eba2eSGeert Uytterhoeven DEF_MOD("i2c4", 522, R8A779G0_CLK_S0D6_PER), 185e90eba2eSGeert Uytterhoeven DEF_MOD("i2c5", 523, R8A779G0_CLK_S0D6_PER), 18686401056SGeert Uytterhoeven DEF_MOD("irqc", 611, R8A779G0_CLK_CL16M), 1878947e5aeSNiklas Söderlund DEF_MOD("ispcs0", 612, R8A779G0_CLK_S0D2_VIO), 1888947e5aeSNiklas Söderlund DEF_MOD("ispcs1", 613, R8A779G0_CLK_S0D2_VIO), 189e0b07ff0SGeert Uytterhoeven DEF_MOD("msi0", 618, R8A779G0_CLK_MSO), 190e0b07ff0SGeert Uytterhoeven DEF_MOD("msi1", 619, R8A779G0_CLK_MSO), 191e0b07ff0SGeert Uytterhoeven DEF_MOD("msi2", 620, R8A779G0_CLK_MSO), 192e0b07ff0SGeert Uytterhoeven DEF_MOD("msi3", 621, R8A779G0_CLK_MSO), 193e0b07ff0SGeert Uytterhoeven DEF_MOD("msi4", 622, R8A779G0_CLK_MSO), 194e0b07ff0SGeert Uytterhoeven DEF_MOD("msi5", 623, R8A779G0_CLK_MSO), 195*5ab16198SYoshihiro Shimoda DEF_MOD("pciec0", 624, R8A779G0_CLK_S0D2_HSC), 196*5ab16198SYoshihiro Shimoda DEF_MOD("pscie1", 625, R8A779G0_CLK_S0D2_HSC), 197b00bf771SGeert Uytterhoeven DEF_MOD("pwm", 628, R8A779G0_CLK_SASYNCPERD4), 198ed823991SGeert Uytterhoeven DEF_MOD("rpc-if", 629, R8A779G0_CLK_RPCD2), 199ceb22d93SGeert Uytterhoeven DEF_MOD("scif0", 702, R8A779G0_CLK_SASYNCPERD4), 200ceb22d93SGeert Uytterhoeven DEF_MOD("scif1", 703, R8A779G0_CLK_SASYNCPERD4), 201ceb22d93SGeert Uytterhoeven DEF_MOD("scif3", 704, R8A779G0_CLK_SASYNCPERD4), 202ceb22d93SGeert Uytterhoeven DEF_MOD("scif4", 705, R8A779G0_CLK_SASYNCPERD4), 2034ee04993SGeert Uytterhoeven DEF_MOD("sdhi", 706, R8A779G0_CLK_SD0), 2043797edf9SKuninori Morimoto DEF_MOD("sys-dmac0", 709, R8A779G0_CLK_S0D6_PER), 2053797edf9SKuninori Morimoto DEF_MOD("sys-dmac1", 710, R8A779G0_CLK_S0D6_PER), 206106f51e9SWolfram Sang DEF_MOD("tmu0", 713, R8A779G0_CLK_SASYNCRT), 207106f51e9SWolfram Sang DEF_MOD("tmu1", 714, R8A779G0_CLK_SASYNCPERD2), 208106f51e9SWolfram Sang DEF_MOD("tmu2", 715, R8A779G0_CLK_SASYNCPERD2), 209106f51e9SWolfram Sang DEF_MOD("tmu3", 716, R8A779G0_CLK_SASYNCPERD2), 210106f51e9SWolfram Sang DEF_MOD("tmu4", 717, R8A779G0_CLK_SASYNCPERD2), 21139658ceeSGeert Uytterhoeven DEF_MOD("tpu0", 718, R8A779G0_CLK_SASYNCPERD4), 212049f39d6SNiklas Söderlund DEF_MOD("vin00", 730, R8A779G0_CLK_S0D4_VIO), 213049f39d6SNiklas Söderlund DEF_MOD("vin01", 731, R8A779G0_CLK_S0D4_VIO), 214049f39d6SNiklas Söderlund DEF_MOD("vin02", 800, R8A779G0_CLK_S0D4_VIO), 215049f39d6SNiklas Söderlund DEF_MOD("vin03", 801, R8A779G0_CLK_S0D4_VIO), 216049f39d6SNiklas Söderlund DEF_MOD("vin04", 802, R8A779G0_CLK_S0D4_VIO), 217049f39d6SNiklas Söderlund DEF_MOD("vin05", 803, R8A779G0_CLK_S0D4_VIO), 218049f39d6SNiklas Söderlund DEF_MOD("vin06", 804, R8A779G0_CLK_S0D4_VIO), 219049f39d6SNiklas Söderlund DEF_MOD("vin07", 805, R8A779G0_CLK_S0D4_VIO), 220049f39d6SNiklas Söderlund DEF_MOD("vin10", 806, R8A779G0_CLK_S0D4_VIO), 221049f39d6SNiklas Söderlund DEF_MOD("vin11", 807, R8A779G0_CLK_S0D4_VIO), 222049f39d6SNiklas Söderlund DEF_MOD("vin12", 808, R8A779G0_CLK_S0D4_VIO), 223049f39d6SNiklas Söderlund DEF_MOD("vin13", 809, R8A779G0_CLK_S0D4_VIO), 224049f39d6SNiklas Söderlund DEF_MOD("vin14", 810, R8A779G0_CLK_S0D4_VIO), 225049f39d6SNiklas Söderlund DEF_MOD("vin15", 811, R8A779G0_CLK_S0D4_VIO), 226049f39d6SNiklas Söderlund DEF_MOD("vin16", 812, R8A779G0_CLK_S0D4_VIO), 227049f39d6SNiklas Söderlund DEF_MOD("vin17", 813, R8A779G0_CLK_S0D4_VIO), 228ff1dd4a8STomi Valkeinen DEF_MOD("vspd0", 830, R8A779G0_CLK_VIOBUSD2), 229ff1dd4a8STomi Valkeinen DEF_MOD("vspd1", 831, R8A779G0_CLK_VIOBUSD2), 230a4f8a6e6SGeert Uytterhoeven DEF_MOD("wdt1:wdt0", 907, R8A779G0_CLK_R), 231523ed944SWolfram Sang DEF_MOD("cmt0", 910, R8A779G0_CLK_R), 232523ed944SWolfram Sang DEF_MOD("cmt1", 911, R8A779G0_CLK_R), 233523ed944SWolfram Sang DEF_MOD("cmt2", 912, R8A779G0_CLK_R), 234523ed944SWolfram Sang DEF_MOD("cmt3", 913, R8A779G0_CLK_R), 23536ff3660SGeert Uytterhoeven DEF_MOD("pfc0", 915, R8A779G0_CLK_CL16M), 23636ff3660SGeert Uytterhoeven DEF_MOD("pfc1", 916, R8A779G0_CLK_CL16M), 23736ff3660SGeert Uytterhoeven DEF_MOD("pfc2", 917, R8A779G0_CLK_CL16M), 23836ff3660SGeert Uytterhoeven DEF_MOD("pfc3", 918, R8A779G0_CLK_CL16M), 2397502a04dSGeert Uytterhoeven DEF_MOD("tsc", 919, R8A779G0_CLK_CL16M), 240f154ef08SNiklas Söderlund DEF_MOD("tsn", 2723, R8A779G0_CLK_S0D4_HSC), 2418dffb520SKuninori Morimoto DEF_MOD("ssiu", 2926, R8A779G0_CLK_S0D6_PER), 2428dffb520SKuninori Morimoto DEF_MOD("ssi", 2927, R8A779G0_CLK_S0D6_PER), 2430ab55cf1SYoshihiro Shimoda }; 2440ab55cf1SYoshihiro Shimoda 2450ab55cf1SYoshihiro Shimoda /* 2460ab55cf1SYoshihiro Shimoda * CPG Clock Data 2470ab55cf1SYoshihiro Shimoda */ 2480ab55cf1SYoshihiro Shimoda /* 2490ab55cf1SYoshihiro Shimoda * MD EXTAL PLL1 PLL2 PLL3 PLL4 PLL5 PLL6 OSC 2500ab55cf1SYoshihiro Shimoda * 14 13 (MHz) 2510ab55cf1SYoshihiro Shimoda * ------------------------------------------------------------------------ 252cf919770SGeert Uytterhoeven * 0 0 16.66 / 1 x192 x204 x192 x144 x192 x168 /16 2530ab55cf1SYoshihiro Shimoda * 0 1 20 / 1 x160 x170 x160 x120 x160 x140 /19 2540ab55cf1SYoshihiro Shimoda * 1 0 Prohibited setting 255cf919770SGeert Uytterhoeven * 1 1 33.33 / 2 x192 x204 x192 x144 x192 x168 /32 2560ab55cf1SYoshihiro Shimoda */ 2570ab55cf1SYoshihiro Shimoda #define CPG_PLL_CONFIG_INDEX(md) ((((md) & BIT(14)) >> 13) | \ 2580ab55cf1SYoshihiro Shimoda (((md) & BIT(13)) >> 13)) 2590ab55cf1SYoshihiro Shimoda 2600ab55cf1SYoshihiro Shimoda static const struct rcar_gen4_cpg_pll_config cpg_pll_configs[4] = { 2610ab55cf1SYoshihiro Shimoda /* EXTAL div PLL1 mult/div PLL2 mult/div PLL3 mult/div PLL4 mult/div PLL5 mult/div PLL6 mult/div OSC prediv */ 262cf919770SGeert Uytterhoeven { 1, 192, 1, 204, 1, 192, 1, 144, 1, 192, 1, 168, 1, 16, }, 2630ab55cf1SYoshihiro Shimoda { 1, 160, 1, 170, 1, 160, 1, 120, 1, 160, 1, 140, 1, 19, }, 2640ab55cf1SYoshihiro Shimoda { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 265cf919770SGeert Uytterhoeven { 2, 192, 1, 204, 1, 192, 1, 144, 1, 192, 1, 168, 1, 32, }, 2660ab55cf1SYoshihiro Shimoda }; 2670ab55cf1SYoshihiro Shimoda 2680ab55cf1SYoshihiro Shimoda static int __init r8a779g0_cpg_mssr_init(struct device *dev) 2690ab55cf1SYoshihiro Shimoda { 2700ab55cf1SYoshihiro Shimoda const struct rcar_gen4_cpg_pll_config *cpg_pll_config; 2710ab55cf1SYoshihiro Shimoda u32 cpg_mode; 2720ab55cf1SYoshihiro Shimoda int error; 2730ab55cf1SYoshihiro Shimoda 2740ab55cf1SYoshihiro Shimoda error = rcar_rst_read_mode_pins(&cpg_mode); 2750ab55cf1SYoshihiro Shimoda if (error) 2760ab55cf1SYoshihiro Shimoda return error; 2770ab55cf1SYoshihiro Shimoda 2780ab55cf1SYoshihiro Shimoda cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)]; 2790ab55cf1SYoshihiro Shimoda if (!cpg_pll_config->extal_div) { 2800ab55cf1SYoshihiro Shimoda dev_err(dev, "Prohibited setting (cpg_mode=0x%x)\n", cpg_mode); 2810ab55cf1SYoshihiro Shimoda return -EINVAL; 2820ab55cf1SYoshihiro Shimoda } 2830ab55cf1SYoshihiro Shimoda 2840ab55cf1SYoshihiro Shimoda return rcar_gen4_cpg_init(cpg_pll_config, CLK_EXTALR, cpg_mode); 2850ab55cf1SYoshihiro Shimoda } 2860ab55cf1SYoshihiro Shimoda 2870ab55cf1SYoshihiro Shimoda const struct cpg_mssr_info r8a779g0_cpg_mssr_info __initconst = { 2880ab55cf1SYoshihiro Shimoda /* Core Clocks */ 2890ab55cf1SYoshihiro Shimoda .core_clks = r8a779g0_core_clks, 2900ab55cf1SYoshihiro Shimoda .num_core_clks = ARRAY_SIZE(r8a779g0_core_clks), 2910ab55cf1SYoshihiro Shimoda .last_dt_core_clk = LAST_DT_CORE_CLK, 2920ab55cf1SYoshihiro Shimoda .num_total_core_clks = MOD_CLK_BASE, 2930ab55cf1SYoshihiro Shimoda 2940ab55cf1SYoshihiro Shimoda /* Module Clocks */ 2950ab55cf1SYoshihiro Shimoda .mod_clks = r8a779g0_mod_clks, 2960ab55cf1SYoshihiro Shimoda .num_mod_clks = ARRAY_SIZE(r8a779g0_mod_clks), 2970ab55cf1SYoshihiro Shimoda .num_hw_mod_clks = 30 * 32, 2980ab55cf1SYoshihiro Shimoda 2990ab55cf1SYoshihiro Shimoda /* Callbacks */ 3000ab55cf1SYoshihiro Shimoda .init = r8a779g0_cpg_mssr_init, 3010ab55cf1SYoshihiro Shimoda .cpg_clk_register = rcar_gen4_cpg_clk_register, 3020ab55cf1SYoshihiro Shimoda 3030ab55cf1SYoshihiro Shimoda .reg_layout = CLK_REG_LAYOUT_RCAR_GEN4, 3040ab55cf1SYoshihiro Shimoda }; 305