blob: 64de04ca29dfc212a52c6fd07a3815efc252dc67 [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{
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +000040 char buf[64];
41 int l = getenv_f("serial#", buf, sizeof(buf));
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 Denkf0c0b3a2011-05-04 10:32:28 +0000118 if (l < 0) {
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200119 printf ("### No HW ID - assuming AMIRIX");
120 } else {
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000121 int i;
122
123 for (i = 0; i < l; ++i) {
124 if (buf[i] == ' ') {
125 buf[i] = '\0';
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200126 break;
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000127 }
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200128 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200129
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000130 puts(buf);
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200131 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200132
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200133 putc ('\n');
134
135 return (0);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200136}
137
138
Becky Bruce9973e3c2008-06-09 16:03:40 -0500139phys_size_t initdram (int board_type)
Wolfgang Denk7521af12005-10-09 01:04:33 +0200140{
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000141 char buf[64];
142 int i = getenv_f("dramsize", buf, sizeof(buf));
Wolfgang Denk7521af12005-10-09 01:04:33 +0200143
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000144 if (i > 0) {
145 char *s = buf;
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200146 if ((s[0] == '0') && ((s[1] == 'x') || (s[1] == 'X'))) {
147 s += 2;
148 }
Stefan Roese18c5e642006-01-18 20:06:44 +0100149 return (long int)simple_strtoul (s, NULL, 16);
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200150 } else {
151 /* give all 64 MB */
Wolfgang Denk7521af12005-10-09 01:04:33 +0200152 return 64 * 1024 * 1024;
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200153 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200154}
155
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200156unsigned 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200161}
162
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200163unsigned int get_device (void)
164{
165 unsigned int *revision_reg_ptr = (unsigned int *) AP1xx_FPGA_REV_ADDR;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200166
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200167 return (*revision_reg_ptr & AP1xx_TARGET_MASK);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200168}
169
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200170#if 0 /* loadace is not working; it appears to be a hardware issue with the system ace. */
Wolfgang Denk7521af12005-10-09 01:04:33 +0200171/*
172 This function loads FPGA configurations from the SystemACE CompactFlash
173*/
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200174int do_loadace (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denk7521af12005-10-09 01:04:33 +0200175{
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200176 unsigned char *p = (unsigned char *) AP1000_SYSACE_REGBASE;
177 int cfg;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200178
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200179 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200185
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200186 /* 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 */
Wolfgang Denk7521af12005-10-09 01:04:33 +0200194
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200195 p[SYSACE_CTRLREG0] = 0x80 | 0x20 | 0x08;
196 p[SYSACE_CTRLREG1] = 0x00;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200197
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200198 /* force config address if arg2 exists */
199 if (argc == 2) {
200 cfg = simple_strtoul (argv[1], NULL, 10);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200201
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200202 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;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200211
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200212 } else {
213 cfg = (p[SYSACE_STATREG1] & 0xE0) >> 5;
214 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200215
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200216 /* release configuration controller */
217 printf ("\nLoading V2PRO with config %d...\n", cfg);
218 p[SYSACE_CTRLREG0] &= ~0x80;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200219
220
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200221 while ((p[SYSACE_STATREG1] & 0x01) == 0) {
Wolfgang Denk7521af12005-10-09 01:04:33 +0200222
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200223 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200232
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200233 p[SYSACE_CTRLREG0] |= 0x20;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200234
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200235 return 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200236}
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 */
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200254int do_swconfigbyte (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200255{
256 unsigned char *sector_buffer = NULL;
257 unsigned char input_char;
258 int write_result;
259 unsigned int input_uint;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200260
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200261 /* 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200271
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200272 /* 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200279
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200280 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200286
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200287 memcpy (sector_buffer, (void *) SW_BYTE_SECTOR_ADDR,
288 SW_BYTE_SECTOR_SIZE);
289 sector_buffer[SW_BYTE_SECTOR_OFFSET] = input_char;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200290
291
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200292 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200298
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200299 printf ("Writing to Flash... ");
300 write_result =
Stefan Roese18c5e642006-01-18 20:06:44 +0100301 flash_write ((char *)sector_buffer, SW_BYTE_SECTOR_ADDR,
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200302 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200312
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200313 return 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200314}
315
316#define ONE_SECOND 1000000
317
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200318int do_pause (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200319{
320 int pause_time;
321 unsigned int delay_time;
322 int break_loop = 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200323
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200324 /* display value if no argument */
325 if (argc < 2) {
326 pause_time = 1;
327 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200328
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200329 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200335
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200336 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200348
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200349 return 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200350}
351
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200352int do_swreconfig (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200353{
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;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200358
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200359 return 0;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200360}
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
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200372int do_temp_sensor (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200373{
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;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200387
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200388 if (argc > 1) {
389 cmd = argv[1][0];
390 } else {
391 cmd = 's'; /* default to status */
392 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200393
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200394 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 ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200408
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200409 if (temp_byte & TEMP_LHIGH_BIT)
410 printf ("LHIGH ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200411
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200412 if (temp_byte & TEMP_LLOW_BIT)
413 printf ("LLOW ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200414
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200415 if (temp_byte & TEMP_EHIGH_BIT)
416 printf ("EHIGH ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200417
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200418 if (temp_byte & TEMP_ELOW_BIT)
419 printf ("ELOW ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200420
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200421 if (temp_byte & TEMP_OPEN_BIT)
422 printf ("OPEN ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200423
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200424 if (temp_byte & TEMP_ETHERM_BIT)
425 printf ("ETHERM ");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200426
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200427 if (temp_byte & TEMP_LTHERM_BIT)
428 printf ("LTHERM");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200429
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200430 printf ("\n");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200431
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200432 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200438
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200439 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200452
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200453 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200460
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200461 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);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200486
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200487 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200540
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200541 /* low */
542 if (I2CAccess
543 (0xC, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,
544 &user_data[0], I2C_WRITE) != 0) {
545 goto fail;
546 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200547
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200548 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200556
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200557 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200571
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200572 /* low */
573 if (I2CAccess
574 (0xE, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,
575 &user_data[0], I2C_WRITE) != 0) {
576 goto fail;
577 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200578
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200579 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200587
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200588 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200597
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200598 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200612
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200613 /* config */
614 if (I2CAccess
615 (0x9, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,
616 &user_data[0], I2C_WRITE) != 0) {
617 goto fail;
618 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200619
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200620 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200628
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200629 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200638
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200639 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 }
Wolfgang Denk7521af12005-10-09 01:04:33 +0200652
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200653 goto done;
654fail:
655 printf ("Access to sensor failed\n");
656 ret_val = -1;
657 goto done;
658usage:
659 printf ("Usage:\n%s\n", cmdtp->help);
Wolfgang Denk7521af12005-10-09 01:04:33 +0200660
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200661done:
662 return ret_val;
Wolfgang Denk7521af12005-10-09 01:04:33 +0200663}
664
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200665U_BOOT_CMD (temp, 6, 0, do_temp_sensor,
Peter Tyser2fb26042009-01-27 18:03:12 -0600666 "interact with the temperature sensor",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200667 "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"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200677 "Only whole numbers are supported for external limits.");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200678
679#if 0
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200680U_BOOT_CMD (loadace, 2, 0, do_loadace,
Peter Tyser2fb26042009-01-27 18:03:12 -0600681 "load fpga configuration from System ACE compact flash",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200682 "N\n"
683 " - Load configuration N (0-7) from System ACE compact flash\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200684 "loadace\n" " - loads default configuration");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200685#endif
686
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200687U_BOOT_CMD (swconfig, 2, 0, do_swconfigbyte,
Peter Tyser2fb26042009-01-27 18:03:12 -0600688 "display or modify the software configuration byte",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200689 "N [ADDRESS]\n"
690 " - set software configuration byte to N, optionally use ADDRESS as\n"
691 " location of buffer for flash copy\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200692 "swconfig\n" " - display software configuration byte");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200693
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200694U_BOOT_CMD (pause, 2, 0, do_pause,
Peter Tyser2fb26042009-01-27 18:03:12 -0600695 "sleep processor until any key is pressed with poll time of N seconds",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200696 "N\n"
697 " - sleep processor until any key is pressed with poll time of N seconds\n"
698 "pause\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200699 " - sleep processor until any key is pressed with poll time of 1 second");
Wolfgang Denk7521af12005-10-09 01:04:33 +0200700
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200701U_BOOT_CMD (swrecon, 1, 0, do_swreconfig,
Peter Tyser2fb26042009-01-27 18:03:12 -0600702 "trigger a board reconfigure to the software selected configuration",
Wolfgang Denk3df5bea2005-10-09 01:41:48 +0200703 "\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200704 " - trigger a board reconfigure to the software selected configuration");
Ben Warrenad3381c2008-08-31 10:44:19 -0700705
706int board_eth_init(bd_t *bis)
707{
708 return pci_eth_init(bis);
709}