cmd_i2c.c 32 KB

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