diff mbox series

[U-Boot] cmd: i2c: Fix use sdram sub command with CONFIG_DM_I2C

Message ID 20171201053940.9539-1-iwamatsu@nigauri.org
State Accepted
Commit 28df8ed07f2ae936e9af28c146d555ed4d0c122a
Delegated to: Heiko Schocher
Headers show
Series [U-Boot] cmd: i2c: Fix use sdram sub command with CONFIG_DM_I2C | expand

Commit Message

Nobuhiro Iwamatsu Dec. 1, 2017, 5:39 a.m. UTC
sdram sub command of i2c command does not support Drivers Model.
This adds Drivers Model support to sdram sub command.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
---
 cmd/i2c.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Simon Glass Dec. 2, 2017, 3:32 a.m. UTC | #1
On 30 November 2017 at 22:39, Nobuhiro Iwamatsu <iwamatsu@nigauri.org> wrote:
> sdram sub command of i2c command does not support Drivers Model.
> This adds Drivers Model support to sdram sub command.
>
> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> ---
>  cmd/i2c.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Heiko Schocher Dec. 7, 2017, 8:27 a.m. UTC | #2
Hello Nobuhiro,

Am 01.12.2017 um 06:39 schrieb Nobuhiro Iwamatsu:
> sdram sub command of i2c command does not support Drivers Model.
> This adds Drivers Model support to sdram sub command.
> 
> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> ---
>   cmd/i2c.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)

Thanks!

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
Heiko Schocher Dec. 7, 2017, 12:22 p.m. UTC | #3
Hello Nobuhiro,

Am 01.12.2017 um 06:39 schrieb Nobuhiro Iwamatsu:
> sdram sub command of i2c command does not support Drivers Model.
> This adds Drivers Model support to sdram sub command.
> 
> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> ---
>   cmd/i2c.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)

Applied to u-boot-i2c master

Thanks!

bye,
Heiko
diff mbox series

Patch

diff --git a/cmd/i2c.c b/cmd/i2c.c
index 3dd7c6ba4d..bfddf8be1b 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -1156,7 +1156,10 @@  static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 	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"
@@ -1210,7 +1213,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;
 	}