All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add device tree probe for i2c-imx driver
@ 2011-07-14 16:03 ` Shawn Guo
  0 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-14 16:03 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	patches-QSEj5FYQhm4dnm+yROfE0A

The first patch removes unused init/exit hooks from platform data,
and the second one actually adds the actual device tree probe support.

Shawn Guo (2):
      i2c/imx: remove init/exit hooks from platform data
      i2c/imx: add device tree probe support

 .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 +++++++++++
 arch/arm/plat-mxc/include/mach/i2c.h               |    4 --
 drivers/i2c/busses/i2c-imx.c                       |   46 +++++++++----------
 3 files changed, 47 insertions(+), 28 deletions(-)

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

* [PATCH 0/2] Add device tree probe for i2c-imx driver
@ 2011-07-14 16:03 ` Shawn Guo
  0 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-14 16:03 UTC (permalink / raw)
  To: linux-arm-kernel

The first patch removes unused init/exit hooks from platform data,
and the second one actually adds the actual device tree probe support.

Shawn Guo (2):
      i2c/imx: remove init/exit hooks from platform data
      i2c/imx: add device tree probe support

 .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 +++++++++++
 arch/arm/plat-mxc/include/mach/i2c.h               |    4 --
 drivers/i2c/busses/i2c-imx.c                       |   46 +++++++++----------
 3 files changed, 47 insertions(+), 28 deletions(-)

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

* [PATCH 1/2] i2c/imx: remove init/exit hooks from platform data
  2011-07-14 16:03 ` Shawn Guo
@ 2011-07-14 16:03     ` Shawn Guo
  -1 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-14 16:03 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	patches-QSEj5FYQhm4dnm+yROfE0A, Shawn Guo, Darius Augulis,
	Ben Dooks

The init/exit hooks in platform data are being used nowhere, so can
be removed.

Signed-off-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Darius Augulis <augulis.darius-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
---
 arch/arm/plat-mxc/include/mach/i2c.h |    4 ----
 drivers/i2c/busses/i2c-imx.c         |   21 +++------------------
 2 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/arch/arm/plat-mxc/include/mach/i2c.h b/arch/arm/plat-mxc/include/mach/i2c.h
index 4a5dc5c..375cdd0 100644
--- a/arch/arm/plat-mxc/include/mach/i2c.h
+++ b/arch/arm/plat-mxc/include/mach/i2c.h
@@ -11,14 +11,10 @@
 
 /**
  * struct imxi2c_platform_data - structure of platform data for MXC I2C driver
- * @init:	Initialise gpio's and other board specific things
- * @exit:	Free everything initialised by @init
  * @bitrate:	Bus speed measured in Hz
  *
  **/
 struct imxi2c_platform_data {
-	int (*init)(struct device *dev);
-	void (*exit)(struct device *dev);
 	int bitrate;
 };
 
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 4c2a62b..54d809e 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -466,7 +466,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 {
 	struct imx_i2c_struct *i2c_imx;
 	struct resource *res;
-	struct imxi2c_platform_data *pdata;
+	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
 	void __iomem *base;
 	resource_size_t res_size;
 	int irq;
@@ -485,19 +485,11 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	pdata = pdev->dev.platform_data;
-
-	if (pdata && pdata->init) {
-		ret = pdata->init(&pdev->dev);
-		if (ret)
-			return ret;
-	}
-
 	res_size = resource_size(res);
 
 	if (!request_mem_region(res->start, res_size, DRIVER_NAME)) {
-		ret = -EBUSY;
-		goto fail0;
+		dev_err(&pdev->dev, "request_mem_region failed\n");
+		return -EBUSY;
 	}
 
 	base = ioremap(res->start, res_size);
@@ -586,9 +578,6 @@ fail2:
 	iounmap(base);
 fail1:
 	release_mem_region(res->start, resource_size(res));
-fail0:
-	if (pdata && pdata->exit)
-		pdata->exit(&pdev->dev);
 	return ret; /* Return error number */
 }
 
@@ -611,10 +600,6 @@ static int __exit i2c_imx_remove(struct platform_device *pdev)
 	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
 	writeb(0, i2c_imx->base + IMX_I2C_I2SR);
 
-	/* Shut down hardware */
-	if (pdata && pdata->exit)
-		pdata->exit(&pdev->dev);
-
 	clk_put(i2c_imx->clk);
 
 	iounmap(i2c_imx->base);
-- 
1.7.4.1

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

