]>
Commit | Line | Data |
---|---|---|
7521af1c WD |
1 | /* |
2 | * amirix.c: ppcboot platform support for AMIRIX board | |
3 | * | |
4 | * Copyright 2002 Mind NV | |
5 | * Copyright 2003 AMIRIX Systems Inc. | |
6 | * | |
7 | * http://www.mind.be/ | |
8 | * http://www.amirix.com/ | |
9 | * | |
10 | * Author : Peter De Schrijver (p2@mind.be) | |
11 | * Frank Smith (smith@amirix.com) | |
12 | * | |
13 | * Derived from : Other platform support files in this tree, ml2 | |
14 | * | |
15 | * This software may be used and distributed according to the terms of | |
16 | * the GNU General Public License (GPL) version 2, incorporated herein by | |
17 | * reference. Drivers based on or derived from this code fall under the GPL | |
18 | * and must retain the authorship, copyright and this license notice. This | |
19 | * file is not a complete program and may only be used when the entire | |
20 | * program is licensed under the GPL. | |
21 | * | |
22 | */ | |
23 | ||
24 | #include <common.h> | |
25 | #include <command.h> | |
ad3381cf | 26 | #include <netdev.h> |
7521af1c WD |
27 | #include <asm/processor.h> |
28 | ||
29 | #include "powerspan.h" | |
30 | #include "ap1000.h" | |
31 | ||
32 | int board_pre_init (void) | |
33 | { | |
3df5bea0 | 34 | return 0; |
7521af1c WD |
35 | } |
36 | ||
37 | /** serial number and platform display at startup */ | |
38 | int checkboard (void) | |
39 | { | |
f0c0b3a9 WD |
40 | char buf[64]; |
41 | int l = getenv_f("serial#", buf, sizeof(buf)); | |
3df5bea0 WD |
42 | |
43 | /* After a loadace command, the SystemAce control register is left in a wonky state. */ | |
44 | /* this code did not work in board_pre_init */ | |
45 | unsigned char *p = (unsigned char *) AP1000_SYSACE_REGBASE; | |
46 | ||
47 | p[SYSACE_CTRLREG0] = 0x0; | |
48 | ||
49 | /* add platform and device to banner */ | |
50 | switch (get_device ()) { | |
51 | case AP1xx_AP107_TARGET: | |
52 | puts (AP1xx_AP107_TARGET_STR); | |
53 | break; | |
54 | case AP1xx_AP120_TARGET: | |
55 | puts (AP1xx_AP120_TARGET_STR); | |
56 | break; | |
57 | case AP1xx_AP130_TARGET: | |
58 | puts (AP1xx_AP130_TARGET_STR); | |
59 | break; | |
60 | case AP1xx_AP1070_TARGET: | |
61 | puts (AP1xx_AP1070_TARGET_STR); | |
62 | break; | |
63 | case AP1xx_AP1100_TARGET: | |
64 | puts (AP1xx_AP1100_TARGET_STR); | |
65 | break; | |
66 | default: | |
67 | puts (AP1xx_UNKNOWN_STR); | |
68 | break; | |
69 | } | |
70 | puts (AP1xx_TARGET_STR); | |
71 | puts (" with "); | |
72 | ||
73 | switch (get_platform ()) { | |
74 | case AP100_BASELINE_PLATFORM: | |
75 | case AP1000_BASELINE_PLATFORM: | |
76 | puts (AP1xx_BASELINE_PLATFORM_STR); | |
77 | break; | |
78 | case AP1xx_QUADGE_PLATFORM: | |
79 | puts (AP1xx_QUADGE_PLATFORM_STR); | |
80 | break; | |
81 | case AP1xx_MGT_REF_PLATFORM: | |
82 | puts (AP1xx_MGT_REF_PLATFORM_STR); | |
83 | break; | |
84 | case AP1xx_STANDARD_PLATFORM: | |
85 | puts (AP1xx_STANDARD_PLATFORM_STR); | |
86 | break; | |
87 | case AP1xx_DUAL_PLATFORM: | |
88 | puts (AP1xx_DUAL_PLATFORM_STR); | |
89 | break; | |
90 | case AP1xx_BASE_SRAM_PLATFORM: | |
91 | puts (AP1xx_BASE_SRAM_PLATFORM_STR); | |
92 | break; | |
93 | case AP1xx_PCI_PCB_TESTPLATFORM: | |
94 | case AP1000_PCI_PCB_TESTPLATFORM: | |
95 | puts (AP1xx_PCI_PCB_TESTPLATFORM_STR); | |
96 | break; | |
97 | case AP1xx_DUAL_GE_MEZZ_TESTPLATFORM: | |
98 | puts (AP1xx_DUAL_GE_MEZZ_TESTPLATFORM_STR); | |
99 | break; | |
100 | case AP1xx_SFP_MEZZ_TESTPLATFORM: | |
101 | puts (AP1xx_SFP_MEZZ_TESTPLATFORM_STR); | |
102 | break; | |
103 | default: | |
104 | puts (AP1xx_UNKNOWN_STR); | |
105 | break; | |
106 | } | |
107 | ||
108 | if ((get_platform () & AP1xx_TESTPLATFORM_MASK) != 0) { | |
109 | puts (AP1xx_TESTPLATFORM_STR); | |
110 | } else { | |
111 | puts (AP1xx_PLATFORM_STR); | |
112 | } | |
113 | ||
114 | putc ('\n'); | |
115 | ||
116 | puts ("Serial#: "); | |
117 | ||
f0c0b3a9 | 118 | if (l < 0) { |
3df5bea0 WD |
119 | printf ("### No HW ID - assuming AMIRIX"); |
120 | } else { | |
f0c0b3a9 WD |
121 | int i; |
122 | ||
123 | for (i = 0; i < l; ++i) { | |
124 | if (buf[i] == ' ') { | |
125 | buf[i] = '\0'; | |
3df5bea0 | 126 | break; |
f0c0b3a9 | 127 | } |
3df5bea0 WD |
128 | } |
129 | ||
f0c0b3a9 | 130 | puts(buf); |
3df5bea0 WD |
131 | } |
132 | ||
133 | putc ('\n'); | |
134 | ||
135 | return (0); | |
7521af1c WD |
136 | } |
137 | ||
138 | ||
9973e3c6 | 139 | phys_size_t initdram (int board_type) |
7521af1c | 140 | { |
f0c0b3a9 WD |
141 | char buf[64]; |
142 | int i = getenv_f("dramsize", buf, sizeof(buf)); | |
3df5bea0 | 143 | |
f0c0b3a9 WD |
144 | if (i > 0) { |
145 | char *s = buf; | |
3df5bea0 WD |
146 | if ((s[0] == '0') && ((s[1] == 'x') || (s[1] == 'X'))) { |
147 | s += 2; | |
148 | } | |
18c5e64c | 149 | return (long int)simple_strtoul (s, NULL, 16); |
3df5bea0 WD |
150 | } else { |
151 | /* give all 64 MB */ | |
7521af1c | 152 | return 64 * 1024 * 1024; |
3df5bea0 | 153 | } |
7521af1c WD |
154 | } |
155 | ||
3df5bea0 WD |
156 | unsigned int get_platform (void) |
157 | { | |
158 | unsigned int *revision_reg_ptr = (unsigned int *) AP1xx_FPGA_REV_ADDR; | |
159 | ||
160 | return (*revision_reg_ptr & AP1xx_PLATFORM_MASK); | |
7521af1c WD |
161 | } |
162 | ||
3df5bea0 WD |
163 | unsigned int get_device (void) |
164 | { | |
165 | unsigned int *revision_reg_ptr = (unsigned int *) AP1xx_FPGA_REV_ADDR; | |
7521af1c | 166 | |
3df5bea0 | 167 | return (*revision_reg_ptr & AP1xx_TARGET_MASK); |
7521af1c WD |
168 | } |
169 | ||
3df5bea0 | 170 | #if 0 /* loadace is not working; it appears to be a hardware issue with the system ace. */ |
7521af1c WD |
171 | /* |
172 | This function loads FPGA configurations from the SystemACE CompactFlash | |
173 | */ | |
54841ab5 | 174 | int do_loadace (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
7521af1c | 175 | { |
3df5bea0 WD |
176 | unsigned char *p = (unsigned char *) AP1000_SYSACE_REGBASE; |
177 | int cfg; | |
178 | ||
179 | if ((p[SYSACE_STATREG0] & 0x10) == 0) { | |
180 | p[SYSACE_CTRLREG0] = 0x80; | |
181 | printf ("\nNo CompactFlash Detected\n\n"); | |
182 | p[SYSACE_CTRLREG0] = 0x00; | |
183 | return 1; | |
184 | } | |
185 | ||
186 | /* reset configuration controller: | 0x80 */ | |
187 | /* select cpflash & ~0x40 */ | |
188 | /* cfg start | 0x20 */ | |
189 | /* wait for cfgstart & ~0x10 */ | |
190 | /* force cfgmode: | 0x08 */ | |
191 | /* do no force cfgaddr: & ~0x04 */ | |
192 | /* clear mpulock: & ~0x02 */ | |
193 | /* do not force lock request & ~0x01 */ | |
194 | ||
195 | p[SYSACE_CTRLREG0] = 0x80 | 0x20 | 0x08; | |
196 | p[SYSACE_CTRLREG1] = 0x00; | |
197 | ||
198 | /* force config address if arg2 exists */ | |
199 | if (argc == 2) { | |
200 | cfg = simple_strtoul (argv[1], NULL, 10); | |
201 | ||
202 | if (cfg > 7) { | |
203 | printf ("\nInvalid Configuration\n\n"); | |
204 | p[SYSACE_CTRLREG0] = 0x00; | |
205 | return 1; | |
206 | } | |
207 | /* Set config address */ | |
208 | p[SYSACE_CTRLREG1] = (cfg << 5); | |
209 | /* force cfgaddr */ | |
210 | p[SYSACE_CTRLREG0] |= 0x04; | |
211 | ||
212 | } else { | |
213 | cfg = (p[SYSACE_STATREG1] & 0xE0) >> 5; | |
214 | } | |
215 | ||
216 | /* release configuration controller */ | |
217 | printf ("\nLoading V2PRO with config %d...\n", cfg); | |
218 | p[SYSACE_CTRLREG0] &= ~0x80; | |
219 | ||
220 | ||
221 | while ((p[SYSACE_STATREG1] & 0x01) == 0) { | |
222 | ||
223 | if (p[SYSACE_ERRREG0] & 0x80) { | |
224 | /* attempting to load an invalid configuration makes the cpflash */ | |
225 | /* appear to be removed. Reset here to avoid that problem */ | |
226 | p[SYSACE_CTRLREG0] = 0x80; | |
227 | printf ("\nConfiguration %d Read Error\n\n", cfg); | |
228 | p[SYSACE_CTRLREG0] = 0x00; | |
229 | return 1; | |
230 | } | |
231 | } | |
232 | ||
233 | p[SYSACE_CTRLREG0] |= 0x20; | |
234 | ||
235 | return 0; | |
7521af1c WD |
236 | } |
237 | #endif | |
238 | ||
239 | /** Console command to display and set the software reconfigure byte | |
240 | * <pre> | |
241 | * swconfig - display the current value of the software reconfigure byte | |
242 | * swconfig [#] - change the software reconfigure byte to # | |
243 | * </pre> | |
244 | * @param *cmdtp [IN] as passed by run_command (ignored) | |
245 | * @param flag [IN] as passed by run_command (ignored) | |
246 | * @param argc [IN] as passed by run_command if 1, display, if 2 change | |
247 | * @param *argv[] [IN] contains the parameters to use | |
248 | * @return | |
249 | * <pre> | |
250 | * 0 if passed | |
251 | * -1 if failed | |
252 | * </pre> | |
253 | */ | |
54841ab5 | 254 | int do_swconfigbyte (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
3df5bea0 WD |
255 | { |
256 | unsigned char *sector_buffer = NULL; | |
257 | unsigned char input_char; | |
258 | int write_result; | |
259 | unsigned int input_uint; | |
260 | ||
261 | /* display value if no argument */ | |
262 | if (argc < 2) { | |
263 | printf ("Software configuration byte is currently: 0x%02x\n", | |
264 | *((unsigned char *) (SW_BYTE_SECTOR_ADDR + | |
265 | SW_BYTE_SECTOR_OFFSET))); | |
266 | return 0; | |
267 | } else if (argc > 3) { | |
268 | printf ("Too many arguments\n"); | |
269 | return -1; | |
270 | } | |
271 | ||
272 | /* if 3 arguments, 3rd argument is the address to use */ | |
273 | if (argc == 3) { | |
274 | input_uint = simple_strtoul (argv[1], NULL, 16); | |
275 | sector_buffer = (unsigned char *) input_uint; | |
276 | } else { | |
277 | sector_buffer = (unsigned char *) DEFAULT_TEMP_ADDR; | |
278 | } | |
279 | ||
280 | input_char = simple_strtoul (argv[1], NULL, 0); | |
281 | if ((input_char & ~SW_BYTE_MASK) != 0) { | |
282 | printf ("Input of 0x%02x will be masked to 0x%02x\n", | |
283 | input_char, (input_char & SW_BYTE_MASK)); | |
284 | input_char = input_char & SW_BYTE_MASK; | |
285 | } | |
286 | ||
287 | memcpy (sector_buffer, (void *) SW_BYTE_SECTOR_ADDR, | |
288 | SW_BYTE_SECTOR_SIZE); | |
289 | sector_buffer[SW_BYTE_SECTOR_OFFSET] = input_char; | |
290 | ||
291 | ||
292 | printf ("Erasing Flash..."); | |
293 | if (flash_sect_erase | |
294 | (SW_BYTE_SECTOR_ADDR, | |
295 | (SW_BYTE_SECTOR_ADDR + SW_BYTE_SECTOR_OFFSET))) { | |
296 | return -1; | |
297 | } | |
298 | ||
299 | printf ("Writing to Flash... "); | |
300 | write_result = | |
18c5e64c | 301 | flash_write ((char *)sector_buffer, SW_BYTE_SECTOR_ADDR, |
3df5bea0 WD |
302 | SW_BYTE_SECTOR_SIZE); |
303 | if (write_result != 0) { | |
304 | flash_perror (write_result); | |
305 | return -1; | |
306 | } else { | |
307 | printf ("done\n"); | |
308 | printf ("Software configuration byte is now: 0x%02x\n", | |
309 | *((unsigned char *) (SW_BYTE_SECTOR_ADDR + | |
310 | SW_BYTE_SECTOR_OFFSET))); | |
311 | } | |
312 | ||
313 | return 0; | |
7521af1c WD |
314 | } |
315 | ||
316 | #define ONE_SECOND 1000000 | |
317 | ||
54841ab5 | 318 | int do_pause (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
3df5bea0 WD |
319 | { |
320 | int pause_time; | |
321 | unsigned int delay_time; | |
322 | int break_loop = 0; | |
323 | ||
324 | /* display value if no argument */ | |
325 | if (argc < 2) { | |
326 | pause_time = 1; | |
327 | } | |
328 | ||
329 | else if (argc > 2) { | |
330 | printf ("Too many arguments\n"); | |
331 | return -1; | |
332 | } else { | |
333 | pause_time = simple_strtoul (argv[1], NULL, 0); | |
334 | } | |
335 | ||
336 | printf ("Pausing with a poll time of %d, press any key to reactivate\n", pause_time); | |
337 | delay_time = pause_time * ONE_SECOND; | |
338 | while (break_loop == 0) { | |
339 | udelay (delay_time); | |
340 | if (serial_tstc () != 0) { | |
341 | break_loop = 1; | |
342 | /* eat user key presses */ | |
343 | while (serial_tstc () != 0) { | |
344 | serial_getc (); | |
345 | } | |
346 | } | |
347 | } | |
348 | ||
349 | return 0; | |
7521af1c WD |
350 | } |
351 | ||
54841ab5 | 352 | int do_swreconfig (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
3df5bea0 WD |
353 | { |
354 | printf ("Triggering software reconfigure (software config byte is 0x%02x)...\n", | |
355 | *((unsigned char *) (SW_BYTE_SECTOR_ADDR + SW_BYTE_SECTOR_OFFSET))); | |
356 | udelay (1000); | |
357 | *((unsigned char *) AP1000_CPLD_BASE) = 1; | |
7521af1c | 358 | |
3df5bea0 | 359 | return 0; |
7521af1c WD |
360 | } |
361 | ||
362 | #define GET_DECIMAL(low_byte) ((low_byte >> 5) * 125) | |
363 | #define TEMP_BUSY_BIT 0x80 | |
364 | #define TEMP_LHIGH_BIT 0x40 | |
365 | #define TEMP_LLOW_BIT 0x20 | |
366 | #define TEMP_EHIGH_BIT 0x10 | |
367 | #define TEMP_ELOW_BIT 0x08 | |
368 | #define TEMP_OPEN_BIT 0x04 | |
369 | #define TEMP_ETHERM_BIT 0x02 | |
370 | #define TEMP_LTHERM_BIT 0x01 | |
371 | ||
54841ab5 | 372 | int do_temp_sensor (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
3df5bea0 WD |
373 | { |
374 | char cmd; | |
375 | int ret_val = 0; | |
376 | unsigned char temp_byte; | |
377 | int temp; | |
378 | int temp_low; | |
379 | int low; | |
380 | int low_low; | |
381 | int high; | |
382 | int high_low; | |
383 | int therm; | |
384 | unsigned char user_data[4] = { 0 }; | |
385 | int user_data_count = 0; | |
386 | int ii; | |
387 | ||
388 | if (argc > 1) { | |
389 | cmd = argv[1][0]; | |
390 | } else { | |
391 | cmd = 's'; /* default to status */ | |
392 | } | |
393 | ||
394 | user_data_count = argc - 2; | |
395 | for (ii = 0; ii < user_data_count; ii++) { | |
396 | user_data[ii] = simple_strtoul (argv[2 + ii], NULL, 0); | |
397 | } | |
398 | switch (cmd) { | |
399 | case 's': | |
400 | if (I2CAccess | |
401 | (0x2, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
402 | &temp_byte, I2C_READ) != 0) { | |
403 | goto fail; | |
404 | } | |
405 | printf ("Status : 0x%02x ", temp_byte); | |
406 | if (temp_byte & TEMP_BUSY_BIT) | |
407 | printf ("BUSY "); | |
408 | ||
409 | if (temp_byte & TEMP_LHIGH_BIT) | |
410 | printf ("LHIGH "); | |
411 | ||
412 | if (temp_byte & TEMP_LLOW_BIT) | |
413 | printf ("LLOW "); | |
414 | ||
415 | if (temp_byte & TEMP_EHIGH_BIT) | |
416 | printf ("EHIGH "); | |
417 | ||
418 | if (temp_byte & TEMP_ELOW_BIT) | |
419 | printf ("ELOW "); | |
420 | ||
421 | if (temp_byte & TEMP_OPEN_BIT) | |
422 | printf ("OPEN "); | |
423 | ||
424 | if (temp_byte & TEMP_ETHERM_BIT) | |
425 | printf ("ETHERM "); | |
426 | ||
427 | if (temp_byte & TEMP_LTHERM_BIT) | |
428 | printf ("LTHERM"); | |
429 | ||
430 | printf ("\n"); | |
431 | ||
432 | if (I2CAccess | |
433 | (0x3, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
434 | &temp_byte, I2C_READ) != 0) { | |
435 | goto fail; | |
436 | } | |
437 | printf ("Config : 0x%02x ", temp_byte); | |
438 | ||
439 | if (I2CAccess | |
440 | (0x4, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
441 | &temp_byte, I2C_READ) != 0) { | |
442 | printf ("\n"); | |
443 | goto fail; | |
444 | } | |
445 | printf ("Conversion: 0x%02x\n", temp_byte); | |
446 | if (I2CAccess | |
447 | (0x22, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
448 | &temp_byte, I2C_READ) != 0) { | |
449 | goto fail; | |
450 | } | |
451 | printf ("Cons Alert: 0x%02x ", temp_byte); | |
452 | ||
453 | if (I2CAccess | |
454 | (0x21, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
455 | &temp_byte, I2C_READ) != 0) { | |
456 | printf ("\n"); | |
457 | goto fail; | |
458 | } | |
459 | printf ("Therm Hyst: %d\n", temp_byte); | |
460 | ||
461 | if (I2CAccess | |
462 | (0x0, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
463 | &temp_byte, I2C_READ) != 0) { | |
464 | goto fail; | |
465 | } | |
466 | temp = temp_byte; | |
467 | if (I2CAccess | |
468 | (0x6, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
469 | &temp_byte, I2C_READ) != 0) { | |
470 | goto fail; | |
471 | } | |
472 | low = temp_byte; | |
473 | if (I2CAccess | |
474 | (0x5, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
475 | &temp_byte, I2C_READ) != 0) { | |
476 | goto fail; | |
477 | } | |
478 | high = temp_byte; | |
479 | if (I2CAccess | |
480 | (0x20, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
481 | &temp_byte, I2C_READ) != 0) { | |
482 | goto fail; | |
483 | } | |
484 | therm = temp_byte; | |
485 | printf ("Local Temp: %2d Low: %2d High: %2d THERM: %2d\n", temp, low, high, therm); | |
486 | ||
487 | if (I2CAccess | |
488 | (0x1, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
489 | &temp_byte, I2C_READ) != 0) { | |
490 | goto fail; | |
491 | } | |
492 | temp = temp_byte; | |
493 | if (I2CAccess | |
494 | (0x10, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
495 | &temp_byte, I2C_READ) != 0) { | |
496 | goto fail; | |
497 | } | |
498 | temp_low = temp_byte; | |
499 | if (I2CAccess | |
500 | (0x8, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
501 | &temp_byte, I2C_READ) != 0) { | |
502 | goto fail; | |
503 | } | |
504 | low = temp_byte; | |
505 | if (I2CAccess | |
506 | (0x14, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
507 | &temp_byte, I2C_READ) != 0) { | |
508 | goto fail; | |
509 | } | |
510 | low_low = temp_byte; | |
511 | if (I2CAccess | |
512 | (0x7, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
513 | &temp_byte, I2C_READ) != 0) { | |
514 | goto fail; | |
515 | } | |
516 | high = temp_byte; | |
517 | if (I2CAccess | |
518 | (0x13, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
519 | &temp_byte, I2C_READ) != 0) { | |
520 | goto fail; | |
521 | } | |
522 | high_low = temp_byte; | |
523 | if (I2CAccess | |
524 | (0x19, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
525 | &temp_byte, I2C_READ) != 0) { | |
526 | goto fail; | |
527 | } | |
528 | therm = temp_byte; | |
529 | if (I2CAccess | |
530 | (0x11, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
531 | &temp_byte, I2C_READ) != 0) { | |
532 | goto fail; | |
533 | } | |
534 | printf ("Ext Temp : %2d.%03d Low: %2d.%03d High: %2d.%03d THERM: %2d Offset: %2d\n", temp, GET_DECIMAL (temp_low), low, GET_DECIMAL (low_low), high, GET_DECIMAL (high_low), therm, temp_byte); | |
535 | break; | |
536 | case 'l': /* alter local limits : low, high, therm */ | |
537 | if (argc < 3) { | |
538 | goto usage; | |
539 | } | |
540 | ||
541 | /* low */ | |
542 | if (I2CAccess | |
543 | (0xC, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
544 | &user_data[0], I2C_WRITE) != 0) { | |
545 | goto fail; | |
546 | } | |
547 | ||
548 | if (user_data_count > 1) { | |
549 | /* high */ | |
550 | if (I2CAccess | |
551 | (0xB, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
552 | &user_data[1], I2C_WRITE) != 0) { | |
553 | goto fail; | |
554 | } | |
555 | } | |
556 | ||
557 | if (user_data_count > 2) { | |
558 | /* therm */ | |
559 | if (I2CAccess | |
560 | (0x20, I2C_SENSOR_DEV, | |
561 | I2C_SENSOR_CHIP_SEL, &user_data[2], | |
562 | I2C_WRITE) != 0) { | |
563 | goto fail; | |
564 | } | |
565 | } | |
566 | break; | |
567 | case 'e': /* alter external limits: low, high, therm, offset */ | |
568 | if (argc < 3) { | |
569 | goto usage; | |
570 | } | |
571 | ||
572 | /* low */ | |
573 | if (I2CAccess | |
574 | (0xE, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
575 | &user_data[0], I2C_WRITE) != 0) { | |
576 | goto fail; | |
577 | } | |
578 | ||
579 | if (user_data_count > 1) { | |
580 | /* high */ | |
581 | if (I2CAccess | |
582 | (0xD, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
583 | &user_data[1], I2C_WRITE) != 0) { | |
584 | goto fail; | |
585 | } | |
586 | } | |
587 | ||
588 | if (user_data_count > 2) { | |
589 | /* therm */ | |
590 | if (I2CAccess | |
591 | (0x19, I2C_SENSOR_DEV, | |
592 | I2C_SENSOR_CHIP_SEL, &user_data[2], | |
593 | I2C_WRITE) != 0) { | |
594 | goto fail; | |
595 | } | |
596 | } | |
597 | ||
598 | if (user_data_count > 3) { | |
599 | /* offset */ | |
600 | if (I2CAccess | |
601 | (0x11, I2C_SENSOR_DEV, | |
602 | I2C_SENSOR_CHIP_SEL, &user_data[3], | |
603 | I2C_WRITE) != 0) { | |
604 | goto fail; | |
605 | } | |
606 | } | |
607 | break; | |
608 | case 'c': /* alter config settings: config, conv, cons alert, therm hyst */ | |
609 | if (argc < 3) { | |
610 | goto usage; | |
611 | } | |
612 | ||
613 | /* config */ | |
614 | if (I2CAccess | |
615 | (0x9, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
616 | &user_data[0], I2C_WRITE) != 0) { | |
617 | goto fail; | |
618 | } | |
619 | ||
620 | if (user_data_count > 1) { | |
621 | /* conversion */ | |
622 | if (I2CAccess | |
623 | (0xA, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
624 | &user_data[1], I2C_WRITE) != 0) { | |
625 | goto fail; | |
626 | } | |
627 | } | |
628 | ||
629 | if (user_data_count > 2) { | |
630 | /* cons alert */ | |
631 | if (I2CAccess | |
632 | (0x22, I2C_SENSOR_DEV, | |
633 | I2C_SENSOR_CHIP_SEL, &user_data[2], | |
634 | I2C_WRITE) != 0) { | |
635 | goto fail; | |
636 | } | |
637 | } | |
638 | ||
639 | if (user_data_count > 3) { | |
640 | /* therm hyst */ | |
641 | if (I2CAccess | |
642 | (0x21, I2C_SENSOR_DEV, | |
643 | I2C_SENSOR_CHIP_SEL, &user_data[3], | |
644 | I2C_WRITE) != 0) { | |
645 | goto fail; | |
646 | } | |
647 | } | |
648 | break; | |
649 | default: | |
650 | goto usage; | |
651 | } | |
652 | ||
653 | goto done; | |
654 | fail: | |
655 | printf ("Access to sensor failed\n"); | |
656 | ret_val = -1; | |
657 | goto done; | |
658 | usage: | |
659 | printf ("Usage:\n%s\n", cmdtp->help); | |
660 | ||
661 | done: | |
662 | return ret_val; | |
7521af1c WD |
663 | } |
664 | ||
3df5bea0 | 665 | U_BOOT_CMD (temp, 6, 0, do_temp_sensor, |
2fb2604d | 666 | "interact with the temperature sensor", |
3df5bea0 WD |
667 | "temp [s]\n" |
668 | " - Show status.\n" | |
669 | "temp l LOW [HIGH] [THERM]\n" | |
670 | " - Set local limits.\n" | |
671 | "temp e LOW [HIGH] [THERM] [OFFSET]\n" | |
672 | " - Set external limits.\n" | |
673 | "temp c CONFIG [CONVERSION] [CONS. ALERT] [THERM HYST]\n" | |
674 | " - Set config options.\n" | |
675 | "\n" | |
676 | "All values can be decimal or hex (hex preceded with 0x).\n" | |
a89c33db | 677 | "Only whole numbers are supported for external limits."); |
7521af1c WD |
678 | |
679 | #if 0 | |
3df5bea0 | 680 | U_BOOT_CMD (loadace, 2, 0, do_loadace, |
2fb2604d | 681 | "load fpga configuration from System ACE compact flash", |
3df5bea0 WD |
682 | "N\n" |
683 | " - Load configuration N (0-7) from System ACE compact flash\n" | |
a89c33db | 684 | "loadace\n" " - loads default configuration"); |
7521af1c WD |
685 | #endif |
686 | ||
3df5bea0 | 687 | U_BOOT_CMD (swconfig, 2, 0, do_swconfigbyte, |
2fb2604d | 688 | "display or modify the software configuration byte", |
3df5bea0 WD |
689 | "N [ADDRESS]\n" |
690 | " - set software configuration byte to N, optionally use ADDRESS as\n" | |
691 | " location of buffer for flash copy\n" | |
a89c33db | 692 | "swconfig\n" " - display software configuration byte"); |
3df5bea0 WD |
693 | |
694 | U_BOOT_CMD (pause, 2, 0, do_pause, | |
2fb2604d | 695 | "sleep processor until any key is pressed with poll time of N seconds", |
3df5bea0 WD |
696 | "N\n" |
697 | " - sleep processor until any key is pressed with poll time of N seconds\n" | |
698 | "pause\n" | |
a89c33db | 699 | " - sleep processor until any key is pressed with poll time of 1 second"); |
3df5bea0 WD |
700 | |
701 | U_BOOT_CMD (swrecon, 1, 0, do_swreconfig, | |
2fb2604d | 702 | "trigger a board reconfigure to the software selected configuration", |
3df5bea0 | 703 | "\n" |
a89c33db | 704 | " - trigger a board reconfigure to the software selected configuration"); |
ad3381cf BW |
705 | |
706 | int board_eth_init(bd_t *bis) | |
707 | { | |
708 | return pci_eth_init(bis); | |
709 | } |