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 *argv[]);
36 /* ------------------------------------------------------------------------- */
37 int do_evb440spe(cmd_tbl_t *cmdtp, int flag, int argc, char *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 *argv[])
54 extern char console_buffer[];
62 printf ("Usage:\n%s\n", cmdtp->usage);
66 if (strcmp(argv[2], "prom0") == 0)
67 chip = IIC0_BOOTPROM_ADDR;
69 chip = IIC0_ALT_BOOTPROM_ADDR;
72 printf("enter sys clock frequency 33 or 66 MHz or quit to abort\n");
73 nbytes = readline (" ? ");
75 if (strcmp(console_buffer, "quit") == 0)
78 if ((strcmp(console_buffer, "33") != 0) &
79 (strcmp(console_buffer, "66") != 0))
82 strcpy(sysClock, console_buffer);
84 } while (nbytes == 0);
87 if (strcmp(sysClock, "66") == 0) {
88 printf("enter cpu clock frequency 400, 533 MHz or quit to abort\n");
91 printf("enter cpu clock frequency 400, 500, 533, 667 MHz or quit to abort\n");
93 printf("enter cpu clock frequency 400, 500, 533 MHz or quit to abort\n");
96 nbytes = readline (" ? ");
98 if (strcmp(console_buffer, "quit") == 0)
101 if (strcmp(sysClock, "66") == 0) {
102 if ((strcmp(console_buffer, "400") != 0) &
103 (strcmp(console_buffer, "533") != 0)
105 & (strcmp(console_buffer, "667") != 0)
111 if ((strcmp(console_buffer, "400") != 0) &
112 (strcmp(console_buffer, "500") != 0) &
113 (strcmp(console_buffer, "533") != 0)
115 & (strcmp(console_buffer, "667") != 0)
122 strcpy(cpuClock, console_buffer);
124 } while (nbytes == 0);
126 if (strcmp(cpuClock, "500") == 0){
127 strcpy(plbClock, "166");
128 } else if (strcmp(cpuClock, "533") == 0){
129 strcpy(plbClock, "133");
132 if (strcmp(cpuClock, "400") == 0)
133 printf("enter plb clock frequency 100, 133 MHz or quit to abort\n");
136 if (strcmp(cpuClock, "667") == 0)
137 printf("enter plb clock frequency 133, 166 MHz or quit to abort\n");
140 nbytes = readline (" ? ");
142 if (strcmp(console_buffer, "quit") == 0)
145 if (strcmp(cpuClock, "400") == 0) {
146 if ((strcmp(console_buffer, "100") != 0) &
147 (strcmp(console_buffer, "133") != 0))
151 if (strcmp(cpuClock, "667") == 0) {
152 if ((strcmp(console_buffer, "133") != 0) &
153 (strcmp(console_buffer, "166") != 0))
157 strcpy(plbClock, console_buffer);
159 } while (nbytes == 0);
163 printf("enter Pci-X clock frequency 33, 66, 100 or 133 MHz or quit to abort\n");
164 nbytes = readline (" ? ");
166 if (strcmp(console_buffer, "quit") == 0)
169 if ((strcmp(console_buffer, "33") != 0) &
170 (strcmp(console_buffer, "66") != 0) &
171 (strcmp(console_buffer, "100") != 0) &
172 (strcmp(console_buffer, "133") != 0)) {
175 strcpy(pcixClock, console_buffer);
177 } while (nbytes == 0);
179 printf("\nsys clk = %s MHz\n", sysClock);
180 printf("cpu clk = %s MHz\n", cpuClock);
181 printf("plb clk = %s MHz\n", plbClock);
182 printf("Pci-X clk = %s MHz\n", pcixClock);
185 printf("\npress [y] to write I2C bootstrap \n");
186 printf("or [n] to abort. \n");
187 printf("Don't forget to set board switches \n");
188 printf("according to your choice before re-starting \n");
189 printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n");
191 nbytes = readline (" ? ");
192 if (strcmp(console_buffer, "n") == 0)
195 } while (nbytes == 0);
197 if (strcmp(sysClock, "33") == 0) {
198 if ((strcmp(cpuClock, "400") == 0) &
199 (strcmp(plbClock, "100") == 0))
202 if ((strcmp(cpuClock, "400") == 0) &
203 (strcmp(plbClock, "133") == 0))
206 if ((strcmp(cpuClock, "500") == 0))
209 if ((strcmp(cpuClock, "533") == 0))
213 if ((strcmp(cpuClock, "667") == 0) &
214 (strcmp(plbClock, "133") == 0))
217 if ((strcmp(cpuClock, "667") == 0) &
218 (strcmp(plbClock, "166") == 0))
223 if (strcmp(sysClock, "66") == 0) {
224 if ((strcmp(cpuClock, "400") == 0) &
225 (strcmp(plbClock, "100") == 0))
228 if ((strcmp(cpuClock, "400") == 0) &
229 (strcmp(plbClock, "133") == 0))
232 if ((strcmp(cpuClock, "533") == 0))
236 if ((strcmp(cpuClock, "667") == 0) &
237 (strcmp(plbClock, "133") == 0))
240 if ((strcmp(cpuClock, "667") == 0) &
241 (strcmp(plbClock, "166") == 0))
248 printf(" pin strap0 to write in i2c = %x\n", data);
251 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
252 printf("Error writing strap0 in %s\n", argv[2]);
254 if (strcmp(pcixClock, "33") == 0)
257 if (strcmp(pcixClock, "66") == 0)
260 if (strcmp(pcixClock, "100") == 0)
263 if (strcmp(pcixClock, "133") == 0)
266 if (strcmp(plbClock, "166") == 0)
267 data = data | 0x05950000;
269 data = data | 0x05A50000;
272 printf(" pin strap1 to write in i2c = %x\n", data);
276 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
277 printf("Error writing strap1 in %s\n", argv[2]);
283 evb440spe, 3, 1, do_evb440spe,
284 "evb440spe - program the serial device strap\n",
285 "wrclk [prom0|prom1] - program the serial device strap\n"