linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/11] i2c: pxa: support hardware lock
@ 2012-11-08 14:17 Leo Song
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:17 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Jett.Zhou,
	Yi Zhang

From: "Jett.Zhou" <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

Append hardware lock support since it's required by Marvell PXA910

Change-Id: I8cd9cdf76785ecf4b6c6fa433d577cb7e3d9956b
Signed-off-by: Jett.Zhou <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Yi Zhang <yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 1034d93..73a1404 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1160,6 +1160,9 @@ static int i2c_pxa_probe(struct platform_device *dev)
 		i2c->slave = plat->slave;
 #endif
 		i2c->adap.class = plat->class;
+		i2c->adap.hardware_lock = plat->hardware_lock;
+		i2c->adap.hardware_unlock = plat->hardware_unlock;
+		i2c->adap.hardware_trylock = plat->hardware_trylock;
 	}
 
 	clk_enable(i2c->clk);
diff --git a/include/linux/i2c/pxa-i2c.h b/include/linux/i2c/pxa-i2c.h
index 1a9f65e..eec9954 100644
--- a/include/linux/i2c/pxa-i2c.h
+++ b/include/linux/i2c/pxa-i2c.h
@@ -67,6 +67,9 @@ struct i2c_pxa_platform_data {
 	unsigned int		class;
 	unsigned int		use_pio :1;
 	unsigned int		fast_mode :1;
+	void			(*hardware_lock)(void);
+	void			(*hardware_unlock)(void);
+	int			(*hardware_trylock)(void);
 };
 
 extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
-- 
1.7.5.4

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

* [PATCH 02/11] i2c: pxa: support pxa910 in id table
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
@ 2012-11-08 14:17   ` Leo Song
  2012-11-08 14:17   ` [PATCH 03/11] i2c: pxa: add more error handling for i2c controller Leo Song
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:17 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Jett.Zhou,
	Yi Zhang

From: "Jett.Zhou" <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

Since it needs to adjust i2c standard and fast mode by customizing
LCR&WCR value for pxa910, so add pxa910 in the id table;

Change-Id: Ibe07f36758acf17e31845f264109fdd3d56b6bff
Signed-off-by: Jett.Zhou <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Yi Zhang <yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 73a1404..063ba23 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -47,12 +47,15 @@ struct pxa_reg_layout {
 	u32 icr;
 	u32 isr;
 	u32 isar;
+	u32 ilcr;
+	u32 iwcr;
 };
 
 enum pxa_i2c_types {
 	REGS_PXA2XX,
 	REGS_PXA3XX,
 	REGS_CE4100,
+	REGS_PXA910,
 };
 
 /*
@@ -80,12 +83,22 @@ static struct pxa_reg_layout pxa_reg_layout[] = {
 		.isr =	0x04,
 		/* no isar register */
 	},
+	[REGS_PXA910] = {
+		.ibmr = 0x00,
+		.idbr = 0x08,
+		.icr =	0x10,
+		.isr =	0x18,
+		.isar = 0x20,
+		.ilcr = 0x28,
+		.iwcr = 0x30,
+	},
 };
 
 static const struct platform_device_id i2c_pxa_id_table[] = {
 	{ "pxa2xx-i2c",		REGS_PXA2XX },
 	{ "pxa3xx-pwri2c",	REGS_PXA3XX },
 	{ "ce4100-i2c",		REGS_CE4100 },
+	{ "pxa910-i2c",		REGS_PXA910 },
 	{ },
 };
 MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);
@@ -148,6 +161,8 @@ struct pxa_i2c {
 	void __iomem		*reg_icr;
 	void __iomem		*reg_isr;
 	void __iomem		*reg_isar;
+	void __iomem		*reg_ilcr;
+	void __iomem		*reg_iwcr;
 
 	unsigned long		iobase;
 	unsigned long		iosize;
@@ -155,6 +170,8 @@ struct pxa_i2c {
 	int			irq;
 	unsigned int		use_pio :1;
 	unsigned int		fast_mode :1;
+	unsigned int		ilcr;
+	unsigned int		iwcr;
 };
 
 #define _IBMR(i2c)	((i2c)->reg_ibmr)
@@ -162,6 +179,8 @@ struct pxa_i2c {
 #define _ICR(i2c)	((i2c)->reg_icr)
 #define _ISR(i2c)	((i2c)->reg_isr)
 #define _ISAR(i2c)	((i2c)->reg_isar)
+#define _ILCR(i2c)	((i2c)->reg_ilcr)
+#define _IWCR(i2c)	((i2c)->reg_iwcr)
 
 /*
  * I2C Slave mode address
@@ -460,6 +479,17 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
 	/* set control register values */
 	writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c));
 
+	/* There are 2 multi-masters on the I2C bus - APPS and COMM
+	 * It is important both uses the standard frequency
+	 * Adjust clock by ILCR, IWCR is important
+	 */
+	if (i2c->ilcr)
+		writel(i2c->ilcr, _ILCR(i2c));
+	if (i2c->iwcr)
+		writel(i2c->iwcr, _IWCR(i2c));
+	udelay(2);
+
+
 #ifdef CONFIG_I2C_PXA_SLAVE
 	dev_info(&i2c->adap.dev, "Enabling slave mode\n");
 	writel(readl(_ICR(i2c)) | ICR_SADIE | ICR_ALDIE | ICR_SSDIE, _ICR(i2c));
@@ -1146,6 +1176,8 @@ static int i2c_pxa_probe(struct platform_device *dev)
 	i2c->reg_isr = i2c->reg_base + pxa_reg_layout[i2c_type].isr;
 	if (i2c_type != REGS_CE4100)
 		i2c->reg_isar = i2c->reg_base + pxa_reg_layout[i2c_type].isar;
+	i2c->reg_ilcr = i2c->reg_base + pxa_reg_layout[i2c_type].ilcr;
+	i2c->reg_iwcr = i2c->reg_base + pxa_reg_layout[i2c_type].iwcr;
 
 	i2c->iobase = res->start;
 	i2c->iosize = resource_size(res);
@@ -1163,6 +1195,8 @@ static int i2c_pxa_probe(struct platform_device *dev)
 		i2c->adap.hardware_lock = plat->hardware_lock;
 		i2c->adap.hardware_unlock = plat->hardware_unlock;
 		i2c->adap.hardware_trylock = plat->hardware_trylock;
+		i2c->ilcr = plat->ilcr;
+		i2c->iwcr = plat->iwcr;
 	}
 
 	clk_enable(i2c->clk);
