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 uC5235 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 | * MCF5235_BSP_START_FROM_FLASH comes from the linker script |
---|
19 | * If it is set to 0 then it is assumed that the motorola debug monitor |
---|
20 | * is present and we do not need to re-initialize the SDRAM. Otherwise, |
---|
21 | * if it is set to 1 then we want to boot our own code from flash and we |
---|
22 | * do need to initialize the SDRAM. |
---|
23 | */ |
---|
24 | |
---|
25 | |
---|
26 | extern uint32_t MCF5235_BSP_START_FROM_FLASH; |
---|
27 | |
---|
28 | void Init5235 (void) |
---|
29 | { |
---|
30 | extern void CopyDataClearBSSAndStart (void); |
---|
31 | int x; |
---|
32 | int temp = 0; |
---|
33 | int *address_of_MCF5235_BSP_START_FROM_FLASH; |
---|
34 | |
---|
35 | /*Setup the GPIO Registers */ |
---|
36 | MCF5235_GPIO_UART=0x3FFF; |
---|
37 | MCF5235_GPIO_PAR_AD=0xE1; |
---|
38 | |
---|
39 | /*Setup the Chip Selects so CS0 is flash */ |
---|
40 | MCF5235_CS_CSAR0 =(0xFFE00000 & 0xffff0000)>>16; |
---|
41 | MCF5235_CS_CSMR0 = 0x001f0001; |
---|
42 | MCF5235_CS_CSCR0 = 0x1980; |
---|
43 | |
---|
44 | address_of_MCF5235_BSP_START_FROM_FLASH = (int *) & MCF5235_BSP_START_FROM_FLASH; |
---|
45 | if ( (int)address_of_MCF5235_BSP_START_FROM_FLASH == 1) { |
---|
46 | /*Setup the SDRAM */ |
---|
47 | for(x=0; x<20000; x++) |
---|
48 | { |
---|
49 | temp +=1; |
---|
50 | } |
---|
51 | MCF5235_SDRAMC_DCR = 0x042E; |
---|
52 | MCF5235_SDRAMC_DACR0 = 0x00001300; |
---|
53 | MCF5235_SDRAMC_DMR0 = (0x00FC0000) | (0x00000001); |
---|
54 | for(x=0; x<20000; x++) |
---|
55 | { |
---|
56 | temp +=1; |
---|
57 | } |
---|
58 | /* set ip ( bit 3 ) in dacr */ |
---|
59 | MCF5235_SDRAMC_DACR0 |= (0x00000008) ; |
---|
60 | /* init precharge */ |
---|
61 | *((unsigned long *)MM_SDRAM_BASE) = 0xDEADBEEF; |
---|
62 | /* set RE in dacr */ |
---|
63 | MCF5235_SDRAMC_DACR0 |= (0x00008000); |
---|
64 | /* wait */ |
---|
65 | for(x=0; x<20000; x++) |
---|
66 | { |
---|
67 | temp +=1; |
---|
68 | } |
---|
69 | /* issue IMRS */ |
---|
70 | MCF5235_SDRAMC_DACR0 |= (0x00000040); |
---|
71 | *((short *)MM_SDRAM_BASE) = 0; |
---|
72 | for(x=0; x<60000; x++) |
---|
73 | { |
---|
74 | temp +=1; |
---|
75 | } |
---|
76 | *((unsigned long*)MM_SDRAM_BASE)=0x12345678; |
---|
77 | } /* we have finished setting up the sdram */ |
---|
78 | |
---|
79 | /* Copy the interrupt vector table to address 0x0 in SDRAM */ |
---|
80 | { |
---|
81 | extern void INTERRUPT_VECTOR(); |
---|
82 | uint32_t *inttab = (uint32_t *)&INTERRUPT_VECTOR; |
---|
83 | uint32_t *intvec = (uint32_t *)0x0; |
---|
84 | register int i; |
---|
85 | for (i = 0; i < 256; i++) |
---|
86 | { |
---|
87 | *(intvec++) = *(inttab++); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | m68k_set_vbr(0); |
---|
92 | |
---|
93 | /* |
---|
94 | * Copy data, clear BSS and call boot_card() |
---|
95 | */ |
---|
96 | CopyDataClearBSSAndStart (); |
---|
97 | } |
---|