Skip to contentSkip to conversation

Bugfixes for i2c-cpm.c

PATCH In review Wolfram Sang 4 participants 10 messages Jun 20, 2008 – Jul 2, 2008 6 messages not in the archive I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bugfixes for i2c-cpm.c

Bugfixes to the i2c-cpm driver

- enable correct interrupts (I2CER_TXE instead of I2CER_BUSY)
- replace forgotten iic with i2c
- fix typo (devided)
- prefix debug-output on init with 0x and add frequency

---
Sorry for the resend; the CC to Jochen was dropped, haven't figured out why, yet.

 drivers/i2c/busses/i2c-cpm.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
i2c/busses/i2c-cpm.c renamed from i2c/busses/i2c-cpm.c.orig +5 -5
Index: drivers/i2c/busses/i2c-cpm.c
===================================================================
@@ -241,7 +241,7 @@
 		eieio();
 		setbits16(&tbdf->cbd_sc, BD_SC_READY);
 	} else {
-		dev_dbg(&adap->dev, "cpm_iic_write(abyte=0x%x)\n", addr);
+		dev_dbg(&adap->dev, "cpm_i2c_write(abyte=0x%x)\n", addr);
 
 		memcpy(tb+1, pmsg->buf, pmsg->len);
 
@@ -350,7 +350,7 @@
 	}
 	/* Start transfer now */
 	/* Enable RX/TX/Error interupts */
-	out_8(&i2c_reg->i2cmr, I2CER_BUSY | I2CER_TXB | I2CER_RXB);
+	out_8(&i2c_reg->i2cmr, I2CER_TXE | I2CER_TXB | I2CER_RXB);
 	out_8(&i2c_reg->i2cer, 0xff);	/* Clear interrupt status */
 	/* Chip bug, set enable here */
 	setbits8(&i2c_reg->i2mod, I2MOD_EN);	/* Enable */
@@ -553,8 +553,8 @@
 
 	cpm_reset_i2c_params(cpm);
 
-	dev_dbg(&cpm->ofdev->dev, "i2c_ram %p, i2c_addr 0x%04x\n",
-		cpm->i2c_ram, cpm->i2c_addr);
+	dev_dbg(&cpm->ofdev->dev, "i2c_ram 0x%p, i2c_addr 0x%04x, freq %d\n",
+		cpm->i2c_ram, cpm->i2c_addr, cpm->freq);
 	dev_dbg(&cpm->ofdev->dev, "tbase 0x%04x, rbase 0x%04x\n",
 		(u8 __iomem *)cpm->tbase - DPRAM_BASE,
 		(u8 __iomem *)cpm->rbase - DPRAM_BASE);
@@ -568,7 +568,7 @@
 
 	/*
 	 * PDIV is set to 00 in i2mod, so brgclk/32 is used as input to the
-	 * i2c baud rate generator. This is devided by 2 x (DIV + 3) to get
+	 * i2c baud rate generator. This is divided by 2 x (DIV + 3) to get
 	 * the actual i2c bus frequency.
 	 */
 	brg = get_brgfreq() / (32 * 2 * cpm->freq) - 3;
Signature · 2 lines
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

On Fri, Jun 20, 2008 at 10:41:55AM +0200, Wolfram Sang wrote:

Any new on this one? I think at least the interrupt fix should make it into 2.6.26. The mistakenly activated interrupt caused a regression here, which made at24 fail on writes.

Wolfram

Quoted 69 lines

Bugfixes to the i2c-cpm driver

- enable correct interrupts (I2CER_TXE instead of I2CER_BUSY)
- replace forgotten iic with i2c
- fix typo (devided)
- prefix debug-output on init with 0x and add frequency

---
Sorry for the resend; the CC to Jochen was dropped, haven't figured out why, yet.

 drivers/i2c/busses/i2c-cpm.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Index: drivers/i2c/busses/i2c-cpm.c
===================================================================