diff --git a/include/linux/i2c/pxa-i2c.h b/include/linux/i2c/pxa-i2c.h
index eec9954..2a03e91 100644
--- a/include/linux/i2c/pxa-i2c.h
+++ b/include/linux/i2c/pxa-i2c.h
@@ -67,6 +67,8 @@ struct i2c_pxa_platform_data {
 	unsigned int		class;
 	unsigned int		use_pio :1;
 	unsigned int		fast_mode :1;
+	unsigned int		ilcr;
+	unsigned int		iwcr;
 	void			(*hardware_lock)(void);
 	void			(*hardware_unlock)(void);
 	int			(*hardware_trylock)(void);
-- 
1.7.5.4

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

* [PATCH 03/11] i2c: pxa: add more error handling for i2c controller
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
  2012-11-08 14:17   ` [PATCH 02/11] i2c: pxa: support pxa910 in id table Leo Song
@ 2012-11-08 14:17   ` Leo Song
  2012-11-08 14:17   ` [PATCH 04/11] i2c: pxa: fix irq unbalanced warning Leo Song
                     ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:17 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Jett.Zhou

From: "Jett.Zhou" <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

1 enable debug function to dump more info if there is error of i2c;
2 add i2c controller reset operation if there is "timeout" error;
3 add enable_irq/disable_irq for the i2c irq mode operation to avoid
"spurious irq" caused by CP polling mode;

Change-Id: Ia3c1bf54e71cbfb48edc259d7f46bec524c5c43a
Signed-off-by: Jett.Zhou <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 063ba23..cca387b 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -144,6 +144,7 @@ struct pxa_i2c {
 	unsigned int		msg_idx;
 	unsigned int		msg_ptr;
 	unsigned int		slave_addr;
+	unsigned int		req_slave_addr;
 
 	struct i2c_adapter	adap;
 	struct clk		*clk;
@@ -187,6 +188,9 @@ struct pxa_i2c {
  */
 #define I2C_PXA_SLAVE_ADDR      0x1
 
+#define DEBUG 0
+static void i2c_pxa_reset(struct pxa_i2c *i2c);
+
 #ifdef DEBUG
 
 struct bits {
@@ -267,11 +271,13 @@ static void i2c_pxa_show_state(struct pxa_i2c *i2c, int lno, const char *fname)
 static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why)
 {
 	unsigned int i;
-	printk(KERN_ERR "i2c: error: %s\n", why);
+	printk(KERN_ERR"i2c: <%s> slave_0x%x error: %s\n", i2c->adap.name,
+		i2c->req_slave_addr >> 1, why);
 	printk(KERN_ERR "i2c: msg_num: %d msg_idx: %d msg_ptr: %d\n",
 		i2c->msg_num, i2c->msg_idx, i2c->msg_ptr);
-	printk(KERN_ERR "i2c: ICR: %08x ISR: %08x\n",
-	       readl(_ICR(i2c)), readl(_ISR(i2c)));
+	printk(KERN_ERR "i2c: IBMR: %08x IDBR: %08x ICR: %08x ISR: %08x\n",
+		readl(_IBMR(i2c)), readl(_IDBR(i2c)), readl(_ICR(i2c)),
+		readl(_ISR(i2c)));
 	printk(KERN_DEBUG "i2c: log: ");
 	for (i = 0; i < i2c->irqlogidx; i++)
 		printk("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]);
@@ -802,6 +808,9 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
 	}
 
  out:
+	if (ret < 0)
+		i2c_pxa_reset(i2c);
+
 	return ret;
 }
 
@@ -933,6 +942,7 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr)
 		 * Write the next address.
 		 */
 		writel(i2c_pxa_addr_byte(i2c->msg), _IDBR(i2c));
+		i2c->req_slave_addr = i2c_pxa_addr_byte(i2c->msg);
 
 		/*
 		 * And trigger a repeated start, and send the byte.
@@ -1038,6 +1048,7 @@ static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num
 	struct pxa_i2c *i2c = adap->algo_data;
 	int ret, i;
 
+	enable_irq(i2c->irq);
 	for (i = adap->retries; i >= 0; i--) {
 		ret = i2c_pxa_do_xfer(i2c, msgs, num);
 		if (ret != I2C_RETRY)
@@ -1051,6 +1062,7 @@ static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num
 	ret = -EREMOTEIO;
  out:
 	i2c_pxa_set_slave(i2c, ret);
+	disable_irq(i2c->irq);
 	return ret;
 }
 
-- 
1.7.5.4

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

* [PATCH 04/11] i2c: pxa: fix irq unbalanced warning
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
  2012-11-08 14:17   ` [PATCH 02/11] i2c: pxa: support pxa910 in id table Leo Song
  2012-11-08 14:17   ` [PATCH 03/11] i2c: pxa: add more error handling for i2c controller Leo Song
@ 2012-11-08 14:17   ` Leo Song
  2012-11-08 14:17   ` [PATCH 05/11] i2c: pxa: add bus reset for platform data; Leo Song
                     ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:17 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Yi Zhang

From: Yi Zhang <yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

Change-Id: Ic8b247e46950bc6b9bc0b9dfb655a3aabbd15638
Signed-off-by: Yi Zhang <yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index cca387b..833ab4d 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1225,6 +1225,8 @@ static int i2c_pxa_probe(struct platform_device *dev)
 
 	i2c_pxa_reset(i2c);
 
+	disable_irq(i2c->irq);
+
 	i2c->adap.algo_data = i2c;
 	i2c->adap.dev.parent = &dev->dev;
 #ifdef CONFIG_OF
-- 
1.7.5.4

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

* [PATCH 05/11] i2c: pxa: add bus reset for platform data;
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
                     ` (2 preceding siblings ...)
  2012-11-08 14:17   ` [PATCH 04/11] i2c: pxa: fix irq unbalanced warning Leo Song
@ 2012-11-08 14:17   ` Leo Song
  2012-11-08 14:17   ` [PATCH 06/11] i2c: pxa: Keep i2c clock enabled when system suspends/resumes Leo Song
                     ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:17 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Xiaofan Tian, Jett.Zhou

From: Xiaofan Tian <tianxf-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

Since there is some problemic i2c slave devices on some platforms such
as dkb sometimes, it will drop down sda and make i2c bus hang, at that
time, it need to config scl/sda into gpio to simulate "stop" sequence to
recover i2c bus, so add this interface in platform data;

Change-Id: I2f7cf98d2f6b7a3a6d3ebac840b8f89f0b31fae6
Signed-off-by: Jett.Zhou <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Xiaofan Tian <tianxf-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 833ab4d..cab0792 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -271,6 +271,9 @@ static void i2c_pxa_show_state(struct pxa_i2c *i2c, int lno, const char *fname)
 static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why)
 {
 	unsigned int i;
+	struct i2c_pxa_platform_data *plat =
+		(i2c->adap.dev.parent)->platform_data;
+
 	printk(KERN_ERR"i2c: <%s> slave_0x%x error: %s\n", i2c->adap.name,
 		i2c->req_slave_addr >> 1, why);
 	printk(KERN_ERR "i2c: msg_num: %d msg_idx: %d msg_ptr: %d\n",
@@ -282,6 +285,12 @@ static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why)
 	for (i = 0; i < i2c->irqlogidx; i++)
 		printk("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]);
 	printk("\n");
+	if (strcmp(why, "exhausted retries") != 0) {
+		if (plat && plat->i2c_bus_reset)
+			plat->i2c_bus_reset();
+		/* reset i2c contorler when it's fail */
+		i2c_pxa_reset(i2c);
+	}
 }
 
 #else /* ifdef DEBUG */
diff --git a/include/linux/i2c/pxa-i2c.h b/include/linux/i2c/pxa-i2c.h
index 2a03e91..a247f48 100644
--- a/include/linux/i2c/pxa-i2c.h
+++ b/include/linux/i2c/pxa-i2c.h
@@ -72,6 +72,7 @@ struct i2c_pxa_platform_data {
 	void			(*hardware_lock)(void);
 	void			(*hardware_unlock)(void);
 	int			(*hardware_trylock)(void);
+	void			(*i2c_bus_reset) (void);
 };
 
 extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
-- 
1.7.5.4

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

* [PATCH 06/11] i2c: pxa: Keep i2c clock enabled when system suspends/resumes.
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
                     ` (3 preceding siblings ...)
  2012-11-08 14:17   ` [PATCH 05/11] i2c: pxa: add bus reset for platform data; Leo Song
@ 2012-11-08 14:17   ` Leo Song
  2012-11-08 14:18   ` [PATCH 07/11] i2c: pxa: keep i2c irq on in suspend Leo Song
                     ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:17 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Xiaofan Tian, Jett.Zhou

From: Xiaofan Tian <tianxf-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

If a PMIC interrupt occurs after i2c clock disables, since PMIC
interrupt handler uses i2c bus, phone hang or key value missing might
happen. So i2c clock should keep enabled when system suspends/resumes.

Change-Id: I983c5d3fe2dc18149d5d836d986e65e356913b47
Signed-off-by: Jett.Zhou <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index cab0792..ad6e69b 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1295,45 +1295,12 @@ static int __exit i2c_pxa_remove(struct platform_device *dev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int i2c_pxa_suspend_noirq(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct pxa_i2c *i2c = platform_get_drvdata(pdev);
-
-	clk_disable(i2c->clk);
-
-	return 0;
-}
-
-static int i2c_pxa_resume_noirq(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct pxa_i2c *i2c = platform_get_drvdata(pdev);
-
-	clk_enable(i2c->clk);
-	i2c_pxa_reset(i2c);
-
-	return 0;
-}
-
-static const struct dev_pm_ops i2c_pxa_dev_pm_ops = {
-	.suspend_noirq = i2c_pxa_suspend_noirq,
-	.resume_noirq = i2c_pxa_resume_noirq,
-};
-
-#define I2C_PXA_DEV_PM_OPS (&i2c_pxa_dev_pm_ops)
-#else
-#define I2C_PXA_DEV_PM_OPS NULL
-#endif
-
 static struct platform_driver i2c_pxa_driver = {
 	.probe		= i2c_pxa_probe,
 	.remove		= __exit_p(i2c_pxa_remove),
 	.driver		= {
 		.name	= "pxa2xx-i2c",
 		.owner	= THIS_MODULE,
-		.pm	= I2C_PXA_DEV_PM_OPS,
 		.of_match_table = i2c_pxa_dt_ids,
 	},
 	.id_table	= i2c_pxa_id_table,
-- 
1.7.5.4

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

* [PATCH 07/11] i2c: pxa: keep i2c irq on in suspend
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
                     ` (4 preceding siblings ...)
  2012-11-08 14:17   ` [PATCH 06/11] i2c: pxa: Keep i2c clock enabled when system suspends/resumes Leo Song
@ 2012-11-08 14:18   ` Leo Song
  2012-11-08 14:18   ` [PATCH 08/11] i2c: pxa: bugfix the slave addr in the transaction Leo Song
                     ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:18 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Xiaofan Tian, Raul Xiong

From: Xiaofan Tian <tianxf-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

During suspending there may still be some i2c accessing, if don't keep
i2c irq on there may be i2c access timeout if i2c is in irq mode.

Change-Id: I43689ab9ee054d235678de83ea4424c03074ea62
Signed-off-by: Raul Xiong <xjian-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Xiaofan Tian <tianxf-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index ad6e69b..f4bbbcc 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1226,8 +1226,9 @@ static int i2c_pxa_probe(struct platform_device *dev)
 		i2c->adap.algo = &i2c_pxa_pio_algorithm;
 	} else {
 		i2c->adap.algo = &i2c_pxa_algorithm;
-		ret = request_irq(irq, i2c_pxa_handler, IRQF_SHARED,
-				  i2c->adap.name, i2c);
+		ret = request_irq(irq, i2c_pxa_handler,
+				IRQF_SHARED | IRQF_NO_SUSPEND,
+				i2c->adap.name, i2c);
 		if (ret)
 			goto ereqirq;
 	}
-- 
1.7.5.4

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

* [PATCH 08/11] i2c: pxa: bugfix the slave addr in the transaction
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
                     ` (5 preceding siblings ...)
  2012-11-08 14:18   ` [PATCH 07/11] i2c: pxa: keep i2c irq on in suspend Leo Song
@ 2012-11-08 14:18   ` Leo Song
  2012-11-08 14:18   ` [PATCH 09/11] i2c: pxa: add qos as constraint for cpu-idle Leo Song
                     ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:18 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Jett.Zhou

From: "Jett.Zhou" <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

The slave address of i2c device should be got in the start of the
msg tranaction, or it will dump wrong slave addr and make confusion.

Change-Id: I9520c245e6bb0a9a1e478aa275841842b588d4cd
Signed-off-by: Jett.Zhou <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index f4bbbcc..5893110 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -677,6 +677,7 @@ static inline void i2c_pxa_start_message(struct pxa_i2c *i2c)
 	 * Step 1: target slave address into IDBR
 	 */
 	writel(i2c_pxa_addr_byte(i2c->msg), _IDBR(i2c));
+	i2c->req_slave_addr = i2c_pxa_addr_byte(i2c->msg);
 
 	/*
 	 * Step 2: initiate the write.
-- 
1.7.5.4

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

* [PATCH 09/11] i2c: pxa: add qos as constraint for cpu-idle
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
                     ` (6 preceding siblings ...)
  2012-11-08 14:18   ` [PATCH 08/11] i2c: pxa: bugfix the slave addr in the transaction Leo Song
@ 2012-11-08 14:18   ` Leo Song
  2012-11-08 14:18   ` [PATCH 10/11] i2c: pxa: modify the parameters of i2c_bus_reset() Leo Song
  2012-11-08 14:18   ` [PATCH 11/11] i2c: pxa: no need slave addr for i2c master mode reset Leo Song
  9 siblings, 0 replies; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:18 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Jett.Zhou

From: "Jett.Zhou" <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

Add qos as constraint for cpu-idle, which is standard way, then
sysfs could get accurae result.

Change-Id: I4165e01ca2c30f8422b4b4850497c70233d741f8
Signed-off-by: Jett.Zhou <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 5893110..f3811d5 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -38,6 +38,7 @@
 #include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/i2c/pxa-i2c.h>
+#include <plat/pm.h>
 
 #include <asm/irq.h>
 
@@ -173,6 +174,7 @@ struct pxa_i2c {
 	unsigned int		fast_mode :1;
 	unsigned int		ilcr;
 	unsigned int		iwcr;
+	struct pm_qos_request	qos_idle;
 };
 
 #define _IBMR(i2c)	((i2c)->reg_ibmr)
@@ -729,7 +731,7 @@ static int i2c_pxa_pio_set_master(struct pxa_i2c *i2c)
 static int i2c_pxa_do_pio_xfer(struct pxa_i2c *i2c,
 			       struct i2c_msg *msg, int num)
 {
-	unsigned long timeout = 500000; /* 5 seconds */
+	unsigned long timeout = 100000; /* 1 seconds */
 	int ret = 0;
 
 	ret = i2c_pxa_pio_set_master(i2c);
@@ -742,6 +744,8 @@ static int i2c_pxa_do_pio_xfer(struct pxa_i2c *i2c,
 	i2c->msg_ptr = 0;
 	i2c->irqlogidx = 0;
 
+	pm_qos_update_request(&i2c->qos_idle, PM_QOS_CONSTRAINT);
+
 	i2c_pxa_start_message(i2c);
 
 	while (i2c->msg_num > 0 && --timeout) {
@@ -751,6 +755,7 @@ static int i2c_pxa_do_pio_xfer(struct pxa_i2c *i2c,
 
 	i2c_pxa_stop_message(i2c);
 
+	pm_qos_update_request(&i2c->qos_idle, PM_QOS_DEFAULT_VALUE);
 	/*
 	 * We place the return code in i2c->msg_idx.
 	 */
@@ -760,6 +765,9 @@ out:
 	if (timeout == 0)
 		i2c_pxa_scream_blue_murder(i2c, "timeout");
 
+	if (ret < 0)
+		i2c_pxa_reset(i2c);
+
 	return ret;
 }
 
@@ -797,6 +805,8 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
 	i2c->msg_ptr = 0;
 	i2c->irqlogidx = 0;
 
+	pm_qos_update_request(&i2c->qos_idle, PM_QOS_CONSTRAINT);
+
 	i2c_pxa_start_message(i2c);
 
 	spin_unlock_irq(&i2c->lock);
@@ -804,9 +814,11 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
 	/*
 	 * The rest of the processing occurs in the interrupt handler.
 	 */
-	timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
+	timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 1);
 	i2c_pxa_stop_message(i2c);
 
+	pm_qos_update_request(&i2c->qos_idle, PM_QOS_DEFAULT_VALUE);
+
 	/*
 	 * We place the return code in i2c->msg_idx.
 	 */
@@ -1146,6 +1158,8 @@ static int i2c_pxa_probe(struct platform_device *dev)
 	struct resource *res = NULL;
 	int ret, irq;
 
+	int pm_qos_class = PM_QOS_CPUIDLE_KEEP_DDR;
+
 	i2c = kzalloc(sizeof(struct pxa_i2c), GFP_KERNEL);
 	if (!i2c) {
 		ret = -ENOMEM;
@@ -1171,7 +1185,10 @@ static int i2c_pxa_probe(struct platform_device *dev)
 	}
 
 	i2c->adap.owner   = THIS_MODULE;
-	i2c->adap.retries = 5;
+	i2c->adap.retries = 3;
+
+	pm_qos_add_request(&i2c->qos_idle, pm_qos_class,
+			PM_QOS_DEFAULT_VALUE);
 
 	spin_lock_init(&i2c->lock);
 	init_waitqueue_head(&i2c->wait);
@@ -1274,6 +1291,7 @@ eclk:
 	kfree(i2c);
 emalloc:
 	release_mem_region(res->start, resource_size(res));
+	pm_qos_remove_request(&i2c->qos_idle);
 	return ret;
 }
 
@@ -1282,6 +1300,7 @@ static int __exit i2c_pxa_remove(struct platform_device *dev)
 	struct pxa_i2c *i2c = platform_get_drvdata(dev);
 
 	platform_set_drvdata(dev, NULL);
+	pm_qos_remove_request(&i2c->qos_idle);
 
 	i2c_del_adapter(&i2c->adap);
 	if (!i2c->use_pio)
-- 
1.7.5.4

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

* [PATCH 10/11] i2c: pxa: modify the parameters of i2c_bus_reset()
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
                     ` (7 preceding siblings ...)
  2012-11-08 14:18   ` [PATCH 09/11] i2c: pxa: add qos as constraint for cpu-idle Leo Song
@ 2012-11-08 14:18   ` Leo Song
  2012-11-08 14:18   ` [PATCH 11/11] i2c: pxa: no need slave addr for i2c master mode reset Leo Song
  9 siblings, 0 replies; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:18 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Yi Zhang

From: Yi Zhang <yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

there may be more than one i2c bus needs to be reset,
add i2c bus number as parameter

Change-Id: I74456743bf640efe2fbf0664e8212be161cef424
Signed-off-by: Yi Zhang <yizhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index f3811d5..3346fef 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -289,7 +289,7 @@ static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why)
 	printk("\n");
 	if (strcmp(why, "exhausted retries") != 0) {
 		if (plat && plat->i2c_bus_reset)
-			plat->i2c_bus_reset();
+			plat->i2c_bus_reset(i2c->adap.nr);
 		/* reset i2c contorler when it's fail */
 		i2c_pxa_reset(i2c);
 	}
diff --git a/include/linux/i2c/pxa-i2c.h b/include/linux/i2c/pxa-i2c.h
index a247f48..04406ba 100644
--- a/include/linux/i2c/pxa-i2c.h
+++ b/include/linux/i2c/pxa-i2c.h
@@ -72,7 +72,7 @@ struct i2c_pxa_platform_data {
 	void			(*hardware_lock)(void);
 	void			(*hardware_unlock)(void);
 	int			(*hardware_trylock)(void);
-	void			(*i2c_bus_reset) (void);
+	void			(*i2c_bus_reset)(int i2c_bus_num);
 };
 
 extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
-- 
1.7.5.4

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

* [PATCH 11/11] i2c: pxa: no need slave addr for i2c master mode reset
       [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
                     ` (8 preceding siblings ...)
  2012-11-08 14:18   ` [PATCH 10/11] i2c: pxa: modify the parameters of i2c_bus_reset() Leo Song
@ 2012-11-08 14:18   ` Leo Song
       [not found]     ` <1352384284-15660-11-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
  9 siblings, 1 reply; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:18 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Leo Song, Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Jett.Zhou

From: "Jett.Zhou" <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

Normally i2c controller works as master, slave addr is not needed, or it
will impact some slave device(eg. ST NFC chip) i2c access, because it has
the same i2c address with controller.

Change-Id: Iaf6e16cf2e211d242b21086e491b751ea311a000
Signed-off-by: Jett.Zhou <jtzhou-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 3346fef..2dc3af3 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -490,8 +490,10 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
 	writel(I2C_ISR_INIT, _ISR(i2c));
 	writel(readl(_ICR(i2c)) & ~ICR_UR, _ICR(i2c));
 
+#ifdef CONFIG_I2C_PXA_SLAVE
 	if (i2c->reg_isar)
 		writel(i2c->slave_addr, _ISAR(i2c));
+#endif
 
 	/* set control register values */
 	writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c));
