From: Bo Shen <voice.shen@atmel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] question about software i2c multi instance
Date: Mon, 23 Mar 2015 16:36:08 +0800 [thread overview]
Message-ID: <550FD078.1040804@atmel.com> (raw)
In-Reply-To: <20150323092828.7a22c885@amdc2363>
Hi Lukasz,
On 03/23/2015 04:28 PM, Lukasz Majewski wrote:
> Hi Bo,
>
>> Hi Heiko,
>> After check the software i2c code, I found it can not support
>> multi instances, although it has I2C_SOFT_DECLARATIONS2,
>> I2C_SOFT_DECLARATIONS3, I2C_SOFT_DECLARATIONS4.
>> Because, when do GPIO operation, there is only one pair of
>> CONFIG_SOFT_I2C_GPIO_SCL and CONFIG_SOFT_I2C_GPIO_SDA.
>> So, if want to support multi instances, it needs to extend the
>> GPIO configuration for SCL/SDA, am I right?
>
> Some time ago we had a similar problem with SW I2C code. Please look
> into Samsung's trats board implementation.
>
> However, such approach might be outdated, since Przemek is working on
> porting this functionality to device model:
>
> https://patchwork.ozlabs.org/patch/448460/
Thanks for your information.
Now, I just do it as following to make it work. For next step, I will
try to switch to use DM.
--->8---
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index db9b402..b9cfbb8 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -126,6 +126,13 @@ DECLARE_GLOBAL_DATA_PTR;
#define PRINTD(fmt,args...)
#endif
+#ifdef I2C_READ_ADAP
+static int soft_i2c_read_sda(void)
+{
+ I2C_READ_ADAP;
+}
+#endif
+
/*-----------------------------------------------------------------------
* Local functions
*/
@@ -256,7 +263,11 @@ static int write_byte(uchar data)
I2C_SCL(1);
I2C_DELAY;
I2C_DELAY;
+#ifdef I2C_READ_ADAP
+ nack = soft_i2c_read_sda();
+#else
nack = I2C_READ;
+#endif
I2C_SCL(0);
I2C_DELAY;
I2C_ACTIVE;
@@ -286,7 +297,11 @@ static uchar read_byte(int ack)
I2C_SCL(1);
I2C_DELAY;
data <<= 1;
+#ifdef I2C_READ_ADAP
+ data |= soft_i2c_read_sda();
+#else
data |= I2C_READ;
+#endif
I2C_DELAY;
}
send_ack(ack);
---8<---
Thanks again.
Best Regards,
Bo Shen
next prev parent reply other threads:[~2015-03-23 8:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-20 9:44 [U-Boot] question about software i2c multi instance Bo Shen
2015-03-20 10:10 ` Heiko Schocher
2015-03-23 6:27 ` Bo Shen
2015-03-23 8:28 ` Lukasz Majewski
2015-03-23 8:36 ` Bo Shen [this message]
2015-03-23 8:47 ` Przemyslaw Marczak
2015-03-23 9:09 ` Bo Shen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=550FD078.1040804@atmel.com \
--to=voice.shen@atmel.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.