Add support for new TQM5200 revisions
  - Support for TQM5200S (short version of the module without SM501
    graphic controller)
  - Support for modules with 'N' type S29GL128N Spansion flashes.
    Because the new flashes have a doubled sector size, the flash
    layout has to be modified.
  - Support for MPC5200B cpu (mostly support for the second SDRAM bank)

Signed-off-by: Martin Krause <martin.krause@tqs.de>

---
commit 1013adfde2ed8006013164ea3c2bb1107e81ffb9
tree 37eddb67e9010c21781172aa962b3db8c8860bb6
parent 29a9dc47c8876462ee73ae6af53bc470ecf61914
author Martin Krause <mkr@tq-sewsrv-4.tq-net.de> Fri, 07 Jul 2006 09:26:41 +0200
committer Martin Krause <mkr@tq-sewsrv-4.tq-net.de> Fri, 07 Jul 2006 09:26:41 +0200

 MAKEALL                     |    4 ++-
 Makefile                    |   12 +++++++++-
 board/tqm5200/cmd_stk52xx.c |    4 ++-
 board/tqm5200/cmd_tb5200.c  |    0 
 board/tqm5200/tqm5200.c     |   35 +++++++++++++++++++++++++---
 common/cmd_reginfo.c        |    2 +-
 include/configs/TB5200.h    |   52 ++++++++++++++++++++++++++++++++++++++---
 include/configs/TQM5200.h   |   54 +++++++++++++++++++++++++++++++++++++++----
 8 files changed, 144 insertions(+), 19 deletions(-)

diff --git a/MAKEALL b/MAKEALL
index 3eee323..691b805 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -27,8 +27,8 @@ ########################################
 LIST_5xxx="	\
 	BC3450		cpci5200	EVAL5200	icecube_5100	\
 	icecube_5200	lite5200b	mcc200		o2dnt		\
-	pf5200		PM520		Total5100	Total5200	\
-	Total5200_Rev2	TQM5200						\
+	pf5200		PM520		TB5200		Total5100	\
+	Total5200	Total5200_Rev2	TQM5200		TQM5200_B	\
 "
 
 #########################################################################
diff --git a/Makefile b/Makefile
index a44dba2..d48988a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ # 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
+# published by the Free Software Foundatio; 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,
@@ -360,7 +360,12 @@ spieval_config:	unconfig
 	@echo "... with automatic CS configuration"
 	@./mkconfig -a spieval ppc mpc5xxx tqm5200
 
+TB5200_B_config \
 TB5200_config:	unconfig
+	@[ -z "$(findstring _B,$@)" ] || \
+		{ echo "#define CONFIG_TQM5200_B"	>>include/config.h ; \
+		  echo "... with MPC5200B processor" ; \
+		}
 	@echo "#define CONFIG_CS_AUTOCONF">>include/config.h
 	@echo "... with automatic CS configuration"
 	@./mkconfig -a TB5200 ppc mpc5xxx tqm5200
@@ -401,6 +406,7 @@ Total5200_Rev2_lowboot_config:	unconfig
 
 TQM5200_config	\
 TQM5200_STK100_config \
+TQM5200_B_config \
 MiniFAP_config:	unconfig
 	@ >include/config.h
 	@[ -z "$(findstring MiniFAP,$@)" ] || \
@@ -411,6 +417,10 @@ MiniFAP_config:	unconfig
 		{ echo "#define CONFIG_STK52XX_REV100"	>>include/config.h ; \
 		  echo "... on a STK52XX.100 base board" ; \
 		}
+	@[ -z "$(findstring B,$@)" ] || \
+		{ echo "#define CONFIG_TQM5200_B"	>>include/config.h ; \
+		  echo "... with MPC5200B processor" ; \
+		}
 	@echo "#define CONFIG_CS_AUTOCONF">>include/config.h ;
 	@echo "... with automatic CS configuration" ;
 	@./mkconfig -a TQM5200 ppc mpc5xxx tqm5200
diff --git a/board/tqm5200/cmd_stk52xx.c b/board/tqm5200/cmd_stk52xx.c
old mode 100755
new mode 100644
index 2326a28..c37d4c6
--- a/board/tqm5200/cmd_stk52xx.c
+++ b/board/tqm5200/cmd_stk52xx.c
@@ -22,7 +22,7 @@
  */
 
 /*
- * SKT52XX specific functions
+ * STK52XX specific functions
  */
 /*#define DEBUG*/
 
@@ -1209,7 +1209,7 @@ U_BOOT_CMD(
 	fkt ,	4,	1,	cmd_fkt,
 	"fkt     - Function test routines\n",
 	"led number on/off\n"
-	"     - 'number's like printed on SKT52XX board\n"
+	"     - 'number's like printed on STK52XX board\n"
 	"fkt can\n"
 	"     - loopback plug for X83 required\n"
 	"fkt rs232 number\n"
diff --git a/board/tqm5200/cmd_tb5200.c b/board/tqm5200/cmd_tb5200.c
old mode 100755
new mode 100644
diff --git a/board/tqm5200/tqm5200.c b/board/tqm5200/tqm5200.c
index 814cc8a..03cc1e7 100644
--- a/board/tqm5200/tqm5200.c
+++ b/board/tqm5200/tqm5200.c
@@ -1,11 +1,11 @@
 /*
- * (C) Copyright 2003-2004
+ * (C) Copyright 2003-2006
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * (C) Copyright 2004
  * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
  *
- * (C) Copyright 2004-2005
+ * (C) Copyright 2004-2006
  * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
  *
  * See file CREDITS for list of people who contributed to this
@@ -30,6 +30,7 @@
 #include <common.h>
 #include <mpc5xxx.h>
 #include <pci.h>
+#include <asm/processor.h>
 
 #ifdef CONFIG_VIDEO_SM501
 #include <sm501.h>
@@ -101,6 +102,8 @@ long int initdram (int board_type)
 {
 	ulong dramsize = 0;
 	ulong dramsize2 = 0;
+	uint svr, pvr;
+
 #ifndef CFG_RAMBOOT
 	ulong test1, test2;
 
@@ -190,11 +193,31 @@ #else /* CFG_RAMBOOT */
 	} else {
 		dramsize2 = 0;
 	}
-
 #endif /* CFG_RAMBOOT */
 
-/*	return dramsize + dramsize2; */
+	/*
+	 * On MPC5200B we need to set the special configuration delay in the
+	 * DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM
+	 * Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190:
+	 *
+	 * "The SDelay should be written to a value of 0x00000004. It is
+	 * required to account for changes caused by normal wafer processing
+	 * parameters."
+	 */
+	svr = get_svr();
+	pvr = get_pvr();
+	if ((SVR_MJREV(svr) >= 2) &&
+	    (PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4)) {
+
+		*(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04;
+		__asm__ volatile ("sync");
+	}
+
+#if defined(CONFIG_TQM5200_B)
+	return dramsize + dramsize2;
+#else
 	return dramsize;
+#endif /* CONFIG_TQM5200_B */
 }
 
 #elif defined(CONFIG_MGT5100)
@@ -255,7 +278,11 @@ #if defined (CONFIG_AEVFIFO)
 	return 0;
 #endif
 #if defined (CONFIG_TQM5200)
+#if defined(CONFIG_TQM5200_B)
+	puts ("Board: TQM5200 or TQM5200S (TQ-Components GmbH)\n");
+#else
 	puts ("Board: TQM5200 (TQ-Components GmbH)\n");
+#endif /* CONFIG_TQM5200_B */
 #endif
 #if defined (CONFIG_STK52XX)
 	puts ("       on a STK52XX baseboard\n");
diff --git a/common/cmd_reginfo.c b/common/cmd_reginfo.c
index 15ac16a..f428f7e 100644
--- a/common/cmd_reginfo.c
+++ b/common/cmd_reginfo.c
@@ -328,7 +328,7 @@ #elif defined(CONFIG_MPC5200)
 		(*(volatile ulong*)MPC5XXX_ADDECR & 0x02000000) ? 1 : 0);
 	printf ("\tSDRAMCS0: %08X\n",
 		*(volatile ulong*)MPC5XXX_SDRAM_CS0CFG);
