diff -Nur colilo-20040221/arch/5235/arch.h colilo-20040221/arch/5235/arch.h --- colilo-20040221/arch/5235/arch.h 1969-12-31 19:00:00.000000000 -0500 +++ colilo-20040221/arch/5235/arch.h 2005-04-12 17:22:40.000000000 -0400 @@ -0,0 +1,81 @@ +/****************************************************************************/ + +/* + * m5235.h -- Motorola Coldfire 5235 CPU Support. + * + * Based on the /arch/5307/arch.h + * (C) Copyright 1999, Greg Ungerer (gerg@moreton.com.au) + * + * (C) Copyright 2003, Jeremy Andrus (jeremy@jeremya.com) + * Added 5249 support + */ + +/****************************************************************************/ +#ifndef m5235_h +#define m5235_h +/****************************************************************************/ + +/* + * Define master clock frequency of our 5235 + * Note: These are exact values calculated from the PLLCR. + * + */ +#define MCF_CLK 150000000 /* The next lower speed */ +#define MCF_BUSCLK MCF_CLK / 2 + +/* + * The MCF5249C3 board memory map is set up as follows: + * + * 0x00000000 -- SDRAM (operational memory - 4MB) + * 0x10000000 -- MBAR1 (5249 SIM module peripherals) + * 0x80000000 -- MBAR2 (5249 SIM module peripherals) + * 0x20010000 -- RAMBAR0 (5249 internal SRAM - 32k) + * 0x20000000 -- RAMBAR1 (5249 internal SRAM - 64k) + * 0xffe00000 -- FLASH (32Mb) (CS0) + * 0xe0000000 -- LAN (smc91c111 ethernet (CS1) + */ + +#define MCF_MEMBASE 0x00000000 +#define MCF_IPSBAR 0x40000000 +#define MCF_MBAR MCF_IPSBAR + +#define MCFUART_BASE1 0x200 /* Base address of UART1 */ +#define MCFUART_BASE2 0x240 /* Base address of UART2 */ +#define MCFUART_BASE3 0x280 /* Base address of UART3 */ + +/* + * useful definitions for reading/writing MBAR offset memory + */ +#define mbar_readLong(x) *((volatile unsigned long *) (MCF_IPSBAR + x)) +#define mbar_writeLong(x,y) *((volatile unsigned long *) (MCF_IPSBAR + x)) = y +#define mbar_writeShort(x,y) *((volatile unsigned short *) (MCF_IPSBAR + x)) = y +#define mbar_writeByte(x,y) *((volatile unsigned char *) (MCF_IPSBAR + x)) = y + + +/* + * Size of internal RAM + */ + +#define INT_RAM_SIZE 65536 /* RAMBAR0 - 32k */ + +/* + * Define the 5235 SCM register set addresses. + */ + +#define MCF_SYNCR 0x120000 +#define MCF_CSAR0 0x80 +#define MCF_CSMR0 0x84 +#define MCF_CSCR0 0x8a +#define MCF_CSAR1 0x8c +#define MCF_CSMR1 0x90 +#define MCF_CSCR1 0x96 +#define MCF_DCR 0x40 +#define MCF_DACR0 0x48 +#define MCF_DMR0 0x4C +#define MCF5235_WCR 0x140000 + +#define MCF5235_PAR_AD *((volatile unsigned char *) (MCF_IPSBAR + 0x100040)) +#define PAR_DATAL 0x01 +#define MCF5235_PAR_UART *((volatile unsigned short *) (MCF_IPSBAR + 0x100048)) +#define PAR_ENABLE_U1U2_TXRX 0x0F0C +#endif /* m5235_h */ diff -Nur colilo-20040221/arch/5235/cache.S colilo-20040221/arch/5235/cache.S --- colilo-20040221/arch/5235/cache.S 1969-12-31 19:00:00.000000000 -0500 +++ colilo-20040221/arch/5235/cache.S 2005-07-22 10:40:11.778059960 -0400 @@ -0,0 +1,18 @@ +.global enableCache +.text + +/* This code enables the cache for Flash and SDRAM. It should really speed + * up the decompression of the image. + */ + +enableCache: + move.l #0x01400000, %d0 /* Invalidate whole cache */ + move.c %d0,%CACR + move.l #0xff00c000, %d0 /* Set FLASH cachable: always match (SM=0b10) */ + move.c %d0, %ACR0 + move.l #0x0000c000, %d0 /* Set SDRAM cachable: always match (SM=0b10) */ + move.c %d0, %ACR1 + move.l #0x90000200, %d0 /* Set cache enable cmd */ + move.c %d0,%CACR + rts + diff -Nur colilo-20040221/boot.S colilo-20040221/boot.S --- colilo-20040221/boot.S 2004-02-21 14:59:44.000000000 -0500 +++ colilo-20040221/boot.S 2005-07-22 10:54:03.988544736 -0400 @@ -32,7 +32,11 @@ * * NOTE: The 5249 has 32k + 64k of internal SRAM. ~Jeremy */ +#ifdef __MCF5235__ +#define MEM_BUILTIN 0x20000000 +#else #define MEM_BUILTIN 0x20010000 +#endif #ifdef __MCF5249__ #define MEM_BUILTIN2 0x20000000 @@ -64,7 +68,11 @@ _vectors: /* The initial program counter is 0x04. The start address needs to be there */ -.long 0x00000000, _start +#ifdef __MCF5235__ +.long 0x20000000, _start +#else +.long 0x00000000, _start +#endif .long _fault, _fault, _fault, _fault, _fault, _fault, _fault, _fault .long _fault, _fault, _fault, _fault, _fault, _fault, _fault, _fault .long _fault, _fault, _fault, _fault, _fault, _fault, _fault, _fault @@ -126,9 +134,10 @@ */ move.l #_vectors, %d0 /* Set VBR address (into FLASH) */ movec %d0, %VBR - +#ifndef __MCF5235__ move.l #(MCF_MBAR+1), %d0 /* Get MBAR address */ movec %d0, %MBAR /* Set MBAR */ +#endif /*** The 5249 has MBAR2 as well ***/ #ifdef MCF_MBAR2 @@ -136,7 +145,13 @@ movec %d0, #0xc0e /* Set MBAR2 */ #endif +#ifdef __MCF5235__ + move.l #(MEM_BUILTIN+0x201),%d0 + move.l %d0,(MCF_MBAR+0x08) + move.l #(MEM_BUILTIN+0x201),%a0 +#else move.l #MEM_BUILTIN+0x1,%a0 /* Set SRAM base addr */ +#endif movec %a0, %RAMBAR0 /* Note: bit 0 is Validate */ move.l #MEM_BUILTIN+INT_RAM_SIZE, %a7 /* Stack in internal SRAM */ diff -Nur colilo-20040221/Changelog colilo-20040221/Changelog --- colilo-20040221/Changelog 2004-02-21 15:03:55.000000000 -0500 +++ colilo-20040221/Changelog 2005-07-22 09:24:23.913440472 -0400 @@ -1,3 +1,7 @@ +20050722 Version 0.3.2 (Jate Sujjavanich, + +* Added support for M523xEVB + 20040221 Version 0.3.1 (Ken Treis, ) * Fix to M5249C3 DRAM initialization code (Jeremy Andrus) diff -Nur colilo-20040221/main.c colilo-20040221/main.c --- colilo-20040221/main.c 2004-02-21 14:59:44.000000000 -0500 +++ colilo-20040221/main.c 2005-04-12 17:22:40.000000000 -0400 @@ -79,7 +79,7 @@ setLED(LED_STATUS_UART); configureConsole(); configureAuxSerial(); - + #ifdef BOOTDEBUG dprintf("\n\r%s boot...\n\r", ident); #endif diff -Nur colilo-20040221/Makefile colilo-20040221/Makefile --- colilo-20040221/Makefile 2004-02-21 14:59:51.000000000 -0500 +++ colilo-20040221/Makefile 2005-07-22 11:08:19.408501136 -0400 @@ -8,6 +8,7 @@ # ---- ------ ----- # 5206e Motorola M5206eC3 # 5206e Motorola eLITE +# 5235 Motorola M5235EVB # 5249 Motorola M5249C3 # 5249 Motorola M5249C3-1MB # 5272 Motorola M5272C3 @@ -17,9 +18,9 @@ # 5307 Lineo NETtel # 5272 HDDLtd LDC -ARCH = 5249 +ARCH = 5235 VENDOR = Motorola -BOARD = M5249C3 +BOARD = M5235EVB # # Board Configuration @@ -47,14 +48,14 @@ CONFIG_FLASH = 1 BOOTDEBUG = 1 -# CONFIG_UI = 1 -MCF_FAST_CLK = 1 +#CONFIG_UI = 1 +#MCF_FAST_CLK = 1 # # Define location of cross-compiler # -CF_ROOT = /usr/local/lib/gcc-lib/m68k-elf/2.95.3 -GCC_EXEC_PREFIX = /usr/local/bin/m68k-elf- +CF_ROOT = /usr/local/m68k-uclinux-tools/lib/gcc/m68k-uclinux/3.4.0 +GCC_EXEC_PREFIX = /usr/local/m68k-uclinux-tools/bin/m68k-elf- CC = $(GCC_EXEC_PREFIX)gcc AS = $(GCC_EXEC_PREFIX)as @@ -89,7 +90,13 @@ endif endif -CFLAGS += -Os -g -fno-builtin -I$(ARCH_DIR) +# added for 5235 +ifeq ($(ARCH), 5235) +CFLAGS += -D__MCF5235__ +endif + +CFLAGS += -O0 -g -fno-builtin -I$(ARCH_DIR) +#changed -Os to -O0 ifdef RAM_SIZE CFLAGS += -DCONFIG_RAM_$(RAM_SIZE) diff -Nur colilo-20040221/mcfuart.h colilo-20040221/mcfuart.h --- colilo-20040221/mcfuart.h 2003-05-02 02:08:19.000000000 -0400 +++ colilo-20040221/mcfuart.h 2005-04-12 17:22:40.000000000 -0400 @@ -81,8 +81,7 @@ #define MCFUART_USR_RXFULL 0x02 /* Receiver full */ #define MCFUART_USR_RXREADY 0x01 /* Receiver ready */ -#define MCFUART_USR_RXERR (MCFUART_USR_RXBREAK | MCFUART_USR_RXFRAMING | \ - MCFUART_USR_RXPARITY | MCFUART_USR_RXOVERRUN) +#define MCFUART_USR_RXERR (MCFUART_USR_RXBREAK | MCFUART_USR_RXFRAMING | MCFUART_USR_RXPARITY | MCFUART_USR_RXOVERRUN) /* * Define bit flags in Clock Select Register (UCSR). diff -Nur colilo-20040221/serial.c colilo-20040221/serial.c --- colilo-20040221/serial.c 2003-05-02 02:08:19.000000000 -0400 +++ colilo-20040221/serial.c 2005-04-12 17:22:40.000000000 -0400 @@ -7,7 +7,7 @@ */ /****************************************************************************/ - + #include "arch.h" #include "mcfuart.h" #include "prototypes.h" @@ -18,6 +18,7 @@ { volatile unsigned char *uartp; double clock, fraction; + int divider, upper, lower; /* * Reset UART, get it into known state... @@ -34,17 +35,22 @@ */ uartp[MCFUART_UMR] = MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8; uartp[MCFUART_UMR] = MCFUART_MR2_STOP1; +#ifdef __MCF5235__ + divider = systemClock / 32 / baudRate; + uartp[MCFUART_UBG1] = ((divider >> 8) & 0xff); /* set msb baud */ + uartp[MCFUART_UBG2] = (divider & 0xff); /* set lsb baud */ +#else clock = ((double)systemClock / 32.0) / (double)(baudRate); /* Set baud above */ fraction = ((clock - (int)clock) * 16.0) + 0.5; - uartp[MCFUART_UBG1] = (((int)clock >> 8) & 0xff); /* set msb baud */ uartp[MCFUART_UBG2] = ((int)clock & 0xff); /* set lsb baud */ - /* Note: This register is not in the 5249 docs. I am assuming that Greg knew + /* Note: This register is not in the 5249 docs. I am assuming that Greg knew * what he was doing, so I'm leaving it here. ~Jeremy */ uartp[MCFUART_UFPD] = ((int)fraction & 0xf); /* set baud fraction adjust */ +#endif uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER; uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE; @@ -88,7 +94,7 @@ void console_nextPutAll(char *s) { char ch; - + while ((ch = *(s++)) != 0) { console_nextPut(ch); @@ -114,7 +120,7 @@ { volatile unsigned char *uartp; - if (port == 0) + if (port == 0) uartp = (volatile unsigned char *) (MCF_MBAR + MCFUART_BASE1); else uartp = (volatile unsigned char *) (MCF_MBAR + MCFUART_BASE2); @@ -130,7 +136,7 @@ int rs_get_char(void) { volatile unsigned char *uartp; - + uartp = (volatile unsigned char *)(MCF_MBAR + consoleBase); return(uartp[MCFUART_URB]); } @@ -139,7 +145,7 @@ { volatile unsigned char *uartp; - if (port == 0) + if (port == 0) uartp = (volatile unsigned char *) (MCF_MBAR + MCFUART_BASE1); else uartp = (volatile unsigned char *) (MCF_MBAR + MCFUART_BASE2); diff -Nur colilo-20040221/vendors/Motorola/M523xEVB/board.c colilo-20040221/vendors/Motorola/M523xEVB/board.c --- colilo-20040221/vendors/Motorola/M523xEVB/board.c 1969-12-31 19:00:00.000000000 -0500 +++ colilo-20040221/vendors/Motorola/M523xEVB/board.c 2005-07-22 11:16:50.646781104 -0400 @@ -0,0 +1,129 @@ +/* + * 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 0xffe08000 /* colilo shouldn't be more than 32k */ +#define IMAGE_SIZE 0x001f7fff /* 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 +} diff -Nur colilo-20040221/vendors/Motorola/M523xEVB/flash.ld colilo-20040221/vendors/Motorola/M523xEVB/flash.ld --- colilo-20040221/vendors/Motorola/M523xEVB/flash.ld 1969-12-31 19:00:00.000000000 -0500 +++ colilo-20040221/vendors/Motorola/M523xEVB/flash.ld 2005-04-12 17:22:40.000000000 -0400 @@ -0,0 +1,28 @@ + +MEMORY { + flash : ORIGIN = 0xffe00000, LENGTH = 0x001F0000 /* 1MB of flash (A[20] pulled high) */ + ram : ORIGIN = 0x00010000, LENGTH = 0x01000000 /* 256Kbytes of sdram */ +} + +SECTIONS { + + .text : { + _stext = . ; + *(.text) + *(.rodata) + _etext = . ; + } > flash + + .data : AT (ADDR(.text) + SIZEOF(.text)) { + _sdata = . ; + *(.data) + _edata = . ; + } > ram + + .bss : AT (ADDR(.text) + SIZEOF(.text) + SIZEOF(.data)) { + _sbss = . ; + *(.bss) + *(COMMON) + _ebss = . ; + } > ram +} diff -Nur colilo-20040221/vendors/Motorola/M523xEVB/Makefile colilo-20040221/vendors/Motorola/M523xEVB/Makefile --- colilo-20040221/vendors/Motorola/M523xEVB/Makefile 1969-12-31 19:00:00.000000000 -0500 +++ colilo-20040221/vendors/Motorola/M523xEVB/Makefile 2005-04-12 17:22:40.000000000 -0400 @@ -0,0 +1,3 @@ +colilo.s19: $(SOURCE_DIR)/colilo.bin + $(OBJCOPY) --input-target=binary --output-target=srec --adjust-vma 0xffe00000 \ + $(SOURCE_DIR)/colilo.bin $(SOURCE_DIR)/colilo.s19 diff -Nur colilo-20040221/vendors/Motorola/M523xEVB/ram.ld colilo-20040221/vendors/Motorola/M523xEVB/ram.ld --- colilo-20040221/vendors/Motorola/M523xEVB/ram.ld 1969-12-31 19:00:00.000000000 -0500 +++ colilo-20040221/vendors/Motorola/M523xEVB/ram.ld 2005-04-12 17:22:40.000000000 -0400 @@ -0,0 +1,28 @@ + +MEMORY { +/* flash : ORIGIN = 0xffe00000, LENGTH = 0x00100000 /* 1MB of flash (A[20] pulled high) */ + ram : ORIGIN = 0x00020000, LENGTH = 0x00FE0000 /* 256Kbytes of sdram */ +} + +SECTIONS { + + .text : { + _stext = . ; + *(.text) + *(.rodata) + _etext = . ; + } > ram + + .data : AT (ADDR(.text) + SIZEOF(.text)) { + _sdata = . ; + *(.data) + _edata = . ; + } > ram + + .bss : AT (ADDR(.text) + SIZEOF(.text) + SIZEOF(.data)) { + _sbss = . ; + *(.bss) + *(COMMON) + _ebss = . ; + } > ram +}