/* * vendors/Motorola/M5235EVB/board.c * CoLiLo MCF5235EVB Development board port * * (C) Copyright April 2003, Jeremy Andrus * */ #include "arch.h" #include "mcfuart.h" #include "ledstate.h" char ident[] = " Motorola MCF523x EVB"; char copyright[] = " (C) 2004, Jate Sujjavanich"; extern unsigned int downloadPort; extern unsigned int image_size; extern unsigned char *xfer_addr; extern unsigned char *down_addr; extern unsigned char *dest_addr; extern unsigned char *source_addr; extern unsigned long consoleBase; void configureConsole(); void configureAuxSerial(); void setLED(int state); void setImageParams(); void setupBoard(); static int delay(int size); void setupDRAM(); #define IMAGE_ADDR 0xfff08000 /* colilo shouldn't be more than 32k */ #define IMAGE_SIZE 0x00100000 /* You really can't get any bigger than 2MB - 32 k :-) */ #define XFER_ADDR 0x20000 #define DEFAULT_PORT 1 void configureConsole() { /** Note: The UART timer in the 5235 uses the bus clock (PSTCLK / 2) to generate the baud ***/ consoleBase = MCFUART_BASE1; configureSerial(MCFUART_BASE1, 19200, MCF_BUSCLK); /* dBUG compliance: 19200 it is. */ } void configureAuxSerial() { configureSerial(MCFUART_BASE2, 115200, MCF_BUSCLK); /* This can be used for image transfers */ } /* * State to LED mapping: * The gpio pins 53,52,51,34,19,18,12,11,9 will serve as a nice boot-up state indicator * */ void setLED(int state) { } void setImageParams() { downloadPort = DEFAULT_PORT; image_size = IMAGE_SIZE; source_addr = (unsigned char *)IMAGE_ADDR; down_addr = (unsigned char *)IMAGE_ADDR; xfer_addr = (unsigned char *)XFER_ADDR; dest_addr = (unsigned char *)XFER_ADDR; } void setup_GPIO() { // set D[15:0] to be data MCF5235_PAR_AD |= PAR_DATAL; MCF5235_PAR_UART |= PAR_ENABLE_U1U2_TXRX; } void setupBoard() { // disable watchdog timer mbar_writeShort(MCF5235_WCR, 0); // set up PLL for 150 MHz mbar_writeLong(MCF_SYNCR, 0x01000000); // set up CS0 mbar_writeShort(MCF_CSAR0, 0xFFE0); mbar_writeShort(MCF_CSCR0, 0x1980); mbar_writeLong(MCF_CSMR0, 0x001F0001); // setup GPIO for DRAM setup_GPIO(); } static int delay(int size) { int i; for (i = 0; (i < size); i++) nop(); } /* * SDRAM is pretty confusing. * Please read _all_ the docs before meddling with this code :-) * ~Jeremy */ void setupDRAM() { int temp; // delay for 100us delay(10000); // initialize registers mbar_writeShort(MCF_DCR, 0x0446); mbar_writeLong(MCF_DACR0, 0x00001300); mbar_writeLong(MCF_DMR0, 0x00FC0001); // Initiate PALL command (set IP) mbar_writeLong(MCF_DACR0, 0x00001308); *((volatile unsigned long *)0x0) = 0xA5A59696; // Enable refresh (set RE) mbar_writeLong(MCF_DACR0, 0x00009300); // wait for 8 refresh cycles delay(10000); // Issue the MRS command (set IMRS) mbar_writeLong(MCF_DACR0, 0x00009340); *((volatile unsigned long *)0x00000000) = 0xA5A59696; // send command reg }