3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
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,
28 #include <asm/byteorder.h>
30 #define CONFIG_STRESS /* enable 667 MHz CPU freq selection */
33 static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
38 extern char console_buffer[];
46 printf ("Usage:\n%s\n", cmdtp->usage);
50 if (strcmp(argv[2], "prom0") == 0)
51 chip = IIC0_BOOTPROM_ADDR;
53 chip = IIC0_ALT_BOOTPROM_ADDR;
55 /* on Katmai SysClk is always 33MHz */
56 strcpy(sysClock, "33");
60 printf("enter cpu clock frequency 400, 500, 533, 667 Mhz or quit to abort\n");
62 printf("enter cpu clock frequency 400, 500, 533 Mhz or quit to abort\n");
64 nbytes = readline (" ? ");
66 if (strcmp(console_buffer, "quit") == 0)
69 if ((strcmp(console_buffer, "400") != 0) &&
70 (strcmp(console_buffer, "500") != 0) &&
71 (strcmp(console_buffer, "533") != 0)
73 && (strcmp(console_buffer, "667") != 0)
79 strcpy(cpuClock, console_buffer);
81 } while (nbytes == 0);
83 if (strcmp(cpuClock, "500") == 0)
84 strcpy(plbClock, "166");
85 else if (strcmp(cpuClock, "533") == 0)
86 strcpy(plbClock, "133");
89 if (strcmp(cpuClock, "400") == 0)
90 printf("enter plb clock frequency 100, 133 Mhz or quit to abort\n");
93 if (strcmp(cpuClock, "667") == 0)
94 printf("enter plb clock frequency 133, 166 Mhz or quit to abort\n");
97 nbytes = readline (" ? ");
99 if (strcmp(console_buffer, "quit") == 0)
102 if (strcmp(cpuClock, "400") == 0) {
103 if ((strcmp(console_buffer, "100") != 0) &&
104 (strcmp(console_buffer, "133") != 0))
108 if (strcmp(cpuClock, "667") == 0) {
109 if ((strcmp(console_buffer, "133") != 0) &&
110 (strcmp(console_buffer, "166") != 0))
114 strcpy(plbClock, console_buffer);
116 } while (nbytes == 0);
120 printf("enter Pci-X clock frequency 33, 66, 100 or 133 Mhz or quit to abort\n");
121 nbytes = readline (" ? ");
123 if (strcmp(console_buffer, "quit") == 0)
126 if ((strcmp(console_buffer, "33") != 0) &&
127 (strcmp(console_buffer, "66") != 0) &&
128 (strcmp(console_buffer, "100") != 0) &&
129 (strcmp(console_buffer, "133") != 0)) {
132 strcpy(pcixClock, console_buffer);
134 } while (nbytes == 0);
136 printf("\nsys clk = %sMhz\n", sysClock);
137 printf("cpu clk = %sMhz\n", cpuClock);
138 printf("plb clk = %sMhz\n", plbClock);
139 printf("Pci-X clk = %sMhz\n", pcixClock);
142 printf("\npress [y] to write I2C bootstrap \n");
143 printf("or [n] to abort. \n");
144 printf("Don't forget to set board switches \n");
145 printf("according to your choice before re-starting \n");
146 printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n");
148 nbytes = readline (" ? ");
149 if (strcmp(console_buffer, "n") == 0)
152 } while (nbytes == 0);
154 if (strcmp(sysClock, "33") == 0) {
155 if ((strcmp(cpuClock, "400") == 0) &&
156 (strcmp(plbClock, "100") == 0))
159 if ((strcmp(cpuClock, "400") == 0) &&
160 (strcmp(plbClock, "133") == 0))
163 if ((strcmp(cpuClock, "500") == 0))
166 if ((strcmp(cpuClock, "533") == 0))
169 if ((strcmp(cpuClock, "667") == 0) &&
170 (strcmp(plbClock, "133") == 0))
173 if ((strcmp(cpuClock, "667") == 0) &&
174 (strcmp(plbClock, "166") == 0))
179 printf(" pin strap0 to write in i2c = %x\n", data);
182 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
183 printf("Error writing strap0 in %s\n", argv[2]);
185 if (strcmp(pcixClock, "33") == 0)
188 if (strcmp(pcixClock, "66") == 0)
191 if (strcmp(pcixClock, "100") == 0)
194 if (strcmp(pcixClock, "133") == 0)
197 if (strcmp(plbClock, "166") == 0)
198 /* data |= 0x05950000; */ /* this set's DDR2 clock == PLB clock */
199 data |= 0x05A50000; /* this set's DDR2 clock == 2 * PLB clock */
204 printf(" pin strap1 to write in i2c = %x\n", data);
208 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
209 printf("Error writing strap1 in %s\n", argv[2]);
215 bootstrap, 3, 1, do_bootstrap,
216 "bootstrap - program the serial device strap\n",
217 "wrclk [prom0|prom1] - program the serial device strap\n"