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,
28 #include <asm/byteorder.h>
30 #define CONFIG_STRESS /* enable 667 MHz CPU freq selection */
32 static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
37 extern char console_buffer[];
45 printf ("Usage:\n%s\n", cmdtp->usage);
49 if (strcmp(argv[2], "prom0") == 0)
50 chip = IIC0_BOOTPROM_ADDR;
52 chip = IIC0_ALT_BOOTPROM_ADDR;
54 /* on Katmai SysClk is always 33MHz */
55 strcpy(sysClock, "33");
59 printf("enter cpu clock frequency 400, 500, 533, 667 Mhz or quit to abort\n");
61 printf("enter cpu clock frequency 400, 500, 533 Mhz or quit to abort\n");
63 nbytes = readline (" ? ");
65 if (strcmp(console_buffer, "quit") == 0)
68 if ((strcmp(console_buffer, "400") != 0) &&
69 (strcmp(console_buffer, "500") != 0) &&
70 (strcmp(console_buffer, "533") != 0)
72 && (strcmp(console_buffer, "667") != 0)
78 strcpy(cpuClock, console_buffer);
80 } while (nbytes == 0);
82 if (strcmp(cpuClock, "500") == 0)
83 strcpy(plbClock, "166");
84 else if (strcmp(cpuClock, "533") == 0)
85 strcpy(plbClock, "133");
88 if (strcmp(cpuClock, "400") == 0)
89 printf("enter plb clock frequency 100, 133 Mhz or quit to abort\n");
92 if (strcmp(cpuClock, "667") == 0)
93 printf("enter plb clock frequency 133, 166 Mhz or quit to abort\n");
96 nbytes = readline (" ? ");
98 if (strcmp(console_buffer, "quit") == 0)
101 if (strcmp(cpuClock, "400") == 0) {
102 if ((strcmp(console_buffer, "100") != 0) &&
103 (strcmp(console_buffer, "133") != 0))
107 if (strcmp(cpuClock, "667") == 0) {
108 if ((strcmp(console_buffer, "133") != 0) &&
109 (strcmp(console_buffer, "166") != 0))
113 strcpy(plbClock, console_buffer);
115 } while (nbytes == 0);
119 printf("enter Pci-X clock frequency 33, 66, 100 or 133 Mhz or quit to abort\n");
120 nbytes = readline (" ? ");
122 if (strcmp(console_buffer, "quit") == 0)
125 if ((strcmp(console_buffer, "33") != 0) &&
126 (strcmp(console_buffer, "66") != 0) &&
127 (strcmp(console_buffer, "100") != 0) &&
128 (strcmp(console_buffer, "133") != 0)) {
131 strcpy(pcixClock, console_buffer);
133 } while (nbytes == 0);
135 printf("\nsys clk = %sMhz\n", sysClock);
136 printf("cpu clk = %sMhz\n", cpuClock);
137 printf("plb clk = %sMhz\n", plbClock);
138 printf("Pci-X clk = %sMhz\n", pcixClock);
141 printf("\npress [y] to write I2C bootstrap \n");
142 printf("or [n] to abort. \n");
143 printf("Don't forget to set board switches \n");
144 printf("according to your choice before re-starting \n");
145 printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n");
147 nbytes = readline (" ? ");
148 if (strcmp(console_buffer, "n") == 0)
151 } while (nbytes == 0);
153 if (strcmp(sysClock, "33") == 0) {
154 if ((strcmp(cpuClock, "400") == 0) &&
155 (strcmp(plbClock, "100") == 0))
158 if ((strcmp(cpuClock, "400") == 0) &&
159 (strcmp(plbClock, "133") == 0))
162 if ((strcmp(cpuClock, "500") == 0))
165 if ((strcmp(cpuClock, "533") == 0))
168 if ((strcmp(cpuClock, "667") == 0) &&
169 (strcmp(plbClock, "133") == 0))
172 if ((strcmp(cpuClock, "667") == 0) &&
173 (strcmp(plbClock, "166") == 0))
178 printf(" pin strap0 to write in i2c = %x\n", data);
181 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
182 printf("Error writing strap0 in %s\n", argv[2]);
184 if (strcmp(pcixClock, "33") == 0)
187 if (strcmp(pcixClock, "66") == 0)
190 if (strcmp(pcixClock, "100") == 0)
193 if (strcmp(pcixClock, "133") == 0)
196 if (strcmp(plbClock, "166") == 0)
202 printf(" pin strap1 to write in i2c = %x\n", data);
206 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
207 printf("Error writing strap1 in %s\n", argv[2]);
213 bootstrap, 3, 1, do_bootstrap,
214 "bootstrap - program the serial device strap\n",
215 "wrclk [prom0|prom1] - program the serial device strap\n"