1 | /* |
---|
2 | * This is where the real hardware setup is done. A minimal stack |
---|
3 | * has been provided by the start.S code. No normal C or RTEMS |
---|
4 | * functions can be called from here. |
---|
5 | * |
---|
6 | * This routine is pretty simple for the uC5282 because all the hard |
---|
7 | * work has been done by the bootstrap dBUG code. |
---|
8 | */ |
---|
9 | |
---|
10 | #include <rtems.h> |
---|
11 | #include <bsp.h> |
---|
12 | #define m68k_set_cacr(_cacr) asm volatile ("movec %0,%%cacr" : : "d" (_cacr)) |
---|
13 | #define m68k_set_acr0(_acr0) asm volatile ("movec %0,%%acr0" : : "d" (_acr0)) |
---|
14 | #define m68k_set_acr1(_acr1) asm volatile ("movec %0,%%acr1" : : "d" (_acr1)) |
---|
15 | #define MM_SDRAM_BASE (0x00000000) |
---|
16 | |
---|
17 | /* |
---|
18 | * External methods used by this file |
---|
19 | */ |
---|
20 | extern void CopyDataClearBSSAndStart (void); |
---|
21 | extern void INTERRUPT_VECTOR(void); |
---|
22 | |
---|
23 | void Init5282 (void) |
---|
24 | { |
---|
25 | int x; |
---|
26 | int temp = 0; |
---|
27 | |
---|
28 | /*Setup the GPIO Registers */ |
---|
29 | MCF5282_GPIO_PBCDPAR = 0x80; |
---|
30 | MCF5282_GPIO_PEPAR = 0x5100; |
---|
31 | MCF5282_GPIO_PJPAR = 0xFF; |
---|
32 | MCF5282_GPIO_PASPAR = 0x0000; |
---|
33 | MCF5282_GPIO_PEHLPAR = 0xC0; |
---|
34 | MCF5282_GPIO_PUAPAR = 0x0F; |
---|
35 | MCF5282_QADC_DDRQB = 0x07; |
---|
36 | MCF5282_GPTA_GPTDDR = 0x0C; |
---|
37 | MCF5282_GPTA_GPTPORT = 0x4; |
---|
38 | |
---|
39 | /*Setup the Chip Selects so CS0 is flash */ |
---|
40 | MCF5282_CS0_CSAR =(0xff800000 & 0xffff0000)>>16; |
---|
41 | MCF5282_CS0_CSMR = 0x007f0001; |
---|
42 | MCF5282_CS0_CSCR =(((0xf)&0x0F)<<10)|(1<<8)|(0x80); |
---|
43 | |
---|
44 | /*Setup the SDRAM */ |
---|
45 | for(x=0; x<20000; x++) |
---|
46 | { |
---|
47 | temp +=1; |
---|
48 | } |
---|
49 | MCF5282_SDRAMC_DCR = 0x00000239; |
---|
50 | MCF5282_SDRAMC_DACR0 = 0x00001320; |
---|
51 | MCF5282_SDRAMC_DMR0 = (0x00FC0000) | (0x00000001); |
---|
52 | for(x=0; x<20000; x++) |
---|
53 | { |
---|
54 | temp +=1; |
---|
55 | } |
---|
56 | /* set ip ( bit 3 ) in dacr */ |
---|
57 | MCF5282_SDRAMC_DACR0 |= (0x00000008) ; |
---|
58 | /* init precharge */ |
---|
59 | *((short *)MM_SDRAM_BASE) = 0; |
---|
60 | /* set RE in dacr */ |
---|
61 | MCF5282_SDRAMC_DACR0 |= (0x00008000); |
---|
62 | /* wait */ |
---|
63 | for(x=0; x<20000; x++) |
---|
64 | { |
---|
65 | temp +=1; |
---|
66 | } |
---|
67 | /* issue IMRS */ |
---|
68 | MCF5282_SDRAMC_DACR0 |= (0x00000040); |
---|
69 | *((short *)MM_SDRAM_BASE) = 0x0000; |
---|
70 | for(x=0; x<60000; x++) |
---|
71 | { |
---|
72 | temp +=1; |
---|
73 | } |
---|
74 | *((unsigned long*)MM_SDRAM_BASE)=0x12345678; |
---|
75 | |
---|
76 | /* Copy the interrupt vector table to address 0x0 in SDRAM */ |
---|
77 | { |
---|
78 | uint32_t *inttab = (uint32_t *)&INTERRUPT_VECTOR; |
---|
79 | uint32_t *intvec = (uint32_t *)0x0; |
---|
80 | register int i; |
---|
81 | for (i = 0; i < 256; i++) |
---|
82 | { |
---|
83 | *(intvec++) = *(inttab++); |
---|
84 | } |
---|
85 | } |
---|
86 | /* |
---|
87 | * Copy data, clear BSS and call boot_card() |
---|
88 | */ |
---|
89 | CopyDataClearBSSAndStart (); |
---|
90 | } |
---|