1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <netdev.h>
26#include <asm/arch/omap2420.h>
27#include <asm/io.h>
28#include <asm/arch/bits.h>
29#include <asm/arch/mux.h>
30#include <asm/arch/sys_proto.h>
31#include <asm/arch/sys_info.h>
32#include <asm/arch/mem.h>
33#include <i2c.h>
34#include <asm/mach-types.h>
35
36DECLARE_GLOBAL_DATA_PTR;
37
38void wait_for_command_complete(unsigned int wd_base);
39
40
41
42
43
44static inline void delay (unsigned long loops)
45{
46 __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
47 "bne 1b":"=r" (loops):"0" (loops));
48}
49
50
51
52
53
54int board_init (void)
55{
56 gpmc_init();
57
58 gd->bd->bi_arch_number = MACH_TYPE_OMAP_H4;
59 gd->bd->bi_boot_params = (OMAP2420_SDRC_CS0+0x100);
60
61 return 0;
62}
63
64
65
66
67
68
69void try_unlock_sram(void)
70{
71
72 if (get_device_type() == GP_DEVICE) {
73 __raw_writel(0xFF, A_REQINFOPERM0);
74 __raw_writel(0xCFDE, A_READPERM0);
75 __raw_writel(0xCFDE, A_WRITEPERM0);
76 }
77}
78
79
80
81
82
83
84void s_init(void)
85{
86 int in_sdram = running_in_sdram();
87
88 watchdog_init();
89 set_muxconf_regs();
90 delay(100);
91 try_unlock_sram();
92
93 if(!in_sdram)
94 prcm_init();
95
96 peripheral_enable();
97 icache_enable();
98 if (!in_sdram)
99 sdrc_init();
100}
101
102
103
104
105
106int misc_init_r (void)
107{
108 ether_init();
109 return(0);
110}
111
112
113
114
115
116void watchdog_init(void)
117{
118
119
120
121
122 __raw_writel(WD_UNLOCK1 ,WD2_BASE+WSPR);
123 wait_for_command_complete(WD2_BASE);
124 __raw_writel(WD_UNLOCK2 ,WD2_BASE+WSPR);
125
126#if MPU_WD_CLOCKED
127 __raw_writel(WD_UNLOCK1 ,WD3_BASE+WSPR);
128 wait_for_command_complete(WD3_BASE);
129 __raw_writel(WD_UNLOCK2 ,WD3_BASE+WSPR);
130
131 __raw_writel(WD_UNLOCK1 ,WD4_BASE+WSPR);
132 wait_for_command_complete(WD4_BASE);
133 __raw_writel(WD_UNLOCK2 ,WD4_BASE+WSPR);
134#endif
135}
136
137
138
139
140
141void wait_for_command_complete(unsigned int wd_base)
142{
143 int pending = 1;
144 do {
145 pending = __raw_readl(wd_base+WWPS);
146 } while (pending);
147}
148
149
150
151
152
153
154void ether_init (void)
155{
156#ifdef CONFIG_DRIVER_LAN91C96
157 int cnt = 20;
158
159 __raw_writeb(0x3,OMAP2420_CTRL_BASE+0x10a);
160
161 __raw_writew(0x0, LAN_RESET_REGISTER);
162 do {
163 __raw_writew(0x1, LAN_RESET_REGISTER);
164 udelay (100);
165 if (cnt == 0)
166 goto h4reset_err_out;
167 --cnt;
168 } while (__raw_readw(LAN_RESET_REGISTER) != 0x1);
169
170 cnt = 20;
171
172 do {
173 __raw_writew(0x0, LAN_RESET_REGISTER);
174 udelay (100);
175 if (cnt == 0)
176 goto h4reset_err_out;
177 --cnt;
178 } while (__raw_readw(LAN_RESET_REGISTER) != 0x0000);
179 udelay (1000);
180
181 *((volatile unsigned char *) ETH_CONTROL_REG) &= ~0x01;
182 udelay (1000);
183
184 h4reset_err_out:
185 return;
186#endif
187}
188
189
190
191
192
193int dram_init (void)
194{
195 unsigned int size0=0,size1=0;
196 u32 mtype, btype, rev;
197 u8 chg_on = 0x5;
198 u8 vmode_on = 0x8C;
199 #define NOT_EARLY 0
200
201 i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
202
203 btype = get_board_type();
204 mtype = get_mem_type();
205 rev = get_cpu_rev();
206
207 display_board_info(btype);
208 if (btype == BOARD_H4_MENELAUS){
209 update_mux(btype,mtype);
210 i2c_write(I2C_MENELAUS, 0x20, 1, &chg_on, 1);
211 i2c_write(I2C_MENELAUS, 0x2, 1, &vmode_on, 1);
212 }
213
214 if ((mtype == DDR_COMBO) || (mtype == DDR_STACKED)) {
215 do_sdrc_init(SDRC_CS1_OSET, NOT_EARLY);
216 }
217 size0 = get_sdr_cs_size(SDRC_CS0_OSET);
218 size1 = get_sdr_cs_size(SDRC_CS1_OSET);
219
220 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
221 gd->bd->bi_dram[0].size = size0;
222 if(rev == CPU_2420_2422_ES1)
223 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
224 else
225 gd->bd->bi_dram[1].start = PHYS_SDRAM_1+size0;
226 gd->bd->bi_dram[1].size = size1;
227
228 return 0;
229}
230
231
232
233
234
235
236void set_muxconf_regs (void)
237{
238 muxSetupSDRC();
239 muxSetupGPMC();
240 muxSetupUsb0();
241 muxSetupUart3();
242 muxSetupI2C1();
243 muxSetupUART1();
244 muxSetupLCD();
245 muxSetupCamera();
246 muxSetupMMCSD();
247 muxSetupTouchScreen();
248 muxSetupHDQ();
249}
250
251
252
253
254
255void peripheral_enable(void)
256{
257 unsigned int v, if_clks=0, func_clks=0;
258
259
260 if_clks |= BIT4;
261 func_clks |= BIT4;
262 v = __raw_readl(CM_CLKSEL2_CORE) | 0x4;
263 __raw_writel(v, CM_CLKSEL2_CORE);
264 __raw_writel(0x1, CM_CLKSEL_WKUP);
265
266#ifdef CONFIG_SYS_NS16550
267
268 func_clks |= BIT21;
269 if_clks |= BIT21;
270#endif
271 v = __raw_readl(CM_ICLKEN1_CORE) | if_clks;
272 __raw_writel(v,CM_ICLKEN1_CORE );
273 v = __raw_readl(CM_FCLKEN1_CORE) | func_clks;
274 __raw_writel(v, CM_FCLKEN1_CORE);
275 delay(1000);
276
277#ifndef KERNEL_UPDATED
278 {
279#define V1 0xffffffff
280#define V2 0x00000007
281
282 __raw_writel(V1, CM_FCLKEN1_CORE);
283 __raw_writel(V2, CM_FCLKEN2_CORE);
284 __raw_writel(V1, CM_ICLKEN1_CORE);
285 __raw_writel(V1, CM_ICLKEN2_CORE);
286 }
287#endif
288}
289
290
291
292
293
294void muxSetupUsb0(void)
295{
296 volatile uint8 *MuxConfigReg;
297 volatile uint32 *otgCtrlReg;
298
299 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_PUEN;
300 *MuxConfigReg &= (uint8)(~0x1F);
301
302 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_VP;
303 *MuxConfigReg &= (uint8)(~0x1F);
304
305 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_VM;
306 *MuxConfigReg &= (uint8)(~0x1F);
307
308 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_RCV;
309 *MuxConfigReg &= (uint8)(~0x1F);
310
311 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_TXEN;
312 *MuxConfigReg &= (uint8)(~0x1F);
313
314 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_SE0;
315 *MuxConfigReg &= (uint8)(~0x1F);
316
317 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_DAT;
318 *MuxConfigReg &= (uint8)(~0x1F);
319
320
321 otgCtrlReg = (volatile uint32 *)USB_OTG_CTRL;
322 *otgCtrlReg |= 0x00040000;
323}
324
325
326
327
328
329void muxSetupUart3(void)
330{
331 volatile uint8 *MuxConfigReg;
332
333 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_UART3_TX_IRTX;
334 *MuxConfigReg &= (uint8)(~0x1F);
335
336 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_UART3_RX_IRRX;
337 *MuxConfigReg &= (uint8)(~0x1F);
338}
339
340
341
342
343
344void muxSetupI2C1(void)
345{
346 volatile unsigned char *MuxConfigReg;
347
348
349 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_I2C1_SCL;
350 *MuxConfigReg = 0x00 ;
351
352
353 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_I2C1_SDA;
354 *MuxConfigReg = 0x00 ;
355
356
357
358
359}
360
361
362
363
364
365void muxSetupUART1(void)
366{
367 volatile unsigned char *MuxConfigReg;
368
369
370 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_CTS;
371 *MuxConfigReg = 0x00 ;
372
373
374 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_RTS;
375 *MuxConfigReg = 0x00 ;
376
377
378 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_TX;
379 *MuxConfigReg = 0x00 ;
380
381
382 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_RX;
383 *MuxConfigReg = 0x00 ;
384}
385
386
387
388
389
390void muxSetupLCD(void)
391{
392 volatile unsigned char *MuxConfigReg;
393
394
395 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D0;
396 *MuxConfigReg = 0x00 ;
397
398
399 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D1;
400 *MuxConfigReg = 0x00 ;
401
402
403 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D2;
404 *MuxConfigReg = 0x00 ;
405
406
407 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D3;
408 *MuxConfigReg = 0x00 ;
409
410
411 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D4;
412 *MuxConfigReg = 0x00 ;
413
414
415 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D5;
416 *MuxConfigReg = 0x00 ;
417
418
419 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D6;
420 *MuxConfigReg = 0x00 ;
421
422
423 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D7;
424 *MuxConfigReg = 0x00 ;
425
426
427 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D8;
428 *MuxConfigReg = 0x00 ;
429
430
431 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D9;
432 *MuxConfigReg = 0x00 ;
433
434
435 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D10;
436 *MuxConfigReg = 0x00 ;
437
438
439 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D11;
440 *MuxConfigReg = 0x00 ;
441
442
443 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D12;
444 *MuxConfigReg = 0x00 ;
445
446
447 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D13;
448 *MuxConfigReg = 0x00 ;
449
450
451 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D14;
452 *MuxConfigReg = 0x00 ;
453
454
455 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D15;
456 *MuxConfigReg = 0x00 ;
457
458
459 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D16;
460 *MuxConfigReg = 0x00 ;
461
462
463 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D17;
464 *MuxConfigReg = 0x00 ;
465
466
467 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_PCLK;
468 *MuxConfigReg = 0x00 ;
469
470
471 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_VSYNC;
472 *MuxConfigReg = 0x00 ;
473
474
475 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_HSYNC;
476 *MuxConfigReg = 0x00 ;
477
478
479 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_ACBIAS;
480 *MuxConfigReg = 0x00 ;
481}
482
483
484
485
486
487void muxSetupCamera(void)
488{
489 volatile unsigned char *MuxConfigReg;
490
491
492
493
494
495
496
497 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_XCLK;
498 *MuxConfigReg = 0x00 ;
499
500
501 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_LCLK;
502 *MuxConfigReg = 0x00 ;
503
504
505 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_VS,
506 *MuxConfigReg = 0x00 ;
507
508
509 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_HS,
510 *MuxConfigReg = 0x00 ;
511
512
513 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D0,
514 *MuxConfigReg = 0x00 ;
515
516
517 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D1,
518 *MuxConfigReg = 0x00 ;
519
520
521 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D2,
522 *MuxConfigReg = 0x00 ;
523
524
525 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D3,
526 *MuxConfigReg = 0x00 ;
527
528
529 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D4,
530 *MuxConfigReg = 0x00 ;
531
532
533 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D5,
534 *MuxConfigReg = 0x00 ;
535
536
537 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D6,
538 *MuxConfigReg = 0x00 ;
539
540
541 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D7,
542 *MuxConfigReg = 0x00 ;
543
544
545 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D8,
546 *MuxConfigReg = 0x00 ;
547
548
549 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D9,
550 *MuxConfigReg = 0x00 ;
551}
552
553
554
555
556
557void muxSetupMMCSD(void)
558{
559 volatile unsigned char *MuxConfigReg;
560
561
562 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CLKI,
563 *MuxConfigReg = 0x00 ;
564
565
566 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CLKO,
567 *MuxConfigReg = 0x00 ;
568
569
570 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CMD,
571 *MuxConfigReg = 0x00 ;
572
573
574
575
576 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT0,
577 *MuxConfigReg = 0x00 ;
578
579
580
581
582 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT1,
583 *MuxConfigReg = 0x00 ;
584
585
586
587
588 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT2,
589 *MuxConfigReg = 0x00 ;
590
591
592
593
594 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT3,
595 *MuxConfigReg = 0x00 ;
596
597
598
599
600 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR0,
601 *MuxConfigReg = 0x00 ;
602
603
604 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR1,
605 *MuxConfigReg = 0x00 ;
606
607
608 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR2,
609 *MuxConfigReg = 0x00 ;
610
611
612 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR3,
613 *MuxConfigReg = 0x00 ;
614
615
616 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CMD_DIR,
617 *MuxConfigReg = 0x00 ;
618
619
620
621 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SDRC_A14,
622 *MuxConfigReg = 0x03 ;
623
624
625 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SDRC_A13,
626 *MuxConfigReg = 0x03 ;
627}
628
629
630
631
632
633void muxSetupTouchScreen(void)
634{
635 volatile unsigned char *MuxConfigReg;
636
637
638 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_CLK,
639 *MuxConfigReg = 0x00 ;
640
641
642 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_SIMO,
643 *MuxConfigReg = 0x00 ;
644
645
646 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_SOMI,
647 *MuxConfigReg = 0x00 ;
648
649
650 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_NCS0,
651 *MuxConfigReg = 0x00 ;
652
653
654 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MCBSP1_FSR,
655 *MuxConfigReg = 0x03 ;
656}
657
658
659
660
661
662void muxSetupHDQ(void)
663{
664 volatile unsigned char *MuxConfigReg;
665
666
667 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_HDQ_SIO,
668 *MuxConfigReg = 0x00 ;
669}
670
671
672
673
674
675void muxSetupGPMC(void)
676{
677 volatile uint8 *MuxConfigReg;
678 volatile unsigned int *MCR = (volatile unsigned int *)0x4800008C;
679
680
681 *MCR = 0x19000000;
682
683
684
685 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_D2_BYTE3,
686 *MuxConfigReg = 0x00 ;
687
688
689 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_NCS0_BYTE3,
690 *MuxConfigReg = 0x01 ;
691
692
693
694 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_NCS0_BYTE1,
695 *MuxConfigReg = 0x00 ;
696
697
698 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_NCS0_BYTE2,
699 *MuxConfigReg = 0x00 ;
700}
701
702
703
704
705
706void muxSetupSDRC(void)
707{
708 volatile uint8 *MuxConfigReg;
709
710
711 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_NCS0_BYTE1,
712 *MuxConfigReg = 0x00 ;
713
714
715 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_A14_BYTE2,
716 *MuxConfigReg = 0x00 ;
717
718
719 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_NCS0_BYTE3,
720 *MuxConfigReg = 0x00;
721
722 if (get_cpu_type() == CPU_2422) {
723 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_A14_BYTE0,
724 *MuxConfigReg = 0x1b;
725 }
726}
727
728
729
730
731
732
733
734
735void update_mux(u32 btype,u32 mtype)
736{
737 u32 cpu, base = OMAP2420_CTRL_BASE;
738 cpu = get_cpu_type();
739
740 if (btype == BOARD_H4_MENELAUS) {
741 if (cpu == CPU_2420) {
742
743 __raw_writeb(0x3, base+0x30);
744
745 __raw_writeb(0x3, base+0xa3);
746
747
748
749
750
751
752 __raw_writeb(0x3, base+0x9d);
753
754
755
756 __raw_writeb(0x3, base+0xe7);
757
758
759
760
761 __raw_writeb(0x3, base+0x10e);
762
763 __raw_writeb(0x3, base+0x110);
764
765
766
767
768 __raw_writeb(0x3, base+0xde);
769
770 __raw_writeb(0x0, base+0x12c);
771
772 __raw_writeb(0x0, base+0x136);
773 } else if (cpu == CPU_2422) {
774
775
776
777
778
779 __raw_writeb(0x0, base+0x92);
780
781
782
783 __raw_writeb(0x3, base+0x10c);
784
785
786 __raw_writeb(0x3, base+0x30);
787
788
789
790
791 __raw_writeb(0x3, base+0x10e);
792
793 __raw_writeb(0x3, base+0x110);
794
795
796
797
798 __raw_writeb(0x3, base+0xde);
799
800 __raw_writeb(0x0, base+0x12c);
801
802 __raw_writeb(0x0, base+0x136);
803 }
804
805 } else if (btype == BOARD_H4_SDP) {
806 if (cpu == CPU_2420) {
807
808
809
810
811
812
813
814
815
816 __raw_writeb(0x3, base+0x10e);
817
818 __raw_writeb(0x3, base+0x110);
819
820
821 __raw_writeb(0x3, base+0x114);
822
823
824 } else if (cpu == CPU_2422) {
825
826
827
828
829
830
831
832
833
834 __raw_writeb(0x3, base+0x10e);
835
836 __raw_writeb(0x3, base+0x110);
837
838
839 __raw_writeb(0x3, base+0x114);
840
841
842 }
843 }
844}
845
846#ifdef CONFIG_CMD_NET
847int board_eth_init(bd_t *bis)
848{
849 int rc = 0;
850#ifdef CONFIG_LAN91C96
851 rc = lan91c96_initialize(0, CONFIG_LAN91C96_BASE);
852#endif
853 return rc;
854}
855#endif
856