-- 
1.7.5.4

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

* RE: [PATCH 11/11] i2c: pxa: no need slave addr for i2c master mode reset
       [not found]     ` <1352384284-15660-11-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
@ 2012-11-08 14:25       ` Leo Song
       [not found]         ` <78895A20B3CF7D49B5589B604D36692B1B59F88BFD-r8ILAu4/owuq90oVIqnETxL4W9x8LtSr@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Leo Song @ 2012-11-08 14:25 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: Chao Xie, linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jett Zhou

Hi Ben Dooks/Wolfram Sang,

Would you please help to review and merge these 11 patches for drivers/i2c/busses/i2c-pxa.c?

[PATCH 01/11] i2c: pxa: support hardware lock 
[PATCH 02/11] i2c: pxa: support pxa910 in id table 
[PATCH 03/11] i2c: pxa: add more error handling for i2c controller 
[PATCH 04/11] i2c: pxa: fix irq unbalanced warning 
[PATCH 05/11] i2c: pxa: add bus reset for platform data; 
[PATCH 06/11] i2c: pxa: Keep i2c clock enabled when system suspends/resumes. 
[PATCH 07/11] i2c: pxa: keep i2c irq on in suspend 
[PATCH 08/11] i2c: pxa: bugfix the slave addr in the transaction 
[PATCH 09/11] i2c: pxa: add qos as constraint for cpu-idle 
[PATCH 10/11] i2c: pxa: modify the parameters of i2c_bus_reset() 
[PATCH 11/11] i2c: pxa: no need slave addr for i2c master mode reset 

Thanks a lot.

Best Wishes, 
  
Leo Song
Tel: 6194-9745, Marvell (Shanghai)
B3-F4-4D12, No. 399 of Keyuan Rd, Pudong District, Shanghai 


>-----Original Message-----
>From: Leo Song [mailto:liangs@marvell.com]
>Sent: 2012年11月8日 22:18
>To: Ben Dooks; Wolfram Sang
>Cc: Leo Song; Chao Xie; linux-i2c@vger.kernel.org; Jett Zhou
>Subject: [PATCH 11/11] i2c: pxa: no need slave addr for i2c master mode
>reset
>
>From: "Jett.Zhou" <jtzhou@marvell.com>
>
>Normally i2c controller works as master, slave addr is not needed, or it
>will impact some slave device(eg. ST NFC chip) i2c access, because it
>has
>the same i2c address with controller.
>
>Change-Id: Iaf6e16cf2e211d242b21086e491b751ea311a000
>Signed-off-by: Jett.Zhou <jtzhou@marvell.com>
>
>diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>index 3346fef..2dc3af3 100644
>--- a/drivers/i2c/busses/i2c-pxa.c
>+++ b/drivers/i2c/busses/i2c-pxa.c
>@@ -490,8 +490,10 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
> 	writel(I2C_ISR_INIT, _ISR(i2c));
> 	writel(readl(_ICR(i2c)) & ~ICR_UR, _ICR(i2c));
>
>+#ifdef CONFIG_I2C_PXA_SLAVE
> 	if (i2c->reg_isar)
> 		writel(i2c->slave_addr, _ISAR(i2c));
>+#endif
>
> 	/* set control register values */
> 	writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c));
>--
>1.7.5.4


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

* Re: [PATCH 11/11] i2c: pxa: no need slave addr for i2c master mode reset
       [not found]         ` <78895A20B3CF7D49B5589B604D36692B1B59F88BFD-r8ILAu4/owuq90oVIqnETxL4W9x8LtSr@public.gmane.org>