i2c/busses/i2c-cpm.c renamed from i2c/busses/i2c-cpm.c.orig +5 -5
@@ -241,7 +241,7 @@
 		eieio();
 		setbits16(&tbdf->cbd_sc, BD_SC_READY);
 	} else {
-		dev_dbg(&adap->dev, "cpm_iic_write(abyte=0x%x)\n", addr);
+		dev_dbg(&adap->dev, "cpm_i2c_write(abyte=0x%x)\n", addr);
 
 		memcpy(tb+1, pmsg->buf, pmsg->len);
 
@@ -350,7 +350,7 @@
 	}
 	/* Start transfer now */
 	/* Enable RX/TX/Error interupts */
-	out_8(&i2c_reg->i2cmr, I2CER_BUSY | I2CER_TXB | I2CER_RXB);
+	out_8(&i2c_reg->i2cmr, I2CER_TXE | I2CER_TXB | I2CER_RXB);
 	out_8(&i2c_reg->i2cer, 0xff);	/* Clear interrupt status */
 	/* Chip bug, set enable here */
 	setbits8(&i2c_reg->i2mod, I2MOD_EN);	/* Enable */
@@ -553,8 +553,8 @@
 
 	cpm_reset_i2c_params(cpm);
 
-	dev_dbg(&cpm->ofdev->dev, "i2c_ram %p, i2c_addr 0x%04x\n",
-		cpm->i2c_ram, cpm->i2c_addr);
+	dev_dbg(&cpm->ofdev->dev, "i2c_ram 0x%p, i2c_addr 0x%04x, freq %d\n",
+		cpm->i2c_ram, cpm->i2c_addr, cpm->freq);
 	dev_dbg(&cpm->ofdev->dev, "tbase 0x%04x, rbase 0x%04x\n",
 		(u8 __iomem *)cpm->tbase - DPRAM_BASE,
 		(u8 __iomem *)cpm->rbase - DPRAM_BASE);
@@ -568,7 +568,7 @@
 
 	/*
 	 * PDIV is set to 00 in i2mod, so brgclk/32 is used as input to the
-	 * i2c baud rate generator. This is devided by 2 x (DIV + 3) to get
+	 * i2c baud rate generator. This is divided by 2 x (DIV + 3) to get
 	 * the actual i2c bus frequency.
 	 */
 	brg = get_brgfreq() / (32 * 2 * cpm->freq) - 3;
Signature · 10 lines
-- 
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry



_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Signature · 2 lines
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Hi Wolfram,

Quoted 5 lines · Wolfram Sang

On Fri, Jun 20, 2008 at 10:41:55AM +0200, Wolfram Sang wrote:

Any new on this one? I think at least the interrupt fix should make it into 2.6.26. The mistakenly activated interrupt caused a regression here, which made at24 fail on writes.

I was away for the week-end and am now processing the stacked e-mail and other real-life tasks (takes time.)

I fail to see how there would be a regression here given that the i2c-cpm driver is new and is not in kernel 2.6.26. It will only be merged in 2.6.27-rc1. Not to mean that we don't want to fix the bugs quickly, but it feels less urgent than if it was in 2.6.26.

