summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrew Dyer <adyer@righthandtech.com>2008-12-29 17:36:01 -0600
committerWolfgang Denk <wd@denx.de>2009-01-27 22:26:31 +0100
commit2ac6985a7466a1c8a7aa8b2fa24d360925a82764 (patch)
tree81c39426e12780c0c88d7634244203916f9f98cf /drivers
parent3429071700963ca2f944c51d695a7481af0cee33 (diff)
downloadblackbird-obmc-uboot-2ac6985a7466a1c8a7aa8b2fa24d360925a82764.tar.gz
blackbird-obmc-uboot-2ac6985a7466a1c8a7aa8b2fa24d360925a82764.zip
soft_i2c.c add option for repeated start in i2c_read()
This patch adds a #define to optionally change the behaviour of i2c_read() in soft_i2c.c to send an I2C repeated start instead of a stop-start between sending the device address pointer write and reading back the data. The current behaviour is retained as the default. While most devices will work either way, I have a smart battery(*) that requires repeated start, and someone at some point found a device that required a stop-start. (*) http://www.inspired-energy.com/Standard_Products/NL2054/NL2054%20Rev1.0%20Data%20Sheet.pdf Signed-off-by: Andrew Dyer <adyer@righthandtech.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/soft_i2c.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index a27de5a7ec..da6cec1fa2 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -385,8 +385,18 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
}
shift -= 8;
}
- send_stop(); /* reportedly some chips need a full stop */
+
+ /* Some I2C chips need a stop/start sequence here,
+ * other chips don't work with a full stop and need
+ * only a start. Default behaviour is to send the
+ * stop/start sequence.
+ */
+#ifdef CONFIG_SOFT_I2C_READ_REPEATED_START
send_start();
+#else
+ send_stop();
+ send_start();
+#endif
}
/*
* Send the chip address again, this time for a read cycle.
OpenPOWER on IntegriCloud