3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 * NOR and NAND boot options change bytes 6, 7, 8, 9, 11. The
32 * values are independent of the rest of the clock settings.
35 #define NAND_COMPATIBLE 0x01
36 #define NOR_COMPATIBLE 0x02
38 #define I2C_EEPROM_ADDR 0x52
40 static char *config_labels[] = {
41 "CPU: 600 PLB: 200 OPB: 100 EBC: 100",
42 "CPU: 800 PLB: 200 OPB: 100 EBC: 100",
46 static u8 boot_configs[][17] = {
49 0x86, 0x80, 0xce, 0x1f, 0x79, 0x80, 0x00, 0xa0, 0x40, 0x08,
50 0x23, 0x50, 0x0d, 0x95, 0x00, 0x00
54 0x86, 0x80, 0xba, 0x14, 0x99, 0x80, 0x00, 0xa0, 0x40, 0x08,
55 0x23, 0x50, 0x0d, 0x95, 0x00, 0x00
59 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
64 * Bytes 6,8,9,11 change for NAND boot
66 static u8 nand_boot[] = {
67 0xd0, 0xa0, 0x68, 0x58
70 static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
73 int x, y, nbytes, selcfg;
74 extern char console_buffer[];
77 printf("Usage:\n%s\n", cmdtp->usage);
81 if ((strcmp(argv[1], "nor") != 0) &&
82 (strcmp(argv[1], "nand") != 0)) {
83 printf("Unsupported boot-device - only nor|nand support\n");
87 /* set the nand flag based on provided input */
88 if ((strcmp(argv[1], "nand") == 0))
93 printf("Available configurations: \n\n");
96 for(x = 0, y = 0; boot_configs[x][0] != 0; x++) {
97 /* filter on nand compatible */
98 if (boot_configs[x][0] & NAND_COMPATIBLE) {
99 printf(" %d - %s\n", (y+1), config_labels[x]);
104 for(x = 0, y = 0; boot_configs[x][0] != 0; x++) {
105 /* filter on nor compatible */
106 if (boot_configs[x][0] & NOR_COMPATIBLE) {
107 printf(" %d - %s\n", (y+1), config_labels[x]);
114 nbytes = readline(" Selection [1-x / quit]: ");
117 if (strcmp(console_buffer, "quit") == 0)
119 selcfg = simple_strtol(console_buffer, NULL, 10);
120 if ((selcfg < 1) || (selcfg > y))
123 } while (nbytes == 0);
128 for (x = 0; boot_configs[x][0] != 0; x++) {
130 if (boot_configs[x][0] & NAND_COMPATIBLE) {
137 if (boot_configs[x][0] & NOR_COMPATIBLE) {
146 buf = &boot_configs[x][1];
149 buf[6] = nand_boot[0];
150 buf[8] = nand_boot[1];
151 buf[9] = nand_boot[2];
152 buf[11] = nand_boot[3];
155 if (i2c_write(I2C_EEPROM_ADDR, 0, 1, buf, 16) != 0)
156 printf("Error writing to EEPROM at address 0x%x\n", I2C_EEPROM_ADDR);
157 udelay(CFG_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
160 printf("Please power-cycle the board for the changes to take effect\n");
166 bootstrap, 2, 0, do_bootstrap,
167 "bootstrap - program the I2C bootstrap EEPROM\n",
168 "<nand|nor> - strap to boot from NAND or NOR flash\n"