As far as the review is concerned, ideally Jochen would do it as the driver author and someone who presumably has hardware to test the driver (I don't.) If Jochen acks the patch then I can add it to my i2c tree quickly.

Thanks,

Signature · 6 lines
Jean Delvare

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 2 lines · Jean Delvare

I was away for the week-end and am now processing the stacked e-mail and other real-life tasks (takes time.)

This was more addressed to Jochen; should have pointed out, that I was waiting for his ACK.

Quoted 2 lines

I fail to see how there would be a regression here given that the i2c-cpm driver is new and is not in kernel 2.6.26.

Ups, sigh, I remembered you added it to your tree and mistook it that you also already pushed it. Point taken, not that urgent. Sorry!

Wolfram

Signature · 2 lines
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

#7 lore raw
In reply to a message not in the archive

Hi Jean,

Quoted 6 lines
Quoted 3 lines

Any new on this one? I think at least the interrupt fix should make it into 2.6.26. The mistakenly activated interrupt caused a regression here, which made at24 fail on writes.

I was away for the week-end and am now processing the stacked e-mail and other real-life tasks (takes time.)

I was away the last 2 weeks, as well and just finished my stacked e-mail.

Quoted 4 lines

As far as the review is concerned, ideally Jochen would do it as the driver author and someone who presumably has hardware to test the driver (I don't.) If Jochen acks the patch then I can add it to my i2c tree quickly.

I'll do this ASAP now.

Thanks,
Jochen

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

#8 lore raw
In reply to a message not in the archive
Quoted 9 lines · Wolfram Sang

Bugfixes to the i2c-cpm driver

- enable correct interrupts (I2CER_TXE instead of I2CER_BUSY)
- replace forgotten iic with i2c
- fix typo (devided)
- prefix debug-output on init with 0x and add frequency

Tested on a MPC8247 board. I have experienced I2C issues since migration from ppc to powerpc. This patch seems to solve the problem.

Quoted 50 lines

---
Sorry for the resend; the CC to Jochen was dropped, haven't figured out why, yet.

 drivers/i2c/busses/i2c-cpm.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Index: drivers/i2c/busses/i2c-cpm.c
===================================================================

i2c/busses/i2c-cpm.c renamed from i2c/busses/i2c-cpm.c.orig +5 -5
@@ -241,7 +241,7 @@
 		eieio();
 		setbits16(&tbdf->cbd_sc, BD_SC_READY);
 	} else {
-		dev_dbg(&adap->dev, "cpm_iic_write(abyte=0x%x)\n", addr);
+		dev_dbg(&adap->dev, "cpm_i2c_write(abyte=0x%x)\n", addr);
 
 		memcpy(tb+1, pmsg->buf, pmsg->len);
 
@@ -350,7 +350,7 @@
 	}
 	/* Start transfer now */
 	/* Enable RX/TX/Error interupts */
-	out_8(&i2c_reg->i2cmr, I2CER_BUSY | I2CER_TXB | I2CER_RXB);
+	out_8(&i2c_reg->i2cmr, I2CER_TXE | I2CER_TXB | I2CER_RXB);
 	out_8(&i2c_reg->i2cer, 0xff);	/* Clear interrupt status */
 	/* Chip bug, set enable here */
 	setbits8(&i2c_reg->i2mod, I2MOD_EN);	/* Enable */
@@ -553,8 +553,8 @@
 
 	cpm_reset_i2c_params(cpm);
 
-	dev_dbg(&cpm->ofdev->dev, "i2c_ram %p, i2c_addr 0x%04x\n",
-		cpm->i2c_ram, cpm->i2c_addr);
+	dev_dbg(&cpm->ofdev->dev, "i2c_ram 0x%p, i2c_addr 0x%04x, freq %d\n",
+		cpm->i2c_ram, cpm->i2c_addr, cpm->freq);
 	dev_dbg(&cpm->ofdev->dev, "tbase 0x%04x, rbase 0x%04x\n",
 		(u8 __iomem *)cpm->tbase - DPRAM_BASE,
 		(u8 __iomem *)cpm->rbase - DPRAM_BASE);
@@ -568,7 +568,7 @@
 
 	/*
 	 * PDIV is set to 00 in i2mod, so brgclk/32 is used as input to the
-	 * i2c baud rate generator. This is devided by 2 x (DIV + 3) to get
+	 * i2c baud rate generator. This is divided by 2 x (DIV + 3) to get
 	 * the actual i2c bus frequency.
 	 */
 	brg = get_brgfreq() / (32 * 2 * cpm->freq) - 3;
Signature · 9 lines
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): 200806241615.08826.laurentp-BSmb2szPELAwsLKNixborgC/[email protected]

#10 lore raw

Hi Laurent,

