Merge branch 'master' of git://git.denx.de/u-boot-net
diff --git a/MAINTAINERS b/MAINTAINERS
index e8ba4bc..fe63a9f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -134,8 +134,6 @@
 	PCIPPC2		MPC750
 	PCIPPC6		MPC750
 
-	EXBITGEN	PPC405GP
-
 Jon Diekema <jon.diekema@smiths-aerospace.com>
 
 	sbc8260		MPC8260
diff --git a/MAKEALL b/MAKEALL
index 15e93cf..684db67 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -213,7 +213,6 @@
 	DU440		\
 	ebony		\
 	ERIC		\
-	EXBITGEN	\
 	fx12mm		\
 	G2000		\
 	gdppc440etx	\
@@ -404,6 +403,7 @@
 	MPC8568MDS	\
 	MPC8569MDS	\
 	MPC8569MDS_ATM	\
+	MPC8569MDS_NAND \
 	MPC8572DS	\
 	MPC8572DS_36BIT	\
 	P2020DS		\
diff --git a/Makefile b/Makefile
index 69b963f..e4431f7 100644
--- a/Makefile
+++ b/Makefile
@@ -1336,9 +1336,6 @@
 ERIC_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) ppc ppc4xx eric
 
-EXBITGEN_config:	unconfig
-	@$(MKCONFIG) $(@:_config=) ppc ppc4xx exbitgen
-
 fx12mm_flash_config: unconfig
 	@mkdir -p $(obj)include $(obj)board/xilinx/ppc405-generic
 	@mkdir -p $(obj)include $(obj)board/avnet/fx12mm
@@ -2490,6 +2487,7 @@
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8568mds freescale
 
 MPC8569MDS_ATM_config \
+MPC8569MDS_NAND_config \
 MPC8569MDS_config:	unconfig
 	@$(MKCONFIG) -t $(@:_config=) MPC8569MDS ppc mpc85xx mpc8569mds freescale
 
diff --git a/board/exbitgen/Makefile b/board/exbitgen/Makefile
deleted file mode 100644
index 4f752a8..0000000
--- a/board/exbitgen/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# (C) Copyright 2000-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# See file CREDITS for list of people who contributed to this
-# project.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-
-include $(TOPDIR)/config.mk
-
-LIB	= $(obj)lib$(BOARD).a
-
-COBJS	= $(BOARD).o flash.o
-
-SOBJS	= init.o
-
-SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(COBJS))
-SOBJS	:= $(addprefix $(obj),$(SOBJS))
-
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) $(ARFLAGS) $@ $^
-
-clean:
-	rm -f $(SOBJS) $(OBJS)
-
-distclean:	clean
-	rm -f $(LIB) core *.bak $(obj).depend
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/board/exbitgen/config.mk b/board/exbitgen/config.mk
deleted file mode 100644
index 42ea0c6..0000000
--- a/board/exbitgen/config.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# (C) Copyright 2000
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# See file CREDITS for list of people who contributed to this
-# project.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-
-#
-# ExbitGen board
-#
-
-LDFLAGS += $(LINKER_UNDEFS)
-
-TEXT_BASE := 0xFFF80000
-#TEXT_BASE := 0x00100000
-
-PLATFORM_RELFLAGS := $(PLATFORM_RELFLAGS)
diff --git a/board/exbitgen/exbitgen.c b/board/exbitgen/exbitgen.c
deleted file mode 100644
index 50d9748..0000000
--- a/board/exbitgen/exbitgen.c
+++ /dev/null
@@ -1,126 +0,0 @@
-#include <common.h>
-#include <asm/u-boot.h>
-#include <asm/processor.h>
-#include "exbitgen.h"
-
-void sdram_init(void);
-
-/* ************************************************************************ */
-int board_early_init_f (void)
-/* ------------------------------------------------------------------------ --
- * Purpose     :
- * Remarks     :
- * Restrictions:
- * See also    :
- * Example     :
- * ************************************************************************ */
-{
-	unsigned long i;
-
-   /*-------------------------------------------------------------------------+
-   | Interrupt controller setup for the Walnut board.
-   | Note: IRQ 0-15  405GP internally generated; active high; level sensitive
-   |       IRQ 16    405GP internally generated; active low; level sensitive
-   |       IRQ 17-24 RESERVED
-   |       IRQ 25 (EXT IRQ 0) FPGA; active high; level sensitive
-   |       IRQ 26 (EXT IRQ 1) SMI; active high; level sensitive
-   |       IRQ 27 (EXT IRQ 2) Not Used
-   |       IRQ 28 (EXT IRQ 3) PCI SLOT 3; active low; level sensitive
-   |       IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
-   |       IRQ 30 (EXT IRQ 5) PCI SLOT 1; active low; level sensitive
-   |       IRQ 31 (EXT IRQ 6) PCI SLOT 0; active low; level sensitive
-   | Note for Walnut board:
-   |       An interrupt taken for the FPGA (IRQ 25) indicates that either
-   |       the Mouse, Keyboard, IRDA, or External Expansion caused the
-   |       interrupt. The FPGA must be read to determine which device
-   |       caused the interrupt. The default setting of the FPGA clears
-   |
-   +-------------------------------------------------------------------------*/
-
-	mtdcr (UIC0SR, 0xFFFFFFFF);	/* clear all ints */
-	mtdcr (UIC0ER, 0x00000000);	/* disable all ints */
-	mtdcr (UIC0CR, 0x00000020);	/* set all but FPGA SMI to be non-critical */
-	mtdcr (UIC0PR, 0xFFFFFF90);	/* set int polarities */
-	mtdcr (UIC0TR, 0x10000000);	/* set int trigger levels */
-	mtdcr (UIC0VCR, 0x00000001);	/* set vect base=0,INT0 highest priority */
-	mtdcr (UIC0SR, 0xFFFFFFFF);	/* clear all ints */
-
-	/* Perform reset of PHY connected to PPC via register in CPLD */
-	out8 (PHY_CTRL_ADDR, 0x2e);	/* activate nRESET,FDX,F100,ANEN, enable output */
-	for (i = 0; i < 10000000; i++) {
-		;
-	}
-	out8 (PHY_CTRL_ADDR, 0x2f);	/* deactivate nRESET */
-
-	return 0;
-}
-
-
-/* ************************************************************************ */
-int checkboard (void)
-/* ------------------------------------------------------------------------ --
- * Purpose     :
- * Remarks     :
- * Restrictions:
- * See also    :
- * Example     :
- * ************************************************************************ */
-{
-	printf ("Exbit H/W id: %d\n", in8 (HW_ID_ADDR));
-	return (0);
-}
-
-/* ************************************************************************ */
-phys_size_t initdram (int board_type)
-/* ------------------------------------------------------------------------ --
- * Purpose     : Determines size of mounted DRAM.
- * Remarks     : Size is determined by reading SDRAM configuration registers as
- *               set up by sdram_init.
- * Restrictions:
- * See also    :
- * Example     :
- * ************************************************************************ */
-{
-	ulong tot_size;
-	ulong bank_size;
-	ulong tmp;
-
-	/*
-	 * ToDo: Move the asm init routine sdram_init() to this C file,
-	 * or even better use some common ppc4xx code available
-	 * in cpu/ppc4xx
-	 */
-	sdram_init();
-
-	tot_size = 0;
-
-	mtdcr (SDRAM0_CFGADDR, SDRAM0_B0CR);
-	tmp = mfdcr (SDRAM0_CFGDATA);
-	if (tmp & 0x00000001) {
-		bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
-		tot_size += bank_size;
-	}
-
-	mtdcr (SDRAM0_CFGADDR, SDRAM0_B1CR);
-	tmp = mfdcr (SDRAM0_CFGDATA);
-	if (tmp & 0x00000001) {
-		bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
-		tot_size += bank_size;
-	}
-
-	mtdcr (SDRAM0_CFGADDR, SDRAM0_B2CR);
-	tmp = mfdcr (SDRAM0_CFGDATA);
-	if (tmp & 0x00000001) {
-		bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
-		tot_size += bank_size;
-	}
-
-	mtdcr (SDRAM0_CFGADDR, SDRAM0_B3CR);
-	tmp = mfdcr (SDRAM0_CFGDATA);
-	if (tmp & 0x00000001) {
-		bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
-		tot_size += bank_size;
-	}
-
-	return tot_size;
-}
diff --git a/board/exbitgen/exbitgen.h b/board/exbitgen/exbitgen.h
deleted file mode 100644
index dceaf6d..0000000
--- a/board/exbitgen/exbitgen.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#define GPIO_CPU_LED		GPIO_3
-
-
-#define CPLD_BASE		0x10000000		/* t.b.m. */
-#define DEBUG_LEDS_ADDR		CPLD_BASE + 0x01
-#define HW_ID_ADDR		CPLD_BASE + 0x02
-#define DIP_SWITCH_ADDR		CPLD_BASE + 0x04
-#define PHY_CTRL_ADDR		CPLD_BASE + 0x05
-#define SPI_OUT_ADDR		CPLD_BASE + 0x07
-#define SPI_IN_ADDR		CPLD_BASE + 0x08
-#define MDIO_OUT_ADDR		CPLD_BASE + 0x09
-#define MDIO_IN_ADDR		CPLD_BASE + 0x0A
-#define MISC_OUT_ADDR		CPLD_BASE + 0x0B
-
-/* Addresses used on I2C bus */
-#define LM75_CHIP_ADDR		0x9C
-#define LM75_CPU_ADDR		0x9E
-#define SDRAM_SPD_ADDR		0xA0
-
-#define SDRAM_SPD_WRITE_ADDRESS	(SDRAM_SPD_ADDR)
-#define SDRAM_SPD_READ_ADDRESS	(SDRAM_SPD_ADDR+1)
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
diff --git a/board/exbitgen/flash.c b/board/exbitgen/flash.c
deleted file mode 100644
index cd45cb6..0000000
--- a/board/exbitgen/flash.c
+++ /dev/null
@@ -1,597 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-/*
- * Modified 4/5/2001
- * Wait for completion of each sector erase command issued
- * 4/5/2001
- * Chris Hallinan - DS4.COM, Inc. - clh@net1plus.com
- */
-
-#include <common.h>
-#include <asm/u-boot.h>
-#include <asm/processor.h>
-#include <ppc4xx.h>
-
-flash_info_t	flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips	*/
-
-/*-----------------------------------------------------------------------
- * Functions
- */
-static ulong flash_get_size (vu_long *addr, flash_info_t *info);
-static int write_word (flash_info_t *info, ulong dest, ulong data);
-
-#ifdef MEIGSBOARD_ONBOARD_FLASH /* onboard = 2MB */
-#  ifdef CONFIG_EXBITGEN
-#     define FLASH_WORD_SIZE unsigned long
-#  endif
-#else /* Meigsboard socket flash = 512KB */
-#  ifdef CONFIG_EXBITGEN
-#    define FLASH_WORD_SIZE unsigned char
-#  endif
-#endif
-
-#ifdef CONFIG_EXBITGEN
-#define ADDR0           0x5555
-#define ADDR1           0x2aaa
-#define FLASH_WORD_SIZE unsigned char
-#endif
-
-/*-----------------------------------------------------------------------
- */
-
-unsigned long flash_init (void)
-{
-	unsigned long bank_size;
-	unsigned long tot_size;
-	unsigned long bank_addr;
-	int i;
-
-	/* Init: no FLASHes known */
-	for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
-		flash_info[i].flash_id = FLASH_UNKNOWN;
-		flash_info[i].size = 0;
-	}
-
-	tot_size = 0;
-
-	/* Detect Boot Flash */
-	bank_addr = CONFIG_SYS_FLASH0_BASE;
-	bank_size = flash_get_size((vu_long *)bank_addr, &flash_info[0]);
-	if (bank_size > 0) {
-		(void)flash_protect(FLAG_PROTECT_CLEAR,
-			bank_addr,
-			bank_addr + bank_size - 1,
-			&flash_info[0]);
-	}
-	if (flash_info[0].flash_id == FLASH_UNKNOWN) {
-		printf ("## Unknown FLASH on Boot Flash Bank\n");
-	}
-	flash_info[0].size = bank_size;
-	tot_size += bank_size;
-
-	/* Detect Application Flash */
-	bank_addr = CONFIG_SYS_FLASH1_BASE;
-	for (i = 1; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
-		bank_size = flash_get_size((vu_long *)bank_addr, &flash_info[i]);
-		if (flash_info[i].flash_id == FLASH_UNKNOWN) {
-			break;
-		}
-		if (bank_size > 0) {
-			(void)flash_protect(FLAG_PROTECT_CLEAR,
-				bank_addr,
-				bank_addr + bank_size - 1,
-				&flash_info[i]);
-		}
-		flash_info[i].size = bank_size;
-		tot_size += bank_size;
-		bank_addr += bank_size;
-	}
-	if (flash_info[1].flash_id == FLASH_UNKNOWN) {
-		printf ("## Unknown FLASH on Application Flash Bank\n");
-	}
-
-	/* Protect monitor and environment sectors */
-#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH0_BASE
-	flash_protect(FLAG_PROTECT_SET,
-		CONFIG_SYS_MONITOR_BASE,
-		CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
-		&flash_info[0]);
-#if 0xfffffffc >= CONFIG_SYS_FLASH0_BASE
-#if 0xfffffffc <= CONFIG_SYS_FLASH0_BASE + CONFIG_SYS_FLASH0_SIZE - 1
-	flash_protect(FLAG_PROTECT_SET,
-		0xfffffffc, 0xffffffff,
-		&flash_info[0]);
-#endif
-#endif
-#endif
-
-#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR)
-	flash_protect(FLAG_PROTECT_SET,
-		CONFIG_ENV_ADDR,
-		CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
-		&flash_info[0]);
-#endif
-
-	return tot_size;
-}
-
-/*-----------------------------------------------------------------------
- */
-void flash_print_info  (flash_info_t *info)
-{
-	int i;
-
-	if (info->flash_id == FLASH_UNKNOWN) {
-		printf ("missing or unknown FLASH type\n");
-		return;
-	}
-
-	switch (info->flash_id & FLASH_VENDMASK) {
-	case FLASH_MAN_AMD:	printf ("AMD ");		break;
-	case FLASH_MAN_FUJ:	printf ("FUJITSU ");		break;
-	case FLASH_MAN_SST:	printf ("SST ");		break;
-	default:		printf ("Unknown Vendor ");	break;
-	}
-
-	switch (info->flash_id & FLASH_TYPEMASK) {
-	case FLASH_AM040:	printf ("AM29F040 (512 Kbit, uniform sector size)\n");
-				break;
-	case FLASH_AM400B:	printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
-				break;
-	case FLASH_AM400T:	printf ("AM29LV400T (4 Mbit, top boot sector)\n");
-				break;
-	case FLASH_AM800B:	printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
-				break;
-	case FLASH_AM800T:	printf ("AM29LV800T (8 Mbit, top boot sector)\n");
-				break;
-	case FLASH_AM160B:	printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
-				break;
-	case FLASH_AM160T:	printf ("AM29LV160T (16 Mbit, top boot sector)\n");
-				break;
-	case FLASH_AM320B:	printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
-				break;
-	case FLASH_AM320T:	printf ("AM29LV320T (32 Mbit, top boot sector)\n");
-				break;
-	case FLASH_AMDLV033C:	printf ("AM29LV033C (32 Mbit, uniform sector size)\n");
-				break;
-	case FLASH_AMDLV065D:	printf ("AM29LV065D (64 Mbit, uniform sector size)\n");
-				break;
-	case FLASH_SST800A:	printf ("SST39LF/VF800 (8 Mbit, uniform sector size)\n");
-				break;
-	case FLASH_SST160A:	printf ("SST39LF/VF160 (16 Mbit, uniform sector size)\n");
-				break;
-	case FLASH_SST040:	printf ("SST39LF/VF040 (4 Mbit, uniform sector size)\n");
-				break;
-	default:		printf ("Unknown Chip Type\n");
-				break;
-	}
-
-	printf ("  Size: %ld KB in %d Sectors\n",
-		info->size >> 10, info->sector_count);
-
-	printf ("  Sector Start Addresses:");
-	for (i=0; i<info->sector_count; ++i) {
-		if ((i % 5) == 0)
-			printf ("\n   ");
-		printf (" %08lX%s",
-			info->start[i],
-			info->protect[i] ? " (RO)" : "     "
-		);
-	}
-	printf ("\n");
-}
-
-/*-----------------------------------------------------------------------
- */
-
-
-/*-----------------------------------------------------------------------
- */
-
-/*
- * The following code cannot be run from FLASH!
- */
-static ulong flash_get_size (vu_long *addr, flash_info_t *info)
-{
-	short i;
-	FLASH_WORD_SIZE value;
-	ulong base = (ulong)addr;
-	volatile FLASH_WORD_SIZE *addr2 = (FLASH_WORD_SIZE *)addr;
-
-	/* Write auto select command: read Manufacturer ID */
-	addr2[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
-	addr2[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
-	addr2[ADDR0] = (FLASH_WORD_SIZE)0x00900090;
-
-	value = addr2[0];
-
-	switch (value) {
-	case (FLASH_WORD_SIZE)AMD_MANUFACT:
-		info->flash_id = FLASH_MAN_AMD;
-		break;
-	case (FLASH_WORD_SIZE)FUJ_MANUFACT:
-		info->flash_id = FLASH_MAN_FUJ;
-		break;
-	case (FLASH_WORD_SIZE)SST_MANUFACT:
-		info->flash_id = FLASH_MAN_SST;
-		break;
-	default:
-		info->flash_id = FLASH_UNKNOWN;
-		info->sector_count = 0;
-		info->size = 0;
-		return (0);			/* no or unknown flash	*/
-	}
-
-	value = addr2[1];			/* device ID		*/
-
-	switch (value) {
-	case (FLASH_WORD_SIZE)AMD_ID_F040B:
-		info->flash_id += FLASH_AM040;
-		info->sector_count = 8;
-		info->size = 0x0080000; /* => 512 ko */
-		break;
-	case (FLASH_WORD_SIZE)AMD_ID_LV400T:
-		info->flash_id += FLASH_AM400T;
-		info->sector_count = 11;
-		info->size = 0x00080000;
-		break;				/* => 0.5 MB		*/
-
-	case (FLASH_WORD_SIZE)AMD_ID_LV400B:
-		info->flash_id += FLASH_AM400B;
-		info->sector_count = 11;
-		info->size = 0x00080000;
-		break;				/* => 0.5 MB		*/
-
-	case (FLASH_WORD_SIZE)AMD_ID_LV800T:
-		info->flash_id += FLASH_AM800T;
-		info->sector_count = 19;
-		info->size = 0x00100000;
-		break;				/* => 1 MB		*/
-
-	case (FLASH_WORD_SIZE)AMD_ID_LV800B:
-		info->flash_id += FLASH_AM800B;
-		info->sector_count = 19;
-		info->size = 0x00100000;
-		break;				/* => 1 MB		*/
-
-	case (FLASH_WORD_SIZE)AMD_ID_LV160T:
-		info->flash_id += FLASH_AM160T;
-		info->sector_count = 35;
-		info->size = 0x00200000;
-		break;				/* => 2 MB		*/
-
-	case (FLASH_WORD_SIZE)AMD_ID_LV160B:
-		info->flash_id += FLASH_AM160B;
-		info->sector_count = 35;
-		info->size = 0x00200000;
-		break;				/* => 2 MB		*/
-
-	case (FLASH_WORD_SIZE)AMD_ID_LV033C:
-		info->flash_id += FLASH_AMDLV033C;
-		info->sector_count = 64;
-		info->size = 0x00400000;
-		break;				/* => 4 MB		*/
-
-	case (FLASH_WORD_SIZE)AMD_ID_LV065D:
-		info->flash_id += FLASH_AMDLV065D;
-		info->sector_count = 128;
-		info->size = 0x00800000;
-		break;				/* => 8 MB		*/
-
-	case (FLASH_WORD_SIZE)AMD_ID_LV320T:
-		info->flash_id += FLASH_AM320T;
-		info->sector_count = 67;
-		info->size = 0x00400000;
-		break;				/* => 4 MB		*/
-
-	case (FLASH_WORD_SIZE)AMD_ID_LV320B:
-		info->flash_id += FLASH_AM320B;
-		info->sector_count = 67;
-		info->size = 0x00400000;
-		break;				/* => 4 MB		*/
-
-	case (FLASH_WORD_SIZE)SST_ID_xF800A:
-		info->flash_id += FLASH_SST800A;
-		info->sector_count = 16;
-		info->size = 0x00100000;
-		break;				/* => 1 MB		*/
-
-	case (FLASH_WORD_SIZE)SST_ID_xF160A:
-		info->flash_id += FLASH_SST160A;
-		info->sector_count = 32;
-		info->size = 0x00200000;
-		break;				/* => 2 MB		*/
-	case (FLASH_WORD_SIZE)SST_ID_xF040:
-		info->flash_id += FLASH_SST040;
-		info->sector_count = 128;
-		info->size = 0x00080000;
-		break;				/* => 512KB		*/
-
-	default:
-		info->flash_id = FLASH_UNKNOWN;
-		return (0);			/* => no or unknown flash */
-
-	}
-
-	/* set up sector start address table */
-	if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) ||
-		(info->flash_id  == FLASH_AM040) ||
-		(info->flash_id == FLASH_AMDLV033C) ||
-		(info->flash_id == FLASH_AMDLV065D)) {
-		ulong sectsize = info->size / info->sector_count;
-		for (i = 0; i < info->sector_count; i++)
-			info->start[i] = base + (i * sectsize);
-	} else {
-	    if (info->flash_id & FLASH_BTYPE) {
-		/* set sector offsets for bottom boot block type	*/
-		info->start[0] = base + 0x00000000;
-		info->start[1] = base + 0x00004000;
-		info->start[2] = base + 0x00006000;
-		info->start[3] = base + 0x00008000;
-		for (i = 4; i < info->sector_count; i++) {
-			info->start[i] = base + (i * 0x00010000) - 0x00030000;
-		}
-	    } else {
-		/* set sector offsets for top boot block type		*/
-		i = info->sector_count - 1;
-		info->start[i--] = base + info->size - 0x00004000;
-		info->start[i--] = base + info->size - 0x00006000;
-		info->start[i--] = base + info->size - 0x00008000;
-		for (; i >= 0; i--) {
-			info->start[i] = base + i * 0x00010000;
-		}
-	    }
-	}
-
-	/* check for protected sectors */
-	for (i = 0; i < info->sector_count; i++) {
-		/* read sector protection at sector address, (A7 .. A0) = 0x02 */
-		/* D0 = 1 if protected */
-
-		addr2 = (volatile FLASH_WORD_SIZE *)(info->start[i]);
-		if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST)
-			info->protect[i] = 0;
-		else
-			info->protect[i] = addr2[2] & 1;
-	}
-
-	/* switch to the read mode */
-	if (info->flash_id != FLASH_UNKNOWN) {
-		addr2 = (FLASH_WORD_SIZE *)info->start[0];
-		*addr2 = (FLASH_WORD_SIZE)0x00F000F0;	/* reset bank */
-	}
-
-	return (info->size);
-}
-
-/*-----------------------------------------------------------------------
- */
-
-int flash_erase (flash_info_t *info, int s_first, int s_last)
-{
-	volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[0]);
-	volatile FLASH_WORD_SIZE *addr2;
-	int flag, prot, sect;
-	ulong start, now, last;
-
-	if ((s_first < 0) || (s_first > s_last)) {
-		if (info->flash_id == FLASH_UNKNOWN) {
-			printf ("- missing\n");
-		} else {
-			printf ("- no sectors to erase\n");
-		}
-		return 1;
-	}
-
-	if (info->flash_id == FLASH_UNKNOWN) {
-		printf ("Can't erase unknown flash type - aborted\n");
-		return 1;
-	}
-
-	prot = 0;
-	for (sect=s_first; sect<=s_last; ++sect) {
-		if (info->protect[sect]) {
-			prot++;
-		}
-	}
-
-	if (prot) {
-		printf ("- Warning: %d protected sectors will not be erased!\n",
-			prot);
-	} else {
-		printf ("\n");
-	}
-
-	start = get_timer (0);
-	last  = start;
-	/* Start erase on unprotected sectors */
-	for (sect = s_first; sect <= s_last; sect++) {
-		if (info->protect[sect] == 0) {	/* not protected */
-			addr2 = (FLASH_WORD_SIZE *)(info->start[sect]);
-
-			/* Disable interrupts which might cause a timeout here */
-			flag = disable_interrupts();
-
-			addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
-			addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
-			addr[ADDR0] = (FLASH_WORD_SIZE)0x00800080;
-			addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
-			addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
-			addr2[0] = (FLASH_WORD_SIZE)0x00300030;
-
-			/* re-enable interrupts if necessary */
-			if (flag)
-				enable_interrupts();
-
-			/* wait at least 80us - let's wait 1 ms */
-			udelay (1000);
-
-			while ((addr2[0] & 0x00800080) !=
-				(FLASH_WORD_SIZE) 0x00800080) {
-				if ((now=get_timer(start)) >
-					   CONFIG_SYS_FLASH_ERASE_TOUT) {
-					printf ("Timeout\n");
-					addr[0] = (FLASH_WORD_SIZE)0x00F000F0;
-					return 1;
-				}
-
-				/* show that we're waiting */
-				if ((now - last) > 1000) {  /* every second  */
-					putc ('.');
-					last = now;
-				}
-			}
-
-			addr[0] = (FLASH_WORD_SIZE)0x00F000F0;
-		}
-	}
-
-	printf (" done\n");
-
-	return 0;
-}
-
-/*-----------------------------------------------------------------------
- * Copy memory to flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-
-int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
-{
-	ulong cp, wp, data;
-	int i, l, rc;
-
-	wp = (addr & ~3);	/* get lower word aligned address */
-
-	/*
-	 * handle unaligned start bytes
-	 */
-	if ((l = addr - wp) != 0) {
-		data = 0;
-		for (i=0, cp=wp; i<l; ++i, ++cp) {
-			data = (data << 8) | (*(uchar *)cp);
-		}
-		for (; i<4 && cnt>0; ++i) {
-			data = (data << 8) | *src++;
-			--cnt;
-			++cp;
-		}
-		for (; cnt==0 && i<4; ++i, ++cp) {
-			data = (data << 8) | (*(uchar *)cp);
-		}
-
-		if ((rc = write_word(info, wp, data)) != 0) {
-			return (rc);
-		}
-		wp += 4;
-	}
-
-	/*
-	 * handle word aligned part
-	 */
-	while (cnt >= 4) {
-		data = 0;
-		for (i=0; i<4; ++i) {
-			data = (data << 8) | *src++;
-		}
-		if ((rc = write_word(info, wp, data)) != 0) {
-			return (rc);
-		}
-		wp  += 4;
-		cnt -= 4;
-	}
-
-	if (cnt == 0) {
-		return (0);
-	}
-
-	/*
-	 * handle unaligned tail bytes
-	 */
-	data = 0;
-	for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
-		data = (data << 8) | *src++;
-		--cnt;
-	}
-	for (; i<4; ++i, ++cp) {
-		data = (data << 8) | (*(uchar *)cp);
-	}
-
-	return (write_word(info, wp, data));
-}
-
-/*-----------------------------------------------------------------------
- * Write a word to Flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-static int write_word (flash_info_t *info, ulong dest, ulong data)
-{
-	volatile FLASH_WORD_SIZE *addr2 = (FLASH_WORD_SIZE *)(info->start[0]);
-	volatile FLASH_WORD_SIZE *dest2 = (FLASH_WORD_SIZE *)dest;
-	volatile FLASH_WORD_SIZE *data2 = (FLASH_WORD_SIZE *)&data;
-	ulong start;
-	int flag;
-	int i;
-
-	/* Check if Flash is (sufficiently) erased */
-	if ((*((volatile ulong *)dest) & data) != data) {
-		printf("dest = %08lx, *dest = %08lx, data = %08lx\n",
-			dest, *(volatile ulong *)dest, data);
-		return 2;
-	}
-
-	for (i=0; i < 4/sizeof(FLASH_WORD_SIZE); i++) {
-		/* Disable interrupts which might cause a timeout here */
-		flag = disable_interrupts();
-
-		addr2[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
-		addr2[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
-		addr2[ADDR0] = (FLASH_WORD_SIZE)0x00A000A0;
-		dest2[i] = data2[i];
-
-		/* re-enable interrupts if necessary */
-		if (flag)
-			enable_interrupts();
-
-		/* data polling for D7 */
-		start = get_timer (0);
-		while ((dest2[i] & 0x00800080) != (data2[i] & 0x00800080)) {
-			if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
-				addr2[0] = (FLASH_WORD_SIZE)0x00F000F0;
-				return (1);
-			}
-		}
-	}
-
-	addr2[0] = (FLASH_WORD_SIZE)0x00F000F0;
-
-	return (0);
-}
-
-/*-----------------------------------------------------------------------
- */
diff --git a/board/exbitgen/init.S b/board/exbitgen/init.S
deleted file mode 100644
index 721aaac..0000000
--- a/board/exbitgen/init.S
+++ /dev/null
@@ -1,1011 +0,0 @@
-/*----------------------------------------------------------------------+
- *       This source code is dual-licensed.  You may use it under the terms of
- *       the GNU General Public License version 2, or under the license below.
- *
- *       This source code has been made available to you by IBM on an AS-IS
- *       basis.  Anyone receiving this source is licensed under IBM
- *       copyrights to use it in any way he or she deems fit, including
- *       copying it, modifying it, compiling it, and redistributing it either
- *       with or without modifications.  No license under IBM patents or
- *       patent applications is to be implied by the copyright license.
- *
- *       Any user of this software should understand that IBM cannot provide
- *       technical support for this software and will not be responsible for
- *       any consequences resulting from the use of this software.
- *
- *       Any person who transfers this source code or any derivative work
- *       must include the IBM copyright notice, this paragraph, and the
- *       preceding two paragraphs in the transferred software.
- *
- *       COPYRIGHT   I B M   CORPORATION 1995
- *       LICENSED MATERIAL  -  PROGRAM PROPERTY OF I B M
- *-----------------------------------------------------------------------
- */
-
-#include <config.h>
-#include <ppc4xx.h>
-#include "config.h"
-
-#define _LINUX_CONFIG_H 1	/* avoid reading Linux autoconf.h file	*/
-#define FPGA_BRDC       0xF0300004
-
-#include <ppc_asm.tmpl>
-#include <ppc_defs.h>
-
-#include <asm/cache.h>
-#include <asm/mmu.h>
-
-#include "exbitgen.h"
-
-/* IIC declarations (This is an extract from 405gp_i2c.h, which also contains some */
-/* c-code declarations and consequently can't be included here). */
-/* (Possibly to be solved somehow else). */
-/*--------------------------------------------------------------------- */
-#define	   I2C_REGISTERS_BASE_ADDRESS 0xEF600500
-#define    IIC_MDBUF	(I2C_REGISTERS_BASE_ADDRESS+IICMDBUF)
-#define    IIC_SDBUF	(I2C_REGISTERS_BASE_ADDRESS+IICSDBUF)
-#define    IIC_LMADR	(I2C_REGISTERS_BASE_ADDRESS+IICLMADR)
-#define    IIC_HMADR	(I2C_REGISTERS_BASE_ADDRESS+IICHMADR)
-#define    IIC_CNTL	(I2C_REGISTERS_BASE_ADDRESS+IICCNTL)
-#define    IIC_MDCNTL	(I2C_REGISTERS_BASE_ADDRESS+IICMDCNTL)
-#define    IIC_STS	(I2C_REGISTERS_BASE_ADDRESS+IICSTS)
-#define    IIC_EXTSTS	(I2C_REGISTERS_BASE_ADDRESS+IICEXTSTS)
-#define    IIC_LSADR	(I2C_REGISTERS_BASE_ADDRESS+IICLSADR)
-#define    IIC_HSADR	(I2C_REGISTERS_BASE_ADDRESS+IICHSADR)
-#define    IIC_CLKDIV	(I2C_REGISTERS_BASE_ADDRESS+IIC0_CLKDIV)
-#define    IIC_INTRMSK	(I2C_REGISTERS_BASE_ADDRESS+IICINTRMSK)
-#define    IIC_XFRCNT	(I2C_REGISTERS_BASE_ADDRESS+IICXFRCNT)
-#define    IIC_XTCNTLSS	(I2C_REGISTERS_BASE_ADDRESS+IICXTCNTLSS)
-#define    IIC_DIRECTCNTL (I2C_REGISTERS_BASE_ADDRESS+IICDIRECTCNTL)
-
-/* MDCNTL Register Bit definition */
-#define    IIC_MDCNTL_HSCL 0x01
-#define    IIC_MDCNTL_EUBS 0x02
-#define    IIC_MDCNTL_FMDB 0x40
-#define    IIC_MDCNTL_FSDB 0x80
-
-/* CNTL Register Bit definition */
-#define    IIC_CNTL_PT     0x01
-#define    IIC_CNTL_READ   0x02
-#define    IIC_CNTL_CHT    0x04
-
-/* STS Register Bit definition */
-#define    IIC_STS_PT	   0X01
-#define    IIC_STS_ERR	   0X04
-#define    IIC_STS_MDBS    0X20
-
-/* EXTSTS Register Bit definition */
-#define    IIC_EXTSTS_XFRA 0X01
-#define    IIC_EXTSTS_ICT  0X02
-#define    IIC_EXTSTS_LA   0X04
-
-/* LED codes used for inditing progress and errors during read of DIMM SPD.  */
-/*--------------------------------------------------------------------- */
-#define LED_SDRAM_CODE_1  0xef
-#define LED_SDRAM_CODE_2  0xee
-#define LED_SDRAM_CODE_3  0xed
-#define LED_SDRAM_CODE_4  0xec
-#define LED_SDRAM_CODE_5  0xeb
-#define LED_SDRAM_CODE_6  0xea
-#define LED_SDRAM_CODE_7  0xe9
-#define LED_SDRAM_CODE_8  0xe8
-#define LED_SDRAM_CODE_9  0xe7
-#define LED_SDRAM_CODE_10 0xe6
-#define LED_SDRAM_CODE_11 0xe5
-#define LED_SDRAM_CODE_12 0xe4
-#define LED_SDRAM_CODE_13 0xe3
-#define LED_SDRAM_CODE_14 0xe2
-#define LED_SDRAM_CODE_15 0xe1
-#define LED_SDRAM_CODE_16 0xe0
-
-
-#define TIMEBASE_10PS (1000000000 / CONFIG_SYS_CLK_FREQ) * 100
-
-#define FLASH_8bit_AP   0x9B015480
-#define FLASH_8bit_CR   0xFFF18000 /* 1MB(min), 8bit, R/W */
-
-#define FLASH_32bit_AP  0x9B015480
-#define FLASH_32bit_CR  0xFFE3C000 /* 2MB, 32bit, R/W */
-
-
-#define WDCR_EBC(reg,val) addi    r4,0,reg;\
-	mtdcr   EBC0_CFGADDR,r4;\
-	addis   r4,0,val@h;\
-	ori     r4,r4,val@l;\
-	mtdcr   EBC0_CFGDATA,r4
-
-/*---------------------------------------------------------------------
- * Function:     ext_bus_cntlr_init
- * Description:  Initializes the External Bus Controller for the external
- *		peripherals. IMPORTANT: For pass1 this code must run from
- *		cache since you can not reliably change a peripheral banks
- *		timing register (pbxap) while running code from that bank.
- *		For ex., since we are running from ROM on bank 0, we can NOT
- *		execute the code that modifies bank 0 timings from ROM, so
- *		we run it from cache.
- *	Bank 0 - Boot flash
- *	Bank 1-4 - application flash
- *	Bank 5 - CPLD
- *	Bank 6 - not used
- *	Bank 7 - Heathrow chip
- *---------------------------------------------------------------------
- */
-	.globl	ext_bus_cntlr_init
-ext_bus_cntlr_init:
-	mflr    r4                      /* save link register */
-	bl      ..getAddr
-..getAddr:
-	mflr    r3                      /* get address of ..getAddr */
-	mtlr    r4                      /* restore link register */
-	addi    r4,0,14                 /* set ctr to 10; used to prefetch */
-	mtctr   r4                      /* 10 cache lines to fit this function */
-					/* in cache (gives us 8x10=80 instrctns) */
-..ebcloop:
-	icbt    r0,r3                   /* prefetch cache line for addr in r3 */
-	addi    r3,r3,32		/* move to next cache line */
-	bdnz    ..ebcloop               /* continue for 10 cache lines */
-
-	mflr	r31			/* save link register */
-
-	/*-----------------------------------------------------------
-	 * Delay to ensure all accesses to ROM are complete before changing
-	 * bank 0 timings. 200usec should be enough.
-	 *   200,000,000 (cycles/sec) X .000200 (sec) = 0x9C40 cycles
-	 *-----------------------------------------------------------
-	 */
-
-	addis	r3,0,0x0
-	ori     r3,r3,0xA000          /* ensure 200usec have passed since reset */
-	mtctr   r3
-..spinlp:
-	bdnz    ..spinlp                /* spin loop */
-
-	/*---------------------------------------------------------------
-	 * Memory Bank 0 (Boot Flash) initialization
-	 *---------------------------------------------------------------
-	 */
-	WDCR_EBC(PB1AP, FLASH_32bit_AP)
-	WDCR_EBC(PB0CR, 0xffe38000)
-/*pnc	WDCR_EBC(PB0CR, FLASH_32bit_CR) */
-
-	/*---------------------------------------------------------------
-	 * Memory Bank 5 (CPLD) initialization
-	 *---------------------------------------------------------------
-	 */
-	WDCR_EBC(PB5AP, 0x01010040)
-/*jsa recommendation:		WDCR_EBC(PB5AP, 0x00010040) */
-	WDCR_EBC(PB5CR, 0x10038000)
-
-	/*--------------------------------------------------------------- */
-	/* Memory Bank 6 (not used) initialization */
-	/*--------------------------------------------------------------- */
-	WDCR_EBC(PB6CR, 0x00000000)
-
-	/* Read HW ID to determine whether old H2 board or new generic CPU board */
-	addis	r3, 0,  HW_ID_ADDR@h
-	ori	r3, r3, HW_ID_ADDR@l
-	lbz     r3,0x0000(r3)
-	cmpi	0, r3, 1          /* if (HW_ID==1) */
-	beq	setup_h2evalboard /* then jump */
-	cmpi	0, r3, 2          /* if (HW_ID==2) */
-	beq	setup_genieboard  /* then jump */
-	cmpi	0, r3, 3          /* if (HW_ID==3) */
-	beq	setup_genieboard  /* then jump */
-
-setup_genieboard:
-	/*--------------------------------------------------------------- */
-	/* Memory Bank 1 (Application Flash) initialization for generic CPU board */
-	/*--------------------------------------------------------------- */
-/*	WDCR_EBC(PB1AP, 0x7b015480)	/###* T.B.M. */
-/*	WDCR_EBC(PB1AP, 0x7F8FFE80)	/###* T.B.M. */
-	WDCR_EBC(PB1AP, 0x9b015480)	/* hlb-20020207: burst 8 bit 6 cycles  */
-
-/*	WDCR_EBC(PB1CR, 0x20098000)	/###* 16 MB */
-	WDCR_EBC(PB1CR, 0x200B8000)	/* 32 MB */
-
-	/*--------------------------------------------------------------- */
-	/* Memory Bank 4 (Onboard FPGA) initialization for generic CPU board */
-	/*--------------------------------------------------------------- */
-	WDCR_EBC(PB4AP, 0x01010000)	/*  */
-	WDCR_EBC(PB4CR, 0x1021c000)	/*  */
-
-	/*--------------------------------------------------------------- */
-	/* Memory Bank 7 (Heathrow chip on Reference board) initialization */
-	/*--------------------------------------------------------------- */
-	WDCR_EBC(PB7AP, 0x200ffe80)	/* No Ready, many wait states (let reflections die out) */
-	WDCR_EBC(PB7CR, 0X4001A000)
-
-	bl	setup_continue
-
-
-setup_h2evalboard:
-	/*--------------------------------------------------------------- */
-	/* Memory Bank 1 (Application Flash) initialization */
-	/*--------------------------------------------------------------- */
-	WDCR_EBC(PB1AP, 0x7b015480)	/* T.B.M. */
-/*3010	WDCR_EBC(PB1AP, 0x7F8FFE80)	/###* T.B.M. */
-	WDCR_EBC(PB1CR, 0x20058000)
-
-	/*--------------------------------------------------------------- */
-	/* Memory Bank 2 (Application Flash) initialization */
-	/*--------------------------------------------------------------- */
-	WDCR_EBC(PB2AP, 0x7b015480)	/* T.B.M. */
-/*3010	WDCR_EBC(PB2AP, 0x7F8FFE80)	/###* T.B.M. */
-	WDCR_EBC(PB2CR, 0x20458000)
-
-	/*--------------------------------------------------------------- */
-	/* Memory Bank 3 (Application Flash) initialization */
-	/*--------------------------------------------------------------- */
-	WDCR_EBC(PB3AP, 0x7b015480)	/* T.B.M. */
-/*3010	WDCR_EBC(PB3AP, 0x7F8FFE80)	/###* T.B.M. */
-	WDCR_EBC(PB3CR, 0x20858000)
-
-	/*--------------------------------------------------------------- */
-	/* Memory Bank 4 (Application Flash) initialization */
-	/*--------------------------------------------------------------- */
-	WDCR_EBC(PB4AP, 0x7b015480)	/* T.B.M. */
-/*3010	WDCR_EBC(PB4AP, 0x7F8FFE80)	/###* T.B.M. */
-	WDCR_EBC(PB4CR, 0x20C58000)
-
-	/*--------------------------------------------------------------- */
-	/* Memory Bank 7 (Heathrow chip) initialization */
-	/*--------------------------------------------------------------- */
-	WDCR_EBC(PB7AP, 0x02000280)	/* No Ready, 4 wait states */
-	WDCR_EBC(PB7CR, 0X4001A000)
-
-setup_continue:
-
-
-	mtlr    r31                     /* restore lr	 */
-	nop				/* pass2 DCR errata #8 */
-	blr
-
-/*--------------------------------------------------------------------- */
-/* Function:     sdram_init */
-/* Description:  Configures SDRAM memory banks. */
-/*--------------------------------------------------------------------- */
-	.globl  sdram_init
-
-sdram_init:
-#if CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE
-	blr
-#else
-	mflr	r31
-
-	/* output SDRAM code  on LEDs */
-	addi	r4, 0, LED_SDRAM_CODE_1
-	addis	r5, 0, 0x1000
-	ori	r5, r5, 0x0001
-	stb	r4,0(r5)
-	eieio
-
-	/* Read contents of spd */
-	/*--------------------- */
-	bl	read_spd
-
-	/*----------------------------------------------------------- */
-	/* */
-	/* */
-	/* Update SDRAM timing register */
-	/* */
-	/* */
-	/*----------------------------------------------------------- */
-
-	/* Read  PLL feedback divider and calculate clock period of local bus in */
-	/* granularity of 10 ps. Save clock period in r30 */
-	/*-------------------------------------------------------------- */
-	mfdcr	r4, CPC0_PLLMR
-	addi	r9, 0, 25
-	srw	r4, r4, r9
-	andi.	r4, r4, 0x07
-	addis	r5, 0,  TIMEBASE_10PS@h
-	ori	r5, r5, TIMEBASE_10PS@l
-	divwu	r30, r5, r4
-
-	/* Determine CASL */
-	/*--------------- */
-	bl	find_casl	/* Returns CASL in r3 */
-
-	/* Calc trp_clocks = (trp * 100 + (clk - 1)) / clk */
-	/* (trp read from byte 27 in granularity of 1 ns) */
-	/*------------------------------------------------ */
-	mulli	r16, r16, 100
-	add	r16, r16, r30
-	addi	r6, 0, 1
-	subf	r16, r6, r16
-	divwu	r16, r16, r30
-
-	/* Calc trcd_clocks = (trcd * 100 + (clk - 1) ) / clk */
-	/* (trcd read from byte 29 in granularity of 1 ns) */
-	/*--------------------------------------------------- */
-	mulli	r17, r17, 100
-	add	r17, r17, r30
-	addi	r6, 0, 1
-	subf	r17, r6, r17
-	divwu	r17, r17, r30
-
-	/* Calc tras_clocks = (tras * 100 + (clk - 1) ) / clk */
-	/* (tras read from byte 30 in granularity of 1 ns) */
-	/*--------------------------------------------------- */
-	mulli	r18, r18, 100
-	add	r18, r18, r30
-	addi	r6, 0, 1
-	subf	r18, r6, r18
-	divwu	r18, r18, r30
-
-	/* Calc trc_clocks = trp_clocks + tras_clocks */
-	/*------------------------------------------- */
-	add	r18, r18, r16
-
-	/* CASL value */
-	/*----------- */
-	addi	r9, 0, 23
-	slw	r4, r3, r9
-
-	/* PTA = trp_clocks - 1 */
-	/*--------------------- */
-	addi	r6, 0, 1
-	subf	r5, r6, r16
-	addi	r9, 0, 18
-	slw	r5, r5, r9
-	or	r4, r4, r5
-
-	/* CTP = trc_clocks - trp_clocks - trcd_clocks - 1 */
-	/*------------------------------------------------ */
-	addi	r5, r18, 0
-	subf	r5, r16, r5
-	subf	r5, r17, r5
-	addi	r6, 0, 1
-	subf	r5, r6, r5
-	addi	r9, 0, 16
-	slw	r5, r5, r9
-	or	r4, r4, r5
-
-	/* LDF = 1 */
-	/*-------- */
-	ori	r4, r4, 0x4000
-
-	/* RFTA = trc_clocks - 4 */
-	/*---------------------- */
-	addi	r6, 0, 4
-	subf	r5, r6, r18
-	addi	r9, 0, 2
-	slw	r5, r5, r9
-	or	r4, r4, r5
-
-	/* RCD = trcd_clocks - 1 */
-	/*---------------------- */
-	addi	r6, 0, 1
-	subf	r5, r6, r17
-	or	r4, r4, r5
-
-	/*----------------------------------------------------------- */
-	/* Set SDTR1  */
-	/*----------------------------------------------------------- */
-	addi    r5,0,SDRAM0_TR
-	mtdcr   SDRAM0_CFGADDR,r5
-	mtdcr   SDRAM0_CFGDATA,r4
-
-	/*----------------------------------------------------------- */
-	/* */
-	/* */
-	/* Update memory bank 0-3 configuration registers */
-	/* */
-	/* */
-	/*----------------------------------------------------------- */
-
-	/* Build contents of configuration register for bank 0 into r6 */
-	/*------------------------------------------------------------ */
-	bl	find_mode	/* returns addressing mode in r3 */
-	addi	r29, r3, 0	/* save mode temporarily in r29 */
-	bl	find_size_code	/* returns size code in r3 */
-	addi	r9, 0, 17	/* bit offset of size code in configuration register */
-	slw	r3, r3, r9	/* */
-	addi	r9, 0, 13	/* bit offset of addressing mode in configuration register  */
-	slw	r29, r29, r9	/*  */
-	or	r3, r29, r3	/* merge size code and addressing mode */
-	ori	r6, r3, CONFIG_SYS_SDRAM_BASE + 1 /* insert base address and enable bank */
-
-	/* Calculate banksize r15 = (density << 22) / 2 */
-	/*--------------------------------------------- */
-	addi	r9, 0, 21
-	slw	r15, r15, r9
-
-	/* Set SDRAM bank 0 register and adjust r6 for next bank */
-	/*------------------------------------------------------ */
-	addi    r7,0,SDRAM0_B0CR
-	mtdcr   SDRAM0_CFGADDR,r7
-	mtdcr   SDRAM0_CFGDATA,r6
-
-	add	r6, r6, r15	/* add bank size to base address for next bank */
-
-	/* If two rows/banks then set SDRAM bank 1 register and adjust r6 for next bank */
-	/*---------------------------------------------------------------------------- */
-	cmpi	0, r12, 2
-	bne	b1skip
-
-	addi    r7,0,SDRAM0_B1CR
-	mtdcr   SDRAM0_CFGADDR,r7
-	mtdcr   SDRAM0_CFGDATA,r6
-
-	add	r6, r6, r15	/* add bank size to base address for next bank */
-
-	/* Set SDRAM bank 2 register and adjust r6 for next bank */
-	/*------------------------------------------------------ */
-b1skip:	addi    r7,0,SDRAM0_B2CR
-	mtdcr   SDRAM0_CFGADDR,r7
-	mtdcr   SDRAM0_CFGDATA,r6
-
-	add	r6, r6, r15	/* add bank size to base address for next bank */
-
-	/* If two rows/banks then set SDRAM bank 3 register */
-	/*------------------------------------------------ */
-	cmpi	0, r12, 2
-	bne	b3skip
-
-	addi    r7,0,SDRAM0_B3CR
-	mtdcr   SDRAM0_CFGADDR,r7
-	mtdcr   SDRAM0_CFGDATA,r6
-b3skip:
-
-	/*----------------------------------------------------------- */
-	/* Set RTR */
-	/*----------------------------------------------------------- */
-	cmpi	0, r30, 1600
-	bge	rtr_1
-	addis   r7, 0, 0x05F0	/* RTR value for 100Mhz */
-	bl	rtr_2
-rtr_1:	addis	r7, 0, 0x03F8
-rtr_2:	addi    r4,0,SDRAM0_RTR
-	mtdcr   SDRAM0_CFGADDR,r4
-	mtdcr   SDRAM0_CFGDATA,r7
-
-	/*----------------------------------------------------------- */
-	/* Delay to ensure 200usec have elapsed since reset. Assume worst */
-	/* case that the core is running 200Mhz: */
-	/*   200,000,000 (cycles/sec) X .000200 (sec) = 0x9C40 cycles */
-	/*----------------------------------------------------------- */
-	addis   r3,0,0x0000
-	ori     r3,r3,0xA000          /* ensure 200usec have passed since reset */
-	mtctr   r3
-..spinlp2:
-	bdnz    ..spinlp2               /* spin loop */
-
-	/*----------------------------------------------------------- */
-	/* Set memory controller options reg, MCOPT1. */
-	/* Set DC_EN to '1' and BRD_PRF to '01' for 16 byte PLB Burst  */
-	/* read/prefetch. */
-	/*----------------------------------------------------------- */
-	addi    r4,0,SDRAM0_CFG
-	mtdcr   SDRAM0_CFGADDR,r4
-	addis   r4,0,0x80C0             /* set DC_EN=1 */
-	ori     r4,r4,0x0000
-	mtdcr   SDRAM0_CFGDATA,r4
-
-
-	/*----------------------------------------------------------- */
-	/* Delay to ensure 10msec have elapsed since reset. This is */
-	/* required for the MPC952 to stabalize. Assume worst */
-	/* case that the core is running 200Mhz: */
-	/*   200,000,000 (cycles/sec) X .010 (sec) = 0x1E8480 cycles */
-	/* This delay should occur before accessing SDRAM. */
-	/*----------------------------------------------------------- */
-	addis   r3,0,0x001E
-	ori     r3,r3,0x8480          /* ensure 10msec have passed since reset */
-	mtctr   r3
-..spinlp3:
-	bdnz    ..spinlp3                /* spin loop */
-
-	/* output SDRAM code  on LEDs */
-	addi	r4, 0, LED_SDRAM_CODE_16
-	addis	r5, 0, 0x1000
-	ori	r5, r5, 0x0001
-	stb	r4,0(r5)
-	eieio
-
-	mtlr    r31                     /* restore lr */
-	blr
-
-/*--------------------------------------------------------------------- */
-/* Function:    read_spd */
-/* Description: Reads contents of SPD and saves parameters to be used for */
-/*		configuration in dedicated registers (see code below). */
-/*---------------------------------------------------------------------	 */
-
-#define WRITE_I2C(reg,val) \
-	addi    r3,0,val;\
-	addis   r4, 0, 0xef60;\
-	ori     r4, r4, 0x0500 + reg;\
-	stb     r3, 0(r4);\
-	eieio
-
-#define READ_I2C(reg) \
-	addis   r3, 0, 0xef60;\
-	ori     r3, r3, 0x0500 + reg;\
-	lbz     r3, 0x0000(r3);\
-	eieio
-
-read_spd:
-
-	mflr	r5
-
-	/* Initialize i2c */
-	/*--------------- */
-	WRITE_I2C(IICLMADR, 0x00)	/* clear lo master address */
-	WRITE_I2C(IICHMADR, 0x00)	/* clear hi master address */
-	WRITE_I2C(IICLSADR, 0x00)	/* clear lo slave address */
-	WRITE_I2C(IICHSADR, 0x00)	/* clear hi slave address */
-	WRITE_I2C(IICSTS, 0x08)		/* update status register */
-	WRITE_I2C(IICEXTSTS, 0x8f)
-	WRITE_I2C(IIC0_CLKDIV, 0x05)
-	WRITE_I2C(IICINTRMSK, 0x00)	/* no interrupts */
-	WRITE_I2C(IICXFRCNT, 0x00)	/* clear transfer count */
-	WRITE_I2C(IICXTCNTLSS, 0xf0)	/* clear extended control & stat */
-	WRITE_I2C(IICMDCNTL, IIC_MDCNTL_FSDB | IIC_MDCNTL_FMDB)	/* mode control */
-	READ_I2C(IICMDCNTL)
-	ori	r3, r3, IIC_MDCNTL_EUBS | IIC_MDCNTL_HSCL
-	WRITE_I2C(IICMDCNTL, r3)	/* mode control */
-	WRITE_I2C(IICCNTL, 0x00)	/* clear control reg */
-
-	/* Wait until initialization completed */
-	/*------------------------------------ */
-	bl	wait_i2c_transfer_done
-
-	WRITE_I2C(IICHMADR, 0x00)	/* 7-bit addressing */
-	WRITE_I2C(IICLMADR, SDRAM_SPD_WRITE_ADDRESS)
-
-	/* Write 0 into buffer(start address) */
-	/*----------------------------------- */
-	WRITE_I2C(IICMDBUF, 0x00);
-
-	/* Wait a little */
-	/*-------------- */
-	addis   r3,0,0x0000
-	ori     r3,r3,0xA000
-	mtctr   r3
-in02:	bdnz    in02
-
-	/* Issue write command */
-	/*-------------------- */
-	WRITE_I2C(IICCNTL, IIC_CNTL_PT)
-	bl	wait_i2c_transfer_done
-
-	/* Read 128 bytes */
-	/*--------------- */
-	addi	r7, 0, 0	/* byte counter in r7 */
-	addi	r8, 0, 0	/* checksum in r8 */
-rdlp:
-	/* issue read command */
-	/*------------------- */
-	cmpi	0, r7, 127
-	blt	rd01
-	WRITE_I2C(IICCNTL, IIC_CNTL_READ | IIC_CNTL_PT)
-	bl	rd02
-rd01:	WRITE_I2C(IICCNTL, IIC_CNTL_READ | IIC_CNTL_CHT | IIC_CNTL_PT)
-rd02:	bl	wait_i2c_transfer_done
-
-	/* Fetch byte from buffer */
-	/*----------------------- */
-	READ_I2C(IICMDBUF)
-
-	/* Retrieve parameters that are going to be used during configuration. */
-	/* Save them in dedicated registers. */
-	/*------------------------------------------------------------ */
-	cmpi	0, r7, 3	/* Save byte 3 in r10 */
-	bne	rd10
-	addi	r10, r3, 0
-rd10:	cmpi	0, r7, 4	/* Save byte 4 in r11 */
-	bne	rd11
-	addi	r11, r3, 0
-rd11:	cmpi	0, r7, 5	/* Save byte 5 in r12 */
-	bne	rd12
-	addi	r12, r3, 0
-rd12:	cmpi	0, r7, 17	/* Save byte 17 in r13 */
-	bne	rd13
-	addi	r13, r3, 0
-rd13:	cmpi	0, r7, 18	/* Save byte 18 in r14 */
-	bne	rd14
-	addi	r14, r3, 0
-rd14:	cmpi	0, r7, 31	/* Save byte 31 in r15 */
-	bne	rd15
-	addi	r15, r3, 0
-rd15:	cmpi	0, r7, 27	/* Save byte 27 in r16 */
-	bne	rd16
-	addi	r16, r3, 0
-rd16:	cmpi	0, r7, 29	/* Save byte 29 in r17 */
-	bne	rd17
-	addi	r17, r3, 0
-rd17:	cmpi	0, r7, 30	/* Save byte 30 in r18 */
-	bne	rd18
-	addi	r18, r3, 0
-rd18:	cmpi	0, r7, 9	/* Save byte 9 in r19 */
-	bne	rd19
-	addi	r19, r3, 0
-rd19:	cmpi	0, r7, 23	/* Save byte 23 in r20 */
-	bne	rd20
-	addi	r20, r3, 0
-rd20:	cmpi	0, r7, 25	/* Save byte 25 in r21 */
-	bne	rd21
-	addi	r21, r3, 0
-rd21:
-
-	/* Calculate checksum of the first 63 bytes */
-	/*----------------------------------------- */
-	cmpi	0, r7, 63
-	bgt	rd31
-	beq	rd30
-	add	r8, r8, r3
-	bl	rd31
-
-	/* Verify checksum at byte 63 */
-	/*--------------------------- */
-rd30:	andi.	r8, r8, 0xff		/* use only 8 bits */
-	cmp	0, r8, r3
-	beq	rd31
-	addi	r4, 0, LED_SDRAM_CODE_8
-	addis	r5, 0, 0x1000
-	ori	r5, r5, 0x0001
-	stb	r4,0(r5)
-	eieio
-rderr:	bl	rderr
-
-rd31:
-
-	/* Increment byte counter and check whether all bytes have been read. */
-	/*------------------------------------------------------------------- */
-	addi	r7, r7, 1
-	cmpi	0, r7, 127
-	bgt	rd05
-	bl	rdlp
-rd05:
-	mtlr    r5                     /* restore lr */
-	blr
-
-wait_i2c_transfer_done:
-	mflr	r6
-wt01:	READ_I2C(IICSTS)
-	andi.	r4, r3, IIC_STS_PT
-	cmpi	0, r4, IIC_STS_PT
-	beq	wt01
-	mtlr    r6                     /* restore lr */
-	blr
-
-/*--------------------------------------------------------------------- */
-/* Function:    find_mode */
-/* Description: Determines addressing mode to be used dependent on   */
-/*		number of rows (r10 = byte 3 from SPD), number of columns (r11 = */
-/*		byte 4 from SPD) and number of banks (r13 = byte 17 from SPD). */
-/*		mode is returned in r3. */
-/* (It would be nicer having a table, pnc). */
-/*---------------------------------------------------------------------	 */
-find_mode:
-
-	mflr	r5
-
-	cmpi	0, r10, 11
-	bne	fm01
-	cmpi	0, r11, 9
-	bne	fm01
-	cmpi	0, r13, 2
-	bne	fm01
-	addi	r3, 0, 1
-	bl	fmfound
-
-fm01:	cmpi	0, r10, 11
-	bne	fm02
-	cmpi	0, r11, 10
-	bne	fm02
-	cmpi	0, r13, 2
-	bne	fm02
-	addi	r3, 0, 1
-	bl	fmfound
-
-fm02:	cmpi	0, r10, 12
-	bne	fm03
-	cmpi	0, r11, 9
-	bne	fm03
-	cmpi	0, r13, 4
-	bne	fm03
-	addi	r3, 0, 2
-	bl	fmfound
-
-fm03:	cmpi	0, r10, 12
-	bne	fm04
-	cmpi	0, r11, 10
-	bne	fm04
-	cmpi	0, r13, 4
-	bne	fm04
-	addi	r3, 0, 2
-	bl	fmfound
-
-fm04:	cmpi	0, r10, 13
-	bne	fm05
-	cmpi	0, r11, 9
-	bne	fm05
-	cmpi	0, r13, 4
-	bne	fm05
-	addi	r3, 0, 3
-	bl	fmfound
-
-fm05:	cmpi	0, r10, 13
-	bne	fm06
-	cmpi	0, r11, 10
-	bne	fm06
-	cmpi	0, r13, 4
-	bne	fm06
-	addi	r3, 0, 3
-	bl	fmfound
-
-fm06:	cmpi	0, r10, 13
-	bne	fm07
-	cmpi	0, r11, 11
-	bne	fm07
-	cmpi	0, r13, 4
-	bne	fm07
-	addi	r3, 0, 3
-	bl	fmfound
-
-fm07:	cmpi	0, r10, 12
-	bne	fm08
-	cmpi	0, r11, 8
-	bne	fm08
-	cmpi	0, r13, 2
-	bne	fm08
-	addi	r3, 0, 4
-	bl	fmfound
-
-fm08:	cmpi	0, r10, 12
-	bne	fm09
-	cmpi	0, r11, 8
-	bne	fm09
-	cmpi	0, r13, 4
-	bne	fm09
-	addi	r3, 0, 4
-	bl	fmfound
-
-fm09:	cmpi	0, r10, 11
-	bne	fm10
-	cmpi	0, r11, 8
-	bne	fm10
-	cmpi	0, r13, 2
-	bne	fm10
-	addi	r3, 0, 5
-	bl	fmfound
-
-fm10:	cmpi	0, r10, 11
-	bne	fm11
-	cmpi	0, r11, 8
-	bne	fm11
-	cmpi	0, r13, 4
-	bne	fm11
-	addi	r3, 0, 5
-	bl	fmfound
-
-fm11:	cmpi	0, r10, 13
-	bne	fm12
-	cmpi	0, r11, 8
-	bne	fm12
-	cmpi	0, r13, 2
-	bne	fm12
-	addi	r3, 0, 6
-	bl	fmfound
-
-fm12:	cmpi	0, r10, 13
-	bne	fm13
-	cmpi	0, r11, 8
-	bne	fm13
-	cmpi	0, r13, 4
-	bne	fm13
-	addi	r3, 0, 6
-	bl	fmfound
-
-fm13:	cmpi	0, r10, 13
-	bne	fm14
-	cmpi	0, r11, 9
-	bne	fm14
-	cmpi	0, r13, 2
-	bne	fm14
-	addi	r3, 0, 7
-	bl	fmfound
-
-fm14:	cmpi	0, r10, 13
-	bne	fm15
-	cmpi	0, r11, 10
-	bne	fm15
-	cmpi	0, r13, 2
-	bne	fm15
-	addi	r3, 0, 7
-	bl	fmfound
-
-fm15:
-	/* not found, error code to be issued on LEDs */
-	addi	r7, 0, LED_SDRAM_CODE_2
-	addis	r6, 0, 0x1000
-	ori	r6, r6, 0x0001
-	stb	r7,0(r6)
-	eieio
-fmerr:	bl	fmerr
-
-fmfound:addi	r6, 0, 1
-	subf	r3, r6, r3
-
-	mtlr    r5                     /* restore lr */
-	blr
-
-/*--------------------------------------------------------------------- */
-/* Function:    find_size_code */
-/* Description: Determines size code to be used in configuring SDRAM controller */
-/*		dependent on density (r15 = byte 31 from SPD) */
-/*--------------------------------------------------------------------- */
-find_size_code:
-
-	mflr	r5
-
-	addi	r3, r15, 0	/* density */
-	addi	r7, 0, 0
-fs01:	andi.	r6, r3, 0x01
-	cmpi	0, r6, 1
-	beq	fs04
-
-	addi	r7, r7, 1
-	cmpi	0, r7, 7
-	bge	fs02
-	addi	r9, 0, 1
-	srw	r3, r3, r9
-	bl	fs01
-
-	/* not found, error code to be issued on LEDs */
-fs02:	addi	r4, 0, LED_SDRAM_CODE_3
-	addis	r8, 0, 0x1000
-	ori	r8, r8, 0x0001
-	stb	r4,0(r8)
-	eieio
-fs03:	bl	fs03
-
-fs04:	addi	r3, r7, 0
-	cmpi	0, r3, 0
-	beq	fs05
-	addi	r6, 0, 1
-	subf	r3, r6, r3
-fs05:
-	mtlr    r5                     /* restore lr */
-	blr
-
-/*--------------------------------------------------------------------- */
-/* Function:    find_casl */
-/* Description: Determines CAS latency */
-/*--------------------------------------------------------------------- */
-find_casl:
-
-	mflr	r5
-
-	andi.	r14, r14, 0x7f	/* r14 holds supported CAS latencies */
-	addi	r3, 0, 0xff	/* preset determined CASL */
-	addi	r4, 0, 6	/* Start at bit 6 of supported CAS latencies */
-	addi	r2, 0, 0	/* Start finding highest CAS latency */
-
-fc01:	srw	r6, r14, r4	/*  */
-	andi.	r6, r6, 0x01	/*  */
-	cmpi	0, r6, 1	/* Check bit for current latency */
-	bne	fc06		/* If not supported, go to next */
-
-	cmpi	0, r2, 2	/* Check if third-highest latency */
-	bge	fc04		/* If so, go calculate with another format */
-
-	cmpi	0, r2, 0	/* Check if highest latency */
-	bgt	fc02		/* */
-	addi	r7, r19, 0	/* SDRAM cycle time for highest CAS latenty */
-
-	bl	fc03
-fc02:
-	addi	r7, r20, 0	/* SDRAM cycle time for next-highest CAS latenty */
-fc03:
-	addi	r8, r7, 0
-	addi	r9, 0, 4
-	srw	r7, r7, r9
-	andi.	r7, r7, 0x0f
-	mulli	r7, r7, 100
-	andi.	r8, r8, 0x0f
-	mulli	r8, r8, 10
-	add	r7, r7, r8
-	cmp	0, r7, r30
-	bgt	fc05
-	addi	r3, r2, 0
-	bl	fc05
-fc04:
-	addi	r7, r21, 0	/* SDRAM cycle time for third-highest CAS latenty */
-	addi	r8, r7, 0
-	addi	r9, 0, 2
-	srw	r7, r7, r9
-	andi.	r7, r7, 0x3f
-	mulli	r7, r7, 100
-	andi.	r8, r8, 0x03
-	mulli	r8, r8, 25
-	add	r7, r7, r8
-
-	cmp	0, r7, r30
-	bgt	fc05
-	addi	r3, r2, 0
-
-fc05:	addi	r2, r2, 1	/* next latency */
-	cmpi	0, r2, 3
-	bge	fc07
-fc06:	addi	r6, 0, 1
-	subf	r4, r6, r4
-	cmpi	0, r4, 0
-	bne	fc01
-
-fc07:
-
-	mtlr    r5		/* restore lr */
-	blr
-#endif
-
-
-/*  Peripheral Bank 1 Access Parameters */
-/*     0	BME = 1	; burstmode enabled */
-/*    " 1:8"	TWT=00110110	;Transfer wait (details below) */
-/*     1:5	FWT=00110	; first wait = 6 cycles */
-/*     6:8	BWT=110	; burst wait = 6 cycles */
-/*     9:11	000	; reserved */
-/*     12:13	CSN=00	; chip select on timing = 0 */
-/*     14:15	OEN=01	; output enable  */
-/*     16:17	WBN=01	; write byte enable on timing 1 cycle */
-/*     18:19	WBF=01	; write byte enable off timing 1 cycle */
-/*     20:22	TH=010	; transfer hold = 2 cycles */
-/*     23	RE=0	; ready enable = disabled */
-/*     24	SOR=1	; sample on ready = same PerClk */
-/*     25	BEM=0	; byte enable mode = only for write cycles */
-/*     26	PEN=0	; parity enable = disable */
-/*     27:31	00000	;reserved */
-/* */
-/* 1 + 00110 + 110 + 000 + 00 + 01 + 01 + 01 + 010 + 0 + 1 + 0 + 0 + 00000 = 0x9b015480 */
-/* */
-/* */
-/*	Code for BDI probe: */
-/* */
-/* WDCR    18      0x00000011      ;Select PB1AP */
-/* WDCR    19      0x1b015480      ;PB1AP: Flash */
-/* */
-/* Peripheral Bank 0 Access Parameters */
-/* 0:11	BAS=0x200	; base address select = 0x200 * 0x100000 (1MB) =  */
-/* 12:14	BS=100	; bank size =  16MB (100) / 32MB (101) */
-/* 15:16	BU=11	; bank usage = read/write */
-/* 17:18	BW=00	; bus width = 8-bit */
-/* 19:31		; reserved */
-/* */
-/* 0x200 + 100 + 11 + 00 + 0 0000 0000 0000 = 0x20098000 */
-/* WDCR    18      0x00000001      ;Select PB1CR */
-/* WDCR    19      0x20098000      ;PB1CR: 1MB at 0x00100000, r/w, 8bit */
-
-/* For CPLD */
-/* 0 + 00000 + 010 + 000 + 00 + 01 + 00 + 00 + 000 + 0 + 0 + 1 + 0 + 00000 */
-/*	WDCR_EBC(PB5AP, 0x01010040) */
-/*jsa recommendation:		WDCR_EBC(PB5AP, 0x00010040) */
-/*	WDCR_EBC(PB5CR, 0X10018000) */
-/* Access parms */
-/*   100   3      8          0    0    0 */
-/* 0x100 + 001 + 11 + 00 + 0 0000 0000 0000 = 0x10038000 */
-/* Address :	0x10000000 */
-/* Size:	2 MB */
-/* Usage:	read/write */
-/* Width:	32 bit */
-
-/* For Genie onboard fpga 32 bit interface */
-/* 0      1      0         1         0         0         0            0 */
-/* 0 + 00000 + 010 + 000 + 00 + 01 + 00 + 00 + 000 + 0 + 0 + 0 + 0 + 00000 */
-/* 0x01010000 */
-/* Access parms */
-/*   102   1      c          0    0    0 */
-/* 0x102 + 000 + 11 + 10 + 0 0000 0000 0000 = 0x1021c000 */
-/* Address :	0x10200000 */
-/* Size:	2 MB */
-/* Usage:	read/write */
-/* Width:	32 bit */
-
-/* Walnut fpga PB7AP */
-/* 0      1      8         1         5         2         8            0 */
-/* 0 + 00000 + 011 + 000 + 00 + 01 + 01 + 01 + 001 + 0 + 1 + 0 + 0 + 00000 */
-/* Walnut fpga PB7CR */
-/* 0xF0318000 */
-/*  */
diff --git a/board/freescale/mpc8569mds/config.mk b/board/freescale/mpc8569mds/config.mk
index 962f79b..7de0f7c 100644
--- a/board/freescale/mpc8569mds/config.mk
+++ b/board/freescale/mpc8569mds/config.mk
@@ -23,4 +23,13 @@
 #
 # mpc8569mds board
 #