* [PATCH 1/2] i2c/imx: remove init/exit hooks from platform data
@ 2011-07-14 16:03     ` Shawn Guo
  0 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-14 16:03 UTC (permalink / raw)
  To: linux-arm-kernel

The init/exit hooks in platform data are being used nowhere, so can
be removed.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Darius Augulis <augulis.darius@gmail.com>
Cc: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/plat-mxc/include/mach/i2c.h |    4 ----
 drivers/i2c/busses/i2c-imx.c         |   21 +++------------------
 2 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/arch/arm/plat-mxc/include/mach/i2c.h b/arch/arm/plat-mxc/include/mach/i2c.h
index 4a5dc5c..375cdd0 100644
--- a/arch/arm/plat-mxc/include/mach/i2c.h
+++ b/arch/arm/plat-mxc/include/mach/i2c.h
@@ -11,14 +11,10 @@
 
 /**
  * struct imxi2c_platform_data - structure of platform data for MXC I2C driver
- * @init:	Initialise gpio's and other board specific things
- * @exit:	Free everything initialised by @init
  * @bitrate:	Bus speed measured in Hz
  *
  **/
 struct imxi2c_platform_data {
-	int (*init)(struct device *dev);
-	void (*exit)(struct device *dev);
 	int bitrate;
 };
 
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 4c2a62b..54d809e 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -466,7 +466,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 {
 	struct imx_i2c_struct *i2c_imx;
 	struct resource *res;
-	struct imxi2c_platform_data *pdata;
+	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
 	void __iomem *base;
 	resource_size_t res_size;
 	int irq;
@@ -485,19 +485,11 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	pdata = pdev->dev.platform_data;
-
-	if (pdata && pdata->init) {
-		ret = pdata->init(&pdev->dev);
-		if (ret)
-			return ret;
-	}
-
 	res_size = resource_size(res);
 
 	if (!request_mem_region(res->start, res_size, DRIVER_NAME)) {
-		ret = -EBUSY;
-		goto fail0;
+		dev_err(&pdev->dev, "request_mem_region failed\n");
+		return -EBUSY;
 	}
 
 	base = ioremap(res->start, res_size);
@@ -586,9 +578,6 @@ fail2:
 	iounmap(base);
 fail1:
 	release_mem_region(res->start, resource_size(res));
-fail0:
-	if (pdata && pdata->exit)
-		pdata->exit(&pdev->dev);
 	return ret; /* Return error number */
 }
 
@@ -611,10 +600,6 @@ static int __exit i2c_imx_remove(struct platform_device *pdev)
 	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
 	writeb(0, i2c_imx->base + IMX_I2C_I2SR);
 
-	/* Shut down hardware */
-	if (pdata && pdata->exit)
-		pdata->exit(&pdev->dev);
-
 	clk_put(i2c_imx->clk);
 
 	iounmap(i2c_imx->base);
-- 
1.7.4.1

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

* [PATCH 2/2] i2c/imx: add device tree probe support
  2011-07-14 16:03 ` Shawn Guo
@ 2011-07-14 16:03     ` Shawn Guo
  -1 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-14 16:03 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	patches-QSEj5FYQhm4dnm+yROfE0A, Shawn Guo, Grant Likely,
	Darius Augulis, Ben Dooks

It adds device tree probe support for i2c-imx driver.

Signed-off-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: Darius Augulis <augulis.darius-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
---
 .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 ++++++++++++++++++++
 drivers/i2c/busses/i2c-imx.c                       |   25 +++++++++++++++----
 2 files changed, 44 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt

diff --git a/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt b/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
new file mode 100644
index 0000000..5066cd9
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
@@ -0,0 +1,25 @@
+* Freescale Inter IC (I2C) and High Speed Inter IC (HS-I2C) for i.MX
+
+Required properties:
+- compatible : Should be "fsl,<chip>-i2c"
+- reg : Should contain I2C/HS-I2C registers location and length
+- interrupts : Should contain I2C/HS-I2C interrupt
+
+Optional properties:
+- clock-frequency : Constains desired I2C/HS-I2C bus clock frequency in Hz.
+  The absence of the propoerty indicates the default frequency 100 kHz.
+
+Examples:
+
+i2c@83fc4000 { /* I2C2 on i.MX51 */
+	compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
+	reg = <0x83fc4000 0x4000>;
+	interrupts = <63>;
+};
+
+i2c@70038000 { /* HS-I2C on i.MX51 */
+	compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
+	reg = <0x70038000 0x4000>;
+	interrupts = <63>;
+	clock-frequency = <400000>
+};
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 54d809e..58832e5 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -48,6 +48,9 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_i2c.h>
 
 #include <mach/irqs.h>
 #include <mach/hardware.h>
@@ -125,6 +128,11 @@ struct imx_i2c_struct {
 	unsigned int		ifdr; /* IMX_I2C_IFDR */
 };
 
+static const struct of_device_id i2c_imx_dt_ids[] = {
+	{ .compatible = "fsl,imx1-i2c", },
+	{ /* sentinel */ }
+};
+
 /** Functions for IMX I2C adapter driver ***************************************
 *******************************************************************************/
 
@@ -469,7 +477,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
 	void __iomem *base;
 	resource_size_t res_size;
-	int irq;
+	int irq, bitrate;
 	int ret;
 
 	dev_dbg(&pdev->dev, "<%s>\n", __func__);
@@ -512,6 +520,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 	i2c_imx->adapter.algo		= &i2c_imx_algo;
 	i2c_imx->adapter.dev.parent	= &pdev->dev;
 	i2c_imx->adapter.nr 		= pdev->id;
+	i2c_imx->adapter.dev.of_node	= pdev->dev.of_node;
 	i2c_imx->irq			= irq;
 	i2c_imx->base			= base;
 	i2c_imx->res			= res;
@@ -538,10 +547,12 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 	i2c_set_adapdata(&i2c_imx->adapter, i2c_imx);
 
 	/* Set up clock divider */
-	if (pdata && pdata->bitrate)
-		i2c_imx_set_clk(i2c_imx, pdata->bitrate);
-	else
-		i2c_imx_set_clk(i2c_imx, IMX_I2C_BIT_RATE);
+	bitrate = IMX_I2C_BIT_RATE;
+	ret = of_property_read_u32(pdev->dev.of_node,
+				   "clock-frequency", &bitrate);
+	if (ret < 0 && pdata && pdata->bitrate)
+		bitrate = pdata->bitrate;
+	i2c_imx_set_clk(i2c_imx, bitrate);
 
 	/* Set up chip registers to defaults */
 	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
@@ -554,6 +565,8 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 		goto fail5;
 	}
 
+	of_i2c_register_devices(&i2c_imx->adapter);
+
 	/* Set up platform driver data */
 	platform_set_drvdata(pdev, i2c_imx);
 
@@ -584,7 +597,6 @@ fail1:
 static int __exit i2c_imx_remove(struct platform_device *pdev)
 {
 	struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev);
-	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
 
 	/* remove adapter */
 	dev_dbg(&i2c_imx->adapter.dev, "adapter removed\n");
@@ -613,6 +625,7 @@ static struct platform_driver i2c_imx_driver = {
 	.driver	= {
 		.name	= DRIVER_NAME,
 		.owner	= THIS_MODULE,
+		.of_match_table = i2c_imx_dt_ids,
 	}
 };
 
-- 
1.7.4.1

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

* [PATCH 2/2] i2c/imx: add device tree probe support
@ 2011-07-14 16:03     ` Shawn Guo
  0 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-14 16:03 UTC (permalink / raw)
  To: linux-arm-kernel

