summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c')
-rw-r--r--c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c81
1 files changed, 49 insertions, 32 deletions
diff --git a/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c b/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c
index 47de7f6d3a..0efab30131 100644
--- a/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c
+++ b/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c
@@ -14,11 +14,23 @@
#define m68k_set_acr1(_acr1) asm volatile ("movec %0,%%acr1" : : "d" (_acr1))
#define MM_SDRAM_BASE (0x00000000)
+/*
+ * MCF5235_BSP_START_FROM_FLASH comes from the linker script
+ * If it is set to 0 then it is assumed that the motorola debug monitor
+ * is present and we do not need to re-initialize the SDRAM. Otherwise,
+ * if it is set to 1 then we want to boot our own code from flash and we
+ * do need to initialize the SDRAM.
+ */
+
+
+extern uint32_t MCF5235_BSP_START_FROM_FLASH;
+
void Init5235 (void)
{
extern void CopyDataClearBSSAndStart (void);
int x;
int temp = 0;
+ int *address_of_MCF5235_BSP_START_FROM_FLASH;
//Setup the GPIO Registers
MCF5235_GPIO_UART=0x3FFF;
@@ -29,37 +41,40 @@ void Init5235 (void)
MCF5235_CS_CSMR0 = 0x001f0001;
MCF5235_CS_CSCR0 = 0x1980;
- //Setup the SDRAM
- for(x=0; x<20000; x++)
- {
- temp +=1;
- }
- MCF5235_SDRAMC_DCR = 0x042E;
- MCF5235_SDRAMC_DACR0 = 0x00001300;
- MCF5235_SDRAMC_DMR0 = (0x00FC0000) | (0x00000001);
- for(x=0; x<20000; x++)
- {
- temp +=1;
- }
- // set ip ( bit 3 ) in dacr
- MCF5235_SDRAMC_DACR0 |= (0x00000008) ;
- // init precharge
- *((unsigned long *)MM_SDRAM_BASE) = 0xDEADBEEF;
- // set RE in dacr
- MCF5235_SDRAMC_DACR0 |= (0x00008000);
- // wait
- for(x=0; x<20000; x++)
- {
- temp +=1;
- }
- // issue IMRS
- MCF5235_SDRAMC_DACR0 |= (0x00000040);
- *((short *)MM_SDRAM_BASE) = 0;
- for(x=0; x<60000; x++)
- {
- temp +=1;
- }
- *((unsigned long*)MM_SDRAM_BASE)=0x12345678;
+ address_of_MCF5235_BSP_START_FROM_FLASH = (int *) & MCF5235_BSP_START_FROM_FLASH;
+ if ( (int)address_of_MCF5235_BSP_START_FROM_FLASH == 1) {
+ //Setup the SDRAM
+ for(x=0; x<20000; x++)
+ {
+ temp +=1;
+ }
+ MCF5235_SDRAMC_DCR = 0x042E;
+ MCF5235_SDRAMC_DACR0 = 0x00001300;
+ MCF5235_SDRAMC_DMR0 = (0x00FC0000) | (0x00000001);
+ for(x=0; x<20000; x++)
+ {
+ temp +=1;
+ }
+ // set ip ( bit 3 ) in dacr
+ MCF5235_SDRAMC_DACR0 |= (0x00000008) ;
+ // init precharge
+ *((unsigned long *)MM_SDRAM_BASE) = 0xDEADBEEF;
+ // set RE in dacr
+ MCF5235_SDRAMC_DACR0 |= (0x00008000);
+ // wait
+ for(x=0; x<20000; x++)
+ {
+ temp +=1;
+ }
+ // issue IMRS
+ MCF5235_SDRAMC_DACR0 |= (0x00000040);
+ *((short *)MM_SDRAM_BASE) = 0;
+ for(x=0; x<60000; x++)
+ {
+ temp +=1;
+ }
+ *((unsigned long*)MM_SDRAM_BASE)=0x12345678;
+ } /* we have finished setting up the sdram */
/* Copy the interrupt vector table to address 0x0 in SDRAM */
{
@@ -73,7 +88,9 @@ void Init5235 (void)
}
}
- /*
+ m68k_set_vbr(0);
+
+ /*
* Copy data, clear BSS and call boot_card()
*/
CopyDataClearBSSAndStart ();