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 along
19 * with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include "qemu/osdep.h"
25 #include "hw/arm/omap.h"
33 #define ALWAYS_ENABLED (1 << 0)
34 #define CLOCK_IN_OMAP310 (1 << 10)
35 #define CLOCK_IN_OMAP730 (1 << 11)
36 #define CLOCK_IN_OMAP1510 (1 << 12)
37 #define CLOCK_IN_OMAP16XX (1 << 13)
38 #define CLOCK_IN_OMAP242X (1 << 14)
39 #define CLOCK_IN_OMAP243X (1 << 15)
40 #define CLOCK_IN_OMAP343X (1 << 16)
44 int running
; /* Is currently ticking */
45 int enabled
; /* Is enabled, regardless of its input clk */
46 unsigned long rate
; /* Current rate (if .running) */
47 unsigned int divisor
; /* Rate relative to input (if .enabled) */
48 unsigned int multiplier
; /* Rate relative to input (if .enabled) */
49 qemu_irq users
[16]; /* Who to notify on change */
50 int usecount
; /* Automatically idle when unused */
53 static struct clk xtal_osc12m
= {
54 .name
= "xtal_osc_12m",
56 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
59 static struct clk xtal_osc32k
= {
60 .name
= "xtal_osc_32k",
62 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
63 CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
66 static struct clk ck_ref
= {
69 .parent
= &xtal_osc12m
,
70 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
74 /* If a dpll is disabled it becomes a bypass, child clocks don't stop */
75 static struct clk dpll1
= {
78 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
82 static struct clk dpll2
= {
85 .flags
= CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
88 static struct clk dpll3
= {
91 .flags
= CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
94 static struct clk dpll4
= {
98 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
101 static struct clk apll
= {
106 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
109 static struct clk ck_48m
= {
111 .parent
= &dpll4
, /* either dpll4 or apll */
112 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
115 static struct clk ck_dpll1out
= {
116 .name
= "ck_dpll1out",
118 .flags
= CLOCK_IN_OMAP16XX
,
121 static struct clk sossi_ck
= {
123 .parent
= &ck_dpll1out
,
124 .flags
= CLOCK_IN_OMAP16XX
,
127 static struct clk clkm1
= {
131 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
135 static struct clk clkm2
= {
139 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
143 static struct clk clkm3
= {
146 .parent
= &dpll1
, /* either dpll1 or ck_ref */
147 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
151 static struct clk arm_ck
= {
155 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
159 static struct clk armper_ck
= {
161 .alias
= "mpuper_ck",
163 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
166 static struct clk arm_gpio_ck
= {
167 .name
= "arm_gpio_ck",
168 .alias
= "mpu_gpio_ck",
171 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
174 static struct clk armxor_ck
= {
176 .alias
= "mpuxor_ck",
178 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
181 static struct clk armtim_ck
= {
183 .alias
= "mputim_ck",
184 .parent
= &ck_ref
, /* either CLKIN or DPLL1 */
185 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
188 static struct clk armwdt_ck
= {
193 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
197 static struct clk arminth_ck16xx
= {
198 .name
= "arminth_ck",
200 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
201 /* Note: On 16xx the frequency can be divided by 2 by programming
202 * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
204 * 1510 version is in TC clocks.
208 static struct clk dsp_ck
= {
211 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
214 static struct clk dspmmu_ck
= {
217 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
|
221 static struct clk dspper_ck
= {
224 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
227 static struct clk dspxor_ck
= {
230 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
233 static struct clk dsptim_ck
= {
236 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
239 static struct clk tc_ck
= {
242 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
|
243 CLOCK_IN_OMAP730
| CLOCK_IN_OMAP310
|
247 static struct clk arminth_ck15xx
= {
248 .name
= "arminth_ck",
250 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
251 /* Note: On 1510 the frequency follows TC_CK
253 * 16xx version is in MPU clocks.
257 static struct clk tipb_ck
= {
258 /* No-idle controlled by "tc_ck" */
261 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
264 static struct clk l3_ocpi_ck
= {
265 /* No-idle controlled by "tc_ck" */
266 .name
= "l3_ocpi_ck",
268 .flags
= CLOCK_IN_OMAP16XX
,
271 static struct clk tc1_ck
= {
274 .flags
= CLOCK_IN_OMAP16XX
,
277 static struct clk tc2_ck
= {
280 .flags
= CLOCK_IN_OMAP16XX
,
283 static struct clk dma_ck
= {
284 /* No-idle controlled by "tc_ck" */
287 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
291 static struct clk dma_lcdfree_ck
= {
292 .name
= "dma_lcdfree_ck",
294 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
297 static struct clk api_ck
= {
301 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
304 static struct clk lb_ck
= {
307 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
310 static struct clk lbfree_ck
= {
313 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
316 static struct clk hsab_ck
= {
319 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
322 static struct clk rhea1_ck
= {
325 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
328 static struct clk rhea2_ck
= {
331 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
334 static struct clk lcd_ck_16xx
= {
337 .flags
= CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP730
,
340 static struct clk lcd_ck_1510
= {
343 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
346 static struct clk uart1_1510
= {
348 /* Direct from ULPD, no real parent */
349 .parent
= &armper_ck
, /* either armper_ck or dpll4 */
351 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
354 static struct clk uart1_16xx
= {
356 /* Direct from ULPD, no real parent */
357 .parent
= &armper_ck
,
359 .flags
= CLOCK_IN_OMAP16XX
,
362 static struct clk uart2_ck
= {
364 /* Direct from ULPD, no real parent */
365 .parent
= &armper_ck
, /* either armper_ck or dpll4 */
367 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
|
371 static struct clk uart3_1510
= {
373 /* Direct from ULPD, no real parent */
374 .parent
= &armper_ck
, /* either armper_ck or dpll4 */
376 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
| ALWAYS_ENABLED
,
379 static struct clk uart3_16xx
= {
381 /* Direct from ULPD, no real parent */
382 .parent
= &armper_ck
,
384 .flags
= CLOCK_IN_OMAP16XX
,
387 static struct clk usb_clk0
= { /* 6 MHz output on W4_USB_CLK0 */
390 /* Direct from ULPD, no parent */
392 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
395 static struct clk usb_hhc_ck1510
= {
396 .name
= "usb_hhc_ck",
397 /* Direct from ULPD, no parent */
398 .rate
= 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
399 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP310
,
402 static struct clk usb_hhc_ck16xx
= {
403 .name
= "usb_hhc_ck",
404 /* Direct from ULPD, no parent */
406 /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
407 .flags
= CLOCK_IN_OMAP16XX
,
410 static struct clk usb_w2fc_mclk
= {
411 .name
= "usb_w2fc_mclk",
412 .alias
= "usb_w2fc_ck",
415 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
418 static struct clk mclk_1510
= {
420 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
422 .flags
= CLOCK_IN_OMAP1510
,
425 static struct clk bclk_310
= {
426 .name
= "bt_mclk_out", /* Alias midi_mclk_out? */
427 .parent
= &armper_ck
,
428 .flags
= CLOCK_IN_OMAP310
,
431 static struct clk mclk_310
= {
432 .name
= "com_mclk_out",
433 .parent
= &armper_ck
,
434 .flags
= CLOCK_IN_OMAP310
,
437 static struct clk mclk_16xx
= {
439 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
440 .flags
= CLOCK_IN_OMAP16XX
,
443 static struct clk bclk_1510
= {
445 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
447 .flags
= CLOCK_IN_OMAP1510
,
450 static struct clk bclk_16xx
= {
452 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
453 .flags
= CLOCK_IN_OMAP16XX
,
456 static struct clk mmc1_ck
= {
459 /* Functional clock is direct from ULPD, interface clock is ARMPER */
460 .parent
= &armper_ck
, /* either armper_ck or dpll4 */
462 .flags
= CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
| CLOCK_IN_OMAP310
,
465 static struct clk mmc2_ck
= {
468 /* Functional clock is direct from ULPD, interface clock is ARMPER */
469 .parent
= &armper_ck
,
471 .flags
= CLOCK_IN_OMAP16XX
,
474 static struct clk cam_mclk
= {
476 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
480 static struct clk cam_exclk
= {
482 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
483 /* Either 12M from cam.mclk or 48M from dpll4 */
487 static struct clk cam_lclk
= {
489 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
,
492 static struct clk i2c_fck
= {
495 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
|
497 .parent
= &armxor_ck
,
500 static struct clk i2c_ick
= {
503 .flags
= CLOCK_IN_OMAP16XX
| ALWAYS_ENABLED
,
504 .parent
= &armper_ck
,
507 static struct clk clk32k
= {
509 .flags
= CLOCK_IN_OMAP310
| CLOCK_IN_OMAP1510
| CLOCK_IN_OMAP16XX
|
510 CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
511 .parent
= &xtal_osc32k
,
514 static struct clk ref_clk
= {
516 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
517 .rate
= 12000000, /* 12 MHz or 13 MHz or 19.2 MHz */
518 /*.parent = sys.xtalin */
521 static struct clk apll_96m
= {
523 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
525 /*.parent = ref_clk */
528 static struct clk apll_54m
= {
530 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
532 /*.parent = ref_clk */
535 static struct clk sys_clk
= {
537 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
539 /*.parent = sys.xtalin */
542 static struct clk sleep_clk
= {
544 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
546 /*.parent = sys.xtalin */
549 static struct clk dpll_ck
= {
551 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
555 static struct clk dpll_x2_ck
= {
557 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
561 static struct clk wdt1_sys_clk
= {
562 .name
= "wdt1_sys_clk",
563 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
| ALWAYS_ENABLED
,
565 /*.parent = sys.xtalin */
568 static struct clk func_96m_clk
= {
569 .name
= "func_96m_clk",
570 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
575 static struct clk func_48m_clk
= {
576 .name
= "func_48m_clk",
577 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
582 static struct clk func_12m_clk
= {
583 .name
= "func_12m_clk",
584 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
589 static struct clk func_54m_clk
= {
590 .name
= "func_54m_clk",
591 .flags
= CLOCK_IN_OMAP242X
,
596 static struct clk sys_clkout
= {
598 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
602 static struct clk sys_clkout2
= {
604 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
608 static struct clk core_clk
= {
610 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
611 .parent
= &dpll_x2_ck
, /* Switchable between dpll_ck and clk32k */
614 static struct clk l3_clk
= {
616 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
620 static struct clk core_l4_iclk
= {
621 .name
= "core_l4_iclk",
622 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
626 static struct clk wu_l4_iclk
= {
627 .name
= "wu_l4_iclk",
628 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
632 static struct clk core_l3_iclk
= {
633 .name
= "core_l3_iclk",
634 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
638 static struct clk core_l4_usb_clk
= {
639 .name
= "core_l4_usb_clk",
640 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
644 static struct clk wu_gpt1_clk
= {
645 .name
= "wu_gpt1_clk",
646 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
650 static struct clk wu_32k_clk
= {
651 .name
= "wu_32k_clk",
652 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
656 static struct clk uart1_fclk
= {
657 .name
= "uart1_fclk",
658 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
659 .parent
= &func_48m_clk
,
662 static struct clk uart1_iclk
= {
663 .name
= "uart1_iclk",
664 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
665 .parent
= &core_l4_iclk
,
668 static struct clk uart2_fclk
= {
669 .name
= "uart2_fclk",
670 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
671 .parent
= &func_48m_clk
,
674 static struct clk uart2_iclk
= {
675 .name
= "uart2_iclk",
676 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
677 .parent
= &core_l4_iclk
,
680 static struct clk uart3_fclk
= {
681 .name
= "uart3_fclk",
682 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
683 .parent
= &func_48m_clk
,
686 static struct clk uart3_iclk
= {
687 .name
= "uart3_iclk",
688 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
689 .parent
= &core_l4_iclk
,
692 static struct clk mpu_fclk
= {
694 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
698 static struct clk mpu_iclk
= {
700 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
704 static struct clk int_m_fclk
= {
705 .name
= "int_m_fclk",
706 .alias
= "mpu_intc_fclk",
707 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
711 static struct clk int_m_iclk
= {
712 .name
= "int_m_iclk",
713 .alias
= "mpu_intc_iclk",
714 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
718 static struct clk core_gpt2_clk
= {
719 .name
= "core_gpt2_clk",
720 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
724 static struct clk core_gpt3_clk
= {
725 .name
= "core_gpt3_clk",
726 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
730 static struct clk core_gpt4_clk
= {
731 .name
= "core_gpt4_clk",
732 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
736 static struct clk core_gpt5_clk
= {
737 .name
= "core_gpt5_clk",
738 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
742 static struct clk core_gpt6_clk
= {
743 .name
= "core_gpt6_clk",
744 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
748 static struct clk core_gpt7_clk
= {
749 .name
= "core_gpt7_clk",
750 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
754 static struct clk core_gpt8_clk
= {
755 .name
= "core_gpt8_clk",
756 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
760 static struct clk core_gpt9_clk
= {
761 .name
= "core_gpt9_clk",
762 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
766 static struct clk core_gpt10_clk
= {
767 .name
= "core_gpt10_clk",
768 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
772 static struct clk core_gpt11_clk
= {
773 .name
= "core_gpt11_clk",
774 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
778 static struct clk core_gpt12_clk
= {
779 .name
= "core_gpt12_clk",
780 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
784 static struct clk mcbsp1_clk
= {
786 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
788 .parent
= &func_96m_clk
,
791 static struct clk mcbsp2_clk
= {
793 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
795 .parent
= &func_96m_clk
,
798 static struct clk emul_clk
= {
800 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
801 .parent
= &func_54m_clk
,
804 static struct clk sdma_fclk
= {
806 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
810 static struct clk sdma_iclk
= {
812 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
813 .parent
= &core_l3_iclk
, /* core_l4_iclk for the configuration port */
816 static struct clk i2c1_fclk
= {
818 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
819 .parent
= &func_12m_clk
,
823 static struct clk i2c1_iclk
= {
825 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
826 .parent
= &core_l4_iclk
,
829 static struct clk i2c2_fclk
= {
831 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
832 .parent
= &func_12m_clk
,
836 static struct clk i2c2_iclk
= {
838 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
839 .parent
= &core_l4_iclk
,
842 static struct clk gpio_dbclk
[5] = {
844 .name
= "gpio1_dbclk",
845 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
846 .parent
= &wu_32k_clk
,
848 .name
= "gpio2_dbclk",
849 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
850 .parent
= &wu_32k_clk
,
852 .name
= "gpio3_dbclk",
853 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
854 .parent
= &wu_32k_clk
,
856 .name
= "gpio4_dbclk",
857 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
858 .parent
= &wu_32k_clk
,
860 .name
= "gpio5_dbclk",
861 .flags
= CLOCK_IN_OMAP243X
,
862 .parent
= &wu_32k_clk
,
866 static struct clk gpio_iclk
= {
868 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
869 .parent
= &wu_l4_iclk
,
872 static struct clk mmc_fck
= {
874 .flags
= CLOCK_IN_OMAP242X
,
875 .parent
= &func_96m_clk
,
878 static struct clk mmc_ick
= {
880 .flags
= CLOCK_IN_OMAP242X
,
881 .parent
= &core_l4_iclk
,
884 static struct clk spi_fclk
[3] = {
887 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
888 .parent
= &func_48m_clk
,
891 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
892 .parent
= &func_48m_clk
,
895 .flags
= CLOCK_IN_OMAP243X
,
896 .parent
= &func_48m_clk
,
900 static struct clk dss_clk
[2] = {
903 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
907 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
912 static struct clk dss_54m_clk
= {
913 .name
= "dss_54m_clk",
914 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
915 .parent
= &func_54m_clk
,
918 static struct clk dss_l3_iclk
= {
919 .name
= "dss_l3_iclk",
920 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
921 .parent
= &core_l3_iclk
,
924 static struct clk dss_l4_iclk
= {
925 .name
= "dss_l4_iclk",
926 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
927 .parent
= &core_l4_iclk
,
930 static struct clk spi_iclk
[3] = {
933 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
934 .parent
= &core_l4_iclk
,
937 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
938 .parent
= &core_l4_iclk
,
941 .flags
= CLOCK_IN_OMAP243X
,
942 .parent
= &core_l4_iclk
,
946 static struct clk omapctrl_clk
= {
947 .name
= "omapctrl_iclk",
948 .flags
= CLOCK_IN_OMAP242X
| CLOCK_IN_OMAP243X
,
949 /* XXX Should be in WKUP domain */
950 .parent
= &core_l4_iclk
,
953 static struct clk
*onchip_clks
[] = {
956 /* non-ULPD clocks */
976 &arminth_ck15xx
, &arminth_ck16xx
,
1008 &usb_hhc_ck1510
, &usb_hhc_ck16xx
,
1009 &mclk_1510
, &mclk_16xx
, &mclk_310
,
1010 &bclk_1510
, &bclk_16xx
, &bclk_310
,
1018 /* Virtual clocks */
1099 void omap_clk_adduser(struct clk
*clk
, qemu_irq user
)
1103 for (i
= clk
->users
; *i
; i
++);
1107 struct clk
*omap_findclk(struct omap_mpu_state_s
*mpu
, const char *name
)
1111 for (i
= mpu
->clks
; i
->name
; i
++)
1112 if (!strcmp(i
->name
, name
) || (i
->alias
&& !strcmp(i
->alias
, name
)))
1114 hw_error("%s: %s not found\n", __func__
, name
);
1117 void omap_clk_get(struct clk
*clk
)
1122 void omap_clk_put(struct clk
*clk
)
1124 if (!(clk
->usecount
--))
1125 hw_error("%s: %s is not in use\n", __func__
, clk
->name
);
1128 static void omap_clk_update(struct clk
*clk
)
1130 int parent
, running
;
1135 parent
= clk
->parent
->running
;
1139 running
= parent
&& (clk
->enabled
||
1140 ((clk
->flags
& ALWAYS_ENABLED
) && clk
->usecount
));
1141 if (clk
->running
!= running
) {
1142 clk
->running
= running
;
1143 for (user
= clk
->users
; *user
; user
++)
1144 qemu_set_irq(*user
, running
);
1145 for (i
= clk
->child1
; i
; i
= i
->sibling
)
1150 static void omap_clk_rate_update_full(struct clk
*clk
, unsigned long int rate
,
1151 unsigned long int div
, unsigned long int mult
)
1156 clk
->rate
= muldiv64(rate
, mult
, div
);
1158 for (user
= clk
->users
; *user
; user
++)
1159 qemu_irq_raise(*user
);
1160 for (i
= clk
->child1
; i
; i
= i
->sibling
)
1161 omap_clk_rate_update_full(i
, rate
,
1162 div
* i
->divisor
, mult
* i
->multiplier
);
1165 static void omap_clk_rate_update(struct clk
*clk
)
1168 unsigned long int div
, mult
= div
= 1;
1170 for (i
= clk
; i
->parent
; i
= i
->parent
) {
1172 mult
*= i
->multiplier
;
1175 omap_clk_rate_update_full(clk
, i
->rate
, div
, mult
);
1178 void omap_clk_reparent(struct clk
*clk
, struct clk
*parent
)
1183 for (p
= &clk
->parent
->child1
; *p
!= clk
; p
= &(*p
)->sibling
);
1187 clk
->parent
= parent
;
1189 clk
->sibling
= parent
->child1
;
1190 parent
->child1
= clk
;
1191 omap_clk_update(clk
);
1192 omap_clk_rate_update(clk
);
1194 clk
->sibling
= NULL
;
1197 void omap_clk_onoff(struct clk
*clk
, int on
)
1200 omap_clk_update(clk
);
1203 void omap_clk_canidle(struct clk
*clk
, int can
)
1211 void omap_clk_setrate(struct clk
*clk
, int divide
, int multiply
)
1213 clk
->divisor
= divide
;
1214 clk
->multiplier
= multiply
;
1215 omap_clk_rate_update(clk
);
1218 int64_t omap_clk_getrate(omap_clk clk
)
1223 void omap_clk_init(struct omap_mpu_state_s
*mpu
)
1225 struct clk
**i
, *j
, *k
;
1229 if (cpu_is_omap310(mpu
))
1230 flag
= CLOCK_IN_OMAP310
;
1231 else if (cpu_is_omap1510(mpu
))
1232 flag
= CLOCK_IN_OMAP1510
;
1233 else if (cpu_is_omap2410(mpu
) || cpu_is_omap2420(mpu
))
1234 flag
= CLOCK_IN_OMAP242X
;
1235 else if (cpu_is_omap2430(mpu
))
1236 flag
= CLOCK_IN_OMAP243X
;
1237 else if (cpu_is_omap3430(mpu
))
1238 flag
= CLOCK_IN_OMAP243X
;
1242 for (i
= onchip_clks
, count
= 0; *i
; i
++)
1243 if ((*i
)->flags
& flag
)
1245 mpu
->clks
= g_new0(struct clk
, count
+ 1);
1246 for (i
= onchip_clks
, j
= mpu
->clks
; *i
; i
++)
1247 if ((*i
)->flags
& flag
) {
1248 memcpy(j
, *i
, sizeof(struct clk
));
1249 for (k
= mpu
->clks
; k
< j
; k
++)
1250 if (j
->parent
&& !strcmp(j
->parent
->name
, k
->name
)) {
1252 j
->sibling
= k
->child1
;
1254 } else if (k
->parent
&& !strcmp(k
->parent
->name
, j
->name
)) {
1256 k
->sibling
= j
->child1
;
1259 j
->divisor
= j
->divisor
?: 1;
1260 j
->multiplier
= j
->multiplier
?: 1;
1263 for (j
= mpu
->clks
; count
--; j
++) {
1265 omap_clk_rate_update(j
);