All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] i2c-mpc: add support for the Freescale MPC512x and other fixes
@ 2010-01-28 13:25 ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-01-28 13:25 UTC (permalink / raw)
  To: Linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Ben Dooks,
	Wolfgang Grandegger

This patch series adds support for the MPC512x from Freescale to the
i2c-mpc driver. At that occasion, issues with  __devinit[data] have
been fixed and the doc of the FSL I2C dts bindings updated. It has
been tested on a MPC5121ADS, TQM5200 and TQM8560 board

Changes since v1:

- use macro MPC_I2C_CLOCK_PRESERVE/SAFE for the special clock settings.
- document the special DTS node "fsl,mpc5121-i2c-ctrl".
- update and correct the Kconfig help.
- some other minor fixes as suggested by Wolfram.

Changes since v2:

- use __init[data] instead of __devinit[data] for this driver.

Changes since v3:

- switch back to __devinit[data] as pointed out by Ben.

Wolfgang

Wolfgang Grandegger (3):
  i2c-mpc: use __devinit[data] for initialization functions and data
  i2c-mpc: add support for the MPC512x processors from Freescale
  powerpc: doc/dts-bindings: update doc of FSL I2C bindings

 Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++-
 drivers/i2c/busses/Kconfig                     |    7 +-
 drivers/i2c/busses/i2c-mpc.c                   |  194 +++++++++++++++---------
 3 files changed, 148 insertions(+), 83 deletions(-)

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

* [PATCH v4 0/3] i2c-mpc: add support for the Freescale MPC512x and other fixes
@ 2010-01-28 13:25 ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-01-28 13:25 UTC (permalink / raw)
  To: Linux-i2c; +Cc: Devicetree-discuss, Linuxppc-dev, Ben Dooks

This patch series adds support for the MPC512x from Freescale to the
i2c-mpc driver. At that occasion, issues with  __devinit[data] have
been fixed and the doc of the FSL I2C dts bindings updated. It has
been tested on a MPC5121ADS, TQM5200 and TQM8560 board

Changes since v1:

- use macro MPC_I2C_CLOCK_PRESERVE/SAFE for the special clock settings.
- document the special DTS node "fsl,mpc5121-i2c-ctrl".
- update and correct the Kconfig help.
- some other minor fixes as suggested by Wolfram.

Changes since v2:

- use __init[data] instead of __devinit[data] for this driver.

Changes since v3:

- switch back to __devinit[data] as pointed out by Ben.

Wolfgang

Wolfgang Grandegger (3):
  i2c-mpc: use __devinit[data] for initialization functions and data
  i2c-mpc: add support for the MPC512x processors from Freescale
  powerpc: doc/dts-bindings: update doc of FSL I2C bindings

 Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++-
 drivers/i2c/busses/Kconfig                     |    7 +-
 drivers/i2c/busses/i2c-mpc.c                   |  194 +++++++++++++++---------
 3 files changed, 148 insertions(+), 83 deletions(-)

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

* [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
  2010-01-28 13:25 ` Wolfgang Grandegger
@ 2010-01-28 13:25     ` Wolfgang Grandegger
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-01-28 13:25 UTC (permalink / raw)
  To: Linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Ben Dooks,
	Wolfgang Grandegger

From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>

"__devinit[data]" has not yet been used for all initialization functions
and data. To avoid truncating lines, the struct "mpc_i2c_match_data" has
been renamed to "mpc_i2c_data", which is even the better name.

Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
---
 drivers/i2c/busses/i2c-mpc.c |  103 +++++++++++++++++++----------------------
 1 files changed, 48 insertions(+), 55 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index f627001..275ebe6 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -66,7 +66,7 @@ struct mpc_i2c_divider {
 	u16 fdr;	/* including dfsrr */
 };
 
-struct mpc_i2c_match_data {
+struct mpc_i2c_data {
 	void (*setclock)(struct device_node *node,
 			 struct mpc_i2c *i2c,
 			 u32 clock, u32 prescaler);
@@ -165,7 +165,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 }
 
 #ifdef CONFIG_PPC_MPC52xx
-static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
+static const struct __devinitdata 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},
@@ -186,7 +186,8 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
 	{10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f}
 };
 
-int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
+static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock,
+					  int prescaler)
 {
 	const struct mpc_i2c_divider *div = NULL;
 	unsigned int pvr = mfspr(SPRN_PVR);
@@ -215,9 +216,9 @@ int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
 	return div ? (int)div->fdr : -EINVAL;
 }
 
-static void mpc_i2c_setclock_52xx(struct device_node *node,
-				  struct mpc_i2c *i2c,
-				  u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
+					    struct mpc_i2c *i2c,
+					    u32 clock, u32 prescaler)
 {
 	int ret, fdr;
 
@@ -230,15 +231,15 @@ static void mpc_i2c_setclock_52xx(struct device_node *node,
 		dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
 }
 #else /* !CONFIG_PPC_MPC52xx */
-static void mpc_i2c_setclock_52xx(struct device_node *node,
-				  struct mpc_i2c *i2c,
-				  u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
+					    struct mpc_i2c *i2c,
+					    u32 clock, u32 prescaler)
 {
 }
 #endif /* CONFIG_PPC_MPC52xx*/
 
 #ifdef CONFIG_FSL_SOC
-static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
+static const struct __devinitdata 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},
@@ -258,7 +259,7 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
 	{49152, 0x011e}, {61440, 0x011f}
 };
 
-u32 mpc_i2c_get_sec_cfg_8xxx(void)
+static u32 __devinit mpc_i2c_get_sec_cfg_8xxx(void)
 {
 	struct device_node *node = NULL;
 	u32 __iomem *reg;
@@ -287,7 +288,8 @@ u32 mpc_i2c_get_sec_cfg_8xxx(void)
 	return val;
 }
 
-int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler)
+static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,
+					  u32 prescaler)
 {
 	const struct mpc_i2c_divider *div = NULL;
 	u32 divider;
@@ -320,9 +322,9 @@ int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler)
 	return div ? (int)div->fdr : -EINVAL;
 }
 
-static void mpc_i2c_setclock_8xxx(struct device_node *node,
-				  struct mpc_i2c *i2c,
-				  u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
+					    struct mpc_i2c *i2c,
+					    u32 clock, u32 prescaler)
 {
 	int ret, fdr;
 
@@ -338,9 +340,9 @@ static void mpc_i2c_setclock_8xxx(struct device_node *node,
 }
 
 #else /* !CONFIG_FSL_SOC */
-static void mpc_i2c_setclock_8xxx(struct device_node *node,
-				  struct mpc_i2c *i2c,
-				  u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
+					    struct mpc_i2c *i2c,
+					    u32 clock, u32 prescaler)
 {
 }
 #endif /* CONFIG_FSL_SOC */
@@ -529,8 +531,8 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
 			clock = *prop;
 
 		if (match->data) {
-			struct mpc_i2c_match_data *data =
-				(struct mpc_i2c_match_data *)match->data;
+			struct mpc_i2c_data *data =
+				(struct mpc_i2c_data *)match->data;
 			data->setclock(op->node, i2c, clock, data->prescaler);
 		} else {
 			/* Backwards compatibility */
@@ -582,44 +584,35 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
 	return 0;
 };
 
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
+	.setclock = mpc_i2c_setclock_52xx,
+};
+
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
+	.setclock = mpc_i2c_setclock_8xxx,
+};
+
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
+	.setclock = mpc_i2c_setclock_8xxx,
+	.prescaler = 2,
+};
+
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
+	.setclock = mpc_i2c_setclock_8xxx,
+	.prescaler = 3,
+};
+
 static const struct of_device_id mpc_i2c_of_match[] = {
-	{.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,
-		},
+	{.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
+	{.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
+	{.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
+	{.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
+	{.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
+	{.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
 	/* Backward compatibility */
-	},
 	{.compatible = "fsl-i2c", },
 	{},
 };
-
 MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
 
 
@@ -634,7 +627,7 @@ static struct of_platform_driver mpc_i2c_driver = {
 	},
 };
 
-static int __init fsl_i2c_init(void)
+static int __devinit fsl_i2c_init(void)
 {
 	int rv;
 
@@ -645,7 +638,7 @@ static int __init fsl_i2c_init(void)
 	return rv;
 }
 
-static void __exit fsl_i2c_exit(void)
+static void __devexit fsl_i2c_exit(void)
 {
 	of_unregister_platform_driver(&mpc_i2c_driver);
 }
-- 
1.6.2.5

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

* [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
@ 2010-01-28 13:25     ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-01-28 13:25 UTC (permalink / raw)
  To: Linux-i2c
  Cc: Devicetree-discuss, Linuxppc-dev, Wolfgang Grandegger, Ben Dooks

From: Wolfgang Grandegger <wg@denx.de>

"__devinit[data]" has not yet been used for all initialization functions
and data. To avoid truncating lines, the struct "mpc_i2c_match_data" has
been renamed to "mpc_i2c_data", which is even the better name.

Signed-off-by: Wolfgang Grandegger <wg@denx.de>
---
 drivers/i2c/busses/i2c-mpc.c |  103 +++++++++++++++++++----------------------
 1 files changed, 48 insertions(+), 55 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index f627001..275ebe6 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -66,7 +66,7 @@ struct mpc_i2c_divider {
 	u16 fdr;	/* including dfsrr */
 };
 
-struct mpc_i2c_match_data {
+struct mpc_i2c_data {
 	void (*setclock)(struct device_node *node,
 			 struct mpc_i2c *i2c,
 			 u32 clock, u32 prescaler);
@@ -165,7 +165,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 }
 
 #ifdef CONFIG_PPC_MPC52xx
-static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
+static const struct __devinitdata 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},
@@ -186,7 +186,8 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
 	{10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f}
 };
 
-int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
+static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock,
+					  int prescaler)
 {
 	const struct mpc_i2c_divider *div = NULL;
 	unsigned int pvr = mfspr(SPRN_PVR);
@@ -215,9 +216,9 @@ int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
 	return div ? (int)div->fdr : -EINVAL;
 }
 
-static void mpc_i2c_setclock_52xx(struct device_node *node,
-				  struct mpc_i2c *i2c,
-				  u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
+					    struct mpc_i2c *i2c,
+					    u32 clock, u32 prescaler)
 {
 	int ret, fdr;
 
@@ -230,15 +231,15 @@ static void mpc_i2c_setclock_52xx(struct device_node *node,
 		dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
 }
 #else /* !CONFIG_PPC_MPC52xx */
-static void mpc_i2c_setclock_52xx(struct device_node *node,
-				  struct mpc_i2c *i2c,
-				  u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
+					    struct mpc_i2c *i2c,
+					    u32 clock, u32 prescaler)
 {
 }
 #endif /* CONFIG_PPC_MPC52xx*/
 
 #ifdef CONFIG_FSL_SOC
-static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
+static const struct __devinitdata 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},
@@ -258,7 +259,7 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
 	{49152, 0x011e}, {61440, 0x011f}
 };
 
-u32 mpc_i2c_get_sec_cfg_8xxx(void)
+static u32 __devinit mpc_i2c_get_sec_cfg_8xxx(void)
 {
 	struct device_node *node = NULL;
 	u32 __iomem *reg;
@@ -287,7 +288,8 @@ u32 mpc_i2c_get_sec_cfg_8xxx(void)
 	return val;
 }
 
-int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler)
+static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,
+					  u32 prescaler)
 {
 	const struct mpc_i2c_divider *div = NULL;
 	u32 divider;
@@ -320,9 +322,9 @@ int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler)
 	return div ? (int)div->fdr : -EINVAL;
 }
 