It adds device tree probe support for i2c-imx driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Darius Augulis <augulis.darius@gmail.com>
Cc: Ben Dooks <ben-linux@fluff.org>
---
 .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 ++++++++++++++++++++
 drivers/i2c/busses/i2c-imx.c                       |   25 +++++++++++++++----
 2 files changed, 44 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt

diff --git a/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt b/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
new file mode 100644
index 0000000..5066cd9
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
@@ -0,0 +1,25 @@
+* Freescale Inter IC (I2C) and High Speed Inter IC (HS-I2C) for i.MX
+
+Required properties:
+- compatible : Should be "fsl,<chip>-i2c"
+- reg : Should contain I2C/HS-I2C registers location and length
+- interrupts : Should contain I2C/HS-I2C interrupt
+
+Optional properties:
+- clock-frequency : Constains desired I2C/HS-I2C bus clock frequency in Hz.
+  The absence of the propoerty indicates the default frequency 100 kHz.
+
+Examples:
+
+i2c at 83fc4000 { /* I2C2 on i.MX51 */
+	compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
+	reg = <0x83fc4000 0x4000>;
+	interrupts = <63>;
+};
+
+i2c at 70038000 { /* HS-I2C on i.MX51 */
+	compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
+	reg = <0x70038000 0x4000>;
+	interrupts = <63>;
+	clock-frequency = <400000>
+};
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 54d809e..58832e5 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -48,6 +48,9 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_i2c.h>
 
 #include <mach/irqs.h>
 #include <mach/hardware.h>
@@ -125,6 +128,11 @@ struct imx_i2c_struct {
 	unsigned int		ifdr; /* IMX_I2C_IFDR */
 };
 
+static const struct of_device_id i2c_imx_dt_ids[] = {
+	{ .compatible = "fsl,imx1-i2c", },
+	{ /* sentinel */ }
+};
+
 /** Functions for IMX I2C adapter driver ***************************************
 *******************************************************************************/
 
@@ -469,7 +477,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
 	void __iomem *base;
 	resource_size_t res_size;
-	int irq;
+	int irq, bitrate;
 	int ret;
 
 	dev_dbg(&pdev->dev, "<%s>\n", __func__);
@@ -512,6 +520,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 	i2c_imx->adapter.algo		= &i2c_imx_algo;
 	i2c_imx->adapter.dev.parent	= &pdev->dev;
 	i2c_imx->adapter.nr 		= pdev->id;
+	i2c_imx->adapter.dev.of_node	= pdev->dev.of_node;
 	i2c_imx->irq			= irq;
 	i2c_imx->base			= base;
 	i2c_imx->res			= res;
@@ -538,10 +547,12 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 	i2c_set_adapdata(&i2c_imx->adapter, i2c_imx);
 
 	/* Set up clock divider */
-	if (pdata && pdata->bitrate)
-		i2c_imx_set_clk(i2c_imx, pdata->bitrate);
-	else
-		i2c_imx_set_clk(i2c_imx, IMX_I2C_BIT_RATE);
+	bitrate = IMX_I2C_BIT_RATE;
+	ret = of_property_read_u32(pdev->dev.of_node,
+				   "clock-frequency", &bitrate);
+	if (ret < 0 && pdata && pdata->bitrate)
+		bitrate = pdata->bitrate;
+	i2c_imx_set_clk(i2c_imx, bitrate);
 
 	/* Set up chip registers to defaults */
 	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
@@ -554,6 +565,8 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 		goto fail5;
 	}
 
+	of_i2c_register_devices(&i2c_imx->adapter);
+
 	/* Set up platform driver data */
 	platform_set_drvdata(pdev, i2c_imx);
 
@@ -584,7 +597,6 @@ fail1:
 static int __exit i2c_imx_remove(struct platform_device *pdev)
 {
 	struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev);
-	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
 
 	/* remove adapter */
 	dev_dbg(&i2c_imx->adapter.dev, "adapter removed\n");
@@ -613,6 +625,7 @@ static struct platform_driver i2c_imx_driver = {
 	.driver	= {
 		.name	= DRIVER_NAME,
 		.owner	= THIS_MODULE,
+		.of_match_table = i2c_imx_dt_ids,
 	}
 };
 
-- 
1.7.4.1

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

* Re: [PATCH 1/2] i2c/imx: remove init/exit hooks from platform data
  2011-07-14 16:03     ` Shawn Guo
@ 2011-07-15  2:54         ` Grant Likely
  -1 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-07-15  2:54 UTC (permalink / raw)
  To: Shawn Guo
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, patches-QSEj5FYQhm4dnm+yROfE0A,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Ben Dooks,
	Darius Augulis,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Fri, Jul 15, 2011 at 12:03:44AM +0800, Shawn Guo wrote:
> The init/exit hooks in platform data are being used nowhere, so can
> be removed.
> 
> Signed-off-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Cc: Darius Augulis <augulis.darius-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>

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

Yes, I think this is the think to do.  Notifiers provide a generic
mechanism.  There is no need for each driver to open code this
functionality.

g.

