blob: 9240bc1026a3d24b622f1144d100200abd4ed9a0 [file] [log] [blame]
Paul Walmsley52650502009-12-08 16:29:38 -07001/*
2 * linux/arch/arm/mach-omap1/clock_data.c
3 *
Paul Walmsley51c19542010-02-22 22:09:26 -07004 * Copyright (C) 2004 - 2005, 2009-2010 Nokia Corporation
Paul Walmsley52650502009-12-08 16:29:38 -07005 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
6 * Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/kernel.h>
14#include <linux/clk.h>
15#include <linux/io.h>
16
17#include <asm/mach-types.h> /* for machine_is_* */
18
19#include <plat/clock.h>
20#include <plat/cpu.h>
21#include <plat/clkdev_omap.h>
22#include <plat/usb.h> /* for OTG_BASE */
23
24#include "clock.h"
25
26/*------------------------------------------------------------------------
27 * Omap1 clocks
28 *-------------------------------------------------------------------------*/
29
Paul Walmsley52650502009-12-08 16:29:38 -070030static struct clk ck_ref = {
31 .name = "ck_ref",
32 .ops = &clkops_null,
33 .rate = 12000000,
34};
35
36static struct clk ck_dpll1 = {
37 .name = "ck_dpll1",
38 .ops = &clkops_null,
39 .parent = &ck_ref,
40};
41
42/*
43 * FIXME: This clock seems to be necessary but no-one has asked for its
44 * activation. [ FIX: SoSSI, SSR ]
45 */
46static struct arm_idlect1_clk ck_dpll1out = {
47 .clk = {
48 .name = "ck_dpll1out",
49 .ops = &clkops_generic,
50 .parent = &ck_dpll1,
51 .flags = CLOCK_IDLE_CONTROL | ENABLE_REG_32BIT |
52 ENABLE_ON_INIT,
53 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
54 .enable_bit = EN_CKOUT_ARM,
55 .recalc = &followparent_recalc,
56 },
57 .idlect_shift = 12,
58};
59
60static struct clk sossi_ck = {
61 .name = "ck_sossi",
62 .ops = &clkops_generic,
63 .parent = &ck_dpll1out.clk,
64 .flags = CLOCK_NO_IDLE_PARENT | ENABLE_REG_32BIT,
65 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1),
66 .enable_bit = 16,
67 .recalc = &omap1_sossi_recalc,
68 .set_rate = &omap1_set_sossi_rate,
69};
70
71static struct clk arm_ck = {
72 .name = "arm_ck",
73 .ops = &clkops_null,
74 .parent = &ck_dpll1,
75 .rate_offset = CKCTL_ARMDIV_OFFSET,
76 .recalc = &omap1_ckctl_recalc,
77 .round_rate = omap1_clk_round_rate_ckctl_arm,
78 .set_rate = omap1_clk_set_rate_ckctl_arm,
79};
80
81static struct arm_idlect1_clk armper_ck = {
82 .clk = {
83 .name = "armper_ck",
84 .ops = &clkops_generic,
85 .parent = &ck_dpll1,
86 .flags = CLOCK_IDLE_CONTROL,
87 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
88 .enable_bit = EN_PERCK,
89 .rate_offset = CKCTL_PERDIV_OFFSET,
90 .recalc = &omap1_ckctl_recalc,
91 .round_rate = omap1_clk_round_rate_ckctl_arm,
92 .set_rate = omap1_clk_set_rate_ckctl_arm,
93 },
94 .idlect_shift = 2,
95};
96
97/*
98 * FIXME: This clock seems to be necessary but no-one has asked for its
99 * activation. [ GPIO code for 1510 ]
100 */
101static struct clk arm_gpio_ck = {
102 .name = "arm_gpio_ck",
103 .ops = &clkops_generic,
104 .parent = &ck_dpll1,
105 .flags = ENABLE_ON_INIT,
106 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
107 .enable_bit = EN_GPIOCK,
108 .recalc = &followparent_recalc,
109};
110
111static struct arm_idlect1_clk armxor_ck = {
112 .clk = {
113 .name = "armxor_ck",
114 .ops = &clkops_generic,
115 .parent = &ck_ref,
116 .flags = CLOCK_IDLE_CONTROL,
117 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
118 .enable_bit = EN_XORPCK,
119 .recalc = &followparent_recalc,
120 },
121 .idlect_shift = 1,
122};
123
124static struct arm_idlect1_clk armtim_ck = {
125 .clk = {
126 .name = "armtim_ck",
127 .ops = &clkops_generic,
128 .parent = &ck_ref,
129 .flags = CLOCK_IDLE_CONTROL,
130 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
131 .enable_bit = EN_TIMCK,
132 .recalc = &followparent_recalc,
133 },
134 .idlect_shift = 9,
135};
136
137static struct arm_idlect1_clk armwdt_ck = {
138 .clk = {
139 .name = "armwdt_ck",
140 .ops = &clkops_generic,
141 .parent = &ck_ref,
142 .flags = CLOCK_IDLE_CONTROL,
143 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
144 .enable_bit = EN_WDTCK,
Paul Walmsley0dfc2422010-01-26 20:12:57 -0700145 .fixed_div = 14,
146 .recalc = &omap_fixed_divisor_recalc,
Paul Walmsley52650502009-12-08 16:29:38 -0700147 },
148 .idlect_shift = 0,
149};
150
151static struct clk arminth_ck16xx = {
152 .name = "arminth_ck",
153 .ops = &clkops_null,
154 .parent = &arm_ck,
155 .recalc = &followparent_recalc,
156 /* Note: On 16xx the frequency can be divided by 2 by programming
157 * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
158 *
159 * 1510 version is in TC clocks.
160 */
161};
162
163static struct clk dsp_ck = {
164 .name = "dsp_ck",
165 .ops = &clkops_generic,
166 .parent = &ck_dpll1,
167 .enable_reg = OMAP1_IO_ADDRESS(ARM_CKCTL),
168 .enable_bit = EN_DSPCK,
169 .rate_offset = CKCTL_DSPDIV_OFFSET,
170 .recalc = &omap1_ckctl_recalc,
171 .round_rate = omap1_clk_round_rate_ckctl_arm,
172 .set_rate = omap1_clk_set_rate_ckctl_arm,
173};
174
175static struct clk dspmmu_ck = {
176 .name = "dspmmu_ck",
177 .ops = &clkops_null,
178 .parent = &ck_dpll1,
179 .rate_offset = CKCTL_DSPMMUDIV_OFFSET,
180 .recalc = &omap1_ckctl_recalc,
181 .round_rate = omap1_clk_round_rate_ckctl_arm,
182 .set_rate = omap1_clk_set_rate_ckctl_arm,
183};
184
185static struct clk dspper_ck = {
186 .name = "dspper_ck",
187 .ops = &clkops_dspck,
188 .parent = &ck_dpll1,
189 .enable_reg = DSP_IDLECT2,
190 .enable_bit = EN_PERCK,
191 .rate_offset = CKCTL_PERDIV_OFFSET,
192 .recalc = &omap1_ckctl_recalc_dsp_domain,
193 .round_rate = omap1_clk_round_rate_ckctl_arm,
194 .set_rate = &omap1_clk_set_rate_dsp_domain,
195};
196
197static struct clk dspxor_ck = {
198 .name = "dspxor_ck",
199 .ops = &clkops_dspck,
200 .parent = &ck_ref,
201 .enable_reg = DSP_IDLECT2,
202 .enable_bit = EN_XORPCK,
203 .recalc = &followparent_recalc,
204};
205
206static struct clk dsptim_ck = {
207 .name = "dsptim_ck",
208 .ops = &clkops_dspck,
209 .parent = &ck_ref,
210 .enable_reg = DSP_IDLECT2,
211 .enable_bit = EN_DSPTIMCK,
212 .recalc = &followparent_recalc,
213};
214
215/* Tie ARM_IDLECT1:IDLIF_ARM to this logical clock structure */
216static struct arm_idlect1_clk tc_ck = {
217 .clk = {
218 .name = "tc_ck",
219 .ops = &clkops_null,
220 .parent = &ck_dpll1,
221 .flags = CLOCK_IDLE_CONTROL,
222 .rate_offset = CKCTL_TCDIV_OFFSET,
223 .recalc = &omap1_ckctl_recalc,
224 .round_rate = omap1_clk_round_rate_ckctl_arm,
225 .set_rate = omap1_clk_set_rate_ckctl_arm,
226 },
227 .idlect_shift = 6,
228};
229
230static struct clk arminth_ck1510 = {
231 .name = "arminth_ck",
232 .ops = &clkops_null,
233 .parent = &tc_ck.clk,
234 .recalc = &followparent_recalc,
235 /* Note: On 1510 the frequency follows TC_CK
236 *
237 * 16xx version is in MPU clocks.
238 */
239};
240
241static struct clk tipb_ck = {
242 /* No-idle controlled by "tc_ck" */
243 .name = "tipb_ck",
244 .ops = &clkops_null,
245 .parent = &tc_ck.clk,
246 .recalc = &followparent_recalc,
247};
248
249static struct clk l3_ocpi_ck = {
250 /* No-idle controlled by "tc_ck" */
251 .name = "l3_ocpi_ck",
252 .ops = &clkops_generic,
253 .parent = &tc_ck.clk,
254 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
255 .enable_bit = EN_OCPI_CK,
256 .recalc = &followparent_recalc,
257};
258
259static struct clk tc1_ck = {
260 .name = "tc1_ck",
261 .ops = &clkops_generic,
262 .parent = &tc_ck.clk,
263 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
264 .enable_bit = EN_TC1_CK,
265 .recalc = &followparent_recalc,
266};
267
268/*
269 * FIXME: This clock seems to be necessary but no-one has asked for its
270 * activation. [ pm.c (SRAM), CCP, Camera ]
271 */
272static struct clk tc2_ck = {
273 .name = "tc2_ck",
274 .ops = &clkops_generic,
275 .parent = &tc_ck.clk,
276 .flags = ENABLE_ON_INIT,
277 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
278 .enable_bit = EN_TC2_CK,
279 .recalc = &followparent_recalc,
280};
281
282static struct clk dma_ck = {
283 /* No-idle controlled by "tc_ck" */
284 .name = "dma_ck",
285 .ops = &clkops_null,
286 .parent = &tc_ck.clk,
287 .recalc = &followparent_recalc,
288};
289
290static struct clk dma_lcdfree_ck = {
291 .name = "dma_lcdfree_ck",
292 .ops = &clkops_null,
293 .parent = &tc_ck.clk,
294 .recalc = &followparent_recalc,
295};
296
297static struct arm_idlect1_clk api_ck = {
298 .clk = {
299 .name = "api_ck",
300 .ops = &clkops_generic,
301 .parent = &tc_ck.clk,
302 .flags = CLOCK_IDLE_CONTROL,
303 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
304 .enable_bit = EN_APICK,
305 .recalc = &followparent_recalc,
306 },
307 .idlect_shift = 8,
308};
309
310static struct arm_idlect1_clk lb_ck = {
311 .clk = {
312 .name = "lb_ck",
313 .ops = &clkops_generic,
314 .parent = &tc_ck.clk,
315 .flags = CLOCK_IDLE_CONTROL,
316 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
317 .enable_bit = EN_LBCK,
318 .recalc = &followparent_recalc,
319 },
320 .idlect_shift = 4,
321};
322
323static struct clk rhea1_ck = {
324 .name = "rhea1_ck",
325 .ops = &clkops_null,
326 .parent = &tc_ck.clk,
327 .recalc = &followparent_recalc,
328};
329
330static struct clk rhea2_ck = {
331 .name = "rhea2_ck",
332 .ops = &clkops_null,
333 .parent = &tc_ck.clk,
334 .recalc = &followparent_recalc,
335};
336
337static struct clk lcd_ck_16xx = {
338 .name = "lcd_ck",
339 .ops = &clkops_generic,
340 .parent = &ck_dpll1,
341 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
342 .enable_bit = EN_LCDCK,
343 .rate_offset = CKCTL_LCDDIV_OFFSET,
344 .recalc = &omap1_ckctl_recalc,
345 .round_rate = omap1_clk_round_rate_ckctl_arm,
346 .set_rate = omap1_clk_set_rate_ckctl_arm,
347};
348
349static struct arm_idlect1_clk lcd_ck_1510 = {
350 .clk = {
351 .name = "lcd_ck",
352 .ops = &clkops_generic,
353 .parent = &ck_dpll1,
354 .flags = CLOCK_IDLE_CONTROL,
355 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
356 .enable_bit = EN_LCDCK,
357 .rate_offset = CKCTL_LCDDIV_OFFSET,
358 .recalc = &omap1_ckctl_recalc,
359 .round_rate = omap1_clk_round_rate_ckctl_arm,
360 .set_rate = omap1_clk_set_rate_ckctl_arm,
361 },
362 .idlect_shift = 3,
363};
364
365static struct clk uart1_1510 = {
366 .name = "uart1_ck",
367 .ops = &clkops_null,
368 /* Direct from ULPD, no real parent */
369 .parent = &armper_ck.clk,
370 .rate = 12000000,
371 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
372 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
373 .enable_bit = 29, /* Chooses between 12MHz and 48MHz */
374 .set_rate = &omap1_set_uart_rate,
375 .recalc = &omap1_uart_recalc,
376};
377
378static struct uart_clk uart1_16xx = {
379 .clk = {
380 .name = "uart1_ck",
381 .ops = &clkops_uart,
382 /* Direct from ULPD, no real parent */
383 .parent = &armper_ck.clk,
384 .rate = 48000000,
Paul Walmsley51c19542010-02-22 22:09:26 -0700385 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
Paul Walmsley52650502009-12-08 16:29:38 -0700386 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
387 .enable_bit = 29,
388 },
389 .sysc_addr = 0xfffb0054,
390};
391
392static struct clk uart2_ck = {
393 .name = "uart2_ck",
394 .ops = &clkops_null,
395 /* Direct from ULPD, no real parent */
396 .parent = &armper_ck.clk,
397 .rate = 12000000,
398 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
399 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
400 .enable_bit = 30, /* Chooses between 12MHz and 48MHz */
401 .set_rate = &omap1_set_uart_rate,
402 .recalc = &omap1_uart_recalc,
403};
404
405static struct clk uart3_1510 = {
406 .name = "uart3_ck",
407 .ops = &clkops_null,
408 /* Direct from ULPD, no real parent */
409 .parent = &armper_ck.clk,
410 .rate = 12000000,
411 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
412 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
413 .enable_bit = 31, /* Chooses between 12MHz and 48MHz */
414 .set_rate = &omap1_set_uart_rate,
415 .recalc = &omap1_uart_recalc,
416};
417
418static struct uart_clk uart3_16xx = {
419 .clk = {
420 .name = "uart3_ck",
421 .ops = &clkops_uart,
422 /* Direct from ULPD, no real parent */
423 .parent = &armper_ck.clk,
424 .rate = 48000000,
Paul Walmsley51c19542010-02-22 22:09:26 -0700425 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
Paul Walmsley52650502009-12-08 16:29:38 -0700426 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
427 .enable_bit = 31,
428 },
429 .sysc_addr = 0xfffb9854,
430};
431
432static struct clk usb_clko = { /* 6 MHz output on W4_USB_CLKO */
433 .name = "usb_clko",
434 .ops = &clkops_generic,
435 /* Direct from ULPD, no parent */
436 .rate = 6000000,
Paul Walmsley51c19542010-02-22 22:09:26 -0700437 .flags = ENABLE_REG_32BIT,
Paul Walmsley52650502009-12-08 16:29:38 -0700438 .enable_reg = OMAP1_IO_ADDRESS(ULPD_CLOCK_CTRL),
439 .enable_bit = USB_MCLK_EN_BIT,
440};
441
442static struct clk usb_hhc_ck1510 = {
443 .name = "usb_hhc_ck",
444 .ops = &clkops_generic,
445 /* Direct from ULPD, no parent */
446 .rate = 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
Paul Walmsley51c19542010-02-22 22:09:26 -0700447 .flags = ENABLE_REG_32BIT,
Paul Walmsley52650502009-12-08 16:29:38 -0700448 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
449 .enable_bit = USB_HOST_HHC_UHOST_EN,
450};
451
452static struct clk usb_hhc_ck16xx = {
453 .name = "usb_hhc_ck",
454 .ops = &clkops_generic,
455 /* Direct from ULPD, no parent */
456 .rate = 48000000,
457 /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
Paul Walmsley51c19542010-02-22 22:09:26 -0700458 .flags = ENABLE_REG_32BIT,
Paul Walmsley52650502009-12-08 16:29:38 -0700459 .enable_reg = OMAP1_IO_ADDRESS(OTG_BASE + 0x08), /* OTG_SYSCON_2 */
460 .enable_bit = 8 /* UHOST_EN */,
461};
462
463static struct clk usb_dc_ck = {
464 .name = "usb_dc_ck",
465 .ops = &clkops_generic,
466 /* Direct from ULPD, no parent */
467 .rate = 48000000,
Paul Walmsley52650502009-12-08 16:29:38 -0700468 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
469 .enable_bit = 4,
470};
471
472static struct clk usb_dc_ck7xx = {
473 .name = "usb_dc_ck",
474 .ops = &clkops_generic,
475 /* Direct from ULPD, no parent */
476 .rate = 48000000,
Paul Walmsley52650502009-12-08 16:29:38 -0700477 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
478 .enable_bit = 8,
479};
480
Cory Maccarrone8b8fbd32010-08-02 14:21:39 +0300481static struct clk uart1_7xx = {
482 .name = "uart1_ck",
483 .ops = &clkops_generic,
484 /* Direct from ULPD, no parent */
485 .rate = 12000000,
486 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
487 .enable_bit = 9,
488};
489
490static struct clk uart2_7xx = {
491 .name = "uart2_ck",
492 .ops = &clkops_generic,
493 /* Direct from ULPD, no parent */
494 .rate = 12000000,
495 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
496 .enable_bit = 11,
497};
498
Paul Walmsley52650502009-12-08 16:29:38 -0700499static struct clk mclk_1510 = {
500 .name = "mclk",
501 .ops = &clkops_generic,
502 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
503 .rate = 12000000,
Paul Walmsley52650502009-12-08 16:29:38 -0700504 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
505 .enable_bit = 6,
506};
507
508static struct clk mclk_16xx = {
509 .name = "mclk",
510 .ops = &clkops_generic,
511 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
512 .enable_reg = OMAP1_IO_ADDRESS(COM_CLK_DIV_CTRL_SEL),
513 .enable_bit = COM_ULPD_PLL_CLK_REQ,
514 .set_rate = &omap1_set_ext_clk_rate,
515 .round_rate = &omap1_round_ext_clk_rate,
516 .init = &omap1_init_ext_clk,
517};
518
519static struct clk bclk_1510 = {
520 .name = "bclk",
521 .ops = &clkops_generic,
522 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
523 .rate = 12000000,
Paul Walmsley52650502009-12-08 16:29:38 -0700524};
525
526static struct clk bclk_16xx = {
527 .name = "bclk",
528 .ops = &clkops_generic,
529 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
530 .enable_reg = OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL),
531 .enable_bit = SWD_ULPD_PLL_CLK_REQ,
532 .set_rate = &omap1_set_ext_clk_rate,
533 .round_rate = &omap1_round_ext_clk_rate,
534 .init = &omap1_init_ext_clk,
535};
536
537static struct clk mmc1_ck = {
Paul Walmsleyb92c1702010-02-22 22:09:19 -0700538 .name = "mmc1_ck",
Paul Walmsley52650502009-12-08 16:29:38 -0700539 .ops = &clkops_generic,
540 /* Functional clock is direct from ULPD, interface clock is ARMPER */
541 .parent = &armper_ck.clk,
542 .rate = 48000000,
Paul Walmsley51c19542010-02-22 22:09:26 -0700543 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
Paul Walmsley52650502009-12-08 16:29:38 -0700544 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
545 .enable_bit = 23,
546};
547
548static struct clk mmc2_ck = {
Paul Walmsleyb92c1702010-02-22 22:09:19 -0700549 .name = "mmc2_ck",
Paul Walmsley52650502009-12-08 16:29:38 -0700550 .ops = &clkops_generic,
551 /* Functional clock is direct from ULPD, interface clock is ARMPER */
552 .parent = &armper_ck.clk,
553 .rate = 48000000,
Paul Walmsley51c19542010-02-22 22:09:26 -0700554 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
Paul Walmsley52650502009-12-08 16:29:38 -0700555 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
556 .enable_bit = 20,
557};
558
559static struct clk mmc3_ck = {
Paul Walmsleyb92c1702010-02-22 22:09:19 -0700560 .name = "mmc3_ck",
Paul Walmsley52650502009-12-08 16:29:38 -0700561 .ops = &clkops_generic,
562 /* Functional clock is direct from ULPD, interface clock is ARMPER */
563 .parent = &armper_ck.clk,
564 .rate = 48000000,
Paul Walmsley51c19542010-02-22 22:09:26 -0700565 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
Paul Walmsley52650502009-12-08 16:29:38 -0700566 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
567 .enable_bit = 12,
568};
569
570static struct clk virtual_ck_mpu = {
571 .name = "mpu",
572 .ops = &clkops_null,
573 .parent = &arm_ck, /* Is smarter alias for */
574 .recalc = &followparent_recalc,
575 .set_rate = &omap1_select_table_rate,
576 .round_rate = &omap1_round_to_table_rate,
577};
578
579/* virtual functional clock domain for I2C. Just for making sure that ARMXOR_CK
580remains active during MPU idle whenever this is enabled */
581static struct clk i2c_fck = {
582 .name = "i2c_fck",
Paul Walmsley52650502009-12-08 16:29:38 -0700583 .ops = &clkops_null,
584 .flags = CLOCK_NO_IDLE_PARENT,
585 .parent = &armxor_ck.clk,
586 .recalc = &followparent_recalc,
587};
588
589static struct clk i2c_ick = {
590 .name = "i2c_ick",
Paul Walmsley52650502009-12-08 16:29:38 -0700591 .ops = &clkops_null,
592 .flags = CLOCK_NO_IDLE_PARENT,
593 .parent = &armper_ck.clk,
594 .recalc = &followparent_recalc,
595};
596
597/*
598 * clkdev integration
599 */
600
601static struct omap_clk omap_clks[] = {
602 /* non-ULPD clocks */
603 CLK(NULL, "ck_ref", &ck_ref, CK_16XX | CK_1510 | CK_310 | CK_7XX),
Cory Maccarronee8ae6b62010-01-08 15:23:10 -0700604 CLK(NULL, "ck_dpll1", &ck_dpll1, CK_16XX | CK_1510 | CK_310 | CK_7XX),
Paul Walmsley52650502009-12-08 16:29:38 -0700605 /* CK_GEN1 clocks */
606 CLK(NULL, "ck_dpll1out", &ck_dpll1out.clk, CK_16XX),
607 CLK(NULL, "ck_sossi", &sossi_ck, CK_16XX),
608 CLK(NULL, "arm_ck", &arm_ck, CK_16XX | CK_1510 | CK_310),
609 CLK(NULL, "armper_ck", &armper_ck.clk, CK_16XX | CK_1510 | CK_310),
610 CLK(NULL, "arm_gpio_ck", &arm_gpio_ck, CK_1510 | CK_310),
611 CLK(NULL, "armxor_ck", &armxor_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
612 CLK(NULL, "armtim_ck", &armtim_ck.clk, CK_16XX | CK_1510 | CK_310),
613 CLK("omap_wdt", "fck", &armwdt_ck.clk, CK_16XX | CK_1510 | CK_310),
614 CLK("omap_wdt", "ick", &armper_ck.clk, CK_16XX),
615 CLK("omap_wdt", "ick", &dummy_ck, CK_1510 | CK_310),
616 CLK(NULL, "arminth_ck", &arminth_ck1510, CK_1510 | CK_310),
617 CLK(NULL, "arminth_ck", &arminth_ck16xx, CK_16XX),
618 /* CK_GEN2 clocks */
619 CLK(NULL, "dsp_ck", &dsp_ck, CK_16XX | CK_1510 | CK_310),
620 CLK(NULL, "dspmmu_ck", &dspmmu_ck, CK_16XX | CK_1510 | CK_310),
621 CLK(NULL, "dspper_ck", &dspper_ck, CK_16XX | CK_1510 | CK_310),
622 CLK(NULL, "dspxor_ck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
623 CLK(NULL, "dsptim_ck", &dsptim_ck, CK_16XX | CK_1510 | CK_310),
624 /* CK_GEN3 clocks */
625 CLK(NULL, "tc_ck", &tc_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
626 CLK(NULL, "tipb_ck", &tipb_ck, CK_1510 | CK_310),
627 CLK(NULL, "l3_ocpi_ck", &l3_ocpi_ck, CK_16XX | CK_7XX),
628 CLK(NULL, "tc1_ck", &tc1_ck, CK_16XX),
629 CLK(NULL, "tc2_ck", &tc2_ck, CK_16XX),
630 CLK(NULL, "dma_ck", &dma_ck, CK_16XX | CK_1510 | CK_310),
631 CLK(NULL, "dma_lcdfree_ck", &dma_lcdfree_ck, CK_16XX),
Cory Maccarronee8ae6b62010-01-08 15:23:10 -0700632 CLK(NULL, "api_ck", &api_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
Paul Walmsley52650502009-12-08 16:29:38 -0700633 CLK(NULL, "lb_ck", &lb_ck.clk, CK_1510 | CK_310),
634 CLK(NULL, "rhea1_ck", &rhea1_ck, CK_16XX),
635 CLK(NULL, "rhea2_ck", &rhea2_ck, CK_16XX),
636 CLK(NULL, "lcd_ck", &lcd_ck_16xx, CK_16XX | CK_7XX),
637 CLK(NULL, "lcd_ck", &lcd_ck_1510.clk, CK_1510 | CK_310),
638 /* ULPD clocks */
639 CLK(NULL, "uart1_ck", &uart1_1510, CK_1510 | CK_310),
640 CLK(NULL, "uart1_ck", &uart1_16xx.clk, CK_16XX),
Cory Maccarrone8b8fbd32010-08-02 14:21:39 +0300641 CLK(NULL, "uart1_ck", &uart1_7xx, CK_7XX),
Paul Walmsley52650502009-12-08 16:29:38 -0700642 CLK(NULL, "uart2_ck", &uart2_ck, CK_16XX | CK_1510 | CK_310),
Cory Maccarrone8b8fbd32010-08-02 14:21:39 +0300643 CLK(NULL, "uart2_ck", &uart2_7xx, CK_7XX),
Paul Walmsley52650502009-12-08 16:29:38 -0700644 CLK(NULL, "uart3_ck", &uart3_1510, CK_1510 | CK_310),
645 CLK(NULL, "uart3_ck", &uart3_16xx.clk, CK_16XX),
646 CLK(NULL, "usb_clko", &usb_clko, CK_16XX | CK_1510 | CK_310),
647 CLK(NULL, "usb_hhc_ck", &usb_hhc_ck1510, CK_1510 | CK_310),
648 CLK(NULL, "usb_hhc_ck", &usb_hhc_ck16xx, CK_16XX),
649 CLK(NULL, "usb_dc_ck", &usb_dc_ck, CK_16XX),
650 CLK(NULL, "usb_dc_ck", &usb_dc_ck7xx, CK_7XX),
651 CLK(NULL, "mclk", &mclk_1510, CK_1510 | CK_310),
652 CLK(NULL, "mclk", &mclk_16xx, CK_16XX),
653 CLK(NULL, "bclk", &bclk_1510, CK_1510 | CK_310),
654 CLK(NULL, "bclk", &bclk_16xx, CK_16XX),
655 CLK("mmci-omap.0", "fck", &mmc1_ck, CK_16XX | CK_1510 | CK_310),
656 CLK("mmci-omap.0", "fck", &mmc3_ck, CK_7XX),
657 CLK("mmci-omap.0", "ick", &armper_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
658 CLK("mmci-omap.1", "fck", &mmc2_ck, CK_16XX),
659 CLK("mmci-omap.1", "ick", &armper_ck.clk, CK_16XX),
660 /* Virtual clocks */
661 CLK(NULL, "mpu", &virtual_ck_mpu, CK_16XX | CK_1510 | CK_310),
Cory Maccarronebf92a4072009-12-11 16:16:34 -0800662 CLK("i2c_omap.1", "fck", &i2c_fck, CK_16XX | CK_1510 | CK_310 | CK_7XX),
Paul Walmsley52650502009-12-08 16:29:38 -0700663 CLK("i2c_omap.1", "ick", &i2c_ick, CK_16XX),
Cory Maccarronebf92a4072009-12-11 16:16:34 -0800664 CLK("i2c_omap.1", "ick", &dummy_ck, CK_1510 | CK_310 | CK_7XX),
Cory Maccarronec5c4dce2010-01-08 10:29:05 -0800665 CLK("omap1_spi100k.1", "fck", &dummy_ck, CK_7XX),
666 CLK("omap1_spi100k.1", "ick", &dummy_ck, CK_7XX),
667 CLK("omap1_spi100k.2", "fck", &dummy_ck, CK_7XX),
668 CLK("omap1_spi100k.2", "ick", &dummy_ck, CK_7XX),
Paul Walmsley52650502009-12-08 16:29:38 -0700669 CLK("omap_uwire", "fck", &armxor_ck.clk, CK_16XX | CK_1510 | CK_310),
670 CLK("omap-mcbsp.1", "ick", &dspper_ck, CK_16XX),
671 CLK("omap-mcbsp.1", "ick", &dummy_ck, CK_1510 | CK_310),
672 CLK("omap-mcbsp.2", "ick", &armper_ck.clk, CK_16XX),
673 CLK("omap-mcbsp.2", "ick", &dummy_ck, CK_1510 | CK_310),
674 CLK("omap-mcbsp.3", "ick", &dspper_ck, CK_16XX),
675 CLK("omap-mcbsp.3", "ick", &dummy_ck, CK_1510 | CK_310),
676 CLK("omap-mcbsp.1", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
677 CLK("omap-mcbsp.2", "fck", &armper_ck.clk, CK_16XX | CK_1510 | CK_310),
678 CLK("omap-mcbsp.3", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
679};
680
681/*
682 * init
683 */
684
Cory Maccarrone9b117692010-01-08 15:23:14 -0700685static struct clk_functions omap1_clk_functions = {
Paul Walmsley52650502009-12-08 16:29:38 -0700686 .clk_enable = omap1_clk_enable,
687 .clk_disable = omap1_clk_disable,
688 .clk_round_rate = omap1_clk_round_rate,
689 .clk_set_rate = omap1_clk_set_rate,
690 .clk_disable_unused = omap1_clk_disable_unused,
691};
692
693int __init omap1_clk_init(void)
694{
695 struct omap_clk *c;
696 const struct omap_clock_config *info;
697 int crystal_type = 0; /* Default 12 MHz */
698 u32 reg, cpu_mask;
699
700#ifdef CONFIG_DEBUG_LL
701 /*
702 * Resets some clocks that may be left on from bootloader,
703 * but leaves serial clocks on.
704 */
705 omap_writel(0x3 << 29, MOD_CONF_CTRL_0);
706#endif
707
708 /* USB_REQ_EN will be disabled later if necessary (usb_dc_ck) */
709 reg = omap_readw(SOFT_REQ_REG) & (1 << 4);
710 omap_writew(reg, SOFT_REQ_REG);
711 if (!cpu_is_omap15xx())
712 omap_writew(0, SOFT_REQ_REG2);
713
714 clk_init(&omap1_clk_functions);
715
716 /* By default all idlect1 clocks are allowed to idle */
717 arm_idlect1_mask = ~0;
718
719 for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++)
720 clk_preinit(c->lk.clk);
721
722 cpu_mask = 0;
723 if (cpu_is_omap16xx())
724 cpu_mask |= CK_16XX;
725 if (cpu_is_omap1510())
726 cpu_mask |= CK_1510;
727 if (cpu_is_omap7xx())
728 cpu_mask |= CK_7XX;
729 if (cpu_is_omap310())
730 cpu_mask |= CK_310;
731
732 for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++)
733 if (c->cpu & cpu_mask) {
734 clkdev_add(&c->lk);
735 clk_register(c->lk.clk);
736 }
737
738 /* Pointers to these clocks are needed by code in clock.c */
739 api_ck_p = clk_get(NULL, "api_ck");
740 ck_dpll1_p = clk_get(NULL, "ck_dpll1");
741 ck_ref_p = clk_get(NULL, "ck_ref");
742
743 info = omap_get_config(OMAP_TAG_CLOCK, struct omap_clock_config);
744 if (info != NULL) {
745 if (!cpu_is_omap15xx())
746 crystal_type = info->system_clock_type;
747 }
748
749#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
750 ck_ref.rate = 13000000;
751#elif defined(CONFIG_ARCH_OMAP16XX)
752 if (crystal_type == 2)
753 ck_ref.rate = 19200000;
754#endif
755
756 pr_info("Clocks: ARM_SYSST: 0x%04x DPLL_CTL: 0x%04x ARM_CKCTL: "
757 "0x%04x\n", omap_readw(ARM_SYSST), omap_readw(DPLL_CTL),
758 omap_readw(ARM_CKCTL));
759
760 /* We want to be in syncronous scalable mode */
761 omap_writew(0x1000, ARM_SYSST);
762
763#ifdef CONFIG_OMAP_CLOCKS_SET_BY_BOOTLOADER
764 /* Use values set by bootloader. Determine PLL rate and recalculate
765 * dependent clocks as if kernel had changed PLL or divisors.
766 */
767 {
768 unsigned pll_ctl_val = omap_readw(DPLL_CTL);
769
770 ck_dpll1.rate = ck_ref.rate; /* Base xtal rate */
771 if (pll_ctl_val & 0x10) {
772 /* PLL enabled, apply multiplier and divisor */
773 if (pll_ctl_val & 0xf80)
774 ck_dpll1.rate *= (pll_ctl_val & 0xf80) >> 7;
775 ck_dpll1.rate /= ((pll_ctl_val & 0x60) >> 5) + 1;
776 } else {
777 /* PLL disabled, apply bypass divisor */
778 switch (pll_ctl_val & 0xc) {
779 case 0:
780 break;
781 case 0x4:
782 ck_dpll1.rate /= 2;
783 break;
784 default:
785 ck_dpll1.rate /= 4;
786 break;
787 }
788 }
789 }
790#else
791 /* Find the highest supported frequency and enable it */
792 if (omap1_select_table_rate(&virtual_ck_mpu, ~0)) {
793 printk(KERN_ERR "System frequencies not set. Check your config.\n");
794 /* Guess sane values (60MHz) */
795 omap_writew(0x2290, DPLL_CTL);
796 omap_writew(cpu_is_omap7xx() ? 0x3005 : 0x1005, ARM_CKCTL);
797 ck_dpll1.rate = 60000000;
798 }
799#endif
800 propagate_rate(&ck_dpll1);
801 /* Cache rates for clocks connected to ck_ref (not dpll1) */
802 propagate_rate(&ck_ref);
803 printk(KERN_INFO "Clocking rate (xtal/DPLL1/MPU): "
804 "%ld.%01ld/%ld.%01ld/%ld.%01ld MHz\n",
805 ck_ref.rate / 1000000, (ck_ref.rate / 100000) % 10,
806 ck_dpll1.rate / 1000000, (ck_dpll1.rate / 100000) % 10,
807 arm_ck.rate / 1000000, (arm_ck.rate / 100000) % 10);
808
809#if defined(CONFIG_MACH_OMAP_PERSEUS2) || defined(CONFIG_MACH_OMAP_FSAMPLE)
810 /* Select slicer output as OMAP input clock */
811 omap_writew(omap_readw(OMAP7XX_PCC_UPLD_CTRL) & ~0x1, OMAP7XX_PCC_UPLD_CTRL);
812#endif
813
814 /* Amstrad Delta wants BCLK high when inactive */
815 if (machine_is_ams_delta())
816 omap_writel(omap_readl(ULPD_CLOCK_CTRL) |
817 (1 << SDW_MCLK_INV_BIT),
818 ULPD_CLOCK_CTRL);
819
820 /* Turn off DSP and ARM_TIMXO. Make sure ARM_INTHCK is not divided */
821 /* (on 730, bit 13 must not be cleared) */
822 if (cpu_is_omap7xx())
823 omap_writew(omap_readw(ARM_CKCTL) & 0x2fff, ARM_CKCTL);
824 else
825 omap_writew(omap_readw(ARM_CKCTL) & 0x0fff, ARM_CKCTL);
826
827 /* Put DSP/MPUI into reset until needed */
828 omap_writew(0, ARM_RSTCT1);
829 omap_writew(1, ARM_RSTCT2);
830 omap_writew(0x400, ARM_IDLECT1);
831
832 /*
833 * According to OMAP5910 Erratum SYS_DMA_1, bit DMACK_REQ (bit 8)
834 * of the ARM_IDLECT2 register must be set to zero. The power-on
835 * default value of this bit is one.
836 */
837 omap_writew(0x0000, ARM_IDLECT2); /* Turn LCD clock off also */
838
839 /*
840 * Only enable those clocks we will need, let the drivers
841 * enable other clocks as necessary
842 */
843 clk_enable(&armper_ck.clk);
844 clk_enable(&armxor_ck.clk);
845 clk_enable(&armtim_ck.clk); /* This should be done by timer code */
846
847 if (cpu_is_omap15xx())
848 clk_enable(&arm_gpio_ck);
849
850 return 0;
851}