All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] I2C: driver updates
@ 2011-07-21  6:53 ` Shubhrajyoti D
  0 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-omap; +Cc: linux-i2c, linux-arm-kernel, khilman, rnayak, Shubhrajyoti D

The series attempts to do the following
- The reset should not be done in the driver 
  have support for the same.
- Remove the sysc register access in the driver.
- Restore the context only if the context is lost.

Shubhrajyoti D (5):
  OMAP: I2C: Add a device reset field to platform data
  OMAP: I2C: Reset support
  OMAP: I2C: Remove the reset in the init path
  OMAP: I2C: Remove the SYSC register definition
  OMAP: I2C: Restore only if context is lost

 arch/arm/plat-omap/i2c.c      |   18 ++++++++
 drivers/i2c/busses/i2c-omap.c |   90 ++++++++++++++++------------------------
 include/linux/i2c-omap.h      |    1 +
 3 files changed, 55 insertions(+), 54 deletions(-)


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

* [PATCH 0/5] I2C: driver updates
@ 2011-07-21  6:53 ` Shubhrajyoti D
  0 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-arm-kernel

The series attempts to do the following
- The reset should not be done in the driver 
  have support for the same.
- Remove the sysc register access in the driver.
- Restore the context only if the context is lost.

Shubhrajyoti D (5):
  OMAP: I2C: Add a device reset field to platform data
  OMAP: I2C: Reset support
  OMAP: I2C: Remove the reset in the init path
  OMAP: I2C: Remove the SYSC register definition
  OMAP: I2C: Restore only if context is lost

 arch/arm/plat-omap/i2c.c      |   18 ++++++++
 drivers/i2c/busses/i2c-omap.c |   90 ++++++++++++++++------------------------
 include/linux/i2c-omap.h      |    1 +
 3 files changed, 55 insertions(+), 54 deletions(-)

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

* [PATCH 1/5] OMAP: I2C: Add a device reset field to platform data
  2011-07-21  6:53 ` Shubhrajyoti D
@ 2011-07-21  6:53   ` Shubhrajyoti D
  -1 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-omap; +Cc: linux-i2c, linux-arm-kernel, khilman, rnayak, Shubhrajyoti D

Under some conditions the driver may want to do a reset
of the device. Adding a reset field field to the platform
data.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 include/linux/i2c-omap.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/i2c-omap.h b/include/linux/i2c-omap.h
index 98ae49b..8aa91b6 100644
--- a/include/linux/i2c-omap.h
+++ b/include/linux/i2c-omap.h
@@ -38,6 +38,7 @@ struct omap_i2c_bus_platform_data {
 	int		(*device_enable) (struct platform_device *pdev);
 	int		(*device_shutdown) (struct platform_device *pdev);
 	int		(*device_idle) (struct platform_device *pdev);
+	int		(*device_reset) (struct device *dev);
 };
 
 #endif
-- 
1.7.1


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

* [PATCH 1/5] OMAP: I2C: Add a device reset field to platform data
@ 2011-07-21  6:53   ` Shubhrajyoti D
  0 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-arm-kernel

Under some conditions the driver may want to do a reset
of the device. Adding a reset field field to the platform
data.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 include/linux/i2c-omap.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/i2c-omap.h b/include/linux/i2c-omap.h
index 98ae49b..8aa91b6 100644
--- a/include/linux/i2c-omap.h
+++ b/include/linux/i2c-omap.h
@@ -38,6 +38,7 @@ struct omap_i2c_bus_platform_data {
 	int		(*device_enable) (struct platform_device *pdev);
 	int		(*device_shutdown) (struct platform_device *pdev);
 	int		(*device_idle) (struct platform_device *pdev);
+	int		(*device_reset) (struct device *dev);
 };
 
 #endif
-- 
1.7.1

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

* [PATCH 2/5] OMAP: I2C: Reset support
  2011-07-21  6:53 ` Shubhrajyoti D
@ 2011-07-21  6:53   ` Shubhrajyoti D
  -1 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-omap; +Cc: linux-i2c, linux-arm-kernel, khilman, rnayak, Shubhrajyoti D

Under some error conditions the i2c  driver may do a reset
adding support in the platform.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 arch/arm/plat-omap/i2c.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 2388b8e..3d144d1 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -146,6 +146,22 @@ static struct omap_device_pm_latency omap_i2c_latency[] = {
 		.flags			= OMAP_DEVICE_LATENCY_AUTO_ADJUST,
 	},
 };
+/**
+ * omap2_i2c_reset - reset the omap i2c module.
+ * @dev: struct device*
+ */
+
+static int omap2_i2c_reset(struct device *dev)
+{
+	int r = 0;
+	struct platform_device *pdev = to_platform_device(dev);
+	struct omap_device *odev = to_omap_device(pdev);
+	struct omap_hwmod *oh;
+
+	oh = odev->hwmods[0];
+	r = omap_hwmod_reset(oh);
+	return r;
+}
 
 static inline int omap2_i2c_add_bus(int bus_id)
 {
@@ -187,6 +203,8 @@ static inline int omap2_i2c_add_bus(int bus_id)
 	 */
 	if (cpu_is_omap34xx())
 		pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat;
+
+	pdata->device_reset = omap2_i2c_reset;
 	od = omap_device_build(name, bus_id, oh, pdata,
 			sizeof(struct omap_i2c_bus_platform_data),
 			omap_i2c_latency, ARRAY_SIZE(omap_i2c_latency), 0);
-- 
1.7.1


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

* [PATCH 2/5] OMAP: I2C: Reset support
@ 2011-07-21  6:53   ` Shubhrajyoti D
  0 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-arm-kernel

