blob: b9b3317bdc2fbe16a4c0939407b3bf1fdbb2421c [file] [log] [blame]
Lee Jones82b0f4b2013-09-17 10:11:53 +01001/*
2 * Clock definitions for u8500 platform.
3 *
4 * Copyright (C) 2012 ST-Ericsson SA
5 * Author: Ulf Hansson <ulf.hansson@linaro.org>
6 *
7 * License terms: GNU General Public License (GPL) version 2
8 */
9
Lee Jonesdec759d2013-09-17 10:26:24 +010010#include <linux/of.h>
Lee Jones82b0f4b2013-09-17 10:11:53 +010011#include <linux/clk.h>
12#include <linux/clkdev.h>
13#include <linux/clk-provider.h>
14#include <linux/mfd/dbx500-prcmu.h>
15#include <linux/platform_data/clk-ux500.h>
16#include "clk.h"
17
Lee Jonesb4bdc812013-07-22 13:13:01 +010018#define PRCC_SHOW(clk, base, bit) \
19 clk[(base * PRCC_PERIPHS_PER_CLUSTER) + bit]
20
21struct clk *ux500_twocell_get(struct of_phandle_args *clkspec, void *data)
22{
23 struct clk **clk_data = data;
24 unsigned int base, bit;
25
26 if (clkspec->args_count != 2)
27 return ERR_PTR(-EINVAL);
28
29 base = clkspec->args[0];
30 bit = clkspec->args[1];
31
32 if (base != 1 && base != 2 && base != 3 && base != 5 && base != 6) {
33 pr_err("%s: invalid PRCC base %d\n", __func__, base);
34 return ERR_PTR(-EINVAL);
35 }
36
37 return PRCC_SHOW(clk_data, base, bit);
38}
39
Lee Jonesdec759d2013-09-17 10:26:24 +010040static const struct of_device_id u8500_clk_of_match[] = {
41 { .compatible = "stericsson,u8500-clks", },
42 { },
43};
44
Lee Jones82b0f4b2013-09-17 10:11:53 +010045void u8500_of_clk_init(u32 clkrst1_base, u32 clkrst2_base, u32 clkrst3_base,
46 u32 clkrst5_base, u32 clkrst6_base)
47{
48 struct prcmu_fw_version *fw_version;
Lee Jonesdec759d2013-09-17 10:26:24 +010049 struct device_node *np = NULL;
50 struct device_node *child = NULL;
Lee Jones82b0f4b2013-09-17 10:11:53 +010051 const char *sgaclk_parent = NULL;
52 struct clk *clk;
53
Lee Jonesdec759d2013-09-17 10:26:24 +010054 if (of_have_populated_dt())
55 np = of_find_matching_node(NULL, u8500_clk_of_match);
56 if (!np) {
57 pr_err("Either DT or U8500 Clock node not found\n");
58 return;
59 }
60
Lee Jones82b0f4b2013-09-17 10:11:53 +010061 /* Clock sources */
62 clk = clk_reg_prcmu_gate("soc0_pll", NULL, PRCMU_PLLSOC0,
63 CLK_IS_ROOT|CLK_IGNORE_UNUSED);
64
65 clk = clk_reg_prcmu_gate("soc1_pll", NULL, PRCMU_PLLSOC1,
66 CLK_IS_ROOT|CLK_IGNORE_UNUSED);
67
68 clk = clk_reg_prcmu_gate("ddr_pll", NULL, PRCMU_PLLDDR,
69 CLK_IS_ROOT|CLK_IGNORE_UNUSED);
70
71 /* FIXME: Add sys, ulp and int clocks here. */
72
73 clk = clk_register_fixed_rate(NULL, "rtc32k", "NULL",
74 CLK_IS_ROOT|CLK_IGNORE_UNUSED,
75 32768);
76
77 /* PRCMU clocks */
78 fw_version = prcmu_get_fw_version();
79 if (fw_version != NULL) {
80 switch (fw_version->project) {
81 case PRCMU_FW_PROJECT_U8500_C2:
82 case PRCMU_FW_PROJECT_U8520:
83 case PRCMU_FW_PROJECT_U8420:
84 sgaclk_parent = "soc0_pll";
85 break;
86 default:
87 break;
88 }
89 }
90
91 if (sgaclk_parent)
92 clk = clk_reg_prcmu_gate("sgclk", sgaclk_parent,
93 PRCMU_SGACLK, 0);
94 else
95 clk = clk_reg_prcmu_gate("sgclk", NULL,
96 PRCMU_SGACLK, CLK_IS_ROOT);
97
98 clk = clk_reg_prcmu_gate("uartclk", NULL, PRCMU_UARTCLK, CLK_IS_ROOT);
99
100 clk = clk_reg_prcmu_gate("msp02clk", NULL, PRCMU_MSP02CLK, CLK_IS_ROOT);
101
102 clk = clk_reg_prcmu_gate("msp1clk", NULL, PRCMU_MSP1CLK, CLK_IS_ROOT);
103
104 clk = clk_reg_prcmu_gate("i2cclk", NULL, PRCMU_I2CCLK, CLK_IS_ROOT);
105
106 clk = clk_reg_prcmu_gate("slimclk", NULL, PRCMU_SLIMCLK, CLK_IS_ROOT);
107
108 clk = clk_reg_prcmu_gate("per1clk", NULL, PRCMU_PER1CLK, CLK_IS_ROOT);
109
110 clk = clk_reg_prcmu_gate("per2clk", NULL, PRCMU_PER2CLK, CLK_IS_ROOT);
111
112 clk = clk_reg_prcmu_gate("per3clk", NULL, PRCMU_PER3CLK, CLK_IS_ROOT);
113
114 clk = clk_reg_prcmu_gate("per5clk", NULL, PRCMU_PER5CLK, CLK_IS_ROOT);
115
116 clk = clk_reg_prcmu_gate("per6clk", NULL, PRCMU_PER6CLK, CLK_IS_ROOT);
117
118 clk = clk_reg_prcmu_gate("per7clk", NULL, PRCMU_PER7CLK, CLK_IS_ROOT);
119
120 clk = clk_reg_prcmu_scalable("lcdclk", NULL, PRCMU_LCDCLK, 0,
121 CLK_IS_ROOT|CLK_SET_RATE_GATE);
122
123 clk = clk_reg_prcmu_opp_gate("bmlclk", NULL, PRCMU_BMLCLK, CLK_IS_ROOT);
124
125 clk = clk_reg_prcmu_scalable("hsitxclk", NULL, PRCMU_HSITXCLK, 0,
126 CLK_IS_ROOT|CLK_SET_RATE_GATE);
127
128 clk = clk_reg_prcmu_scalable("hsirxclk", NULL, PRCMU_HSIRXCLK, 0,
129 CLK_IS_ROOT|CLK_SET_RATE_GATE);
130
131 clk = clk_reg_prcmu_scalable("hdmiclk", NULL, PRCMU_HDMICLK, 0,
132 CLK_IS_ROOT|CLK_SET_RATE_GATE);
133
134 clk = clk_reg_prcmu_gate("apeatclk", NULL, PRCMU_APEATCLK, CLK_IS_ROOT);
135
136 clk = clk_reg_prcmu_gate("apetraceclk", NULL, PRCMU_APETRACECLK,
137 CLK_IS_ROOT);
138
139 clk = clk_reg_prcmu_gate("mcdeclk", NULL, PRCMU_MCDECLK, CLK_IS_ROOT);
140
141 clk = clk_reg_prcmu_opp_gate("ipi2cclk", NULL, PRCMU_IPI2CCLK,
142 CLK_IS_ROOT);
143
144 clk = clk_reg_prcmu_gate("dsialtclk", NULL, PRCMU_DSIALTCLK,
145 CLK_IS_ROOT);
146
147 clk = clk_reg_prcmu_gate("dmaclk", NULL, PRCMU_DMACLK, CLK_IS_ROOT);
148
149 clk = clk_reg_prcmu_gate("b2r2clk", NULL, PRCMU_B2R2CLK, CLK_IS_ROOT);
150
151 clk = clk_reg_prcmu_scalable("tvclk", NULL, PRCMU_TVCLK, 0,
152 CLK_IS_ROOT|CLK_SET_RATE_GATE);
153
154 clk = clk_reg_prcmu_gate("sspclk", NULL, PRCMU_SSPCLK, CLK_IS_ROOT);
155
156 clk = clk_reg_prcmu_gate("rngclk", NULL, PRCMU_RNGCLK, CLK_IS_ROOT);
157
158 clk = clk_reg_prcmu_gate("uiccclk", NULL, PRCMU_UICCCLK, CLK_IS_ROOT);
159
160 clk = clk_reg_prcmu_gate("timclk", NULL, PRCMU_TIMCLK, CLK_IS_ROOT);
161
162 clk = clk_reg_prcmu_opp_volt_scalable("sdmmcclk", NULL, PRCMU_SDMMCCLK,
163 100000000,
164 CLK_IS_ROOT|CLK_SET_RATE_GATE);
165
166 clk = clk_reg_prcmu_scalable("dsi_pll", "hdmiclk",
167 PRCMU_PLLDSI, 0, CLK_SET_RATE_GATE);
168
169
170 clk = clk_reg_prcmu_scalable("dsi0clk", "dsi_pll",
171 PRCMU_DSI0CLK, 0, CLK_SET_RATE_GATE);
172
173 clk = clk_reg_prcmu_scalable("dsi1clk", "dsi_pll",
174 PRCMU_DSI1CLK, 0, CLK_SET_RATE_GATE);
175
176 clk = clk_reg_prcmu_scalable("dsi0escclk", "tvclk",
177 PRCMU_DSI0ESCCLK, 0, CLK_SET_RATE_GATE);
178
179 clk = clk_reg_prcmu_scalable("dsi1escclk", "tvclk",
180 PRCMU_DSI1ESCCLK, 0, CLK_SET_RATE_GATE);
181
182 clk = clk_reg_prcmu_scalable("dsi2escclk", "tvclk",
183 PRCMU_DSI2ESCCLK, 0, CLK_SET_RATE_GATE);
184
185 clk = clk_reg_prcmu_scalable_rate("armss", NULL,
186 PRCMU_ARMSS, 0, CLK_IS_ROOT|CLK_IGNORE_UNUSED);
187
188 clk = clk_register_fixed_factor(NULL, "smp_twd", "armss",
189 CLK_IGNORE_UNUSED, 1, 2);
190
191 /*
192 * FIXME: Add special handled PRCMU clocks here:
193 * 1. clkout0yuv, use PRCMU as parent + need regulator + pinctrl.
194 * 2. ab9540_clkout1yuv, see clkout0yuv
195 */
196
197 /* PRCC P-clocks */
198 clk = clk_reg_prcc_pclk("p1_pclk0", "per1clk", clkrst1_base,
199 BIT(0), 0);
200
201 clk = clk_reg_prcc_pclk("p1_pclk1", "per1clk", clkrst1_base,
202 BIT(1), 0);
203
204 clk = clk_reg_prcc_pclk("p1_pclk2", "per1clk", clkrst1_base,
205 BIT(2), 0);
206
207 clk = clk_reg_prcc_pclk("p1_pclk3", "per1clk", clkrst1_base,
208 BIT(3), 0);
209
210 clk = clk_reg_prcc_pclk("p1_pclk4", "per1clk", clkrst1_base,
211 BIT(4), 0);
212
213 clk = clk_reg_prcc_pclk("p1_pclk5", "per1clk", clkrst1_base,
214 BIT(5), 0);
215
216 clk = clk_reg_prcc_pclk("p1_pclk6", "per1clk", clkrst1_base,
217 BIT(6), 0);
218
219 clk = clk_reg_prcc_pclk("p1_pclk7", "per1clk", clkrst1_base,
220 BIT(7), 0);
221
222 clk = clk_reg_prcc_pclk("p1_pclk8", "per1clk", clkrst1_base,
223 BIT(8), 0);
224
225 clk = clk_reg_prcc_pclk("p1_pclk9", "per1clk", clkrst1_base,
226 BIT(9), 0);
227
228 clk = clk_reg_prcc_pclk("p1_pclk10", "per1clk", clkrst1_base,
229 BIT(10), 0);
230
231 clk = clk_reg_prcc_pclk("p1_pclk11", "per1clk", clkrst1_base,
232 BIT(11), 0);
233
234 clk = clk_reg_prcc_pclk("p2_pclk0", "per2clk", clkrst2_base,
235 BIT(0), 0);
236
237 clk = clk_reg_prcc_pclk("p2_pclk1", "per2clk", clkrst2_base,
238 BIT(1), 0);
239
240 clk = clk_reg_prcc_pclk("p2_pclk2", "per2clk", clkrst2_base,
241 BIT(2), 0);
242
243 clk = clk_reg_prcc_pclk("p2_pclk3", "per2clk", clkrst2_base,
244 BIT(3), 0);
245
246 clk = clk_reg_prcc_pclk("p2_pclk4", "per2clk", clkrst2_base,
247 BIT(4), 0);
248
249 clk = clk_reg_prcc_pclk("p2_pclk5", "per2clk", clkrst2_base,
250 BIT(5), 0);
251
252 clk = clk_reg_prcc_pclk("p2_pclk6", "per2clk", clkrst2_base,
253 BIT(6), 0);
254
255 clk = clk_reg_prcc_pclk("p2_pclk7", "per2clk", clkrst2_base,
256 BIT(7), 0);
257
258 clk = clk_reg_prcc_pclk("p2_pclk8", "per2clk", clkrst2_base,
259 BIT(8), 0);
260
261 clk = clk_reg_prcc_pclk("p2_pclk9", "per2clk", clkrst2_base,
262 BIT(9), 0);
263
264 clk = clk_reg_prcc_pclk("p2_pclk10", "per2clk", clkrst2_base,
265 BIT(10), 0);
266
267 clk = clk_reg_prcc_pclk("p2_pclk11", "per2clk", clkrst2_base,
268 BIT(11), 0);
269
270 clk = clk_reg_prcc_pclk("p2_pclk12", "per2clk", clkrst2_base,
271 BIT(12), 0);
272
273 clk = clk_reg_prcc_pclk("p3_pclk0", "per3clk", clkrst3_base,
274 BIT(0), 0);
275
276 clk = clk_reg_prcc_pclk("p3_pclk1", "per3clk", clkrst3_base,
277 BIT(1), 0);
278
279 clk = clk_reg_prcc_pclk("p3_pclk2", "per3clk", clkrst3_base,
280 BIT(2), 0);
281
282 clk = clk_reg_prcc_pclk("p3_pclk3", "per3clk", clkrst3_base,
283 BIT(3), 0);
284
285 clk = clk_reg_prcc_pclk("p3_pclk4", "per3clk", clkrst3_base,
286 BIT(4), 0);
287
288 clk = clk_reg_prcc_pclk("p3_pclk5", "per3clk", clkrst3_base,
289 BIT(5), 0);
290
291 clk = clk_reg_prcc_pclk("p3_pclk6", "per3clk", clkrst3_base,
292 BIT(6), 0);
293
294 clk = clk_reg_prcc_pclk("p3_pclk7", "per3clk", clkrst3_base,
295 BIT(7), 0);
296
297 clk = clk_reg_prcc_pclk("p3_pclk8", "per3clk", clkrst3_base,
298 BIT(8), 0);
299
300 clk = clk_reg_prcc_pclk("p5_pclk0", "per5clk", clkrst5_base,
301 BIT(0), 0);
302
303 clk = clk_reg_prcc_pclk("p5_pclk1", "per5clk", clkrst5_base,
304 BIT(1), 0);
305
306 clk = clk_reg_prcc_pclk("p6_pclk0", "per6clk", clkrst6_base,
307 BIT(0), 0);
308
309 clk = clk_reg_prcc_pclk("p6_pclk1", "per6clk", clkrst6_base,
310 BIT(1), 0);
311
312 clk = clk_reg_prcc_pclk("p6_pclk2", "per6clk", clkrst6_base,
313 BIT(2), 0);
314
315 clk = clk_reg_prcc_pclk("p6_pclk3", "per6clk", clkrst6_base,
316 BIT(3), 0);
317
318 clk = clk_reg_prcc_pclk("p6_pclk4", "per6clk", clkrst6_base,
319 BIT(4), 0);
320
321 clk = clk_reg_prcc_pclk("p6_pclk5", "per6clk", clkrst6_base,
322 BIT(5), 0);
323
324 clk = clk_reg_prcc_pclk("p6_pclk6", "per6clk", clkrst6_base,
325 BIT(6), 0);
326
327 clk = clk_reg_prcc_pclk("p6_pclk7", "per6clk", clkrst6_base,
328 BIT(7), 0);
329
330 /* PRCC K-clocks
331 *
332 * FIXME: Some drivers requires PERPIH[n| to be automatically enabled
333 * by enabling just the K-clock, even if it is not a valid parent to
334 * the K-clock. Until drivers get fixed we might need some kind of
335 * "parent muxed join".
336 */
337
338 /* Periph1 */
339 clk = clk_reg_prcc_kclk("p1_uart0_kclk", "uartclk",
340 clkrst1_base, BIT(0), CLK_SET_RATE_GATE);
341
342 clk = clk_reg_prcc_kclk("p1_uart1_kclk", "uartclk",
343 clkrst1_base, BIT(1), CLK_SET_RATE_GATE);
344
345 clk = clk_reg_prcc_kclk("p1_i2c1_kclk", "i2cclk",
346 clkrst1_base, BIT(2), CLK_SET_RATE_GATE);
347
348 clk = clk_reg_prcc_kclk("p1_msp0_kclk", "msp02clk",
349 clkrst1_base, BIT(3), CLK_SET_RATE_GATE);
350
351 clk = clk_reg_prcc_kclk("p1_msp1_kclk", "msp1clk",
352 clkrst1_base, BIT(4), CLK_SET_RATE_GATE);
353
354 clk = clk_reg_prcc_kclk("p1_sdi0_kclk", "sdmmcclk",
355 clkrst1_base, BIT(5), CLK_SET_RATE_GATE);
356
357 clk = clk_reg_prcc_kclk("p1_i2c2_kclk", "i2cclk",
358 clkrst1_base, BIT(6), CLK_SET_RATE_GATE);
359
360 clk = clk_reg_prcc_kclk("p1_slimbus0_kclk", "slimclk",
361 clkrst1_base, BIT(8), CLK_SET_RATE_GATE);
362
363 clk = clk_reg_prcc_kclk("p1_i2c4_kclk", "i2cclk",
364 clkrst1_base, BIT(9), CLK_SET_RATE_GATE);
365
366 clk = clk_reg_prcc_kclk("p1_msp3_kclk", "msp1clk",
367 clkrst1_base, BIT(10), CLK_SET_RATE_GATE);
368
369 /* Periph2 */
370 clk = clk_reg_prcc_kclk("p2_i2c3_kclk", "i2cclk",
371 clkrst2_base, BIT(0), CLK_SET_RATE_GATE);
372
373 clk = clk_reg_prcc_kclk("p2_sdi4_kclk", "sdmmcclk",
374 clkrst2_base, BIT(2), CLK_SET_RATE_GATE);
375
376 clk = clk_reg_prcc_kclk("p2_msp2_kclk", "msp02clk",
377 clkrst2_base, BIT(3), CLK_SET_RATE_GATE);
378
379 clk = clk_reg_prcc_kclk("p2_sdi1_kclk", "sdmmcclk",
380 clkrst2_base, BIT(4), CLK_SET_RATE_GATE);
381
382 clk = clk_reg_prcc_kclk("p2_sdi3_kclk", "sdmmcclk",
383 clkrst2_base, BIT(5), CLK_SET_RATE_GATE);
384
385 /* Note that rate is received from parent. */
386 clk = clk_reg_prcc_kclk("p2_ssirx_kclk", "hsirxclk",
387 clkrst2_base, BIT(6),
388 CLK_SET_RATE_GATE|CLK_SET_RATE_PARENT);
389 clk = clk_reg_prcc_kclk("p2_ssitx_kclk", "hsitxclk",
390 clkrst2_base, BIT(7),
391 CLK_SET_RATE_GATE|CLK_SET_RATE_PARENT);
392
393 /* Periph3 */
394 clk = clk_reg_prcc_kclk("p3_ssp0_kclk", "sspclk",
395 clkrst3_base, BIT(1), CLK_SET_RATE_GATE);
396
397 clk = clk_reg_prcc_kclk("p3_ssp1_kclk", "sspclk",
398 clkrst3_base, BIT(2), CLK_SET_RATE_GATE);
399
400 clk = clk_reg_prcc_kclk("p3_i2c0_kclk", "i2cclk",
401 clkrst3_base, BIT(3), CLK_SET_RATE_GATE);
402
403 clk = clk_reg_prcc_kclk("p3_sdi2_kclk", "sdmmcclk",
404 clkrst3_base, BIT(4), CLK_SET_RATE_GATE);
405
406 clk = clk_reg_prcc_kclk("p3_ske_kclk", "rtc32k",
407 clkrst3_base, BIT(5), CLK_SET_RATE_GATE);
408
409 clk = clk_reg_prcc_kclk("p3_uart2_kclk", "uartclk",
410 clkrst3_base, BIT(6), CLK_SET_RATE_GATE);
411
412 clk = clk_reg_prcc_kclk("p3_sdi5_kclk", "sdmmcclk",
413 clkrst3_base, BIT(7), CLK_SET_RATE_GATE);
414
415 /* Periph6 */
416 clk = clk_reg_prcc_kclk("p3_rng_kclk", "rngclk",
417 clkrst6_base, BIT(0), CLK_SET_RATE_GATE);
Lee Jonesdec759d2013-09-17 10:26:24 +0100418
419 for_each_child_of_node(np, child) {
420 /* Place holder for supported nodes. */
421 }
Lee Jones82b0f4b2013-09-17 10:11:53 +0100422}