Skip to contentSkip to conversation

(unknown)

PATCH In review Moiz Sonasath 3 participants 5 messages Feb 17, 2010 – Feb 19, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

This patch disables the newly introduced internal pull-up feature in OMAP3630, to use only the external HW resitor >= 470 Ohm for the assured functionality in HS mode.

While testing the I2C in High Speed mode, it was discovered that without a proper pull-up resitor, there is data corruption during multi-byte transfers. RTC(time_set) test case was used for testing.

Quoted 1 line

From the analysis done, it was concluded that ideally we need a pull-up

of 1.6 K Ohm (recomended) or atleast 470 Ohm or greater for assured performance in HS mode.

---
 arch/arm/mach-omap2/i2c.c                 |   24 ++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/control.h |   14 ++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/i2c.c +24 -0
index 789ca8c..2e6eb28 100644
@@ -22,6 +22,7 @@
 #include <plat/cpu.h>
 #include <plat/i2c.h>
 #include <plat/mux.h>
+#include <plat/control.h>
 
 #include "mux.h"
 
@@ -52,5 +53,28 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
 		omap_mux_init_signal(mux_name, OMAP_PIN_INPUT);
 	}
 
+	/* Disable OMAP 3630 internal pull-ups for all I2Ci */
+	if (cpu_is_omap3630() && !(omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1) & OMAP3630_PRG_I2C1_PULLUPRESX)) {
+
+		u32 prog_io;
+
+		prog_io = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1);
+		/* Program (bit 19)=1 to disable internal pull-up on I2C1 */
+		prog_io |= OMAP3630_PRG_I2C1_PULLUPRESX;
+		/* Program (bit 0)=1 to disable internal pull-up on I2C2 */
+		prog_io |= OMAP3630_PRG_I2C2_PULLUPRESX;
+		omap_ctrl_writel(prog_io, OMAP343X_CONTROL_PROG_IO1);
+
+		prog_io = omap_ctrl_readl(OMAP36XX_CONTROL_PROG_IO2);
+		/* Program (bit 7)=1 to disable internal pull-up on I2C3 */
+		prog_io |= OMAP3630_PRG_I2C3_PULLUPRESX;
+		omap_ctrl_writel(prog_io, OMAP36XX_CONTROL_PROG_IO2);
+
+		prog_io = omap_ctrl_readl(OMAP36XX_CONTROL_PROG_IO_WKUP1);
+		/* Program (bit 5)=1 to disable internall pull-up on I2C4(SR) */
+		prog_io |= OMAP3630_PRG_SR_PULLUPRESX;
+		omap_ctrl_writel(prog_io, OMAP36XX_CONTROL_PROG_IO_WKUP1);
+	}
+
 	return omap_plat_register_i2c_bus(bus_id, clkrate, info, len);
 }
arch/arm/plat-omap/include/plat/control.h +14 -0
index 2074473..9e58d8e 100644
@@ -169,6 +169,9 @@
 #define AM35XX_CONTROL_IP_SW_RESET      (OMAP2_CONTROL_GENERAL + 0x0328)
 #define AM35XX_CONTROL_IPSS_CLK_CTRL    (OMAP2_CONTROL_GENERAL + 0x032C)
 
+/* 36xx-only CONTROL_GENERAL register offsets */
+#define OMAP36XX_CONTROL_PROG_IO2       (OMAP2_CONTROL_GENERAL + 0x0198)
+
 /* 34xx PADCONF register offsets */
 #define OMAP343X_PADCONF_ETK(i)		(OMAP2_CONTROL_PADCONFS + 0x5a8 + \
 						(i)*2)
@@ -200,6 +203,9 @@
 #define OMAP343X_CONTROL_WKUP_DEBOBS3 (OMAP343X_CONTROL_GENERAL_WKUP + 0x014)
 #define OMAP343X_CONTROL_WKUP_DEBOBS4 (OMAP343X_CONTROL_GENERAL_WKUP + 0x018)
 
+/* 36xx-only GENERAL_WKUP register offsets */
+#define OMAP36XX_CONTROL_PROG_IO_WKUP1 (OMAP343X_CONTROL_GENERAL_WKUP + 0x020)
+
 /* 34xx D2D idle-related pins, handled by PM core */
 #define OMAP3_PADCONF_SAD2D_MSTANDBY   0x250
 #define OMAP3_PADCONF_SAD2D_IDLEACK    0x254
@@ -250,6 +256,8 @@
 #define OMAP2_PBIASLITEVMODE0		(1 << 0)
 
 /* CONTROL_PROG_IO1 bits */
+#define OMAP3630_PRG_I2C2_PULLUPRESX    (1 << 0)
+#define OMAP3630_PRG_I2C1_PULLUPRESX	(1 << 19)
 #define OMAP3630_PRG_SDMMC1_SPEEDCTRL	(1 << 20)
 
 /* CONTROL_IVA2_BOOTMOD bits */
