ap1000.c 17 KB

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