-static void mpc_i2c_setclock_8xxx(struct device_node *node,
-				  struct mpc_i2c *i2c,
-				  u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
+					    struct mpc_i2c *i2c,
+					    u32 clock, u32 prescaler)
 {
 	int ret, fdr;
 
@@ -338,9 +340,9 @@ static void mpc_i2c_setclock_8xxx(struct device_node *node,
 }
 
 #else /* !CONFIG_FSL_SOC */
-static void mpc_i2c_setclock_8xxx(struct device_node *node,
-				  struct mpc_i2c *i2c,
-				  u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
+					    struct mpc_i2c *i2c,
+					    u32 clock, u32 prescaler)
 {
 }
 #endif /* CONFIG_FSL_SOC */
@@ -529,8 +531,8 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
 			clock = *prop;
 
 		if (match->data) {
-			struct mpc_i2c_match_data *data =
-				(struct mpc_i2c_match_data *)match->data;
+			struct mpc_i2c_data *data =
+				(struct mpc_i2c_data *)match->data;
 			data->setclock(op->node, i2c, clock, data->prescaler);
 		} else {
 			/* Backwards compatibility */
@@ -582,44 +584,35 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
 	return 0;
 };
 
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
+	.setclock = mpc_i2c_setclock_52xx,
+};
+
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
+	.setclock = mpc_i2c_setclock_8xxx,
+};
+
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
+	.setclock = mpc_i2c_setclock_8xxx,
+	.prescaler = 2,
+};
+
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
+	.setclock = mpc_i2c_setclock_8xxx,
+	.prescaler = 3,
+};
+
 static const struct of_device_id mpc_i2c_of_match[] = {
-	{.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,
-		},
+	{.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
+	{.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
+	{.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
+	{.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
+	{.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
+	{.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
 	/* Backward compatibility */
-	},
 	{.compatible = "fsl-i2c", },
 	{},
 };
-
 MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
 
 
@@ -634,7 +627,7 @@ static struct of_platform_driver mpc_i2c_driver = {
 	},
 };
 
-static int __init fsl_i2c_init(void)
+static int __devinit fsl_i2c_init(void)
 {
 	int rv;
 
@@ -645,7 +638,7 @@ static int __init fsl_i2c_init(void)
 	return rv;
 }
 
-static void __exit fsl_i2c_exit(void)
+static void __devexit fsl_i2c_exit(void)
 {
 	of_unregister_platform_driver(&mpc_i2c_driver);
 }
-- 
1.6.2.5

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

* [PATCH v4 2/3] i2c-mpc: add support for the MPC512x processors from Freescale
  2010-01-28 13:25     ` Wolfgang Grandegger
@ 2010-01-28 13:25         ` Wolfgang Grandegger
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-01-28 13:25 UTC (permalink / raw)
  To: Linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Ben Dooks,
	Wolfgang Grandegger

From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>

The "setclock" initialization functions have been renamed to "setup"
because I2C interrupts must be enabled for the MPC512x. This requires
to handle "fsl,preserve-clocking" in a slighly different way. Also,
the old settings are now reported calling dev_dbg(). For the MPC512x
the clock setup function of the MPC52xx can be re-used. Furthermore,
the Kconfig help has been updated and corrected.

Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
---
 drivers/i2c/busses/Kconfig   |    7 +-
 drivers/i2c/busses/i2c-mpc.c |  127 ++++++++++++++++++++++++++++++------------
 2 files changed, 94 insertions(+), 40 deletions(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5f318ce..5477e41 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -418,13 +418,12 @@ config I2C_IXP2000
 	  instead.
 
 config I2C_MPC
-	tristate "MPC107/824x/85xx/52xx/86xx"
+	tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx"
 	depends on PPC32
 	help
 	  If you say yes to this option, support will be included for the
-	  built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
-	  MPC85xx/MPC8641 family processors. The driver may also work on 52xx
-	  family processors, though interrupts are known not to work.
+	  built-in I2C interface on the MPC107, Tsi107, MPC512x, MPC52xx,
+	  MPC8240, MPC8245, MPC83xx, MPC85xx and MPC8641 family processors.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-mpc.
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 275ebe6..1af0730 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -31,6 +31,9 @@
 
 #define DRV_NAME "mpc-i2c"
 
+#define MPC_I2C_CLOCK_SAFE     0
+#define MPC_I2C_CLOCK_PRESERVE (~0U)
+
 #define MPC_I2C_FDR   0x04
 #define MPC_I2C_CR    0x08
 #define MPC_I2C_SR    0x0c
@@ -67,9 +70,8 @@ struct mpc_i2c_divider {
 };
 
 struct mpc_i2c_data {
-	void (*setclock)(struct device_node *node,
-			 struct mpc_i2c *i2c,
-			 u32 clock, u32 prescaler);
+	void (*setup)(struct device_node *node, struct mpc_i2c *i2c,
+		      u32 clock, u32 prescaler);
 	u32 prescaler;
 };
 
@@ -164,7 +166,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 	return 0;
 }
 
-#ifdef CONFIG_PPC_MPC52xx
+#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x)
 static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
 	{20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
 	{28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
@@ -216,12 +218,18 @@ static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock,
 	return div ? (int)div->fdr : -EINVAL;
 }
 
-static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
-					    struct mpc_i2c *i2c,
-					    u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
 {
 	int ret, fdr;
 
+	if (clock == MPC_I2C_CLOCK_PRESERVE) {
+		dev_dbg(i2c->dev, "using fdr %d\n",
+			readb(i2c->base + MPC_I2C_FDR));
+		return;
+	}
+
 	ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler);
 	fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */
 
@@ -230,13 +238,49 @@ static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
 	if (ret >= 0)
 		dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
 }
-#else /* !CONFIG_PPC_MPC52xx */
-static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
-					    struct mpc_i2c *i2c,
-					    u32 clock, u32 prescaler)
+#else /* !(CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x) */
+static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
+{
+}
+#endif /* CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x */
+
+#ifdef CONFIG_PPC_MPC512x
+static void __devinit mpc_i2c_setup_512x(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
+{
+	struct device_node *node_ctrl;
+	void __iomem *ctrl;
+	const u32 *pval;
+	u32 idx;
+
+	/* Enable I2C interrupts for mpc5121 */
+	node_ctrl = of_find_compatible_node(NULL, NULL,
+					    "fsl,mpc5121-i2c-ctrl");
+	if (node_ctrl) {
+		ctrl = of_iomap(node_ctrl, 0);
+		if (ctrl) {
+			/* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */
+			pval = of_get_property(node, "reg", NULL);
+			idx = (*pval & 0xff) / 0x20;
+			setbits32(ctrl, 1 << (24 + idx * 2));
+			iounmap(ctrl);
+		}
+		of_node_put(node_ctrl);
+	}
+
+	/* The clock setup for the 52xx works also fine for the 512x */
+	mpc_i2c_setup_52xx(node, i2c, clock, prescaler);
+}
+#else /* CONFIG_PPC_MPC512x */
+static void __devinit mpc_i2c_setup_512x(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
 {
 }
-#endif /* CONFIG_PPC_MPC52xx*/
+#endif /* CONFIG_PPC_MPC512x */
 
 #ifdef CONFIG_FSL_SOC
 static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
@@ -322,12 +366,19 @@ static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,
 	return div ? (int)div->fdr : -EINVAL;
 }
 
-static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
-					    struct mpc_i2c *i2c,
-					    u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
 {
 	int ret, fdr;
 
+	if (clock == MPC_I2C_CLOCK_PRESERVE) {
+		dev_dbg(i2c->dev, "using dfsrr %d, fdr %d\n",
+			readb(i2c->base + MPC_I2C_DFSRR),
+			readb(i2c->base + MPC_I2C_FDR));
+		return;
+	}
+
 	ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
 	fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */
 
@@ -340,9 +391,9 @@ static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
 }
 
 #else /* !CONFIG_FSL_SOC */
-static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
-					    struct mpc_i2c *i2c,
-					    u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
 {
 }
 #endif /* CONFIG_FSL_SOC */
@@ -496,7 +547,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
 {
 	struct mpc_i2c *i2c;
 	const u32 *prop;
-	u32 clock = 0;
+	u32 clock = MPC_I2C_CLOCK_SAFE;
 	int result = 0;
 	int plen;
 
@@ -525,21 +576,21 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
 		}
 	}
 
-	if (!of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
+	if (of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
+		clock = MPC_I2C_CLOCK_PRESERVE;
+	} else {
 		prop = of_get_property(op->node, "clock-frequency", &plen);
 		if (prop && plen == sizeof(u32))
 			clock = *prop;
+	}
 
-		if (match->data) {
-			struct mpc_i2c_data *data =
-				(struct mpc_i2c_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);
-		}
+	if (match->data) {
+		struct mpc_i2c_data *data = match->data;
+		data->setup(op->node, i2c, clock, data->prescaler);
+	} else {
+		/* Backwards compatibility */
+		if (of_get_property(op->node, "dfsrr", NULL))
+			mpc_i2c_setup_8xxx(op->node, i2c, clock, 0);
 	}
 
 	dev_set_drvdata(&op->dev, i2c);
@@ -584,21 +635,25 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
 	return 0;
 };
 
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_512x = {
+	.setup = mpc_i2c_setup_512x,
+};
+
 static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
-	.setclock = mpc_i2c_setclock_52xx,
+	.setup = mpc_i2c_setup_52xx,
 };
 
 static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
-	.setclock = mpc_i2c_setclock_8xxx,
+	.setup = mpc_i2c_setup_8xxx,
 };
 
 static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
-	.setclock = mpc_i2c_setclock_8xxx,
+	.setup = mpc_i2c_setup_8xxx,
 	.prescaler = 2,
 };
 
 static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
-	.setclock = mpc_i2c_setclock_8xxx,
+	.setup = mpc_i2c_setup_8xxx,
 	.prescaler = 3,
 };
 
@@ -606,6 +661,7 @@ static const struct of_device_id mpc_i2c_of_match[] = {
 	{.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
 	{.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
 	{.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
+	{.compatible = "fsl,mpc5121-i2c", .data = &mpc_i2c_data_512x, },
 	{.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
 	{.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
 	{.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
@@ -615,7 +671,6 @@ static const struct of_device_id mpc_i2c_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
 
-
 /* Structure for a device driver */
 static struct of_platform_driver mpc_i2c_driver = {
 	.match_table	= mpc_i2c_of_match,
@@ -648,5 +703,5 @@ 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");
+		   "MPC824x/85xx/512x/52xx processors");
 MODULE_LICENSE("GPL");
-- 
1.6.2.5

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

* [PATCH v4 2/3] i2c-mpc: add support for the MPC512x processors from Freescale
@ 2010-01-28 13:25         ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-01-28 13:25 UTC (permalink / raw)
  To: Linux-i2c
  Cc: Devicetree-discuss, Linuxppc-dev, Wolfgang Grandegger, Ben Dooks

From: Wolfgang Grandegger <wg@denx.de>

The "setclock" initialization functions have been renamed to "setup"
because I2C interrupts must be enabled for the MPC512x. This requires
to handle "fsl,preserve-clocking" in a slighly different way. Also,
the old settings are now reported calling dev_dbg(). For the MPC512x
the clock setup function of the MPC52xx can be re-used. Furthermore,
the Kconfig help has been updated and corrected.

Signed-off-by: Wolfgang Grandegger <wg@denx.de>
---
 drivers/i2c/busses/Kconfig   |    7 +-
 drivers/i2c/busses/i2c-mpc.c |  127 ++++++++++++++++++++++++++++++------------
 2 files changed, 94 insertions(+), 40 deletions(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5f318ce..5477e41 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -418,13 +418,12 @@ config I2C_IXP2000
 	  instead.
 
 config I2C_MPC
-	tristate "MPC107/824x/85xx/52xx/86xx"
+	tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx"
 	depends on PPC32
 	help
 	  If you say yes to this option, support will be included for the
-	  built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
-	  MPC85xx/MPC8641 family processors. The driver may also work on 52xx
-	  family processors, though interrupts are known not to work.
+	  built-in I2C interface on the MPC107, Tsi107, MPC512x, MPC52xx,
+	  MPC8240, MPC8245, MPC83xx, MPC85xx and MPC8641 family processors.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-mpc.
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 275ebe6..1af0730 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -31,6 +31,9 @@
 
 #define DRV_NAME "mpc-i2c"
 
+#define MPC_I2C_CLOCK_SAFE     0
+#define MPC_I2C_CLOCK_PRESERVE (~0U)
+
 #define MPC_I2C_FDR   0x04
 #define MPC_I2C_CR    0x08
 #define MPC_I2C_SR    0x0c
@@ -67,9 +70,8 @@ struct mpc_i2c_divider {
 };
 
 struct mpc_i2c_data {
-	void (*setclock)(struct device_node *node,
-			 struct mpc_i2c *i2c,
-			 u32 clock, u32 prescaler);
+	void (*setup)(struct device_node *node, struct mpc_i2c *i2c,
+		      u32 clock, u32 prescaler);
 	u32 prescaler;
 };
 
@@ -164,7 +166,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 	return 0;
 }
 
-#ifdef CONFIG_PPC_MPC52xx
+#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x)
 static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
 	{20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
 	{28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
@@ -216,12 +218,18 @@ static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock,
 	return div ? (int)div->fdr : -EINVAL;
 }
 
-static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
-					    struct mpc_i2c *i2c,
-					    u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
 {
 	int ret, fdr;
 
+	if (clock == MPC_I2C_CLOCK_PRESERVE) {
+		dev_dbg(i2c->dev, "using fdr %d\n",
+			readb(i2c->base + MPC_I2C_FDR));
+		return;
+	}
+
 	ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler);
 	fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */
 
@@ -230,13 +238,49 @@ static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
 	if (ret >= 0)
 		dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
 }
-#else /* !CONFIG_PPC_MPC52xx */
-static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
-					    struct mpc_i2c *i2c,
-					    u32 clock, u32 prescaler)
+#else /* !(CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x) */
+static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
+{
+}
+#endif /* CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x */
+
+#ifdef CONFIG_PPC_MPC512x
+static void __devinit mpc_i2c_setup_512x(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
+{
+	struct device_node *node_ctrl;
+	void __iomem *ctrl;
+	const u32 *pval;
+	u32 idx;
+
+	/* Enable I2C interrupts for mpc5121 */
+	node_ctrl = of_find_compatible_node(NULL, NULL,
+					    "fsl,mpc5121-i2c-ctrl");
+	if (node_ctrl) {
+		ctrl = of_iomap(node_ctrl, 0);
+		if (ctrl) {
+			/* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */
+			pval = of_get_property(node, "reg", NULL);
+			idx = (*pval & 0xff) / 0x20;
+			setbits32(ctrl, 1 << (24 + idx * 2));
+			iounmap(ctrl);
+		}
+		of_node_put(node_ctrl);
+	}
+
+	/* The clock setup for the 52xx works also fine for the 512x */
+	mpc_i2c_setup_52xx(node, i2c, clock, prescaler);
+}
+#else /* CONFIG_PPC_MPC512x */
+static void __devinit mpc_i2c_setup_512x(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
 {
 }
-#endif /* CONFIG_PPC_MPC52xx*/
+#endif /* CONFIG_PPC_MPC512x */
 
 #ifdef CONFIG_FSL_SOC
 static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
@@ -322,12 +366,19 @@ static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,
 	return div ? (int)div->fdr : -EINVAL;
 }
 
-static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
-					    struct mpc_i2c *i2c,
-					    u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
 {
 	int ret, fdr;
 
+	if (clock == MPC_I2C_CLOCK_PRESERVE) {
+		dev_dbg(i2c->dev, "using dfsrr %d, fdr %d\n",
+			readb(i2c->base + MPC_I2C_DFSRR),
+			readb(i2c->base + MPC_I2C_FDR));
+		return;
+	}
+
 	ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
 	fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */
 
@@ -340,9 +391,9 @@ static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
 }
 
 #else /* !CONFIG_FSL_SOC */
-static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
-					    struct mpc_i2c *i2c,
-					    u32 clock, u32 prescaler)
+static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
+					 struct mpc_i2c *i2c,
+					 u32 clock, u32 prescaler)
 {
 }
 #endif /* CONFIG_FSL_SOC */
@@ -496,7 +547,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
 {
 	struct mpc_i2c *i2c;
 	const u32 *prop;
-	u32 clock = 0;
+	u32 clock = MPC_I2C_CLOCK_SAFE;
 	int result = 0;
 	int plen;
 
@@ -525,21 +576,21 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
 		}
 	}
 
-	if (!of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
+	if (of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
+		clock = MPC_I2C_CLOCK_PRESERVE;
+	} else {
 		prop = of_get_property(op->node, "clock-frequency", &plen);
 		if (prop && plen == sizeof(u32))
 			clock = *prop;
+	}
 
-		if (match->data) {
-			struct mpc_i2c_data *data =
-				(struct mpc_i2c_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);
-		}
+	if (match->data) {
+		struct mpc_i2c_data *data = match->data;
+		data->setup(op->node, i2c, clock, data->prescaler);
+	} else {
+		/* Backwards compatibility */
+		if (of_get_property(op->node, "dfsrr", NULL))
+			mpc_i2c_setup_8xxx(op->node, i2c, clock, 0);
 	}
 
 	dev_set_drvdata(&op->dev, i2c);
@@ -584,21 +635,25 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
 	return 0;
 };
 
+static struct mpc_i2c_data __devinitdata mpc_i2c_data_512x = {
+	.setup = mpc_i2c_setup_512x,
+};
+
 static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
-	.setclock = mpc_i2c_setclock_52xx,
+	.setup = mpc_i2c_setup_52xx,
 };
 
 static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
-	.setclock = mpc_i2c_setclock_8xxx,
+	.setup = mpc_i2c_setup_8xxx,
 };
 
 static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
-	.setclock = mpc_i2c_setclock_8xxx,
+	.setup = mpc_i2c_setup_8xxx,
 	.prescaler = 2,
 };
 
 static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
-	.setclock = mpc_i2c_setclock_8xxx,
+	.setup = mpc_i2c_setup_8xxx,
 	.prescaler = 3,
 };
 
