All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv8 00/13] I2C cleanups
@ 2012-06-18 14:30 ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Shubhrajyoti D


The patch series does the following

- I2C register restore only if context if the context is lost
- Bus busy recovery mechanism.
- the reset is not done in init.
- Adds a patch to use devm_* functions
- Adds a pdata function pointer to do context save restore
- Split the omap_i2c_isr to increase readability
- Make the i2c use SET_RUNTIME_PM_OPS
- Use INIT_COMPLETION instead of init_completion
- Dropping a cleanup and taking few patchs Felipe's series as it may
 not be needed.

This applies on Wolfram's i2c-embedded/for-next branch.
 
Functional testing on omap4sdp and omap3sdp. 

Previous discurssions 
http://www.spinics.net/lists/linux-i2c/msg07748.html

This series mainly is the cleanups rebased on
i2c-embedded/for-next branch.


The following changes since commit 0f009a914b40be8786fa67b1f4345cacc263b48c:

  i2c: tegra: make all resource allocation through devm_* (2012-06-13 16:01:38 +0200)

are available in the git repository at:
  git://gitorious.org/linus-tree/linus-tree.git for_next/i2c_omap

Felipe Balbi (4):
      I2C: OMAP: simplify num_bytes handling
      I2C: OMAP: decrease indentation level on data handling
      I2C: OMAP: add blank lines
      I2C: OMAP: simplify omap_i2c_ack_stat()

Jon Hunter (1):
      I2C: OMAP: Correct I2C revision for OMAP3

Shubhrajyoti D (7):
      I2C: OMAP: I2C register restore only if context is lost
      I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK
      I2C: OMAP: Remove reset at init
      I2C: OMAP: Optimise the remove code
      I2C: OMAP: use devm_* functions
      I2C: OMAP: Use SET_RUNTIME_PM_OPS
      I2C: OMAP: Do not initialise the completion everytime

Vikram Pandita (1):
      I2C: OMAP: Recover from Bus Busy condition

 arch/arm/plat-omap/i2c.c      |    3 +
 drivers/i2c/busses/i2c-omap.c |  261 +++++++++++++++++++++++-----------------
 include/linux/i2c-omap.h      |    1 +
 3 files changed, 154 insertions(+), 111 deletions(-)

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

* [PATCHv8 00/13] I2C cleanups
@ 2012-06-18 14:30 ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel


The patch series does the following

- I2C register restore only if context if the context is lost
- Bus busy recovery mechanism.
- the reset is not done in init.
- Adds a patch to use devm_* functions
- Adds a pdata function pointer to do context save restore
- Split the omap_i2c_isr to increase readability
- Make the i2c use SET_RUNTIME_PM_OPS
- Use INIT_COMPLETION instead of init_completion
- Dropping a cleanup and taking few patchs Felipe's series as it may
 not be needed.

This applies on Wolfram's i2c-embedded/for-next branch.
 
Functional testing on omap4sdp and omap3sdp. 

Previous discurssions 
http://www.spinics.net/lists/linux-i2c/msg07748.html

This series mainly is the cleanups rebased on
i2c-embedded/for-next branch.


The following changes since commit 0f009a914b40be8786fa67b1f4345cacc263b48c:

  i2c: tegra: make all resource allocation through devm_* (2012-06-13 16:01:38 +0200)

are available in the git repository at:
  git://gitorious.org/linus-tree/linus-tree.git for_next/i2c_omap

Felipe Balbi (4):
      I2C: OMAP: simplify num_bytes handling
      I2C: OMAP: decrease indentation level on data handling
      I2C: OMAP: add blank lines
      I2C: OMAP: simplify omap_i2c_ack_stat()

Jon Hunter (1):
      I2C: OMAP: Correct I2C revision for OMAP3

Shubhrajyoti D (7):
      I2C: OMAP: I2C register restore only if context is lost
      I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK
      I2C: OMAP: Remove reset at init
      I2C: OMAP: Optimise the remove code
      I2C: OMAP: use devm_* functions
      I2C: OMAP: Use SET_RUNTIME_PM_OPS
      I2C: OMAP: Do not initialise the completion everytime

Vikram Pandita (1):
      I2C: OMAP: Recover from Bus Busy condition

 arch/arm/plat-omap/i2c.c      |    3 +
 drivers/i2c/busses/i2c-omap.c |  261 +++++++++++++++++++++++-----------------
 include/linux/i2c-omap.h      |    1 +
 3 files changed, 154 insertions(+), 111 deletions(-)

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

* [PATCHv8 01/13] I2C: OMAP: I2C register restore only if context is lost
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30   ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap
  Cc: linux-i2c, linux-arm-kernel, ben-linux, tony, w.sang,
	Shubhrajyoti D, Kevin Hilman

 Currently i2c register restore is done always.
 Adding conditional restore.
 The i2c register restore is done only if the context is lost
 or in case of error to be on the safe side.

Cc: Kevin Hilman <khilman@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 arch/arm/plat-omap/i2c.c      |    3 +++
 drivers/i2c/busses/i2c-omap.c |   35 ++++++++++++++++++++++++++---------
 include/linux/i2c-omap.h      |    1 +
 3 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index db071bc..4ccab07 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -179,6 +179,9 @@ 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->get_context_loss_count = omap_pm_get_dev_context_loss_count;
+
 	pdev = omap_device_build(name, bus_id, oh, pdata,
 			sizeof(struct omap_i2c_bus_platform_data),
 			NULL, 0, 0);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 9895fa7..9a54e88 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -43,6 +43,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
@@ -185,6 +186,7 @@ struct omap_i2c_dev {
 	u32			latency;	/* maximum mpu wkup latency */
 	void			(*set_mpu_wkup_lat)(struct device *dev,
 						    long latency);
+	int			(*get_context_loss_count)(struct device *dev);
 	u32			speed;		/* Speed of bus in kHz */
 	u32			dtrev;		/* extra revision from DT */
 	u32			flags;
@@ -207,6 +209,7 @@ struct omap_i2c_dev {
 	u16			syscstate;
 	u16			westate;
 	u16			errata;
+	int			dev_lost_count;
 };
 
 static const u8 reg_map_ip_v1[] = {
@@ -987,6 +990,7 @@ omap_i2c_probe(struct platform_device *pdev)
 		dev->speed = pdata->clkrate;
 		dev->flags = pdata->flags;
 		dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
+		dev->get_context_loss_count = pdata->get_context_loss_count;
 		dev->dtrev = pdata->rev;
 	}
 
@@ -1128,12 +1132,26 @@ omap_i2c_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM_RUNTIME
+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 int omap_i2c_runtime_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct omap_i2c_dev *_dev = platform_get_drvdata(pdev);
 	u16 iv;
 
+	if (_dev->get_context_loss_count)
+		_dev->dev_lost_count = _dev->get_context_loss_count(dev);
+
 	_dev->iestate = omap_i2c_read_reg(_dev, OMAP_I2C_IE_REG);
 
 	omap_i2c_write_reg(_dev, OMAP_I2C_IE_REG, 0);
@@ -1154,16 +1172,15 @@ static int omap_i2c_runtime_resume(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct omap_i2c_dev *_dev = platform_get_drvdata(pdev);
+	int loss_cnt;
+
+	if (!(_dev->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE))
+		return 0;
 
-	if (_dev->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_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);
+	if (_dev->get_context_loss_count) {
+		loss_cnt = _dev->get_context_loss_count(dev);
+		if (_dev->dev_lost_count != loss_cnt)
+			omap_i2c_restore(_dev);
 	}
 
 	/*
diff --git a/include/linux/i2c-omap.h b/include/linux/i2c-omap.h
index 92a0dc7..c76cbc0 100644
--- a/include/linux/i2c-omap.h
+++ b/include/linux/i2c-omap.h
@@ -35,6 +35,7 @@ struct omap_i2c_bus_platform_data {
 	u32		rev;
 	u32		flags;
 	void		(*set_mpu_wkup_lat)(struct device *dev, long set);
+	int		(*get_context_loss_count)(struct device *dev);
 };
 
 #endif
-- 
1.7.5.4


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

* [PATCHv8 01/13] I2C: OMAP: I2C register restore only if context is lost
@ 2012-06-18 14:30   ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

 Currently i2c register restore is done always.
 Adding conditional restore.
 The i2c register restore is done only if the context is lost
 or in case of error to be on the safe side.

Cc: Kevin Hilman <khilman@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 arch/arm/plat-omap/i2c.c      |    3 +++
 drivers/i2c/busses/i2c-omap.c |   35 ++++++++++++++++++++++++++---------
 include/linux/i2c-omap.h      |    1 +
 3 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index db071bc..4ccab07 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -179,6 +179,9 @@ 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->get_context_loss_count = omap_pm_get_dev_context_loss_count;
+
 	pdev = omap_device_build(name, bus_id, oh, pdata,
 			sizeof(struct omap_i2c_bus_platform_data),
 			NULL, 0, 0);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 9895fa7..9a54e88 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -43,6 +43,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
@@ -185,6 +186,7 @@ struct omap_i2c_dev {
 	u32			latency;	/* maximum mpu wkup latency */
 	void			(*set_mpu_wkup_lat)(struct device *dev,
 						    long latency);
+	int			(*get_context_loss_count)(struct device *dev);
 	u32			speed;		/* Speed of bus in kHz */
 	u32			dtrev;		/* extra revision from DT */
 	u32			flags;
@@ -207,6 +209,7 @@ struct omap_i2c_dev {
 	u16			syscstate;
 	u16			westate;
 	u16			errata;
+	int			dev_lost_count;
 };
 
 static const u8 reg_map_ip_v1[] = {
@@ -987,6 +990,7 @@ omap_i2c_probe(struct platform_device *pdev)
 		dev->speed = pdata->clkrate;
 		dev->flags = pdata->flags;
 		dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
+		dev->get_context_loss_count = pdata->get_context_loss_count;
 		dev->dtrev = pdata->rev;
 	}
 
@@ -1128,12 +1132,26 @@ omap_i2c_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM_RUNTIME
+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 int omap_i2c_runtime_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct omap_i2c_dev *_dev = platform_get_drvdata(pdev);
 	u16 iv;
 
+	if (_dev->get_context_loss_count)
+		_dev->dev_lost_count = _dev->get_context_loss_count(dev);
+
 	_dev->iestate = omap_i2c_read_reg(_dev, OMAP_I2C_IE_REG);
 
 	omap_i2c_write_reg(_dev, OMAP_I2C_IE_REG, 0);
@@ -1154,16 +1172,15 @@ static int omap_i2c_runtime_resume(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct omap_i2c_dev *_dev = platform_get_drvdata(pdev);
+	int loss_cnt;
+
+	if (!(_dev->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE))
+		return 0;
 
-	if (_dev->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_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);
+	if (_dev->get_context_loss_count) {
+		loss_cnt = _dev->get_context_loss_count(dev);
+		if (_dev->dev_lost_count != loss_cnt)
+			omap_i2c_restore(_dev);
 	}
 
 	/*
diff --git a/include/linux/i2c-omap.h b/include/linux/i2c-omap.h
index 92a0dc7..c76cbc0 100644
--- a/include/linux/i2c-omap.h
+++ b/include/linux/i2c-omap.h
@@ -35,6 +35,7 @@ struct omap_i2c_bus_platform_data {
 	u32		rev;
 	u32		flags;
 	void		(*set_mpu_wkup_lat)(struct device *dev, long set);
+	int		(*get_context_loss_count)(struct device *dev);
 };
 
 #endif
-- 
1.7.5.4

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

* [PATCHv8 02/13] I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30   ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap
  Cc: linux-i2c, linux-arm-kernel, ben-linux, tony, w.sang, Shubhrajyoti D

Remove the definition of SYSS_RESETDONE_MASK and use the
one in omap_hwmod.h.

Also fixes the warning
 CC      drivers/i2c/busses/i2c-omap.o
drivers/i2c/busses/i2c-omap.c:163: warning: "SYSS_RESETDONE_MASK" redefined

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 9a54e88..838a0ae 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -159,9 +159,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)
-- 
1.7.5.4


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

* [PATCHv8 02/13] I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK
@ 2012-06-18 14:30   ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the definition of SYSS_RESETDONE_MASK and use the
one in omap_hwmod.h.

Also fixes the warning
 CC      drivers/i2c/busses/i2c-omap.o
drivers/i2c/busses/i2c-omap.c:163: warning: "SYSS_RESETDONE_MASK" redefined

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 9a54e88..838a0ae 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -159,9 +159,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)
-- 
1.7.5.4

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

* [PATCHv8 03/13] I2C: OMAP: Remove reset at init
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30     ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Shubhrajyoti D

The reset in the driver at init is not needed anymore as the
following patch has removed the HWMOD_INIT_NO_RESET flag.
6d3c55f [OMAP: hwmod: fix the i2c-reset timeout during bootup]

This patch does the following
-removes the reset from the probe and implements a omap_i2c_reset
 function to reset.
- Reset is removed from omap_i2c_init, which was called
 not only during probe, but also after time out and error handling.
 omap_i2c_reset is added in those places to effect the reset.

Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 838a0ae..5da91b5 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -269,15 +269,9 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
 				(i2c_dev->regs[reg] << i2c_dev->reg_shift));
 }
 
-static int omap_i2c_init(struct omap_i2c_dev *dev)
+static int omap_i2c_reset(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;
-
 	if (dev->rev >= OMAP_I2C_OMAP1_REV_2) {
 		/* Disable I2C controller before soft reset */
 		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
@@ -315,16 +309,18 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 
 			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;
-			omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
-							dev->westate);
 		}
 	}
+}
+
+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 internal_clk = 0;
+	struct clk *fclk;
+
 	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 
 	if (dev->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) {
@@ -433,6 +429,16 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 			OMAP_I2C_IE_AL)  | ((dev->fifo_size) ?
 				(OMAP_I2C_IE_RDR | OMAP_I2C_IE_XDR) : 0);
 	omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
+	if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
+		/*
+		 * 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;
+		omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
+	}
+
 	if (dev->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) {
 		dev->pscstate = psc;
 		dev->scllstate = scll;
@@ -541,6 +547,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 	dev->buf_len = 0;
 	if (timeout == 0) {
 		dev_err(dev->dev, "controller timed out\n");
+		omap_i2c_reset(dev);
 		omap_i2c_init(dev);
 		return -ETIMEDOUT;
 	}
@@ -551,6 +558,7 @@ 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)) {
+		omap_i2c_reset(dev);
 		omap_i2c_init(dev);
 		return -EIO;
 	}
-- 
1.7.5.4

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

* [PATCHv8 03/13] I2C: OMAP: Remove reset at init
@ 2012-06-18 14:30     ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

The reset in the driver at init is not needed anymore as the
following patch has removed the HWMOD_INIT_NO_RESET flag.
6d3c55f [OMAP: hwmod: fix the i2c-reset timeout during bootup]

This patch does the following
-removes the reset from the probe and implements a omap_i2c_reset
 function to reset.
- Reset is removed from omap_i2c_init, which was called
 not only during probe, but also after time out and error handling.
 omap_i2c_reset is added in those places to effect the reset.

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 838a0ae..5da91b5 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -269,15 +269,9 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
 				(i2c_dev->regs[reg] << i2c_dev->reg_shift));
 }
 
-static int omap_i2c_init(struct omap_i2c_dev *dev)
+static int omap_i2c_reset(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;
-
 	if (dev->rev >= OMAP_I2C_OMAP1_REV_2) {
 		/* Disable I2C controller before soft reset */
 		omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
