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 extern int cmd_get_data_size(char* arg, int default_size);
38 /* ------------------------------------------------------------------------- */
39 int do_evb440spe(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
41 return setBootStrapClock (cmdtp, 1, flag, argc, argv);
44 /* ------------------------------------------------------------------------- */
48 * evb440spe wrclk prom0,prom1
50 static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,
51 int argc, char *argv[])
56 extern char console_buffer[];
64 printf ("Usage:\n%s\n", cmdtp->usage);
68 if (strcmp(argv[2], "prom0") == 0)
69 chip = IIC0_BOOTPROM_ADDR;
71 chip = IIC0_ALT_BOOTPROM_ADDR;
74 printf("enter sys clock frequency 33 or 66 Mhz or quit to abort\n");
75 nbytes = readline (" ? ");
77 if (strcmp(console_buffer, "quit") == 0)
80 if ((strcmp(console_buffer, "33") != 0) &
81 (strcmp(console_buffer, "66") != 0))
84 strcpy(sysClock, console_buffer);
86 } while (nbytes == 0);
89 if (strcmp(sysClock, "66") == 0) {
90 printf("enter cpu clock frequency 400, 533 Mhz or quit to abort\n");
93 printf("enter cpu clock frequency 400, 500, 533, 667 Mhz or quit to abort\n");
95 printf("enter cpu clock frequency 400, 500, 533 Mhz or quit to abort\n");
98 nbytes = readline (" ? ");
100 if (strcmp(console_buffer, "quit") == 0)
103 if (strcmp(sysClock, "66") == 0) {
104 if ((strcmp(console_buffer, "400") != 0) &
105 (strcmp(console_buffer, "533") != 0)
107 & (strcmp(console_buffer, "667") != 0)
113 if ((strcmp(console_buffer, "400") != 0) &
114 (strcmp(console_buffer, "500") != 0) &
115 (strcmp(console_buffer, "533") != 0)
117 & (strcmp(console_buffer, "667") != 0)
124 strcpy(cpuClock, console_buffer);
126 } while (nbytes == 0);
128 if (strcmp(cpuClock, "500") == 0){
129 strcpy(plbClock, "166");
130 } else if (strcmp(cpuClock, "533") == 0){
131 strcpy(plbClock, "133");
134 if (strcmp(cpuClock, "400") == 0)
135 printf("enter plb clock frequency 100, 133 Mhz or quit to abort\n");
138 if (strcmp(cpuClock, "667") == 0)
139 printf("enter plb clock frequency 133, 166 Mhz or quit to abort\n");
142 nbytes = readline (" ? ");
144 if (strcmp(console_buffer, "quit") == 0)
147 if (strcmp(cpuClock, "400") == 0) {
148 if ((strcmp(console_buffer, "100") != 0) &
149 (strcmp(console_buffer, "133") != 0))
153 if (strcmp(cpuClock, "667") == 0) {
154 if ((strcmp(console_buffer, "133") != 0) &
155 (strcmp(console_buffer, "166") != 0))
159 strcpy(plbClock, console_buffer);
161 } while (nbytes == 0);
165 printf("enter Pci-X clock frequency 33, 66, 100 or 133 Mhz or quit to abort\n");
166 nbytes = readline (" ? ");
168 if (strcmp(console_buffer, "quit") == 0)
171 if ((strcmp(console_buffer, "33") != 0) &
172 (strcmp(console_buffer, "66") != 0) &
173 (strcmp(console_buffer, "100") != 0) &
174 (strcmp(console_buffer, "133") != 0)) {
177 strcpy(pcixClock, console_buffer);
179 } while (nbytes == 0);
181 printf("\nsys clk = %sMhz\n", sysClock);
182 printf("cpu clk = %sMhz\n", cpuClock);
183 printf("plb clk = %sMhz\n", plbClock);
184 printf("Pci-X clk = %sMhz\n", pcixClock);
187 printf("\npress [y] to write I2C bootstrap \n");
188 printf("or [n] to abort. \n");
189 printf("Don't forget to set board switches \n");
190 printf("according to your choice before re-starting \n");
191 printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n");
193 nbytes = readline (" ? ");
194 if (strcmp(console_buffer, "n") == 0)
197 } while (nbytes == 0);
199 if (strcmp(sysClock, "33") == 0) {
200 if ((strcmp(cpuClock, "400") == 0) &
201 (strcmp(plbClock, "100") == 0))
204 if ((strcmp(cpuClock, "400") == 0) &
205 (strcmp(plbClock, "133") == 0))
208 if ((strcmp(cpuClock, "500") == 0))
211 if ((strcmp(cpuClock, "533") == 0))
215 if ((strcmp(cpuClock, "667") == 0) &
216 (strcmp(plbClock, "133") == 0))
219 if ((strcmp(cpuClock, "667") == 0) &
220 (strcmp(plbClock, "166") == 0))
225 if (strcmp(sysClock, "66") == 0) {
226 if ((strcmp(cpuClock, "400") == 0) &
227 (strcmp(plbClock, "100") == 0))
230 if ((strcmp(cpuClock, "400") == 0) &
231 (strcmp(plbClock, "133") == 0))
234 if ((strcmp(cpuClock, "533") == 0))
238 if ((strcmp(cpuClock, "667") == 0) &
239 (strcmp(plbClock, "133") == 0))
242 if ((strcmp(cpuClock, "667") == 0) &
243 (strcmp(plbClock, "166") == 0))
250 printf(" pin strap0 to write in i2c = %x\n", data);
253 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
254 printf("Error writing strap0 in %s\n", argv[2]);
256 if (strcmp(pcixClock, "33") == 0)
259 if (strcmp(pcixClock, "66") == 0)
262 if (strcmp(pcixClock, "100") == 0)
265 if (strcmp(pcixClock, "133") == 0)
268 if (strcmp(plbClock, "166") == 0)
269 data = data | 0x05950000;
271 data = data | 0x05A50000;
274 printf(" pin strap1 to write in i2c = %x\n", data);
278 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
279 printf("Error writing strap1 in %s\n", argv[2]);
285 evb440spe, 3, 1, do_evb440spe,
286 "evb440spe - program the serial device strap\n",
287 "wrclk [prom0|prom1] - program the serial device strap\n"