3 * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
5 * SPDX-License-Identifier: GPL-2.0+
15 #include <asm/byteorder.h>
17 extern void print_evb440spe_info(void);
18 static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag,
19 int flag, int argc, char * const argv[]);
21 /* ------------------------------------------------------------------------- */
22 int do_evb440spe(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
24 return setBootStrapClock (cmdtp, 1, flag, argc, argv);
27 /* ------------------------------------------------------------------------- */
31 * evb440spe wrclk prom0,prom1
33 static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,
34 int argc, char * const argv[])
46 return cmd_usage(cmdtp);
48 if (strcmp(argv[2], "prom0") == 0)
49 chip = IIC0_BOOTPROM_ADDR;
51 chip = IIC0_ALT_BOOTPROM_ADDR;
54 printf("enter sys clock frequency 33 or 66 MHz or quit to abort\n");
55 nbytes = cli_readline(" ? ");
57 if (strcmp(console_buffer, "quit") == 0)
60 if ((strcmp(console_buffer, "33") != 0) &
61 (strcmp(console_buffer, "66") != 0))
64 strcpy(sysClock, console_buffer);
66 } while (nbytes == 0);
69 if (strcmp(sysClock, "66") == 0) {
70 printf("enter cpu clock frequency 400, 533 MHz or quit to abort\n");
73 printf("enter cpu clock frequency 400, 500, 533, 667 MHz or quit to abort\n");
75 printf("enter cpu clock frequency 400, 500, 533 MHz or quit to abort\n");
78 nbytes = cli_readline(" ? ");
80 if (strcmp(console_buffer, "quit") == 0)
83 if (strcmp(sysClock, "66") == 0) {
84 if ((strcmp(console_buffer, "400") != 0) &
85 (strcmp(console_buffer, "533") != 0)
87 & (strcmp(console_buffer, "667") != 0)
93 if ((strcmp(console_buffer, "400") != 0) &
94 (strcmp(console_buffer, "500") != 0) &
95 (strcmp(console_buffer, "533") != 0)
97 & (strcmp(console_buffer, "667") != 0)
104 strcpy(cpuClock, console_buffer);
106 } while (nbytes == 0);
108 if (strcmp(cpuClock, "500") == 0){
109 strcpy(plbClock, "166");
110 } else if (strcmp(cpuClock, "533") == 0){
111 strcpy(plbClock, "133");
114 if (strcmp(cpuClock, "400") == 0)
115 printf("enter plb clock frequency 100, 133 MHz or quit to abort\n");
118 if (strcmp(cpuClock, "667") == 0)
119 printf("enter plb clock frequency 133, 166 MHz or quit to abort\n");
122 nbytes = cli_readline(" ? ");
124 if (strcmp(console_buffer, "quit") == 0)
127 if (strcmp(cpuClock, "400") == 0) {
128 if ((strcmp(console_buffer, "100") != 0) &
129 (strcmp(console_buffer, "133") != 0))
133 if (strcmp(cpuClock, "667") == 0) {
134 if ((strcmp(console_buffer, "133") != 0) &
135 (strcmp(console_buffer, "166") != 0))
139 strcpy(plbClock, console_buffer);
141 } while (nbytes == 0);
145 printf("enter Pci-X clock frequency 33, 66, 100 or 133 MHz or quit to abort\n");
146 nbytes = cli_readline(" ? ");
148 if (strcmp(console_buffer, "quit") == 0)
151 if ((strcmp(console_buffer, "33") != 0) &
152 (strcmp(console_buffer, "66") != 0) &
153 (strcmp(console_buffer, "100") != 0) &
154 (strcmp(console_buffer, "133") != 0)) {
157 strcpy(pcixClock, console_buffer);
159 } while (nbytes == 0);
161 printf("\nsys clk = %s MHz\n", sysClock);
162 printf("cpu clk = %s MHz\n", cpuClock);
163 printf("plb clk = %s MHz\n", plbClock);
164 printf("Pci-X clk = %s MHz\n", pcixClock);
167 printf("\npress [y] to write I2C bootstrap\n");
168 printf("or [n] to abort.\n");
169 printf("Don't forget to set board switches\n");
170 printf("according to your choice before re-starting\n");
171 printf("(refer to 440spe_uboot_kit_um_1_01.pdf)\n");
173 nbytes = cli_readline(" ? ");
174 if (strcmp(console_buffer, "n") == 0)
177 } while (nbytes == 0);
179 if (strcmp(sysClock, "33") == 0) {
180 if ((strcmp(cpuClock, "400") == 0) &
181 (strcmp(plbClock, "100") == 0))
184 if ((strcmp(cpuClock, "400") == 0) &
185 (strcmp(plbClock, "133") == 0))
188 if ((strcmp(cpuClock, "500") == 0))
191 if ((strcmp(cpuClock, "533") == 0))
195 if ((strcmp(cpuClock, "667") == 0) &
196 (strcmp(plbClock, "133") == 0))
199 if ((strcmp(cpuClock, "667") == 0) &
200 (strcmp(plbClock, "166") == 0))
205 if (strcmp(sysClock, "66") == 0) {
206 if ((strcmp(cpuClock, "400") == 0) &
207 (strcmp(plbClock, "100") == 0))
210 if ((strcmp(cpuClock, "400") == 0) &
211 (strcmp(plbClock, "133") == 0))
214 if ((strcmp(cpuClock, "533") == 0))
218 if ((strcmp(cpuClock, "667") == 0) &
219 (strcmp(plbClock, "133") == 0))
222 if ((strcmp(cpuClock, "667") == 0) &
223 (strcmp(plbClock, "166") == 0))
230 printf(" pin strap0 to write in i2c = %x\n", data);
233 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
234 printf("Error writing strap0 in %s\n", argv[2]);
236 if (strcmp(pcixClock, "33") == 0)
239 if (strcmp(pcixClock, "66") == 0)
242 if (strcmp(pcixClock, "100") == 0)
245 if (strcmp(pcixClock, "133") == 0)
248 if (strcmp(plbClock, "166") == 0)
249 data = data | 0x05950000;
251 data = data | 0x05A50000;
254 printf(" pin strap1 to write in i2c = %x\n", data);
258 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
259 printf("Error writing strap1 in %s\n", argv[2]);
265 evb440spe, 3, 1, do_evb440spe,
266 "program the serial device strap",
267 "wrclk [prom0|prom1] - program the serial device strap"