@@ -315,16 +309,18 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 
 			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;
-			omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
-							dev->westate);
 		}
 	}
+}
+
+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 internal_clk = 0;
+	struct clk *fclk;
+
 	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 
 	if (dev->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) {
@@ -433,6 +429,16 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 			OMAP_I2C_IE_AL)  | ((dev->fifo_size) ?
 				(OMAP_I2C_IE_RDR | OMAP_I2C_IE_XDR) : 0);
 	omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
+	if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
+		/*
+		 * 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;
+		omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate);
+	}
+
 	if (dev->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) {
 		dev->pscstate = psc;
 		dev->scllstate = scll;
@@ -541,6 +547,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 	dev->buf_len = 0;
 	if (timeout == 0) {
 		dev_err(dev->dev, "controller timed out\n");
+		omap_i2c_reset(dev);
 		omap_i2c_init(dev);
 		return -ETIMEDOUT;
 	}
@@ -551,6 +558,7 @@ 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)) {
+		omap_i2c_reset(dev);
 		omap_i2c_init(dev);
 		return -EIO;
 	}
-- 
1.7.5.4

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

* [PATCHv8 04/13] I2C: OMAP: Recover from Bus Busy condition
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30     ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Vikram Pandita, Jon Hunter,
	Shubhrajyoti D

From: Vikram Pandita <vikram.pandita-l0cyMroinI0@public.gmane.org>

In case a peripheral is driving SDA bus low (ie. a start condition), provide
a constant clock output using the test mode of the OMAP I2C controller to
try and clear the bus. Soft reset I2C controller after attempting the bus clear
to ensure that controller is in a good state.

Based upon Vikram Pandita's patch from TI Android 3.0.
I acknowledge the contributions and suggestions of Jon and Hemant.

A couple differences from the original patch ...
1. Add a new function for bus clear
2. Ensure that the CON.I2C_EN bit is set when using the SYSTEST feature to
   output a permanent clock. This bit needs to be set and typically it would
   be set by the unidle function but this is not the case for all OMAP
   generations.
3. Program the SYSTEST setting only the bits we care about. However, restore
   SYSTEST registers to there original state as some OMAP generations do not
   implement perform a soft-reset.
4. Clear the CON register after performing the bus clear, so when we call the
   init function the controller is disabled and the init function will
   re-enable later.

Original patch can be found here:
http://git.omapzoom.org/?p=kernel/omap.git;a=commit;h=a2ab04192ba25e60f95ba1ff3af5601a2d7b5bd1

Signed-off-by: Vikram Pandita <vikram.pandita-l0cyMroinI0@public.gmane.org>
Signed-off-by: Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c |   33 ++++++++++++++++++++++++++++++---
 1 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 5da91b5..7ab9fe1 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -148,16 +148,15 @@ enum {
 #define OMAP_I2C_SCLH_HSSCLH	8
 
 /* I2C System Test Register (OMAP_I2C_SYSTEST): */
-#ifdef DEBUG
 #define OMAP_I2C_SYSTEST_ST_EN		(1 << 15)	/* System test enable */
 #define OMAP_I2C_SYSTEST_FREE		(1 << 14)	/* Free running mode */
 #define OMAP_I2C_SYSTEST_TMODE_MASK	(3 << 12)	/* Test mode select */
-#define OMAP_I2C_SYSTEST_TMODE_SHIFT	(12)		/* Test mode select */
+#define OMAP_I2C_SYSTEST_TMODE_TEST	(2 << 12)	/* Test mode select */
+#define OMAP_I2C_SYSTEST_TMODE_LOOP	(3 << 12)	/* Test mode select */
 #define OMAP_I2C_SYSTEST_SCL_I		(1 << 3)	/* SCL line sense in */
 #define OMAP_I2C_SYSTEST_SCL_O		(1 << 2)	/* SCL line drive out */
 #define OMAP_I2C_SYSTEST_SDA_I		(1 << 1)	/* SDA line sense in */
 #define OMAP_I2C_SYSTEST_SDA_O		(1 << 0)	/* SDA line drive out */
-#endif
 
 /* OCP_SYSCONFIG bit definitions */
 #define SYSC_CLOCKACTIVITY_MASK		(0x3 << 8)
@@ -311,6 +310,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
 							dev->syscstate);
 		}
 	}
+	return 0;
 }
 
 static int omap_i2c_init(struct omap_i2c_dev *dev)
@@ -468,6 +468,31 @@ static int omap_i2c_wait_for_bb(struct omap_i2c_dev *dev)
 }
 
 /*
+ * Bus Clear
+ */
+static int omap_i2c_bus_clear(struct omap_i2c_dev *dev)
+{
+	u16 w;
+
+	/*
+	 * Per the I2C specification, if we are stuck in a bus busy state
+	 * we can attempt a bus clear to try and recover the bus by sending
+	 * at least 9 clock pulses on SCL. Put the I2C in a test mode so it
+	 * will output a continuous clock on SCL.
+	 */
+	w = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG);
+	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
+	omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, (OMAP_I2C_SYSTEST_ST_EN
+			   | OMAP_I2C_SYSTEST_TMODE_TEST));
+	msleep(1);
+	omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, w);
+	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
+	omap_i2c_reset(dev);
+	omap_i2c_init(dev);
+	return omap_i2c_wait_for_bb(dev);
+}
+
+/*
  * Low level master read/write transaction.
  */
 static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
@@ -594,6 +619,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 
 	r = omap_i2c_wait_for_bb(dev);
 	if (r < 0)
+		r = omap_i2c_bus_clear(dev);
+	if (r < 0)
 		goto out;
 
 	if (dev->set_mpu_wkup_lat != NULL)
-- 
1.7.5.4

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

* [PATCHv8 04/13] I2C: OMAP: Recover from Bus Busy condition
@ 2012-06-18 14:30     ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

From: Vikram Pandita <vikram.pandita@ti.com>

In case a peripheral is driving SDA bus low (ie. a start condition), provide
a constant clock output using the test mode of the OMAP I2C controller to
try and clear the bus. Soft reset I2C controller after attempting the bus clear
to ensure that controller is in a good state.

Based upon Vikram Pandita's patch from TI Android 3.0.
I acknowledge the contributions and suggestions of Jon and Hemant.

A couple differences from the original patch ...
1. Add a new function for bus clear
2. Ensure that the CON.I2C_EN bit is set when using the SYSTEST feature to
   output a permanent clock. This bit needs to be set and typically it would
   be set by the unidle function but this is not the case for all OMAP
   generations.
3. Program the SYSTEST setting only the bits we care about. However, restore
   SYSTEST registers to there original state as some OMAP generations do not
   implement perform a soft-reset.
4. Clear the CON register after performing the bus clear, so when we call the
   init function the controller is disabled and the init function will
   re-enable later.

Original patch can be found here:
http://git.omapzoom.org/?p=kernel/omap.git;a=commit;h=a2ab04192ba25e60f95ba1ff3af5601a2d7b5bd1

Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   33 ++++++++++++++++++++++++++++++---
 1 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 5da91b5..7ab9fe1 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -148,16 +148,15 @@ enum {
 #define OMAP_I2C_SCLH_HSSCLH	8
 
 /* I2C System Test Register (OMAP_I2C_SYSTEST): */
-#ifdef DEBUG
 #define OMAP_I2C_SYSTEST_ST_EN		(1 << 15)	/* System test enable */
 #define OMAP_I2C_SYSTEST_FREE		(1 << 14)	/* Free running mode */
 #define OMAP_I2C_SYSTEST_TMODE_MASK	(3 << 12)	/* Test mode select */
-#define OMAP_I2C_SYSTEST_TMODE_SHIFT	(12)		/* Test mode select */
+#define OMAP_I2C_SYSTEST_TMODE_TEST	(2 << 12)	/* Test mode select */
+#define OMAP_I2C_SYSTEST_TMODE_LOOP	(3 << 12)	/* Test mode select */
 #define OMAP_I2C_SYSTEST_SCL_I		(1 << 3)	/* SCL line sense in */
 #define OMAP_I2C_SYSTEST_SCL_O		(1 << 2)	/* SCL line drive out */
 #define OMAP_I2C_SYSTEST_SDA_I		(1 << 1)	/* SDA line sense in */
 #define OMAP_I2C_SYSTEST_SDA_O		(1 << 0)	/* SDA line drive out */
-#endif
 
 /* OCP_SYSCONFIG bit definitions */
 #define SYSC_CLOCKACTIVITY_MASK		(0x3 << 8)
@@ -311,6 +310,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
 							dev->syscstate);
 		}
 	}
+	return 0;
 }
 
 static int omap_i2c_init(struct omap_i2c_dev *dev)
@@ -468,6 +468,31 @@ static int omap_i2c_wait_for_bb(struct omap_i2c_dev *dev)
 }
 
 /*
+ * Bus Clear
+ */
+static int omap_i2c_bus_clear(struct omap_i2c_dev *dev)
+{
+	u16 w;
+
+	/*
+	 * Per the I2C specification, if we are stuck in a bus busy state
+	 * we can attempt a bus clear to try and recover the bus by sending
+	 * at least 9 clock pulses on SCL. Put the I2C in a test mode so it
+	 * will output a continuous clock on SCL.
+	 */
+	w = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG);
+	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
+	omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, (OMAP_I2C_SYSTEST_ST_EN
+			   | OMAP_I2C_SYSTEST_TMODE_TEST));
+	msleep(1);
+	omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, w);
+	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
+	omap_i2c_reset(dev);
+	omap_i2c_init(dev);
+	return omap_i2c_wait_for_bb(dev);
+}
+
+/*
  * Low level master read/write transaction.
  */
 static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
@@ -594,6 +619,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 
 	r = omap_i2c_wait_for_bb(dev);
 	if (r < 0)
+		r = omap_i2c_bus_clear(dev);
+	if (r < 0)
 		goto out;
 
 	if (dev->set_mpu_wkup_lat != NULL)
-- 
1.7.5.4

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

* [PATCHv8 05/13] I2C: OMAP: Optimise the remove code
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30   ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap
  Cc: linux-i2c, linux-arm-kernel, ben-linux, tony, w.sang, Shubhrajyoti D

The omap_i2c_remove function may not be needed after
device exit so the memory could be freed.

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 7ab9fe1..691550a 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1138,8 +1138,7 @@ err_release_region:
 	return r;
 }
 
