blob: 6cb474c593e7b111fa9da58e93bce5412b586422 [file] [log] [blame]
Heiko Stuebner3536c972015-07-05 11:00:20 +02001/*
2 * Copyright (c) 2015 Heiko Stuebner <heiko@sntech.de>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <linux/clk-provider.h>
16#include <linux/of.h>
17#include <linux/of_address.h>
18#include <linux/platform_device.h>
19#include <dt-bindings/clock/rk3368-cru.h>
20#include "clk.h"
21
22#define RK3368_GRF_SOC_STATUS0 0x480
23
24enum rk3368_plls {
25 apllb, aplll, dpll, cpll, gpll, npll,
26};
27
28static struct rockchip_pll_rate_table rk3368_pll_rates[] = {
29 RK3066_PLL_RATE(2208000000, 1, 92, 1),
30 RK3066_PLL_RATE(2184000000, 1, 91, 1),
31 RK3066_PLL_RATE(2160000000, 1, 90, 1),
32 RK3066_PLL_RATE(2136000000, 1, 89, 1),
33 RK3066_PLL_RATE(2112000000, 1, 88, 1),
34 RK3066_PLL_RATE(2088000000, 1, 87, 1),
35 RK3066_PLL_RATE(2064000000, 1, 86, 1),
36 RK3066_PLL_RATE(2040000000, 1, 85, 1),
37 RK3066_PLL_RATE(2016000000, 1, 84, 1),
38 RK3066_PLL_RATE(1992000000, 1, 83, 1),
39 RK3066_PLL_RATE(1968000000, 1, 82, 1),
40 RK3066_PLL_RATE(1944000000, 1, 81, 1),
41 RK3066_PLL_RATE(1920000000, 1, 80, 1),
42 RK3066_PLL_RATE(1896000000, 1, 79, 1),
43 RK3066_PLL_RATE(1872000000, 1, 78, 1),
44 RK3066_PLL_RATE(1848000000, 1, 77, 1),
45 RK3066_PLL_RATE(1824000000, 1, 76, 1),
46 RK3066_PLL_RATE(1800000000, 1, 75, 1),
47 RK3066_PLL_RATE(1776000000, 1, 74, 1),
48 RK3066_PLL_RATE(1752000000, 1, 73, 1),
49 RK3066_PLL_RATE(1728000000, 1, 72, 1),
50 RK3066_PLL_RATE(1704000000, 1, 71, 1),
51 RK3066_PLL_RATE(1680000000, 1, 70, 1),
52 RK3066_PLL_RATE(1656000000, 1, 69, 1),
53 RK3066_PLL_RATE(1632000000, 1, 68, 1),
54 RK3066_PLL_RATE(1608000000, 1, 67, 1),
55 RK3066_PLL_RATE(1560000000, 1, 65, 1),
56 RK3066_PLL_RATE(1512000000, 1, 63, 1),
57 RK3066_PLL_RATE(1488000000, 1, 62, 1),
58 RK3066_PLL_RATE(1464000000, 1, 61, 1),
59 RK3066_PLL_RATE(1440000000, 1, 60, 1),
60 RK3066_PLL_RATE(1416000000, 1, 59, 1),
61 RK3066_PLL_RATE(1392000000, 1, 58, 1),
62 RK3066_PLL_RATE(1368000000, 1, 57, 1),
63 RK3066_PLL_RATE(1344000000, 1, 56, 1),
64 RK3066_PLL_RATE(1320000000, 1, 55, 1),
65 RK3066_PLL_RATE(1296000000, 1, 54, 1),
66 RK3066_PLL_RATE(1272000000, 1, 53, 1),
67 RK3066_PLL_RATE(1248000000, 1, 52, 1),
68 RK3066_PLL_RATE(1224000000, 1, 51, 1),
69 RK3066_PLL_RATE(1200000000, 1, 50, 1),
70 RK3066_PLL_RATE(1176000000, 1, 49, 1),
71 RK3066_PLL_RATE(1128000000, 1, 47, 1),
72 RK3066_PLL_RATE(1104000000, 1, 46, 1),
73 RK3066_PLL_RATE(1008000000, 1, 84, 2),
74 RK3066_PLL_RATE( 912000000, 1, 76, 2),
75 RK3066_PLL_RATE( 888000000, 1, 74, 2),
76 RK3066_PLL_RATE( 816000000, 1, 68, 2),
77 RK3066_PLL_RATE( 792000000, 1, 66, 2),
78 RK3066_PLL_RATE( 696000000, 1, 58, 2),
79 RK3066_PLL_RATE( 672000000, 1, 56, 2),
80 RK3066_PLL_RATE( 648000000, 1, 54, 2),
81 RK3066_PLL_RATE( 624000000, 1, 52, 2),
82 RK3066_PLL_RATE( 600000000, 1, 50, 2),
83 RK3066_PLL_RATE( 576000000, 1, 48, 2),
84 RK3066_PLL_RATE( 552000000, 1, 46, 2),
85 RK3066_PLL_RATE( 528000000, 1, 88, 4),
86 RK3066_PLL_RATE( 504000000, 1, 84, 4),
87 RK3066_PLL_RATE( 480000000, 1, 80, 4),
88 RK3066_PLL_RATE( 456000000, 1, 76, 4),
89 RK3066_PLL_RATE( 408000000, 1, 68, 4),
90 RK3066_PLL_RATE( 312000000, 1, 52, 4),
91 RK3066_PLL_RATE( 252000000, 1, 84, 8),
92 RK3066_PLL_RATE( 216000000, 1, 72, 8),
93 RK3066_PLL_RATE( 126000000, 2, 84, 8),
94 RK3066_PLL_RATE( 48000000, 2, 32, 8),
95 { /* sentinel */ },
96};
97
98PNAME(mux_pll_p) = { "xin24m", "xin32k" };
99PNAME(mux_armclkb_p) = { "apllb_core", "gpllb_core" };
100PNAME(mux_armclkl_p) = { "aplll_core", "gplll_core" };
101PNAME(mux_ddrphy_p) = { "dpll_ddr", "gpll_ddr" };
102PNAME(mux_cs_src_p) = { "apllb_cs", "aplll_cs", "gpll_cs"};
103PNAME(mux_aclk_bus_src_p) = { "cpll_aclk_bus", "gpll_aclk_bus" };
104
105PNAME(mux_pll_src_cpll_gpll_p) = { "cpll", "gpll" };
106PNAME(mux_pll_src_cpll_gpll_npll_p) = { "cpll", "gpll", "npll" };
107PNAME(mux_pll_src_npll_cpll_gpll_p) = { "npll", "cpll", "gpll" };
108PNAME(mux_pll_src_cpll_gpll_usb_p) = { "cpll", "gpll", "usbphy_480m" };
109PNAME(mux_pll_src_cpll_gpll_usb_usb_p) = { "cpll", "gpll", "usbphy_480m",
110 "usbphy_480m" };
111PNAME(mux_pll_src_cpll_gpll_usb_npll_p) = { "cpll", "gpll", "usbphy_480m",
112 "npll" };
113PNAME(mux_pll_src_cpll_gpll_npll_npll_p) = { "cpll", "gpll", "npll", "npll" };
114PNAME(mux_pll_src_cpll_gpll_npll_usb_p) = { "cpll", "gpll", "npll",
115 "usbphy_480m" };
116
117PNAME(mux_i2s_8ch_pre_p) = { "i2s_8ch_src", "i2s_8ch_frac",
118 "ext_i2s", "xin12m" };
119PNAME(mux_i2s_8ch_clkout_p) = { "i2s_8ch_pre", "xin12m" };
120PNAME(mux_i2s_2ch_p) = { "i2s_2ch_src", "i2s_2ch_frac",
121 "dummy", "xin12m" };
122PNAME(mux_spdif_8ch_p) = { "spdif_8ch_pre", "spdif_8ch_frac",
123 "ext_i2s", "xin12m" };
zhangqingd566ebc2016-01-25 08:56:00 -0800124PNAME(mux_edp_24m_p) = { "xin24m", "dummy" };
Heiko Stuebner3536c972015-07-05 11:00:20 +0200125PNAME(mux_vip_out_p) = { "vip_src", "xin24m" };
126PNAME(mux_usbphy480m_p) = { "usbotg_out", "xin24m" };
127PNAME(mux_hsic_usbphy480m_p) = { "usbotg_out", "dummy" };
128PNAME(mux_hsicphy480m_p) = { "cpll", "gpll", "usbphy_480m" };
129PNAME(mux_uart0_p) = { "uart0_src", "uart0_frac", "xin24m" };
130PNAME(mux_uart1_p) = { "uart1_src", "uart1_frac", "xin24m" };
131PNAME(mux_uart2_p) = { "uart2_src", "xin24m" };
132PNAME(mux_uart3_p) = { "uart3_src", "uart3_frac", "xin24m" };
133PNAME(mux_uart4_p) = { "uart4_src", "uart4_frac", "xin24m" };
134PNAME(mux_mac_p) = { "mac_pll_src", "ext_gmac" };
135PNAME(mux_mmc_src_p) = { "cpll", "gpll", "usbphy_480m", "xin24m" };
136
137static struct rockchip_pll_clock rk3368_pll_clks[] __initdata = {
138 [apllb] = PLL(pll_rk3066, PLL_APLLB, "apllb", mux_pll_p, 0, RK3368_PLL_CON(0),
139 RK3368_PLL_CON(3), 8, 1, 0, rk3368_pll_rates),
140 [aplll] = PLL(pll_rk3066, PLL_APLLL, "aplll", mux_pll_p, 0, RK3368_PLL_CON(4),
141 RK3368_PLL_CON(7), 8, 0, 0, rk3368_pll_rates),
142 [dpll] = PLL(pll_rk3066, PLL_DPLL, "dpll", mux_pll_p, 0, RK3368_PLL_CON(8),
143 RK3368_PLL_CON(11), 8, 2, 0, NULL),
144 [cpll] = PLL(pll_rk3066, PLL_CPLL, "cpll", mux_pll_p, 0, RK3368_PLL_CON(12),
145 RK3368_PLL_CON(15), 8, 3, ROCKCHIP_PLL_SYNC_RATE, rk3368_pll_rates),
146 [gpll] = PLL(pll_rk3066, PLL_GPLL, "gpll", mux_pll_p, 0, RK3368_PLL_CON(16),
147 RK3368_PLL_CON(19), 8, 4, ROCKCHIP_PLL_SYNC_RATE, rk3368_pll_rates),
148 [npll] = PLL(pll_rk3066, PLL_NPLL, "npll", mux_pll_p, 0, RK3368_PLL_CON(20),
149 RK3368_PLL_CON(23), 8, 5, ROCKCHIP_PLL_SYNC_RATE, rk3368_pll_rates),
150};
151
152static struct clk_div_table div_ddrphy_t[] = {
153 { .val = 0, .div = 1 },
154 { .val = 1, .div = 2 },
155 { .val = 3, .div = 4 },
156 { /* sentinel */ },
157};
158
159#define MFLAGS CLK_MUX_HIWORD_MASK
160#define DFLAGS CLK_DIVIDER_HIWORD_MASK
161#define GFLAGS (CLK_GATE_HIWORD_MASK | CLK_GATE_SET_TO_DISABLE)
162#define IFLAGS ROCKCHIP_INVERTER_HIWORD_MASK
163
164static const struct rockchip_cpuclk_reg_data rk3368_cpuclkb_data = {
165 .core_reg = RK3368_CLKSEL_CON(0),
166 .div_core_shift = 0,
167 .div_core_mask = 0x1f,
Xing Zheng268aeba2016-03-09 10:37:03 +0800168 .mux_core_alt = 1,
169 .mux_core_main = 0,
Heiko Stuebner535ebd42016-01-19 10:01:08 +0100170 .mux_core_shift = 7,
Xing Zheng268aeba2016-03-09 10:37:03 +0800171 .mux_core_mask = 0x1,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200172};
173
174static const struct rockchip_cpuclk_reg_data rk3368_cpuclkl_data = {
175 .core_reg = RK3368_CLKSEL_CON(2),
176 .div_core_shift = 0,
Xing Zheng268aeba2016-03-09 10:37:03 +0800177 .mux_core_alt = 1,
178 .mux_core_main = 0,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200179 .div_core_mask = 0x1f,
180 .mux_core_shift = 7,
Xing Zheng268aeba2016-03-09 10:37:03 +0800181 .mux_core_mask = 0x1,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200182};
183
184#define RK3368_DIV_ACLKM_MASK 0x1f
185#define RK3368_DIV_ACLKM_SHIFT 8
186#define RK3368_DIV_ATCLK_MASK 0x1f
187#define RK3368_DIV_ATCLK_SHIFT 0
188#define RK3368_DIV_PCLK_DBG_MASK 0x1f
189#define RK3368_DIV_PCLK_DBG_SHIFT 8
190
191#define RK3368_CLKSEL0(_offs, _aclkm) \
192 { \
Heiko Stuebner8ad0df32015-12-01 22:23:45 +0100193 .reg = RK3368_CLKSEL_CON(0 + _offs), \
Heiko Stuebner3536c972015-07-05 11:00:20 +0200194 .val = HIWORD_UPDATE(_aclkm, RK3368_DIV_ACLKM_MASK, \
195 RK3368_DIV_ACLKM_SHIFT), \
196 }
197#define RK3368_CLKSEL1(_offs, _atclk, _pdbg) \
198 { \
Heiko Stuebner8ad0df32015-12-01 22:23:45 +0100199 .reg = RK3368_CLKSEL_CON(1 + _offs), \
Heiko Stuebner3536c972015-07-05 11:00:20 +0200200 .val = HIWORD_UPDATE(_atclk, RK3368_DIV_ATCLK_MASK, \
201 RK3368_DIV_ATCLK_SHIFT) | \
202 HIWORD_UPDATE(_pdbg, RK3368_DIV_PCLK_DBG_MASK, \
203 RK3368_DIV_PCLK_DBG_SHIFT), \
204 }
205
206/* cluster_b: aclkm in clksel0, rest in clksel1 */
207#define RK3368_CPUCLKB_RATE(_prate, _aclkm, _atclk, _pdbg) \
208 { \
209 .prate = _prate, \
210 .divs = { \
211 RK3368_CLKSEL0(0, _aclkm), \
212 RK3368_CLKSEL1(0, _atclk, _pdbg), \
213 }, \
214 }
215
216/* cluster_l: aclkm in clksel2, rest in clksel3 */
217#define RK3368_CPUCLKL_RATE(_prate, _aclkm, _atclk, _pdbg) \
218 { \
219 .prate = _prate, \
220 .divs = { \
221 RK3368_CLKSEL0(2, _aclkm), \
222 RK3368_CLKSEL1(2, _atclk, _pdbg), \
223 }, \
224 }
225
226static struct rockchip_cpuclk_rate_table rk3368_cpuclkb_rates[] __initdata = {
Heiko Stuebnerc6d5fe22016-01-19 10:09:22 +0100227 RK3368_CPUCLKB_RATE(1512000000, 1, 5, 5),
228 RK3368_CPUCLKB_RATE(1488000000, 1, 4, 4),
229 RK3368_CPUCLKB_RATE(1416000000, 1, 4, 4),
230 RK3368_CPUCLKB_RATE(1200000000, 1, 3, 3),
231 RK3368_CPUCLKB_RATE(1008000000, 1, 3, 3),
232 RK3368_CPUCLKB_RATE( 816000000, 1, 2, 2),
233 RK3368_CPUCLKB_RATE( 696000000, 1, 2, 2),
234 RK3368_CPUCLKB_RATE( 600000000, 1, 1, 1),
235 RK3368_CPUCLKB_RATE( 408000000, 1, 1, 1),
236 RK3368_CPUCLKB_RATE( 312000000, 1, 1, 1),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200237};
238
239static struct rockchip_cpuclk_rate_table rk3368_cpuclkl_rates[] __initdata = {
Heiko Stuebnerc6d5fe22016-01-19 10:09:22 +0100240 RK3368_CPUCLKL_RATE(1512000000, 1, 6, 6),
241 RK3368_CPUCLKL_RATE(1488000000, 1, 5, 5),
242 RK3368_CPUCLKL_RATE(1416000000, 1, 5, 5),
243 RK3368_CPUCLKL_RATE(1200000000, 1, 4, 4),
244 RK3368_CPUCLKL_RATE(1008000000, 1, 4, 4),
245 RK3368_CPUCLKL_RATE( 816000000, 1, 3, 3),
246 RK3368_CPUCLKL_RATE( 696000000, 1, 2, 2),
247 RK3368_CPUCLKL_RATE( 600000000, 1, 2, 2),
248 RK3368_CPUCLKL_RATE( 408000000, 1, 1, 1),
249 RK3368_CPUCLKL_RATE( 312000000, 1, 1, 1),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200250};
251
Elaine Zhang7af8a262016-02-24 08:44:11 +0800252static struct rockchip_clk_branch rk3368_i2s_8ch_fracmux __initdata =
253 MUX(0, "i2s_8ch_pre", mux_i2s_8ch_pre_p, CLK_SET_RATE_PARENT,
254 RK3368_CLKSEL_CON(27), 8, 2, MFLAGS);
255
256static struct rockchip_clk_branch rk3368_spdif_8ch_fracmux __initdata =
257 MUX(0, "spdif_8ch_pre", mux_spdif_8ch_p, CLK_SET_RATE_PARENT,
258 RK3368_CLKSEL_CON(31), 8, 2, MFLAGS);
259
260static struct rockchip_clk_branch rk3368_i2s_2ch_fracmux __initdata =
261 MUX(0, "i2s_2ch_pre", mux_i2s_2ch_p, CLK_SET_RATE_PARENT,
262 RK3368_CLKSEL_CON(53), 8, 2, MFLAGS);
263
264static struct rockchip_clk_branch rk3368_uart0_fracmux __initdata =
265 MUX(SCLK_UART0, "sclk_uart0", mux_uart0_p, CLK_SET_RATE_PARENT,
266 RK3368_CLKSEL_CON(33), 8, 2, MFLAGS);
267
268static struct rockchip_clk_branch rk3368_uart1_fracmux __initdata =
269 MUX(SCLK_UART1, "sclk_uart1", mux_uart1_p, CLK_SET_RATE_PARENT,
270 RK3368_CLKSEL_CON(35), 8, 2, MFLAGS);
271
272static struct rockchip_clk_branch rk3368_uart3_fracmux __initdata =
273 MUX(SCLK_UART3, "sclk_uart3", mux_uart3_p, CLK_SET_RATE_PARENT,
274 RK3368_CLKSEL_CON(39), 8, 2, MFLAGS);
275
276static struct rockchip_clk_branch rk3368_uart4_fracmux __initdata =
277 MUX(SCLK_UART4, "sclk_uart4", mux_uart4_p, CLK_SET_RATE_PARENT,
278 RK3368_CLKSEL_CON(41), 8, 2, MFLAGS);
279
Heiko Stuebner3536c972015-07-05 11:00:20 +0200280static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
281 /*
282 * Clock-Architecture Diagram 2
283 */
284
Heiko Stuebner36714522015-06-20 16:06:02 +0200285 FACTOR(0, "xin12m", "xin24m", 0, 1, 2),
286
Heiko Stuebner3536c972015-07-05 11:00:20 +0200287 MUX(SCLK_USBPHY480M, "usbphy_480m", mux_usbphy480m_p, CLK_SET_RATE_PARENT,
288 RK3368_CLKSEL_CON(13), 8, 1, MFLAGS),
289
290 GATE(0, "apllb_core", "apllb", CLK_IGNORE_UNUSED,
291 RK3368_CLKGATE_CON(0), 0, GFLAGS),
292 GATE(0, "gpllb_core", "gpll", CLK_IGNORE_UNUSED,
293 RK3368_CLKGATE_CON(0), 1, GFLAGS),
294
295 GATE(0, "aplll_core", "aplll", CLK_IGNORE_UNUSED,
296 RK3368_CLKGATE_CON(0), 4, GFLAGS),
297 GATE(0, "gplll_core", "gpll", CLK_IGNORE_UNUSED,
298 RK3368_CLKGATE_CON(0), 5, GFLAGS),
299
300 DIV(0, "aclkm_core_b", "armclkb", 0,
301 RK3368_CLKSEL_CON(0), 8, 5, DFLAGS | CLK_DIVIDER_READ_ONLY),
302 DIV(0, "atclk_core_b", "armclkb", 0,
303 RK3368_CLKSEL_CON(1), 0, 5, DFLAGS | CLK_DIVIDER_READ_ONLY),
304 DIV(0, "pclk_dbg_b", "armclkb", 0,
305 RK3368_CLKSEL_CON(1), 8, 5, DFLAGS | CLK_DIVIDER_READ_ONLY),
306
307 DIV(0, "aclkm_core_l", "armclkl", 0,
308 RK3368_CLKSEL_CON(2), 8, 5, DFLAGS | CLK_DIVIDER_READ_ONLY),
309 DIV(0, "atclk_core_l", "armclkl", 0,
310 RK3368_CLKSEL_CON(3), 0, 5, DFLAGS | CLK_DIVIDER_READ_ONLY),
311 DIV(0, "pclk_dbg_l", "armclkl", 0,
312 RK3368_CLKSEL_CON(3), 8, 5, DFLAGS | CLK_DIVIDER_READ_ONLY),
313
314 GATE(0, "apllb_cs", "apllb", CLK_IGNORE_UNUSED,
315 RK3368_CLKGATE_CON(0), 9, GFLAGS),
316 GATE(0, "aplll_cs", "aplll", CLK_IGNORE_UNUSED,
317 RK3368_CLKGATE_CON(0), 10, GFLAGS),
318 GATE(0, "gpll_cs", "gpll", CLK_IGNORE_UNUSED,
319 RK3368_CLKGATE_CON(0), 8, GFLAGS),
320 COMPOSITE_NOGATE(0, "sclk_cs_pre", mux_cs_src_p, CLK_IGNORE_UNUSED,
321 RK3368_CLKSEL_CON(4), 6, 2, MFLAGS, 0, 5, DFLAGS),
322 COMPOSITE_NOMUX(0, "clkin_trace", "sclk_cs_pre", CLK_IGNORE_UNUSED,
323 RK3368_CLKSEL_CON(4), 8, 5, DFLAGS,
324 RK3368_CLKGATE_CON(0), 13, GFLAGS),
325
326 COMPOSITE(0, "aclk_cci_pre", mux_pll_src_cpll_gpll_usb_npll_p, CLK_IGNORE_UNUSED,
327 RK3368_CLKSEL_CON(5), 6, 2, MFLAGS, 0, 7, DFLAGS,
328 RK3368_CLKGATE_CON(0), 12, GFLAGS),
329 GATE(SCLK_PVTM_CORE, "sclk_pvtm_core", "xin24m", 0, RK3368_CLKGATE_CON(7), 10, GFLAGS),
330
331 GATE(0, "dpll_ddr", "dpll", CLK_IGNORE_UNUSED,
332 RK3368_CLKGATE_CON(1), 8, GFLAGS),
333 GATE(0, "gpll_ddr", "gpll", 0,
334 RK3368_CLKGATE_CON(1), 9, GFLAGS),
335 COMPOSITE_NOGATE_DIVTBL(0, "ddrphy_src", mux_ddrphy_p, CLK_IGNORE_UNUSED,
336 RK3368_CLKSEL_CON(13), 4, 1, MFLAGS, 0, 2, DFLAGS, div_ddrphy_t),
337
Heiko Stuebner36714522015-06-20 16:06:02 +0200338 FACTOR_GATE(0, "sclk_ddr", "ddrphy_src", CLK_IGNORE_UNUSED, 1, 4,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200339 RK3368_CLKGATE_CON(6), 14, GFLAGS),
340 GATE(0, "sclk_ddr4x", "ddrphy_src", CLK_IGNORE_UNUSED,
341 RK3368_CLKGATE_CON(6), 15, GFLAGS),
342
343 GATE(0, "gpll_aclk_bus", "gpll", CLK_IGNORE_UNUSED,
344 RK3368_CLKGATE_CON(1), 10, GFLAGS),
345 GATE(0, "cpll_aclk_bus", "cpll", CLK_IGNORE_UNUSED,
346 RK3368_CLKGATE_CON(1), 11, GFLAGS),
347 COMPOSITE_NOGATE(0, "aclk_bus_src", mux_aclk_bus_src_p, CLK_IGNORE_UNUSED,
348 RK3368_CLKSEL_CON(8), 7, 1, MFLAGS, 0, 5, DFLAGS),
349
350 GATE(ACLK_BUS, "aclk_bus", "aclk_bus_src", CLK_IGNORE_UNUSED,
351 RK3368_CLKGATE_CON(1), 0, GFLAGS),
352 COMPOSITE_NOMUX(PCLK_BUS, "pclk_bus", "aclk_bus_src", CLK_IGNORE_UNUSED,
353 RK3368_CLKSEL_CON(8), 12, 3, DFLAGS,
354 RK3368_CLKGATE_CON(1), 2, GFLAGS),
355 COMPOSITE_NOMUX(HCLK_BUS, "hclk_bus", "aclk_bus_src", CLK_IGNORE_UNUSED,
356 RK3368_CLKSEL_CON(8), 8, 2, DFLAGS,
357 RK3368_CLKGATE_CON(1), 1, GFLAGS),
358 COMPOSITE_NOMUX(0, "sclk_crypto", "aclk_bus_src", 0,
359 RK3368_CLKSEL_CON(10), 14, 2, DFLAGS,
360 RK3368_CLKGATE_CON(7), 2, GFLAGS),
361
362 COMPOSITE(0, "fclk_mcu_src", mux_pll_src_cpll_gpll_p, CLK_IGNORE_UNUSED,
363 RK3368_CLKSEL_CON(12), 7, 1, MFLAGS, 0, 5, DFLAGS,
364 RK3368_CLKGATE_CON(1), 3, GFLAGS),
365 /*
366 * stclk_mcu is listed as child of fclk_mcu_src in diagram 5,
367 * but stclk_mcu has an additional own divider in diagram 2
368 */
369 COMPOSITE_NOMUX(0, "stclk_mcu", "fclk_mcu_src", 0,
370 RK3368_CLKSEL_CON(12), 8, 3, DFLAGS,
371 RK3368_CLKGATE_CON(13), 13, GFLAGS),
372
373 COMPOSITE(0, "i2s_8ch_src", mux_pll_src_cpll_gpll_p, 0,
374 RK3368_CLKSEL_CON(27), 12, 1, MFLAGS, 0, 7, DFLAGS,
375 RK3368_CLKGATE_CON(6), 1, GFLAGS),
Elaine Zhang7af8a262016-02-24 08:44:11 +0800376 COMPOSITE_FRACMUX(0, "i2s_8ch_frac", "i2s_8ch_src", CLK_SET_RATE_PARENT,
377 RK3368_CLKSEL_CON(28), 0,
378 RK3368_CLKGATE_CON(6), 2, GFLAGS,
379 &rk3368_i2s_8ch_fracmux),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200380 COMPOSITE_NODIV(SCLK_I2S_8CH_OUT, "i2s_8ch_clkout", mux_i2s_8ch_clkout_p, 0,
381 RK3368_CLKSEL_CON(27), 15, 1, MFLAGS,
382 RK3368_CLKGATE_CON(6), 0, GFLAGS),
383 GATE(SCLK_I2S_8CH, "sclk_i2s_8ch", "i2s_8ch_pre", CLK_SET_RATE_PARENT,
384 RK3368_CLKGATE_CON(6), 3, GFLAGS),
385 COMPOSITE(0, "spdif_8ch_src", mux_pll_src_cpll_gpll_p, 0,
386 RK3368_CLKSEL_CON(31), 12, 1, MFLAGS, 0, 7, DFLAGS,
387 RK3368_CLKGATE_CON(6), 4, GFLAGS),
Elaine Zhang7af8a262016-02-24 08:44:11 +0800388 COMPOSITE_FRACMUX(0, "spdif_8ch_frac", "spdif_8ch_src", CLK_SET_RATE_PARENT,
389 RK3368_CLKSEL_CON(32), 0,
390 RK3368_CLKGATE_CON(6), 5, GFLAGS,
391 &rk3368_spdif_8ch_fracmux),
392 GATE(SCLK_SPDIF_8CH, "sclk_spdif_8ch", "spdif_8ch_pre", CLK_SET_RATE_PARENT,
393 RK3368_CLKGATE_CON(6), 6, GFLAGS),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200394 COMPOSITE(0, "i2s_2ch_src", mux_pll_src_cpll_gpll_p, 0,
395 RK3368_CLKSEL_CON(53), 12, 1, MFLAGS, 0, 7, DFLAGS,
396 RK3368_CLKGATE_CON(5), 13, GFLAGS),
Elaine Zhang7af8a262016-02-24 08:44:11 +0800397 COMPOSITE_FRACMUX(0, "i2s_2ch_frac", "i2s_2ch_src", CLK_SET_RATE_PARENT,
398 RK3368_CLKSEL_CON(54), 0,
399 RK3368_CLKGATE_CON(5), 14, GFLAGS,
400 &rk3368_i2s_2ch_fracmux),
401 GATE(SCLK_I2S_2CH, "sclk_i2s_2ch", "i2s_2ch_pre", CLK_SET_RATE_PARENT,
402 RK3368_CLKGATE_CON(5), 15, GFLAGS),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200403
404 COMPOSITE(0, "sclk_tsp", mux_pll_src_cpll_gpll_npll_p, 0,
405 RK3368_CLKSEL_CON(46), 6, 2, MFLAGS, 0, 5, DFLAGS,
406 RK3368_CLKGATE_CON(6), 12, GFLAGS),
407 GATE(0, "sclk_hsadc_tsp", "ext_hsadc_tsp", 0,
408 RK3368_CLKGATE_CON(13), 7, GFLAGS),
409
410 MUX(0, "uart_src", mux_pll_src_cpll_gpll_p, 0,
411 RK3368_CLKSEL_CON(35), 12, 1, MFLAGS),
412 COMPOSITE_NOMUX(0, "uart2_src", "uart_src", 0,
413 RK3368_CLKSEL_CON(37), 0, 7, DFLAGS,
414 RK3368_CLKGATE_CON(2), 4, GFLAGS),
415 MUX(SCLK_UART2, "sclk_uart2", mux_uart2_p, CLK_SET_RATE_PARENT,
416 RK3368_CLKSEL_CON(37), 8, 1, MFLAGS),
417
418 /*
419 * Clock-Architecture Diagram 3
420 */
421
Heiko Stuebner0f28d982016-01-20 19:22:38 +0100422 COMPOSITE(0, "aclk_vepu", mux_pll_src_cpll_gpll_npll_usb_p, 0,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200423 RK3368_CLKSEL_CON(15), 6, 2, MFLAGS, 0, 5, DFLAGS,
424 RK3368_CLKGATE_CON(4), 6, GFLAGS),
Heiko Stuebner0f28d982016-01-20 19:22:38 +0100425 COMPOSITE(0, "aclk_vdpu", mux_pll_src_cpll_gpll_npll_usb_p, 0,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200426 RK3368_CLKSEL_CON(15), 14, 2, MFLAGS, 8, 5, DFLAGS,
427 RK3368_CLKGATE_CON(4), 7, GFLAGS),
428
429 /*
Heiko Stuebner36714522015-06-20 16:06:02 +0200430 * We use aclk_vdpu by default ---GRF_SOC_CON0[7] setting in system,
431 * so we ignore the mux and make clocks nodes as following,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200432 */
Heiko Stuebner36714522015-06-20 16:06:02 +0200433 FACTOR_GATE(0, "hclk_video_pre", "aclk_vdpu", 0, 1, 4,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200434 RK3368_CLKGATE_CON(4), 8, GFLAGS),
435
436 COMPOSITE(0, "sclk_hevc_cabac_src", mux_pll_src_cpll_gpll_npll_usb_p, 0,
437 RK3368_CLKSEL_CON(17), 6, 2, MFLAGS, 0, 5, DFLAGS,
438 RK3368_CLKGATE_CON(5), 1, GFLAGS),
439 COMPOSITE(0, "sclk_hevc_core_src", mux_pll_src_cpll_gpll_npll_usb_p, 0,
440 RK3368_CLKSEL_CON(17), 14, 2, MFLAGS, 8, 5, DFLAGS,
441 RK3368_CLKGATE_CON(5), 2, GFLAGS),
442
443 COMPOSITE(0, "aclk_vio0", mux_pll_src_cpll_gpll_usb_p, CLK_IGNORE_UNUSED,
444 RK3368_CLKSEL_CON(19), 6, 2, MFLAGS, 0, 5, DFLAGS,
445 RK3368_CLKGATE_CON(4), 0, GFLAGS),
446 DIV(0, "hclk_vio", "aclk_vio0", 0,
447 RK3368_CLKSEL_CON(21), 0, 5, DFLAGS),
448
449 COMPOSITE(0, "aclk_rga_pre", mux_pll_src_cpll_gpll_usb_p, 0,
450 RK3368_CLKSEL_CON(18), 14, 2, MFLAGS, 8, 5, DFLAGS,
451 RK3368_CLKGATE_CON(4), 3, GFLAGS),
452 COMPOSITE(SCLK_RGA, "sclk_rga", mux_pll_src_cpll_gpll_usb_p, 0,
453 RK3368_CLKSEL_CON(18), 6, 2, MFLAGS, 0, 5, DFLAGS,
454 RK3368_CLKGATE_CON(4), 4, GFLAGS),
455
456 COMPOSITE(DCLK_VOP, "dclk_vop", mux_pll_src_cpll_gpll_npll_p, 0,
457 RK3368_CLKSEL_CON(20), 8, 2, MFLAGS, 0, 8, DFLAGS,
458 RK3368_CLKGATE_CON(4), 1, GFLAGS),
459
460 GATE(SCLK_VOP0_PWM, "sclk_vop0_pwm", "xin24m", 0,
461 RK3368_CLKGATE_CON(4), 2, GFLAGS),
462
463 COMPOSITE(SCLK_ISP, "sclk_isp", mux_pll_src_cpll_gpll_npll_npll_p, 0,
464 RK3368_CLKSEL_CON(22), 6, 2, MFLAGS, 0, 6, DFLAGS,
465 RK3368_CLKGATE_CON(4), 9, GFLAGS),
466
467 GATE(0, "pclk_isp_in", "ext_isp", 0,
468 RK3368_CLKGATE_CON(17), 2, GFLAGS),
469 INVERTER(PCLK_ISP, "pclk_isp", "pclk_isp_in",
470 RK3368_CLKSEL_CON(21), 6, IFLAGS),
471
472 GATE(0, "pclk_vip_in", "ext_vip", 0,
473 RK3368_CLKGATE_CON(16), 13, GFLAGS),
474 INVERTER(PCLK_VIP, "pclk_vip", "pclk_vip_in",
475 RK3368_CLKSEL_CON(21), 13, IFLAGS),
476
477 GATE(SCLK_HDMI_HDCP, "sclk_hdmi_hdcp", "xin24m", 0,
478 RK3368_CLKGATE_CON(4), 13, GFLAGS),
479 GATE(SCLK_HDMI_CEC, "sclk_hdmi_cec", "xin32k", 0,
Heiko Stuebnerfd0c0742016-01-20 21:47:57 +0100480 RK3368_CLKGATE_CON(4), 12, GFLAGS),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200481
482 COMPOSITE_NODIV(0, "vip_src", mux_pll_src_cpll_gpll_p, 0,
483 RK3368_CLKSEL_CON(21), 15, 1, MFLAGS,
484 RK3368_CLKGATE_CON(4), 5, GFLAGS),
485 COMPOSITE_NOGATE(0, "sclk_vip_out", mux_vip_out_p, 0,
486 RK3368_CLKSEL_CON(21), 14, 1, MFLAGS, 8, 5, DFLAGS),
487
488 COMPOSITE_NODIV(SCLK_EDP_24M, "sclk_edp_24m", mux_edp_24m_p, 0,
489 RK3368_CLKSEL_CON(23), 8, 1, MFLAGS,
490 RK3368_CLKGATE_CON(5), 4, GFLAGS),
491 COMPOSITE(SCLK_EDP, "sclk_edp", mux_pll_src_cpll_gpll_npll_npll_p, 0,
492 RK3368_CLKSEL_CON(23), 6, 2, MFLAGS, 0, 6, DFLAGS,
493 RK3368_CLKGATE_CON(5), 3, GFLAGS),
494
495 COMPOSITE(SCLK_HDCP, "sclk_hdcp", mux_pll_src_cpll_gpll_npll_npll_p, 0,
496 RK3368_CLKSEL_CON(55), 6, 2, MFLAGS, 0, 6, DFLAGS,
497 RK3368_CLKGATE_CON(5), 5, GFLAGS),
498
499 DIV(0, "pclk_pd_alive", "gpll", 0,
500 RK3368_CLKSEL_CON(10), 8, 5, DFLAGS),
501
502 /* sclk_timer has a gate in the sgrf */
503
504 COMPOSITE_NOMUX(0, "pclk_pd_pmu", "gpll", CLK_IGNORE_UNUSED,
505 RK3368_CLKSEL_CON(10), 0, 5, DFLAGS,
506 RK3368_CLKGATE_CON(7), 9, GFLAGS),
507 GATE(SCLK_PVTM_PMU, "sclk_pvtm_pmu", "xin24m", 0,
508 RK3368_CLKGATE_CON(7), 3, GFLAGS),
509 COMPOSITE(0, "sclk_gpu_core_src", mux_pll_src_cpll_gpll_usb_npll_p, 0,
510 RK3368_CLKSEL_CON(14), 6, 2, MFLAGS, 0, 5, DFLAGS,
511 RK3368_CLKGATE_CON(4), 11, GFLAGS),
512 MUX(0, "aclk_gpu_src", mux_pll_src_cpll_gpll_p, 0,
513 RK3368_CLKSEL_CON(14), 14, 1, MFLAGS),
514 COMPOSITE_NOMUX(0, "aclk_gpu_mem_pre", "aclk_gpu_src", 0,
515 RK3368_CLKSEL_CON(14), 8, 5, DFLAGS,
516 RK3368_CLKGATE_CON(5), 8, GFLAGS),
517 COMPOSITE_NOMUX(0, "aclk_gpu_cfg_pre", "aclk_gpu_src", 0,
518 RK3368_CLKSEL_CON(16), 8, 5, DFLAGS,
519 RK3368_CLKGATE_CON(5), 9, GFLAGS),
520 GATE(SCLK_PVTM_GPU, "sclk_pvtm_gpu", "xin24m", 0,
521 RK3368_CLKGATE_CON(7), 11, GFLAGS),
522
523 COMPOSITE(0, "aclk_peri_src", mux_pll_src_cpll_gpll_p, CLK_IGNORE_UNUSED,
524 RK3368_CLKSEL_CON(9), 7, 1, MFLAGS, 0, 5, DFLAGS,
525 RK3368_CLKGATE_CON(3), 0, GFLAGS),
526 COMPOSITE_NOMUX(PCLK_PERI, "pclk_peri", "aclk_peri_src", 0,
527 RK3368_CLKSEL_CON(9), 12, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO,
528 RK3368_CLKGATE_CON(3), 3, GFLAGS),
529 COMPOSITE_NOMUX(HCLK_PERI, "hclk_peri", "aclk_peri_src", CLK_IGNORE_UNUSED,
530 RK3368_CLKSEL_CON(9), 8, 2, DFLAGS | CLK_DIVIDER_POWER_OF_TWO,
531 RK3368_CLKGATE_CON(3), 2, GFLAGS),
532 GATE(ACLK_PERI, "aclk_peri", "aclk_peri_src", CLK_IGNORE_UNUSED,
533 RK3368_CLKGATE_CON(3), 1, GFLAGS),
534
535 GATE(0, "sclk_mipidsi_24m", "xin24m", 0, RK3368_CLKGATE_CON(4), 14, GFLAGS),
536
537 /*
538 * Clock-Architecture Diagram 4
539 */
540
541 COMPOSITE(SCLK_SPI0, "sclk_spi0", mux_pll_src_cpll_gpll_p, 0,
542 RK3368_CLKSEL_CON(45), 7, 1, MFLAGS, 0, 7, DFLAGS,
543 RK3368_CLKGATE_CON(3), 7, GFLAGS),
544 COMPOSITE(SCLK_SPI1, "sclk_spi1", mux_pll_src_cpll_gpll_p, 0,
545 RK3368_CLKSEL_CON(45), 15, 1, MFLAGS, 8, 7, DFLAGS,
546 RK3368_CLKGATE_CON(3), 8, GFLAGS),
547 COMPOSITE(SCLK_SPI2, "sclk_spi2", mux_pll_src_cpll_gpll_p, 0,
548 RK3368_CLKSEL_CON(46), 15, 1, MFLAGS, 8, 7, DFLAGS,
549 RK3368_CLKGATE_CON(3), 9, GFLAGS),
550
551
552 COMPOSITE(SCLK_SDMMC, "sclk_sdmmc", mux_mmc_src_p, 0,
553 RK3368_CLKSEL_CON(50), 8, 2, MFLAGS, 0, 7, DFLAGS,
554 RK3368_CLKGATE_CON(7), 12, GFLAGS),
555 COMPOSITE(SCLK_SDIO0, "sclk_sdio0", mux_mmc_src_p, 0,
556 RK3368_CLKSEL_CON(48), 8, 2, MFLAGS, 0, 7, DFLAGS,
557 RK3368_CLKGATE_CON(7), 13, GFLAGS),
558 COMPOSITE(SCLK_EMMC, "sclk_emmc", mux_mmc_src_p, 0,
559 RK3368_CLKSEL_CON(51), 8, 2, MFLAGS, 0, 7, DFLAGS,
560 RK3368_CLKGATE_CON(7), 15, GFLAGS),
561
562 MMC(SCLK_SDMMC_DRV, "sdmmc_drv", "sclk_sdmmc", RK3368_SDMMC_CON0, 1),
563 MMC(SCLK_SDMMC_SAMPLE, "sdmmc_sample", "sclk_sdmmc", RK3368_SDMMC_CON1, 0),
564
565 MMC(SCLK_SDIO0_DRV, "sdio0_drv", "sclk_sdio0", RK3368_SDIO0_CON0, 1),
566 MMC(SCLK_SDIO0_SAMPLE, "sdio0_sample", "sclk_sdio0", RK3368_SDIO0_CON1, 0),
567
568 MMC(SCLK_EMMC_DRV, "emmc_drv", "sclk_emmc", RK3368_EMMC_CON0, 1),
569 MMC(SCLK_EMMC_SAMPLE, "emmc_sample", "sclk_emmc", RK3368_EMMC_CON1, 0),
570
571 GATE(SCLK_OTGPHY0, "sclk_otgphy0", "xin24m", CLK_IGNORE_UNUSED,
572 RK3368_CLKGATE_CON(8), 1, GFLAGS),
573
574 /* pmu_grf_soc_con0[6] allows to select between xin32k and pvtm_pmu */
575 GATE(SCLK_OTG_ADP, "sclk_otg_adp", "xin32k", CLK_IGNORE_UNUSED,
576 RK3368_CLKGATE_CON(8), 4, GFLAGS),
577
578 /* pmu_grf_soc_con0[6] allows to select between xin32k and pvtm_pmu */
579 COMPOSITE_NOMUX(SCLK_TSADC, "sclk_tsadc", "xin32k", 0,
580 RK3368_CLKSEL_CON(25), 0, 6, DFLAGS,
581 RK3368_CLKGATE_CON(3), 5, GFLAGS),
582
583 COMPOSITE_NOMUX(SCLK_SARADC, "sclk_saradc", "xin24m", 0,
584 RK3368_CLKSEL_CON(25), 8, 8, DFLAGS,
585 RK3368_CLKGATE_CON(3), 6, GFLAGS),
586
587 COMPOSITE(SCLK_NANDC0, "sclk_nandc0", mux_pll_src_cpll_gpll_p, 0,
588 RK3368_CLKSEL_CON(47), 7, 1, MFLAGS, 0, 5, DFLAGS,
589 RK3368_CLKGATE_CON(7), 8, GFLAGS),
590
591 COMPOSITE(SCLK_SFC, "sclk_sfc", mux_pll_src_cpll_gpll_p, 0,
592 RK3368_CLKSEL_CON(52), 7, 1, MFLAGS, 0, 5, DFLAGS,
593 RK3368_CLKGATE_CON(6), 7, GFLAGS),
594
595 COMPOSITE(0, "uart0_src", mux_pll_src_cpll_gpll_usb_usb_p, 0,
596 RK3368_CLKSEL_CON(33), 12, 2, MFLAGS, 0, 7, DFLAGS,
597 RK3368_CLKGATE_CON(2), 0, GFLAGS),
Elaine Zhang7af8a262016-02-24 08:44:11 +0800598 COMPOSITE_FRACMUX(0, "uart0_frac", "uart0_src", CLK_SET_RATE_PARENT,
599 RK3368_CLKSEL_CON(34), 0,
600 RK3368_CLKGATE_CON(2), 1, GFLAGS,
601 &rk3368_uart0_fracmux),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200602
603 COMPOSITE_NOMUX(0, "uart1_src", "uart_src", 0,
604 RK3368_CLKSEL_CON(35), 0, 7, DFLAGS,
605 RK3368_CLKGATE_CON(2), 2, GFLAGS),
Elaine Zhang7af8a262016-02-24 08:44:11 +0800606 COMPOSITE_FRACMUX(0, "uart1_frac", "uart1_src", CLK_SET_RATE_PARENT,
607 RK3368_CLKSEL_CON(36), 0,
608 RK3368_CLKGATE_CON(2), 3, GFLAGS,
609 &rk3368_uart1_fracmux),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200610
611 COMPOSITE_NOMUX(0, "uart3_src", "uart_src", 0,
612 RK3368_CLKSEL_CON(39), 0, 7, DFLAGS,
613 RK3368_CLKGATE_CON(2), 6, GFLAGS),
Elaine Zhang7af8a262016-02-24 08:44:11 +0800614 COMPOSITE_FRACMUX(0, "uart3_frac", "uart3_src", CLK_SET_RATE_PARENT,
615 RK3368_CLKSEL_CON(40), 0,
616 RK3368_CLKGATE_CON(2), 7, GFLAGS,
617 &rk3368_uart3_fracmux),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200618
619 COMPOSITE_NOMUX(0, "uart4_src", "uart_src", 0,
620 RK3368_CLKSEL_CON(41), 0, 7, DFLAGS,
621 RK3368_CLKGATE_CON(2), 8, GFLAGS),
Elaine Zhang7af8a262016-02-24 08:44:11 +0800622 COMPOSITE_FRACMUX(0, "uart4_frac", "uart4_src", CLK_SET_RATE_PARENT,
623 RK3368_CLKSEL_CON(42), 0,
624 RK3368_CLKGATE_CON(2), 9, GFLAGS,
625 &rk3368_uart4_fracmux),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200626
627 COMPOSITE(0, "mac_pll_src", mux_pll_src_npll_cpll_gpll_p, 0,
628 RK3368_CLKSEL_CON(43), 6, 2, MFLAGS, 0, 5, DFLAGS,
629 RK3368_CLKGATE_CON(3), 4, GFLAGS),
630 MUX(SCLK_MAC, "mac_clk", mux_mac_p, CLK_SET_RATE_PARENT,
631 RK3368_CLKSEL_CON(43), 8, 1, MFLAGS),
632 GATE(SCLK_MACREF_OUT, "sclk_macref_out", "mac_clk", 0,
633 RK3368_CLKGATE_CON(7), 7, GFLAGS),
634 GATE(SCLK_MACREF, "sclk_macref", "mac_clk", 0,
635 RK3368_CLKGATE_CON(7), 6, GFLAGS),
636 GATE(SCLK_MAC_RX, "sclk_mac_rx", "mac_clk", 0,
637 RK3368_CLKGATE_CON(7), 4, GFLAGS),
638 GATE(SCLK_MAC_TX, "sclk_mac_tx", "mac_clk", 0,
639 RK3368_CLKGATE_CON(7), 5, GFLAGS),
640
641 GATE(0, "jtag", "ext_jtag", 0,
642 RK3368_CLKGATE_CON(7), 0, GFLAGS),
643
644 COMPOSITE_NODIV(0, "hsic_usbphy_480m", mux_hsic_usbphy480m_p, 0,
645 RK3368_CLKSEL_CON(26), 8, 2, MFLAGS,
646 RK3368_CLKGATE_CON(8), 0, GFLAGS),
647 COMPOSITE_NODIV(SCLK_HSICPHY480M, "sclk_hsicphy480m", mux_hsicphy480m_p, 0,
648 RK3368_CLKSEL_CON(26), 12, 2, MFLAGS,
649 RK3368_CLKGATE_CON(8), 7, GFLAGS),
650 GATE(SCLK_HSICPHY12M, "sclk_hsicphy12m", "xin12m", 0,
651 RK3368_CLKGATE_CON(8), 6, GFLAGS),
652
653 /*
654 * Clock-Architecture Diagram 5
655 */
656
657 /* aclk_cci_pre gates */
658 GATE(0, "aclk_core_niu_cpup", "aclk_cci_pre", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(11), 4, GFLAGS),
659 GATE(0, "aclk_core_niu_cci", "aclk_cci_pre", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(11), 3, GFLAGS),
660 GATE(0, "aclk_cci400", "aclk_cci_pre", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(11), 2, GFLAGS),
661 GATE(0, "aclk_adb400m_pd_core_b", "aclk_cci_pre", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(11), 1, GFLAGS),
662 GATE(0, "aclk_adb400m_pd_core_l", "aclk_cci_pre", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(11), 0, GFLAGS),
663
664 /* aclkm_core_* gates */
665 GATE(0, "aclk_adb400s_pd_core_b", "aclkm_core_b", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(10), 0, GFLAGS),
666 GATE(0, "aclk_adb400s_pd_core_l", "aclkm_core_l", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(9), 0, GFLAGS),
667
668 /* armclk* gates */
669 GATE(0, "sclk_dbg_pd_core_b", "armclkb", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(10), 1, GFLAGS),
670 GATE(0, "sclk_dbg_pd_core_l", "armclkl", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(9), 1, GFLAGS),
671
672 /* sclk_cs_pre gates */
673 GATE(0, "sclk_dbg", "sclk_cs_pre", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(11), 7, GFLAGS),
674 GATE(0, "pclk_core_niu_sdbg", "sclk_cs_pre", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(11), 6, GFLAGS),
675 GATE(0, "hclk_core_niu_dbg", "sclk_cs_pre", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(11), 5, GFLAGS),
676
677 /* aclk_bus gates */
678 GATE(0, "aclk_strc_sys", "aclk_bus", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(12), 12, GFLAGS),
679 GATE(ACLK_DMAC_BUS, "aclk_dmac_bus", "aclk_bus", 0, RK3368_CLKGATE_CON(12), 11, GFLAGS),
680 GATE(0, "sclk_intmem1", "aclk_bus", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(12), 6, GFLAGS),
681 GATE(0, "sclk_intmem0", "aclk_bus", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(12), 5, GFLAGS),
682 GATE(0, "aclk_intmem", "aclk_bus", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(12), 4, GFLAGS),
683 GATE(0, "aclk_gic400", "aclk_bus", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(13), 9, GFLAGS),
684
685 /* sclk_ddr gates */
686 GATE(0, "nclk_ddrupctl", "sclk_ddr", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(13), 2, GFLAGS),
687
688 /* clk_hsadc_tsp is part of diagram2 */
689
690 /* fclk_mcu_src gates */
691 GATE(0, "hclk_noc_mcu", "fclk_mcu_src", 0, RK3368_CLKGATE_CON(13), 14, GFLAGS),
692 GATE(0, "fclk_mcu", "fclk_mcu_src", 0, RK3368_CLKGATE_CON(13), 12, GFLAGS),
693 GATE(0, "hclk_mcu", "fclk_mcu_src", 0, RK3368_CLKGATE_CON(13), 11, GFLAGS),
694
695 /* hclk_cpu gates */
696 GATE(HCLK_SPDIF, "hclk_spdif", "hclk_bus", 0, RK3368_CLKGATE_CON(12), 10, GFLAGS),
697 GATE(HCLK_ROM, "hclk_rom", "hclk_bus", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(12), 9, GFLAGS),
698 GATE(HCLK_I2S_2CH, "hclk_i2s_2ch", "hclk_bus", 0, RK3368_CLKGATE_CON(12), 8, GFLAGS),
699 GATE(HCLK_I2S_8CH, "hclk_i2s_8ch", "hclk_bus", 0, RK3368_CLKGATE_CON(12), 7, GFLAGS),
700 GATE(HCLK_TSP, "hclk_tsp", "hclk_bus", 0, RK3368_CLKGATE_CON(13), 10, GFLAGS),
701 GATE(HCLK_CRYPTO, "hclk_crypto", "hclk_bus", 0, RK3368_CLKGATE_CON(13), 4, GFLAGS),
702 GATE(MCLK_CRYPTO, "mclk_crypto", "hclk_bus", 0, RK3368_CLKGATE_CON(13), 3, GFLAGS),
703
704 /* pclk_cpu gates */
705 GATE(PCLK_DDRPHY, "pclk_ddrphy", "pclk_bus", 0, RK3368_CLKGATE_CON(12), 14, GFLAGS),
706 GATE(PCLK_DDRUPCTL, "pclk_ddrupctl", "pclk_bus", 0, RK3368_CLKGATE_CON(12), 13, GFLAGS),
707 GATE(PCLK_I2C1, "pclk_i2c1", "pclk_bus", 0, RK3368_CLKGATE_CON(12), 3, GFLAGS),
708 GATE(PCLK_I2C0, "pclk_i2c0", "pclk_bus", 0, RK3368_CLKGATE_CON(12), 2, GFLAGS),
709 GATE(PCLK_MAILBOX, "pclk_mailbox", "pclk_bus", 0, RK3368_CLKGATE_CON(12), 1, GFLAGS),
710 GATE(PCLK_PWM0, "pclk_pwm0", "pclk_bus", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(12), 0, GFLAGS),
711 GATE(PCLK_SIM, "pclk_sim", "pclk_bus", 0, RK3368_CLKGATE_CON(13), 8, GFLAGS),
712 GATE(PCLK_PWM1, "pclk_pwm1", "pclk_bus", 0, RK3368_CLKGATE_CON(13), 6, GFLAGS),
713 GATE(PCLK_UART2, "pclk_uart2", "pclk_bus", 0, RK3368_CLKGATE_CON(13), 5, GFLAGS),
714 GATE(0, "pclk_efuse_256", "pclk_bus", 0, RK3368_CLKGATE_CON(13), 1, GFLAGS),
715 GATE(0, "pclk_efuse_1024", "pclk_bus", 0, RK3368_CLKGATE_CON(13), 0, GFLAGS),
716
717 /*
718 * video clk gates
719 * aclk_video(_pre) can actually select between parents of aclk_vdpu
720 * and aclk_vepu by setting bit GRF_SOC_CON0[7].
721 */
722 GATE(ACLK_VIDEO, "aclk_video", "aclk_vdpu", 0, RK3368_CLKGATE_CON(15), 0, GFLAGS),
723 GATE(SCLK_HEVC_CABAC, "sclk_hevc_cabac", "sclk_hevc_cabac_src", 0, RK3368_CLKGATE_CON(15), 3, GFLAGS),
724 GATE(SCLK_HEVC_CORE, "sclk_hevc_core", "sclk_hevc_core_src", 0, RK3368_CLKGATE_CON(15), 2, GFLAGS),
725 GATE(HCLK_VIDEO, "hclk_video", "hclk_video_pre", 0, RK3368_CLKGATE_CON(15), 1, GFLAGS),
726
727 /* aclk_rga_pre gates */
728 GATE(ACLK_VIO1_NOC, "aclk_vio1_noc", "aclk_rga_pre", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(16), 10, GFLAGS),
729 GATE(ACLK_RGA, "aclk_rga", "aclk_rga_pre", 0, RK3368_CLKGATE_CON(16), 0, GFLAGS),
730 GATE(ACLK_HDCP, "aclk_hdcp", "aclk_rga_pre", 0, RK3368_CLKGATE_CON(17), 10, GFLAGS),
731
732 /* aclk_vio0 gates */
733 GATE(ACLK_VIP, "aclk_vip", "aclk_vio0", 0, RK3368_CLKGATE_CON(16), 11, GFLAGS),
734 GATE(ACLK_VIO0_NOC, "aclk_vio0_noc", "aclk_vio0", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(16), 9, GFLAGS),
735 GATE(ACLK_VOP, "aclk_vop", "aclk_vio0", 0, RK3368_CLKGATE_CON(16), 5, GFLAGS),
736 GATE(ACLK_VOP_IEP, "aclk_vop_iep", "aclk_vio0", 0, RK3368_CLKGATE_CON(16), 4, GFLAGS),
737 GATE(ACLK_IEP, "aclk_iep", "aclk_vio0", 0, RK3368_CLKGATE_CON(16), 2, GFLAGS),
738
739 /* sclk_isp gates */
740 GATE(HCLK_ISP, "hclk_isp", "sclk_isp", 0, RK3368_CLKGATE_CON(16), 14, GFLAGS),
741 GATE(ACLK_ISP, "aclk_isp", "sclk_isp", 0, RK3368_CLKGATE_CON(17), 0, GFLAGS),
742
743 /* hclk_vio gates */
744 GATE(HCLK_VIP, "hclk_vip", "hclk_vio", 0, RK3368_CLKGATE_CON(16), 12, GFLAGS),
745 GATE(HCLK_VIO_NOC, "hclk_vio_noc", "hclk_vio", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(16), 8, GFLAGS),
746 GATE(HCLK_VIO_AHB_ARBI, "hclk_vio_ahb_arbi", "hclk_vio", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(16), 7, GFLAGS),
747 GATE(HCLK_VOP, "hclk_vop", "hclk_vio", 0, RK3368_CLKGATE_CON(16), 6, GFLAGS),
748 GATE(HCLK_IEP, "hclk_iep", "hclk_vio", 0, RK3368_CLKGATE_CON(16), 3, GFLAGS),
749 GATE(HCLK_RGA, "hclk_rga", "hclk_vio", 0, RK3368_CLKGATE_CON(16), 1, GFLAGS),
750 GATE(HCLK_VIO_HDCPMMU, "hclk_hdcpmmu", "hclk_vio", 0, RK3368_CLKGATE_CON(17), 12, GFLAGS),
751 GATE(HCLK_VIO_H2P, "hclk_vio_h2p", "hclk_vio", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(17), 7, GFLAGS),
752
753 /*
754 * pclk_vio gates
755 * pclk_vio comes from the exactly same source as hclk_vio
756 */
757 GATE(PCLK_HDCP, "pclk_hdcp", "hclk_vio", 0, RK3368_CLKGATE_CON(17), 11, GFLAGS),
758 GATE(PCLK_EDP_CTRL, "pclk_edp_ctrl", "hclk_vio", 0, RK3368_CLKGATE_CON(17), 9, GFLAGS),
759 GATE(PCLK_VIO_H2P, "pclk_vio_h2p", "hclk_vio", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(17), 8, GFLAGS),
760 GATE(PCLK_HDMI_CTRL, "pclk_hdmi_ctrl", "hclk_vio", 0, RK3368_CLKGATE_CON(17), 6, GFLAGS),
761 GATE(PCLK_MIPI_CSI, "pclk_mipi_csi", "hclk_vio", 0, RK3368_CLKGATE_CON(17), 4, GFLAGS),
762 GATE(PCLK_MIPI_DSI0, "pclk_mipi_dsi0", "hclk_vio", 0, RK3368_CLKGATE_CON(17), 3, GFLAGS),
763
764 /* ext_vip gates in diagram3 */
765
766 /* gpu gates */
767 GATE(SCLK_GPU_CORE, "sclk_gpu_core", "sclk_gpu_core_src", 0, RK3368_CLKGATE_CON(18), 2, GFLAGS),
768 GATE(ACLK_GPU_MEM, "aclk_gpu_mem", "aclk_gpu_mem_pre", 0, RK3368_CLKGATE_CON(18), 1, GFLAGS),
769 GATE(ACLK_GPU_CFG, "aclk_gpu_cfg", "aclk_gpu_cfg_pre", 0, RK3368_CLKGATE_CON(18), 0, GFLAGS),
770
771 /* aclk_peri gates */
772 GATE(ACLK_DMAC_PERI, "aclk_dmac_peri", "aclk_peri", 0, RK3368_CLKGATE_CON(19), 3, GFLAGS),
773 GATE(0, "aclk_peri_axi_matrix", "aclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(19), 2, GFLAGS),
774 GATE(HCLK_SFC, "hclk_sfc", "aclk_peri", 0, RK3368_CLKGATE_CON(20), 15, GFLAGS),
775 GATE(ACLK_GMAC, "aclk_gmac", "aclk_peri", 0, RK3368_CLKGATE_CON(20), 13, GFLAGS),
776 GATE(0, "aclk_peri_niu", "aclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(20), 8, GFLAGS),
777 GATE(ACLK_PERI_MMU, "aclk_peri_mmu", "aclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(21), 4, GFLAGS),
778
779 /* hclk_peri gates */
780 GATE(0, "hclk_peri_axi_matrix", "hclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(19), 0, GFLAGS),
781 GATE(HCLK_NANDC0, "hclk_nandc0", "hclk_peri", 0, RK3368_CLKGATE_CON(20), 11, GFLAGS),
782 GATE(0, "hclk_mmc_peri", "hclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(20), 10, GFLAGS),
783 GATE(0, "hclk_emem_peri", "hclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(20), 9, GFLAGS),
784 GATE(0, "hclk_peri_ahb_arbi", "hclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(20), 7, GFLAGS),
785 GATE(0, "hclk_usb_peri", "hclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(20), 6, GFLAGS),
786 GATE(HCLK_HSIC, "hclk_hsic", "hclk_peri", 0, RK3368_CLKGATE_CON(20), 5, GFLAGS),
787 GATE(HCLK_HOST1, "hclk_host1", "hclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(20), 4, GFLAGS),
788 GATE(HCLK_HOST0, "hclk_host0", "hclk_peri", 0, RK3368_CLKGATE_CON(20), 3, GFLAGS),
789 GATE(0, "pmu_hclk_otg0", "hclk_peri", 0, RK3368_CLKGATE_CON(20), 2, GFLAGS),
790 GATE(HCLK_OTG0, "hclk_otg0", "hclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(20), 1, GFLAGS),
791 GATE(HCLK_HSADC, "hclk_hsadc", "hclk_peri", 0, RK3368_CLKGATE_CON(21), 3, GFLAGS),
792 GATE(HCLK_EMMC, "hclk_emmc", "hclk_peri", 0, RK3368_CLKGATE_CON(21), 2, GFLAGS),
793 GATE(HCLK_SDIO0, "hclk_sdio0", "hclk_peri", 0, RK3368_CLKGATE_CON(21), 1, GFLAGS),
794 GATE(HCLK_SDMMC, "hclk_sdmmc", "hclk_peri", 0, RK3368_CLKGATE_CON(21), 0, GFLAGS),
795
796 /* pclk_peri gates */
797 GATE(PCLK_SARADC, "pclk_saradc", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 15, GFLAGS),
798 GATE(PCLK_I2C5, "pclk_i2c5", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 14, GFLAGS),
799 GATE(PCLK_I2C4, "pclk_i2c4", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 13, GFLAGS),
800 GATE(PCLK_I2C3, "pclk_i2c3", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 12, GFLAGS),
801 GATE(PCLK_I2C2, "pclk_i2c2", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 11, GFLAGS),
802 GATE(PCLK_UART4, "pclk_uart4", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 10, GFLAGS),
803 GATE(PCLK_UART3, "pclk_uart3", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 9, GFLAGS),
804 GATE(PCLK_UART1, "pclk_uart1", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 8, GFLAGS),
805 GATE(PCLK_UART0, "pclk_uart0", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 7, GFLAGS),
806 GATE(PCLK_SPI2, "pclk_spi2", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 6, GFLAGS),
807 GATE(PCLK_SPI1, "pclk_spi1", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 5, GFLAGS),
808 GATE(PCLK_SPI0, "pclk_spi0", "pclk_peri", 0, RK3368_CLKGATE_CON(19), 4, GFLAGS),
809 GATE(0, "pclk_peri_axi_matrix", "pclk_peri", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(19), 1, GFLAGS),
810 GATE(PCLK_GMAC, "pclk_gmac", "pclk_peri", 0, RK3368_CLKGATE_CON(20), 14, GFLAGS),
811 GATE(PCLK_TSADC, "pclk_tsadc", "pclk_peri", 0, RK3368_CLKGATE_CON(20), 0, GFLAGS),
812
813 /* pclk_pd_alive gates */
Jianqun xu8931f8e2016-01-07 17:18:07 +0800814 GATE(PCLK_TIMER1, "pclk_timer1", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 13, GFLAGS),
815 GATE(PCLK_TIMER0, "pclk_timer0", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 12, GFLAGS),
816 GATE(0, "pclk_alive_niu", "pclk_pd_alive", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(22), 9, GFLAGS),
817 GATE(PCLK_GRF, "pclk_grf", "pclk_pd_alive", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(22), 8, GFLAGS),
818 GATE(PCLK_GPIO3, "pclk_gpio3", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 3, GFLAGS),
819 GATE(PCLK_GPIO2, "pclk_gpio2", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 2, GFLAGS),
820 GATE(PCLK_GPIO1, "pclk_gpio1", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 1, GFLAGS),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200821
822 /*
823 * pclk_vio gates
824 * pclk_vio comes from the exactly same source as hclk_vio
825 */
826 GATE(0, "pclk_dphyrx", "hclk_vio", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(14), 8, GFLAGS),
827 GATE(0, "pclk_dphytx", "hclk_vio", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(14), 8, GFLAGS),
828
829 /* pclk_pd_pmu gates */
Jianqun xu8931f8e2016-01-07 17:18:07 +0800830 GATE(PCLK_PMUGRF, "pclk_pmugrf", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 5, GFLAGS),
831 GATE(PCLK_GPIO0, "pclk_gpio0", "pclk_pd_pmu", 0, RK3368_CLKGATE_CON(23), 4, GFLAGS),
832 GATE(PCLK_SGRF, "pclk_sgrf", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 3, GFLAGS),
833 GATE(0, "pclk_pmu_noc", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 2, GFLAGS),
834 GATE(0, "pclk_intmem1", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 1, GFLAGS),
835 GATE(PCLK_PMU, "pclk_pmu", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 0, GFLAGS),
Heiko Stuebner3536c972015-07-05 11:00:20 +0200836
837 /* timer gates */
838 GATE(0, "sclk_timer15", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 11, GFLAGS),
839 GATE(0, "sclk_timer14", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 10, GFLAGS),
840 GATE(0, "sclk_timer13", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 9, GFLAGS),
841 GATE(0, "sclk_timer12", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 8, GFLAGS),
842 GATE(0, "sclk_timer11", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 7, GFLAGS),
843 GATE(0, "sclk_timer10", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 6, GFLAGS),
844 GATE(0, "sclk_timer05", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 5, GFLAGS),
845 GATE(0, "sclk_timer04", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 4, GFLAGS),
846 GATE(0, "sclk_timer03", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 3, GFLAGS),
847 GATE(0, "sclk_timer02", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 2, GFLAGS),
848 GATE(0, "sclk_timer01", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 1, GFLAGS),
849 GATE(0, "sclk_timer00", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 0, GFLAGS),
850};
851
Heiko Stübner380528f2015-09-13 13:20:36 +0200852static const char *const rk3368_critical_clocks[] __initconst = {
Jianqun xu941c4d32015-12-02 21:22:31 +0800853 "aclk_bus",
854 "aclk_peri",
Caesar Wanga7ce4052015-12-01 17:13:24 +0800855 /*
856 * pwm1 supplies vdd_logic on a lot of boards, is currently unhandled
857 * but needs to stay enabled there (including its parents) at all times.
858 */
859 "pclk_pwm1",
Heiko Stübner380528f2015-09-13 13:20:36 +0200860 "pclk_pd_pmu",
861};
862
Heiko Stuebner3536c972015-07-05 11:00:20 +0200863static void __init rk3368_clk_init(struct device_node *np)
864{
Xing Zhengef1d9fe2016-03-09 10:37:04 +0800865 struct rockchip_clk_provider *ctx;
Heiko Stuebner3536c972015-07-05 11:00:20 +0200866 void __iomem *reg_base;
867 struct clk *clk;
868
869 reg_base = of_iomap(np, 0);
870 if (!reg_base) {
871 pr_err("%s: could not map cru region\n", __func__);
872 return;
873 }
874
Xing Zhengef1d9fe2016-03-09 10:37:04 +0800875 ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
876 if (IS_ERR(ctx)) {
877 pr_err("%s: rockchip clk init failed\n", __func__);
Shawn Lin1d003eb2016-03-13 12:13:22 +0800878 iounmap(reg_base);
Xing Zhengef1d9fe2016-03-09 10:37:04 +0800879 return;
880 }
Heiko Stuebner3536c972015-07-05 11:00:20 +0200881
Heiko Stuebner3536c972015-07-05 11:00:20 +0200882 /* Watchdog pclk is controlled by sgrf_soc_con3[7]. */
883 clk = clk_register_fixed_factor(NULL, "pclk_wdt", "pclk_pd_alive", 0, 1, 1);
884 if (IS_ERR(clk))
885 pr_warn("%s: could not register clock pclk_wdt: %ld\n",
886 __func__, PTR_ERR(clk));
887 else
Xing Zhengef1d9fe2016-03-09 10:37:04 +0800888 rockchip_clk_add_lookup(ctx, clk, PCLK_WDT);
Heiko Stuebner3536c972015-07-05 11:00:20 +0200889
Xing Zhengef1d9fe2016-03-09 10:37:04 +0800890 rockchip_clk_register_plls(ctx, rk3368_pll_clks,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200891 ARRAY_SIZE(rk3368_pll_clks),
892 RK3368_GRF_SOC_STATUS0);
Xing Zhengef1d9fe2016-03-09 10:37:04 +0800893 rockchip_clk_register_branches(ctx, rk3368_clk_branches,
Heiko Stuebner3536c972015-07-05 11:00:20 +0200894 ARRAY_SIZE(rk3368_clk_branches));
Heiko Stübner380528f2015-09-13 13:20:36 +0200895 rockchip_clk_protect_critical(rk3368_critical_clocks,
896 ARRAY_SIZE(rk3368_critical_clocks));
Heiko Stuebner3536c972015-07-05 11:00:20 +0200897
Xing Zhengef1d9fe2016-03-09 10:37:04 +0800898 rockchip_clk_register_armclk(ctx, ARMCLKB, "armclkb",
Heiko Stuebner3536c972015-07-05 11:00:20 +0200899 mux_armclkb_p, ARRAY_SIZE(mux_armclkb_p),
900 &rk3368_cpuclkb_data, rk3368_cpuclkb_rates,
901 ARRAY_SIZE(rk3368_cpuclkb_rates));
902
Xing Zhengef1d9fe2016-03-09 10:37:04 +0800903 rockchip_clk_register_armclk(ctx, ARMCLKL, "armclkl",
Heiko Stuebner3536c972015-07-05 11:00:20 +0200904 mux_armclkl_p, ARRAY_SIZE(mux_armclkl_p),
905 &rk3368_cpuclkl_data, rk3368_cpuclkl_rates,
906 ARRAY_SIZE(rk3368_cpuclkl_rates));
907
908 rockchip_register_softrst(np, 15, reg_base + RK3368_SOFTRST_CON(0),
909 ROCKCHIP_SOFTRST_HIWORD_MASK);
910
Xing Zhengef1d9fe2016-03-09 10:37:04 +0800911 rockchip_register_restart_notifier(ctx, RK3368_GLB_SRST_FST, NULL);
912
913 rockchip_clk_of_add_provider(np, ctx);
Heiko Stuebner3536c972015-07-05 11:00:20 +0200914}
915CLK_OF_DECLARE(rk3368_cru, "rockchip,rk3368-cru", rk3368_clk_init);