ap1000.c 16 KB

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