ppc4xx: Katmai: Add chip_config command

This patch removes the Katmai "bootstrap" command and replaces it
with the now common command "chip_config".

Signed-off-by: Stefan Roese <sr@denx.de>
diff --git a/board/amcc/katmai/Makefile b/board/amcc/katmai/Makefile
index 318016d..168bab5 100644
--- a/board/amcc/katmai/Makefile
+++ b/board/amcc/katmai/Makefile
@@ -25,9 +25,11 @@
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	= $(BOARD).o cmd_katmai.o
+COBJS-y	:= $(BOARD).o
+COBJS-$(CONFIG_CMD_CHIP_CONFIG) += chip_config.o
 SOBJS	= init.o
 
+COBJS   := $(COBJS-y)
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
 SOBJS	:= $(addprefix $(obj),$(SOBJS))
diff --git a/board/amcc/katmai/chip_config.c b/board/amcc/katmai/chip_config.c
new file mode 100644
index 0000000..efaf378
--- /dev/null
+++ b/board/amcc/katmai/chip_config.c
@@ -0,0 +1,55 @@
+/*
+ * (C) Copyright 2009
+ * Stefan Roese, DENX Software Engineering, sr@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 <common.h>
+#include <asm/ppc4xx_config.h>
+
+struct ppc4xx_config ppc4xx_config_val[] = {
+	{
+		"400-133","CPU: 400 PLB: 133 OPB:  66 EBC:  66",
+		{ 0x86, 0x78, 0xc2, 0xc6, 0x05, 0xa5, 0x04, 0xe1 }
+	},
+	{
+		"500-166","CPU: 500 PLB: 166 OPB:  83 EBC:  83",
+		{ 0x87, 0x78, 0xf2, 0xc6, 0x05, 0xa5, 0x04, 0xe1 }
+	},
+	{
+		"533-133","CPU: 533 PLB: 133 OPB:  66 EBC:  66",
+		{ 0x87, 0x79, 0x02, 0x52, 0x05, 0xa5, 0x04, 0xe1 }
+	},
+	{
+		"667-133","CPU: 667 PLB: 133 OPB:  66 EBC:  66",
+		{ 0x87, 0x79, 0x42, 0x56, 0x05, 0xa5, 0x04, 0xe1 }
+	},
+	{
+		"667-166","CPU: 667 PLB: 166 OPB:  83 EBC:  83",
+		{ 0x87, 0x79, 0x42, 0x06, 0x05, 0xa5, 0x04, 0xe1 }
+	},
+	{
+		"800-160","CPU: 800 PLB: 160 OPB:  53 EBC:  17",
+		{ 0x86, 0x79, 0x81, 0xa7, 0x07, 0xa5, 0x04, 0xe1 }
+	},
+};
+
+int ppc4xx_config_count = ARRAY_SIZE(ppc4xx_config_val);
diff --git a/board/amcc/katmai/cmd_katmai.c b/board/amcc/katmai/cmd_katmai.c
deleted file mode 100644
index 335d30c..0000000
--- a/board/amcc/katmai/cmd_katmai.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * (C) Copyright 2007
- * Stefan Roese, DENX Software Engineering, sr@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 <common.h>
-#include <command.h>
-#include <i2c.h>
-#include <asm/byteorder.h>
-
-#define	CONFIG_STRESS		/* enable 667 MHz CPU freq selection */
-#define DEBUG
-
-static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
-	uchar	chip;
-	ulong	data;
-	int	nbytes;
-	extern char console_buffer[];
-
-	char sysClock[4];
-	char cpuClock[4];
-	char plbClock[4];
-	char pcixClock[4];
-
-	if (argc < 3) {
-		cmd_usage(cmdtp);
-		return 1;
-	}
-
-	if (strcmp(argv[2], "prom0") == 0)
-		chip = IIC0_BOOTPROM_ADDR;
-	else
-		chip = IIC0_ALT_BOOTPROM_ADDR;
-
-	/* on Katmai SysClk is always 33MHz */
-	strcpy(sysClock, "33");
-
-	do {
-#ifdef	CONFIG_STRESS
-		printf("enter cpu clock frequency 400, 500, 533, 667 MHz or quit to abort\n");
-#else
-		printf("enter cpu clock frequency 400, 500, 533 MHz or quit to abort\n");
-#endif
-		nbytes = readline (" ? ");
-
-		if (strcmp(console_buffer, "quit") == 0)
-			return 0;
-
-		if ((strcmp(console_buffer, "400") != 0) &&
-		    (strcmp(console_buffer, "500") != 0) &&
-		    (strcmp(console_buffer, "533") != 0)
-#ifdef	CONFIG_STRESS
-		    && (strcmp(console_buffer, "667") != 0)
-#endif
-			) {
-			nbytes = 0;
-		}
-
-		strcpy(cpuClock, console_buffer);
-
-	} while (nbytes == 0);
-
-	if (strcmp(cpuClock, "500") == 0)
-		strcpy(plbClock, "166");
-	else if (strcmp(cpuClock, "533") == 0)
-		strcpy(plbClock, "133");
-	else {
-		do {
-			if (strcmp(cpuClock, "400") == 0)
-				printf("enter plb clock frequency 100, 133 MHz or quit to abort\n");
-
-#ifdef	CONFIG_STRESS
-			if (strcmp(cpuClock, "667") == 0)
-				printf("enter plb clock frequency 133, 166 MHz or quit to abort\n");
-
-#endif
-			nbytes = readline (" ? ");
-
-			if (strcmp(console_buffer, "quit") == 0)
-				return 0;
-
-			if (strcmp(cpuClock, "400") == 0) {
-				if ((strcmp(console_buffer, "100") != 0) &&
-				    (strcmp(console_buffer, "133") != 0))
-					nbytes = 0;
-			}
-#ifdef	CONFIG_STRESS
-			if (strcmp(cpuClock, "667") == 0) {
-				if ((strcmp(console_buffer, "133") != 0) &&
-				    (strcmp(console_buffer, "166") != 0))
-					nbytes = 0;
-			}
-#endif
-			strcpy(plbClock, console_buffer);
-
-		} while (nbytes == 0);
-	}
-
-	do {
-		printf("enter Pci-X clock frequency 33, 66, 100 or 133 MHz or quit to abort\n");
-		nbytes = readline (" ? ");
-
-		if (strcmp(console_buffer, "quit") == 0)
-			return 0;
-
-		if ((strcmp(console_buffer, "33") != 0) &&
-		    (strcmp(console_buffer, "66") != 0) &&
-		    (strcmp(console_buffer, "100") != 0) &&
-		    (strcmp(console_buffer, "133") != 0)) {
-			nbytes = 0;
-		}
-		strcpy(pcixClock, console_buffer);
-
-	} while (nbytes == 0);
-
-	printf("\nsys clk   = %s MHz\n", sysClock);
-	printf("cpu clk   = %s MHz\n", cpuClock);
-	printf("plb clk   = %s MHz\n", plbClock);
-	printf("Pci-X clk = %s MHz\n", pcixClock);
-
-	do {
-		printf("\npress [y] to write I2C bootstrap \n");
-		printf("or [n] to abort.  \n");
-		printf("Don't forget to set board switches \n");
-		printf("according to your choice before re-starting \n");
-		printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n");
-
-		nbytes = readline (" ? ");
-		if (strcmp(console_buffer, "n") == 0)
-			return 0;
-
-	} while (nbytes == 0);
-
-	if (strcmp(sysClock, "33") == 0) {
-		if ((strcmp(cpuClock, "400") == 0) &&
-		    (strcmp(plbClock, "100") == 0))
-			data = 0x8678c206;
-
-		if ((strcmp(cpuClock, "400") == 0) &&
-		    (strcmp(plbClock, "133") == 0))
-			data = 0x8678c2c6;
-
-		if ((strcmp(cpuClock, "500") == 0))
-			data = 0x8778f2c6;
-
-		if ((strcmp(cpuClock, "533") == 0))
-			data = 0x87790252;
-#ifdef	CONFIG_STRESS
-		if ((strcmp(cpuClock, "667") == 0) &&
-		    (strcmp(plbClock, "133") == 0))
-			data = 0x87794256;
-
-		if ((strcmp(cpuClock, "667") == 0) &&
-		    (strcmp(plbClock, "166") == 0))
-			data = 0x87794206;
-#endif
-	}
-#ifdef	DEBUG
-	printf(" pin strap0 to write in i2c  = %lx\n", data);
-#endif	/* DEBUG */
-
-	if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
-		printf("Error writing strap0 in %s\n", argv[2]);
-
-	if (strcmp(pcixClock, "33") == 0)
-		data = 0x000007E1;
-
-	if (strcmp(pcixClock, "66") == 0)
-		data = 0x000006E1;
-
-	if (strcmp(pcixClock, "100") == 0)
-		data = 0x000005E1;
-
-	if (strcmp(pcixClock, "133") == 0)
-		data = 0x000004E1;
-
-	if (strcmp(plbClock, "166") == 0)
-/*		data |= 0x05950000; */	/* this set's DDR2 clock == PLB clock */
-		data |= 0x05A50000;	/* this set's DDR2 clock == 2 * PLB clock */
-	else
-		data |= 0x05A50000;
-
-#ifdef	DEBUG
-	printf(" pin strap1 to write in i2c  = %lx\n", data);
-#endif	/* DEBUG */
-
-	udelay(1000);
-	if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
-		printf("Error writing strap1 in %s\n", argv[2]);
-
-	return 0;
-}
-
-U_BOOT_CMD(
-	bootstrap,	3,	1,	do_bootstrap,
-	"program the serial device strap",
-	"wrclk [prom0|prom1] - program the serial device strap"
-);
diff --git a/include/configs/katmai.h b/include/configs/katmai.h
index 3840267..c013ac4 100644
--- a/include/configs/katmai.h
+++ b/include/configs/katmai.h
@@ -140,6 +140,11 @@
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10
 
+/* I2C bootstrap EEPROM */
+#define CONFIG_4xx_CONFIG_I2C_EEPROM_ADDR	0x50
+#define CONFIG_4xx_CONFIG_I2C_EEPROM_OFFSET	0
+#define CONFIG_4xx_CONFIG_BLOCKSIZE		8
+
 /* I2C RTC */
 #define CONFIG_RTC_M41T11	1
 #define CONFIG_SYS_RTC_BUS_NUM		1	/* The I2C bus for RTC		*/
@@ -194,8 +199,10 @@
 /*
  * Commands additional to the ones defined in amcc-common.h
  */
-#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_CHIP_CONFIG
 #define CONFIG_CMD_DATE
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_FAT
 #define CONFIG_CMD_PCI
 #define CONFIG_CMD_SDRAM
 #define CONFIG_CMD_SNTP