3 * Sergey Kubushyn, himself, ksi@koi8.net
5 * Changes for unified multibus/multiadapter I2C support.
8 * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com.
10 * SPDX-License-Identifier: GPL-2.0+
14 * I2C Functions similar to the standard memory functions.
16 * There are several parameters in many of the commands that bear further
19 * {i2c_chip} is the I2C chip address (the first byte sent on the bus).
20 * Each I2C chip on the bus has a unique address. On the I2C data bus,
21 * the address is the upper seven bits and the LSB is the "read/write"
22 * bit. Note that the {i2c_chip} address specified on the command
23 * line is not shifted up: e.g. a typical EEPROM memory chip may have
24 * an I2C address of 0x50, but the data put on the bus will be 0xA0
25 * for write and 0xA1 for read. This "non shifted" address notation
26 * matches at least half of the data sheets :-/.
28 * {addr} is the address (or offset) within the chip. Small memory
29 * chips have 8 bit addresses. Large memory chips have 16 bit
30 * addresses. Other memory chips have 9, 10, or 11 bit addresses.
31 * Many non-memory chips have multiple registers and {addr} is used
32 * as the register index. Some non-memory chips have only one register
33 * and therefore don't need any {addr} parameter.
35 * The default {addr} parameter is one byte (.1) which works well for
36 * memories and registers with 8 bits of address space.
38 * You can specify the length of the {addr} field with the optional .0,
39 * .1, or .2 modifier (similar to the .b, .w, .l modifier). If you are
40 * manipulating a single register device which doesn't use an address
41 * field, use "0.0" for the address and the ".0" length field will
42 * suppress the address in the I2C data stream. This also works for
43 * successive reads using the I2C auto-incrementing memory pointer.
45 * If you are manipulating a large memory with 2-byte addresses, use
46 * the .2 address modifier, e.g. 210.2 addresses location 528 (decimal).
48 * Then there are the unfortunate memory chips that spill the most
49 * significant 1, 2, or 3 bits of address into the chip address byte.
50 * This effectively makes one chip (logically) look like 2, 4, or
51 * 8 chips. This is handled (awkwardly) by #defining
52 * CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW and using the .1 modifier on the
53 * {addr} field (since .1 is the default, it doesn't actually have to
54 * be specified). Examples: given a memory chip at I2C chip address
55 * 0x50, the following would happen...
56 * i2c md 50 0 10 display 16 bytes starting at 0x000
57 * On the bus: <S> A0 00 <E> <S> A1 <rd> ... <rd>
58 * i2c md 50 100 10 display 16 bytes starting at 0x100
59 * On the bus: <S> A2 00 <E> <S> A3 <rd> ... <rd>
60 * i2c md 50 210 10 display 16 bytes starting at 0x210
61 * On the bus: <S> A4 10 <E> <S> A5 <rd> ... <rd>
62 * This is awfully ugly. It would be nice if someone would think up
63 * a better way of handling this.
65 * Adapted from cmd_mem.c which is copyright Wolfgang Denk (wd@denx.de).
69 #include <bootretry.h>
74 #include <environment.h>
78 #include <asm/byteorder.h>
79 #include <linux/compiler.h>
81 DECLARE_GLOBAL_DATA_PTR;
83 /* Display values from last command.
84 * Memory modify remembered values are different from display memory.
86 static uint i2c_dp_last_chip;
87 static uint i2c_dp_last_addr;
88 static uint i2c_dp_last_alen;
89 static uint i2c_dp_last_length = 0x10;
91 static uint i2c_mm_last_chip;
92 static uint i2c_mm_last_addr;
93 static uint i2c_mm_last_alen;
95 /* If only one I2C bus is present, the list of devices to ignore when
96 * the probe command is issued is represented by a 1D array of addresses.
97 * When multiple buses are present, the list is an array of bus-address
98 * pairs. The following macros take care of this */
100 #if defined(CONFIG_SYS_I2C_NOPROBES)
101 #if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MULTI_BUS)
106 } i2c_no_probes[] = CONFIG_SYS_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[] = CONFIG_SYS_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 /* defined(CONFIG_SYS_I2C) */
120 #define DISP_LINE_LEN 16
123 * Default for driver model is to use the chip's existing address length.
124 * For legacy code, this is not stored, so we need to use a suitable
128 #define DEFAULT_ADDR_LEN (-1)
130 #define DEFAULT_ADDR_LEN 1
134 static struct udevice *i2c_cur_bus;
136 static int cmd_i2c_set_bus_num(unsigned int busnum)
141 ret = uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus);
143 debug("%s: No bus %d\n", __func__, busnum);
151 static int i2c_get_cur_bus(struct udevice **busp)
154 puts("No I2C bus selected\n");
162 static int i2c_get_cur_bus_chip(uint chip_addr, struct udevice **devp)
167 ret = i2c_get_cur_bus(&bus);
171 return i2c_get_chip(bus, chip_addr, 1, devp);
177 * i2c_init_board() - Board-specific I2C bus init
179 * This function is the default no-op implementation of I2C bus
180 * initialization. This function can be overriden by board-specific
181 * implementation if needed.
184 void i2c_init_board(void)
188 /* TODO: Implement architecture-specific get/set functions */
191 * i2c_get_bus_speed() - Return I2C bus speed
193 * This function is the default implementation of function for retrieveing
194 * the current I2C bus speed in Hz.
196 * A driver implementing runtime switching of I2C bus speed must override
197 * this function to report the speed correctly. Simple or legacy drivers
198 * can use this fallback.
200 * Returns I2C bus speed in Hz.
202 #if !defined(CONFIG_SYS_I2C) && !defined(CONFIG_DM_I2C)
204 * TODO: Implement architecture-specific get/set functions
205 * Should go away, if we switched completely to new multibus support
208 unsigned int i2c_get_bus_speed(void)
210 return CONFIG_SYS_I2C_SPEED;
214 * i2c_set_bus_speed() - Configure I2C bus speed
215 * @speed: Newly set speed of the I2C bus in Hz
217 * This function is the default implementation of function for setting
218 * the I2C bus speed in Hz.
220 * A driver implementing runtime switching of I2C bus speed must override
221 * this function to report the speed correctly. Simple or legacy drivers
222 * can use this fallback.
224 * Returns zero on success, negative value on error.
227 int i2c_set_bus_speed(unsigned int speed)
229 if (speed != CONFIG_SYS_I2C_SPEED)
237 * get_alen() - Small parser helper function to get address length
239 * Returns the address length.
241 static uint get_alen(char *arg, int default_len)
247 for (j = 0; j < 8; j++) {
249 alen = arg[j+1] - '0';
251 } else if (arg[j] == '\0')
262 static int i2c_report_err(int ret, enum i2c_err_op op)
264 printf("Error %s the chip: %d\n",
265 op == I2C_ERR_READ ? "reading" : "writing", ret);
267 return CMD_RET_FAILURE;
271 * do_i2c_read() - Handle the "i2c read" command-line command
272 * @cmdtp: Command data struct pointer
273 * @flag: Command flag
274 * @argc: Command-line argument count
275 * @argv: Array of command-line arguments
277 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
281 * i2c read {i2c_chip} {devaddr}{.0, .1, .2} {len} {memaddr}
283 static int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
286 uint devaddr, length;
295 return CMD_RET_USAGE;
300 chip = simple_strtoul(argv[1], NULL, 16);
303 * I2C data address within the chip. This can be 1 or
304 * 2 bytes long. Some day it might be 3 bytes long :-).
306 devaddr = simple_strtoul(argv[2], NULL, 16);
307 alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
309 return CMD_RET_USAGE;
312 * Length is the number of objects, not number of bytes.
314 length = simple_strtoul(argv[3], NULL, 16);
317 * memaddr is the address where to store things in memory
319 memaddr = (u_char *)simple_strtoul(argv[4], NULL, 16);
322 ret = i2c_get_cur_bus_chip(chip, &dev);
323 if (!ret && alen != -1)
324 ret = i2c_set_chip_offset_len(dev, alen);
326 ret = dm_i2c_read(dev, devaddr, memaddr, length);
328 ret = i2c_read(chip, devaddr, alen, memaddr, length);
331 return i2c_report_err(ret, I2C_ERR_READ);
336 static int do_i2c_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
339 uint devaddr, length;
348 return cmd_usage(cmdtp);
351 * memaddr is the address where to store things in memory
353 memaddr = (u_char *)simple_strtoul(argv[1], NULL, 16);
358 chip = simple_strtoul(argv[2], NULL, 16);
361 * I2C data address within the chip. This can be 1 or
362 * 2 bytes long. Some day it might be 3 bytes long :-).
364 devaddr = simple_strtoul(argv[3], NULL, 16);
365 alen = get_alen(argv[3], DEFAULT_ADDR_LEN);
367 return cmd_usage(cmdtp);
370 * Length is the number of objects, not number of bytes.
372 length = simple_strtoul(argv[4], NULL, 16);
375 ret = i2c_get_cur_bus_chip(chip, &dev);
376 if (!ret && alen != -1)
377 ret = i2c_set_chip_offset_len(dev, alen);
379 return i2c_report_err(ret, I2C_ERR_WRITE);
382 while (length-- > 0) {
384 ret = dm_i2c_write(dev, devaddr++, memaddr++, 1);
386 ret = i2c_write(chip, devaddr++, alen, memaddr++, 1);
389 return i2c_report_err(ret, I2C_ERR_WRITE);
391 * No write delay with FRAM devices.
393 #if !defined(CONFIG_SYS_I2C_FRAM)
401 static int do_i2c_flags(cmd_tbl_t *cmdtp, int flag, int argc,
410 return CMD_RET_USAGE;
412 chip = simple_strtoul(argv[1], NULL, 16);
413 ret = i2c_get_cur_bus_chip(chip, &dev);
415 return i2c_report_err(ret, I2C_ERR_READ);
418 flags = simple_strtoul(argv[2], NULL, 16);
419 ret = i2c_set_chip_flags(dev, flags);
421 ret = i2c_get_chip_flags(dev, &flags);
423 printf("%x\n", flags);
426 return i2c_report_err(ret, I2C_ERR_READ);
433 * do_i2c_md() - Handle the "i2c md" command-line command
434 * @cmdtp: Command data struct pointer
435 * @flag: Command flag
436 * @argc: Command-line argument count
437 * @argv: Array of command-line arguments
439 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
443 * i2c md {i2c_chip} {addr}{.0, .1, .2} {len}
445 static int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
450 int j, nbytes, linebytes;
456 /* We use the last specified parameters, unless new ones are
459 chip = i2c_dp_last_chip;
460 addr = i2c_dp_last_addr;
461 alen = i2c_dp_last_alen;
462 length = i2c_dp_last_length;
465 return CMD_RET_USAGE;
467 if ((flag & CMD_FLAG_REPEAT) == 0) {
469 * New command specified.
475 chip = simple_strtoul(argv[1], NULL, 16);
478 * I2C data address within the chip. This can be 1 or
479 * 2 bytes long. Some day it might be 3 bytes long :-).
481 addr = simple_strtoul(argv[2], NULL, 16);
482 alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
484 return CMD_RET_USAGE;
487 * If another parameter, it is the length to display.
488 * Length is the number of objects, not number of bytes.
491 length = simple_strtoul(argv[3], NULL, 16);
495 ret = i2c_get_cur_bus_chip(chip, &dev);
496 if (!ret && alen != -1)
497 ret = i2c_set_chip_offset_len(dev, alen);
499 return i2c_report_err(ret, I2C_ERR_READ);
505 * We buffer all read data, so we can make sure data is read only
510 unsigned char linebuf[DISP_LINE_LEN];
513 linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
516 ret = dm_i2c_read(dev, addr, linebuf, linebytes);
518 ret = i2c_read(chip, addr, alen, linebuf, linebytes);
521 i2c_report_err(ret, I2C_ERR_READ);
523 printf("%04x:", addr);
525 for (j=0; j<linebytes; j++) {
526 printf(" %02x", *cp++);
531 for (j=0; j<linebytes; j++) {
532 if ((*cp < 0x20) || (*cp > 0x7e))
541 } while (nbytes > 0);
543 i2c_dp_last_chip = chip;
544 i2c_dp_last_addr = addr;
545 i2c_dp_last_alen = alen;
546 i2c_dp_last_length = length;
552 * do_i2c_mw() - Handle the "i2c mw" command-line command
553 * @cmdtp: Command data struct pointer
554 * @flag: Command flag
555 * @argc: Command-line argument count
556 * @argv: Array of command-line arguments
558 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
562 * i2c mw {i2c_chip} {addr}{.0, .1, .2} {data} [{count}]
564 static int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
576 if ((argc < 4) || (argc > 5))
577 return CMD_RET_USAGE;
580 * Chip is always specified.
582 chip = simple_strtoul(argv[1], NULL, 16);
585 * Address is always specified.
587 addr = simple_strtoul(argv[2], NULL, 16);
588 alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
590 return CMD_RET_USAGE;
593 ret = i2c_get_cur_bus_chip(chip, &dev);
594 if (!ret && alen != -1)
595 ret = i2c_set_chip_offset_len(dev, alen);
597 return i2c_report_err(ret, I2C_ERR_WRITE);
600 * Value to write is always specified.
602 byte = simple_strtoul(argv[3], NULL, 16);
608 count = simple_strtoul(argv[4], NULL, 16);
612 while (count-- > 0) {
614 ret = dm_i2c_write(dev, addr++, &byte, 1);
616 ret = i2c_write(chip, addr++, alen, &byte, 1);
619 i2c_report_err(ret, I2C_ERR_WRITE);
621 * Wait for the write to complete. The write can take
622 * up to 10mSec (we allow a little more time).
625 * No write delay with FRAM devices.
627 #if !defined(CONFIG_SYS_I2C_FRAM)
636 * do_i2c_crc() - Handle the "i2c crc32" command-line command
637 * @cmdtp: Command data struct pointer
638 * @flag: Command flag
639 * @argc: Command-line argument count
640 * @argv: Array of command-line arguments
642 * Calculate a CRC on memory
644 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
648 * i2c crc32 {i2c_chip} {addr}{.0, .1, .2} {count}
650 static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
665 return CMD_RET_USAGE;
668 * Chip is always specified.
670 chip = simple_strtoul(argv[1], NULL, 16);
673 * Address is always specified.
675 addr = simple_strtoul(argv[2], NULL, 16);
676 alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
678 return CMD_RET_USAGE;
681 ret = i2c_get_cur_bus_chip(chip, &dev);
682 if (!ret && alen != -1)
683 ret = i2c_set_chip_offset_len(dev, alen);
685 return i2c_report_err(ret, I2C_ERR_READ);
688 * Count is always specified
690 count = simple_strtoul(argv[3], NULL, 16);
692 printf ("CRC32 for %08lx ... %08lx ==> ", addr, addr + count - 1);
694 * CRC a byte at a time. This is going to be slooow, but hey, the
695 * memories are small and slow too so hopefully nobody notices.
699 while (count-- > 0) {
701 ret = dm_i2c_read(dev, addr, &byte, 1);
703 ret = i2c_read(chip, addr, alen, &byte, 1);
707 crc = crc32 (crc, &byte, 1);
711 i2c_report_err(ret, I2C_ERR_READ);
713 printf ("%08lx\n", crc);
719 * mod_i2c_mem() - Handle the "i2c mm" and "i2c nm" command-line command
720 * @cmdtp: Command data struct pointer
721 * @flag: Command flag
722 * @argc: Command-line argument count
723 * @argv: Array of command-line arguments
727 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
731 * i2c mm{.b, .w, .l} {i2c_chip} {addr}{.0, .1, .2}
732 * i2c nm{.b, .w, .l} {i2c_chip} {addr}{.0, .1, .2}
735 mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
749 return CMD_RET_USAGE;
751 bootretry_reset_cmd_timeout(); /* got a good command to get here */
753 * We use the last specified parameters, unless new ones are
756 chip = i2c_mm_last_chip;
757 addr = i2c_mm_last_addr;
758 alen = i2c_mm_last_alen;
760 if ((flag & CMD_FLAG_REPEAT) == 0) {
762 * New command specified. Check for a size specification.
763 * Defaults to byte if no or incorrect specification.
765 size = cmd_get_data_size(argv[0], 1);
768 * Chip is always specified.
770 chip = simple_strtoul(argv[1], NULL, 16);
773 * Address is always specified.
775 addr = simple_strtoul(argv[2], NULL, 16);
776 alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
778 return CMD_RET_USAGE;
782 ret = i2c_get_cur_bus_chip(chip, &dev);
783 if (!ret && alen != -1)
784 ret = i2c_set_chip_offset_len(dev, alen);
786 return i2c_report_err(ret, I2C_ERR_WRITE);
790 * Print the address, followed by value. Then accept input for
791 * the next value. A non-converted value exits.
794 printf("%08lx:", addr);
796 ret = dm_i2c_read(dev, addr, (uchar *)&data, size);
798 ret = i2c_read(chip, addr, alen, (uchar *)&data, size);
801 i2c_report_err(ret, I2C_ERR_READ);
803 data = cpu_to_be32(data);
805 printf(" %02lx", (data >> 24) & 0x000000FF);
807 printf(" %04lx", (data >> 16) & 0x0000FFFF);
809 printf(" %08lx", data);
812 nbytes = cli_readline(" ? ");
815 * <CR> pressed as only input, don't modify current
816 * location and move to next.
821 /* good enough to not time out */
822 bootretry_reset_cmd_timeout();
824 #ifdef CONFIG_BOOT_RETRY_TIME
825 else if (nbytes == -2)
826 break; /* timed out, exit the command */
831 data = simple_strtoul(console_buffer, &endp, 16);
836 data = be32_to_cpu(data);
837 nbytes = endp - console_buffer;
840 * good enough to not time out
842 bootretry_reset_cmd_timeout();
844 ret = dm_i2c_write(dev, addr, (uchar *)&data,
847 ret = i2c_write(chip, addr, alen,
848 (uchar *)&data, size);
851 i2c_report_err(ret, I2C_ERR_WRITE);
852 #ifdef CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
853 udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
861 i2c_mm_last_chip = chip;
862 i2c_mm_last_addr = addr;
863 i2c_mm_last_alen = alen;
869 * do_i2c_probe() - Handle the "i2c probe" command-line command
870 * @cmdtp: Command data struct pointer
871 * @flag: Command flag
872 * @argc: Command-line argument count
873 * @argv: Array of command-line arguments
875 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
881 * Returns zero (success) if one or more I2C devices was found
883 static int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
888 #if defined(CONFIG_SYS_I2C_NOPROBES)
890 unsigned int bus = GET_BUS_NUM;
891 #endif /* NOPROBES */
894 struct udevice *bus, *dev;
896 if (i2c_get_cur_bus(&bus))
897 return CMD_RET_FAILURE;
901 addr = simple_strtol(argv[1], 0, 16);
903 puts ("Valid chip addresses:");
904 for (j = 0; j < 128; j++) {
905 if ((0 <= addr) && (j != addr))
908 #if defined(CONFIG_SYS_I2C_NOPROBES)
910 for (k = 0; k < ARRAY_SIZE(i2c_no_probes); k++) {
911 if (COMPARE_BUS(bus, k) && COMPARE_ADDR(j, k)) {
920 ret = dm_i2c_probe(bus, j, 0, &dev);
931 #if defined(CONFIG_SYS_I2C_NOPROBES)
932 puts ("Excluded chip addresses:");
933 for (k = 0; k < ARRAY_SIZE(i2c_no_probes); k++) {
934 if (COMPARE_BUS(bus,k))
935 printf(" %02X", NO_PROBE_ADDR(k));
944 * do_i2c_loop() - Handle the "i2c loop" command-line command
945 * @cmdtp: Command data struct pointer
946 * @flag: Command flag
947 * @argc: Command-line argument count
948 * @argv: Array of command-line arguments
950 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
954 * i2c loop {i2c_chip} {addr}{.0, .1, .2} [{length}] [{delay}]
955 * {length} - Number of bytes to read
956 * {delay} - A DECIMAL number and defaults to 1000 uSec
958 static int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
972 return CMD_RET_USAGE;
975 * Chip is always specified.
977 chip = simple_strtoul(argv[1], NULL, 16);
980 * Address is always specified.
982 addr = simple_strtoul(argv[2], NULL, 16);
983 alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
985 return CMD_RET_USAGE;
987 ret = i2c_get_cur_bus_chip(chip, &dev);
988 if (!ret && alen != -1)
989 ret = i2c_set_chip_offset_len(dev, alen);
991 return i2c_report_err(ret, I2C_ERR_WRITE);
995 * Length is the number of objects, not number of bytes.
998 length = simple_strtoul(argv[3], NULL, 16);
999 if (length > sizeof(bytes))
1000 length = sizeof(bytes);
1003 * The delay time (uSec) is optional.
1007 delay = simple_strtoul(argv[4], NULL, 10);
1012 #ifdef CONFIG_DM_I2C
1013 ret = dm_i2c_read(dev, addr, bytes, length);
1015 ret = i2c_read(chip, addr, alen, bytes, length);
1018 i2c_report_err(ret, I2C_ERR_READ);
1027 * The SDRAM command is separately configured because many
1028 * (most?) embedded boards don't use SDRAM DIMMs.
1030 * FIXME: Document and probably move elsewhere!
1032 #if defined(CONFIG_CMD_SDRAM)
1033 static void print_ddr2_tcyc (u_char const b)
1035 printf ("%d.", (b >> 4) & 0x0F);
1047 printf ("%d ns\n", b & 0x0F);
1067 static void decode_bits (u_char const b, char const *str[], int const do_once)
1071 for (mask = 0x80; mask != 0x00; mask >>= 1, ++str) {
1082 * i2c sdram {i2c_chip}
1084 static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
1086 enum { unknown, EDO, SDRAM, DDR2 } type;
1093 static const char *decode_CAS_DDR2[] = {
1094 " TBD", " 6", " 5", " 4", " 3", " 2", " TBD", " TBD"
1097 static const char *decode_CAS_default[] = {
1098 " TBD", " 7", " 6", " 5", " 4", " 3", " 2", " 1"
1101 static const char *decode_CS_WE_default[] = {
1102 " TBD", " 6", " 5", " 4", " 3", " 2", " 1", " 0"
1105 static const char *decode_byte21_default[] = {
1107 " Redundant row address\n",
1108 " Differential clock input\n",
1109 " Registerd DQMB inputs\n",
1110 " Buffered DQMB inputs\n",
1112 " Registered address/control lines\n",
1113 " Buffered address/control lines\n"
1116 static const char *decode_byte22_DDR2[] = {
1122 " Supports partial array self refresh\n",
1123 " Supports 50 ohm ODT\n",
1124 " Supports weak driver\n"
1127 static const char *decode_row_density_DDR2[] = {
1128 "512 MiB", "256 MiB", "128 MiB", "16 GiB",
1129 "8 GiB", "4 GiB", "2 GiB", "1 GiB"
1132 static const char *decode_row_density_default[] = {
1133 "512 MiB", "256 MiB", "128 MiB", "64 MiB",
1134 "32 MiB", "16 MiB", "8 MiB", "4 MiB"
1138 return CMD_RET_USAGE;
1141 * Chip is always specified.
1143 chip = simple_strtoul (argv[1], NULL, 16);
1145 if (i2c_read (chip, 0, 1, data, sizeof (data)) != 0) {
1146 puts ("No SDRAM Serial Presence Detect found.\n");
1151 for (j = 0; j < 63; j++) {
1154 if (cksum != data[63]) {
1155 printf ("WARNING: Configuration data checksum failure:\n"
1156 " is 0x%02x, calculated 0x%02x\n", data[63], cksum);
1158 printf ("SPD data revision %d.%d\n",
1159 (data[62] >> 4) & 0x0F, data[62] & 0x0F);
1160 printf ("Bytes used 0x%02X\n", data[0]);
1161 printf ("Serial memory size 0x%02X\n", 1 << data[1]);
1163 puts ("Memory type ");
1183 puts ("Row address bits ");
1184 if ((data[3] & 0x00F0) == 0)
1185 printf ("%d\n", data[3] & 0x0F);
1187 printf ("%d/%d\n", data[3] & 0x0F, (data[3] >> 4) & 0x0F);
1189 puts ("Column address bits ");
1190 if ((data[4] & 0x00F0) == 0)
1191 printf ("%d\n", data[4] & 0x0F);
1193 printf ("%d/%d\n", data[4] & 0x0F, (data[4] >> 4) & 0x0F);
1197 printf ("Number of ranks %d\n",
1198 (data[5] & 0x07) + 1);
1201 printf ("Module rows %d\n", data[5]);
1207 printf ("Module data width %d bits\n", data[6]);
1210 printf ("Module data width %d bits\n",
1211 (data[7] << 8) | data[6]);
1215 puts ("Interface signal levels ");
1217 case 0: puts ("TTL 5.0 V\n"); break;
1218 case 1: puts ("LVTTL\n"); break;
1219 case 2: puts ("HSTL 1.5 V\n"); break;
1220 case 3: puts ("SSTL 3.3 V\n"); break;
1221 case 4: puts ("SSTL 2.5 V\n"); break;
1222 case 5: puts ("SSTL 1.8 V\n"); break;
1223 default: puts ("unknown\n"); break;
1228 printf ("SDRAM cycle time ");
1229 print_ddr2_tcyc (data[9]);
1232 printf ("SDRAM cycle time %d.%d ns\n",
1233 (data[9] >> 4) & 0x0F, data[9] & 0x0F);
1239 printf ("SDRAM access time 0.%d%d ns\n",
1240 (data[10] >> 4) & 0x0F, data[10] & 0x0F);
1243 printf ("SDRAM access time %d.%d ns\n",
1244 (data[10] >> 4) & 0x0F, data[10] & 0x0F);
1248 puts ("EDC configuration ");
1250 case 0: puts ("None\n"); break;
1251 case 1: puts ("Parity\n"); break;
1252 case 2: puts ("ECC\n"); break;
1253 default: puts ("unknown\n"); break;
1256 if ((data[12] & 0x80) == 0)
1257 puts ("No self refresh, rate ");
1259 puts ("Self refresh, rate ");
1261 switch(data[12] & 0x7F) {
1262 case 0: puts ("15.625 us\n"); break;
1263 case 1: puts ("3.9 us\n"); break;
1264 case 2: puts ("7.8 us\n"); break;
1265 case 3: puts ("31.3 us\n"); break;
1266 case 4: puts ("62.5 us\n"); break;
1267 case 5: puts ("125 us\n"); break;
1268 default: puts ("unknown\n"); break;
1273 printf ("SDRAM width (primary) %d\n", data[13]);
1276 printf ("SDRAM width (primary) %d\n", data[13] & 0x7F);
1277 if ((data[13] & 0x80) != 0) {
1278 printf (" (second bank) %d\n",
1279 2 * (data[13] & 0x7F));
1287 printf ("EDC width %d\n", data[14]);
1290 if (data[14] != 0) {
1291 printf ("EDC width %d\n",
1294 if ((data[14] & 0x80) != 0) {
1295 printf (" (second bank) %d\n",
1296 2 * (data[14] & 0x7F));
1303 printf ("Min clock delay, back-to-back random column addresses "
1307 puts ("Burst length(s) ");
1308 if (data[16] & 0x80) puts (" Page");
1309 if (data[16] & 0x08) puts (" 8");
1310 if (data[16] & 0x04) puts (" 4");
1311 if (data[16] & 0x02) puts (" 2");
1312 if (data[16] & 0x01) puts (" 1");
1314 printf ("Number of banks %d\n", data[17]);
1318 puts ("CAS latency(s) ");
1319 decode_bits (data[18], decode_CAS_DDR2, 0);
1323 puts ("CAS latency(s) ");
1324 decode_bits (data[18], decode_CAS_default, 0);
1330 puts ("CS latency(s) ");
1331 decode_bits (data[19], decode_CS_WE_default, 0);
1336 puts ("WE latency(s) ");
1337 decode_bits (data[20], decode_CS_WE_default, 0);
1343 puts ("Module attributes:\n");
1344 if (data[21] & 0x80)
1345 puts (" TBD (bit 7)\n");
1346 if (data[21] & 0x40)
1347 puts (" Analysis probe installed\n");
1348 if (data[21] & 0x20)
1349 puts (" TBD (bit 5)\n");
1350 if (data[21] & 0x10)
1351 puts (" FET switch external enable\n");
1352 printf (" %d PLLs on DIMM\n", (data[21] >> 2) & 0x03);
1353 if (data[20] & 0x11) {
1354 printf (" %d active registers on DIMM\n",
1355 (data[21] & 0x03) + 1);
1359 puts ("Module attributes:\n");
1363 decode_bits (data[21], decode_byte21_default, 0);
1369 decode_bits (data[22], decode_byte22_DDR2, 0);
1372 puts ("Device attributes:\n");
1373 if (data[22] & 0x80) puts (" TBD (bit 7)\n");
1374 if (data[22] & 0x40) puts (" TBD (bit 6)\n");
1375 if (data[22] & 0x20) puts (" Upper Vcc tolerance 5%\n");
1376 else puts (" Upper Vcc tolerance 10%\n");
1377 if (data[22] & 0x10) puts (" Lower Vcc tolerance 5%\n");
1378 else puts (" Lower Vcc tolerance 10%\n");
1379 if (data[22] & 0x08) puts (" Supports write1/read burst\n");
1380 if (data[22] & 0x04) puts (" Supports precharge all\n");
1381 if (data[22] & 0x02) puts (" Supports auto precharge\n");
1382 if (data[22] & 0x01) puts (" Supports early RAS# precharge\n");
1388 printf ("SDRAM cycle time (2nd highest CAS latency) ");
1389 print_ddr2_tcyc (data[23]);
1392 printf ("SDRAM cycle time (2nd highest CAS latency) %d."
1393 "%d ns\n", (data[23] >> 4) & 0x0F, data[23] & 0x0F);
1399 printf ("SDRAM access from clock (2nd highest CAS latency) 0."
1400 "%d%d ns\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F);
1403 printf ("SDRAM access from clock (2nd highest CAS latency) %d."
1404 "%d ns\n", (data[24] >> 4) & 0x0F, data[24] & 0x0F);
1410 printf ("SDRAM cycle time (3rd highest CAS latency) ");
1411 print_ddr2_tcyc (data[25]);
1414 printf ("SDRAM cycle time (3rd highest CAS latency) %d."
1415 "%d ns\n", (data[25] >> 4) & 0x0F, data[25] & 0x0F);
1421 printf ("SDRAM access from clock (3rd highest CAS latency) 0."
1422 "%d%d ns\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F);
1425 printf ("SDRAM access from clock (3rd highest CAS latency) %d."
1426 "%d ns\n", (data[26] >> 4) & 0x0F, data[26] & 0x0F);
1432 printf ("Minimum row precharge %d.%02d ns\n",
1433 (data[27] >> 2) & 0x3F, 25 * (data[27] & 0x03));
1436 printf ("Minimum row precharge %d ns\n", data[27]);
1442 printf ("Row active to row active min %d.%02d ns\n",
1443 (data[28] >> 2) & 0x3F, 25 * (data[28] & 0x03));
1446 printf ("Row active to row active min %d ns\n", data[28]);
1452 printf ("RAS to CAS delay min %d.%02d ns\n",
1453 (data[29] >> 2) & 0x3F, 25 * (data[29] & 0x03));
1456 printf ("RAS to CAS delay min %d ns\n", data[29]);
1460 printf ("Minimum RAS pulse width %d ns\n", data[30]);
1464 puts ("Density of each row ");
1465 decode_bits (data[31], decode_row_density_DDR2, 1);
1469 puts ("Density of each row ");
1470 decode_bits (data[31], decode_row_density_default, 1);
1477 puts ("Command and Address setup ");
1478 if (data[32] >= 0xA0) {
1479 printf ("1.%d%d ns\n",
1480 ((data[32] >> 4) & 0x0F) - 10, data[32] & 0x0F);
1482 printf ("0.%d%d ns\n",
1483 ((data[32] >> 4) & 0x0F), data[32] & 0x0F);
1487 printf ("Command and Address setup %c%d.%d ns\n",
1488 (data[32] & 0x80) ? '-' : '+',
1489 (data[32] >> 4) & 0x07, data[32] & 0x0F);
1495 puts ("Command and Address hold ");
1496 if (data[33] >= 0xA0) {
1497 printf ("1.%d%d ns\n",
1498 ((data[33] >> 4) & 0x0F) - 10, data[33] & 0x0F);
1500 printf ("0.%d%d ns\n",
1501 ((data[33] >> 4) & 0x0F), data[33] & 0x0F);
1505 printf ("Command and Address hold %c%d.%d ns\n",
1506 (data[33] & 0x80) ? '-' : '+',
1507 (data[33] >> 4) & 0x07, data[33] & 0x0F);
1513 printf ("Data signal input setup 0.%d%d ns\n",
1514 (data[34] >> 4) & 0x0F, data[34] & 0x0F);
1517 printf ("Data signal input setup %c%d.%d ns\n",
1518 (data[34] & 0x80) ? '-' : '+',
1519 (data[34] >> 4) & 0x07, data[34] & 0x0F);
1525 printf ("Data signal input hold 0.%d%d ns\n",
1526 (data[35] >> 4) & 0x0F, data[35] & 0x0F);
1529 printf ("Data signal input hold %c%d.%d ns\n",
1530 (data[35] & 0x80) ? '-' : '+',
1531 (data[35] >> 4) & 0x07, data[35] & 0x0F);
1535 puts ("Manufacturer's JEDEC ID ");
1536 for (j = 64; j <= 71; j++)
1537 printf ("%02X ", data[j]);
1539 printf ("Manufacturing Location %02X\n", data[72]);
1540 puts ("Manufacturer's Part Number ");
1541 for (j = 73; j <= 90; j++)
1542 printf ("%02X ", data[j]);
1544 printf ("Revision Code %02X %02X\n", data[91], data[92]);
1545 printf ("Manufacturing Date %02X %02X\n", data[93], data[94]);
1546 puts ("Assembly Serial Number ");
1547 for (j = 95; j <= 98; j++)
1548 printf ("%02X ", data[j]);
1552 printf ("Speed rating PC%d\n",
1553 data[126] == 0x66 ? 66 : data[126]);
1561 * i2c edid {i2c_chip}
1563 #if defined(CONFIG_I2C_EDID)
1564 int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
1567 struct edid1_info edid;
1569 #ifdef CONFIG_DM_I2C
1570 struct udevice *dev;
1578 chip = simple_strtoul(argv[1], NULL, 16);
1579 #ifdef CONFIG_DM_I2C
1580 ret = i2c_get_cur_bus_chip(chip, &dev);
1582 ret = dm_i2c_read(dev, 0, (uchar *)&edid, sizeof(edid));
1584 ret = i2c_read(chip, 0, 1, (uchar *)&edid, sizeof(edid));
1587 return i2c_report_err(ret, I2C_ERR_READ);
1589 if (edid_check_info(&edid)) {
1590 puts("Content isn't valid EDID.\n");
1594 edid_print_info(&edid);
1598 #endif /* CONFIG_I2C_EDID */
1601 * do_i2c_show_bus() - Handle the "i2c bus" command-line command
1602 * @cmdtp: Command data struct pointer
1603 * @flag: Command flag
1604 * @argc: Command-line argument count
1605 * @argv: Array of command-line arguments
1607 * Returns zero always.
1609 #if defined(CONFIG_SYS_I2C)
1610 static int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc,
1611 char * const argv[])
1614 #ifndef CONFIG_SYS_I2C_DIRECT_BUS
1619 /* show all busses */
1620 for (i = 0; i < CONFIG_SYS_NUM_I2C_BUSES; i++) {
1621 printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name);
1622 #ifndef CONFIG_SYS_I2C_DIRECT_BUS
1623 for (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {
1624 if (i2c_bus[i].next_hop[j].chip == 0)
1626 printf("->%s@0x%2x:%d",
1627 i2c_bus[i].next_hop[j].mux.name,
1628 i2c_bus[i].next_hop[j].chip,
1629 i2c_bus[i].next_hop[j].channel);
1635 /* show specific bus */
1636 i = simple_strtoul(argv[1], NULL, 10);
1637 if (i >= CONFIG_SYS_NUM_I2C_BUSES) {
1638 printf("Invalid bus %d\n", i);
1641 printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name);
1642 #ifndef CONFIG_SYS_I2C_DIRECT_BUS
1643 for (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {
1644 if (i2c_bus[i].next_hop[j].chip == 0)
1646 printf("->%s@0x%2x:%d",
1647 i2c_bus[i].next_hop[j].mux.name,
1648 i2c_bus[i].next_hop[j].chip,
1649 i2c_bus[i].next_hop[j].channel);
1660 * do_i2c_bus_num() - Handle the "i2c dev" command-line command
1661 * @cmdtp: Command data struct pointer
1662 * @flag: Command flag
1663 * @argc: Command-line argument count
1664 * @argv: Array of command-line arguments
1666 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
1669 #if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MULTI_BUS) || \
1670 defined(CONFIG_DM_I2C)
1671 static int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc,
1672 char * const argv[])
1678 /* querying current setting */
1679 #ifdef CONFIG_DM_I2C
1680 struct udevice *bus;
1682 if (!i2c_get_cur_bus(&bus))
1687 bus_no = i2c_get_bus_num();
1689 printf("Current bus is %d\n", bus_no);
1691 bus_no = simple_strtoul(argv[1], NULL, 10);
1692 #if defined(CONFIG_SYS_I2C)
1693 if (bus_no >= CONFIG_SYS_NUM_I2C_BUSES) {
1694 printf("Invalid bus %d\n", bus_no);
1698 printf("Setting bus to %d\n", bus_no);
1699 #ifdef CONFIG_DM_I2C
1700 ret = cmd_i2c_set_bus_num(bus_no);
1702 ret = i2c_set_bus_num(bus_no);
1705 printf("Failure changing bus number (%d)\n", ret);
1709 #endif /* defined(CONFIG_SYS_I2C) */
1712 * do_i2c_bus_speed() - Handle the "i2c speed" command-line command
1713 * @cmdtp: Command data struct pointer
1714 * @flag: Command flag
1715 * @argc: Command-line argument count
1716 * @argv: Array of command-line arguments
1718 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
1721 static int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
1725 #ifdef CONFIG_DM_I2C
1726 struct udevice *bus;
1728 if (i2c_get_cur_bus(&bus))
1732 #ifdef CONFIG_DM_I2C
1733 speed = i2c_get_bus_speed(bus);
1735 speed = i2c_get_bus_speed();
1737 /* querying current speed */
1738 printf("Current bus speed=%d\n", speed);
1740 speed = simple_strtoul(argv[1], NULL, 10);
1741 printf("Setting bus speed to %d Hz\n", speed);
1742 #ifdef CONFIG_DM_I2C
1743 ret = i2c_set_bus_speed(bus, speed);
1745 ret = i2c_set_bus_speed(speed);
1748 printf("Failure changing bus speed (%d)\n", ret);
1754 * do_i2c_mm() - Handle the "i2c mm" command-line command
1755 * @cmdtp: Command data struct pointer
1756 * @flag: Command flag
1757 * @argc: Command-line argument count
1758 * @argv: Array of command-line arguments
1760 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
1763 static int do_i2c_mm(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
1765 return mod_i2c_mem (cmdtp, 1, flag, argc, argv);
1769 * do_i2c_nm() - Handle the "i2c nm" command-line command
1770 * @cmdtp: Command data struct pointer
1771 * @flag: Command flag
1772 * @argc: Command-line argument count
1773 * @argv: Array of command-line arguments
1775 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
1778 static int do_i2c_nm(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
1780 return mod_i2c_mem (cmdtp, 0, flag, argc, argv);
1784 * do_i2c_reset() - Handle the "i2c reset" command-line command
1785 * @cmdtp: Command data struct pointer
1786 * @flag: Command flag
1787 * @argc: Command-line argument count
1788 * @argv: Array of command-line arguments
1790 * Returns zero always.
1792 static int do_i2c_reset(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
1794 #if defined(CONFIG_DM_I2C)
1795 struct udevice *bus;
1797 if (i2c_get_cur_bus(&bus))
1798 return CMD_RET_FAILURE;
1799 if (i2c_deblock(bus)) {
1800 printf("Error: Not supported by the driver\n");
1801 return CMD_RET_FAILURE;
1803 #elif defined(CONFIG_SYS_I2C)
1804 i2c_init(I2C_ADAP->speed, I2C_ADAP->slaveaddr);
1806 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
1811 static cmd_tbl_t cmd_i2c_sub[] = {
1812 #if defined(CONFIG_SYS_I2C)
1813 U_BOOT_CMD_MKENT(bus, 1, 1, do_i2c_show_bus, "", ""),
1815 U_BOOT_CMD_MKENT(crc32, 3, 1, do_i2c_crc, "", ""),
1816 #if defined(CONFIG_SYS_I2C) || \
1817 defined(CONFIG_I2C_MULTI_BUS) || defined(CONFIG_DM_I2C)
1818 U_BOOT_CMD_MKENT(dev, 1, 1, do_i2c_bus_num, "", ""),
1819 #endif /* CONFIG_I2C_MULTI_BUS */
1820 #if defined(CONFIG_I2C_EDID)
1821 U_BOOT_CMD_MKENT(edid, 1, 1, do_edid, "", ""),
1822 #endif /* CONFIG_I2C_EDID */
1823 U_BOOT_CMD_MKENT(loop, 3, 1, do_i2c_loop, "", ""),
1824 U_BOOT_CMD_MKENT(md, 3, 1, do_i2c_md, "", ""),
1825 U_BOOT_CMD_MKENT(mm, 2, 1, do_i2c_mm, "", ""),
1826 U_BOOT_CMD_MKENT(mw, 3, 1, do_i2c_mw, "", ""),
1827 U_BOOT_CMD_MKENT(nm, 2, 1, do_i2c_nm, "", ""),
1828 U_BOOT_CMD_MKENT(probe, 0, 1, do_i2c_probe, "", ""),
1829 U_BOOT_CMD_MKENT(read, 5, 1, do_i2c_read, "", ""),
1830 U_BOOT_CMD_MKENT(write, 5, 0, do_i2c_write, "", ""),
1831 #ifdef CONFIG_DM_I2C
1832 U_BOOT_CMD_MKENT(flags, 2, 1, do_i2c_flags, "", ""),
1834 U_BOOT_CMD_MKENT(reset, 0, 1, do_i2c_reset, "", ""),
1835 #if defined(CONFIG_CMD_SDRAM)
1836 U_BOOT_CMD_MKENT(sdram, 1, 1, do_sdram, "", ""),
1838 U_BOOT_CMD_MKENT(speed, 1, 1, do_i2c_bus_speed, "", ""),
1841 #ifdef CONFIG_NEEDS_MANUAL_RELOC
1842 void i2c_reloc(void) {
1843 fixup_cmdtable(cmd_i2c_sub, ARRAY_SIZE(cmd_i2c_sub));
1848 * do_i2c() - Handle the "i2c" command-line command
1849 * @cmdtp: Command data struct pointer
1850 * @flag: Command flag
1851 * @argc: Command-line argument count
1852 * @argv: Array of command-line arguments
1854 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
1857 static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
1862 return CMD_RET_USAGE;
1864 /* Strip off leading 'i2c' command argument */
1868 c = find_cmd_tbl(argv[0], &cmd_i2c_sub[0], ARRAY_SIZE(cmd_i2c_sub));
1871 return c->cmd(cmdtp, flag, argc, argv);
1873 return CMD_RET_USAGE;
1876 /***************************************************/
1877 #ifdef CONFIG_SYS_LONGHELP
1878 static char i2c_help_text[] =
1879 #if defined(CONFIG_SYS_I2C)
1880 "bus [muxtype:muxaddr:muxchannel] - show I2C bus info\n"
1882 "crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n"
1883 #if defined(CONFIG_SYS_I2C) || \
1884 defined(CONFIG_I2C_MULTI_BUS) || defined(CONFIG_DM_I2C)
1885 "i2c dev [dev] - show or set current I2C bus\n"
1886 #endif /* CONFIG_I2C_MULTI_BUS */
1887 #if defined(CONFIG_I2C_EDID)
1888 "i2c edid chip - print EDID configuration information\n"
1889 #endif /* CONFIG_I2C_EDID */
1890 "i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device\n"
1891 "i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device\n"
1892 "i2c mm chip address[.0, .1, .2] - write to I2C device (auto-incrementing)\n"
1893 "i2c mw chip address[.0, .1, .2] value [count] - write to I2C device (fill)\n"
1894 "i2c nm chip address[.0, .1, .2] - write to I2C device (constant address)\n"
1895 "i2c probe [address] - test for and show device(s) on the I2C bus\n"
1896 "i2c read chip address[.0, .1, .2] length memaddress - read to memory\n"
1897 "i2c write memaddress chip address[.0, .1, .2] length - write memory to i2c\n"
1898 #ifdef CONFIG_DM_I2C
1899 "i2c flags chip [flags] - set or get chip flags\n"
1901 "i2c reset - re-init the I2C Controller\n"
1902 #if defined(CONFIG_CMD_SDRAM)
1903 "i2c sdram chip - print SDRAM configuration information\n"
1905 "i2c speed [speed] - show or set I2C bus speed";