+ifndef NAND_SPL
+ifeq ($(CONFIG_MK_NAND), y)
+TEXT_BASE = $(CONFIG_RAMBOOT_TEXT_BASE)
+LDSCRIPT := $(TOPDIR)/cpu/$(CPU)/u-boot-nand.lds
+endif
+endif
+
+ifndef TEXT_BASE
 TEXT_BASE = 0xfff80000
+endif
diff --git a/board/freescale/mpc8569mds/tlb.c b/board/freescale/mpc8569mds/tlb.c
index 3b8ee05..73dcc3e 100644
--- a/board/freescale/mpc8569mds/tlb.c
+++ b/board/freescale/mpc8569mds/tlb.c
@@ -90,6 +90,17 @@
 	SET_TLB_ENTRY(1, CONFIG_SYS_CCSRBAR, CONFIG_SYS_CCSRBAR_PHYS,
 		      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
 		      0, 4, BOOKE_PAGESZ_64M, 1),
+
+#if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
+	/* *I*G - L2SRAM */
+	SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR, CONFIG_SYS_INIT_L2_ADDR_PHYS,
+			MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
+			0, 5, BOOKE_PAGESZ_256K, 1),
+	SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR + 0x40000,
+			CONFIG_SYS_INIT_L2_ADDR_PHYS + 0x40000,
+			MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
+			0, 6, BOOKE_PAGESZ_256K, 1),
+#endif
 };
 
 int num_tlb_entries = ARRAY_SIZE(tlb_table);
diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
index 3e5fb44..b34c4d0 100644
--- a/common/cmd_ximg.c
+++ b/common/cmd_ximg.c
@@ -225,20 +225,25 @@
 			break;
 #if defined(CONFIG_BZIP2)
 		case IH_COMP_BZIP2:
-			printf ("   Uncompressing part %d ... ", part);
-			/*
-			 * If we've got less than 4 MB of malloc() space,
-			 * use slower decompression algorithm which requires
-			 * at most 2300 KB of memory.
-			 */
-			i = BZ2_bzBuffToBuffDecompress
-				((char*)ntohl(hdr->ih_load),
-				 &unc_len, (char *)data, len,
-				 CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0);
-			if (i != BZ_OK) {
-				printf ("BUNZIP2 ERROR %d - "
-					"image not loaded\n", i);
-				return 1;
+			{
+				int i;
+
+				printf ("   Uncompressing part %d ... ", part);
+				/*
+                                 * If we've got less than 4 MB of malloc()
+				 * space, use slower decompression algorithm
+				 * which requires at most 2300 KB of memory.
+				 */
+				i = BZ2_bzBuffToBuffDecompress(
+					(char*)ntohl(hdr->ih_load),
+					&unc_len, (char *)data, len,
+					CONFIG_SYS_MALLOC_LEN < (4096 * 1024),
+					0);
+				if (i != BZ_OK) {
+					printf ("BUNZIP2 ERROR %d - "
+						"image not loaded\n", i);
+					return 1;
+				}
 			}
 			break;
 #endif /* CONFIG_BZIP2 */
diff --git a/common/env_nand.c b/common/env_nand.c
index ca631af..a15a950 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -298,6 +298,13 @@
 	tmp_env1 = (env_t *) malloc(CONFIG_ENV_SIZE);
 	tmp_env2 = (env_t *) malloc(CONFIG_ENV_SIZE);
 
+	if ((tmp_env1 == NULL) || (tmp_env2 == NULL)) {
+		puts("Can't allocate buffers for environment\n");
+		free (tmp_env1);
+		free (tmp_env2);
+		return use_default();
+	}
+
 	if (readenv(CONFIG_ENV_OFFSET, (u_char *) tmp_env1))
 		puts("No Valid Environment Area Found\n");
 	if (readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2))