Under some error conditions the i2c  driver may do a reset
adding support in the platform.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 arch/arm/plat-omap/i2c.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 2388b8e..3d144d1 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -146,6 +146,22 @@ static struct omap_device_pm_latency omap_i2c_latency[] = {
 		.flags			= OMAP_DEVICE_LATENCY_AUTO_ADJUST,
 	},
 };
+/**
+ * omap2_i2c_reset - reset the omap i2c module.
+ * @dev: struct device*
+ */
+
+static int omap2_i2c_reset(struct device *dev)
+{
+	int r = 0;
+	struct platform_device *pdev = to_platform_device(dev);
+	struct omap_device *odev = to_omap_device(pdev);
+	struct omap_hwmod *oh;
+
+	oh = odev->hwmods[0];
+	r = omap_hwmod_reset(oh);
+	return r;
+}
 
 static inline int omap2_i2c_add_bus(int bus_id)
 {
@@ -187,6 +203,8 @@ static inline int omap2_i2c_add_bus(int bus_id)
 	 */
 	if (cpu_is_omap34xx())
 		pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat;
+
+	pdata->device_reset = omap2_i2c_reset;
 	od = omap_device_build(name, bus_id, oh, pdata,
 			sizeof(struct omap_i2c_bus_platform_data),
 			omap_i2c_latency, ARRAY_SIZE(omap_i2c_latency), 0);
-- 
1.7.1

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

* [PATCH 3/5] OMAP: I2C: Remove the reset in the init path
  2011-07-21  6:53 ` Shubhrajyoti D
@ 2011-07-21  6:53   ` Shubhrajyoti D
  -1 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, rnayak, linux-i2c, linux-arm-kernel, Shubhrajyoti D

The reset in the driver at init is not needed
anymore as the hwmod framework takes care of
reseting it.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   57 +++++++++++------------------------------
 1 files changed, 15 insertions(+), 42 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 8f87a37..d6ea7de 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -155,9 +155,6 @@ enum {
 #define OMAP_I2C_SYSTEST_SDA_O		(1 << 0)	/* SDA line drive out */
 #endif
 
-/* OCP_SYSSTATUS bit definitions */
-#define SYSS_RESETDONE_MASK		(1 << 0)
-
 /* OCP_SYSCONFIG bit definitions */
 #define SYSC_CLOCKACTIVITY_MASK		(0x3 << 8)
 #define SYSC_SIDLEMODE_MASK		(0x3 << 3)
@@ -182,6 +179,8 @@ struct omap_i2c_dev {
 	u32			latency;	/* maximum mpu wkup latency */
 	void			(*set_mpu_wkup_lat)(struct device *dev,
 						    long latency);
+	int			(*device_reset)(struct device *dev);
+
 	u32			speed;		/* Speed of bus in Khz */
 	u16			cmd_err;
 	u8			*buf;
@@ -332,7 +331,6 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 	u16 psc = 0, scll = 0, sclh = 0, buf = 0;
 	u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0;
 	unsigned long fclk_rate = 12000000;
-	unsigned long timeout;
 	unsigned long internal_clk = 0;
 	struct clk *fclk;
 	struct platform_device *pdev;
@@ -341,43 +339,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 	pdev = to_platform_device(dev->dev);
 	pdata = pdev->dev.platform_data;
 
-	if (dev->rev >= OMAP_I2C_OMAP1_REV_2) {
-		/* Disable I2C controller before soft reset */
-		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
-			omap_i2c_read_reg(dev, OMAP_I2C_CON_REG) &
-				~(OMAP_I2C_CON_EN));
-
-		omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK);
-		/* For some reason we need to set the EN bit before the
-		 * reset done bit gets set. */
-		timeout = jiffies + OMAP_I2C_TIMEOUT;
-		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
-		while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) &
-			 SYSS_RESETDONE_MASK)) {
-			if (time_after(jiffies, timeout)) {
-				dev_warn(dev->dev, "timeout waiting "
-						"for controller reset\n");
-				return -ETIMEDOUT;
-			}
-			msleep(1);
-		}
-
-		/* SYSC register is cleared by the reset; rewrite it */
-		if (dev->rev == OMAP_I2C_REV_ON_2430) {
-
-			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
-					   SYSC_AUTOIDLE_MASK);
-
-		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
-			dev->syscstate = SYSC_AUTOIDLE_MASK;
-			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
-			dev->syscstate |= (SYSC_IDLEMODE_SMART <<
-			      __ffs(SYSC_SIDLEMODE_MASK));
-			dev->syscstate |= (SYSC_CLOCKACTIVITY_FCLK <<
-			      __ffs(SYSC_CLOCKACTIVITY_MASK));
-
-			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
-							dev->syscstate);
+	if (dev->rev >= OMAP_I2C_REV_ON_3430) {
 			/*
 			 * Enabling all wakup sources to stop I2C freezing on
 			 * WFI instruction.
@@ -388,7 +350,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 				omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
 								dev->westate);
 		}
-	}
+
 	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 
 	if (pdata->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) {
@@ -612,6 +574,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 		return r;
 	if (r == 0) {
 		dev_err(dev->dev, "controller timed out\n");
+		if (dev->device_reset != NULL) {
+			r = dev->device_reset(dev->dev);
+			if (r < 0)
+				dev_err(dev->dev, "reset failed\n");
+		}
 		omap_i2c_init(dev);
 		return -ETIMEDOUT;
 	}
@@ -622,6 +589,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 	/* We have an error */
 	if (dev->cmd_err & (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR |
 			    OMAP_I2C_STAT_XUDF)) {
+		if (dev->device_reset != NULL) {
+			r = dev->device_reset(dev->dev);
+			if (r < 0)
+				dev_err(dev->dev, "reset failed\n");
+		}
 		omap_i2c_init(dev);
 		return -EIO;
 	}
@@ -1024,6 +996,7 @@ omap_i2c_probe(struct platform_device *pdev)
 	if (pdata != NULL) {
 		speed = pdata->clkrate;
 		dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
+		dev->device_reset = pdata->device_reset;
 	} else {
 		speed = 100;	/* Default speed */
 		dev->set_mpu_wkup_lat = NULL;
-- 
1.7.1

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

* [PATCH 3/5] OMAP: I2C: Remove the reset in the init path
@ 2011-07-21  6:53   ` Shubhrajyoti D
  0 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-arm-kernel

The reset in the driver at init is not needed
anymore as the hwmod framework takes care of
reseting it.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   57 +++++++++++------------------------------
 1 files changed, 15 insertions(+), 42 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 8f87a37..d6ea7de 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -155,9 +155,6 @@ enum {
 #define OMAP_I2C_SYSTEST_SDA_O		(1 << 0)	/* SDA line drive out */
 #endif
 
-/* OCP_SYSSTATUS bit definitions */
-#define SYSS_RESETDONE_MASK		(1 << 0)
-
 /* OCP_SYSCONFIG bit definitions */
 #define SYSC_CLOCKACTIVITY_MASK		(0x3 << 8)
 #define SYSC_SIDLEMODE_MASK		(0x3 << 3)
@@ -182,6 +179,8 @@ struct omap_i2c_dev {
 	u32			latency;	/* maximum mpu wkup latency */
 	void			(*set_mpu_wkup_lat)(struct device *dev,
 						    long latency);
+	int			(*device_reset)(struct device *dev);
+
 	u32			speed;		/* Speed of bus in Khz */
 	u16			cmd_err;
 	u8			*buf;
@@ -332,7 +331,6 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 	u16 psc = 0, scll = 0, sclh = 0, buf = 0;
 	u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0;
 	unsigned long fclk_rate = 12000000;
-	unsigned long timeout;
 	unsigned long internal_clk = 0;
 	struct clk *fclk;
 	struct platform_device *pdev;
@@ -341,43 +339,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 	pdev = to_platform_device(dev->dev);
 	pdata = pdev->dev.platform_data;
 
-	if (dev->rev >= OMAP_I2C_OMAP1_REV_2) {
-		/* Disable I2C controller before soft reset */
-		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
-			omap_i2c_read_reg(dev, OMAP_I2C_CON_REG) &
-				~(OMAP_I2C_CON_EN));
-
-		omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK);
-		/* For some reason we need to set the EN bit before the
-		 * reset done bit gets set. */
-		timeout = jiffies + OMAP_I2C_TIMEOUT;
-		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
-		while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) &
-			 SYSS_RESETDONE_MASK)) {
-			if (time_after(jiffies, timeout)) {
-				dev_warn(dev->dev, "timeout waiting "
-						"for controller reset\n");
-				return -ETIMEDOUT;
-			}
-			msleep(1);
-		}
-
-		/* SYSC register is cleared by the reset; rewrite it */
-		if (dev->rev == OMAP_I2C_REV_ON_2430) {
-
-			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
-					   SYSC_AUTOIDLE_MASK);
-
-		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
-			dev->syscstate = SYSC_AUTOIDLE_MASK;
-			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
-			dev->syscstate |= (SYSC_IDLEMODE_SMART <<
-			      __ffs(SYSC_SIDLEMODE_MASK));
-			dev->syscstate |= (SYSC_CLOCKACTIVITY_FCLK <<
-			      __ffs(SYSC_CLOCKACTIVITY_MASK));
-
-			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
-							dev->syscstate);
+	if (dev->rev >= OMAP_I2C_REV_ON_3430) {
 			/*
 			 * Enabling all wakup sources to stop I2C freezing on
 			 * WFI instruction.
@@ -388,7 +350,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 				omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
 								dev->westate);
 		}
-	}
+
 	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 
 	if (pdata->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) {
@@ -612,6 +574,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 		return r;
 	if (r == 0) {
 		dev_err(dev->dev, "controller timed out\n");
+		if (dev->device_reset != NULL) {
+			r = dev->device_reset(dev->dev);
+			if (r < 0)
+				dev_err(dev->dev, "reset failed\n");
+		}
 		omap_i2c_init(dev);
 		return -ETIMEDOUT;
 	}
@@ -622,6 +589,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 	/* We have an error */
 	if (dev->cmd_err & (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR |
 			    OMAP_I2C_STAT_XUDF)) {
+		if (dev->device_reset != NULL) {
+			r = dev->device_reset(dev->dev);
+			if (r < 0)
+				dev_err(dev->dev, "reset failed\n");
+		}
 		omap_i2c_init(dev);
 		return -EIO;
 	}
@@ -1024,6 +996,7 @@ omap_i2c_probe(struct platform_device *pdev)
 	if (pdata != NULL) {
 		speed = pdata->clkrate;
 		dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
+		dev->device_reset = pdata->device_reset;
 	} else {
 		speed = 100;	/* Default speed */
 		dev->set_mpu_wkup_lat = NULL;
-- 
1.7.1

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

* [PATCH 4/5] OMAP: I2C: Remove the SYSC register definition
  2011-07-21  6:53 ` Shubhrajyoti D
@ 2011-07-21  6:53   ` Shubhrajyoti D
  -1 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, rnayak, linux-i2c, linux-arm-kernel, Shubhrajyoti D

The SYSC register should not accessed in the driver removing the
define from the driver.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index d6ea7de..07e5a64 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -63,7 +63,6 @@ enum {
 	OMAP_I2C_BUF_REG,
 	OMAP_I2C_CNT_REG,
 	OMAP_I2C_DATA_REG,
-	OMAP_I2C_SYSC_REG,
 	OMAP_I2C_CON_REG,
 	OMAP_I2C_OA_REG,
 	OMAP_I2C_SA_REG,
@@ -214,7 +213,6 @@ const static u8 reg_map_ip_v1[] = {
 	[OMAP_I2C_BUF_REG] = 0x05,
 	[OMAP_I2C_CNT_REG] = 0x06,
 	[OMAP_I2C_DATA_REG] = 0x07,
-	[OMAP_I2C_SYSC_REG] = 0x08,
 	[OMAP_I2C_CON_REG] = 0x09,
 	[OMAP_I2C_OA_REG] = 0x0a,
 	[OMAP_I2C_SA_REG] = 0x0b,
@@ -235,7 +233,6 @@ const static u8 reg_map_ip_v2[] = {
 	[OMAP_I2C_BUF_REG] = 0x94,
 	[OMAP_I2C_CNT_REG] = 0x98,
 	[OMAP_I2C_DATA_REG] = 0x9c,
-	[OMAP_I2C_SYSC_REG] = 0x20,
 	[OMAP_I2C_CON_REG] = 0xa4,
 	[OMAP_I2C_OA_REG] = 0xa8,
 	[OMAP_I2C_SA_REG] = 0xac,
@@ -282,7 +279,6 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)
 		omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
 		omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
 		omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, dev->syscstate);
 		omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
 		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
 	}
-- 
1.7.1

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

* [PATCH 4/5] OMAP: I2C: Remove the SYSC register definition
@ 2011-07-21  6:53   ` Shubhrajyoti D
  0 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-arm-kernel

The SYSC register should not accessed in the driver removing the
define from the driver.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index d6ea7de..07e5a64 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -63,7 +63,6 @@ enum {
 	OMAP_I2C_BUF_REG,
 	OMAP_I2C_CNT_REG,
 	OMAP_I2C_DATA_REG,
-	OMAP_I2C_SYSC_REG,
 	OMAP_I2C_CON_REG,
 	OMAP_I2C_OA_REG,
 	OMAP_I2C_SA_REG,
@@ -214,7 +213,6 @@ const static u8 reg_map_ip_v1[] = {
 	[OMAP_I2C_BUF_REG] = 0x05,
 	[OMAP_I2C_CNT_REG] = 0x06,
 	[OMAP_I2C_DATA_REG] = 0x07,
-	[OMAP_I2C_SYSC_REG] = 0x08,
 	[OMAP_I2C_CON_REG] = 0x09,
 	[OMAP_I2C_OA_REG] = 0x0a,
 	[OMAP_I2C_SA_REG] = 0x0b,
@@ -235,7 +233,6 @@ const static u8 reg_map_ip_v2[] = {
 	[OMAP_I2C_BUF_REG] = 0x94,
 	[OMAP_I2C_CNT_REG] = 0x98,
 	[OMAP_I2C_DATA_REG] = 0x9c,
-	[OMAP_I2C_SYSC_REG] = 0x20,
 	[OMAP_I2C_CON_REG] = 0xa4,
 	[OMAP_I2C_OA_REG] = 0xa8,
 	[OMAP_I2C_SA_REG] = 0xac,
@@ -282,7 +279,6 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)
 		omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
 		omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
 		omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, dev->syscstate);
 		omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
 		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
 	}
-- 
1.7.1

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

* [PATCH 5/5] OMAP: I2C: Restore only if context is lost
  2011-07-21  6:53 ` Shubhrajyoti D
@ 2011-07-21  6:53   ` Shubhrajyoti D
  -1 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-omap; +Cc: linux-i2c, linux-arm-kernel, khilman, rnayak, Shubhrajyoti D

Currently restore is done always.
Adding conditional restore.The restore is done only if the context is lost.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 07e5a64..06fa457 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -40,6 +40,7 @@
 #include <linux/slab.h>
 #include <linux/i2c-omap.h>
 #include <linux/pm_runtime.h>
+#include <plat/omap_device.h>
 
 /* I2C controller revisions */
 #define OMAP_I2C_OMAP1_REV_2		0x20
@@ -201,6 +202,7 @@ struct omap_i2c_dev {
 	u16			syscstate;
 	u16			westate;
 	u16			errata;
+	u32			dev_lost_count;
 };
 
 const static u8 reg_map_ip_v1[] = {
@@ -261,6 +263,18 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
 				(i2c_dev->regs[reg] << i2c_dev->reg_shift));
 }
 
+
+static void omap_i2c_restore(struct omap_i2c_dev *dev)
+{
+	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
+	omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate);
+	omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
+	omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
+	omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
+	omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
+	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
+}
+
 static void omap_i2c_unidle(struct omap_i2c_dev *dev)
 {
 	struct platform_device *pdev;
@@ -274,14 +288,11 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)
 	pm_runtime_get_sync(&pdev->dev);
 
 	if (pdata->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) {
-		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
-		omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
-		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
+		u32 loss_cnt = omap_device_get_context_loss_count(pdev);
+		if (dev->dev_lost_count != loss_cnt)
+			omap_i2c_restore(dev);
 	}