-static int
-omap_i2c_remove(struct platform_device *pdev)
+static int __devexit omap_i2c_remove(struct platform_device *pdev)
 {
 	struct omap_i2c_dev	*dev = platform_get_drvdata(pdev);
 	struct resource		*mem;
@@ -1236,7 +1235,7 @@ static struct dev_pm_ops omap_i2c_pm_ops = {
 
 static struct platform_driver omap_i2c_driver = {
 	.probe		= omap_i2c_probe,
-	.remove		= omap_i2c_remove,
+	.remove		= __devexit_p(omap_i2c_remove),
 	.driver		= {
 		.name	= "omap_i2c",
 		.owner	= THIS_MODULE,
-- 
1.7.5.4


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

* [PATCHv8 05/13] I2C: OMAP: Optimise the remove code
@ 2012-06-18 14:30   ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

The omap_i2c_remove function may not be needed after
device exit so the memory could be freed.

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 7ab9fe1..691550a 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1138,8 +1138,7 @@ err_release_region:
 	return r;
 }
 
-static int
-omap_i2c_remove(struct platform_device *pdev)
+static int __devexit omap_i2c_remove(struct platform_device *pdev)
 {
 	struct omap_i2c_dev	*dev = platform_get_drvdata(pdev);
 	struct resource		*mem;
@@ -1236,7 +1235,7 @@ static struct dev_pm_ops omap_i2c_pm_ops = {
 
 static struct platform_driver omap_i2c_driver = {
 	.probe		= omap_i2c_probe,
-	.remove		= omap_i2c_remove,
+	.remove		= __devexit_p(omap_i2c_remove),
 	.driver		= {
 		.name	= "omap_i2c",
 		.owner	= THIS_MODULE,
-- 
1.7.5.4

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

* [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30     ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Jon Hunter, Shubhrajyoti D

From: Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>

The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
revision is the same for 3430 and 3530. However, the OMAP3630 device has the
same I2C revision as OMAP4. Correct the revision definition to reflect this.

This patch is based on work done by Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>
Changes from his patch
- Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530

Signed-off-by: Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 691550a..5c3a299 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -50,8 +50,8 @@
 
 /* I2C controller revisions present on specific hardware */
 #define OMAP_I2C_REV_ON_2430		0x36
-#define OMAP_I2C_REV_ON_3430		0x3C
-#define OMAP_I2C_REV_ON_3530_4430	0x40
+#define OMAP_I2C_REV_ON_3430_3530	0x3C
+#define OMAP_I2C_REV_ON_3630_4430	0x40
 
 /* timeout waiting for the controller to respond */
 #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
@@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
 			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
 					   SYSC_AUTOIDLE_MASK);
 
-		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
+		} else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
 			dev->syscstate = SYSC_AUTOIDLE_MASK;
 			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
 			dev->syscstate |= (SYSC_IDLEMODE_SMART <<
@@ -1055,7 +1055,7 @@ omap_i2c_probe(struct platform_device *pdev)
 	if (dev->flags & OMAP_I2C_FLAG_APPLY_ERRATA_I207)
 		dev->errata |= I2C_OMAP_ERRATA_I207;
 
-	if (dev->rev <= OMAP_I2C_REV_ON_3430)
+	if (dev->rev <= OMAP_I2C_REV_ON_3430_3530)
 		dev->errata |= I2C_OMAP_ERRATA_I462;
 
 	if (!(dev->flags & OMAP_I2C_FLAG_NO_FIFO)) {
@@ -1073,7 +1073,7 @@ omap_i2c_probe(struct platform_device *pdev)
 
 		dev->fifo_size = (dev->fifo_size / 2);
 
-		if (dev->rev >= OMAP_I2C_REV_ON_3530_4430)
+		if (dev->rev >= OMAP_I2C_REV_ON_3630_4430)
 			dev->b_hw = 0; /* Disable hardware fixes */
 		else
 			dev->b_hw = 1; /* Enable hardware fixes */
-- 
1.7.5.4

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

* [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
@ 2012-06-18 14:30     ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

From: Jon Hunter <jon-hunter@ti.com>

The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
revision is the same for 3430 and 3530. However, the OMAP3630 device has the
same I2C revision as OMAP4. Correct the revision definition to reflect this.

This patch is based on work done by Jon Hunter <jon-hunter@ti.com>
Changes from his patch
- Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 691550a..5c3a299 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -50,8 +50,8 @@
 
 /* I2C controller revisions present on specific hardware */
 #define OMAP_I2C_REV_ON_2430		0x36
-#define OMAP_I2C_REV_ON_3430		0x3C
-#define OMAP_I2C_REV_ON_3530_4430	0x40
+#define OMAP_I2C_REV_ON_3430_3530	0x3C
+#define OMAP_I2C_REV_ON_3630_4430	0x40
 
 /* timeout waiting for the controller to respond */
 #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
@@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
 			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
 					   SYSC_AUTOIDLE_MASK);
 
-		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
+		} else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
 			dev->syscstate = SYSC_AUTOIDLE_MASK;
 			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
 			dev->syscstate |= (SYSC_IDLEMODE_SMART <<
@@ -1055,7 +1055,7 @@ omap_i2c_probe(struct platform_device *pdev)
 	if (dev->flags & OMAP_I2C_FLAG_APPLY_ERRATA_I207)
 		dev->errata |= I2C_OMAP_ERRATA_I207;
 
-	if (dev->rev <= OMAP_I2C_REV_ON_3430)
+	if (dev->rev <= OMAP_I2C_REV_ON_3430_3530)
 		dev->errata |= I2C_OMAP_ERRATA_I462;
 
 	if (!(dev->flags & OMAP_I2C_FLAG_NO_FIFO)) {
@@ -1073,7 +1073,7 @@ omap_i2c_probe(struct platform_device *pdev)
 
 		dev->fifo_size = (dev->fifo_size / 2);
 
-		if (dev->rev >= OMAP_I2C_REV_ON_3530_4430)
+		if (dev->rev >= OMAP_I2C_REV_ON_3630_4430)
 			dev->b_hw = 0; /* Disable hardware fixes */
 		else
 			dev->b_hw = 1; /* Enable hardware fixes */
-- 
1.7.5.4

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

* [PATCHv8 07/13] I2C: OMAP: use devm_* functions
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30     ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Shubhrajyoti D

The various devm_* functions allocate memory that is released when a driver
detaches. This patch uses devm_kzalloc, devm_request_and_ioremap for data
that is allocated in the probe function of a platform device and is only
freed in the remove function.

Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c |   33 +++++++++------------------------
 1 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 5c3a299..326b99c 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -975,7 +975,7 @@ omap_i2c_probe(struct platform_device *pdev)
 {
 	struct omap_i2c_dev	*dev;
 	struct i2c_adapter	*adap;
-	struct resource		*mem, *irq, *ioarea;
+	struct resource		*mem, *irq;
 	struct omap_i2c_bus_platform_data *pdata = pdev->dev.platform_data;
 	struct device_node	*node = pdev->dev.of_node;
 	const struct of_device_id *match;
@@ -994,17 +994,16 @@ omap_i2c_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	ioarea = request_mem_region(mem->start, resource_size(mem),
-			pdev->name);
-	if (!ioarea) {
-		dev_err(&pdev->dev, "I2C region already claimed\n");
-		return -EBUSY;
+	dev = devm_kzalloc(&pdev->dev, sizeof(struct omap_i2c_dev), GFP_KERNEL);
+	if (!dev) {
+		dev_err(&pdev->dev, "Menory allocation failed\n");
+		return -ENOMEM;
 	}
 
-	dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL);
-	if (!dev) {
-		r = -ENOMEM;
-		goto err_release_region;
+	dev->base = devm_request_and_ioremap(&pdev->dev, mem);
+	if (!dev->base) {
+		dev_err(&pdev->dev, "I2C region already claimed\n");
+		return -ENOMEM;
 	}
 
 	match = of_match_device(of_match_ptr(omap_i2c_of_match), &pdev->dev);
@@ -1028,11 +1027,6 @@ omap_i2c_probe(struct platform_device *pdev)
 
 	dev->dev = &pdev->dev;
 	dev->irq = irq->start;
-	dev->base = ioremap(mem->start, resource_size(mem));
-	if (!dev->base) {
-		r = -ENOMEM;
-		goto err_free_mem;
-	}
 
 	platform_set_drvdata(pdev, dev);
 
@@ -1127,13 +1121,9 @@ err_free_irq:
 err_unuse_clocks:
 	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 	pm_runtime_put(dev->dev);
-	iounmap(dev->base);
 	pm_runtime_disable(&pdev->dev);
 err_free_mem:
 	platform_set_drvdata(pdev, NULL);
-	kfree(dev);
-err_release_region:
-	release_mem_region(mem->start, resource_size(mem));
 
 	return r;
 }
@@ -1141,7 +1131,6 @@ err_release_region:
 static int __devexit omap_i2c_remove(struct platform_device *pdev)
 {
 	struct omap_i2c_dev	*dev = platform_get_drvdata(pdev);
-	struct resource		*mem;
 	int ret;
 
 	platform_set_drvdata(pdev, NULL);
@@ -1155,10 +1144,6 @@ static int __devexit omap_i2c_remove(struct platform_device *pdev)
 	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	iounmap(dev->base);
-	kfree(dev);
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(mem->start, resource_size(mem));
 	return 0;
 }
 
-- 
1.7.5.4

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

* [PATCHv8 07/13] I2C: OMAP: use devm_* functions
@ 2012-06-18 14:30     ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

The various devm_* functions allocate memory that is released when a driver
detaches. This patch uses devm_kzalloc, devm_request_and_ioremap for data
that is allocated in the probe function of a platform device and is only
freed in the remove function.

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 5c3a299..326b99c 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -975,7 +975,7 @@ omap_i2c_probe(struct platform_device *pdev)
 {
 	struct omap_i2c_dev	*dev;
 	struct i2c_adapter	*adap;
-	struct resource		*mem, *irq, *ioarea;
+	struct resource		*mem, *irq;
 	struct omap_i2c_bus_platform_data *pdata = pdev->dev.platform_data;
 	struct device_node	*node = pdev->dev.of_node;
 	const struct of_device_id *match;
@@ -994,17 +994,16 @@ omap_i2c_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	ioarea = request_mem_region(mem->start, resource_size(mem),
-			pdev->name);
-	if (!ioarea) {
-		dev_err(&pdev->dev, "I2C region already claimed\n");
-		return -EBUSY;
+	dev = devm_kzalloc(&pdev->dev, sizeof(struct omap_i2c_dev), GFP_KERNEL);
+	if (!dev) {
+		dev_err(&pdev->dev, "Menory allocation failed\n");
+		return -ENOMEM;
 	}
 
-	dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL);
-	if (!dev) {
-		r = -ENOMEM;
-		goto err_release_region;
+	dev->base = devm_request_and_ioremap(&pdev->dev, mem);
+	if (!dev->base) {
+		dev_err(&pdev->dev, "I2C region already claimed\n");
+		return -ENOMEM;
 	}
 
 	match = of_match_device(of_match_ptr(omap_i2c_of_match), &pdev->dev);
@@ -1028,11 +1027,6 @@ omap_i2c_probe(struct platform_device *pdev)
 
 	dev->dev = &pdev->dev;
 	dev->irq = irq->start;
-	dev->base = ioremap(mem->start, resource_size(mem));
-	if (!dev->base) {
-		r = -ENOMEM;
-		goto err_free_mem;
-	}
 
 	platform_set_drvdata(pdev, dev);
 
@@ -1127,13 +1121,9 @@ err_free_irq:
 err_unuse_clocks:
 	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 	pm_runtime_put(dev->dev);
-	iounmap(dev->base);
 	pm_runtime_disable(&pdev->dev);
 err_free_mem:
 	platform_set_drvdata(pdev, NULL);
-	kfree(dev);
-err_release_region:
-	release_mem_region(mem->start, resource_size(mem));
 
 	return r;
 }
@@ -1141,7 +1131,6 @@ err_release_region:
 static int __devexit omap_i2c_remove(struct platform_device *pdev)
 {
 	struct omap_i2c_dev	*dev = platform_get_drvdata(pdev);
-	struct resource		*mem;
 	int ret;
 
 	platform_set_drvdata(pdev, NULL);
@@ -1155,10 +1144,6 @@ static int __devexit omap_i2c_remove(struct platform_device *pdev)
 	omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	iounmap(dev->base);
-	kfree(dev);
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(mem->start, resource_size(mem));
 	return 0;
 }
 
-- 
1.7.5.4

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

* [PATCHv8 08/13] I2C: OMAP: Use SET_RUNTIME_PM_OPS
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30     ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Shubhrajyoti D

Use SET_RUNTIME_PM_OPS macro to set runtime functions.

Acked-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 326b99c..6f8e7d9 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1147,6 +1147,7 @@ static int __devexit omap_i2c_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
 #ifdef CONFIG_PM_RUNTIME
 static void omap_i2c_restore(struct omap_i2c_dev *dev)
 {
@@ -1208,15 +1209,16 @@ static int omap_i2c_runtime_resume(struct device *dev)
 
 	return 0;
 }
+#endif /* CONFIG_PM_RUNTIME */
 
 static struct dev_pm_ops omap_i2c_pm_ops = {
-	.runtime_suspend = omap_i2c_runtime_suspend,
-	.runtime_resume = omap_i2c_runtime_resume,
+	SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend,
+			   omap_i2c_runtime_resume, NULL)
 };
 #define OMAP_I2C_PM_OPS (&omap_i2c_pm_ops)
 #else
 #define OMAP_I2C_PM_OPS NULL
-#endif
+#endif /* CONFIG_PM */
 
 static struct platform_driver omap_i2c_driver = {
 	.probe		= omap_i2c_probe,
-- 
1.7.5.4

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

* [PATCHv8 08/13] I2C: OMAP: Use SET_RUNTIME_PM_OPS
@ 2012-06-18 14:30     ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

Use SET_RUNTIME_PM_OPS macro to set runtime functions.

Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 326b99c..6f8e7d9 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1147,6 +1147,7 @@ static int __devexit omap_i2c_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
 #ifdef CONFIG_PM_RUNTIME
 static void omap_i2c_restore(struct omap_i2c_dev *dev)
 {
@@ -1208,15 +1209,16 @@ static int omap_i2c_runtime_resume(struct device *dev)
 
 	return 0;
 }
+#endif /* CONFIG_PM_RUNTIME */
 
 static struct dev_pm_ops omap_i2c_pm_ops = {
-	.runtime_suspend = omap_i2c_runtime_suspend,
-	.runtime_resume = omap_i2c_runtime_resume,
+	SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend,
+			   omap_i2c_runtime_resume, NULL)
 };
 #define OMAP_I2C_PM_OPS (&omap_i2c_pm_ops)
 #else
 #define OMAP_I2C_PM_OPS NULL
-#endif
+#endif /* CONFIG_PM */
 
 static struct platform_driver omap_i2c_driver = {
 	.probe		= omap_i2c_probe,
-- 
1.7.5.4

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

* [PATCHv8 09/13] I2C: OMAP: Do not initialise the completion everytime
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30   ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap
  Cc: linux-i2c, linux-arm-kernel, ben-linux, tony, w.sang, Shubhrajyoti D

Use INIT_COMPLETION instead of init_completion in transfer.

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 6f8e7d9..e24eb1f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -521,7 +521,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 	w |= OMAP_I2C_BUF_RXFIF_CLR | OMAP_I2C_BUF_TXFIF_CLR;
 	omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, w);
 
-	init_completion(&dev->cmd_complete);
+	INIT_COMPLETION(dev->cmd_complete);
 	dev->cmd_err = 0;
 
 	w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT;
@@ -1029,6 +1029,7 @@ omap_i2c_probe(struct platform_device *pdev)
 	dev->irq = irq->start;
 
 	platform_set_drvdata(pdev, dev);
+	init_completion(&dev->cmd_complete);
 
 	dev->reg_shift = (dev->flags >> OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
 
-- 
1.7.5.4


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

* [PATCHv8 09/13] I2C: OMAP: Do not initialise the completion everytime
@ 2012-06-18 14:30   ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

Use INIT_COMPLETION instead of init_completion in transfer.

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 6f8e7d9..e24eb1f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -521,7 +521,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 	w |= OMAP_I2C_BUF_RXFIF_CLR | OMAP_I2C_BUF_TXFIF_CLR;
 	omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, w);
 
-	init_completion(&dev->cmd_complete);
+	INIT_COMPLETION(dev->cmd_complete);
 	dev->cmd_err = 0;
 
 	w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT;
@@ -1029,6 +1029,7 @@ omap_i2c_probe(struct platform_device *pdev)
 	dev->irq = irq->start;
 
 	platform_set_drvdata(pdev, dev);
+	init_completion(&dev->cmd_complete);
 
 	dev->reg_shift = (dev->flags >> OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
 
-- 
1.7.5.4

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

* [PATCHv8 10/13] I2C: OMAP: simplify num_bytes handling
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30     ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Felipe Balbi, Shubhrajyoti D

From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>

trivial patch, no functional changes

Signed-off-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
Reviewed-by : Santosh Shilimkar <santosh.shilimkar-l0cyMroinI0@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index e24eb1f..080193a 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -844,8 +844,7 @@ complete:
 							OMAP_I2C_BUFSTAT_REG)
 							>> 8) & 0x3F;
 			}
-			while (num_bytes) {
-				num_bytes--;
+			while (num_bytes--) {
 				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
 				if (dev->buf_len) {
 					*dev->buf++ = w;
@@ -887,8 +886,7 @@ complete:
 							OMAP_I2C_BUFSTAT_REG)
 							& 0x3F;
 			}
-			while (num_bytes) {
-				num_bytes--;
+			while (num_bytes--) {
 				w = 0;
 				if (dev->buf_len) {
 					w = *dev->buf++;
-- 
1.7.5.4

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

* [PATCHv8 10/13] I2C: OMAP: simplify num_bytes handling
@ 2012-06-18 14:30     ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

From: Felipe Balbi <balbi@ti.com>

trivial patch, no functional changes

Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index e24eb1f..080193a 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -844,8 +844,7 @@ complete:
 							OMAP_I2C_BUFSTAT_REG)
 							>> 8) & 0x3F;
 			}
-			while (num_bytes) {
-				num_bytes--;
+			while (num_bytes--) {
 				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
 				if (dev->buf_len) {
 					*dev->buf++ = w;
@@ -887,8 +886,7 @@ complete:
 							OMAP_I2C_BUFSTAT_REG)
 							& 0x3F;
 			}
-			while (num_bytes) {
-				num_bytes--;
+			while (num_bytes--) {
 				w = 0;
 				if (dev->buf_len) {
 					w = *dev->buf++;
-- 
1.7.5.4

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

* [PATCHv8 11/13] I2C: OMAP: decrease indentation level on data handling
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30     ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Felipe Balbi, Shubhrajyoti D

From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>

trivial patch, no functional changes.

Signed-off-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
Reviewed-by : Santosh Shilimkar <santosh.shilimkar-l0cyMroinI0@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c |   63 ++++++++++++++++++++---------------------
 1 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 080193a..0e0ab8f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -845,22 +845,7 @@ complete:
 							>> 8) & 0x3F;
 			}
 			while (num_bytes--) {
-				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
-				if (dev->buf_len) {
-					*dev->buf++ = w;
-					dev->buf_len--;
-					/*
-					 * Data reg in 2430, omap3 and
-					 * omap4 is 8 bit wide
-					 */
-					if (dev->flags &
-						 OMAP_I2C_FLAG_16BIT_DATA_REG) {
-						if (dev->buf_len) {
-							*dev->buf++ = w >> 8;
-							dev->buf_len--;
-						}
-					}
-				} else {
+				if (!dev->buf_len) {
 					if (stat & OMAP_I2C_STAT_RRDY)
 						dev_err(dev->dev,
 							"RRDY IRQ while no data"
@@ -871,6 +856,21 @@ complete:
 								" requested\n");
 					break;
 				}
+
+				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
+				*dev->buf++ = w;
+				dev->buf_len--;
+				/*
+				 * Data reg in 2430, omap3 and
+				 * omap4 is 8 bit wide
+				 */
+				if (dev->flags &
+						OMAP_I2C_FLAG_16BIT_DATA_REG) {
+					if (dev->buf_len) {
+						*dev->buf++ = w >> 8;
+						dev->buf_len--;
+					}
+				}
 			}
 			omap_i2c_ack_stat(dev,
 				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
@@ -887,22 +887,7 @@ complete:
 							& 0x3F;
 			}
 			while (num_bytes--) {
-				w = 0;
-				if (dev->buf_len) {
-					w = *dev->buf++;
-					dev->buf_len--;
-					/*
-					 * Data reg in 2430, omap3 and
-					 * omap4 is 8 bit wide
-					 */
-					if (dev->flags &
-						 OMAP_I2C_FLAG_16BIT_DATA_REG) {
-						if (dev->buf_len) {
-							w |= *dev->buf++ << 8;
-							dev->buf_len--;
-						}
-					}
-				} else {
+				if (!dev->buf_len) {
 					if (stat & OMAP_I2C_STAT_XRDY)
 						dev_err(dev->dev,
 							"XRDY IRQ while no "
@@ -914,6 +899,20 @@ complete:
 					break;
 				}
 
+				w = *dev->buf++;
+				dev->buf_len--;
+				/*
+				 * Data reg in 2430, omap3 and
+				 * omap4 is 8 bit wide
+				 */
+				if (dev->flags &
+						OMAP_I2C_FLAG_16BIT_DATA_REG) {
+					if (dev->buf_len) {
+						w |= *dev->buf++ << 8;
+						dev->buf_len--;
+					}
+				}
+
 				if ((dev->errata & I2C_OMAP_ERRATA_I462) &&
 				    errata_omap3_i462(dev, &stat, &err))
 					goto complete;
-- 
1.7.5.4

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

* [PATCHv8 11/13] I2C: OMAP: decrease indentation level on data handling
@ 2012-06-18 14:30     ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

From: Felipe Balbi <balbi@ti.com>

trivial patch, no functional changes.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   63 ++++++++++++++++++++---------------------
 1 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 080193a..0e0ab8f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -845,22 +845,7 @@ complete:
 							>> 8) & 0x3F;
 			}
 			while (num_bytes--) {
-				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
-				if (dev->buf_len) {
-					*dev->buf++ = w;
-					dev->buf_len--;
-					/*
-					 * Data reg in 2430, omap3 and
-					 * omap4 is 8 bit wide
-					 */
-					if (dev->flags &
-						 OMAP_I2C_FLAG_16BIT_DATA_REG) {
-						if (dev->buf_len) {
-							*dev->buf++ = w >> 8;
-							dev->buf_len--;
-						}
-					}
-				} else {
+				if (!dev->buf_len) {
 					if (stat & OMAP_I2C_STAT_RRDY)
 						dev_err(dev->dev,
 							"RRDY IRQ while no data"
@@ -871,6 +856,21 @@ complete:
 								" requested\n");
 					break;
 				}
+
+				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
+				*dev->buf++ = w;
+				dev->buf_len--;
+				/*
+				 * Data reg in 2430, omap3 and
+				 * omap4 is 8 bit wide
+				 */
+				if (dev->flags &
+						OMAP_I2C_FLAG_16BIT_DATA_REG) {
+					if (dev->buf_len) {
+						*dev->buf++ = w >> 8;
+						dev->buf_len--;
+					}
+				}
 			}
 			omap_i2c_ack_stat(dev,
 				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
@@ -887,22 +887,7 @@ complete:
 							& 0x3F;
 			}
 			while (num_bytes--) {
-				w = 0;
-				if (dev->buf_len) {
-					w = *dev->buf++;
-					dev->buf_len--;
-					/*
-					 * Data reg in 2430, omap3 and
-					 * omap4 is 8 bit wide
-					 */
-					if (dev->flags &
-						 OMAP_I2C_FLAG_16BIT_DATA_REG) {
-						if (dev->buf_len) {
-							w |= *dev->buf++ << 8;
-							dev->buf_len--;
-						}
-					}
-				} else {
+				if (!dev->buf_len) {
 					if (stat & OMAP_I2C_STAT_XRDY)
 						dev_err(dev->dev,
 							"XRDY IRQ while no "
@@ -914,6 +899,20 @@ complete:
 					break;
 				}
 
+				w = *dev->buf++;
+				dev->buf_len--;
+				/*
+				 * Data reg in 2430, omap3 and
+				 * omap4 is 8 bit wide
+				 */
+				if (dev->flags &
+						OMAP_I2C_FLAG_16BIT_DATA_REG) {
+					if (dev->buf_len) {
+						w |= *dev->buf++ << 8;
+						dev->buf_len--;
+					}
+				}
+
 				if ((dev->errata & I2C_OMAP_ERRATA_I462) &&
 				    errata_omap3_i462(dev, &stat, &err))
 					goto complete;
-- 
1.7.5.4

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

* [PATCHv8 12/13] I2C: OMAP: add blank lines
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30   ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap
  Cc: linux-i2c, linux-arm-kernel, ben-linux, tony, w.sang,
	Felipe Balbi, Shubhrajyoti D

From: Felipe Balbi <balbi@ti.com>

trivial patch to aid readability. No functional
changes.

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 0e0ab8f..6a79089 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -818,6 +818,7 @@ complete:
 			dev_err(dev->dev, "Arbitration lost\n");
 			err |= OMAP_I2C_STAT_AL;
 		}
+
 		/*
 		 * ProDB0017052: Clear ARDY bit twice
 		 */
@@ -830,6 +831,7 @@ complete:
 			omap_i2c_complete_cmd(dev, err);
 			return IRQ_HANDLED;
 		}
+
 		if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
 			u8 num_bytes = 1;
 
@@ -876,6 +878,7 @@ complete:
 				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
 			continue;
 		}
+
 		if (stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)) {
 			u8 num_bytes = 1;
 			if (dev->fifo_size) {
@@ -923,10 +926,12 @@ complete:
 				stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
 			continue;
 		}
+
 		if (stat & OMAP_I2C_STAT_ROVR) {
 			dev_err(dev->dev, "Receive overrun\n");
 			dev->cmd_err |= OMAP_I2C_STAT_ROVR;
 		}
+
 		if (stat & OMAP_I2C_STAT_XUDF) {
 			dev_err(dev->dev, "Transmit underflow\n");
 			dev->cmd_err |= OMAP_I2C_STAT_XUDF;
-- 
1.7.5.4


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

* [PATCHv8 12/13] I2C: OMAP: add blank lines
@ 2012-06-18 14:30   ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

From: Felipe Balbi <balbi@ti.com>

trivial patch to aid readability. No functional
changes.

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

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 0e0ab8f..6a79089 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -818,6 +818,7 @@ complete:
 			dev_err(dev->dev, "Arbitration lost\n");
 			err |= OMAP_I2C_STAT_AL;
 		}
+
 		/*
 		 * ProDB0017052: Clear ARDY bit twice
 		 */
@@ -830,6 +831,7 @@ complete:
 			omap_i2c_complete_cmd(dev, err);
 			return IRQ_HANDLED;
 		}
+
 		if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
 			u8 num_bytes = 1;
 
@@ -876,6 +878,7 @@ complete:
 				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
 			continue;
 		}
+
 		if (stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)) {
 			u8 num_bytes = 1;
 			if (dev->fifo_size) {
@@ -923,10 +926,12 @@ complete:
 				stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
 			continue;
 		}
+
 		if (stat & OMAP_I2C_STAT_ROVR) {
 			dev_err(dev->dev, "Receive overrun\n");
 			dev->cmd_err |= OMAP_I2C_STAT_ROVR;
 		}
+
 		if (stat & OMAP_I2C_STAT_XUDF) {
 			dev_err(dev->dev, "Transmit underflow\n");
 			dev->cmd_err |= OMAP_I2C_STAT_XUDF;
-- 
1.7.5.4

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

* [PATCHv8 13/13] I2C: OMAP: simplify omap_i2c_ack_stat()
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 14:30     ` Shubhrajyoti D
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Felipe Balbi, Shubhrajyoti D

From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>

stat & BIT(1) is the same as BIT(1), so let's
simplify things a bit by removing "stat &" from
all omap_i2c_ack_stat() calls.

Signed-off-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
Reviewed-by : Santosh Shilimkar <santosh.shilimkar-l0cyMroinI0@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 6a79089..bac6305 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -763,7 +763,7 @@ static int errata_omap3_i462(struct omap_i2c_dev *dev, u16 *stat, int *err)
 
 	while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) {
 		if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
-			omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY |
+			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
 							OMAP_I2C_STAT_XDR));
 			return -ETIMEDOUT;
 		}
@@ -824,10 +824,11 @@ complete:
 		 */
 		if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
 					OMAP_I2C_STAT_AL)) {
-			omap_i2c_ack_stat(dev, stat &
-				(OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
-				OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR |
-				OMAP_I2C_STAT_ARDY));
+			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
+						OMAP_I2C_STAT_RDR |
+						OMAP_I2C_STAT_XRDY |
+						OMAP_I2C_STAT_XDR |
+						OMAP_I2C_STAT_ARDY));
 			omap_i2c_complete_cmd(dev, err);
 			return IRQ_HANDLED;
 		}
@@ -874,8 +875,8 @@ complete:
 					}
 				}
 			}
-			omap_i2c_ack_stat(dev,
-				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
+			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
+						OMAP_I2C_STAT_RDR));
 			continue;
 		}
 
@@ -922,8 +923,8 @@ complete:
 
 				omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
 			}
-			omap_i2c_ack_stat(dev,
-				stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
+			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
+						OMAP_I2C_STAT_XDR));
 			continue;
 		}
 
-- 
1.7.5.4

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

* [PATCHv8 13/13] I2C: OMAP: simplify omap_i2c_ack_stat()
@ 2012-06-18 14:30     ` Shubhrajyoti D
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti D @ 2012-06-18 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

From: Felipe Balbi <balbi@ti.com>

stat & BIT(1) is the same as BIT(1), so let's
simplify things a bit by removing "stat &" from
all omap_i2c_ack_stat() calls.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 6a79089..bac6305 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -763,7 +763,7 @@ static int errata_omap3_i462(struct omap_i2c_dev *dev, u16 *stat, int *err)
 
 	while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) {
 		if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
-			omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY |
+			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
 							OMAP_I2C_STAT_XDR));
 			return -ETIMEDOUT;
 		}
@@ -824,10 +824,11 @@ complete:
 		 */
 		if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
 					OMAP_I2C_STAT_AL)) {
-			omap_i2c_ack_stat(dev, stat &
-				(OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
-				OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR |
-				OMAP_I2C_STAT_ARDY));
+			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
+						OMAP_I2C_STAT_RDR |
+						OMAP_I2C_STAT_XRDY |
+						OMAP_I2C_STAT_XDR |
+						OMAP_I2C_STAT_ARDY));
 			omap_i2c_complete_cmd(dev, err);
 			return IRQ_HANDLED;
 		}
@@ -874,8 +875,8 @@ complete:
 					}
 				}
 			}
-			omap_i2c_ack_stat(dev,
-				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
+			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
+						OMAP_I2C_STAT_RDR));
 			continue;
 		}
 
@@ -922,8 +923,8 @@ complete:
 
 				omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
 			}
-			omap_i2c_ack_stat(dev,
-				stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
+			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
+						OMAP_I2C_STAT_XDR));
 			continue;
 		}
 
-- 
1.7.5.4

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

* Re: [PATCHv8 10/13] I2C: OMAP: simplify num_bytes handling
  2012-06-18 14:30     ` Shubhrajyoti D
@ 2012-06-18 15:22         ` Wolfram Sang
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-18 15:22 UTC (permalink / raw)
  To: Shubhrajyoti D
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	Felipe Balbi

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

On Mon, Jun 18, 2012 at 08:00:25PM +0530, Shubhrajyoti D wrote:
> From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
> 
> trivial patch, no functional changes

Wrong. This patch does change some behaviour, are you aware of that?

So, please check if the side-effect is affectong the code and adapt the
commit message, if everything is okay.

> 
> Signed-off-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
> Reviewed-by : Santosh Shilimkar <santosh.shilimkar-l0cyMroinI0@public.gmane.org>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-omap.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index e24eb1f..080193a 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -844,8 +844,7 @@ complete:
>  							OMAP_I2C_BUFSTAT_REG)
>  							>> 8) & 0x3F;
>  			}
> -			while (num_bytes) {
> -				num_bytes--;
> +			while (num_bytes--) {
>  				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
>  				if (dev->buf_len) {
>  					*dev->buf++ = w;
> @@ -887,8 +886,7 @@ complete:
>  							OMAP_I2C_BUFSTAT_REG)
>  							& 0x3F;
>  			}
> -			while (num_bytes) {
> -				num_bytes--;
> +			while (num_bytes--) {
>  				w = 0;
>  				if (dev->buf_len) {
>  					w = *dev->buf++;
> -- 
> 1.7.5.4
> 

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

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

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

* [PATCHv8 10/13] I2C: OMAP: simplify num_bytes handling
@ 2012-06-18 15:22         ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-18 15:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 18, 2012 at 08:00:25PM +0530, Shubhrajyoti D wrote:
> From: Felipe Balbi <balbi@ti.com>
> 
> trivial patch, no functional changes

Wrong. This patch does change some behaviour, are you aware of that?

So, please check if the side-effect is affectong the code and adapt the
commit message, if everything is okay.

> 
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> Reviewed-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> ---
>  drivers/i2c/busses/i2c-omap.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index e24eb1f..080193a 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -844,8 +844,7 @@ complete:
>  							OMAP_I2C_BUFSTAT_REG)
>  							>> 8) & 0x3F;
>  			}
> -			while (num_bytes) {
> -				num_bytes--;
> +			while (num_bytes--) {
>  				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
>  				if (dev->buf_len) {
>  					*dev->buf++ = w;
> @@ -887,8 +886,7 @@ complete:
>  							OMAP_I2C_BUFSTAT_REG)
>  							& 0x3F;
>  			}
> -			while (num_bytes) {
> -				num_bytes--;
> +			while (num_bytes--) {
>  				w = 0;
>  				if (dev->buf_len) {
>  					w = *dev->buf++;
> -- 
> 1.7.5.4
> 

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

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

* Re: [PATCHv8 11/13] I2C: OMAP: decrease indentation level on data handling
  2012-06-18 14:30     ` Shubhrajyoti D
@ 2012-06-18 15:25       ` Wolfram Sang
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-18 15:25 UTC (permalink / raw)
  To: Shubhrajyoti D
  Cc: linux-omap, linux-i2c, linux-arm-kernel, ben-linux, tony, Felipe Balbi

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

On Mon, Jun 18, 2012 at 08:00:26PM +0530, Shubhrajyoti D wrote:
> From: Felipe Balbi <balbi@ti.com>
> 
> trivial patch, no functional changes.

This patch seems to be correct, but it is not trivial. In fact, it is
pretty easy to miss a "!" here which can cause subtle bugs.

> 
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> Reviewed-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> ---
>  drivers/i2c/busses/i2c-omap.c |   63 ++++++++++++++++++++---------------------
>  1 files changed, 31 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 080193a..0e0ab8f 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -845,22 +845,7 @@ complete:
>  							>> 8) & 0x3F;
>  			}
>  			while (num_bytes--) {
> -				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
> -				if (dev->buf_len) {
> -					*dev->buf++ = w;
> -					dev->buf_len--;
> -					/*
> -					 * Data reg in 2430, omap3 and
> -					 * omap4 is 8 bit wide
> -					 */
> -					if (dev->flags &
> -						 OMAP_I2C_FLAG_16BIT_DATA_REG) {
> -						if (dev->buf_len) {
> -							*dev->buf++ = w >> 8;
> -							dev->buf_len--;
> -						}
> -					}
> -				} else {
> +				if (!dev->buf_len) {
>  					if (stat & OMAP_I2C_STAT_RRDY)
>  						dev_err(dev->dev,
>  							"RRDY IRQ while no data"
> @@ -871,6 +856,21 @@ complete:
>  								" requested\n");
>  					break;
>  				}
> +
> +				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
> +				*dev->buf++ = w;
> +				dev->buf_len--;
> +				/*
> +				 * Data reg in 2430, omap3 and
> +				 * omap4 is 8 bit wide
> +				 */
> +				if (dev->flags &
> +						OMAP_I2C_FLAG_16BIT_DATA_REG) {
> +					if (dev->buf_len) {
> +						*dev->buf++ = w >> 8;
> +						dev->buf_len--;
> +					}
> +				}
>  			}
>  			omap_i2c_ack_stat(dev,
>  				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
> @@ -887,22 +887,7 @@ complete:
>  							& 0x3F;
>  			}
>  			while (num_bytes--) {
> -				w = 0;
> -				if (dev->buf_len) {
> -					w = *dev->buf++;
> -					dev->buf_len--;
> -					/*
> -					 * Data reg in 2430, omap3 and
> -					 * omap4 is 8 bit wide
> -					 */
> -					if (dev->flags &
> -						 OMAP_I2C_FLAG_16BIT_DATA_REG) {
> -						if (dev->buf_len) {
> -							w |= *dev->buf++ << 8;
> -							dev->buf_len--;
> -						}
> -					}
> -				} else {
> +				if (!dev->buf_len) {
>  					if (stat & OMAP_I2C_STAT_XRDY)
>  						dev_err(dev->dev,
>  							"XRDY IRQ while no "
> @@ -914,6 +899,20 @@ complete:
>  					break;
>  				}
>  
> +				w = *dev->buf++;
> +				dev->buf_len--;
> +				/*
> +				 * Data reg in 2430, omap3 and
> +				 * omap4 is 8 bit wide
> +				 */
> +				if (dev->flags &
> +						OMAP_I2C_FLAG_16BIT_DATA_REG) {
> +					if (dev->buf_len) {
> +						w |= *dev->buf++ << 8;
> +						dev->buf_len--;
> +					}
> +				}
> +
>  				if ((dev->errata & I2C_OMAP_ERRATA_I462) &&
>  				    errata_omap3_i462(dev, &stat, &err))
>  					goto complete;
> -- 
> 1.7.5.4
> 

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

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

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

* [PATCHv8 11/13] I2C: OMAP: decrease indentation level on data handling
@ 2012-06-18 15:25       ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-18 15:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 18, 2012 at 08:00:26PM +0530, Shubhrajyoti D wrote:
> From: Felipe Balbi <balbi@ti.com>
> 
> trivial patch, no functional changes.

This patch seems to be correct, but it is not trivial. In fact, it is
pretty easy to miss a "!" here which can cause subtle bugs.

> 
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> Reviewed-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> ---
>  drivers/i2c/busses/i2c-omap.c |   63 ++++++++++++++++++++---------------------
>  1 files changed, 31 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 080193a..0e0ab8f 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -845,22 +845,7 @@ complete:
>  							>> 8) & 0x3F;
>  			}
>  			while (num_bytes--) {
> -				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
> -				if (dev->buf_len) {
> -					*dev->buf++ = w;
> -					dev->buf_len--;
> -					/*
> -					 * Data reg in 2430, omap3 and
> -					 * omap4 is 8 bit wide
> -					 */
> -					if (dev->flags &
> -						 OMAP_I2C_FLAG_16BIT_DATA_REG) {
> -						if (dev->buf_len) {
> -							*dev->buf++ = w >> 8;
> -							dev->buf_len--;
> -						}
> -					}
> -				} else {
> +				if (!dev->buf_len) {
>  					if (stat & OMAP_I2C_STAT_RRDY)
>  						dev_err(dev->dev,
>  							"RRDY IRQ while no data"
> @@ -871,6 +856,21 @@ complete:
>  								" requested\n");
>  					break;
>  				}
> +
> +				w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
> +				*dev->buf++ = w;
> +				dev->buf_len--;
> +				/*
> +				 * Data reg in 2430, omap3 and
> +				 * omap4 is 8 bit wide
> +				 */
> +				if (dev->flags &
> +						OMAP_I2C_FLAG_16BIT_DATA_REG) {
> +					if (dev->buf_len) {
> +						*dev->buf++ = w >> 8;
> +						dev->buf_len--;
> +					}
> +				}
>  			}
>  			omap_i2c_ack_stat(dev,
>  				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
> @@ -887,22 +887,7 @@ complete:
>  							& 0x3F;
>  			}
>  			while (num_bytes--) {
> -				w = 0;
> -				if (dev->buf_len) {
> -					w = *dev->buf++;
> -					dev->buf_len--;
> -					/*
> -					 * Data reg in 2430, omap3 and
> -					 * omap4 is 8 bit wide
> -					 */
> -					if (dev->flags &
> -						 OMAP_I2C_FLAG_16BIT_DATA_REG) {
> -						if (dev->buf_len) {
> -							w |= *dev->buf++ << 8;
> -							dev->buf_len--;
> -						}
> -					}
> -				} else {
> +				if (!dev->buf_len) {
>  					if (stat & OMAP_I2C_STAT_XRDY)
>  						dev_err(dev->dev,
>  							"XRDY IRQ while no "
> @@ -914,6 +899,20 @@ complete:
>  					break;
>  				}
>  
> +				w = *dev->buf++;
> +				dev->buf_len--;
> +				/*
> +				 * Data reg in 2430, omap3 and
> +				 * omap4 is 8 bit wide
> +				 */
> +				if (dev->flags &
> +						OMAP_I2C_FLAG_16BIT_DATA_REG) {
> +					if (dev->buf_len) {
> +						w |= *dev->buf++ << 8;
> +						dev->buf_len--;
> +					}
> +				}
> +
>  				if ((dev->errata & I2C_OMAP_ERRATA_I462) &&
>  				    errata_omap3_i462(dev, &stat, &err))
>  					goto complete;
> -- 
> 1.7.5.4
> 

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

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

* Re: [PATCHv8 13/13] I2C: OMAP: simplify omap_i2c_ack_stat()
  2012-06-18 14:30     ` Shubhrajyoti D
@ 2012-06-18 15:30         ` Wolfram Sang
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-18 15:30 UTC (permalink / raw)
  To: Shubhrajyoti D
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	Felipe Balbi

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

On Mon, Jun 18, 2012 at 08:00:28PM +0530, Shubhrajyoti D wrote:
> From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
> 
> stat & BIT(1) is the same as BIT(1),

Not true. I'd guess you are missing some context in the patch
description.

> so let's
> simplify things a bit by removing "stat &" from
> all omap_i2c_ack_stat() calls.
> 
> Signed-off-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
> Reviewed-by : Santosh Shilimkar <santosh.shilimkar-l0cyMroinI0@public.gmane.org>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-omap.c |   19 ++++++++++---------
>  1 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 6a79089..bac6305 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -763,7 +763,7 @@ static int errata_omap3_i462(struct omap_i2c_dev *dev, u16 *stat, int *err)
>  
>  	while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) {
>  		if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
> -			omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY |
> +			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
>  							OMAP_I2C_STAT_XDR));
>  			return -ETIMEDOUT;
>  		}
> @@ -824,10 +824,11 @@ complete:
>  		 */
>  		if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
>  					OMAP_I2C_STAT_AL)) {
> -			omap_i2c_ack_stat(dev, stat &
> -				(OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
> -				OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR |
> -				OMAP_I2C_STAT_ARDY));
> +			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
> +						OMAP_I2C_STAT_RDR |
> +						OMAP_I2C_STAT_XRDY |
> +						OMAP_I2C_STAT_XDR |
> +						OMAP_I2C_STAT_ARDY));
>  			omap_i2c_complete_cmd(dev, err);
>  			return IRQ_HANDLED;
>  		}
> @@ -874,8 +875,8 @@ complete:
>  					}
>  				}
>  			}
> -			omap_i2c_ack_stat(dev,
> -				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
> +			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
> +						OMAP_I2C_STAT_RDR));
>  			continue;
>  		}
>  
> @@ -922,8 +923,8 @@ complete:
>  
>  				omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
>  			}
> -			omap_i2c_ack_stat(dev,
> -				stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
> +			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
> +						OMAP_I2C_STAT_XDR));
>  			continue;
>  		}
>  
> -- 
> 1.7.5.4
> 

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

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

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

* [PATCHv8 13/13] I2C: OMAP: simplify omap_i2c_ack_stat()
@ 2012-06-18 15:30         ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-18 15:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 18, 2012 at 08:00:28PM +0530, Shubhrajyoti D wrote:
> From: Felipe Balbi <balbi@ti.com>
> 
> stat & BIT(1) is the same as BIT(1),

Not true. I'd guess you are missing some context in the patch
description.

> so let's
> simplify things a bit by removing "stat &" from
> all omap_i2c_ack_stat() calls.
> 
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> Reviewed-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> ---
>  drivers/i2c/busses/i2c-omap.c |   19 ++++++++++---------
>  1 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 6a79089..bac6305 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -763,7 +763,7 @@ static int errata_omap3_i462(struct omap_i2c_dev *dev, u16 *stat, int *err)
>  
>  	while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) {
>  		if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
> -			omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY |
> +			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
>  							OMAP_I2C_STAT_XDR));
>  			return -ETIMEDOUT;
>  		}
> @@ -824,10 +824,11 @@ complete:
>  		 */
>  		if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
>  					OMAP_I2C_STAT_AL)) {
> -			omap_i2c_ack_stat(dev, stat &
> -				(OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
> -				OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR |
> -				OMAP_I2C_STAT_ARDY));
> +			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
> +						OMAP_I2C_STAT_RDR |
> +						OMAP_I2C_STAT_XRDY |
> +						OMAP_I2C_STAT_XDR |
> +						OMAP_I2C_STAT_ARDY));
>  			omap_i2c_complete_cmd(dev, err);
>  			return IRQ_HANDLED;
>  		}
> @@ -874,8 +875,8 @@ complete:
>  					}
>  				}
>  			}
> -			omap_i2c_ack_stat(dev,
> -				stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
> +			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
> +						OMAP_I2C_STAT_RDR));
>  			continue;
>  		}
>  
> @@ -922,8 +923,8 @@ complete:
>  
>  				omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
>  			}
> -			omap_i2c_ack_stat(dev,
> -				stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
> +			omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
> +						OMAP_I2C_STAT_XDR));
>  			continue;
>  		}
>  
> -- 
> 1.7.5.4
> 

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

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

* Re: [PATCHv8 00/13] I2C cleanups
  2012-06-18 14:30 ` Shubhrajyoti D
@ 2012-06-18 15:33     ` Wolfram Sang
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-18 15:33 UTC (permalink / raw)
  To: Shubhrajyoti D
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ

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

On Mon, Jun 18, 2012 at 08:00:15PM +0530, Shubhrajyoti D wrote:
> 
> The patch series does the following
> 
> - I2C register restore only if context if the context is lost
> - Bus busy recovery mechanism.
> - the reset is not done in init.
> - Adds a patch to use devm_* functions
> - Adds a pdata function pointer to do context save restore
> - Split the omap_i2c_isr to increase readability
> - Make the i2c use SET_RUNTIME_PM_OPS
> - Use INIT_COMPLETION instead of init_completion
> - Dropping a cleanup and taking few patchs Felipe's series as it may
>  not be needed.

Patches look mostly okay for me without knowing the platform too much.
For that reason, I'd be really appreciating Tested-by or even
Reviewed-by tags!

> This series mainly is the cleanups rebased on
> i2c-embedded/for-next branch.

Thanks.

Regards,

   Wolfram

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

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

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

* [PATCHv8 00/13] I2C cleanups
@ 2012-06-18 15:33     ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-18 15:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 18, 2012 at 08:00:15PM +0530, Shubhrajyoti D wrote:
> 
> The patch series does the following
> 
> - I2C register restore only if context if the context is lost
> - Bus busy recovery mechanism.
> - the reset is not done in init.
> - Adds a patch to use devm_* functions
> - Adds a pdata function pointer to do context save restore
> - Split the omap_i2c_isr to increase readability
> - Make the i2c use SET_RUNTIME_PM_OPS
> - Use INIT_COMPLETION instead of init_completion
> - Dropping a cleanup and taking few patchs Felipe's series as it may
>  not be needed.

Patches look mostly okay for me without knowing the platform too much.
For that reason, I'd be really appreciating Tested-by or even
Reviewed-by tags!

> This series mainly is the cleanups rebased on
> i2c-embedded/for-next branch.

Thanks.

Regards,

   Wolfram

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

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

* Re: [PATCHv8 13/13] I2C: OMAP: simplify omap_i2c_ack_stat()
  2012-06-18 15:30         ` Wolfram Sang
@ 2012-06-19  9:20             ` Shubhrajyoti Datta
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-06-19  9:20 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Shubhrajyoti D, linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	Felipe Balbi

On Mon, Jun 18, 2012 at 9:00 PM, Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> wrote:
> On Mon, Jun 18, 2012 at 08:00:28PM +0530, Shubhrajyoti D wrote:
>> From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
>>
>> stat & BIT(1) is the same as BIT(1),
>
> Not true. I'd guess you are missing some context in the patch
> description.


See the explanation , hope I understood your concern correctly.

http://www.mail-archive.com/linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg70277.html

>
>> so let's
>> simplify things a bit by removing "stat &" from
>> all omap_i2c_ack_stat() calls.
>>
>> Signed-off-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
>> Reviewed-by : Santosh Shilimkar <santosh.shilimkar-l0cyMroinI0@public.gmane.org>
>> Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
>> ---
>>  drivers/i2c/busses/i2c-omap.c |   19 ++++++++++---------
>>  1 files changed, 10 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
>> index 6a79089..bac6305 100644
>> --- a/drivers/i2c/busses/i2c-omap.c
>> +++ b/drivers/i2c/busses/i2c-omap.c
>> @@ -763,7 +763,7 @@ static int errata_omap3_i462(struct omap_i2c_dev *dev, u16 *stat, int *err)
>>
>>       while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) {
>>               if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
>> -                     omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY |
>> +                     omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
>>                                                       OMAP_I2C_STAT_XDR));
>>                       return -ETIMEDOUT;
>>               }
>> @@ -824,10 +824,11 @@ complete:
>>                */
>>               if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
>>                                       OMAP_I2C_STAT_AL)) {
>> -                     omap_i2c_ack_stat(dev, stat &
>> -                             (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
>> -                             OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR |
>> -                             OMAP_I2C_STAT_ARDY));
>> +                     omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
>> +                                             OMAP_I2C_STAT_RDR |
>> +                                             OMAP_I2C_STAT_XRDY |
>> +                                             OMAP_I2C_STAT_XDR |
>> +                                             OMAP_I2C_STAT_ARDY));
>>                       omap_i2c_complete_cmd(dev, err);
>>                       return IRQ_HANDLED;
>>               }
>> @@ -874,8 +875,8 @@ complete:
>>                                       }
>>                               }
>>                       }
>> -                     omap_i2c_ack_stat(dev,
>> -                             stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
>> +                     omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
>> +                                             OMAP_I2C_STAT_RDR));
>>                       continue;
>>               }
>>
>> @@ -922,8 +923,8 @@ complete:
>>
>>                               omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
>>                       }
>> -                     omap_i2c_ack_stat(dev,
>> -                             stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
>> +                     omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
>> +                                             OMAP_I2C_STAT_XDR));
>>                       continue;
>>               }
>>
>> --
>> 1.7.5.4
>>
>
> --
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* [PATCHv8 13/13] I2C: OMAP: simplify omap_i2c_ack_stat()
@ 2012-06-19  9:20             ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-06-19  9:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 18, 2012 at 9:00 PM, Wolfram Sang <w.sang@pengutronix.de> wrote:
> On Mon, Jun 18, 2012 at 08:00:28PM +0530, Shubhrajyoti D wrote:
>> From: Felipe Balbi <balbi@ti.com>
>>
>> stat & BIT(1) is the same as BIT(1),
>
> Not true. I'd guess you are missing some context in the patch
> description.


See the explanation , hope I understood your concern correctly.

http://www.mail-archive.com/linux-omap at vger.kernel.org/msg70277.html

>
>> so let's
>> simplify things a bit by removing "stat &" from
>> all omap_i2c_ack_stat() calls.
>>
>> Signed-off-by: Felipe Balbi <balbi@ti.com>
>> Reviewed-by : Santosh Shilimkar <santosh.shilimkar@ti.com>
>> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
>> ---
>> ?drivers/i2c/busses/i2c-omap.c | ? 19 ++++++++++---------
>> ?1 files changed, 10 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
>> index 6a79089..bac6305 100644
>> --- a/drivers/i2c/busses/i2c-omap.c
>> +++ b/drivers/i2c/busses/i2c-omap.c
>> @@ -763,7 +763,7 @@ static int errata_omap3_i462(struct omap_i2c_dev *dev, u16 *stat, int *err)
>>
>> ? ? ? while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) {
>> ? ? ? ? ? ? ? if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
>> - ? ? ? ? ? ? ? ? ? ? omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY |
>> + ? ? ? ? ? ? ? ? ? ? omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_XDR));
>> ? ? ? ? ? ? ? ? ? ? ? return -ETIMEDOUT;
>> ? ? ? ? ? ? ? }
>> @@ -824,10 +824,11 @@ complete:
>> ? ? ? ? ? ? ? ?*/
>> ? ? ? ? ? ? ? if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_AL)) {
>> - ? ? ? ? ? ? ? ? ? ? omap_i2c_ack_stat(dev, stat &
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR |
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_ARDY));
>> + ? ? ? ? ? ? ? ? ? ? omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_RDR |
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_XRDY |
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_XDR |
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_ARDY));
>> ? ? ? ? ? ? ? ? ? ? ? omap_i2c_complete_cmd(dev, err);
>> ? ? ? ? ? ? ? ? ? ? ? return IRQ_HANDLED;
>> ? ? ? ? ? ? ? }
>> @@ -874,8 +875,8 @@ complete:
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
>> ? ? ? ? ? ? ? ? ? ? ? }
>> - ? ? ? ? ? ? ? ? ? ? omap_i2c_ack_stat(dev,
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
>> + ? ? ? ? ? ? ? ? ? ? omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_RDR));
>> ? ? ? ? ? ? ? ? ? ? ? continue;
>> ? ? ? ? ? ? ? }
>>
>> @@ -922,8 +923,8 @@ complete:
>>
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
>> ? ? ? ? ? ? ? ? ? ? ? }
>> - ? ? ? ? ? ? ? ? ? ? omap_i2c_ack_stat(dev,
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
>> + ? ? ? ? ? ? ? ? ? ? omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY |
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_I2C_STAT_XDR));
>> ? ? ? ? ? ? ? ? ? ? ? continue;
>> ? ? ? ? ? ? ? }
>>
>> --
>> 1.7.5.4
>>
>
> --
> Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Wolfram Sang ? ? ? ? ? ? ? ?|
> Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|

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

* Re: [PATCHv8 13/13] I2C: OMAP: simplify omap_i2c_ack_stat()
  2012-06-19  9:20             ` Shubhrajyoti Datta
@ 2012-06-19 13:33               ` Wolfram Sang
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-19 13:33 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: Shubhrajyoti D, linux-omap, linux-i2c, linux-arm-kernel,
	ben-linux, tony, Felipe Balbi

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

On Tue, Jun 19, 2012 at 02:50:23PM +0530, Shubhrajyoti Datta wrote:
> On Mon, Jun 18, 2012 at 9:00 PM, Wolfram Sang <w.sang@pengutronix.de> wrote:
> > On Mon, Jun 18, 2012 at 08:00:28PM +0530, Shubhrajyoti D wrote:
> >> From: Felipe Balbi <balbi@ti.com>
> >>
> >> stat & BIT(1) is the same as BIT(1),
> >
> > Not true. I'd guess you are missing some context in the patch
> > description.
> 
> 
> See the explanation , hope I understood your concern correctly.
> 
> http://www.mail-archive.com/linux-omap@vger.kernel.org/msg70277.html

The code may be right, but as Russell pointed out, the patch description
is very weak. I could read the mail now to understand, but I prefer to
wait for a better patch description. Because I need to ensure other
people reading the git history later will understand easily without
having to search the web.

Regards,

   Wolfram

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

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

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

* [PATCHv8 13/13] I2C: OMAP: simplify omap_i2c_ack_stat()
@ 2012-06-19 13:33               ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-19 13:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jun 19, 2012 at 02:50:23PM +0530, Shubhrajyoti Datta wrote:
> On Mon, Jun 18, 2012 at 9:00 PM, Wolfram Sang <w.sang@pengutronix.de> wrote:
> > On Mon, Jun 18, 2012 at 08:00:28PM +0530, Shubhrajyoti D wrote:
> >> From: Felipe Balbi <balbi@ti.com>
> >>
> >> stat & BIT(1) is the same as BIT(1),
> >
> > Not true. I'd guess you are missing some context in the patch
> > description.
> 
> 
> See the explanation , hope I understood your concern correctly.
> 
> http://www.mail-archive.com/linux-omap at vger.kernel.org/msg70277.html

The code may be right, but as Russell pointed out, the patch description
is very weak. I could read the mail now to understand, but I prefer to
wait for a better patch description. Because I need to ensure other
people reading the git history later will understand easily without
having to search the web.

Regards,

   Wolfram

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

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

* Re: [PATCHv8 03/13] I2C: OMAP: Remove reset at init
  2012-06-18 14:30     ` Shubhrajyoti D
@ 2012-06-20 10:29       ` Tony Lindgren
  -1 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-20 10:29 UTC (permalink / raw)
  To: Shubhrajyoti D; +Cc: linux-omap, linux-i2c, linux-arm-kernel, ben-linux, w.sang

* Shubhrajyoti D <shubhrajyoti@ti.com> [120618 07:35]:
> The reset in the driver at init is not needed anymore as the
> following patch has removed the HWMOD_INIT_NO_RESET flag.
> 6d3c55f [OMAP: hwmod: fix the i2c-reset timeout during bootup]
> 
> This patch does the following
> -removes the reset from the probe and implements a omap_i2c_reset
>  function to reset.
> - Reset is removed from omap_i2c_init, which was called
>  not only during probe, but also after time out and error handling.
>  omap_i2c_reset is added in those places to effect the reset.

See the comments regarding driver specific resets in hwmod code.

The way to set this up is to have a shared inline function in
i2c-omap.h that both the driver and hwmod code can use.

Eventually hwmod code will do the reset only in late initcall
if no driver is loaded for the device in question.

Tony

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

* [PATCHv8 03/13] I2C: OMAP: Remove reset at init
@ 2012-06-20 10:29       ` Tony Lindgren
  0 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-20 10:29 UTC (permalink / raw)
  To: linux-arm-kernel

* Shubhrajyoti D <shubhrajyoti@ti.com> [120618 07:35]:
> The reset in the driver at init is not needed anymore as the
> following patch has removed the HWMOD_INIT_NO_RESET flag.
> 6d3c55f [OMAP: hwmod: fix the i2c-reset timeout during bootup]
> 
> This patch does the following
> -removes the reset from the probe and implements a omap_i2c_reset
>  function to reset.
> - Reset is removed from omap_i2c_init, which was called
>  not only during probe, but also after time out and error handling.
>  omap_i2c_reset is added in those places to effect the reset.

See the comments regarding driver specific resets in hwmod code.

The way to set this up is to have a shared inline function in
i2c-omap.h that both the driver and hwmod code can use.

Eventually hwmod code will do the reset only in late initcall
if no driver is loaded for the device in question.

Tony

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

* Re: [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
  2012-06-18 14:30     ` Shubhrajyoti D
@ 2012-06-20 10:32         ` Tony Lindgren
  -1 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-20 10:32 UTC (permalink / raw)
  To: Shubhrajyoti D
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, w.sang-bIcnvbaLZ9MEGnE8C9+IrQ,
	Jon Hunter

* Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org> [120618 07:35]:
> From: Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>
> 
> The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
> revision is the same for 3430 and 3530. However, the OMAP3630 device has the
> same I2C revision as OMAP4. Correct the revision definition to reflect this.
> 
> This patch is based on work done by Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>
> Changes from his patch
> - Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530
...
>  /* timeout waiting for the controller to respond */
>  #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
> @@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
>  			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
>  					   SYSC_AUTOIDLE_MASK);
>  
> -		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
> +		} else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
>  			dev->syscstate = SYSC_AUTOIDLE_MASK;
>  			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
>  			dev->syscstate |= (SYSC_IDLEMODE_SMART <<

Having to patch all over the place for these revision defines leads
into unmaintainable code as new SoCs get added.

Please instead just check the revision once during init, then set
up some feature bits like I2C_OMAP_NEEDS_XYZ_RESET that the runtime
code can check.


> @@ -1055,7 +1055,7 @@ omap_i2c_probe(struct platform_device *pdev)
>  	if (dev->flags & OMAP_I2C_FLAG_APPLY_ERRATA_I207)
>  		dev->errata |= I2C_OMAP_ERRATA_I207;
>  
> -	if (dev->rev <= OMAP_I2C_REV_ON_3430)
> +	if (dev->rev <= OMAP_I2C_REV_ON_3430_3530)
>  		dev->errata |= I2C_OMAP_ERRATA_I462;
>  
>  	if (!(dev->flags & OMAP_I2C_FLAG_NO_FIFO)) {
> @@ -1073,7 +1073,7 @@ omap_i2c_probe(struct platform_device *pdev)
>  
>  		dev->fifo_size = (dev->fifo_size / 2);
>  
> -		if (dev->rev >= OMAP_I2C_REV_ON_3530_4430)
> +		if (dev->rev >= OMAP_I2C_REV_ON_3630_4430)
>  			dev->b_hw = 0; /* Disable hardware fixes */
>  		else
>  			dev->b_hw = 1; /* Enable hardware fixes */

That way the code does not need to change when new SoC revisions
get added.

Tony

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

* [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
@ 2012-06-20 10:32         ` Tony Lindgren
  0 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-20 10:32 UTC (permalink / raw)
  To: linux-arm-kernel

* Shubhrajyoti D <shubhrajyoti@ti.com> [120618 07:35]:
> From: Jon Hunter <jon-hunter@ti.com>
> 
> The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
> revision is the same for 3430 and 3530. However, the OMAP3630 device has the
> same I2C revision as OMAP4. Correct the revision definition to reflect this.
> 
> This patch is based on work done by Jon Hunter <jon-hunter@ti.com>
> Changes from his patch
> - Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530
...
>  /* timeout waiting for the controller to respond */
>  #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
> @@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
>  			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
>  					   SYSC_AUTOIDLE_MASK);
>  
> -		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
> +		} else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
>  			dev->syscstate = SYSC_AUTOIDLE_MASK;
>  			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
>  			dev->syscstate |= (SYSC_IDLEMODE_SMART <<

Having to patch all over the place for these revision defines leads
into unmaintainable code as new SoCs get added.

Please instead just check the revision once during init, then set
up some feature bits like I2C_OMAP_NEEDS_XYZ_RESET that the runtime
code can check.


> @@ -1055,7 +1055,7 @@ omap_i2c_probe(struct platform_device *pdev)
>  	if (dev->flags & OMAP_I2C_FLAG_APPLY_ERRATA_I207)
>  		dev->errata |= I2C_OMAP_ERRATA_I207;
>  
> -	if (dev->rev <= OMAP_I2C_REV_ON_3430)
> +	if (dev->rev <= OMAP_I2C_REV_ON_3430_3530)
>  		dev->errata |= I2C_OMAP_ERRATA_I462;
>  
>  	if (!(dev->flags & OMAP_I2C_FLAG_NO_FIFO)) {
> @@ -1073,7 +1073,7 @@ omap_i2c_probe(struct platform_device *pdev)
>  
>  		dev->fifo_size = (dev->fifo_size / 2);
>  
> -		if (dev->rev >= OMAP_I2C_REV_ON_3530_4430)
> +		if (dev->rev >= OMAP_I2C_REV_ON_3630_4430)
>  			dev->b_hw = 0; /* Disable hardware fixes */
>  		else
>  			dev->b_hw = 1; /* Enable hardware fixes */

That way the code does not need to change when new SoC revisions
get added.

Tony

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

* Re: [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
  2012-06-20 10:32         ` Tony Lindgren
@ 2012-06-20 13:01           ` Shubhrajyoti
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti @ 2012-06-20 13:01 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-i2c, linux-arm-kernel, ben-linux, w.sang, Jon Hunter

On Wednesday 20 June 2012 04:02 PM, Tony Lindgren wrote:
> * Shubhrajyoti D <shubhrajyoti@ti.com> [120618 07:35]:
>> From: Jon Hunter <jon-hunter@ti.com>
>>
>> The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
>> revision is the same for 3430 and 3530. However, the OMAP3630 device has the
>> same I2C revision as OMAP4. Correct the revision definition to reflect this.
>>
>> This patch is based on work done by Jon Hunter <jon-hunter@ti.com>
>> Changes from his patch
>> - Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530
> ...
>>  /* timeout waiting for the controller to respond */
>>  #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
>> @@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
>>  			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
>>  					   SYSC_AUTOIDLE_MASK);
>>  
>> -		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
>> +		} else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
>>  			dev->syscstate = SYSC_AUTOIDLE_MASK;
>>  			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
>>  			dev->syscstate |= (SYSC_IDLEMODE_SMART <<
> Having to patch all over the place for these revision defines leads
> into unmaintainable code as new SoCs get added.
>
> Please instead just check the revision once during init, then set
> up some feature bits like I2C_OMAP_NEEDS_XYZ_RESET that the runtime
> code can check.
Even now at probe

dev->rev is set by reading the rev register.

The (macro)name used to identify is only changed.

Also all the ips need reset the difference is that 2430 has less bits eg only autoidle and reset.
So a flag needs reset may not be meaningful.



>
>
>> @@ -1055,7 +1055,7 @@ omap_i2c_probe(struct platform_device *pdev)
>>  	if (dev->flags & OMAP_I2C_FLAG_APPLY_ERRATA_I207)
>>  		dev->errata |= I2C_OMAP_ERRATA_I207;
>>  
>> -	if (dev->rev <= OMAP_I2C_REV_ON_3430)
>> +	if (dev->rev <= OMAP_I2C_REV_ON_3430_3530)
>>  		dev->errata |= I2C_OMAP_ERRATA_I462;
>>  
>>  	if (!(dev->flags & OMAP_I2C_FLAG_NO_FIFO)) {
>> @@ -1073,7 +1073,7 @@ omap_i2c_probe(struct platform_device *pdev)
>>  
>>  		dev->fifo_size = (dev->fifo_size / 2);
>>  
>> -		if (dev->rev >= OMAP_I2C_REV_ON_3530_4430)
>> +		if (dev->rev >= OMAP_I2C_REV_ON_3630_4430)
>>  			dev->b_hw = 0; /* Disable hardware fixes */
>>  		else
>>  			dev->b_hw = 1; /* Enable hardware fixes */
> That way the code does not need to change when new SoC revisions
> get added.
I think it might still not need to change because of >= .
I have just renamed

OMAP_I2C_REV_ON_3530_4430 as 3530 rev is not the same as 4430 that the name implies.

>
> Tony


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

* [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
@ 2012-06-20 13:01           ` Shubhrajyoti
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti @ 2012-06-20 13:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Wednesday 20 June 2012 04:02 PM, Tony Lindgren wrote:
> * Shubhrajyoti D <shubhrajyoti@ti.com> [120618 07:35]:
>> From: Jon Hunter <jon-hunter@ti.com>
>>
>> The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
>> revision is the same for 3430 and 3530. However, the OMAP3630 device has the
>> same I2C revision as OMAP4. Correct the revision definition to reflect this.
>>
>> This patch is based on work done by Jon Hunter <jon-hunter@ti.com>
>> Changes from his patch
>> - Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530
> ...
>>  /* timeout waiting for the controller to respond */
>>  #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
>> @@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
>>  			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
>>  					   SYSC_AUTOIDLE_MASK);
>>  
>> -		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
>> +		} else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
>>  			dev->syscstate = SYSC_AUTOIDLE_MASK;
>>  			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
>>  			dev->syscstate |= (SYSC_IDLEMODE_SMART <<
> Having to patch all over the place for these revision defines leads
> into unmaintainable code as new SoCs get added.
>
> Please instead just check the revision once during init, then set
> up some feature bits like I2C_OMAP_NEEDS_XYZ_RESET that the runtime
> code can check.
Even now at probe

dev->rev is set by reading the rev register.

The (macro)name used to identify is only changed.

Also all the ips need reset the difference is that 2430 has less bits eg only autoidle and reset.
So a flag needs reset may not be meaningful.



>
>
>> @@ -1055,7 +1055,7 @@ omap_i2c_probe(struct platform_device *pdev)
>>  	if (dev->flags & OMAP_I2C_FLAG_APPLY_ERRATA_I207)
>>  		dev->errata |= I2C_OMAP_ERRATA_I207;
>>  
>> -	if (dev->rev <= OMAP_I2C_REV_ON_3430)
>> +	if (dev->rev <= OMAP_I2C_REV_ON_3430_3530)
>>  		dev->errata |= I2C_OMAP_ERRATA_I462;
>>  
>>  	if (!(dev->flags & OMAP_I2C_FLAG_NO_FIFO)) {
>> @@ -1073,7 +1073,7 @@ omap_i2c_probe(struct platform_device *pdev)
>>  
>>  		dev->fifo_size = (dev->fifo_size / 2);
>>  
>> -		if (dev->rev >= OMAP_I2C_REV_ON_3530_4430)
>> +		if (dev->rev >= OMAP_I2C_REV_ON_3630_4430)
>>  			dev->b_hw = 0; /* Disable hardware fixes */
>>  		else
>>  			dev->b_hw = 1; /* Enable hardware fixes */
> That way the code does not need to change when new SoC revisions
> get added.
I think it might still not need to change because of >= .
I have just renamed

OMAP_I2C_REV_ON_3530_4430 as 3530 rev is not the same as 4430 that the name implies.

>
> Tony

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

* Re: [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
  2012-06-20 13:01           ` Shubhrajyoti
@ 2012-06-20 14:14               ` Tony Lindgren
  -1 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-20 14:14 UTC (permalink / raw)
  To: Shubhrajyoti
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, w.sang-bIcnvbaLZ9MEGnE8C9+IrQ,
	Jon Hunter

* Shubhrajyoti <shubhrajyoti-l0cyMroinI0@public.gmane.org> [120620 06:06]:
> On Wednesday 20 June 2012 04:02 PM, Tony Lindgren wrote:
> > * Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org> [120618 07:35]:
> >> From: Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>
> >>
> >> The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
> >> revision is the same for 3430 and 3530. However, the OMAP3630 device has the
> >> same I2C revision as OMAP4. Correct the revision definition to reflect this.
> >>
> >> This patch is based on work done by Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>
> >> Changes from his patch
> >> - Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530
> > ...
> >>  /* timeout waiting for the controller to respond */
> >>  #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
> >> @@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
> >>  			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
> >>  					   SYSC_AUTOIDLE_MASK);
> >>  
> >> -		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
> >> +		} else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
> >>  			dev->syscstate = SYSC_AUTOIDLE_MASK;
> >>  			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
> >>  			dev->syscstate |= (SYSC_IDLEMODE_SMART <<
> > Having to patch all over the place for these revision defines leads
> > into unmaintainable code as new SoCs get added.
> >
> > Please instead just check the revision once during init, then set
> > up some feature bits like I2C_OMAP_NEEDS_XYZ_RESET that the runtime
> > code can check.
> Even now at probe
> 
> dev->rev is set by reading the rev register.
> 
> The (macro)name used to identify is only changed.
> 
> Also all the ips need reset the difference is that 2430 has less bits eg only autoidle and reset.
> So a flag needs reset may not be meaningful.
 
Hmm OK so this is a cosmetic/readability fix..

..but your earlier patch now spreads the checking of revision
to the new non-init function omap_i2c_reset.

Why don't you just do this cosmetic/readability rename fix
before your 03/13 patch? Then set the already existing
OMAP_I2C_FLAG_RESET_REGS_POSTIDLE during init for some
revisions and use that instead of the rev check in
omap_i2c_reset?

Tony
 

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

* [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
@ 2012-06-20 14:14               ` Tony Lindgren
  0 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-20 14:14 UTC (permalink / raw)
  To: linux-arm-kernel

* Shubhrajyoti <shubhrajyoti@ti.com> [120620 06:06]:
> On Wednesday 20 June 2012 04:02 PM, Tony Lindgren wrote:
> > * Shubhrajyoti D <shubhrajyoti@ti.com> [120618 07:35]:
> >> From: Jon Hunter <jon-hunter@ti.com>
> >>
> >> The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
> >> revision is the same for 3430 and 3530. However, the OMAP3630 device has the
> >> same I2C revision as OMAP4. Correct the revision definition to reflect this.
> >>
> >> This patch is based on work done by Jon Hunter <jon-hunter@ti.com>
> >> Changes from his patch
> >> - Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530
> > ...
> >>  /* timeout waiting for the controller to respond */
> >>  #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
> >> @@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
> >>  			omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
> >>  					   SYSC_AUTOIDLE_MASK);
> >>  
> >> -		} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
> >> +		} else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
> >>  			dev->syscstate = SYSC_AUTOIDLE_MASK;
> >>  			dev->syscstate |= SYSC_ENAWAKEUP_MASK;
> >>  			dev->syscstate |= (SYSC_IDLEMODE_SMART <<
> > Having to patch all over the place for these revision defines leads
> > into unmaintainable code as new SoCs get added.
> >
> > Please instead just check the revision once during init, then set
> > up some feature bits like I2C_OMAP_NEEDS_XYZ_RESET that the runtime
> > code can check.
> Even now at probe
> 
> dev->rev is set by reading the rev register.
> 
> The (macro)name used to identify is only changed.
> 
> Also all the ips need reset the difference is that 2430 has less bits eg only autoidle and reset.
> So a flag needs reset may not be meaningful.
 
Hmm OK so this is a cosmetic/readability fix..

..but your earlier patch now spreads the checking of revision
to the new non-init function omap_i2c_reset.

Why don't you just do this cosmetic/readability rename fix
before your 03/13 patch? Then set the already existing
OMAP_I2C_FLAG_RESET_REGS_POSTIDLE during init for some
revisions and use that instead of the rev check in
omap_i2c_reset?

Tony
 

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

* Re: [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
  2012-06-20 14:14               ` Tony Lindgren
@ 2012-06-21  6:56                   ` Shubhrajyoti Datta
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-06-21  6:56 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Shubhrajyoti, linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, w.sang-bIcnvbaLZ9MEGnE8C9+IrQ,
	Jon Hunter

On Wed, Jun 20, 2012 at 7:44 PM, Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> wrote:
> * Shubhrajyoti <shubhrajyoti-l0cyMroinI0@public.gmane.org> [120620 06:06]:
>> On Wednesday 20 June 2012 04:02 PM, Tony Lindgren wrote:
>> > * Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org> [120618 07:35]:
>> >> From: Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>
>> >>
>> >> The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
>> >> revision is the same for 3430 and 3530. However, the OMAP3630 device has the
>> >> same I2C revision as OMAP4. Correct the revision definition to reflect this.
>> >>
>> >> This patch is based on work done by Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org>
>> >> Changes from his patch
>> >> - Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530
>> > ...
>> >>  /* timeout waiting for the controller to respond */
>> >>  #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
>> >> @@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
>> >>                    omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
>> >>                                       SYSC_AUTOIDLE_MASK);
>> >>
>> >> -          } else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
>> >> +          } else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
>> >>                    dev->syscstate = SYSC_AUTOIDLE_MASK;
>> >>                    dev->syscstate |= SYSC_ENAWAKEUP_MASK;
>> >>                    dev->syscstate |= (SYSC_IDLEMODE_SMART <<
>> > Having to patch all over the place for these revision defines leads
>> > into unmaintainable code as new SoCs get added.
>> >
>> > Please instead just check the revision once during init, then set
>> > up some feature bits like I2C_OMAP_NEEDS_XYZ_RESET that the runtime
>> > code can check.
>> Even now at probe
>>
>> dev->rev is set by reading the rev register.
>>
>> The (macro)name used to identify is only changed.
>>
>> Also all the ips need reset the difference is that 2430 has less bits eg only autoidle and reset.
>> So a flag needs reset may not be meaningful.
>
> Hmm OK so this is a cosmetic/readability fix..

Yes

>
> ..but your earlier patch now spreads the checking of revision
> to the new non-init function omap_i2c_reset.
>
> Why don't you just do this cosmetic/readability rename fix
> before your 03/13 patch?

OK thats doable.I can reorder the patch.

> Then set the already existing
> OMAP_I2C_FLAG_RESET_REGS_POSTIDLE during init for some
> revisions and use that instead of the rev check in
> omap_i2c_reset?

OMAP_I2C_FLAG_RESET_REGS_POSTIDLE is a hwmod flag whose intention is to find
know if it can lose context after idle.

The rev check that we have is because post reset( triggered by driver)
to know if we have to restore only autoidle or other bits like clockactivity
sidle , enable wakeup .

>
> Tony
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3
@ 2012-06-21  6:56                   ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-06-21  6:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 20, 2012 at 7:44 PM, Tony Lindgren <tony@atomide.com> wrote:
> * Shubhrajyoti <shubhrajyoti@ti.com> [120620 06:06]:
>> On Wednesday 20 June 2012 04:02 PM, Tony Lindgren wrote:
>> > * Shubhrajyoti D <shubhrajyoti@ti.com> [120618 07:35]:
>> >> From: Jon Hunter <jon-hunter@ti.com>
>> >>
>> >> The OMAP3530 is based upon the same silicon as the OMAP3430 and so the I2C
>> >> revision is the same for 3430 and 3530. However, the OMAP3630 device has the
>> >> same I2C revision as OMAP4. Correct the revision definition to reflect this.
>> >>
>> >> This patch is based on work done by Jon Hunter <jon-hunter@ti.com>
>> >> Changes from his patch
>> >> - Update OMAP_I2C_REV_ON_3430 also to reflect that it is same as 3530
>> > ...
>> >> ?/* timeout waiting for the controller to respond */
>> >> ?#define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
>> >> @@ -298,7 +298,7 @@ static int omap_i2c_reset(struct omap_i2c_dev *dev)
>> >> ? ? ? ? ? ? ? ? ? ?omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
>> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SYSC_AUTOIDLE_MASK);
>> >>
>> >> - ? ? ? ? ?} else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
>> >> + ? ? ? ? ?} else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
>> >> ? ? ? ? ? ? ? ? ? ?dev->syscstate = SYSC_AUTOIDLE_MASK;
>> >> ? ? ? ? ? ? ? ? ? ?dev->syscstate |= SYSC_ENAWAKEUP_MASK;
>> >> ? ? ? ? ? ? ? ? ? ?dev->syscstate |= (SYSC_IDLEMODE_SMART <<
>> > Having to patch all over the place for these revision defines leads
>> > into unmaintainable code as new SoCs get added.
>> >
>> > Please instead just check the revision once during init, then set
>> > up some feature bits like I2C_OMAP_NEEDS_XYZ_RESET that the runtime
>> > code can check.
>> Even now at probe
>>
>> dev->rev is set by reading the rev register.
>>
>> The (macro)name used to identify is only changed.
>>
>> Also all the ips need reset the difference is that 2430 has less bits eg only autoidle and reset.
>> So a flag needs reset may not be meaningful.
>
> Hmm OK so this is a cosmetic/readability fix..

Yes

>
> ..but your earlier patch now spreads the checking of revision
> to the new non-init function omap_i2c_reset.
>
> Why don't you just do this cosmetic/readability rename fix
> before your 03/13 patch?

OK thats doable.I can reorder the patch.

> Then set the already existing
> OMAP_I2C_FLAG_RESET_REGS_POSTIDLE during init for some
> revisions and use that instead of the rev check in
> omap_i2c_reset?

OMAP_I2C_FLAG_RESET_REGS_POSTIDLE is a hwmod flag whose intention is to find
know if it can lose context after idle.

The rev check that we have is because post reset( triggered by driver)
to know if we have to restore only autoidle or other bits like clockactivity
sidle , enable wakeup .

>
> Tony
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" 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] 58+ messages in thread

* Re: [PATCHv8 03/13] I2C: OMAP: Remove reset at init
  2012-06-20 10:29       ` Tony Lindgren
@ 2012-06-21  7:03           ` Shubhrajyoti
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti @ 2012-06-21  7:03 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, w.sang-bIcnvbaLZ9MEGnE8C9+IrQ

On Wednesday 20 June 2012 03:59 PM, Tony Lindgren wrote:
> See the comments regarding driver specific resets in hwmod code.
you mean omap_hwmod.c
>
> The way to set this up is to have a shared inline function in
> i2c-omap.h that both the driver and hwmod code can use.
hwmod reset function uses oh (omap_hwmod).

How could the driver also pass oh ?
Could we keep a local copy in driver data?
> Eventually hwmod code will do the reset only in late initcall
> if no driver is loaded for the device in question.

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

* [PATCHv8 03/13] I2C: OMAP: Remove reset at init
@ 2012-06-21  7:03           ` Shubhrajyoti
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti @ 2012-06-21  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Wednesday 20 June 2012 03:59 PM, Tony Lindgren wrote:
> See the comments regarding driver specific resets in hwmod code.
you mean omap_hwmod.c
>
> The way to set this up is to have a shared inline function in
> i2c-omap.h that both the driver and hwmod code can use.
hwmod reset function uses oh (omap_hwmod).

How could the driver also pass oh ?
Could we keep a local copy in driver data?
> Eventually hwmod code will do the reset only in late initcall
> if no driver is loaded for the device in question.

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

* Re: [PATCHv8 03/13] I2C: OMAP: Remove reset at init
  2012-06-21  7:03           ` Shubhrajyoti
@ 2012-06-21  7:20             ` Tony Lindgren
  -1 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-21  7:20 UTC (permalink / raw)
  To: Shubhrajyoti; +Cc: linux-omap, linux-i2c, linux-arm-kernel, ben-linux, w.sang

* Shubhrajyoti <shubhrajyoti@ti.com> [120621 00:08]:
> On Wednesday 20 June 2012 03:59 PM, Tony Lindgren wrote:
> > See the comments regarding driver specific resets in hwmod code.
> you mean omap_hwmod.c
> >
> > The way to set this up is to have a shared inline function in
> > i2c-omap.h that both the driver and hwmod code can use.
> hwmod reset function uses oh (omap_hwmod).
> 
> How could the driver also pass oh ?
> Could we keep a local copy in driver data?
> > Eventually hwmod code will do the reset only in late initcall
> > if no driver is loaded for the device in question.
> 

There's no need for the driver to know anything about oh.
The driver just needs to know the iobase.

Tony

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

* [PATCHv8 03/13] I2C: OMAP: Remove reset at init
@ 2012-06-21  7:20             ` Tony Lindgren
  0 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-21  7:20 UTC (permalink / raw)
  To: linux-arm-kernel

* Shubhrajyoti <shubhrajyoti@ti.com> [120621 00:08]:
> On Wednesday 20 June 2012 03:59 PM, Tony Lindgren wrote:
> > See the comments regarding driver specific resets in hwmod code.
> you mean omap_hwmod.c
> >
> > The way to set this up is to have a shared inline function in
> > i2c-omap.h that both the driver and hwmod code can use.
> hwmod reset function uses oh (omap_hwmod).
> 
> How could the driver also pass oh ?
> Could we keep a local copy in driver data?
> > Eventually hwmod code will do the reset only in late initcall
> > if no driver is loaded for the device in question.
> 

There's no need for the driver to know anything about oh.
The driver just needs to know the iobase.

Tony

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

* Re: [PATCHv8 03/13] I2C: OMAP: Remove reset at init
  2012-06-21  7:20             ` Tony Lindgren
@ 2012-06-21  9:30               ` Shubhrajyoti
  -1 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti @ 2012-06-21  9:30 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-i2c, linux-arm-kernel, ben-linux, w.sang

On Thursday 21 June 2012 12:50 PM, Tony Lindgren wrote:
> * Shubhrajyoti <shubhrajyoti@ti.com> [120621 00:08]:
>> On Wednesday 20 June 2012 03:59 PM, Tony Lindgren wrote:
>>> See the comments regarding driver specific resets in hwmod code.
>> you mean omap_hwmod.c
>>> The way to set this up is to have a shared inline function in
>>> i2c-omap.h that both the driver and hwmod code can use.
>> hwmod reset function uses oh (omap_hwmod).
>>
>> How could the driver also pass oh ?
>> Could we keep a local copy in driver data?
>>> Eventually hwmod code will do the reset only in late initcall
>>> if no driver is loaded for the device in question.
> There's no need for the driver to know anything about oh.
> The driver just needs to know the iobase.
I will rework to make the hwmod and driver use the same function.
In the meanwhile I will send a minimal/ remaining cleanups/ fixes so that
it might get some time to bake in the next branch.


>
> Tony


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

* [PATCHv8 03/13] I2C: OMAP: Remove reset at init
@ 2012-06-21  9:30               ` Shubhrajyoti
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti @ 2012-06-21  9:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Thursday 21 June 2012 12:50 PM, Tony Lindgren wrote:
> * Shubhrajyoti <shubhrajyoti@ti.com> [120621 00:08]:
>> On Wednesday 20 June 2012 03:59 PM, Tony Lindgren wrote:
>>> See the comments regarding driver specific resets in hwmod code.
>> you mean omap_hwmod.c
>>> The way to set this up is to have a shared inline function in
>>> i2c-omap.h that both the driver and hwmod code can use.
>> hwmod reset function uses oh (omap_hwmod).
>>
>> How could the driver also pass oh ?
>> Could we keep a local copy in driver data?
>>> Eventually hwmod code will do the reset only in late initcall
>>> if no driver is loaded for the device in question.
> There's no need for the driver to know anything about oh.
> The driver just needs to know the iobase.
I will rework to make the hwmod and driver use the same function.
In the meanwhile I will send a minimal/ remaining cleanups/ fixes so that
it might get some time to bake in the next branch.


>
> Tony

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

* Re: [PATCHv8 03/13] I2C: OMAP: Remove reset at init
  2012-06-21  9:30               ` Shubhrajyoti
@ 2012-06-26 11:15                   ` Tony Lindgren
  -1 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-26 11:15 UTC (permalink / raw)
  To: Shubhrajyoti
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, w.sang-bIcnvbaLZ9MEGnE8C9+IrQ

* Shubhrajyoti <shubhrajyoti-l0cyMroinI0@public.gmane.org> [120621 02:35]:
> On Thursday 21 June 2012 12:50 PM, Tony Lindgren wrote:
> > * Shubhrajyoti <shubhrajyoti-l0cyMroinI0@public.gmane.org> [120621 00:08]:
> >> On Wednesday 20 June 2012 03:59 PM, Tony Lindgren wrote:
> >>> See the comments regarding driver specific resets in hwmod code.
> >> you mean omap_hwmod.c
> >>> The way to set this up is to have a shared inline function in
> >>> i2c-omap.h that both the driver and hwmod code can use.
> >> hwmod reset function uses oh (omap_hwmod).
> >>
> >> How could the driver also pass oh ?
> >> Could we keep a local copy in driver data?
> >>> Eventually hwmod code will do the reset only in late initcall
> >>> if no driver is loaded for the device in question.
> > There's no need for the driver to know anything about oh.
> > The driver just needs to know the iobase.
> I will rework to make the hwmod and driver use the same function.
> In the meanwhile I will send a minimal/ remaining cleanups/ fixes so that
> it might get some time to bake in the next branch.

OK thanks!

Tony

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

* [PATCHv8 03/13] I2C: OMAP: Remove reset at init
@ 2012-06-26 11:15                   ` Tony Lindgren
  0 siblings, 0 replies; 58+ messages in thread
From: Tony Lindgren @ 2012-06-26 11:15 UTC (permalink / raw)
  To: linux-arm-kernel

* Shubhrajyoti <shubhrajyoti@ti.com> [120621 02:35]:
> On Thursday 21 June 2012 12:50 PM, Tony Lindgren wrote:
> > * Shubhrajyoti <shubhrajyoti@ti.com> [120621 00:08]:
> >> On Wednesday 20 June 2012 03:59 PM, Tony Lindgren wrote:
> >>> See the comments regarding driver specific resets in hwmod code.
> >> you mean omap_hwmod.c
> >>> The way to set this up is to have a shared inline function in
> >>> i2c-omap.h that both the driver and hwmod code can use.
> >> hwmod reset function uses oh (omap_hwmod).
> >>
> >> How could the driver also pass oh ?
> >> Could we keep a local copy in driver data?
> >>> Eventually hwmod code will do the reset only in late initcall
> >>> if no driver is loaded for the device in question.
> > There's no need for the driver to know anything about oh.
> > The driver just needs to know the iobase.
> I will rework to make the hwmod and driver use the same function.
> In the meanwhile I will send a minimal/ remaining cleanups/ fixes so that
> it might get some time to bake in the next branch.

OK thanks!

Tony

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

end of thread, other threads:[~2012-06-26 11:15 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-18 14:30 [PATCHv8 00/13] I2C cleanups Shubhrajyoti D
2012-06-18 14:30 ` Shubhrajyoti D
2012-06-18 14:30 ` [PATCHv8 01/13] I2C: OMAP: I2C register restore only if context is lost Shubhrajyoti D
2012-06-18 14:30   ` Shubhrajyoti D
2012-06-18 14:30 ` [PATCHv8 02/13] I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK Shubhrajyoti D
2012-06-18 14:30   ` Shubhrajyoti D
2012-06-18 14:30 ` [PATCHv8 05/13] I2C: OMAP: Optimise the remove code Shubhrajyoti D
2012-06-18 14:30   ` Shubhrajyoti D
     [not found] ` <1340029828-20751-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2012-06-18 14:30   ` [PATCHv8 03/13] I2C: OMAP: Remove reset at init Shubhrajyoti D
2012-06-18 14:30     ` Shubhrajyoti D
2012-06-20 10:29     ` Tony Lindgren
2012-06-20 10:29       ` Tony Lindgren
     [not found]       ` <20120620102905.GC12766-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-06-21  7:03         ` Shubhrajyoti
2012-06-21  7:03           ` Shubhrajyoti
2012-06-21  7:20           ` Tony Lindgren
2012-06-21  7:20             ` Tony Lindgren
2012-06-21  9:30             ` Shubhrajyoti
2012-06-21  9:30               ` Shubhrajyoti
     [not found]               ` <4FE2E9D3.5060304-l0cyMroinI0@public.gmane.org>
2012-06-26 11:15                 ` Tony Lindgren
2012-06-26 11:15                   ` Tony Lindgren
2012-06-18 14:30   ` [PATCHv8 04/13] I2C: OMAP: Recover from Bus Busy condition Shubhrajyoti D
2012-06-18 14:30     ` Shubhrajyoti D
2012-06-18 14:30   ` [PATCHv8 06/13] I2C: OMAP: Correct I2C revision for OMAP3 Shubhrajyoti D
2012-06-18 14:30     ` Shubhrajyoti D
     [not found]     ` <1340029828-20751-7-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2012-06-20 10:32       ` Tony Lindgren
2012-06-20 10:32         ` Tony Lindgren
2012-06-20 13:01         ` Shubhrajyoti
2012-06-20 13:01           ` Shubhrajyoti
     [not found]           ` <4FE1C9AC.3020104-l0cyMroinI0@public.gmane.org>
2012-06-20 14:14             ` Tony Lindgren
2012-06-20 14:14               ` Tony Lindgren
     [not found]               ` <20120620141437.GN12766-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-06-21  6:56                 ` Shubhrajyoti Datta
2012-06-21  6:56                   ` Shubhrajyoti Datta
2012-06-18 14:30   ` [PATCHv8 07/13] I2C: OMAP: use devm_* functions Shubhrajyoti D
2012-06-18 14:30     ` Shubhrajyoti D
2012-06-18 14:30   ` [PATCHv8 08/13] I2C: OMAP: Use SET_RUNTIME_PM_OPS Shubhrajyoti D
2012-06-18 14:30     ` Shubhrajyoti D
2012-06-18 14:30   ` [PATCHv8 10/13] I2C: OMAP: simplify num_bytes handling Shubhrajyoti D
2012-06-18 14:30     ` Shubhrajyoti D
     [not found]     ` <1340029828-20751-11-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2012-06-18 15:22       ` Wolfram Sang
2012-06-18 15:22         ` Wolfram Sang
2012-06-18 14:30   ` [PATCHv8 11/13] I2C: OMAP: decrease indentation level on data handling Shubhrajyoti D
2012-06-18 14:30     ` Shubhrajyoti D
2012-06-18 15:25     ` Wolfram Sang
2012-06-18 15:25       ` Wolfram Sang
2012-06-18 14:30   ` [PATCHv8 13/13] I2C: OMAP: simplify omap_i2c_ack_stat() Shubhrajyoti D
2012-06-18 14:30     ` Shubhrajyoti D
     [not found]     ` <1340029828-20751-14-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2012-06-18 15:30       ` Wolfram Sang
2012-06-18 15:30         ` Wolfram Sang
     [not found]         ` <20120618153000.GC10768-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-06-19  9:20           ` Shubhrajyoti Datta
2012-06-19  9:20             ` Shubhrajyoti Datta
2012-06-19 13:33             ` Wolfram Sang
2012-06-19 13:33               ` Wolfram Sang
2012-06-18 15:33   ` [PATCHv8 00/13] I2C cleanups Wolfram Sang
2012-06-18 15:33     ` Wolfram Sang
2012-06-18 14:30 ` [PATCHv8 09/13] I2C: OMAP: Do not initialise the completion everytime Shubhrajyoti D
2012-06-18 14:30   ` Shubhrajyoti D
2012-06-18 14:30 ` [PATCHv8 12/13] I2C: OMAP: add blank lines Shubhrajyoti D
2012-06-18 14:30   ` Shubhrajyoti D

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.