diff --git a/common/lcd.c b/common/lcd.c
index 4e31618..db799db 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -456,22 +456,14 @@
 
 static void lcd_setfgcolor (int color)
 {
-#ifdef CONFIG_ATMEL_LCD
 	lcd_color_fg = color;
-#else
-	lcd_color_fg = color & 0x0F;
-#endif
 }
 
 /*----------------------------------------------------------------------*/
 
 static void lcd_setbgcolor (int color)
 {
-#ifdef CONFIG_ATMEL_LCD
 	lcd_color_bg = color;
-#else
-	lcd_color_bg = color & 0x0F;
-#endif
 }
 
 /*----------------------------------------------------------------------*/
diff --git a/cpu/arm926ejs/start.S b/cpu/arm926ejs/start.S
index 4421b6a..3b81151 100644
--- a/cpu/arm926ejs/start.S
+++ b/cpu/arm926ejs/start.S
@@ -53,6 +53,27 @@
 .globl _start
 _start:
 	b	reset
+#ifdef CONFIG_PRELOADER
+/* No exception handlers in preloader */
+	ldr	pc, _hang
+	ldr	pc, _hang
+	ldr	pc, _hang
+	ldr	pc, _hang
+	ldr	pc, _hang
+	ldr	pc, _hang
+	ldr	pc, _hang
+
+_hang:
+	.word	do_hang
+/* pad to 64 byte boundary */
+	.word	0x12345678
+	.word	0x12345678
+	.word	0x12345678
+	.word	0x12345678
+	.word	0x12345678
+	.word	0x12345678
+	.word	0x12345678
+#else
 	ldr	pc, _undefined_instruction
 	ldr	pc, _software_interrupt
 	ldr	pc, _prefetch_abort
@@ -76,6 +97,7 @@
 _fiq:
 	.word fiq
 
+#endif	/* CONFIG_PRELOADER */
 	.balignl 16,0xdeadbeef
 
 
@@ -150,7 +172,6 @@
 	ldr	r1, _TEXT_BASE		/* test if we run from flash or RAM */
 	cmp     r0, r1                  /* don't reloc during debug         */
 	beq     stack_setup
-
 	ldr	r2, _armboot_start
 	ldr	r3, _bss_start
 	sub	r2, r3, r2		/* r2 <- size of armboot            */
@@ -166,11 +187,14 @@
 	/* Set up the stack						    */
 stack_setup:
 	ldr	r0, _TEXT_BASE		/* upper 128 KiB: relocated uboot   */
+	sub	sp, r0, #128		/* leave 32 words for abort-stack   */
+#ifndef CONFIG_PRELOADER
 	sub	r0, r0, #CONFIG_SYS_MALLOC_LEN	/* malloc area                      */
 	sub	r0, r0, #CONFIG_SYS_GBL_DATA_SIZE /* bdinfo                        */
 #ifdef CONFIG_USE_IRQ
 	sub	r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
+#endif /* CONFIG_PRELOADER */
 	sub	sp, r0, #12		/* leave 3 words for abort-stack    */
 	bic	sp, r0, #7		/* 8-byte align stack for ABI compliance */
 
@@ -179,6 +203,7 @@
 	ldr	r1, _bss_end		/* stop here                        */
 	mov	r2, #0x00000000		/* clear                            */
 
+#ifndef CONFIG_PRELOADER
 clbss_l:str	r2, [r0]		/* clear loop...                    */
 	add	r0, r0, #4
 	cmp	r0, r1
@@ -186,11 +211,16 @@
 
 	bl coloured_LED_init
 	bl red_LED_on
+#endif /* CONFIG_PRELOADER */
 
 	ldr	pc, _start_armboot
 
 _start_armboot:
+#ifdef CONFIG_NAND_SPL
+	.word nand_boot
+#else
 	.word start_armboot
+#endif /* CONFIG_NAND_SPL */
 
 
 /*
@@ -231,6 +261,7 @@
 	mov	pc, lr		/* back to my caller */
 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
 
+#ifndef CONFIG_PRELOADER
 /*
  *************************************************************************
  *
@@ -332,10 +363,18 @@
 	.macro get_fiq_stack			@ setup FIQ stack
 	ldr	sp, FIQ_STACK_START
 	.endm
+#endif	/* CONFIG_PRELOADER */
 
 /*
  * exception handlers
  */
+#ifdef CONFIG_PRELOADER
+	.align	5
+do_hang:
+	ldr	sp, _TEXT_BASE			/* switch to abort stack */
+1:
+	bl	1b				/* hang and never return */
+#else	/* !CONFIG_PRELOADER */
 	.align  5
 undefined_instruction:
 	get_bad_stack
@@ -398,3 +437,4 @@
 	bl	do_fiq
 
 #endif
+#endif	/* CONFIG_PRELOADER */
diff --git a/cpu/mpc5xxx/cpu_init.c b/cpu/mpc5xxx/cpu_init.c
index b151464..560c9b3 100644
--- a/cpu/mpc5xxx/cpu_init.c
+++ b/cpu/mpc5xxx/cpu_init.c
@@ -40,15 +40,20 @@
 		(struct mpc5xxx_mmap_ctl *) CONFIG_SYS_MBAR;
 	volatile struct mpc5xxx_lpb *lpb =
 		(struct mpc5xxx_lpb *) MPC5XXX_LPB;
-	volatile struct mpc5xxx_cdm *cdm =
-		(struct mpc5xxx_cdm *) MPC5XXX_CDM;
 	volatile struct mpc5xxx_gpio *gpio =
 		(struct mpc5xxx_gpio *) MPC5XXX_GPIO;
 	volatile struct mpc5xxx_xlb *xlb =
 		(struct mpc5xxx_xlb *) MPC5XXX_XLBARB;
+#if defined(CONFIG_SYS_IPBCLK_EQUALS_XLBCLK)
+	volatile struct mpc5xxx_cdm *cdm =
+		(struct mpc5xxx_cdm *) MPC5XXX_CDM;
+#endif	/* CONFIG_SYS_IPBCLK_EQUALS_XLBCLK */
+#if defined(CONFIG_WATCHDOG)
 	volatile struct mpc5xxx_gpt *gpt0 =
 		(struct mpc5xxx_gpt *) MPC5XXX_GPT;
+#endif /* CONFIG_WATCHDOG */
 	unsigned long addecr = (1 << 25); /* Boot_CS */
+
 #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_MGT5100)
 	addecr |= (1 << 22); /* SDRAM enable */
 #endif
@@ -184,11 +189,11 @@
 
 # if defined(CONFIG_SYS_IPBCLK_EQUALS_XLBCLK)
 	/* Motorola reports IPB should better run at 133 MHz. */
-#if defined(CONFIG_MGT5100)
+#  if defined(CONFIG_MGT5100)
 	setbits_be32(&mm->addecr, 1);
-#elif defined(CONFIG_MPC5200)
+#  elif defined(CONFIG_MPC5200)
 	setbits_be32(&mm->ipbi_ws_ctrl, 1);
-#endif
+#  endif
 	/* pci_clk_sel = 0x02, ipb_clk_sel = 0x00; */
 	addecr = in_be32(&cdm->cfg);
 	addecr &= ~0x103;
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index b2b612e..9633858 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -22,27 +22,65 @@
 #include <nand.h>
 #include <linux/err.h>
 #include <asm/io.h>
-#ifdef CONFIG_MX27
+#if defined(CONFIG_MX27) || defined(CONFIG_MX25) 
 #include <asm/arch/imx-regs.h>
 #endif
 
 #define DRIVER_NAME "mxc_nand"
 
+/*
+ * TODO: Use same register defs here as nand_spl mxc nand driver.
+ */
+/*
+ * Register map and bit definitions for the Freescale NAND Flash Controller
+ * present in various i.MX devices.
+ *
+ * MX31 and MX27 have version 1 which has
+ * 	4 512 byte main buffers and
+ * 	4 16 byte spare buffers
+ * 	to support up to 2K byte pagesize nand.
+ * 	Reading or writing a 2K page requires 4 FDI/FDO cycles.
+ *
+ * MX25 has version 1.1 which has
+ * 	8 512 byte main buffers and
+ * 	8 64 byte spare buffers
+ * 	to support up to 4K byte pagesize nand.
+ * 	Reading or writing a 2K or 4K page requires only 1 FDI/FDO cycle.
+ *      Also some of registers are moved and/or changed meaning as seen below.
+ */
+#if defined(CONFIG_MX31) || defined(CONFIG_MX27)
+#define MXC_NFC_V1
+#elif defined(CONFIG_MX25)
+#define MXC_NFC_V1_1
+#else
+#warning "MXC NFC version not defined"
+#endif
+
+#if defined(MXC_NFC_V1)
+#define NAND_MXC_NR_BUFS		4
+#define NAND_MXC_SPARE_BUF_SIZE		16
+#define NAND_MXC_REG_OFFSET		0xe00
+#define is_mxc_nfc_11() 		0
+#elif defined(MXC_NFC_V1_1)
+#define NAND_MXC_NR_BUFS		8
+#define NAND_MXC_SPARE_BUF_SIZE		64
+#define NAND_MXC_REG_OFFSET		0x1e00
+#define is_mxc_nfc_11() 		1
+#else
+#error "define CONFIG_NAND_MXC_VXXX to use mtd mxc nand driver"
+#endif
 struct nfc_regs {
-/* NFC RAM BUFFER Main area 0 */
-	uint8_t main_area0[0x200];
-	uint8_t main_area1[0x200];
-	uint8_t main_area2[0x200];
-	uint8_t main_area3[0x200];
-/* SPARE BUFFER Spare area 0 */
-	uint8_t spare_area0[0x10];
-	uint8_t spare_area1[0x10];
-	uint8_t spare_area2[0x10];
-	uint8_t spare_area3[0x10];
-	uint8_t pad[0x5c0];
-/* NFC registers */
+	uint8_t main_area[NAND_MXC_NR_BUFS][0x200];
+	uint8_t spare_area[NAND_MXC_NR_BUFS][NAND_MXC_SPARE_BUF_SIZE];
+	/*
+	 * reserved size is offset of nfc registers
+	 * minus total main and spare sizes
+	 */
+	uint8_t reserved1[NAND_MXC_REG_OFFSET
+		- NAND_MXC_NR_BUFS * (512 + NAND_MXC_SPARE_BUF_SIZE)];
+#if defined(MXC_NFC_V1)
 	uint16_t nfc_buf_size;
-	uint16_t reserved;
+	uint16_t reserved2;
 	uint16_t nfc_buf_addr;
 	uint16_t nfc_flash_addr;
 	uint16_t nfc_flash_cmd;
@@ -56,6 +94,30 @@
 	uint16_t nfc_nf_wrprst;
 	uint16_t nfc_config1;
 	uint16_t nfc_config2;
+#elif defined(MXC_NFC_V1_1)
+	uint16_t reserved2[2];
+	uint16_t nfc_buf_addr;
+	uint16_t nfc_flash_addr;
+	uint16_t nfc_flash_cmd;
+	uint16_t nfc_config;
+	uint16_t nfc_ecc_status_result;
+	uint16_t nfc_ecc_status_result2;
+	uint16_t nfc_spare_area_size;
+	uint16_t nfc_wrprot;
+	uint16_t reserved3[2];
+	uint16_t nfc_nf_wrprst;
+	uint16_t nfc_config1;
+	uint16_t nfc_config2;
+	uint16_t reserved4;
+	uint16_t nfc_unlockstart_blkaddr;
+	uint16_t nfc_unlockend_blkaddr;
+	uint16_t nfc_unlockstart_blkaddr1;
+	uint16_t nfc_unlockend_blkaddr1;
+	uint16_t nfc_unlockstart_blkaddr2;
+	uint16_t nfc_unlockend_blkaddr2;
+	uint16_t nfc_unlockstart_blkaddr3;
+	uint16_t nfc_unlockend_blkaddr3;
+#endif
 };
 
 /*
@@ -100,6 +162,11 @@
  */
 #define NFC_INT            0x8000
 
+#ifdef MXC_NFC_V1_1
+#define NFC_4_8N_ECC	(1 << 0)
+#else
+#define NFC_4_8N_ECC	0
+#endif
 #define NFC_SP_EN           (1 << 2)
 #define NFC_ECC_EN          (1 << 3)
 #define NFC_BIG             (1 << 5)
@@ -119,6 +186,7 @@
 	int			pagesize_2k;
 	int			clk_act;
 	uint16_t		col_addr;
+	unsigned int		page_addr;
 };
 
 static struct mxc_nand_host mxc_host;
@@ -135,26 +203,45 @@
 #define SPARE_SINGLEBIT_ERROR 0x1
 
 /* OOB placement block for use with hardware ecc generation */
-#ifdef CONFIG_MXC_NAND_HWECC
+#if defined(MXC_NFC_V1)
+#ifndef CONFIG_SYS_NAND_LARGEPAGE
 static struct nand_ecclayout nand_hw_eccoob = {
 	.eccbytes = 5,
 	.eccpos = {6, 7, 8, 9, 10},
-	.oobfree = {{0, 5}, {11, 5}, }
+	.oobfree = { {0, 5}, {11, 5}, }
 };
 #else