> ---
>  arch/arm/plat-mxc/include/mach/i2c.h |    4 ----
>  drivers/i2c/busses/i2c-imx.c         |   21 +++------------------
>  2 files changed, 3 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/plat-mxc/include/mach/i2c.h b/arch/arm/plat-mxc/include/mach/i2c.h
> index 4a5dc5c..375cdd0 100644
> --- a/arch/arm/plat-mxc/include/mach/i2c.h
> +++ b/arch/arm/plat-mxc/include/mach/i2c.h
> @@ -11,14 +11,10 @@
>  
>  /**
>   * struct imxi2c_platform_data - structure of platform data for MXC I2C driver
> - * @init:	Initialise gpio's and other board specific things
> - * @exit:	Free everything initialised by @init
>   * @bitrate:	Bus speed measured in Hz
>   *
>   **/
>  struct imxi2c_platform_data {
> -	int (*init)(struct device *dev);
> -	void (*exit)(struct device *dev);
>  	int bitrate;
>  };
>  
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 4c2a62b..54d809e 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -466,7 +466,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  {
>  	struct imx_i2c_struct *i2c_imx;
>  	struct resource *res;
> -	struct imxi2c_platform_data *pdata;
> +	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
>  	void __iomem *base;
>  	resource_size_t res_size;
>  	int irq;
> @@ -485,19 +485,11 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  		return -ENOENT;
>  	}
>  
> -	pdata = pdev->dev.platform_data;
> -
> -	if (pdata && pdata->init) {
> -		ret = pdata->init(&pdev->dev);
> -		if (ret)
> -			return ret;
> -	}
> -
>  	res_size = resource_size(res);
>  
>  	if (!request_mem_region(res->start, res_size, DRIVER_NAME)) {
> -		ret = -EBUSY;
> -		goto fail0;
> +		dev_err(&pdev->dev, "request_mem_region failed\n");
> +		return -EBUSY;
>  	}
>  
>  	base = ioremap(res->start, res_size);
> @@ -586,9 +578,6 @@ fail2:
>  	iounmap(base);
>  fail1:
>  	release_mem_region(res->start, resource_size(res));
> -fail0:
> -	if (pdata && pdata->exit)
> -		pdata->exit(&pdev->dev);
>  	return ret; /* Return error number */
>  }
>  
> @@ -611,10 +600,6 @@ static int __exit i2c_imx_remove(struct platform_device *pdev)
>  	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
>  	writeb(0, i2c_imx->base + IMX_I2C_I2SR);
>  
> -	/* Shut down hardware */
> -	if (pdata && pdata->exit)
> -		pdata->exit(&pdev->dev);
> -
>  	clk_put(i2c_imx->clk);
>  
>  	iounmap(i2c_imx->base);
> -- 
> 1.7.4.1
> 
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* [PATCH 1/2] i2c/imx: remove init/exit hooks from platform data
@ 2011-07-15  2:54         ` Grant Likely
  0 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-07-15  2:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 15, 2011 at 12:03:44AM +0800, Shawn Guo wrote:
> The init/exit hooks in platform data are being used nowhere, so can
> be removed.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Darius Augulis <augulis.darius@gmail.com>
> Cc: Ben Dooks <ben-linux@fluff.org>

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

Yes, I think this is the think to do.  Notifiers provide a generic
mechanism.  There is no need for each driver to open code this
functionality.

g.

> ---
>  arch/arm/plat-mxc/include/mach/i2c.h |    4 ----
>  drivers/i2c/busses/i2c-imx.c         |   21 +++------------------
>  2 files changed, 3 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/plat-mxc/include/mach/i2c.h b/arch/arm/plat-mxc/include/mach/i2c.h
> index 4a5dc5c..375cdd0 100644
> --- a/arch/arm/plat-mxc/include/mach/i2c.h
> +++ b/arch/arm/plat-mxc/include/mach/i2c.h
> @@ -11,14 +11,10 @@
>  
>  /**
>   * struct imxi2c_platform_data - structure of platform data for MXC I2C driver
> - * @init:	Initialise gpio's and other board specific things
> - * @exit:	Free everything initialised by @init
>   * @bitrate:	Bus speed measured in Hz
>   *
>   **/
>  struct imxi2c_platform_data {
> -	int (*init)(struct device *dev);
> -	void (*exit)(struct device *dev);
>  	int bitrate;
>  };
>  
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 4c2a62b..54d809e 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -466,7 +466,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  {
>  	struct imx_i2c_struct *i2c_imx;
>  	struct resource *res;
> -	struct imxi2c_platform_data *pdata;
> +	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
>  	void __iomem *base;
>  	resource_size_t res_size;
>  	int irq;
> @@ -485,19 +485,11 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  		return -ENOENT;
>  	}
>  
> -	pdata = pdev->dev.platform_data;
> -
> -	if (pdata && pdata->init) {
> -		ret = pdata->init(&pdev->dev);
> -		if (ret)
> -			return ret;
> -	}
> -
>  	res_size = resource_size(res);
>  
>  	if (!request_mem_region(res->start, res_size, DRIVER_NAME)) {
> -		ret = -EBUSY;
> -		goto fail0;
> +		dev_err(&pdev->dev, "request_mem_region failed\n");
> +		return -EBUSY;
>  	}
>  
>  	base = ioremap(res->start, res_size);
> @@ -586,9 +578,6 @@ fail2:
>  	iounmap(base);
>  fail1:
>  	release_mem_region(res->start, resource_size(res));
> -fail0:
> -	if (pdata && pdata->exit)
> -		pdata->exit(&pdev->dev);
>  	return ret; /* Return error number */
>  }
>  
> @@ -611,10 +600,6 @@ static int __exit i2c_imx_remove(struct platform_device *pdev)
>  	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
>  	writeb(0, i2c_imx->base + IMX_I2C_I2SR);
>  
> -	/* Shut down hardware */
> -	if (pdata && pdata->exit)
> -		pdata->exit(&pdev->dev);
> -
>  	clk_put(i2c_imx->clk);
>  
>  	iounmap(i2c_imx->base);
> -- 
> 1.7.4.1
> 
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [PATCH 2/2] i2c/imx: add device tree probe support
  2011-07-14 16:03     ` Shawn Guo