@@ -257,6 +265,12 @@
 #define OMAP3_IVA2_BOOTMOD_MASK		(0xf << 0)
 #define OMAP3_IVA2_BOOTMOD_IDLE		(0x1 << 0)
 
+/* CONTROL_PROG_IO2 bits on omap3630 */
+#define OMAP3630_PRG_I2C3_PULLUPRESX    (1 << 7)
+
+/* CONTROL_PROG_IO_WKUP1 bits on omap3630 */
+#define OMAP3630_PRG_SR_PULLUPRESX    (1 << 5)
+
 /* CONTROL_PADCONF_X bits */
 #define OMAP3_PADCONF_WAKEUPEVENT0	(1 << 15)
 #define OMAP3_PADCONF_WAKEUPENABLE0	(1 << 14)
Signature · 1 line
1.5.6.3
#1 lore raw

PATCH 1/2 omap: Disable TWL4030/5030 I2C1/I2C4 internal pull-ups

This patch disables TWL4030/5030 I2C1 adn I2C4(SR) internal pull-up, to use only the external HW resistor >=470 Ohm for the assured functionality in HS mode.

While testing the I2C in High Speed mode, it was discovered that without a proper pull-up resistor, there is data corruption during multi-byte transfer. RTC(time_set) test case was used for testing.

Quoted 1 line

From the analysis done, it was concluded that ideally we need a

pull-up of 1.6k Ohm(recomended) or atleast 470 Ohm or greater for assured performance in HS mode.

---
 drivers/mfd/twl-core.c  |   13 +++++++++++++
 include/linux/i2c/twl.h |   15 +++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
drivers/mfd/twl-core.c +13 -0
index 2a76065..35ae2ee 100644
@@ -965,6 +965,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	int				status;
 	unsigned			i;
 	struct twl4030_platform_data	*pdata = client->dev.platform_data;
+	u8 temp;
 
 	if (!pdata) {
 		dev_dbg(&client->dev, "no platform data?\n");
@@ -1032,6 +1033,18 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 			goto fail;
 	}
 
+	/* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.
+	 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,
+	 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.
+	 */
+
+	if (twl_class_is_4030()) {
+		twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1);
+		temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \
+		I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
+		twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
+	}
+
 	status = add_children(pdata, id->driver_data);
 fail:
 	if (status < 0)
include/linux/i2c/twl.h +15 -0
index bf1c5be..fd95eca 100644
@@ -239,6 +239,21 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
 
 /*----------------------------------------------------------------------*/
 
+/*Interface Bit Register (INTBR) offsets
+ *(Use TWL_4030_MODULE_INTBR)
+ */
+
+#define REG_GPPUPDCTR1			0x0F
+
+/*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
+
+#define I2C_SCL_CTRL_PU			BIT(0)
+#define I2C_SDA_CTRL_PU			BIT(2)
+#define SR_I2C_SCL_CTRL_PU		BIT(4)
+#define SR_I2C_SDA_CTRL_PU		BIT(6)
+
+/*----------------------------------------------------------------------*/
+
 /*
  * Keypad register offsets (use TWL4030_MODULE_KEYPAD)
  * ... SIH/interrupt only
Signature · 1 line
1.5.6.3
#2 lore raw

Re: [PATCH 1/2] omap: Disable TWL4030/5030 I2C1/I2C4 internal pull-ups

Hello Moiz,

Quoted 7 lines · ext Moiz Sonasath

This patch disables TWL4030/5030 I2C1 adn I2C4(SR) internal pull-up, to use only the external HW resistor >=470 Ohm for the assured functionality in HS mode.

While testing the I2C in High Speed mode, it was discovered that without a proper pull-up resistor, there is data corruption during multi-byte transfer. RTC(time_set) test case was used for testing.

Nice findings!

Quoted 25 lines
Quoted 2 lines

From the analysis done, it was concluded that ideally we need a

pull-up of 1.6k Ohm(recomended) or atleast 470 Ohm or greater for assured performance in HS mode.

---
 drivers/mfd/twl-core.c  |   13 +++++++++++++
 include/linux/i2c/twl.h |   15 +++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
drivers/mfd/twl-core.c +1 -0
index 2a76065..35ae2ee 100644
@@ -965,6 +965,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	int				status;
 	unsigned			i;
 	struct twl4030_platform_data	*pdata = client->dev.platform_data;
+	u8 temp;
 
 	if (!pdata) {
 		dev_dbg(&client->dev, "no platform data?\n");

drivers/mfd/twl-core.c twl_probe(struct i2c_client *client, const struct i2c_device_id *id) · line 1041

Quoted 9 lines
drivers/mfd/twl-core.c +6 -0
@@ -1032,6 +1033,18 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 			goto fail;
 	}
 
+	/* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.
+	 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,
+	 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.
+	 */
+
+	if (twl_class_is_4030()) {

Is this run time check sufficient enough to determine if this fix must be applied?

Quoted 1 line

From what you have described on you patch description, looks like it is supposed to be

only for HS mode. I don't know, maybe if you bind this to a platform / board configuration flag would it be better? I mean, you create a flag inside the platform data to determine if this fix must be applied or not. At least for me, having an external pu resistor seams to be very board dependent.

Quoted 42 lines
drivers/mfd/twl-core.c +6 -0
+		twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1);
+		temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \
+		I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
+		twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
+	}
+
 	status = add_children(pdata, id->driver_data);
 fail:
 	if (status < 0)