-static struct nand_ecclayout nand_soft_eccoob = {
-	.eccbytes = 6,
-	.eccpos = {6, 7, 8, 9, 10, 11},
-	.oobfree = {{0, 5}, {12, 4}, }
+static struct nand_ecclayout nand_hw_eccoob2k = {
+	.eccbytes = 20,
+	.eccpos = {
+		6, 7, 8, 9, 10,
+		22, 23, 24, 25, 26,
+		38, 39, 40, 41, 42,
+		54, 55, 56, 57, 58,
+	},
+	.oobfree = { {2, 4}, {11, 11}, {27, 11}, {43, 11}, {59, 5} },
 };
 #endif
-
-static struct nand_ecclayout nand_hw_eccoob_largepage = {
-	.eccbytes = 20,
-	.eccpos = {6, 7, 8, 9, 10, 22, 23, 24, 25, 26,
-		   38, 39, 40, 41, 42, 54, 55, 56, 57, 58},
-	.oobfree = {{2, 4}, {11, 10}, {27, 10}, {43, 10}, {59, 5}, }
+#elif defined(MXC_NFC_V1_1)
+#ifndef CONFIG_SYS_NAND_LARGEPAGE
+static struct nand_ecclayout nand_hw_eccoob = {
+	.eccbytes = 9,
+	.eccpos = {7, 8, 9, 10, 11, 12, 13, 14, 15},
+	.oobfree = { {2, 5} }
+};
+#else
+static struct nand_ecclayout nand_hw_eccoob2k = {
+	.eccbytes = 36,
+	.eccpos = {
+		7, 8, 9, 10, 11, 12, 13, 14, 15,
+		23, 24, 25, 26, 27, 28, 29, 30, 31,
+		39, 40, 41, 42, 43, 44, 45, 46, 47,
+		55, 56, 57, 58, 59, 60, 61, 62, 63,
+	},
+	.oobfree = { {2, 5}, {16, 7}, {32, 7}, {48, 7} },
 };
+#endif
+#endif
 
 #ifdef CONFIG_MX27
 static int is_16bit_nand(void)
@@ -178,6 +265,17 @@
 	else
 		return 0;
 }
+#elif defined(CONFIG_MX25)
+static int is_16bit_nand(void)
+{
+	struct ccm_regs *ccm =
+		(struct ccm_regs *)IMX_CCM_BASE;
+
+	if (readl(&ccm->rcsr) & CCM_RCSR_NF_16BIT_SEL)
+		return 1;
+	else
+		return 0;
+}
 #else
 #warning "8/16 bit NAND autodetection not supported"
 static int is_16bit_nand(void)
@@ -258,7 +356,24 @@
 static void send_prog_page(struct mxc_nand_host *host, uint8_t buf_id,
 			int spare_only)
 {
-	MTDDEBUG(MTD_DEBUG_LEVEL3, "send_prog_page (%d)\n", spare_only);
+	if (spare_only)
+		MTDDEBUG(MTD_DEBUG_LEVEL1, "send_prog_page (%d)\n", spare_only);
+
+	if (is_mxc_nfc_11()) {
+		int i;
+		/*
+		 *  The controller copies the 64 bytes of spare data from
+		 *  the first 16 bytes of each of the 4 64 byte spare buffers.
+		 *  Copy the contiguous data starting in spare_area[0] to
+		 *  the four spare area buffers.
+		 */
+		for (i = 1; i < 4; i++) {
+			void __iomem *src = &host->regs->spare_area[0][i * 16];
+			void __iomem *dst = &host->regs->spare_area[i][0];
+
+			mxc_nand_memcpy32(dst, src, 16);
+		}
+	}
 
 	writew(buf_id, &host->regs->nfc_buf_addr);
 
@@ -303,6 +418,22 @@
 
 	/* Wait for operation to complete */
 	wait_op_done(host, TROP_US_DELAY, spare_only);
+
+	if (is_mxc_nfc_11()) {
+		int i;
+
+		/*
+		 *  The controller copies the 64 bytes of spare data to
+		 *  the first 16 bytes of each of the 4 spare buffers.
+		 *  Make the data contiguous starting in spare_area[0].
+		 */
+		for (i = 1; i < 4; i++) {
+			void __iomem *src = &host->regs->spare_area[i][0];
+			void __iomem *dst = &host->regs->spare_area[0][i * 16];
+
+			mxc_nand_memcpy32(dst, src, 16);
+		}
+	}
 }
 
 /* Request the NANDFC to perform a read of the NAND device ID. */
@@ -330,7 +461,7 @@
  */
 static uint16_t get_dev_status(struct mxc_nand_host *host)
 {
-	void __iomem *main_buf = host->regs->main_area1;
+	void __iomem *main_buf = host->regs->main_area[1];
 	uint32_t store;
 	uint16_t ret, tmp;
 	/* Issue status request to NAND device */
@@ -379,11 +510,335 @@
 	 */
 }
 
+#ifdef MXC_NFC_V1_1
+static void _mxc_nand_enable_hwecc(struct mtd_info *mtd, int on)
+{
+	struct nand_chip *nand_chip = mtd->priv;
+	struct mxc_nand_host *host = nand_chip->priv;
+	uint16_t tmp = readw(&host->regs->nfc_config1);
+
+	if (on)
+		tmp |= NFC_ECC_EN;
+	else
+		tmp &= ~NFC_ECC_EN;
+	writew(tmp, &host->regs->nfc_config1);
+}
+
+static int mxc_nand_read_oob_syndrome(struct mtd_info *mtd,
+				      struct nand_chip *chip,
+				      int page, int sndcmd)
+{
+	struct mxc_nand_host *host = chip->priv;
+	uint8_t *buf = chip->oob_poi;
+	int length = mtd->oobsize;
+	int eccpitch = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
+	uint8_t *bufpoi = buf;
+	int i, toread;
+
+	MTDDEBUG(MTD_DEBUG_LEVEL0,
+			"%s: Reading OOB area of page %u to oob %p\n",
+			 __FUNCTION__, host->page_addr, buf);
+
+	chip->cmdfunc(mtd, NAND_CMD_READOOB, mtd->writesize, page);
+	for (i = 0; i < chip->ecc.steps; i++) {
+		toread = min_t(int, length, chip->ecc.prepad);
+		if (toread) {
+			chip->read_buf(mtd, bufpoi, toread);
+			bufpoi += toread;
+			length -= toread;
+		}
+		bufpoi += chip->ecc.bytes;
+		host->col_addr += chip->ecc.bytes;
+		length -= chip->ecc.bytes;
+
+		toread = min_t(int, length, chip->ecc.postpad);
+		if (toread) {
+			chip->read_buf(mtd, bufpoi, toread);
+			bufpoi += toread;
+			length -= toread;
+		}
+	}
+	if (length > 0)
+		chip->read_buf(mtd, bufpoi, length);
+
+	_mxc_nand_enable_hwecc(mtd, 0);
+	chip->cmdfunc(mtd, NAND_CMD_READOOB,
+			mtd->writesize + chip->ecc.prepad, page);
+	bufpoi = buf + chip->ecc.prepad;
+	length = mtd->oobsize - chip->ecc.prepad;
+	for (i = 0; i < chip->ecc.steps; i++) {
+		toread = min_t(int, length, chip->ecc.bytes);
+		chip->read_buf(mtd, bufpoi, toread);
+		bufpoi += eccpitch;
+		length -= eccpitch;
+		host->col_addr += chip->ecc.postpad + chip->ecc.prepad;
+	}
+	_mxc_nand_enable_hwecc(mtd, 1);
+	return 1;
+}
+
+static int mxc_nand_read_page_raw_syndrome(struct mtd_info *mtd,
+					   struct nand_chip *chip,
+					   uint8_t *buf,
+					   int page)
+{
+	struct mxc_nand_host *host = chip->priv;
+	int eccsize = chip->ecc.size;
+	int eccbytes = chip->ecc.bytes;
+	int eccpitch = eccbytes + chip->ecc.prepad + chip->ecc.postpad;
+	uint8_t *oob = chip->oob_poi;
+	int steps, size;
+	int n;
+
+	_mxc_nand_enable_hwecc(mtd, 0);
+	chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, host->page_addr);
+
+	for (n = 0, steps = chip->ecc.steps; steps > 0; n++, steps--) {
+		host->col_addr = n * eccsize;
+		chip->read_buf(mtd, buf, eccsize);
+		buf += eccsize;
+
+		host->col_addr = mtd->writesize + n * eccpitch;
+		if (chip->ecc.prepad) {
+			chip->read_buf(mtd, oob, chip->ecc.prepad);
+			oob += chip->ecc.prepad;
+		}
+
+		chip->read_buf(mtd, oob, eccbytes);
+		oob += eccbytes;
+
+		if (chip->ecc.postpad) {
+			chip->read_buf(mtd, oob, chip->ecc.postpad);
+			oob += chip->ecc.postpad;
+		}
+	}
+
+	size = mtd->oobsize - (oob - chip->oob_poi);
+	if (size)
+		chip->read_buf(mtd, oob, size);
+	_mxc_nand_enable_hwecc(mtd, 0);
+
+	return 0;
+}
+
+static int mxc_nand_read_page_syndrome(struct mtd_info *mtd,
+				       struct nand_chip *chip,
+				       uint8_t *buf,
+				       int page)
+{
+	struct mxc_nand_host *host = chip->priv;
+	int n, eccsize = chip->ecc.size;
+	int eccbytes = chip->ecc.bytes;
+	int eccpitch = eccbytes + chip->ecc.prepad + chip->ecc.postpad;
+	int eccsteps = chip->ecc.steps;
+	uint8_t *p = buf;
+	uint8_t *oob = chip->oob_poi;
+
+	MTDDEBUG(MTD_DEBUG_LEVEL1, "Reading page %u to buf %p oob %p\n",
+	      host->page_addr, buf, oob);
+
+	/* first read out the data area and the available portion of OOB */
+	for (n = 0; eccsteps; n++, eccsteps--, p += eccsize) {
+		int stat;
+
+		host->col_addr = n * eccsize;
+
+		chip->read_buf(mtd, p, eccsize);
+
+		host->col_addr = mtd->writesize + n * eccpitch;
+
+		if (chip->ecc.prepad) {
+			chip->read_buf(mtd, oob, chip->ecc.prepad);
+			oob += chip->ecc.prepad;
+		}
+
+		stat = chip->ecc.correct(mtd, p, oob, NULL);
+
+		if (stat < 0)
+			mtd->ecc_stats.failed++;
+		else
+			mtd->ecc_stats.corrected += stat;
+		oob += eccbytes;
+
+		if (chip->ecc.postpad) {
+			chip->read_buf(mtd, oob, chip->ecc.postpad);
+			oob += chip->ecc.postpad;
+		}
+	}
+
+	/* Calculate remaining oob bytes */
+	n = mtd->oobsize - (oob - chip->oob_poi);
+	if (n)
+		chip->read_buf(mtd, oob, n);
+
+	/* Then switch ECC off and read the OOB area to get the ECC code */
+	_mxc_nand_enable_hwecc(mtd, 0);
+	chip->cmdfunc(mtd, NAND_CMD_READOOB, mtd->writesize, host->page_addr);
+	eccsteps = chip->ecc.steps;
+	oob = chip->oob_poi + chip->ecc.prepad;
+	for (n = 0; eccsteps; n++, eccsteps--, p += eccsize) {
+		host->col_addr = mtd->writesize +
+				 n * eccpitch +
+				 chip->ecc.prepad;
+		chip->read_buf(mtd, oob, eccbytes);
+		oob += eccbytes + chip->ecc.postpad;
+	}
+	_mxc_nand_enable_hwecc(mtd, 1);
+	return 0;
+}
+
+static int mxc_nand_write_oob_syndrome(struct mtd_info *mtd,
+				       struct nand_chip *chip, int page)
+{
+	struct mxc_nand_host *host = chip->priv;
+	int eccpitch = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
+	int length = mtd->oobsize;
+	int i, len, status, steps = chip->ecc.steps;
+	const uint8_t *bufpoi = chip->oob_poi;
+
+	chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page);
+	for (i = 0; i < steps; i++) {
+		len = min_t(int, length, eccpitch);
+
+		chip->write_buf(mtd, bufpoi, len);
+		bufpoi += len;
+		length -= len;
+		host->col_addr += chip->ecc.prepad + chip->ecc.postpad;
+	}
+	if (length > 0)
+		chip->write_buf(mtd, bufpoi, length);
+
+	chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
+	status = chip->waitfunc(mtd, chip);
+	return status & NAND_STATUS_FAIL ? -EIO : 0;
+}
+
+static void mxc_nand_write_page_raw_syndrome(struct mtd_info *mtd,
+					     struct nand_chip *chip,
+					     const uint8_t *buf)
+{
+	struct mxc_nand_host *host = chip->priv;
+	int eccsize = chip->ecc.size;
+	int eccbytes = chip->ecc.bytes;
+	int eccpitch = eccbytes + chip->ecc.prepad + chip->ecc.postpad;
+	uint8_t *oob = chip->oob_poi;
+	int steps, size;
+	int n;
+
+	for (n = 0, steps = chip->ecc.steps; steps > 0; n++, steps--) {
+		host->col_addr = n * eccsize;
+		chip->write_buf(mtd, buf, eccsize);
+		buf += eccsize;
+
+		host->col_addr = mtd->writesize + n * eccpitch;
+
+		if (chip->ecc.prepad) {
+			chip->write_buf(mtd, oob, chip->ecc.prepad);
+			oob += chip->ecc.prepad;
+		}
+
+		host->col_addr += eccbytes;
+		oob += eccbytes;
+
+		if (chip->ecc.postpad) {
+			chip->write_buf(mtd, oob, chip->ecc.postpad);
+			oob += chip->ecc.postpad;
+		}
+	}
+
+	size = mtd->oobsize - (oob - chip->oob_poi);
+	if (size)
+		chip->write_buf(mtd, oob, size);
+}
+
+static void mxc_nand_write_page_syndrome(struct mtd_info *mtd,
+					 struct nand_chip *chip,
+					 const uint8_t *buf)
+{
+	struct mxc_nand_host *host = chip->priv;
+	int i, n, eccsize = chip->ecc.size;
+	int eccbytes = chip->ecc.bytes;
+	int eccpitch = eccbytes + chip->ecc.prepad + chip->ecc.postpad;
+	int eccsteps = chip->ecc.steps;
+	const uint8_t *p = buf;
+	uint8_t *oob = chip->oob_poi;
+
+	chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
+
+	for (i = n = 0;
+	     eccsteps;
+	     n++, eccsteps--, i += eccbytes, p += eccsize) {
+		host->col_addr = n * eccsize;
+
+		chip->write_buf(mtd, p, eccsize);
+
+		host->col_addr = mtd->writesize + n * eccpitch;
+
+		if (chip->ecc.prepad) {
+			chip->write_buf(mtd, oob, chip->ecc.prepad);
+			oob += chip->ecc.prepad;
+		}
+
+		chip->write_buf(mtd, oob, eccbytes);
+		oob += eccbytes;
+
+		if (chip->ecc.postpad) {
+			chip->write_buf(mtd, oob, chip->ecc.postpad);
+			oob += chip->ecc.postpad;
+		}
+	}
+
+	/* Calculate remaining oob bytes */
+	i = mtd->oobsize - (oob - chip->oob_poi);
+	if (i)
+		chip->write_buf(mtd, oob, i);
+}
+
 static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat,
 				 u_char *read_ecc, u_char *calc_ecc)
 {
 	struct nand_chip *nand_chip = mtd->priv;
 	struct mxc_nand_host *host = nand_chip->priv;
+	uint16_t ecc_status = readw(&host->regs->nfc_ecc_status_result);
+	int subpages = mtd->writesize / nand_chip->subpagesize;
+	int pg2blk_shift = nand_chip->phys_erase_shift -
+			   nand_chip->page_shift;
+
+	do {
+		if ((ecc_status & 0xf) > 4) {
+			static int last_bad = -1;
+
+			if (last_bad != host->page_addr >> pg2blk_shift) {
+				last_bad = host->page_addr >> pg2blk_shift;
+				printk(KERN_DEBUG
+				       "MXC_NAND: HWECC uncorrectable ECC error"
+				       " in block %u page %u subpage %d\n",
+				       last_bad, host->page_addr,
+				       mtd->writesize / nand_chip->subpagesize
+					    - subpages);
+			}
+			return -1;
+		}
+		ecc_status >>= 4;
+		subpages--;
+	} while (subpages > 0);
+
+	return 0;
+}
+#else
+#define mxc_nand_read_page_syndrome NULL
+#define mxc_nand_read_page_raw_syndrome NULL
+#define mxc_nand_read_oob_syndrome NULL
+#define mxc_nand_write_page_syndrome NULL
+#define mxc_nand_write_page_raw_syndrome NULL
+#define mxc_nand_write_oob_syndrome NULL
+#define mxc_nfc_11_nand_correct_data NULL
+
+static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat,
+				 u_char *read_ecc, u_char *calc_ecc)
+{
+	struct nand_chip *nand_chip = mtd->priv;
+	struct mxc_nand_host *host = nand_chip->priv;
 
 	/*
 	 * 1-Bit errors are automatically corrected in HW.  No need for
@@ -400,6 +855,9 @@
 
 	return 0;
 }
+#endif
+
+
 
 static int mxc_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
 				  u_char *ecc_code)
@@ -415,9 +873,9 @@
 	uint8_t ret = 0;
 	uint16_t col;
 	uint16_t __iomem *main_buf =
-		(uint16_t __iomem *)host->regs->main_area0;
+		(uint16_t __iomem *)host->regs->main_area[0];
 	uint16_t __iomem *spare_buf =
-		(uint16_t __iomem *)host->regs->spare_area0;
+		(uint16_t __iomem *)host->regs->spare_area[0];
 	union {
 		uint16_t word;
 		uint8_t bytes[2];
@@ -464,9 +922,10 @@
 		col += mtd->writesize;
 
 	if (col < mtd->writesize) {
-		p = (uint16_t __iomem *)(host->regs->main_area0 + (col >> 1));
+		p = (uint16_t __iomem *)(host->regs->main_area[0] +
+				(col >> 1));
 	} else {
-		p = (uint16_t __iomem *)(host->regs->spare_area0 +
+		p = (uint16_t __iomem *)(host->regs->spare_area[0] +
 				((col - mtd->writesize) >> 1));
 	}
 
@@ -525,9 +984,9 @@
 		void __iomem *p;
 
 		if (col < mtd->writesize) {
-			p = host->regs->main_area0 + (col & ~3);
+			p = host->regs->main_area[0] + (col & ~3);
 		} else {
-			p = host->regs->spare_area0 -
+			p = host->regs->spare_area[0] -
 						mtd->writesize + (col & ~3);
 		}
 
@@ -595,9 +1054,9 @@
 		void __iomem *p;
 
 		if (col < mtd->writesize) {
-			p = host->regs->main_area0 + (col & ~3);
+			p = host->regs->main_area[0] + (col & ~3);
 		} else {
-			p = host->regs->spare_area0 -
+			p = host->regs->spare_area[0] -
 					mtd->writesize + (col & ~3);
 		}
 
@@ -683,7 +1142,7 @@
  * Used by the upper layer to write command to NAND Flash for
  * different operations to be carried out on NAND Flash
  */
-static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
+void mxc_nand_command(struct mtd_info *mtd, unsigned command,
 				int column, int page_addr)
 {
 	struct nand_chip *nand_chip = mtd->priv;
@@ -705,6 +1164,7 @@
 		break;
 
 	case NAND_CMD_READ0:
+		host->page_addr = page_addr;
 		host->col_addr = column;
 		host->spare_only = false;
 		break;
@@ -750,7 +1210,7 @@
 	case NAND_CMD_PAGEPROG:
 		send_prog_page(host, 0, host->spare_only);
 
-		if (host->pagesize_2k) {
+		if (host->pagesize_2k && !is_mxc_nfc_11()) {
 			/* data in 4 areas datas */
 			send_prog_page(host, 1, host->spare_only);
 			send_prog_page(host, 2, host->spare_only);
@@ -780,30 +1240,12 @@
 
 	/* Write out page address, if necessary */
 	if (page_addr != -1) {
-		/* paddr_0 - p_addr_7 */
-		send_addr(host, (page_addr & 0xff));
-
-		if (host->pagesize_2k) {
-			send_addr(host, (page_addr >> 8) & 0xFF);
-			if (mtd->size >= 0x10000000) {
-				/* paddr_8 - paddr_15 */
-				send_addr(host, (page_addr >> 8) & 0xff);
-				send_addr(host, (page_addr >> 16) & 0xff);
-			} else {
-				/* paddr_8 - paddr_15 */
-				send_addr(host, (page_addr >> 8) & 0xff);
-			}
-		} else {
-			/* One more address cycle for higher density devices */
-			if (mtd->size >= 0x4000000) {
-				/* paddr_8 - paddr_15 */
-				send_addr(host, (page_addr >> 8) & 0xff);
-				send_addr(host, (page_addr >> 16) & 0xff);
-			} else {
-				/* paddr_8 - paddr_15 */
-				send_addr(host, (page_addr >> 8) & 0xff);
-			}
-		}
+		u32 page_mask = nand_chip->pagemask;
+		do {
+			send_addr(host, page_addr & 0xFF);
+			page_addr >>= 8;
+			page_mask >>= 8;
+		} while (page_mask);
 	}
 
 	/* Command post-processing step */
@@ -819,9 +1261,11 @@
 			send_cmd(host, NAND_CMD_READSTART);
 			/* read for each AREA */
 			send_read_page(host, 0, host->spare_only);
-			send_read_page(host, 1, host->spare_only);
-			send_read_page(host, 2, host->spare_only);
-			send_read_page(host, 3, host->spare_only);
+			if (!is_mxc_nfc_11()) {
+				send_read_page(host, 1, host->spare_only);
+				send_read_page(host, 2, host->spare_only);
+				send_read_page(host, 3, host->spare_only);
+			}
 		} else {
 			send_read_page(host, 0, host->spare_only);
 		}
@@ -843,6 +1287,24 @@
 	}
 }
 
+#ifdef MXC_NFC_V1_1
+static void mxc_setup_config1(void)
+{
+	uint16_t tmp;
+
+	tmp = readw(&host->regs->nfc_config1);
+	tmp |= NFC_ONE_CYCLE;
+	tmp |= NFC_4_8N_ECC;
+	writew(tmp, &host->regs->nfc_config1);
+	if (host->pagesize_2k)
+		writew(64/2, &host->regs->nfc_spare_area_size);
+	else
+		writew(16/2, &host->regs->nfc_spare_area_size);
+}
+#else
+#define mxc_setup_config1()
+#endif
+
 int board_nand_init(struct nand_chip *this)
 {
 	struct mtd_info *mtd;
@@ -874,10 +1336,23 @@
 	this->ecc.calculate = mxc_nand_calculate_ecc;
 	this->ecc.hwctl = mxc_nand_enable_hwecc;
 	this->ecc.correct = mxc_nand_correct_data;
-	this->ecc.mode = NAND_ECC_HW;
+	if (is_mxc_nfc_11()) {
+		this->ecc.mode = NAND_ECC_HW_SYNDROME;
+		this->ecc.read_page = mxc_nand_read_page_syndrome;
+		this->ecc.read_page_raw = mxc_nand_read_page_raw_syndrome;
+		this->ecc.read_oob = mxc_nand_read_oob_syndrome;
+		this->ecc.write_page = mxc_nand_write_page_syndrome;
+		this->ecc.write_page_raw = mxc_nand_write_page_raw_syndrome;
+		this->ecc.write_oob = mxc_nand_write_oob_syndrome;
+		this->ecc.bytes = 9;
+		this->ecc.prepad = 7;
+	} else {
+		this->ecc.mode = NAND_ECC_HW;
+	}
+
+	host->pagesize_2k = 0;
+
 	this->ecc.size = 512;
-	this->ecc.bytes = 3;
-	this->ecc.layout = &nand_hw_eccoob;
 	tmp = readw(&host->regs->nfc_config1);
 	tmp |= NFC_ECC_EN;
 	writew(tmp, &host->regs->nfc_config1);
@@ -888,7 +1363,6 @@
 	tmp &= ~NFC_ECC_EN;
 	writew(tmp, &host->regs->nfc_config1);
 #endif
-
 	/* Reset NAND */
 	this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
 
@@ -911,10 +1385,11 @@
 
 #ifdef CONFIG_SYS_NAND_LARGEPAGE
 	host->pagesize_2k = 1;
-	this->ecc.layout = &nand_hw_eccoob_largepage;
+	this->ecc.layout = &nand_hw_eccoob2k;
 #else
 	host->pagesize_2k = 0;
+	this->ecc.layout = &nand_hw_eccoob;
 #endif
-
+	mxc_setup_config1();
 	return err;
 }
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index bb6b5a0..a5e339a 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -29,6 +29,7 @@
 COBJS-$(CONFIG_ATMEL_LCD) += atmel_lcdfb.o
 COBJS-$(CONFIG_CFB_CONSOLE) += cfb_console.o
 COBJS-$(CONFIG_S6E63D6) += s6e63d6.o
+COBJS-$(CONFIG_VIDEO_AMBA) += amba.o
 COBJS-$(CONFIG_VIDEO_CT69000) += ct69000.o
 COBJS-$(CONFIG_VIDEO_MB862xx) += mb862xx.o
 COBJS-$(CONFIG_VIDEO_MX3) += mx3fb.o
diff --git a/drivers/video/amba.c b/drivers/video/amba.c
new file mode 100644
index 0000000..ffa1c39
--- /dev/null
+++ b/drivers/video/amba.c
@@ -0,0 +1,79 @@
+/*
+ * Driver for AMBA PrimeCell CLCD
+ *
+ * Copyright (C) 2009 Alessandro Rubini
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <lcd.h>
+#include <amba_clcd.h>
+
+/* These variables are required by lcd.c -- although it sets them by itself */
+int lcd_line_length;
+int lcd_color_fg;
+int lcd_color_bg;
+void *lcd_base;
+void *lcd_console_address;
+short console_col;
+short console_row;
+
+/*
+ * To use this driver you need to provide the following in board files:
+ *	a panel_info definition
+ *	an lcd_enable function (can't define a weak default with current code)
+ */
+
+/* There is nothing to do with color registers, we use true color */
+void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
+{
+	return;
+}
+
+/* Low level initialization of the logic cell: depends on panel_info */
+void lcd_ctrl_init(void *lcdbase)
+{
+	struct clcd_config *config;
+	struct clcd_registers *regs;
+	u32 cntl;
+
+	config = panel_info.priv;
+	regs = config->address;
+	cntl = config->cntl & ~CNTL_LCDEN;
+
+	/* Lazily, just copy the registers over: first control with disable */
+	writel(cntl, &regs->cntl);
+
+	writel(config->tim0, &regs->tim0);
+	writel(config->tim1, &regs->tim1);
+	writel(config->tim2, &regs->tim2);
+	writel(config->tim3, &regs->tim3);
+	writel((u32)lcdbase, &regs->ubas);
+	/* finally, enable */
+	writel(cntl | CNTL_LCDEN, &regs->cntl);
+}
+
+/* This is trivial, and copied from atmel_lcdfb.c */
+ulong calc_fbsize(void)
+{
+	return ((panel_info.vl_col * panel_info.vl_row *
+		NBITS(panel_info.vl_bpix)) / 8) + PAGE_SIZE;
+}
diff --git a/include/amba_clcd.h b/include/amba_clcd.h
new file mode 100644
index 0000000..db80517
--- /dev/null
+++ b/include/amba_clcd.h
@@ -0,0 +1,77 @@
+/*
+ * Register definitions for the AMBA CLCD logic cell.
+ *
+ * derived from David A Rusling, although rearranged as a C structure
+ *     linux/include/asm-arm/hardware/amba_clcd.h -- Integrator LCD panel.
+ *
+ * Copyright (C) 2001 ARM Limited
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+/*
+ * CLCD Controller Internal Register addresses
+ */
+struct clcd_registers {
+	u32 tim0;	/* 0x00 */
+	u32 tim1;
+	u32 tim2;
+	u32 tim3;
+	u32 ubas;	/* 0x10 */
+	u32 lbas;
+#if !defined(CONFIG_ARCH_VERSATILE) && !defined(CONFIG_ARCH_REALVIEW)
+	u32 ienb;
+	u32 cntl;
+#else /* Someone rearranged these two registers on the Versatile */
+	u32 cntl;
+	u32 ienb;
+#endif
+	u32 stat;	/* 0x20 */
+	u32 intr;
+	u32 ucur;
+	u32 lcur;
+	u32 unused[0x74];	/* 0x030..0x1ff */
+	u32 palette[0x80];	/* 0x200..0x3ff */
+};
+
+/* Bit definition for TIM2 */
+#define TIM2_CLKSEL		(1 << 5)
+#define TIM2_IVS		(1 << 11)
+#define TIM2_IHS		(1 << 12)
+#define TIM2_IPC		(1 << 13)
+#define TIM2_IOE		(1 << 14)
+#define TIM2_BCD		(1 << 26)
+
+/* Bit definitions for control register */
+#define CNTL_LCDEN		(1 << 0)
+#define CNTL_LCDBPP1		(0 << 1)
+#define CNTL_LCDBPP2		(1 << 1)
+#define CNTL_LCDBPP4		(2 << 1)
+#define CNTL_LCDBPP8		(3 << 1)
+#define CNTL_LCDBPP16		(4 << 1)
+#define CNTL_LCDBPP16_565	(6 << 1)
+#define CNTL_LCDBPP24		(5 << 1)
+#define CNTL_LCDBW		(1 << 4)
+#define CNTL_LCDTFT		(1 << 5)
+#define CNTL_LCDMONO8		(1 << 6)
+#define CNTL_LCDDUAL		(1 << 7)
+#define CNTL_BGR		(1 << 8)
+#define CNTL_BEBO		(1 << 9)
+#define CNTL_BEPO		(1 << 10)
+#define CNTL_LCDPWR		(1 << 11)
+#define CNTL_LCDVCOMP(x)	((x) << 12)
+#define CNTL_LDMAFIFOTIME	(1 << 15)
+#define CNTL_WATERMARK		(1 << 16)
+
+/* u-boot specific: information passed by the board file */
+struct clcd_config {
+	struct clcd_registers *address;
+	u32			tim0;
+	u32			tim1;
+	u32			tim2;
+	u32			tim3;
+	u32			cntl;
+	unsigned long		pixclock;
+};
diff --git a/include/configs/MPC8569MDS.h b/include/configs/MPC8569MDS.h
index 4f4bcbe..9b81703 100644
--- a/include/configs/MPC8569MDS.h
+++ b/include/configs/MPC8569MDS.h
@@ -62,6 +62,12 @@
 #define CONFIG_L2_CACHE				/* toggle L2 cache	*/
 #define CONFIG_BTB				/* toggle branch predition */
 
+#ifdef CONFIG_MK_NAND
+#define CONFIG_NAND_U_BOOT		1
+#define CONFIG_RAMBOOT_NAND		1
+#define CONFIG_RAMBOOT_TEXT_BASE	0xf8f82000
+#endif
+
 /*
  * Only possible on E500 Version 2 or newer cores.
  */
@@ -74,16 +80,29 @@
 #define CONFIG_SYS_MEMTEST_END		0x00400000
 
 /*
+ * Config the L2 Cache as L2 SRAM
+ */
+#define CONFIG_SYS_INIT_L2_ADDR		0xf8f80000
+#define CONFIG_SYS_INIT_L2_ADDR_PHYS	CONFIG_SYS_INIT_L2_ADDR
+#define CONFIG_SYS_L2_SIZE		(512 << 10)
+#define CONFIG_SYS_INIT_L2_END	(CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_L2_SIZE)
+
+/*
  * Base addresses -- Note these are effective addresses where the
  * actual resources get mapped (not physical addresses)
  */
-#define CONFIG_SYS_CCSRBAR_DEFAULT	0xff700000	/* CCSRBAR Default */
 #define CONFIG_SYS_CCSRBAR		0xe0000000	/* relocated CCSRBAR */
 #define CONFIG_SYS_CCSRBAR_PHYS	CONFIG_SYS_CCSRBAR
 						/* physical addr of CCSRBAR */
 #define CONFIG_SYS_IMMR		CONFIG_SYS_CCSRBAR
 						/* PQII uses CONFIG_SYS_IMMR */
 
+#if defined(CONFIG_RAMBOOT_NAND) && !defined(CONFIG_NAND_SPL)
+#define CONFIG_SYS_CCSRBAR_DEFAULT	CONFIG_SYS_CCSRBAR
+#else
+#define CONFIG_SYS_CCSRBAR_DEFAULT	0xff700000	/* CCSRBAR Default */
+#endif
+
 #define CONFIG_SYS_PCI1_ADDR           (CONFIG_SYS_CCSRBAR+0x8000)
 #define CONFIG_SYS_PCIE1_ADDR          (CONFIG_SYS_CCSRBAR+0xa000)
 
@@ -152,8 +171,8 @@
 #define CONFIG_SYS_BCSR_BASE_PHYS	CONFIG_SYS_BCSR_BASE
 
 /*Chip select 0 - Flash*/
-#define CONFIG_SYS_BR0_PRELIM		0xfe000801
-#define	CONFIG_SYS_OR0_PRELIM		0xfe000ff7
+#define CONFIG_FLASH_BR_PRELIM		0xfe000801
+#define	CONFIG_FLASH_OR_PRELIM		0xfe000ff7
 
 /*Chip select 1 - BCSR*/
 #define CONFIG_SYS_BR1_PRELIM		0xf8000801
@@ -175,12 +194,33 @@
 
 #define CONFIG_SYS_MONITOR_BASE	TEXT_BASE	/* start of monitor */
 
+#if defined(CONFIG_SYS_SPL) || defined(CONFIG_RAMBOOT_NAND)
+#define CONFIG_SYS_RAMBOOT
+#else
+#undef CONFIG_SYS_RAMBOOT
+#endif
+
 #define CONFIG_FLASH_CFI_DRIVER
 #define CONFIG_SYS_FLASH_CFI
 #define CONFIG_SYS_FLASH_EMPTY_INFO
 
 /* Chip select 3 - NAND */
+#ifndef CONFIG_NAND_SPL
 #define CONFIG_SYS_NAND_BASE		0xFC000000
+#else
+#define CONFIG_SYS_NAND_BASE		0xFFF00000
+#endif
+
+/* NAND boot: 4K NAND loader config */
+#define CONFIG_SYS_NAND_SPL_SIZE	0x1000
+#define CONFIG_SYS_NAND_U_BOOT_SIZE	((512 << 10) - 0x2000)
+#define CONFIG_SYS_NAND_U_BOOT_DST	(CONFIG_SYS_INIT_L2_ADDR)
+#define CONFIG_SYS_NAND_U_BOOT_START \
+	(CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_NAND_SPL_SIZE)
+#define CONFIG_SYS_NAND_U_BOOT_OFFS	(0)
+#define CONFIG_SYS_NAND_U_BOOT_RELOC	(CONFIG_SYS_INIT_L2_END - 0x2000)
+#define CONFIG_SYS_NAND_U_BOOT_RELOC_SP	((CONFIG_SYS_INIT_L2_END - 1) & ~0xF)
+
 #define CONFIG_SYS_NAND_BASE_PHYS	CONFIG_SYS_NAND_BASE
 #define CONFIG_SYS_NAND_BASE_LIST	{ CONFIG_SYS_NAND_BASE, }
 #define CONFIG_SYS_MAX_NAND_DEVICE	1
@@ -200,8 +240,18 @@
 				| OR_FCM_SCY_1 \
 				| OR_FCM_TRLX \
 				| OR_FCM_EHTR)