@ 2011-07-15  2:54         ` Grant Likely
  -1 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-07-15  2:54 UTC (permalink / raw)
  To: Shawn Guo
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	patches-QSEj5FYQhm4dnm+yROfE0A, Darius Augulis, Ben Dooks

On Fri, Jul 15, 2011 at 12:03:45AM +0800, Shawn Guo wrote:
> It adds device tree probe support for i2c-imx driver.
> 
> Signed-off-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Cc: Darius Augulis <augulis.darius-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
> ---
>  .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 ++++++++++++++++++++
>  drivers/i2c/busses/i2c-imx.c                       |   25 +++++++++++++++----
>  2 files changed, 44 insertions(+), 6 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
> 
> diff --git a/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt b/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
> new file mode 100644
> index 0000000..5066cd9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
> @@ -0,0 +1,25 @@
> +* Freescale Inter IC (I2C) and High Speed Inter IC (HS-I2C) for i.MX
> +
> +Required properties:
> +- compatible : Should be "fsl,<chip>-i2c"
> +- reg : Should contain I2C/HS-I2C registers location and length
> +- interrupts : Should contain I2C/HS-I2C interrupt
> +
> +Optional properties:
> +- clock-frequency : Constains desired I2C/HS-I2C bus clock frequency in Hz.
> +  The absence of the propoerty indicates the default frequency 100 kHz.
> +
> +Examples:
> +
> +i2c@83fc4000 { /* I2C2 on i.MX51 */
> +	compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
> +	reg = <0x83fc4000 0x4000>;
> +	interrupts = <63>;
> +};
> +
> +i2c@70038000 { /* HS-I2C on i.MX51 */
> +	compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
> +	reg = <0x70038000 0x4000>;
> +	interrupts = <63>;
> +	clock-frequency = <400000>
> +};
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 54d809e..58832e5 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -48,6 +48,9 @@
>  #include <linux/platform_device.h>
>  #include <linux/clk.h>
>  #include <linux/slab.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_i2c.h>
>  
>  #include <mach/irqs.h>
>  #include <mach/hardware.h>
> @@ -125,6 +128,11 @@ struct imx_i2c_struct {
>  	unsigned int		ifdr; /* IMX_I2C_IFDR */
>  };
>  
> +static const struct of_device_id i2c_imx_dt_ids[] = {
> +	{ .compatible = "fsl,imx1-i2c", },
> +	{ /* sentinel */ }
> +};
> +

This isn't dangerous, and I think the patch should be merged, but you
should send a followup patch to protect the of_device_id table with
#ifdef CONFIG_OF/#else/#endif to save a bit of data when CONFIG_OF is
not selected.  (Although maybe I'm quibbling over nothing).

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

Ben, can you merge this series?

g.

>  /** Functions for IMX I2C adapter driver ***************************************
>  *******************************************************************************/
>  
> @@ -469,7 +477,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
>  	void __iomem *base;
>  	resource_size_t res_size;
> -	int irq;
> +	int irq, bitrate;
>  	int ret;
>  
>  	dev_dbg(&pdev->dev, "<%s>\n", __func__);
> @@ -512,6 +520,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  	i2c_imx->adapter.algo		= &i2c_imx_algo;
>  	i2c_imx->adapter.dev.parent	= &pdev->dev;
>  	i2c_imx->adapter.nr 		= pdev->id;
> +	i2c_imx->adapter.dev.of_node	= pdev->dev.of_node;
>  	i2c_imx->irq			= irq;
>  	i2c_imx->base			= base;
>  	i2c_imx->res			= res;
> @@ -538,10 +547,12 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  	i2c_set_adapdata(&i2c_imx->adapter, i2c_imx);
>  
>  	/* Set up clock divider */
> -	if (pdata && pdata->bitrate)
> -		i2c_imx_set_clk(i2c_imx, pdata->bitrate);
> -	else
> -		i2c_imx_set_clk(i2c_imx, IMX_I2C_BIT_RATE);
> +	bitrate = IMX_I2C_BIT_RATE;
> +	ret = of_property_read_u32(pdev->dev.of_node,
> +				   "clock-frequency", &bitrate);
> +	if (ret < 0 && pdata && pdata->bitrate)
> +		bitrate = pdata->bitrate;
> +	i2c_imx_set_clk(i2c_imx, bitrate);
>  
>  	/* Set up chip registers to defaults */
>  	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
> @@ -554,6 +565,8 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  		goto fail5;
>  	}
>  
> +	of_i2c_register_devices(&i2c_imx->adapter);
> +
>  	/* Set up platform driver data */
>  	platform_set_drvdata(pdev, i2c_imx);
>  
> @@ -584,7 +597,6 @@ fail1:
>  static int __exit i2c_imx_remove(struct platform_device *pdev)
>  {
>  	struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev);
> -	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
>  
>  	/* remove adapter */
>  	dev_dbg(&i2c_imx->adapter.dev, "adapter removed\n");
> @@ -613,6 +625,7 @@ static struct platform_driver i2c_imx_driver = {
>  	.driver	= {
>  		.name	= DRIVER_NAME,
>  		.owner	= THIS_MODULE,
> +		.of_match_table = i2c_imx_dt_ids,
>  	}
>  };
>  
> -- 
> 1.7.4.1
> 

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

* [PATCH 2/2] i2c/imx: add device tree probe support
@ 2011-07-15  2:54         ` Grant Likely
  0 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2011-07-15  2:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 15, 2011 at 12:03:45AM +0800, Shawn Guo wrote:
