summaryrefslogtreecommitdiffstats
path: root/qemu/hw/misc/omap_clk.c
blob: 19151d07d62c22da52ed3c6f0452373e0982ded1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
/*
 * OMAP clocks.
 *
 * Copyright (C) 2006-2008 Andrzej Zaborowski  <balrog@zabor.org>
 *
 * Clocks data comes in part from arch/arm/mach-omap1/clock.h in Linux.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, see <http://www.gnu.org/licenses/>.
 */
#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/arm/omap.h"

struct clk {
    const char *name;
    const char *alias;
    struct clk *parent;
    struct clk *child1;
    struct clk *sibling;
#define ALWAYS_ENABLED		(1 << 0)
#define CLOCK_IN_OMAP310	(1 << 10)
#define CLOCK_IN_OMAP730	(1 << 11)
#define CLOCK_IN_OMAP1510	(1 << 12)
#define CLOCK_IN_OMAP16XX	(1 << 13)
#define CLOCK_IN_OMAP242X	(1 << 14)
#define CLOCK_IN_OMAP243X	(1 << 15)
#define CLOCK_IN_OMAP343X	(1 << 16)
    uint32_t flags;
    int id;

    int running;		/* Is currently ticking */
    int enabled;		/* Is enabled, regardless of its input clk */
    unsigned long rate;		/* Current rate (if .running) */
    unsigned int divisor;	/* Rate relative to input (if .enabled) */
    unsigned int multiplier;	/* Rate relative to input (if .enabled) */
    qemu_irq users[16];		/* Who to notify on change */
    int usecount;		/* Automatically idle when unused */
};