+
+#ifdef CONFIG_RAMBOOT_NAND
+#define CONFIG_SYS_BR0_PRELIM	CONFIG_NAND_BR_PRELIM	/* NAND Base Address */
+#define CONFIG_SYS_OR0_PRELIM	CONFIG_NAND_OR_PRELIM	/* NAND Options */
+#define CONFIG_SYS_BR3_PRELIM	CONFIG_FLASH_BR_PRELIM	/* NOR Base Address */
+#define CONFIG_SYS_OR3_PRELIM	CONFIG_FLASH_OR_PRELIM	/* NOR Options */
+#else
+#define CONFIG_SYS_BR0_PRELIM	CONFIG_FLASH_BR_PRELIM	/* NOR Base Address */
+#define CONFIG_SYS_OR0_PRELIM	CONFIG_FLASH_OR_PRELIM	/* NOR Options */
 #define CONFIG_SYS_BR3_PRELIM	CONFIG_NAND_BR_PRELIM /* NAND Base Address */
 #define CONFIG_SYS_OR3_PRELIM	CONFIG_NAND_OR_PRELIM /* NAND Options */
+#endif
 
 /*
  * SDRAM on the LocalBus
@@ -447,10 +497,18 @@
 /*
  * Environment
  */
+#if defined(CONFIG_SYS_RAMBOOT)
+#if defined(CONFIG_RAMBOOT_NAND)
+#define CONFIG_ENV_IS_IN_NAND	1
+#define CONFIG_ENV_SIZE		CONFIG_SYS_NAND_BLOCK_SIZE
+#define CONFIG_ENV_OFFSET	((512 * 1024) + CONFIG_SYS_NAND_BLOCK_SIZE)
+#endif
+#else
 #define CONFIG_ENV_IS_IN_FLASH	1
 #define CONFIG_ENV_ADDR		(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SECT_SIZE)
 #define CONFIG_ENV_SECT_SIZE	0x20000	/* 256K(one sector) for env */
 #define CONFIG_ENV_SIZE		CONFIG_ENV_SECT_SIZE
+#endif
 
 #define CONFIG_LOADS_ECHO	1	/* echo on for serial download */
 #define CONFIG_SYS_LOADS_BAUD_CHANGE	1	/* allow baudrate change */
