1 // SPDX-License-Identifier: GPL-2.0
3 * RZ/V2M Clock Pulse Generator / Module Standby and Software Reset
5 * Copyright (C) 2022 Renesas Electronics Corp.
7 * Based on r9a07g044-cpg.c
10 #include <linux/clk-provider.h>
11 #include <linux/device.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
15 #include <dt-bindings/clock/r9a09g011-cpg.h>
17 #include "rzg2l-cpg.h"
19 #define RZV2M_SAMPLL4_CLK1 0x104
20 #define RZV2M_SAMPLL4_CLK2 0x108
22 #define PLL4_CONF (RZV2M_SAMPLL4_CLK1 << 22 | RZV2M_SAMPLL4_CLK2 << 12)
24 #define DIV_A DDIV_PACK(0x200, 0, 3)
25 #define DIV_B DDIV_PACK(0x204, 0, 2)
26 #define DIV_E DDIV_PACK(0x204, 8, 1)
27 #define DIV_W DDIV_PACK(0x328, 0, 3)
29 #define SEL_B SEL_PLL_PACK(0x214, 0, 1)
30 #define SEL_E SEL_PLL_PACK(0x214, 2, 1)
31 #define SEL_W0 SEL_PLL_PACK(0x32C, 0, 1)
34 /* Core Clock Outputs exported to DT */
37 /* External Input Clocks */
40 /* Internal Core Clocks */
65 static const struct clk_div_table dtable_diva[] = {
76 static const struct clk_div_table dtable_divb[] = {
84 static const struct clk_div_table dtable_divw[] = {
95 /* Mux clock tables */
96 static const char * const sel_b[] = { ".main", ".divb" };
97 static const char * const sel_e[] = { ".main", ".dive" };
98 static const char * const sel_w[] = { ".main", ".divw" };
100 static const struct cpg_core_clk r9a09g011_core_clks[] __initconst = {
101 /* External Clock Inputs */
102 DEF_INPUT("extal", CLK_EXTAL),
104 /* Internal Core Clocks */
105 DEF_FIXED(".main", CLK_MAIN, CLK_EXTAL, 1, 1),
106 DEF_FIXED(".main_24", CLK_MAIN_24, CLK_MAIN, 1, 2),
107 DEF_FIXED(".main_2", CLK_MAIN_2, CLK_MAIN, 1, 24),
108 DEF_FIXED(".pll1", CLK_PLL1, CLK_MAIN_2, 498, 1),
109 DEF_FIXED(".pll2", CLK_PLL2, CLK_MAIN_2, 800, 1),
110 DEF_FIXED(".pll2_800", CLK_PLL2_800, CLK_PLL2, 1, 2),
111 DEF_FIXED(".pll2_400", CLK_PLL2_400, CLK_PLL2_800, 1, 2),
112 DEF_FIXED(".pll2_200", CLK_PLL2_200, CLK_PLL2_800, 1, 4),
113 DEF_FIXED(".pll2_100", CLK_PLL2_100, CLK_PLL2_800, 1, 8),
114 DEF_SAMPLL(".pll4", CLK_PLL4, CLK_MAIN_2, PLL4_CONF),
116 DEF_DIV_RO(".diva", CLK_DIV_A, CLK_PLL1, DIV_A, dtable_diva),
117 DEF_DIV_RO(".divb", CLK_DIV_B, CLK_PLL2_400, DIV_B, dtable_divb),
118 DEF_DIV_RO(".dive", CLK_DIV_E, CLK_PLL2_100, DIV_E, NULL),
119 DEF_DIV_RO(".divw", CLK_DIV_W, CLK_PLL4, DIV_W, dtable_divw),
121 DEF_MUX_RO(".selb", CLK_SEL_B, SEL_B, sel_b),
122 DEF_MUX_RO(".sele", CLK_SEL_E, SEL_E, sel_e),
123 DEF_MUX(".selw0", CLK_SEL_W0, SEL_W0, sel_w),
125 DEF_FIXED(".selb_d2", CLK_SEL_B_D2, CLK_SEL_B, 1, 2),
128 static const struct rzg2l_mod_clk r9a09g011_mod_clks[] __initconst = {
129 DEF_MOD("pfc", R9A09G011_PFC_PCLK, CLK_MAIN, 0x400, 2),
130 DEF_MOD("gic", R9A09G011_GIC_CLK, CLK_SEL_B_D2, 0x400, 5),
131 DEF_COUPLED("eth_axi", R9A09G011_ETH0_CLK_AXI, CLK_PLL2_200, 0x40c, 8),
132 DEF_COUPLED("eth_chi", R9A09G011_ETH0_CLK_CHI, CLK_PLL2_100, 0x40c, 8),
133 DEF_MOD("eth_clk_gptp", R9A09G011_ETH0_GPTP_EXT, CLK_PLL2_100, 0x40c, 9),
134 DEF_MOD("syc_cnt_clk", R9A09G011_SYC_CNT_CLK, CLK_MAIN_24, 0x41c, 12),
135 DEF_MOD("wdt0_pclk", R9A09G011_WDT0_PCLK, CLK_SEL_E, 0x428, 12),
136 DEF_MOD("wdt0_clk", R9A09G011_WDT0_CLK, CLK_MAIN, 0x428, 13),
137 DEF_MOD("urt_pclk", R9A09G011_URT_PCLK, CLK_SEL_E, 0x438, 4),
138 DEF_MOD("urt0_clk", R9A09G011_URT0_CLK, CLK_SEL_W0, 0x438, 5),
139 DEF_MOD("ca53", R9A09G011_CA53_CLK, CLK_DIV_A, 0x448, 0),
142 static const struct rzg2l_reset r9a09g011_resets[] = {
143 DEF_RST(R9A09G011_PFC_PRESETN, 0x600, 2),
144 DEF_RST_MON(R9A09G011_ETH0_RST_HW_N, 0x608, 11, 11),
145 DEF_RST_MON(R9A09G011_SYC_RST_N, 0x610, 9, 13),
146 DEF_RST_MON(R9A09G011_WDT0_PRESETN, 0x614, 12, 19),
149 static const unsigned int r9a09g011_crit_mod_clks[] __initconst = {
150 MOD_CLK_BASE + R9A09G011_CA53_CLK,
151 MOD_CLK_BASE + R9A09G011_GIC_CLK,
152 MOD_CLK_BASE + R9A09G011_SYC_CNT_CLK,
153 MOD_CLK_BASE + R9A09G011_URT_PCLK,
156 const struct rzg2l_cpg_info r9a09g011_cpg_info = {
158 .core_clks = r9a09g011_core_clks,
159 .num_core_clks = ARRAY_SIZE(r9a09g011_core_clks),
160 .last_dt_core_clk = LAST_DT_CORE_CLK,
161 .num_total_core_clks = MOD_CLK_BASE,
163 /* Critical Module Clocks */
164 .crit_mod_clks = r9a09g011_crit_mod_clks,
165 .num_crit_mod_clks = ARRAY_SIZE(r9a09g011_crit_mod_clks),
168 .mod_clks = r9a09g011_mod_clks,
169 .num_mod_clks = ARRAY_SIZE(r9a09g011_mod_clks),
170 .num_hw_mod_clks = R9A09G011_CA53_CLK + 1,
173 .resets = r9a09g011_resets,
174 .num_resets = ARRAY_SIZE(r9a09g011_resets),
176 .has_clk_mon_regs = false,