blob: abb6c5ac8a10297505a8a7f1cb1cb0d5f8eccf16 [file] [log] [blame]
Emilio Lópeze874a662013-02-25 11:44:26 -03001/*
2 * Copyright 2013 Emilio López
3 *
4 * Emilio López <emilio@elopez.com.ar>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/clk-provider.h>
18#include <linux/clkdev.h>
Emilio Lópeze874a662013-02-25 11:44:26 -030019#include <linux/of.h>
20#include <linux/of_address.h>
21
22#include "clk-factors.h"
23
24static DEFINE_SPINLOCK(clk_lock);
25
Emilio López40a5dcb2013-12-23 00:32:32 -030026/* Maximum number of parents our clocks have */
27#define SUNXI_MAX_PARENTS 5
28
Emilio Lópeze874a662013-02-25 11:44:26 -030029/**
Maxime Ripard81ba6c52013-07-22 18:21:32 +020030 * sun4i_osc_clk_setup() - Setup function for gatable oscillator
Emilio Lópeze874a662013-02-25 11:44:26 -030031 */
32
33#define SUNXI_OSC24M_GATE 0
34
Maxime Ripard81ba6c52013-07-22 18:21:32 +020035static void __init sun4i_osc_clk_setup(struct device_node *node)
Emilio Lópeze874a662013-02-25 11:44:26 -030036{
37 struct clk *clk;
Emilio López38e4aa02013-04-10 15:02:57 -070038 struct clk_fixed_rate *fixed;
39 struct clk_gate *gate;
Emilio Lópeze874a662013-02-25 11:44:26 -030040 const char *clk_name = node->name;
Emilio López38e4aa02013-04-10 15:02:57 -070041 u32 rate;
Emilio Lópeze874a662013-02-25 11:44:26 -030042
Victor N. Ramos Melloe71c69f2013-10-18 20:27:51 -030043 if (of_property_read_u32(node, "clock-frequency", &rate))
44 return;
45
Emilio López38e4aa02013-04-10 15:02:57 -070046 /* allocate fixed-rate and gate clock structs */
47 fixed = kzalloc(sizeof(struct clk_fixed_rate), GFP_KERNEL);
48 if (!fixed)
49 return;
50 gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
Victor N. Ramos Melloe71c69f2013-10-18 20:27:51 -030051 if (!gate)
52 goto err_free_fixed;
Emilio Lópeze874a662013-02-25 11:44:26 -030053
Emilio López38e4aa02013-04-10 15:02:57 -070054 /* set up gate and fixed rate properties */
55 gate->reg = of_iomap(node, 0);
56 gate->bit_idx = SUNXI_OSC24M_GATE;
57 gate->lock = &clk_lock;
58 fixed->fixed_rate = rate;
59
60 clk = clk_register_composite(NULL, clk_name,
61 NULL, 0,
62 NULL, NULL,
63 &fixed->hw, &clk_fixed_rate_ops,
64 &gate->hw, &clk_gate_ops,
65 CLK_IS_ROOT);
Emilio Lópeze874a662013-02-25 11:44:26 -030066
Victor N. Ramos Melloe71c69f2013-10-18 20:27:51 -030067 if (IS_ERR(clk))
68 goto err_free_gate;
69
70 of_clk_add_provider(node, of_clk_src_simple_get, clk);
71 clk_register_clkdev(clk, clk_name, NULL);
72
73 return;
74
75err_free_gate:
76 kfree(gate);
77err_free_fixed:
78 kfree(fixed);
Emilio Lópeze874a662013-02-25 11:44:26 -030079}
Maxime Ripard81ba6c52013-07-22 18:21:32 +020080CLK_OF_DECLARE(sun4i_osc, "allwinner,sun4i-osc-clk", sun4i_osc_clk_setup);
Emilio Lópeze874a662013-02-25 11:44:26 -030081
82
83
84/**
Maxime Ripard81ba6c52013-07-22 18:21:32 +020085 * sun4i_get_pll1_factors() - calculates n, k, m, p factors for PLL1
Emilio Lópeze874a662013-02-25 11:44:26 -030086 * PLL1 rate is calculated as follows
87 * rate = (parent_rate * n * (k + 1) >> p) / (m + 1);
88 * parent_rate is always 24Mhz
89 */
90
Maxime Ripard81ba6c52013-07-22 18:21:32 +020091static void sun4i_get_pll1_factors(u32 *freq, u32 parent_rate,
Emilio Lópeze874a662013-02-25 11:44:26 -030092 u8 *n, u8 *k, u8 *m, u8 *p)
93{
94 u8 div;
95
96 /* Normalize value to a 6M multiple */
97 div = *freq / 6000000;
98 *freq = 6000000 * div;
99
100 /* we were called to round the frequency, we can now return */
101 if (n == NULL)
102 return;
103
104 /* m is always zero for pll1 */
105 *m = 0;
106
107 /* k is 1 only on these cases */
108 if (*freq >= 768000000 || *freq == 42000000 || *freq == 54000000)
109 *k = 1;
110 else
111 *k = 0;
112
113 /* p will be 3 for divs under 10 */
114 if (div < 10)
115 *p = 3;
116
117 /* p will be 2 for divs between 10 - 20 and odd divs under 32 */
118 else if (div < 20 || (div < 32 && (div & 1)))
119 *p = 2;
120
121 /* p will be 1 for even divs under 32, divs under 40 and odd pairs
122 * of divs between 40-62 */
123 else if (div < 40 || (div < 64 && (div & 2)))
124 *p = 1;
125
126 /* any other entries have p = 0 */
127 else
128 *p = 0;
129
130 /* calculate a suitable n based on k and p */
131 div <<= *p;
132 div /= (*k + 1);
133 *n = div / 4;
134}
135
Maxime Ripard6a721db2013-07-23 23:34:10 +0200136/**
137 * sun6i_a31_get_pll1_factors() - calculates n, k and m factors for PLL1
138 * PLL1 rate is calculated as follows
139 * rate = parent_rate * (n + 1) * (k + 1) / (m + 1);
140 * parent_rate should always be 24MHz
141 */
142static void sun6i_a31_get_pll1_factors(u32 *freq, u32 parent_rate,
143 u8 *n, u8 *k, u8 *m, u8 *p)
144{
145 /*
146 * We can operate only on MHz, this will make our life easier
147 * later.
148 */
149 u32 freq_mhz = *freq / 1000000;
150 u32 parent_freq_mhz = parent_rate / 1000000;
Emilio Lópeze874a662013-02-25 11:44:26 -0300151
Maxime Ripard6a721db2013-07-23 23:34:10 +0200152 /*
153 * Round down the frequency to the closest multiple of either
154 * 6 or 16
155 */
156 u32 round_freq_6 = round_down(freq_mhz, 6);
157 u32 round_freq_16 = round_down(freq_mhz, 16);
158
159 if (round_freq_6 > round_freq_16)
160 freq_mhz = round_freq_6;
161 else
162 freq_mhz = round_freq_16;
163
164 *freq = freq_mhz * 1000000;
165
166 /*
167 * If the factors pointer are null, we were just called to
168 * round down the frequency.
169 * Exit.
170 */
171 if (n == NULL)
172 return;
173
174 /* If the frequency is a multiple of 32 MHz, k is always 3 */
175 if (!(freq_mhz % 32))
176 *k = 3;
177 /* If the frequency is a multiple of 9 MHz, k is always 2 */
178 else if (!(freq_mhz % 9))
179 *k = 2;
180 /* If the frequency is a multiple of 8 MHz, k is always 1 */
181 else if (!(freq_mhz % 8))
182 *k = 1;
183 /* Otherwise, we don't use the k factor */
184 else
185 *k = 0;
186
187 /*
188 * If the frequency is a multiple of 2 but not a multiple of
189 * 3, m is 3. This is the first time we use 6 here, yet we
190 * will use it on several other places.
191 * We use this number because it's the lowest frequency we can
192 * generate (with n = 0, k = 0, m = 3), so every other frequency
193 * somehow relates to this frequency.
194 */
195 if ((freq_mhz % 6) == 2 || (freq_mhz % 6) == 4)
196 *m = 2;
197 /*
198 * If the frequency is a multiple of 6MHz, but the factor is
199 * odd, m will be 3
200 */
201 else if ((freq_mhz / 6) & 1)
202 *m = 3;
203 /* Otherwise, we end up with m = 1 */
204 else
205 *m = 1;
206
207 /* Calculate n thanks to the above factors we already got */
208 *n = freq_mhz * (*m + 1) / ((*k + 1) * parent_freq_mhz) - 1;
209
210 /*
211 * If n end up being outbound, and that we can still decrease
212 * m, do it.
213 */
214 if ((*n + 1) > 31 && (*m + 1) > 1) {
215 *n = (*n + 1) / 2 - 1;
216 *m = (*m + 1) / 2 - 1;
217 }
218}
Emilio Lópeze874a662013-02-25 11:44:26 -0300219
220/**
Emilio Lópezd584c132013-12-23 00:32:37 -0300221 * sun4i_get_pll5_factors() - calculates n, k factors for PLL5
222 * PLL5 rate is calculated as follows
223 * rate = parent_rate * n * (k + 1)
224 * parent_rate is always 24Mhz
225 */
226
227static void sun4i_get_pll5_factors(u32 *freq, u32 parent_rate,
228 u8 *n, u8 *k, u8 *m, u8 *p)
229{
230 u8 div;
231
232 /* Normalize value to a parent_rate multiple (24M) */
233 div = *freq / parent_rate;
234 *freq = parent_rate * div;
235
236 /* we were called to round the frequency, we can now return */
237 if (n == NULL)
238 return;
239
240 if (div < 31)
241 *k = 0;
242 else if (div / 2 < 31)
243 *k = 1;
244 else if (div / 3 < 31)
245 *k = 2;
246 else
247 *k = 3;
248
249 *n = DIV_ROUND_UP(div, (*k+1));
250}
251
252
253
254/**
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200255 * sun4i_get_apb1_factors() - calculates m, p factors for APB1
Emilio Lópeze874a662013-02-25 11:44:26 -0300256 * APB1 rate is calculated as follows
257 * rate = (parent_rate >> p) / (m + 1);
258 */
259
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200260static void sun4i_get_apb1_factors(u32 *freq, u32 parent_rate,
Emilio Lópeze874a662013-02-25 11:44:26 -0300261 u8 *n, u8 *k, u8 *m, u8 *p)
262{
263 u8 calcm, calcp;
264
265 if (parent_rate < *freq)
266 *freq = parent_rate;
267
268 parent_rate = (parent_rate + (*freq - 1)) / *freq;
269
270 /* Invalid rate! */
271 if (parent_rate > 32)
272 return;
273
274 if (parent_rate <= 4)
275 calcp = 0;
276 else if (parent_rate <= 8)
277 calcp = 1;
278 else if (parent_rate <= 16)
279 calcp = 2;
280 else
281 calcp = 3;
282
283 calcm = (parent_rate >> calcp) - 1;
284
285 *freq = (parent_rate >> calcp) / (calcm + 1);
286
287 /* we were called to round the frequency, we can now return */
288 if (n == NULL)
289 return;
290
291 *m = calcm;
292 *p = calcp;
293}
294
295
296
297/**
Emilio López75517692013-12-23 00:32:39 -0300298 * sun4i_get_mod0_factors() - calculates m, n factors for MOD0-style clocks
299 * MMC rate is calculated as follows
300 * rate = (parent_rate >> p) / (m + 1);
301 */
302
303static void sun4i_get_mod0_factors(u32 *freq, u32 parent_rate,
304 u8 *n, u8 *k, u8 *m, u8 *p)
305{
306 u8 div, calcm, calcp;
307
308 /* These clocks can only divide, so we will never be able to achieve
309 * frequencies higher than the parent frequency */
310 if (*freq > parent_rate)
311 *freq = parent_rate;
312
313 div = parent_rate / *freq;
314
315 if (div < 16)
316 calcp = 0;
317 else if (div / 2 < 16)
318 calcp = 1;
319 else if (div / 4 < 16)
320 calcp = 2;
321 else
322 calcp = 3;
323
324 calcm = DIV_ROUND_UP(div, 1 << calcp);
325
326 *freq = (parent_rate >> calcp) / calcm;
327
328 /* we were called to round the frequency, we can now return */
329 if (n == NULL)
330 return;
331
332 *m = calcm - 1;
333 *p = calcp;
334}
335
336
337
338/**
Chen-Yu Tsai6f863412013-12-24 21:26:17 +0800339 * sun7i_a20_get_out_factors() - calculates m, p factors for CLK_OUT_A/B
340 * CLK_OUT rate is calculated as follows
341 * rate = (parent_rate >> p) / (m + 1);
342 */
343
344static void sun7i_a20_get_out_factors(u32 *freq, u32 parent_rate,
345 u8 *n, u8 *k, u8 *m, u8 *p)
346{
347 u8 div, calcm, calcp;
348
349 /* These clocks can only divide, so we will never be able to achieve
350 * frequencies higher than the parent frequency */
351 if (*freq > parent_rate)
352 *freq = parent_rate;
353
354 div = parent_rate / *freq;
355
356 if (div < 32)
357 calcp = 0;
358 else if (div / 2 < 32)
359 calcp = 1;
360 else if (div / 4 < 32)
361 calcp = 2;
362 else
363 calcp = 3;
364
365 calcm = DIV_ROUND_UP(div, 1 << calcp);
366
367 *freq = (parent_rate >> calcp) / calcm;
368
369 /* we were called to round the frequency, we can now return */
370 if (n == NULL)
371 return;
372
373 *m = calcm - 1;
374 *p = calcp;
375}
376
377
378
379/**
Emilio Lópeze874a662013-02-25 11:44:26 -0300380 * sunxi_factors_clk_setup() - Setup function for factor clocks
381 */
382
Emilio López40a5dcb2013-12-23 00:32:32 -0300383#define SUNXI_FACTORS_MUX_MASK 0x3
384
Emilio Lópeze874a662013-02-25 11:44:26 -0300385struct factors_data {
Emilio López40a5dcb2013-12-23 00:32:32 -0300386 int enable;
387 int mux;
Emilio Lópeze874a662013-02-25 11:44:26 -0300388 struct clk_factors_config *table;
389 void (*getter) (u32 *rate, u32 parent_rate, u8 *n, u8 *k, u8 *m, u8 *p);
390};
391
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200392static struct clk_factors_config sun4i_pll1_config = {
Emilio Lópeze874a662013-02-25 11:44:26 -0300393 .nshift = 8,
394 .nwidth = 5,
395 .kshift = 4,
396 .kwidth = 2,
397 .mshift = 0,
398 .mwidth = 2,
399 .pshift = 16,
400 .pwidth = 2,
401};
402
Maxime Ripard6a721db2013-07-23 23:34:10 +0200403static struct clk_factors_config sun6i_a31_pll1_config = {
404 .nshift = 8,
405 .nwidth = 5,
406 .kshift = 4,
407 .kwidth = 2,
408 .mshift = 0,
409 .mwidth = 2,
410};
411
Emilio Lópezd584c132013-12-23 00:32:37 -0300412static struct clk_factors_config sun4i_pll5_config = {
413 .nshift = 8,
414 .nwidth = 5,
415 .kshift = 4,
416 .kwidth = 2,
417};
418
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200419static struct clk_factors_config sun4i_apb1_config = {
Emilio Lópeze874a662013-02-25 11:44:26 -0300420 .mshift = 0,
421 .mwidth = 5,
422 .pshift = 16,
423 .pwidth = 2,
424};
425
Emilio López75517692013-12-23 00:32:39 -0300426/* user manual says "n" but it's really "p" */
427static struct clk_factors_config sun4i_mod0_config = {
428 .mshift = 0,
429 .mwidth = 4,
430 .pshift = 16,
431 .pwidth = 2,
432};
433
Chen-Yu Tsai6f863412013-12-24 21:26:17 +0800434/* user manual says "n" but it's really "p" */
435static struct clk_factors_config sun7i_a20_out_config = {
436 .mshift = 8,
437 .mwidth = 5,
438 .pshift = 20,
439 .pwidth = 2,
440};
441
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530442static const struct factors_data sun4i_pll1_data __initconst = {
Emilio Lópezd838ff32013-12-23 00:32:34 -0300443 .enable = 31,
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200444 .table = &sun4i_pll1_config,
445 .getter = sun4i_get_pll1_factors,
Emilio Lópeze874a662013-02-25 11:44:26 -0300446};
447
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530448static const struct factors_data sun6i_a31_pll1_data __initconst = {
Emilio Lópezd838ff32013-12-23 00:32:34 -0300449 .enable = 31,
Maxime Ripard6a721db2013-07-23 23:34:10 +0200450 .table = &sun6i_a31_pll1_config,
451 .getter = sun6i_a31_get_pll1_factors,
452};
453
Emilio Lópezd584c132013-12-23 00:32:37 -0300454static const struct factors_data sun4i_pll5_data __initconst = {
455 .enable = 31,
456 .table = &sun4i_pll5_config,
457 .getter = sun4i_get_pll5_factors,
458};
459
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530460static const struct factors_data sun4i_apb1_data __initconst = {
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200461 .table = &sun4i_apb1_config,
462 .getter = sun4i_get_apb1_factors,
Emilio Lópeze874a662013-02-25 11:44:26 -0300463};
464
Emilio López75517692013-12-23 00:32:39 -0300465static const struct factors_data sun4i_mod0_data __initconst = {
466 .enable = 31,
467 .mux = 24,
468 .table = &sun4i_mod0_config,
469 .getter = sun4i_get_mod0_factors,
470};
471
Chen-Yu Tsai6f863412013-12-24 21:26:17 +0800472static const struct factors_data sun7i_a20_out_data __initconst = {
473 .enable = 31,
474 .mux = 24,
475 .table = &sun7i_a20_out_config,
476 .getter = sun7i_a20_get_out_factors,
477};
478
Emilio López5f4e0be2013-12-23 00:32:36 -0300479static struct clk * __init sunxi_factors_clk_setup(struct device_node *node,
480 const struct factors_data *data)
Emilio Lópeze874a662013-02-25 11:44:26 -0300481{
482 struct clk *clk;
Emilio López40a5dcb2013-12-23 00:32:32 -0300483 struct clk_factors *factors;
484 struct clk_gate *gate = NULL;
485 struct clk_mux *mux = NULL;
486 struct clk_hw *gate_hw = NULL;
487 struct clk_hw *mux_hw = NULL;
Emilio Lópeze874a662013-02-25 11:44:26 -0300488 const char *clk_name = node->name;
Emilio López40a5dcb2013-12-23 00:32:32 -0300489 const char *parents[SUNXI_MAX_PARENTS];
Emilio Lópeze874a662013-02-25 11:44:26 -0300490 void *reg;
Emilio López40a5dcb2013-12-23 00:32:32 -0300491 int i = 0;
Emilio Lópeze874a662013-02-25 11:44:26 -0300492
493 reg = of_iomap(node, 0);
494
Emilio López40a5dcb2013-12-23 00:32:32 -0300495 /* if we have a mux, we will have >1 parents */
496 while (i < SUNXI_MAX_PARENTS &&
497 (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
498 i++;
Emilio Lópeze874a662013-02-25 11:44:26 -0300499
Emilio López76192dc2013-12-23 00:32:40 -0300500 /* Nodes should be providing the name via clock-output-names
501 * but originally our dts didn't, and so we used node->name.
502 * The new, better nodes look like clk@deadbeef, so we pull the
503 * name just in this case */
504 if (!strcmp("clk", clk_name)) {
505 of_property_read_string_index(node, "clock-output-names",
506 0, &clk_name);
507 }
508
Emilio López40a5dcb2013-12-23 00:32:32 -0300509 factors = kzalloc(sizeof(struct clk_factors), GFP_KERNEL);
510 if (!factors)
Emilio López5f4e0be2013-12-23 00:32:36 -0300511 return NULL;
Emilio López40a5dcb2013-12-23 00:32:32 -0300512
513 /* Add a gate if this factor clock can be gated */
514 if (data->enable) {
515 gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
516 if (!gate) {
517 kfree(factors);
Emilio López5f4e0be2013-12-23 00:32:36 -0300518 return NULL;
Emilio López40a5dcb2013-12-23 00:32:32 -0300519 }
520
521 /* set up gate properties */
522 gate->reg = reg;
523 gate->bit_idx = data->enable;
524 gate->lock = &clk_lock;
525 gate_hw = &gate->hw;
526 }
527
528 /* Add a mux if this factor clock can be muxed */
529 if (data->mux) {
530 mux = kzalloc(sizeof(struct clk_mux), GFP_KERNEL);
531 if (!mux) {
532 kfree(factors);
533 kfree(gate);
Emilio López5f4e0be2013-12-23 00:32:36 -0300534 return NULL;
Emilio López40a5dcb2013-12-23 00:32:32 -0300535 }
536
537 /* set up gate properties */
538 mux->reg = reg;
539 mux->shift = data->mux;
540 mux->mask = SUNXI_FACTORS_MUX_MASK;
541 mux->lock = &clk_lock;
542 mux_hw = &mux->hw;
543 }
544
545 /* set up factors properties */
546 factors->reg = reg;
547 factors->config = data->table;
548 factors->get_factors = data->getter;
549 factors->lock = &clk_lock;
550
551 clk = clk_register_composite(NULL, clk_name,
552 parents, i,
553 mux_hw, &clk_mux_ops,
554 &factors->hw, &clk_factors_ops,
Emilio López5f4e0be2013-12-23 00:32:36 -0300555 gate_hw, &clk_gate_ops, 0);
Emilio Lópeze874a662013-02-25 11:44:26 -0300556
Axel Linee85e9b2013-07-12 16:15:15 +0800557 if (!IS_ERR(clk)) {
Emilio Lópeze874a662013-02-25 11:44:26 -0300558 of_clk_add_provider(node, of_clk_src_simple_get, clk);
559 clk_register_clkdev(clk, clk_name, NULL);
560 }
Emilio López5f4e0be2013-12-23 00:32:36 -0300561
562 return clk;
Emilio Lópeze874a662013-02-25 11:44:26 -0300563}
564
565
566
567/**
568 * sunxi_mux_clk_setup() - Setup function for muxes
569 */
570
571#define SUNXI_MUX_GATE_WIDTH 2
572
573struct mux_data {
574 u8 shift;
575};
576
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530577static const struct mux_data sun4i_cpu_mux_data __initconst = {
Emilio Lópeze874a662013-02-25 11:44:26 -0300578 .shift = 16,
579};
580
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530581static const struct mux_data sun6i_a31_ahb1_mux_data __initconst = {
Maxime Ripard6a721db2013-07-23 23:34:10 +0200582 .shift = 12,
583};
584
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530585static const struct mux_data sun4i_apb1_mux_data __initconst = {
Emilio Lópeze874a662013-02-25 11:44:26 -0300586 .shift = 24,
587};
588
589static void __init sunxi_mux_clk_setup(struct device_node *node,
590 struct mux_data *data)
591{
592 struct clk *clk;
593 const char *clk_name = node->name;
Emilio Lópezedaf3fb2013-12-23 00:32:33 -0300594 const char *parents[SUNXI_MAX_PARENTS];
Emilio Lópeze874a662013-02-25 11:44:26 -0300595 void *reg;
596 int i = 0;
597
598 reg = of_iomap(node, 0);
599
Emilio Lópezedaf3fb2013-12-23 00:32:33 -0300600 while (i < SUNXI_MAX_PARENTS &&
601 (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
Emilio Lópeze874a662013-02-25 11:44:26 -0300602 i++;
603
James Hogan819c1de2013-07-29 12:25:01 +0100604 clk = clk_register_mux(NULL, clk_name, parents, i,
605 CLK_SET_RATE_NO_REPARENT, reg,
Emilio Lópeze874a662013-02-25 11:44:26 -0300606 data->shift, SUNXI_MUX_GATE_WIDTH,
607 0, &clk_lock);
608
609 if (clk) {
610 of_clk_add_provider(node, of_clk_src_simple_get, clk);
611 clk_register_clkdev(clk, clk_name, NULL);
612 }
613}
614
615
616
617/**
618 * sunxi_divider_clk_setup() - Setup function for simple divider clocks
619 */
620
Emilio Lópeze874a662013-02-25 11:44:26 -0300621struct div_data {
Maxime Ripard70855bb2013-07-23 09:25:56 +0200622 u8 shift;
623 u8 pow;
624 u8 width;
Emilio Lópeze874a662013-02-25 11:44:26 -0300625};
626
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530627static const struct div_data sun4i_axi_data __initconst = {
Maxime Ripard70855bb2013-07-23 09:25:56 +0200628 .shift = 0,
629 .pow = 0,
630 .width = 2,
Emilio Lópeze874a662013-02-25 11:44:26 -0300631};
632
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530633static const struct div_data sun4i_ahb_data __initconst = {
Maxime Ripard70855bb2013-07-23 09:25:56 +0200634 .shift = 4,
635 .pow = 1,
636 .width = 2,
Emilio Lópeze874a662013-02-25 11:44:26 -0300637};
638
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530639static const struct div_data sun4i_apb0_data __initconst = {
Maxime Ripard70855bb2013-07-23 09:25:56 +0200640 .shift = 8,
641 .pow = 1,
642 .width = 2,
Emilio Lópeze874a662013-02-25 11:44:26 -0300643};
644
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530645static const struct div_data sun6i_a31_apb2_div_data __initconst = {
Maxime Ripard6a721db2013-07-23 23:34:10 +0200646 .shift = 0,
647 .pow = 0,
648 .width = 4,
649};
650
Emilio Lópeze874a662013-02-25 11:44:26 -0300651static void __init sunxi_divider_clk_setup(struct device_node *node,
652 struct div_data *data)
653{
654 struct clk *clk;
655 const char *clk_name = node->name;
656 const char *clk_parent;
657 void *reg;
658
659 reg = of_iomap(node, 0);
660
661 clk_parent = of_clk_get_parent_name(node, 0);
662
663 clk = clk_register_divider(NULL, clk_name, clk_parent, 0,
Maxime Ripard70855bb2013-07-23 09:25:56 +0200664 reg, data->shift, data->width,
Emilio Lópeze874a662013-02-25 11:44:26 -0300665 data->pow ? CLK_DIVIDER_POWER_OF_TWO : 0,
666 &clk_lock);
667 if (clk) {
668 of_clk_add_provider(node, of_clk_src_simple_get, clk);
669 clk_register_clkdev(clk, clk_name, NULL);
670 }
671}
672
673
Emilio López13569a72013-03-27 18:20:37 -0300674
675/**
676 * sunxi_gates_clk_setup() - Setup function for leaf gates on clocks
677 */
678
679#define SUNXI_GATES_MAX_SIZE 64
680
681struct gates_data {
682 DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE);
683};
684
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530685static const struct gates_data sun4i_axi_gates_data __initconst = {
Emilio López13569a72013-03-27 18:20:37 -0300686 .mask = {1},
687};
688
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530689static const struct gates_data sun4i_ahb_gates_data __initconst = {
Emilio López13569a72013-03-27 18:20:37 -0300690 .mask = {0x7F77FFF, 0x14FB3F},
691};
692
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530693static const struct gates_data sun5i_a10s_ahb_gates_data __initconst = {
Maxime Ripard2371dd82013-07-16 11:21:59 +0200694 .mask = {0x147667e7, 0x185915},
695};
696
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530697static const struct gates_data sun5i_a13_ahb_gates_data __initconst = {
Maxime Ripard4f985b42013-04-30 11:56:22 +0200698 .mask = {0x107067e7, 0x185111},
699};
700
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530701static const struct gates_data sun6i_a31_ahb1_gates_data __initconst = {
Maxime Ripard6a721db2013-07-23 23:34:10 +0200702 .mask = {0xEDFE7F62, 0x794F931},
703};
704
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530705static const struct gates_data sun7i_a20_ahb_gates_data __initconst = {
Maxime Ripard1fb2e4a2013-07-25 21:06:56 +0200706 .mask = { 0x12f77fff, 0x16ff3f },
707};
708
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530709static const struct gates_data sun4i_apb0_gates_data __initconst = {
Emilio López13569a72013-03-27 18:20:37 -0300710 .mask = {0x4EF},
711};
712
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530713static const struct gates_data sun5i_a10s_apb0_gates_data __initconst = {
Maxime Ripard2371dd82013-07-16 11:21:59 +0200714 .mask = {0x469},
715};
716
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530717static const struct gates_data sun5i_a13_apb0_gates_data __initconst = {
Maxime Ripard4f985b42013-04-30 11:56:22 +0200718 .mask = {0x61},
719};
720
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530721static const struct gates_data sun7i_a20_apb0_gates_data __initconst = {
Maxime Ripard1fb2e4a2013-07-25 21:06:56 +0200722 .mask = { 0x4ff },
723};
724
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530725static const struct gates_data sun4i_apb1_gates_data __initconst = {
Emilio López13569a72013-03-27 18:20:37 -0300726 .mask = {0xFF00F7},
727};
728
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530729static const struct gates_data sun5i_a10s_apb1_gates_data __initconst = {
Maxime Ripard2371dd82013-07-16 11:21:59 +0200730 .mask = {0xf0007},
731};
732
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530733static const struct gates_data sun5i_a13_apb1_gates_data __initconst = {
Maxime Ripard4f985b42013-04-30 11:56:22 +0200734 .mask = {0xa0007},
735};
736
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530737static const struct gates_data sun6i_a31_apb1_gates_data __initconst = {
Maxime Ripard6a721db2013-07-23 23:34:10 +0200738 .mask = {0x3031},
739};
740
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530741static const struct gates_data sun6i_a31_apb2_gates_data __initconst = {
Maxime Ripard6a721db2013-07-23 23:34:10 +0200742 .mask = {0x3F000F},
743};
744
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530745static const struct gates_data sun7i_a20_apb1_gates_data __initconst = {
Maxime Ripard1fb2e4a2013-07-25 21:06:56 +0200746 .mask = { 0xff80ff },
747};
748
Emilio López13569a72013-03-27 18:20:37 -0300749static void __init sunxi_gates_clk_setup(struct device_node *node,
750 struct gates_data *data)
751{
752 struct clk_onecell_data *clk_data;
753 const char *clk_parent;
754 const char *clk_name;
755 void *reg;
756 int qty;
757 int i = 0;
758 int j = 0;
759 int ignore;
760
761 reg = of_iomap(node, 0);
762
763 clk_parent = of_clk_get_parent_name(node, 0);
764
765 /* Worst-case size approximation and memory allocation */
766 qty = find_last_bit(data->mask, SUNXI_GATES_MAX_SIZE);
767 clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
768 if (!clk_data)
769 return;
770 clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL);
771 if (!clk_data->clks) {
772 kfree(clk_data);
773 return;
774 }
775
776 for_each_set_bit(i, data->mask, SUNXI_GATES_MAX_SIZE) {
777 of_property_read_string_index(node, "clock-output-names",
778 j, &clk_name);
779
780 /* No driver claims this clock, but it should remain gated */
781 ignore = !strcmp("ahb_sdram", clk_name) ? CLK_IGNORE_UNUSED : 0;
782
783 clk_data->clks[i] = clk_register_gate(NULL, clk_name,
784 clk_parent, ignore,
785 reg + 4 * (i/32), i % 32,
786 0, &clk_lock);
787 WARN_ON(IS_ERR(clk_data->clks[i]));
788
789 j++;
790 }
791
792 /* Adjust to the real max */
793 clk_data->clk_num = i;
794
795 of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
796}
797
Emilio Lópezd584c132013-12-23 00:32:37 -0300798
799
800/**
801 * sunxi_divs_clk_setup() helper data
802 */
803
804#define SUNXI_DIVS_MAX_QTY 2
805#define SUNXI_DIVISOR_WIDTH 2
806
807struct divs_data {
808 const struct factors_data *factors; /* data for the factor clock */
809 struct {
810 u8 fixed; /* is it a fixed divisor? if not... */
811 struct clk_div_table *table; /* is it a table based divisor? */
812 u8 shift; /* otherwise it's a normal divisor with this shift */
813 u8 pow; /* is it power-of-two based? */
814 u8 gate; /* is it independently gateable? */
815 } div[SUNXI_DIVS_MAX_QTY];
816};
817
818static struct clk_div_table pll6_sata_tbl[] = {
819 { .val = 0, .div = 6, },
820 { .val = 1, .div = 12, },
821 { .val = 2, .div = 18, },
822 { .val = 3, .div = 24, },
823 { } /* sentinel */
824};
825
826static const struct divs_data pll5_divs_data __initconst = {
827 .factors = &sun4i_pll5_data,
828 .div = {
829 { .shift = 0, .pow = 0, }, /* M, DDR */
830 { .shift = 16, .pow = 1, }, /* P, other */
831 }
832};
833
834static const struct divs_data pll6_divs_data __initconst = {
835 .factors = &sun4i_pll5_data,
836 .div = {
837 { .shift = 0, .table = pll6_sata_tbl, .gate = 14 }, /* M, SATA */
838 { .fixed = 2 }, /* P, other */
839 }
840};
841
842/**
843 * sunxi_divs_clk_setup() - Setup function for leaf divisors on clocks
844 *
845 * These clocks look something like this
846 * ________________________
847 * | ___divisor 1---|----> to consumer
848 * parent >--| pll___/___divisor 2---|----> to consumer
849 * | \_______________|____> to consumer
850 * |________________________|
851 */
852
853static void __init sunxi_divs_clk_setup(struct device_node *node,
854 struct divs_data *data)
855{
856 struct clk_onecell_data *clk_data;
857 const char *parent = node->name;
858 const char *clk_name;
859 struct clk **clks, *pclk;
860 struct clk_hw *gate_hw, *rate_hw;
861 const struct clk_ops *rate_ops;
862 struct clk_gate *gate = NULL;
863 struct clk_fixed_factor *fix_factor;
864 struct clk_divider *divider;
865 void *reg;
866 int i = 0;
867 int flags, clkflags;
868
869 /* Set up factor clock that we will be dividing */
870 pclk = sunxi_factors_clk_setup(node, data->factors);
871
872 reg = of_iomap(node, 0);
873
874 clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
875 if (!clk_data)
876 return;
877
Emilio Lópezd1933682014-01-24 22:32:41 -0300878 clks = kzalloc((SUNXI_DIVS_MAX_QTY+1) * sizeof(*clks), GFP_KERNEL);
Emilio Lópezd584c132013-12-23 00:32:37 -0300879 if (!clks)
880 goto free_clkdata;
881
882 clk_data->clks = clks;
883
884 /* It's not a good idea to have automatic reparenting changing
885 * our RAM clock! */
886 clkflags = !strcmp("pll5", parent) ? 0 : CLK_SET_RATE_PARENT;
887
888 for (i = 0; i < SUNXI_DIVS_MAX_QTY; i++) {
889 if (of_property_read_string_index(node, "clock-output-names",
890 i, &clk_name) != 0)
891 break;
892
893 gate_hw = NULL;
894 rate_hw = NULL;
895 rate_ops = NULL;
896
897 /* If this leaf clock can be gated, create a gate */
898 if (data->div[i].gate) {
899 gate = kzalloc(sizeof(*gate), GFP_KERNEL);
900 if (!gate)
901 goto free_clks;
902
903 gate->reg = reg;
904 gate->bit_idx = data->div[i].gate;
905 gate->lock = &clk_lock;
906
907 gate_hw = &gate->hw;
908 }
909
910 /* Leaves can be fixed or configurable divisors */
911 if (data->div[i].fixed) {
912 fix_factor = kzalloc(sizeof(*fix_factor), GFP_KERNEL);
913 if (!fix_factor)
914 goto free_gate;
915
916 fix_factor->mult = 1;
917 fix_factor->div = data->div[i].fixed;
918
919 rate_hw = &fix_factor->hw;
920 rate_ops = &clk_fixed_factor_ops;
921 } else {
922 divider = kzalloc(sizeof(*divider), GFP_KERNEL);
923 if (!divider)
924 goto free_gate;
925
926 flags = data->div[i].pow ? CLK_DIVIDER_POWER_OF_TWO : 0;
927
928 divider->reg = reg;
929 divider->shift = data->div[i].shift;
930 divider->width = SUNXI_DIVISOR_WIDTH;
931 divider->flags = flags;
932 divider->lock = &clk_lock;
933 divider->table = data->div[i].table;
934
935 rate_hw = &divider->hw;
936 rate_ops = &clk_divider_ops;
937 }
938
939 /* Wrap the (potential) gate and the divisor on a composite
940 * clock to unify them */
941 clks[i] = clk_register_composite(NULL, clk_name, &parent, 1,
942 NULL, NULL,
943 rate_hw, rate_ops,
944 gate_hw, &clk_gate_ops,
945 clkflags);
946
947 WARN_ON(IS_ERR(clk_data->clks[i]));
948 clk_register_clkdev(clks[i], clk_name, NULL);
949 }
950
951 /* The last clock available on the getter is the parent */
952 clks[i++] = pclk;
953
954 /* Adjust to the real max */
955 clk_data->clk_num = i;
956
957 of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
958
959 return;
960
961free_gate:
962 kfree(gate);
963free_clks:
964 kfree(clks);
965free_clkdata:
966 kfree(clk_data);
967}
968
969
970
Emilio Lópeze874a662013-02-25 11:44:26 -0300971/* Matches for factors clocks */
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530972static const struct of_device_id clk_factors_match[] __initconst = {
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200973 {.compatible = "allwinner,sun4i-pll1-clk", .data = &sun4i_pll1_data,},
Maxime Ripard6a721db2013-07-23 23:34:10 +0200974 {.compatible = "allwinner,sun6i-a31-pll1-clk", .data = &sun6i_a31_pll1_data,},
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200975 {.compatible = "allwinner,sun4i-apb1-clk", .data = &sun4i_apb1_data,},
Emilio López75517692013-12-23 00:32:39 -0300976 {.compatible = "allwinner,sun4i-mod0-clk", .data = &sun4i_mod0_data,},
Chen-Yu Tsai6f863412013-12-24 21:26:17 +0800977 {.compatible = "allwinner,sun7i-a20-out-clk", .data = &sun7i_a20_out_data,},
Emilio Lópeze874a662013-02-25 11:44:26 -0300978 {}
979};
980
981/* Matches for divider clocks */
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530982static const struct of_device_id clk_div_match[] __initconst = {
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200983 {.compatible = "allwinner,sun4i-axi-clk", .data = &sun4i_axi_data,},
984 {.compatible = "allwinner,sun4i-ahb-clk", .data = &sun4i_ahb_data,},
985 {.compatible = "allwinner,sun4i-apb0-clk", .data = &sun4i_apb0_data,},
Maxime Ripard6a721db2013-07-23 23:34:10 +0200986 {.compatible = "allwinner,sun6i-a31-apb2-div-clk", .data = &sun6i_a31_apb2_div_data,},
Emilio Lópeze874a662013-02-25 11:44:26 -0300987 {}
988};
989
Emilio Lópezd584c132013-12-23 00:32:37 -0300990/* Matches for divided outputs */
991static const struct of_device_id clk_divs_match[] __initconst = {
992 {.compatible = "allwinner,sun4i-pll5-clk", .data = &pll5_divs_data,},
993 {.compatible = "allwinner,sun4i-pll6-clk", .data = &pll6_divs_data,},
994 {}
995};
996
Emilio Lópeze874a662013-02-25 11:44:26 -0300997/* Matches for mux clocks */
Sachin Kamat52be7cc2013-08-12 14:44:06 +0530998static const struct of_device_id clk_mux_match[] __initconst = {
Maxime Ripard81ba6c52013-07-22 18:21:32 +0200999 {.compatible = "allwinner,sun4i-cpu-clk", .data = &sun4i_cpu_mux_data,},
1000 {.compatible = "allwinner,sun4i-apb1-mux-clk", .data = &sun4i_apb1_mux_data,},
Maxime Ripard6a721db2013-07-23 23:34:10 +02001001 {.compatible = "allwinner,sun6i-a31-ahb1-mux-clk", .data = &sun6i_a31_ahb1_mux_data,},
Emilio Lópeze874a662013-02-25 11:44:26 -03001002 {}
1003};
1004
Emilio López13569a72013-03-27 18:20:37 -03001005/* Matches for gate clocks */
Sachin Kamat52be7cc2013-08-12 14:44:06 +05301006static const struct of_device_id clk_gates_match[] __initconst = {
Maxime Ripard4f985b42013-04-30 11:56:22 +02001007 {.compatible = "allwinner,sun4i-axi-gates-clk", .data = &sun4i_axi_gates_data,},
1008 {.compatible = "allwinner,sun4i-ahb-gates-clk", .data = &sun4i_ahb_gates_data,},
Maxime Ripard2371dd82013-07-16 11:21:59 +02001009 {.compatible = "allwinner,sun5i-a10s-ahb-gates-clk", .data = &sun5i_a10s_ahb_gates_data,},
Maxime Ripard4f985b42013-04-30 11:56:22 +02001010 {.compatible = "allwinner,sun5i-a13-ahb-gates-clk", .data = &sun5i_a13_ahb_gates_data,},
Maxime Ripard6a721db2013-07-23 23:34:10 +02001011 {.compatible = "allwinner,sun6i-a31-ahb1-gates-clk", .data = &sun6i_a31_ahb1_gates_data,},
Maxime Ripard1fb2e4a2013-07-25 21:06:56 +02001012 {.compatible = "allwinner,sun7i-a20-ahb-gates-clk", .data = &sun7i_a20_ahb_gates_data,},
Maxime Ripard4f985b42013-04-30 11:56:22 +02001013 {.compatible = "allwinner,sun4i-apb0-gates-clk", .data = &sun4i_apb0_gates_data,},
Maxime Ripard2371dd82013-07-16 11:21:59 +02001014 {.compatible = "allwinner,sun5i-a10s-apb0-gates-clk", .data = &sun5i_a10s_apb0_gates_data,},
Maxime Ripard4f985b42013-04-30 11:56:22 +02001015 {.compatible = "allwinner,sun5i-a13-apb0-gates-clk", .data = &sun5i_a13_apb0_gates_data,},
Maxime Ripard1fb2e4a2013-07-25 21:06:56 +02001016 {.compatible = "allwinner,sun7i-a20-apb0-gates-clk", .data = &sun7i_a20_apb0_gates_data,},
Maxime Ripard4f985b42013-04-30 11:56:22 +02001017 {.compatible = "allwinner,sun4i-apb1-gates-clk", .data = &sun4i_apb1_gates_data,},
Maxime Ripard2371dd82013-07-16 11:21:59 +02001018 {.compatible = "allwinner,sun5i-a10s-apb1-gates-clk", .data = &sun5i_a10s_apb1_gates_data,},
Maxime Ripard4f985b42013-04-30 11:56:22 +02001019 {.compatible = "allwinner,sun5i-a13-apb1-gates-clk", .data = &sun5i_a13_apb1_gates_data,},
Maxime Ripard6a721db2013-07-23 23:34:10 +02001020 {.compatible = "allwinner,sun6i-a31-apb1-gates-clk", .data = &sun6i_a31_apb1_gates_data,},
Maxime Ripard1fb2e4a2013-07-25 21:06:56 +02001021 {.compatible = "allwinner,sun7i-a20-apb1-gates-clk", .data = &sun7i_a20_apb1_gates_data,},
Maxime Ripard6a721db2013-07-23 23:34:10 +02001022 {.compatible = "allwinner,sun6i-a31-apb2-gates-clk", .data = &sun6i_a31_apb2_gates_data,},
Emilio López13569a72013-03-27 18:20:37 -03001023 {}
1024};
1025
Emilio Lópeze874a662013-02-25 11:44:26 -03001026static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_match,
1027 void *function)
1028{
1029 struct device_node *np;
1030 const struct div_data *data;
1031 const struct of_device_id *match;
1032 void (*setup_function)(struct device_node *, const void *) = function;
1033
1034 for_each_matching_node(np, clk_match) {
1035 match = of_match_node(clk_match, np);
1036 data = match->data;
1037 setup_function(np, data);
1038 }
1039}
1040
Emilio López8e6a4c42013-09-20 22:03:12 -03001041/**
1042 * System clock protection
1043 *
1044 * By enabling these critical clocks, we prevent their accidental gating
1045 * by the framework
1046 */
1047static void __init sunxi_clock_protect(void)
1048{
1049 struct clk *clk;
1050
1051 /* memory bus clock - sun5i+ */
1052 clk = clk_get(NULL, "mbus");
1053 if (!IS_ERR(clk)) {
1054 clk_prepare_enable(clk);
1055 clk_put(clk);
1056 }
1057
1058 /* DDR clock - sun4i+ */
1059 clk = clk_get(NULL, "pll5_ddr");
1060 if (!IS_ERR(clk)) {
1061 clk_prepare_enable(clk);
1062 clk_put(clk);
1063 }
1064}
1065
Mike Turquette1d9438f2013-12-01 12:42:45 -08001066static void __init sunxi_init_clocks(void)
Emilio Lópeze874a662013-02-25 11:44:26 -03001067{
Emilio Lópeze874a662013-02-25 11:44:26 -03001068 /* Register factor clocks */
1069 of_sunxi_table_clock_setup(clk_factors_match, sunxi_factors_clk_setup);
1070
1071 /* Register divider clocks */
1072 of_sunxi_table_clock_setup(clk_div_match, sunxi_divider_clk_setup);
1073
Emilio Lópezd584c132013-12-23 00:32:37 -03001074 /* Register divided output clocks */
1075 of_sunxi_table_clock_setup(clk_divs_match, sunxi_divs_clk_setup);
1076
Emilio Lópeze874a662013-02-25 11:44:26 -03001077 /* Register mux clocks */
1078 of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup);
Emilio López13569a72013-03-27 18:20:37 -03001079
1080 /* Register gate clocks */
1081 of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup);
Emilio López8e6a4c42013-09-20 22:03:12 -03001082
1083 /* Enable core system clocks */
1084 sunxi_clock_protect();
Emilio Lópeze874a662013-02-25 11:44:26 -03001085}
Sebastian Hesselbarthbe080452013-09-06 14:59:57 +02001086CLK_OF_DECLARE(sun4i_a10_clk_init, "allwinner,sun4i-a10", sunxi_init_clocks);
1087CLK_OF_DECLARE(sun5i_a10s_clk_init, "allwinner,sun5i-a10s", sunxi_init_clocks);
1088CLK_OF_DECLARE(sun5i_a13_clk_init, "allwinner,sun5i-a13", sunxi_init_clocks);
1089CLK_OF_DECLARE(sun6i_a31_clk_init, "allwinner,sun6i-a31", sunxi_init_clocks);
1090CLK_OF_DECLARE(sun7i_a20_clk_init, "allwinner,sun7i-a20", sunxi_init_clocks);