blob: fcf26984ff5be6004dc354dc49236a3f762cac6a [file] [log] [blame]
Wolfgang Denk7521af12005-10-09 01:04:33 +02001/*
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>
Ben Warrenad3381c2008-08-31 10:44:19 -070026#include <netdev.h>
Wolfgang Denk7521af12005-10-09 01:04:33 +020027#include <asm/processor.h>
28
29#include "powerspan.h"
30#include "ap1000.h"
31
32int board_pre_init (void)
33{
Wolfgang Denk3df5bea2005-10-09 01:41:48 +020034 return 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +020035}
36
37/** serial number and platform display at startup */
38int checkboard (void)
39{
Stefan Roese18c5e642006-01-18 20:06:44 +010040 char *s = getenv ("serial#");
41 char *e;
Wolfgang Denk7521af12005-10-09 01:04:33 +020042
Wolfgang Denk3df5bea2005-10-09 01:41:48 +020043 /* 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;
Wolfgang Denk7521af12005-10-09 01:04:33 +020046
Wolfgang Denk3df5bea2005-10-09 01:41:48 +020047 p[SYSACE_CTRLREG0] = 0x0;
Wolfgang Denk7521af12005-10-09 01:04:33 +020048
Wolfgang Denk3df5bea2005-10-09 01:41:48 +020049 /* 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 ");
Wolfgang Denk7521af12005-10-09 01:04:33 +020072
Wolfgang Denk3df5bea2005-10-09 01:41:48 +020073 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200107
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200108 if ((get_platform () & AP1xx_TESTPLATFORM_MASK) != 0) {
109 puts (AP1xx_TESTPLATFORM_STR);
110 } else {
111 puts (AP1xx_PLATFORM_STR);
112 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200113
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200114 putc ('\n');
Wolfgang Denk7521af12005-10-09 01:04:33 +0200115
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200116 puts ("Serial#: ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200117
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200118 if (!s) {
119 printf ("### No HW ID - assuming AMIRIX");
120 } else {
121 for (e = s; *e; ++e) {
122 if (*e == ' ')
123 break;
124 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200125
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200126 for (; s < e; ++s) {
127 putc (*s);
128 }
129 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200130
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200131 putc ('\n');
132
133 return (0);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200134}
135
136
Becky Bruce9973e3c2008-06-09 16:03:40 -0500137phys_size_t initdram (int board_type)
Wolfgang Denk7521af12005-10-09 01:04:33 +0200138{
Stefan Roese18c5e642006-01-18 20:06:44 +0100139 char *s = getenv ("dramsize");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200140
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200141 if (s != NULL) {
142 if ((s[0] == '0') && ((s[1] == 'x') || (s[1] == 'X'))) {
143 s += 2;
144 }
Stefan Roese18c5e642006-01-18 20:06:44 +0100145 return (long int)simple_strtoul (s, NULL, 16);
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200146 } else {
147 /* give all 64 MB */
Wolfgang Denk7521af12005-10-09 01:04:33 +0200148 return 64 * 1024 * 1024;
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200149 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200150}
151
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200152unsigned 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200157}
158
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200159unsigned int get_device (void)
160{
161 unsigned int *revision_reg_ptr = (unsigned int *) AP1xx_FPGA_REV_ADDR;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200162
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200163 return (*revision_reg_ptr & AP1xx_TARGET_MASK);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200164}
165
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200166#if 0 /* loadace is not working; it appears to be a hardware issue with the system ace. */
Wolfgang Denk7521af12005-10-09 01:04:33 +0200167/*
168 This function loads FPGA configurations from the SystemACE CompactFlash
169*/
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200170int do_loadace (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
Wolfgang Denk7521af12005-10-09 01:04:33 +0200171{
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200172 unsigned char *p = (unsigned char *) AP1000_SYSACE_REGBASE;
173 int cfg;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200174
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200175 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200181
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200182 /* 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 */
Wolfgang Denk7521af12005-10-09 01:04:33 +0200190
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200191 p[SYSACE_CTRLREG0] = 0x80 | 0x20 | 0x08;
192 p[SYSACE_CTRLREG1] = 0x00;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200193
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200194 /* force config address if arg2 exists */
195 if (argc == 2) {
196 cfg = simple_strtoul (argv[1], NULL, 10);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200197
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200198 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;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200207
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200208 } else {
209 cfg = (p[SYSACE_STATREG1] & 0xE0) >> 5;
210 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200211
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200212 /* release configuration controller */
213 printf ("\nLoading V2PRO with config %d...\n", cfg);
214 p[SYSACE_CTRLREG0] &= ~0x80;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200215
216
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200217 while ((p[SYSACE_STATREG1] & 0x01) == 0) {
Wolfgang Denk7521af12005-10-09 01:04:33 +0200218
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200219 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200228
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200229 p[SYSACE_CTRLREG0] |= 0x20;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200230
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200231 return 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200232}
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 */
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200250int 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;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200256
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200257 /* 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200267
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200268 /* 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200275
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200276 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200282
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200283 memcpy (sector_buffer, (void *) SW_BYTE_SECTOR_ADDR,
284 SW_BYTE_SECTOR_SIZE);
285 sector_buffer[SW_BYTE_SECTOR_OFFSET] = input_char;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200286
287
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200288 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200294
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200295 printf ("Writing to Flash... ");
296 write_result =
Stefan Roese18c5e642006-01-18 20:06:44 +0100297 flash_write ((char *)sector_buffer, SW_BYTE_SECTOR_ADDR,
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200298 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200308
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200309 return 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200310}
311
312#define ONE_SECOND 1000000
313
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200314int 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;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200319
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200320 /* display value if no argument */
321 if (argc < 2) {
322 pause_time = 1;
323 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200324
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200325 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200331
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200332 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200344
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200345 return 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200346}
347
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200348int 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;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200354
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200355 return 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200356}
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
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200368int 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;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200383
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200384 if (argc > 1) {
385 cmd = argv[1][0];
386 } else {
387 cmd = 's'; /* default to status */
388 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200389
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200390 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 ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200404
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200405 if (temp_byte & TEMP_LHIGH_BIT)
406 printf ("LHIGH ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200407
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200408 if (temp_byte & TEMP_LLOW_BIT)
409 printf ("LLOW ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200410
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200411 if (temp_byte & TEMP_EHIGH_BIT)
412 printf ("EHIGH ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200413
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200414 if (temp_byte & TEMP_ELOW_BIT)
415 printf ("ELOW ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200416
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200417 if (temp_byte & TEMP_OPEN_BIT)
418 printf ("OPEN ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200419
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200420 if (temp_byte & TEMP_ETHERM_BIT)
421 printf ("ETHERM ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200422
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200423 if (temp_byte & TEMP_LTHERM_BIT)
424 printf ("LTHERM");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200425
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200426 printf ("\n");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200427
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200428 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200434
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200435 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200448
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200449 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200456
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200457 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200482
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200483 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200536
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200537 /* low */
538 if (I2CAccess
539 (0xC, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,
540 &user_data[0], I2C_WRITE) != 0) {
541 goto fail;
542 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200543
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200544 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200552
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200553 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200567
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200568 /* low */
569 if (I2CAccess
570 (0xE, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,
571 &user_data[0], I2C_WRITE) != 0) {
572 goto fail;
573 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200574
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200575 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200583
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200584 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200593
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200594 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200608
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200609 /* config */
610 if (I2CAccess
611 (0x9, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,
612 &user_data[0], I2C_WRITE) != 0) {
613 goto fail;
614 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200615
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200616 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200624
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200625 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200634
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200635 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200648
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200649 goto done;
650fail:
651 printf ("Access to sensor failed\n");
652 ret_val = -1;
653 goto done;
654usage:
655 printf ("Usage:\n%s\n", cmdtp->help);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200656
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200657done:
658 return ret_val;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200659}
660
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200661U_BOOT_CMD (temp, 6, 0, do_temp_sensor,
Peter Tyser2fb26042009-01-27 18:03:12 -0600662 "interact with the temperature sensor",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200663 "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");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200674
675#if 0
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200676U_BOOT_CMD (loadace, 2, 0, do_loadace,
Peter Tyser2fb26042009-01-27 18:03:12 -0600677 "load fpga configuration from System ACE compact flash",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200678 "N\n"
679 " - Load configuration N (0-7) from System ACE compact flash\n"
680 "loadace\n" " - loads default configuration\n");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200681#endif
682
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200683U_BOOT_CMD (swconfig, 2, 0, do_swconfigbyte,
Peter Tyser2fb26042009-01-27 18:03:12 -0600684 "display or modify the software configuration byte",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200685 "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");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200689
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200690U_BOOT_CMD (pause, 2, 0, do_pause,
Peter Tyser2fb26042009-01-27 18:03:12 -0600691 "sleep processor until any key is pressed with poll time of N seconds",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200692 "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");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200696
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200697U_BOOT_CMD (swrecon, 1, 0, do_swreconfig,
Peter Tyser2fb26042009-01-27 18:03:12 -0600698 "trigger a board reconfigure to the software selected configuration",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200699 "\n"
700 " - trigger a board reconfigure to the software selected configuration\n");
Ben Warrenad3381c2008-08-31 10:44:19 -0700701
702int board_eth_init(bd_t *bis)
703{
704 return pci_eth_init(bis);
705}