All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv9 0/7] I2C cleanups
@ 2012-06-25 11:11 ` Shubhrajyoti D
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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.
- 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
- the reset patch is dropped will try to rework it as per the 
 review comments recieved.

This applies on Wolfram's i2c-embedded/for-next branch.

Functional testing on omap4430 , 4460 panda 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.

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

Shubhrajyoti D (5):
  I2C: OMAP: I2C register restore only if context is lost
  I2C: OMAP: Optimise the remove code
  I2C: OMAP: Use SET_RUNTIME_PM_OPS
  I2C: OMAP: Do not initialise the completion everytime
  I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK

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

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

-- 
1.7.5.4

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

* [PATCHv9 0/7] I2C cleanups
@ 2012-06-25 11:11 ` Shubhrajyoti D
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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.
- 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
- the reset patch is dropped will try to rework it as per the 
 review comments recieved.

This applies on Wolfram's i2c-embedded/for-next branch.

Functional testing on omap4430 , 4460 panda 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.

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

Shubhrajyoti D (5):
  I2C: OMAP: I2C register restore only if context is lost
  I2C: OMAP: Optimise the remove code
  I2C: OMAP: Use SET_RUNTIME_PM_OPS
  I2C: OMAP: Do not initialise the completion everytime
  I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK

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

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

-- 
1.7.5.4

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

* [PATCHv10 1/7] I2C: OMAP: I2C register restore only if context is lost
  2012-06-25 11:11 ` Shubhrajyoti D
@ 2012-06-25 11:11   ` Shubhrajyoti D
  -1 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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] 28+ messages in thread

* [PATCHv10 1/7] I2C: OMAP: I2C register restore only if context is lost
@ 2012-06-25 11:11   ` Shubhrajyoti D
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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] 28+ messages in thread

* [PATCHv10 2/7] I2C: OMAP: Optimise the remove code
  2012-06-25 11:11 ` Shubhrajyoti D
@ 2012-06-25 11:11     ` Shubhrajyoti D
  -1 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 omap_i2c_remove function may not be needed after
device exit so the memory could be freed.

Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 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 9a54e88..d704f64 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1106,8 +1106,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;
@@ -1204,7 +1203,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] 28+ messages in thread

* [PATCHv10 2/7] I2C: OMAP: Optimise the remove code
@ 2012-06-25 11:11     ` Shubhrajyoti D
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 9a54e88..d704f64 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1106,8 +1106,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;
@@ -1204,7 +1203,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] 28+ messages in thread

* [PATCHv10 3/7] I2C: OMAP: Use SET_RUNTIME_PM_OPS
  2012-06-25 11:11 ` Shubhrajyoti D
@ 2012-06-25 11:11     ` Shubhrajyoti D
  -1 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 d704f64..c771c28 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1130,6 +1130,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)
 {
@@ -1191,15 +1192,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] 28+ messages in thread

* [PATCHv10 3/7] I2C: OMAP: Use SET_RUNTIME_PM_OPS
@ 2012-06-25 11:11     ` Shubhrajyoti D
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 d704f64..c771c28 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1130,6 +1130,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)
 {
@@ -1191,15 +1192,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] 28+ messages in thread

* [PATCHv10 4/7] I2C: OMAP: Do not initialise the completion everytime
  2012-06-25 11:11 ` Shubhrajyoti D
@ 2012-06-25 11:11   ` Shubhrajyoti D
  -1 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 c771c28..f1109f4 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -493,7 +493,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;
@@ -1003,6 +1003,7 @@ omap_i2c_probe(struct platform_device *pdev)
 	}
 
 	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] 28+ messages in thread

* [PATCHv10 4/7] I2C: OMAP: Do not initialise the completion everytime
@ 2012-06-25 11:11   ` Shubhrajyoti D
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 c771c28..f1109f4 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -493,7 +493,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;
@@ -1003,6 +1003,7 @@ omap_i2c_probe(struct platform_device *pdev)
 	}
 
 	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] 28+ messages in thread

* [PATCHv10 5/7] I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK
  2012-06-25 11:11 ` Shubhrajyoti D
@ 2012-06-25 11:11   ` Shubhrajyoti D
  -1 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 f1109f4..8344ad030 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] 28+ messages in thread

