2 * linux/arch/arm/mach-omap1/clock.h
4 * Copyright (C) 2004 - 2005 Nokia corporation
5 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
6 * Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
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.
13 #ifndef __ARCH_ARM_MACH_OMAP1_CLOCK_H
14 #define __ARCH_ARM_MACH_OMAP1_CLOCK_H
16 static unsigned long omap1_ckctl_recalc(struct clk *clk);
17 static unsigned long omap1_watchdog_recalc(struct clk *clk);
18 static int omap1_set_sossi_rate(struct clk *clk, unsigned long rate);
19 static unsigned long omap1_sossi_recalc(struct clk *clk);
20 static unsigned long omap1_ckctl_recalc_dsp_domain(struct clk *clk);
21 static int omap1_clk_set_rate_dsp_domain(struct clk * clk, unsigned long rate);
22 static int omap1_set_uart_rate(struct clk * clk, unsigned long rate);
23 static unsigned long omap1_uart_recalc(struct clk *clk);
24 static int omap1_set_ext_clk_rate(struct clk * clk, unsigned long rate);
25 static long omap1_round_ext_clk_rate(struct clk * clk, unsigned long rate);
26 static void omap1_init_ext_clk(struct clk * clk);
27 static int omap1_select_table_rate(struct clk * clk, unsigned long rate);
28 static long omap1_round_to_table_rate(struct clk * clk, unsigned long rate);
30 static int omap1_clk_set_rate_ckctl_arm(struct clk *clk, unsigned long rate);
31 static long omap1_clk_round_rate_ckctl_arm(struct clk *clk, unsigned long rate);
36 unsigned long pll_rate;
43 unsigned long sysc_addr;
46 /* Provide a method for preventing idling some ARM IDLECT clocks */
47 struct arm_idlect1_clk {
49 unsigned long no_idle_count;
53 /* ARM_CKCTL bit shifts */
54 #define CKCTL_PERDIV_OFFSET 0
55 #define CKCTL_LCDDIV_OFFSET 2
56 #define CKCTL_ARMDIV_OFFSET 4
57 #define CKCTL_DSPDIV_OFFSET 6
58 #define CKCTL_TCDIV_OFFSET 8
59 #define CKCTL_DSPMMUDIV_OFFSET 10
60 /*#define ARM_TIMXO 12*/
62 /*#define ARM_INTHCK_SEL 14*/ /* Divide-by-2 for mpu inth_ck */
63 /* DSP_CKCTL bit shifts */
64 #define CKCTL_DSPPERDIV_OFFSET 0
66 /* ARM_IDLECT2 bit shifts */
71 #define EN_LBCK 4 /* Not on 1610/1710 */
72 /*#define EN_HSABCK 5*/
76 #define EN_GPIOCK 9 /* Not on 1610/1710 */
77 /*#define EN_LBFREECK 10*/
78 #define EN_CKOUT_ARM 11
80 /* ARM_IDLECT3 bit shifts */
85 /* DSP_IDLECT2 bit shifts (0,1,2 are same as for ARM_IDLECT2) */
88 /* Various register defines for clock controls scattered around OMAP chip */
89 #define SDW_MCLK_INV_BIT 2 /* In ULPD_CLKC_CTRL */
90 #define USB_MCLK_EN_BIT 4 /* In ULPD_CLKC_CTRL */
91 #define USB_HOST_HHC_UHOST_EN 9 /* In MOD_CONF_CTRL_0 */
92 #define SWD_ULPD_PLL_CLK_REQ 1 /* In SWD_CLK_DIV_CTRL_SEL */
93 #define COM_ULPD_PLL_CLK_REQ 1 /* In COM_CLK_DIV_CTRL_SEL */
94 #define SWD_CLK_DIV_CTRL_SEL 0xfffe0874
95 #define COM_CLK_DIV_CTRL_SEL 0xfffe0878
96 #define SOFT_REQ_REG 0xfffe0834
97 #define SOFT_REQ_REG2 0xfffe0880
99 /*-------------------------------------------------------------------------
100 * Omap1 MPU rate table
101 *-------------------------------------------------------------------------*/
102 static struct mpu_rate rate_table[] = {
103 /* MPU MHz, xtal MHz, dpll1 MHz, CKCTL, DPLL_CTL
104 * NOTE: Comment order here is different from bits in CKCTL value:
105 * armdiv, dspdiv, dspmmu, tcdiv, perdiv, lcddiv
107 #if defined(CONFIG_OMAP_ARM_216MHZ)
108 { 216000000, 12000000, 216000000, 0x050d, 0x2910 }, /* 1/1/2/2/2/8 */
110 #if defined(CONFIG_OMAP_ARM_195MHZ)
111 { 195000000, 13000000, 195000000, 0x050e, 0x2790 }, /* 1/1/2/2/4/8 */
113 #if defined(CONFIG_OMAP_ARM_192MHZ)
114 { 192000000, 19200000, 192000000, 0x050f, 0x2510 }, /* 1/1/2/2/8/8 */
115 { 192000000, 12000000, 192000000, 0x050f, 0x2810 }, /* 1/1/2/2/8/8 */
116 { 96000000, 12000000, 192000000, 0x055f, 0x2810 }, /* 2/2/2/2/8/8 */
117 { 48000000, 12000000, 192000000, 0x0baf, 0x2810 }, /* 4/4/4/8/8/8 */
118 { 24000000, 12000000, 192000000, 0x0fff, 0x2810 }, /* 8/8/8/8/8/8 */
120 #if defined(CONFIG_OMAP_ARM_182MHZ)
121 { 182000000, 13000000, 182000000, 0x050e, 0x2710 }, /* 1/1/2/2/4/8 */
123 #if defined(CONFIG_OMAP_ARM_168MHZ)
124 { 168000000, 12000000, 168000000, 0x010f, 0x2710 }, /* 1/1/1/2/8/8 */
126 #if defined(CONFIG_OMAP_ARM_150MHZ)
127 { 150000000, 12000000, 150000000, 0x010a, 0x2cb0 }, /* 1/1/1/2/4/4 */
129 #if defined(CONFIG_OMAP_ARM_120MHZ)
130 { 120000000, 12000000, 120000000, 0x010a, 0x2510 }, /* 1/1/1/2/4/4 */
132 #if defined(CONFIG_OMAP_ARM_96MHZ)
133 { 96000000, 12000000, 96000000, 0x0005, 0x2410 }, /* 1/1/1/1/2/2 */
135 #if defined(CONFIG_OMAP_ARM_60MHZ)
136 { 60000000, 12000000, 60000000, 0x0005, 0x2290 }, /* 1/1/1/1/2/2 */
138 #if defined(CONFIG_OMAP_ARM_30MHZ)
139 { 30000000, 12000000, 60000000, 0x0555, 0x2290 }, /* 2/2/2/2/2/2 */
144 /*-------------------------------------------------------------------------
146 *-------------------------------------------------------------------------*/
148 static struct clk ck_ref = {
154 static struct clk ck_dpll1 = {
161 * FIXME: This clock seems to be necessary but no-one has asked for its
162 * activation. [ FIX: SoSSI, SSR ]
164 static struct arm_idlect1_clk ck_dpll1out = {
166 .name = "ck_dpll1out",
167 .ops = &clkops_generic,
169 .flags = CLOCK_IDLE_CONTROL | ENABLE_REG_32BIT |
171 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
172 .enable_bit = EN_CKOUT_ARM,
173 .recalc = &followparent_recalc,
178 static struct clk sossi_ck = {
180 .ops = &clkops_generic,
181 .parent = &ck_dpll1out.clk,
182 .flags = CLOCK_NO_IDLE_PARENT | ENABLE_REG_32BIT,
183 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1),
185 .recalc = &omap1_sossi_recalc,
186 .set_rate = &omap1_set_sossi_rate,
189 static struct clk arm_ck = {
193 .rate_offset = CKCTL_ARMDIV_OFFSET,
194 .recalc = &omap1_ckctl_recalc,
195 .round_rate = omap1_clk_round_rate_ckctl_arm,
196 .set_rate = omap1_clk_set_rate_ckctl_arm,
199 static struct arm_idlect1_clk armper_ck = {
202 .ops = &clkops_generic,
204 .flags = CLOCK_IDLE_CONTROL,
205 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
206 .enable_bit = EN_PERCK,
207 .rate_offset = CKCTL_PERDIV_OFFSET,
208 .recalc = &omap1_ckctl_recalc,
209 .round_rate = omap1_clk_round_rate_ckctl_arm,
210 .set_rate = omap1_clk_set_rate_ckctl_arm,
216 * FIXME: This clock seems to be necessary but no-one has asked for its
217 * activation. [ GPIO code for 1510 ]
219 static struct clk arm_gpio_ck = {
220 .name = "arm_gpio_ck",
221 .ops = &clkops_generic,
223 .flags = ENABLE_ON_INIT,
224 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
225 .enable_bit = EN_GPIOCK,
226 .recalc = &followparent_recalc,
229 static struct arm_idlect1_clk armxor_ck = {
232 .ops = &clkops_generic,
234 .flags = CLOCK_IDLE_CONTROL,
235 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
236 .enable_bit = EN_XORPCK,
237 .recalc = &followparent_recalc,
242 static struct arm_idlect1_clk armtim_ck = {
245 .ops = &clkops_generic,
247 .flags = CLOCK_IDLE_CONTROL,
248 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
249 .enable_bit = EN_TIMCK,
250 .recalc = &followparent_recalc,
255 static struct arm_idlect1_clk armwdt_ck = {
258 .ops = &clkops_generic,
260 .flags = CLOCK_IDLE_CONTROL,
261 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
262 .enable_bit = EN_WDTCK,
263 .recalc = &omap1_watchdog_recalc,
268 static struct clk arminth_ck16xx = {
269 .name = "arminth_ck",
272 .recalc = &followparent_recalc,
273 /* Note: On 16xx the frequency can be divided by 2 by programming
274 * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
276 * 1510 version is in TC clocks.
280 static struct clk dsp_ck = {
282 .ops = &clkops_generic,
284 .enable_reg = OMAP1_IO_ADDRESS(ARM_CKCTL),
285 .enable_bit = EN_DSPCK,
286 .rate_offset = CKCTL_DSPDIV_OFFSET,
287 .recalc = &omap1_ckctl_recalc,
288 .round_rate = omap1_clk_round_rate_ckctl_arm,
289 .set_rate = omap1_clk_set_rate_ckctl_arm,
292 static struct clk dspmmu_ck = {
296 .rate_offset = CKCTL_DSPMMUDIV_OFFSET,
297 .recalc = &omap1_ckctl_recalc,
298 .round_rate = omap1_clk_round_rate_ckctl_arm,
299 .set_rate = omap1_clk_set_rate_ckctl_arm,
302 static struct clk dspper_ck = {
304 .ops = &clkops_dspck,
306 .enable_reg = DSP_IDLECT2,
307 .enable_bit = EN_PERCK,
308 .rate_offset = CKCTL_PERDIV_OFFSET,
309 .recalc = &omap1_ckctl_recalc_dsp_domain,
310 .round_rate = omap1_clk_round_rate_ckctl_arm,
311 .set_rate = &omap1_clk_set_rate_dsp_domain,
314 static struct clk dspxor_ck = {
316 .ops = &clkops_dspck,
318 .enable_reg = DSP_IDLECT2,
319 .enable_bit = EN_XORPCK,
320 .recalc = &followparent_recalc,
323 static struct clk dsptim_ck = {
325 .ops = &clkops_dspck,
327 .enable_reg = DSP_IDLECT2,
328 .enable_bit = EN_DSPTIMCK,
329 .recalc = &followparent_recalc,
332 /* Tie ARM_IDLECT1:IDLIF_ARM to this logical clock structure */
333 static struct arm_idlect1_clk tc_ck = {
338 .flags = CLOCK_IDLE_CONTROL,
339 .rate_offset = CKCTL_TCDIV_OFFSET,
340 .recalc = &omap1_ckctl_recalc,
341 .round_rate = omap1_clk_round_rate_ckctl_arm,
342 .set_rate = omap1_clk_set_rate_ckctl_arm,
347 static struct clk arminth_ck1510 = {
348 .name = "arminth_ck",
350 .parent = &tc_ck.clk,
351 .recalc = &followparent_recalc,
352 /* Note: On 1510 the frequency follows TC_CK
354 * 16xx version is in MPU clocks.
358 static struct clk tipb_ck = {
359 /* No-idle controlled by "tc_ck" */
362 .parent = &tc_ck.clk,
363 .recalc = &followparent_recalc,
366 static struct clk l3_ocpi_ck = {
367 /* No-idle controlled by "tc_ck" */
368 .name = "l3_ocpi_ck",
369 .ops = &clkops_generic,
370 .parent = &tc_ck.clk,
371 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
372 .enable_bit = EN_OCPI_CK,
373 .recalc = &followparent_recalc,
376 static struct clk tc1_ck = {
378 .ops = &clkops_generic,
379 .parent = &tc_ck.clk,
380 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
381 .enable_bit = EN_TC1_CK,
382 .recalc = &followparent_recalc,
386 * FIXME: This clock seems to be necessary but no-one has asked for its
387 * activation. [ pm.c (SRAM), CCP, Camera ]
389 static struct clk tc2_ck = {
391 .ops = &clkops_generic,
392 .parent = &tc_ck.clk,
393 .flags = ENABLE_ON_INIT,
394 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
395 .enable_bit = EN_TC2_CK,
396 .recalc = &followparent_recalc,
399 static struct clk dma_ck = {
400 /* No-idle controlled by "tc_ck" */
403 .parent = &tc_ck.clk,
404 .recalc = &followparent_recalc,
407 static struct clk dma_lcdfree_ck = {
408 .name = "dma_lcdfree_ck",
410 .parent = &tc_ck.clk,
411 .recalc = &followparent_recalc,
414 static struct arm_idlect1_clk api_ck = {
417 .ops = &clkops_generic,
418 .parent = &tc_ck.clk,
419 .flags = CLOCK_IDLE_CONTROL,
420 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
421 .enable_bit = EN_APICK,
422 .recalc = &followparent_recalc,
427 static struct arm_idlect1_clk lb_ck = {
430 .ops = &clkops_generic,
431 .parent = &tc_ck.clk,
432 .flags = CLOCK_IDLE_CONTROL,
433 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
434 .enable_bit = EN_LBCK,
435 .recalc = &followparent_recalc,
440 static struct clk rhea1_ck = {
443 .parent = &tc_ck.clk,
444 .recalc = &followparent_recalc,
447 static struct clk rhea2_ck = {
450 .parent = &tc_ck.clk,
451 .recalc = &followparent_recalc,
454 static struct clk lcd_ck_16xx = {
456 .ops = &clkops_generic,
458 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
459 .enable_bit = EN_LCDCK,
460 .rate_offset = CKCTL_LCDDIV_OFFSET,
461 .recalc = &omap1_ckctl_recalc,
462 .round_rate = omap1_clk_round_rate_ckctl_arm,
463 .set_rate = omap1_clk_set_rate_ckctl_arm,
466 static struct arm_idlect1_clk lcd_ck_1510 = {
469 .ops = &clkops_generic,
471 .flags = CLOCK_IDLE_CONTROL,
472 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
473 .enable_bit = EN_LCDCK,
474 .rate_offset = CKCTL_LCDDIV_OFFSET,
475 .recalc = &omap1_ckctl_recalc,
476 .round_rate = omap1_clk_round_rate_ckctl_arm,
477 .set_rate = omap1_clk_set_rate_ckctl_arm,
482 static struct clk uart1_1510 = {
485 /* Direct from ULPD, no real parent */
486 .parent = &armper_ck.clk,
488 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
489 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
490 .enable_bit = 29, /* Chooses between 12MHz and 48MHz */
491 .set_rate = &omap1_set_uart_rate,
492 .recalc = &omap1_uart_recalc,
495 static struct uart_clk uart1_16xx = {
499 /* Direct from ULPD, no real parent */
500 .parent = &armper_ck.clk,
502 .flags = RATE_FIXED | ENABLE_REG_32BIT |
503 CLOCK_NO_IDLE_PARENT,
504 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
507 .sysc_addr = 0xfffb0054,
510 static struct clk uart2_ck = {
513 /* Direct from ULPD, no real parent */
514 .parent = &armper_ck.clk,
516 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
517 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
518 .enable_bit = 30, /* Chooses between 12MHz and 48MHz */
519 .set_rate = &omap1_set_uart_rate,
520 .recalc = &omap1_uart_recalc,
523 static struct clk uart3_1510 = {
526 /* Direct from ULPD, no real parent */
527 .parent = &armper_ck.clk,
529 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
530 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
531 .enable_bit = 31, /* Chooses between 12MHz and 48MHz */
532 .set_rate = &omap1_set_uart_rate,
533 .recalc = &omap1_uart_recalc,
536 static struct uart_clk uart3_16xx = {
540 /* Direct from ULPD, no real parent */
541 .parent = &armper_ck.clk,
543 .flags = RATE_FIXED | ENABLE_REG_32BIT |
544 CLOCK_NO_IDLE_PARENT,
545 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
548 .sysc_addr = 0xfffb9854,
551 static struct clk usb_clko = { /* 6 MHz output on W4_USB_CLKO */
553 .ops = &clkops_generic,
554 /* Direct from ULPD, no parent */
556 .flags = RATE_FIXED | ENABLE_REG_32BIT,
557 .enable_reg = OMAP1_IO_ADDRESS(ULPD_CLOCK_CTRL),
558 .enable_bit = USB_MCLK_EN_BIT,
561 static struct clk usb_hhc_ck1510 = {
562 .name = "usb_hhc_ck",
563 .ops = &clkops_generic,
564 /* Direct from ULPD, no parent */
565 .rate = 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
566 .flags = RATE_FIXED | ENABLE_REG_32BIT,
567 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
568 .enable_bit = USB_HOST_HHC_UHOST_EN,
571 static struct clk usb_hhc_ck16xx = {
572 .name = "usb_hhc_ck",
573 .ops = &clkops_generic,
574 /* Direct from ULPD, no parent */
576 /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
577 .flags = RATE_FIXED | ENABLE_REG_32BIT,
578 .enable_reg = OMAP1_IO_ADDRESS(OTG_BASE + 0x08), /* OTG_SYSCON_2 */
579 .enable_bit = 8 /* UHOST_EN */,
582 static struct clk usb_dc_ck = {
584 .ops = &clkops_generic,
585 /* Direct from ULPD, no parent */
588 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
592 static struct clk usb_dc_ck7xx = {
594 .ops = &clkops_generic,
595 /* Direct from ULPD, no parent */
598 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
602 static struct clk mclk_1510 = {
604 .ops = &clkops_generic,
605 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
608 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
612 static struct clk mclk_16xx = {
614 .ops = &clkops_generic,
615 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
616 .enable_reg = OMAP1_IO_ADDRESS(COM_CLK_DIV_CTRL_SEL),
617 .enable_bit = COM_ULPD_PLL_CLK_REQ,
618 .set_rate = &omap1_set_ext_clk_rate,
619 .round_rate = &omap1_round_ext_clk_rate,
620 .init = &omap1_init_ext_clk,
623 static struct clk bclk_1510 = {
625 .ops = &clkops_generic,
626 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
631 static struct clk bclk_16xx = {
633 .ops = &clkops_generic,
634 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
635 .enable_reg = OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL),
636 .enable_bit = SWD_ULPD_PLL_CLK_REQ,
637 .set_rate = &omap1_set_ext_clk_rate,
638 .round_rate = &omap1_round_ext_clk_rate,
639 .init = &omap1_init_ext_clk,
642 static struct clk mmc1_ck = {
644 .ops = &clkops_generic,
645 /* Functional clock is direct from ULPD, interface clock is ARMPER */
646 .parent = &armper_ck.clk,
648 .flags = RATE_FIXED | ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
649 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
653 static struct clk mmc2_ck = {
656 .ops = &clkops_generic,
657 /* Functional clock is direct from ULPD, interface clock is ARMPER */
658 .parent = &armper_ck.clk,
660 .flags = RATE_FIXED | ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
661 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
665 static struct clk mmc3_ck = {
668 .ops = &clkops_generic,
669 /* Functional clock is direct from ULPD, interface clock is ARMPER */
670 .parent = &armper_ck.clk,
672 .flags = RATE_FIXED | ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
673 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
677 static struct clk virtual_ck_mpu = {
680 .parent = &arm_ck, /* Is smarter alias for */
681 .recalc = &followparent_recalc,
682 .set_rate = &omap1_select_table_rate,
683 .round_rate = &omap1_round_to_table_rate,
686 /* virtual functional clock domain for I2C. Just for making sure that ARMXOR_CK
687 remains active during MPU idle whenever this is enabled */
688 static struct clk i2c_fck = {
692 .flags = CLOCK_NO_IDLE_PARENT,
693 .parent = &armxor_ck.clk,
694 .recalc = &followparent_recalc,
697 static struct clk i2c_ick = {
701 .flags = CLOCK_NO_IDLE_PARENT,
702 .parent = &armper_ck.clk,
703 .recalc = &followparent_recalc,