Add support for WTK FO300 board (TQM5200 based).
diff --git a/CHANGELOG b/CHANGELOG
index e40de36..82be4e3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@
 Changes since U-Boot 1.1.4:
 ======================================================================
 
+* Add support for WTK FO300 board (TQM5200 based).
+
 * Fix TQM834x hang.
 
 * Update for SC520 board.
diff --git a/MAKEALL b/MAKEALL
index 467a9be..48eeaaa 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -29,7 +29,7 @@
 	icecube_5200	lite5200b	mcc200		o2dnt		\
 	pf5200		PM520		TB5200		Total5100	\
 	Total5200	Total5200_Rev2	TQM5200		TQM5200_B	\
-	TQM5200S							\
+	TQM5200S	fo300						\
 "
 
 #########################################################################
diff --git a/Makefile b/Makefile
index 4d579d9..4cc7a48 100644
--- a/Makefile
+++ b/Makefile
@@ -424,8 +424,13 @@
 TQM5200S_HIGHBOOT_config \
 TQM5200_STK100_config \
 cam5200_config \
-MiniFAP_config:	unconfig
+MiniFAP_config \
+fo300_config:	unconfig
 	@ >include/config.h
+	@[ -z "$(findstring fo300,$@)" ] || \
+		{ echo "#define CONFIG_FO300"	>>include/config.h ; \
+		  echo "... TQM5200 on FO300" ; \
+		}
 	@[ -z "$(findstring MiniFAP,$@)" ] || \
 		{ echo "#define CONFIG_MINIFAP"	>>include/config.h ; \
 		  echo "... TQM5200_AC on MiniFAP" ; \
diff --git a/board/tqm5200/cmd_stk52xx.c b/board/tqm5200/cmd_stk52xx.c
index c37d4c6..7af69f2 100755
--- a/board/tqm5200/cmd_stk52xx.c
+++ b/board/tqm5200/cmd_stk52xx.c
@@ -30,8 +30,8 @@
 #include <command.h>
 
 #if (CONFIG_COMMANDS & CFG_CMD_BSP)
-#if defined (CONFIG_STK52XX)
 
+#if defined(CONFIG_STK52XX) || defined(CONFIG_FO300)
 #define DEFAULT_VOL	45
 #define DEFAULT_FREQ	500
 #define DEFAULT_DURATION	200
@@ -537,7 +537,9 @@
 
 	return rcode;
 }
+#endif
 
+#if defined(CONFIG_STK52XX)
 void led_init(void)
 {
 	struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO;
@@ -736,7 +738,9 @@
 
 	return 0;
 }
+#endif
 
+#if defined(CONFIG_STK52XX) || defined(CONFIG_FO300)
 /*
  * return 1 on CAN initialization failure
  * return 0 if no failure
@@ -1106,6 +1110,7 @@
 	return error_status;
 }
 
+#ifndef CONFIG_FO300
 static void sm501_backlight (unsigned int state)
 {
 	if (state == BL_ON) {
@@ -1115,6 +1120,7 @@
 		*(vu_long *)(SM501_MMIO_BASE+SM501_PANEL_DISPLAY_CONTROL) &=
 			~((1 << 26) | (1 << 27));
 }
+#endif
 
 int cmd_fkt(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
@@ -1124,7 +1130,9 @@
 	printf ("Revision 100 of STK52XX not supported!\n");
 	return 1;
 #endif
+#if defined(CONFIG_STK52XX)
 	led_init();
+#endif
 	can_init();
 
 	switch (argc) {
@@ -1152,6 +1160,7 @@
 			else
 				printf ("Error\n");
 			return rcode;
+#ifndef CONFIG_FO300
 		} else if (strncmp (argv[1], "backlight", 4) == 0) {
 			if (strncmp (argv[2], "on", 2) == 0) {
 				sm501_backlight (BL_ON);
@@ -1161,14 +1170,17 @@
 				sm501_backlight (BL_OFF);
 				return 0;
 			}
+#endif
 		}
 		break;
 
+#if defined(CONFIG_STK52XX)
 	case 4:
 		if (strcmp (argv[1], "led") == 0) {
 			return (do_led (argv));
 		}
 		break;
+#endif
 
 	default:
 		break;
@@ -1204,7 +1216,9 @@
 	"[channel]\n"
 	"    - play short beep on \"l\"eft or \"r\"ight channel\n"
 );
+#endif /* CONFIG_STK52XX  || CONFIG_FO300 */
 
