X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fi2c.c;h=09c4ba9a1c752f48f6b0b5d293be0f6b80f639b8;hb=80b44fb3765e42e88e9cdd6cc037b47e3e263ff1;hp=b3bb64408fe18af0c2a754ed653384bd55dee880;hpb=d82477748d641e60ba3e1a0b55d98362aed70f80;p=oweals%2Fu-boot.git diff --git a/cmd/i2c.c b/cmd/i2c.c index b3bb64408f..09c4ba9a1c 100644 --- a/cmd/i2c.c +++ b/cmd/i2c.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2009 * Sergey Kubushyn, himself, ksi@koi8.net @@ -6,8 +7,6 @@ * * (C) Copyright 2001 * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com. - * - * SPDX-License-Identifier: GPL-2.0+ */ /* @@ -79,8 +78,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - /* Display values from last command. * Memory modify remembered values are different from display memory. */ @@ -151,6 +148,16 @@ static int cmd_i2c_set_bus_num(unsigned int busnum) static int i2c_get_cur_bus(struct udevice **busp) { +#ifdef CONFIG_I2C_SET_DEFAULT_BUS_NUM + if (!i2c_cur_bus) { + if (cmd_i2c_set_bus_num(CONFIG_I2C_DEFAULT_BUS_NUMBER)) { + printf("Default I2C bus %d not found\n", + CONFIG_I2C_DEFAULT_BUS_NUMBER); + return -ENODEV; + } + } +#endif + if (!i2c_cur_bus) { puts("No I2C bus selected\n"); return -ENODEV; @@ -178,7 +185,7 @@ static int i2c_get_cur_bus_chip(uint chip_addr, struct udevice **devp) * i2c_init_board() - Board-specific I2C bus init * * This function is the default no-op implementation of I2C bus - * initialization. This function can be overriden by board-specific + * initialization. This function can be overridden by board-specific * implementation if needed. */ __weak @@ -1141,12 +1148,15 @@ static void decode_bits (u_char const b, char const *str[], int const do_once) */ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) { - enum { unknown, EDO, SDRAM, DDR2 } type; + enum { unknown, EDO, SDRAM, DDR, DDR2, DDR3, DDR4 } type; uint chip; u_char data[128]; u_char cksum; - int j; + int j, ret; +#ifdef CONFIG_DM_I2C + struct udevice *dev; +#endif static const char *decode_CAS_DDR2[] = { " TBD", " 6", " 5", " 4", " 3", " 2", " TBD", " TBD" @@ -1200,7 +1210,14 @@ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) */ chip = simple_strtoul (argv[1], NULL, 16); - if (i2c_read (chip, 0, 1, data, sizeof (data)) != 0) { +#ifdef CONFIG_DM_I2C + ret = i2c_get_cur_bus_chip(chip, &dev); + if (!ret) + ret = dm_i2c_read(dev, 0, data, sizeof(data)); +#else + ret = i2c_read(chip, 0, 1, data, sizeof(data)); +#endif + if (ret) { puts ("No SDRAM Serial Presence Detect found.\n"); return 1; } @@ -1228,10 +1245,22 @@ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) type = SDRAM; puts ("SDRAM\n"); break; + case 7: + type = DDR; + puts("DDR\n"); + break; case 8: type = DDR2; puts ("DDR2\n"); break; + case 11: + type = DDR3; + puts("DDR3\n"); + break; + case 12: + type = DDR4; + puts("DDR4\n"); + break; default: type = unknown; puts ("unknown\n"); @@ -1994,6 +2023,7 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) static char i2c_help_text[] = #if defined(CONFIG_SYS_I2C) || defined(CONFIG_DM_I2C) "bus [muxtype:muxaddr:muxchannel] - show I2C bus info\n" + "i2c " /* That's the prefix for the crc32 command below. */ #endif "crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n" #if defined(CONFIG_SYS_I2C) || \