+
 	dev->idle = 0;
 
 	/*
@@ -318,7 +329,7 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
 		omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
 	}
 	dev->idle = 1;
-
+	dev->dev_lost_count = omap_device_get_context_loss_count(pdev);
 	pm_runtime_put_sync(&pdev->dev);
 }
 
@@ -574,6 +585,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 			r = dev->device_reset(dev->dev);
 			if (r < 0)
 				dev_err(dev->dev, "reset failed\n");
+			omap_i2c_restore(dev);
 		}
 		omap_i2c_init(dev);
 		return -ETIMEDOUT;
@@ -589,6 +601,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 			r = dev->device_reset(dev->dev);
 			if (r < 0)
 				dev_err(dev->dev, "reset failed\n");
+			omap_i2c_restore(dev);
 		}
 		omap_i2c_init(dev);
 		return -EIO;
-- 
1.7.1


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

* [PATCH 5/5] OMAP: I2C: Restore only if context is lost
@ 2011-07-21  6:53   ` Shubhrajyoti D
  0 siblings, 0 replies; 16+ messages in thread
From: Shubhrajyoti D @ 2011-07-21  6:53 UTC (permalink / raw)
  To: linux-arm-kernel

Currently restore is done always.
Adding conditional restore.The restore is done only if the context is lost.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 07e5a64..06fa457 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -40,6 +40,7 @@
 #include <linux/slab.h>
 #include <linux/i2c-omap.h>
 #include <linux/pm_runtime.h>
+#include <plat/omap_device.h>
 
 /* I2C controller revisions */
 #define OMAP_I2C_OMAP1_REV_2		0x20
@@ -201,6 +202,7 @@ struct omap_i2c_dev {
 	u16			syscstate;
 	u16			westate;
 	u16			errata;
+	u32			dev_lost_count;
 };
 
 const static u8 reg_map_ip_v1[] = {
@@ -261,6 +263,18 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
 				(i2c_dev->regs[reg] << i2c_dev->reg_shift));
 }
 
+
+static void omap_i2c_restore(struct omap_i2c_dev *dev)
+{
+	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
+	omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate);
+	omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
+	omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
+	omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
+	omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
+	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
+}
+
 static void omap_i2c_unidle(struct omap_i2c_dev *dev)
 {
 	struct platform_device *pdev;
@@ -274,14 +288,11 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)
 	pm_runtime_get_sync(&pdev->dev);
 
 	if (pdata->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) {
-		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
-		omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
-		omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
-		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
+		u32 loss_cnt = omap_device_get_context_loss_count(pdev);
+		if (dev->dev_lost_count != loss_cnt)
+			omap_i2c_restore(dev);
 	}
+
 	dev->idle = 0;
 
 	/*
@@ -318,7 +329,7 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
 		omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
 	}
 	dev->idle = 1;
-
+	dev->dev_lost_count = omap_device_get_context_loss_count(pdev);
 	pm_runtime_put_sync(&pdev->dev);
 }
 
@@ -574,6 +585,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 			r = dev->device_reset(dev->dev);
 			if (r < 0)
 				dev_err(dev->dev, "reset failed\n");
+			omap_i2c_restore(dev);
 		}
 		omap_i2c_init(dev);
 		return -ETIMEDOUT;
@@ -589,6 +601,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 			r = dev->device_reset(dev->dev);
 			if (r < 0)
 				dev_err(dev->dev, "reset failed\n");
+			omap_i2c_restore(dev);
 		}
 		omap_i2c_init(dev);
 		return -EIO;
-- 
1.7.1

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

* Re: [PATCH 5/5] OMAP: I2C: Restore only if context is lost
  2011-07-21  6:53   ` Shubhrajyoti D
@ 2011-07-21  8:14     ` T Krishnamoorthy, Balaji
  -1 siblings, 0 replies; 16+ messages in thread
From: T Krishnamoorthy, Balaji @ 2011-07-21  8:14 UTC (permalink / raw)
  To: Shubhrajyoti D; +Cc: khilman, linux-omap, linux-i2c, linux-arm-kernel, rnayak

On Thu, Jul 21, 2011 at 12:23 PM, Shubhrajyoti D <shubhrajyoti@ti.com> wrote:
> Currently restore is done always.
> Adding conditional restore.The restore is done only if the context is lost.
>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> ---
> @@ -261,6 +263,18 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
>                                (i2c_dev->regs[reg] << i2c_dev->reg_shift));
>  }
>
> +
spurious line

> +static void omap_i2c_restore(struct omap_i2c_dev *dev)
> +{
> +       omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
> +       omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate);
> +       omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
> +       omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
> +       omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
> +       omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
> +       omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
> +}
> +
>  static void omap_i2c_unidle(struct omap_i2c_dev *dev)
>  {
>        struct platform_device *pdev;
> @@ -274,14 +288,11 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)
>        pm_runtime_get_sync(&pdev->dev);
>
>        if (pdata->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) {
> -               omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
> -               omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate);
> -               omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
> -               omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
> -               omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
> -               omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
> -               omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
> +               u32 loss_cnt = omap_device_get_context_loss_count(pdev);
> +               if (dev->dev_lost_count != loss_cnt)
> +                       omap_i2c_restore(dev);
>        }
> +
>        dev->idle = 0;
>
>        /*
> @@ -318,7 +329,7 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
>                omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
>        }
>        dev->idle = 1;
> -
> +       dev->dev_lost_count = omap_device_get_context_loss_count(pdev);
>        pm_runtime_put_sync(&pdev->dev);
>  }
>
> @@ -574,6 +585,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
>                        r = dev->device_reset(dev->dev);
>                        if (r < 0)
>                                dev_err(dev->dev, "reset failed\n");
> +                       omap_i2c_restore(dev);
>                }
>                omap_i2c_init(dev);

Are you sure you need both omap_i2c_restore, omap_i2c_init calls here ?

>                return -ETIMEDOUT;
> @@ -589,6 +601,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
>                        r = dev->device_reset(dev->dev);
>                        if (r < 0)
>                                dev_err(dev->dev, "reset failed\n");
> +                       omap_i2c_restore(dev);

same comment here

>                }
>                omap_i2c_init(dev);
>                return -EIO;
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* [PATCH 5/5] OMAP: I2C: Restore only if context is lost
@ 2011-07-21  8:14     ` T Krishnamoorthy, Balaji
  0 siblings, 0 replies; 16+ messages in thread
From: T Krishnamoorthy, Balaji @ 2011-07-21  8:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 21, 2011 at 12:23 PM, Shubhrajyoti D <shubhrajyoti@ti.com> wrote:
> Currently restore is done always.
> Adding conditional restore.The restore is done only if the context is lost.
>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> ---
> @@ -261,6 +263,18 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(i2c_dev->regs[reg] << i2c_dev->reg_shift));
> ?}
>
> +
spurious line

> +static void omap_i2c_restore(struct omap_i2c_dev *dev)
> +{
> + ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
> + ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate);
> + ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
> + ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
> + ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
> + ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
> + ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
> +}
> +
> ?static void omap_i2c_unidle(struct omap_i2c_dev *dev)
> ?{
> ? ? ? ?struct platform_device *pdev;
> @@ -274,14 +288,11 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)
> ? ? ? ?pm_runtime_get_sync(&pdev->dev);
>
> ? ? ? ?if (pdata->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) {
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate);
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
> + ? ? ? ? ? ? ? u32 loss_cnt = omap_device_get_context_loss_count(pdev);
> + ? ? ? ? ? ? ? if (dev->dev_lost_count != loss_cnt)
> + ? ? ? ? ? ? ? ? ? ? ? omap_i2c_restore(dev);
> ? ? ? ?}
> +
> ? ? ? ?dev->idle = 0;
>
> ? ? ? ?/*
> @@ -318,7 +329,7 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
> ? ? ? ? ? ? ? ?omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
> ? ? ? ?}
> ? ? ? ?dev->idle = 1;
> -
> + ? ? ? dev->dev_lost_count = omap_device_get_context_loss_count(pdev);
> ? ? ? ?pm_runtime_put_sync(&pdev->dev);
> ?}
>
> @@ -574,6 +585,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
> ? ? ? ? ? ? ? ? ? ? ? ?r = dev->device_reset(dev->dev);
> ? ? ? ? ? ? ? ? ? ? ? ?if (r < 0)
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dev_err(dev->dev, "reset failed\n");
> + ? ? ? ? ? ? ? ? ? ? ? omap_i2c_restore(dev);
> ? ? ? ? ? ? ? ?}
> ? ? ? ? ? ? ? ?omap_i2c_init(dev);

Are you sure you need both omap_i2c_restore, omap_i2c_init calls here ?

> ? ? ? ? ? ? ? ?return -ETIMEDOUT;
> @@ -589,6 +601,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
> ? ? ? ? ? ? ? ? ? ? ? ?r = dev->device_reset(dev->dev);
> ? ? ? ? ? ? ? ? ? ? ? ?if (r < 0)
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dev_err(dev->dev, "reset failed\n");
> + ? ? ? ? ? ? ? ? ? ? ? omap_i2c_restore(dev);

same comment here

> ? ? ? ? ? ? ? ?}
> ? ? ? ? ? ? ? ?omap_i2c_init(dev);
> ? ? ? ? ? ? ? ?return -EIO;
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH 3/5] OMAP: I2C: Remove the reset in the init path
  2011-07-21  6:53   ` Shubhrajyoti D
@ 2011-07-21  8:31     ` T Krishnamoorthy, Balaji
  -1 siblings, 0 replies; 16+ messages in thread
From: T Krishnamoorthy, Balaji @ 2011-07-21  8:31 UTC (permalink / raw)
  To: Shubhrajyoti D; +Cc: khilman, linux-omap, linux-i2c, linux-arm-kernel, rnayak

On Thu, Jul 21, 2011 at 12:23 PM, Shubhrajyoti D <shubhrajyoti@ti.com> wrote:
> The reset in the driver at init is not needed
> anymore as the hwmod framework takes care of
> reseting it.
>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> ---
>  drivers/i2c/busses/i2c-omap.c |   57 +++++++++++------------------------------
>  1 files changed, 15 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 8f87a37..d6ea7de 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -155,9 +155,6 @@ enum {
>  #define OMAP_I2C_SYSTEST_SDA_O         (1 << 0)        /* SDA line drive out */
>  #endif
>
> -/* OCP_SYSSTATUS bit definitions */
> -#define SYSS_RESETDONE_MASK            (1 << 0)
> -
>  /* OCP_SYSCONFIG bit definitions */
>  #define SYSC_CLOCKACTIVITY_MASK                (0x3 << 8)
>  #define SYSC_SIDLEMODE_MASK            (0x3 << 3)
> @@ -182,6 +179,8 @@ struct omap_i2c_dev {
>        u32                     latency;        /* maximum mpu wkup latency */
>        void                    (*set_mpu_wkup_lat)(struct device *dev,
>                                                    long latency);
> +       int                     (*device_reset)(struct device *dev);
> +
>        u32                     speed;          /* Speed of bus in Khz */
>        u16                     cmd_err;
>        u8                      *buf;
> @@ -332,7 +331,6 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
>        u16 psc = 0, scll = 0, sclh = 0, buf = 0;
>        u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0;
>        unsigned long fclk_rate = 12000000;
> -       unsigned long timeout;
>        unsigned long internal_clk = 0;
>        struct clk *fclk;
>        struct platform_device *pdev;
> @@ -341,43 +339,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
>        pdev = to_platform_device(dev->dev);
>        pdata = pdev->dev.platform_data;
>
> -       if (dev->rev >= OMAP_I2C_OMAP1_REV_2) {
> -               /* Disable I2C controller before soft reset */
> -               omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
> -                       omap_i2c_read_reg(dev, OMAP_I2C_CON_REG) &
> -                               ~(OMAP_I2C_CON_EN));
> -
> -               omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK);
> -               /* For some reason we need to set the EN bit before the
> -                * reset done bit gets set. */
> -               timeout = jiffies + OMAP_I2C_TIMEOUT;
> -               omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
> -               while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) &
> -                        SYSS_RESETDONE_MASK)) {
> -                       if (time_after(jiffies, timeout)) {
> -                               dev_warn(dev->dev, "timeout waiting "
> -                                               "for controller reset\n");
> -                               return -ETIMEDOUT;
> -                       }
> -                       msleep(1);
> -               }
> -
> -               /* SYSC register is cleared by the reset; rewrite it */
> -               if (dev->rev == OMAP_I2C_REV_ON_2430) {
> -
> -                       omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
> -                                          SYSC_AUTOIDLE_MASK);
> -
> -               } else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
> -                       dev->syscstate = SYSC_AUTOIDLE_MASK;
> -                       dev->syscstate |= SYSC_ENAWAKEUP_MASK;
> -                       dev->syscstate |= (SYSC_IDLEMODE_SMART <<
> -                             __ffs(SYSC_SIDLEMODE_MASK));
> -                       dev->syscstate |= (SYSC_CLOCKACTIVITY_FCLK <<
> -                             __ffs(SYSC_CLOCKACTIVITY_MASK));
> -
> -                       omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
> -                                                       dev->syscstate);
> +       if (dev->rev >= OMAP_I2C_REV_ON_3430) {
>                        /*
>                         * Enabling all wakup sources to stop I2C freezing on
>                         * WFI instruction.

one extra level of indentation

> @@ -388,7 +350,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
>                                omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
>                                                                dev->westate);
>                }

same

> -       }
> +

spurious change, This comment applies to other patches in the series.

>        omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
>
>        if (pdata->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) {

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

* [PATCH 3/5] OMAP: I2C: Remove the reset in the init path
@ 2011-07-21  8:31     ` T Krishnamoorthy, Balaji
  0 siblings, 0 replies; 16+ messages in thread
From: T Krishnamoorthy, Balaji @ 2011-07-21  8:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 21, 2011 at 12:23 PM, Shubhrajyoti D <shubhrajyoti@ti.com> wrote:
> The reset in the driver at init is not needed
> anymore as the hwmod framework takes care of
> reseting it.
>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> ---
> ?drivers/i2c/busses/i2c-omap.c | ? 57 +++++++++++------------------------------
> ?1 files changed, 15 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 8f87a37..d6ea7de 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -155,9 +155,6 @@ enum {
> ?#define OMAP_I2C_SYSTEST_SDA_O ? ? ? ? (1 << 0) ? ? ? ?/* SDA line drive out */
> ?#endif
>
> -/* OCP_SYSSTATUS bit definitions */
> -#define SYSS_RESETDONE_MASK ? ? ? ? ? ?(1 << 0)
> -
> ?/* OCP_SYSCONFIG bit definitions */
> ?#define SYSC_CLOCKACTIVITY_MASK ? ? ? ? ? ? ? ?(0x3 << 8)
> ?#define SYSC_SIDLEMODE_MASK ? ? ? ? ? ?(0x3 << 3)
> @@ -182,6 +179,8 @@ struct omap_i2c_dev {
> ? ? ? ?u32 ? ? ? ? ? ? ? ? ? ? latency; ? ? ? ?/* maximum mpu wkup latency */
> ? ? ? ?void ? ? ? ? ? ? ? ? ? ?(*set_mpu_wkup_lat)(struct device *dev,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?long latency);
> + ? ? ? int ? ? ? ? ? ? ? ? ? ? (*device_reset)(struct device *dev);
> +
> ? ? ? ?u32 ? ? ? ? ? ? ? ? ? ? speed; ? ? ? ? ?/* Speed of bus in Khz */
> ? ? ? ?u16 ? ? ? ? ? ? ? ? ? ? cmd_err;
> ? ? ? ?u8 ? ? ? ? ? ? ? ? ? ? ?*buf;
> @@ -332,7 +331,6 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
> ? ? ? ?u16 psc = 0, scll = 0, sclh = 0, buf = 0;
> ? ? ? ?u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0;
> ? ? ? ?unsigned long fclk_rate = 12000000;
> - ? ? ? unsigned long timeout;
> ? ? ? ?unsigned long internal_clk = 0;
> ? ? ? ?struct clk *fclk;
> ? ? ? ?struct platform_device *pdev;
> @@ -341,43 +339,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
> ? ? ? ?pdev = to_platform_device(dev->dev);
> ? ? ? ?pdata = pdev->dev.platform_data;
>
> - ? ? ? if (dev->rev >= OMAP_I2C_OMAP1_REV_2) {
> - ? ? ? ? ? ? ? /* Disable I2C controller before soft reset */
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
> - ? ? ? ? ? ? ? ? ? ? ? omap_i2c_read_reg(dev, OMAP_I2C_CON_REG) &
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ~(OMAP_I2C_CON_EN));
> -
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK);
> - ? ? ? ? ? ? ? /* For some reason we need to set the EN bit before the
> - ? ? ? ? ? ? ? ?* reset done bit gets set. */
> - ? ? ? ? ? ? ? timeout = jiffies + OMAP_I2C_TIMEOUT;
> - ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
> - ? ? ? ? ? ? ? while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) &
> - ? ? ? ? ? ? ? ? ? ? ? ?SYSS_RESETDONE_MASK)) {
> - ? ? ? ? ? ? ? ? ? ? ? if (time_after(jiffies, timeout)) {
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? dev_warn(dev->dev, "timeout waiting "
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "for controller reset\n");
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return -ETIMEDOUT;
> - ? ? ? ? ? ? ? ? ? ? ? }
> - ? ? ? ? ? ? ? ? ? ? ? msleep(1);
> - ? ? ? ? ? ? ? }
> -
> - ? ? ? ? ? ? ? /* SYSC register is cleared by the reset; rewrite it */
> - ? ? ? ? ? ? ? if (dev->rev == OMAP_I2C_REV_ON_2430) {
> -
> - ? ? ? ? ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SYSC_AUTOIDLE_MASK);
> -
> - ? ? ? ? ? ? ? } else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
> - ? ? ? ? ? ? ? ? ? ? ? dev->syscstate = SYSC_AUTOIDLE_MASK;
> - ? ? ? ? ? ? ? ? ? ? ? dev->syscstate |= SYSC_ENAWAKEUP_MASK;
> - ? ? ? ? ? ? ? ? ? ? ? dev->syscstate |= (SYSC_IDLEMODE_SMART <<
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? __ffs(SYSC_SIDLEMODE_MASK));
> - ? ? ? ? ? ? ? ? ? ? ? dev->syscstate |= (SYSC_CLOCKACTIVITY_FCLK <<
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? __ffs(SYSC_CLOCKACTIVITY_MASK));
> -
> - ? ? ? ? ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? dev->syscstate);
> + ? ? ? if (dev->rev >= OMAP_I2C_REV_ON_3430) {
> ? ? ? ? ? ? ? ? ? ? ? ?/*
> ? ? ? ? ? ? ? ? ? ? ? ? * Enabling all wakup sources to stop I2C freezing on
> ? ? ? ? ? ? ? ? ? ? ? ? * WFI instruction.

one extra level of indentation

> @@ -388,7 +350,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dev->westate);
> ? ? ? ? ? ? ? ?}

same

> - ? ? ? }
> +

spurious change, This comment applies to other patches in the series.

> ? ? ? ?omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
>
> ? ? ? ?if (pdata->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) {

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

end of thread, other threads:[~2011-07-21  8:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-21  6:53 [PATCH 0/5] I2C: driver updates Shubhrajyoti D
2011-07-21  6:53 ` Shubhrajyoti D
2011-07-21  6:53 ` [PATCH 1/5] OMAP: I2C: Add a device reset field to platform data Shubhrajyoti D
2011-07-21  6:53   ` Shubhrajyoti D
2011-07-21  6:53 ` [PATCH 2/5] OMAP: I2C: Reset support Shubhrajyoti D
2011-07-21  6:53   ` Shubhrajyoti D
2011-07-21  6:53 ` [PATCH 3/5] OMAP: I2C: Remove the reset in the init path Shubhrajyoti D
2011-07-21  6:53   ` Shubhrajyoti D
2011-07-21  8:31   ` T Krishnamoorthy, Balaji
2011-07-21  8:31     ` T Krishnamoorthy, Balaji
2011-07-21  6:53 ` [PATCH 4/5] OMAP: I2C: Remove the SYSC register definition Shubhrajyoti D
2011-07-21  6:53   ` Shubhrajyoti D
2011-07-21  6:53 ` [PATCH 5/5] OMAP: I2C: Restore only if context is lost Shubhrajyoti D
2011-07-21  6:53   ` Shubhrajyoti D
2011-07-21  8:14   ` T Krishnamoorthy, Balaji
2011-07-21  8:14     ` T Krishnamoorthy, Balaji

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.