include/linux/i2c/twl.h +15 -0
index bf1c5be..fd95eca 100644
@@ -239,6 +239,21 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
 
 /*----------------------------------------------------------------------*/
 
+/*Interface Bit Register (INTBR) offsets
+ *(Use TWL_4030_MODULE_INTBR)
+ */
+
+#define REG_GPPUPDCTR1			0x0F
+
+/*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
+
+#define I2C_SCL_CTRL_PU			BIT(0)
+#define I2C_SDA_CTRL_PU			BIT(2)
+#define SR_I2C_SCL_CTRL_PU		BIT(4)
+#define SR_I2C_SDA_CTRL_PU		BIT(6)
+
+/*----------------------------------------------------------------------*/
+
 /*
  * Keypad register offsets (use TWL4030_MODULE_KEYPAD)
  * ... SIH/interrupt only
Signature · 6 lines
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Eduardo Valentin
#3 lore raw

RE: [PATCH 1/2] omap: Disable TWL4030/5030 I2C1/I2C4 internal pull-ups

Hello Eduardo,

Quoted 123 lines

-----Original Message-----
From: Eduardo Valentin [mailto:[email protected]]
Sent: Wednesday, February 17, 2010 1:46 AM
To: Sonasath, Moiz
Cc: [email protected]; [email protected]; [email protected]; Pais, Allen
Subject: Re: [PATCH 1/2] omap: Disable TWL4030/5030 I2C1/I2C4 internal pull-ups

Hello Moiz,

Quoted 7 lines · ext Moiz Sonasath

This patch disables TWL4030/5030 I2C1 adn I2C4(SR) internal pull-up, to use only the external HW resistor >=470 Ohm for the assured functionality in HS mode.

While testing the I2C in High Speed mode, it was discovered that without a proper pull-up resistor, there is data corruption during multi-byte transfer. RTC(time_set) test case was used for testing.

Nice findings!

drivers/mfd/twl-core.c twl_probe(struct i2c_client *client, const struct

Quoted 17 lines
Quoted 2 lines

From the analysis done, it was concluded that ideally we need a

pull-up of 1.6k Ohm(recomended) or atleast 470 Ohm or greater for assured performance in HS mode.

---
 drivers/mfd/twl-core.c  |   13 +++++++++++++
 include/linux/i2c/twl.h |   15 +++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
drivers/mfd/twl-core.c +0 -0
index 2a76065..35ae2ee 100644
@@ -965,6 +965,7 @@ twl_probe(struct i2c_client *client, const struct

i2c_device_id *id)

drivers/mfd/twl-core.c twl_probe(struct i2c_client *client, const struct

Quoted 8 lines
drivers/mfd/twl-core.c +1 -0
 	int				status;
 	unsigned			i;
 	struct twl4030_platform_data	*pdata = client->dev.platform_data;
+	u8 temp;
 
 	if (!pdata) {
 		dev_dbg(&client->dev, "no platform data?\n");
@@ -1032,6 +1033,18 @@ twl_probe(struct i2c_client *client, const struct

i2c_device_id *id)

drivers/mfd/twl-core.c twl_probe(struct i2c_client *client, const struct i2c_device_id *id)

Quoted 4 lines
drivers/mfd/twl-core.c +1 -0
 			goto fail;
 	}
 
+	/* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR)

interface.

drivers/mfd/twl-core.c twl_probe(struct i2c_client *client, const struct i2c_device_id *id) · line 1041

Quoted 5 lines
drivers/mfd/twl-core.c +5 -0
+	 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,
+	 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.
+	 */
+
+	if (twl_class_is_4030()) {

Is this run time check sufficient enough to determine if this fix must be applied?
From what you have described on you patch description, looks like it is supposed to be
only for HS mode. I don't know, maybe if you bind this to a platform / board configuration
flag would it be better? I mean, you create a flag inside the platform data to determine
if this fix must be applied or not. At least for me, having an external pu resistor
seams to be very board dependent.

From what I observed, having a smaller pull-up (<470 OHM) resistor is affecting HS mode operation. Moreover, irrespective of whatever external pull-up value we have, if we have internal pull-up enabled, it comes in parallel to the external pull-up and thereby reduces the effective pull-up on the line. So it's safe to have a higher pull-up value instead rather than having the internal pull-up enabled (irrespective of whatever the external value is). Also, for all the OMAP boards that we have I think we always have an external pull-up typically 470 ohm and hence if we just depend on that external resistor without involving any of the internal pull-ups, HS/FS/LS should just work fine. That was the whole idea.

Quoted 14 lines
drivers/mfd/twl-core.c +6 -0
+		twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1);
+		temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \
+		I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
+		twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
+	}
+
 	status = add_children(pdata, id->driver_data);
 fail:
 	if (status < 0)
