mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Bo Shen <voice.shen@atmel.com>
To: "Raphaël Poggi" <raphio98@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH V2 0/2] Add device tree support of i2c Atmel driver
Date: Tue, 5 Aug 2014 14:55:32 +0800	[thread overview]
Message-ID: <53E07FE4.6070107@atmel.com> (raw)
In-Reply-To: <53DF5293.2010305@atmel.com>

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

Hi Raphaël Poggi,

On 08/04/2014 05:29 PM, Bo Shen wrote:
> Hi Raphaël Poggi,
>
> On 08/04/2014 05:22 PM, Raphaël Poggi wrote:
>> Hi,
>>
>> I have tested it on a custom board which use a sam9m10 and it
>> worked... Tell me more when we have found something suspicious.
>
> I tested on sama5d3xek with qt1070 connect to i2c, and the i2c host
> register successfully, however can not access qt1070, if I use i2c-gpio
> driver, it works well.
>
> I am still working on it, if any news, I will let you know.

I have re-write the interrupt function as the enclosed patch. Then, the 
i2c host driver works properly.

Can you help test it also on your board?

Thanks.

> Best Regards,
> Bo Shen
>
>> Thanks for your test.
>>
>> Raphaël Poggi
>>

Best Regards,
Bo Shen

[-- Attachment #2: 0001-I2C-at91-fix-the-method-for-interrupt.patch --]
[-- Type: text/x-patch, Size: 2146 bytes --]

From 1dd3da701f15d360b5432c9d2eb6e5ca1e5368ad Mon Sep 17 00:00:00 2001
From: Bo Shen <voice.shen@atmel.com>
Date: Tue, 5 Aug 2014 14:41:31 +0800
Subject: [PATCH] I2C: at91: fix the method for interrupt

As the i2c-at91 driver won't work in the interrupt mode,
so need to poll the interrupts.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
 drivers/i2c/busses/i2c-at91.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 944a8b3..8e3afe6 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -174,24 +174,32 @@ static void at91_twi_read_next_byte(struct at91_twi_dev *dev)
 static int at91_twi_wait_completion(struct at91_twi_dev *dev)
 {
 	uint64_t start = get_time_ns();
-	unsigned int status = at91_twi_read(dev, AT91_TWI_SR);
-	unsigned int irqstatus = at91_twi_read(dev, AT91_TWI_IMR);
+	unsigned int status;
+	unsigned int irqstatus;
+
+	do {
+		status = at91_twi_read(dev, AT91_TWI_SR);
+		irqstatus = at91_twi_read(dev, AT91_TWI_IMR);
+
+		if (!(status & irqstatus)) {
+			if(is_timeout(start, AT91_I2C_TIMEOUT)) {
+				dev_warn(&dev->adapter.dev, "timeout waiting for bus ready\n");
+				return -ETIMEDOUT;
+			} else {
+				continue;
+			}
+		}
 
-	if (irqstatus & AT91_TWI_RXRDY)
-		at91_twi_read_next_byte(dev);
-	else if (irqstatus & AT91_TWI_TXRDY)
-		at91_twi_write_next_byte(dev);
-	else
-		dev_warn(&dev->adapter.dev, "neither rx and tx are ready\n");
+		if (irqstatus & AT91_TWI_RXRDY)
+			at91_twi_read_next_byte(dev);
+		else if (irqstatus & AT91_TWI_TXRDY)
+			at91_twi_write_next_byte(dev);
+		else
+			dev_warn(&dev->adapter.dev, "neither rx and tx are ready\n");
 
-	dev->transfer_status |= status;
+		dev->transfer_status |= status;
 
-	while(!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP)) {
-		if(is_timeout(start, AT91_I2C_TIMEOUT)) {
-			dev_warn(&dev->adapter.dev, "timeout waiting for bus ready\n");
-			return -ETIMEDOUT;
-		}
-	}
+	} while (!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP));
 
 	at91_disable_twi_interrupts(dev);
 
-- 
1.8.5.2


[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-08-05  6:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04  8:31 Raphaël Poggi
2014-08-04  8:31 ` [PATCH V2 1/2] i2c: at91: add support of device tree Raphaël Poggi
2014-08-04  9:14   ` Bo Shen
2014-08-04  9:42     ` Raphaël Poggi
2014-08-04  9:50       ` Bo Shen
2014-08-04  8:31 ` [PATCH V2 2/2] at91sam9g45: clock: add i2c clocks Raphaël Poggi
2014-08-04  9:17   ` Bo Shen
2014-08-04  9:28     ` Raphaël Poggi
2014-08-04  9:11 ` [PATCH V2 0/2] Add device tree support of i2c Atmel driver Bo Shen
2014-08-04  9:22   ` Raphaël Poggi
2014-08-04  9:29     ` Bo Shen
2014-08-05  6:55       ` Bo Shen [this message]
2014-08-05  8:32         ` Raphaël Poggi
2014-08-05 20:05           ` Raphaël Poggi
2014-08-06  1:06             ` Bo Shen
2014-08-06  7:16               ` Raphaël Poggi
2014-08-06  7:33                 ` Bo Shen
2014-08-06  7:40                   ` Raphaël Poggi

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=53E07FE4.6070107@atmel.com \
    --to=voice.shen@atmel.com \
    --cc=barebox@lists.infradead.org \
    --cc=raphio98@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox