All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: i2c-mpc: make speed registers configurable via FDT
@ 2008-07-25  7:37 Wolfgang Grandegger
  2008-07-25  8:51 ` Jochen Friedrich
  0 siblings, 1 reply; 135+ messages in thread
From: Wolfgang Grandegger @ 2008-07-25  7:37 UTC (permalink / raw)
  To: Linuxppc-dev

The I2C driver for the MPC currently uses a fixed speed hard-coded into
the driver. This patch adds the FDT properties "fdr" and "dfsrr" for the
corresponding I2C registers to make the speed configurable via FDT, 
e.g.:

    i2c@3100 {
        compatible = "fsl-i2c";
        reg = <0x3100 0x100>;
        interrupts = <43 2>;
        interrupt-parent = <&mpic>;
        dfsrr = <0x20>;
        fdr = <0x03>;
    };

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
 Documentation/powerpc/dts-bindings/fsl/i2c.txt |    9 +++--
 drivers/i2c/busses/i2c-mpc.c                   |   45 ++++++++++++++++++++-----
 2 files changed, 42 insertions(+), 12 deletions(-)

Index: linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
===================================================================
--- linux-2.6-galak.orig/drivers/i2c/busses/i2c-mpc.c
+++ linux-2.6-galak/drivers/i2c/busses/i2c-mpc.c
@@ -56,6 +56,8 @@ struct mpc_i2c {
 	struct i2c_adapter adap;
 	int irq;
 	u32 flags;
+	u32 fdr;
+	u32 dfsrr;
 };
 
 static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x)
@@ -156,13 +158,16 @@ static int i2c_wait(struct mpc_i2c *i2c,
 static void mpc_i2c_setclock(struct mpc_i2c *i2c)
 {
 	/* Set clock and filters */
+	pr_debug("I2C: flags=%#x fdr=%#x dfsrr=%#x\n",
+		 i2c->flags, i2c->fdr, i2c->dfsrr);
 	if (i2c->flags & FSL_I2C_DEV_SEPARATE_DFSRR) {
-		writeb(0x31, i2c->base + MPC_I2C_FDR);
-		writeb(0x10, i2c->base + MPC_I2C_DFSRR);
-	} else if (i2c->flags & FSL_I2C_DEV_CLOCK_5200)
-		writeb(0x3f, i2c->base + MPC_I2C_FDR);
-	else
-		writel(0x1031, i2c->base + MPC_I2C_FDR);
+		writeb(i2c->fdr, i2c->base + MPC_I2C_FDR);
+		writeb(i2c->dfsrr, i2c->base + MPC_I2C_DFSRR);
+	} else if (i2c->flags & FSL_I2C_DEV_CLOCK_5200) {
+		writeb(i2c->fdr, i2c->base + MPC_I2C_FDR);
+	} else {
+		writel(i2c->fdr, i2c->base + MPC_I2C_FDR);
+	}
 }
 
 static void mpc_i2c_start(struct mpc_i2c *i2c)
@@ -320,18 +325,40 @@ static int __devinit fsl_i2c_probe(struc
 {
 	int result = 0;
 	struct mpc_i2c *i2c;
+	const u32 *prop;
+	int prop_len;
 
 	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
 	if (!i2c)
 		return -ENOMEM;
 
-	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;
 
+	prop = of_get_property(op->node, "dfsrr", &prop_len);
+	if (prop) {
+		i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
+		if (prop_len == sizeof(*prop))
+			i2c->dfsrr = *prop;
+		else
+			/* Set resonable default value */
+			i2c->dfsrr = 0x10;
+	}
+
+	prop = of_get_property(op->node, "fdr", &prop_len);
+	if (prop && prop_len == sizeof(*prop)) {
+		i2c->fdr = *prop;
+	} else {
+		/* Set resonable default values */
+		if (i2c->flags & FSL_I2C_DEV_SEPARATE_DFSRR)
+			i2c->fdr = 0x31;
+		else if (i2c->flags & FSL_I2C_DEV_CLOCK_5200)
+			i2c->fdr = 0x3f;
+		else
+			i2c->fdr = 0x1031;
+	}
+
 	init_waitqueue_head(&i2c->queue);
 
 	i2c->base = of_iomap(op->node, 0);
Index: linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt
===================================================================
--- linux-2.6-galak.orig/Documentation/powerpc/dts-bindings/fsl/i2c.txt
+++ linux-2.6-galak/Documentation/powerpc/dts-bindings/fsl/i2c.txt
@@ -16,10 +16,12 @@ Recommended properties :
    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.
+ - dfsrr : boolean or <v>; if defined, indicates that this I2C device has
+   a digital filter sampling rate register. Optionally you can specify a
+   value v for the this register.
+ - fdr : <v>, if defined, the FDR register will be set to the value v.
 
 Example :
 	i2c@3000 {
@@ -28,5 +30,6 @@ Example :
 		reg = <3000 18>;
 		device_type = "i2c";
 		compatible  = "fsl-i2c";
-		dfsrr;
+		fdr = <0x20>
+		dfsrr = <0x03>;
 	};

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

end of thread, other threads:[~2008-08-01 21:14 UTC | newest]

Thread overview: 135+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-25  7:37 [PATCH] powerpc: i2c-mpc: make speed registers configurable via FDT Wolfgang Grandegger
2008-07-25  8:51 ` Jochen Friedrich
2008-07-25  9:04   ` Wolfgang Grandegger
2008-07-25 13:12     ` Grant Likely
2008-07-25 14:21       ` Timur Tabi
2008-07-25 15:04         ` Jon Smirl
2008-07-25 15:23         ` Wolfgang Grandegger
2008-07-25 16:19           ` Timur Tabi
2008-07-27  1:27             ` Grant Likely
2008-07-31 11:51               ` Wolfgang Grandegger
2008-07-31 15:49                 ` Jon Smirl
2008-07-31 15:55                   ` Timur Tabi
     [not found]                     ` <4891E06A.4070608-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2008-07-31 23:32                       ` Trent Piepho
2008-07-31 23:32                         ` [i2c] " Trent Piepho
2008-08-01 13:17                         ` Timur Tabi
2008-08-01 15:47                           ` Scott Wood
2008-08-01 19:47                           ` Trent Piepho
     [not found]                             ` <Pine.LNX.4.58.0808011246290.10341-13q4cmjDBaTP3RPoUHIrnuTW4wlIGRCZ@public.gmane.org>
2008-08-01 19:50                               ` Timur Tabi
2008-08-01 19:50                                 ` [i2c] " Timur Tabi
2008-07-31 17:22                   ` Wolfgang Grandegger
     [not found]                     ` <4891F4D8.9090905-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2008-07-31 17:31                       ` Grant Likely
2008-07-31 17:31                         ` Grant Likely
2008-07-31 17:51                         ` Wolfgang Grandegger
     [not found]                         ` <fa686aa40807311031r66f6451aw206faf54509c14d9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-31 17:54                           ` Timur Tabi
2008-07-31 17:54                             ` Timur Tabi
2008-07-31 18:07                             ` Wolfgang Grandegger
     [not found]                               ` <4891FF51.4020701-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2008-07-31 18:06                                 ` Timur Tabi
2008-07-31 18:06                                   ` Timur Tabi
2008-07-31 18:07                               ` Grant Likely
     [not found]                                 ` <fa686aa40807311107m44ce7fbk35e94d1a24b992fb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-31 18:10                                   ` Timur Tabi
2008-07-31 18:10                                     ` Timur Tabi
     [not found]                                     ` <48920016.5000506-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2008-07-31 18:21                                       ` Grant Likely
2008-07-31 18:21                                         ` Grant Likely
2008-07-31 18:09                             ` Grant Likely
     [not found]                               ` <20080731180959.GA29057-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2008-07-31 18:13                                 ` Timur Tabi
2008-07-31 18:13                                   ` Timur Tabi
2008-07-31 18:28                                   ` Grant Likely
     [not found]                                     ` <20080731182810.GB29097-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2008-07-31 18:35                                       ` Timur Tabi
2008-07-31 18:35                                         ` Timur Tabi
2008-07-31 18:57                                         ` Jon Smirl
     [not found]                                           ` <9e4733910807311157q358640ddyef1f14865c069b8-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-31 19:01                                             ` Timur Tabi
2008-07-31 19:01                                               ` Timur Tabi
2008-07-31 19:25                                             ` Grant Likely
2008-07-31 19:25                                               ` Grant Likely
2008-08-01  0:22                                           ` [i2c] " Trent Piepho
     [not found]                                             ` <Pine.LNX.4.58.0807311656250.10341-13q4cmjDBaTP3RPoUHIrnuTW4wlIGRCZ@public.gmane.org>
2008-08-01  1:19                                               ` Jon Smirl
2008-08-01  1:19                                                 ` [i2c] " Jon Smirl
     [not found]                                                 ` <9e4733910807311819i60872285ga4829c841185fdc0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-08-01  1:36                                                   ` Trent Piepho
2008-08-01  1:36                                                     ` [i2c] " Trent Piepho
     [not found]                                                     ` <Pine.LNX.4.58.0807311828580.10341-13q4cmjDBaTP3RPoUHIrnuTW4wlIGRCZ@public.gmane.org>
2008-08-01  1:44                                                       ` Jon Smirl
2008-08-01  1:44                                                         ` [i2c] " Jon Smirl
     [not found]                                                         ` <9e4733910807311844p142b26ffyb4105df3e136f65-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-08-01 15:02                                                           ` Timur Tabi
2008-08-01 15:02                                                             ` [i2c] " Timur Tabi
2008-08-01 16:05                                                             ` Jon Smirl
2008-08-01  7:29                                                     ` Wolfgang Grandegger
2008-08-01  2:03                                                 ` Grant Likely
2008-08-01  2:35                                                   ` Jon Smirl
2008-08-01 13:25                                                     ` Timur Tabi
2008-08-01 14:28                                                       ` Jon Smirl
     [not found]                                                       ` <ed82fe3e0808010625q53680d42l83f28a6df835f959-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-08-01 14:32                                                         ` Jon Smirl
2008-08-01 14:32                                                           ` [i2c] " Jon Smirl
2008-08-01 21:14                                                           ` Trent Piepho
2008-08-01  7:25                                                 ` Wolfgang Grandegger
2008-08-01 14:38                                                   ` Grant Likely
     [not found]                                         ` <48920607.5040606-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2008-07-31 19:01                                           ` Scott Wood
2008-07-31 19:01                                             ` Scott Wood
2008-07-31 19:08                                             ` Timur Tabi
2008-07-31 19:15                                               ` Scott Wood
     [not found]                                                 ` <48920F69.6020909-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2008-07-31 19:19                                                   ` Timur Tabi
2008-07-31 19:19                                                     ` Timur Tabi
     [not found]                                                     ` <48921057.8030807-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2008-07-31 19:21                                                       ` Scott Wood
2008-07-31 19:21                                                         ` Scott Wood
     [not found]                                                         ` <489210AF.7000909-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2008-07-31 19:22                                                           ` Timur Tabi
2008-07-31 19:22                                                             ` Timur Tabi
2008-07-31 19:11                                             ` Jon Smirl
2008-07-31 19:14                                         ` Grant Likely
2008-07-31 19:24                                         ` Wolfgang Grandegger
     [not found]                                           ` <48921187.1090101-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2008-07-31 19:24                                             ` Timur Tabi
2008-07-31 19:24                                               ` Timur Tabi
2008-07-31 19:54                                               ` Wolfgang Grandegger
2008-07-31 19:58                                                 ` Timur Tabi
2008-07-31 20:17                                                   ` Wolfgang Grandegger
     [not found]                                                     ` <48921DED.6010403-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2008-07-31 20:19                                                       ` Timur Tabi
2008-07-31 20:19                                                         ` Timur Tabi
2008-07-31 20:28                                                         ` Wolfgang Grandegger
     [not found]                                                           ` <48922087.4050903-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2008-07-31 20:28                                                             ` Timur Tabi