static struct clk xtal_osc12m = {
    .name	= "xtal_osc_12m",
    .rate	= 12000000,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk xtal_osc32k = {
    .name	= "xtal_osc_32k",
    .rate	= 32768,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
};

static struct clk ck_ref = {
    .name	= "ck_ref",
    .alias	= "clkin",
    .parent	= &xtal_osc12m,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

/* If a dpll is disabled it becomes a bypass, child clocks don't stop */
static struct clk dpll1 = {
    .name	= "dpll1",
    .parent	= &ck_ref,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

static struct clk dpll2 = {
    .name	= "dpll2",
    .parent	= &ck_ref,
    .flags	= CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
};

static struct clk dpll3 = {
    .name	= "dpll3",
    .parent	= &ck_ref,
    .flags	= CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
};

static struct clk dpll4 = {
    .name	= "dpll4",
    .parent	= &ck_ref,
    .multiplier	= 4,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk apll = {
    .name	= "apll",
    .parent	= &ck_ref,
    .multiplier	= 48,
    .divisor	= 12,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk ck_48m = {
    .name	= "ck_48m",
    .parent	= &dpll4,	/* either dpll4 or apll */
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk ck_dpll1out = {
    .name	= "ck_dpll1out",
    .parent	= &dpll1,
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk sossi_ck = {
    .name	= "ck_sossi",
    .parent	= &ck_dpll1out,
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk clkm1 = {
    .name	= "clkm1",
    .alias	= "ck_gen1",
    .parent	= &dpll1,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

static struct clk clkm2 = {
    .name	= "clkm2",
    .alias	= "ck_gen2",
    .parent	= &dpll1,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

static struct clk clkm3 = {
    .name	= "clkm3",
    .alias	= "ck_gen3",
    .parent	= &dpll1,	/* either dpll1 or ck_ref */
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

static struct clk arm_ck = {
    .name	= "arm_ck",
    .alias	= "mpu_ck",
    .parent	= &clkm1,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

static struct clk armper_ck = {
    .name	= "armper_ck",
    .alias	= "mpuper_ck",
    .parent	= &clkm1,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk arm_gpio_ck = {
    .name	= "arm_gpio_ck",
    .alias	= "mpu_gpio_ck",
    .parent	= &clkm1,
    .divisor	= 1,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310,
};

static struct clk armxor_ck = {
    .name	= "armxor_ck",
    .alias	= "mpuxor_ck",
    .parent	= &ck_ref,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk armtim_ck = {
    .name	= "armtim_ck",
    .alias	= "mputim_ck",
    .parent	= &ck_ref,	/* either CLKIN or DPLL1 */
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk armwdt_ck = {
    .name	= "armwdt_ck",
    .alias	= "mpuwd_ck",
    .parent	= &clkm1,
    .divisor	= 14,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

static struct clk arminth_ck16xx = {
    .name	= "arminth_ck",
    .parent	= &arm_ck,
    .flags	= CLOCK_IN_OMAP16XX | ALWAYS_ENABLED,
    /* Note: On 16xx the frequency can be divided by 2 by programming
     * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
     *
     * 1510 version is in TC clocks.
     */
};

static struct clk dsp_ck = {
    .name	= "dsp_ck",
    .parent	= &clkm2,
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
};

static struct clk dspmmu_ck = {
    .name	= "dspmmu_ck",
    .parent	= &clkm2,
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
            ALWAYS_ENABLED,
};

static struct clk dspper_ck = {
    .name	= "dspper_ck",
    .parent	= &clkm2,
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
};

static struct clk dspxor_ck = {
    .name	= "dspxor_ck",
    .parent	= &ck_ref,
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
};

static struct clk dsptim_ck = {
    .name	= "dsptim_ck",
    .parent	= &ck_ref,
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
};

static struct clk tc_ck = {
    .name	= "tc_ck",
    .parent	= &clkm3,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
            CLOCK_IN_OMAP730 | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

static struct clk arminth_ck15xx = {
    .name	= "arminth_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
    /* Note: On 1510 the frequency follows TC_CK
     *
     * 16xx version is in MPU clocks.
     */
};

static struct clk tipb_ck = {
    /* No-idle controlled by "tc_ck" */
    .name	= "tipb_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
};

static struct clk l3_ocpi_ck = {
    /* No-idle controlled by "tc_ck" */
    .name	= "l3_ocpi_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk tc1_ck = {
    .name	= "tc1_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk tc2_ck = {
    .name	= "tc2_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk dma_ck = {
    /* No-idle controlled by "tc_ck" */
    .name	= "dma_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

static struct clk dma_lcdfree_ck = {
    .name	= "dma_lcdfree_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP16XX | ALWAYS_ENABLED,
};

static struct clk api_ck = {
    .name	= "api_ck",
    .alias	= "mpui_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk lb_ck = {
    .name	= "lb_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310,
};

static struct clk lbfree_ck = {
    .name	= "lbfree_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310,
};

static struct clk hsab_ck = {
    .name	= "hsab_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310,
};

static struct clk rhea1_ck = {
    .name	= "rhea1_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP16XX | ALWAYS_ENABLED,
};

static struct clk rhea2_ck = {
    .name	= "rhea2_ck",
    .parent	= &tc_ck,
    .flags	= CLOCK_IN_OMAP16XX | ALWAYS_ENABLED,
};

static struct clk lcd_ck_16xx = {
    .name	= "lcd_ck",
    .parent	= &clkm3,
    .flags	= CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP730,
};

static struct clk lcd_ck_1510 = {
    .name	= "lcd_ck",
    .parent	= &clkm3,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310,
};

static struct clk uart1_1510 = {
    .name	= "uart1_ck",
    /* Direct from ULPD, no real parent */
    .parent	= &armper_ck,	/* either armper_ck or dpll4 */
    .rate	= 12000000,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
};

static struct clk uart1_16xx = {
    .name	= "uart1_ck",
    /* Direct from ULPD, no real parent */
    .parent	= &armper_ck,
    .rate	= 48000000,
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk uart2_ck = {
    .name	= "uart2_ck",
    /* Direct from ULPD, no real parent */
    .parent	= &armper_ck,	/* either armper_ck or dpll4 */
    .rate	= 12000000,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310 |
            ALWAYS_ENABLED,
};

static struct clk uart3_1510 = {
    .name	= "uart3_ck",
    /* Direct from ULPD, no real parent */
    .parent	= &armper_ck,	/* either armper_ck or dpll4 */
    .rate	= 12000000,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
};

static struct clk uart3_16xx = {
    .name	= "uart3_ck",
    /* Direct from ULPD, no real parent */
    .parent	= &armper_ck,
    .rate	= 48000000,
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk usb_clk0 = {	/* 6 MHz output on W4_USB_CLK0 */
    .name	= "usb_clk0",
    .alias	= "usb.clko",
    /* Direct from ULPD, no parent */
    .rate	= 6000000,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk usb_hhc_ck1510 = {
    .name	= "usb_hhc_ck",
    /* Direct from ULPD, no parent */
    .rate	= 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310,
};

static struct clk usb_hhc_ck16xx = {
    .name	= "usb_hhc_ck",
    /* Direct from ULPD, no parent */
    .rate	= 48000000,
    /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk usb_w2fc_mclk = {
    .name	= "usb_w2fc_mclk",
    .alias	= "usb_w2fc_ck",
    .parent	= &ck_48m,
    .rate	= 48000000,
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
};

static struct clk mclk_1510 = {
    .name	= "mclk",
    /* Direct from ULPD, no parent. May be enabled by ext hardware. */
    .rate	= 12000000,
    .flags	= CLOCK_IN_OMAP1510,
};

static struct clk bclk_310 = {
    .name	= "bt_mclk_out",	/* Alias midi_mclk_out? */
    .parent	= &armper_ck,
    .flags	= CLOCK_IN_OMAP310,
};

static struct clk mclk_310 = {
    .name	= "com_mclk_out",
    .parent	= &armper_ck,
    .flags	= CLOCK_IN_OMAP310,
};

static struct clk mclk_16xx = {
    .name	= "mclk",
    /* Direct from ULPD, no parent. May be enabled by ext hardware. */
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk bclk_1510 = {
    .name	= "bclk",
    /* Direct from ULPD, no parent. May be enabled by ext hardware. */
    .rate	= 12000000,
    .flags	= CLOCK_IN_OMAP1510,
};

static struct clk bclk_16xx = {
    .name	= "bclk",
    /* Direct from ULPD, no parent. May be enabled by ext hardware. */
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk mmc1_ck = {
    .name	= "mmc_ck",
    .id		= 1,
    /* Functional clock is direct from ULPD, interface clock is ARMPER */
    .parent	= &armper_ck,	/* either armper_ck or dpll4 */
    .rate	= 48000000,
    .flags	= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP310,
};

static struct clk mmc2_ck = {
    .name	= "mmc_ck",
    .id		= 2,
    /* Functional clock is direct from ULPD, interface clock is ARMPER */
    .parent	= &armper_ck,
    .rate	= 48000000,
    .flags	= CLOCK_IN_OMAP16XX,
};

static struct clk cam_mclk = {
    .name	= "cam.mclk",
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
    .rate	= 12000000,
};

static struct clk cam_exclk = {
    .name	= "cam.exclk",
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
    /* Either 12M from cam.mclk or 48M from dpll4 */
    .parent	= &cam_mclk,
};

static struct clk cam_lclk = {
    .name	= "cam.lclk",
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX,
};

static struct clk i2c_fck = {
    .name	= "i2c_fck",
    .id		= 1,
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
            ALWAYS_ENABLED,
    .parent	= &armxor_ck,
};

static struct clk i2c_ick = {
    .name	= "i2c_ick",
    .id		= 1,
    .flags	= CLOCK_IN_OMAP16XX | ALWAYS_ENABLED,
    .parent	= &armper_ck,
};

static struct clk clk32k = {
    .name	= "clk32-kHz",
    .flags	= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
            CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ALWAYS_ENABLED,
    .parent	= &xtal_osc32k,
};

static struct clk ref_clk = {
    .name	= "ref_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ALWAYS_ENABLED,
    .rate	= 12000000,	/* 12 MHz or 13 MHz or 19.2 MHz */
    /*.parent	= sys.xtalin */
};

static struct clk apll_96m = {
    .name	= "apll_96m",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ALWAYS_ENABLED,
    .rate	= 96000000,
    /*.parent	= ref_clk */
};

static struct clk apll_54m = {
    .name	= "apll_54m",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ALWAYS_ENABLED,
    .rate	= 54000000,
    /*.parent	= ref_clk */
};

static struct clk sys_clk = {
    .name	= "sys_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ALWAYS_ENABLED,
    .rate	= 32768,
    /*.parent	= sys.xtalin */
};

static struct clk sleep_clk = {
    .name	= "sleep_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ALWAYS_ENABLED,
    .rate	= 32768,
    /*.parent	= sys.xtalin */
};

static struct clk dpll_ck = {
    .name	= "dpll",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ALWAYS_ENABLED,
    .parent	= &ref_clk,
};

static struct clk dpll_x2_ck = {
    .name	= "dpll_x2",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ALWAYS_ENABLED,
    .parent	= &ref_clk,
};

static struct clk wdt1_sys_clk = {
    .name	= "wdt1_sys_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | ALWAYS_ENABLED,
    .rate	= 32768,
    /*.parent	= sys.xtalin */
};

static struct clk func_96m_clk = {
    .name	= "func_96m_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .divisor	= 1,
    .parent	= &apll_96m,
};

static struct clk func_48m_clk = {
    .name	= "func_48m_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .divisor	= 2,
    .parent	= &apll_96m,
};

static struct clk func_12m_clk = {
    .name	= "func_12m_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .divisor	= 8,
    .parent	= &apll_96m,
};

static struct clk func_54m_clk = {
    .name	= "func_54m_clk",
    .flags	= CLOCK_IN_OMAP242X,
    .divisor	= 1,
    .parent	= &apll_54m,
};

static struct clk sys_clkout = {
    .name	= "clkout",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk sys_clkout2 = {
    .name	= "clkout2",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_clk = {
    .name	= "core_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &dpll_x2_ck,	/* Switchable between dpll_ck and clk32k */
};

static struct clk l3_clk = {
    .name	= "l3_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_clk,
};

static struct clk core_l4_iclk = {
    .name	= "core_l4_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &l3_clk,
};

static struct clk wu_l4_iclk = {
    .name	= "wu_l4_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &l3_clk,
};

static struct clk core_l3_iclk = {
    .name	= "core_l3_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_clk,
};

static struct clk core_l4_usb_clk = {
    .name	= "core_l4_usb_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &l3_clk,
};

static struct clk wu_gpt1_clk = {
    .name	= "wu_gpt1_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk wu_32k_clk = {
    .name	= "wu_32k_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk uart1_fclk = {
    .name	= "uart1_fclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &func_48m_clk,
};

static struct clk uart1_iclk = {
    .name	= "uart1_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_l4_iclk,
};

static struct clk uart2_fclk = {
    .name	= "uart2_fclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &func_48m_clk,
};

static struct clk uart2_iclk = {
    .name	= "uart2_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_l4_iclk,
};

static struct clk uart3_fclk = {
    .name	= "uart3_fclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &func_48m_clk,
};

static struct clk uart3_iclk = {
    .name	= "uart3_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_l4_iclk,
};

static struct clk mpu_fclk = {
    .name	= "mpu_fclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_clk,
};

static struct clk mpu_iclk = {
    .name	= "mpu_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_clk,
};

static struct clk int_m_fclk = {
    .name	= "int_m_fclk",
    .alias	= "mpu_intc_fclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_clk,
};

static struct clk int_m_iclk = {
    .name	= "int_m_iclk",
    .alias	= "mpu_intc_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_clk,
};

static struct clk core_gpt2_clk = {
    .name	= "core_gpt2_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt3_clk = {
    .name	= "core_gpt3_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt4_clk = {
    .name	= "core_gpt4_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt5_clk = {
    .name	= "core_gpt5_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt6_clk = {
    .name	= "core_gpt6_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt7_clk = {
    .name	= "core_gpt7_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt8_clk = {
    .name	= "core_gpt8_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt9_clk = {
    .name	= "core_gpt9_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt10_clk = {
    .name	= "core_gpt10_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt11_clk = {
    .name	= "core_gpt11_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk core_gpt12_clk = {
    .name	= "core_gpt12_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &sys_clk,
};

static struct clk mcbsp1_clk = {
    .name	= "mcbsp1_cg",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .divisor	= 2,
    .parent	= &func_96m_clk,
};

static struct clk mcbsp2_clk = {
    .name	= "mcbsp2_cg",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .divisor	= 2,
    .parent	= &func_96m_clk,
};

static struct clk emul_clk = {
    .name	= "emul_ck",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &func_54m_clk,
};

static struct clk sdma_fclk = {
    .name	= "sdma_fclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &l3_clk,
};

static struct clk sdma_iclk = {
    .name	= "sdma_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_l3_iclk, /* core_l4_iclk for the configuration port */
};

static struct clk i2c1_fclk = {
    .name	= "i2c1.fclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &func_12m_clk,
    .divisor	= 1,
};

static struct clk i2c1_iclk = {
    .name	= "i2c1.iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_l4_iclk,
};

static struct clk i2c2_fclk = {
    .name	= "i2c2.fclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &func_12m_clk,
    .divisor	= 1,
};

static struct clk i2c2_iclk = {
    .name	= "i2c2.iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_l4_iclk,
};

static struct clk gpio_dbclk[5] = {
    {
        .name	= "gpio1_dbclk",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &wu_32k_clk,
    }, {
        .name	= "gpio2_dbclk",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &wu_32k_clk,
    }, {
        .name	= "gpio3_dbclk",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &wu_32k_clk,
    }, {
        .name	= "gpio4_dbclk",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &wu_32k_clk,
    }, {
        .name   = "gpio5_dbclk",
        .flags  = CLOCK_IN_OMAP243X,
        .parent = &wu_32k_clk,
    },
};

static struct clk gpio_iclk = {
    .name	= "gpio_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &wu_l4_iclk,
};

static struct clk mmc_fck = {
    .name	= "mmc_fclk",
    .flags	= CLOCK_IN_OMAP242X,
    .parent	= &func_96m_clk,
};

static struct clk mmc_ick = {
    .name	= "mmc_iclk",
    .flags	= CLOCK_IN_OMAP242X,
    .parent	= &core_l4_iclk,
};

static struct clk spi_fclk[3] = {
    {
        .name	= "spi1_fclk",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &func_48m_clk,
    }, {
        .name	= "spi2_fclk",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &func_48m_clk,
    }, {
        .name	= "spi3_fclk",
        .flags	= CLOCK_IN_OMAP243X,
        .parent	= &func_48m_clk,
    },
};

static struct clk dss_clk[2] = {
    {
        .name	= "dss_clk1",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &core_clk,
    }, {
        .name	= "dss_clk2",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &sys_clk,
    },
};

static struct clk dss_54m_clk = {
    .name	= "dss_54m_clk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &func_54m_clk,
};

static struct clk dss_l3_iclk = {
    .name	= "dss_l3_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_l3_iclk,
};

static struct clk dss_l4_iclk = {
    .name	= "dss_l4_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    .parent	= &core_l4_iclk,
};

static struct clk spi_iclk[3] = {
    {
        .name	= "spi1_iclk",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &core_l4_iclk,
    }, {
        .name	= "spi2_iclk",
        .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
        .parent	= &core_l4_iclk,
    }, {
        .name	= "spi3_iclk",
        .flags	= CLOCK_IN_OMAP243X,
        .parent	= &core_l4_iclk,
    },
};

static struct clk omapctrl_clk = {
    .name	= "omapctrl_iclk",
    .flags	= CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X,
    /* XXX Should be in WKUP domain */
    .parent	= &core_l4_iclk,
};

static struct clk *onchip_clks[] = {
    /* OMAP 1 */

    /* non-ULPD clocks */
    &xtal_osc12m,
    &xtal_osc32k,
    &ck_ref,
    &dpll1,
    &dpll2,
    &dpll3,
    &dpll4,
    &apll,
    &ck_48m,
    /* CK_GEN1 clocks */
    &clkm1,
    &ck_dpll1out,
    &sossi_ck,
    &arm_ck,
    &armper_ck,
    &arm_gpio_ck,
    &armxor_ck,
    &armtim_ck,
    &armwdt_ck,
    &arminth_ck15xx,  &arminth_ck16xx,
    /* CK_GEN2 clocks */
    &clkm2,
    &dsp_ck,
    &dspmmu_ck,
    &dspper_ck,
    &dspxor_ck,
    &dsptim_ck,
    /* CK_GEN3 clocks */
    &clkm3,
    &tc_ck,
    &tipb_ck,
    &l3_ocpi_ck,
    &tc1_ck,
    &tc2_ck,
    &dma_ck,
    &dma_lcdfree_ck,
    &api_ck,
    &lb_ck,
    &lbfree_ck,
    &hsab_ck,
    &rhea1_ck,
    &rhea2_ck,
    &lcd_ck_16xx,
    &lcd_ck_1510,
    /* ULPD clocks */
    &uart1_1510,
    &uart1_16xx,
    &uart2_ck,
    &uart3_1510,
    &uart3_16xx,
    &usb_clk0,
    &usb_hhc_ck1510, &usb_hhc_ck16xx,
    &mclk_1510,  &mclk_16xx, &mclk_310,
    &bclk_1510,  &bclk_16xx, &bclk_310,
    &mmc1_ck,
    &mmc2_ck,
    &cam_mclk,
    &cam_exclk,
    &cam_lclk,
    &clk32k,
    &usb_w2fc_mclk,
    /* Virtual clocks */
    &i2c_fck,
    &i2c_ick,

    /* OMAP 2 */

    &ref_clk,
    &apll_96m,
    &apll_54m,
    &sys_clk,
    &sleep_clk,
    &dpll_ck,
    &dpll_x2_ck,
    &wdt1_sys_clk,
    &func_96m_clk,
    &func_48m_clk,
    &func_12m_clk,
    &func_54m_clk,
    &sys_clkout,
    &sys_clkout2,
    &core_clk,
    &l3_clk,
    &core_l4_iclk,
    &wu_l4_iclk,
    &core_l3_iclk,
    &core_l4_usb_clk,
    &wu_gpt1_clk,
    &wu_32k_clk,
    &uart1_fclk,
    &uart1_iclk,
    &uart2_fclk,
    &uart2_iclk,
    &uart3_fclk,
    &uart3_iclk,
    &mpu_fclk,
    &mpu_iclk,
    &int_m_fclk,
    &int_m_iclk,
    &core_gpt2_clk,
    &core_gpt3_clk,
    &core_gpt4_clk,
    &core_gpt5_clk,
    &core_gpt6_clk,
    &core_gpt7_clk,
    &core_gpt8_clk,
    &core_gpt9_clk,
    &core_gpt10_clk,
    &core_gpt11_clk,
    &core_gpt12_clk,
    &mcbsp1_clk,
    &mcbsp2_clk,
    &emul_clk,
    &sdma_fclk,
    &sdma_iclk,
    &i2c1_fclk,
    &i2c1_iclk,
    &i2c2_fclk,
    &i2c2_iclk,
    &gpio_dbclk[0],
    &gpio_dbclk[1],
    &gpio_dbclk[2],
    &gpio_dbclk[3],
    &gpio_iclk,
    &mmc_fck,
    &mmc_ick,
    &spi_fclk[0],
    &spi_iclk[0],
    &spi_fclk[1],
    &spi_iclk[1],
    &spi_fclk[2],
    &spi_iclk[2],
    &dss_clk[0],
    &dss_clk[1],
    &dss_54m_clk,
    &dss_l3_iclk,
    &dss_l4_iclk,
    &omapctrl_clk,

    NULL
};

void omap_clk_adduser(struct clk *clk, qemu_irq user)
{
    qemu_irq *i;

    for (i = clk->users; *i; i ++);
    *i = user;
}

struct clk *omap_findclk(struct omap_mpu_state_s *mpu, const char *name)
{
    struct clk *i;

    for (i = mpu->clks; i->name; i ++)
        if (!strcmp(i->name, name) || (i->alias && !strcmp(i->alias, name)))
            return i;
    hw_error("%s: %s not found\n", __FUNCTION__, name);
}

void omap_clk_get(struct clk *clk)
{
    clk->usecount ++;
}

void omap_clk_put(struct clk *clk)
{
    if (!(clk->usecount --))
        hw_error("%s: %s is not in use\n", __FUNCTION__, clk->name);
}

static void omap_clk_update(struct clk *clk)
{
    int parent, running;
    qemu_irq *user;
    struct clk *i;

    if (clk->parent)
        parent = clk->parent->running;
    else
        parent = 1;

    running = parent && (clk->enabled ||
                    ((clk->flags & ALWAYS_ENABLED) && clk->usecount));
    if (clk->running != running) {
        clk->running = running;
        for (user = clk->users; *user; user ++)
            qemu_set_irq(*user, running);
        for (i = clk->child1; i; i = i->sibling)
            omap_clk_update(i);
    }
}

static void omap_clk_rate_update_full(struct clk *clk, unsigned long int rate,
                unsigned long int div, unsigned long int mult)
{
    struct clk *i;
    qemu_irq *user;

    clk->rate = muldiv64(rate, mult, div);
    if (clk->running)
        for (user = clk->users; *user; user ++)
            qemu_irq_raise(*user);
    for (i = clk->child1; i; i = i->sibling)
        omap_clk_rate_update_full(i, rate,
                        div * i->divisor, mult * i->multiplier);
}

static void omap_clk_rate_update(struct clk *clk)
{
    struct clk *i;
    unsigned long int div, mult = div = 1;

    for (i = clk; i->parent; i = i->parent) {
        div *= i->divisor;
        mult *= i->multiplier;
    }

    omap_clk_rate_update_full(clk, i->rate, div, mult);
}

void omap_clk_reparent(struct clk *clk, struct clk *parent)
{
    struct clk **p;

    if (clk->parent) {
        for (p = &clk->parent->child1; *p != clk; p = &(*p)->sibling);
        *p = clk->sibling;
    }

    clk->parent = parent;
    if (parent) {
        clk->sibling = parent->child1;
        parent->child1 = clk;
        omap_clk_update(clk);
        omap_clk_rate_update(clk);
    } else
        clk->sibling = NULL;
}

void omap_clk_onoff(struct clk *clk, int on)
{
    clk->enabled = on;
    omap_clk_update(clk);
}

void omap_clk_canidle(struct clk *clk, int can)
{
    if (can)
        omap_clk_put(clk);
    else
        omap_clk_get(clk);
}

void omap_clk_setrate(struct clk *clk, int divide, int multiply)
{
    clk->divisor = divide;
    clk->multiplier = multiply;
    omap_clk_rate_update(clk);
}

int64_t omap_clk_getrate(omap_clk clk)
{
    return clk->rate;
}

void omap_clk_init(struct omap_mpu_state_s *mpu)
{
    struct clk **i, *j, *k;
    int count;
    int flag;

    if (cpu_is_omap310(mpu))
        flag = CLOCK_IN_OMAP310;
    else if (cpu_is_omap1510(mpu))
        flag = CLOCK_IN_OMAP1510;
    else if (cpu_is_omap2410(mpu) || cpu_is_omap2420(mpu))
        flag = CLOCK_IN_OMAP242X;
    else if (cpu_is_omap2430(mpu))
        flag = CLOCK_IN_OMAP243X;
    else if (cpu_is_omap3430(mpu))
        flag = CLOCK_IN_OMAP243X;
    else
        return;

    for (i = onchip_clks, count = 0; *i; i ++)
        if ((*i)->flags & flag)
            count ++;
    mpu->clks = g_new0(struct clk, count + 1);
    for (i = onchip_clks, j = mpu->clks; *i; i ++)
        if ((*i)->flags & flag) {
            memcpy(j, *i, sizeof(struct clk));
            for (k = mpu->clks; k < j; k ++)
                if (j->parent && !strcmp(j->parent->name, k->name)) {
                    j->parent = k;
                    j->sibling = k->child1;
                    k->child1 = j;
                } else if (k->parent && !strcmp(k->parent->name, j->name)) {
                    k->parent = j;
                    k->sibling = j->child1;
                    j->child1 = k;
                }
            j->divisor = j->divisor ?: 1;
            j->multiplier = j->multiplier ?: 1;
            j ++;
        }
    for (j = mpu->clks; count --; j ++) {
        omap_clk_update(j);
        omap_clk_rate_update(j);
    }
}