> It adds device tree probe support for i2c-imx driver.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Darius Augulis <augulis.darius@gmail.com>
> Cc: Ben Dooks <ben-linux@fluff.org>
> ---
>  .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 ++++++++++++++++++++
>  drivers/i2c/busses/i2c-imx.c                       |   25 +++++++++++++++----
>  2 files changed, 44 insertions(+), 6 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
> 
> diff --git a/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt b/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
> new file mode 100644
> index 0000000..5066cd9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
> @@ -0,0 +1,25 @@
> +* Freescale Inter IC (I2C) and High Speed Inter IC (HS-I2C) for i.MX
> +
> +Required properties:
> +- compatible : Should be "fsl,<chip>-i2c"
> +- reg : Should contain I2C/HS-I2C registers location and length
> +- interrupts : Should contain I2C/HS-I2C interrupt
> +
> +Optional properties:
> +- clock-frequency : Constains desired I2C/HS-I2C bus clock frequency in Hz.
> +  The absence of the propoerty indicates the default frequency 100 kHz.
> +
> +Examples:
> +
> +i2c at 83fc4000 { /* I2C2 on i.MX51 */
> +	compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
> +	reg = <0x83fc4000 0x4000>;
> +	interrupts = <63>;
> +};
> +
> +i2c at 70038000 { /* HS-I2C on i.MX51 */
> +	compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
> +	reg = <0x70038000 0x4000>;
> +	interrupts = <63>;
> +	clock-frequency = <400000>
> +};
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 54d809e..58832e5 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -48,6 +48,9 @@
>  #include <linux/platform_device.h>
>  #include <linux/clk.h>
>  #include <linux/slab.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_i2c.h>
>  
>  #include <mach/irqs.h>
>  #include <mach/hardware.h>
> @@ -125,6 +128,11 @@ struct imx_i2c_struct {
>  	unsigned int		ifdr; /* IMX_I2C_IFDR */
>  };
>  
> +static const struct of_device_id i2c_imx_dt_ids[] = {
> +	{ .compatible = "fsl,imx1-i2c", },
> +	{ /* sentinel */ }
> +};
> +

This isn't dangerous, and I think the patch should be merged, but you
should send a followup patch to protect the of_device_id table with
#ifdef CONFIG_OF/#else/#endif to save a bit of data when CONFIG_OF is
not selected.  (Although maybe I'm quibbling over nothing).

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

Ben, can you merge this series?

g.

>  /** Functions for IMX I2C adapter driver ***************************************
>  *******************************************************************************/
>  
> @@ -469,7 +477,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
>  	void __iomem *base;
>  	resource_size_t res_size;
> -	int irq;
> +	int irq, bitrate;
>  	int ret;
>  
>  	dev_dbg(&pdev->dev, "<%s>\n", __func__);
> @@ -512,6 +520,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  	i2c_imx->adapter.algo		= &i2c_imx_algo;
>  	i2c_imx->adapter.dev.parent	= &pdev->dev;
>  	i2c_imx->adapter.nr 		= pdev->id;
> +	i2c_imx->adapter.dev.of_node	= pdev->dev.of_node;
>  	i2c_imx->irq			= irq;
>  	i2c_imx->base			= base;
>  	i2c_imx->res			= res;
> @@ -538,10 +547,12 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  	i2c_set_adapdata(&i2c_imx->adapter, i2c_imx);
>  
>  	/* Set up clock divider */
> -	if (pdata && pdata->bitrate)
> -		i2c_imx_set_clk(i2c_imx, pdata->bitrate);
> -	else
> -		i2c_imx_set_clk(i2c_imx, IMX_I2C_BIT_RATE);
> +	bitrate = IMX_I2C_BIT_RATE;
> +	ret = of_property_read_u32(pdev->dev.of_node,
> +				   "clock-frequency", &bitrate);
> +	if (ret < 0 && pdata && pdata->bitrate)
> +		bitrate = pdata->bitrate;
> +	i2c_imx_set_clk(i2c_imx, bitrate);
>  
>  	/* Set up chip registers to defaults */
>  	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
> @@ -554,6 +565,8 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  		goto fail5;
>  	}
>  
> +	of_i2c_register_devices(&i2c_imx->adapter);
> +
>  	/* Set up platform driver data */
>  	platform_set_drvdata(pdev, i2c_imx);
>  
> @@ -584,7 +597,6 @@ fail1:
>  static int __exit i2c_imx_remove(struct platform_device *pdev)
>  {
>  	struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev);
> -	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
>  
>  	/* remove adapter */
>  	dev_dbg(&i2c_imx->adapter.dev, "adapter removed\n");
> @@ -613,6 +625,7 @@ static struct platform_driver i2c_imx_driver = {
>  	.driver	= {
>  		.name	= DRIVER_NAME,
>  		.owner	= THIS_MODULE,
> +		.of_match_table = i2c_imx_dt_ids,
>  	}
>  };
>  
> -- 
> 1.7.4.1
> 

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

* Re: [PATCH 1/2] i2c/imx: remove init/exit hooks from platform data
  2011-07-14 16:03     ` Shawn Guo
@ 2011-07-15  8:00         ` Sascha Hauer
  -1 siblings, 0 replies; 16+ messages in thread
From: Sascha Hauer @ 2011-07-15  8:00 UTC (permalink / raw)
  To: Shawn Guo
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, patches-QSEj5FYQhm4dnm+yROfE0A,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Ben Dooks,
	Darius Augulis,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Fri, Jul 15, 2011 at 12:03:44AM +0800, Shawn Guo wrote:
> The init/exit hooks in platform data are being used nowhere, so can
> be removed.
> 
> Signed-off-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Cc: Darius Augulis <augulis.darius-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>

Can safely go via the i2c tree.

Acked-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>


