]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/amcc/katmai/cmd_katmai.c
Standardize command usage messages with cmd_usage()
[people/ms/u-boot.git] / board / amcc / katmai / cmd_katmai.c
1 /*
2 * (C) Copyright 2007
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
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.
12 *
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.
17 *
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,
21 * MA 02111-1307 USA
22 *
23 */
24
25 #include <common.h>
26 #include <command.h>
27 #include <i2c.h>
28 #include <asm/byteorder.h>
29
30 #define CONFIG_STRESS /* enable 667 MHz CPU freq selection */
31 #define DEBUG
32
33 static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
34 {
35 uchar chip;
36 ulong data;
37 int nbytes;
38 extern char console_buffer[];
39
40 char sysClock[4];
41 char cpuClock[4];
42 char plbClock[4];
43 char pcixClock[4];
44
45 if (argc < 3) {
46 cmd_usage(cmdtp);
47 return 1;
48 }
49
50 if (strcmp(argv[2], "prom0") == 0)
51 chip = IIC0_BOOTPROM_ADDR;
52 else
53 chip = IIC0_ALT_BOOTPROM_ADDR;
54
55 /* on Katmai SysClk is always 33MHz */
56 strcpy(sysClock, "33");
57
58 do {
59 #ifdef CONFIG_STRESS
60 printf("enter cpu clock frequency 400, 500, 533, 667 MHz or quit to abort\n");
61 #else
62 printf("enter cpu clock frequency 400, 500, 533 MHz or quit to abort\n");
63 #endif
64 nbytes = readline (" ? ");
65
66 if (strcmp(console_buffer, "quit") == 0)
67 return 0;
68
69 if ((strcmp(console_buffer, "400") != 0) &&
70 (strcmp(console_buffer, "500") != 0) &&
71 (strcmp(console_buffer, "533") != 0)
72 #ifdef CONFIG_STRESS
73 && (strcmp(console_buffer, "667") != 0)
74 #endif
75 ) {
76 nbytes = 0;
77 }
78
79 strcpy(cpuClock, console_buffer);
80
81 } while (nbytes == 0);
82
83 if (strcmp(cpuClock, "500") == 0)
84 strcpy(plbClock, "166");
85 else if (strcmp(cpuClock, "533") == 0)
86 strcpy(plbClock, "133");
87 else {
88 do {
89 if (strcmp(cpuClock, "400") == 0)
90 printf("enter plb clock frequency 100, 133 MHz or quit to abort\n");
91
92 #ifdef CONFIG_STRESS
93 if (strcmp(cpuClock, "667") == 0)
94 printf("enter plb clock frequency 133, 166 MHz or quit to abort\n");
95
96 #endif
97 nbytes = readline (" ? ");
98
99 if (strcmp(console_buffer, "quit") == 0)
100 return 0;
101
102 if (strcmp(cpuClock, "400") == 0) {
103 if ((strcmp(console_buffer, "100") != 0) &&
104 (strcmp(console_buffer, "133") != 0))
105 nbytes = 0;
106 }
107 #ifdef CONFIG_STRESS
108 if (strcmp(cpuClock, "667") == 0) {
109 if ((strcmp(console_buffer, "133") != 0) &&
110 (strcmp(console_buffer, "166") != 0))
111 nbytes = 0;
112 }
113 #endif
114 strcpy(plbClock, console_buffer);
115
116 } while (nbytes == 0);
117 }
118
119 do {
120 printf("enter Pci-X clock frequency 33, 66, 100 or 133 MHz or quit to abort\n");
121 nbytes = readline (" ? ");
122
123 if (strcmp(console_buffer, "quit") == 0)
124 return 0;
125
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)) {
130 nbytes = 0;
131 }
132 strcpy(pcixClock, console_buffer);
133
134 } while (nbytes == 0);
135
136 printf("\nsys clk = %s MHz\n", sysClock);
137 printf("cpu clk = %s MHz\n", cpuClock);
138 printf("plb clk = %s MHz\n", plbClock);
139 printf("Pci-X clk = %s MHz\n", pcixClock);
140
141 do {
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");
147
148 nbytes = readline (" ? ");
149 if (strcmp(console_buffer, "n") == 0)
150 return 0;
151
152 } while (nbytes == 0);
153
154 if (strcmp(sysClock, "33") == 0) {
155 if ((strcmp(cpuClock, "400") == 0) &&
156 (strcmp(plbClock, "100") == 0))
157 data = 0x8678c206;
158
159 if ((strcmp(cpuClock, "400") == 0) &&
160 (strcmp(plbClock, "133") == 0))
161 data = 0x8678c2c6;
162
163 if ((strcmp(cpuClock, "500") == 0))
164 data = 0x8778f2c6;
165
166 if ((strcmp(cpuClock, "533") == 0))
167 data = 0x87790252;
168 #ifdef CONFIG_STRESS
169 if ((strcmp(cpuClock, "667") == 0) &&
170 (strcmp(plbClock, "133") == 0))
171 data = 0x87794256;
172
173 if ((strcmp(cpuClock, "667") == 0) &&
174 (strcmp(plbClock, "166") == 0))
175 data = 0x87794206;
176 #endif
177 }
178 #ifdef DEBUG
179 printf(" pin strap0 to write in i2c = %lx\n", data);
180 #endif /* DEBUG */
181
182 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
183 printf("Error writing strap0 in %s\n", argv[2]);
184
185 if (strcmp(pcixClock, "33") == 0)
186 data = 0x000007E1;
187
188 if (strcmp(pcixClock, "66") == 0)
189 data = 0x000006E1;
190
191 if (strcmp(pcixClock, "100") == 0)
192 data = 0x000005E1;
193
194 if (strcmp(pcixClock, "133") == 0)
195 data = 0x000004E1;
196
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 */
200 else
201 data |= 0x05A50000;
202
203 #ifdef DEBUG
204 printf(" pin strap1 to write in i2c = %lx\n", data);
205 #endif /* DEBUG */
206
207 udelay(1000);
208 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
209 printf("Error writing strap1 in %s\n", argv[2]);
210
211 return 0;
212 }
213
214 U_BOOT_CMD(
215 bootstrap, 3, 1, do_bootstrap,
216 "bootstrap - program the serial device strap\n",
217 "wrclk [prom0|prom1] - program the serial device strap\n"
218 );