3 * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
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,
23 * hacked for evb440spe
30 #include <asm/byteorder.h>
32 extern void print_evb440spe_info(void);
33 static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag,
34 int flag, int argc, char * const argv[]);
36 /* ------------------------------------------------------------------------- */
37 int do_evb440spe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
39 return setBootStrapClock (cmdtp, 1, flag, argc, argv);
42 /* ------------------------------------------------------------------------- */
46 * evb440spe wrclk prom0,prom1
48 static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,
49 int argc, char * const argv[])
61 return cmd_usage(cmdtp);
63 if (strcmp(argv[2], "prom0") == 0)
64 chip = IIC0_BOOTPROM_ADDR;
66 chip = IIC0_ALT_BOOTPROM_ADDR;
69 printf("enter sys clock frequency 33 or 66 MHz or quit to abort\n");
70 nbytes = readline (" ? ");
72 if (strcmp(console_buffer, "quit") == 0)
75 if ((strcmp(console_buffer, "33") != 0) &
76 (strcmp(console_buffer, "66") != 0))
79 strcpy(sysClock, console_buffer);
81 } while (nbytes == 0);
84 if (strcmp(sysClock, "66") == 0) {
85 printf("enter cpu clock frequency 400, 533 MHz or quit to abort\n");
88 printf("enter cpu clock frequency 400, 500, 533, 667 MHz or quit to abort\n");
90 printf("enter cpu clock frequency 400, 500, 533 MHz or quit to abort\n");
93 nbytes = readline (" ? ");
95 if (strcmp(console_buffer, "quit") == 0)
98 if (strcmp(sysClock, "66") == 0) {
99 if ((strcmp(console_buffer, "400") != 0) &
100 (strcmp(console_buffer, "533") != 0)
102 & (strcmp(console_buffer, "667") != 0)
108 if ((strcmp(console_buffer, "400") != 0) &
109 (strcmp(console_buffer, "500") != 0) &
110 (strcmp(console_buffer, "533") != 0)
112 & (strcmp(console_buffer, "667") != 0)
119 strcpy(cpuClock, console_buffer);
121 } while (nbytes == 0);
123 if (strcmp(cpuClock, "500") == 0){
124 strcpy(plbClock, "166");
125 } else if (strcmp(cpuClock, "533") == 0){
126 strcpy(plbClock, "133");
129 if (strcmp(cpuClock, "400") == 0)
130 printf("enter plb clock frequency 100, 133 MHz or quit to abort\n");
133 if (strcmp(cpuClock, "667") == 0)
134 printf("enter plb clock frequency 133, 166 MHz or quit to abort\n");
137 nbytes = readline (" ? ");
139 if (strcmp(console_buffer, "quit") == 0)
142 if (strcmp(cpuClock, "400") == 0) {
143 if ((strcmp(console_buffer, "100") != 0) &
144 (strcmp(console_buffer, "133") != 0))
148 if (strcmp(cpuClock, "667") == 0) {
149 if ((strcmp(console_buffer, "133") != 0) &
150 (strcmp(console_buffer, "166") != 0))
154 strcpy(plbClock, console_buffer);
156 } while (nbytes == 0);
160 printf("enter Pci-X clock frequency 33, 66, 100 or 133 MHz or quit to abort\n");
161 nbytes = readline (" ? ");
163 if (strcmp(console_buffer, "quit") == 0)
166 if ((strcmp(console_buffer, "33") != 0) &
167 (strcmp(console_buffer, "66") != 0) &
168 (strcmp(console_buffer, "100") != 0) &
169 (strcmp(console_buffer, "133") != 0)) {
172 strcpy(pcixClock, console_buffer);
174 } while (nbytes == 0);
176 printf("\nsys clk = %s MHz\n", sysClock);
177 printf("cpu clk = %s MHz\n", cpuClock);
178 printf("plb clk = %s MHz\n", plbClock);
179 printf("Pci-X clk = %s MHz\n", pcixClock);
182 printf("\npress [y] to write I2C bootstrap \n");
183 printf("or [n] to abort. \n");
184 printf("Don't forget to set board switches \n");
185 printf("according to your choice before re-starting \n");
186 printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n");
188 nbytes = readline (" ? ");
189 if (strcmp(console_buffer, "n") == 0)
192 } while (nbytes == 0);
194 if (strcmp(sysClock, "33") == 0) {
195 if ((strcmp(cpuClock, "400") == 0) &
196 (strcmp(plbClock, "100") == 0))
199 if ((strcmp(cpuClock, "400") == 0) &
200 (strcmp(plbClock, "133") == 0))
203 if ((strcmp(cpuClock, "500") == 0))
206 if ((strcmp(cpuClock, "533") == 0))
210 if ((strcmp(cpuClock, "667") == 0) &
211 (strcmp(plbClock, "133") == 0))
214 if ((strcmp(cpuClock, "667") == 0) &
215 (strcmp(plbClock, "166") == 0))
220 if (strcmp(sysClock, "66") == 0) {
221 if ((strcmp(cpuClock, "400") == 0) &
222 (strcmp(plbClock, "100") == 0))
225 if ((strcmp(cpuClock, "400") == 0) &
226 (strcmp(plbClock, "133") == 0))
229 if ((strcmp(cpuClock, "533") == 0))
233 if ((strcmp(cpuClock, "667") == 0) &
234 (strcmp(plbClock, "133") == 0))
237 if ((strcmp(cpuClock, "667") == 0) &
238 (strcmp(plbClock, "166") == 0))
245 printf(" pin strap0 to write in i2c = %x\n", data);
248 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
249 printf("Error writing strap0 in %s\n", argv[2]);
251 if (strcmp(pcixClock, "33") == 0)
254 if (strcmp(pcixClock, "66") == 0)
257 if (strcmp(pcixClock, "100") == 0)
260 if (strcmp(pcixClock, "133") == 0)
263 if (strcmp(plbClock, "166") == 0)
264 data = data | 0x05950000;
266 data = data | 0x05A50000;
269 printf(" pin strap1 to write in i2c = %x\n", data);
273 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
274 printf("Error writing strap1 in %s\n", argv[2]);
280 evb440spe, 3, 1, do_evb440spe,
281 "program the serial device strap",
282 "wrclk [prom0|prom1] - program the serial device strap"