All of lore.kernel.org
 help / color / mirror / Atom feed
* [BK PATCH] I2C fixes for 2.6.11-rc1
@ 2005-05-19  6:25 ` Greg KH
  0 siblings, 0 replies; 41+ messages in thread
From: Greg KH @ 2005-01-17 21:45 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: linux-kernel, sensors

Hi,

Here are some i2c driver fixes and updates for 2.6.11-rc1.  There is a
new chip and a new bus driver, as well as a bunch of minor fixes.  All
of these patches have been in the past few -mm releases.

Please pull from:  bk://kernel.bkbits.net/gregkh/linux/i2c-2.6

Individual patches will follow, sent to the sensors and linux-kernel
lists.

thanks,

greg k-h

 drivers/i2c/busses/Kconfig    |    6 -
 drivers/i2c/busses/i2c-i801.c |    2 
 drivers/i2c/busses/i2c-mpc.c  |  171 +++++++++++++++++++++++++------
 drivers/i2c/chips/adm1026.c   |   11 +-
 drivers/i2c/chips/eeprom.c    |   47 ++++----
 drivers/i2c/chips/it87.c      |  230 +++++++++++++++++++++++++++++++++---------
 drivers/i2c/chips/lm63.c      |    4 
 drivers/i2c/chips/lm85.c      |   76 +++++++++++--
 drivers/i2c/chips/via686a.c   |    9 -
 9 files changed, 427 insertions(+), 129 deletions(-)
-----


<jason.d.gaston:intel.com>:
  o I2C support for Intel ICH7 - 2.6.10 - resubmit

<rafael.espindola:gmail.com>:
  o I2C: add EMC6D100 support in lm85 driver

Greg Kroah-Hartman:
  o I2C: add MODULE_DEVICE_TABLE to via686a.c driver

Jean Delvare:
  o I2C: Improve it87 super-i/o detection
  o I2C: Cleanups to the eeprom driver
  o I2C: Fix bogus bitmask in lm63 debug message

Jonas Munsin:
  o I2C: fix it87 sensor driver stops CPU fan
  o I2C: it87 fan update

Justin Thiessen:
  o I2C: adm1026.c fixes

Kumar Gala:
  o I2C-MPC: Convert to platform_device driver
  o I2C-MPC: use wait_event_interruptible_timeout between transactions


^ permalink raw reply	[flat|nested] 41+ messages in thread
* [PATCH] I2C-MPC: use wait_event_interruptible_timeout
@ 2005-05-19  6:25 Kumar Gala
  2005-05-19  6:25 ` Kumar Gala
  2005-05-19  6:25 ` Greg KH
  0 siblings, 2 replies; 41+ messages in thread
From: Kumar Gala @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

I've changed the i2c-mpc.c driver to use wait_event_interruptible_timeout

Can you take a look and let me know if this looks good.  I'm going to have 
some other changes to the driver to handle moving it from an OCP based 
driver to using platform_device.

thanks

- kumar

=== drivers/i2c/busses/i2c-mpc.c 1.2 vs edited ==--- 1.2/drivers/i2c/busses/i2c-mpc.c	2004-09-16 18:37:31 -05:00
+++ edited/drivers/i2c/busses/i2c-mpc.c	2005-01-13 16:41:57 -06:00
@@ -75,7 +75,6 @@
 
 static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 {
-	DECLARE_WAITQUEUE(wait, current);
 	unsigned long orig_jiffies = jiffies;
 	u32 x;
 	int result = 0;
@@ -92,28 +91,22 @@
 		x = readb(i2c->base + MPC_I2C_SR);
 		writeb(0, i2c->base + MPC_I2C_SR);
 	} else {
-		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&i2c->queue, &wait);
-		while (!(i2c->interrupt & CSR_MIF)) {
-			if (signal_pending(current)) {
-				pr_debug("I2C: Interrupted\n");
-				result = -EINTR;
-				break;
-			}
-			if (time_after(jiffies, orig_jiffies + timeout)) {
-				pr_debug("I2C: timeout\n");
-				result = -EIO;
-				break;
-			}
-			msleep_interruptible(jiffies_to_msecs(timeout));
+		/* Interrupt mode */
+		result = wait_event_interruptible_timeout(i2c->queue, 
+			(i2c->interrupt & CSR_MIF), timeout * HZ);
+
+		if (unlikely(result < 0))
+			pr_debug("I2C: wait interrupted\n");
+		else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
+			pr_debug("I2C: wait timeout\n");
+			result = -ETIMEDOUT;
 		}
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&i2c->queue, &wait);
+
 		x = i2c->interrupt;
 		i2c->interrupt = 0;
 	}
 
-	if (result < -0)
+	if (result < 0)
 		return result;
 
 	if (!(x & CSR_MCF)) {
@@ -165,7 +158,7 @@
 		     const u8 * data, int length, int restart)
 {
 	int i;
-	unsigned timeout = HZ;
+	unsigned timeout = i2c->adap.timeout;
 	u32 flags = restart ? CCR_RSTA : 0;
 
 	/* Start with MEN */
@@ -193,7 +186,7 @@
 static int mpc_read(struct mpc_i2c *i2c, int target,
 		    u8 * data, int length, int restart)
 {
-	unsigned timeout = HZ;
+	unsigned timeout = i2c->adap.timeout;
 	int i;
 	u32 flags = restart ? CCR_RSTA : 0;
 
@@ -302,6 +295,7 @@
 	if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) {
 		return -ENOMEM;
 	}
+	memset(i2c, 0, sizeof(*i2c));
 	i2c->ocpdef = ocp->def;
 	init_waitqueue_head(&i2c->queue);
 

^ permalink raw reply	[flat|nested] 41+ messages in thread
* [PATCH] I2C-MPC: Convert to platform_device driver
@ 2005-01-14  3:35 ` Kumar Gala
  0 siblings, 0 replies; 41+ messages in thread
From: Kumar Gala @ 2005-01-14  3:35 UTC (permalink / raw)
  To: greg; +Cc: linux-kernel, sensors, linuxppc-embedded

Converted the driver to work as either a OCP or platform_device driver.  
The intent in the future (once we convert all PPC sub-archs from OCP to 
platform_device) is to remove the OCP code.

Signed-off-by: Kumar Gala <kumar.gala@freescale.com>

--

diff -Nru a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
--- a/drivers/i2c/busses/Kconfig	2005-01-13 21:27:38 -06:00
+++ b/drivers/i2c/busses/Kconfig	2005-01-13 21:27:38 -06:00
@@ -208,7 +208,7 @@
 
 config I2C_MPC
 	tristate "MPC107/824x/85xx/52xx"
-	depends on I2C && FSL_OCP
+	depends on I2C && PPC
 	help
 	  If you say yes to this option, support will be included for the
 	  built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
diff -Nru a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
--- a/drivers/i2c/busses/i2c-mpc.c	2005-01-13 21:27:38 -06:00
+++ b/drivers/i2c/busses/i2c-mpc.c	2005-01-13 21:27:38 -06:00
@@ -1,12 +1,12 @@
 /*
  * (C) Copyright 2003-2004
  * Humboldt Solutions Ltd, adrian@humboldt.co.uk.
- 
+
  * This is a combined i2c adapter and algorithm driver for the
  * MPC107/Tsi107 PowerPC northbridge and processors that include
- * the same I2C unit (8240, 8245, 85xx). 
+ * the same I2C unit (8240, 8245, 85xx).
  *
- * Release 0.7
+ * Release 0.8
  *
  * This file is licensed under the terms of the GNU General Public
  * License version 2. This program is licensed "as is" without any
@@ -20,7 +20,13 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <asm/io.h>
+#ifdef CONFIG_FSL_OCP
 #include <asm/ocp.h>
+#define FSL_I2C_DEV_SEPARATE_DFSRR FS_I2C_SEPARATE_DFSRR
+#define FSL_I2C_DEV_CLOCK_5200 FS_I2C_CLOCK_5200
+#else
+#include <linux/fsl_devices.h>
+#endif
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
@@ -50,10 +56,11 @@
 
 struct mpc_i2c {
 	char *base;
-	struct ocp_def *ocpdef;
 	u32 interrupt;
 	wait_queue_head_t queue;
 	struct i2c_adapter adap;
+	int irq;
+	u32 flags;
 };
 
 static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x)
@@ -79,7 +86,8 @@
 	u32 x;
 	int result = 0;
 
-	if (i2c->ocpdef->irq == OCP_IRQ_NA) {
+	if (i2c->irq == 0)
+	{
 		while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
 			schedule();
 			if (time_after(jiffies, orig_jiffies + timeout)) {
@@ -92,7 +100,7 @@
 		writeb(0, i2c->base + MPC_I2C_SR);
 	} else {
 		/* Interrupt mode */