Quoted 11 lines
Quoted 8 lines

Bugfixes to the i2c-cpm driver

- enable correct interrupts (I2CER_TXE instead of I2CER_BUSY)
- replace forgotten iic with i2c
- fix typo (devided)
- prefix debug-output on init with 0x and add frequency

Tested on a MPC8247 board. I have experienced I2C issues since migration from ppc to powerpc. This patch seems to solve the problem.

What kind of problems have this been? In normal operation there shouldn't be any I2CER_TXE interrupts being generated.

Thanks,
Jochen

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw

Hi Jochen,

Quoted 2 lines · Jochen Friedrich

What kind of problems have this been? In normal operation there shouldn't be any I2CER_TXE interrupts being generated.

I had problems when writing to an EEPROM, reading worked, though.

I didn't really investigate why this happened. I just saw that the old version used a hardcoded 0x13 to set interrupts and the replacement using defined constants resulted in 0x7. Changing constants to achieve 0x13 solved my problems.

All the best,

Wolfram

Signature · 2 lines
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

#13 lore raw
In reply to a message not in the archive
Quoted 9 lines · Jochen Friedrich

Hi Laurent,

Quoted 7 lines
Quoted 7 lines

Bugfixes to the i2c-cpm driver

- enable correct interrupts (I2CER_TXE instead of I2CER_BUSY)
- replace forgotten iic with i2c
- fix typo (devided)
- prefix debug-output on init with 0x and add frequency

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Tested on a MPC8247 board. I have experienced I2C issues since migration from ppc to powerpc. This patch seems to solve the problem.

What kind of problems have this been? In normal operation there shouldn't be any I2CER_TXE interrupts being generated.

I2C devices would frequently (about once every 10 cold boots) be undetected by the kernel. I tried to investigate the issue by hooking up a scope to the I2C signals, but haven't been able to reproduce the problem once the probes were connected.

This might of course be a case of Murphy's law in action, but the problem disappeared after applying the patch.

Signature · 9 lines
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): 200807011526.14514.laurentp-BSmb2szPELAwsLKNixborgC/[email protected]

#15 lore raw
Quoted 18 lines · Laurent Pinchart
Quoted 9 lines · Jochen Friedrich

Hi Laurent,

Quoted 7 lines
Quoted 7 lines

Bugfixes to the i2c-cpm driver

- enable correct interrupts (I2CER_TXE instead of I2CER_BUSY)
- replace forgotten iic with i2c
- fix typo (devided)
- prefix debug-output on init with 0x and add frequency

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Tested on a MPC8247 board. I have experienced I2C issues since migration from ppc to powerpc. This patch seems to solve the problem.

What kind of problems have this been? In normal operation there shouldn't be any I2CER_TXE interrupts being generated.

Quoted 7 lines

I2C devices would frequently (about once every 10 cold boots) be undetected by the kernel. I tried to investigate the issue by hooking up a scope to the I2C signals, but haven't been able to reproduce the problem once the probes were connected.

This might of course be a case of Murphy's law in action, but the problem disappeared after applying the patch.

Seems Murphy's law was involved :-( I've run into the same issue just now.

[    0.555664] i2c /dev entries driver
[    0.564539] rtc-pcf8563 0-0051: chip found, driver version 0.4.3
[    0.570038] rtc-pcf8563 0-0051: rtc core: registered rtc-pcf8563 as rtc0
[    1.576209] i2c-adapter i2c-0: I2C transfer: timeout
[    1.579642] lm75: probe of 0-0048 failed with error -1
[snip]
[    2.766230] i2c-adapter i2c-0: I2C transfer: timeout
[    2.769602] rtc-pcf8563 0-0051: pcf8563_get_datetime: read error
[    2.775345] rtc-pcf8563 0-0051: hctosys: unable to read the hardware clock                                                               

The lm75 is there and works after a reboot. In this particular run the pcf8563 was detected, but it would sometimes time out during probe as well.

Signature · 9 lines
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c