-	printf ("\tSDRAMCS0: %08X\n",
+	printf ("\tSDRAMCS1: %08X\n",
 		*(volatile ulong*)MPC5XXX_SDRAM_CS1CFG);
 #endif /* CONFIG_MPC5200 */
 	return 0;
diff --git a/include/configs/TB5200.h b/include/configs/TB5200.h
old mode 100755
new mode 100644
index 96ef4af..555a221
--- a/include/configs/TB5200.h
+++ b/include/configs/TB5200.h
@@ -147,6 +147,30 @@ #define CONFIG_PREBOOT	"echo;" \
 
 #undef	CONFIG_BOOTARGS
 
+#if defined(CONFIG_TQM5200_B)
+#define CONFIG_EXTRA_ENV_SETTINGS					\
+	"netdev=eth0\0"							\
+	"rootpath=/opt/eldk/ppc_6xx\0"					\
+	"ramargs=setenv bootargs root=/dev/ram rw\0"			\
+	"nfsargs=setenv bootargs root=/dev/nfs rw "			\
+		"nfsroot=${serverip}:${rootpath}\0"			\
+	"addip=setenv bootargs ${bootargs} "				\
+		"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}"	\
+		":${hostname}:${netdev}:off panic=1\0"			\
+	"flash_self=run ramargs addip;"					\
+		"bootm ${kernel_addr} ${ramdisk_addr}\0"		\
+	"flash_nfs=run nfsargs addip;"					\
+		"bootm ${kernel_addr}\0"				\
+	"net_nfs=tftp 200000 ${bootfile};run nfsargs addip;bootm\0"	\
+	"bootfile=/tftpboot/tqm5200/uImage\0"				\
+	"load=tftp 200000 ${u-boot}\0"					\
+	"u-boot=/tftpboot/tqm5200/u-boot.bin\0"				\
+	"update=protect off FC000000 FC07FFFF;"				\
+		"erase FC000000 FC07FFFF;"				\
+		"cp.b 200000 FC000000 ${filesize};"			\
+		"protect on FC000000 FC07FFFF\0"			\
+	""
+#else
 #define CONFIG_EXTRA_ENV_SETTINGS					\
 	"netdev=eth0\0"							\
 	"rootpath=/opt/eldk/ppc_6xx\0"					\
@@ -169,6 +193,7 @@ #define CONFIG_EXTRA_ENV_SETTINGS					\
 		"cp.b 200000 FC000000 ${filesize};"			\
 		"protect on FC000000 FC05FFFF\0"			\
 	""
+#endif /* CONFIG_TQM5200_B */
 
 #define CONFIG_BOOTCOMMAND	"run net_nfs"
 
@@ -228,7 +253,7 @@ #define I2C_ADDR_LIST	{	CFG_I2C_EEPROM_A
  */
 #define CFG_FLASH_BASE		TEXT_BASE /* 0xFC000000 */
 
-/* use CFI flash driver if no module variant is spezified */
+/* use CFI flash driver */
 #define CFG_FLASH_CFI		1	/* Flash is CFI conformant */
 #define CFG_FLASH_CFI_DRIVER	1	/* Use the common driver */
 #define CFG_FLASH_BANKS_LIST	{ CFG_BOOTCS_START }
@@ -240,31 +265,46 @@ #undef CFG_FLASH_USE_BUFFER_WRITE	/* not
 #if !defined(CFG_LOWBOOT)
 #define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x00760000 + 0x00800000)
 #else	/* CFG_LOWBOOT */
+#if defined(CONFIG_TQM5200_B)
+#define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x00080000)
+#else
 #define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x00060000)
+#endif /* CONFIG_TQM5200_B */
 #endif	/* CFG_LOWBOOT */
 #define CFG_MAX_FLASH_BANKS	1	/* max num of flash banks
 					   (= chip selects) */
-#define CFG_FLASH_ERASE_TOUT	240000	/* Flash Erase Timeout (in ms)	*/
-#define CFG_FLASH_WRITE_TOUT	500	/* Flash Write Timeout (in ms)	*/
 
 /* Dynamic MTD partition support */
 #define CONFIG_JFFS2_CMDLINE
 #define MTDIDS_DEFAULT		"nor0=TQM5200-0"
+#if defined(CONFIG_TQM5200_B)
+#define MTDPARTS_DEFAULT	"mtdparts=TQM5200-0:768k(firmware),"	\
+						"1280k(kernel),"	\
+						"2m(initrd),"		\
+						"4m(small-fs),"		\
+						"16m(big-fs),"		\
+						"8m(misc)"
+#else
 #define MTDPARTS_DEFAULT	"mtdparts=TQM5200-0:640k(firmware),"	\
 						"1408k(kernel),"	\
 						"2m(initrd),"		\
 						"4m(small-fs),"		\
 						"16m(big-fs),"		\
 						"8m(misc)"
+#endif /* CONFIG_TQM5200_B */
 
 /*
  * Environment settings
  */
 #define CFG_ENV_IS_IN_FLASH	1
 #define CFG_ENV_SIZE		0x10000
+#if defined(CONFIG_TQM5200_B)
+#define CFG_ENV_SECT_SIZE	0x40000
+#else
 #define CFG_ENV_SECT_SIZE	0x20000
 #define CFG_ENV_ADDR_REDUND	(CFG_ENV_ADDR + CFG_ENV_SECT_SIZE)
-#define	CFG_ENV_SIZE_REDUND	(CFG_ENV_SIZE)
+#define CFG_ENV_SIZE_REDUND	(CFG_ENV_SIZE)
+#endif /* CONFIG_TQM5200_B */
 
 /*
  * Memory map
@@ -292,7 +332,11 @@ #if (CFG_MONITOR_BASE < CFG_FLASH_BASE)
 #   define CFG_RAMBOOT		1
 #endif
 
+#if defined(CONFIG_TQM5200_B)
+#define CFG_MONITOR_LEN		(512 << 10)	/* Reserve 512 kB for Monitor	*/
+#else
 #define CFG_MONITOR_LEN		(384 << 10)	/* Reserve 384 kB for Monitor	*/
+#endif /* CONFIG_TQM5200_B */
 #define CFG_MALLOC_LEN		(256 << 10)	/* Reserve 256 kB for malloc()	*/
 #define CFG_BOOTMAPSZ		(8 << 20)	/* Initial Memory map for Linux */
 
diff --git a/include/configs/TQM5200.h b/include/configs/TQM5200.h
old mode 100755
new mode 100644
index 6b949c9..5c6ed1e
--- a/include/configs/TQM5200.h
+++ b/include/configs/TQM5200.h
@@ -2,7 +2,7 @@
  * (C) Copyright 2003-2005
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
- * (C) Copyright 2004-2005
+ * (C) Copyright 2004-2006
  * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
  *
  * See file CREDITS for list of people who contributed to this
@@ -191,6 +191,30 @@ #define CONFIG_PREBOOT	"echo;" \
 
 #undef	CONFIG_BOOTARGS
 
+#if defined(CONFIG_TQM5200_B)
+#define CONFIG_EXTRA_ENV_SETTINGS					\
+	"netdev=eth0\0"							\
+	"rootpath=/opt/eldk/ppc_6xx\0"					\
+	"ramargs=setenv bootargs root=/dev/ram rw\0"			\
+	"nfsargs=setenv bootargs root=/dev/nfs rw "			\
+		"nfsroot=${serverip}:${rootpath}\0"			\
+	"addip=setenv bootargs ${bootargs} "				\
+		"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}"	\
+		":${hostname}:${netdev}:off panic=1\0"			\
+	"flash_self=run ramargs addip;"					\
+		"bootm ${kernel_addr} ${ramdisk_addr}\0"		\
+	"flash_nfs=run nfsargs addip;"					\
+		"bootm ${kernel_addr}\0"				\
+	"net_nfs=tftp 200000 ${bootfile};run nfsargs addip;bootm\0"	\
+	"bootfile=/tftpboot/tqm5200/uImage\0"				\
+	"load=tftp 200000 ${u-boot}\0"					\
+	"u-boot=/tftpboot/tqm5200/u-boot.bin\0"				\
+	"update=protect off FC000000 FC07FFFF;"				\
+		"erase FC000000 FC07FFFF;"				\
+		"cp.b 200000 FC000000 ${filesize};"			\
+		"protect on FC000000 FC07FFFF\0"			\
+	""
+#else
 #define CONFIG_EXTRA_ENV_SETTINGS					\
 	"netdev=eth0\0"							\
 	"rootpath=/opt/eldk/ppc_6xx\0"					\
@@ -213,6 +237,7 @@ #define CONFIG_EXTRA_ENV_SETTINGS					\
 		"cp.b 200000 FC000000 ${filesize};"			\
 		"protect on FC000000 FC05FFFF\0"			\
 	""
+#endif /* CONFIG_TQM5200_B */
 
 #define CONFIG_BOOTCOMMAND	"run net_nfs"
 
@@ -285,7 +310,7 @@ #endif
  */
 #define CFG_FLASH_BASE		TEXT_BASE /* 0xFC000000 */
 
-/* use CFI flash driver if no module variant is spezified */
+/* use CFI flash driver */
 #define CFG_FLASH_CFI		1	/* Flash is CFI conformant */
 #define CFG_FLASH_CFI_DRIVER	1	/* Use the common driver */
 #define CFG_FLASH_BANKS_LIST	{ CFG_BOOTCS_START }
@@ -297,31 +322,46 @@ #undef CFG_FLASH_USE_BUFFER_WRITE	/* not
 #if !defined(CFG_LOWBOOT)
 #define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x00760000 + 0x00800000)
 #else	/* CFG_LOWBOOT */
+#if defined(CONFIG_TQM5200_B)
+#define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x00080000)
+#else
 #define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x00060000)
+#endif /* CONFIG_TQM5200_B */
 #endif	/* CFG_LOWBOOT */
 #define CFG_MAX_FLASH_BANKS	1	/* max num of flash banks
 					   (= chip selects) */
-#define CFG_FLASH_ERASE_TOUT	240000	/* Flash Erase Timeout (in ms)	*/
-#define CFG_FLASH_WRITE_TOUT	500	/* Flash Write Timeout (in ms)	*/
 
 /* Dynamic MTD partition support */
 #define CONFIG_JFFS2_CMDLINE
 #define MTDIDS_DEFAULT		"nor0=TQM5200-0"
+#if defined(CONFIG_TQM5200_B)
+#define MTDPARTS_DEFAULT	"mtdparts=TQM5200-0:768k(firmware),"	\
+						"1280k(kernel),"	\
+						"2m(initrd),"		\
+						"4m(small-fs),"		\
+						"16m(big-fs),"		\
+						"8m(misc)"
+#else
 #define MTDPARTS_DEFAULT	"mtdparts=TQM5200-0:640k(firmware),"	\
 						"1408k(kernel),"	\
 						"2m(initrd),"		\
 						"4m(small-fs),"		\
 						"16m(big-fs),"		\
 						"8m(misc)"
+#endif /* CONFIG_TQM5200_B */
 
 /*
  * Environment settings
  */
 #define CFG_ENV_IS_IN_FLASH	1
 #define CFG_ENV_SIZE		0x10000
+#if defined(CONFIG_TQM5200_B)
+#define CFG_ENV_SECT_SIZE	0x40000
+#else
 #define CFG_ENV_SECT_SIZE	0x20000
 #define CFG_ENV_ADDR_REDUND	(CFG_ENV_ADDR + CFG_ENV_SECT_SIZE)
-#define	CFG_ENV_SIZE_REDUND	(CFG_ENV_SIZE)
+#define CFG_ENV_SIZE_REDUND	(CFG_ENV_SIZE)
+#endif /* CONFIG_TQM5200_B */
 
 /*
  * Memory map
@@ -349,7 +389,11 @@ #if (CFG_MONITOR_BASE < CFG_FLASH_BASE)
 #   define CFG_RAMBOOT		1
 #endif
 
+#if defined(CONFIG_TQM5200_B)
+#define CFG_MONITOR_LEN		(512 << 10)	/* Reserve 512 kB for Monitor	*/
+#else
 #define CFG_MONITOR_LEN		(384 << 10)	/* Reserve 384 kB for Monitor	*/
+#endif /* CONFIG_TQM5200_B */
 #define CFG_MALLOC_LEN		(256 << 10)	/* Reserve 256 kB for malloc()	*/
 #define CFG_BOOTMAPSZ		(8 << 20)	/* Initial Memory map for Linux */
 
