4 * Copyright (C) 2006-2008 Andrzej Zaborowski <balrog@zabor.org>
6 * Clocks data comes in part from arch/arm/mach-omap1/clock.h in Linux.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 #define ALWAYS_ENABLED (1 << 0)
33 #define CLOCK_IN_OMAP310 (1 << 10)
34 #define CLOCK_IN_OMAP730 (1 << 11)
35 #define CLOCK_IN_OMAP1510 (1 << 12)
36 #define CLOCK_IN_OMAP16XX (1 << 13)
37 #define CLOCK_IN_OMAP242X (1 << 14)
38 #define CLOCK_IN_OMAP243X (1 << 15)
39 #define CLOCK_IN_OMAP343X (1 << 16)
43 int running
; /* Is currently ticking */
44 int enabled
; /* Is enabled, regardless of its input clk */
45 unsigned long rate
; /* Current rate (if .running) */
46 unsigned int divisor
; /* Rate relative to input (if .enabled) */
47 unsigned int multiplier
; /* Rate relative to input (if .enabled) */
48 qemu_irq users
[16]; /* Who to notify on change */
49 int usecount
; /* Automatically idle when unused */
52 static struct clk xtal_osc12m
= {
53 .name
= "xtal_osc_12m",
55 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
58 static struct clk xtal_osc32k
= {
59 .name
= "xtal_osc_32k",
61 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
62 CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
65 static struct clk ck_ref
= {
68 .parent
= &xtal_osc12m
,
69 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
73 /* If a dpll is disabled it becomes a bypass, child clocks don't stop */
74 static struct clk dpll1
= {
77 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
81 static struct clk dpll2
= {
84 .flags
= CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
87 static struct clk dpll3
= {
90 .flags
= CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
93 static struct clk dpll4
= {
97 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
100 static struct clk apll
= {
105 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
108 static struct clk ck_48m
= {
110 .parent
= &dpll4
, /* either dpll4 or apll */
111 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
114 static struct clk ck_dpll1out
= {
115 .name
= "ck_dpll1out",
117 .flags
= CLOCK_IN_OMAP16XX
,
120 static struct clk sossi_ck
= {
122 .parent
= &ck_dpll1out
,
123 .flags
= CLOCK_IN_OMAP16XX
,
126 static struct clk clkm1
= {
130 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
134 static struct clk clkm2
= {
138 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
142 static struct clk clkm3
= {
145 .parent
= &dpll1
, /* either dpll1 or ck_ref */
146 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
150 static struct clk arm_ck
= {
154 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
158 static struct clk armper_ck
= {
160 .alias
= "mpuper_ck",
162 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
165 static struct clk arm_gpio_ck
= {
166 .name
= "arm_gpio_ck",
167 .alias
= "mpu_gpio_ck",
170 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
173 static struct clk armxor_ck
= {
175 .alias
= "mpuxor_ck",
177 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
180 static struct clk armtim_ck
= {
182 .alias
= "mputim_ck",
183 .parent
= &ck_ref
, /* either CLKIN or DPLL1 */
184 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
187 static struct clk armwdt_ck
= {
192 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
196 static struct clk arminth_ck16xx
= {
197 .name
= "arminth_ck",
199 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
200 /* Note: On 16xx the frequency can be divided by 2 by programming
201 * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
203 * 1510 version is in TC clocks.
207 static struct clk dsp_ck
= {
210 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
213 static struct clk dspmmu_ck
= {
216 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
|
220 static struct clk dspper_ck
= {
223 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
226 static struct clk dspxor_ck
= {
229 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
232 static struct clk dsptim_ck
= {
235 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
238 static struct clk tc_ck
= {
241 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
|
242 CLOCK_IN_OMAP730
| CLOCK_IN_OMAP310
|
246 static struct clk arminth_ck15xx
= {
247 .name
= "arminth_ck",
249 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
250 /* Note: On 1510 the frequency follows TC_CK
252 * 16xx version is in MPU clocks.
256 static struct clk tipb_ck
= {
257 /* No-idle controlled by "tc_ck" */
260 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
263 static struct clk l3_ocpi_ck
= {
264 /* No-idle controlled by "tc_ck" */
265 .name
= "l3_ocpi_ck",
267 .flags
= CLOCK_IN_OMAP16XX
,
270 static struct clk tc1_ck
= {
273 .flags
= CLOCK_IN_OMAP16XX
,
276 static struct clk tc2_ck
= {
279 .flags
= CLOCK_IN_OMAP16XX
,
282 static struct clk dma_ck
= {
283 /* No-idle controlled by "tc_ck" */
286 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
290 static struct clk dma_lcdfree_ck
= {
291 .name
= "dma_lcdfree_ck",
293 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
296 static struct clk api_ck
= {
300 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
303 static struct clk lb_ck
= {
306 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
309 static struct clk lbfree_ck
= {
312 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
315 static struct clk hsab_ck
= {
318 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
321 static struct clk rhea1_ck
= {
324 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
327 static struct clk rhea2_ck
= {
330 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
333 static struct clk lcd_ck_16xx
= {
336 .flags
= CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP730
,
339 static struct clk lcd_ck_1510
= {
342 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
345 static struct clk uart1_1510
= {
347 /* Direct from ULPD, no real parent */
348 .parent
= &armper_ck
, /* either armper_ck or dpll4 */
350 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
353 static struct clk uart1_16xx
= {
355 /* Direct from ULPD, no real parent */
356 .parent
= &armper_ck
,
358 .flags
= CLOCK_IN_OMAP16XX
,
361 static struct clk uart2_ck
= {
363 /* Direct from ULPD, no real parent */
364 .parent
= &armper_ck
, /* either armper_ck or dpll4 */
366 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
370 static struct clk uart3_1510
= {
372 /* Direct from ULPD, no real parent */
373 .parent
= &armper_ck
, /* either armper_ck or dpll4 */
375 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
378 static struct clk uart3_16xx
= {
380 /* Direct from ULPD, no real parent */
381 .parent
= &armper_ck
,
383 .flags
= CLOCK_IN_OMAP16XX
,
386 static struct clk usb_clk0
= { /* 6 MHz output on W4_USB_CLK0 */
389 /* Direct from ULPD, no parent */
391 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
394 static struct clk usb_hhc_ck1510
= {
395 .name
= "usb_hhc_ck",
396 /* Direct from ULPD, no parent */
397 .rate
= 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
398 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
401 static struct clk usb_hhc_ck16xx
= {
402 .name
= "usb_hhc_ck",
403 /* Direct from ULPD, no parent */
405 /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
406 .flags
= CLOCK_IN_OMAP16XX
,
409 static struct clk usb_w2fc_mclk
= {
410 .name
= "usb_w2fc_mclk",
411 .alias
= "usb_w2fc_ck",
414 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
417 static struct clk mclk_1510
= {
419 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
421 .flags
= CLOCK_IN_OMAP1510
,
424 static struct clk bclk_310
= {
425 .name
= "bt_mclk_out", /* Alias midi_mclk_out? */
426 .parent
= &armper_ck
,
427 .flags
= CLOCK_IN_OMAP310
,
430 static struct clk mclk_310
= {
431 .name
= "com_mclk_out",
432 .parent
= &armper_ck
,
433 .flags
= CLOCK_IN_OMAP310
,
436 static struct clk mclk_16xx
= {
438 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
439 .flags
= CLOCK_IN_OMAP16XX
,
442 static struct clk bclk_1510
= {
444 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
446 .flags
= CLOCK_IN_OMAP1510
,
449 static struct clk bclk_16xx
= {
451 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
452 .flags
= CLOCK_IN_OMAP16XX
,
455 static struct clk mmc1_ck
= {
458 /* Functional clock is direct from ULPD, interface clock is ARMPER */
459 .parent
= &armper_ck
, /* either armper_ck or dpll4 */
461 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
464 static struct clk mmc2_ck
= {
467 /* Functional clock is direct from ULPD, interface clock is ARMPER */
468 .parent
= &armper_ck
,
470 .flags
= CLOCK_IN_OMAP16XX
,
473 static struct clk cam_mclk
= {
475 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
479 static struct clk cam_exclk
= {
481 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
482 /* Either 12M from cam.mclk or 48M from dpll4 */
486 static struct clk cam_lclk
= {
488 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
491 static struct clk i2c_fck
= {
494 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
|
496 .parent
= &armxor_ck
,
499 static struct clk i2c_ick
= {
502 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
503 .parent
= &armper_ck
,
506 static struct clk clk32k
= {
508 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
|
509 CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
510 .parent
= &xtal_osc32k
,
513 static struct clk apll_96m
= {
515 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
517 /*.parent = sys.xtalin */
520 static struct clk apll_54m
= {
522 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
524 /*.parent = sys.xtalin */
527 static struct clk sys_clk
= {
529 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
531 /*.parent = sys.xtalin */
534 static struct clk sleep_clk
= {
536 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
538 /*.parent = sys.xtalin */
541 static struct clk dpll_ck
= {
543 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
544 /*.parent = sys.xtalin */
547 static struct clk dpll_x2_ck
= {
549 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
550 /*.parent = sys.xtalin */
553 static struct clk wdt1_sys_clk
= {
554 .name
= "wdt1_sys_clk",
555 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
557 /*.parent = sys.xtalin */
560 static struct clk func_96m_clk
= {
561 .name
= "func_96m_clk",
562 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
567 static struct clk func_48m_clk
= {
568 .name
= "func_48m_clk",
569 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
574 static struct clk func_12m_clk
= {
575 .name
= "func_12m_clk",
576 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
581 static struct clk func_54m_clk
= {
582 .name
= "func_54m_clk",
583 .flags
= CLOCK_IN_OMAP242X
,
588 static struct clk sys_clkout
= {
590 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
594 static struct clk sys_clkout2
= {
596 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
600 static struct clk core_clk
= {
602 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
606 static struct clk l3_clk
= {
608 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
612 static struct clk core_l4_iclk
= {
613 .name
= "core_l4_iclk",
614 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
618 static struct clk wu_l4_iclk
= {
619 .name
= "wu_l4_iclk",
620 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
624 static struct clk core_l3_iclk
= {
625 .name
= "core_l3_iclk",
626 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
630 static struct clk core_l4_usb_clk
= {
631 .name
= "core_l4_usb_clk",
632 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
636 static struct clk wu_gpt1_clk
= {
637 .name
= "wu_gpt1_clk",
638 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
642 static struct clk wu_32k_clk
= {
643 .name
= "wu_32k_clk",
644 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
648 static struct clk uart1_fclk
= {
649 .name
= "uart1_fclk",
650 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
651 .parent
= &func_48m_clk
,
654 static struct clk uart1_iclk
= {
655 .name
= "uart1_iclk",
656 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
657 .parent
= &core_l4_iclk
,
660 static struct clk uart2_fclk
= {
661 .name
= "uart2_fclk",
662 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
663 .parent
= &func_48m_clk
,
666 static struct clk uart2_iclk
= {
667 .name
= "uart2_iclk",
668 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
669 .parent
= &core_l4_iclk
,
672 static struct clk uart3_fclk
= {
673 .name
= "uart3_fclk",
674 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
675 .parent
= &func_48m_clk
,
678 static struct clk uart3_iclk
= {
679 .name
= "uart3_iclk",
680 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
681 .parent
= &core_l4_iclk
,
684 static struct clk mpu_fclk
= {
686 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
690 static struct clk mpu_iclk
= {
692 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
696 static struct clk int_m_fclk
= {
697 .name
= "int_m_fclk",
698 .alias
= "mpu_intc_fclk",
699 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
703 static struct clk int_m_iclk
= {
704 .name
= "int_m_iclk",
705 .alias
= "mpu_intc_iclk",
706 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
710 static struct clk core_gpt2_clk
= {
711 .name
= "core_gpt2_clk",
712 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
716 static struct clk core_gpt3_clk
= {
717 .name
= "core_gpt3_clk",
718 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
722 static struct clk core_gpt4_clk
= {
723 .name
= "core_gpt4_clk",
724 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
728 static struct clk core_gpt5_clk
= {
729 .name
= "core_gpt5_clk",
730 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
734 static struct clk core_gpt6_clk
= {
735 .name
= "core_gpt6_clk",
736 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
740 static struct clk core_gpt7_clk
= {
741 .name
= "core_gpt7_clk",
742 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
746 static struct clk core_gpt8_clk
= {
747 .name
= "core_gpt8_clk",
748 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
752 static struct clk core_gpt9_clk
= {
753 .name
= "core_gpt9_clk",
754 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
758 static struct clk core_gpt10_clk
= {
759 .name
= "core_gpt10_clk",
760 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
764 static struct clk core_gpt11_clk
= {
765 .name
= "core_gpt11_clk",
766 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
770 static struct clk core_gpt12_clk
= {
771 .name
= "core_gpt12_clk",
772 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
776 static struct clk mcbsp1_clk
= {
778 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
780 .parent
= &func_96m_clk
,
783 static struct clk mcbsp2_clk
= {
785 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
787 .parent
= &func_96m_clk
,
790 static struct clk emul_clk
= {
792 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
793 .parent
= &func_54m_clk
,
796 static struct clk sdma_fclk
= {
798 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
802 static struct clk sdma_iclk
= {
804 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
805 .parent
= &core_l3_iclk
, /* core_l4_iclk for the configuration port */
808 static struct clk i2c1_fclk
= {
810 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
811 .parent
= &func_12m_clk
,
815 static struct clk i2c1_iclk
= {
817 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
818 .parent
= &core_l4_iclk
,
821 static struct clk i2c2_fclk
= {
823 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
824 .parent
= &func_12m_clk
,
828 static struct clk i2c2_iclk
= {
830 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
831 .parent
= &core_l4_iclk
,
834 static struct clk gpio_dbclk
[4] = {
836 .name
= "gpio1_dbclk",
837 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
838 .parent
= &wu_32k_clk
,
840 .name
= "gpio2_dbclk",
841 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
842 .parent
= &wu_32k_clk
,
844 .name
= "gpio3_dbclk",
845 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
846 .parent
= &wu_32k_clk
,
848 .name
= "gpio4_dbclk",
849 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
850 .parent
= &wu_32k_clk
,
854 static struct clk gpio_iclk
= {
856 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
857 .parent
= &wu_l4_iclk
,
860 static struct clk mmc_fck
= {
862 .flags
= CLOCK_IN_OMAP242X
,
863 .parent
= &func_96m_clk
,
866 static struct clk mmc_ick
= {
868 .flags
= CLOCK_IN_OMAP242X
,
869 .parent
= &core_l4_iclk
,
872 static struct clk spi_fclk
[3] = {
875 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
876 .parent
= &func_48m_clk
,
879 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
880 .parent
= &func_48m_clk
,
883 .flags
= CLOCK_IN_OMAP243X
,
884 .parent
= &func_48m_clk
,
888 static struct clk dss_clk
[2] = {
891 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
895 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
900 static struct clk dss_54m_clk
= {
901 .name
= "dss_54m_clk",
902 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
903 .parent
= &func_54m_clk
,
906 static struct clk dss_l3_iclk
= {
907 .name
= "dss_l3_iclk",
908 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
909 .parent
= &core_l3_iclk
,
912 static struct clk dss_l4_iclk
= {
913 .name
= "dss_l4_iclk",
914 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
915 .parent
= &core_l4_iclk
,
918 static struct clk spi_iclk
[3] = {
921 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
922 .parent
= &core_l4_iclk
,
925 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
926 .parent
= &core_l4_iclk
,
929 .flags
= CLOCK_IN_OMAP243X
,
930 .parent
= &core_l4_iclk
,
934 static struct clk omapctrl_clk
= {
935 .name
= "omapctrl_iclk",
936 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
937 /* XXX Should be in WKUP domain */
938 .parent
= &core_l4_iclk
,
941 static struct clk
*onchip_clks
[] = {
944 /* non-ULPD clocks */
964 &arminth_ck15xx
, &arminth_ck16xx
,
996 &usb_hhc_ck1510
, &usb_hhc_ck16xx
,
997 &mclk_1510
, &mclk_16xx
, &mclk_310
,
998 &bclk_1510
, &bclk_16xx
, &bclk_310
,
1006 /* Virtual clocks */
1086 void omap_clk_adduser(struct clk
*clk
, qemu_irq user
)
1090 for (i
= clk
->users
; *i
; i
++);
1094 /* If a clock is allowed to idle, it is disabled automatically when
1095 * all of clock domains using it are disabled. */
1096 int omap_clk_is_idle(struct clk
*clk
)
1100 if (!clk
->enabled
&& (!clk
->usecount
|| !(clk
->flags
&& ALWAYS_ENABLED
)))
1105 for (chld
= clk
->child1
; chld
; chld
= chld
->sibling
)
1106 if (!omap_clk_is_idle(chld
))
1111 struct clk
*omap_findclk(struct omap_mpu_state_s
*mpu
, const char *name
)
1115 for (i
= mpu
->clks
; i
->name
; i
++)
1116 if (!strcmp(i
->name
, name
) || (i
->alias
&& !strcmp(i
->alias
, name
)))
1118 cpu_abort(mpu
->env
, "%s: %s not found\n", __FUNCTION__
, name
);
1121 void omap_clk_get(struct clk
*clk
)
1126 void omap_clk_put(struct clk
*clk
)
1128 if (!(clk
->usecount
--))
1129 cpu_abort(cpu_single_env
, "%s: %s is not in use\n",
1130 __FUNCTION__
, clk
->name
);
1133 static void omap_clk_update(struct clk
*clk
)
1135 int parent
, running
;
1140 parent
= clk
->parent
->running
;
1144 running
= parent
&& (clk
->enabled
||
1145 ((clk
->flags
& ALWAYS_ENABLED
) && clk
->usecount
));
1146 if (clk
->running
!= running
) {
1147 clk
->running
= running
;
1148 for (user
= clk
->users
; *user
; user
++)
1149 qemu_set_irq(*user
, running
);
1150 for (i
= clk
->child1
; i
; i
= i
->sibling
)
1155 static void omap_clk_rate_update_full(struct clk
*clk
, unsigned long int rate
,
1156 unsigned long int div
, unsigned long int mult
)
1161 clk
->rate
= muldiv64(rate
, mult
, div
);
1163 for (user
= clk
->users
; *user
; user
++)
1164 qemu_irq_raise(*user
);
1165 for (i
= clk
->child1
; i
; i
= i
->sibling
)
1166 omap_clk_rate_update_full(i
, rate
,
1167 div
* i
->divisor
, mult
* i
->multiplier
);
1170 static void omap_clk_rate_update(struct clk
*clk
)
1173 unsigned long int div
, mult
= div
= 1;
1175 for (i
= clk
; i
->parent
; i
= i
->parent
) {
1177 mult
*= i
->multiplier
;
1180 omap_clk_rate_update_full(clk
, i
->rate
, div
, mult
);
1183 void omap_clk_reparent(struct clk
*clk
, struct clk
*parent
)
1188 for (p
= &clk
->parent
->child1
; *p
!= clk
; p
= &(*p
)->sibling
);
1192 clk
->parent
= parent
;
1194 clk
->sibling
= parent
->child1
;
1195 parent
->child1
= clk
;
1196 omap_clk_update(clk
);
1197 omap_clk_rate_update(clk
);
1202 void omap_clk_onoff(struct clk
*clk
, int on
)
1205 omap_clk_update(clk
);
1208 void omap_clk_canidle(struct clk
*clk
, int can
)
1216 void omap_clk_setrate(struct clk
*clk
, int divide
, int multiply
)
1218 clk
->divisor
= divide
;
1219 clk
->multiplier
= multiply
;
1220 omap_clk_rate_update(clk
);
1223 int64_t omap_clk_getrate(omap_clk clk
)
1228 void omap_clk_init(struct omap_mpu_state_s
*mpu
)
1230 struct clk
**i
, *j
, *k
;
1234 if (cpu_is_omap310(mpu
))
1235 flag
= CLOCK_IN_OMAP310
;
1236 else if (cpu_is_omap1510(mpu
))
1237 flag
= CLOCK_IN_OMAP1510
;
1238 else if (cpu_is_omap2410(mpu
) || cpu_is_omap2420(mpu
))
1239 flag
= CLOCK_IN_OMAP242X
;
1240 else if (cpu_is_omap2430(mpu
))
1241 flag
= CLOCK_IN_OMAP243X
;
1242 else if (cpu_is_omap3430(mpu
))
1243 flag
= CLOCK_IN_OMAP243X
;
1247 for (i
= onchip_clks
, count
= 0; *i
; i
++)
1248 if ((*i
)->flags
& flag
)
1250 mpu
->clks
= (struct clk
*) qemu_mallocz(sizeof(struct clk
) * (count
+ 1));
1251 for (i
= onchip_clks
, j
= mpu
->clks
; *i
; i
++)
1252 if ((*i
)->flags
& flag
) {
1253 memcpy(j
, *i
, sizeof(struct clk
));
1254 for (k
= mpu
->clks
; k
< j
; k
++)
1255 if (j
->parent
&& !strcmp(j
->parent
->name
, k
->name
)) {
1257 j
->sibling
= k
->child1
;
1259 } else if (k
->parent
&& !strcmp(k
->parent
->name
, j
->name
)) {
1261 k
->sibling
= j
->child1
;
1264 j
->divisor
= j
->divisor
?: 1;
1265 j
->multiplier
= j
->multiplier
?: 1;
1268 for (j
= mpu
->clks
; count
--; j
++) {
1270 omap_clk_rate_update(j
);