]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/amcc/yucca/cmd_yucca.c
Merge branch 'mpc85xx'
[people/ms/u-boot.git] / board / amcc / yucca / cmd_yucca.c
1 /*
2 * (C) Copyright 2001
3 * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
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 * hacked for evb440spe
24 */
25
26 #include <common.h>
27 #include <command.h>
28 #include "yucca.h"
29 #include <i2c.h>
30 #include <asm/byteorder.h>
31
32 extern void print_evb440spe_info(void);
33 static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag,
34 int flag, int argc, char *argv[]);
35
36 extern int cmd_get_data_size(char* arg, int default_size);
37
38 /* ------------------------------------------------------------------------- */
39 int do_evb440spe(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
40 {
41 return setBootStrapClock (cmdtp, 1, flag, argc, argv);
42 }
43
44 /* ------------------------------------------------------------------------- */
45 /* Modify memory.
46 *
47 * Syntax:
48 * evb440spe wrclk prom0,prom1
49 */
50 static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,
51 int argc, char *argv[])
52 {
53 uchar chip;
54 ulong data;
55 int nbytes;
56 extern char console_buffer[];
57
58 char sysClock[4];
59 char cpuClock[4];
60 char plbClock[4];
61 char pcixClock[4];
62
63 if (argc < 3) {
64 printf ("Usage:\n%s\n", cmdtp->usage);
65 return 1;
66 }
67
68 if (strcmp(argv[2], "prom0") == 0)
69 chip = IIC0_BOOTPROM_ADDR;
70 else
71 chip = IIC0_ALT_BOOTPROM_ADDR;
72
73 do {
74 printf("enter sys clock frequency 33 or 66 Mhz or quit to abort\n");
75 nbytes = readline (" ? ");
76
77 if (strcmp(console_buffer, "quit") == 0)
78 return 0;
79
80 if ((strcmp(console_buffer, "33") != 0) &
81 (strcmp(console_buffer, "66") != 0))
82 nbytes=0;
83
84 strcpy(sysClock, console_buffer);
85
86 } while (nbytes == 0);
87
88 do {
89 if (strcmp(sysClock, "66") == 0) {
90 printf("enter cpu clock frequency 400, 533 Mhz or quit to abort\n");
91 } else {
92 #ifdef CONFIG_STRESS
93 printf("enter cpu clock frequency 400, 500, 533, 667 Mhz or quit to abort\n");
94 #else
95 printf("enter cpu clock frequency 400, 500, 533 Mhz or quit to abort\n");
96 #endif
97 }
98 nbytes = readline (" ? ");
99
100 if (strcmp(console_buffer, "quit") == 0)
101 return 0;
102
103 if (strcmp(sysClock, "66") == 0) {
104 if ((strcmp(console_buffer, "400") != 0) &
105 (strcmp(console_buffer, "533") != 0)
106 #ifdef CONFIG_STRESS
107 & (strcmp(console_buffer, "667") != 0)
108 #endif
109 ) {
110 nbytes = 0;
111 }
112 } else {
113 if ((strcmp(console_buffer, "400") != 0) &
114 (strcmp(console_buffer, "500") != 0) &
115 (strcmp(console_buffer, "533") != 0)
116 #ifdef CONFIG_STRESS
117 & (strcmp(console_buffer, "667") != 0)
118 #endif
119 ) {
120 nbytes = 0;
121 }
122 }
123
124 strcpy(cpuClock, console_buffer);
125
126 } while (nbytes == 0);
127
128 if (strcmp(cpuClock, "500") == 0){
129 strcpy(plbClock, "166");
130 } else if (strcmp(cpuClock, "533") == 0){
131 strcpy(plbClock, "133");
132 } else {
133 do {
134 if (strcmp(cpuClock, "400") == 0)
135 printf("enter plb clock frequency 100, 133 Mhz or quit to abort\n");
136
137 #ifdef CONFIG_STRESS
138 if (strcmp(cpuClock, "667") == 0)
139 printf("enter plb clock frequency 133, 166 Mhz or quit to abort\n");
140
141 #endif
142 nbytes = readline (" ? ");
143
144 if (strcmp(console_buffer, "quit") == 0)
145 return 0;
146
147 if (strcmp(cpuClock, "400") == 0) {
148 if ((strcmp(console_buffer, "100") != 0) &
149 (strcmp(console_buffer, "133") != 0))
150 nbytes = 0;
151 }
152 #ifdef CONFIG_STRESS
153 if (strcmp(cpuClock, "667") == 0) {
154 if ((strcmp(console_buffer, "133") != 0) &
155 (strcmp(console_buffer, "166") != 0))
156 nbytes = 0;
157 }
158 #endif
159 strcpy(plbClock, console_buffer);
160
161 } while (nbytes == 0);
162 }
163
164 do {
165 printf("enter Pci-X clock frequency 33, 66, 100 or 133 Mhz or quit to abort\n");
166 nbytes = readline (" ? ");
167
168 if (strcmp(console_buffer, "quit") == 0)
169 return 0;
170
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)) {
175 nbytes = 0;
176 }
177 strcpy(pcixClock, console_buffer);
178
179 } while (nbytes == 0);
180
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);
185
186 do {
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");
192
193 nbytes = readline (" ? ");
194 if (strcmp(console_buffer, "n") == 0)
195 return 0;
196
197 } while (nbytes == 0);
198
199 if (strcmp(sysClock, "33") == 0) {
200 if ((strcmp(cpuClock, "400") == 0) &
201 (strcmp(plbClock, "100") == 0))
202 data = 0x8678c206;
203
204 if ((strcmp(cpuClock, "400") == 0) &
205 (strcmp(plbClock, "133") == 0))
206 data = 0x8678c2c6;
207
208 if ((strcmp(cpuClock, "500") == 0))
209 data = 0x8778f2c6;
210
211 if ((strcmp(cpuClock, "533") == 0))
212 data = 0x87790252;
213
214 #ifdef CONFIG_STRESS
215 if ((strcmp(cpuClock, "667") == 0) &
216 (strcmp(plbClock, "133") == 0))
217 data = 0x87794256;
218
219 if ((strcmp(cpuClock, "667") == 0) &
220 (strcmp(plbClock, "166") == 0))
221 data = 0x87794206;
222
223 #endif
224 }
225 if (strcmp(sysClock, "66") == 0) {
226 if ((strcmp(cpuClock, "400") == 0) &
227 (strcmp(plbClock, "100") == 0))
228 data = 0x84706206;
229
230 if ((strcmp(cpuClock, "400") == 0) &
231 (strcmp(plbClock, "133") == 0))
232 data = 0x847062c6;
233
234 if ((strcmp(cpuClock, "533") == 0))
235 data = 0x85708206;
236
237 #ifdef CONFIG_STRESS
238 if ((strcmp(cpuClock, "667") == 0) &
239 (strcmp(plbClock, "133") == 0))
240 data = 0x8570a256;
241
242 if ((strcmp(cpuClock, "667") == 0) &
243 (strcmp(plbClock, "166") == 0))
244 data = 0x8570a206;
245
246 #endif
247 }
248
249 #ifdef DEBUG
250 printf(" pin strap0 to write in i2c = %x\n", data);
251 #endif /* DEBUG */
252
253 if (i2c_write(chip, 0, 1, (uchar *)&data, 4) != 0)
254 printf("Error writing strap0 in %s\n", argv[2]);
255
256 if (strcmp(pcixClock, "33") == 0)
257 data = 0x00000701;
258
259 if (strcmp(pcixClock, "66") == 0)
260 data = 0x00000601;
261
262 if (strcmp(pcixClock, "100") == 0)
263 data = 0x00000501;
264
265 if (strcmp(pcixClock, "133") == 0)
266 data = 0x00000401;
267
268 if (strcmp(plbClock, "166") == 0)
269 data = data | 0x05950000;
270 else
271 data = data | 0x05A50000;
272
273 #ifdef DEBUG
274 printf(" pin strap1 to write in i2c = %x\n", data);
275 #endif /* DEBUG */
276
277 udelay(1000);
278 if (i2c_write(chip, 4, 1, (uchar *)&data, 4) != 0)
279 printf("Error writing strap1 in %s\n", argv[2]);
280
281 return 0;
282 }
283
284 U_BOOT_CMD(
285 evb440spe, 3, 1, do_evb440spe,
286 "evb440spe - program the serial device strap\n",
287 "wrclk [prom0|prom1] - program the serial device strap\n"
288 );