* [PATCHv10 5/7] I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK
@ 2012-06-25 11:11   ` Shubhrajyoti D
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 f1109f4..8344ad030 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] 28+ messages in thread

* [PATCHv10 6/7] I2C: OMAP: Correct I2C revision for OMAP3
  2012-06-25 11:11 ` Shubhrajyoti D
@ 2012-06-25 11:11     ` Shubhrajyoti D
  -1 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 8344ad030..0557b0d 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))
@@ -305,7 +305,7 @@ static int omap_i2c_init(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 <<
@@ -1021,7 +1021,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)) {
@@ -1039,7 +1039,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] 28+ messages in thread

* [PATCHv10 6/7] I2C: OMAP: Correct I2C revision for OMAP3
@ 2012-06-25 11:11     ` Shubhrajyoti D
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 8344ad030..0557b0d 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))
@@ -305,7 +305,7 @@ static int omap_i2c_init(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 <<
@@ -1021,7 +1021,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)) {
@@ -1039,7 +1039,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] 28+ messages in thread

* [PATCHv10 7/7] I2C: OMAP: Recover from Bus Busy condition
  2012-06-25 11:11 ` Shubhrajyoti D
@ 2012-06-25 11:11   ` Shubhrajyoti D
  -1 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 UTC (permalink / raw)
  To: linux-omap
  Cc: linux-i2c, linux-arm-kernel, ben-linux, tony, w.sang,
	Vikram Pandita, Jon Hunter, Shubhrajyoti D

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 |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 0557b0d..421dcd7 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)
@@ -460,6 +459,29 @@ static int omap_i2c_wait_for_bb(struct omap_i2c_dev *dev)
 
 	return 0;
 }
+/*
+ * 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_init(dev);
+	return omap_i2c_wait_for_bb(dev);
+}
 
 /*
  * Low level master read/write transaction.
@@ -586,6 +608,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)
@@ -654,6 +678,7 @@ static inline void i2c_omap_errata_i207(struct omap_i2c_dev *dev, u16 stat)
 
 		}
 	}
+	return 0;
 }
 
 /* rev1 devices are apparently only on some 15xx */
-- 
1.7.5.4


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

* [PATCHv10 7/7] I2C: OMAP: Recover from Bus Busy condition
@ 2012-06-25 11:11   ` Shubhrajyoti D
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti D @ 2012-06-25 11:11 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 |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 0557b0d..421dcd7 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)
@@ -460,6 +459,29 @@ static int omap_i2c_wait_for_bb(struct omap_i2c_dev *dev)
 
 	return 0;
 }
+/*
+ * 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
+	 *@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_init(dev);
+	return omap_i2c_wait_for_bb(dev);
+}
 
 /*
  * Low level master read/write transaction.
@@ -586,6 +608,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)
@@ -654,6 +678,7 @@ static inline void i2c_omap_errata_i207(struct omap_i2c_dev *dev, u16 stat)
 
 		}
 	}
+	return 0;
 }
 
 /* rev1 devices are apparently only on some 15xx */
-- 
1.7.5.4

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

* Re: [PATCHv10 1/7] I2C: OMAP: I2C register restore only if context is lost
  2012-06-25 11:11   ` Shubhrajyoti D
@ 2012-06-25 12:30     ` Felipe Balbi
  -1 siblings, 0 replies; 28+ messages in thread
From: Felipe Balbi @ 2012-06-25 12:30 UTC (permalink / raw)
  To: Shubhrajyoti D
  Cc: linux-omap, linux-i2c, linux-arm-kernel, ben-linux, tony, w.sang,
	Kevin Hilman

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

Hi,

On Mon, Jun 25, 2012 at 04:41:36PM +0530, Shubhrajyoti D wrote:
>  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>

how will this ever work with DT ? I say we get rid of the OMAP-specific
API and build this "context lost" status directly on dev_pm_info and
have something like pm_runtime_lost_context() or something with pm QoS
tell you if a device has lost its context.

Also, your commit log doesn't really state any problems you might have
reached before, or any improvements wrt latency coming out of suspend
and so on.

IMHO, drivers need a generic way to differentiate if they're resuming
from OFF or RET, otherwise we will end up with a bunch of OMAP-specific
hackery on all drivers

-- 
balbi

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

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

* [PATCHv10 1/7] I2C: OMAP: I2C register restore only if context is lost
@ 2012-06-25 12:30     ` Felipe Balbi
  0 siblings, 0 replies; 28+ messages in thread