> ---
>  arch/arm/plat-mxc/include/mach/i2c.h |    4 ----
>  drivers/i2c/busses/i2c-imx.c         |   21 +++------------------
>  2 files changed, 3 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/plat-mxc/include/mach/i2c.h b/arch/arm/plat-mxc/include/mach/i2c.h
> index 4a5dc5c..375cdd0 100644
> --- a/arch/arm/plat-mxc/include/mach/i2c.h
> +++ b/arch/arm/plat-mxc/include/mach/i2c.h
> @@ -11,14 +11,10 @@
>  
>  /**
>   * struct imxi2c_platform_data - structure of platform data for MXC I2C driver
> - * @init:	Initialise gpio's and other board specific things
> - * @exit:	Free everything initialised by @init
>   * @bitrate:	Bus speed measured in Hz
>   *
>   **/
>  struct imxi2c_platform_data {
> -	int (*init)(struct device *dev);
> -	void (*exit)(struct device *dev);
>  	int bitrate;
>  };
>  
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 4c2a62b..54d809e 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -466,7 +466,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  {
>  	struct imx_i2c_struct *i2c_imx;
>  	struct resource *res;
> -	struct imxi2c_platform_data *pdata;
> +	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
>  	void __iomem *base;
>  	resource_size_t res_size;
>  	int irq;
> @@ -485,19 +485,11 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  		return -ENOENT;
>  	}
>  
> -	pdata = pdev->dev.platform_data;
> -
> -	if (pdata && pdata->init) {
> -		ret = pdata->init(&pdev->dev);
> -		if (ret)
> -			return ret;
> -	}
> -
>  	res_size = resource_size(res);
>  
>  	if (!request_mem_region(res->start, res_size, DRIVER_NAME)) {
> -		ret = -EBUSY;
> -		goto fail0;
> +		dev_err(&pdev->dev, "request_mem_region failed\n");
> +		return -EBUSY;
>  	}
>  
>  	base = ioremap(res->start, res_size);
> @@ -586,9 +578,6 @@ fail2:
>  	iounmap(base);
>  fail1:
>  	release_mem_region(res->start, resource_size(res));
> -fail0:
> -	if (pdata && pdata->exit)
> -		pdata->exit(&pdev->dev);
>  	return ret; /* Return error number */
>  }
>  
> @@ -611,10 +600,6 @@ static int __exit i2c_imx_remove(struct platform_device *pdev)
>  	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
>  	writeb(0, i2c_imx->base + IMX_I2C_I2SR);
>  
> -	/* Shut down hardware */
> -	if (pdata && pdata->exit)
> -		pdata->exit(&pdev->dev);
> -
>  	clk_put(i2c_imx->clk);
>  
>  	iounmap(i2c_imx->base);
> -- 
> 1.7.4.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* [PATCH 1/2] i2c/imx: remove init/exit hooks from platform data
@ 2011-07-15  8:00         ` Sascha Hauer
  0 siblings, 0 replies; 16+ messages in thread
From: Sascha Hauer @ 2011-07-15  8:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 15, 2011 at 12:03:44AM +0800, Shawn Guo wrote:
> The init/exit hooks in platform data are being used nowhere, so can
> be removed.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Darius Augulis <augulis.darius@gmail.com>
> Cc: Ben Dooks <ben-linux@fluff.org>

Can safely go via the i2c tree.

Acked-by: Sascha Hauer <s.hauer@pengutronix.de>


> ---
>  arch/arm/plat-mxc/include/mach/i2c.h |    4 ----
>  drivers/i2c/busses/i2c-imx.c         |   21 +++------------------
>  2 files changed, 3 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/plat-mxc/include/mach/i2c.h b/arch/arm/plat-mxc/include/mach/i2c.h
> index 4a5dc5c..375cdd0 100644
> --- a/arch/arm/plat-mxc/include/mach/i2c.h
> +++ b/arch/arm/plat-mxc/include/mach/i2c.h
> @@ -11,14 +11,10 @@
>  
>  /**
>   * struct imxi2c_platform_data - structure of platform data for MXC I2C driver
> - * @init:	Initialise gpio's and other board specific things
> - * @exit:	Free everything initialised by @init
>   * @bitrate:	Bus speed measured in Hz
>   *
>   **/
>  struct imxi2c_platform_data {
> -	int (*init)(struct device *dev);
> -	void (*exit)(struct device *dev);
>  	int bitrate;
>  };
>  
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 4c2a62b..54d809e 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -466,7 +466,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  {
>  	struct imx_i2c_struct *i2c_imx;
>  	struct resource *res;
> -	struct imxi2c_platform_data *pdata;
> +	struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
>  	void __iomem *base;
>  	resource_size_t res_size;
>  	int irq;
> @@ -485,19 +485,11 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  		return -ENOENT;
>  	}
>  
> -	pdata = pdev->dev.platform_data;
> -
> -	if (pdata && pdata->init) {
> -		ret = pdata->init(&pdev->dev);
> -		if (ret)
> -			return ret;
> -	}
> -
>  	res_size = resource_size(res);
>  
>  	if (!request_mem_region(res->start, res_size, DRIVER_NAME)) {
> -		ret = -EBUSY;
> -		goto fail0;
> +		dev_err(&pdev->dev, "request_mem_region failed\n");
> +		return -EBUSY;
>  	}
>  
>  	base = ioremap(res->start, res_size);
> @@ -586,9 +578,6 @@ fail2:
>  	iounmap(base);
>  fail1:
>  	release_mem_region(res->start, resource_size(res));
> -fail0:
> -	if (pdata && pdata->exit)
> -		pdata->exit(&pdev->dev);
>  	return ret; /* Return error number */
>  }
>  
> @@ -611,10 +600,6 @@ static int __exit i2c_imx_remove(struct platform_device *pdev)
>  	writeb(0, i2c_imx->base + IMX_I2C_I2CR);
>  	writeb(0, i2c_imx->base + IMX_I2C_I2SR);
>  
> -	/* Shut down hardware */
> -	if (pdata && pdata->exit)
> -		pdata->exit(&pdev->dev);
> -
>  	clk_put(i2c_imx->clk);
>  
>  	iounmap(i2c_imx->base);
> -- 
> 1.7.4.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [PATCH 0/2] Add device tree probe for i2c-imx driver
  2011-07-14 16:03 ` Shawn Guo