+#if defined(CONFIG_STK52XX)
 U_BOOT_CMD(
 	fkt ,	4,	1,	cmd_fkt,
 	"fkt     - Function test routines\n",
@@ -1217,5 +1231,14 @@
 	"fkt backlight on/off\n"
 	"     - switch backlight on or off\n"
 );
-#endif /* CONFIG_STK52XX */
+#elif defined(CONFIG_FO300)
+U_BOOT_CMD(
+	fkt ,	3,	1,	cmd_fkt,
+	"fkt     - Function test routines\n",
+	"fkt can\n"
+	"     - loopback plug for X16/X29 required\n"
+	"fkt rs232 number\n"
+	"     - loopback plug(s) for X21/X22 required\n"
+);
+#endif
 #endif /* CFG_CMD_BSP */
diff --git a/board/tqm5200/tqm5200.c b/board/tqm5200/tqm5200.c
index d6f7737..0026e08 100644
--- a/board/tqm5200/tqm5200.c
+++ b/board/tqm5200/tqm5200.c
@@ -290,6 +290,8 @@
 # define CARRIER_NAME	"TB5200"
 #elif defined(CONFIG_CAM5200)
 # define CARRIER_NAME	"Cam5200"
+#elif defined(CONFIG_FO300)
+# define CARRIER_NAME	"FO300"
 #else
 # error "Unknown carrier board"
 #endif
@@ -541,7 +543,11 @@
 
 #ifdef CONFIG_VIDEO_SM501
 
+#ifdef CONFIG_FO300
+#define DISPLAY_WIDTH   800
+#else
 #define DISPLAY_WIDTH   640
+#endif
 #define DISPLAY_HEIGHT  480
 
 #ifdef CONFIG_VIDEO_SM501_8BPP
@@ -571,6 +577,28 @@
 	{0x80218, 0x000201e9},
 	{0x80200, 0x00013306},
 #else  /* panel + CRT */
+#ifdef CONFIG_FO300
+	{0x00004, 0x0},
+	{0x00048, 0x00021807},
+	{0x0004C, 0x301a0a01},
+	{0x00054, 0x1},
+	{0x00040, 0x00021807},
+	{0x00044, 0x091a0a01},
+	{0x00054, 0x0},
+	{0x80000, 0x0f013106},
+	{0x80004, 0xc428bb17},
+	{0x8000C, 0x00000000},
+	{0x80010, 0x0C800C80},
+	{0x80014, 0x03200000},
+	{0x80018, 0x01e00000},
+	{0x8001C, 0x00000000},
+	{0x80020, 0x01e00320},
+	{0x80024, 0x042a031f},
+	{0x80028, 0x0086034a},
+	{0x8002C, 0x020c01df},
+	{0x80030, 0x000201ea},
+	{0x80200, 0x00010000},
+#else
 	{0x00004, 0x0},
 	{0x00048, 0x00021807},
 	{0x0004C, 0x091a0a01},
@@ -591,6 +619,7 @@
 	{0x8002C, 0x020c01df},
 	{0x80030, 0x000201e9},
 	{0x80200, 0x00010000},
+#endif /* #ifdef CONFIG_FO300 */
 #endif
 	{0, 0}
 };
@@ -604,7 +633,7 @@
 {
 	if (line_number == 1) {
 	strcpy (info, " Board: TQM5200 (TQ-Components GmbH)");
-#if defined (CONFIG_STK52XX) || defined (CONFIG_TB5200)
+#if defined (CONFIG_STK52XX) || defined (CONFIG_TB5200) || defined(CONFIG_FO300)
 	} else if (line_number == 2) {
 #if defined (CONFIG_STK52XX)
 		strcpy (info, "        on a STK52xx carrier board");
@@ -612,6 +641,9 @@
 #if defined (CONFIG_TB5200)
 		strcpy (info, "        on a TB5200 carrier board");
 #endif
+#if defined (CONFIG_FO300)
+		strcpy (info, "        on a FO300 carrier board");
+#endif
 #endif
 	}
 	else {
@@ -697,3 +729,33 @@
 }
 
 #endif /* CONFIG_VIDEO_SM501 */
+
+
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+#ifdef CONFIG_FO300
+int board_early_init_f (void)
+{
+	vu_long timer3_status;
+	DECLARE_GLOBAL_DATA_PTR;
+
+	/* Configure GPT3 as GPIO input */
+	*(vu_long *)MPC5XXX_GPT3_ENABLE = 0x00000004;
+
+	/* Read in TIMER_3 pin status */
+	timer3_status = *(vu_long *)MPC5XXX_GPT3_STATUS;
+	
+#ifdef FO300_SILENT_CONSOLE_WHEN_S1_CLOSED
+	/* Force silent console mode if S1 switch
+	 * is in closed position (TIMER_3 pin status is LOW). */
+	if (MPC5XXX_GPT_GPIO_PIN(timer3_status) == 0)
+#else
+	/* Force silent console mode if S1 switch
+	 * is in open position (TIMER_3 pin status is HIGH). */
+	if (MPC5XXX_GPT_GPIO_PIN(timer3_status) == 1)
+#endif
+		gd->flags |= GD_FLG_SILENT;
+
+	return 0;
+}
+#endif
+#endif
diff --git a/include/configs/TQM5200.h b/include/configs/TQM5200.h
index be83b67..f157d42 100644
--- a/include/configs/TQM5200.h
+++ b/include/configs/TQM5200.h
@@ -37,7 +37,8 @@
 #define CONFIG_TQM5200		1	/* ... on TQM5200 module		*/
 #undef CONFIG_TQM5200_REV100		/*  define for revision 100 modules	*/
 
-#ifndef CONFIG_CAM5200			/* On a Cameron board or ...		*/
+/* On a Cameron board or on a FO300 board or ...				*/
+#if !defined(CONFIG_CAM5200) && !defined(CONFIG_FO300)
 #define CONFIG_STK52XX		1	/* ... on a STK52XX board		*/
 #endif
 
@@ -58,6 +59,20 @@
 #define CONFIG_BAUDRATE		115200	/* ... at 115200 bps			*/
 #define CFG_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200, 230400 }
 
+#ifdef CONFIG_FO300
+#define CFG_DEVICE_NULLDEV		1	/* enable null device */
+#define CONFIG_SILENT_CONSOLE		1	/* enable silent startup */
+#define CONFIG_BOARD_EARLY_INIT_F	1	/* used to detect S1 switch position */
+
+#if 0
+#define FO300_SILENT_CONSOLE_WHEN_S1_CLOSED	1	/* silent console on PSC1 when S1 */
+							/* switch is closed */
+#endif
+
+#undef FO300_SILENT_CONSOLE_WHEN_S1_CLOSED		/* silent console on PSC1 when S1 */
+							/* switch is open */
+#endif
+
 #ifdef CONFIG_STK52XX
 #define CONFIG_PS2KBD			/* AT-PS/2 Keyboard		*/
 #define CONFIG_PS2MULT			/* .. on PS/2 Multiplexer	*/
@@ -105,12 +120,18 @@
 #define CONFIG_VIDEO_SM501_32BPP
 #define CONFIG_CFB_CONSOLE
 #define CONFIG_VIDEO_LOGO
-#define CONFIG_VGA_AS_SINGLE_DEVICE
+
+#ifndef CONFIG_FO300
 #define CONFIG_CONSOLE_EXTRA_INFO
+#else
+#define CONFIG_VIDEO_BMP_LOGO
+#endif
+
+#define CONFIG_VGA_AS_SINGLE_DEVICE
 #define CONFIG_VIDEO_SW_CURSOR
 #define CONFIG_SPLASH_SCREEN
 #define CFG_CONSOLE_IS_IN_ENV
-#endif
+#endif /* #ifndef CONFIG_TQM5200S */
 
 #ifdef CONFIG_VIDEO
 #define ADD_BMP_CMD		CFG_CMD_BMP
@@ -124,7 +145,7 @@
 #define CONFIG_ISO_PARTITION
 
 /* USB */
-#ifdef CONFIG_STK52XX
+#if defined(CONFIG_STK52XX) || defined(CONFIG_FO300)
 #define CONFIG_USB_OHCI
 #define ADD_USB_CMD		CFG_CMD_USB | CFG_CMD_FAT
 #define CONFIG_USB_STORAGE
@@ -148,7 +169,7 @@
 #endif
 
 /* IDE */
-#if defined (CONFIG_MINIFAP) || defined (CONFIG_STK52XX)
+#if defined (CONFIG_MINIFAP) || defined (CONFIG_STK52XX) || defined(CONFIG_FO300)
 #define ADD_IDE_CMD		(CFG_CMD_IDE | CFG_CMD_FAT | CFG_CMD_EXT2)
 #else
 #define ADD_IDE_CMD		0
@@ -224,6 +245,12 @@
 		"erase FC000000 FC03FFFF;"				\
 		"cp.b 200000 FC000000 ${filesize};"			\
 		"protect on FC000000 FC03FFFF\0"
+#elif defined (CONFIG_FO300)
+#   define ENV_UPDT							\
+	"update=protect off FC000000 FC05FFFF;"				\
+		"erase FC000000 FC05FFFF;"				\
+		"cp.b 200000 FC000000 ${filesize};"			\
+		"protect on FC000000 FC05FFFF\0"
 #else
 # error "Unknown Carrier Board"
 #endif	/* CONFIG_STK52XX */
@@ -378,6 +405,13 @@
 						"2m(initrd),"		\
 						"8m(misc),"		\
 						"16m(big-fs)"
+#elif defined (CONFIG_FO300)
+#   define MTDPARTS_DEFAULT	"mtdparts=TQM5200-0:640k(firmware),"	\
+						"1408k(kernel),"	\
+						"2m(initrd),"		\
+						"4m(small-fs),"		\
+						"8m(misc),"		\
+						"16m(big-fs)"
 #else
 # error "Unknown Carrier Board"
 #endif	/* CONFIG_STK52XX */
@@ -450,15 +484,18 @@
  * use ALT CAN position: Bits 2-3 (mask: 0x30000000):
  *	00 -> No Alternatives, CAN1/2 on PSC2 according to PSC2 setting.
  *	01 -> CAN1 on I2C1, CAN2 on Tmr0/1.
- *	      Use for REV200 STK52XX boards. Do not use with REV100 modules
- *	      (because, there I2C1 is used as I2C bus)
+ *	      Use for REV200 STK52XX boards and FO300 boards. Do not use
+ *	      with REV100 modules (because, there I2C1 is used as I2C bus)
  * use PSC1 as UART: Bits 28-31 (mask: 0x00000007): 0100
  * use PSC2 as CAN: Bits 25:27 (mask: 0x00000030)
  *	000 -> All PSC2 pins are GIOPs
  *	001 -> CAN1/2 on PSC2 pins
  *	       Use for REV100 STK52xx boards
+ *	01x -> Use AC97
+ * use PSC3: Bits 20-23 (mask: 0x00000f00)
+ *	1100 -> UART/SPI (on FO300 board)
  * use PSC6:
- *   on STK52xx:
+ *   on STK52xx and FO300:
  *	use as UART. Pins PSC6_0 to PSC6_3 are used.
  *	Bits 9:11 (mask: 0x00700000):
  *	   101 -> PSC6 : Extended POST test is not available
@@ -480,6 +517,8 @@
 #   define CFG_GPS_PORT_CONFIG	0x91500004
 #  endif
 # endif
+#elif defined (CONFIG_FO300)
+# define CFG_GPS_PORT_CONFIG	0x91502c24
 #else  /* TMQ5200 Inbetriebnahme-Board */
 # define CFG_GPS_PORT_CONFIG	0x81000004
 #endif
diff --git a/include/mpc5xxx.h b/include/mpc5xxx.h
index 50a6ac1..daa4d5f 100644
--- a/include/mpc5xxx.h
+++ b/include/mpc5xxx.h
@@ -235,20 +235,30 @@
 /* General Purpose Timers registers */
 #define MPC5XXX_GPT0_ENABLE		(MPC5XXX_GPT + 0x0)
 #define MPC5XXX_GPT0_COUNTER		(MPC5XXX_GPT + 0x4)
+#define MPC5XXX_GPT0_STATUS		(MPC5XXX_GPT + 0x0C)
 #define MPC5XXX_GPT1_ENABLE		(MPC5XXX_GPT + 0x10)
 #define MPC5XXX_GPT1_COUNTER		(MPC5XXX_GPT + 0x14)
+#define MPC5XXX_GPT1_STATUS		(MPC5XXX_GPT + 0x1C)
 #define MPC5XXX_GPT2_ENABLE		(MPC5XXX_GPT + 0x20)
 #define MPC5XXX_GPT2_COUNTER		(MPC5XXX_GPT + 0x24)
+#define MPC5XXX_GPT2_STATUS		(MPC5XXX_GPT + 0x2C)
 #define MPC5XXX_GPT3_ENABLE		(MPC5XXX_GPT + 0x30)
 #define MPC5XXX_GPT3_COUNTER		(MPC5XXX_GPT + 0x34)
+#define MPC5XXX_GPT3_STATUS		(MPC5XXX_GPT + 0x3C)
 #define MPC5XXX_GPT4_ENABLE		(MPC5XXX_GPT + 0x40)
 #define MPC5XXX_GPT4_COUNTER		(MPC5XXX_GPT + 0x44)
+#define MPC5XXX_GPT4_STATUS		(MPC5XXX_GPT + 0x4C)
 #define MPC5XXX_GPT5_ENABLE		(MPC5XXX_GPT + 0x50)
+#define MPC5XXX_GPT5_STATUS		(MPC5XXX_GPT + 0x5C)
 #define MPC5XXX_GPT5_COUNTER		(MPC5XXX_GPT + 0x54)
 #define MPC5XXX_GPT6_ENABLE		(MPC5XXX_GPT + 0x60)
 #define MPC5XXX_GPT6_COUNTER		(MPC5XXX_GPT + 0x64)
+#define MPC5XXX_GPT6_STATUS		(MPC5XXX_GPT + 0x6C)
 #define MPC5XXX_GPT7_ENABLE		(MPC5XXX_GPT + 0x70)
 #define MPC5XXX_GPT7_COUNTER		(MPC5XXX_GPT + 0x74)
+#define MPC5XXX_GPT7_STATUS		(MPC5XXX_GPT + 0x7C)
+
+#define MPC5XXX_GPT_GPIO_PIN(status)	((0x00000100 & (status)) >> 8)
 
 #define MPC5XXX_GPT7_PWMCFG		(MPC5XXX_GPT + 0x78)