cmd_i2c.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  1. /*
  2. * (C) Copyright 2001
  3. * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /*
  24. * I2C Functions similar to the standard memory functions.
  25. *
  26. * There are several parameters in many of the commands that bear further
  27. * explanations:
  28. *
  29. * Two of the commands (imm and imw) take a byte/word/long modifier
  30. * (e.g. imm.w specifies the word-length modifier). This was done to
  31. * allow manipulating word-length registers. It was not done on any other
  32. * commands because it was not deemed useful.
  33. *
  34. * {i2c_chip} is the I2C chip address (the first byte sent on the bus).
  35. * Each I2C chip on the bus has a unique address. On the I2C data bus,
  36. * the address is the upper seven bits and the LSB is the "read/write"
  37. * bit. Note that the {i2c_chip} address specified on the command
  38. * line is not shifted up: e.g. a typical EEPROM memory chip may have
  39. * an I2C address of 0x50, but the data put on the bus will be 0xA0
  40. * for write and 0xA1 for read. This "non shifted" address notation
  41. * matches at least half of the data sheets :-/.
  42. *
  43. * {addr} is the address (or offset) within the chip. Small memory
  44. * chips have 8 bit addresses. Large memory chips have 16 bit
  45. * addresses. Other memory chips have 9, 10, or 11 bit addresses.
  46. * Many non-memory chips have multiple registers and {addr} is used
  47. * as the register index. Some non-memory chips have only one register
  48. * and therefore don't need any {addr} parameter.
  49. *
  50. * The default {addr} parameter is one byte (.1) which works well for
  51. * memories and registers with 8 bits of address space.
  52. *
  53. * You can specify the length of the {addr} field with the optional .0,
  54. * .1, or .2 modifier (similar to the .b, .w, .l modifier). If you are
  55. * manipulating a single register device which doesn't use an address
  56. * field, use "0.0" for the address and the ".0" length field will
  57. * suppress the address in the I2C data stream. This also works for
  58. * successive reads using the I2C auto-incrementing memory pointer.
  59. *
  60. * If you are manipulating a large memory with 2-byte addresses, use
  61. * the .2 address modifier, e.g. 210.2 addresses location 528 (decimal).
  62. *
  63. * Then there are the unfortunate memory chips that spill the most
  64. * significant 1, 2, or 3 bits of address into the chip address byte.
  65. * This effectively makes one chip (logically) look like 2, 4, or
  66. * 8 chips. This is handled (awkwardly) by #defining
  67. * CFG_I2C_EEPROM_ADDR_OVERFLOW and using the .1 modifier on the
  68. * {addr} field (since .1 is the default, it doesn't actually have to
  69. * be specified). Examples: given a memory chip at I2C chip address
  70. * 0x50, the following would happen...
  71. * imd 50 0 10 display 16 bytes starting at 0x000
  72. * On the bus: <S> A0 00 <E> <S> A1 <rd> ... <rd>
  73. * imd 50 100 10 display 16 bytes starting at 0x100
  74. * On the bus: <S> A2 00 <E> <S> A3 <rd> ... <rd>
  75. * imd 50 210 10 display 16 bytes starting at 0x210
  76. * On the bus: <S> A4 10 <E> <S> A5 <rd> ... <rd>
  77. * This is awfully ugly. It would be nice if someone would think up
  78. * a better way of handling this.
  79. *
  80. * Adapted from cmd_mem.c which is copyright Wolfgang Denk (wd@denx.de).
  81. */
  82. #include <common.h>
  83. #include <command.h>
  84. #include <i2c.h>
  85. #include <asm/byteorder.h>
  86. /* Display values from last command.
  87. * Memory modify remembered values are different from display memory.
  88. */
  89. static uchar i2c_dp_last_chip;
  90. static uint i2c_dp_last_addr;
  91. static uint i2c_dp_last_alen;
  92. static uint i2c_dp_last_length = 0x10;
  93. static uchar i2c_mm_last_chip;
  94. static uint i2c_mm_last_addr;
  95. static uint i2c_mm_last_alen;
  96. /* If only one I2C bus is present, the list of devices to ignore when
  97. * the probe command is issued is represented by a 1D array of addresses.
  98. * When multiple buses are present, the list is an array of bus-address
  99. * pairs. The following macros take care of this */
  100. #if defined(CFG_I2C_NOPROBES)
  101. #if defined(CONFIG_I2C_MULTI_BUS)
  102. static struct
  103. {
  104. uchar bus;
  105. uchar addr;
  106. } i2c_no_probes[] = CFG_I2C_NOPROBES;
  107. #define GET_BUS_NUM i2c_get_bus_num()
  108. #define COMPARE_BUS(b,i) (i2c_no_probes[(i)].bus == (b))
  109. #define COMPARE_ADDR(a,i) (i2c_no_probes[(i)].addr == (a))
  110. #define NO_PROBE_ADDR(i) i2c_no_probes[(i)].addr
  111. #else /* single bus */
  112. static uchar i2c_no_probes[] = CFG_I2C_NOPROBES;
  113. #define GET_BUS_NUM 0
  114. #define COMPARE_BUS(b,i) ((b) == 0) /* Make compiler happy */
  115. #define COMPARE_ADDR(a,i) (i2c_no_probes[(i)] == (a))
  116. #define NO_PROBE_ADDR(i) i2c_no_probes[(i)]
  117. #endif /* CONFIG_MULTI_BUS */
  118. #define NUM_ELEMENTS_NOPROBE (sizeof(i2c_no_probes)/sizeof(i2c_no_probes[0]))
  119. #endif
  120. static int
  121. mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]);
  122. extern int cmd_get_data_size(char* arg, int default_size);
  123. /*
  124. * Syntax:
  125. * imd {i2c_chip} {addr}{.0, .1, .2} {len}
  126. */
  127. #define DISP_LINE_LEN 16
  128. int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  129. {
  130. u_char chip;
  131. uint addr, alen, length;
  132. int j, nbytes, linebytes;
  133. /* We use the last specified parameters, unless new ones are
  134. * entered.
  135. */
  136. chip = i2c_dp_last_chip;
  137. addr = i2c_dp_last_addr;
  138. alen = i2c_dp_last_alen;
  139. length = i2c_dp_last_length;
  140. if (argc < 3) {
  141. printf ("Usage:\n%s\n", cmdtp->usage);
  142. return 1;
  143. }
  144. if ((flag & CMD_FLAG_REPEAT) == 0) {
  145. /*
  146. * New command specified.
  147. */
  148. alen = 1;
  149. /*
  150. * I2C chip address
  151. */
  152. chip = simple_strtoul(argv[1], NULL, 16);
  153. /*
  154. * I2C data address within the chip. This can be 1 or
  155. * 2 bytes long. Some day it might be 3 bytes long :-).
  156. */
  157. addr = simple_strtoul(argv[2], NULL, 16);
  158. alen = 1;
  159. for (j = 0; j < 8; j++) {
  160. if (argv[2][j] == '.') {
  161. alen = argv[2][j+1] - '0';
  162. if (alen > 4) {
  163. printf ("Usage:\n%s\n", cmdtp->usage);
  164. return 1;
  165. }
  166. break;
  167. } else if (argv[2][j] == '\0')
  168. break;
  169. }
  170. /*
  171. * If another parameter, it is the length to display.
  172. * Length is the number of objects, not number of bytes.
  173. */
  174. if (argc > 3)
  175. length = simple_strtoul(argv[3], NULL, 16);
  176. }
  177. /*
  178. * Print the lines.
  179. *
  180. * We buffer all read data, so we can make sure data is read only
  181. * once.
  182. */
  183. nbytes = length;
  184. do {
  185. unsigned char linebuf[DISP_LINE_LEN];
  186. unsigned char *cp;
  187. linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
  188. if (i2c_read(chip, addr, alen, linebuf, linebytes) != 0)
  189. puts ("Error reading the chip.\n");
  190. else {
  191. printf("%04x:", addr);
  192. cp = linebuf;
  193. for (j=0; j<linebytes; j++) {
  194. printf(" %02x", *cp++);
  195. addr++;
  196. }
  197. puts (" ");
  198. cp = linebuf;
  199. for (j=0; j<linebytes; j++) {
  200. if ((*cp < 0x20) || (*cp > 0x7e))
  201. puts (".");
  202. else
  203. printf("%c", *cp);
  204. cp++;
  205. }
  206. putc ('\n');
  207. }
  208. nbytes -= linebytes;
  209. } while (nbytes > 0);
  210. i2c_dp_last_chip = chip;
  211. i2c_dp_last_addr = addr;
  212. i2c_dp_last_alen = alen;
  213. i2c_dp_last_length = length;
  214. return 0;
  215. }
  216. int do_i2c_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  217. {
  218. return mod_i2c_mem (cmdtp, 1, flag, argc, argv);
  219. }
  220. int do_i2c_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  221. {
  222. return mod_i2c_mem (cmdtp, 0, flag, argc, argv);
  223. }
  224. /* Write (fill) memory
  225. *
  226. * Syntax:
  227. * imw {i2c_chip} {addr}{.0, .1, .2} {data} [{count}]
  228. */
  229. int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  230. {
  231. uchar chip;
  232. ulong addr;
  233. uint alen;
  234. uchar byte;
  235. int count;
  236. int j;
  237. if ((argc < 4) || (argc > 5)) {
  238. printf ("Usage:\n%s\n", cmdtp->usage);
  239. return 1;
  240. }
  241. /*
  242. * Chip is always specified.
  243. */
  244. chip = simple_strtoul(argv[1], NULL, 16);
  245. /*
  246. * Address is always specified.
  247. */
  248. addr = simple_strtoul(argv[2], NULL, 16);
  249. alen = 1;
  250. for (j = 0; j < 8; j++) {
  251. if (argv[2][j] == '.') {
  252. alen = argv[2][j+1] - '0';
  253. if (alen > 4) {
  254. printf ("Usage:\n%s\n", cmdtp->usage);
  255. return 1;
  256. }
  257. break;
  258. } else if (argv[2][j] == '\0')
  259. break;
  260. }
  261. /*
  262. * Value to write is always specified.
  263. */
  264. byte = simple_strtoul(argv[3], NULL, 16);
  265. /*
  266. * Optional count
  267. */
  268. if (argc == 5)
  269. count = simple_strtoul(argv[4], NULL, 16);
  270. else
  271. count = 1;
  272. while (count-- > 0) {
  273. if (i2c_write(chip, addr++, alen, &byte, 1) != 0)
  274. puts ("Error writing the chip.\n");
  275. /*
  276. * Wait for the write to complete. The write can take
  277. * up to 10mSec (we allow a little more time).
  278. *
  279. * On some chips, while the write is in progress, the
  280. * chip doesn't respond. This apparently isn't a
  281. * universal feature so we don't take advantage of it.
  282. */
  283. /*
  284. * No write delay with FRAM devices.
  285. */
  286. #if !defined(CFG_I2C_FRAM)
  287. udelay(11000);
  288. #endif
  289. #if 0
  290. for (timeout = 0; timeout < 10; timeout++) {
  291. udelay(2000);
  292. if (i2c_probe(chip) == 0)
  293. break;
  294. }
  295. #endif
  296. }
  297. return (0);
  298. }
  299. /* Calculate a CRC on memory
  300. *
  301. * Syntax:
  302. * icrc32 {i2c_chip} {addr}{.0, .1, .2} {count}
  303. */
  304. int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  305. {
  306. uchar chip;
  307. ulong addr;
  308. uint alen;
  309. int count;
  310. uchar byte;
  311. ulong crc;
  312. ulong err;
  313. int j;
  314. if (argc < 4) {
  315. printf ("Usage:\n%s\n", cmdtp->usage);
  316. return 1;
  317. }
  318. /*
  319. * Chip is always specified.
  320. */
  321. chip = simple_strtoul(argv[1], NULL, 16);
  322. /*
  323. * Address is always specified.
  324. */
  325. addr = simple_strtoul(argv[2], NULL, 16);
  326. alen = 1;
  327. for (j = 0; j < 8; j++) {
  328. if (argv[2][j] == '.') {
  329. alen = argv[2][j+1] - '0';
  330. if (alen > 4) {
  331. printf ("Usage:\n%s\n", cmdtp->usage);
  332. return 1;
  333. }
  334. break;
  335. } else if (argv[2][j] == '\0')
  336. break;
  337. }
  338. /*
  339. * Count is always specified
  340. */
  341. count = simple_strtoul(argv[3], NULL, 16);
  342. printf ("CRC32 for %08lx ... %08lx ==> ", addr, addr + count - 1);
  343. /*
  344. * CRC a byte at a time. This is going to be slooow, but hey, the
  345. * memories are small and slow too so hopefully nobody notices.
  346. */
  347. crc = 0;
  348. err = 0;
  349. while (count-- > 0) {
  350. if (i2c_read(chip, addr, alen, &byte, 1) != 0)
  351. err++;
  352. crc = crc32 (crc, &byte, 1);
  353. addr++;
  354. }
  355. if (err > 0)
  356. puts ("Error reading the chip,\n");
  357. else
  358. printf ("%08lx\n", crc);
  359. return 0;
  360. }
  361. /* Modify memory.
  362. *
  363. * Syntax:
  364. * imm{.b, .w, .l} {i2c_chip} {addr}{.0, .1, .2}
  365. * inm{.b, .w, .l} {i2c_chip} {addr}{.0, .1, .2}
  366. */
  367. static int
  368. mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])
  369. {
  370. uchar chip;
  371. ulong addr;
  372. uint alen;
  373. ulong data;
  374. int size = 1;
  375. int nbytes;
  376. int j;
  377. extern char console_buffer[];
  378. if (argc != 3) {
  379. printf ("Usage:\n%s\n", cmdtp->usage);
  380. return 1;
  381. }
  382. #ifdef CONFIG_BOOT_RETRY_TIME
  383. reset_cmd_timeout(); /* got a good command to get here */
  384. #endif
  385. /*
  386. * We use the last specified parameters, unless new ones are
  387. * entered.
  388. */
  389. chip = i2c_mm_last_chip;
  390. addr = i2c_mm_last_addr;
  391. alen = i2c_mm_last_alen;
  392. if ((flag & CMD_FLAG_REPEAT) == 0) {
  393. /*
  394. * New command specified. Check for a size specification.
  395. * Defaults to byte if no or incorrect specification.
  396. */
  397. size = cmd_get_data_size(argv[0], 1);
  398. /*
  399. * Chip is always specified.
  400. */
  401. chip = simple_strtoul(argv[1], NULL, 16);
  402. /*
  403. * Address is always specified.
  404. */
  405. addr = simple_strtoul(argv[2], NULL, 16);
  406. alen = 1;
  407. for (j = 0; j < 8; j++) {
  408. if (argv[2][j] == '.') {
  409. alen = argv[2][j+1] - '0';
  410. if (alen > 4) {
  411. printf ("Usage:\n%s\n", cmdtp->usage);
  412. return 1;
  413. }
  414. break;
  415. } else if (argv[2][j] == '\0')
  416. break;
  417. }
  418. }
  419. /*
  420. * Print the address, followed by value. Then accept input for
  421. * the next value. A non-converted value exits.
  422. */
  423. do {
  424. printf("%08lx:", addr);
  425. if (i2c_read(chip, addr, alen, (uchar *)&data, size) != 0)
  426. puts ("\nError reading the chip,\n");
  427. else {
  428. data = cpu_to_be32(data);
  429. if (size == 1)
  430. printf(" %02lx", (data >> 24) & 0x000000FF);
  431. else if (size == 2)
  432. printf(" %04lx", (data >> 16) & 0x0000FFFF);
  433. else
  434. printf(" %08lx", data);
  435. }
  436. nbytes = readline (" ? ");
  437. if (nbytes == 0) {
  438. /*
  439. * <CR> pressed as only input, don't modify current
  440. * location and move to next.
  441. */
  442. if (incrflag)
  443. addr += size;
  444. nbytes = size;
  445. #ifdef CONFIG_BOOT_RETRY_TIME
  446. reset_cmd_timeout(); /* good enough to not time out */
  447. #endif
  448. }
  449. #ifdef CONFIG_BOOT_RETRY_TIME
  450. else if (nbytes == -2)
  451. break; /* timed out, exit the command */
  452. #endif
  453. else {
  454. char *endp;
  455. data = simple_strtoul(console_buffer, &endp, 16);
  456. if (size == 1)
  457. data = data << 24;
  458. else if (size == 2)
  459. data = data << 16;
  460. data = be32_to_cpu(data);
  461. nbytes = endp - console_buffer;
  462. if (nbytes) {
  463. #ifdef CONFIG_BOOT_RETRY_TIME
  464. /*
  465. * good enough to not time out
  466. */
  467. reset_cmd_timeout();
  468. #endif
  469. if (i2c_write(chip, addr, alen, (uchar *)&data, size) != 0)
  470. puts ("Error writing the chip.\n");
  471. #ifdef CFG_EEPROM_PAGE_WRITE_DELAY_MS
  472. udelay(CFG_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
  473. #endif
  474. if (incrflag)
  475. addr += size;
  476. }
  477. }
  478. } while (nbytes);
  479. chip = i2c_mm_last_chip;
  480. addr = i2c_mm_last_addr;
  481. alen = i2c_mm_last_alen;
  482. return 0;
  483. }
  484. /*
  485. * Syntax:
  486. * iprobe {addr}{.0, .1, .2}
  487. */
  488. int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  489. {
  490. int j;
  491. #if defined(CFG_I2C_NOPROBES)
  492. int k, skip;
  493. uchar bus = GET_BUS_NUM;
  494. #endif /* NOPROBES */
  495. puts ("Valid chip addresses:");
  496. for (j = 0; j < 128; j++) {
  497. #if defined(CFG_I2C_NOPROBES)
  498. skip = 0;
  499. for (k=0; k < NUM_ELEMENTS_NOPROBE; k++) {
  500. if (COMPARE_BUS(bus, k) && COMPARE_ADDR(j, k)) {
  501. skip = 1;
  502. break;
  503. }
  504. }
  505. if (skip)
  506. continue;
  507. #endif
  508. if (i2c_probe(j) == 0)
  509. printf(" %02X", j);
  510. }
  511. putc ('\n');
  512. #if defined(CFG_I2C_NOPROBES)
  513. puts ("Excluded chip addresses:");
  514. for (k=0; k < NUM_ELEMENTS_NOPROBE; k++) {
  515. if (COMPARE_BUS(bus,k))
  516. printf(" %02X", NO_PROBE_ADDR(k));
  517. }
  518. putc ('\n');
  519. #endif
  520. return 0;
  521. }
  522. /*
  523. * Syntax:
  524. * iloop {i2c_chip} {addr}{.0, .1, .2} [{length}] [{delay}]
  525. * {length} - Number of bytes to read
  526. * {delay} - A DECIMAL number and defaults to 1000 uSec
  527. */
  528. int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  529. {
  530. u_char chip;
  531. ulong alen;
  532. uint addr;
  533. uint length;
  534. u_char bytes[16];
  535. int delay;
  536. int j;
  537. if (argc < 3) {
  538. printf ("Usage:\n%s\n", cmdtp->usage);
  539. return 1;
  540. }
  541. /*
  542. * Chip is always specified.
  543. */
  544. chip = simple_strtoul(argv[1], NULL, 16);
  545. /*
  546. * Address is always specified.
  547. */
  548. addr = simple_strtoul(argv[2], NULL, 16);
  549. alen = 1;
  550. for (j = 0; j < 8; j++) {
  551. if (argv[2][j] == '.') {
  552. alen = argv[2][j+1] - '0';
  553. if (alen > 4) {
  554. printf ("Usage:\n%s\n", cmdtp->usage);
  555. return 1;
  556. }
  557. break;
  558. } else if (argv[2][j] == '\0')
  559. break;
  560. }
  561. /*
  562. * Length is the number of objects, not number of bytes.
  563. */
  564. length = 1;
  565. length = simple_strtoul(argv[3], NULL, 16);
  566. if (length > sizeof(bytes))
  567. length = sizeof(bytes);
  568. /*
  569. * The delay time (uSec) is optional.
  570. */
  571. delay = 1000;
  572. if (argc > 3)
  573. delay = simple_strtoul(argv[4], NULL, 10);
  574. /*
  575. * Run the loop...
  576. */
  577. while (1) {
  578. if (i2c_read(chip, addr, alen, bytes, length) != 0)
  579. puts ("Error reading the chip.\n");
  580. udelay(delay);
  581. }
  582. /* NOTREACHED */
  583. return 0;
  584. }
  585. /*
  586. * The SDRAM command is separately configured because many
  587. * (most?) embedded boards don't use SDRAM DIMMs.
  588. */
  589. #if defined(CONFIG_CMD_SDRAM)
  590. static void print_ddr2_tcyc (u_char const b)
  591. {
  592. printf ("%d.", (b >> 4) & 0x0F);
  593. switch (b & 0x0F) {
  594. case 0x0:
  595. case 0x1:
  596. case 0x2:
  597. case 0x3:
  598. case 0x4:
  599. case 0x5:
  600. case 0x6:
  601. case 0x7:
  602. case 0x8:
  603. case 0x9:
  604. printf ("%d ns\n", b & 0x0F);
  605. break;
  606. case 0xA:
  607. puts ("25 ns\n");
  608. break;
  609. case 0xB:
  610. puts ("33 ns\n");
  611. break;
  612. case 0xC:
  613. puts ("66 ns\n");
  614. break;
  615. case 0xD:
  616. puts ("75 ns\n");
  617. break;
  618. default:
  619. puts ("?? ns\n");
  620. break;
  621. }
  622. }
  623. static void decode_bits (u_char const b, char const *str[], int const do_once)
  624. {
  625. u_char mask;
  626. for (mask = 0x80; mask != 0x00; mask >>= 1, ++str) {
  627. if (b & mask) {
  628. puts (*str);
  629. if (do_once)
  630. return;
  631. }
  632. }
  633. }
  634. /*
  635. * Syntax:
  636. * sdram {i2c_chip}
  637. */
  638. int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  639. {
  640. enum { unknown, EDO, SDRAM, DDR2 } type;
  641. u_char chip;
  642. u_char data[128];
  643. u_char cksum;
  644. int j;
  645. static const char *decode_CAS_DDR2[] = {
  646. " TBD", " 6", " 5", " 4", " 3", " 2", " TBD", " TBD"
  647. };
  648. static const char *decode_CAS_default[] = {
  649. " TBD", " 7", " 6", " 5", " 4", " 3", " 2", " 1"
  650. };
  651. static const char *decode_CS_WE_default[] = {
  652. " TBD", " 6", " 5", " 4", " 3", " 2", " 1", " 0"
  653. };
  654. static const char *decode_byte21_default[] = {
  655. " TBD (bit 7)\n",
  656. " Redundant row address\n",
  657. " Differential clock input\n",
  658. " Registerd DQMB inputs\n",
  659. " Buffered DQMB inputs\n",
  660. " On-card PLL\n",
  661. " Registered address/control lines\n",
  662. " Buffered address/control lines\n"
  663. };
  664. static const char *decode_byte22_DDR2[] = {
  665. " TBD (bit 7)\n",
  666. " TBD (bit 6)\n",
  667. " TBD (bit 5)\n",
  668. " TBD (bit 4)\n",
  669. " TBD (bit 3)\n",
  670. " Supports partial array self refresh\n",
  671. " Supports 50 ohm ODT\n",
  672. " Supports weak driver\n"
  673. };
  674. static const char *decode_row_density_DDR2[] = {
  675. "512 MiB", "256 MiB", "128 MiB", "16 GiB",
  676. "8 GiB", "4 GiB", "2 GiB", "1 GiB"
  677. };
  678. static const char *decode_row_density_default[] = {
  679. "512 MiB", "256 MiB", "128 MiB", "64 MiB",
  680. "32 MiB", "16 MiB", "8 MiB", "4 MiB"
  681. };
  682. if (argc < 2) {
  683. printf ("Usage:\n%s\n", cmdtp->usage);
  684. return 1;
  685. }
  686. /*
  687. * Chip is always specified.
  688. */
  689. chip = simple_strtoul (argv[1], NULL, 16);
  690. if (i2c_read (chip, 0, 1, data, sizeof (data)) != 0) {
  691. puts ("No SDRAM Serial Presence Detect found.\n");
  692. return 1;
  693. }
  694. cksum = 0;
  695. for (j = 0; j < 63; j++) {
  696. cksum += data[j];
  697. }
  698. if (cksum != data[63]) {
  699. printf ("WARNING: Configuration data checksum failure:\n"
  700. " is 0x%02x, calculated 0x%02x\n", data[63], cksum);
  701. }
  702. printf ("SPD data revision %d.%d\n",
  703. (data[62] >> 4) & 0x0F, data[62] & 0x0F);
  704. printf ("Bytes used 0x%02X\n", data[0]);
  705. printf ("Serial memory size 0x%02X\n", 1 << data[1]);
  706. puts ("Memory type ");
  707. switch (data[2]) {
  708. case 2:
  709. type = EDO;
  710. puts ("EDO\n");
  711. break;
  712. case 4:
  713. type = SDRAM;
  714. puts ("SDRAM\n");
  715. break;
  716. case 8:
  717. type = DDR2;
  718. puts ("DDR2\n");
  719. break;
  720. default:
  721. type = unknown;
  722. puts ("unknown\n");
  723. break;
  724. }
  725. puts ("Row address bits ");
  726. if ((data[3] & 0x00F0) == 0)
  727. printf ("%d\n", data[3] & 0x0F);
  728. else
  729. printf ("%d/%d\n", data[3] & 0x0F, (data[3] >> 4) & 0x0F);
  730. puts ("Column address bits ");
  731. if ((data[4] & 0x00F0) == 0)
  732. printf ("%d\n", data[4] & 0x0F);
  733. else
  734. printf ("%d/%d\n", data[4] & 0x0F, (data[4] >> 4) & 0x0F);
  735. switch (type) {
  736. case DDR2:
  737. printf ("Number of ranks %d\n",
  738. (data[5] & 0x07) + 1);
  739. break;
  740. default:
  741. printf ("Module rows %d\n", data[5]);
  742. break;
  743. }
  744. switch (type) {
  745. case DDR2:
  746. printf ("Module data width %d bits\n", data[6]);
  747. break;
  748. default:
  749. printf ("Module data width %d bits\n",
  750. (data[7] << 8) | data[6]);
  751. break;
  752. }
  753. puts ("Interface signal levels ");
  754. switch(data[8]) {
  755. case 0: puts ("TTL 5.0 V\n"); break;
  756. case 1: puts ("LVTTL\n"); break;
  757. case 2: puts ("HSTL 1.5 V\n"); break;
  758. case 3: puts ("SSTL 3.3 V\n"); break;
  759. case 4: puts ("SSTL 2.5 V\n"); break;
  760. case 5: puts ("SSTL 1.8 V\n"); break;
  761. default: puts ("unknown\n"); break;
  762. }
  763. switch (type) {
  764. case DDR2:
  765. printf ("SDRAM cycle time ");
  766. print_ddr2_tcyc (data[9]);
  767. break;
  768. default:
  769. printf ("SDRAM cycle time %d.%d ns\n",
  770. (data[9] >> 4) & 0x0F, data[9] & 0x0F);
  771. break;
  772. }
  773. switch (type) {
  774. case DDR2:
  775. printf ("SDRAM access time 0.%d%d ns\n",
  776. (data[10] >> 4) & 0x0F, data[10] & 0x0F);
  777. break;
  778. default:
  779. printf ("SDRAM access time %d.%d ns\n",
  780. (data[10] >> 4) & 0x0F, data[10] & 0x0F);
  781. break;
  782. }
  783. puts ("EDC configuration ");
  784. switch (data[11]) {
  785. case 0: puts ("None\n"); break;
  786. case 1: puts ("Parity\n"); break;
  787. case 2: puts ("ECC\n"); break;
  788. default: puts ("unknown\n"); break;
  789. }
  790. if ((data[12] & 0x80) == 0)
  791. puts ("No self refresh, rate ");
  792. else
  793. puts ("Self refresh, rate ");
  794. switch(data[12] & 0x7F) {
  795. case 0: puts ("15.625 us\n"); break;
  796. case 1: puts ("3.9 us\n"); break;
  797. case 2: puts ("7.8 us\n"); break;
  798. case 3: puts ("31.3 us\n"); break;
  799. case 4: puts ("62.5 us\n"); break;
  800. case 5: puts ("125 us\n"); break;
  801. default: puts ("unknown\n"); break;
  802. }
  803. switch (type) {
  804. case DDR2:
  805. printf ("SDRAM width (primary) %d\n", data[13]);
  806. break;
  807. default:
  808. printf ("SDRAM width (primary) %d\n", data[13] & 0x7F);
  809. if ((data[13] & 0x80) != 0) {
  810. printf (" (second bank) %d\n",
  811. 2 * (data[13] & 0x7F));
  812. }
  813. break;
  814. }
  815. switch (type) {
  816. case DDR2:
  817. if (data[14] != 0)
  818. printf ("EDC width %d\n", data[14]);
  819. break;
  820. default:
  821. if (data[14] != 0) {
  822. printf ("EDC width %d\n",
  823. data[14] & 0x7F);
  824. if ((data[14] & 0x80) != 0) {
  825. printf (" (second bank) %d\n",
  826. 2 * (data[14] & 0x7F));
  827. }
  828. }
  829. break;
  830. }
  831. if (DDR2 != type) {
  832. printf ("Min clock delay, back-to-back random column addresses "
  833. "%d\n", data[15]);
  834. }
  835. puts ("Burst length(s) ");
  836. if (data[16] & 0x80) puts (" Page");
  837. if (data[16] & 0x08) puts (" 8");
  838. if (data[16] & 0x04) puts (" 4");
  839. if (data[16] & 0x02) puts (" 2");
  840. if (data[16] & 0x01) puts (" 1");
  841. putc ('\n');
  842. printf ("Number of banks %d\n", data[17]);
  843. switch (type) {
  844. case DDR2:
  845. puts ("CAS latency(s) ");
  846. decode_bits (data[18], decode_CAS_DDR2, 0);
  847. putc ('\n');
  848. break;
  849. default:
  850. puts ("CAS latency(s) ");
  851. decode_bits (data[18], decode_CAS_default, 0);
  852. putc ('\n');
  853. break;
  854. }
  855. if (DDR2 != type) {
  856. puts ("CS latency(s) ");
  857. decode_bits (data[19], decode_CS_WE_default, 0);
  858. putc ('\n');
  859. }
  860. if (DDR2 != type) {
  861. puts ("WE latency(s) ");
  862. decode_bits (data[20], decode_CS_WE_default, 0);
  863. putc ('\n');
  864. }
  865. switch (type) {
  866. case DDR2:
  867. puts ("Module attributes:\n");
  868. if (data[21] & 0x80)
  869. puts (" TBD (bit 7)\n");
  870. if (data[21] & 0x40)
  871. puts (" Analysis probe installed\n");
  872. if (data[21] & 0x20)
  873. puts (" TBD (bit 5)\n");
  874. if (data[21] & 0x10)
  875. puts (" FET switch external enable\n");
  876. printf (" %d PLLs on DIMM\n", (data[21] >> 2) & 0x03);
  877. if (data[20] & 0x11) {
  878. printf (" %d active registers on DIMM\n",
  879. (data[21] & 0x03) + 1);
  880. }
  881. break;
  882. default:
  883. puts ("Module attributes:\n");
  884. if (!data[21])
  885. puts (" (none)\n");
  886. else
  887. decode_bits (data[21], decode_byte21_default, 0);
  888. break;
  889. }
  890. switch (type) {
  891. case DDR2:
  892. decode_bits (data[22], decode_byte22_DDR2, 0);
  893. break;
  894. default:
  895. puts ("Device attributes:\n");
  896. if (data[22] & 0x80) puts (" TBD (bit 7)\n");
  897. if (data[22] & 0x40) puts (" TBD (bit 6)\n");
  898. if (data[22] & 0x20) puts (" Upper Vcc tolerance 5%\n");
  899. else puts (" Upper Vcc tolerance 10%\n");
  900. if (data[22] & 0x10) puts (" Lower Vcc tolerance 5%\n");
  901. else puts (" Lower Vcc tolerance 10%\n");
  902. if (data[22] & 0x08) puts (" Supports write1/read burst\n");
  903. if (data[22] & 0x04) puts (" Supports precharge all\n");
  904. if (data[22] & 0x02) puts (" Supports auto precharge\n");
  905. if (data[22] & 0x01) puts (" Supports early RAS# precharge\n");
  906. break;
  907. }
  908. switch (type) {
  909. case DDR2:
  910. printf ("SDRAM cycle time (2nd highest CAS latency) ");
  911. print_ddr2_tcyc (data[23]);
  912. break;
  913. default:
  914. printf ("SDRAM cycle time (2nd highest CAS latency) %d."
  915. "%d ns\n", (data[23] >> 4) & 0x0F, data[23] & 0x0F);
  916. break;
  917. }
  918. switch (type) {
  919. case DDR2:
  920. printf ("SDRAM access from clock (2nd highest CAS latency) 0."
  921. "%d%d ns\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F);
  922. break;
  923. default:
  924. printf ("SDRAM access from clock (2nd highest CAS latency) %d."
  925. "%d ns\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F);
  926. break;
  927. }
  928. switch (type) {
  929. case DDR2:
  930. printf ("SDRAM cycle time (3rd highest CAS latency) ");
  931. print_ddr2_tcyc (data[25]);
  932. break;
  933. default:
  934. printf ("SDRAM cycle time (3rd highest CAS latency) %d."
  935. "%d ns\n", (data[25] >> 4) & 0x0F, data[25] & 0x0F);
  936. break;
  937. }
  938. switch (type) {
  939. case DDR2:
  940. printf ("SDRAM access from clock (3rd highest CAS latency) 0."
  941. "%d%d ns\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F);
  942. break;
  943. default:
  944. printf ("SDRAM access from clock (3rd highest CAS latency) %d."
  945. "%d ns\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F);
  946. break;
  947. }
  948. switch (type) {
  949. case DDR2:
  950. printf ("Minimum row precharge %d.%02d ns\n",
  951. (data[27] >> 2) & 0x3F, 25 * (data[27] & 0x03));
  952. break;
  953. default:
  954. printf ("Minimum row precharge %d ns\n", data[27]);
  955. break;
  956. }
  957. switch (type) {
  958. case DDR2:
  959. printf ("Row active to row active min %d.%02d ns\n",
  960. (data[28] >> 2) & 0x3F, 25 * (data[28] & 0x03));
  961. break;
  962. default:
  963. printf ("Row active to row active min %d ns\n", data[28]);
  964. break;
  965. }
  966. switch (type) {
  967. case DDR2:
  968. printf ("RAS to CAS delay min %d.%02d ns\n",
  969. (data[29] >> 2) & 0x3F, 25 * (data[29] & 0x03));
  970. break;
  971. default:
  972. printf ("RAS to CAS delay min %d ns\n", data[29]);
  973. break;
  974. }
  975. printf ("Minimum RAS pulse width %d ns\n", data[30]);
  976. switch (type) {
  977. case DDR2:
  978. puts ("Density of each row ");
  979. decode_bits (data[31], decode_row_density_DDR2, 1);
  980. putc ('\n');
  981. break;
  982. default:
  983. puts ("Density of each row ");
  984. decode_bits (data[31], decode_row_density_default, 1);
  985. putc ('\n');
  986. break;
  987. }
  988. switch (type) {
  989. case DDR2:
  990. puts ("Command and Address setup ");
  991. if (data[32] >= 0xA0) {
  992. printf ("1.%d%d ns\n",
  993. ((data[32] >> 4) & 0x0F) - 10, data[32] & 0x0F);
  994. } else {
  995. printf ("0.%d%d ns\n",
  996. ((data[32] >> 4) & 0x0F), data[32] & 0x0F);
  997. }
  998. break;
  999. default:
  1000. printf ("Command and Address setup %c%d.%d ns\n",
  1001. (data[32] & 0x80) ? '-' : '+',
  1002. (data[32] >> 4) & 0x07, data[32] & 0x0F);
  1003. break;
  1004. }
  1005. switch (type) {
  1006. case DDR2:
  1007. puts ("Command and Address hold ");
  1008. if (data[33] >= 0xA0) {
  1009. printf ("1.%d%d ns\n",
  1010. ((data[33] >> 4) & 0x0F) - 10, data[33] & 0x0F);
  1011. } else {
  1012. printf ("0.%d%d ns\n",
  1013. ((data[33] >> 4) & 0x0F), data[33] & 0x0F);
  1014. }
  1015. break;
  1016. default:
  1017. printf ("Command and Address hold %c%d.%d ns\n",
  1018. (data[33] & 0x80) ? '-' : '+',
  1019. (data[33] >> 4) & 0x07, data[33] & 0x0F);
  1020. break;
  1021. }
  1022. switch (type) {
  1023. case DDR2:
  1024. printf ("Data signal input setup 0.%d%d ns\n",
  1025. (data[34] >> 4) & 0x0F, data[34] & 0x0F);
  1026. break;
  1027. default:
  1028. printf ("Data signal input setup %c%d.%d ns\n",
  1029. (data[34] & 0x80) ? '-' : '+',
  1030. (data[34] >> 4) & 0x07, data[34] & 0x0F);
  1031. break;
  1032. }
  1033. switch (type) {
  1034. case DDR2:
  1035. printf ("Data signal input hold 0.%d%d ns\n",
  1036. (data[35] >> 4) & 0x0F, data[35] & 0x0F);
  1037. break;
  1038. default:
  1039. printf ("Data signal input hold %c%d.%d ns\n",
  1040. (data[35] & 0x80) ? '-' : '+',
  1041. (data[35] >> 4) & 0x07, data[35] & 0x0F);
  1042. break;
  1043. }
  1044. puts ("Manufacturer's JEDEC ID ");
  1045. for (j = 64; j <= 71; j++)
  1046. printf ("%02X ", data[j]);
  1047. putc ('\n');
  1048. printf ("Manufacturing Location %02X\n", data[72]);
  1049. puts ("Manufacturer's Part Number ");
  1050. for (j = 73; j <= 90; j++)
  1051. printf ("%02X ", data[j]);
  1052. putc ('\n');
  1053. printf ("Revision Code %02X %02X\n", data[91], data[92]);
  1054. printf ("Manufacturing Date %02X %02X\n", data[93], data[94]);
  1055. puts ("Assembly Serial Number ");
  1056. for (j = 95; j <= 98; j++)
  1057. printf ("%02X ", data[j]);
  1058. putc ('\n');
  1059. if (DDR2 != type) {
  1060. printf ("Speed rating PC%d\n",
  1061. data[126] == 0x66 ? 66 : data[126]);
  1062. }
  1063. return 0;
  1064. }
  1065. #endif
  1066. #if defined(CONFIG_I2C_CMD_TREE)
  1067. #if defined(CONFIG_I2C_MULTI_BUS)
  1068. int do_i2c_bus_num(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  1069. {
  1070. int bus_idx, ret=0;
  1071. if (argc == 1)
  1072. /* querying current setting */
  1073. printf("Current bus is %d\n", i2c_get_bus_num());
  1074. else {
  1075. bus_idx = simple_strtoul(argv[1], NULL, 10);
  1076. printf("Setting bus to %d\n", bus_idx);
  1077. ret = i2c_set_bus_num(bus_idx);
  1078. if (ret)
  1079. printf("Failure changing bus number (%d)\n", ret);
  1080. }
  1081. return ret;
  1082. }
  1083. #endif /* CONFIG_I2C_MULTI_BUS */
  1084. int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  1085. {
  1086. int speed, ret=0;
  1087. if (argc == 1)
  1088. /* querying current speed */
  1089. printf("Current bus speed=%d\n", i2c_get_bus_speed());
  1090. else {
  1091. speed = simple_strtoul(argv[1], NULL, 10);
  1092. printf("Setting bus speed to %d Hz\n", speed);
  1093. ret = i2c_set_bus_speed(speed);
  1094. if (ret)
  1095. printf("Failure changing bus speed (%d)\n", ret);
  1096. }
  1097. return ret;
  1098. }
  1099. int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  1100. {
  1101. #if defined(CONFIG_I2C_MULTI_BUS)
  1102. if (!strncmp(argv[1], "de", 2))
  1103. return do_i2c_bus_num(cmdtp, flag, --argc, ++argv);
  1104. #endif /* CONFIG_I2C_MULTI_BUS */
  1105. if (!strncmp(argv[1], "sp", 2))
  1106. return do_i2c_bus_speed(cmdtp, flag, --argc, ++argv);
  1107. if (!strncmp(argv[1], "md", 2))
  1108. return do_i2c_md(cmdtp, flag, --argc, ++argv);
  1109. if (!strncmp(argv[1], "mm", 2))
  1110. return do_i2c_mm(cmdtp, flag, --argc, ++argv);
  1111. if (!strncmp(argv[1], "mw", 2))
  1112. return do_i2c_mw(cmdtp, flag, --argc, ++argv);
  1113. if (!strncmp(argv[1], "nm", 2))
  1114. return do_i2c_nm(cmdtp, flag, --argc, ++argv);
  1115. if (!strncmp(argv[1], "cr", 2))
  1116. return do_i2c_crc(cmdtp, flag, --argc, ++argv);
  1117. if (!strncmp(argv[1], "pr", 2))
  1118. return do_i2c_probe(cmdtp, flag, --argc, ++argv);
  1119. if (!strncmp(argv[1], "lo", 2))
  1120. return do_i2c_loop(cmdtp, flag, --argc, ++argv);
  1121. #if defined(CONFIG_CMD_SDRAM)
  1122. if (!strncmp(argv[1], "sd", 2))
  1123. return do_sdram(cmdtp, flag, --argc, ++argv);
  1124. #endif
  1125. else
  1126. printf ("Usage:\n%s\n", cmdtp->usage);
  1127. return 0;
  1128. }
  1129. #endif /* CONFIG_I2C_CMD_TREE */
  1130. /***************************************************/
  1131. #if defined(CONFIG_I2C_CMD_TREE)
  1132. U_BOOT_CMD(
  1133. i2c, 6, 1, do_i2c,
  1134. "i2c - I2C sub-system\n",
  1135. #if defined(CONFIG_I2C_MULTI_BUS)
  1136. "dev [dev] - show or set current I2C bus\n"
  1137. #endif /* CONFIG_I2C_MULTI_BUS */
  1138. "i2c speed [speed] - show or set I2C bus speed\n"
  1139. "i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device\n"
  1140. "i2c mm chip address[.0, .1, .2] - write to I2C device (auto-incrementing)\n"
  1141. "i2c mw chip address[.0, .1, .2] value [count] - write to I2C device (fill)\n"
  1142. "i2c nm chip address[.0, .1, .2] - write to I2C device (constant address)\n"
  1143. "i2c crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n"
  1144. "i2c probe - show devices on the I2C bus\n"
  1145. "i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device\n"
  1146. #if defined(CONFIG_CMD_SDRAM)
  1147. "i2c sdram chip - print SDRAM configuration information\n"
  1148. #endif
  1149. );
  1150. #endif /* CONFIG_I2C_CMD_TREE */
  1151. U_BOOT_CMD(
  1152. imd, 4, 1, do_i2c_md, \
  1153. "imd - i2c memory display\n", \
  1154. "chip address[.0, .1, .2] [# of objects]\n - i2c memory display\n" \
  1155. );
  1156. U_BOOT_CMD(
  1157. imm, 3, 1, do_i2c_mm,
  1158. "imm - i2c memory modify (auto-incrementing)\n",
  1159. "chip address[.0, .1, .2]\n"
  1160. " - memory modify, auto increment address\n"
  1161. );
  1162. U_BOOT_CMD(
  1163. inm, 3, 1, do_i2c_nm,
  1164. "inm - memory modify (constant address)\n",
  1165. "chip address[.0, .1, .2]\n - memory modify, read and keep address\n"
  1166. );
  1167. U_BOOT_CMD(
  1168. imw, 5, 1, do_i2c_mw,
  1169. "imw - memory write (fill)\n",
  1170. "chip address[.0, .1, .2] value [count]\n - memory write (fill)\n"
  1171. );
  1172. U_BOOT_CMD(
  1173. icrc32, 5, 1, do_i2c_crc,
  1174. "icrc32 - checksum calculation\n",
  1175. "chip address[.0, .1, .2] count\n - compute CRC32 checksum\n"
  1176. );
  1177. U_BOOT_CMD(
  1178. iprobe, 1, 1, do_i2c_probe,
  1179. "iprobe - probe to discover valid I2C chip addresses\n",
  1180. "\n -discover valid I2C chip addresses\n"
  1181. );
  1182. /*
  1183. * Require full name for "iloop" because it is an infinite loop!
  1184. */
  1185. U_BOOT_CMD(
  1186. iloop, 5, 1, do_i2c_loop,
  1187. "iloop - infinite loop on address range\n",
  1188. "chip address[.0, .1, .2] [# of objects]\n"
  1189. " - loop, reading a set of addresses\n"
  1190. );
  1191. #if defined(CONFIG_CMD_SDRAM)
  1192. U_BOOT_CMD(
  1193. isdram, 2, 1, do_sdram,
  1194. "isdram - print SDRAM configuration information\n",
  1195. "chip\n - print SDRAM configuration information\n"
  1196. " (valid chip values 50..57)\n"
  1197. );
  1198. #endif