2008-07-31 20:28                                                               ` Timur Tabi
     [not found]                                                         ` <48921E44.7010502-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2008-07-31 20:30                                                           ` Grant Likely
2008-07-31 20:30                                                             ` Grant Likely
2008-07-31 20:32                                                       ` Jon Smirl
2008-07-31 20:32                                                         ` Jon Smirl
     [not found]                                                         ` <9e4733910807311332q611b43b3y26f64b5269ccb657-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-31 20:35                                                           ` Grant Likely
2008-07-31 20:35                                                             ` Grant Likely
     [not found]                                                             ` <fa686aa40807311335t1dd123d0mc385234ebe55248-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-31 20:37                                                               ` Timur Tabi
2008-07-31 20:37                                                                 ` Timur Tabi
2008-07-31 20:48                                                                 ` Grant Likely
2008-07-31 20:55                                                                   ` Jon Smirl
     [not found]                                                                     ` <9e4733910807311355q3394b4bfg66c37055384451f7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-31 20:56                                                                       ` Scott Wood
2008-07-31 20:56                                                                         ` Scott Wood
2008-07-31 20:56                                                                       ` Timur Tabi
2008-07-31 20:56                                                                         ` Timur Tabi
2008-07-31 21:03                                                                         ` Jon Smirl
     [not found]                                                                           ` <9e4733910807311403o63c37366ldae30e873f33a21e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-31 21:10                                                                             ` Timur Tabi
2008-07-31 21:10                                                                               ` Timur Tabi
2008-07-31 21:14                                                                           ` Wolfgang Grandegger
     [not found]                                                                             ` <48922B40.3010808-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2008-07-31 21:17                                                                               ` Timur Tabi
2008-07-31 21:17                                                                                 ` Timur Tabi
2008-08-01  1:16                                                                                 ` [i2c] " Trent Piepho
2008-08-01  0:57                                                             ` Trent Piepho
2008-07-31 20:35                                                           ` Timur Tabi
2008-07-31 20:35                                                             ` Timur Tabi
     [not found]                                                             ` <48922218.9020503-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2008-07-31 20:43                                                               ` Jon Smirl
2008-07-31 20:43                                                                 ` Jon Smirl
     [not found]                                                                 ` <9e4733910807311343h3a1b21dbub15754090a67fac6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-31 20:44                                                                   ` Timur Tabi
2008-07-31 20:44                                                                     ` Timur Tabi
2008-07-31 19:59                                                 ` Grant Likely
     [not found]                                                   ` <20080731195911.GA29610-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2008-07-31 20:00                                                     ` Timur Tabi
2008-07-31 20:00                                                       ` Timur Tabi
2008-07-31 20:20                                                   ` Wolfgang Grandegger
     [not found]                                                     ` <48921EA2.1080600-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2008-07-31 20:19                                                       ` Timur Tabi
2008-07-31 20:19                                                         ` Timur Tabi
2008-08-01  0:46                                                   ` [i2c] " Trent Piepho
     [not found]                                                     ` <Pine.LNX.4.58.0807311742230.10341-13q4cmjDBaTP3RPoUHIrnuTW4wlIGRCZ@public.gmane.org>
2008-08-01 14:34                                                       ` Grant Likely
2008-08-01 14:34                                                         ` [i2c] " Grant Likely
2008-08-01 14:48                                                     ` Geert Uytterhoeven
2008-08-01 14:48                                                       ` Geert Uytterhoeven
2008-07-31 17:35                       ` Jon Smirl
2008-07-31 17:35                         ` Jon Smirl
2008-07-31 16:51                 ` Grant Likely
2008-07-31 17:06                   ` Jon Smirl
2008-07-31 17:36                     ` Grant Likely
2008-07-31 17:47                       ` Jon Smirl
2008-07-31 17:24                   ` Wolfgang Grandegger
2008-07-25 15:34       ` Wolfgang Grandegger
2008-07-27  1:25         ` 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.