@@ -606,6 +661,7 @@ static const struct of_device_id mpc_i2c_of_match[] = {
 	{.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
 	{.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
 	{.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
+	{.compatible = "fsl,mpc5121-i2c", .data = &mpc_i2c_data_512x, },
 	{.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
 	{.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
 	{.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
@@ -615,7 +671,6 @@ static const struct of_device_id mpc_i2c_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
 
-
 /* Structure for a device driver */
 static struct of_platform_driver mpc_i2c_driver = {
 	.match_table	= mpc_i2c_of_match,
@@ -648,5 +703,5 @@ 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");
+		   "MPC824x/85xx/512x/52xx processors");
 MODULE_LICENSE("GPL");
-- 
1.6.2.5

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

* [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
  2010-01-28 13:25         ` Wolfgang Grandegger
@ 2010-01-28 13:25             ` Wolfgang Grandegger
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-01-28 13:25 UTC (permalink / raw)
  To: Linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Ben Dooks,
	Wolfgang Grandegger

From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>

This patch adds the MPC5121 to the list of supported devices,
enhances the doc of the "clock-frequency" property and removes
the obsolete "cell-index" property from the example nodes.
Furthermore and example for the MPC5121 has been added.

Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
---
 Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++++++++++++++++++----
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
index b6d2e21..2f62dae 100644
--- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
+++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
@@ -9,8 +9,9 @@ Recommended properties :
 
  - 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".
+   e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. The
+   second one should be "fsl-i2c". For the mpc5121, an additional node
+   "fsl,mpc5121-i2c-ctrl" is required as shown in the example below.
  - 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
@@ -20,29 +21,46 @@ Recommended properties :
    services interrupts for this device.
  - 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.
+ - clock-frequency : desired I2C bus clock frequency in Hz.  If this
+   property and "fsl,preserve-clocking" is not defined, a safe fixed
+   clock divider value is used (resulting in a small clock frequency).
 
 Examples :
 
+	/* MPC5121 based board */
+	i2c@1740 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "fsl,mpc5121-i2c", "fsl-i2c";
+		reg = <0x1740 0x20>;
+		interrupts = <11 0x8>;
+		interrupt-parent = <&ipic>;
+		clock-frequency = <100000>;
+	};
+
+	i2ccontrol@1760 {
+		compatible = "fsl,mpc5121-i2c-ctrl";
+		reg = <0x1760 0x8>;
+	};
+
+	/* MPC5200B based board */
 	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;
 	};
 
+	/* MPC8544 base board */
 	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>;
 	};
-
-- 
1.6.2.5

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

* [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
@ 2010-01-28 13:25             ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-01-28 13:25 UTC (permalink / raw)
  To: Linux-i2c
  Cc: Devicetree-discuss, Linuxppc-dev, Wolfgang Grandegger, Ben Dooks

From: Wolfgang Grandegger <wg@denx.de>

This patch adds the MPC5121 to the list of supported devices,
enhances the doc of the "clock-frequency" property and removes
the obsolete "cell-index" property from the example nodes.
Furthermore and example for the MPC5121 has been added.

Signed-off-by: Wolfgang Grandegger <wg@denx.de>
---
 Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++++++++++++++++++----
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
index b6d2e21..2f62dae 100644
--- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
+++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
@@ -9,8 +9,9 @@ Recommended properties :
 
  - 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".
+   e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. The
+   second one should be "fsl-i2c". For the mpc5121, an additional node
+   "fsl,mpc5121-i2c-ctrl" is required as shown in the example below.
  - 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
@@ -20,29 +21,46 @@ Recommended properties :
    services interrupts for this device.
  - 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.
+ - clock-frequency : desired I2C bus clock frequency in Hz.  If this
+   property and "fsl,preserve-clocking" is not defined, a safe fixed
+   clock divider value is used (resulting in a small clock frequency).
 
 Examples :
 
+	/* MPC5121 based board */
+	i2c@1740 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "fsl,mpc5121-i2c", "fsl-i2c";
+		reg = <0x1740 0x20>;
+		interrupts = <11 0x8>;
+		interrupt-parent = <&ipic>;
+		clock-frequency = <100000>;
+	};
+
+	i2ccontrol@1760 {
+		compatible = "fsl,mpc5121-i2c-ctrl";
+		reg = <0x1760 0x8>;
+	};
+
+	/* MPC5200B based board */
 	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;
 	};
 
+	/* MPC8544 base board */
 	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>;
 	};
-
-- 
1.6.2.5

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
  2010-01-28 13:25     ` Wolfgang Grandegger
@ 2010-01-29 16:15       ` Wolfram Sang
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfram Sang @ 2010-01-29 16:15 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Wolfgang Grandegger, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Ben Dooks


[-- Attachment #1.1: Type: text/plain, Size: 599 bytes --]

On Thu, Jan 28, 2010 at 02:25:39PM +0100, Wolfgang Grandegger wrote:
> From: Wolfgang Grandegger <wg@denx.de>
> 
> "__devinit[data]" has not yet been used for all initialization functions
> and data. To avoid truncating lines, the struct "mpc_i2c_match_data" has
> been renamed to "mpc_i2c_data", which is even the better name.
> 
> Signed-off-by: Wolfgang Grandegger <wg@denx.de>

Tested-by: Wolfram Sang <w.sang@pengutronix.de>

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

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
@ 2010-01-29 16:15       ` Wolfram Sang
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfram Sang @ 2010-01-29 16:15 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Wolfgang Grandegger, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Ben Dooks

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

On Thu, Jan 28, 2010 at 02:25:39PM +0100, Wolfgang Grandegger wrote:
> From: Wolfgang Grandegger <wg@denx.de>
> 
> "__devinit[data]" has not yet been used for all initialization functions
> and data. To avoid truncating lines, the struct "mpc_i2c_match_data" has
> been renamed to "mpc_i2c_data", which is even the better name.
> 
> Signed-off-by: Wolfgang Grandegger <wg@denx.de>

Tested-by: Wolfram Sang <w.sang@pengutronix.de>

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

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

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

* Re: [PATCH v4 2/3] i2c-mpc: add support for the MPC512x processors from Freescale
  2010-01-28 13:25         ` Wolfgang Grandegger
@ 2010-01-29 16:24             ` Wolfram Sang
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfram Sang @ 2010-01-29 16:24 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Ben Dooks,
	Wolfgang Grandegger

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

On Thu, Jan 28, 2010 at 02:25:40PM +0100, Wolfgang Grandegger wrote:
> From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
> 
> The "setclock" initialization functions have been renamed to "setup"
> because I2C interrupts must be enabled for the MPC512x. This requires
> to handle "fsl,preserve-clocking" in a slighly different way. Also,
> the old settings are now reported calling dev_dbg(). For the MPC512x
> the clock setup function of the MPC52xx can be re-used. Furthermore,
> the Kconfig help has been updated and corrected.
> 
> Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>

One minor thing and you can add my

Reviewed-by: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

> ---
>  drivers/i2c/busses/Kconfig   |    7 +-
>  drivers/i2c/busses/i2c-mpc.c |  127 ++++++++++++++++++++++++++++++------------
>  2 files changed, 94 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 5f318ce..5477e41 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -418,13 +418,12 @@ config I2C_IXP2000
>  	  instead.
>  
>  config I2C_MPC
> -	tristate "MPC107/824x/85xx/52xx/86xx"
> +	tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx"
>  	depends on PPC32
>  	help
>  	  If you say yes to this option, support will be included for the
> -	  built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
> -	  MPC85xx/MPC8641 family processors. The driver may also work on 52xx
> -	  family processors, though interrupts are known not to work.
> +	  built-in I2C interface on the MPC107, Tsi107, MPC512x, MPC52xx,
> +	  MPC8240, MPC8245, MPC83xx, MPC85xx and MPC8641 family processors.
>  
>  	  This driver can also be built as a module.  If so, the module
>  	  will be called i2c-mpc.
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 275ebe6..1af0730 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -31,6 +31,9 @@
>  
>  #define DRV_NAME "mpc-i2c"
>  
> +#define MPC_I2C_CLOCK_SAFE     0

For clarity, I think this define should also be used when checking for the
condition (instead of using !clock).

> +#define MPC_I2C_CLOCK_PRESERVE (~0U)
> +
>  #define MPC_I2C_FDR   0x04
>  #define MPC_I2C_CR    0x08
>  #define MPC_I2C_SR    0x0c
> @@ -67,9 +70,8 @@ struct mpc_i2c_divider {
>  };
>  
>  struct mpc_i2c_data {
> -	void (*setclock)(struct device_node *node,
> -			 struct mpc_i2c *i2c,
> -			 u32 clock, u32 prescaler);
> +	void (*setup)(struct device_node *node, struct mpc_i2c *i2c,
> +		      u32 clock, u32 prescaler);
>  	u32 prescaler;
>  };
>  
> @@ -164,7 +166,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PPC_MPC52xx
> +#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x)
>  static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
>  	{20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
>  	{28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
> @@ -216,12 +218,18 @@ static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock,
>  	return div ? (int)div->fdr : -EINVAL;
>  }
>  
> -static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
> -					    struct mpc_i2c *i2c,
> -					    u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
>  {
>  	int ret, fdr;
>  
> +	if (clock == MPC_I2C_CLOCK_PRESERVE) {
> +		dev_dbg(i2c->dev, "using fdr %d\n",
> +			readb(i2c->base + MPC_I2C_FDR));
> +		return;
> +	}
> +
>  	ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler);
>  	fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */
>  
> @@ -230,13 +238,49 @@ static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
>  	if (ret >= 0)
>  		dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
>  }
> -#else /* !CONFIG_PPC_MPC52xx */
> -static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
> -					    struct mpc_i2c *i2c,
> -					    u32 clock, u32 prescaler)
> +#else /* !(CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x) */
> +static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
> +{
> +}
> +#endif /* CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x */
> +
> +#ifdef CONFIG_PPC_MPC512x
> +static void __devinit mpc_i2c_setup_512x(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
> +{
> +	struct device_node *node_ctrl;
> +	void __iomem *ctrl;
> +	const u32 *pval;
> +	u32 idx;
> +
> +	/* Enable I2C interrupts for mpc5121 */
> +	node_ctrl = of_find_compatible_node(NULL, NULL,
> +					    "fsl,mpc5121-i2c-ctrl");
> +	if (node_ctrl) {
> +		ctrl = of_iomap(node_ctrl, 0);
> +		if (ctrl) {
> +			/* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */
> +			pval = of_get_property(node, "reg", NULL);
> +			idx = (*pval & 0xff) / 0x20;
> +			setbits32(ctrl, 1 << (24 + idx * 2));
> +			iounmap(ctrl);
> +		}
> +		of_node_put(node_ctrl);
> +	}
> +
> +	/* The clock setup for the 52xx works also fine for the 512x */
> +	mpc_i2c_setup_52xx(node, i2c, clock, prescaler);
> +}
> +#else /* CONFIG_PPC_MPC512x */
> +static void __devinit mpc_i2c_setup_512x(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
>  {
>  }
> -#endif /* CONFIG_PPC_MPC52xx*/
> +#endif /* CONFIG_PPC_MPC512x */
>  
>  #ifdef CONFIG_FSL_SOC
>  static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
> @@ -322,12 +366,19 @@ static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,
>  	return div ? (int)div->fdr : -EINVAL;
>  }
>  
> -static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
> -					    struct mpc_i2c *i2c,
> -					    u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
>  {
>  	int ret, fdr;
>  
> +	if (clock == MPC_I2C_CLOCK_PRESERVE) {
> +		dev_dbg(i2c->dev, "using dfsrr %d, fdr %d\n",
> +			readb(i2c->base + MPC_I2C_DFSRR),
> +			readb(i2c->base + MPC_I2C_FDR));
> +		return;
> +	}
> +
>  	ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
>  	fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */
>  
> @@ -340,9 +391,9 @@ static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
>  }
>  
>  #else /* !CONFIG_FSL_SOC */
> -static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
> -					    struct mpc_i2c *i2c,
> -					    u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
>  {
>  }
>  #endif /* CONFIG_FSL_SOC */
> @@ -496,7 +547,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
>  {
>  	struct mpc_i2c *i2c;
>  	const u32 *prop;
> -	u32 clock = 0;
> +	u32 clock = MPC_I2C_CLOCK_SAFE;
>  	int result = 0;
>  	int plen;
>  
> @@ -525,21 +576,21 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
>  		}
>  	}
>  
> -	if (!of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
> +	if (of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
> +		clock = MPC_I2C_CLOCK_PRESERVE;
> +	} else {
>  		prop = of_get_property(op->node, "clock-frequency", &plen);
>  		if (prop && plen == sizeof(u32))
>  			clock = *prop;
> +	}
>  
> -		if (match->data) {
> -			struct mpc_i2c_data *data =
> -				(struct mpc_i2c_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);
> -		}
> +	if (match->data) {
> +		struct mpc_i2c_data *data = match->data;
> +		data->setup(op->node, i2c, clock, data->prescaler);
> +	} else {
> +		/* Backwards compatibility */
> +		if (of_get_property(op->node, "dfsrr", NULL))
> +			mpc_i2c_setup_8xxx(op->node, i2c, clock, 0);
>  	}
>  
>  	dev_set_drvdata(&op->dev, i2c);
> @@ -584,21 +635,25 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
>  	return 0;
>  };
>  
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_512x = {
> +	.setup = mpc_i2c_setup_512x,
> +};
> +
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
> -	.setclock = mpc_i2c_setclock_52xx,
> +	.setup = mpc_i2c_setup_52xx,
>  };
>  
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
> -	.setclock = mpc_i2c_setclock_8xxx,
> +	.setup = mpc_i2c_setup_8xxx,
>  };
>  
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
> -	.setclock = mpc_i2c_setclock_8xxx,
> +	.setup = mpc_i2c_setup_8xxx,
>  	.prescaler = 2,
>  };
>  
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
> -	.setclock = mpc_i2c_setclock_8xxx,
> +	.setup = mpc_i2c_setup_8xxx,
>  	.prescaler = 3,
>  };
>  
> @@ -606,6 +661,7 @@ static const struct of_device_id mpc_i2c_of_match[] = {
>  	{.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
>  	{.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
>  	{.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
> +	{.compatible = "fsl,mpc5121-i2c", .data = &mpc_i2c_data_512x, },
>  	{.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
>  	{.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
>  	{.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
> @@ -615,7 +671,6 @@ static const struct of_device_id mpc_i2c_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
>  
> -
>  /* Structure for a device driver */
>  static struct of_platform_driver mpc_i2c_driver = {
>  	.match_table	= mpc_i2c_of_match,
> @@ -648,5 +703,5 @@ 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");
> +		   "MPC824x/85xx/512x/52xx processors");
>  MODULE_LICENSE("GPL");
> -- 
> 1.6.2.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

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

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

* Re: [PATCH v4 2/3] i2c-mpc: add support for the MPC512x processors from Freescale
@ 2010-01-29 16:24             ` Wolfram Sang
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfram Sang @ 2010-01-29 16:24 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Wolfgang Grandegger, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Ben Dooks

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

On Thu, Jan 28, 2010 at 02:25:40PM +0100, Wolfgang Grandegger wrote:
> From: Wolfgang Grandegger <wg@denx.de>
> 
> The "setclock" initialization functions have been renamed to "setup"
> because I2C interrupts must be enabled for the MPC512x. This requires
> to handle "fsl,preserve-clocking" in a slighly different way. Also,
> the old settings are now reported calling dev_dbg(). For the MPC512x
> the clock setup function of the MPC52xx can be re-used. Furthermore,
> the Kconfig help has been updated and corrected.
> 
> Signed-off-by: Wolfgang Grandegger <wg@denx.de>

One minor thing and you can add my

Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>

> ---
>  drivers/i2c/busses/Kconfig   |    7 +-
>  drivers/i2c/busses/i2c-mpc.c |  127 ++++++++++++++++++++++++++++++------------
>  2 files changed, 94 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 5f318ce..5477e41 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -418,13 +418,12 @@ config I2C_IXP2000
>  	  instead.
>  
>  config I2C_MPC
> -	tristate "MPC107/824x/85xx/52xx/86xx"
> +	tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx"
>  	depends on PPC32
>  	help
>  	  If you say yes to this option, support will be included for the
> -	  built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
> -	  MPC85xx/MPC8641 family processors. The driver may also work on 52xx
> -	  family processors, though interrupts are known not to work.
> +	  built-in I2C interface on the MPC107, Tsi107, MPC512x, MPC52xx,
> +	  MPC8240, MPC8245, MPC83xx, MPC85xx and MPC8641 family processors.
>  
>  	  This driver can also be built as a module.  If so, the module
>  	  will be called i2c-mpc.
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 275ebe6..1af0730 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -31,6 +31,9 @@
>  
>  #define DRV_NAME "mpc-i2c"
>  
> +#define MPC_I2C_CLOCK_SAFE     0

For clarity, I think this define should also be used when checking for the
condition (instead of using !clock).

> +#define MPC_I2C_CLOCK_PRESERVE (~0U)
> +
>  #define MPC_I2C_FDR   0x04
>  #define MPC_I2C_CR    0x08
>  #define MPC_I2C_SR    0x0c
> @@ -67,9 +70,8 @@ struct mpc_i2c_divider {
>  };
>  
>  struct mpc_i2c_data {
> -	void (*setclock)(struct device_node *node,
> -			 struct mpc_i2c *i2c,
> -			 u32 clock, u32 prescaler);
> +	void (*setup)(struct device_node *node, struct mpc_i2c *i2c,
> +		      u32 clock, u32 prescaler);
>  	u32 prescaler;
>  };
>  
> @@ -164,7 +166,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PPC_MPC52xx
> +#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x)
>  static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
>  	{20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
>  	{28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
> @@ -216,12 +218,18 @@ static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock,
>  	return div ? (int)div->fdr : -EINVAL;
>  }
>  
> -static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
> -					    struct mpc_i2c *i2c,
> -					    u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
>  {
>  	int ret, fdr;
>  
> +	if (clock == MPC_I2C_CLOCK_PRESERVE) {
> +		dev_dbg(i2c->dev, "using fdr %d\n",
> +			readb(i2c->base + MPC_I2C_FDR));
> +		return;
> +	}
> +
>  	ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler);
>  	fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */
>  
> @@ -230,13 +238,49 @@ static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
>  	if (ret >= 0)
>  		dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
>  }
> -#else /* !CONFIG_PPC_MPC52xx */
> -static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
> -					    struct mpc_i2c *i2c,
> -					    u32 clock, u32 prescaler)
> +#else /* !(CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x) */
> +static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
> +{
> +}
> +#endif /* CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x */
> +
> +#ifdef CONFIG_PPC_MPC512x
> +static void __devinit mpc_i2c_setup_512x(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
> +{
> +	struct device_node *node_ctrl;
> +	void __iomem *ctrl;
> +	const u32 *pval;
> +	u32 idx;
> +
> +	/* Enable I2C interrupts for mpc5121 */
> +	node_ctrl = of_find_compatible_node(NULL, NULL,
> +					    "fsl,mpc5121-i2c-ctrl");
> +	if (node_ctrl) {
> +		ctrl = of_iomap(node_ctrl, 0);
> +		if (ctrl) {
> +			/* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */
> +			pval = of_get_property(node, "reg", NULL);
> +			idx = (*pval & 0xff) / 0x20;
> +			setbits32(ctrl, 1 << (24 + idx * 2));
> +			iounmap(ctrl);
> +		}
> +		of_node_put(node_ctrl);
> +	}
> +
> +	/* The clock setup for the 52xx works also fine for the 512x */
> +	mpc_i2c_setup_52xx(node, i2c, clock, prescaler);
> +}
> +#else /* CONFIG_PPC_MPC512x */
> +static void __devinit mpc_i2c_setup_512x(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
>  {
>  }
> -#endif /* CONFIG_PPC_MPC52xx*/
> +#endif /* CONFIG_PPC_MPC512x */
>  
>  #ifdef CONFIG_FSL_SOC
>  static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
> @@ -322,12 +366,19 @@ static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,
>  	return div ? (int)div->fdr : -EINVAL;
>  }
>  
> -static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
> -					    struct mpc_i2c *i2c,
> -					    u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
>  {
>  	int ret, fdr;
>  
> +	if (clock == MPC_I2C_CLOCK_PRESERVE) {
> +		dev_dbg(i2c->dev, "using dfsrr %d, fdr %d\n",
> +			readb(i2c->base + MPC_I2C_DFSRR),
> +			readb(i2c->base + MPC_I2C_FDR));
> +		return;
> +	}
> +
>  	ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
>  	fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */
>  
> @@ -340,9 +391,9 @@ static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
>  }
>  
>  #else /* !CONFIG_FSL_SOC */
> -static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
> -					    struct mpc_i2c *i2c,
> -					    u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
> +					 struct mpc_i2c *i2c,
> +					 u32 clock, u32 prescaler)
>  {
>  }
>  #endif /* CONFIG_FSL_SOC */
> @@ -496,7 +547,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
>  {
>  	struct mpc_i2c *i2c;
>  	const u32 *prop;
> -	u32 clock = 0;
> +	u32 clock = MPC_I2C_CLOCK_SAFE;
>  	int result = 0;
>  	int plen;
>  
> @@ -525,21 +576,21 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
>  		}
>  	}
>  
> -	if (!of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
> +	if (of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
> +		clock = MPC_I2C_CLOCK_PRESERVE;
> +	} else {
>  		prop = of_get_property(op->node, "clock-frequency", &plen);
>  		if (prop && plen == sizeof(u32))
>  			clock = *prop;
> +	}
>  
> -		if (match->data) {
> -			struct mpc_i2c_data *data =
> -				(struct mpc_i2c_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);
> -		}
> +	if (match->data) {
> +		struct mpc_i2c_data *data = match->data;
> +		data->setup(op->node, i2c, clock, data->prescaler);
> +	} else {
> +		/* Backwards compatibility */
> +		if (of_get_property(op->node, "dfsrr", NULL))
> +			mpc_i2c_setup_8xxx(op->node, i2c, clock, 0);
>  	}
>  
>  	dev_set_drvdata(&op->dev, i2c);
> @@ -584,21 +635,25 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
>  	return 0;
>  };
>  
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_512x = {
> +	.setup = mpc_i2c_setup_512x,
> +};
> +
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
> -	.setclock = mpc_i2c_setclock_52xx,
> +	.setup = mpc_i2c_setup_52xx,
>  };
>  
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
> -	.setclock = mpc_i2c_setclock_8xxx,
> +	.setup = mpc_i2c_setup_8xxx,
>  };
>  
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
> -	.setclock = mpc_i2c_setclock_8xxx,
> +	.setup = mpc_i2c_setup_8xxx,
>  	.prescaler = 2,
>  };
>  
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
> -	.setclock = mpc_i2c_setclock_8xxx,
> +	.setup = mpc_i2c_setup_8xxx,
>  	.prescaler = 3,
>  };
>  
> @@ -606,6 +661,7 @@ static const struct of_device_id mpc_i2c_of_match[] = {
>  	{.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
>  	{.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
>  	{.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
> +	{.compatible = "fsl,mpc5121-i2c", .data = &mpc_i2c_data_512x, },
>  	{.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
>  	{.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
>  	{.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
> @@ -615,7 +671,6 @@ static const struct of_device_id mpc_i2c_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
>  
> -
>  /* Structure for a device driver */
>  static struct of_platform_driver mpc_i2c_driver = {
>  	.match_table	= mpc_i2c_of_match,
> @@ -648,5 +703,5 @@ 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");
> +		   "MPC824x/85xx/512x/52xx processors");
>  MODULE_LICENSE("GPL");
> -- 
> 1.6.2.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

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

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
  2010-01-28 13:25             ` Wolfgang Grandegger
@ 2010-01-29 16:26                 ` Wolfram Sang
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfram Sang @ 2010-01-29 16:26 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, Wolfgang Grandegger,
	Ben Dooks

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

On Thu, Jan 28, 2010 at 02:25:41PM +0100, Wolfgang Grandegger wrote:
> From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
> 
> This patch adds the MPC5121 to the list of supported devices,
> enhances the doc of the "clock-frequency" property and removes
> the obsolete "cell-index" property from the example nodes.
> Furthermore and example for the MPC5121 has been added.
> 
> Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>

Reviewed-by: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

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

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

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
@ 2010-01-29 16:26                 ` Wolfram Sang
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfram Sang @ 2010-01-29 16:26 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Ben Dooks, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Wolfgang Grandegger

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

On Thu, Jan 28, 2010 at 02:25:41PM +0100, Wolfgang Grandegger wrote:
> From: Wolfgang Grandegger <wg@denx.de>
> 
> This patch adds the MPC5121 to the list of supported devices,
> enhances the doc of the "clock-frequency" property and removes
> the obsolete "cell-index" property from the example nodes.
> Furthermore and example for the MPC5121 has been added.
> 
> Signed-off-by: Wolfgang Grandegger <wg@denx.de>

Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>

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

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

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
  2010-01-28 13:25     ` Wolfgang Grandegger
@ 2010-02-09 17:41         ` Grant Likely
  -1 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-09 17:41 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, Wolfgang Grandegger,
	Ben Dooks

On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
>
> "__devinit[data]" has not yet been used for all initialization functions
> and data. To avoid truncating lines, the struct "mpc_i2c_match_data" has
> been renamed to "mpc_i2c_data", which is even the better name.
>
> Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>

Several comments below.

> ---
>  drivers/i2c/busses/i2c-mpc.c |  103 +++++++++++++++++++----------------------
>  1 files changed, 48 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index f627001..275ebe6 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -66,7 +66,7 @@ struct mpc_i2c_divider {
>        u16 fdr;        /* including dfsrr */
>  };
>
> -struct mpc_i2c_match_data {
> +struct mpc_i2c_data {
>        void (*setclock)(struct device_node *node,
>                         struct mpc_i2c *i2c,
>                         u32 clock, u32 prescaler);
> @@ -165,7 +165,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
>  }
>
>  #ifdef CONFIG_PPC_MPC52xx
> -static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
> +static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52xx[] = {

__devinitdata goes at the end, immediately before the '='.  Ditto
throughout the file.

>        {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
>        {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
>        {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
> @@ -582,44 +584,35 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
>        return 0;
>  };
>
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
> +       .setclock = mpc_i2c_setclock_52xx,
> +};
> +
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
> +       .setclock = mpc_i2c_setclock_8xxx,
> +};
> +
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
> +       .setclock = mpc_i2c_setclock_8xxx,
> +       .prescaler = 2,
> +};
> +
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
> +       .setclock = mpc_i2c_setclock_8xxx,
> +       .prescaler = 3,
> +};
> +
>  static const struct of_device_id mpc_i2c_of_match[] = {

You can make this __devinitdata too.

> -       {.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,
> -               },
> +       {.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
> +       {.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
> +       {.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
> +       {.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
> +       {.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
> +       {.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
>        /* Backward compatibility */
> -       },
>        {.compatible = "fsl-i2c", },
>        {},
>  };
> -
>  MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
>
>
> @@ -634,7 +627,7 @@ static struct of_platform_driver mpc_i2c_driver = {
>        },
>  };
>
> -static int __init fsl_i2c_init(void)
> +static int __devinit fsl_i2c_init(void)

No, __init was correct.  This is called as a module_init() not as a .probe hook.

>  {
>        int rv;
>
> @@ -645,7 +638,7 @@ static int __init fsl_i2c_init(void)
>        return rv;
>  }
>
> -static void __exit fsl_i2c_exit(void)
> +static void __devexit fsl_i2c_exit(void)

Same here for __exit.

>  {
>        of_unregister_platform_driver(&mpc_i2c_driver);
>  }
> --
> 1.6.2.5
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>



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

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
@ 2010-02-09 17:41         ` Grant Likely
  0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-09 17:41 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Ben Dooks, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Wolfgang Grandegger

On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg@grandegger.com> wr=
ote:
> From: Wolfgang Grandegger <wg@denx.de>
>
> "__devinit[data]" has not yet been used for all initialization functions
> and data. To avoid truncating lines, the struct "mpc_i2c_match_data" has
> been renamed to "mpc_i2c_data", which is even the better name.
>
> Signed-off-by: Wolfgang Grandegger <wg@denx.de>

Several comments below.

> ---
> =A0drivers/i2c/busses/i2c-mpc.c | =A0103 +++++++++++++++++++-------------=
---------
> =A01 files changed, 48 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index f627001..275ebe6 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -66,7 +66,7 @@ struct mpc_i2c_divider {
> =A0 =A0 =A0 =A0u16 fdr; =A0 =A0 =A0 =A0/* including dfsrr */
> =A0};
>
> -struct mpc_i2c_match_data {
> +struct mpc_i2c_data {
> =A0 =A0 =A0 =A0void (*setclock)(struct device_node *node,
> =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 u32 clock, u32 prescaler)=
;
> @@ -165,7 +165,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned tim=
eout, int writing)
> =A0}
>
> =A0#ifdef CONFIG_PPC_MPC52xx
> -static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] =3D {
> +static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52xx[=
] =3D {

__devinitdata goes at the end, immediately before the '=3D'.  Ditto
throughout the file.

> =A0 =A0 =A0 =A0{20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
> =A0 =A0 =A0 =A0{28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
> =A0 =A0 =A0 =A0{36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
> @@ -582,44 +584,35 @@ static int __devexit fsl_i2c_remove(struct of_devic=
e *op)
> =A0 =A0 =A0 =A0return 0;
> =A0};
>
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx =3D {
> + =A0 =A0 =A0 .setclock =3D mpc_i2c_setclock_52xx,
> +};
> +
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 =3D {
> + =A0 =A0 =A0 .setclock =3D mpc_i2c_setclock_8xxx,
> +};
> +
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 =3D {
> + =A0 =A0 =A0 .setclock =3D mpc_i2c_setclock_8xxx,
> + =A0 =A0 =A0 .prescaler =3D 2,
> +};
> +
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 =3D {
> + =A0 =A0 =A0 .setclock =3D mpc_i2c_setclock_8xxx,
> + =A0 =A0 =A0 .prescaler =3D 3,
> +};
> +
> =A0static const struct of_device_id mpc_i2c_of_match[] =3D {

You can make this __devinitdata too.

> - =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 {.compatible =3D "mpc5200-i2c", .data =3D &mpc_i2c_data_52x=
x, },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc5200b-i2c", .data =3D &mpc_i2c_dat=
a_52xx, },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc5200-i2c", .data =3D &mpc_i2c_data=
_52xx, },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc8313-i2c", .data =3D &mpc_i2c_data=
_8313, },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc8543-i2c", .data =3D &mpc_i2c_data=
_8543, },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc8544-i2c", .data =3D &mpc_i2c_data=
_8544, },
> =A0 =A0 =A0 =A0/* Backward compatibility */
> - =A0 =A0 =A0 },
> =A0 =A0 =A0 =A0{.compatible =3D "fsl-i2c", },
> =A0 =A0 =A0 =A0{},
> =A0};
> -
> =A0MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
>
>
> @@ -634,7 +627,7 @@ static struct of_platform_driver mpc_i2c_driver =3D {
> =A0 =A0 =A0 =A0},
> =A0};
>
> -static int __init fsl_i2c_init(void)
> +static int __devinit fsl_i2c_init(void)

No, __init was correct.  This is called as a module_init() not as a .probe =
hook.

> =A0{
> =A0 =A0 =A0 =A0int rv;
>
> @@ -645,7 +638,7 @@ static int __init fsl_i2c_init(void)
> =A0 =A0 =A0 =A0return rv;
> =A0}
>
> -static void __exit fsl_i2c_exit(void)
> +static void __devexit fsl_i2c_exit(void)

Same here for __exit.

> =A0{
> =A0 =A0 =A0 =A0of_unregister_platform_driver(&mpc_i2c_driver);
> =A0}
> --
> 1.6.2.5
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>



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

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

* Re: [PATCH v4 2/3] i2c-mpc: add support for the MPC512x processors from Freescale
  2010-01-28 13:25         ` Wolfgang Grandegger
@ 2010-02-09 17:45             ` Grant Likely
  -1 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-09 17:45 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, Wolfgang Grandegger,
	Ben Dooks

On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
>
> The "setclock" initialization functions have been renamed to "setup"
> because I2C interrupts must be enabled for the MPC512x. This requires
> to handle "fsl,preserve-clocking" in a slighly different way. Also,
> the old settings are now reported calling dev_dbg(). For the MPC512x
> the clock setup function of the MPC52xx can be re-used. Furthermore,
> the Kconfig help has been updated and corrected.

Please split the rename portion into a separate patch.

Otherwise this looks pretty okay.
g.

>
> Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
> ---
>  drivers/i2c/busses/Kconfig   |    7 +-
>  drivers/i2c/busses/i2c-mpc.c |  127 ++++++++++++++++++++++++++++++------------
>  2 files changed, 94 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 5f318ce..5477e41 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -418,13 +418,12 @@ config I2C_IXP2000
>          instead.
>
>  config I2C_MPC
> -       tristate "MPC107/824x/85xx/52xx/86xx"
> +       tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx"
>        depends on PPC32
>        help
>          If you say yes to this option, support will be included for the
> -         built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
> -         MPC85xx/MPC8641 family processors. The driver may also work on 52xx
> -         family processors, though interrupts are known not to work.
> +         built-in I2C interface on the MPC107, Tsi107, MPC512x, MPC52xx,
> +         MPC8240, MPC8245, MPC83xx, MPC85xx and MPC8641 family processors.
>
>          This driver can also be built as a module.  If so, the module
>          will be called i2c-mpc.
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 275ebe6..1af0730 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -31,6 +31,9 @@
>
>  #define DRV_NAME "mpc-i2c"
>
> +#define MPC_I2C_CLOCK_SAFE     0
> +#define MPC_I2C_CLOCK_PRESERVE (~0U)
> +
>  #define MPC_I2C_FDR   0x04
>  #define MPC_I2C_CR    0x08
>  #define MPC_I2C_SR    0x0c
> @@ -67,9 +70,8 @@ struct mpc_i2c_divider {
>  };
>
>  struct mpc_i2c_data {
> -       void (*setclock)(struct device_node *node,
> -                        struct mpc_i2c *i2c,
> -                        u32 clock, u32 prescaler);
> +       void (*setup)(struct device_node *node, struct mpc_i2c *i2c,
> +                     u32 clock, u32 prescaler);
>        u32 prescaler;
>  };
>
> @@ -164,7 +166,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
>        return 0;
>  }
>
> -#ifdef CONFIG_PPC_MPC52xx
> +#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x)
>  static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
>        {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
>        {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
> @@ -216,12 +218,18 @@ static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock,
>        return div ? (int)div->fdr : -EINVAL;
>  }
>
> -static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
> -                                           struct mpc_i2c *i2c,
> -                                           u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
> +                                        struct mpc_i2c *i2c,
> +                                        u32 clock, u32 prescaler)
>  {
>        int ret, fdr;
>
> +       if (clock == MPC_I2C_CLOCK_PRESERVE) {
> +               dev_dbg(i2c->dev, "using fdr %d\n",
> +                       readb(i2c->base + MPC_I2C_FDR));
> +               return;
> +       }
> +
>        ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler);
>        fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */
>
> @@ -230,13 +238,49 @@ static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
>        if (ret >= 0)
>                dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
>  }
> -#else /* !CONFIG_PPC_MPC52xx */
> -static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
> -                                           struct mpc_i2c *i2c,
> -                                           u32 clock, u32 prescaler)
> +#else /* !(CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x) */
> +static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
> +                                        struct mpc_i2c *i2c,
> +                                        u32 clock, u32 prescaler)
> +{
> +}
> +#endif /* CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x */
> +
> +#ifdef CONFIG_PPC_MPC512x
> +static void __devinit mpc_i2c_setup_512x(struct device_node *node,
> +                                        struct mpc_i2c *i2c,
> +                                        u32 clock, u32 prescaler)
> +{
> +       struct device_node *node_ctrl;
> +       void __iomem *ctrl;
> +       const u32 *pval;
> +       u32 idx;
> +
> +       /* Enable I2C interrupts for mpc5121 */
> +       node_ctrl = of_find_compatible_node(NULL, NULL,
> +                                           "fsl,mpc5121-i2c-ctrl");
> +       if (node_ctrl) {
> +               ctrl = of_iomap(node_ctrl, 0);
> +               if (ctrl) {
> +                       /* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */
> +                       pval = of_get_property(node, "reg", NULL);
> +                       idx = (*pval & 0xff) / 0x20;
> +                       setbits32(ctrl, 1 << (24 + idx * 2));
> +                       iounmap(ctrl);
> +               }
> +               of_node_put(node_ctrl);
> +       }
> +
> +       /* The clock setup for the 52xx works also fine for the 512x */
> +       mpc_i2c_setup_52xx(node, i2c, clock, prescaler);
> +}
> +#else /* CONFIG_PPC_MPC512x */
> +static void __devinit mpc_i2c_setup_512x(struct device_node *node,
> +                                        struct mpc_i2c *i2c,
> +                                        u32 clock, u32 prescaler)
>  {
>  }
> -#endif /* CONFIG_PPC_MPC52xx*/
> +#endif /* CONFIG_PPC_MPC512x */
>
>  #ifdef CONFIG_FSL_SOC
>  static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
> @@ -322,12 +366,19 @@ static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,
>        return div ? (int)div->fdr : -EINVAL;
>  }
>
> -static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
> -                                           struct mpc_i2c *i2c,
> -                                           u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
> +                                        struct mpc_i2c *i2c,
> +                                        u32 clock, u32 prescaler)
>  {
>        int ret, fdr;
>
> +       if (clock == MPC_I2C_CLOCK_PRESERVE) {
> +               dev_dbg(i2c->dev, "using dfsrr %d, fdr %d\n",
> +                       readb(i2c->base + MPC_I2C_DFSRR),
> +                       readb(i2c->base + MPC_I2C_FDR));
> +               return;
> +       }
> +
>        ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
>        fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */
>
> @@ -340,9 +391,9 @@ static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
>  }
>
>  #else /* !CONFIG_FSL_SOC */
> -static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
> -                                           struct mpc_i2c *i2c,
> -                                           u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
> +                                        struct mpc_i2c *i2c,
> +                                        u32 clock, u32 prescaler)
>  {
>  }
>  #endif /* CONFIG_FSL_SOC */
> @@ -496,7 +547,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
>  {
>        struct mpc_i2c *i2c;
>        const u32 *prop;
> -       u32 clock = 0;
> +       u32 clock = MPC_I2C_CLOCK_SAFE;
>        int result = 0;
>        int plen;
>
> @@ -525,21 +576,21 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
>                }
>        }
>
> -       if (!of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
> +       if (of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
> +               clock = MPC_I2C_CLOCK_PRESERVE;
> +       } else {
>                prop = of_get_property(op->node, "clock-frequency", &plen);
>                if (prop && plen == sizeof(u32))
>                        clock = *prop;
> +       }
>
> -               if (match->data) {
> -                       struct mpc_i2c_data *data =
> -                               (struct mpc_i2c_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);
> -               }
> +       if (match->data) {
> +               struct mpc_i2c_data *data = match->data;
> +               data->setup(op->node, i2c, clock, data->prescaler);
> +       } else {
> +               /* Backwards compatibility */
> +               if (of_get_property(op->node, "dfsrr", NULL))
> +                       mpc_i2c_setup_8xxx(op->node, i2c, clock, 0);
>        }
>
>        dev_set_drvdata(&op->dev, i2c);
> @@ -584,21 +635,25 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
>        return 0;
>  };
>
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_512x = {
> +       .setup = mpc_i2c_setup_512x,
> +};
> +
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
> -       .setclock = mpc_i2c_setclock_52xx,
> +       .setup = mpc_i2c_setup_52xx,
>  };
>
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
> -       .setclock = mpc_i2c_setclock_8xxx,
> +       .setup = mpc_i2c_setup_8xxx,
>  };
>
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
> -       .setclock = mpc_i2c_setclock_8xxx,
> +       .setup = mpc_i2c_setup_8xxx,
>        .prescaler = 2,
>  };
>
>  static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
> -       .setclock = mpc_i2c_setclock_8xxx,
> +       .setup = mpc_i2c_setup_8xxx,
>        .prescaler = 3,
>  };
>
> @@ -606,6 +661,7 @@ static const struct of_device_id mpc_i2c_of_match[] = {
>        {.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
>        {.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
>        {.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
> +       {.compatible = "fsl,mpc5121-i2c", .data = &mpc_i2c_data_512x, },
>        {.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
>        {.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
>        {.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
> @@ -615,7 +671,6 @@ static const struct of_device_id mpc_i2c_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
>
> -
>  /* Structure for a device driver */
>  static struct of_platform_driver mpc_i2c_driver = {
>        .match_table    = mpc_i2c_of_match,
> @@ -648,5 +703,5 @@ 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");
> +                  "MPC824x/85xx/512x/52xx processors");
>  MODULE_LICENSE("GPL");
> --
> 1.6.2.5
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
>



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

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

* Re: [PATCH v4 2/3] i2c-mpc: add support for the MPC512x processors from Freescale
@ 2010-02-09 17:45             ` Grant Likely
  0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-09 17:45 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Ben Dooks, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Wolfgang Grandegger

On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg@grandegger.com> wr=
ote:
> From: Wolfgang Grandegger <wg@denx.de>
>
> The "setclock" initialization functions have been renamed to "setup"
> because I2C interrupts must be enabled for the MPC512x. This requires
> to handle "fsl,preserve-clocking" in a slighly different way. Also,
> the old settings are now reported calling dev_dbg(). For the MPC512x
> the clock setup function of the MPC52xx can be re-used. Furthermore,
> the Kconfig help has been updated and corrected.

Please split the rename portion into a separate patch.

Otherwise this looks pretty okay.
g.

>
> Signed-off-by: Wolfgang Grandegger <wg@denx.de>
> ---
> =A0drivers/i2c/busses/Kconfig =A0 | =A0 =A07 +-
> =A0drivers/i2c/busses/i2c-mpc.c | =A0127 ++++++++++++++++++++++++++++++--=
----------
> =A02 files changed, 94 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 5f318ce..5477e41 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -418,13 +418,12 @@ config I2C_IXP2000
> =A0 =A0 =A0 =A0 =A0instead.
>
> =A0config I2C_MPC
> - =A0 =A0 =A0 tristate "MPC107/824x/85xx/52xx/86xx"
> + =A0 =A0 =A0 tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx"
> =A0 =A0 =A0 =A0depends on PPC32
> =A0 =A0 =A0 =A0help
> =A0 =A0 =A0 =A0 =A0If you say yes to this option, support will be include=
d for the
> - =A0 =A0 =A0 =A0 built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC=
8245 and
> - =A0 =A0 =A0 =A0 MPC85xx/MPC8641 family processors. The driver may also =
work on 52xx
> - =A0 =A0 =A0 =A0 family processors, though interrupts are known not to w=
ork.
> + =A0 =A0 =A0 =A0 built-in I2C interface on the MPC107, Tsi107, MPC512x, =
MPC52xx,
> + =A0 =A0 =A0 =A0 MPC8240, MPC8245, MPC83xx, MPC85xx and MPC8641 family p=
rocessors.
>
> =A0 =A0 =A0 =A0 =A0This driver can also be built as a module. =A0If so, t=
he module
> =A0 =A0 =A0 =A0 =A0will be called i2c-mpc.
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 275ebe6..1af0730 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -31,6 +31,9 @@
>
> =A0#define DRV_NAME "mpc-i2c"
>
> +#define MPC_I2C_CLOCK_SAFE =A0 =A0 0
> +#define MPC_I2C_CLOCK_PRESERVE (~0U)
> +
> =A0#define MPC_I2C_FDR =A0 0x04
> =A0#define MPC_I2C_CR =A0 =A00x08
> =A0#define MPC_I2C_SR =A0 =A00x0c
> @@ -67,9 +70,8 @@ struct mpc_i2c_divider {
> =A0};
>
> =A0struct mpc_i2c_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 void (*setup)(struct device_node *node, struct mpc_i2c *i2c=
,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 u32 clock, u32 prescaler);
> =A0 =A0 =A0 =A0u32 prescaler;
> =A0};
>
> @@ -164,7 +166,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned tim=
eout, int writing)
> =A0 =A0 =A0 =A0return 0;
> =A0}
>
> -#ifdef CONFIG_PPC_MPC52xx
> +#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x)
> =A0static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52x=
x[] =3D {
> =A0 =A0 =A0 =A0{20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
> =A0 =A0 =A0 =A0{28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
> @@ -216,12 +218,18 @@ static int __devinit mpc_i2c_get_fdr_52xx(struct de=
vice_node *node, u32 clock,
> =A0 =A0 =A0 =A0return div ? (int)div->fdr : -EINVAL;
> =A0}
>
> -static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
> - =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0=
 =A0 =A0 =A0 u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0u32 clock, u32 prescaler)
> =A0{
> =A0 =A0 =A0 =A0int ret, fdr;
>
> + =A0 =A0 =A0 if (clock =3D=3D MPC_I2C_CLOCK_PRESERVE) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c->dev, "using fdr %d\n",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 readb(i2c->base + MPC_I2C_F=
DR));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
> + =A0 =A0 =A0 }
> +
> =A0 =A0 =A0 =A0ret =3D mpc_i2c_get_fdr_52xx(node, clock, prescaler);
> =A0 =A0 =A0 =A0fdr =3D (ret >=3D 0) ? ret : 0x3f; /* backward compatibili=
ty */
>
> @@ -230,13 +238,49 @@ static void __devinit mpc_i2c_setclock_52xx(struct =
device_node *node,
> =A0 =A0 =A0 =A0if (ret >=3D 0)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_info(i2c->dev, "clock %d Hz (fdr=3D%d)=
\n", clock, fdr);
> =A0}
> -#else /* !CONFIG_PPC_MPC52xx */
> -static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
> - =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0=
 =A0 =A0 =A0 u32 clock, u32 prescaler)
> +#else /* !(CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x) */
> +static void __devinit mpc_i2c_setup_52xx(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0u32 clock, u32 prescaler)
> +{
> +}
> +#endif /* CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x */
> +
> +#ifdef CONFIG_PPC_MPC512x
> +static void __devinit mpc_i2c_setup_512x(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0u32 clock, u32 prescaler)
> +{
> + =A0 =A0 =A0 struct device_node *node_ctrl;
> + =A0 =A0 =A0 void __iomem *ctrl;
> + =A0 =A0 =A0 const u32 *pval;
> + =A0 =A0 =A0 u32 idx;
> +
> + =A0 =A0 =A0 /* Enable I2C interrupts for mpc5121 */
> + =A0 =A0 =A0 node_ctrl =3D of_find_compatible_node(NULL, NULL,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 "fsl,mpc5121-i2c-ctrl");
> + =A0 =A0 =A0 if (node_ctrl) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ctrl =3D of_iomap(node_ctrl, 0);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ctrl) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Interrupt enable bits fo=
r i2c-0/1/2: bit 24/26/28 */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pval =3D of_get_property(no=
de, "reg", NULL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 idx =3D (*pval & 0xff) / 0x=
20;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 setbits32(ctrl, 1 << (24 + =
idx * 2));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 iounmap(ctrl);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_node_put(node_ctrl);
> + =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 /* The clock setup for the 52xx works also fine for the 512=
x */
> + =A0 =A0 =A0 mpc_i2c_setup_52xx(node, i2c, clock, prescaler);
> +}
> +#else /* CONFIG_PPC_MPC512x */
> +static void __devinit mpc_i2c_setup_512x(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0u32 clock, u32 prescaler)
> =A0{
> =A0}
> -#endif /* CONFIG_PPC_MPC52xx*/
> +#endif /* CONFIG_PPC_MPC512x */
>
> =A0#ifdef CONFIG_FSL_SOC
> =A0static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_8xx=
x[] =3D {
> @@ -322,12 +366,19 @@ static int __devinit mpc_i2c_get_fdr_8xxx(struct de=
vice_node *node, u32 clock,
> =A0 =A0 =A0 =A0return div ? (int)div->fdr : -EINVAL;
> =A0}
>
> -static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
> - =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0=
 =A0 =A0 =A0 u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0u32 clock, u32 prescaler)
> =A0{
> =A0 =A0 =A0 =A0int ret, fdr;
>
> + =A0 =A0 =A0 if (clock =3D=3D MPC_I2C_CLOCK_PRESERVE) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(i2c->dev, "using dfsrr %d, fdr %d\n=
",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 readb(i2c->base + MPC_I2C_D=
FSRR),
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 readb(i2c->base + MPC_I2C_F=
DR));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
> + =A0 =A0 =A0 }
> +
> =A0 =A0 =A0 =A0ret =3D mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
> =A0 =A0 =A0 =A0fdr =3D (ret >=3D 0) ? ret : 0x1031; /* backward compatibi=
lity */
>
> @@ -340,9 +391,9 @@ static void __devinit mpc_i2c_setclock_8xxx(struct de=
vice_node *node,
> =A0}
>
> =A0#else /* !CONFIG_FSL_SOC */
> -static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
> - =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0=
 =A0 =A0 =A0 u32 clock, u32 prescaler)
> +static void __devinit mpc_i2c_setup_8xxx(struct device_node *node,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =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 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0u32 clock, u32 prescaler)
> =A0{
> =A0}
> =A0#endif /* CONFIG_FSL_SOC */
> @@ -496,7 +547,7 @@ static int __devinit fsl_i2c_probe(struct of_device *=
op,
> =A0{
> =A0 =A0 =A0 =A0struct mpc_i2c *i2c;
> =A0 =A0 =A0 =A0const u32 *prop;
> - =A0 =A0 =A0 u32 clock =3D 0;
> + =A0 =A0 =A0 u32 clock =3D MPC_I2C_CLOCK_SAFE;
> =A0 =A0 =A0 =A0int result =3D 0;
> =A0 =A0 =A0 =A0int plen;
>
> @@ -525,21 +576,21 @@ 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 if (!of_get_property(op->node, "fsl,preserve-clocking", NUL=
L)) {
> + =A0 =A0 =A0 if (of_get_property(op->node, "fsl,preserve-clocking", NULL=
)) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 clock =3D MPC_I2C_CLOCK_PRESERVE;
> + =A0 =A0 =A0 } else {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0prop =3D of_get_property(op->node, "clock-=
frequency", &plen);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (prop && plen =3D=3D sizeof(u32))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clock =3D *prop;
> + =A0 =A0 =A0 }
>
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (match->data) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct mpc_i2c_data *data =
=3D
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (struct mpc=
_i2c_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 if (match->data) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct mpc_i2c_data *data =3D match->data;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 data->setup(op->node, i2c, clock, data->pre=
scaler);
> + =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Backwards compatibility */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (of_get_property(op->node, "dfsrr", NULL=
))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mpc_i2c_setup_8xxx(op->node=
, i2c, clock, 0);
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0dev_set_drvdata(&op->dev, i2c);
> @@ -584,21 +635,25 @@ static int __devexit fsl_i2c_remove(struct of_devic=
e *op)
> =A0 =A0 =A0 =A0return 0;
> =A0};
>
> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_512x =3D {
> + =A0 =A0 =A0 .setup =3D mpc_i2c_setup_512x,
> +};
> +
> =A0static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx =3D {
> - =A0 =A0 =A0 .setclock =3D mpc_i2c_setclock_52xx,
> + =A0 =A0 =A0 .setup =3D mpc_i2c_setup_52xx,
> =A0};
>
> =A0static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 =3D {
> - =A0 =A0 =A0 .setclock =3D mpc_i2c_setclock_8xxx,
> + =A0 =A0 =A0 .setup =3D mpc_i2c_setup_8xxx,
> =A0};
>
> =A0static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 =3D {
> - =A0 =A0 =A0 .setclock =3D mpc_i2c_setclock_8xxx,
> + =A0 =A0 =A0 .setup =3D mpc_i2c_setup_8xxx,
> =A0 =A0 =A0 =A0.prescaler =3D 2,
> =A0};
>
> =A0static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 =3D {
> - =A0 =A0 =A0 .setclock =3D mpc_i2c_setclock_8xxx,
> + =A0 =A0 =A0 .setup =3D mpc_i2c_setup_8xxx,
> =A0 =A0 =A0 =A0.prescaler =3D 3,
> =A0};
>
> @@ -606,6 +661,7 @@ static const struct of_device_id mpc_i2c_of_match[] =
=3D {
> =A0 =A0 =A0 =A0{.compatible =3D "mpc5200-i2c", .data =3D &mpc_i2c_data_52=
xx, },
> =A0 =A0 =A0 =A0{.compatible =3D "fsl,mpc5200b-i2c", .data =3D &mpc_i2c_da=
ta_52xx, },
> =A0 =A0 =A0 =A0{.compatible =3D "fsl,mpc5200-i2c", .data =3D &mpc_i2c_dat=
a_52xx, },
> + =A0 =A0 =A0 {.compatible =3D "fsl,mpc5121-i2c", .data =3D &mpc_i2c_data=
_512x, },
> =A0 =A0 =A0 =A0{.compatible =3D "fsl,mpc8313-i2c", .data =3D &mpc_i2c_dat=
a_8313, },
> =A0 =A0 =A0 =A0{.compatible =3D "fsl,mpc8543-i2c", .data =3D &mpc_i2c_dat=
a_8543, },
> =A0 =A0 =A0 =A0{.compatible =3D "fsl,mpc8544-i2c", .data =3D &mpc_i2c_dat=
a_8544, },
> @@ -615,7 +671,6 @@ static const struct of_device_id mpc_i2c_of_match[] =
=3D {
> =A0};
> =A0MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
>
> -
> =A0/* Structure for a device driver */
> =A0static struct of_platform_driver mpc_i2c_driver =3D {
> =A0 =A0 =A0 =A0.match_table =A0 =A0=3D mpc_i2c_of_match,
> @@ -648,5 +703,5 @@ module_exit(fsl_i2c_exit);
>
> =A0MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
> =A0MODULE_DESCRIPTION("I2C-Bus adapter for MPC107 bridge and "
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"MPC824x/85xx/52xx processors");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"MPC824x/85xx/512x/52xx processors")=
;
> =A0MODULE_LICENSE("GPL");
> --
> 1.6.2.5
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
>



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

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
  2010-01-28 13:25             ` Wolfgang Grandegger
@ 2010-02-09 17:50                 ` Grant Likely
  -1 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-09 17:50 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, Wolfgang Grandegger,
	Ben Dooks

On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
>
> This patch adds the MPC5121 to the list of supported devices,
> enhances the doc of the "clock-frequency" property and removes
> the obsolete "cell-index" property from the example nodes.
> Furthermore and example for the MPC5121 has been added.
>
> Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>

Thanks Wolfgang.  Comments below.

> ---
>  Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++++++++++++++++++----
>  1 files changed, 24 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
> index b6d2e21..2f62dae 100644
> --- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
> +++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
> @@ -9,8 +9,9 @@ Recommended properties :
>
>  - 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".
> +   e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. The
> +   second one should be "fsl-i2c". For the mpc5121, an additional node
> +   "fsl,mpc5121-i2c-ctrl" is required as shown in the example below.

While you're editing this line; drop the requirement for the second
value to be 'fsl-i2c'.  We don't use it anymore, and only preserve it
for backwards compatibility with old trees.

>  - 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
> @@ -20,29 +21,46 @@ Recommended properties :
>    services interrupts for this device.
>  - 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.
> + - clock-frequency : desired I2C bus clock frequency in Hz.  If this
> +   property and "fsl,preserve-clocking" is not defined, a safe fixed
> +   clock divider value is used (resulting in a small clock frequency).

Nah, leave this as is.  Don't make it sound like omitting both
properties is a valid option.  The driver may (and should!) handle the
situation gracefully, but that fact does not need to be documented.

>
>  Examples :
>
> +       /* MPC5121 based board */
> +       i2c@1740 {
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +               compatible = "fsl,mpc5121-i2c", "fsl-i2c";
> +               reg = <0x1740 0x20>;
> +               interrupts = <11 0x8>;
> +               interrupt-parent = <&ipic>;
> +               clock-frequency = <100000>;
> +       };
> +
> +       i2ccontrol@1760 {
> +               compatible = "fsl,mpc5121-i2c-ctrl";
> +               reg = <0x1760 0x8>;
> +       };
> +
> +       /* MPC5200B based board */
>        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;
>        };
>
> +       /* MPC8544 base board */
>        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>;
>        };
> -
> --
> 1.6.2.5
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
>



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

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
@ 2010-02-09 17:50                 ` Grant Likely
  0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-09 17:50 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Ben Dooks, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Wolfgang Grandegger

On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg@grandegger.com> wr=
ote:
> From: Wolfgang Grandegger <wg@denx.de>
>
> This patch adds the MPC5121 to the list of supported devices,
> enhances the doc of the "clock-frequency" property and removes
> the obsolete "cell-index" property from the example nodes.
> Furthermore and example for the MPC5121 has been added.
>
> Signed-off-by: Wolfgang Grandegger <wg@denx.de>

Thanks Wolfgang.  Comments below.

> ---
> =A0Documentation/powerpc/dts-bindings/fsl/i2c.txt | =A0 30 ++++++++++++++=
+++++----
> =A01 files changed, 24 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentati=
on/powerpc/dts-bindings/fsl/i2c.txt
> index b6d2e21..2f62dae 100644
> --- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
> +++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
> @@ -9,8 +9,9 @@ Recommended properties :
>
> =A0- compatible : compatibility list with 2 entries, the first should
> =A0 =A0be "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 e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. The
> + =A0 second one should be "fsl-i2c". For the mpc5121, an additional node
> + =A0 "fsl,mpc5121-i2c-ctrl" is required as shown in the example below.

While you're editing this line; drop the requirement for the second
value to be 'fsl-i2c'.  We don't use it anymore, and only preserve it
for backwards compatibility with old trees.

> =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
> @@ -20,29 +21,46 @@ Recommended properties :
> =A0 =A0services interrupts for this device.
> =A0- fsl,preserve-clocking : boolean; if defined, the clock settings
> =A0 =A0from the bootloader are preserved (not touched).
> - - clock-frequency : desired I2C bus clock frequency in Hz.
> + - clock-frequency : desired I2C bus clock frequency in Hz. =A0If this
> + =A0 property and "fsl,preserve-clocking" is not defined, a safe fixed
> + =A0 clock divider value is used (resulting in a small clock frequency).

Nah, leave this as is.  Don't make it sound like omitting both
properties is a valid option.  The driver may (and should!) handle the
situation gracefully, but that fact does not need to be documented.

>
> =A0Examples :
>
> + =A0 =A0 =A0 /* MPC5121 based board */
> + =A0 =A0 =A0 i2c@1740 {
> + =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,mpc5121-i2c", "fsl-i2c"=
;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x1740 0x20>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupts =3D <11 0x8>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupt-parent =3D <&ipic>;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 clock-frequency =3D <100000>;
> + =A0 =A0 =A0 };
> +
> + =A0 =A0 =A0 i2ccontrol@1760 {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc5121-i2c-ctrl";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x1760 0x8>;
> + =A0 =A0 =A0 };
> +
> + =A0 =A0 =A0 /* MPC5200B based board */
> =A0 =A0 =A0 =A0i2c@3d00 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#address-cells =3D <1>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#size-cells =3D <0>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compatible =3D "fsl,mpc5200b-i2c","fsl,mpc=
5200-i2c","fsl-i2c";
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 cell-index =3D <0>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0x3d00 0x40>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D <2 15 0>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-parent =3D <&mpc5200_pic>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fsl,preserve-clocking;
> =A0 =A0 =A0 =A0};
>
> + =A0 =A0 =A0 /* MPC8544 base board */
> =A0 =A0 =A0 =A0i2c@3100 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#address-cells =3D <1>;
> =A0 =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 =A0compatible =3D "fsl,mpc8544-i2c", "fsl-i2c=
";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reg =3D <0x3100 0x100>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupts =3D <43 2>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0interrupt-parent =3D <&mpic>;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clock-frequency =3D <400000>;
> =A0 =A0 =A0 =A0};
> -
> --
> 1.6.2.5
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
>



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

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
  2010-02-09 17:50                 ` Grant Likely
@ 2010-02-09 18:57                     ` Wolfgang Grandegger
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-09 18:57 UTC (permalink / raw)
  To: Grant Likely
  Cc: Linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, Wolfgang Grandegger,
	Ben Dooks

Hi Grant,

Grant Likely wrote:
> On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>> From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
>>
>> This patch adds the MPC5121 to the list of supported devices,
>> enhances the doc of the "clock-frequency" property and removes
>> the obsolete "cell-index" property from the example nodes.
>> Furthermore and example for the MPC5121 has been added.
>>
>> Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
> 
> Thanks Wolfgang.  Comments below.
> 
>> ---
>>  Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++++++++++++++++++----
>>  1 files changed, 24 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>> index b6d2e21..2f62dae 100644
>> --- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>> +++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>> @@ -9,8 +9,9 @@ Recommended properties :
>>
>>  - 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".
>> +   e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. The
>> +   second one should be "fsl-i2c". For the mpc5121, an additional node
>> +   "fsl,mpc5121-i2c-ctrl" is required as shown in the example below.
> 
> While you're editing this line; drop the requirement for the second
> value to be 'fsl-i2c'.  We don't use it anymore, and only preserve it
> for backwards compatibility with old trees.

OK.

>>  - 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
>> @@ -20,29 +21,46 @@ Recommended properties :
>>    services interrupts for this device.
>>  - 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.
>> + - clock-frequency : desired I2C bus clock frequency in Hz.  If this
>> +   property and "fsl,preserve-clocking" is not defined, a safe fixed
>> +   clock divider value is used (resulting in a small clock frequency).
> 
> Nah, leave this as is.  Don't make it sound like omitting both
> properties is a valid option.  The driver may (and should!) handle the
> situation gracefully, but that fact does not need to be documented.

The safe value is not a good choice, indeed. Then it will also change
MPC_I2C_CLOCK_SAFE to MPC_I2C_CLOCK_LEGACY in i2c-mpc.c.

I will also fix the other issues you commented on.

Thanks,

Wolfgang.

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
@ 2010-02-09 18:57                     ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-09 18:57 UTC (permalink / raw)
  To: Grant Likely
  Cc: Ben Dooks, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Wolfgang Grandegger

Hi Grant,

Grant Likely wrote:
> On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>> From: Wolfgang Grandegger <wg@denx.de>
>>
>> This patch adds the MPC5121 to the list of supported devices,
>> enhances the doc of the "clock-frequency" property and removes
>> the obsolete "cell-index" property from the example nodes.
>> Furthermore and example for the MPC5121 has been added.
>>
>> Signed-off-by: Wolfgang Grandegger <wg@denx.de>
> 
> Thanks Wolfgang.  Comments below.
> 
>> ---
>>  Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++++++++++++++++++----
>>  1 files changed, 24 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>> index b6d2e21..2f62dae 100644
>> --- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>> +++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>> @@ -9,8 +9,9 @@ Recommended properties :
>>
>>  - 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".
>> +   e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. The
>> +   second one should be "fsl-i2c". For the mpc5121, an additional node
>> +   "fsl,mpc5121-i2c-ctrl" is required as shown in the example below.
> 
> While you're editing this line; drop the requirement for the second
> value to be 'fsl-i2c'.  We don't use it anymore, and only preserve it
> for backwards compatibility with old trees.

OK.

>>  - 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
>> @@ -20,29 +21,46 @@ Recommended properties :
>>    services interrupts for this device.
>>  - 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.
>> + - clock-frequency : desired I2C bus clock frequency in Hz.  If this
>> +   property and "fsl,preserve-clocking" is not defined, a safe fixed
>> +   clock divider value is used (resulting in a small clock frequency).
> 
> Nah, leave this as is.  Don't make it sound like omitting both
> properties is a valid option.  The driver may (and should!) handle the
> situation gracefully, but that fact does not need to be documented.

The safe value is not a good choice, indeed. Then it will also change
MPC_I2C_CLOCK_SAFE to MPC_I2C_CLOCK_LEGACY in i2c-mpc.c.

I will also fix the other issues you commented on.

Thanks,

Wolfgang.

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
  2010-02-09 18:57                     ` Wolfgang Grandegger
@ 2010-02-09 19:23                         ` Wolfgang Grandegger
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-09 19:23 UTC (permalink / raw)
  To: Grant Likely
  Cc: Ben Dooks, Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfgang Grandegger

Wolfgang Grandegger wrote:
> Hi Grant,
> 
> Grant Likely wrote:
>> On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>>> From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
>>>
>>> This patch adds the MPC5121 to the list of supported devices,
>>> enhances the doc of the "clock-frequency" property and removes
>>> the obsolete "cell-index" property from the example nodes.
>>> Furthermore and example for the MPC5121 has been added.
>>>
>>> Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
>> Thanks Wolfgang.  Comments below.
>>
>>> ---
>>>  Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++++++++++++++++++----
>>>  1 files changed, 24 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>> index b6d2e21..2f62dae 100644
>>> --- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>> +++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>> @@ -9,8 +9,9 @@ Recommended properties :
>>>
>>>  - 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".
>>> +   e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. The
>>> +   second one should be "fsl-i2c". For the mpc5121, an additional node
>>> +   "fsl,mpc5121-i2c-ctrl" is required as shown in the example below.
>> While you're editing this line; drop the requirement for the second
>> value to be 'fsl-i2c'.  We don't use it anymore, and only preserve it
>> for backwards compatibility with old trees.
> 
> OK.
> 
>>>  - 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
>>> @@ -20,29 +21,46 @@ Recommended properties :
>>>    services interrupts for this device.
>>>  - 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.
>>> + - clock-frequency : desired I2C bus clock frequency in Hz.  If this
>>> +   property and "fsl,preserve-clocking" is not defined, a safe fixed
>>> +   clock divider value is used (resulting in a small clock frequency).
>> Nah, leave this as is.  Don't make it sound like omitting both
>> properties is a valid option.  The driver may (and should!) handle the
>> situation gracefully, but that fact does not need to be documented.
> 
> The safe value is not a good choice, indeed. Then it will also change
> MPC_I2C_CLOCK_SAFE to MPC_I2C_CLOCK_LEGACY in i2c-mpc.c.
> 
> I will also fix the other issues you commented on.

And I will also remove the "device_type" line from:

 -------------
 Required properties :

 - device_type : Should be "i2c"
 - reg : Offset and length of the register set for the device
 -------------

Wolfgang.

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
@ 2010-02-09 19:23                         ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-09 19:23 UTC (permalink / raw)
  To: Grant Likely
  Cc: Wolfgang Grandegger, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Ben Dooks

Wolfgang Grandegger wrote:
> Hi Grant,
> 
> Grant Likely wrote:
>> On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>>> From: Wolfgang Grandegger <wg@denx.de>
>>>
>>> This patch adds the MPC5121 to the list of supported devices,
>>> enhances the doc of the "clock-frequency" property and removes
>>> the obsolete "cell-index" property from the example nodes.
>>> Furthermore and example for the MPC5121 has been added.
>>>
>>> Signed-off-by: Wolfgang Grandegger <wg@denx.de>
>> Thanks Wolfgang.  Comments below.
>>
>>> ---
>>>  Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++++++++++++++++++----
>>>  1 files changed, 24 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>> index b6d2e21..2f62dae 100644
>>> --- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>> +++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>> @@ -9,8 +9,9 @@ Recommended properties :
>>>
>>>  - 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".
>>> +   e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. The
>>> +   second one should be "fsl-i2c". For the mpc5121, an additional node
>>> +   "fsl,mpc5121-i2c-ctrl" is required as shown in the example below.
>> While you're editing this line; drop the requirement for the second
>> value to be 'fsl-i2c'.  We don't use it anymore, and only preserve it
>> for backwards compatibility with old trees.
> 
> OK.
> 
>>>  - 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
>>> @@ -20,29 +21,46 @@ Recommended properties :
>>>    services interrupts for this device.
>>>  - 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.
>>> + - clock-frequency : desired I2C bus clock frequency in Hz.  If this
>>> +   property and "fsl,preserve-clocking" is not defined, a safe fixed
>>> +   clock divider value is used (resulting in a small clock frequency).
>> Nah, leave this as is.  Don't make it sound like omitting both
>> properties is a valid option.  The driver may (and should!) handle the
>> situation gracefully, but that fact does not need to be documented.
> 
> The safe value is not a good choice, indeed. Then it will also change
> MPC_I2C_CLOCK_SAFE to MPC_I2C_CLOCK_LEGACY in i2c-mpc.c.
> 
> I will also fix the other issues you commented on.

And I will also remove the "device_type" line from:

 -------------
 Required properties :

 - device_type : Should be "i2c"
 - reg : Offset and length of the register set for the device
 -------------

Wolfgang.

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
  2010-02-09 19:23                         ` Wolfgang Grandegger
@ 2010-02-09 22:15                             ` Grant Likely
  -1 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-09 22:15 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Ben Dooks, Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfgang Grandegger

On Tue, Feb 9, 2010 at 12:23 PM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> Wolfgang Grandegger wrote:
>> Hi Grant,
>>
>> Grant Likely wrote:
>>> On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>>>> From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
>>>>
>>>> This patch adds the MPC5121 to the list of supported devices,
>>>> enhances the doc of the "clock-frequency" property and removes
>>>> the obsolete "cell-index" property from the example nodes.
>>>> Furthermore and example for the MPC5121 has been added.
>>>>
>>>> Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
>>> Thanks Wolfgang.  Comments below.
>>>
>>>> ---
>>>>  Documentation/powerpc/dts-bindings/fsl/i2c.txt |   30 +++++++++++++++++++----
>>>>  1 files changed, 24 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>>> index b6d2e21..2f62dae 100644
>>>> --- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>>> +++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>>> @@ -9,8 +9,9 @@ Recommended properties :
>>>>
>>>>  - 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".
>>>> +   e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. The
>>>> +   second one should be "fsl-i2c". For the mpc5121, an additional node
>>>> +   "fsl,mpc5121-i2c-ctrl" is required as shown in the example below.
>>> While you're editing this line; drop the requirement for the second
>>> value to be 'fsl-i2c'.  We don't use it anymore, and only preserve it
>>> for backwards compatibility with old trees.
>>
>> OK.
>>
>>>>  - 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
>>>> @@ -20,29 +21,46 @@ Recommended properties :
>>>>    services interrupts for this device.
>>>>  - 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.
>>>> + - clock-frequency : desired I2C bus clock frequency in Hz.  If this
>>>> +   property and "fsl,preserve-clocking" is not defined, a safe fixed
>>>> +   clock divider value is used (resulting in a small clock frequency).
>>> Nah, leave this as is.  Don't make it sound like omitting both
>>> properties is a valid option.  The driver may (and should!) handle the
>>> situation gracefully, but that fact does not need to be documented.
>>
>> The safe value is not a good choice, indeed. Then it will also change
>> MPC_I2C_CLOCK_SAFE to MPC_I2C_CLOCK_LEGACY in i2c-mpc.c.
>>
>> I will also fix the other issues you commented on.
>
> And I will also remove the "device_type" line from:
>
>  -------------
>  Required properties :
>
>  - device_type : Should be "i2c"
>  - reg : Offset and length of the register set for the device

Yes, please.

Hmmm.  compatible should also be in the 'required properties' section.

Thanks,
g.

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

* Re: [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings
@ 2010-02-09 22:15                             ` Grant Likely
  0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-09 22:15 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Wolfgang Grandegger, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Ben Dooks

On Tue, Feb 9, 2010 at 12:23 PM, Wolfgang Grandegger <wg@grandegger.com> wr=
ote:
> Wolfgang Grandegger wrote:
>> Hi Grant,
>>
>> Grant Likely wrote:
>>> On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg@grandegger.com=
> wrote:
>>>> From: Wolfgang Grandegger <wg@denx.de>
>>>>
>>>> This patch adds the MPC5121 to the list of supported devices,
>>>> enhances the doc of the "clock-frequency" property and removes
>>>> the obsolete "cell-index" property from the example nodes.
>>>> Furthermore and example for the MPC5121 has been added.
>>>>
>>>> Signed-off-by: Wolfgang Grandegger <wg@denx.de>
>>> Thanks Wolfgang. =A0Comments below.
>>>
>>>> ---
>>>> =A0Documentation/powerpc/dts-bindings/fsl/i2c.txt | =A0 30 +++++++++++=
++++++++----
>>>> =A01 files changed, 24 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Document=
ation/powerpc/dts-bindings/fsl/i2c.txt
>>>> index b6d2e21..2f62dae 100644
>>>> --- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>>> +++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt
>>>> @@ -9,8 +9,9 @@ Recommended properties :
>>>>
>>>> =A0- compatible : compatibility list with 2 entries, the first should
>>>> =A0 =A0be "fsl,CHIP-i2c" where CHIP is the name of a compatible proces=
sor,
>>>> - =A0 e.g. mpc8313, mpc8543, mpc8544, mpc5200 or mpc5200b. The second =
one
>>>> - =A0 should be "fsl-i2c".
>>>> + =A0 e.g. mpc8313, mpc8543, mpc8544, mpc5121, mpc5200 or mpc5200b. Th=
e
>>>> + =A0 second one should be "fsl-i2c". For the mpc5121, an additional n=
ode
>>>> + =A0 "fsl,mpc5121-i2c-ctrl" is required as shown in the example below=
.
>>> While you're editing this line; drop the requirement for the second
>>> value to be 'fsl-i2c'. =A0We don't use it anymore, and only preserve it
>>> for backwards compatibility with old trees.
>>
>> OK.
>>
>>>> =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
>>>> @@ -20,29 +21,46 @@ Recommended properties :
>>>> =A0 =A0services interrupts for this device.
>>>> =A0- fsl,preserve-clocking : boolean; if defined, the clock settings
>>>> =A0 =A0from the bootloader are preserved (not touched).
>>>> - - clock-frequency : desired I2C bus clock frequency in Hz.
>>>> + - clock-frequency : desired I2C bus clock frequency in Hz. =A0If thi=
s
>>>> + =A0 property and "fsl,preserve-clocking" is not defined, a safe fixe=
d
>>>> + =A0 clock divider value is used (resulting in a small clock frequenc=
y).
>>> Nah, leave this as is. =A0Don't make it sound like omitting both
>>> properties is a valid option. =A0The driver may (and should!) handle th=
e
>>> situation gracefully, but that fact does not need to be documented.
>>
>> The safe value is not a good choice, indeed. Then it will also change
>> MPC_I2C_CLOCK_SAFE to MPC_I2C_CLOCK_LEGACY in i2c-mpc.c.
>>
>> I will also fix the other issues you commented on.
>
> And I will also remove the "device_type" line from:
>
> =A0-------------
> =A0Required properties :
>
> =A0- device_type : Should be "i2c"
> =A0- reg : Offset and length of the register set for the device

Yes, please.

Hmmm.  compatible should also be in the 'required properties' section.

Thanks,
g.

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
  2010-02-09 17:41         ` Grant Likely
@ 2010-02-10 10:09             ` Wolfgang Grandegger
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-10 10:09 UTC (permalink / raw)
  To: Grant Likely
  Cc: Linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, Wolfgang Grandegger,
	Ben Dooks

Grant Likely wrote:
> On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>> From: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
>>
>> "__devinit[data]" has not yet been used for all initialization functions
>> and data. To avoid truncating lines, the struct "mpc_i2c_match_data" has
>> been renamed to "mpc_i2c_data", which is even the better name.
>>
>> Signed-off-by: Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
> 
> Several comments below.
> 
>> ---
>>  drivers/i2c/busses/i2c-mpc.c |  103 +++++++++++++++++++----------------------
>>  1 files changed, 48 insertions(+), 55 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
>> index f627001..275ebe6 100644
>> --- a/drivers/i2c/busses/i2c-mpc.c
>> +++ b/drivers/i2c/busses/i2c-mpc.c
>> @@ -66,7 +66,7 @@ struct mpc_i2c_divider {
>>        u16 fdr;        /* including dfsrr */
>>  };
>>
>> -struct mpc_i2c_match_data {
>> +struct mpc_i2c_data {
>>        void (*setclock)(struct device_node *node,
>>                         struct mpc_i2c *i2c,
>>                         u32 clock, u32 prescaler);
>> @@ -165,7 +165,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
>>  }
>>
>>  #ifdef CONFIG_PPC_MPC52xx
>> -static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
>> +static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
> 
> __devinitdata goes at the end, immediately before the '='.  Ditto
> throughout the file.

This made a difference and revealed section mismatches. "const" seems to
be incompatible with "__devinitdata".

>>        {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
>>        {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
>>        {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
>> @@ -582,44 +584,35 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
>>        return 0;
>>  };
>>
>> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
>> +       .setclock = mpc_i2c_setclock_52xx,
>> +};
>> +
>> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
>> +       .setclock = mpc_i2c_setclock_8xxx,
>> +};
>> +
>> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
>> +       .setclock = mpc_i2c_setclock_8xxx,
>> +       .prescaler = 2,
>> +};
>> +
>> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
>> +       .setclock = mpc_i2c_setclock_8xxx,
>> +       .prescaler = 3,
>> +};
>> +
>>  static const struct of_device_id mpc_i2c_of_match[] = {
> 
> You can make this __devinitdata too.

This results in a section mismatch as it's referenced by fsl_i2c_init().
I just sent out v6. Hope it's OK now.

Thanks,

Wolfgang.

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
@ 2010-02-10 10:09             ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-10 10:09 UTC (permalink / raw)
  To: Grant Likely
  Cc: Ben Dooks, Devicetree-discuss, Linuxppc-dev, Linux-i2c,
	Wolfgang Grandegger

Grant Likely wrote:
> On Thu, Jan 28, 2010 at 6:25 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>> From: Wolfgang Grandegger <wg@denx.de>
>>
>> "__devinit[data]" has not yet been used for all initialization functions
>> and data. To avoid truncating lines, the struct "mpc_i2c_match_data" has
>> been renamed to "mpc_i2c_data", which is even the better name.
>>
>> Signed-off-by: Wolfgang Grandegger <wg@denx.de>
> 
> Several comments below.
> 
>> ---
>>  drivers/i2c/busses/i2c-mpc.c |  103 +++++++++++++++++++----------------------
>>  1 files changed, 48 insertions(+), 55 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
>> index f627001..275ebe6 100644
>> --- a/drivers/i2c/busses/i2c-mpc.c
>> +++ b/drivers/i2c/busses/i2c-mpc.c
>> @@ -66,7 +66,7 @@ struct mpc_i2c_divider {
>>        u16 fdr;        /* including dfsrr */
>>  };
>>
>> -struct mpc_i2c_match_data {
>> +struct mpc_i2c_data {
>>        void (*setclock)(struct device_node *node,
>>                         struct mpc_i2c *i2c,
>>                         u32 clock, u32 prescaler);
>> @@ -165,7 +165,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
>>  }
>>
>>  #ifdef CONFIG_PPC_MPC52xx
>> -static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
>> +static const struct __devinitdata mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
> 
> __devinitdata goes at the end, immediately before the '='.  Ditto
> throughout the file.

This made a difference and revealed section mismatches. "const" seems to
be incompatible with "__devinitdata".

>>        {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
>>        {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
>>        {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
>> @@ -582,44 +584,35 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
>>        return 0;
>>  };
>>
>> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_52xx = {
>> +       .setclock = mpc_i2c_setclock_52xx,
>> +};
>> +
>> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8313 = {
>> +       .setclock = mpc_i2c_setclock_8xxx,
>> +};
>> +
>> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8543 = {
>> +       .setclock = mpc_i2c_setclock_8xxx,
>> +       .prescaler = 2,
>> +};
>> +
>> +static struct mpc_i2c_data __devinitdata mpc_i2c_data_8544 = {
>> +       .setclock = mpc_i2c_setclock_8xxx,
>> +       .prescaler = 3,
>> +};
>> +
>>  static const struct of_device_id mpc_i2c_of_match[] = {
> 
> You can make this __devinitdata too.

This results in a section mismatch as it's referenced by fsl_i2c_init().
I just sent out v6. Hope it's OK now.

Thanks,

Wolfgang.

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
  2010-02-10 10:09             ` Wolfgang Grandegger
@ 2010-02-10 10:32                 ` Stephen Rothwell
  -1 siblings, 0 replies; 36+ messages in thread
From: Stephen Rothwell @ 2010-02-10 10:32 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Grant Likely, Ben Dooks,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfgang Grandegger

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

Hi Wolfgang,

On Wed, 10 Feb 2010 11:09:25 +0100 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>
> > __devinitdata goes at the end, immediately before the '='.  Ditto
> > throughout the file.
> 
> This made a difference and revealed section mismatches. "const" seems to
> be incompatible with "__devinitdata".

Maybe try no "const" and "__devinitconst" (I am not sure if both will
work).

-- 
Cheers,
Stephen Rothwell                    sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org
http://www.canb.auug.org.au/~sfr/

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

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
@ 2010-02-10 10:32                 ` Stephen Rothwell
  0 siblings, 0 replies; 36+ messages in thread
From: Stephen Rothwell @ 2010-02-10 10:32 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Devicetree-discuss, Linux-i2c, Ben Dooks, Linuxppc-dev,
	Wolfgang Grandegger

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

Hi Wolfgang,

On Wed, 10 Feb 2010 11:09:25 +0100 Wolfgang Grandegger <wg@grandegger.com> wrote:
>
> > __devinitdata goes at the end, immediately before the '='.  Ditto
> > throughout the file.
> 
> This made a difference and revealed section mismatches. "const" seems to
> be incompatible with "__devinitdata".

Maybe try no "const" and "__devinitconst" (I am not sure if both will
work).

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

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

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
  2010-02-10 10:32                 ` Stephen Rothwell
@ 2010-02-10 10:53                     ` Wolfgang Grandegger
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-10 10:53 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Grant Likely, Ben Dooks,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfgang Grandegger

Stephen Rothwell wrote:
> Hi Wolfgang,
> 
> On Wed, 10 Feb 2010 11:09:25 +0100 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>>> __devinitdata goes at the end, immediately before the '='.  Ditto
>>> throughout the file.
>> This made a difference and revealed section mismatches. "const" seems to
>> be incompatible with "__devinitdata".
> 
> Maybe try no "const" and "__devinitconst" (I am not sure if both will
> work).

Yes, that works, even together with "const". To avoid rolling out the
whole patch series again, I can prepare a follow-up patch fixing this issue.

Wolfgang.

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
@ 2010-02-10 10:53                     ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-10 10:53 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Devicetree-discuss, Linux-i2c, Ben Dooks, Linuxppc-dev,
	Wolfgang Grandegger

Stephen Rothwell wrote:
> Hi Wolfgang,
> 
> On Wed, 10 Feb 2010 11:09:25 +0100 Wolfgang Grandegger <wg@grandegger.com> wrote:
>>> __devinitdata goes at the end, immediately before the '='.  Ditto
>>> throughout the file.
>> This made a difference and revealed section mismatches. "const" seems to
>> be incompatible with "__devinitdata".
> 
> Maybe try no "const" and "__devinitconst" (I am not sure if both will
> work).

Yes, that works, even together with "const". To avoid rolling out the
whole patch series again, I can prepare a follow-up patch fixing this issue.

Wolfgang.

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
  2010-02-10 10:53                     ` Wolfgang Grandegger
@ 2010-02-10 14:14                         ` Grant Likely
  -1 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-10 14:14 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Stephen Rothwell, Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, Wolfgang Grandegger

On Wed, Feb 10, 2010 at 3:53 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
> Stephen Rothwell wrote:
>> Hi Wolfgang,
>>
>> On Wed, 10 Feb 2010 11:09:25 +0100 Wolfgang Grandegger <wg-5Yr1BZd7O63KJghVJtBX7w@public.gmane.orgm> wrote:
>>>> __devinitdata goes at the end, immediately before the '='.  Ditto
>>>> throughout the file.
>>> This made a difference and revealed section mismatches. "const" seems to
>>> be incompatible with "__devinitdata".
>>
>> Maybe try no "const" and "__devinitconst" (I am not sure if both will
>> work).
>
> Yes, that works, even together with "const". To avoid rolling out the
> whole patch series again, I can prepare a follow-up patch fixing this issue.

Nah, just resend this one patch.

g.

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
@ 2010-02-10 14:14                         ` Grant Likely
  0 siblings, 0 replies; 36+ messages in thread
From: Grant Likely @ 2010-02-10 14:14 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Stephen Rothwell, Devicetree-discuss, Linux-i2c, Ben Dooks,
	Linuxppc-dev, Wolfgang Grandegger

On Wed, Feb 10, 2010 at 3:53 AM, Wolfgang Grandegger <wg@grandegger.com> wr=
ote:
> Stephen Rothwell wrote:
>> Hi Wolfgang,
>>
>> On Wed, 10 Feb 2010 11:09:25 +0100 Wolfgang Grandegger <wg@grandegger.co=
m> wrote:
>>>> __devinitdata goes at the end, immediately before the '=3D'. =A0Ditto
>>>> throughout the file.
>>> This made a difference and revealed section mismatches. "const" seems t=
o
>>> be incompatible with "__devinitdata".
>>
>> Maybe try no "const" and "__devinitconst" (I am not sure if both will
>> work).
>
> Yes, that works, even together with "const". To avoid rolling out the
> whole patch series again, I can prepare a follow-up patch fixing this iss=
ue.

Nah, just resend this one patch.

g.

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
  2010-02-10 14:14                         ` Grant Likely
@ 2010-02-10 14:45                             ` Wolfgang Grandegger
  -1 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-10 14:45 UTC (permalink / raw)
  To: Grant Likely
  Cc: Stephen Rothwell, Ben Dooks,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	Linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfgang Grandegger

Grant Likely wrote:
> On Wed, Feb 10, 2010 at 3:53 AM, Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>> Stephen Rothwell wrote:
>>> Hi Wolfgang,
>>>
>>> On Wed, 10 Feb 2010 11:09:25 +0100 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> wrote:
>>>>> __devinitdata goes at the end, immediately before the '='.  Ditto
>>>>> throughout the file.
>>>> This made a difference and revealed section mismatches. "const" seems to
>>>> be incompatible with "__devinitdata".
>>> Maybe try no "const" and "__devinitconst" (I am not sure if both will
>>> work).
>> Yes, that works, even together with "const". To avoid rolling out the
>> whole patch series again, I can prepare a follow-up patch fixing this issue.
> 
> Nah, just resend this one patch.

Even if it break the following patches? Will resend v7 in a second.

Wolfgang.

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

* Re: [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data
@ 2010-02-10 14:45                             ` Wolfgang Grandegger
  0 siblings, 0 replies; 36+ messages in thread
From: Wolfgang Grandegger @ 2010-02-10 14:45 UTC (permalink / raw)
  To: Grant Likely
  Cc: Stephen Rothwell, Devicetree-discuss, Linux-i2c, Ben Dooks,
	Linuxppc-dev, Wolfgang Grandegger

Grant Likely wrote:
> On Wed, Feb 10, 2010 at 3:53 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>> Stephen Rothwell wrote:
>>> Hi Wolfgang,
>>>
>>> On Wed, 10 Feb 2010 11:09:25 +0100 Wolfgang Grandegger <wg@grandegger.com> wrote:
>>>>> __devinitdata goes at the end, immediately before the '='.  Ditto
>>>>> throughout the file.
>>>> This made a difference and revealed section mismatches. "const" seems to
>>>> be incompatible with "__devinitdata".
>>> Maybe try no "const" and "__devinitconst" (I am not sure if both will
>>> work).
>> Yes, that works, even together with "const". To avoid rolling out the
>> whole patch series again, I can prepare a follow-up patch fixing this issue.
> 
> Nah, just resend this one patch.

Even if it break the following patches? Will resend v7 in a second.

Wolfgang.

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

end of thread, other threads:[~2010-02-10 14:45 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-28 13:25 [PATCH v4 0/3] i2c-mpc: add support for the Freescale MPC512x and other fixes Wolfgang Grandegger
2010-01-28 13:25 ` Wolfgang Grandegger
     [not found] ` <1264685141-26391-1-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-01-28 13:25   ` [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data Wolfgang Grandegger
2010-01-28 13:25     ` Wolfgang Grandegger
2010-01-29 16:15     ` Wolfram Sang
2010-01-29 16:15       ` Wolfram Sang
     [not found]     ` <1264685141-26391-2-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-01-28 13:25       ` [PATCH v4 2/3] i2c-mpc: add support for the MPC512x processors from Freescale Wolfgang Grandegger
2010-01-28 13:25         ` Wolfgang Grandegger
     [not found]         ` <1264685141-26391-3-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-01-28 13:25           ` [PATCH v4 3/3] powerpc: doc/dts-bindings: update doc of FSL I2C bindings Wolfgang Grandegger
2010-01-28 13:25             ` Wolfgang Grandegger
     [not found]             ` <1264685141-26391-4-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-01-29 16:26               ` Wolfram Sang
2010-01-29 16:26                 ` Wolfram Sang
2010-02-09 17:50               ` Grant Likely
2010-02-09 17:50                 ` Grant Likely
     [not found]                 ` <fa686aa41002090950w2c3cd008k47784089dd3417d7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-09 18:57                   ` Wolfgang Grandegger
2010-02-09 18:57                     ` Wolfgang Grandegger
     [not found]                     ` <4B71AFFC.3010301-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-02-09 19:23                       ` Wolfgang Grandegger
2010-02-09 19:23                         ` Wolfgang Grandegger
     [not found]                         ` <4B71B618.6020807-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-02-09 22:15                           ` Grant Likely
2010-02-09 22:15                             ` Grant Likely
2010-01-29 16:24           ` [PATCH v4 2/3] i2c-mpc: add support for the MPC512x processors from Freescale Wolfram Sang
2010-01-29 16:24             ` Wolfram Sang
2010-02-09 17:45           ` Grant Likely
2010-02-09 17:45             ` Grant Likely
2010-02-09 17:41       ` [PATCH v4 1/3] i2c-mpc: use __devinit[data] for initialization functions and data Grant Likely
2010-02-09 17:41         ` Grant Likely
     [not found]         ` <fa686aa41002090941je3e4fdqbecf2616a8b90e42-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-10 10:09           ` Wolfgang Grandegger
2010-02-10 10:09             ` Wolfgang Grandegger
     [not found]             ` <4B7285D5.9060008-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-02-10 10:32               ` Stephen Rothwell
2010-02-10 10:32                 ` Stephen Rothwell
     [not found]                 ` <20100210213203.48a9105e.sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org>
2010-02-10 10:53                   ` Wolfgang Grandegger
2010-02-10 10:53                     ` Wolfgang Grandegger
     [not found]                     ` <4B729043.9080303-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-02-10 14:14                       ` Grant Likely
2010-02-10 14:14                         ` Grant Likely
     [not found]                         ` <fa686aa41002100614l76bff396ved847c0b0a4c71ff-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-10 14:45                           ` Wolfgang Grandegger
2010-02-10 14:45                             ` Wolfgang Grandegger

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.