@ 2012-11-16 13:55           ` Wolfram Sang
  0 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2012-11-16 13:55 UTC (permalink / raw)
  To: Leo Song
  Cc: Ben Dooks, Chao Xie,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jett Zhou

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

Hi,

On Thu, Nov 08, 2012 at 06:25:24AM -0800, Leo Song wrote:

> Would you please help to review and merge these 11 patches for
> drivers/i2c/busses/i2c-pxa.c?

There are already a few formal things:

- For large series, please write a cover-letter describing the series in
  total (use --cover-letter). The omap guys do this very well, check the
  list archive.

- why would upstream need Change-Id: in the patch description?

- the cover letter should also state what testing you did. the pxa
  driver is used in lots of different SoCs and I'd like to know how
  much this was tested on other systems regarding regressions.

- if you can't test it on other machines, ask for help. Putting alkml on
  CC is one way to do this

- I'd ask you to add alkml anyway since your patches include hooks to
  the mach and there are people having more experience on this platform
  than me

I didn't really have a look at the code yet, since I ask you to resend
it fixing the above points first. But from a glimpse, you should try to
avoid adding function pointers to platform_data at all costs. Maybe you
can think of alternative solutions.

Regards and thanks for the submission,

   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] 13+ messages in thread

end of thread, other threads:[~2012-11-16 13:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-08 14:17 [PATCH 01/11] i2c: pxa: support hardware lock Leo Song
     [not found] ` <1352384284-15660-1-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-11-08 14:17   ` [PATCH 02/11] i2c: pxa: support pxa910 in id table Leo Song
2012-11-08 14:17   ` [PATCH 03/11] i2c: pxa: add more error handling for i2c controller Leo Song
2012-11-08 14:17   ` [PATCH 04/11] i2c: pxa: fix irq unbalanced warning Leo Song
2012-11-08 14:17   ` [PATCH 05/11] i2c: pxa: add bus reset for platform data; Leo Song
2012-11-08 14:17   ` [PATCH 06/11] i2c: pxa: Keep i2c clock enabled when system suspends/resumes Leo Song
2012-11-08 14:18   ` [PATCH 07/11] i2c: pxa: keep i2c irq on in suspend Leo Song
2012-11-08 14:18   ` [PATCH 08/11] i2c: pxa: bugfix the slave addr in the transaction Leo Song
2012-11-08 14:18   ` [PATCH 09/11] i2c: pxa: add qos as constraint for cpu-idle Leo Song
2012-11-08 14:18   ` [PATCH 10/11] i2c: pxa: modify the parameters of i2c_bus_reset() Leo Song
2012-11-08 14:18   ` [PATCH 11/11] i2c: pxa: no need slave addr for i2c master mode reset Leo Song
     [not found]     ` <1352384284-15660-11-git-send-email-liangs-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-11-08 14:25       ` Leo Song
     [not found]         ` <78895A20B3CF7D49B5589B604D36692B1B59F88BFD-r8ILAu4/owuq90oVIqnETxL4W9x8LtSr@public.gmane.org>
2012-11-16 13:55           ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).