-		result = wait_event_interruptible_timeout(i2c->queue, 
+		result = wait_event_interruptible_timeout(i2c->queue,
 			(i2c->interrupt & CSR_MIF), timeout * HZ);
 
 		if (unlikely(result < 0))
@@ -130,12 +138,11 @@
 
 static void mpc_i2c_setclock(struct mpc_i2c *i2c)
 {
-	struct ocp_fs_i2c_data *i2c_data = i2c->ocpdef->additions;
 	/* Set clock and filters */
-	if (i2c_data && (i2c_data->flags & FS_I2C_SEPARATE_DFSRR)) {
+	if (i2c->flags & FSL_I2C_DEV_SEPARATE_DFSRR) {
 		writeb(0x31, i2c->base + MPC_I2C_FDR);
 		writeb(0x10, i2c->base + MPC_I2C_DFSRR);
-	} else if (i2c_data && (i2c_data->flags & FS_I2C_CLOCK_5200))
+	} else if (i2c->flags & FSL_I2C_DEV_CLOCK_5200)
 		writeb(0x3f, i2c->base + MPC_I2C_FDR);
 	else
 		writel(0x1031, i2c->base + MPC_I2C_FDR);
@@ -287,6 +294,7 @@
 	.retries = 1
 };
 
+#ifdef CONFIG_FSL_OCP
 static int __devinit mpc_i2c_probe(struct ocp_device *ocp)
 {
 	int result = 0;
@@ -296,7 +304,9 @@
 		return -ENOMEM;
 	}
 	memset(i2c, 0, sizeof(*i2c));
-	i2c->ocpdef = ocp->def;
+
+	i2c->irq = ocp->def->irq;
+	i2c->flags = ((struct ocp_fs_i2c_data *)ocp->def->additions)->flags;
 	init_waitqueue_head(&i2c->queue);
 
 	if (!request_mem_region(ocp->def->paddr, MPC_I2C_REGION, "i2c-mpc")) {
@@ -312,16 +322,20 @@
 		goto fail_map;
 	}
 
-	if (ocp->def->irq != OCP_IRQ_NA)
+	if (i2c->irq != OCP_IRQ_NA)
+	{
 		if ((result = request_irq(ocp->def->irq, mpc_i2c_isr,
 					  0, "i2c-mpc", i2c)) < 0) {
 			printk(KERN_ERR
 			       "i2c-mpc - failed to attach interrupt\n");
 			goto fail_irq;
 		}
+	} else
+		i2c->irq = 0;
 
 	i2c->adap = mpc_ops;
 	i2c_set_adapdata(&i2c->adap, i2c);
+
 	if ((result = i2c_add_adapter(&i2c->adap)) < 0) {
 		printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
 		goto fail_add;
@@ -348,9 +362,9 @@
 	i2c_del_adapter(&i2c->adap);
 
 	if (ocp->def->irq != OCP_IRQ_NA)
-		free_irq(i2c->ocpdef->irq, i2c);
+		free_irq(i2c->irq, i2c);
 	iounmap(i2c->base);
-	release_mem_region(i2c->ocpdef->paddr, MPC_I2C_REGION);
+	release_mem_region(ocp->def->paddr, MPC_I2C_REGION);
 	kfree(i2c);
 }
 
@@ -380,6 +394,101 @@
 
 module_init(iic_init);
 module_exit(iic_exit);
+#else
+static int fsl_i2c_probe(struct device *device)
+{
+	int result = 0;
+	struct mpc_i2c *i2c;
+	struct platform_device *pdev = to_platform_device(device);
+	struct fsl_i2c_platform_data *pdata;
+	struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+	pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
+
+	if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) {
+		return -ENOMEM;
+	}
+	memset(i2c, 0, sizeof(*i2c));
+
+	i2c->irq = platform_get_irq(pdev, 0);
+	i2c->flags = pdata->device_flags;
+	init_waitqueue_head(&i2c->queue);
+
+	i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION);
+
+	if (!i2c->base) {
+		printk(KERN_ERR "i2c-mpc - failed to map controller\n");
+		result = -ENOMEM;
+		goto fail_map;
+	}
+
+	if (i2c->irq != 0)
+		if ((result = request_irq(i2c->irq, mpc_i2c_isr,
+					  0, "fsl-i2c", i2c)) < 0) {
+			printk(KERN_ERR
+			       "i2c-mpc - failed to attach interrupt\n");
+			goto fail_irq;
+		}
+
+	i2c->adap = mpc_ops;
+	i2c_set_adapdata(&i2c->adap, i2c);
+	i2c->adap.dev.parent = &pdev->dev;
+	if ((result = i2c_add_adapter(&i2c->adap)) < 0) {
+		printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
+		goto fail_add;
+	}
+
+	mpc_i2c_setclock(i2c);
+	dev_set_drvdata(device, i2c);
+	return result;
+
+      fail_add:
+	if (i2c->irq != 0)
+		free_irq(i2c->irq, 0);
+      fail_irq:
+	iounmap(i2c->base);
+      fail_map:
+	kfree(i2c);
+	return result;
+};
+
+static int fsl_i2c_remove(struct device *device)
+{
+	struct mpc_i2c *i2c = dev_get_drvdata(device);
+
+	dev_set_drvdata(device, NULL);
+	i2c_del_adapter(&i2c->adap);
+
+	if (i2c->irq != 0)
+		free_irq(i2c->irq, i2c);
+
+	iounmap(i2c->base);
+	kfree(i2c);
+	return 0;
+};
+
+/* Structure for a device driver */
+static struct device_driver fsl_i2c_driver = {
+	.name = "fsl-i2c",
+	.bus = &platform_bus_type,
+	.probe = fsl_i2c_probe,
+	.remove = fsl_i2c_remove,
+};
+
+static int __init fsl_i2c_init(void)
+{
+	return driver_register(&fsl_i2c_driver);
+}
+
+static void __exit fsl_i2c_exit(void)
+{
+	driver_unregister(&fsl_i2c_driver);
+}
+
+module_init(fsl_i2c_init);
+module_exit(fsl_i2c_exit);
+
+#endif /* CONFIG_FSL_OCP */
 
 MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
 MODULE_DESCRIPTION

