]>
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 | { | |
18c5e64c SR |
40 | char *s = getenv ("serial#"); |
41 | char *e; | |
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 | ||
118 | if (!s) { | |
119 | printf ("### No HW ID - assuming AMIRIX"); | |
120 | } else { | |
121 | for (e = s; *e; ++e) { | |
122 | if (*e == ' ') | |
123 | break; | |
124 | } | |
125 | ||
126 | for (; s < e; ++s) { | |
127 | putc (*s); | |
128 | } | |
129 | } | |
130 | ||
131 | putc ('\n'); | |
132 | ||
133 | return (0); | |
7521af1c WD |
134 | } |
135 | ||
136 | ||
9973e3c6 | 137 | phys_size_t initdram (int board_type) |
7521af1c | 138 | { |
18c5e64c | 139 | char *s = getenv ("dramsize"); |
3df5bea0 WD |
140 | |
141 | if (s != NULL) { | |
142 | if ((s[0] == '0') && ((s[1] == 'x') || (s[1] == 'X'))) { | |
143 | s += 2; | |
144 | } | |
18c5e64c | 145 | return (long int)simple_strtoul (s, NULL, 16); |
3df5bea0 WD |
146 | } else { |
147 | /* give all 64 MB */ | |
7521af1c | 148 | return 64 * 1024 * 1024; |
3df5bea0 | 149 | } |
7521af1c WD |
150 | } |
151 | ||
3df5bea0 WD |
152 | unsigned int get_platform (void) |
153 | { | |
154 | unsigned int *revision_reg_ptr = (unsigned int *) AP1xx_FPGA_REV_ADDR; | |
155 | ||
156 | return (*revision_reg_ptr & AP1xx_PLATFORM_MASK); | |
7521af1c WD |
157 | } |
158 | ||
3df5bea0 WD |
159 | unsigned int get_device (void) |
160 | { | |
161 | unsigned int *revision_reg_ptr = (unsigned int *) AP1xx_FPGA_REV_ADDR; | |
7521af1c | 162 | |
3df5bea0 | 163 | return (*revision_reg_ptr & AP1xx_TARGET_MASK); |
7521af1c WD |
164 | } |
165 | ||
3df5bea0 | 166 | #if 0 /* loadace is not working; it appears to be a hardware issue with the system ace. */ |
7521af1c WD |
167 | /* |
168 | This function loads FPGA configurations from the SystemACE CompactFlash | |
169 | */ | |
3df5bea0 | 170 | int do_loadace (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
7521af1c | 171 | { |
3df5bea0 WD |
172 | unsigned char *p = (unsigned char *) AP1000_SYSACE_REGBASE; |
173 | int cfg; | |
174 | ||
175 | if ((p[SYSACE_STATREG0] & 0x10) == 0) { | |
176 | p[SYSACE_CTRLREG0] = 0x80; | |
177 | printf ("\nNo CompactFlash Detected\n\n"); | |
178 | p[SYSACE_CTRLREG0] = 0x00; | |
179 | return 1; | |
180 | } | |
181 | ||
182 | /* reset configuration controller: | 0x80 */ | |
183 | /* select cpflash & ~0x40 */ | |
184 | /* cfg start | 0x20 */ | |
185 | /* wait for cfgstart & ~0x10 */ | |
186 | /* force cfgmode: | 0x08 */ | |
187 | /* do no force cfgaddr: & ~0x04 */ | |
188 | /* clear mpulock: & ~0x02 */ | |
189 | /* do not force lock request & ~0x01 */ | |
190 | ||
191 | p[SYSACE_CTRLREG0] = 0x80 | 0x20 | 0x08; | |
192 | p[SYSACE_CTRLREG1] = 0x00; | |
193 | ||
194 | /* force config address if arg2 exists */ | |
195 | if (argc == 2) { | |
196 | cfg = simple_strtoul (argv[1], NULL, 10); | |
197 | ||
198 | if (cfg > 7) { | |
199 | printf ("\nInvalid Configuration\n\n"); | |
200 | p[SYSACE_CTRLREG0] = 0x00; | |
201 | return 1; | |
202 | } | |
203 | /* Set config address */ | |
204 | p[SYSACE_CTRLREG1] = (cfg << 5); | |
205 | /* force cfgaddr */ | |
206 | p[SYSACE_CTRLREG0] |= 0x04; | |
207 | ||
208 | } else { | |
209 | cfg = (p[SYSACE_STATREG1] & 0xE0) >> 5; | |
210 | } | |
211 | ||
212 | /* release configuration controller */ | |
213 | printf ("\nLoading V2PRO with config %d...\n", cfg); | |
214 | p[SYSACE_CTRLREG0] &= ~0x80; | |
215 | ||
216 | ||
217 | while ((p[SYSACE_STATREG1] & 0x01) == 0) { | |
218 | ||
219 | if (p[SYSACE_ERRREG0] & 0x80) { | |
220 | /* attempting to load an invalid configuration makes the cpflash */ | |
221 | /* appear to be removed. Reset here to avoid that problem */ | |
222 | p[SYSACE_CTRLREG0] = 0x80; | |
223 | printf ("\nConfiguration %d Read Error\n\n", cfg); | |
224 | p[SYSACE_CTRLREG0] = 0x00; | |
225 | return 1; | |
226 | } | |
227 | } | |
228 | ||
229 | p[SYSACE_CTRLREG0] |= 0x20; | |
230 | ||
231 | return 0; | |
7521af1c WD |
232 | } |
233 | #endif | |
234 | ||
235 | /** Console command to display and set the software reconfigure byte | |
236 | * <pre> | |
237 | * swconfig - display the current value of the software reconfigure byte | |
238 | * swconfig [#] - change the software reconfigure byte to # | |
239 | * </pre> | |
240 | * @param *cmdtp [IN] as passed by run_command (ignored) | |
241 | * @param flag [IN] as passed by run_command (ignored) | |
242 | * @param argc [IN] as passed by run_command if 1, display, if 2 change | |
243 | * @param *argv[] [IN] contains the parameters to use | |
244 | * @return | |
245 | * <pre> | |
246 | * 0 if passed | |
247 | * -1 if failed | |
248 | * </pre> | |
249 | */ | |
3df5bea0 WD |
250 | int do_swconfigbyte (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
251 | { | |
252 | unsigned char *sector_buffer = NULL; | |
253 | unsigned char input_char; | |
254 | int write_result; | |
255 | unsigned int input_uint; | |
256 | ||
257 | /* display value if no argument */ | |
258 | if (argc < 2) { | |
259 | printf ("Software configuration byte is currently: 0x%02x\n", | |
260 | *((unsigned char *) (SW_BYTE_SECTOR_ADDR + | |
261 | SW_BYTE_SECTOR_OFFSET))); | |
262 | return 0; | |
263 | } else if (argc > 3) { | |
264 | printf ("Too many arguments\n"); | |
265 | return -1; | |
266 | } | |
267 | ||
268 | /* if 3 arguments, 3rd argument is the address to use */ | |
269 | if (argc == 3) { | |
270 | input_uint = simple_strtoul (argv[1], NULL, 16); | |
271 | sector_buffer = (unsigned char *) input_uint; | |
272 | } else { | |
273 | sector_buffer = (unsigned char *) DEFAULT_TEMP_ADDR; | |
274 | } | |
275 | ||
276 | input_char = simple_strtoul (argv[1], NULL, 0); | |
277 | if ((input_char & ~SW_BYTE_MASK) != 0) { | |
278 | printf ("Input of 0x%02x will be masked to 0x%02x\n", | |
279 | input_char, (input_char & SW_BYTE_MASK)); | |
280 | input_char = input_char & SW_BYTE_MASK; | |
281 | } | |
282 | ||
283 | memcpy (sector_buffer, (void *) SW_BYTE_SECTOR_ADDR, | |
284 | SW_BYTE_SECTOR_SIZE); | |
285 | sector_buffer[SW_BYTE_SECTOR_OFFSET] = input_char; | |
286 | ||
287 | ||
288 | printf ("Erasing Flash..."); | |
289 | if (flash_sect_erase | |
290 | (SW_BYTE_SECTOR_ADDR, | |
291 | (SW_BYTE_SECTOR_ADDR + SW_BYTE_SECTOR_OFFSET))) { | |
292 | return -1; | |
293 | } | |
294 | ||
295 | printf ("Writing to Flash... "); | |
296 | write_result = | |
18c5e64c | 297 | flash_write ((char *)sector_buffer, SW_BYTE_SECTOR_ADDR, |
3df5bea0 WD |
298 | SW_BYTE_SECTOR_SIZE); |
299 | if (write_result != 0) { | |
300 | flash_perror (write_result); | |
301 | return -1; | |
302 | } else { | |
303 | printf ("done\n"); | |
304 | printf ("Software configuration byte is now: 0x%02x\n", | |
305 | *((unsigned char *) (SW_BYTE_SECTOR_ADDR + | |
306 | SW_BYTE_SECTOR_OFFSET))); | |
307 | } | |
308 | ||
309 | return 0; | |
7521af1c WD |
310 | } |
311 | ||
312 | #define ONE_SECOND 1000000 | |
313 | ||
3df5bea0 WD |
314 | int do_pause (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
315 | { | |
316 | int pause_time; | |
317 | unsigned int delay_time; | |
318 | int break_loop = 0; | |
319 | ||
320 | /* display value if no argument */ | |
321 | if (argc < 2) { | |
322 | pause_time = 1; | |
323 | } | |
324 | ||
325 | else if (argc > 2) { | |
326 | printf ("Too many arguments\n"); | |
327 | return -1; | |
328 | } else { | |
329 | pause_time = simple_strtoul (argv[1], NULL, 0); | |
330 | } | |
331 | ||
332 | printf ("Pausing with a poll time of %d, press any key to reactivate\n", pause_time); | |
333 | delay_time = pause_time * ONE_SECOND; | |
334 | while (break_loop == 0) { | |
335 | udelay (delay_time); | |
336 | if (serial_tstc () != 0) { | |
337 | break_loop = 1; | |
338 | /* eat user key presses */ | |
339 | while (serial_tstc () != 0) { | |
340 | serial_getc (); | |
341 | } | |
342 | } | |
343 | } | |
344 | ||
345 | return 0; | |
7521af1c WD |
346 | } |
347 | ||
3df5bea0 WD |
348 | int do_swreconfig (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
349 | { | |
350 | printf ("Triggering software reconfigure (software config byte is 0x%02x)...\n", | |
351 | *((unsigned char *) (SW_BYTE_SECTOR_ADDR + SW_BYTE_SECTOR_OFFSET))); | |
352 | udelay (1000); | |
353 | *((unsigned char *) AP1000_CPLD_BASE) = 1; | |
7521af1c | 354 | |
3df5bea0 | 355 | return 0; |
7521af1c WD |
356 | } |
357 | ||
358 | #define GET_DECIMAL(low_byte) ((low_byte >> 5) * 125) | |
359 | #define TEMP_BUSY_BIT 0x80 | |
360 | #define TEMP_LHIGH_BIT 0x40 | |
361 | #define TEMP_LLOW_BIT 0x20 | |
362 | #define TEMP_EHIGH_BIT 0x10 | |
363 | #define TEMP_ELOW_BIT 0x08 | |
364 | #define TEMP_OPEN_BIT 0x04 | |
365 | #define TEMP_ETHERM_BIT 0x02 | |
366 | #define TEMP_LTHERM_BIT 0x01 | |
367 | ||
3df5bea0 WD |
368 | int do_temp_sensor (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
369 | { | |
370 | char cmd; | |
371 | int ret_val = 0; | |
372 | unsigned char temp_byte; | |
373 | int temp; | |
374 | int temp_low; | |
375 | int low; | |
376 | int low_low; | |
377 | int high; | |
378 | int high_low; | |
379 | int therm; | |
380 | unsigned char user_data[4] = { 0 }; | |
381 | int user_data_count = 0; | |
382 | int ii; | |
383 | ||
384 | if (argc > 1) { | |
385 | cmd = argv[1][0]; | |
386 | } else { | |
387 | cmd = 's'; /* default to status */ | |
388 | } | |
389 | ||
390 | user_data_count = argc - 2; | |
391 | for (ii = 0; ii < user_data_count; ii++) { | |
392 | user_data[ii] = simple_strtoul (argv[2 + ii], NULL, 0); | |
393 | } | |
394 | switch (cmd) { | |
395 | case 's': | |
396 | if (I2CAccess | |
397 | (0x2, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
398 | &temp_byte, I2C_READ) != 0) { | |
399 | goto fail; | |
400 | } | |
401 | printf ("Status : 0x%02x ", temp_byte); | |
402 | if (temp_byte & TEMP_BUSY_BIT) | |
403 | printf ("BUSY "); | |
404 | ||
405 | if (temp_byte & TEMP_LHIGH_BIT) | |
406 | printf ("LHIGH "); | |
407 | ||
408 | if (temp_byte & TEMP_LLOW_BIT) | |
409 | printf ("LLOW "); | |
410 | ||
411 | if (temp_byte & TEMP_EHIGH_BIT) | |
412 | printf ("EHIGH "); | |
413 | ||
414 | if (temp_byte & TEMP_ELOW_BIT) | |
415 | printf ("ELOW "); | |
416 | ||
417 | if (temp_byte & TEMP_OPEN_BIT) | |
418 | printf ("OPEN "); | |
419 | ||
420 | if (temp_byte & TEMP_ETHERM_BIT) | |
421 | printf ("ETHERM "); | |
422 | ||
423 | if (temp_byte & TEMP_LTHERM_BIT) | |
424 | printf ("LTHERM"); | |
425 | ||
426 | printf ("\n"); | |
427 | ||
428 | if (I2CAccess | |
429 | (0x3, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
430 | &temp_byte, I2C_READ) != 0) { | |
431 | goto fail; | |
432 | } | |
433 | printf ("Config : 0x%02x ", temp_byte); | |
434 | ||
435 | if (I2CAccess | |
436 | (0x4, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
437 | &temp_byte, I2C_READ) != 0) { | |
438 | printf ("\n"); | |
439 | goto fail; | |
440 | } | |
441 | printf ("Conversion: 0x%02x\n", temp_byte); | |
442 | if (I2CAccess | |
443 | (0x22, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
444 | &temp_byte, I2C_READ) != 0) { | |
445 | goto fail; | |
446 | } | |
447 | printf ("Cons Alert: 0x%02x ", temp_byte); | |
448 | ||
449 | if (I2CAccess | |
450 | (0x21, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
451 | &temp_byte, I2C_READ) != 0) { | |
452 | printf ("\n"); | |
453 | goto fail; | |
454 | } | |
455 | printf ("Therm Hyst: %d\n", temp_byte); | |
456 | ||
457 | if (I2CAccess | |
458 | (0x0, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
459 | &temp_byte, I2C_READ) != 0) { | |
460 | goto fail; | |
461 | } | |
462 | temp = temp_byte; | |
463 | if (I2CAccess | |
464 | (0x6, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
465 | &temp_byte, I2C_READ) != 0) { | |
466 | goto fail; | |
467 | } | |
468 | low = temp_byte; | |
469 | if (I2CAccess | |
470 | (0x5, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
471 | &temp_byte, I2C_READ) != 0) { | |
472 | goto fail; | |
473 | } | |
474 | high = temp_byte; | |
475 | if (I2CAccess | |
476 | (0x20, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
477 | &temp_byte, I2C_READ) != 0) { | |
478 | goto fail; | |
479 | } | |
480 | therm = temp_byte; | |
481 | printf ("Local Temp: %2d Low: %2d High: %2d THERM: %2d\n", temp, low, high, therm); | |
482 | ||
483 | if (I2CAccess | |
484 | (0x1, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
485 | &temp_byte, I2C_READ) != 0) { | |
486 | goto fail; | |
487 | } | |
488 | temp = temp_byte; | |
489 | if (I2CAccess | |
490 | (0x10, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
491 | &temp_byte, I2C_READ) != 0) { | |
492 | goto fail; | |
493 | } | |
494 | temp_low = temp_byte; | |
495 | if (I2CAccess | |
496 | (0x8, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
497 | &temp_byte, I2C_READ) != 0) { | |
498 | goto fail; | |
499 | } | |
500 | low = temp_byte; | |
501 | if (I2CAccess | |
502 | (0x14, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
503 | &temp_byte, I2C_READ) != 0) { | |
504 | goto fail; | |
505 | } | |
506 | low_low = temp_byte; | |
507 | if (I2CAccess | |
508 | (0x7, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
509 | &temp_byte, I2C_READ) != 0) { | |
510 | goto fail; | |
511 | } | |
512 | high = temp_byte; | |
513 | if (I2CAccess | |
514 | (0x13, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
515 | &temp_byte, I2C_READ) != 0) { | |
516 | goto fail; | |
517 | } | |
518 | high_low = temp_byte; | |
519 | if (I2CAccess | |
520 | (0x19, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
521 | &temp_byte, I2C_READ) != 0) { | |
522 | goto fail; | |
523 | } | |
524 | therm = temp_byte; | |
525 | if (I2CAccess | |
526 | (0x11, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
527 | &temp_byte, I2C_READ) != 0) { | |
528 | goto fail; | |
529 | } | |
530 | 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); | |
531 | break; | |
532 | case 'l': /* alter local limits : low, high, therm */ | |
533 | if (argc < 3) { | |
534 | goto usage; | |
535 | } | |
536 | ||
537 | /* low */ | |
538 | if (I2CAccess | |
539 | (0xC, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
540 | &user_data[0], I2C_WRITE) != 0) { | |
541 | goto fail; | |
542 | } | |
543 | ||
544 | if (user_data_count > 1) { | |
545 | /* high */ | |
546 | if (I2CAccess | |
547 | (0xB, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
548 | &user_data[1], I2C_WRITE) != 0) { | |
549 | goto fail; | |
550 | } | |
551 | } | |
552 | ||
553 | if (user_data_count > 2) { | |
554 | /* therm */ | |
555 | if (I2CAccess | |
556 | (0x20, I2C_SENSOR_DEV, | |
557 | I2C_SENSOR_CHIP_SEL, &user_data[2], | |
558 | I2C_WRITE) != 0) { | |
559 | goto fail; | |
560 | } | |
561 | } | |
562 | break; | |
563 | case 'e': /* alter external limits: low, high, therm, offset */ | |
564 | if (argc < 3) { | |
565 | goto usage; | |
566 | } | |
567 | ||
568 | /* low */ | |
569 | if (I2CAccess | |
570 | (0xE, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
571 | &user_data[0], I2C_WRITE) != 0) { | |
572 | goto fail; | |
573 | } | |
574 | ||
575 | if (user_data_count > 1) { | |
576 | /* high */ | |
577 | if (I2CAccess | |
578 | (0xD, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
579 | &user_data[1], I2C_WRITE) != 0) { | |
580 | goto fail; | |
581 | } | |
582 | } | |
583 | ||
584 | if (user_data_count > 2) { | |
585 | /* therm */ | |
586 | if (I2CAccess | |
587 | (0x19, I2C_SENSOR_DEV, | |
588 | I2C_SENSOR_CHIP_SEL, &user_data[2], | |
589 | I2C_WRITE) != 0) { | |
590 | goto fail; | |
591 | } | |
592 | } | |
593 | ||
594 | if (user_data_count > 3) { | |
595 | /* offset */ | |
596 | if (I2CAccess | |
597 | (0x11, I2C_SENSOR_DEV, | |
598 | I2C_SENSOR_CHIP_SEL, &user_data[3], | |
599 | I2C_WRITE) != 0) { | |
600 | goto fail; | |
601 | } | |
602 | } | |
603 | break; | |
604 | case 'c': /* alter config settings: config, conv, cons alert, therm hyst */ | |
605 | if (argc < 3) { | |
606 | goto usage; | |
607 | } | |
608 | ||
609 | /* config */ | |
610 | if (I2CAccess | |
611 | (0x9, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
612 | &user_data[0], I2C_WRITE) != 0) { | |
613 | goto fail; | |
614 | } | |
615 | ||
616 | if (user_data_count > 1) { | |
617 | /* conversion */ | |
618 | if (I2CAccess | |
619 | (0xA, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL, | |
620 | &user_data[1], I2C_WRITE) != 0) { | |
621 | goto fail; | |
622 | } | |
623 | } | |
624 | ||
625 | if (user_data_count > 2) { | |
626 | /* cons alert */ | |
627 | if (I2CAccess | |
628 | (0x22, I2C_SENSOR_DEV, | |
629 | I2C_SENSOR_CHIP_SEL, &user_data[2], | |
630 | I2C_WRITE) != 0) { | |
631 | goto fail; | |
632 | } | |
633 | } | |
634 | ||
635 | if (user_data_count > 3) { | |
636 | /* therm hyst */ | |
637 | if (I2CAccess | |
638 | (0x21, I2C_SENSOR_DEV, | |
639 | I2C_SENSOR_CHIP_SEL, &user_data[3], | |
640 | I2C_WRITE) != 0) { | |
641 | goto fail; | |
642 | } | |
643 | } | |
644 | break; | |
645 | default: | |
646 | goto usage; | |
647 | } | |
648 | ||
649 | goto done; | |
650 | fail: | |
651 | printf ("Access to sensor failed\n"); | |
652 | ret_val = -1; | |
653 | goto done; | |
654 | usage: | |
655 | printf ("Usage:\n%s\n", cmdtp->help); | |
656 | ||
657 | done: | |
658 | return ret_val; | |
7521af1c WD |
659 | } |
660 | ||
3df5bea0 | 661 | U_BOOT_CMD (temp, 6, 0, do_temp_sensor, |
2fb2604d | 662 | "interact with the temperature sensor", |
3df5bea0 WD |
663 | "temp [s]\n" |
664 | " - Show status.\n" | |
665 | "temp l LOW [HIGH] [THERM]\n" | |
666 | " - Set local limits.\n" | |
667 | "temp e LOW [HIGH] [THERM] [OFFSET]\n" | |
668 | " - Set external limits.\n" | |
669 | "temp c CONFIG [CONVERSION] [CONS. ALERT] [THERM HYST]\n" | |
670 | " - Set config options.\n" | |
671 | "\n" | |
672 | "All values can be decimal or hex (hex preceded with 0x).\n" | |
673 | "Only whole numbers are supported for external limits.\n"); | |
7521af1c WD |
674 | |
675 | #if 0 | |
3df5bea0 | 676 | U_BOOT_CMD (loadace, 2, 0, do_loadace, |
2fb2604d | 677 | "load fpga configuration from System ACE compact flash", |
3df5bea0 WD |
678 | "N\n" |
679 | " - Load configuration N (0-7) from System ACE compact flash\n" | |
680 | "loadace\n" " - loads default configuration\n"); | |
7521af1c WD |
681 | #endif |
682 | ||
3df5bea0 | 683 | U_BOOT_CMD (swconfig, 2, 0, do_swconfigbyte, |
2fb2604d | 684 | "display or modify the software configuration byte", |
3df5bea0 WD |
685 | "N [ADDRESS]\n" |
686 | " - set software configuration byte to N, optionally use ADDRESS as\n" | |
687 | " location of buffer for flash copy\n" | |
688 | "swconfig\n" " - display software configuration byte\n"); | |
689 | ||
690 | U_BOOT_CMD (pause, 2, 0, do_pause, | |
2fb2604d | 691 | "sleep processor until any key is pressed with poll time of N seconds", |
3df5bea0 WD |
692 | "N\n" |
693 | " - sleep processor until any key is pressed with poll time of N seconds\n" | |
694 | "pause\n" | |
695 | " - sleep processor until any key is pressed with poll time of 1 second\n"); | |
696 | ||
697 | U_BOOT_CMD (swrecon, 1, 0, do_swreconfig, | |
2fb2604d | 698 | "trigger a board reconfigure to the software selected configuration", |
3df5bea0 WD |
699 | "\n" |
700 | " - trigger a board reconfigure to the software selected configuration\n"); | |
ad3381cf BW |
701 | |
702 | int board_eth_init(bd_t *bis) | |
703 | { | |
704 | return pci_eth_init(bis); | |
705 | } |