diff --git a/include/fsl_nfc.h b/include/fsl_nfc.h
index da5be37..279aaa5 100644
--- a/include/fsl_nfc.h
+++ b/include/fsl_nfc.h
@@ -1,5 +1,4 @@
 /*
- *
  * (c) 2009 Magnus Lilja <lilja.magnus@gmail.com>
  *
  * See file CREDITS for list of people who contributed to this
@@ -25,21 +24,57 @@
 #define __FSL_NFC_H
 
 /*
+ * TODO: Use same register defs for nand_spl mxc nand driver
+ * and mtd mxc nand driver.
+ *
  * Register map and bit definitions for the Freescale NAND Flash
- * Controller present in i.MX31 and other devices.
+ * Controller present in various i.MX devices.
+ *
+ * MX31 and MX27 have version 1 which has
+ * 	4 512 byte main buffers and
+ * 	4 16 byte spare buffers
+ * 	to support up to 2K byte pagesize nand.
+ * 	Reading or writing a 2K page requires 4 FDI/FDO cycles.
+ *
+ * MX25 has version 1.1 which has
+ * 	8 512 byte main buffers and
+ * 	8 64 byte spare buffers
+ * 	to support up to 4K byte pagesize nand.
+ * 	Reading or writing a 2K or 4K page requires only 1 FDI/FDO cycle.
+ *      Also some of registers are moved and/or changed meaning as seen below.
  */
+#if defined(CONFIG_MX31) || defined(CONFIG_MX27)
+#define MXC_NFC_V1
+#elif defined(CONFIG_MX25)
+#define MXC_NFC_V1_1
+#else
+#warning "MXC NFC version not defined"
+#endif
+
+#if defined(MXC_NFC_V1)
+#define NAND_MXC_NR_BUFS		4
+#define NAND_MXC_SPARE_BUF_SIZE		16
+#define NAND_MXC_REG_OFFSET		0xe00
+#define NAND_MXC_2K_MULTI_CYCLE		1
+#elif defined(MXC_NFC_V1_1)
+#define NAND_MXC_NR_BUFS		8
+#define NAND_MXC_SPARE_BUF_SIZE		64
+#define NAND_MXC_REG_OFFSET		0x1e00
+#else
+#error "define CONFIG_NAND_MXC_VXXX to use the mxc spl_nand driver"
+#endif
 
 struct fsl_nfc_regs {
-	u32 main_area0[128]; /* @0x000 */
-	u32 main_area1[128];
-	u32 main_area2[128];
-	u32 main_area3[128];
-	u32 spare_area0[4];
-	u32 spare_area1[4];
-	u32 spare_area2[4];
-	u32 spare_area3[4];
-	u32 reserved1[64 - 16 + 64 * 5];
-	u16 bufsiz; /* @ 0xe00 */
+	u32 main_area[NAND_MXC_NR_BUFS][512/4];
+	u32 spare_area[NAND_MXC_NR_BUFS][NAND_MXC_SPARE_BUF_SIZE/4];
+	/*
+	 * reserved size is offset of nfc registers
+	 * minus total main and spare sizes
+	 */
+	u8 reserved1[NAND_MXC_REG_OFFSET
+		- NAND_MXC_NR_BUFS * (512 + NAND_MXC_SPARE_BUF_SIZE)];
+#if defined(MXC_NFC_V1)
+	u16 bufsiz;
 	u16 reserved2;
 	u16 buffer_address;
 	u16 flash_add;
@@ -54,6 +89,30 @@
 	u16 nand_flash_wr_pr_st;
 	u16 nand_flash_config1;
 	u16 nand_flash_config2;
+#elif defined(MXC_NFC_V1_1)
+	u16 reserved2[2];
+	u16 buffer_address;
+	u16 flash_add;
+	u16 flash_cmd;
+	u16 configuration;
+	u16 ecc_status_result;
+	u16 ecc_status_result2;
+	u16 spare_area_size;
+	u16 nf_wr_prot;
+	u16 reserved3[2];
+	u16 nand_flash_wr_pr_st;
+	u16 nand_flash_config1;
+	u16 nand_flash_config2;
+	u16 reserved4;
+	u16 unlock_start_blk_add0;
+	u16 unlock_end_blk_add0;
+	u16 unlock_start_blk_add1;
+	u16 unlock_end_blk_add1;
+	u16 unlock_start_blk_add2;
+	u16 unlock_end_blk_add2;
+	u16 unlock_start_blk_add3;
+	u16 unlock_end_blk_add3;
+#endif
 };
 
 /*
@@ -98,6 +157,9 @@
  */
 #define NFC_INT		0x8000
 
+#ifdef MXC_NFC_V1_1
+#define NFC_4_8N_ECC	(1 << 0)
+#endif
 #define NFC_SP_EN	(1 << 2)
 #define NFC_ECC_EN	(1 << 3)
 #define NFC_INT_MSK	(1 << 4)
diff --git a/include/nomadik.h b/include/nomadik.h
index d9405fd..ea65b2d 100644
--- a/include/nomadik.h
+++ b/include/nomadik.h
@@ -4,6 +4,7 @@
 #define __NOMADIK_H__
 
 /* Base addresses of our peripherals */
+#define NOMADIK_CLCDC_BASE	0x10120000	/* CLCD Controller */
 #define NOMADIK_SRC_BASE	0x101E0000	/* System and Reset Cnt */
 #define NOMADIK_PMU_BASE	0x101E9000	/* Power Management Unit */
 #define NOMADIK_MPMC_BASE	0x10110000	/* SDRAM Controller */
diff --git a/nand_spl/board/freescale/mpc8569mds/Makefile b/nand_spl/board/freescale/mpc8569mds/Makefile
new file mode 100644
index 0000000..7ed9d61
--- /dev/null
+++ b/nand_spl/board/freescale/mpc8569mds/Makefile
@@ -0,0 +1,133 @@
+#
+# (C) Copyright 2007
+# Stefan Roese, DENX Software Engineering, sr@denx.de.
+#
+# Copyright 2009 Freescale Semiconductor, Inc.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+NAND_SPL := y
+TEXT_BASE := 0xfff00000
+PAD_TO := 0xfff01000
+
+include $(TOPDIR)/config.mk
+
+LDSCRIPT= $(TOPDIR)/cpu/$(CPU)/u-boot-nand_spl.lds
+LDFLAGS	= -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
+AFLAGS	+= -DCONFIG_NAND_SPL
+CFLAGS	+= -DCONFIG_NAND_SPL
+
+SOBJS	= start.o resetvec.o
+COBJS	= cache.o cpu_init_early.o cpu_init_nand.o fsl_law.o law.o \
+	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
+
+SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+__OBJS	:= $(SOBJS) $(COBJS)
+LNDIR	:= $(OBJTREE)/nand_spl/board/$(BOARDDIR)
+
+nandobj	:= $(OBJTREE)/nand_spl/
+
+ALL	= $(nandobj)u-boot-spl $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
+
+all:	$(obj).depend $(ALL)
+
+$(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
+	$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $< $@
+
+$(nandobj)u-boot-spl.bin:	$(nandobj)u-boot-spl
+	$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
+
+$(nandobj)u-boot-spl:	$(OBJS)
+	cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \
+		-Map $(nandobj)u-boot-spl.map \
+		-o $(nandobj)u-boot-spl
+
+# create symbolic links for common files
+
+$(obj)cache.c:
+	@rm -f $(obj)cache.c
+	ln -sf $(SRCTREE)/lib_ppc/cache.c $(obj)cache.c
+
+$(obj)cpu_init_early.c:
+	@rm -f $(obj)cpu_init_early.c
+	ln -sf $(SRCTREE)/cpu/mpc85xx/cpu_init_early.c $(obj)cpu_init_early.c
+
+$(obj)cpu_init_nand.c:
+	@rm -f $(obj)cpu_init_nand.c
+	ln -sf $(SRCTREE)/cpu/mpc85xx/cpu_init_nand.c $(obj)cpu_init_nand.c
+
+$(obj)fsl_law.c:
+	@rm -f $(obj)fsl_law.c
+	ln -sf $(SRCTREE)/drivers/misc/fsl_law.c $(obj)fsl_law.c
+
+$(obj)law.c:
+	@rm -f $(obj)law.c
+	ln -sf $(SRCTREE)/board/$(BOARDDIR)/law.c $(obj)law.c
+
+$(obj)nand_boot_fsl_elbc.c:
+	@rm -f $(obj)nand_boot_fsl_elbc.c
+	ln -sf $(SRCTREE)/nand_spl/nand_boot_fsl_elbc.c \
+	       $(obj)nand_boot_fsl_elbc.c
+
+$(obj)ns16550.c:
+	@rm -f $(obj)ns16550.c
+	ln -sf $(SRCTREE)/drivers/serial/ns16550.c $(obj)ns16550.c
+
+$(obj)resetvec.S:
+	@rm -f $(obj)resetvec.S
+	ln -s $(SRCTREE)/cpu/$(CPU)/resetvec.S $(obj)resetvec.S
+
+$(obj)fixed_ivor.S:
+	@rm -f $(obj)fixed_ivor.S
+	ln -sf $(SRCTREE)/cpu/mpc85xx/fixed_ivor.S $(obj)fixed_ivor.S
+
+$(obj)start.S: $(obj)fixed_ivor.S
+	@rm -f $(obj)start.S
+	ln -sf $(SRCTREE)/cpu/mpc85xx/start.S $(obj)start.S
+
+$(obj)tlb.c:
+	@rm -f $(obj)tlb.c
+	ln -sf $(SRCTREE)/cpu/mpc85xx/tlb.c $(obj)tlb.c
+
+$(obj)tlb_table.c:
+	@rm -f $(obj)tlb_table.c
+	ln -sf $(SRCTREE)/board/$(BOARDDIR)/tlb.c $(obj)tlb_table.c
+
+ifneq ($(OBJTREE), $(SRCTREE))
+$(obj)nand_boot.c:
+	@rm -f $(obj)nand_boot.c
+	ln -s $(SRCTREE)/nand_spl/board/$(BOARDDIR)/nand_boot.c $(obj)nand_boot.c
+endif
+
+#########################################################################
+
+$(obj)%.o:	$(obj)%.S
+	$(CC) $(AFLAGS) -c -o $@ $<
+
+$(obj)%.o:	$(obj)%.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/nand_spl/board/freescale/mpc8569mds/nand_boot.c b/nand_spl/board/freescale/mpc8569mds/nand_boot.c
new file mode 100644
index 0000000..e030656
--- /dev/null
+++ b/nand_spl/board/freescale/mpc8569mds/nand_boot.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2009 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+#include <common.h>
+#include <mpc85xx.h>
+#include <asm-ppc/io.h>
+#include <ns16550.h>
+#include <nand.h>
+#include <asm/mmu.h>
+#include <asm/immap_85xx.h>
+#include <asm/fsl_ddr_sdram.h>
+#include <asm/fsl_law.h>
+
+#define SYSCLK_66       66666666
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void board_init_f(ulong bootflag)
+{
+	uint plat_ratio, bus_clk, sys_clk;
+	volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+
+	sys_clk = SYSCLK_66;
+
+	plat_ratio = gur->porpllsr & 0x0000003e;
+	plat_ratio >>= 1;
+	bus_clk = plat_ratio * sys_clk;
+	NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+			bus_clk / 16 / CONFIG_BAUDRATE);
+
+	puts("\nNAND boot... ");
+
+	/* copy code to DDR and jump to it - this should not return */
+	/* NOTE - code has to be copied out of NAND buffer before
+	 * other blocks can be read.
+	 */
+	relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, 0,
+			CONFIG_SYS_NAND_U_BOOT_RELOC);
+}
+
+void board_init_r(gd_t *gd, ulong dest_addr)
+{
+	nand_boot();
+}
+
+void putc(char c)
+{
+	if (c == '\n')
+		NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
+
+	NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
+}
+
+void puts(const char *str)
+{
+	while (*str)
+		putc(*str++);
+}
diff --git a/nand_spl/nand_boot_fsl_nfc.c b/nand_spl/nand_boot_fsl_nfc.c
index a9df2a8..f4040a7 100644
--- a/nand_spl/nand_boot_fsl_nfc.c
+++ b/nand_spl/nand_boot_fsl_nfc.c
@@ -26,11 +26,15 @@
 
 #include <common.h>
 #include <nand.h>
+#ifdef CONFIG_MX31
 #include <asm-arm/arch/mx31-regs.h>
+#else
+#include <asm-arm/arch/imx-regs.h>
+#endif
 #include <asm/io.h>
 #include <fsl_nfc.h>
 
-static struct fsl_nfc_regs *nfc;
+struct fsl_nfc_regs *nfc;
 
 static void nfc_wait_ready(void)
 {
@@ -45,13 +49,35 @@
 	writew(tmp, &nfc->nand_flash_config2);
 }
 
-static void nfc_nand_init(void)
+void nfc_nand_init(void)
 {
+#if defined(MXC_NFC_V1_1)
+	int ecc_per_page  = CONFIG_SYS_NAND_PAGE_SIZE / 512;
+	int config1;
+
+	writew(CONFIG_SYS_NAND_SPARE_SIZE / 2, &nfc->spare_area_size);
+
+	/* unlocking RAM Buff */
+	writew(0x2, &nfc->configuration);
+
+	/* hardware ECC checking and correct */
+	config1 = readw(&nfc->nand_flash_config1) | NFC_ECC_EN | 0x800;
+	/*
+	 * if spare size is larger that 16 bytes per 512 byte hunk
+	 * then use 8 symbol correction instead of 4
+	 */
+	if ((CONFIG_SYS_NAND_SPARE_SIZE / ecc_per_page) > 16)
+		config1 &= ~NFC_4_8N_ECC;
+	else
+		config1 |= NFC_4_8N_ECC;
+	writew(config1, &nfc->nand_flash_config1);
+#elif defined(MXC_NFC_V1)
 	/* unlocking RAM Buff */
 	writew(0x2, &nfc->configuration);
 
 	/* hardware ECC checking and correct */
 	writew(NFC_ECC_EN, &nfc->nand_flash_config1);
+#endif
 }
 
 static void nfc_nand_command(unsigned short command)
@@ -65,12 +91,12 @@
 {
 	unsigned int page_count;
 
-	writew(0x00, &nfc->flash_cmd);
+	writew(0x00, &nfc->flash_add);
 	writew(NFC_ADDR, &nfc->nand_flash_config2);
 	nfc_wait_ready();
 
-	/* code only for 2kb flash */
-	if (CONFIG_SYS_NAND_PAGE_SIZE == 0x800) {
+	/* code only for large page flash */
+	if (CONFIG_SYS_NAND_PAGE_SIZE > 512) {
 		writew(0x00, &nfc->flash_add);
 		writew(NFC_ADDR, &nfc->nand_flash_config2);
 		nfc_wait_ready();
@@ -88,22 +114,38 @@
 			page_count = page_count >> 8;
 		} while (page_count);
 	}
+
+	writew(0x00, &nfc->flash_add);
+	writew(NFC_ADDR, &nfc->nand_flash_config2);
+	nfc_wait_ready();
 }
 
 static void nfc_nand_data_output(void)
 {
+	int config1 = readw(&nfc->nand_flash_config1);
+#ifdef NAND_MXC_2K_MULTI_CYCLE
 	int i;
+#endif
 
+	config1 |= NFC_ECC_EN | NFC_INT_MSK;
+	writew(config1, &nfc->nand_flash_config1);
+	writew(0, &nfc->buffer_address);
+	writew(NFC_OUTPUT, &nfc->nand_flash_config2);
+	nfc_wait_ready();
+#ifdef NAND_MXC_2K_MULTI_CYCLE
 	/*
-	 * The NAND controller requires four output commands for
-	 * large page devices.
+	 * This NAND controller requires multiple input commands
+	 * for pages larger than 512 bytes.
 	 */
-	for (i = 0; i < (CONFIG_SYS_NAND_PAGE_SIZE / 512); i++) {
-		writew(NFC_ECC_EN, &nfc->nand_flash_config1);
-		writew(i, &nfc->buffer_address); /* read in i:th buffer */
+	for (i = 1; i < (CONFIG_SYS_NAND_PAGE_SIZE / 512); i++) {
+		config1 = readw(&nfc->nand_flash_config1);
+		config1 |= NFC_ECC_EN | NFC_INT_MSK;
+		writew(config1, &nfc->nand_flash_config1);
+		writew(i, &nfc->buffer_address);
 		writew(NFC_OUTPUT, &nfc->nand_flash_config2);
 		nfc_wait_ready();
 	}
+#endif
 }
 
 static int nfc_nand_check_ecc(void)
@@ -121,7 +163,7 @@
 	nfc_nand_command(NAND_CMD_READ0);
 	nfc_nand_page_address(page_address);
 
-	if (CONFIG_SYS_NAND_PAGE_SIZE == 0x800)
+	if (CONFIG_SYS_NAND_PAGE_SIZE > 512)
 		nfc_nand_command(NAND_CMD_READSTART);
 
 	nfc_nand_data_output(); /* fill the main buffer 0 */
@@ -129,7 +171,7 @@
 	if (nfc_nand_check_ecc())
 		return -1;
 
-	src = &nfc->main_area0[0];
+	src = &nfc->main_area[0][0];
 	dst = (u32 *)buf;
 
 	/* main copy loop from NAND-buffer to SDRAM memory */
@@ -154,12 +196,12 @@
 		nfc_nand_command(NAND_CMD_READ0);
 		nfc_nand_page_address(page);
 
-		if (CONFIG_SYS_NAND_PAGE_SIZE == 0x800)
+		if (CONFIG_SYS_NAND_PAGE_SIZE > 512)
 			nfc_nand_command(NAND_CMD_READSTART);
 
 		nfc_nand_data_output(); /* fill the main buffer 0 */
 
-		src = &nfc->spare_area0[0];
+		src = &nfc->spare_area[0][0];
 
 		/*
 		 * IMPORTANT NOTE: The nand flash controller uses a non-
@@ -209,7 +251,7 @@
 		if (!(page % CONFIG_SYS_NAND_PAGE_COUNT)) {
 			/*
 			 * Yes, new block. See if this block is good. If not,
-			 * loop until we find i good block.
+			 * loop until we find a good block.
 			 */
 			while (is_badblock(page)) {
 				page = page + CONFIG_SYS_NAND_PAGE_COUNT;