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, cpu;
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 cpu = get_cpu_type();
207
208 display_board_info(btype);
209 if (btype == BOARD_H4_MENELAUS){
210 update_mux(btype,mtype);
211 i2c_write(I2C_MENELAUS, 0x20, 1, &chg_on, 1);
212 i2c_write(I2C_MENELAUS, 0x2, 1, &vmode_on, 1);
213 }
214
215 if ((mtype == DDR_COMBO) || (mtype == DDR_STACKED)) {
216 do_sdrc_init(SDRC_CS1_OSET, NOT_EARLY);
217 }
218 size0 = get_sdr_cs_size(SDRC_CS0_OSET);
219 size1 = get_sdr_cs_size(SDRC_CS1_OSET);
220
221 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
222 gd->bd->bi_dram[0].size = size0;
223 if(rev == CPU_2420_2422_ES1)
224 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
225 else
226 gd->bd->bi_dram[1].start = PHYS_SDRAM_1+size0;
227 gd->bd->bi_dram[1].size = size1;
228
229 return 0;
230}
231
232
233
234
235
236
237void set_muxconf_regs (void)
238{
239 muxSetupSDRC();
240 muxSetupGPMC();
241 muxSetupUsb0();
242 muxSetupUart3();
243 muxSetupI2C1();
244 muxSetupUART1();
245 muxSetupLCD();
246 muxSetupCamera();
247 muxSetupMMCSD();
248 muxSetupTouchScreen();
249 muxSetupHDQ();
250}
251
252
253
254
255
256void peripheral_enable(void)
257{
258 unsigned int v, if_clks=0, func_clks=0;
259
260
261 if_clks |= BIT4;
262 func_clks |= BIT4;
263 v = __raw_readl(CM_CLKSEL2_CORE) | 0x4;
264 __raw_writel(v, CM_CLKSEL2_CORE);
265 __raw_writel(0x1, CM_CLKSEL_WKUP);
266
267#ifdef CONFIG_SYS_NS16550
268
269 func_clks |= BIT21;
270 if_clks |= BIT21;
271#endif
272 v = __raw_readl(CM_ICLKEN1_CORE) | if_clks;
273 __raw_writel(v,CM_ICLKEN1_CORE );
274 v = __raw_readl(CM_FCLKEN1_CORE) | func_clks;
275 __raw_writel(v, CM_FCLKEN1_CORE);
276 delay(1000);
277
278#ifndef KERNEL_UPDATED
279 {
280#define V1 0xffffffff
281#define V2 0x00000007
282
283 __raw_writel(V1, CM_FCLKEN1_CORE);
284 __raw_writel(V2, CM_FCLKEN2_CORE);
285 __raw_writel(V1, CM_ICLKEN1_CORE);
286 __raw_writel(V1, CM_ICLKEN2_CORE);
287 }
288#endif
289}
290
291
292
293
294
295void muxSetupUsb0(void)
296{
297 volatile uint8 *MuxConfigReg;
298 volatile uint32 *otgCtrlReg;
299
300 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_PUEN;
301 *MuxConfigReg &= (uint8)(~0x1F);
302
303 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_VP;
304 *MuxConfigReg &= (uint8)(~0x1F);
305
306 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_VM;
307 *MuxConfigReg &= (uint8)(~0x1F);
308
309 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_RCV;
310 *MuxConfigReg &= (uint8)(~0x1F);
311
312 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_TXEN;
313 *MuxConfigReg &= (uint8)(~0x1F);
314
315 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_SE0;
316 *MuxConfigReg &= (uint8)(~0x1F);
317
318 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_DAT;
319 *MuxConfigReg &= (uint8)(~0x1F);
320
321
322 otgCtrlReg = (volatile uint32 *)USB_OTG_CTRL;
323 *otgCtrlReg |= 0x00040000;
324}
325
326
327
328
329
330void muxSetupUart3(void)
331{
332 volatile uint8 *MuxConfigReg;
333
334 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_UART3_TX_IRTX;
335 *MuxConfigReg &= (uint8)(~0x1F);
336
337 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_UART3_RX_IRRX;
338 *MuxConfigReg &= (uint8)(~0x1F);
339}
340
341
342
343
344
345void muxSetupI2C1(void)
346{
347 volatile unsigned char *MuxConfigReg;
348
349
350 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_I2C1_SCL;
351 *MuxConfigReg = 0x00 ;
352
353
354 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_I2C1_SDA;
355 *MuxConfigReg = 0x00 ;
356
357
358
359
360}
361
362
363
364
365
366void muxSetupUART1(void)
367{
368 volatile unsigned char *MuxConfigReg;
369
370
371 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_CTS;
372 *MuxConfigReg = 0x00 ;
373
374
375 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_RTS;
376 *MuxConfigReg = 0x00 ;
377
378
379 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_TX;
380 *MuxConfigReg = 0x00 ;
381
382
383 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_RX;
384 *MuxConfigReg = 0x00 ;
385}
386
387
388
389
390
391void muxSetupLCD(void)
392{
393 volatile unsigned char *MuxConfigReg;
394
395
396 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D0;
397 *MuxConfigReg = 0x00 ;
398
399
400 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D1;
401 *MuxConfigReg = 0x00 ;
402
403
404 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D2;
405 *MuxConfigReg = 0x00 ;
406
407
408 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D3;
409 *MuxConfigReg = 0x00 ;
410
411
412 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D4;
413 *MuxConfigReg = 0x00 ;
414
415
416 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D5;
417 *MuxConfigReg = 0x00 ;
418
419
420 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D6;
421 *MuxConfigReg = 0x00 ;
422
423
424 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D7;
425 *MuxConfigReg = 0x00 ;
426
427
428 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D8;
429 *MuxConfigReg = 0x00 ;
430
431
432 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D9;
433 *MuxConfigReg = 0x00 ;
434
435
436 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D10;
437 *MuxConfigReg = 0x00 ;
438
439
440 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D11;
441 *MuxConfigReg = 0x00 ;
442
443
444 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D12;
445 *MuxConfigReg = 0x00 ;
446
447
448 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D13;
449 *MuxConfigReg = 0x00 ;
450
451
452 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D14;
453 *MuxConfigReg = 0x00 ;
454
455
456 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D15;
457 *MuxConfigReg = 0x00 ;
458
459
460 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D16;
461 *MuxConfigReg = 0x00 ;
462
463
464 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D17;
465 *MuxConfigReg = 0x00 ;
466
467
468 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_PCLK;
469 *MuxConfigReg = 0x00 ;
470
471
472 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_VSYNC;
473 *MuxConfigReg = 0x00 ;
474
475
476 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_HSYNC;
477 *MuxConfigReg = 0x00 ;
478
479
480 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_ACBIAS;
481 *MuxConfigReg = 0x00 ;
482}
483
484
485
486
487
488void muxSetupCamera(void)
489{
490 volatile unsigned char *MuxConfigReg;
491
492
493
494
495
496
497
498 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_XCLK;
499 *MuxConfigReg = 0x00 ;
500
501
502 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_LCLK;
503 *MuxConfigReg = 0x00 ;
504
505
506 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_VS,
507 *MuxConfigReg = 0x00 ;
508
509
510 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_HS,
511 *MuxConfigReg = 0x00 ;
512
513
514 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D0,
515 *MuxConfigReg = 0x00 ;
516
517
518 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D1,
519 *MuxConfigReg = 0x00 ;
520
521
522 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D2,
523 *MuxConfigReg = 0x00 ;
524
525
526 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D3,
527 *MuxConfigReg = 0x00 ;
528
529
530 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D4,
531 *MuxConfigReg = 0x00 ;
532
533
534 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D5,
535 *MuxConfigReg = 0x00 ;
536
537
538 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D6,
539 *MuxConfigReg = 0x00 ;
540
541
542 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D7,
543 *MuxConfigReg = 0x00 ;
544
545
546 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D8,
547 *MuxConfigReg = 0x00 ;
548
549
550 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D9,
551 *MuxConfigReg = 0x00 ;
552}
553
554
555
556
557
558void muxSetupMMCSD(void)
559{
560 volatile unsigned char *MuxConfigReg;
561
562
563 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CLKI,
564 *MuxConfigReg = 0x00 ;
565
566
567 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CLKO,
568 *MuxConfigReg = 0x00 ;
569
570
571 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CMD,
572 *MuxConfigReg = 0x00 ;
573
574
575
576
577 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT0,
578 *MuxConfigReg = 0x00 ;
579
580
581
582
583 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT1,
584 *MuxConfigReg = 0x00 ;
585
586
587
588
589 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT2,
590 *MuxConfigReg = 0x00 ;
591
592
593
594
595 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT3,
596 *MuxConfigReg = 0x00 ;
597
598
599
600
601 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR0,
602 *MuxConfigReg = 0x00 ;
603
604
605 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR1,
606 *MuxConfigReg = 0x00 ;
607
608
609 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR2,
610 *MuxConfigReg = 0x00 ;
611
612
613 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR3,
614 *MuxConfigReg = 0x00 ;
615
616
617 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CMD_DIR,
618 *MuxConfigReg = 0x00 ;
619
620
621
622 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SDRC_A14,
623 *MuxConfigReg = 0x03 ;
624
625
626 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SDRC_A13,
627 *MuxConfigReg = 0x03 ;
628}
629
630
631
632
633
634void muxSetupTouchScreen(void)
635{
636 volatile unsigned char *MuxConfigReg;
637
638
639 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_CLK,
640 *MuxConfigReg = 0x00 ;
641
642
643 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_SIMO,
644 *MuxConfigReg = 0x00 ;
645
646
647 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_SOMI,
648 *MuxConfigReg = 0x00 ;
649
650
651 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_NCS0,
652 *MuxConfigReg = 0x00 ;
653
654
655 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MCBSP1_FSR,
656 *MuxConfigReg = 0x03 ;
657}
658
659
660
661
662
663void muxSetupHDQ(void)
664{
665 volatile unsigned char *MuxConfigReg;
666
667
668 MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_HDQ_SIO,
669 *MuxConfigReg = 0x00 ;
670}
671
672
673
674
675
676void muxSetupGPMC(void)
677{
678 volatile uint8 *MuxConfigReg;
679 volatile unsigned int *MCR = (volatile unsigned int *)0x4800008C;
680
681
682 *MCR = 0x19000000;
683
684
685
686 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_D2_BYTE3,
687 *MuxConfigReg = 0x00 ;
688
689
690 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_NCS0_BYTE3,
691 *MuxConfigReg = 0x01 ;
692
693
694
695 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_NCS0_BYTE1,
696 *MuxConfigReg = 0x00 ;
697
698
699 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_NCS0_BYTE2,
700 *MuxConfigReg = 0x00 ;
701}
702
703
704
705
706
707void muxSetupSDRC(void)
708{
709 volatile uint8 *MuxConfigReg;
710
711
712 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_NCS0_BYTE1,
713 *MuxConfigReg = 0x00 ;
714
715
716 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_A14_BYTE2,
717 *MuxConfigReg = 0x00 ;
718
719
720 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_NCS0_BYTE3,
721 *MuxConfigReg = 0x00;
722
723 if (get_cpu_type() == CPU_2422) {
724 MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_A14_BYTE0,
725 *MuxConfigReg = 0x1b;
726 }
727}
728
729
730
731
732
733
734
735
736void update_mux(u32 btype,u32 mtype)
737{
738 u32 cpu, base = OMAP2420_CTRL_BASE;
739 cpu = get_cpu_type();
740
741 if (btype == BOARD_H4_MENELAUS) {
742 if (cpu == CPU_2420) {
743
744 __raw_writeb(0x3, base+0x30);
745
746 __raw_writeb(0x3, base+0xa3);
747
748
749
750
751
752
753 __raw_writeb(0x3, base+0x9d);
754
755
756
757 __raw_writeb(0x3, base+0xe7);
758
759
760
761
762 __raw_writeb(0x3, base+0x10e);
763
764 __raw_writeb(0x3, base+0x110);
765
766
767
768
769 __raw_writeb(0x3, base+0xde);
770
771 __raw_writeb(0x0, base+0x12c);
772
773 __raw_writeb(0x0, base+0x136);
774 } else if (cpu == CPU_2422) {
775
776
777
778
779
780 __raw_writeb(0x0, base+0x92);
781
782
783
784 __raw_writeb(0x3, base+0x10c);
785
786
787 __raw_writeb(0x3, base+0x30);
788
789
790
791
792 __raw_writeb(0x3, base+0x10e);
793
794 __raw_writeb(0x3, base+0x110);
795
796
797
798
799 __raw_writeb(0x3, base+0xde);
800
801 __raw_writeb(0x0, base+0x12c);
802
803 __raw_writeb(0x0, base+0x136);
804 }
805
806 } else if (btype == BOARD_H4_SDP) {
807 if (cpu == CPU_2420) {
808
809
810
811
812
813
814
815
816
817 __raw_writeb(0x3, base+0x10e);
818
819 __raw_writeb(0x3, base+0x110);
820
821
822 __raw_writeb(0x3, base+0x114);
823
824
825 } else if (cpu == CPU_2422) {
826
827
828
829
830
831
832
833
834
835 __raw_writeb(0x3, base+0x10e);
836
837 __raw_writeb(0x3, base+0x110);
838
839
840 __raw_writeb(0x3, base+0x114);
841
842
843 }
844 }
845}
846
847#ifdef CONFIG_CMD_NET
848int board_eth_init(bd_t *bis)
849{
850 int rc = 0;
851#ifdef CONFIG_LAN91C96
852 rc = lan91c96_initialize(0, CONFIG_LAN91C96_BASE);
853#endif
854 return rc;
855}
856#endif
857