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 static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
35 extern char console_buffer[];
43 printf ("Usage:\n%s\n", cmdtp->usage);
47 if (strcmp(argv[2], "prom0") == 0)
48 chip = IIC0_BOOTPROM_ADDR;
50 chip = IIC0_ALT_BOOTPROM_ADDR;
53 printf("enter sys clock frequency 33 or 66 Mhz or quit to abort\n");
54 nbytes = readline (" ? ");
56 if (strcmp(console_buffer, "quit") == 0)
59 if ((strcmp(console_buffer, "33") != 0) &
60 (strcmp(console_buffer, "66") != 0))
63 strcpy(sysClock, console_buffer);
65 } while (nbytes == 0);
68 if (strcmp(sysClock, "66") == 0) {
69 printf("enter cpu clock frequency 400, 533 Mhz or quit to abort\n");
72 printf("enter cpu clock frequency 400, 500, 533, 667 Mhz or quit to abort\n");
74 printf("enter cpu clock frequency 400, 500, 533 Mhz or quit to abort\n");
77 nbytes = readline (" ? ");
79 if (strcmp(console_buffer, "quit") == 0)
82 if (strcmp(sysClock, "66") == 0) {
83 if ((strcmp(console_buffer, "400") != 0) &
84 (strcmp(console_buffer, "533") != 0)
86 & (strcmp(console_buffer, "667") != 0)
92 if ((strcmp(console_buffer, "400") != 0) &
93 (strcmp(console_buffer, "500") != 0) &
94 (strcmp(console_buffer, "533") != 0)
96 & (strcmp(console_buffer, "667") != 0)
103 strcpy(cpuClock, console_buffer);
105 } while (nbytes == 0);
107 if (strcmp(cpuClock, "500") == 0)
108 strcpy(plbClock, "166");
109 else if (strcmp(cpuClock, "533") == 0)
110 strcpy(plbClock, "133");
113 if (strcmp(cpuClock, "400") == 0)
114 printf("enter plb clock frequency 100, 133 Mhz or quit to abort\n");
117 if (strcmp(cpuClock, "667") == 0)
118 printf("enter plb clock frequency 133, 166 Mhz or quit to abort\n");
121 nbytes = readline (" ? ");
123 if (strcmp(console_buffer, "quit") == 0)
126 if (strcmp(cpuClock, "400") == 0) {
127 if ((strcmp(console_buffer, "100") != 0) &
128 (strcmp(console_buffer, "133") != 0))
132 if (strcmp(cpuClock, "667") == 0) {
133 if ((strcmp(console_buffer, "133") != 0) &
134 (strcmp(console_buffer, "166") != 0))
138 strcpy(plbClock, console_buffer);
140 } while (nbytes == 0);
144 printf("enter Pci-X clock frequency 33, 66, 100 or 133 Mhz or quit to abort\n");
145 nbytes = readline (" ? ");
147 if (strcmp(console_buffer, "quit") == 0)
150 if ((strcmp(console_buffer, "33") != 0) &
151 (strcmp(console_buffer, "66") != 0) &
152 (strcmp(console_buffer, "100") != 0) &
153 (strcmp(console_buffer, "133") != 0)) {
156 strcpy(pcixClock, console_buffer);
158 } while (nbytes == 0);
160 printf("\nsys clk = %sMhz\n", sysClock);
161 printf("cpu clk = %sMhz\n", cpuClock);
162 printf("plb clk = %sMhz\n", plbClock);
163 printf("Pci-X clk = %sMhz\n", pcixClock);
166 printf("\npress [y] to write I2C bootstrap \n");
167 printf("or [n] to abort. \n");
168 printf("Don't forget to set board switches \n");
169 printf("according to your choice before re-starting \n");
170 printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n");
172 nbytes = readline (" ? ");
173 if (strcmp(console_buffer, "n") == 0)
176 } while (nbytes == 0);
178 if (strcmp(sysClock, "33") == 0) {
179 if ((strcmp(cpuClock, "400") == 0) &
180 (strcmp(plbClock, "100") == 0))
183 if ((strcmp(cpuClock, "400") == 0) &
184 (strcmp(plbClock, "133") == 0))
187 if ((strcmp(cpuClock, "500") == 0))
190 if ((strcmp(cpuClock, "533") == 0))
194 if ((strcmp(cpuClock, "667") == 0) &
195 (strcmp(plbClock, "133") == 0))
198 if ((strcmp(cpuClock, "667") == 0) &
199 (strcmp(plbClock, "166") == 0))
204 if (strcmp(sysClock, "66") == 0) {
205 if ((strcmp(cpuClock, "400") == 0) &
206 (strcmp(plbClock, "100") == 0))
209 if ((strcmp(cpuClock, "400") == 0) &
210 (strcmp(plbClock, "133") == 0))
213 if ((strcmp(cpuClock, "533") == 0))
217 if ((strcmp(cpuClock, "667") == 0) &
218 (strcmp(plbClock, "133") == 0))
221 if ((strcmp(cpuClock, "667") == 0) &
222 (strcmp(plbClock, "166") == 0))
229 printf(" pin strap0 to write in i2c = %x\n", data);
232 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
233 printf("Error writing strap0 in %s\n", argv[2]);
235 if (strcmp(pcixClock, "33") == 0)
238 if (strcmp(pcixClock, "66") == 0)
241 if (strcmp(pcixClock, "100") == 0)
244 if (strcmp(pcixClock, "133") == 0)
247 if (strcmp(plbClock, "166") == 0)
253 printf(" pin strap1 to write in i2c = %x\n", data);
257 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
258 printf("Error writing strap1 in %s\n", argv[2]);
264 bootstrap, 3, 1, do_bootstrap,
265 "bootstrap - program the serial device strap\n",
266 "wrclk [prom0|prom1] - program the serial device strap\n"