All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] i2c: at91: fix SMBus quick command
@ 2012-11-13 15:43 ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 6+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-11-13 15:43 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, N.Voss-+umVssTZoCsb1SvskN2V4Q,
	khali-PUYAD+kWke1g9hUCZPvPmw, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

The driver claims to support SMBus quick command but it was not the case.
This patch fixes this issue.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---

Hi Wolfram,

Thanks to Jean explanation about i2cdetect and eeprom behavior, I realized
that the first version of the patch was incorrect. This time all the i2c
devices are detected with i2cdetect -q.

I hope this fix could go into 3.7 since the driver claims SMBus quick
capability but it doesn't support it. Moreover without it i2cdetect find
imaginary devices, and with some IP versions, trying to send 0 byte can cause
issue when writing data to an EEPROM.

Regards

Ludovic

Changes since v1:
 * enable txcomp irq to have a correct behavior

 drivers/i2c/busses/i2c-at91.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index f471747..e9c926c 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -44,6 +44,7 @@
 #define	AT91_TWI_STOP		0x0002	/* Send a Stop Condition */
 #define	AT91_TWI_MSEN		0x0004	/* Master Transfer Enable */
 #define	AT91_TWI_SVDIS		0x0020	/* Slave Transfer Disable */
+#define	AT91_TWI_QUICK		0x0040	/* SMBus quick command */
 #define	AT91_TWI_SWRST		0x0080	/* Software Reset */
 
 #define	AT91_TWI_MMR		0x0004	/* Master Mode Register */
@@ -386,7 +387,11 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
 
 	INIT_COMPLETION(dev->cmd_complete);
 	dev->transfer_status = 0;
-	if (dev->msg->flags & I2C_M_RD) {
+
+	if (!dev->buf_len) {
+		at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_QUICK);
+		at91_twi_write(dev, AT91_TWI_IER, AT91_TWI_TXCOMP);
+	} else if (dev->msg->flags & I2C_M_RD) {
 		unsigned start_flags = AT91_TWI_START;
 
 		if (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY) {
-- 
1.7.11.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2] i2c: at91: fix SMBus quick command
@ 2012-11-13 15:43 ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 6+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-11-13 15:43 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

The driver claims to support SMBus quick command but it was not the case.
This patch fixes this issue.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---

Hi Wolfram,

Thanks to Jean explanation about i2cdetect and eeprom behavior, I realized
that the first version of the patch was incorrect. This time all the i2c
devices are detected with i2cdetect -q.

I hope this fix could go into 3.7 since the driver claims SMBus quick
capability but it doesn't support it. Moreover without it i2cdetect find
imaginary devices, and with some IP versions, trying to send 0 byte can cause
issue when writing data to an EEPROM.

Regards

Ludovic

Changes since v1:
 * enable txcomp irq to have a correct behavior

 drivers/i2c/busses/i2c-at91.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index f471747..e9c926c 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -44,6 +44,7 @@
 #define	AT91_TWI_STOP		0x0002	/* Send a Stop Condition */
 #define	AT91_TWI_MSEN		0x0004	/* Master Transfer Enable */
 #define	AT91_TWI_SVDIS		0x0020	/* Slave Transfer Disable */
+#define	AT91_TWI_QUICK		0x0040	/* SMBus quick command */
 #define	AT91_TWI_SWRST		0x0080	/* Software Reset */
 
 #define	AT91_TWI_MMR		0x0004	/* Master Mode Register */
@@ -386,7 +387,11 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
 
 	INIT_COMPLETION(dev->cmd_complete);
 	dev->transfer_status = 0;
-	if (dev->msg->flags & I2C_M_RD) {
+
+	if (!dev->buf_len) {
+		at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_QUICK);
+		at91_twi_write(dev, AT91_TWI_IER, AT91_TWI_TXCOMP);
+	} else if (dev->msg->flags & I2C_M_RD) {
 		unsigned start_flags = AT91_TWI_START;
 
 		if (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY) {
-- 
1.7.11.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: at91: fix SMBus quick command
  2012-11-13 15:43 ` ludovic.desroches at atmel.com
@ 2012-11-14  6:01   ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-14  6:01 UTC (permalink / raw)
  To: ludovic.desroches
  Cc: khali, N.Voss, nicolas.ferre, linux-i2c, linux-arm-kernel

On 16:43 Tue 13 Nov     , ludovic.desroches@atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> The driver claims to support SMBus quick command but it was not the case.
> This patch fixes this issue.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards
J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] i2c: at91: fix SMBus quick command
@ 2012-11-14  6:01   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-14  6:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 16:43 Tue 13 Nov     , ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> The driver claims to support SMBus quick command but it was not the case.
> This patch fixes this issue.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards
J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: at91: fix SMBus quick command
  2012-11-13 15:43 ` ludovic.desroches at atmel.com
@ 2012-11-14  9:33     ` Wolfram Sang
  -1 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2012-11-14  9:33 UTC (permalink / raw)
  To: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, N.Voss-+umVssTZoCsb1SvskN2V4Q,
	khali-PUYAD+kWke1g9hUCZPvPmw

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

On Tue, Nov 13, 2012 at 04:43:21PM +0100, ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org wrote:
> From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> 
> The driver claims to support SMBus quick command but it was not the case.
> This patch fixes this issue.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> ---
> 
> Hi Wolfram,
> 
> Thanks to Jean explanation about i2cdetect and eeprom behavior, I realized
> that the first version of the patch was incorrect. This time all the i2c
> devices are detected with i2cdetect -q.
> 
> I hope this fix could go into 3.7 since the driver claims SMBus quick
> capability but it doesn't support it. Moreover without it i2cdetect find
> imaginary devices, and with some IP versions, trying to send 0 byte can cause
> issue when writing data to an EEPROM.

Updated the commit message with the latter paragraph and added to
for-current, thanks!

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] i2c: at91: fix SMBus quick command
@ 2012-11-14  9:33     ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2012-11-14  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Nov 13, 2012 at 04:43:21PM +0100, ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> The driver claims to support SMBus quick command but it was not the case.
> This patch fixes this issue.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
> 
> Hi Wolfram,
> 
> Thanks to Jean explanation about i2cdetect and eeprom behavior, I realized
> that the first version of the patch was incorrect. This time all the i2c
> devices are detected with i2cdetect -q.
> 
> I hope this fix could go into 3.7 since the driver claims SMBus quick
> capability but it doesn't support it. Moreover without it i2cdetect find
> imaginary devices, and with some IP versions, trying to send 0 byte can cause
> issue when writing data to an EEPROM.

Updated the commit message with the latter paragraph and added to
for-current, thanks!

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121114/45ccbe2b/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-14  9:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-13 15:43 [PATCH v2] i2c: at91: fix SMBus quick command ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-11-13 15:43 ` ludovic.desroches at atmel.com
2012-11-14  6:01 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-14  6:01   ` Jean-Christophe PLAGNIOL-VILLARD
     [not found] ` <1352821401-1944-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-11-14  9:33   ` Wolfram Sang
2012-11-14  9:33     ` Wolfram Sang

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.