From: Felipe Balbi @ 2012-06-25 12:30 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Mon, Jun 25, 2012 at 04:41:36PM +0530, Shubhrajyoti D wrote:
>  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>

how will this ever work with DT ? I say we get rid of the OMAP-specific
API and build this "context lost" status directly on dev_pm_info and
have something like pm_runtime_lost_context() or something with pm QoS
tell you if a device has lost its context.

Also, your commit log doesn't really state any problems you might have
reached before, or any improvements wrt latency coming out of suspend
and so on.

IMHO, drivers need a generic way to differentiate if they're resuming
from OFF or RET, otherwise we will end up with a bunch of OMAP-specific
hackery on all drivers

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120625/f28aa29c/attachment.sig>

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

* Re: [PATCHv10 4/7] I2C: OMAP: Do not initialise the completion everytime
  2012-06-25 11:11   ` Shubhrajyoti D
@ 2012-06-25 12:33       ` Felipe Balbi
  -1 siblings, 0 replies; 28+ messages in thread
From: Felipe Balbi @ 2012-06-25 12: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,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ

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

Hi,

On Mon, Jun 25, 2012 at 04:41:39PM +0530, Shubhrajyoti D wrote:
> Use INIT_COMPLETION instead of init_completion in transfer.
> 
> Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>

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

> ---
>  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 c771c28..f1109f4 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -493,7 +493,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;
> @@ -1003,6 +1003,7 @@ omap_i2c_probe(struct platform_device *pdev)
>  	}
>  
>  	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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
balbi

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

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

* [PATCHv10 4/7] I2C: OMAP: Do not initialise the completion everytime
@ 2012-06-25 12:33       ` Felipe Balbi
  0 siblings, 0 replies; 28+ messages in thread
From: Felipe Balbi @ 2012-06-25 12:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Mon, Jun 25, 2012 at 04:41:39PM +0530, Shubhrajyoti D wrote:
> Use INIT_COMPLETION instead of init_completion in transfer.
> 
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>

Reviewed-by: Felipe Balbi <balbi@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 c771c28..f1109f4 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -493,7 +493,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;
> @@ -1003,6 +1003,7 @@ omap_i2c_probe(struct platform_device *pdev)
>  	}
>  
>  	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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120625/819e5806/attachment.sig>

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

* Re: [PATCHv10 5/7] I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK
  2012-06-25 11:11   ` Shubhrajyoti D
@ 2012-06-25 12:34       ` Felipe Balbi
  -1 siblings, 0 replies; 28+ messages in thread
From: Felipe Balbi @ 2012-06-25 12:34 UTC (permalink / raw)
  To: Shubhrajyoti D
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ

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

Hi,

On Mon, Jun 25, 2012 at 04:41:40PM +0530, Shubhrajyoti D wrote:
> 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-l0cyMroinI0@public.gmane.org>

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

> ---
>  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 f1109f4..8344ad030 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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
balbi

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

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

* [PATCHv10 5/7] I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK
@ 2012-06-25 12:34       ` Felipe Balbi
  0 siblings, 0 replies; 28+ messages in thread
From: Felipe Balbi @ 2012-06-25 12:34 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Mon, Jun 25, 2012 at 04:41:40PM +0530, Shubhrajyoti D wrote:
> 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>

Reviewed-by: Felipe Balbi <balbi@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 f1109f4..8344ad030 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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120625/84938d01/attachment-0001.sig>

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

* Re: [PATCHv10 6/7] I2C: OMAP: Correct I2C revision for OMAP3
  2012-06-25 11:11     ` Shubhrajyoti D
@ 2012-06-25 12:35         ` Felipe Balbi
  -1 siblings, 0 replies; 28+ messages in thread
From: Felipe Balbi @ 2012-06-25 12:35 UTC (permalink / raw)
  To: Shubhrajyoti D
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Jon Hunter

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

On Mon, Jun 25, 2012 at 04:41:41PM +0530, Shubhrajyoti D wrote:
> 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>

Reviewed-by: Felipe Balbi <balbi-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 8344ad030..0557b0d 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))
> @@ -305,7 +305,7 @@ static int omap_i2c_init(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 <<
> @@ -1021,7 +1021,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)) {
> @@ -1039,7 +1039,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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
balbi

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

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

* [PATCHv10 6/7] I2C: OMAP: Correct I2C revision for OMAP3
@ 2012-06-25 12:35         ` Felipe Balbi
  0 siblings, 0 replies; 28+ messages in thread
From: Felipe Balbi @ 2012-06-25 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 25, 2012 at 04:41:41PM +0530, Shubhrajyoti D wrote:
> 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>

Reviewed-by: Felipe Balbi <balbi@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 8344ad030..0557b0d 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))
> @@ -305,7 +305,7 @@ static int omap_i2c_init(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 <<
> @@ -1021,7 +1021,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)) {
> @@ -1039,7 +1039,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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120625/c9cb3632/attachment.sig>

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

* Re: [PATCHv10 1/7] I2C: OMAP: I2C register restore only if context is lost
  2012-06-25 12:30     ` Felipe Balbi
@ 2012-06-26  6:08       ` Shubhrajyoti
  -1 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti @ 2012-06-26  6:08 UTC (permalink / raw)
  To: balbi
  Cc: linux-omap, linux-i2c, linux-arm-kernel, ben-linux, tony, w.sang,
	Kevin Hilman

On Monday 25 June 2012 06:00 PM, Felipe Balbi wrote:
>> Cc: Kevin Hilman <khilman@ti.com>
>> > Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> how will this ever work with DT ? 
What you say makes sense however that is what currently
most of the omap drivers do.

Will check on this.
> I say we get rid of the OMAP-specific
> API and build this "context lost" status directly on dev_pm_info and
> have something like pm_runtime_lost_context() or something with pm QoS
> tell you if a device has lost its context.
>
> Also, your commit log doesn't really state any problems you might have
> reached before, or any improvements wrt latency coming out of suspend
> and so on.
>
> IMHO, drivers need a generic way to differentiate if they're resuming
> from OFF or RET, otherwise we will end up with a bunch of OMAP-specific
> hackery on all drivers



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

* [PATCHv10 1/7] I2C: OMAP: I2C register restore only if context is lost
@ 2012-06-26  6:08       ` Shubhrajyoti
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti @ 2012-06-26  6:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Monday 25 June 2012 06:00 PM, Felipe Balbi wrote:
>> Cc: Kevin Hilman <khilman@ti.com>
>> > Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> how will this ever work with DT ? 
What you say makes sense however that is what currently
most of the omap drivers do.

Will check on this.
> I say we get rid of the OMAP-specific
> API and build this "context lost" status directly on dev_pm_info and
> have something like pm_runtime_lost_context() or something with pm QoS
> tell you if a device has lost its context.
>
> Also, your commit log doesn't really state any problems you might have
> reached before, or any improvements wrt latency coming out of suspend
> and so on.
>
> IMHO, drivers need a generic way to differentiate if they're resuming
> from OFF or RET, otherwise we will end up with a bunch of OMAP-specific
> hackery on all drivers

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

* Re: [PATCHv10 1/7] I2C: OMAP: I2C register restore only if context is lost
  2012-06-26  6:08       ` Shubhrajyoti
@ 2012-06-26 11:23           ` Shubhrajyoti
  -1 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti @ 2012-06-26 11:23 UTC (permalink / raw)
  To: balbi-l0cyMroinI0
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, tony-4v6yS6AI5VpBDgjK7y7TUQ,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Kevin Hilman

On Tuesday 26 June 2012 11:38 AM, Shubhrajyoti wrote:
> On Monday 25 June 2012 06:00 PM, Felipe Balbi wrote:
>>> Cc: Kevin Hilman <khilman-l0cyMroinI0@public.gmane.org>
>>>> Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
>> how will this ever work with DT ? 
> What you say makes sense however that is what currently
> most of the omap drivers do.
>
> Will check on this.
>> I say we get rid of the OMAP-specific
>> API and build this "context lost" status directly on dev_pm_info and
>> have something like pm_runtime_lost_context() or something with pm QoS
>> tell you if a device has lost its context.
>>
>> Also, your commit log doesn't really state any problems you might have
>> reached before,
Didnt see any issues while reviewing found that the restore was done always.
>>  or any improvements wrt latency coming out of suspend
>> and so on.
I am only restoring only 4-5 registers.

>>
>> IMHO, drivers need a generic way to differentiate if they're resuming
>> from OFF or RET, otherwise we will end up with a bunch of OMAP-specific
>> hackery on all drivers
>

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

* [PATCHv10 1/7] I2C: OMAP: I2C register restore only if context is lost
@ 2012-06-26 11:23           ` Shubhrajyoti
  0 siblings, 0 replies; 28+ messages in thread
From: Shubhrajyoti @ 2012-06-26 11:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday 26 June 2012 11:38 AM, Shubhrajyoti wrote:
> On Monday 25 June 2012 06:00 PM, Felipe Balbi wrote:
>>> Cc: Kevin Hilman <khilman@ti.com>
>>>> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
>> how will this ever work with DT ? 
> What you say makes sense however that is what currently
> most of the omap drivers do.
>
> Will check on this.
>> I say we get rid of the OMAP-specific
>> API and build this "context lost" status directly on dev_pm_info and
>> have something like pm_runtime_lost_context() or something with pm QoS
>> tell you if a device has lost its context.
>>
>> Also, your commit log doesn't really state any problems you might have
>> reached before,
Didnt see any issues while reviewing found that the restore was done always.
>>  or any improvements wrt latency coming out of suspend
>> and so on.
I am only restoring only 4-5 registers.

>>
>> IMHO, drivers need a generic way to differentiate if they're resuming
>> from OFF or RET, otherwise we will end up with a bunch of OMAP-specific
>> hackery on all drivers
>

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

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

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-25 11:11 [PATCHv9 0/7] I2C cleanups Shubhrajyoti D
2012-06-25 11:11 ` Shubhrajyoti D
2012-06-25 11:11 ` [PATCHv10 1/7] I2C: OMAP: I2C register restore only if context is lost Shubhrajyoti D
2012-06-25 11:11   ` Shubhrajyoti D
2012-06-25 12:30   ` Felipe Balbi
2012-06-25 12:30     ` Felipe Balbi
2012-06-26  6:08     ` Shubhrajyoti
2012-06-26  6:08       ` Shubhrajyoti
     [not found]       ` <4FE951C7.8070907-l0cyMroinI0@public.gmane.org>
2012-06-26 11:23         ` Shubhrajyoti
2012-06-26 11:23           ` Shubhrajyoti
     [not found] ` <1340622702-21622-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2012-06-25 11:11   ` [PATCHv10 2/7] I2C: OMAP: Optimise the remove code Shubhrajyoti D
2012-06-25 11:11     ` Shubhrajyoti D
2012-06-25 11:11   ` [PATCHv10 3/7] I2C: OMAP: Use SET_RUNTIME_PM_OPS Shubhrajyoti D
2012-06-25 11:11     ` Shubhrajyoti D
2012-06-25 11:11   ` [PATCHv10 6/7] I2C: OMAP: Correct I2C revision for OMAP3 Shubhrajyoti D
2012-06-25 11:11     ` Shubhrajyoti D
     [not found]     ` <1340622702-21622-7-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2012-06-25 12:35       ` Felipe Balbi
2012-06-25 12:35         ` Felipe Balbi
2012-06-25 11:11 ` [PATCHv10 4/7] I2C: OMAP: Do not initialise the completion everytime Shubhrajyoti D
2012-06-25 11:11   ` Shubhrajyoti D
     [not found]   ` <1340622702-21622-5-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2012-06-25 12:33     ` Felipe Balbi
2012-06-25 12:33       ` Felipe Balbi
2012-06-25 11:11 ` [PATCHv10 5/7] I2C: OMAP: Remove the definition of SYSS_RESETDONE_MASK Shubhrajyoti D
2012-06-25 11:11   ` Shubhrajyoti D
     [not found]   ` <1340622702-21622-6-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2012-06-25 12:34     ` Felipe Balbi
2012-06-25 12:34       ` Felipe Balbi
2012-06-25 11:11 ` [PATCHv10 7/7] I2C: OMAP: Recover from Bus Busy condition Shubhrajyoti D
2012-06-25 11:11   ` 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.