@ 2011-07-22  2:15     ` Shawn Guo
  -1 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-22  2:15 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	patches-QSEj5FYQhm4dnm+yROfE0A

Hi Ben,

Any comments, or it's been good for you to queue them for v3.1 window?

Regards,
Shawn

On Fri, Jul 15, 2011 at 12:03:43AM +0800, Shawn Guo wrote:
> The first patch removes unused init/exit hooks from platform data,
> and the second one actually adds the actual device tree probe support.
> 
> Shawn Guo (2):
>       i2c/imx: remove init/exit hooks from platform data
>       i2c/imx: add device tree probe support
> 
>  .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 +++++++++++
>  arch/arm/plat-mxc/include/mach/i2c.h               |    4 --
>  drivers/i2c/busses/i2c-imx.c                       |   46 +++++++++----------
>  3 files changed, 47 insertions(+), 28 deletions(-)
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
> 

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

* [PATCH 0/2] Add device tree probe for i2c-imx driver
@ 2011-07-22  2:15     ` Shawn Guo
  0 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-22  2:15 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ben,

Any comments, or it's been good for you to queue them for v3.1 window?

Regards,
Shawn

On Fri, Jul 15, 2011 at 12:03:43AM +0800, Shawn Guo wrote:
> The first patch removes unused init/exit hooks from platform data,
> and the second one actually adds the actual device tree probe support.
> 
> Shawn Guo (2):
>       i2c/imx: remove init/exit hooks from platform data
>       i2c/imx: add device tree probe support
> 
>  .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 +++++++++++
>  arch/arm/plat-mxc/include/mach/i2c.h               |    4 --
>  drivers/i2c/busses/i2c-imx.c                       |   46 +++++++++----------
>  3 files changed, 47 insertions(+), 28 deletions(-)
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
> 

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

* Re: [PATCH 0/2] Add device tree probe for i2c-imx driver
  2011-07-22  2:15     ` Shawn Guo
@ 2011-07-29  1:51       ` Shawn Guo
  -1 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-29  1:51 UTC (permalink / raw)
  To: Ben Dooks; +Cc: devicetree-discuss, linux-i2c, linux-arm-kernel, patches

Ping ...

On Fri, Jul 22, 2011 at 10:15:25AM +0800, Shawn Guo wrote:
> Hi Ben,
> 
> Any comments, or it's been good for you to queue them for v3.1 window?
> 
> Regards,
> Shawn
> 
> On Fri, Jul 15, 2011 at 12:03:43AM +0800, Shawn Guo wrote:
> > The first patch removes unused init/exit hooks from platform data,
> > and the second one actually adds the actual device tree probe support.
> > 
> > Shawn Guo (2):
> >       i2c/imx: remove init/exit hooks from platform data
> >       i2c/imx: add device tree probe support
> > 
> >  .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 +++++++++++
> >  arch/arm/plat-mxc/include/mach/i2c.h               |    4 --
> >  drivers/i2c/busses/i2c-imx.c                       |   46 +++++++++----------
> >  3 files changed, 47 insertions(+), 28 deletions(-)

-- 
Regards,
Shawn

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

* [PATCH 0/2] Add device tree probe for i2c-imx driver
@ 2011-07-29  1:51       ` Shawn Guo
  0 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2011-07-29  1:51 UTC (permalink / raw)
  To: linux-arm-kernel

Ping ...

On Fri, Jul 22, 2011 at 10:15:25AM +0800, Shawn Guo wrote:
> Hi Ben,
> 
> Any comments, or it's been good for you to queue them for v3.1 window?
> 
> Regards,
> Shawn
> 
> On Fri, Jul 15, 2011 at 12:03:43AM +0800, Shawn Guo wrote:
> > The first patch removes unused init/exit hooks from platform data,
> > and the second one actually adds the actual device tree probe support.
> > 
> > Shawn Guo (2):
> >       i2c/imx: remove init/exit hooks from platform data
> >       i2c/imx: add device tree probe support
> > 
> >  .../devicetree/bindings/i2c/fsl-imx-i2c.txt        |   25 +++++++++++
> >  arch/arm/plat-mxc/include/mach/i2c.h               |    4 --
> >  drivers/i2c/busses/i2c-imx.c                       |   46 +++++++++----------
> >  3 files changed, 47 insertions(+), 28 deletions(-)

-- 
Regards,
Shawn

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

end of thread, other threads:[~2011-07-29  1:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-14 16:03 [PATCH 0/2] Add device tree probe for i2c-imx driver Shawn Guo
2011-07-14 16:03 ` Shawn Guo
     [not found] ` <1310659425-17499-1-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-14 16:03   ` [PATCH 1/2] i2c/imx: remove init/exit hooks from platform data Shawn Guo
2011-07-14 16:03     ` Shawn Guo
     [not found]     ` <1310659425-17499-2-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-15  2:54       ` Grant Likely
2011-07-15  2:54         ` Grant Likely
2011-07-15  8:00       ` Sascha Hauer
2011-07-15  8:00         ` Sascha Hauer
2011-07-14 16:03   ` [PATCH 2/2] i2c/imx: add device tree probe support Shawn Guo
2011-07-14 16:03     ` Shawn Guo
     [not found]     ` <1310659425-17499-3-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-07-15  2:54       ` Grant Likely
2011-07-15  2:54         ` Grant Likely
2011-07-22  2:15   ` [PATCH 0/2] Add device tree probe for i2c-imx driver Shawn Guo
2011-07-22  2:15     ` Shawn Guo
2011-07-29  1:51     ` Shawn Guo
2011-07-29  1:51       ` Shawn Guo

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.