All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-07  8:20 Wolfgang Grandegger
  2009-04-07  8:20   ` Wolfgang Grandegger
                   ` (5 more replies)
  0 siblings, 6 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c; +Cc: linuxppc-dev, devicetree-discuss, Ben Dooks

This patch series makes the I2C bus speed configurable by using the
I2C node property "clock-frequency". If the property is not defined,
the old fixed clock settings will be used for backward compatibility.
The property "fsl,preserve-clocking" allows to inherit the settings
from the bootloader. Furthermore, it does some cleanup and uses the
new bindings for the Socrates board:

  i2c: i2c-mpc: various coding style fixes
  i2c: i2c-mpc: use dev based printout function
  i2c: i2c-mpc: make I2C bus speed configurable
  powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
  powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board

Ben, could you please consider this patch series for inclusion into
2.6.30.

TIA,

Wolfgang.

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

* [PATCH v3 1/5] i2c: i2c-mpc: various coding style fixes
  2009-04-07  8:20 [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable Wolfgang Grandegger
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  2009-04-07  8:20   ` Wolfgang Grandegger
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Ben Dooks, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Grant Likely,
	Kumar Gala, Wolfgang Grandegger

[-- Attachment #1: i2c-mpc-coding-style.patch --]
[-- Type: text/plain, Size: 3412 bytes --]

Fix errors reported by checkpatch (indention, long lines, trailing
white space, etc.).

Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
---
 drivers/i2c/busses/i2c-mpc.c |   35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
===================================================================
--- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:09.400719216 +0200
+++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:13.271719088 +0200
@@ -20,7 +20,7 @@
 #include <linux/of_platform.h>
 #include <linux/of_i2c.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/fsl_devices.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
@@ -28,10 +28,10 @@
 
 #define DRV_NAME "mpc-i2c"
 
-#define MPC_I2C_FDR 	0x04
-#define MPC_I2C_CR	0x08
-#define MPC_I2C_SR	0x0c
-#define MPC_I2C_DR	0x10
+#define MPC_I2C_FDR   0x04
+#define MPC_I2C_CR    0x08
+#define MPC_I2C_SR    0x0c
+#define MPC_I2C_DR    0x10
 #define MPC_I2C_DFSRR 0x14
 
 #define CCR_MEN  0x80
@@ -58,7 +58,7 @@
 	u32 flags;
 };
 
-static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x)
+static inline void writeccr(struct mpc_i2c *i2c, u32 x)
 {
 	writeb(x, i2c->base + MPC_I2C_CR);
 }
@@ -100,8 +100,7 @@
 	u32 x;
 	int result = 0;
 
-	if (i2c->irq == NO_IRQ)
-	{
+	if (i2c->irq == NO_IRQ) {
 		while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
 			schedule();
 			if (time_after(jiffies, orig_jiffies + timeout)) {
@@ -176,7 +175,7 @@
 }
 
 static int mpc_write(struct mpc_i2c *i2c, int target,
-		     const u8 * data, int length, int restart)
+		     const u8 *data, int length, int restart)
 {
 	int i, result;
 	unsigned timeout = i2c->adap.timeout;
@@ -207,7 +206,7 @@
 }
 
 static int mpc_read(struct mpc_i2c *i2c, int target,
-		    u8 * data, int length, int restart)
+		    u8 *data, int length, int restart)
 {
 	unsigned timeout = i2c->adap.timeout;
 	int i, result;
@@ -311,7 +310,8 @@
 	.timeout = HZ,
 };
 
-static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match)
+static int __devinit fsl_i2c_probe(struct of_device *op,
+				   const struct of_device_id *match)
 {
 	int result = 0;
 	struct mpc_i2c *i2c;
@@ -341,11 +341,12 @@
 		result = request_irq(i2c->irq, mpc_i2c_isr,
 				     IRQF_SHARED, "i2c-mpc", i2c);
 		if (result < 0) {
-			printk(KERN_ERR "i2c-mpc - failed to attach interrupt\n");
+			printk(KERN_ERR
+			       "i2c-mpc - failed to attach interrupt\n");
 			goto fail_request;
 		}
 	}
-	
+
 	mpc_i2c_setclock(i2c);
 
 	dev_set_drvdata(&op->dev, i2c);
@@ -368,7 +369,7 @@
 	free_irq(i2c->irq, i2c);
  fail_request:
 	irq_dispose_mapping(i2c->irq);
- 	iounmap(i2c->base);
+	iounmap(i2c->base);
  fail_map:
 	kfree(i2c);
 	return result;
@@ -414,7 +415,7 @@
 
 	rv = of_register_platform_driver(&mpc_i2c_driver);
 	if (rv)
-		printk(KERN_ERR DRV_NAME 
+		printk(KERN_ERR DRV_NAME
 		       " of_register_platform_driver failed (%i)\n", rv);
 	return rv;
 }
@@ -428,6 +429,6 @@
 module_exit(fsl_i2c_exit);
 
 MODULE_AUTHOR("Adrian Cox <adrian-nKrwMtk+6Wm9FHfhHBbuYA@public.gmane.org>");
-MODULE_DESCRIPTION
-    ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors");
+MODULE_DESCRIPTION("I2C-Bus adapter for MPC107 bridge and "
+		   "MPC824x/85xx/52xx processors");
 MODULE_LICENSE("GPL");

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

* [PATCH v3 1/5] i2c: i2c-mpc: various coding style fixes
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c; +Cc: devicetree-discuss, linuxppc-dev, Ben Dooks

Fix errors reported by checkpatch (indention, long lines, trailing
white space, etc.).

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
 drivers/i2c/busses/i2c-mpc.c |   35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
===================================================================
--- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:09.400719216 +0200
+++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:13.271719088 +0200
@@ -20,7 +20,7 @@
 #include <linux/of_platform.h>
 #include <linux/of_i2c.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/fsl_devices.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
@@ -28,10 +28,10 @@
 
 #define DRV_NAME "mpc-i2c"
 
-#define MPC_I2C_FDR 	0x04
-#define MPC_I2C_CR	0x08
-#define MPC_I2C_SR	0x0c
-#define MPC_I2C_DR	0x10
+#define MPC_I2C_FDR   0x04
+#define MPC_I2C_CR    0x08
+#define MPC_I2C_SR    0x0c
+#define MPC_I2C_DR    0x10
 #define MPC_I2C_DFSRR 0x14
 
 #define CCR_MEN  0x80
@@ -58,7 +58,7 @@
 	u32 flags;
 };
 
-static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x)
+static inline void writeccr(struct mpc_i2c *i2c, u32 x)
 {
 	writeb(x, i2c->base + MPC_I2C_CR);
 }
@@ -100,8 +100,7 @@
 	u32 x;
 	int result = 0;
 
-	if (i2c->irq == NO_IRQ)
-	{
+	if (i2c->irq == NO_IRQ) {
 		while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
 			schedule();
 			if (time_after(jiffies, orig_jiffies + timeout)) {
@@ -176,7 +175,7 @@
 }
 
 static int mpc_write(struct mpc_i2c *i2c, int target,
-		     const u8 * data, int length, int restart)
+		     const u8 *data, int length, int restart)
 {
 	int i, result;
 	unsigned timeout = i2c->adap.timeout;
@@ -207,7 +206,7 @@
 }
 
 static int mpc_read(struct mpc_i2c *i2c, int target,
-		    u8 * data, int length, int restart)
+		    u8 *data, int length, int restart)
 {
 	unsigned timeout = i2c->adap.timeout;
 	int i, result;
@@ -311,7 +310,8 @@
 	.timeout = HZ,
 };
 
-static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match)
+static int __devinit fsl_i2c_probe(struct of_device *op,
+				   const struct of_device_id *match)
 {
 	int result = 0;
 	struct mpc_i2c *i2c;
@@ -341,11 +341,12 @@
 		result = request_irq(i2c->irq, mpc_i2c_isr,
 				     IRQF_SHARED, "i2c-mpc", i2c);
 		if (result < 0) {
-			printk(KERN_ERR "i2c-mpc - failed to attach interrupt\n");
+			printk(KERN_ERR
+			       "i2c-mpc - failed to attach interrupt\n");
 			goto fail_request;
 		}
 	}
-	
+
 	mpc_i2c_setclock(i2c);
 
 	dev_set_drvdata(&op->dev, i2c);
@@ -368,7 +369,7 @@
 	free_irq(i2c->irq, i2c);
  fail_request:
 	irq_dispose_mapping(i2c->irq);
- 	iounmap(i2c->base);
+	iounmap(i2c->base);
  fail_map:
 	kfree(i2c);
 	return result;
@@ -414,7 +415,7 @@
 
 	rv = of_register_platform_driver(&mpc_i2c_driver);
 	if (rv)
-		printk(KERN_ERR DRV_NAME 
+		printk(KERN_ERR DRV_NAME
 		       " of_register_platform_driver failed (%i)\n", rv);
 	return rv;
 }
@@ -428,6 +429,6 @@
 module_exit(fsl_i2c_exit);
 
 MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
-MODULE_DESCRIPTION
-    ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors");
+MODULE_DESCRIPTION("I2C-Bus adapter for MPC107 bridge and "
+		   "MPC824x/85xx/52xx processors");
 MODULE_LICENSE("GPL");

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

* [PATCH v3 2/5] i2c: i2c-mpc: use dev based printout function
  2009-04-07  8:20 [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable Wolfgang Grandegger
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  2009-04-07  8:20   ` Wolfgang Grandegger
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Ben Dooks, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Grant Likely,
	Kumar Gala, Wolfgang Grandegger

[-- Attachment #1: i2c-mpc-dev-print.patch --]
[-- Type: text/plain, Size: 3696 bytes --]

This patch used the dev_dbg, dev_err, etc. functions for debug
and error output instead of printk and pr_debug.

Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
---
 drivers/i2c/busses/i2c-mpc.c |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
===================================================================
--- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:13.271719088 +0200
+++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:14.012720756 +0200
@@ -50,6 +50,7 @@
 #define CSR_RXAK 0x01
 
 struct mpc_i2c {
+	struct device *dev;
 	void __iomem *base;
 	u32 interrupt;
 	wait_queue_head_t queue;
@@ -104,7 +105,7 @@
 		while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
 			schedule();
 			if (time_after(jiffies, orig_jiffies + timeout)) {
-				pr_debug("I2C: timeout\n");
+				dev_dbg(i2c->dev, "timeout\n");
 				writeccr(i2c, 0);
 				result = -EIO;
 				break;
@@ -118,7 +119,7 @@
 			(i2c->interrupt & CSR_MIF), timeout);
 
 		if (unlikely(!(i2c->interrupt & CSR_MIF))) {
-			pr_debug("I2C: wait timeout\n");
+			dev_dbg(i2c->dev, "wait timeout\n");
 			writeccr(i2c, 0);
 			result = -ETIMEDOUT;
 		}
@@ -131,17 +132,17 @@
 		return result;
 
 	if (!(x & CSR_MCF)) {
-		pr_debug("I2C: unfinished\n");
+		dev_dbg(i2c->dev, "unfinished\n");
 		return -EIO;
 	}
 
 	if (x & CSR_MAL) {
-		pr_debug("I2C: MAL\n");
+		dev_dbg(i2c->dev, "MAL\n");
 		return -EIO;
 	}
 
 	if (writing && (x & CSR_RXAK)) {
-		pr_debug("I2C: No RXAK\n");
+		dev_dbg(i2c->dev, "No RXAK\n");
 		/* generate stop */
 		writeccr(i2c, CCR_MEN);
 		return -EIO;
@@ -263,12 +264,12 @@
 	/* Allow bus up to 1s to become not busy */
 	while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
 		if (signal_pending(current)) {
-			pr_debug("I2C: Interrupted\n");
+			dev_dbg(i2c->dev, "Interrupted\n");
 			writeccr(i2c, 0);
 			return -EINTR;
 		}
 		if (time_after(jiffies, orig_jiffies + HZ)) {
-			pr_debug("I2C: timeout\n");
+			dev_dbg(i2c->dev, "timeout\n");
 			if (readb(i2c->base + MPC_I2C_SR) ==
 			    (CSR_MCF | CSR_MBB | CSR_RXAK))
 				mpc_i2c_fixup(i2c);
@@ -279,9 +280,10 @@
 
 	for (i = 0; ret >= 0 && i < num; i++) {
 		pmsg = &msgs[i];
-		pr_debug("Doing %s %d bytes to 0x%02x - %d of %d messages\n",
-			 pmsg->flags & I2C_M_RD ? "read" : "write",
-			 pmsg->len, pmsg->addr, i + 1, num);
+		dev_dbg(i2c->dev,
+			"Doing %s %d bytes to 0x%02x - %d of %d messages\n",
+			pmsg->flags & I2C_M_RD ? "read" : "write",
+			pmsg->len, pmsg->addr, i + 1, num);
 		if (pmsg->flags & I2C_M_RD)
 			ret =
 			    mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
@@ -320,6 +322,8 @@
 	if (!i2c)
 		return -ENOMEM;
 
+	i2c->dev = &op->dev; /* for debug and error output */
+
 	if (of_get_property(op->node, "dfsrr", NULL))
 		i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
 
@@ -331,7 +335,7 @@
 
 	i2c->base = of_iomap(op->node, 0);
 	if (!i2c->base) {
-		printk(KERN_ERR "i2c-mpc - failed to map controller\n");
+		dev_err(i2c->dev, "failed to map controller\n");
 		result = -ENOMEM;
 		goto fail_map;
 	}
@@ -341,8 +345,7 @@
 		result = request_irq(i2c->irq, mpc_i2c_isr,
 				     IRQF_SHARED, "i2c-mpc", i2c);
 		if (result < 0) {
-			printk(KERN_ERR
-			       "i2c-mpc - failed to attach interrupt\n");
+			dev_err(i2c->dev, "failed to attach interrupt\n");
 			goto fail_request;
 		}
 	}
@@ -357,7 +360,7 @@
 
 	result = i2c_add_adapter(&i2c->adap);
 	if (result < 0) {
-		printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
+		dev_err(i2c->dev, "failed to add adapter\n");
 		goto fail_add;
 	}
 	of_register_i2c_devices(&i2c->adap, op->node);

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

* [PATCH v3 2/5] i2c: i2c-mpc: use dev based printout function
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c; +Cc: devicetree-discuss, linuxppc-dev, Ben Dooks

This patch used the dev_dbg, dev_err, etc. functions for debug
and error output instead of printk and pr_debug.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
 drivers/i2c/busses/i2c-mpc.c |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
===================================================================
--- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:13.271719088 +0200
+++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:14.012720756 +0200
@@ -50,6 +50,7 @@
 #define CSR_RXAK 0x01
 
 struct mpc_i2c {
+	struct device *dev;
 	void __iomem *base;
 	u32 interrupt;
 	wait_queue_head_t queue;
@@ -104,7 +105,7 @@
 		while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
 			schedule();
 			if (time_after(jiffies, orig_jiffies + timeout)) {
-				pr_debug("I2C: timeout\n");
+				dev_dbg(i2c->dev, "timeout\n");
 				writeccr(i2c, 0);
 				result = -EIO;
 				break;
@@ -118,7 +119,7 @@
 			(i2c->interrupt & CSR_MIF), timeout);
 
 		if (unlikely(!(i2c->interrupt & CSR_MIF))) {
-			pr_debug("I2C: wait timeout\n");
+			dev_dbg(i2c->dev, "wait timeout\n");
 			writeccr(i2c, 0);
 			result = -ETIMEDOUT;
 		}
@@ -131,17 +132,17 @@
 		return result;
 
 	if (!(x & CSR_MCF)) {
-		pr_debug("I2C: unfinished\n");
+		dev_dbg(i2c->dev, "unfinished\n");
 		return -EIO;
 	}
 
 	if (x & CSR_MAL) {
-		pr_debug("I2C: MAL\n");
+		dev_dbg(i2c->dev, "MAL\n");
 		return -EIO;
 	}
 
 	if (writing && (x & CSR_RXAK)) {
-		pr_debug("I2C: No RXAK\n");
+		dev_dbg(i2c->dev, "No RXAK\n");
 		/* generate stop */
 		writeccr(i2c, CCR_MEN);
 		return -EIO;
@@ -263,12 +264,12 @@
 	/* Allow bus up to 1s to become not busy */
 	while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
 		if (signal_pending(current)) {
-			pr_debug("I2C: Interrupted\n");
+			dev_dbg(i2c->dev, "Interrupted\n");
 			writeccr(i2c, 0);
 			return -EINTR;
 		}
 		if (time_after(jiffies, orig_jiffies + HZ)) {
-			pr_debug("I2C: timeout\n");
+			dev_dbg(i2c->dev, "timeout\n");
 			if (readb(i2c->base + MPC_I2C_SR) ==
 			    (CSR_MCF | CSR_MBB | CSR_RXAK))
 				mpc_i2c_fixup(i2c);
@@ -279,9 +280,10 @@
 
 	for (i = 0; ret >= 0 && i < num; i++) {
 		pmsg = &msgs[i];
-		pr_debug("Doing %s %d bytes to 0x%02x - %d of %d messages\n",
-			 pmsg->flags & I2C_M_RD ? "read" : "write",
-			 pmsg->len, pmsg->addr, i + 1, num);
+		dev_dbg(i2c->dev,
+			"Doing %s %d bytes to 0x%02x - %d of %d messages\n",
+			pmsg->flags & I2C_M_RD ? "read" : "write",
+			pmsg->len, pmsg->addr, i + 1, num);
 		if (pmsg->flags & I2C_M_RD)
 			ret =
 			    mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
@@ -320,6 +322,8 @@
 	if (!i2c)
 		return -ENOMEM;
 
+	i2c->dev = &op->dev; /* for debug and error output */
+
 	if (of_get_property(op->node, "dfsrr", NULL))
 		i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
 
@@ -331,7 +335,7 @@
 
 	i2c->base = of_iomap(op->node, 0);
 	if (!i2c->base) {
-		printk(KERN_ERR "i2c-mpc - failed to map controller\n");
+		dev_err(i2c->dev, "failed to map controller\n");
 		result = -ENOMEM;
 		goto fail_map;
 	}
@@ -341,8 +345,7 @@
 		result = request_irq(i2c->irq, mpc_i2c_isr,
 				     IRQF_SHARED, "i2c-mpc", i2c);
 		if (result < 0) {
-			printk(KERN_ERR
-			       "i2c-mpc - failed to attach interrupt\n");
+			dev_err(i2c->dev, "failed to attach interrupt\n");
 			goto fail_request;
 		}
 	}
@@ -357,7 +360,7 @@
 
 	result = i2c_add_adapter(&i2c->adap);
 	if (result < 0) {
-		printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
+		dev_err(i2c->dev, "failed to add adapter\n");
 		goto fail_add;
 	}
 	of_register_i2c_devices(&i2c->adap, op->node);

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

* [PATCH v3 3/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-07  8:20 [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable Wolfgang Grandegger
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  2009-04-07  8:20   ` Wolfgang Grandegger
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Ben Dooks, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Grant Likely,
	Kumar Gala, Wolfgang Grandegger

[-- Attachment #1: i2c-mpc-set-clock.patch --]
[-- Type: text/plain, Size: 10467 bytes --]

This patch makes the I2C bus speed configurable by using the I2C node
property "clock-frequency". If the property is not defined, the old
fixed clock settings will be used for backward comptibility.

The generic I2C clock properties, especially the CPU-specific source
clock pre-scaler are defined via the OF match table:

  static const struct of_device_id mpc_i2c_of_match[] = {
	...
	{.compatible = "fsl,mpc8543-i2c",
	 .data = &(struct fsl_i2c_match_data) {
			.setclock = mpc_i2c_setclock_8xxx,
			.prescaler = 2,
		},
	},

The "data" field defines the relevant I2C setclock function and the
relevant pre-scaler for the I2C source clock frequency.

It uses arch-specific tables and functions to determine resonable
Freqency Divider Register (fdr) values for MPC83xx, MPC85xx, MPC86xx,
MPC5200 and MPC5200B.

The i2c->flags field and the corresponding FSL_I2C_DEV_* definitions
have been removed as they are obsolete.

Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
---
 drivers/i2c/busses/i2c-mpc.c |  262 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 242 insertions(+), 20 deletions(-)

Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
===================================================================
--- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:14.012720756 +0200
+++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:14.581719146 +0200
@@ -26,6 +26,9 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 
+#include <asm/mpc52xx.h>
+#include <sysdev/fsl_soc.h>
+
 #define DRV_NAME "mpc-i2c"
 
 #define MPC_I2C_FDR   0x04
@@ -56,7 +59,18 @@
 	wait_queue_head_t queue;
 	struct i2c_adapter adap;
 	int irq;
-	u32 flags;
+};
+
+struct mpc_i2c_divider {
+	u16 divider;
+	u16 fdr;	/* including dfsrr */
+};
+
+struct mpc_i2c_match_data {
+	void (*setclock)(struct device_node *node,
+			 struct mpc_i2c *i2c,
+			 u32 clock, u32 prescaler);
+	u32 prescaler;
 };
 
 static inline void writeccr(struct mpc_i2c *i2c, u32 x)
@@ -150,17 +164,180 @@
 	return 0;
 }
 
-static void mpc_i2c_setclock(struct mpc_i2c *i2c)
+#ifdef CONFIG_PPC_52xx
+static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
+	{20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
+	{28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
+	{36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
+	{52, 0x63}, {56, 0x29}, {60, 0x41}, {64, 0x2a},
+	{68, 0x07}, {72, 0x2b}, {80, 0x2c}, {88, 0x09},
+	{96, 0x2d}, {104, 0x0a}, {112, 0x2e}, {120, 0x81},
+	{128, 0x2f}, {136, 0x47}, {144, 0x0c}, {160, 0x30},
+	{176, 0x49}, {192, 0x31}, {208, 0x4a}, {224, 0x32},
+	{240, 0x0f}, {256, 0x33}, {272, 0x87}, {288, 0x10},
+	{320, 0x34}, {352, 0x89}, {384, 0x35}, {416, 0x8a},
+	{448, 0x36}, {480, 0x13}, {512, 0x37}, {576, 0x14},
+	{640, 0x38}, {768, 0x39}, {896, 0x3a}, {960, 0x17},
+	{1024, 0x3b}, {1152, 0x18}, {1280, 0x3c}, {1536, 0x3d},
+	{1792, 0x3e}, {1920, 0x1b}, {2048, 0x3f}, {2304, 0x1c},
+	{2560, 0x1d}, {3072, 0x1e}, {3584, 0x7e}, {3840, 0x1f},
+	{4096, 0x7f}, {4608, 0x5c}, {5120, 0x5d}, {6144, 0x5e},
+	{7168, 0xbe}, {7680, 0x5f}, {8192, 0xbf}, {9216, 0x9c},
+	{10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f}
+};
+
+int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
+{
+	const struct mpc52xx_i2c_divider *div = NULL;
+	unsigned int pvr = mfspr(SPRN_PVR);
+	u32 divider;
+	int i;
+
+	if (!clock)
+		return -EINVAL;
+
+	/* Determine divider value */
+	divider = mpc52xx_find_ipb_freq(node) / clock;
+
+	/*
+	 * We want to choose an FDR/DFSR that generates an I2C bus speed that
+	 * is equal to or lower than the requested speed.
+	 */
+	for (i = 0; i < ARRAY_SIZE(mpc52xx_i2c_dividers); i++) {
+		div = &mpc_i2c_dividers_52xx[i];
+		/* Old MPC5200 rev A CPUs do not support the high bits */
+		if (div->fdr & 0xc0 && pvr == 0x80822011)
+			continue;
+		if (div->divider >= divider)
+			break;
+	}
+
+	return div ? (int)div->fdr : -EINVAL;
+}
+
+static void mpc_i2c_setclock_52xx(struct device_node *node,
+				  struct mpc_i2c *i2c,
+				  u32 clock, u32 prescaler)
+{
+	int fdr = mpc52xx_i2c_get_fdr(node, clock, prescaler);
+
+	if (fdr < 0)
+		fdr = 0x3f; /* backward compatibility */
+	writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
+	dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
+}
+#else /* !CONFIG_PPC_52xx */
+static void mpc_i2c_setclock_52xx(struct device_node *node,
+				  struct mpc_i2c *i2c,
+				  u32 clock, u32 prescaler)
+{
+}
+#endif /* CONFIG_PPC_52xx*/
+
+#ifdef CONFIG_FSL_SOC
+static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
+	{160, 0x0120}, {192, 0x0121}, {224, 0x0122}, {256, 0x0123},
+	{288, 0x0100}, {320, 0x0101}, {352, 0x0601}, {384, 0x0102},
+	{416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127},
+	{544, 0x0b03}, {576, 0x0104}, {608, 0x1603}, {640, 0x0105},
+	{672, 0x2003}, {704, 0x0b05}, {736, 0x2b03}, {768, 0x0106},
+	{800, 0x3603}, {832, 0x0b06}, {896, 0x012a}, {960, 0x0107},
+	{1024, 0x012b}, {1088, 0x1607}, {1152, 0x0108}, {1216, 0x2b07},
+	{1280, 0x0109}, {1408, 0x1609}, {1536, 0x010a}, {1664, 0x160a},
+	{1792, 0x012e}, {1920, 0x010b}, {2048, 0x012f}, {2176, 0x2b0b},
+	{2304, 0x010c}, {2560, 0x010d}, {2816, 0x2b0d}, {3072, 0x010e},
+	{3328, 0x2b0e}, {3584, 0x0132}, {3840, 0x010f}, {4096, 0x0133},
+	{4608, 0x0110}, {5120, 0x0111}, {6144, 0x0112}, {7168, 0x0136},
+	{7680, 0x0113}, {8192, 0x0137}, {9216, 0x0114}, {10240, 0x0115},
+	{12288, 0x0116}, {14336, 0x013a}, {15360, 0x0117}, {16384, 0x013b},
+	{18432, 0x0118}, {20480, 0x0119}, {24576, 0x011a}, {28672, 0x013e},
+	{30720, 0x011b}, {32768, 0x013f}, {36864, 0x011c}, {40960, 0x011d},
+	{49152, 0x011e}, {61440, 0x011f}
+};
+
+u32 mpc_i2c_get_sec_cfg_8xxx(void)
+{
+	struct device_node *node = NULL;
+	u32 __iomem *reg;
+	u32 val = 0;
+
+	node = of_find_node_by_name(NULL, "global-utilities");
+	if (node) {
+		const u32 *prop = of_get_property(node, "reg", NULL);
+		if (prop) {
+			/*
+			 * Map and check POR Device Status Register 2
+			 * (PORDEVSR2) at 0xE0014
+			 */
+			reg = ioremap(get_immrbase() + *prop + 0x14, 0x4);
+			if (!reg)
+				printk(KERN_ERR
+				       "Error: couldn't map PORDEVSR2\n");
+			else
+				val = in_be32(reg) & 0x00000080; /* sec-cfg */
+			iounmap(reg);
+		}
+	}
+	if (node)
+		of_node_put(node);
+
+	return val;
+}
+
+int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler)
+{
+	const struct mpc_i2c_divider *div = NULL;
+	u32 divider;
+	int i;
+
+	if (!clock)
+		return -EINVAL;
+
+	/* Determine proper divider value */
+	if (of_device_is_compatible(node, "fsl,mpc8544-i2c"))
+		prescaler = mpc_i2c_get_sec_cfg_8xxx() ? 3 : 2;
+	if (!prescaler)
+		prescaler = 1;
+
+	divider = fsl_get_sys_freq() / clock / prescaler;
+
+	pr_debug("I2C: src_clock=%d clock=%d divider=%d\n",
+		 fsl_get_sys_freq(), clock, divider);
+
+	/*
+	 * We want to choose an FDR/DFSR that generates an I2C bus speed that
+	 * is equal to or lower than the requested speed.
+	 */
+	for (i = 0; i < ARRAY_SIZE(mpc_i2c_dividers_8xxx); i++) {
+		div = &mpc_i2c_dividers_8xxx[i];
+		if (div->divider >= divider)
+			break;
+	}
+
+	return div ? (int)div->fdr : -EINVAL;
+}
+
+static void mpc_i2c_setclock_8xxx(struct device_node *node,
+				  struct mpc_i2c *i2c,
+				  u32 clock, u32 prescaler)
+{
+	int fdr = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
+
+	if (fdr < 0)
+		fdr = 0x1031; /* backward compatibility */
+	writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
+	writeb((fdr >> 8) & 0xff, i2c->base + MPC_I2C_DFSRR);
+	dev_info(i2c->dev, "clock %d Hz (dfsrr=%d fdr=%d)\n",
+		 clock, fdr >> 8, fdr & 0xff);
+}
+
+#else /* !CONFIG_FSL_SOC */
+static void mpc_i2c_setclock_8xxx(struct device_node *node,
+				  struct mpc_i2c *i2c,
+				  u32 clock, u32 prescaler)
 {
-	/* Set clock and filters */
-	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->flags & FSL_I2C_DEV_CLOCK_5200)
-		writeb(0x3f, i2c->base + MPC_I2C_FDR);
-	else
-		writel(0x1031, i2c->base + MPC_I2C_FDR);
 }
+#endif /* CONFIG_FSL_SOC */
 
 static void mpc_i2c_start(struct mpc_i2c *i2c)
 {
@@ -315,8 +492,11 @@
 static int __devinit fsl_i2c_probe(struct of_device *op,
 				   const struct of_device_id *match)
 {
-	int result = 0;
 	struct mpc_i2c *i2c;
+	const u32 *prop;
+	u32 clock = 0;
+	int result = 0;
+	int plen;
 
 	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
 	if (!i2c)
@@ -324,13 +504,6 @@
 
 	i2c->dev = &op->dev; /* for debug and error output */
 
-	if (of_get_property(op->node, "dfsrr", NULL))
-		i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-	if (of_device_is_compatible(op->node, "fsl,mpc5200-i2c") ||
-			of_device_is_compatible(op->node, "mpc5200-i2c"))
-		i2c->flags |= FSL_I2C_DEV_CLOCK_5200;
-
 	init_waitqueue_head(&i2c->queue);
 
 	i2c->base = of_iomap(op->node, 0);
@@ -350,7 +523,22 @@
 		}
 	}
 
-	mpc_i2c_setclock(i2c);
+	if (!of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
+		prop = of_get_property(op->node, "clock-frequency", &plen);
+		if (prop && plen == sizeof(u32))
+			clock = *prop;
+
+		if (match->data) {
+			struct mpc_i2c_match_data *data =
+				(struct mpc_i2c_match_data *)match->data;
+			data->setclock(op->node, i2c, clock, data->prescaler);
+		} else {
+			/* Backwards compatibility */
+			if (of_get_property(op->node, "dfsrr", NULL))
+				mpc_i2c_setclock_8xxx(op->node, i2c,
+						      clock, 0);
+		}
+	}
 
 	dev_set_drvdata(&op->dev, i2c);
 
@@ -395,9 +583,43 @@
 };
 
 static const struct of_device_id mpc_i2c_of_match[] = {
-	{.compatible = "fsl-i2c",},
+	{.compatible = "mpc5200-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_52xx,
+		},
+	},
+	{.compatible = "fsl,mpc5200b-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_52xx,
+		},
+	},
+	{.compatible = "fsl,mpc5200-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_52xx,
+		},
+	},
+	{.compatible = "fsl,mpc8313-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_8xxx,
+		},
+	},
+	{.compatible = "fsl,mpc8543-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_8xxx,
+			.prescaler = 2,
+		},
+	},
+	{.compatible = "fsl,mpc8544-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_8xxx,
+			.prescaler = 3,
+		},
+	/* Backward compatibility */
+	},
+	{.compatible = "fsl-i2c", },
 	{},
 };
+
 MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
 
 

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

* [PATCH v3 3/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c; +Cc: devicetree-discuss, linuxppc-dev, Ben Dooks

This patch makes the I2C bus speed configurable by using the I2C node
property "clock-frequency". If the property is not defined, the old
fixed clock settings will be used for backward comptibility.

The generic I2C clock properties, especially the CPU-specific source
clock pre-scaler are defined via the OF match table:

  static const struct of_device_id mpc_i2c_of_match[] = {
	...
	{.compatible = "fsl,mpc8543-i2c",
	 .data = &(struct fsl_i2c_match_data) {
			.setclock = mpc_i2c_setclock_8xxx,
			.prescaler = 2,
		},
	},

The "data" field defines the relevant I2C setclock function and the
relevant pre-scaler for the I2C source clock frequency.

It uses arch-specific tables and functions to determine resonable
Freqency Divider Register (fdr) values for MPC83xx, MPC85xx, MPC86xx,
MPC5200 and MPC5200B.

The i2c->flags field and the corresponding FSL_I2C_DEV_* definitions
have been removed as they are obsolete.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
 drivers/i2c/busses/i2c-mpc.c |  262 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 242 insertions(+), 20 deletions(-)

Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
===================================================================
--- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:14.012720756 +0200
+++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c	2009-04-07 10:09:14.581719146 +0200
@@ -26,6 +26,9 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 
+#include <asm/mpc52xx.h>
+#include <sysdev/fsl_soc.h>
+
 #define DRV_NAME "mpc-i2c"
 
 #define MPC_I2C_FDR   0x04
@@ -56,7 +59,18 @@
 	wait_queue_head_t queue;
 	struct i2c_adapter adap;
 	int irq;
-	u32 flags;
+};
+
+struct mpc_i2c_divider {
+	u16 divider;
+	u16 fdr;	/* including dfsrr */
+};
+
+struct mpc_i2c_match_data {
+	void (*setclock)(struct device_node *node,
+			 struct mpc_i2c *i2c,
+			 u32 clock, u32 prescaler);
+	u32 prescaler;
 };
 
 static inline void writeccr(struct mpc_i2c *i2c, u32 x)
@@ -150,17 +164,180 @@
 	return 0;
 }
 
-static void mpc_i2c_setclock(struct mpc_i2c *i2c)
+#ifdef CONFIG_PPC_52xx
+static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
+	{20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
+	{28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
+	{36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
+	{52, 0x63}, {56, 0x29}, {60, 0x41}, {64, 0x2a},
+	{68, 0x07}, {72, 0x2b}, {80, 0x2c}, {88, 0x09},
+	{96, 0x2d}, {104, 0x0a}, {112, 0x2e}, {120, 0x81},
+	{128, 0x2f}, {136, 0x47}, {144, 0x0c}, {160, 0x30},
+	{176, 0x49}, {192, 0x31}, {208, 0x4a}, {224, 0x32},
+	{240, 0x0f}, {256, 0x33}, {272, 0x87}, {288, 0x10},
+	{320, 0x34}, {352, 0x89}, {384, 0x35}, {416, 0x8a},
+	{448, 0x36}, {480, 0x13}, {512, 0x37}, {576, 0x14},
+	{640, 0x38}, {768, 0x39}, {896, 0x3a}, {960, 0x17},
+	{1024, 0x3b}, {1152, 0x18}, {1280, 0x3c}, {1536, 0x3d},
+	{1792, 0x3e}, {1920, 0x1b}, {2048, 0x3f}, {2304, 0x1c},
+	{2560, 0x1d}, {3072, 0x1e}, {3584, 0x7e}, {3840, 0x1f},
+	{4096, 0x7f}, {4608, 0x5c}, {5120, 0x5d}, {6144, 0x5e},
+	{7168, 0xbe}, {7680, 0x5f}, {8192, 0xbf}, {9216, 0x9c},
+	{10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f}
+};
+
+int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
+{
+	const struct mpc52xx_i2c_divider *div = NULL;
+	unsigned int pvr = mfspr(SPRN_PVR);
+	u32 divider;
+	int i;
+
+	if (!clock)
+		return -EINVAL;
+
+	/* Determine divider value */
+	divider = mpc52xx_find_ipb_freq(node) / clock;
+
+	/*
+	 * We want to choose an FDR/DFSR that generates an I2C bus speed that
+	 * is equal to or lower than the requested speed.
+	 */
+	for (i = 0; i < ARRAY_SIZE(mpc52xx_i2c_dividers); i++) {
+		div = &mpc_i2c_dividers_52xx[i];
+		/* Old MPC5200 rev A CPUs do not support the high bits */
+		if (div->fdr & 0xc0 && pvr == 0x80822011)
+			continue;
+		if (div->divider >= divider)
+			break;
+	}
+
+	return div ? (int)div->fdr : -EINVAL;
+}
+
+static void mpc_i2c_setclock_52xx(struct device_node *node,
+				  struct mpc_i2c *i2c,
+				  u32 clock, u32 prescaler)
+{
+	int fdr = mpc52xx_i2c_get_fdr(node, clock, prescaler);
+
+	if (fdr < 0)
+		fdr = 0x3f; /* backward compatibility */
+	writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
+	dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
+}
+#else /* !CONFIG_PPC_52xx */
+static void mpc_i2c_setclock_52xx(struct device_node *node,
+				  struct mpc_i2c *i2c,
+				  u32 clock, u32 prescaler)
+{
+}
+#endif /* CONFIG_PPC_52xx*/
+
+#ifdef CONFIG_FSL_SOC
+static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
+	{160, 0x0120}, {192, 0x0121}, {224, 0x0122}, {256, 0x0123},
+	{288, 0x0100}, {320, 0x0101}, {352, 0x0601}, {384, 0x0102},
+	{416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127},
+	{544, 0x0b03}, {576, 0x0104}, {608, 0x1603}, {640, 0x0105},
+	{672, 0x2003}, {704, 0x0b05}, {736, 0x2b03}, {768, 0x0106},
+	{800, 0x3603}, {832, 0x0b06}, {896, 0x012a}, {960, 0x0107},
+	{1024, 0x012b}, {1088, 0x1607}, {1152, 0x0108}, {1216, 0x2b07},
+	{1280, 0x0109}, {1408, 0x1609}, {1536, 0x010a}, {1664, 0x160a},
+	{1792, 0x012e}, {1920, 0x010b}, {2048, 0x012f}, {2176, 0x2b0b},
+	{2304, 0x010c}, {2560, 0x010d}, {2816, 0x2b0d}, {3072, 0x010e},
+	{3328, 0x2b0e}, {3584, 0x0132}, {3840, 0x010f}, {4096, 0x0133},
+	{4608, 0x0110}, {5120, 0x0111}, {6144, 0x0112}, {7168, 0x0136},
+	{7680, 0x0113}, {8192, 0x0137}, {9216, 0x0114}, {10240, 0x0115},
+	{12288, 0x0116}, {14336, 0x013a}, {15360, 0x0117}, {16384, 0x013b},
+	{18432, 0x0118}, {20480, 0x0119}, {24576, 0x011a}, {28672, 0x013e},
+	{30720, 0x011b}, {32768, 0x013f}, {36864, 0x011c}, {40960, 0x011d},
+	{49152, 0x011e}, {61440, 0x011f}
+};
+
+u32 mpc_i2c_get_sec_cfg_8xxx(void)
+{
+	struct device_node *node = NULL;
+	u32 __iomem *reg;
+	u32 val = 0;
+
+	node = of_find_node_by_name(NULL, "global-utilities");
+	if (node) {
+		const u32 *prop = of_get_property(node, "reg", NULL);
+		if (prop) {
+			/*
+			 * Map and check POR Device Status Register 2
+			 * (PORDEVSR2) at 0xE0014
+			 */
+			reg = ioremap(get_immrbase() + *prop + 0x14, 0x4);
+			if (!reg)
+				printk(KERN_ERR
+				       "Error: couldn't map PORDEVSR2\n");
+			else
+				val = in_be32(reg) & 0x00000080; /* sec-cfg */
+			iounmap(reg);
+		}
+	}
+	if (node)
+		of_node_put(node);
+
+	return val;
+}
+
+int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler)
+{
+	const struct mpc_i2c_divider *div = NULL;
+	u32 divider;
+	int i;
+
+	if (!clock)
+		return -EINVAL;
+
+	/* Determine proper divider value */
+	if (of_device_is_compatible(node, "fsl,mpc8544-i2c"))
+		prescaler = mpc_i2c_get_sec_cfg_8xxx() ? 3 : 2;
+	if (!prescaler)
+		prescaler = 1;
+
+	divider = fsl_get_sys_freq() / clock / prescaler;
+
+	pr_debug("I2C: src_clock=%d clock=%d divider=%d\n",
+		 fsl_get_sys_freq(), clock, divider);
+
+	/*
+	 * We want to choose an FDR/DFSR that generates an I2C bus speed that
+	 * is equal to or lower than the requested speed.
+	 */
+	for (i = 0; i < ARRAY_SIZE(mpc_i2c_dividers_8xxx); i++) {
+		div = &mpc_i2c_dividers_8xxx[i];
+		if (div->divider >= divider)
+			break;
+	}
+
+	return div ? (int)div->fdr : -EINVAL;
+}
+
+static void mpc_i2c_setclock_8xxx(struct device_node *node,
+				  struct mpc_i2c *i2c,
+				  u32 clock, u32 prescaler)
+{
+	int fdr = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
+
+	if (fdr < 0)
+		fdr = 0x1031; /* backward compatibility */
+	writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
+	writeb((fdr >> 8) & 0xff, i2c->base + MPC_I2C_DFSRR);
+	dev_info(i2c->dev, "clock %d Hz (dfsrr=%d fdr=%d)\n",
+		 clock, fdr >> 8, fdr & 0xff);
+}
+
+#else /* !CONFIG_FSL_SOC */
+static void mpc_i2c_setclock_8xxx(struct device_node *node,
+				  struct mpc_i2c *i2c,
+				  u32 clock, u32 prescaler)
 {
-	/* Set clock and filters */
-	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->flags & FSL_I2C_DEV_CLOCK_5200)
-		writeb(0x3f, i2c->base + MPC_I2C_FDR);
-	else
-		writel(0x1031, i2c->base + MPC_I2C_FDR);
 }
+#endif /* CONFIG_FSL_SOC */
 
 static void mpc_i2c_start(struct mpc_i2c *i2c)
 {
@@ -315,8 +492,11 @@
 static int __devinit fsl_i2c_probe(struct of_device *op,
 				   const struct of_device_id *match)
 {
-	int result = 0;
 	struct mpc_i2c *i2c;
+	const u32 *prop;
+	u32 clock = 0;
+	int result = 0;
+	int plen;
 
 	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
 	if (!i2c)
@@ -324,13 +504,6 @@
 
 	i2c->dev = &op->dev; /* for debug and error output */
 
-	if (of_get_property(op->node, "dfsrr", NULL))
-		i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-	if (of_device_is_compatible(op->node, "fsl,mpc5200-i2c") ||
-			of_device_is_compatible(op->node, "mpc5200-i2c"))
-		i2c->flags |= FSL_I2C_DEV_CLOCK_5200;
-
 	init_waitqueue_head(&i2c->queue);
 
 	i2c->base = of_iomap(op->node, 0);
@@ -350,7 +523,22 @@
 		}
 	}
 
-	mpc_i2c_setclock(i2c);
+	if (!of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
+		prop = of_get_property(op->node, "clock-frequency", &plen);
+		if (prop && plen == sizeof(u32))
+			clock = *prop;
+
+		if (match->data) {
+			struct mpc_i2c_match_data *data =
+				(struct mpc_i2c_match_data *)match->data;
+			data->setclock(op->node, i2c, clock, data->prescaler);
+		} else {
+			/* Backwards compatibility */
+			if (of_get_property(op->node, "dfsrr", NULL))
+				mpc_i2c_setclock_8xxx(op->node, i2c,
+						      clock, 0);
+		}
+	}
 
 	dev_set_drvdata(&op->dev, i2c);
 
@@ -395,9 +583,43 @@
 };
 
 static const struct of_device_id mpc_i2c_of_match[] = {
-	{.compatible = "fsl-i2c",},
+	{.compatible = "mpc5200-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_52xx,
+		},
+	},
+	{.compatible = "fsl,mpc5200b-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_52xx,
+		},
+	},
+	{.compatible = "fsl,mpc5200-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_52xx,
+		},
+	},
+	{.compatible = "fsl,mpc8313-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_8xxx,
+		},
+	},
+	{.compatible = "fsl,mpc8543-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_8xxx,
+			.prescaler = 2,
+		},
+	},
+	{.compatible = "fsl,mpc8544-i2c",
+	 .data = &(struct mpc_i2c_match_data) {
+			.setclock = mpc_i2c_setclock_8xxx,
+			.prescaler = 3,
+		},
+	/* Backward compatibility */
+	},
+	{.compatible = "fsl-i2c", },
 	{},
 };
+
 MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
 
 

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

* [PATCH v3 4/5] powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
  2009-04-07  8:20 [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable Wolfgang Grandegger
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  2009-04-07  8:20   ` Wolfgang Grandegger
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Ben Dooks, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Grant Likely,
	Kumar Gala, Wolfgang Grandegger

[-- Attachment #1: i2c-mpc-dts-bindings.patch --]
[-- Type: text/plain, Size: 3193 bytes --]

This patch documents the new bindings for the MPC I2C bus driver.
Furthermore, it removes obsolete FSL device related definitions
for I2C.
It should go through the appropriate PowerPC maintainer(s) hands.

Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
---
 Documentation/powerpc/dts-bindings/fsl/i2c.txt |   46 ++++++++++++++++---------
 include/linux/fsl_devices.h                    |    4 --
 2 files changed, 31 insertions(+), 19 deletions(-)

Index: linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt
===================================================================
--- linux-2.6-galak.orig/Documentation/powerpc/dts-bindings/fsl/i2c.txt	2009-04-07 10:09:08.185721241 +0200
+++ linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt	2009-04-07 10:09:15.413719535 +0200
@@ -7,8 +7,10 @@
 
 Recommended properties :
 
- - compatible : Should be "fsl-i2c" for parts compatible with
-   Freescale I2C specifications.
+ - compatible : compatibility list with 2 entries, the first should
+   be "fsl,CHIP-i2c" where CHIP is the name of a compatible processor,
+   e.g. mpc8313, mpc8543, mpc8544, mpc5200 or mpc5200b. The second one
+   should be "fsl-i2c".
  - interrupts : <a b> where a is the interrupt number and b is a
    field that represents an encoding of the sense and level
    information for the interrupt.  This should be encoded based on
@@ -16,17 +18,31 @@
    controller you have.
  - interrupt-parent : the phandle for the interrupt controller that
    services interrupts for this device.
- - dfsrr : boolean; if defined, indicates that this I2C device has
-   a digital filter sampling rate register
- - fsl5200-clocking : boolean; if defined, indicated that this device
-   uses the FSL 5200 clocking mechanism.
-
-Example :
-	i2c@3000 {
-		interrupt-parent = <40000>;
-		interrupts = <1b 3>;
-		reg = <3000 18>;
-		device_type = "i2c";
-		compatible  = "fsl-i2c";
-		dfsrr;
+ - fsl,preserve-clocking : boolean; if defined, the clock settings
+   from the bootloader are preserved (not touched).
+ - clock-frequency : desired I2C bus clock frequency in Hz.
+
+Examples :
+
+	i2c@3d00 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
+		cell-index = <0>;
+		reg = <0x3d00 0x40>;
+		interrupts = <2 15 0>;
+		interrupt-parent = <&mpc5200_pic>;
+		fsl,preserve-clocking;
 	};
+
+	i2c@3100 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		cell-index = <1>;
+		compatible = "fsl,mpc8544-i2c", "fsl-i2c";
+		reg = <0x3100 0x100>;
+		interrupts = <43 2>;
+		interrupt-parent = <&mpic>;
+		clock-frequency = <400000>;
+	};
+
Index: linux-2.6-galak/include/linux/fsl_devices.h
===================================================================
--- linux-2.6-galak.orig/include/linux/fsl_devices.h	2009-04-07 10:09:08.185721241 +0200
+++ linux-2.6-galak/include/linux/fsl_devices.h	2009-04-07 10:09:15.414719119 +0200
@@ -43,10 +43,6 @@
  *
  */
 
-/* Flags related to I2C device features */
-#define FSL_I2C_DEV_SEPARATE_DFSRR	0x00000001
-#define FSL_I2C_DEV_CLOCK_5200		0x00000002
-
 enum fsl_usb2_operating_modes {
 	FSL_USB2_MPH_HOST,
 	FSL_USB2_DR_HOST,

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

* [PATCH v3 4/5] powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c; +Cc: devicetree-discuss, linuxppc-dev, Ben Dooks

This patch documents the new bindings for the MPC I2C bus driver.
Furthermore, it removes obsolete FSL device related definitions
for I2C.
It should go through the appropriate PowerPC maintainer(s) hands.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
 Documentation/powerpc/dts-bindings/fsl/i2c.txt |   46 ++++++++++++++++---------
 include/linux/fsl_devices.h                    |    4 --
 2 files changed, 31 insertions(+), 19 deletions(-)

Index: linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt
===================================================================
--- linux-2.6-galak.orig/Documentation/powerpc/dts-bindings/fsl/i2c.txt	2009-04-07 10:09:08.185721241 +0200
+++ linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt	2009-04-07 10:09:15.413719535 +0200
@@ -7,8 +7,10 @@
 
 Recommended properties :
 
- - compatible : Should be "fsl-i2c" for parts compatible with
-   Freescale I2C specifications.
+ - compatible : compatibility list with 2 entries, the first should
+   be "fsl,CHIP-i2c" where CHIP is the name of a compatible processor,
+   e.g. mpc8313, mpc8543, mpc8544, mpc5200 or mpc5200b. The second one
+   should be "fsl-i2c".
  - interrupts : <a b> where a is the interrupt number and b is a
    field that represents an encoding of the sense and level
    information for the interrupt.  This should be encoded based on
@@ -16,17 +18,31 @@
    controller you have.
  - interrupt-parent : the phandle for the interrupt controller that
    services interrupts for this device.
- - dfsrr : boolean; if defined, indicates that this I2C device has
-   a digital filter sampling rate register
- - fsl5200-clocking : boolean; if defined, indicated that this device
-   uses the FSL 5200 clocking mechanism.
-
-Example :
-	i2c@3000 {
-		interrupt-parent = <40000>;
-		interrupts = <1b 3>;
-		reg = <3000 18>;
-		device_type = "i2c";
-		compatible  = "fsl-i2c";
-		dfsrr;
+ - fsl,preserve-clocking : boolean; if defined, the clock settings
+   from the bootloader are preserved (not touched).
+ - clock-frequency : desired I2C bus clock frequency in Hz.
+
+Examples :
+
+	i2c@3d00 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
+		cell-index = <0>;
+		reg = <0x3d00 0x40>;
+		interrupts = <2 15 0>;
+		interrupt-parent = <&mpc5200_pic>;
+		fsl,preserve-clocking;
 	};
+
+	i2c@3100 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		cell-index = <1>;
+		compatible = "fsl,mpc8544-i2c", "fsl-i2c";
+		reg = <0x3100 0x100>;
+		interrupts = <43 2>;
+		interrupt-parent = <&mpic>;
+		clock-frequency = <400000>;
+	};
+
Index: linux-2.6-galak/include/linux/fsl_devices.h
===================================================================
--- linux-2.6-galak.orig/include/linux/fsl_devices.h	2009-04-07 10:09:08.185721241 +0200
+++ linux-2.6-galak/include/linux/fsl_devices.h	2009-04-07 10:09:15.414719119 +0200
@@ -43,10 +43,6 @@
  *
  */
 
-/* Flags related to I2C device features */
-#define FSL_I2C_DEV_SEPARATE_DFSRR	0x00000001
-#define FSL_I2C_DEV_CLOCK_5200		0x00000002
-
 enum fsl_usb2_operating_modes {
 	FSL_USB2_MPH_HOST,
 	FSL_USB2_DR_HOST,

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

* [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
  2009-04-07  8:20 [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable Wolfgang Grandegger
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  2009-04-07  8:20   ` Wolfgang Grandegger
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Ben Dooks, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Grant Likely,
	Kumar Gala, Wolfgang Grandegger

[-- Attachment #1: i2c-mpc-socrates-dts.patch --]
[-- Type: text/plain, Size: 1223 bytes --]

Preserve I2C clock settings for the Socrates MPC8544 board.

Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
---
 arch/powerpc/boot/dts/socrates.dts |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6-galak/arch/powerpc/boot/dts/socrates.dts
===================================================================
--- linux-2.6-galak.orig/arch/powerpc/boot/dts/socrates.dts	2009-04-07 10:09:07.161718915 +0200
+++ linux-2.6-galak/arch/powerpc/boot/dts/socrates.dts	2009-04-07 10:09:16.207719258 +0200
@@ -79,11 +79,11 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 			cell-index = <0>;
-			compatible = "fsl-i2c";
+			compatible = "fsl,mpc8544-i2c", "fsl-i2c";
 			reg = <0x3000 0x100>;
 			interrupts = <43 2>;
 			interrupt-parent = <&mpic>;
-			dfsrr;
+			fsl,preserve-clocking;
 
 			dtt@28 {
 				compatible = "winbond,w83782d";
@@ -111,11 +111,11 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 			cell-index = <1>;
-			compatible = "fsl-i2c";
+			compatible = "fsl,mpc8544-i2c", "fsl-i2c";
 			reg = <0x3100 0x100>;
 			interrupts = <43 2>;
 			interrupt-parent = <&mpic>;
-			dfsrr;
+			fsl,preserve-clocking;
 		};
 
 		enet0: ethernet@24000 {

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

* [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
@ 2009-04-07  8:20   ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-07  8:20 UTC (permalink / raw)
  To: linux-i2c; +Cc: devicetree-discuss, linuxppc-dev, Ben Dooks

Preserve I2C clock settings for the Socrates MPC8544 board.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
 arch/powerpc/boot/dts/socrates.dts |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6-galak/arch/powerpc/boot/dts/socrates.dts
===================================================================
--- linux-2.6-galak.orig/arch/powerpc/boot/dts/socrates.dts	2009-04-07 10:09:07.161718915 +0200
+++ linux-2.6-galak/arch/powerpc/boot/dts/socrates.dts	2009-04-07 10:09:16.207719258 +0200
@@ -79,11 +79,11 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 			cell-index = <0>;
-			compatible = "fsl-i2c";
+			compatible = "fsl,mpc8544-i2c", "fsl-i2c";
 			reg = <0x3000 0x100>;
 			interrupts = <43 2>;
 			interrupt-parent = <&mpic>;
-			dfsrr;
+			fsl,preserve-clocking;
 
 			dtt@28 {
 				compatible = "winbond,w83782d";
@@ -111,11 +111,11 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 			cell-index = <1>;
-			compatible = "fsl-i2c";
+			compatible = "fsl,mpc8544-i2c", "fsl-i2c";
 			reg = <0x3100 0x100>;
 			interrupts = <43 2>;
 			interrupt-parent = <&mpic>;
-			dfsrr;
+			fsl,preserve-clocking;
 		};
 
 		enet0: ethernet@24000 {

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

* Re: [PATCH v3 3/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-07  8:20   ` Wolfgang Grandegger
@ 2009-04-07 15:36       ` Grant Likely
  -1 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:36 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Kumar Gala

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> This patch makes the I2C bus speed configurable by using the I2C node
> property "clock-frequency". If the property is not defined, the old
> fixed clock settings will be used for backward comptibility.
>
> The generic I2C clock properties, especially the CPU-specific source
> clock pre-scaler are defined via the OF match table:
>
>  static const struct of_device_id mpc_i2c_of_match[] = {
>        ...
>        {.compatible = "fsl,mpc8543-i2c",
>         .data = &(struct fsl_i2c_match_data) {
>                        .setclock = mpc_i2c_setclock_8xxx,
>                        .prescaler = 2,
>                },
>        },
>
> The "data" field defines the relevant I2C setclock function and the
> relevant pre-scaler for the I2C source clock frequency.
>
> It uses arch-specific tables and functions to determine resonable
> Freqency Divider Register (fdr) values for MPC83xx, MPC85xx, MPC86xx,
> MPC5200 and MPC5200B.
>
> The i2c->flags field and the corresponding FSL_I2C_DEV_* definitions
> have been removed as they are obsolete.
>
> Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

I haven't tested it, but it looks good and I trust Wolfgang.

Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>

> ---
>  drivers/i2c/busses/i2c-mpc.c |  262 +++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 242 insertions(+), 20 deletions(-)
>
> Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
> ===================================================================
> --- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c   2009-04-07 10:09:14.012720756 +0200
> +++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c        2009-04-07 10:09:14.581719146 +0200
> @@ -26,6 +26,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/delay.h>
>
> +#include <asm/mpc52xx.h>
> +#include <sysdev/fsl_soc.h>
> +
>  #define DRV_NAME "mpc-i2c"
>
>  #define MPC_I2C_FDR   0x04
> @@ -56,7 +59,18 @@
>        wait_queue_head_t queue;
>        struct i2c_adapter adap;
>        int irq;
> -       u32 flags;
> +};
> +
> +struct mpc_i2c_divider {
> +       u16 divider;
> +       u16 fdr;        /* including dfsrr */
> +};
> +
> +struct mpc_i2c_match_data {
> +       void (*setclock)(struct device_node *node,
> +                        struct mpc_i2c *i2c,
> +                        u32 clock, u32 prescaler);
> +       u32 prescaler;
>  };
>
>  static inline void writeccr(struct mpc_i2c *i2c, u32 x)
> @@ -150,17 +164,180 @@
>        return 0;
>  }
>
> -static void mpc_i2c_setclock(struct mpc_i2c *i2c)
> +#ifdef CONFIG_PPC_52xx
> +static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
> +       {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
> +       {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
> +       {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
> +       {52, 0x63}, {56, 0x29}, {60, 0x41}, {64, 0x2a},
> +       {68, 0x07}, {72, 0x2b}, {80, 0x2c}, {88, 0x09},
> +       {96, 0x2d}, {104, 0x0a}, {112, 0x2e}, {120, 0x81},
> +       {128, 0x2f}, {136, 0x47}, {144, 0x0c}, {160, 0x30},
> +       {176, 0x49}, {192, 0x31}, {208, 0x4a}, {224, 0x32},
> +       {240, 0x0f}, {256, 0x33}, {272, 0x87}, {288, 0x10},
> +       {320, 0x34}, {352, 0x89}, {384, 0x35}, {416, 0x8a},
> +       {448, 0x36}, {480, 0x13}, {512, 0x37}, {576, 0x14},
> +       {640, 0x38}, {768, 0x39}, {896, 0x3a}, {960, 0x17},
> +       {1024, 0x3b}, {1152, 0x18}, {1280, 0x3c}, {1536, 0x3d},
> +       {1792, 0x3e}, {1920, 0x1b}, {2048, 0x3f}, {2304, 0x1c},
> +       {2560, 0x1d}, {3072, 0x1e}, {3584, 0x7e}, {3840, 0x1f},
> +       {4096, 0x7f}, {4608, 0x5c}, {5120, 0x5d}, {6144, 0x5e},
> +       {7168, 0xbe}, {7680, 0x5f}, {8192, 0xbf}, {9216, 0x9c},
> +       {10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f}
> +};
> +
> +int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
> +{
> +       const struct mpc52xx_i2c_divider *div = NULL;
> +       unsigned int pvr = mfspr(SPRN_PVR);
> +       u32 divider;
> +       int i;
> +
> +       if (!clock)
> +               return -EINVAL;
> +
> +       /* Determine divider value */
> +       divider = mpc52xx_find_ipb_freq(node) / clock;
> +
> +       /*
> +        * We want to choose an FDR/DFSR that generates an I2C bus speed that
> +        * is equal to or lower than the requested speed.
> +        */
> +       for (i = 0; i < ARRAY_SIZE(mpc52xx_i2c_dividers); i++) {
> +               div = &mpc_i2c_dividers_52xx[i];
> +               /* Old MPC5200 rev A CPUs do not support the high bits */
> +               if (div->fdr & 0xc0 && pvr == 0x80822011)
> +                       continue;
> +               if (div->divider >= divider)
> +                       break;
> +       }
> +
> +       return div ? (int)div->fdr : -EINVAL;
> +}
> +
> +static void mpc_i2c_setclock_52xx(struct device_node *node,
> +                                 struct mpc_i2c *i2c,
> +                                 u32 clock, u32 prescaler)
> +{
> +       int fdr = mpc52xx_i2c_get_fdr(node, clock, prescaler);
> +
> +       if (fdr < 0)
> +               fdr = 0x3f; /* backward compatibility */
> +       writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
> +       dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
> +}
> +#else /* !CONFIG_PPC_52xx */
> +static void mpc_i2c_setclock_52xx(struct device_node *node,
> +                                 struct mpc_i2c *i2c,
> +                                 u32 clock, u32 prescaler)
> +{
> +}
> +#endif /* CONFIG_PPC_52xx*/
> +
> +#ifdef CONFIG_FSL_SOC
> +static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
> +       {160, 0x0120}, {192, 0x0121}, {224, 0x0122}, {256, 0x0123},
> +       {288, 0x0100}, {320, 0x0101}, {352, 0x0601}, {384, 0x0102},
> +       {416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127},
> +       {544, 0x0b03}, {576, 0x0104}, {608, 0x1603}, {640, 0x0105},
> +       {672, 0x2003}, {704, 0x0b05}, {736, 0x2b03}, {768, 0x0106},
> +       {800, 0x3603}, {832, 0x0b06}, {896, 0x012a}, {960, 0x0107},
> +       {1024, 0x012b}, {1088, 0x1607}, {1152, 0x0108}, {1216, 0x2b07},
> +       {1280, 0x0109}, {1408, 0x1609}, {1536, 0x010a}, {1664, 0x160a},
> +       {1792, 0x012e}, {1920, 0x010b}, {2048, 0x012f}, {2176, 0x2b0b},
> +       {2304, 0x010c}, {2560, 0x010d}, {2816, 0x2b0d}, {3072, 0x010e},
> +       {3328, 0x2b0e}, {3584, 0x0132}, {3840, 0x010f}, {4096, 0x0133},
> +       {4608, 0x0110}, {5120, 0x0111}, {6144, 0x0112}, {7168, 0x0136},
> +       {7680, 0x0113}, {8192, 0x0137}, {9216, 0x0114}, {10240, 0x0115},
> +       {12288, 0x0116}, {14336, 0x013a}, {15360, 0x0117}, {16384, 0x013b},
> +       {18432, 0x0118}, {20480, 0x0119}, {24576, 0x011a}, {28672, 0x013e},
> +       {30720, 0x011b}, {32768, 0x013f}, {36864, 0x011c}, {40960, 0x011d},
> +       {49152, 0x011e}, {61440, 0x011f}
> +};
> +
> +u32 mpc_i2c_get_sec_cfg_8xxx(void)
> +{
> +       struct device_node *node = NULL;
> +       u32 __iomem *reg;
> +       u32 val = 0;
> +
> +       node = of_find_node_by_name(NULL, "global-utilities");
> +       if (node) {
> +               const u32 *prop = of_get_property(node, "reg", NULL);
> +               if (prop) {
> +                       /*
> +                        * Map and check POR Device Status Register 2
> +                        * (PORDEVSR2) at 0xE0014
> +                        */
> +                       reg = ioremap(get_immrbase() + *prop + 0x14, 0x4);
> +                       if (!reg)
> +                               printk(KERN_ERR
> +                                      "Error: couldn't map PORDEVSR2\n");
> +                       else
> +                               val = in_be32(reg) & 0x00000080; /* sec-cfg */
> +                       iounmap(reg);
> +               }
> +       }
> +       if (node)
> +               of_node_put(node);
> +
> +       return val;
> +}
> +
> +int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler)
> +{
> +       const struct mpc_i2c_divider *div = NULL;
> +       u32 divider;
> +       int i;
> +
> +       if (!clock)
> +               return -EINVAL;
> +
> +       /* Determine proper divider value */
> +       if (of_device_is_compatible(node, "fsl,mpc8544-i2c"))
> +               prescaler = mpc_i2c_get_sec_cfg_8xxx() ? 3 : 2;
> +       if (!prescaler)
> +               prescaler = 1;
> +
> +       divider = fsl_get_sys_freq() / clock / prescaler;
> +
> +       pr_debug("I2C: src_clock=%d clock=%d divider=%d\n",
> +                fsl_get_sys_freq(), clock, divider);
> +
> +       /*
> +        * We want to choose an FDR/DFSR that generates an I2C bus speed that
> +        * is equal to or lower than the requested speed.
> +        */
> +       for (i = 0; i < ARRAY_SIZE(mpc_i2c_dividers_8xxx); i++) {
> +               div = &mpc_i2c_dividers_8xxx[i];
> +               if (div->divider >= divider)
> +                       break;
> +       }
> +
> +       return div ? (int)div->fdr : -EINVAL;
> +}
> +
> +static void mpc_i2c_setclock_8xxx(struct device_node *node,
> +                                 struct mpc_i2c *i2c,
> +                                 u32 clock, u32 prescaler)
> +{
> +       int fdr = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
> +
> +       if (fdr < 0)
> +               fdr = 0x1031; /* backward compatibility */
> +       writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
> +       writeb((fdr >> 8) & 0xff, i2c->base + MPC_I2C_DFSRR);
> +       dev_info(i2c->dev, "clock %d Hz (dfsrr=%d fdr=%d)\n",
> +                clock, fdr >> 8, fdr & 0xff);
> +}
> +
> +#else /* !CONFIG_FSL_SOC */
> +static void mpc_i2c_setclock_8xxx(struct device_node *node,
> +                                 struct mpc_i2c *i2c,
> +                                 u32 clock, u32 prescaler)
>  {
> -       /* Set clock and filters */
> -       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->flags & FSL_I2C_DEV_CLOCK_5200)
> -               writeb(0x3f, i2c->base + MPC_I2C_FDR);
> -       else
> -               writel(0x1031, i2c->base + MPC_I2C_FDR);
>  }
> +#endif /* CONFIG_FSL_SOC */
>
>  static void mpc_i2c_start(struct mpc_i2c *i2c)
>  {
> @@ -315,8 +492,11 @@
>  static int __devinit fsl_i2c_probe(struct of_device *op,
>                                   const struct of_device_id *match)
>  {
> -       int result = 0;
>        struct mpc_i2c *i2c;
> +       const u32 *prop;
> +       u32 clock = 0;
> +       int result = 0;
> +       int plen;
>
>        i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
>        if (!i2c)
> @@ -324,13 +504,6 @@
>
>        i2c->dev = &op->dev; /* for debug and error output */
>
> -       if (of_get_property(op->node, "dfsrr", NULL))
> -               i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
> -
> -       if (of_device_is_compatible(op->node, "fsl,mpc5200-i2c") ||
> -                       of_device_is_compatible(op->node, "mpc5200-i2c"))
> -               i2c->flags |= FSL_I2C_DEV_CLOCK_5200;
> -
>        init_waitqueue_head(&i2c->queue);
>
>        i2c->base = of_iomap(op->node, 0);
> @@ -350,7 +523,22 @@
>                }
>        }
>
> -       mpc_i2c_setclock(i2c);
> +       if (!of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
> +               prop = of_get_property(op->node, "clock-frequency", &plen);
> +               if (prop && plen == sizeof(u32))
> +                       clock = *prop;
> +
> +               if (match->data) {
> +                       struct mpc_i2c_match_data *data =
> +                               (struct mpc_i2c_match_data *)match->data;
> +                       data->setclock(op->node, i2c, clock, data->prescaler);
> +               } else {
> +                       /* Backwards compatibility */
> +                       if (of_get_property(op->node, "dfsrr", NULL))
> +                               mpc_i2c_setclock_8xxx(op->node, i2c,
> +                                                     clock, 0);
> +               }
> +       }
>
>        dev_set_drvdata(&op->dev, i2c);
>
> @@ -395,9 +583,43 @@
>  };
>
>  static const struct of_device_id mpc_i2c_of_match[] = {
> -       {.compatible = "fsl-i2c",},
> +       {.compatible = "mpc5200-i2c",
> +        .data = &(struct mpc_i2c_match_data) {
> +                       .setclock = mpc_i2c_setclock_52xx,
> +               },
> +       },
> +       {.compatible = "fsl,mpc5200b-i2c",
> +        .data = &(struct mpc_i2c_match_data) {
> +                       .setclock = mpc_i2c_setclock_52xx,
> +               },
> +       },
> +       {.compatible = "fsl,mpc5200-i2c",
> +        .data = &(struct mpc_i2c_match_data) {
> +                       .setclock = mpc_i2c_setclock_52xx,
> +               },
> +       },
> +       {.compatible = "fsl,mpc8313-i2c",
> +        .data = &(struct mpc_i2c_match_data) {
> +                       .setclock = mpc_i2c_setclock_8xxx,
> +               },
> +       },
> +       {.compatible = "fsl,mpc8543-i2c",
> +        .data = &(struct mpc_i2c_match_data) {
> +                       .setclock = mpc_i2c_setclock_8xxx,
> +                       .prescaler = 2,
> +               },
> +       },
> +       {.compatible = "fsl,mpc8544-i2c",
> +        .data = &(struct mpc_i2c_match_data) {
> +                       .setclock = mpc_i2c_setclock_8xxx,
> +                       .prescaler = 3,
> +               },
> +       /* Backward compatibility */
> +       },
> +       {.compatible = "fsl-i2c", },
>        {},
>  };
> +
>  MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
>
>
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 3/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-07 15:36       ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:36 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> wro=
te:
> This patch makes the I2C bus speed configurable by using the I2C node
> property "clock-frequency". If the property is not defined, the old
> fixed clock settings will be used for backward comptibility.
>
> The generic I2C clock properties, especially the CPU-specific source
> clock pre-scaler are defined via the OF match table:
>
> =A0static const struct of_device_id mpc_i2c_of_match[] =3D {
> =A0 =A0 =A0 =A0...
> =A0 =A0 =A0 =A0{.compatible =3D "fsl,mpc8543-i2c",
> =A0 =A0 =A0 =A0 .data =3D &(struct fsl_i2c_match_data) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.setclock =3D mpc_i2c_setc=
lock_8xxx,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.prescaler =3D 2,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0},
> =A0 =A0 =A0 =A0},
>
> The "data" field defines the relevant I2C setclock function and the
> relevant pre-scaler for the I2C source clock frequency.
>
> It uses arch-specific tables and functions to determine resonable
> Freqency Divider Register (fdr) values for MPC83xx, MPC85xx, MPC86xx,
> MPC5200 and MPC5200B.
>
> The i2c->flags field and the corresponding FSL_I2C_DEV_* definitions
> have been removed as they are obsolete.
>
> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>

I haven't tested it, but it looks good and I trust Wolfgang.

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
> =A0drivers/i2c/busses/i2c-mpc.c | =A0262 ++++++++++++++++++++++++++++++++=
+++++++----
> =A01 file changed, 242 insertions(+), 20 deletions(-)
>
> Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c =A0 2009-04-07 10:0=
9:14.012720756 +0200
> +++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c =A0 =A0 =A0 =A02009-04-0=
7 10:09:14.581719146 +0200
> @@ -26,6 +26,9 @@
> =A0#include <linux/interrupt.h>
> =A0#include <linux/delay.h>
>
> +#include <asm/mpc52xx.h>
> +#include <sysdev/fsl_soc.h>
> +
> =A0#define DRV_NAME "mpc-i2c"
>
> =A0#define MPC_I2C_FDR =A0 0x04
> @@ -56,7 +59,18 @@
> =A0 =A0 =A0 =A0wait_queue_head_t queue;
> =A0 =A0 =A0 =A0struct i2c_adapter adap;
> =A0 =A0 =A0 =A0int irq;
> - =A0 =A0 =A0 u32 flags;
> +};
> +
> +struct mpc_i2c_divider {
> + =A0 =A0 =A0 u16 divider;
> + =A0 =A0 =A0 u16 fdr; =A0 =A0 =A0 =A0/* including dfsrr */
> +};
> +
> +struct mpc_i2c_match_data {
> + =A0 =A0 =A0 void (*setclock)(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct mpc_i2c *i2c,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0u32 clock, u32 prescaler=
);
> + =A0 =A0 =A0 u32 prescaler;
> =A0};
>
> =A0static inline void writeccr(struct mpc_i2c *i2c, u32 x)
> @@ -150,17 +164,180 @@
> =A0 =A0 =A0 =A0return 0;
> =A0}
>
> -static void mpc_i2c_setclock(struct mpc_i2c *i2c)
> +#ifdef CONFIG_PPC_52xx
> +static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] =3D {
> + =A0 =A0 =A0 {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
> + =A0 =A0 =A0 {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
> + =A0 =A0 =A0 {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
> + =A0 =A0 =A0 {52, 0x63}, {56, 0x29}, {60, 0x41}, {64, 0x2a},
> + =A0 =A0 =A0 {68, 0x07}, {72, 0x2b}, {80, 0x2c}, {88, 0x09},
> + =A0 =A0 =A0 {96, 0x2d}, {104, 0x0a}, {112, 0x2e}, {120, 0x81},
> + =A0 =A0 =A0 {128, 0x2f}, {136, 0x47}, {144, 0x0c}, {160, 0x30},
> + =A0 =A0 =A0 {176, 0x49}, {192, 0x31}, {208, 0x4a}, {224, 0x32},
> + =A0 =A0 =A0 {240, 0x0f}, {256, 0x33}, {272, 0x87}, {288, 0x10},
> + =A0 =A0 =A0 {320, 0x34}, {352, 0x89}, {384, 0x35}, {416, 0x8a},
> + =A0 =A0 =A0 {448, 0x36}, {480, 0x13}, {512, 0x37}, {576, 0x14},
> + =A0 =A0 =A0 {640, 0x38}, {768, 0x39}, {896, 0x3a}, {960, 0x17},
> + =A0 =A0 =A0 {1024, 0x3b}, {1152, 0x18}, {1280, 0x3c}, {1536, 0x3d},
> + =A0 =A0 =A0 {1792, 0x3e}, {1920, 0x1b}, {2048, 0x3f}, {2304, 0x1c},
> + =A0 =A0 =A0 {2560, 0x1d}, {3072, 0x1e}, {3584, 0x7e}, {3840, 0x1f},
> + =A0 =A0 =A0 {4096, 0x7f}, {4608, 0x5c}, {5120, 0x5d}, {6144, 0x5e},
> + =A0 =A0 =A0 {7168, 0xbe}, {7680, 0x5f}, {8192, 0xbf}, {9216, 0x9c},
> + =A0 =A0 =A0 {10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f}
> +};
> +
> +int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int presca=
ler)
> +{
> + =A0 =A0 =A0 const struct mpc52xx_i2c_divider *div =3D NULL;
> + =A0 =A0 =A0 unsigned int pvr =3D mfspr(SPRN_PVR);
> + =A0 =A0 =A0 u32 divider;
> + =A0 =A0 =A0 int i;
> +
> + =A0 =A0 =A0 if (!clock)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
> +
> + =A0 =A0 =A0 /* Determine divider value */
> + =A0 =A0 =A0 divider =3D mpc52xx_find_ipb_freq(node) / clock;
> +
> + =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0* We want to choose an FDR/DFSR that generates an I2C bu=
s speed that
> + =A0 =A0 =A0 =A0* is equal to or lower than the requested speed.
> + =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 for (i =3D 0; i < ARRAY_SIZE(mpc52xx_i2c_dividers); i++) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 div =3D &mpc_i2c_dividers_52xx[i];
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Old MPC5200 rev A CPUs do not support th=
e high bits */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (div->fdr & 0xc0 && pvr =3D=3D 0x8082201=
1)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (div->divider >=3D divider)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> + =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 return div ? (int)div->fdr : -EINVAL;
> +}
> +
> +static void mpc_i2c_setclock_52xx(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct =
mpc_i2c *i2c,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 u32 clo=
ck, u32 prescaler)
> +{
> + =A0 =A0 =A0 int fdr =3D mpc52xx_i2c_get_fdr(node, clock, prescaler);
> +
> + =A0 =A0 =A0 if (fdr < 0)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 fdr =3D 0x3f; /* backward compatibility */
> + =A0 =A0 =A0 writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
> + =A0 =A0 =A0 dev_info(i2c->dev, "clock %d Hz (fdr=3D%d)\n", clock, fdr);
> +}
> +#else /* !CONFIG_PPC_52xx */
> +static void mpc_i2c_setclock_52xx(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct =
mpc_i2c *i2c,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 u32 clo=
ck, u32 prescaler)
> +{
> +}
> +#endif /* CONFIG_PPC_52xx*/
> +
> +#ifdef CONFIG_FSL_SOC
> +static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] =3D {
> + =A0 =A0 =A0 {160, 0x0120}, {192, 0x0121}, {224, 0x0122}, {256, 0x0123},
> + =A0 =A0 =A0 {288, 0x0100}, {320, 0x0101}, {352, 0x0601}, {384, 0x0102},
> + =A0 =A0 =A0 {416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127},
> + =A0 =A0 =A0 {544, 0x0b03}, {576, 0x0104}, {608, 0x1603}, {640, 0x0105},
> + =A0 =A0 =A0 {672, 0x2003}, {704, 0x0b05}, {736, 0x2b03}, {768, 0x0106},
> + =A0 =A0 =A0 {800, 0x3603}, {832, 0x0b06}, {896, 0x012a}, {960, 0x0107},
> + =A0 =A0 =A0 {1024, 0x012b}, {1088, 0x1607}, {1152, 0x0108}, {1216, 0x2b=
07},
> + =A0 =A0 =A0 {1280, 0x0109}, {1408, 0x1609}, {1536, 0x010a}, {1664, 0x16=
0a},
> + =A0 =A0 =A0 {1792, 0x012e}, {1920, 0x010b}, {2048, 0x012f}, {2176, 0x2b=
0b},
> + =A0 =A0 =A0 {2304, 0x010c}, {2560, 0x010d}, {2816, 0x2b0d}, {3072, 0x01=
0e},
> + =A0 =A0 =A0 {3328, 0x2b0e}, {3584, 0x0132}, {3840, 0x010f}, {4096, 0x01=
33},
> + =A0 =A0 =A0 {4608, 0x0110}, {5120, 0x0111}, {6144, 0x0112}, {7168, 0x01=
36},
> + =A0 =A0 =A0 {7680, 0x0113}, {8192, 0x0137}, {9216, 0x0114}, {10240, 0x0=
115},
> + =A0 =A0 =A0 {12288, 0x0116}, {14336, 0x013a}, {15360, 0x0117}, {16384, =
0x013b},
> + =A0 =A0 =A0 {18432, 0x0118}, {20480, 0x0119}, {24576, 0x011a}, {28672, =
0x013e},
> + =A0 =A0 =A0 {30720, 0x011b}, {32768, 0x013f}, {36864, 0x011c}, {40960, =
0x011d},
> + =A0 =A0 =A0 {49152, 0x011e}, {61440, 0x011f}
> +};
> +
> +u32 mpc_i2c_get_sec_cfg_8xxx(void)
> +{
> + =A0 =A0 =A0 struct device_node *node =3D NULL;
> + =A0 =A0 =A0 u32 __iomem *reg;
> + =A0 =A0 =A0 u32 val =3D 0;
> +
> + =A0 =A0 =A0 node =3D of_find_node_by_name(NULL, "global-utilities");
> + =A0 =A0 =A0 if (node) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 const u32 *prop =3D of_get_property(node, "=
reg", NULL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (prop) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* Map and check POR Devi=
ce Status Register 2
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* (PORDEVSR2) at 0xE0014
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D ioremap(get_immrbas=
e() + *prop + 0x14, 0x4);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!reg)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN=
_ERR
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0"Error: couldn't map PORDEVSR2\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 else
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 val =3D in_=
be32(reg) & 0x00000080; /* sec-cfg */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 iounmap(reg);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 }
> + =A0 =A0 =A0 if (node)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_node_put(node);
> +
> + =A0 =A0 =A0 return val;
> +}
> +
> +int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 presca=
ler)
> +{
> + =A0 =A0 =A0 const struct mpc_i2c_divider *div =3D NULL;
> + =A0 =A0 =A0 u32 divider;
> + =A0 =A0 =A0 int i;
> +
> + =A0 =A0 =A0 if (!clock)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
> +
> + =A0 =A0 =A0 /* Determine proper divider value */
> + =A0 =A0 =A0 if (of_device_is_compatible(node, "fsl,mpc8544-i2c"))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 prescaler =3D mpc_i2c_get_sec_cfg_8xxx() ? =
3 : 2;
> + =A0 =A0 =A0 if (!prescaler)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 prescaler =3D 1;
> +
> + =A0 =A0 =A0 divider =3D fsl_get_sys_freq() / clock / prescaler;
> +
> + =A0 =A0 =A0 pr_debug("I2C: src_clock=3D%d clock=3D%d divider=3D%d\n",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fsl_get_sys_freq(), clock, divider);
> +
> + =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0* We want to choose an FDR/DFSR that generates an I2C bu=
s speed that
> + =A0 =A0 =A0 =A0* is equal to or lower than the requested speed.
> + =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 for (i =3D 0; i < ARRAY_SIZE(mpc_i2c_dividers_8xxx); i++) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 div =3D &mpc_i2c_dividers_8xxx[i];
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (div->divider >=3D divider)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> + =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 return div ? (int)div->fdr : -EINVAL;
> +}
> +
> +static void mpc_i2c_setclock_8xxx(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct =
mpc_i2c *i2c,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 u32 clo=
ck, u32 prescaler)
> +{
> + =A0 =A0 =A0 int fdr =3D mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
> +
> + =A0 =A0 =A0 if (fdr < 0)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 fdr =3D 0x1031; /* backward compatibility *=
/
> + =A0 =A0 =A0 writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
> + =A0 =A0 =A0 writeb((fdr >> 8) & 0xff, i2c->base + MPC_I2C_DFSRR);
> + =A0 =A0 =A0 dev_info(i2c->dev, "clock %d Hz (dfsrr=3D%d fdr=3D%d)\n",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clock, fdr >> 8, fdr & 0xff);
> +}
> +
> +#else /* !CONFIG_FSL_SOC */
> +static void mpc_i2c_setclock_8xxx(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct =
mpc_i2c *i2c,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 u32 clo=
ck, u32 prescaler)
> =A0{
> - =A0 =A0 =A0 /* Set clock and filters */
> - =A0 =A0 =A0 if (i2c->flags & FSL_I2C_DEV_SEPARATE_DFSRR) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 writeb(0x31, i2c->base + MPC_I2C_FDR);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 writeb(0x10, i2c->base + MPC_I2C_DFSRR);
> - =A0 =A0 =A0 } else if (i2c->flags & FSL_I2C_DEV_CLOCK_5200)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 writeb(0x3f, i2c->base + MPC_I2C_FDR);
> - =A0 =A0 =A0 else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 writel(0x1031, i2c->base + MPC_I2C_FDR);
> =A0}
> +#endif /* CONFIG_FSL_SOC */
>
> =A0static void mpc_i2c_start(struct mpc_i2c *i2c)
> =A0{
> @@ -315,8 +492,11 @@
> =A0static int __devinit fsl_i2c_probe(struct of_device *op,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const=
 struct of_device_id *match)
> =A0{
> - =A0 =A0 =A0 int result =3D 0;
> =A0 =A0 =A0 =A0struct mpc_i2c *i2c;
> + =A0 =A0 =A0 const u32 *prop;
> + =A0 =A0 =A0 u32 clock =3D 0;
> + =A0 =A0 =A0 int result =3D 0;
> + =A0 =A0 =A0 int plen;
>
> =A0 =A0 =A0 =A0i2c =3D kzalloc(sizeof(*i2c), GFP_KERNEL);
> =A0 =A0 =A0 =A0if (!i2c)
> @@ -324,13 +504,6 @@
>
> =A0 =A0 =A0 =A0i2c->dev =3D &op->dev; /* for debug and error output */
>
> - =A0 =A0 =A0 if (of_get_property(op->node, "dfsrr", NULL))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 i2c->flags |=3D FSL_I2C_DEV_SEPARATE_DFSRR;
> -
> - =A0 =A0 =A0 if (of_device_is_compatible(op->node, "fsl,mpc5200-i2c") ||
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_device_is_compatible(op-=
>node, "mpc5200-i2c"))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 i2c->flags |=3D FSL_I2C_DEV_CLOCK_5200;
> -
> =A0 =A0 =A0 =A0init_waitqueue_head(&i2c->queue);
>
> =A0 =A0 =A0 =A0i2c->base =3D of_iomap(op->node, 0);
> @@ -350,7 +523,22 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0}
>
> - =A0 =A0 =A0 mpc_i2c_setclock(i2c);
> + =A0 =A0 =A0 if (!of_get_property(op->node, "fsl,preserve-clocking", NUL=
L)) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 prop =3D of_get_property(op->node, "clock-f=
requency", &plen);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (prop && plen =3D=3D sizeof(u32))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 clock =3D *prop;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (match->data) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct mpc_i2c_match_data *=
data =3D
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (struct mpc=
_i2c_match_data *)match->data;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 data->setclock(op->node, i2=
c, clock, data->prescaler);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Backwards compatibility =
*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (of_get_property(op->nod=
e, "dfsrr", NULL))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mpc_i2c_set=
clock_8xxx(op->node, i2c,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 clock, 0);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 }
>
> =A0 =A0 =A0 =A0dev_set_drvdata(&op->dev, i2c);
>
> @@ -395,9 +583,43 @@
> =A0};
>
> =A0static const struct of_device_id mpc_i2c_of_match[] =3D {
> - =A0 =A0 =A0 {.compatible =3D "fsl-i2c",},
> + =A0 =A0 =A0 {.compatible =3D "mpc5200-i2c",
> + =A0 =A0 =A0 =A0.data =3D &(struct mpc_i2c_match_data) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .setclock =3D mpc_i2c_setcl=
ock_52xx,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 },
> + =A0 =A0 =A0 },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc5200b-i2c",
> + =A0 =A0 =A0 =A0.data =3D &(struct mpc_i2c_match_data) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .setclock =3D mpc_i2c_setcl=
ock_52xx,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 },
> + =A0 =A0 =A0 },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc5200-i2c",
> + =A0 =A0 =A0 =A0.data =3D &(struct mpc_i2c_match_data) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .setclock =3D mpc_i2c_setcl=
ock_52xx,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 },
> + =A0 =A0 =A0 },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc8313-i2c",
> + =A0 =A0 =A0 =A0.data =3D &(struct mpc_i2c_match_data) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .setclock =3D mpc_i2c_setcl=
ock_8xxx,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 },
> + =A0 =A0 =A0 },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc8543-i2c",
> + =A0 =A0 =A0 =A0.data =3D &(struct mpc_i2c_match_data) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .setclock =3D mpc_i2c_setcl=
ock_8xxx,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .prescaler =3D 2,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 },
> + =A0 =A0 =A0 },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc8544-i2c",
> + =A0 =A0 =A0 =A0.data =3D &(struct mpc_i2c_match_data) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .setclock =3D mpc_i2c_setcl=
ock_8xxx,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .prescaler =3D 3,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 },
> + =A0 =A0 =A0 /* Backward compatibility */
> + =A0 =A0 =A0 },
> + =A0 =A0 =A0 {.compatible =3D "fsl-i2c", },
> =A0 =A0 =A0 =A0{},
> =A0};
> +
> =A0MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
>
>
>
>



--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 1/5] i2c: i2c-mpc: various coding style fixes
  2009-04-07  8:20   ` Wolfgang Grandegger
@ 2009-04-07 15:36       ` Grant Likely
  -1 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:36 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Kumar Gala

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> Fix errors reported by checkpatch (indention, long lines, trailing
> white space, etc.).
>
> Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>

> ---
>  drivers/i2c/busses/i2c-mpc.c |   35 ++++++++++++++++++-----------------
>  1 file changed, 18 insertions(+), 17 deletions(-)
>
> Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
> ===================================================================
> --- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c   2009-04-07 10:09:09.400719216 +0200
> +++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c        2009-04-07 10:09:13.271719088 +0200
> @@ -20,7 +20,7 @@
>  #include <linux/of_platform.h>
>  #include <linux/of_i2c.h>
>
> -#include <asm/io.h>
> +#include <linux/io.h>
>  #include <linux/fsl_devices.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> @@ -28,10 +28,10 @@
>
>  #define DRV_NAME "mpc-i2c"
>
> -#define MPC_I2C_FDR    0x04
> -#define MPC_I2C_CR     0x08
> -#define MPC_I2C_SR     0x0c
> -#define MPC_I2C_DR     0x10
> +#define MPC_I2C_FDR   0x04
> +#define MPC_I2C_CR    0x08
> +#define MPC_I2C_SR    0x0c
> +#define MPC_I2C_DR    0x10
>  #define MPC_I2C_DFSRR 0x14
>
>  #define CCR_MEN  0x80
> @@ -58,7 +58,7 @@
>        u32 flags;
>  };
>
> -static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x)
> +static inline void writeccr(struct mpc_i2c *i2c, u32 x)
>  {
>        writeb(x, i2c->base + MPC_I2C_CR);
>  }
> @@ -100,8 +100,7 @@
>        u32 x;
>        int result = 0;
>
> -       if (i2c->irq == NO_IRQ)
> -       {
> +       if (i2c->irq == NO_IRQ) {
>                while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
>                        schedule();
>                        if (time_after(jiffies, orig_jiffies + timeout)) {
> @@ -176,7 +175,7 @@
>  }
>
>  static int mpc_write(struct mpc_i2c *i2c, int target,
> -                    const u8 * data, int length, int restart)
> +                    const u8 *data, int length, int restart)
>  {
>        int i, result;
>        unsigned timeout = i2c->adap.timeout;
> @@ -207,7 +206,7 @@
>  }
>
>  static int mpc_read(struct mpc_i2c *i2c, int target,
> -                   u8 * data, int length, int restart)
> +                   u8 *data, int length, int restart)
>  {
>        unsigned timeout = i2c->adap.timeout;
>        int i, result;
> @@ -311,7 +310,8 @@
>        .timeout = HZ,
>  };
>
> -static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match)
> +static int __devinit fsl_i2c_probe(struct of_device *op,
> +                                  const struct of_device_id *match)
>  {
>        int result = 0;
>        struct mpc_i2c *i2c;
> @@ -341,11 +341,12 @@
>                result = request_irq(i2c->irq, mpc_i2c_isr,
>                                     IRQF_SHARED, "i2c-mpc", i2c);
>                if (result < 0) {
> -                       printk(KERN_ERR "i2c-mpc - failed to attach interrupt\n");
> +                       printk(KERN_ERR
> +                              "i2c-mpc - failed to attach interrupt\n");
>                        goto fail_request;
>                }
>        }
> -
> +
>        mpc_i2c_setclock(i2c);
>
>        dev_set_drvdata(&op->dev, i2c);
> @@ -368,7 +369,7 @@
>        free_irq(i2c->irq, i2c);
>  fail_request:
>        irq_dispose_mapping(i2c->irq);
> -       iounmap(i2c->base);
> +       iounmap(i2c->base);
>  fail_map:
>        kfree(i2c);
>        return result;
> @@ -414,7 +415,7 @@
>
>        rv = of_register_platform_driver(&mpc_i2c_driver);
>        if (rv)
> -               printk(KERN_ERR DRV_NAME
> +               printk(KERN_ERR DRV_NAME
>                       " of_register_platform_driver failed (%i)\n", rv);
>        return rv;
>  }
> @@ -428,6 +429,6 @@
>  module_exit(fsl_i2c_exit);
>
>  MODULE_AUTHOR("Adrian Cox <adrian-nKrwMtk+6Wm9FHfhHBbuYA@public.gmane.org>");
> -MODULE_DESCRIPTION
> -    ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors");
> +MODULE_DESCRIPTION("I2C-Bus adapter for MPC107 bridge and "
> +                  "MPC824x/85xx/52xx processors");
>  MODULE_LICENSE("GPL");
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 1/5] i2c: i2c-mpc: various coding style fixes
@ 2009-04-07 15:36       ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:36 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> wro=
te:
> Fix errors reported by checkpatch (indention, long lines, trailing
> white space, etc.).
>
> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
> =A0drivers/i2c/busses/i2c-mpc.c | =A0 35 ++++++++++++++++++--------------=
---
> =A01 file changed, 18 insertions(+), 17 deletions(-)
>
> Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c =A0 2009-04-07 10:0=
9:09.400719216 +0200
> +++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c =A0 =A0 =A0 =A02009-04-0=
7 10:09:13.271719088 +0200
> @@ -20,7 +20,7 @@
> =A0#include <linux/of_platform.h>
> =A0#include <linux/of_i2c.h>
>
> -#include <asm/io.h>
> +#include <linux/io.h>
> =A0#include <linux/fsl_devices.h>
> =A0#include <linux/i2c.h>
> =A0#include <linux/interrupt.h>
> @@ -28,10 +28,10 @@
>
> =A0#define DRV_NAME "mpc-i2c"
>
> -#define MPC_I2C_FDR =A0 =A00x04
> -#define MPC_I2C_CR =A0 =A0 0x08
> -#define MPC_I2C_SR =A0 =A0 0x0c
> -#define MPC_I2C_DR =A0 =A0 0x10
> +#define MPC_I2C_FDR =A0 0x04
> +#define MPC_I2C_CR =A0 =A00x08
> +#define MPC_I2C_SR =A0 =A00x0c
> +#define MPC_I2C_DR =A0 =A00x10
> =A0#define MPC_I2C_DFSRR 0x14
>
> =A0#define CCR_MEN =A00x80
> @@ -58,7 +58,7 @@
> =A0 =A0 =A0 =A0u32 flags;
> =A0};
>
> -static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x)
> +static inline void writeccr(struct mpc_i2c *i2c, u32 x)
> =A0{
> =A0 =A0 =A0 =A0writeb(x, i2c->base + MPC_I2C_CR);
> =A0}
> @@ -100,8 +100,7 @@
> =A0 =A0 =A0 =A0u32 x;
> =A0 =A0 =A0 =A0int result =3D 0;
>
> - =A0 =A0 =A0 if (i2c->irq =3D=3D NO_IRQ)
> - =A0 =A0 =A0 {
> + =A0 =A0 =A0 if (i2c->irq =3D=3D NO_IRQ) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0while (!(readb(i2c->base + MPC_I2C_SR) & C=
SR_MIF)) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0schedule();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (time_after(jiffies, or=
ig_jiffies + timeout)) {
> @@ -176,7 +175,7 @@
> =A0}
>
> =A0static int mpc_write(struct mpc_i2c *i2c, int target,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const u8 * data, int length, int=
 restart)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const u8 *data, int length, int =
restart)
> =A0{
> =A0 =A0 =A0 =A0int i, result;
> =A0 =A0 =A0 =A0unsigned timeout =3D i2c->adap.timeout;
> @@ -207,7 +206,7 @@
> =A0}
>
> =A0static int mpc_read(struct mpc_i2c *i2c, int target,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 u8 * data, int length, int restart)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 u8 *data, int length, int restart)
> =A0{
> =A0 =A0 =A0 =A0unsigned timeout =3D i2c->adap.timeout;
> =A0 =A0 =A0 =A0int i, result;
> @@ -311,7 +310,8 @@
> =A0 =A0 =A0 =A0.timeout =3D HZ,
> =A0};
>
> -static int __devinit fsl_i2c_probe(struct of_device *op, const struct of=
_device_id *match)
> +static int __devinit fsl_i2c_probe(struct of_device *op,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cons=
t struct of_device_id *match)
> =A0{
> =A0 =A0 =A0 =A0int result =3D 0;
> =A0 =A0 =A0 =A0struct mpc_i2c *i2c;
> @@ -341,11 +341,12 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0result =3D request_irq(i2c->irq, mpc_i2c_i=
sr,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 I=
RQF_SHARED, "i2c-mpc", i2c);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (result < 0) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR "i2c-mpc - =
failed to attach interrupt\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"i2c-mpc - f=
ailed to attach interrupt\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto fail_request;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0}
> -
> +
> =A0 =A0 =A0 =A0mpc_i2c_setclock(i2c);
>
> =A0 =A0 =A0 =A0dev_set_drvdata(&op->dev, i2c);
> @@ -368,7 +369,7 @@
> =A0 =A0 =A0 =A0free_irq(i2c->irq, i2c);
> =A0fail_request:
> =A0 =A0 =A0 =A0irq_dispose_mapping(i2c->irq);
> - =A0 =A0 =A0 iounmap(i2c->base);
> + =A0 =A0 =A0 iounmap(i2c->base);
> =A0fail_map:
> =A0 =A0 =A0 =A0kfree(i2c);
> =A0 =A0 =A0 =A0return result;
> @@ -414,7 +415,7 @@
>
> =A0 =A0 =A0 =A0rv =3D of_register_platform_driver(&mpc_i2c_driver);
> =A0 =A0 =A0 =A0if (rv)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR DRV_NAME
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR DRV_NAME
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " of_register_platform_driver=
 failed (%i)\n", rv);
> =A0 =A0 =A0 =A0return rv;
> =A0}
> @@ -428,6 +429,6 @@
> =A0module_exit(fsl_i2c_exit);
>
> =A0MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
> -MODULE_DESCRIPTION
> - =A0 =A0("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx proces=
sors");
> +MODULE_DESCRIPTION("I2C-Bus adapter for MPC107 bridge and "
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"MPC824x/85xx/52xx processors");
> =A0MODULE_LICENSE("GPL");
>
>



--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 2/5] i2c: i2c-mpc: use dev based printout function
  2009-04-07  8:20   ` Wolfgang Grandegger
@ 2009-04-07 15:37       ` Grant Likely
  -1 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:37 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Kumar Gala

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> This patch used the dev_dbg, dev_err, etc. functions for debug
> and error output instead of printk and pr_debug.
>
> Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>

> ---
>  drivers/i2c/busses/i2c-mpc.c |   31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
>
> Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
> ===================================================================
> --- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c   2009-04-07 10:09:13.271719088 +0200
> +++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c        2009-04-07 10:09:14.012720756 +0200
> @@ -50,6 +50,7 @@
>  #define CSR_RXAK 0x01
>
>  struct mpc_i2c {
> +       struct device *dev;
>        void __iomem *base;
>        u32 interrupt;
>        wait_queue_head_t queue;
> @@ -104,7 +105,7 @@
>                while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
>                        schedule();
>                        if (time_after(jiffies, orig_jiffies + timeout)) {
> -                               pr_debug("I2C: timeout\n");
> +                               dev_dbg(i2c->dev, "timeout\n");
>                                writeccr(i2c, 0);
>                                result = -EIO;
>                                break;
> @@ -118,7 +119,7 @@
>                        (i2c->interrupt & CSR_MIF), timeout);
>
>                if (unlikely(!(i2c->interrupt & CSR_MIF))) {
> -                       pr_debug("I2C: wait timeout\n");
> +                       dev_dbg(i2c->dev, "wait timeout\n");
>                        writeccr(i2c, 0);
>                        result = -ETIMEDOUT;
>                }
> @@ -131,17 +132,17 @@
>                return result;
>
>        if (!(x & CSR_MCF)) {
> -               pr_debug("I2C: unfinished\n");
> +               dev_dbg(i2c->dev, "unfinished\n");
>                return -EIO;
>        }
>
>        if (x & CSR_MAL) {
> -               pr_debug("I2C: MAL\n");
> +               dev_dbg(i2c->dev, "MAL\n");
>                return -EIO;
>        }
>
>        if (writing && (x & CSR_RXAK)) {
> -               pr_debug("I2C: No RXAK\n");
> +               dev_dbg(i2c->dev, "No RXAK\n");
>                /* generate stop */
>                writeccr(i2c, CCR_MEN);
>                return -EIO;
> @@ -263,12 +264,12 @@
>        /* Allow bus up to 1s to become not busy */
>        while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
>                if (signal_pending(current)) {
> -                       pr_debug("I2C: Interrupted\n");
> +                       dev_dbg(i2c->dev, "Interrupted\n");
>                        writeccr(i2c, 0);
>                        return -EINTR;
>                }
>                if (time_after(jiffies, orig_jiffies + HZ)) {
> -                       pr_debug("I2C: timeout\n");
> +                       dev_dbg(i2c->dev, "timeout\n");
>                        if (readb(i2c->base + MPC_I2C_SR) ==
>                            (CSR_MCF | CSR_MBB | CSR_RXAK))
>                                mpc_i2c_fixup(i2c);
> @@ -279,9 +280,10 @@
>
>        for (i = 0; ret >= 0 && i < num; i++) {
>                pmsg = &msgs[i];
> -               pr_debug("Doing %s %d bytes to 0x%02x - %d of %d messages\n",
> -                        pmsg->flags & I2C_M_RD ? "read" : "write",
> -                        pmsg->len, pmsg->addr, i + 1, num);
> +               dev_dbg(i2c->dev,
> +                       "Doing %s %d bytes to 0x%02x - %d of %d messages\n",
> +                       pmsg->flags & I2C_M_RD ? "read" : "write",
> +                       pmsg->len, pmsg->addr, i + 1, num);
>                if (pmsg->flags & I2C_M_RD)
>                        ret =
>                            mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
> @@ -320,6 +322,8 @@
>        if (!i2c)
>                return -ENOMEM;
>
> +       i2c->dev = &op->dev; /* for debug and error output */
> +
>        if (of_get_property(op->node, "dfsrr", NULL))
>                i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
>
> @@ -331,7 +335,7 @@
>
>        i2c->base = of_iomap(op->node, 0);
>        if (!i2c->base) {
> -               printk(KERN_ERR "i2c-mpc - failed to map controller\n");
> +               dev_err(i2c->dev, "failed to map controller\n");
>                result = -ENOMEM;
>                goto fail_map;
>        }
> @@ -341,8 +345,7 @@
>                result = request_irq(i2c->irq, mpc_i2c_isr,
>                                     IRQF_SHARED, "i2c-mpc", i2c);
>                if (result < 0) {
> -                       printk(KERN_ERR
> -                              "i2c-mpc - failed to attach interrupt\n");
> +                       dev_err(i2c->dev, "failed to attach interrupt\n");
>                        goto fail_request;
>                }
>        }
> @@ -357,7 +360,7 @@
>
>        result = i2c_add_adapter(&i2c->adap);
>        if (result < 0) {
> -               printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
> +               dev_err(i2c->dev, "failed to add adapter\n");
>                goto fail_add;
>        }
>        of_register_i2c_devices(&i2c->adap, op->node);
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 2/5] i2c: i2c-mpc: use dev based printout function
@ 2009-04-07 15:37       ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:37 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> wro=
te:
> This patch used the dev_dbg, dev_err, etc. functions for debug
> and error output instead of printk and pr_debug.
>
> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
> =A0drivers/i2c/busses/i2c-mpc.c | =A0 31 +++++++++++++++++--------------
> =A01 file changed, 17 insertions(+), 14 deletions(-)
>
> Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c =A0 2009-04-07 10:0=
9:13.271719088 +0200
> +++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c =A0 =A0 =A0 =A02009-04-0=
7 10:09:14.012720756 +0200
> @@ -50,6 +50,7 @@
> =A0#define CSR_RXAK 0x01
>
> =A0struct mpc_i2c {
> + =A0 =A0 =A0 struct device *dev;
> =A0 =A0 =A0 =A0void __iomem *base;
> =A0 =A0 =A0 =A0u32 interrupt;
> =A0 =A0 =A0 =A0wait_queue_head_t queue;
> @@ -104,7 +105,7 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0while (!(readb(i2c->base + MPC_I2C_SR) & C=
SR_MIF)) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0schedule();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (time_after(jiffies, or=
ig_jiffies + timeout)) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_debug("I=
2C: timeout\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c=
->dev, "timeout\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0writeccr(i=
2c, 0);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0result =3D=
 -EIO;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
> @@ -118,7 +119,7 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(i2c->interrupt & CSR_MIF)=
, timeout);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (unlikely(!(i2c->interrupt & CSR_MIF)))=
 {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_debug("I2C: wait timeout=
\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c->dev, "wait tim=
eout\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0writeccr(i2c, 0);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0result =3D -ETIMEDOUT;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> @@ -131,17 +132,17 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return result;
>
> =A0 =A0 =A0 =A0if (!(x & CSR_MCF)) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_debug("I2C: unfinished\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c->dev, "unfinished\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -EIO;
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0if (x & CSR_MAL) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_debug("I2C: MAL\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c->dev, "MAL\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -EIO;
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0if (writing && (x & CSR_RXAK)) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_debug("I2C: No RXAK\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c->dev, "No RXAK\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* generate stop */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0writeccr(i2c, CCR_MEN);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -EIO;
> @@ -263,12 +264,12 @@
> =A0 =A0 =A0 =A0/* Allow bus up to 1s to become not busy */
> =A0 =A0 =A0 =A0while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (signal_pending(current)) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_debug("I2C: Interrupted\=
n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c->dev, "Interrup=
ted\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0writeccr(i2c, 0);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -EINTR;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (time_after(jiffies, orig_jiffies + HZ)=
) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_debug("I2C: timeout\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c->dev, "timeout\=
n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (readb(i2c->base + MPC_=
I2C_SR) =3D=3D
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(CSR_MCF | CSR_MBB=
 | CSR_RXAK))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mpc_i2c_fi=
xup(i2c);
> @@ -279,9 +280,10 @@
>
> =A0 =A0 =A0 =A0for (i =3D 0; ret >=3D 0 && i < num; i++) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pmsg =3D &msgs[i];
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_debug("Doing %s %d bytes to 0x%02x - %d =
of %d messages\n",
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pmsg->flags & I2C_M_RD ?=
 "read" : "write",
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pmsg->len, pmsg->addr, i=
 + 1, num);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c->dev,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Doing %s %d bytes to 0x%02=
x - %d of %d messages\n",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmsg->flags & I2C_M_RD ? "r=
ead" : "write",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pmsg->len, pmsg->addr, i + =
1, num);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (pmsg->flags & I2C_M_RD)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mpc_read(i2c, pmsg=
->addr, pmsg->buf, pmsg->len, i);
> @@ -320,6 +322,8 @@
> =A0 =A0 =A0 =A0if (!i2c)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -ENOMEM;
>
> + =A0 =A0 =A0 i2c->dev =3D &op->dev; /* for debug and error output */
> +
> =A0 =A0 =A0 =A0if (of_get_property(op->node, "dfsrr", NULL))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0i2c->flags |=3D FSL_I2C_DEV_SEPARATE_DFSRR=
;
>
> @@ -331,7 +335,7 @@
>
> =A0 =A0 =A0 =A0i2c->base =3D of_iomap(op->node, 0);
> =A0 =A0 =A0 =A0if (!i2c->base) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR "i2c-mpc - failed to map co=
ntroller\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_err(i2c->dev, "failed to map controller=
\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0result =3D -ENOMEM;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto fail_map;
> =A0 =A0 =A0 =A0}
> @@ -341,8 +345,7 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0result =3D request_irq(i2c->irq, mpc_i2c_i=
sr,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 I=
RQF_SHARED, "i2c-mpc", i2c);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (result < 0) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"i2c-mpc - f=
ailed to attach interrupt\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_err(i2c->dev, "failed t=
o attach interrupt\n");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto fail_request;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0}
> @@ -357,7 +360,7 @@
>
> =A0 =A0 =A0 =A0result =3D i2c_add_adapter(&i2c->adap);
> =A0 =A0 =A0 =A0if (result < 0) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR "i2c-mpc - failed to add ad=
apter\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_err(i2c->dev, "failed to add adapter\n"=
);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto fail_add;
> =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0of_register_i2c_devices(&i2c->adap, op->node);
>
>



--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
  2009-04-07  8:20   ` Wolfgang Grandegger
@ 2009-04-07 15:43       ` Grant Likely
  -1 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:43 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Kumar Gala

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> Preserve I2C clock settings for the Socrates MPC8544 board.

I had thought that the preserve-clocking property was intended for
older boards that don't currently have any method of getting the clock
setting out of u-boot.  Since Socrates is a new board, U-Boot should
probably be made to fill in the real clock rate setting.

g.

>
> Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
> ---
>  arch/powerpc/boot/dts/socrates.dts |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> Index: linux-2.6-galak/arch/powerpc/boot/dts/socrates.dts
> ===================================================================
> --- linux-2.6-galak.orig/arch/powerpc/boot/dts/socrates.dts     2009-04-07 10:09:07.161718915 +0200
> +++ linux-2.6-galak/arch/powerpc/boot/dts/socrates.dts  2009-04-07 10:09:16.207719258 +0200
> @@ -79,11 +79,11 @@
>                        #address-cells = <1>;
>                        #size-cells = <0>;
>                        cell-index = <0>;
> -                       compatible = "fsl-i2c";
> +                       compatible = "fsl,mpc8544-i2c", "fsl-i2c";
>                        reg = <0x3000 0x100>;
>                        interrupts = <43 2>;
>                        interrupt-parent = <&mpic>;
> -                       dfsrr;
> +                       fsl,preserve-clocking;
>
>                        dtt@28 {
>                                compatible = "winbond,w83782d";
> @@ -111,11 +111,11 @@
>                        #address-cells = <1>;
>                        #size-cells = <0>;
>                        cell-index = <1>;
> -                       compatible = "fsl-i2c";
> +                       compatible = "fsl,mpc8544-i2c", "fsl-i2c";
>                        reg = <0x3100 0x100>;
>                        interrupts = <43 2>;
>                        interrupt-parent = <&mpic>;
> -                       dfsrr;
> +                       fsl,preserve-clocking;
>                };
>
>                enet0: ethernet@24000 {
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
@ 2009-04-07 15:43       ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:43 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> wro=
te:
> Preserve I2C clock settings for the Socrates MPC8544 board.

I had thought that the preserve-clocking property was intended for
older boards that don't currently have any method of getting the clock
setting out of u-boot.  Since Socrates is a new board, U-Boot should
probably be made to fill in the real clock rate setting.

g.

>
> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
> ---
> =A0arch/powerpc/boot/dts/socrates.dts | =A0 =A08 ++++----
> =A01 file changed, 4 insertions(+), 4 deletions(-)
>
> Index: linux-2.6-galak/arch/powerpc/boot/dts/socrates.dts
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- linux-2.6-galak.orig/arch/powerpc/boot/dts/socrates.dts =A0 =A0 2009-=
04-07 10:09:07.161718915 +0200
> +++ linux-2.6-galak/arch/powerpc/boot/dts/socrates.dts =A02009-04-07 10:0=
9:16.207719258 +0200
> @@ -79,11 +79,11 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#address-cells =3D <1>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#size-cells =3D <0>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cell-index =3D <0>;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl-i2c";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc8544=
-i2c", "fsl-i2c";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0x3000 0x100>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D <43 2>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-parent =3D <&mpi=
c>;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dfsrr;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fsl,preserve-clocking;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dtt@28 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible=
 =3D "winbond,w83782d";
> @@ -111,11 +111,11 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#address-cells =3D <1>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#size-cells =3D <0>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cell-index =3D <1>;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl-i2c";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc8544=
-i2c", "fsl-i2c";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0x3100 0x100>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D <43 2>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-parent =3D <&mpi=
c>;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dfsrr;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fsl,preserve-clocking;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0};
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0enet0: ethernet@24000 {
>
>



--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 4/5] powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
  2009-04-07  8:20   ` Wolfgang Grandegger
@ 2009-04-07 15:43       ` Grant Likely
  -1 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:43 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Kumar Gala

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> This patch documents the new bindings for the MPC I2C bus driver.
> Furthermore, it removes obsolete FSL device related definitions
> for I2C.
> It should go through the appropriate PowerPC maintainer(s) hands.
>
> Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>

> ---
>  Documentation/powerpc/dts-bindings/fsl/i2c.txt |   46 ++++++++++++++++---------
>  include/linux/fsl_devices.h                    |    4 --
>  2 files changed, 31 insertions(+), 19 deletions(-)
>
> Index: linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt
> ===================================================================
> --- linux-2.6-galak.orig/Documentation/powerpc/dts-bindings/fsl/i2c.txt 2009-04-07 10:09:08.185721241 +0200
> +++ linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt      2009-04-07 10:09:15.413719535 +0200
> @@ -7,8 +7,10 @@
>
>  Recommended properties :
>
> - - compatible : Should be "fsl-i2c" for parts compatible with
> -   Freescale I2C specifications.
> + - compatible : compatibility list with 2 entries, the first should
> +   be "fsl,CHIP-i2c" where CHIP is the name of a compatible processor,
> +   e.g. mpc8313, mpc8543, mpc8544, mpc5200 or mpc5200b. The second one
> +   should be "fsl-i2c".
>  - interrupts : <a b> where a is the interrupt number and b is a
>    field that represents an encoding of the sense and level
>    information for the interrupt.  This should be encoded based on
> @@ -16,17 +18,31 @@
>    controller you have.
>  - interrupt-parent : the phandle for the interrupt controller that
>    services interrupts for this device.
> - - dfsrr : boolean; if defined, indicates that this I2C device has
> -   a digital filter sampling rate register
> - - fsl5200-clocking : boolean; if defined, indicated that this device
> -   uses the FSL 5200 clocking mechanism.
> -
> -Example :
> -       i2c@3000 {
> -               interrupt-parent = <40000>;
> -               interrupts = <1b 3>;
> -               reg = <3000 18>;
> -               device_type = "i2c";
> -               compatible  = "fsl-i2c";
> -               dfsrr;
> + - fsl,preserve-clocking : boolean; if defined, the clock settings
> +   from the bootloader are preserved (not touched).
> + - clock-frequency : desired I2C bus clock frequency in Hz.
> +
> +Examples :
> +
> +       i2c@3d00 {
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +               compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
> +               cell-index = <0>;
> +               reg = <0x3d00 0x40>;
> +               interrupts = <2 15 0>;
> +               interrupt-parent = <&mpc5200_pic>;
> +               fsl,preserve-clocking;
>        };
> +
> +       i2c@3100 {
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +               cell-index = <1>;
> +               compatible = "fsl,mpc8544-i2c", "fsl-i2c";
> +               reg = <0x3100 0x100>;
> +               interrupts = <43 2>;
> +               interrupt-parent = <&mpic>;
> +               clock-frequency = <400000>;
> +       };
> +
> Index: linux-2.6-galak/include/linux/fsl_devices.h
> ===================================================================
> --- linux-2.6-galak.orig/include/linux/fsl_devices.h    2009-04-07 10:09:08.185721241 +0200
> +++ linux-2.6-galak/include/linux/fsl_devices.h 2009-04-07 10:09:15.414719119 +0200
> @@ -43,10 +43,6 @@
>  *
>  */
>
> -/* Flags related to I2C device features */
> -#define FSL_I2C_DEV_SEPARATE_DFSRR     0x00000001
> -#define FSL_I2C_DEV_CLOCK_5200         0x00000002
> -
>  enum fsl_usb2_operating_modes {
>        FSL_USB2_MPH_HOST,
>        FSL_USB2_DR_HOST,
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 4/5] powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
@ 2009-04-07 15:43       ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-07 15:43 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> wro=
te:
> This patch documents the new bindings for the MPC I2C bus driver.
> Furthermore, it removes obsolete FSL device related definitions
> for I2C.
> It should go through the appropriate PowerPC maintainer(s) hands.
>
> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
> =A0Documentation/powerpc/dts-bindings/fsl/i2c.txt | =A0 46 ++++++++++++++=
++---------
> =A0include/linux/fsl_devices.h =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =
=A0 =A04 --
> =A02 files changed, 31 insertions(+), 19 deletions(-)
>
> Index: linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- linux-2.6-galak.orig/Documentation/powerpc/dts-bindings/fsl/i2c.txt 2=
009-04-07 10:09:08.185721241 +0200
> +++ linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt =A0 =
=A0 =A02009-04-07 10:09:15.413719535 +0200
> @@ -7,8 +7,10 @@
>
> =A0Recommended properties :
>
> - - compatible : Should be "fsl-i2c" for parts compatible with
> - =A0 Freescale I2C specifications.
> + - compatible : compatibility list with 2 entries, the first should
> + =A0 be "fsl,CHIP-i2c" where CHIP is the name of a compatible processor,
> + =A0 e.g. mpc8313, mpc8543, mpc8544, mpc5200 or mpc5200b. The second one
> + =A0 should be "fsl-i2c".
> =A0- interrupts : <a b> where a is the interrupt number and b is a
> =A0 =A0field that represents an encoding of the sense and level
> =A0 =A0information for the interrupt. =A0This should be encoded based on
> @@ -16,17 +18,31 @@
> =A0 =A0controller you have.
> =A0- interrupt-parent : the phandle for the interrupt controller that
> =A0 =A0services interrupts for this device.
> - - dfsrr : boolean; if defined, indicates that this I2C device has
> - =A0 a digital filter sampling rate register
> - - fsl5200-clocking : boolean; if defined, indicated that this device
> - =A0 uses the FSL 5200 clocking mechanism.
> -
> -Example :
> - =A0 =A0 =A0 i2c@3000 {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupt-parent =3D <40000>;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupts =3D <1b 3>;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <3000 18>;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 device_type =3D "i2c";
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =A0=3D "fsl-i2c";
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 dfsrr;
> + - fsl,preserve-clocking : boolean; if defined, the clock settings
> + =A0 from the bootloader are preserved (not touched).
> + - clock-frequency : desired I2C bus clock frequency in Hz.
> +
> +Examples :
> +
> + =A0 =A0 =A0 i2c@3d00 {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 #address-cells =3D <1>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 #size-cells =3D <0>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc5200b-i2c","fsl,mpc5=
200-i2c","fsl-i2c";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 cell-index =3D <0>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x3d00 0x40>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupts =3D <2 15 0>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupt-parent =3D <&mpc5200_pic>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 fsl,preserve-clocking;
> =A0 =A0 =A0 =A0};
> +
> + =A0 =A0 =A0 i2c@3100 {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 #address-cells =3D <1>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 #size-cells =3D <0>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 cell-index =3D <1>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc8544-i2c", "fsl-i2c"=
;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x3100 0x100>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupts =3D <43 2>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupt-parent =3D <&mpic>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 clock-frequency =3D <400000>;
> + =A0 =A0 =A0 };
> +
> Index: linux-2.6-galak/include/linux/fsl_devices.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- linux-2.6-galak.orig/include/linux/fsl_devices.h =A0 =A02009-04-07 10=
:09:08.185721241 +0200
> +++ linux-2.6-galak/include/linux/fsl_devices.h 2009-04-07 10:09:15.41471=
9119 +0200
> @@ -43,10 +43,6 @@
> =A0*
> =A0*/
>
> -/* Flags related to I2C device features */
> -#define FSL_I2C_DEV_SEPARATE_DFSRR =A0 =A0 0x00000001
> -#define FSL_I2C_DEV_CLOCK_5200 =A0 =A0 =A0 =A0 0x00000002
> -
> =A0enum fsl_usb2_operating_modes {
> =A0 =A0 =A0 =A0FSL_USB2_MPH_HOST,
> =A0 =A0 =A0 =A0FSL_USB2_DR_HOST,
>
>



--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-07  8:20 [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable Wolfgang Grandegger
@ 2009-04-08  5:11     ` Kumar Gala
  2009-04-07  8:20   ` Wolfgang Grandegger
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08  5:11 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Grant Likely


On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:

> This patch series makes the I2C bus speed configurable by using the
> I2C node property "clock-frequency". If the property is not defined,
> the old fixed clock settings will be used for backward compatibility.
> The property "fsl,preserve-clocking" allows to inherit the settings
> from the bootloader. Furthermore, it does some cleanup and uses the
> new bindings for the Socrates board:
>
>  i2c: i2c-mpc: various coding style fixes
>  i2c: i2c-mpc: use dev based printout function
>  i2c: i2c-mpc: make I2C bus speed configurable

It looks like Ben picked up these patches.

>  powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>  powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board

I would have preferred these two go via me, but it looks like the  
board one got picked up by Ben.  I'll deal with the doc/binding update.
>
> Ben, could you please consider this patch series for inclusion into
> 2.6.30.

- k

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-08  5:11     ` Kumar Gala
  0 siblings, 0 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08  5:11 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks


On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:

> This patch series makes the I2C bus speed configurable by using the
> I2C node property "clock-frequency". If the property is not defined,
> the old fixed clock settings will be used for backward compatibility.
> The property "fsl,preserve-clocking" allows to inherit the settings
> from the bootloader. Furthermore, it does some cleanup and uses the
> new bindings for the Socrates board:
>
>  i2c: i2c-mpc: various coding style fixes
>  i2c: i2c-mpc: use dev based printout function
>  i2c: i2c-mpc: make I2C bus speed configurable

It looks like Ben picked up these patches.

>  powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>  powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board

I would have preferred these two go via me, but it looks like the  
board one got picked up by Ben.  I'll deal with the doc/binding update.
>
> Ben, could you please consider this patch series for inclusion into
> 2.6.30.

- k

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

* Re: [PATCH v3 4/5] powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
  2009-04-07  8:20   ` Wolfgang Grandegger
@ 2009-04-08  5:13       ` Kumar Gala
  -1 siblings, 0 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08  5:13 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A, Grant Likely


On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:

> This patch documents the new bindings for the MPC I2C bus driver.
> Furthermore, it removes obsolete FSL device related definitions
> for I2C.
> It should go through the appropriate PowerPC maintainer(s) hands.
>
> Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
> ---
> Documentation/powerpc/dts-bindings/fsl/i2c.txt |   46 +++++++++++++++ 
> +---------
> include/linux/fsl_devices.h                    |    4 --
> 2 files changed, 31 insertions(+), 19 deletions(-)

applied to merge

- k

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

* Re: [PATCH v3 4/5] powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
@ 2009-04-08  5:13       ` Kumar Gala
  0 siblings, 0 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08  5:13 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks


On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:

> This patch documents the new bindings for the MPC I2C bus driver.
> Furthermore, it removes obsolete FSL device related definitions
> for I2C.
> It should go through the appropriate PowerPC maintainer(s) hands.
>
> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
> ---
> Documentation/powerpc/dts-bindings/fsl/i2c.txt |   46 +++++++++++++++ 
> +---------
> include/linux/fsl_devices.h                    |    4 --
> 2 files changed, 31 insertions(+), 19 deletions(-)

applied to merge

- k

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08  5:11     ` Kumar Gala
@ 2009-04-08  5:16         ` Grant Likely
  -1 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-08  5:16 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Wolfgang Grandegger, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A

On Tue, Apr 7, 2009 at 10:11 PM, Kumar Gala <galak-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org> wrote:
>
> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>
>> This patch series makes the I2C bus speed configurable by using the
>> I2C node property "clock-frequency". If the property is not defined,
>> the old fixed clock settings will be used for backward compatibility.
>> The property "fsl,preserve-clocking" allows to inherit the settings
>> from the bootloader. Furthermore, it does some cleanup and uses the
>> new bindings for the Socrates board:
>>
>>  i2c: i2c-mpc: various coding style fixes
>>  i2c: i2c-mpc: use dev based printout function
>>  i2c: i2c-mpc: make I2C bus speed configurable
>
> It looks like Ben picked up these patches.
>
>>  powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>>  powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>
> I would have preferred these two go via me, but it looks like the board one
> got picked up by Ben.  I'll deal with the doc/binding update.

hrummm.  As I mentioned in my reply, I'm not convinced that the board
one is the right thing in this case.  I would have preferred it to be
deferred.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-08  5:16         ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-08  5:16 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, devicetree-discuss, Ben Dooks, linux-i2c

On Tue, Apr 7, 2009 at 10:11 PM, Kumar Gala <galak@kernel.crashing.org> wro=
te:
>
> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>
>> This patch series makes the I2C bus speed configurable by using the
>> I2C node property "clock-frequency". If the property is not defined,
>> the old fixed clock settings will be used for backward compatibility.
>> The property "fsl,preserve-clocking" allows to inherit the settings
>> from the bootloader. Furthermore, it does some cleanup and uses the
>> new bindings for the Socrates board:
>>
>> =A0i2c: i2c-mpc: various coding style fixes
>> =A0i2c: i2c-mpc: use dev based printout function
>> =A0i2c: i2c-mpc: make I2C bus speed configurable
>
> It looks like Ben picked up these patches.
>
>> =A0powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>> =A0powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>
> I would have preferred these two go via me, but it looks like the board o=
ne
> got picked up by Ben. =A0I'll deal with the doc/binding update.

hrummm.  As I mentioned in my reply, I'm not convinced that the board
one is the right thing in this case.  I would have preferred it to be
deferred.

g.

--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08  5:16         ` Grant Likely
  (?)
@ 2009-04-08  5:22         ` Kumar Gala
  2009-04-08  5:32             ` Grant Likely
                             ` (2 more replies)
  -1 siblings, 3 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08  5:22 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, devicetree-discuss, Ben Dooks, linux-i2c


On Apr 8, 2009, at 12:16 AM, Grant Likely wrote:

> On Tue, Apr 7, 2009 at 10:11 PM, Kumar Gala  
> <galak@kernel.crashing.org> wrote:
>>
>> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>>
>>> This patch series makes the I2C bus speed configurable by using the
>>> I2C node property "clock-frequency". If the property is not defined,
>>> the old fixed clock settings will be used for backward  
>>> compatibility.
>>> The property "fsl,preserve-clocking" allows to inherit the settings
>>> from the bootloader. Furthermore, it does some cleanup and uses the
>>> new bindings for the Socrates board:
>>>
>>>  i2c: i2c-mpc: various coding style fixes
>>>  i2c: i2c-mpc: use dev based printout function
>>>  i2c: i2c-mpc: make I2C bus speed configurable
>>
>> It looks like Ben picked up these patches.
>>
>>>  powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>>>  powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>>
>> I would have preferred these two go via me, but it looks like the  
>> board one
>> got picked up by Ben.  I'll deal with the doc/binding update.
>
> hrummm.  As I mentioned in my reply, I'm not convinced that the board
> one is the right thing in this case.  I would have preferred it to be
> deferred.

which part?  I missed this whole thread as I had it forwarding to my  
devicetree-discuss folder which I don't normally look at.

- k

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08  5:11     ` Kumar Gala
  (?)
  (?)
@ 2009-04-08  5:28     ` Kumar Gala
       [not found]       ` <F4E3E1FF-C544-460A-AC27-DB9501C13ED3-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
  -1 siblings, 1 reply; 58+ messages in thread
From: Kumar Gala @ 2009-04-08  5:28 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux/PPC Development, devicetree-discuss, linux-i2c, Ben Dooks


On Apr 8, 2009, at 12:11 AM, Kumar Gala wrote:

>
> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>
>> This patch series makes the I2C bus speed configurable by using the
>> I2C node property "clock-frequency". If the property is not defined,
>> the old fixed clock settings will be used for backward compatibility.
>> The property "fsl,preserve-clocking" allows to inherit the settings
>> from the bootloader. Furthermore, it does some cleanup and uses the
>> new bindings for the Socrates board:
>>
>> i2c: i2c-mpc: various coding style fixes
>> i2c: i2c-mpc: use dev based printout function
>> i2c: i2c-mpc: make I2C bus speed configurable
>
> It looks like Ben picked up these patches.
>
>> powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>> powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>
> I would have preferred these two go via me, but it looks like the  
> board one got picked up by Ben.  I'll deal with the doc/binding  
> update.
>>
>> Ben, could you please consider this patch series for inclusion into
>> 2.6.30

So I'm a bit concerned with the output we now get:

mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)

why 0? is that right?

- k

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08  5:22         ` Kumar Gala
@ 2009-04-08  5:32             ` Grant Likely
       [not found]           ` <5FDB097C-7D71-41DF-A4F4-2DE34FD710C5-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
  2009-04-08 17:03           ` Scott Wood
  2 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-08  5:32 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, devicetree-discuss, Ben Dooks, linux-i2c

On Tue, Apr 7, 2009 at 10:22 PM, Kumar Gala <galak@kernel.crashing.org> wrote:
>
> On Apr 8, 2009, at 12:16 AM, Grant Likely wrote:
>
>> On Tue, Apr 7, 2009 at 10:11 PM, Kumar Gala <galak@kernel.crashing.org>
>> wrote:
>>>
>>> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>>>
>>>> This patch series makes the I2C bus speed configurable by using the
>>>> I2C node property "clock-frequency". If the property is not defined,
>>>> the old fixed clock settings will be used for backward compatibility.
>>>> The property "fsl,preserve-clocking" allows to inherit the settings
>>>> from the bootloader. Furthermore, it does some cleanup and uses the
>>>> new bindings for the Socrates board:
>>>>
>>>>  i2c: i2c-mpc: various coding style fixes
>>>>  i2c: i2c-mpc: use dev based printout function
>>>>  i2c: i2c-mpc: make I2C bus speed configurable
>>>
>>> It looks like Ben picked up these patches.
>>>
>>>>  powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>>>>  powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>>>
>>> I would have preferred these two go via me, but it looks like the board
>>> one
>>> got picked up by Ben.  I'll deal with the doc/binding update.
>>
>> hrummm.  As I mentioned in my reply, I'm not convinced that the board
>> one is the right thing in this case.  I would have preferred it to be
>> deferred.
>
> which part?  I missed this whole thread as I had it forwarding to my
> devicetree-discuss folder which I don't normally look at.

Here you go:

On Tue, Apr 7, 2009 at 8:43 AM, Grant Likely <grant.likely@secretlab.ca> wrote:
> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>> Preserve I2C clock settings for the Socrates MPC8544 board.
>
> I had thought that the preserve-clocking property was intended for
> older boards that don't currently have any method of getting the clock
> setting out of u-boot.  Since Socrates is a new board, U-Boot should
> probably be made to fill in the real clock rate setting.
>
> g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-08  5:32             ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-08  5:32 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, devicetree-discuss, Ben Dooks, linux-i2c

On Tue, Apr 7, 2009 at 10:22 PM, Kumar Gala <galak@kernel.crashing.org> wro=
te:
>
> On Apr 8, 2009, at 12:16 AM, Grant Likely wrote:
>
>> On Tue, Apr 7, 2009 at 10:11 PM, Kumar Gala <galak@kernel.crashing.org>
>> wrote:
>>>
>>> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>>>
>>>> This patch series makes the I2C bus speed configurable by using the
>>>> I2C node property "clock-frequency". If the property is not defined,
>>>> the old fixed clock settings will be used for backward compatibility.
>>>> The property "fsl,preserve-clocking" allows to inherit the settings
>>>> from the bootloader. Furthermore, it does some cleanup and uses the
>>>> new bindings for the Socrates board:
>>>>
>>>> =A0i2c: i2c-mpc: various coding style fixes
>>>> =A0i2c: i2c-mpc: use dev based printout function
>>>> =A0i2c: i2c-mpc: make I2C bus speed configurable
>>>
>>> It looks like Ben picked up these patches.
>>>
>>>> =A0powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>>>> =A0powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>>>
>>> I would have preferred these two go via me, but it looks like the board
>>> one
>>> got picked up by Ben. =A0I'll deal with the doc/binding update.
>>
>> hrummm. =A0As I mentioned in my reply, I'm not convinced that the board
>> one is the right thing in this case. =A0I would have preferred it to be
>> deferred.
>
> which part? =A0I missed this whole thread as I had it forwarding to my
> devicetree-discuss folder which I don't normally look at.

Here you go:

On Tue, Apr 7, 2009 at 8:43 AM, Grant Likely <grant.likely@secretlab.ca> wr=
ote:
> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> w=
rote:
>> Preserve I2C clock settings for the Socrates MPC8544 board.
>
> I had thought that the preserve-clocking property was intended for
> older boards that don't currently have any method of getting the clock
> setting out of u-boot.  Since Socrates is a new board, U-Boot should
> probably be made to fill in the real clock rate setting.
>
> g.

--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
  2009-04-07 15:43       ` Grant Likely
  (?)
@ 2009-04-08  7:16       ` Wolfgang Grandegger
  2009-04-08 14:53           ` Grant Likely
  -1 siblings, 1 reply; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08  7:16 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

Grant Likely wrote:
> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>> Preserve I2C clock settings for the Socrates MPC8544 board.
> 
> I had thought that the preserve-clocking property was intended for
> older boards that don't currently have any method of getting the clock
> setting out of u-boot.  Since Socrates is a new board, U-Boot should
> probably be made to fill in the real clock rate setting.

I'm not sure if I understand what you mean. If an old version of U-Boot
on an old board sets the I2C clock, it can be used (inherited) by Linux
using the property "preserve-clocking".

It is actually the customers choice to set the I2C clock in U-Boot and
re-use it by Linux.

Wolfgang.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08  5:22         ` Kumar Gala
@ 2009-04-08  7:21               ` Wolfgang Grandegger
       [not found]           ` <5FDB097C-7D71-41DF-A4F4-2DE34FD710C5-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
  2009-04-08 17:03           ` Scott Wood
  2 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08  7:21 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Grant Likely, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A

Kumar Gala wrote:
> 
> On Apr 8, 2009, at 12:16 AM, Grant Likely wrote:
> 
>> On Tue, Apr 7, 2009 at 10:11 PM, Kumar Gala
>> <galak-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org> wrote:
>>>
>>> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>>>
>>>> This patch series makes the I2C bus speed configurable by using the
>>>> I2C node property "clock-frequency". If the property is not defined,
>>>> the old fixed clock settings will be used for backward compatibility.
>>>> The property "fsl,preserve-clocking" allows to inherit the settings
>>>> from the bootloader. Furthermore, it does some cleanup and uses the
>>>> new bindings for the Socrates board:
>>>>
>>>>  i2c: i2c-mpc: various coding style fixes
>>>>  i2c: i2c-mpc: use dev based printout function
>>>>  i2c: i2c-mpc: make I2C bus speed configurable
>>>
>>> It looks like Ben picked up these patches.

Ah, I just saw the pull request.

>>>>  powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>>>>  powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>>>
>>> I would have preferred these two go via me, but it looks like the
>>> board one
>>> got picked up by Ben.  I'll deal with the doc/binding update.

That was my intention, at least.

>> hrummm.  As I mentioned in my reply, I'm not convinced that the board
>> one is the right thing in this case.  I would have preferred it to be
>> deferred.
> 
> which part?  I missed this whole thread as I had it forwarding to my
> devicetree-discuss folder which I don't normally look at.

I hate these cross-postings as well. I just answered to Grant's mail.

Wolfgang.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-08  7:21               ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08  7:21 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

Kumar Gala wrote:
> 
> On Apr 8, 2009, at 12:16 AM, Grant Likely wrote:
> 
>> On Tue, Apr 7, 2009 at 10:11 PM, Kumar Gala
>> <galak@kernel.crashing.org> wrote:
>>>
>>> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>>>
>>>> This patch series makes the I2C bus speed configurable by using the
>>>> I2C node property "clock-frequency". If the property is not defined,
>>>> the old fixed clock settings will be used for backward compatibility.
>>>> The property "fsl,preserve-clocking" allows to inherit the settings
>>>> from the bootloader. Furthermore, it does some cleanup and uses the
>>>> new bindings for the Socrates board:
>>>>
>>>>  i2c: i2c-mpc: various coding style fixes
>>>>  i2c: i2c-mpc: use dev based printout function
>>>>  i2c: i2c-mpc: make I2C bus speed configurable
>>>
>>> It looks like Ben picked up these patches.

Ah, I just saw the pull request.

>>>>  powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>>>>  powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>>>
>>> I would have preferred these two go via me, but it looks like the
>>> board one
>>> got picked up by Ben.  I'll deal with the doc/binding update.

That was my intention, at least.

>> hrummm.  As I mentioned in my reply, I'm not convinced that the board
>> one is the right thing in this case.  I would have preferred it to be
>> deferred.
> 
> which part?  I missed this whole thread as I had it forwarding to my
> devicetree-discuss folder which I don't normally look at.

I hate these cross-postings as well. I just answered to Grant's mail.

Wolfgang.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08  5:28     ` Kumar Gala
@ 2009-04-08  7:25           ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08  7:25 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Linux/PPC Development, devicetree-discuss,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks

Kumar Gala wrote:
> 
> On Apr 8, 2009, at 12:11 AM, Kumar Gala wrote:
> 
>>
>> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>>
>>> This patch series makes the I2C bus speed configurable by using the
>>> I2C node property "clock-frequency". If the property is not defined,
>>> the old fixed clock settings will be used for backward compatibility.
>>> The property "fsl,preserve-clocking" allows to inherit the settings
>>> from the bootloader. Furthermore, it does some cleanup and uses the
>>> new bindings for the Socrates board:
>>>
>>> i2c: i2c-mpc: various coding style fixes
>>> i2c: i2c-mpc: use dev based printout function
>>> i2c: i2c-mpc: make I2C bus speed configurable
>>
>> It looks like Ben picked up these patches.
>>
>>> powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>>> powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>>
>> I would have preferred these two go via me, but it looks like the
>> board one got picked up by Ben.  I'll deal with the doc/binding update.
>>>
>>> Ben, could you please consider this patch series for inclusion into
>>> 2.6.30
> 
> So I'm a bit concerned with the output we now get:
> 
> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)
> 
> why 0? is that right?

This is the backward compatibility mode using hard-coded FDR values. The
output is missleading, I agree.

Wolfgang.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-08  7:25           ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08  7:25 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Linux/PPC Development, devicetree-discuss, linux-i2c, Ben Dooks

Kumar Gala wrote:
> 
> On Apr 8, 2009, at 12:11 AM, Kumar Gala wrote:
> 
>>
>> On Apr 7, 2009, at 3:20 AM, Wolfgang Grandegger wrote:
>>
>>> This patch series makes the I2C bus speed configurable by using the
>>> I2C node property "clock-frequency". If the property is not defined,
>>> the old fixed clock settings will be used for backward compatibility.
>>> The property "fsl,preserve-clocking" allows to inherit the settings
>>> from the bootloader. Furthermore, it does some cleanup and uses the
>>> new bindings for the Socrates board:
>>>
>>> i2c: i2c-mpc: various coding style fixes
>>> i2c: i2c-mpc: use dev based printout function
>>> i2c: i2c-mpc: make I2C bus speed configurable
>>
>> It looks like Ben picked up these patches.
>>
>>> powerpc: i2c-mpc: document new FSL I2C bindings and cleanup
>>> powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
>>
>> I would have preferred these two go via me, but it looks like the
>> board one got picked up by Ben.  I'll deal with the doc/binding update.
>>>
>>> Ben, could you please consider this patch series for inclusion into
>>> 2.6.30
> 
> So I'm a bit concerned with the output we now get:
> 
> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)
> 
> why 0? is that right?

This is the backward compatibility mode using hard-coded FDR values. The
output is missleading, I agree.

Wolfgang.

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
  2009-04-08  7:16       ` Wolfgang Grandegger
@ 2009-04-08 14:53           ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-08 14:53 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

On Wed, Apr 8, 2009 at 12:16 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
> Grant Likely wrote:
>> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>>> Preserve I2C clock settings for the Socrates MPC8544 board.
>>
>> I had thought that the preserve-clocking property was intended for
>> older boards that don't currently have any method of getting the clock
>> setting out of u-boot.  Since Socrates is a new board, U-Boot should
>> probably be made to fill in the real clock rate setting.
>
> I'm not sure if I understand what you mean. If an old version of U-Boot
> on an old board sets the I2C clock, it can be used (inherited) by Linux
> using the property "preserve-clocking".
>
> It is actually the customers choice to set the I2C clock in U-Boot and
> re-use it by Linux.

Setting it in the register != recording the value in the device tree.
I'm saying that since Socrates is a new board it should not use the
preserve-clocking dirty trick (and it is a dirty trick) because the
correct clocking data can be passed via the device tree.

g.


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
@ 2009-04-08 14:53           ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-08 14:53 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

On Wed, Apr 8, 2009 at 12:16 AM, Wolfgang Grandegger <wg@grandegger.com> wr=
ote:
> Grant Likely wrote:
>> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> =
wrote:
>>> Preserve I2C clock settings for the Socrates MPC8544 board.
>>
>> I had thought that the preserve-clocking property was intended for
>> older boards that don't currently have any method of getting the clock
>> setting out of u-boot. =A0Since Socrates is a new board, U-Boot should
>> probably be made to fill in the real clock rate setting.
>
> I'm not sure if I understand what you mean. If an old version of U-Boot
> on an old board sets the I2C clock, it can be used (inherited) by Linux
> using the property "preserve-clocking".
>
> It is actually the customers choice to set the I2C clock in U-Boot and
> re-use it by Linux.

Setting it in the register !=3D recording the value in the device tree.
I'm saying that since Socrates is a new board it should not use the
preserve-clocking dirty trick (and it is a dirty trick) because the
correct clocking data can be passed via the device tree.

g.


--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08  7:25           ` Wolfgang Grandegger
@ 2009-04-08 15:21               ` Kumar Gala
  -1 siblings, 0 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08 15:21 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux/PPC Development, devicetree-discuss,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks


On Apr 8, 2009, at 2:25 AM, Wolfgang Grandegger wrote:

>> So I'm a bit concerned with the output we now get:
>>
>> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)
>>
>> why 0? is that right?
>
> This is the backward compatibility mode using hard-coded FDR values.  
> The
> output is missleading, I agree.
>
> Wolfgang.

Can the output be fixed.  0 Hz seemed bad to me.

- k

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-08 15:21               ` Kumar Gala
  0 siblings, 0 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08 15:21 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux/PPC Development, devicetree-discuss, linux-i2c, Ben Dooks


On Apr 8, 2009, at 2:25 AM, Wolfgang Grandegger wrote:

>> So I'm a bit concerned with the output we now get:
>>
>> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)
>>
>> why 0? is that right?
>
> This is the backward compatibility mode using hard-coded FDR values.  
> The
> output is missleading, I agree.
>
> Wolfgang.

Can the output be fixed.  0 Hz seemed bad to me.

- k

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08  5:22         ` Kumar Gala
  2009-04-08  5:32             ` Grant Likely
       [not found]           ` <5FDB097C-7D71-41DF-A4F4-2DE34FD710C5-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
@ 2009-04-08 17:03           ` Scott Wood
  2009-04-08 17:49             ` Kumar Gala
  2 siblings, 1 reply; 58+ messages in thread
From: Scott Wood @ 2009-04-08 17:03 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

On Wed, Apr 08, 2009 at 12:22:29AM -0500, Kumar Gala wrote:
> >hrummm.  As I mentioned in my reply, I'm not convinced that the board
> >one is the right thing in this case.  I would have preferred it to be
> >deferred.
> 
> which part?  I missed this whole thread as I had it forwarding to my  
> devicetree-discuss folder which I don't normally look at.

Can you reorder your filters to check for more frequently read lists
first?

-Scott

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08 17:03           ` Scott Wood
@ 2009-04-08 17:49             ` Kumar Gala
  0 siblings, 0 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08 17:49 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks


On Apr 8, 2009, at 12:03 PM, Scott Wood wrote:

> On Wed, Apr 08, 2009 at 12:22:29AM -0500, Kumar Gala wrote:
>>> hrummm.  As I mentioned in my reply, I'm not convinced that the  
>>> board
>>> one is the right thing in this case.  I would have preferred it to  
>>> be
>>> deferred.
>>
>> which part?  I missed this whole thread as I had it forwarding to my
>> devicetree-discuss folder which I don't normally look at.
>
> Can you reorder your filters to check for more frequently read lists
> first?

Yeah I did.

- k

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
  2009-04-08 14:53           ` Grant Likely
@ 2009-04-08 18:27               ` Wolfgang Grandegger
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08 18:27 UTC (permalink / raw)
  To: Grant Likely
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks

Grant Likely wrote:
> On Wed, Apr 8, 2009 at 12:16 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>> Grant Likely wrote:
>>> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>>>> Preserve I2C clock settings for the Socrates MPC8544 board.
>>> I had thought that the preserve-clocking property was intended for
>>> older boards that don't currently have any method of getting the clock
>>> setting out of u-boot.  Since Socrates is a new board, U-Boot should
>>> probably be made to fill in the real clock rate setting.
>> I'm not sure if I understand what you mean. If an old version of U-Boot
>> on an old board sets the I2C clock, it can be used (inherited) by Linux
>> using the property "preserve-clocking".
>>
>> It is actually the customers choice to set the I2C clock in U-Boot and
>> re-use it by Linux.
> 
> Setting it in the register != recording the value in the device tree.
> I'm saying that since Socrates is a new board it should not use the
> preserve-clocking dirty trick (and it is a dirty trick) because the
> correct clocking data can be passed via the device tree.

Why should an old board then use it. "fsl, preserve-clocking" is a new
feature, like using "clock-frequency" and you have the choice to
explicitly set the clocking via device tree or inherit it from the boot
loader. So far, a fixed FDR/DFRSS value (0x1031) was written to the
registers by Linux.

Wolfgang.

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
@ 2009-04-08 18:27               ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08 18:27 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

Grant Likely wrote:
> On Wed, Apr 8, 2009 at 12:16 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>> Grant Likely wrote:
>>> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>>>> Preserve I2C clock settings for the Socrates MPC8544 board.
>>> I had thought that the preserve-clocking property was intended for
>>> older boards that don't currently have any method of getting the clock
>>> setting out of u-boot.  Since Socrates is a new board, U-Boot should
>>> probably be made to fill in the real clock rate setting.
>> I'm not sure if I understand what you mean. If an old version of U-Boot
>> on an old board sets the I2C clock, it can be used (inherited) by Linux
>> using the property "preserve-clocking".
>>
>> It is actually the customers choice to set the I2C clock in U-Boot and
>> re-use it by Linux.
> 
> Setting it in the register != recording the value in the device tree.
> I'm saying that since Socrates is a new board it should not use the
> preserve-clocking dirty trick (and it is a dirty trick) because the
> correct clocking data can be passed via the device tree.

Why should an old board then use it. "fsl, preserve-clocking" is a new
feature, like using "clock-frequency" and you have the choice to
explicitly set the clocking via device tree or inherit it from the boot
loader. So far, a fixed FDR/DFRSS value (0x1031) was written to the
registers by Linux.

Wolfgang.

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
  2009-04-08 18:27               ` Wolfgang Grandegger
@ 2009-04-08 18:43                   ` Kumar Gala
  -1 siblings, 0 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08 18:43 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Grant Likely, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A


On Apr 8, 2009, at 1:27 PM, Wolfgang Grandegger wrote:

> Grant Likely wrote:
>> On Wed, Apr 8, 2009 at 12:16 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org 
>> > wrote:
>>> Grant Likely wrote:
>>>> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org 
>>>> > wrote:
>>>>> Preserve I2C clock settings for the Socrates MPC8544 board.
>>>> I had thought that the preserve-clocking property was intended for
>>>> older boards that don't currently have any method of getting the  
>>>> clock
>>>> setting out of u-boot.  Since Socrates is a new board, U-Boot  
>>>> should
>>>> probably be made to fill in the real clock rate setting.
>>> I'm not sure if I understand what you mean. If an old version of U- 
>>> Boot
>>> on an old board sets the I2C clock, it can be used (inherited) by  
>>> Linux
>>> using the property "preserve-clocking".
>>>
>>> It is actually the customers choice to set the I2C clock in U-Boot  
>>> and
>>> re-use it by Linux.
>>
>> Setting it in the register != recording the value in the device tree.
>> I'm saying that since Socrates is a new board it should not use the
>> preserve-clocking dirty trick (and it is a dirty trick) because the
>> correct clocking data can be passed via the device tree.
>
> Why should an old board then use it. "fsl, preserve-clocking" is a new
> feature, like using "clock-frequency" and you have the choice to
> explicitly set the clocking via device tree or inherit it from the  
> boot
> loader. So far, a fixed FDR/DFRSS value (0x1031) was written to the
> registers by Linux.

I think Grant's point is socrates is a new board with a new u-boot.   
That u-boot should be able to set the clock-frequency property in  
i2c.  One assumes if you a clock-frequency property you wouldn't use  
"fsl,preserve-clocking".  (However -- its feasible they are mutually  
exclusive).

- k

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
@ 2009-04-08 18:43                   ` Kumar Gala
  0 siblings, 0 replies; 58+ messages in thread
From: Kumar Gala @ 2009-04-08 18:43 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks


On Apr 8, 2009, at 1:27 PM, Wolfgang Grandegger wrote:

> Grant Likely wrote:
>> On Wed, Apr 8, 2009 at 12:16 AM, Wolfgang Grandegger <wg@grandegger.com 
>> > wrote:
>>> Grant Likely wrote:
>>>> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger <wg@grandegger.com 
>>>> > wrote:
>>>>> Preserve I2C clock settings for the Socrates MPC8544 board.
>>>> I had thought that the preserve-clocking property was intended for
>>>> older boards that don't currently have any method of getting the  
>>>> clock
>>>> setting out of u-boot.  Since Socrates is a new board, U-Boot  
>>>> should
>>>> probably be made to fill in the real clock rate setting.
>>> I'm not sure if I understand what you mean. If an old version of U- 
>>> Boot
>>> on an old board sets the I2C clock, it can be used (inherited) by  
>>> Linux
>>> using the property "preserve-clocking".
>>>
>>> It is actually the customers choice to set the I2C clock in U-Boot  
>>> and
>>> re-use it by Linux.
>>
>> Setting it in the register != recording the value in the device tree.
>> I'm saying that since Socrates is a new board it should not use the
>> preserve-clocking dirty trick (and it is a dirty trick) because the
>> correct clocking data can be passed via the device tree.
>
> Why should an old board then use it. "fsl, preserve-clocking" is a new
> feature, like using "clock-frequency" and you have the choice to
> explicitly set the clocking via device tree or inherit it from the  
> boot
> loader. So far, a fixed FDR/DFRSS value (0x1031) was written to the
> registers by Linux.

I think Grant's point is socrates is a new board with a new u-boot.   
That u-boot should be able to set the clock-frequency property in  
i2c.  One assumes if you a clock-frequency property you wouldn't use  
"fsl,preserve-clocking".  (However -- its feasible they are mutually  
exclusive).

- k

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
  2009-04-08 18:43                   ` Kumar Gala
@ 2009-04-08 18:53                       ` Wolfgang Grandegger
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08 18:53 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Grant Likely, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A

Kumar Gala wrote:
> 
> On Apr 8, 2009, at 1:27 PM, Wolfgang Grandegger wrote:
> 
>> Grant Likely wrote:
>>> On Wed, Apr 8, 2009 at 12:16 AM, Wolfgang Grandegger
>>> <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>>>> Grant Likely wrote:
>>>>> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger
>>>>> <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>>>>>> Preserve I2C clock settings for the Socrates MPC8544 board.
>>>>> I had thought that the preserve-clocking property was intended for
>>>>> older boards that don't currently have any method of getting the clock
>>>>> setting out of u-boot.  Since Socrates is a new board, U-Boot should
>>>>> probably be made to fill in the real clock rate setting.
>>>> I'm not sure if I understand what you mean. If an old version of U-Boot
>>>> on an old board sets the I2C clock, it can be used (inherited) by Linux
>>>> using the property "preserve-clocking".
>>>>
>>>> It is actually the customers choice to set the I2C clock in U-Boot and
>>>> re-use it by Linux.
>>>
>>> Setting it in the register != recording the value in the device tree.
>>> I'm saying that since Socrates is a new board it should not use the
>>> preserve-clocking dirty trick (and it is a dirty trick) because the
>>> correct clocking data can be passed via the device tree.
>>
>> Why should an old board then use it. "fsl, preserve-clocking" is a new
>> feature, like using "clock-frequency" and you have the choice to
>> explicitly set the clocking via device tree or inherit it from the boot
>> loader. So far, a fixed FDR/DFRSS value (0x1031) was written to the
>> registers by Linux.
> 
> I think Grant's point is socrates is a new board with a new u-boot. 
> That u-boot should be able to set the clock-frequency property in i2c. 
> One assumes if you a clock-frequency property you wouldn't use
> "fsl,preserve-clocking".  (However -- its feasible they are mutually
> exclusive).

OK, now it makes more sense to me even if I never thought that way. My
intention was to allow Linux to use a *different* frequency as the
bootloader by specifying the "clock-frequency" property. This would not
be possible with a fixup by the bootloader.

Wolfgang.

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

* Re: [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board
@ 2009-04-08 18:53                       ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08 18:53 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, devicetree-discuss, linux-i2c, Ben Dooks

Kumar Gala wrote:
> 
> On Apr 8, 2009, at 1:27 PM, Wolfgang Grandegger wrote:
> 
>> Grant Likely wrote:
>>> On Wed, Apr 8, 2009 at 12:16 AM, Wolfgang Grandegger
>>> <wg@grandegger.com> wrote:
>>>> Grant Likely wrote:
>>>>> On Tue, Apr 7, 2009 at 1:20 AM, Wolfgang Grandegger
>>>>> <wg@grandegger.com> wrote:
>>>>>> Preserve I2C clock settings for the Socrates MPC8544 board.
>>>>> I had thought that the preserve-clocking property was intended for
>>>>> older boards that don't currently have any method of getting the clock
>>>>> setting out of u-boot.  Since Socrates is a new board, U-Boot should
>>>>> probably be made to fill in the real clock rate setting.
>>>> I'm not sure if I understand what you mean. If an old version of U-Boot
>>>> on an old board sets the I2C clock, it can be used (inherited) by Linux
>>>> using the property "preserve-clocking".
>>>>
>>>> It is actually the customers choice to set the I2C clock in U-Boot and
>>>> re-use it by Linux.
>>>
>>> Setting it in the register != recording the value in the device tree.
>>> I'm saying that since Socrates is a new board it should not use the
>>> preserve-clocking dirty trick (and it is a dirty trick) because the
>>> correct clocking data can be passed via the device tree.
>>
>> Why should an old board then use it. "fsl, preserve-clocking" is a new
>> feature, like using "clock-frequency" and you have the choice to
>> explicitly set the clocking via device tree or inherit it from the boot
>> loader. So far, a fixed FDR/DFRSS value (0x1031) was written to the
>> registers by Linux.
> 
> I think Grant's point is socrates is a new board with a new u-boot. 
> That u-boot should be able to set the clock-frequency property in i2c. 
> One assumes if you a clock-frequency property you wouldn't use
> "fsl,preserve-clocking".  (However -- its feasible they are mutually
> exclusive).

OK, now it makes more sense to me even if I never thought that way. My
intention was to allow Linux to use a *different* frequency as the
bootloader by specifying the "clock-frequency" property. This would not
be possible with a fixup by the bootloader.

Wolfgang.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08 15:21               ` Kumar Gala
@ 2009-04-08 19:55                   ` Wolfgang Grandegger
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08 19:55 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Linux/PPC Development, devicetree-discuss,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks

Kumar Gala wrote:
> 
> On Apr 8, 2009, at 2:25 AM, Wolfgang Grandegger wrote:
> 
>>> So I'm a bit concerned with the output we now get:
>>>
>>> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)
>>>
>>> why 0? is that right?
>>
>> This is the backward compatibility mode using hard-coded FDR values. The
>> output is missleading, I agree.
>>
>> Wolfgang.
> 
> Can the output be fixed.  0 Hz seemed bad to me.

Of course. No info message will be printed for the legacy case
like it was with the old driver version. I just realized a bug in the
MPC52xx part. Will send patches tomorrow, after some more thorough testing.

Wolfgang.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-08 19:55                   ` Wolfgang Grandegger
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-08 19:55 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Linux/PPC Development, devicetree-discuss, linux-i2c, Ben Dooks

Kumar Gala wrote:
> 
> On Apr 8, 2009, at 2:25 AM, Wolfgang Grandegger wrote:
> 
>>> So I'm a bit concerned with the output we now get:
>>>
>>> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)
>>>
>>> why 0? is that right?
>>
>> This is the backward compatibility mode using hard-coded FDR values. The
>> output is missleading, I agree.
>>
>> Wolfgang.
> 
> Can the output be fixed.  0 Hz seemed bad to me.

Of course. No info message will be printed for the legacy case
like it was with the old driver version. I just realized a bug in the
MPC52xx part. Will send patches tomorrow, after some more thorough testing.

Wolfgang.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-08 19:55                   ` Wolfgang Grandegger
  (?)
@ 2009-04-09  9:59                   ` Wolfgang Grandegger
  2009-04-20  9:01                     ` Wolfgang Grandegger
  -1 siblings, 1 reply; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-09  9:59 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Linux/PPC Development, devicetree-discuss, linux-i2c, Ben Dooks

Wolfgang Grandegger wrote:
> Kumar Gala wrote:
>> On Apr 8, 2009, at 2:25 AM, Wolfgang Grandegger wrote:
>>
>>>> So I'm a bit concerned with the output we now get:
>>>>
>>>> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)
>>>>
>>>> why 0? is that right?
>>> This is the backward compatibility mode using hard-coded FDR values. The
>>> output is missleading, I agree.
>>>
>>> Wolfgang.
>> Can the output be fixed.  0 Hz seemed bad to me.
> 
> Of course. No info message will be printed for the legacy case
> like it was with the old driver version. I just realized a bug in the
> MPC52xx part. Will send patches tomorrow, after some more thorough testing.

The patch below fixes both issues. Ben, could you please apply it. Sorry for
the inconvenience caused.

Thanks,

Wolfgang.



[PATCH] i2c: i2c-mpc: bug fix for MPC52xx clock setting and printout

The clock setting did not work for the MPC52xx due to a stupid bug.
Furthermore, the dev info output "clock=0" for old device trees was
misleading. This patch fixes both issues.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
 drivers/i2c/busses/i2c-mpc.c |   34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
===================================================================
--- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c	2009-04-08 21:51:31.771719368 +0200
+++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c	2009-04-09 11:18:45.812969033 +0200
@@ -164,7 +164,7 @@
 	return 0;
 }
 
-#ifdef CONFIG_PPC_52xx
+#ifdef CONFIG_PPC_MPC52xx
 static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
 	{20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
 	{28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
@@ -188,7 +188,7 @@
 
 int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
 {
-	const struct mpc52xx_i2c_divider *div = NULL;
+	const struct mpc_i2c_divider *div = NULL;
 	unsigned int pvr = mfspr(SPRN_PVR);
 	u32 divider;
 	int i;
@@ -203,7 +203,7 @@
 	 * We want to choose an FDR/DFSR that generates an I2C bus speed that
 	 * is equal to or lower than the requested speed.
 	 */
-	for (i = 0; i < ARRAY_SIZE(mpc52xx_i2c_dividers); i++) {
+	for (i = 0; i < ARRAY_SIZE(mpc_i2c_dividers_52xx); i++) {
 		div = &mpc_i2c_dividers_52xx[i];
 		/* Old MPC5200 rev A CPUs do not support the high bits */
 		if (div->fdr & 0xc0 && pvr == 0x80822011)
@@ -219,20 +219,23 @@
 				  struct mpc_i2c *i2c,
 				  u32 clock, u32 prescaler)
 {
-	int fdr = mpc52xx_i2c_get_fdr(node, clock, prescaler);
+	int ret, fdr;
+
+	ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler);
+	fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */
 
-	if (fdr < 0)
-		fdr = 0x3f; /* backward compatibility */
 	writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
-	dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
+
+	if (ret >= 0)
+		dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
 }
-#else /* !CONFIG_PPC_52xx */
+#else /* !CONFIG_PPC_MPC52xx */
 static void mpc_i2c_setclock_52xx(struct device_node *node,
 				  struct mpc_i2c *i2c,
 				  u32 clock, u32 prescaler)
 {
 }
-#endif /* CONFIG_PPC_52xx*/
+#endif /* CONFIG_PPC_MPC52xx*/
 
 #ifdef CONFIG_FSL_SOC
 static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
@@ -321,14 +324,17 @@
 				  struct mpc_i2c *i2c,
 				  u32 clock, u32 prescaler)
 {
-	int fdr = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
+	int ret, fdr;
+
+	ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
+	fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */
 
-	if (fdr < 0)
-		fdr = 0x1031; /* backward compatibility */
 	writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
 	writeb((fdr >> 8) & 0xff, i2c->base + MPC_I2C_DFSRR);
-	dev_info(i2c->dev, "clock %d Hz (dfsrr=%d fdr=%d)\n",
-		 clock, fdr >> 8, fdr & 0xff);
+
+	if (ret >= 0)
+		dev_info(i2c->dev, "clock %d Hz (dfsrr=%d fdr=%d)\n",
+			 clock, fdr >> 8, fdr & 0xff);
 }
 
 #else /* !CONFIG_FSL_SOC */

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-09  9:59                   ` Wolfgang Grandegger
@ 2009-04-20  9:01                     ` Wolfgang Grandegger
  2009-04-20 13:26                         ` Grant Likely
  0 siblings, 1 reply; 58+ messages in thread
From: Wolfgang Grandegger @ 2009-04-20  9:01 UTC (permalink / raw)
  To: Ben Dooks; +Cc: Linux/PPC Development, devicetree-discuss, linux-i2c

Hi Ben,

Wolfgang Grandegger wrote:
> Wolfgang Grandegger wrote:
>> Kumar Gala wrote:
>>> On Apr 8, 2009, at 2:25 AM, Wolfgang Grandegger wrote:
>>>
>>>>> So I'm a bit concerned with the output we now get:
>>>>>
>>>>> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)
>>>>>
>>>>> why 0? is that right?
>>>> This is the backward compatibility mode using hard-coded FDR values. The
>>>> output is missleading, I agree.
>>>>
>>>> Wolfgang.
>>> Can the output be fixed.  0 Hz seemed bad to me.
>> Of course. No info message will be printed for the legacy case
>> like it was with the old driver version. I just realized a bug in the
>> MPC52xx part. Will send patches tomorrow, after some more thorough testing.
> 
> The patch below fixes both issues. Ben, could you please apply it. Sorry for
> the inconvenience caused.
> 
> Thanks,
> 
> Wolfgang.
> 
> 
> 
> [PATCH] i2c: i2c-mpc: bug fix for MPC52xx clock setting and printout
> 
> The clock setting did not work for the MPC52xx due to a stupid bug.
> Furthermore, the dev info output "clock=0" for old device trees was
> misleading. This patch fixes both issues.
> 
> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>

Could you please apply this bug-fix for the MPC driver for 2.6.30.

  http://marc.info/?l=linux-i2c&m=123927120910293&w=2

Thanks,

Wolfgang.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
  2009-04-20  9:01                     ` Wolfgang Grandegger
@ 2009-04-20 13:26                         ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-20 13:26 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux/PPC Development, devicetree-discuss, linux-i2c, Ben Dooks

On Mon, Apr 20, 2009 at 3:01 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
> Hi Ben,
>
> Wolfgang Grandegger wrote:
>> Wolfgang Grandegger wrote:
>>> Kumar Gala wrote:
>>>> On Apr 8, 2009, at 2:25 AM, Wolfgang Grandegger wrote:
>>>>
>>>>>> So I'm a bit concerned with the output we now get:
>>>>>>
>>>>>> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=16 fdr=49)
>>>>>>
>>>>>> why 0? is that right?
>>>>> This is the backward compatibility mode using hard-coded FDR values. The
>>>>> output is missleading, I agree.
>>>>>
>>>>> Wolfgang.
>>>> Can the output be fixed.  0 Hz seemed bad to me.
>>> Of course. No info message will be printed for the legacy case
>>> like it was with the old driver version. I just realized a bug in the
>>> MPC52xx part. Will send patches tomorrow, after some more thorough testing.
>>
>> The patch below fixes both issues. Ben, could you please apply it. Sorry for
>> the inconvenience caused.
>>
>> Thanks,
>>
>> Wolfgang.
>>
>>
>>
>> [PATCH] i2c: i2c-mpc: bug fix for MPC52xx clock setting and printout
>>
>> The clock setting did not work for the MPC52xx due to a stupid bug.
>> Furthermore, the dev info output "clock=0" for old device trees was
>> misleading. This patch fixes both issues.
>>
>> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
>
> Could you please apply this bug-fix for the MPC driver for 2.6.30.

Acked-by: Grant Likely <grant.likely@secretlab.ca>

>
>  http://marc.info/?l=linux-i2c&m=123927120910293&w=2
>
> Thanks,
>
> Wolfgang.
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable
@ 2009-04-20 13:26                         ` Grant Likely
  0 siblings, 0 replies; 58+ messages in thread
From: Grant Likely @ 2009-04-20 13:26 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux/PPC Development, devicetree-discuss, linux-i2c, Ben Dooks

On Mon, Apr 20, 2009 at 3:01 AM, Wolfgang Grandegger <wg@grandegger.com> wr=
ote:
> Hi Ben,
>
> Wolfgang Grandegger wrote:
>> Wolfgang Grandegger wrote:
>>> Kumar Gala wrote:
>>>> On Apr 8, 2009, at 2:25 AM, Wolfgang Grandegger wrote:
>>>>
>>>>>> So I'm a bit concerned with the output we now get:
>>>>>>
>>>>>> mpc-i2c fffe03000.i2c: clock 0 Hz (dfsrr=3D16 fdr=3D49)
>>>>>>
>>>>>> why 0? is that right?
>>>>> This is the backward compatibility mode using hard-coded FDR values. =
The
>>>>> output is missleading, I agree.
>>>>>
>>>>> Wolfgang.
>>>> Can the output be fixed. =A00 Hz seemed bad to me.
>>> Of course. No info message will be printed for the legacy case
>>> like it was with the old driver version. I just realized a bug in the
>>> MPC52xx part. Will send patches tomorrow, after some more thorough test=
ing.
>>
>> The patch below fixes both issues. Ben, could you please apply it. Sorry=
 for
>> the inconvenience caused.
>>
>> Thanks,
>>
>> Wolfgang.
>>
>>
>>
>> [PATCH] i2c: i2c-mpc: bug fix for MPC52xx clock setting and printout
>>
>> The clock setting did not work for the MPC52xx due to a stupid bug.
>> Furthermore, the dev info output "clock=3D0" for old device trees was
>> misleading. This patch fixes both issues.
>>
>> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
>
> Could you please apply this bug-fix for the MPC driver for 2.6.30.

Acked-by: Grant Likely <grant.likely@secretlab.ca>

>
> =A0http://marc.info/?l=3Dlinux-i2c&m=3D123927120910293&w=3D2
>
> Thanks,
>
> Wolfgang.
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>



--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH v3 3/5] i2c: i2c-mpc: make I2C bus speed configurable
       [not found]   ` <20090407082231.500525932-ynQEQJNshbs@public.gmane.org>
  2009-04-07 15:36       ` Grant Likely
@ 2012-11-01 19:19     ` Tabi Timur-B04825
  2012-11-07 16:40     ` Timur Tabi
  2 siblings, 0 replies; 58+ messages in thread
From: Tabi Timur-B04825 @ 2012-11-01 19:19 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA

Wolfgang,

I know it's been 3 1/2 years since you wrote this code, but I think I
found a bug.

On Tue, Apr 7, 2009 at 3:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> This patch makes the I2C bus speed configurable by using the I2C node
> property "clock-frequency". If the property is not defined, the old
> fixed clock settings will be used for backward comptibility.
>
> The generic I2C clock properties, especially the CPU-specific source
> clock pre-scaler are defined via the OF match table:
>
>   static const struct of_device_id mpc_i2c_of_match[] = {
>         ...
>         {.compatible = "fsl,mpc8543-i2c",
>          .data = &(struct fsl_i2c_match_data) {
>                         .setclock = mpc_i2c_setclock_8xxx,
>                         .prescaler = 2,
>                 },
>         },
>
> The "data" field defines the relevant I2C setclock function and the
> relevant pre-scaler for the I2C source clock frequency.
>
> It uses arch-specific tables and functions to determine resonable
> Freqency Divider Register (fdr) values for MPC83xx, MPC85xx, MPC86xx,
> MPC5200 and MPC5200B.
>
> The i2c->flags field and the corresponding FSL_I2C_DEV_* definitions
> have been removed as they are obsolete.
>
> Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

...

> +u32 mpc_i2c_get_sec_cfg_8xxx(void)
> +{
> +       struct device_node *node = NULL;
> +       u32 __iomem *reg;
> +       u32 val = 0;
> +
> +       node = of_find_node_by_name(NULL, "global-utilities");
> +       if (node) {
> +               const u32 *prop = of_get_property(node, "reg", NULL);
> +               if (prop) {
> +                       /*
> +                        * Map and check POR Device Status Register 2
> +                        * (PORDEVSR2) at 0xE0014
> +                        */
> +                       reg = ioremap(get_immrbase() + *prop + 0x14, 0x4);
> +                       if (!reg)
> +                               printk(KERN_ERR
> +                                      "Error: couldn't map PORDEVSR2\n");
> +                       else
> +                               val = in_be32(reg) & 0x00000080; /* sec-cfg */

I'm looking at the MPC8544 reference manual, and PORDEVSR2[SEC_CFG] is
in position 26, which means that this line should be "& 0x20", not "&
0x80".

Can you check this for me and let me know if I'm right?

> +                       iounmap(reg);
> +               }
> +       }
> +       if (node)
> +               of_node_put(node);
> +
> +       return val;
> +}

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* Re: [PATCH v3 3/5] i2c: i2c-mpc: make I2C bus speed configurable
       [not found]   ` <20090407082231.500525932-ynQEQJNshbs@public.gmane.org>
  2009-04-07 15:36       ` Grant Likely
  2012-11-01 19:19     ` Tabi Timur-B04825
@ 2012-11-07 16:40     ` Timur Tabi
       [not found]       ` <509A8F0F.4070806-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
  2 siblings, 1 reply; 58+ messages in thread
From: Timur Tabi @ 2012-11-07 16:40 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA

Wolfgang,

I know it's been 3 1/2 years since you wrote this code, but I think I
found a bug.

On Tue, Apr 7, 2009 at 3:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> This patch makes the I2C bus speed configurable by using the I2C node
> property "clock-frequency". If the property is not defined, the old
> fixed clock settings will be used for backward comptibility.
>
> The generic I2C clock properties, especially the CPU-specific source
> clock pre-scaler are defined via the OF match table:
>
>   static const struct of_device_id mpc_i2c_of_match[] = {
>         ...
>         {.compatible = "fsl,mpc8543-i2c",
>          .data = &(struct fsl_i2c_match_data) {
>                         .setclock = mpc_i2c_setclock_8xxx,
>                         .prescaler = 2,
>                 },
>         },
>
> The "data" field defines the relevant I2C setclock function and the
> relevant pre-scaler for the I2C source clock frequency.
>
> It uses arch-specific tables and functions to determine resonable
> Freqency Divider Register (fdr) values for MPC83xx, MPC85xx, MPC86xx,
> MPC5200 and MPC5200B.
>
> The i2c->flags field and the corresponding FSL_I2C_DEV_* definitions
> have been removed as they are obsolete.
>
> Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

...

> +u32 mpc_i2c_get_sec_cfg_8xxx(void)
> +{
> +       struct device_node *node = NULL;
> +       u32 __iomem *reg;
> +       u32 val = 0;
> +
> +       node = of_find_node_by_name(NULL, "global-utilities");
> +       if (node) {
> +               const u32 *prop = of_get_property(node, "reg", NULL);
> +               if (prop) {
> +                       /*
> +                        * Map and check POR Device Status Register 2
> +                        * (PORDEVSR2) at 0xE0014
> +                        */
> +                       reg = ioremap(get_immrbase() + *prop + 0x14, 0x4);
> +                       if (!reg)
> +                               printk(KERN_ERR
> +                                      "Error: couldn't map PORDEVSR2\n");
> +                       else
> +                               val = in_be32(reg) & 0x00000080; /* sec-cfg */

I'm looking at the MPC8544 reference manual, and PORDEVSR2[SEC_CFG] is
in position 26, which means that this line should be "& 0x20", not "&
0x80".

Can you check this for me and let me know if I'm right?

> +                       iounmap(reg);
> +               }
> +       }
> +       if (node)
> +               of_node_put(node);
> +
> +       return val;
> +}

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* Re: [PATCH v3 3/5] i2c: i2c-mpc: make I2C bus speed configurable
       [not found]       ` <509A8F0F.4070806-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2012-11-16 13:29         ` Wolfram Sang
       [not found]           ` <20121116132939.GB7313-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 58+ messages in thread
From: Wolfram Sang @ 2012-11-16 13:29 UTC (permalink / raw)
  To: Timur Tabi; +Cc: Wolfgang Grandegger, linux-i2c-u79uwXL29TY76Z2rM5mHXA

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

On Wed, Nov 07, 2012 at 10:40:47AM -0600, Timur Tabi wrote:
> Wolfgang,
> 
> I know it's been 3 1/2 years since you wrote this code, but I think I
> found a bug.
> 
> On Tue, Apr 7, 2009 at 3:20 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> > This patch makes the I2C bus speed configurable by using the I2C node
> > property "clock-frequency". If the property is not defined, the old
> > fixed clock settings will be used for backward comptibility.
> >
> > The generic I2C clock properties, especially the CPU-specific source
> > clock pre-scaler are defined via the OF match table:
> >
> >   static const struct of_device_id mpc_i2c_of_match[] = {
> >         ...
> >         {.compatible = "fsl,mpc8543-i2c",
> >          .data = &(struct fsl_i2c_match_data) {
> >                         .setclock = mpc_i2c_setclock_8xxx,
> >                         .prescaler = 2,
> >                 },
> >         },
> >
> > The "data" field defines the relevant I2C setclock function and the
> > relevant pre-scaler for the I2C source clock frequency.
> >
> > It uses arch-specific tables and functions to determine resonable
> > Freqency Divider Register (fdr) values for MPC83xx, MPC85xx, MPC86xx,
> > MPC5200 and MPC5200B.
> >
> > The i2c->flags field and the corresponding FSL_I2C_DEV_* definitions
> > have been removed as they are obsolete.
> >
> > Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
> 
> ...
> 
> > +u32 mpc_i2c_get_sec_cfg_8xxx(void)
> > +{
> > +       struct device_node *node = NULL;
> > +       u32 __iomem *reg;
> > +       u32 val = 0;
> > +
> > +       node = of_find_node_by_name(NULL, "global-utilities");
> > +       if (node) {
> > +               const u32 *prop = of_get_property(node, "reg", NULL);
> > +               if (prop) {
> > +                       /*
> > +                        * Map and check POR Device Status Register 2
> > +                        * (PORDEVSR2) at 0xE0014
> > +                        */
> > +                       reg = ioremap(get_immrbase() + *prop + 0x14, 0x4);
> > +                       if (!reg)
> > +                               printk(KERN_ERR
> > +                                      "Error: couldn't map PORDEVSR2\n");
> > +                       else
> > +                               val = in_be32(reg) & 0x00000080; /* sec-cfg */
> 
> I'm looking at the MPC8544 reference manual, and PORDEVSR2[SEC_CFG] is
> in position 26, which means that this line should be "& 0x20", not "&
> 0x80".
> 
> Can you check this for me and let me know if I'm right?

Ping. Somebody wants to send a patch?

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

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

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

* Re: [PATCH v3 3/5] i2c: i2c-mpc: make I2C bus speed configurable
       [not found]           ` <20121116132939.GB7313-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2012-11-16 16:09             ` Timur Tabi
  0 siblings, 0 replies; 58+ messages in thread
From: Timur Tabi @ 2012-11-16 16:09 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Wolfgang Grandegger, linux-i2c-u79uwXL29TY76Z2rM5mHXA

Wolfram Sang wrote:
> Ping. Somebody wants to send a patch?

I already have a patch that fixes it, I just want confirmation that I'm
right first.

-- 
Timur Tabi
Linux kernel developer at Freescale

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

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

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-07  8:20 [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable Wolfgang Grandegger
2009-04-07  8:20 ` [PATCH v3 1/5] i2c: i2c-mpc: various coding style fixes Wolfgang Grandegger
2009-04-07  8:20   ` Wolfgang Grandegger
     [not found]   ` <20090407082231.177941706-ynQEQJNshbs@public.gmane.org>
2009-04-07 15:36     ` Grant Likely
2009-04-07 15:36       ` Grant Likely
2009-04-07  8:20 ` [PATCH v3 2/5] i2c: i2c-mpc: use dev based printout function Wolfgang Grandegger
2009-04-07  8:20   ` Wolfgang Grandegger
     [not found]   ` <20090407082231.335327816-ynQEQJNshbs@public.gmane.org>
2009-04-07 15:37     ` Grant Likely
2009-04-07 15:37       ` Grant Likely
2009-04-07  8:20 ` [PATCH v3 3/5] i2c: i2c-mpc: make I2C bus speed configurable Wolfgang Grandegger
2009-04-07  8:20   ` Wolfgang Grandegger
     [not found]   ` <20090407082231.500525932-ynQEQJNshbs@public.gmane.org>
2009-04-07 15:36     ` Grant Likely
2009-04-07 15:36       ` Grant Likely
2012-11-01 19:19     ` Tabi Timur-B04825
2012-11-07 16:40     ` Timur Tabi
     [not found]       ` <509A8F0F.4070806-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2012-11-16 13:29         ` Wolfram Sang
     [not found]           ` <20121116132939.GB7313-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-11-16 16:09             ` Timur Tabi
2009-04-07  8:20 ` [PATCH v3 4/5] powerpc: i2c-mpc: document new FSL I2C bindings and cleanup Wolfgang Grandegger
2009-04-07  8:20   ` Wolfgang Grandegger
     [not found]   ` <20090407082231.646648985-ynQEQJNshbs@public.gmane.org>
2009-04-07 15:43     ` Grant Likely
2009-04-07 15:43       ` Grant Likely
2009-04-08  5:13     ` Kumar Gala
2009-04-08  5:13       ` Kumar Gala
2009-04-07  8:20 ` [PATCH v3 5/5] powerpc/85xx: i2c-mpc: use new I2C bindings for the Socates board Wolfgang Grandegger
2009-04-07  8:20   ` Wolfgang Grandegger
     [not found]   ` <20090407082231.803193635-ynQEQJNshbs@public.gmane.org>
2009-04-07 15:43     ` Grant Likely
2009-04-07 15:43       ` Grant Likely
2009-04-08  7:16       ` Wolfgang Grandegger
2009-04-08 14:53         ` Grant Likely
2009-04-08 14:53           ` Grant Likely
     [not found]           ` <fa686aa40904080753p2b282338r9ba463c47f897fb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-04-08 18:27             ` Wolfgang Grandegger
2009-04-08 18:27               ` Wolfgang Grandegger
     [not found]               ` <49DCEC80.2050507-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2009-04-08 18:43                 ` Kumar Gala
2009-04-08 18:43                   ` Kumar Gala
     [not found]                   ` <C3323B74-40FE-41BC-A49C-C94D7DB3FF5A-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2009-04-08 18:53                     ` Wolfgang Grandegger
2009-04-08 18:53                       ` Wolfgang Grandegger
     [not found] ` <20090407082052.477328750-ynQEQJNshbs@public.gmane.org>
2009-04-08  5:11   ` [PATCH v3 0/5] i2c: i2c-mpc: make I2C bus speed configurable Kumar Gala
2009-04-08  5:11     ` Kumar Gala
     [not found]     ` <53B42D49-C040-442E-8448-7BC3190220A5-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2009-04-08  5:16       ` Grant Likely
2009-04-08  5:16         ` Grant Likely
2009-04-08  5:22         ` Kumar Gala
2009-04-08  5:32           ` Grant Likely
2009-04-08  5:32             ` Grant Likely
     [not found]           ` <5FDB097C-7D71-41DF-A4F4-2DE34FD710C5-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2009-04-08  7:21             ` Wolfgang Grandegger
2009-04-08  7:21               ` Wolfgang Grandegger
2009-04-08 17:03           ` Scott Wood
2009-04-08 17:49             ` Kumar Gala
2009-04-08  5:28     ` Kumar Gala
     [not found]       ` <F4E3E1FF-C544-460A-AC27-DB9501C13ED3-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2009-04-08  7:25         ` Wolfgang Grandegger
2009-04-08  7:25           ` Wolfgang Grandegger
     [not found]           ` <49DC515F.3040100-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2009-04-08 15:21             ` Kumar Gala
2009-04-08 15:21               ` Kumar Gala
     [not found]               ` <E9E24C93-F147-49F0-9FBE-FCE4883D11BF-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2009-04-08 19:55                 ` Wolfgang Grandegger
2009-04-08 19:55                   ` Wolfgang Grandegger
2009-04-09  9:59                   ` Wolfgang Grandegger
2009-04-20  9:01                     ` Wolfgang Grandegger
2009-04-20 13:26                       ` Grant Likely
2009-04-20 13:26                         ` Grant Likely

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.