include/linux/i2c/twl.h +0 -0
index bf1c5be..fd95eca 100644

include/linux/i2c/twl.h int twl6030_interrupt_mask(u8 bit_mask, u8 offset); · line 240

Quoted 2 lines
include/linux/i2c/twl.h +0 -0
@@ -239,6 +239,21 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
 
 /*---------------------------------------------------------------------

-*/

Quoted 5 lines
include/linux/i2c/twl.h +4 -0
+/*Interface Bit Register (INTBR) offsets
+ *(Use TWL_4030_MODULE_INTBR)
+ */
+

include/linux/i2c/twl.h int twl6030_interrupt_mask(u8 bit_mask, u8 offset);

Quoted 10 lines
include/linux/i2c/twl.h +10 -0
+#define REG_GPPUPDCTR1			0x0F
+
+/*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
+
+#define I2C_SCL_CTRL_PU			BIT(0)
+#define I2C_SDA_CTRL_PU			BIT(2)
+#define SR_I2C_SCL_CTRL_PU		BIT(4)
+#define SR_I2C_SDA_CTRL_PU		BIT(6)
+
+/*---------------------------------------------------------------------

-*/

Quoted 11 lines
include/linux/i2c/twl.h +1 -1
+
 /*
  * Keypad register offsets (use TWL4030_MODULE_KEYPAD)
  * ... SIH/interrupt only
--

1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Eduardo Valentin

#4 lore raw

Re: [PATCH 1/2] omap: Disable TWL4030/5030 I2C1/I2C4 internal pull-ups

In reply to Moiz Sonasath

Hi Moiz,

Quoted 11 lines · Moiz Sonasath

This patch disables TWL4030/5030 I2C1 adn I2C4(SR) internal pull-up, to use only the external HW resistor >=470 Ohm for the assured functionality in HS mode.

While testing the I2C in High Speed mode, it was discovered that without a proper pull-up resistor, there is data corruption during multi-byte transfer. RTC(time_set) test case was used for testing.

From the analysis done, it was concluded that ideally we need a pull-up of 1.6k Ohm(recomended) or atleast 470 Ohm or greater for assured performance in HS mode.

Patch applied, many thanks.

Cheers,
Samuel.

Quoted 67 lines
---
 drivers/mfd/twl-core.c  |   13 +++++++++++++
 include/linux/i2c/twl.h |   15 +++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
drivers/mfd/twl-core.c +13 -0
index 2a76065..35ae2ee 100644
@@ -965,6 +965,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	int				status;
 	unsigned			i;
 	struct twl4030_platform_data	*pdata = client->dev.platform_data;
+	u8 temp;
 
 	if (!pdata) {
 		dev_dbg(&client->dev, "no platform data?\n");
@@ -1032,6 +1033,18 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 			goto fail;
 	}
 
+	/* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.
+	 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,
+	 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.
+	 */
+
+	if (twl_class_is_4030()) {
+		twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1);
+		temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \
+		I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
+		twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
+	}
+
 	status = add_children(pdata, id->driver_data);
 fail:
 	if (status < 0)
include/linux/i2c/twl.h +15 -0
index bf1c5be..fd95eca 100644
@@ -239,6 +239,21 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
 
 /*----------------------------------------------------------------------*/
 
+/*Interface Bit Register (INTBR) offsets
+ *(Use TWL_4030_MODULE_INTBR)
+ */
+
+#define REG_GPPUPDCTR1			0x0F
+
+/*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
+
+#define I2C_SCL_CTRL_PU			BIT(0)
+#define I2C_SDA_CTRL_PU			BIT(2)
+#define SR_I2C_SCL_CTRL_PU		BIT(4)
+#define SR_I2C_SDA_CTRL_PU		BIT(6)
+
+/*----------------------------------------------------------------------*/
+
 /*
  * Keypad register offsets (use TWL4030_MODULE_KEYPAD)
  * ... SIH/interrupt only
Signature · 1 line
1.5.6.3
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/