ppc4xx: ML507: U-Boot in flash and System ACE

This patch allows booting from FLASH the ML507 board by Xilinx.
Previously, U-Boot needed to be loaded from JTAG or a Sytem ACE CF

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
Signed-off-by: Stefan Roese <sr@denx.de>
diff --git a/board/xilinx/ml507/config.mk b/board/xilinx/ml507/config.mk
index 35c52ad..e827e8a 100644
--- a/board/xilinx/ml507/config.mk
+++ b/board/xilinx/ml507/config.mk
@@ -20,5 +20,8 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
 #
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
+ifndef TEXT_BASE
 TEXT_BASE = 0x04000000
+endif
diff --git a/board/xilinx/ml507/init.S b/board/xilinx/ml507/init.S
index f54d929..3228a65 100644
--- a/board/xilinx/ml507/init.S
+++ b/board/xilinx/ml507/init.S
@@ -35,13 +35,19 @@
 	/* PIC */
 tlbentry(XPAR_INTC_0_BASEADDR, SZ_64K, XPAR_INTC_0_BASEADDR, 0,
 	 AC_R | AC_W | SA_G | SA_I)
+#ifdef XPAR_IIC_EEPROM_BASEADDR
 	/* I2C */
 tlbentry(XPAR_IIC_EEPROM_BASEADDR, SZ_64K, XPAR_IIC_EEPROM_BASEADDR, 0,
 	 AC_R | AC_W | SA_G | SA_I)
+#endif
+#ifdef XPAR_LLTEMAC_0_BASEADDR
 	/* Net */
 tlbentry(XPAR_LLTEMAC_0_BASEADDR, SZ_64K, XPAR_LLTEMAC_0_BASEADDR, 0,
 	 AC_R | AC_W | SA_G | SA_I)
+#endif
+#ifdef XPAR_FLASH_MEM0_BASEADDR
 	/*Flash*/
 tlbentry(XPAR_FLASH_MEM0_BASEADDR, SZ_256M, XPAR_FLASH_MEM0_BASEADDR, 0,
-	AC_R | AC_W | SA_G | SA_I)
+	 AC_R | AC_W | AC_X | SA_G | SA_I)
+#endif
 tlbtab_end
diff --git a/board/xilinx/ml507/u-boot.lds b/board/xilinx/ml507/u-boot-ram.lds
similarity index 89%
rename from board/xilinx/ml507/u-boot.lds
rename to board/xilinx/ml507/u-boot-ram.lds
index ef2bdc3..2c98d27 100644
--- a/board/xilinx/ml507/u-boot.lds
+++ b/board/xilinx/ml507/u-boot-ram.lds
@@ -1,8 +1,6 @@
 /*
- * (C) Copyright 2000
+ * (C) Copyright 2000-2004
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- * 2008:
- * Modified by: Ricardo Ribalda Delgado ricardo.ribalda@uam.es
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -25,8 +23,7 @@
 
 OUTPUT_ARCH(powerpc)
 ENTRY(_start_440)
-/* Do we need any of these for elf?
-   __DYNAMIC = 0;    */
+
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
@@ -55,6 +52,10 @@
   .plt : { *(.plt) }
   .text      :
   {
+    /* WARNING - the following is hand-optimized to fit within	*/
+    /* the sector layout of our flash chips!	XXX FIXME XXX	*/
+
+
     *(.text)
     *(.fixup)
     *(.got1)
@@ -125,6 +126,9 @@
    *(.bss)
    *(COMMON)
   }
+
+  ppcenv_assert = ASSERT(. < 0xFFFFB000, ".bss section too big, overlaps .ppcenv section. Please update your confguration: CFG_MONITOR_BASE, CFG_MONITOR_LEN and TEXT_BASE may need to be modified.");
+
   _end = . ;
   PROVIDE (end = .);
 }
diff --git a/board/xilinx/ml507/u-boot.lds b/board/xilinx/ml507/u-boot-rom.lds
similarity index 85%
copy from board/xilinx/ml507/u-boot.lds
copy to board/xilinx/ml507/u-boot-rom.lds
index ef2bdc3..d5da018 100644
--- a/board/xilinx/ml507/u-boot.lds
+++ b/board/xilinx/ml507/u-boot-rom.lds
@@ -1,8 +1,6 @@
 /*
- * (C) Copyright 2000
+ * (C) Copyright 2000-2004
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- * 2008:
- * Modified by: Ricardo Ribalda Delgado ricardo.ribalda@uam.es
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -25,10 +23,19 @@
 
 OUTPUT_ARCH(powerpc)
 ENTRY(_start_440)
-/* Do we need any of these for elf?
-   __DYNAMIC = 0;    */
+
 SECTIONS
 {
+  .resetvec 0xFFFFFFFC :
+  {
+    *(.resetvec)
+  } = 0xffff
+
+  .bootpg 0xFFFFF000 :
+  {
+    cpu/ppc4xx/start.o	(.bootpg)
+  } = 0xffff
+
   /* Read-only sections, merged into text segment: */
   . = + SIZEOF_HEADERS;
   .interp : { *(.interp) }
@@ -55,6 +62,10 @@
   .plt : { *(.plt) }
   .text      :
   {
+    /* WARNING - the following is hand-optimized to fit within	*/
+    /* the sector layout of our flash chips!	XXX FIXME XXX	*/
+
+
     *(.text)
     *(.fixup)
     *(.got1)
@@ -125,6 +136,9 @@
    *(.bss)
    *(COMMON)
   }
+
+  ppcenv_assert = ASSERT(. < 0xFFFFB000, ".bss section too big, overlaps .ppcenv section. Please update your confguration: CFG_MONITOR_BASE, CFG_MONITOR_LEN and TEXT_BASE may need to be modified.");
+
   _end = . ;
   PROVIDE (end = .);
 }
diff --git a/board/xilinx/ml507/xparameters.h b/board/xilinx/ml507/xparameters.h
index 1542e84..6a8e183 100644
--- a/board/xilinx/ml507/xparameters.h
+++ b/board/xilinx/ml507/xparameters.h
@@ -22,13 +22,14 @@
 #define XPARAMETER_H
 
 #define XPAR_DDR2_SDRAM_MEM_BASEADDR 	0x00000000
-#define XPAR_INTC_0_BASEADDR 		0x81800000
-#define XPAR_UARTLITE_0_BASEADDR 	0x84000000
 #define XPAR_IIC_EEPROM_BASEADDR 	0x81600000
+#define XPAR_INTC_0_BASEADDR 		0x81800000
 #define XPAR_LLTEMAC_0_BASEADDR 	0x81c00000
-#define XPAR_FLASH_MEM0_BASEADDR 	0xFC000000
+#define XPAR_UARTLITE_0_BASEADDR 	0x84000000
+#define XPAR_FLASH_MEM0_BASEADDR 	0xFE000000
 #define XPAR_PLB_CLOCK_FREQ_HZ 		100000000
 #define XPAR_CORE_CLOCK_FREQ_HZ 	400000000
 #define XPAR_INTC_MAX_NUM_INTR_INPUTS 	13
+#define XPAR_UARTLITE_0_BAUDRATE	9600
 
 #endif