* [U-Boot] [PATCH] soft_i2c.c add option for repeated start in i2c_read()
@ 2008-12-29 23:36 Andrew Dyer
2009-01-27 21:26 ` Wolfgang Denk
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Dyer @ 2008-12-29 23:36 UTC (permalink / raw)
To: u-boot
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>
---
README | 9 +++++++++
drivers/i2c/soft_i2c.c | 12 +++++++++++-
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/README b/README
index 2a553c2..763fb7a 100644
--- a/README
+++ b/README
@@ -1496,6 +1496,15 @@ The following options need to be configured:
Bus on the MPC8260. But it should be not so difficult
to add this option to other architectures.
+ CONFIG_SOFT_I2C_READ_REPEATED_START
+
+ defining this will force the i2c_read() function in
+ the soft_i2c driver to perform an I2C repeated start
+ between writing the address pointer and reading the
+ data. If this define is omitted the default behaviour
+ of doing a stop-start sequence will be used. Most I2C
+ devices can use either method, but some require one or
+ the other.
- SPI Support: CONFIG_SPI
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index a27de5a..da6cec1 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.
--
1.5.6.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] soft_i2c.c add option for repeated start in i2c_read()
2008-12-29 23:36 [U-Boot] [PATCH] soft_i2c.c add option for repeated start in i2c_read() Andrew Dyer
@ 2009-01-27 21:26 ` Wolfgang Denk
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2009-01-27 21:26 UTC (permalink / raw)
To: u-boot
Dear Andrew Dyer,
In message <49595EE1.8040001@righthandtech.com> you wrote:
>
> 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>
> ---
> README | 9 +++++++++
> drivers/i2c/soft_i2c.c | 12 +++++++++++-
> 2 files changed, 20 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A wise person makes his own decisions, a weak one obeys public
opinion. -- Chinese proverb
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-27 21:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-29 23:36 [U-Boot] [PATCH] soft_i2c.c add option for repeated start in i2c_read() Andrew Dyer
2009-01-27 21:26 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox