* [PATCHV2 0/5] I2C: driver updates
@ 2011-07-21 11:09 ` Shubhrajyoti D
0 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 UTC (permalink / raw)
To: linux-omap
Cc: linux-i2c, linux-arm-kernel, khilman, rnayak, balajitk, 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.
version 2
- Fix the indentation.
- Restore in the error path is not needed as we are
doing a init.
Tested on sdp4430 and on omap3430
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 | 17 +++++++
drivers/i2c/busses/i2c-omap.c | 101 ++++++++++++++++-------------------------
include/linux/i2c-omap.h | 1 +
3 files changed, 57 insertions(+), 62 deletions(-)
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCHV2 0/5] I2C: driver updates
@ 2011-07-21 11:09 ` Shubhrajyoti D
0 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 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.
version 2
- Fix the indentation.
- Restore in the error path is not needed as we are
doing a init.
Tested on sdp4430 and on omap3430
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 | 17 +++++++
drivers/i2c/busses/i2c-omap.c | 101 ++++++++++++++++-------------------------
include/linux/i2c-omap.h | 1 +
3 files changed, 57 insertions(+), 62 deletions(-)
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCHV2 1/5] OMAP: I2C: Add a device reset field to platform data
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:09 ` Shubhrajyoti D
-1 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 UTC (permalink / raw)
To: linux-omap
Cc: linux-i2c, linux-arm-kernel, khilman, rnayak, balajitk, Shubhrajyoti D
Under some conditions the driver may want to do a reset
of the device. Adding a reset 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] 26+ messages in thread
* [PATCHV2 1/5] OMAP: I2C: Add a device reset field to platform data
@ 2011-07-21 11:09 ` Shubhrajyoti D
0 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 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 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] 26+ messages in thread
* [PATCHV2 2/5] OMAP: I2C: Reset support
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:09 ` Shubhrajyoti D
-1 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 UTC (permalink / raw)
To: linux-omap-u79uwXL29TY76Z2rM5mHXA
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
khilman-l0cyMroinI0, rnayak-l0cyMroinI0, balajitk-l0cyMroinI0,
Shubhrajyoti D
Under some error conditions the i2c driver may do a reset
adding support in the platform.
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
arch/arm/plat-omap/i2c.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 2388b8e..98a97b0 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,7 @@ 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] 26+ messages in thread
* [PATCHV2 2/5] OMAP: I2C: Reset support
@ 2011-07-21 11:09 ` Shubhrajyoti D
0 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 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 | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 2388b8e..98a97b0 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,7 @@ 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] 26+ messages in thread
* [PATCHV2 3/5] OMAP: I2C: Remove the reset in the init path
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:09 ` Shubhrajyoti D
-1 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 UTC (permalink / raw)
To: linux-omap-u79uwXL29TY76Z2rM5mHXA
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
khilman-l0cyMroinI0, rnayak-l0cyMroinI0, balajitk-l0cyMroinI0,
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-l0cyMroinI0@public.gmane.org>
---
drivers/i2c/busses/i2c-omap.c | 73 ++++++++++++----------------------------
1 files changed, 22 insertions(+), 51 deletions(-)
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 8f87a37..8dc54d5 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,7 @@ 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 +330,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,53 +338,16 @@ 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);
- /*
- * Enabling all wakup sources to stop I2C freezing on
- * WFI instruction.
- * REVISIT: Some wkup sources might not be needed.
- */
- dev->westate = OMAP_I2C_WE_ALL;
- if (dev->rev < OMAP_I2C_REV_ON_3530_4430)
- omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
- dev->westate);
- }
+ if (dev->rev >= OMAP_I2C_REV_ON_3430) {
+ /*
+ * Enabling all wakup sources to stop I2C freezing on
+ * WFI instruction.
+ * REVISIT: Some wkup sources might not be needed.
+ */
+ dev->westate = OMAP_I2C_WE_ALL;
+ if (dev->rev < OMAP_I2C_REV_ON_3530_4430)
+ omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
+ dev->westate);
}
omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
@@ -612,6 +572,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 +587,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 +994,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] 26+ messages in thread
* [PATCHV2 3/5] OMAP: I2C: Remove the reset in the init path
@ 2011-07-21 11:09 ` Shubhrajyoti D
0 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 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 | 73 ++++++++++++----------------------------
1 files changed, 22 insertions(+), 51 deletions(-)
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 8f87a37..8dc54d5 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,7 @@ 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 +330,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,53 +338,16 @@ 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);
- /*
- * Enabling all wakup sources to stop I2C freezing on
- * WFI instruction.
- * REVISIT: Some wkup sources might not be needed.
- */
- dev->westate = OMAP_I2C_WE_ALL;
- if (dev->rev < OMAP_I2C_REV_ON_3530_4430)
- omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
- dev->westate);
- }
+ if (dev->rev >= OMAP_I2C_REV_ON_3430) {
+ /*
+ * Enabling all wakup sources to stop I2C freezing on
+ * WFI instruction.
+ * REVISIT: Some wkup sources might not be needed.
+ */
+ dev->westate = OMAP_I2C_WE_ALL;
+ if (dev->rev < OMAP_I2C_REV_ON_3530_4430)
+ omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
+ dev->westate);
}
omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
@@ -612,6 +572,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 +587,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 +994,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] 26+ messages in thread
* [PATCHV2 4/5] OMAP: I2C: Remove the SYSC register definition
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:09 ` Shubhrajyoti D
-1 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 UTC (permalink / raw)
To: linux-omap
Cc: khilman, balajitk, rnayak, linux-i2c, Shubhrajyoti D, 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 8dc54d5..75bb62d 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,
@@ -213,7 +212,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,
@@ -234,7 +232,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,
@@ -281,7 +278,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] 26+ messages in thread
* [PATCHV2 4/5] OMAP: I2C: Remove the SYSC register definition
@ 2011-07-21 11:09 ` Shubhrajyoti D
0 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 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 8dc54d5..75bb62d 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,
@@ -213,7 +212,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,
@@ -234,7 +232,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,
@@ -281,7 +278,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] 26+ messages in thread
* [PATCHV2 5/5] OMAP: I2C: Restore only if context is lost
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:09 ` Shubhrajyoti D
-1 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 UTC (permalink / raw)
To: linux-omap
Cc: khilman, balajitk, rnayak, linux-i2c, Shubhrajyoti D, 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 | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 75bb62d..dffdbfd 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
@@ -200,6 +201,7 @@ struct omap_i2c_dev {
u16 syscstate;
u16 westate;
u16 errata;
+ u32 dev_lost_count;
};
const static u8 reg_map_ip_v1[] = {
@@ -260,6 +262,17 @@ 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;
@@ -273,13 +286,9 @@ 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,6 +327,7 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
}
dev->idle = 1;
+ dev->dev_lost_count = omap_device_get_context_loss_count(pdev);
pm_runtime_put_sync(&pdev->dev);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCHV2 5/5] OMAP: I2C: Restore only if context is lost
@ 2011-07-21 11:09 ` Shubhrajyoti D
0 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti D @ 2011-07-21 11:09 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 | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 75bb62d..dffdbfd 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
@@ -200,6 +201,7 @@ struct omap_i2c_dev {
u16 syscstate;
u16 westate;
u16 errata;
+ u32 dev_lost_count;
};
const static u8 reg_map_ip_v1[] = {
@@ -260,6 +262,17 @@ 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;
@@ -273,13 +286,9 @@ 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,6 +327,7 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
}
dev->idle = 1;
+ dev->dev_lost_count = omap_device_get_context_loss_count(pdev);
pm_runtime_put_sync(&pdev->dev);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCHV2 1/5] OMAP: I2C: Add a device reset field to platform data
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:18 ` Santosh Shilimkar
-1 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:18 UTC (permalink / raw)
To: Shubhrajyoti D
Cc: linux-omap, linux-i2c, linux-arm-kernel, khilman, rnayak, balajitk
Shubro,
On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
> Under some conditions the driver may want to do a reset
> of the device. Adding a reset 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);
Any reason you haven't clubbed this with the omap i2c reset
implementation patch ?
Since i2c-omap.h isn't a generic header file and specific
to omap i2c drive, you could combine 1/5 and 2/5
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCHV2 1/5] OMAP: I2C: Add a device reset field to platform data
@ 2011-07-21 11:18 ` Santosh Shilimkar
0 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:18 UTC (permalink / raw)
To: linux-arm-kernel
Shubro,
On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
> Under some conditions the driver may want to do a reset
> of the device. Adding a reset 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);
Any reason you haven't clubbed this with the omap i2c reset
implementation patch ?
Since i2c-omap.h isn't a generic header file and specific
to omap i2c drive, you could combine 1/5 and 2/5
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCHV2 2/5] OMAP: I2C: Reset support
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:19 ` Santosh Shilimkar
-1 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:19 UTC (permalink / raw)
To: Shubhrajyoti D
Cc: linux-omap, linux-i2c, linux-arm-kernel, khilman, rnayak, balajitk
On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
> Under some error conditions the i2c driver may do a reset
> adding support in the platform.
>
> Signed-off-by: Shubhrajyoti D<shubhrajyoti@ti.com>
> ---
As commented on 1/5, this one should be folded
with 1/5 unless and until you have some valid reason.
Regards
Santosh
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCHV2 2/5] OMAP: I2C: Reset support
@ 2011-07-21 11:19 ` Santosh Shilimkar
0 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:19 UTC (permalink / raw)
To: linux-arm-kernel
On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
> Under some error conditions the i2c driver may do a reset
> adding support in the platform.
>
> Signed-off-by: Shubhrajyoti D<shubhrajyoti@ti.com>
> ---
As commented on 1/5, this one should be folded
with 1/5 unless and until you have some valid reason.
Regards
Santosh
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCHV2 3/5] OMAP: I2C: Remove the reset in the init path
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:27 ` Santosh Shilimkar
-1 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:27 UTC (permalink / raw)
To: Shubhrajyoti D
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-i2c-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
khilman-l0cyMroinI0, rnayak-l0cyMroinI0, balajitk-l0cyMroinI0
On 7/21/2011 4:39 PM, Shubhrajyoti D 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-l0cyMroinI0@public.gmane.org>
> ---
> drivers/i2c/busses/i2c-omap.c | 73 ++++++++++++----------------------------
> 1 files changed, 22 insertions(+), 51 deletions(-)
Excellent cleanup. Some minor coments
>
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 8f87a37..8dc54d5 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,7 @@ 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 +330,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,53 +338,16 @@ 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);
> - /*
> - * Enabling all wakup sources to stop I2C freezing on
> - * WFI instruction.
> - * REVISIT: Some wkup sources might not be needed.
> - */
> - dev->westate = OMAP_I2C_WE_ALL;
> - if (dev->rev< OMAP_I2C_REV_ON_3530_4430)
> - omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
> - dev->westate);
> - }
> + if (dev->rev>= OMAP_I2C_REV_ON_3430) {
Space please if (dev->rev >= OMAP_I2C_REV_ON_3430) {
> + /*
> + * Enabling all wakup sources to stop I2C freezing on
> + * WFI instruction.
> + * REVISIT: Some wkup sources might not be needed.
> + */
Surely not related to your patch. But the 'REVISIT:' caught
my attention. Is the comment still valid.
> + dev->westate = OMAP_I2C_WE_ALL;
> + if (dev->rev< OMAP_I2C_REV_ON_3530_4430)
Space if (dev->rev < OMAP_I2C_REV_ON_3530_4430)
> + omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
> + dev->westate);
> }
> omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
>
> @@ -612,6 +572,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)
ditto
> + dev_err(dev->dev, "reset failed\n");
> + }
> omap_i2c_init(dev);
> return -ETIMEDOUT;
> }
> @@ -622,6 +587,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 |
You can fix this one as well.
> OMAP_I2C_STAT_XUDF)) {
> + if (dev->device_reset != NULL) {
> + r = dev->device_reset(dev->dev);
> + if (r< 0)
here too.
> + dev_err(dev->dev, "reset failed\n");
> + }
> omap_i2c_init(dev);
> return -EIO;
> }
> @@ -1024,6 +994,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;
Regards
Santosh
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCHV2 3/5] OMAP: I2C: Remove the reset in the init path
@ 2011-07-21 11:27 ` Santosh Shilimkar
0 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:27 UTC (permalink / raw)
To: linux-arm-kernel
On 7/21/2011 4:39 PM, Shubhrajyoti D 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 | 73 ++++++++++++----------------------------
> 1 files changed, 22 insertions(+), 51 deletions(-)
Excellent cleanup. Some minor coments
>
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 8f87a37..8dc54d5 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,7 @@ 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 +330,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,53 +338,16 @@ 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);
> - /*
> - * Enabling all wakup sources to stop I2C freezing on
> - * WFI instruction.
> - * REVISIT: Some wkup sources might not be needed.
> - */
> - dev->westate = OMAP_I2C_WE_ALL;
> - if (dev->rev< OMAP_I2C_REV_ON_3530_4430)
> - omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
> - dev->westate);
> - }
> + if (dev->rev>= OMAP_I2C_REV_ON_3430) {
Space please if (dev->rev >= OMAP_I2C_REV_ON_3430) {
> + /*
> + * Enabling all wakup sources to stop I2C freezing on
> + * WFI instruction.
> + * REVISIT: Some wkup sources might not be needed.
> + */
Surely not related to your patch. But the 'REVISIT:' caught
my attention. Is the comment still valid.
> + dev->westate = OMAP_I2C_WE_ALL;
> + if (dev->rev< OMAP_I2C_REV_ON_3530_4430)
Space if (dev->rev < OMAP_I2C_REV_ON_3530_4430)
> + omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
> + dev->westate);
> }
> omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
>
> @@ -612,6 +572,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)
ditto
> + dev_err(dev->dev, "reset failed\n");
> + }
> omap_i2c_init(dev);
> return -ETIMEDOUT;
> }
> @@ -622,6 +587,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 |
You can fix this one as well.
> OMAP_I2C_STAT_XUDF)) {
> + if (dev->device_reset != NULL) {
> + r = dev->device_reset(dev->dev);
> + if (r< 0)
here too.
> + dev_err(dev->dev, "reset failed\n");
> + }
> omap_i2c_init(dev);
> return -EIO;
> }
> @@ -1024,6 +994,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;
Regards
Santosh
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCHV2 4/5] OMAP: I2C: Remove the SYSC register definition
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:28 ` Santosh Shilimkar
-1 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:28 UTC (permalink / raw)
To: Shubhrajyoti D
Cc: linux-omap, linux-i2c, linux-arm-kernel, khilman, rnayak, balajitk
On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
> The SYSC register should not accessed in the driver removing the
> define from the driver.
>
> Signed-off-by: Shubhrajyoti D<shubhrajyoti@ti.com>
Looks good.
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCHV2 4/5] OMAP: I2C: Remove the SYSC register definition
@ 2011-07-21 11:28 ` Santosh Shilimkar
0 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:28 UTC (permalink / raw)
To: linux-arm-kernel
On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
> The SYSC register should not accessed in the driver removing the
> define from the driver.
>
> Signed-off-by: Shubhrajyoti D<shubhrajyoti@ti.com>
Looks good.
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCHV2 5/5] OMAP: I2C: Restore only if context is lost
2011-07-21 11:09 ` Shubhrajyoti D
@ 2011-07-21 11:30 ` Santosh Shilimkar
-1 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:30 UTC (permalink / raw)
To: Shubhrajyoti D
Cc: linux-omap, linux-i2c, linux-arm-kernel, khilman, rnayak, balajitk
On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
> Currently restore is done always.
> Adding conditional restore. The restore is done only if the context is lost.
>
Minor comment. You may want to say 'i2c register restore'
instead of just 'restore'
> Signed-off-by: Shubhrajyoti D<shubhrajyoti@ti.com>
o.w
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCHV2 5/5] OMAP: I2C: Restore only if context is lost
@ 2011-07-21 11:30 ` Santosh Shilimkar
0 siblings, 0 replies; 26+ messages in thread
From: Santosh Shilimkar @ 2011-07-21 11:30 UTC (permalink / raw)
To: linux-arm-kernel
On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
> Currently restore is done always.
> Adding conditional restore. The restore is done only if the context is lost.
>
Minor comment. You may want to say 'i2c register restore'
instead of just 'restore'
> Signed-off-by: Shubhrajyoti D<shubhrajyoti@ti.com>
o.w
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCHV2 2/5] OMAP: I2C: Reset support
2011-07-21 11:19 ` Santosh Shilimkar
@ 2011-07-21 12:02 ` Shubhrajyoti
-1 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti @ 2011-07-21 12:02 UTC (permalink / raw)
To: Santosh Shilimkar
Cc: linux-omap, linux-i2c, linux-arm-kernel, khilman, rnayak, balajitk
On Thursday 21 July 2011 04:49 PM, Santosh Shilimkar wrote:
> On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
>> Under some error conditions the i2c driver may do a reset
>> adding support in the platform.
>>
>> Signed-off-by: Shubhrajyoti D<shubhrajyoti@ti.com>
>> ---
> As commented on 1/5, this one should be folded
> with 1/5 unless and until you have some valid reason.
Thanks for your review.
Will combine the patches and send.
>
> Regards
> Santosh
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCHV2 2/5] OMAP: I2C: Reset support
@ 2011-07-21 12:02 ` Shubhrajyoti
0 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti @ 2011-07-21 12:02 UTC (permalink / raw)
To: linux-arm-kernel
On Thursday 21 July 2011 04:49 PM, Santosh Shilimkar wrote:
> On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
>> Under some error conditions the i2c driver may do a reset
>> adding support in the platform.
>>
>> Signed-off-by: Shubhrajyoti D<shubhrajyoti@ti.com>
>> ---
> As commented on 1/5, this one should be folded
> with 1/5 unless and until you have some valid reason.
Thanks for your review.
Will combine the patches and send.
>
> Regards
> Santosh
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCHV2 3/5] OMAP: I2C: Remove the reset in the init path
2011-07-21 11:27 ` Santosh Shilimkar
@ 2011-07-29 11:27 ` Shubhrajyoti
-1 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti @ 2011-07-29 11:27 UTC (permalink / raw)
To: Santosh Shilimkar
Cc: linux-omap, linux-i2c, linux-arm-kernel, khilman, rnayak, balajitk
On Thursday 21 July 2011 04:57 PM, Santosh Shilimkar wrote:
Thanks for your review.
> On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
>
<snip>
>> + /*
>> + * Enabling all wakup sources to stop I2C freezing on
>> + * WFI instruction.
>> + * REVISIT: Some wkup sources might not be needed.
>> + */
> Surely not related to your patch. But the 'REVISIT:' caught
> my attention. Is the comment still valid.
Yes I will look and optimise the settings. Obviously all of them may not
be needed.
Will get back on this.
Also I see that we are not writing it for " < OMAP_I2C_REV_ON_3530_4430"
I will send a patch correcting the same.
>
>> + dev->westate = OMAP_I2C_WE_ALL;
>> + if (dev->rev< OMAP_I2C_REV_ON_3530_4430)
> Space if (dev->rev < OMAP_I2C_REV_ON_3530_4430)
>> + omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
>> + dev->westate);
>> }
>> omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
>>
>> @@ -612,6 +572,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)
> ditto
>> + dev_err(dev->dev, "reset failed\n");
>> + }
>> omap_i2c_init(dev);
>> return -ETIMEDOUT;
>> }
>> @@ -622,6 +587,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 |
> You can fix this one as well.
>> OMAP_I2C_STAT_XUDF)) {
>> + if (dev->device_reset != NULL) {
>> + r = dev->device_reset(dev->dev);
>> + if (r< 0)
> here too.
>> + dev_err(dev->dev, "reset failed\n");
>> + }
>> omap_i2c_init(dev);
>> return -EIO;
>> }
>> @@ -1024,6 +994,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;
>
> Regards
> Santosh
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCHV2 3/5] OMAP: I2C: Remove the reset in the init path
@ 2011-07-29 11:27 ` Shubhrajyoti
0 siblings, 0 replies; 26+ messages in thread
From: Shubhrajyoti @ 2011-07-29 11:27 UTC (permalink / raw)
To: linux-arm-kernel
On Thursday 21 July 2011 04:57 PM, Santosh Shilimkar wrote:
Thanks for your review.
> On 7/21/2011 4:39 PM, Shubhrajyoti D wrote:
>
<snip>
>> + /*
>> + * Enabling all wakup sources to stop I2C freezing on
>> + * WFI instruction.
>> + * REVISIT: Some wkup sources might not be needed.
>> + */
> Surely not related to your patch. But the 'REVISIT:' caught
> my attention. Is the comment still valid.
Yes I will look and optimise the settings. Obviously all of them may not
be needed.
Will get back on this.
Also I see that we are not writing it for " < OMAP_I2C_REV_ON_3530_4430"
I will send a patch correcting the same.
>
>> + dev->westate = OMAP_I2C_WE_ALL;
>> + if (dev->rev< OMAP_I2C_REV_ON_3530_4430)
> Space if (dev->rev < OMAP_I2C_REV_ON_3530_4430)
>> + omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
>> + dev->westate);
>> }
>> omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
>>
>> @@ -612,6 +572,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)
> ditto
>> + dev_err(dev->dev, "reset failed\n");
>> + }
>> omap_i2c_init(dev);
>> return -ETIMEDOUT;
>> }
>> @@ -622,6 +587,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 |
> You can fix this one as well.
>> OMAP_I2C_STAT_XUDF)) {
>> + if (dev->device_reset != NULL) {
>> + r = dev->device_reset(dev->dev);
>> + if (r< 0)
> here too.
>> + dev_err(dev->dev, "reset failed\n");
>> + }
>> omap_i2c_init(dev);
>> return -EIO;
>> }
>> @@ -1024,6 +994,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;
>
> Regards
> Santosh
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2011-07-29 11:27 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-21 11:09 [PATCHV2 0/5] I2C: driver updates Shubhrajyoti D
2011-07-21 11:09 ` Shubhrajyoti D
2011-07-21 11:09 ` [PATCHV2 1/5] OMAP: I2C: Add a device reset field to platform data Shubhrajyoti D
2011-07-21 11:09 ` Shubhrajyoti D
2011-07-21 11:18 ` Santosh Shilimkar
2011-07-21 11:18 ` Santosh Shilimkar
[not found] ` <1311246554-22975-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2011-07-21 11:09 ` [PATCHV2 2/5] OMAP: I2C: Reset support Shubhrajyoti D
2011-07-21 11:09 ` Shubhrajyoti D
2011-07-21 11:19 ` Santosh Shilimkar
2011-07-21 11:19 ` Santosh Shilimkar
2011-07-21 12:02 ` Shubhrajyoti
2011-07-21 12:02 ` Shubhrajyoti
2011-07-21 11:09 ` [PATCHV2 3/5] OMAP: I2C: Remove the reset in the init path Shubhrajyoti D
2011-07-21 11:09 ` Shubhrajyoti D
[not found] ` <1311246554-22975-4-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2011-07-21 11:27 ` Santosh Shilimkar
2011-07-21 11:27 ` Santosh Shilimkar
2011-07-29 11:27 ` Shubhrajyoti
2011-07-29 11:27 ` Shubhrajyoti
2011-07-21 11:09 ` [PATCHV2 4/5] OMAP: I2C: Remove the SYSC register definition Shubhrajyoti D
2011-07-21 11:09 ` Shubhrajyoti D
2011-07-21 11:28 ` Santosh Shilimkar
2011-07-21 11:28 ` Santosh Shilimkar
2011-07-21 11:09 ` [PATCHV2 5/5] OMAP: I2C: Restore only if context is lost Shubhrajyoti D
2011-07-21 11:09 ` Shubhrajyoti D
2011-07-21 11:30 ` Santosh Shilimkar
2011-07-21 11:30 ` Santosh Shilimkar
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.