From 6fa1c350fa19a054371eccef84e4885cfdd6a2d7 Mon Sep 17 00:00:00 2001
From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Date: Mon, 19 Aug 2013 18:11:31 +0200
Subject: MIPS: lantiq: easy80920: add support for NAND SPL

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

--- a/boards.cfg
+++ b/boards.cfg
@@ -509,6 +509,7 @@ Active  mips        mips32         incai
 Active  mips        mips32         incaip      -               incaip              incaip_100MHz                        incaip:CPU_CLOCK_RATE=100000000                                                                                                   Wolfgang Denk <wd@denx.de>
 Active  mips        mips32         incaip      -               incaip              incaip_133MHz                        incaip:CPU_CLOCK_RATE=133000000                                                                                                   Wolfgang Denk <wd@denx.de>
 Active  mips        mips32         incaip      -               incaip              incaip_150MHz                        incaip:CPU_CLOCK_RATE=150000000                                                                                                   Wolfgang Denk <wd@denx.de>
+Active  mips        mips32         vrx200      lantiq          easy80920           easy80920_nandspl                    easy80920:SYS_BOOT_NANDSPL                                                                                                        Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
 Active  mips        mips32         vrx200      lantiq          easy80920           easy80920_nor                        easy80920:SYS_BOOT_NOR                                                                                                            Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
 Active  mips        mips32         vrx200      lantiq          easy80920           easy80920_norspl                     easy80920:SYS_BOOT_NORSPL                                                                                                         Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
 Active  mips        mips32         vrx200      lantiq          easy80920           easy80920_ram                        easy80920:SYS_BOOT_RAM                                                                                                            Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
--- a/include/configs/easy80920.h
+++ b/include/configs/easy80920.h
@@ -31,6 +31,14 @@
 
 #define CONFIG_LTQ_SUPPORT_SPL_NOR_FLASH	/* Build NOR flash SPL */
 
+#define CONFIG_LTQ_SUPPORT_SPL_NAND_FLASH	/* Build NAND flash SPL */
+#define CONFIG_SYS_NAND_PAGE_COUNT	128
+#define CONFIG_SYS_NAND_PAGE_SIZE	2048
+#define CONFIG_SYS_NAND_OOBSIZE		64
+#define CONFIG_SYS_NAND_BLOCK_SIZE	(256 * 1024)
+#define CONFIG_SYS_NAND_BAD_BLOCK_POS	NAND_LARGE_BADBLOCK_POS
+#define CONFIG_SYS_NAND_U_BOOT_OFFS	0x4000
+
 #define CONFIG_LTQ_SPL_COMP_LZO
 #define CONFIG_LTQ_SPL_CONSOLE
 
@@ -57,6 +65,11 @@
 #define CONFIG_ENV_OVERWRITE
 #define CONFIG_ENV_OFFSET		(192 * 1024)
 #define CONFIG_ENV_SECT_SIZE		(64 * 1024)
+#elif defined(CONFIG_SYS_BOOT_NANDSPL)
+#define CONFIG_ENV_IS_IN_NAND
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_ENV_OFFSET		(256 * 1024)
+#define CONFIG_ENV_SECT_SIZE		(256 * 1024)
 #else
 #define CONFIG_ENV_IS_NOWHERE
 #endif
@@ -84,9 +97,13 @@
 #define CONFIG_ENV_UPDATE_UBOOT_SF					\
 	"update-uboot-sf=run load-uboot-sfspl-lzo write-uboot-sf\0"
 
+#define CONFIG_ENV_UPDATE_UBOOT_NAND					\
+	"update-uboot-nand=run load-uboot-nandspl-lzo write-uboot-nand\0"
+
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	CONFIG_ENV_LANTIQ_DEFAULTS	\
 	CONFIG_ENV_UPDATE_UBOOT_NOR	\
-	CONFIG_ENV_UPDATE_UBOOT_SF
+	CONFIG_ENV_UPDATE_UBOOT_SF	\
+	CONFIG_ENV_UPDATE_UBOOT_NAND
 
 #endif /* __CONFIG_H */