^ permalink raw reply	[flat|nested] 41+ messages in thread
* [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions
@ 2005-01-14  0:21 ` Kumar Gala
  0 siblings, 0 replies; 41+ messages in thread
From: Kumar Gala @ 2005-01-14  0:21 UTC (permalink / raw)
  To: greg; +Cc: linux-kernel, sensors, linuxppc-embedded

Use wait_event_interruptible_timeout so we dont waste time waiting between 
transactions like we use to.  Also, we use the adapters timeout so the 
ioctl cmd I2C_TIMEOUT will now work.

Signed-off-by: Kumar Gala <kumar.gala@freescale.com>

--

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/01/13 18:09:31-06:00 galak@cde-tx32-ldt330.sps.mot.com 
#   use wait_even_interruptible_timeout instead of msleep_interruptible
# 
# drivers/i2c/busses/i2c-mpc.c
#   2005/01/13 18:08:40-06:00 galak@cde-tx32-ldt330.sps.mot.com +15 -21
#   use wait_even_interruptible_timeout instead of msleep_interruptible
# 
diff -Nru a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
--- a/drivers/i2c/busses/i2c-mpc.c	2005-01-13 18:15:58 -06:00
+++ b/drivers/i2c/busses/i2c-mpc.c	2005-01-13 18:15:58 -06:00
@@ -6,7 +6,7 @@
  * MPC107/Tsi107 PowerPC northbridge and processors that include
  * the same I2C unit (8240, 8245, 85xx). 
  *
- * Release 0.6
+ * Release 0.7
  *
  * This file is licensed under the terms of the GNU General Public
  * License version 2. This program is licensed "as is" without any
@@ -75,7 +75,6 @@
 
 static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 {
-	DECLARE_WAITQUEUE(wait, current);
 	unsigned long orig_jiffies = jiffies;
 	u32 x;
 	int result = 0;
@@ -92,28 +91,22 @@
 		x = readb(i2c->base + MPC_I2C_SR);
 		writeb(0, i2c->base + MPC_I2C_SR);
 	} else {
-		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&i2c->queue, &wait);
-		while (!(i2c->interrupt & CSR_MIF)) {
-			if (signal_pending(current)) {
-				pr_debug("I2C: Interrupted\n");
-				result = -EINTR;
-				break;
-			}
-			if (time_after(jiffies, orig_jiffies + timeout)) {
-				pr_debug("I2C: timeout\n");
-				result = -EIO;
-				break;
-			}
-			msleep_interruptible(jiffies_to_msecs(timeout));
+		/* Interrupt mode */
+		result = wait_event_interruptible_timeout(i2c->queue, 
+			(i2c->interrupt & CSR_MIF), timeout * HZ);
+
+		if (unlikely(result < 0))
+			pr_debug("I2C: wait interrupted\n");
+		else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
+			pr_debug("I2C: wait timeout\n");
+			result = -ETIMEDOUT;
 		}
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&i2c->queue, &wait);
+
 		x = i2c->interrupt;
 		i2c->interrupt = 0;
 	}
 
-	if (result < -0)
+	if (result < 0)
 		return result;
 
 	if (!(x & CSR_MCF)) {
@@ -165,7 +158,7 @@
 		     const u8 * data, int length, int restart)
 {
 	int i;
-	unsigned timeout = HZ;
+	unsigned timeout = i2c->adap.timeout;
 	u32 flags = restart ? CCR_RSTA : 0;
 
 	/* Start with MEN */
@@ -193,7 +186,7 @@
 static int mpc_read(struct mpc_i2c *i2c, int target,
 		    u8 * data, int length, int restart)
 {
-	unsigned timeout = HZ;
+	unsigned timeout = i2c->adap.timeout;
 	int i;
 	u32 flags = restart ? CCR_RSTA : 0;
 
@@ -302,6 +295,7 @@
 	if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) {
 		return -ENOMEM;
 	}
+	memset(i2c, 0, sizeof(*i2c));
 	i2c->ocpdef = ocp->def;
 	init_waitqueue_head(&i2c->queue);
 

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

end of thread, other threads:[~2005-05-19  6:25 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-17 21:45 [BK PATCH] I2C fixes for 2.6.11-rc1 Greg KH
2005-05-19  6:25 ` Greg KH
2005-01-17 21:46 ` [PATCH] I2C: add MODULE_DEVICE_TABLE to via686a.c driver Greg KH
2005-05-19  6:25   ` Greg KH
2005-01-17 21:46   ` [PATCH] I2C support for Intel ICH7 - 2.6.10 - resubmit Greg KH
2005-05-19  6:25     ` Greg KH
2005-01-17 21:46     ` [PATCH] I2C: it87 fan update Greg KH
2005-05-19  6:25       ` Greg KH
2005-01-17 21:46       ` [PATCH] I2C: adm1026.c fixes Greg KH
2005-05-19  6:25         ` Greg KH
2005-01-17 21:46         ` [PATCH] I2C: Fix bogus bitmask in lm63 debug message Greg KH
2005-05-19  6:25           ` Greg KH
2005-01-17 21:46           ` [PATCH] I2C: Cleanups to the eeprom driver Greg KH
2005-05-19  6:25             ` Greg KH
2005-01-17 21:46             ` [PATCH] I2C: fix it87 sensor driver stops CPU fan Greg KH
2005-05-19  6:25               ` Greg KH
2005-01-17 21:46               ` [PATCH] I2C: add EMC6D100 support in lm85 driver Greg KH
2005-05-19  6:25                 ` Greg KH
2005-01-17 21:46                 ` [PATCH] I2C: Improve it87 super-i/o detection Greg KH
2005-05-19  6:25                   ` Greg KH
2005-01-17 21:46                   ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Greg KH
2005-05-19  6:25                     ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between Greg KH
2005-01-17 21:46                     ` [PATCH] I2C-MPC: Convert to platform_device driver Greg KH
2005-05-19  6:25                       ` Greg KH
2005-01-17 22:12 ` [BK PATCH] I2C fixes for 2.6.11-rc1 Greg KH
2005-05-19  6:25   ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2005-05-19  6:25 [PATCH] I2C-MPC: use wait_event_interruptible_timeout Kumar Gala
2005-05-19  6:25 ` Kumar Gala
2005-05-19  6:25 ` Greg KH
2005-01-14  3:35 [PATCH] I2C-MPC: Convert to platform_device driver Kumar Gala
2005-05-19  6:25 ` Kumar Gala
2005-01-14  3:35 ` Kumar Gala
2005-01-14 18:42 ` Greg KH
2005-05-19  6:25   ` Greg KH
2005-01-14 18:42   ` Greg KH
2005-01-14  0:21 [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Kumar Gala
2005-05-19  6:25 ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between Kumar Gala
2005-01-14  0:21 ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Kumar Gala
2005-01-14 18:41 ` Greg KH
2005-05-19  6:25   ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between Greg KH
2005-01-14 18:41   ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Greg KH

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.