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[])
54 extern char console_buffer[];
62 return cmd_usage(cmdtp);
64 if (strcmp(argv[2], "prom0") == 0)
65 chip = IIC0_BOOTPROM_ADDR;
67 chip = IIC0_ALT_BOOTPROM_ADDR;
70 printf("enter sys clock frequency 33 or 66 MHz or quit to abort\n");
71 nbytes = readline (" ? ");
73 if (strcmp(console_buffer, "quit") == 0)
76 if ((strcmp(console_buffer, "33") != 0) &
77 (strcmp(console_buffer, "66") != 0))
80 strcpy(sysClock, console_buffer);
82 } while (nbytes == 0);
85 if (strcmp(sysClock, "66") == 0) {
86 printf("enter cpu clock frequency 400, 533 MHz or quit to abort\n");
89 printf("enter cpu clock frequency 400, 500, 533, 667 MHz or quit to abort\n");
91 printf("enter cpu clock frequency 400, 500, 533 MHz or quit to abort\n");
94 nbytes = readline (" ? ");
96 if (strcmp(console_buffer, "quit") == 0)
99 if (strcmp(sysClock, "66") == 0) {
100 if ((strcmp(console_buffer, "400") != 0) &
101 (strcmp(console_buffer, "533") != 0)
103 & (strcmp(console_buffer, "667") != 0)
109 if ((strcmp(console_buffer, "400") != 0) &
110 (strcmp(console_buffer, "500") != 0) &
111 (strcmp(console_buffer, "533") != 0)
113 & (strcmp(console_buffer, "667") != 0)
120 strcpy(cpuClock, console_buffer);
122 } while (nbytes == 0);
124 if (strcmp(cpuClock, "500") == 0){
125 strcpy(plbClock, "166");
126 } else if (strcmp(cpuClock, "533") == 0){
127 strcpy(plbClock, "133");
130 if (strcmp(cpuClock, "400") == 0)
131 printf("enter plb clock frequency 100, 133 MHz or quit to abort\n");
134 if (strcmp(cpuClock, "667") == 0)
135 printf("enter plb clock frequency 133, 166 MHz or quit to abort\n");
138 nbytes = readline (" ? ");
140 if (strcmp(console_buffer, "quit") == 0)
143 if (strcmp(cpuClock, "400") == 0) {
144 if ((strcmp(console_buffer, "100") != 0) &
145 (strcmp(console_buffer, "133") != 0))
149 if (strcmp(cpuClock, "667") == 0) {
150 if ((strcmp(console_buffer, "133") != 0) &
151 (strcmp(console_buffer, "166") != 0))
155 strcpy(plbClock, console_buffer);
157 } while (nbytes == 0);
161 printf("enter Pci-X clock frequency 33, 66, 100 or 133 MHz or quit to abort\n");
162 nbytes = readline (" ? ");
164 if (strcmp(console_buffer, "quit") == 0)
167 if ((strcmp(console_buffer, "33") != 0) &
168 (strcmp(console_buffer, "66") != 0) &
169 (strcmp(console_buffer, "100") != 0) &
170 (strcmp(console_buffer, "133") != 0)) {
173 strcpy(pcixClock, console_buffer);
175 } while (nbytes == 0);
177 printf("\nsys clk = %s MHz\n", sysClock);
178 printf("cpu clk = %s MHz\n", cpuClock);
179 printf("plb clk = %s MHz\n", plbClock);
180 printf("Pci-X clk = %s MHz\n", pcixClock);
183 printf("\npress [y] to write I2C bootstrap \n");
184 printf("or [n] to abort. \n");
185 printf("Don't forget to set board switches \n");
186 printf("according to your choice before re-starting \n");
187 printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n");
189 nbytes = readline (" ? ");
190 if (strcmp(console_buffer, "n") == 0)
193 } while (nbytes == 0);
195 if (strcmp(sysClock, "33") == 0) {
196 if ((strcmp(cpuClock, "400") == 0) &
197 (strcmp(plbClock, "100") == 0))
200 if ((strcmp(cpuClock, "400") == 0) &
201 (strcmp(plbClock, "133") == 0))
204 if ((strcmp(cpuClock, "500") == 0))
207 if ((strcmp(cpuClock, "533") == 0))
211 if ((strcmp(cpuClock, "667") == 0) &
212 (strcmp(plbClock, "133") == 0))
215 if ((strcmp(cpuClock, "667") == 0) &
216 (strcmp(plbClock, "166") == 0))
221 if (strcmp(sysClock, "66") == 0) {
222 if ((strcmp(cpuClock, "400") == 0) &
223 (strcmp(plbClock, "100") == 0))
226 if ((strcmp(cpuClock, "400") == 0) &
227 (strcmp(plbClock, "133") == 0))
230 if ((strcmp(cpuClock, "533") == 0))
234 if ((strcmp(cpuClock, "667") == 0) &
235 (strcmp(plbClock, "133") == 0))
238 if ((strcmp(cpuClock, "667") == 0) &
239 (strcmp(plbClock, "166") == 0))
246 printf(" pin strap0 to write in i2c = %x\n", data);
249 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
250 printf("Error writing strap0 in %s\n", argv[2]);
252 if (strcmp(pcixClock, "33") == 0)
255 if (strcmp(pcixClock, "66") == 0)
258 if (strcmp(pcixClock, "100") == 0)
261 if (strcmp(pcixClock, "133") == 0)
264 if (strcmp(plbClock, "166") == 0)
265 data = data | 0x05950000;
267 data = data | 0x05A50000;
270 printf(" pin strap1 to write in i2c = %x\n", data);
274 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
275 printf("Error writing strap1 in %s\n", argv[2]);
281 evb440spe, 3, 1, do_evb440spe,
282 "program the serial device strap",
283 "wrclk [prom0|prom1] - program the serial device strap"