All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] fixes and DT support based on Nikolaus TWI driver
@ 2012-08-21 14:29 ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-08-21 14:29 UTC (permalink / raw)
  To: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

Hi Nikolaus,

First of all, thanks for the work you have done on i2c-at91 driver and sorry
to have been so long to answer you.

This set of patches is based on:
http://article.gmane.org/gmane.linux.kernel/1285193/match=patch+v10+0+4+at91+replace+broken+twi+driver+i2c+c

On my side, I don't see any issue with this new driver. I am not an I2C guru
but it works with all the I2C devices I have and your patches have already
been reviewed and tested. I'll continue to test it with other I2C devices and
on several chips.

So the goal of this set of patches is to get feedback on the fix I added, on
the DT support and to resurect your set of patches.

Regards

Ludovic

Ludovic Desroches (5):
  i2c: at91: add new fixes for some TWI ip versions
  i2c: at91: add dt support to i2c-at91
  ARM: at91: add clocks for i2c DT entries
  ARM: dts: add twi nodes for atmel SOCs
  ARM: dts: add twi nodes for atmel boards

 .../devicetree/bindings/i2c/atmel-i2c.txt          | 29 +++++++++
 arch/arm/boot/dts/at91sam9260.dtsi                 | 23 +++----
 arch/arm/boot/dts/at91sam9263.dtsi                 | 23 +++----
 arch/arm/boot/dts/at91sam9263ek.dts                | 20 +++---
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi        | 28 ++++-----
 arch/arm/boot/dts/at91sam9g25ek.dts                | 12 ++++
 arch/arm/boot/dts/at91sam9g45.dtsi                 | 33 ++++++----
 arch/arm/boot/dts/at91sam9m10g45ek.dts             | 14 +++++
 arch/arm/boot/dts/at91sam9n12.dtsi                 | 33 ++++++----
 arch/arm/boot/dts/at91sam9n12ek.dts                |  8 +++
 arch/arm/boot/dts/at91sam9x5.dtsi                  | 69 +++++++++------------
 arch/arm/mach-at91/at91rm9200_devices.c            |  9 ---
 arch/arm/mach-at91/at91sam9260.c                   |  1 +
 arch/arm/mach-at91/at91sam9263.c                   |  1 +
 arch/arm/mach-at91/at91sam9g45.c                   |  2 +
 arch/arm/mach-at91/at91sam9n12.c                   |  2 +
 arch/arm/mach-at91/at91sam9x5.c                    |  3 +
 drivers/i2c/busses/i2c-at91.c                      | 71 ++++++++++++++++------
 18 files changed, 239 insertions(+), 142 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt

-- 
1.7.11.3

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

* [RFC PATCH 0/5] fixes and DT support based on Nikolaus TWI driver
@ 2012-08-21 14:29 ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-08-21 14:29 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Hi Nikolaus,

First of all, thanks for the work you have done on i2c-at91 driver and sorry
to have been so long to answer you.

This set of patches is based on:
http://article.gmane.org/gmane.linux.kernel/1285193/match=patch+v10+0+4+at91+replace+broken+twi+driver+i2c+c

On my side, I don't see any issue with this new driver. I am not an I2C guru
but it works with all the I2C devices I have and your patches have already
been reviewed and tested. I'll continue to test it with other I2C devices and
on several chips.

So the goal of this set of patches is to get feedback on the fix I added, on
the DT support and to resurect your set of patches.

Regards

Ludovic

Ludovic Desroches (5):
  i2c: at91: add new fixes for some TWI ip versions
  i2c: at91: add dt support to i2c-at91
  ARM: at91: add clocks for i2c DT entries
  ARM: dts: add twi nodes for atmel SOCs
  ARM: dts: add twi nodes for atmel boards

 .../devicetree/bindings/i2c/atmel-i2c.txt          | 29 +++++++++
 arch/arm/boot/dts/at91sam9260.dtsi                 | 23 +++----
 arch/arm/boot/dts/at91sam9263.dtsi                 | 23 +++----
 arch/arm/boot/dts/at91sam9263ek.dts                | 20 +++---
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi        | 28 ++++-----
 arch/arm/boot/dts/at91sam9g25ek.dts                | 12 ++++
 arch/arm/boot/dts/at91sam9g45.dtsi                 | 33 ++++++----
 arch/arm/boot/dts/at91sam9m10g45ek.dts             | 14 +++++
 arch/arm/boot/dts/at91sam9n12.dtsi                 | 33 ++++++----
 arch/arm/boot/dts/at91sam9n12ek.dts                |  8 +++
 arch/arm/boot/dts/at91sam9x5.dtsi                  | 69 +++++++++------------
 arch/arm/mach-at91/at91rm9200_devices.c            |  9 ---
 arch/arm/mach-at91/at91sam9260.c                   |  1 +
 arch/arm/mach-at91/at91sam9263.c                   |  1 +
 arch/arm/mach-at91/at91sam9g45.c                   |  2 +
 arch/arm/mach-at91/at91sam9n12.c                   |  2 +
 arch/arm/mach-at91/at91sam9x5.c                    |  3 +
 drivers/i2c/busses/i2c-at91.c                      | 71 ++++++++++++++++------
 18 files changed, 239 insertions(+), 142 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt

-- 
1.7.11.3

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

* [PATCH 1/5] i2c: at91: add new fixes for some TWI ip versions
  2012-08-21 14:29 ` ludovic.desroches at atmel.com
@ 2012-08-21 14:29     ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-08-21 14:29 UTC (permalink / raw)
  To: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

The at91sam9261 TWI ip version requires also some fixes. The id_entry
field from the platform device structure has been replaced by the use
of cpu_is_xxx function to determine when to use these fixes.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/mach-at91/at91rm9200_devices.c |  9 -------
 drivers/i2c/busses/i2c-at91.c           | 42 +++++++++++++++++++--------------
 2 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 2b9b493..e6b7d05 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -494,18 +494,9 @@ static struct resource twi_resources[] = {
 	},
 };
 
-static const struct platform_device_id twi_id = {
-	/*
-	 * driver_data is "1" for hardware with ckdiv upper limit == 5
-	 * (AT91RM9200 erratum 22), "0" for twi modules without this bug
-	 */
-	.driver_data	= 1,
-};
-
 static struct platform_device at91rm9200_twi_device = {
 	.name		= "at91_i2c",
 	.id		= -1,
-	.id_entry	= &twi_id,
 	.resource	= twi_resources,
 	.num_resources	= ARRAY_SIZE(twi_resources),
 };
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index b1cb780..4599522 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -27,6 +27,8 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
+#include <mach/cpu.h>
+
 #define TWI_CLK_HZ		100000			/* max 400 Kbits/s */
 #define AT91_I2C_TIMEOUT	msecs_to_jiffies(100)	/* transfer timeout */
 
@@ -72,7 +74,6 @@ struct at91_twi_dev {
 	int			irq;
 	unsigned		transfer_status;
 	struct i2c_adapter	adapter;
-	bool			is_rm9200;
 	unsigned		twi_cwgr_reg;
 };
 
@@ -111,20 +112,28 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
  */
 static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 {
-	const int offset = dev->is_rm9200 ? 3 : 4;
-	const int div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
-						 2 * twi_clk) - offset);
-	int ckdiv = fls(div >> 8);
-	int cdiv = div >> ckdiv;
-
-	if (dev->is_rm9200 && (ckdiv > 5)) {
-		dev_warn(dev->dev, "AT91RM9200 erratum 22: using ckdiv = 5.\n");
-		ckdiv = 5;
-		cdiv = 255;
-	} else if (ckdiv > 7) {
-		dev_warn(dev->dev, "%d exceeds 3 bits for ckdiv, limiting.\n",
-			 ckdiv);
-		ckdiv = 7;
+	int offset, div, max_ckdiv, ckdiv, cdiv;
+
+	if (cpu_is_at91rm9200()) {
+		offset = 3;
+		max_ckdiv = 5;
+	} else if (cpu_is_at91sam9261()) {
+		offset = 4;
+		max_ckdiv = 5;
+	} else {
+		offset = 4;
+		max_ckdiv = 7;
+	}
+
+	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
+				       2 * twi_clk) - offset);
+	ckdiv = fls(div >> 8);
+	cdiv = div >> ckdiv;
+
+	if (ckdiv > max_ckdiv) {
+		dev_warn(dev->dev, "%d exceeds ckdiv max value which is %d.\n",
+			 ckdiv, max_ckdiv);
+		ckdiv = max_ckdiv;
 		cdiv = 255;
 	}
 
@@ -331,9 +340,6 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 		goto err_release_region;
 	}
 
-	if (pdev->id_entry && pdev->id_entry->driver_data == 1)
-		dev->is_rm9200 = 1;
-
 	init_completion(&dev->cmd_complete);
 
 	dev->dev = &pdev->dev;
-- 
1.7.11.3

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

* [PATCH 1/5] i2c: at91: add new fixes for some TWI ip versions
@ 2012-08-21 14:29     ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-08-21 14:29 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

The at91sam9261 TWI ip version requires also some fixes. The id_entry
field from the platform device structure has been replaced by the use
of cpu_is_xxx function to determine when to use these fixes.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/mach-at91/at91rm9200_devices.c |  9 -------
 drivers/i2c/busses/i2c-at91.c           | 42 +++++++++++++++++++--------------
 2 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 2b9b493..e6b7d05 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -494,18 +494,9 @@ static struct resource twi_resources[] = {
 	},
 };
 
-static const struct platform_device_id twi_id = {
-	/*
-	 * driver_data is "1" for hardware with ckdiv upper limit == 5
-	 * (AT91RM9200 erratum 22), "0" for twi modules without this bug
-	 */
-	.driver_data	= 1,
-};
-
 static struct platform_device at91rm9200_twi_device = {
 	.name		= "at91_i2c",
 	.id		= -1,
-	.id_entry	= &twi_id,
 	.resource	= twi_resources,
 	.num_resources	= ARRAY_SIZE(twi_resources),
 };
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index b1cb780..4599522 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -27,6 +27,8 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
+#include <mach/cpu.h>
+
 #define TWI_CLK_HZ		100000			/* max 400 Kbits/s */
 #define AT91_I2C_TIMEOUT	msecs_to_jiffies(100)	/* transfer timeout */
 
@@ -72,7 +74,6 @@ struct at91_twi_dev {
 	int			irq;
 	unsigned		transfer_status;
 	struct i2c_adapter	adapter;
-	bool			is_rm9200;
 	unsigned		twi_cwgr_reg;
 };
 
@@ -111,20 +112,28 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
  */
 static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 {
-	const int offset = dev->is_rm9200 ? 3 : 4;
-	const int div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
-						 2 * twi_clk) - offset);
-	int ckdiv = fls(div >> 8);
-	int cdiv = div >> ckdiv;
-
-	if (dev->is_rm9200 && (ckdiv > 5)) {
-		dev_warn(dev->dev, "AT91RM9200 erratum 22: using ckdiv = 5.\n");
-		ckdiv = 5;
-		cdiv = 255;
-	} else if (ckdiv > 7) {
-		dev_warn(dev->dev, "%d exceeds 3 bits for ckdiv, limiting.\n",
-			 ckdiv);
-		ckdiv = 7;
+	int offset, div, max_ckdiv, ckdiv, cdiv;
+
+	if (cpu_is_at91rm9200()) {
+		offset = 3;
+		max_ckdiv = 5;
+	} else if (cpu_is_at91sam9261()) {
+		offset = 4;
+		max_ckdiv = 5;
+	} else {
+		offset = 4;
+		max_ckdiv = 7;
+	}
+
+	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
+				       2 * twi_clk) - offset);
+	ckdiv = fls(div >> 8);
+	cdiv = div >> ckdiv;
+
+	if (ckdiv > max_ckdiv) {
+		dev_warn(dev->dev, "%d exceeds ckdiv max value which is %d.\n",
+			 ckdiv, max_ckdiv);
+		ckdiv = max_ckdiv;
 		cdiv = 255;
 	}
 
@@ -331,9 +340,6 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 		goto err_release_region;
 	}
 
-	if (pdev->id_entry && pdev->id_entry->driver_data == 1)
-		dev->is_rm9200 = 1;
-
 	init_completion(&dev->cmd_complete);
 
 	dev->dev = &pdev->dev;
-- 
1.7.11.3

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

* [PATCH 2/5] i2c: at91: add dt support to i2c-at91
  2012-08-21 14:29 ` ludovic.desroches at atmel.com
@ 2012-08-21 14:29     ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-08-21 14:29 UTC (permalink / raw)
  To: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 .../devicetree/bindings/i2c/atmel-i2c.txt          | 29 +++++++++++++
 drivers/i2c/busses/i2c-at91.c                      | 49 +++++++++++++++++-----
 2 files changed, 68 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt

diff --git a/Documentation/devicetree/bindings/i2c/atmel-i2c.txt b/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
new file mode 100644
index 0000000..9e46289
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
@@ -0,0 +1,29 @@
+I2C for Atmel platforms
+
+Required properties :
+- compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c" or
+     "atmel,at91sam9g20-i2c"
+- reg: physical base address of the controller and length of memory mapped
+     region.
+- interrupts: interrupt number to the cpu.
+- #address-cells = <1>;
+- #size-cells = <0>;
+
+Optional properties:
+- Child nodes conforming to i2c bus binding
+
+Examples :
+
+i2c0: i2c@fff84000 {
+	compatible = "atmel,at91sam9g20-i2c";
+	reg = <0xfff84000 0x100>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	24c512@50 {
+		compatible = "24c512";
+		reg = <0x50>;
+		pagesize = <128>;
+	}
+}
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 4599522..1c86b24 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -24,6 +24,9 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_i2c.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
@@ -112,17 +115,27 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
  */
 static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 {
-	int offset, div, max_ckdiv, ckdiv, cdiv;
-
-	if (cpu_is_at91rm9200()) {
-		offset = 3;
-		max_ckdiv = 5;
-	} else if (cpu_is_at91sam9261()) {
-		offset = 4;
-		max_ckdiv = 5;
+	int offset = 4, max_ckdiv = 7;
+	int div, ckdiv, cdiv;
+
+	if (dev->dev->of_node) {
+		if (of_device_is_compatible(dev->dev->of_node,
+					    "atmel,at91rm9200-i2c")) {
+			offset = 3;
+			max_ckdiv = 5;
+		} else if (of_device_is_compatible(dev->dev->of_node,
+						   "atmel,at91sam9261-i2c")) {
+			offset = 4;
+			max_ckdiv = 5;
+		}
 	} else {
-		offset = 4;
-		max_ckdiv = 7;
+		if (cpu_is_at91rm9200()) {
+			offset = 3;
+			max_ckdiv = 5;
+		} else if (cpu_is_at91sam9261()) {
+			offset = 4;
+			max_ckdiv = 5;
+		}
 	}
 
 	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
@@ -379,6 +392,7 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 	dev->adapter.dev.parent = dev->dev;
 	dev->adapter.nr = pdev->id;
 	dev->adapter.timeout = AT91_I2C_TIMEOUT;
+	dev->adapter.dev.of_node = pdev->dev.of_node;
 
 	rc = i2c_add_numbered_adapter(&dev->adapter);
 	if (rc) {
@@ -387,6 +401,8 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 		goto err_free_irq;
 	}
 
+	of_i2c_register_devices(&dev->adapter);
+
 	dev_info(dev->dev, "AT91 i2c bus driver.\n");
 	return 0;
 
@@ -454,12 +470,25 @@ static const struct dev_pm_ops at91_twi_pm = {
 #define at91_twi_pm_ops NULL
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id at91_twi_dt_ids[] = {
+	{ .compatible = "atmel,at91rm9200-i2c", },
+	{ .compatible = "atmel,at91sam9260-i2c", },
+	{ .compatible = "atmel,at91sam9261-i2c", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, at91_twi_dt_ids);
+#else
+#define at91_twi_dt_ids NULL
+#endif
+
 static struct platform_driver at91_twi_driver = {
 	.probe		= at91_twi_probe,
 	.remove		= __devexit_p(at91_twi_remove),
 	.driver		= {
 		.name	= "at91_i2c",
 		.owner	= THIS_MODULE,
+		.of_match_table = at91_twi_dt_ids,
 		.pm	= at91_twi_pm_ops,
 	},
 };
-- 
1.7.11.3

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

* [PATCH 2/5] i2c: at91: add dt support to i2c-at91
@ 2012-08-21 14:29     ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-08-21 14:29 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 .../devicetree/bindings/i2c/atmel-i2c.txt          | 29 +++++++++++++
 drivers/i2c/busses/i2c-at91.c                      | 49 +++++++++++++++++-----
 2 files changed, 68 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt

diff --git a/Documentation/devicetree/bindings/i2c/atmel-i2c.txt b/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
new file mode 100644
index 0000000..9e46289
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
@@ -0,0 +1,29 @@
+I2C for Atmel platforms
+
+Required properties :
+- compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c" or
+     "atmel,at91sam9g20-i2c"
+- reg: physical base address of the controller and length of memory mapped
+     region.
+- interrupts: interrupt number to the cpu.
+- #address-cells = <1>;
+- #size-cells = <0>;
+
+Optional properties:
+- Child nodes conforming to i2c bus binding
+
+Examples :
+
+i2c0: i2c at fff84000 {
+	compatible = "atmel,at91sam9g20-i2c";
+	reg = <0xfff84000 0x100>;
+	interrupts = <12 4>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	24c512 at 50 {
+		compatible = "24c512";
+		reg = <0x50>;
+		pagesize = <128>;
+	}
+}
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 4599522..1c86b24 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -24,6 +24,9 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_i2c.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
@@ -112,17 +115,27 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
  */
 static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
 {
-	int offset, div, max_ckdiv, ckdiv, cdiv;
-
-	if (cpu_is_at91rm9200()) {
-		offset = 3;
-		max_ckdiv = 5;
-	} else if (cpu_is_at91sam9261()) {
-		offset = 4;
-		max_ckdiv = 5;
+	int offset = 4, max_ckdiv = 7;
+	int div, ckdiv, cdiv;
+
+	if (dev->dev->of_node) {
+		if (of_device_is_compatible(dev->dev->of_node,
+					    "atmel,at91rm9200-i2c")) {
+			offset = 3;
+			max_ckdiv = 5;
+		} else if (of_device_is_compatible(dev->dev->of_node,
+						   "atmel,at91sam9261-i2c")) {
+			offset = 4;
+			max_ckdiv = 5;
+		}
 	} else {
-		offset = 4;
-		max_ckdiv = 7;
+		if (cpu_is_at91rm9200()) {
+			offset = 3;
+			max_ckdiv = 5;
+		} else if (cpu_is_at91sam9261()) {
+			offset = 4;
+			max_ckdiv = 5;
+		}
 	}
 
 	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
@@ -379,6 +392,7 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 	dev->adapter.dev.parent = dev->dev;
 	dev->adapter.nr = pdev->id;
 	dev->adapter.timeout = AT91_I2C_TIMEOUT;
+	dev->adapter.dev.of_node = pdev->dev.of_node;
 
 	rc = i2c_add_numbered_adapter(&dev->adapter);
 	if (rc) {
@@ -387,6 +401,8 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 		goto err_free_irq;
 	}
 
+	of_i2c_register_devices(&dev->adapter);
+
 	dev_info(dev->dev, "AT91 i2c bus driver.\n");
 	return 0;
 
@@ -454,12 +470,25 @@ static const struct dev_pm_ops at91_twi_pm = {
 #define at91_twi_pm_ops NULL
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id at91_twi_dt_ids[] = {
+	{ .compatible = "atmel,at91rm9200-i2c", },
+	{ .compatible = "atmel,at91sam9260-i2c", },
+	{ .compatible = "atmel,at91sam9261-i2c", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, at91_twi_dt_ids);
+#else
+#define at91_twi_dt_ids NULL
+#endif
+
 static struct platform_driver at91_twi_driver = {
 	.probe		= at91_twi_probe,
 	.remove		= __devexit_p(at91_twi_remove),
 	.driver		= {
 		.name	= "at91_i2c",
 		.owner	= THIS_MODULE,
+		.of_match_table = at91_twi_dt_ids,
 		.pm	= at91_twi_pm_ops,
 	},
 };
-- 
1.7.11.3

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

* [PATCH 3/5] ARM: at91: add clocks for i2c DT entries
  2012-08-21 14:29 ` ludovic.desroches at atmel.com
@ 2012-08-21 14:29     ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-08-21 14:29 UTC (permalink / raw)
  To: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/mach-at91/at91sam9260.c | 1 +
 arch/arm/mach-at91/at91sam9263.c | 1 +
 arch/arm/mach-at91/at91sam9g45.c | 2 ++
 arch/arm/mach-at91/at91sam9n12.c | 2 ++
 arch/arm/mach-at91/at91sam9x5.c  | 3 +++
 5 files changed, 9 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 2e56321..f3fdca7 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -227,6 +227,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
 	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
 	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fffac000.i2c", &twi_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 71305fa..15458ad 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -210,6 +210,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("hclk", "a00000.ohci", &ohci_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 2944fc7..dcc4e3c 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -244,6 +244,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fff84000.i2c", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi1_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
index 0849466..732d3d3 100644
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -169,6 +169,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb_clk),
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
 	CLKDEV_CON_ID("pioC", &pioCD_clk),
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 1b144b4..744ffc2 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -231,6 +231,9 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8018000.i2c", &twi2_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
 	CLKDEV_CON_ID("pioC", &pioCD_clk),
-- 
1.7.11.3

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

* [PATCH 3/5] ARM: at91: add clocks for i2c DT entries
@ 2012-08-21 14:29     ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-08-21 14:29 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/mach-at91/at91sam9260.c | 1 +
 arch/arm/mach-at91/at91sam9263.c | 1 +
 arch/arm/mach-at91/at91sam9g45.c | 2 ++
 arch/arm/mach-at91/at91sam9n12.c | 2 ++
 arch/arm/mach-at91/at91sam9x5.c  | 3 +++
 5 files changed, 9 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 2e56321..f3fdca7 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -227,6 +227,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
 	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
 	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fffac000.i2c", &twi_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 71305fa..15458ad 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -210,6 +210,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("hclk", "a00000.ohci", &ohci_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 2944fc7..dcc4e3c 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -244,6 +244,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fff84000.i2c", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi1_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
index 0849466..732d3d3 100644
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -169,6 +169,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb_clk),
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
 	CLKDEV_CON_ID("pioC", &pioCD_clk),
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 1b144b4..744ffc2 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -231,6 +231,9 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
 	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "f8018000.i2c", &twi2_clk),
 	CLKDEV_CON_ID("pioA", &pioAB_clk),
 	CLKDEV_CON_ID("pioB", &pioAB_clk),
 	CLKDEV_CON_ID("pioC", &pioCD_clk),
-- 
1.7.11.3

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

* [PATCH 4/5] ARM: dts: add twi nodes for atmel SOCs
  2012-08-21 14:29 ` ludovic.desroches at atmel.com
@ 2012-08-21 14:29     ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-08-21 14:29 UTC (permalink / raw)
  To: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

Add twi nodes for atmel SOCs and remove i2c-gpio ones.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/boot/dts/at91sam9260.dtsi | 23 ++++++-------
 arch/arm/boot/dts/at91sam9263.dtsi | 23 ++++++-------
 arch/arm/boot/dts/at91sam9g45.dtsi | 33 +++++++++++-------
 arch/arm/boot/dts/at91sam9n12.dtsi | 33 +++++++++++-------
 arch/arm/boot/dts/at91sam9x5.dtsi  | 69 +++++++++++++++++---------------------
 5 files changed, 90 insertions(+), 91 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index f449efc..0ab7a3c 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -28,6 +28,7 @@
 		gpio2 = &pioC;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
 	};
 	cpus {
 		cpu@0 {
@@ -198,6 +199,15 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c@fffac000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfffac000 0x100>;
+				interrupts = <11 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc@fffe0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffe0000 0x100>;
@@ -257,17 +267,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 23 0 /* sda */
-			 &pioA 24 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 0209913..efb86dd 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -24,6 +24,7 @@
 		gpio3 = &pioD;
 		gpio4 = &pioE;
 		tcb0 = &tcb0;
+		i2c0 = &i2c0;
 	};
 	cpus {
 		cpu@0 {
@@ -179,6 +180,15 @@
 				interrupts = <24 4>;
 				status = "disabled";
 			};
+
+			i2c0: i2c@fff88000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand@40000000 {
@@ -204,17 +214,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioB 4 0 /* sda */
-			 &pioB 5 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 7dbccaf..8dd3ff8 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -29,6 +29,8 @@
 		gpio4 = &pioE;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
 	};
 	cpus {
 		cpu@0 {
@@ -200,6 +202,24 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c@fff84000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff84000 0x100>;
+				interrupts = <12 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@fff88000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc@fffb0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffb0000 0x100>;
@@ -268,17 +288,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 20 0 /* sda */
-			 &pioA 21 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <5>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index cb84de7..8a1969d 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -26,6 +26,8 @@
 		gpio3 = &pioD;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
 	};
 	cpus {
 		cpu@0 {
@@ -178,6 +180,24 @@
 				atmel,use-dma-tx;
 				status = "disabled";
 			};
+
+			i2c0: i2c@f8010000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@f8014000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand@40000000 {
@@ -205,17 +225,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 30 0 /* sda */
-			 &pioA 31 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 6b3ef43..ec56eaf 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -27,6 +27,9 @@
 		gpio3 = &pioD;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
+		i2c2 = &i2c2;
 	};
 	cpus {
 		cpu@0 {
@@ -191,6 +194,33 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c@f8010000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@f8014000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c2: i2c@f8018000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8018000 0x100>;
+				interrupts = <11 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc@f804c000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xf804c000 0x100>;
@@ -259,43 +289,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 30 0 /* sda */
-			 &pioA 31 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
-
-	i2c@1 {
-		compatible = "i2c-gpio";
-		gpios = <&pioC 0 0 /* sda */
-			 &pioC 1 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
-
-	i2c@2 {
-		compatible = "i2c-gpio";
-		gpios = <&pioB 4 0 /* sda */
-			 &pioB 5 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
-- 
1.7.11.3

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

* [PATCH 4/5] ARM: dts: add twi nodes for atmel SOCs
@ 2012-08-21 14:29     ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-08-21 14:29 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add twi nodes for atmel SOCs and remove i2c-gpio ones.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/at91sam9260.dtsi | 23 ++++++-------
 arch/arm/boot/dts/at91sam9263.dtsi | 23 ++++++-------
 arch/arm/boot/dts/at91sam9g45.dtsi | 33 +++++++++++-------
 arch/arm/boot/dts/at91sam9n12.dtsi | 33 +++++++++++-------
 arch/arm/boot/dts/at91sam9x5.dtsi  | 69 +++++++++++++++++---------------------
 5 files changed, 90 insertions(+), 91 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index f449efc..0ab7a3c 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -28,6 +28,7 @@
 		gpio2 = &pioC;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
 	};
 	cpus {
 		cpu at 0 {
@@ -198,6 +199,15 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c at fffac000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfffac000 0x100>;
+				interrupts = <11 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc at fffe0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffe0000 0x100>;
@@ -257,17 +267,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 23 0 /* sda */
-			 &pioA 24 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 0209913..efb86dd 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -24,6 +24,7 @@
 		gpio3 = &pioD;
 		gpio4 = &pioE;
 		tcb0 = &tcb0;
+		i2c0 = &i2c0;
 	};
 	cpus {
 		cpu at 0 {
@@ -179,6 +180,15 @@
 				interrupts = <24 4>;
 				status = "disabled";
 			};
+
+			i2c0: i2c at fff88000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand at 40000000 {
@@ -204,17 +214,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioB 4 0 /* sda */
-			 &pioB 5 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 7dbccaf..8dd3ff8 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -29,6 +29,8 @@
 		gpio4 = &pioE;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
 	};
 	cpus {
 		cpu at 0 {
@@ -200,6 +202,24 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c at fff84000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff84000 0x100>;
+				interrupts = <12 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c at fff88000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc at fffb0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffb0000 0x100>;
@@ -268,17 +288,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 20 0 /* sda */
-			 &pioA 21 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <5>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index cb84de7..8a1969d 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -26,6 +26,8 @@
 		gpio3 = &pioD;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
 	};
 	cpus {
 		cpu at 0 {
@@ -178,6 +180,24 @@
 				atmel,use-dma-tx;
 				status = "disabled";
 			};
+
+			i2c0: i2c at f8010000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c at f8014000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand at 40000000 {
@@ -205,17 +225,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 30 0 /* sda */
-			 &pioA 31 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 6b3ef43..ec56eaf 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -27,6 +27,9 @@
 		gpio3 = &pioD;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
+		i2c2 = &i2c2;
 	};
 	cpus {
 		cpu at 0 {
@@ -191,6 +194,33 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c at f8010000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c at f8014000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c2: i2c at f8018000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8018000 0x100>;
+				interrupts = <11 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc at f804c000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xf804c000 0x100>;
@@ -259,43 +289,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 30 0 /* sda */
-			 &pioA 31 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
-
-	i2c at 1 {
-		compatible = "i2c-gpio";
-		gpios = <&pioC 0 0 /* sda */
-			 &pioC 1 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
-
-	i2c at 2 {
-		compatible = "i2c-gpio";
-		gpios = <&pioB 4 0 /* sda */
-			 &pioB 5 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
-- 
1.7.11.3

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

* [PATCH 4/5] ARM: dts: add twi nodes for atmel SOCs
  2012-08-21 14:29     ` ludovic.desroches at atmel.com
@ 2012-08-21 14:30         ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-08-21 14:30 UTC (permalink / raw)
  To: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

Add twi nodes for atmel SOCs and remove i2c-gpio ones.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/boot/dts/at91sam9260.dtsi | 23 ++++++-------
 arch/arm/boot/dts/at91sam9263.dtsi | 23 ++++++-------
 arch/arm/boot/dts/at91sam9g45.dtsi | 33 +++++++++++-------
 arch/arm/boot/dts/at91sam9n12.dtsi | 33 +++++++++++-------
 arch/arm/boot/dts/at91sam9x5.dtsi  | 69 +++++++++++++++++---------------------
 5 files changed, 90 insertions(+), 91 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index f449efc..0ab7a3c 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -28,6 +28,7 @@
 		gpio2 = &pioC;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
 	};
 	cpus {
 		cpu@0 {
@@ -198,6 +199,15 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c@fffac000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfffac000 0x100>;
+				interrupts = <11 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc@fffe0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffe0000 0x100>;
@@ -257,17 +267,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 23 0 /* sda */
-			 &pioA 24 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 0209913..efb86dd 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -24,6 +24,7 @@
 		gpio3 = &pioD;
 		gpio4 = &pioE;
 		tcb0 = &tcb0;
+		i2c0 = &i2c0;
 	};
 	cpus {
 		cpu@0 {
@@ -179,6 +180,15 @@
 				interrupts = <24 4>;
 				status = "disabled";
 			};
+
+			i2c0: i2c@fff88000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand@40000000 {
@@ -204,17 +214,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioB 4 0 /* sda */
-			 &pioB 5 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 7dbccaf..8dd3ff8 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -29,6 +29,8 @@
 		gpio4 = &pioE;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
 	};
 	cpus {
 		cpu@0 {
@@ -200,6 +202,24 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c@fff84000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff84000 0x100>;
+				interrupts = <12 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@fff88000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc@fffb0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffb0000 0x100>;
@@ -268,17 +288,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 20 0 /* sda */
-			 &pioA 21 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <5>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index cb84de7..8a1969d 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -26,6 +26,8 @@
 		gpio3 = &pioD;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
 	};
 	cpus {
 		cpu@0 {
@@ -178,6 +180,24 @@
 				atmel,use-dma-tx;
 				status = "disabled";
 			};
+
+			i2c0: i2c@f8010000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@f8014000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand@40000000 {
@@ -205,17 +225,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 30 0 /* sda */
-			 &pioA 31 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 6b3ef43..ec56eaf 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -27,6 +27,9 @@
 		gpio3 = &pioD;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
+		i2c2 = &i2c2;
 	};
 	cpus {
 		cpu@0 {
@@ -191,6 +194,33 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c@f8010000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@f8014000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c2: i2c@f8018000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8018000 0x100>;
+				interrupts = <11 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc@f804c000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xf804c000 0x100>;
@@ -259,43 +289,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c@0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 30 0 /* sda */
-			 &pioA 31 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
-
-	i2c@1 {
-		compatible = "i2c-gpio";
-		gpios = <&pioC 0 0 /* sda */
-			 &pioC 1 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
-
-	i2c@2 {
-		compatible = "i2c-gpio";
-		gpios = <&pioB 4 0 /* sda */
-			 &pioB 5 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
-- 
1.7.11.3

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

* [PATCH 4/5] ARM: dts: add twi nodes for atmel SOCs
@ 2012-08-21 14:30         ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-08-21 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Add twi nodes for atmel SOCs and remove i2c-gpio ones.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/at91sam9260.dtsi | 23 ++++++-------
 arch/arm/boot/dts/at91sam9263.dtsi | 23 ++++++-------
 arch/arm/boot/dts/at91sam9g45.dtsi | 33 +++++++++++-------
 arch/arm/boot/dts/at91sam9n12.dtsi | 33 +++++++++++-------
 arch/arm/boot/dts/at91sam9x5.dtsi  | 69 +++++++++++++++++---------------------
 5 files changed, 90 insertions(+), 91 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index f449efc..0ab7a3c 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -28,6 +28,7 @@
 		gpio2 = &pioC;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
 	};
 	cpus {
 		cpu at 0 {
@@ -198,6 +199,15 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c at fffac000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfffac000 0x100>;
+				interrupts = <11 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc at fffe0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffe0000 0x100>;
@@ -257,17 +267,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 23 0 /* sda */
-			 &pioA 24 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 0209913..efb86dd 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -24,6 +24,7 @@
 		gpio3 = &pioD;
 		gpio4 = &pioE;
 		tcb0 = &tcb0;
+		i2c0 = &i2c0;
 	};
 	cpus {
 		cpu at 0 {
@@ -179,6 +180,15 @@
 				interrupts = <24 4>;
 				status = "disabled";
 			};
+
+			i2c0: i2c at fff88000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand at 40000000 {
@@ -204,17 +214,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioB 4 0 /* sda */
-			 &pioB 5 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 7dbccaf..8dd3ff8 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -29,6 +29,8 @@
 		gpio4 = &pioE;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
 	};
 	cpus {
 		cpu at 0 {
@@ -200,6 +202,24 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c at fff84000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff84000 0x100>;
+				interrupts = <12 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c at fff88000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc at fffb0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffb0000 0x100>;
@@ -268,17 +288,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 20 0 /* sda */
-			 &pioA 21 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <5>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index cb84de7..8a1969d 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -26,6 +26,8 @@
 		gpio3 = &pioD;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
 	};
 	cpus {
 		cpu at 0 {
@@ -178,6 +180,24 @@
 				atmel,use-dma-tx;
 				status = "disabled";
 			};
+
+			i2c0: i2c at f8010000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c at f8014000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand at 40000000 {
@@ -205,17 +225,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 30 0 /* sda */
-			 &pioA 31 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 6b3ef43..ec56eaf 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -27,6 +27,9 @@
 		gpio3 = &pioD;
 		tcb0 = &tcb0;
 		tcb1 = &tcb1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
+		i2c2 = &i2c2;
 	};
 	cpus {
 		cpu at 0 {
@@ -191,6 +194,33 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c at f8010000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c at f8014000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c2: i2c at f8018000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xf8018000 0x100>;
+				interrupts = <11 4>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc at f804c000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xf804c000 0x100>;
@@ -259,43 +289,4 @@
 			status = "disabled";
 		};
 	};
-
-	i2c at 0 {
-		compatible = "i2c-gpio";
-		gpios = <&pioA 30 0 /* sda */
-			 &pioA 31 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
-
-	i2c at 1 {
-		compatible = "i2c-gpio";
-		gpios = <&pioC 0 0 /* sda */
-			 &pioC 1 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
-
-	i2c at 2 {
-		compatible = "i2c-gpio";
-		gpios = <&pioB 4 0 /* sda */
-			 &pioB 5 0 /* scl */
-			>;
-		i2c-gpio,sda-open-drain;
-		i2c-gpio,scl-open-drain;
-		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
-		#address-cells = <1>;
-		#size-cells = <0>;
-		status = "disabled";
-	};
 };
-- 
1.7.11.3

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

* [PATCH 5/5] ARM: dts: add twi nodes for atmel boards
  2012-08-21 14:29 ` ludovic.desroches at atmel.com
@ 2012-08-21 14:32     ` ludovic.desroches at atmel.com
  -1 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-08-21 14:32 UTC (permalink / raw)
  To: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, Ludovic Desroches

From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

Use the atmel twi instead of gpio for i2c stuff.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/boot/dts/at91sam9263ek.dts         | 20 ++++++++++----------
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 28 ++++++++++++++--------------
 arch/arm/boot/dts/at91sam9g25ek.dts         | 12 ++++++++++++
 arch/arm/boot/dts/at91sam9m10g45ek.dts      | 14 ++++++++++++++
 arch/arm/boot/dts/at91sam9n12ek.dts         |  8 ++++++++
 5 files changed, 58 insertions(+), 24 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
index f86ac4b..772ab75 100644
--- a/arch/arm/boot/dts/at91sam9263ek.dts
+++ b/arch/arm/boot/dts/at91sam9263ek.dts
@@ -50,6 +50,16 @@
 				atmel,vbus-gpio = <&pioA 25 0>;
 				status = "okay";
 			};
+
+			i2c0: i2c@fff88000 {
+				status = "okay";
+
+				24c512@50 {
+					compatible = "24c512";
+					reg = <0x50>;
+					pagesize = <128>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
@@ -143,14 +153,4 @@
 			gpio-key,wakeup;
 		};
 	};
-
-	i2c@0 {
-		status = "okay";
-
-		24c512@50 {
-			compatible = "24c512";
-			reg = <0x50>;
-			pagesize = <128>;
-		};
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index b06c0db..712106b 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -51,6 +51,20 @@
 				atmel,vbus-gpio = <&pioC 5 0>;
 				status = "okay";
 			};
+
+			i2c0: i2c@fffac000 {
+				status = "okay";
+
+				24c512@50 {
+					compatible = "24c512";
+					reg = <0x50>;
+				};
+
+				wm8731@1b {
+					compatible = "wm8731";
+					reg = <0x1b>;
+				};
+			};
 		};
 
 		nand0: nand@40000000 {
@@ -106,20 +120,6 @@
 		};
 	};
 
-	i2c@0 {
-		status = "okay";
-
-		24c512@50 {
-			compatible = "24c512";
-			reg = <0x50>;
-		};
-
-		wm8731@1b {
-			compatible = "wm8731";
-			reg = <0x1b>;
-		};
-	};
-
 	gpio_keys {
 		compatible = "gpio-keys";
 		#address-cells = <1>;
diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
index 7829a4d..3b0adbc 100644
--- a/arch/arm/boot/dts/at91sam9g25ek.dts
+++ b/arch/arm/boot/dts/at91sam9g25ek.dts
@@ -32,6 +32,18 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			i2c0: i2c@f8010000 {
+				status = "okay";
+			};
+
+			i2c1: i2c@f8014000 {
+				status = "okay";
+			};
+
+			i2c2: i2c@f8018000 {
+				status = "okay";
+			};
 		};
 
 		usb0: ohci@00600000 {
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index a3633bd..4f94f23 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -46,6 +46,20 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			i2c0: i2c@fff84000 {
+				status = "okay";
+
+				24c512@50 {
+					compatible = "24c512";
+					reg = <0x50>;
+					pagesize = <128>;
+				};
+			};
+			
+			i2c1: i2c@fff88000 {
+				status = "okay";
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
index f4e43e3..912b2c2 100644
--- a/arch/arm/boot/dts/at91sam9n12ek.dts
+++ b/arch/arm/boot/dts/at91sam9n12ek.dts
@@ -37,6 +37,14 @@
 			dbgu: serial@fffff200 {
 				status = "okay";
 			};
+
+			i2c0: i2c@f8010000 {
+				status = "okay";
+			};
+
+			i2c1: i2c@f8014000 {
+				status = "okay";
+			};
 		};
 
 		nand0: nand@40000000 {
-- 
1.7.11.3

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

* [PATCH 5/5] ARM: dts: add twi nodes for atmel boards
@ 2012-08-21 14:32     ` ludovic.desroches at atmel.com
  0 siblings, 0 replies; 28+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-08-21 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Ludovic Desroches <ludovic.desroches@atmel.com>

Use the atmel twi instead of gpio for i2c stuff.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 arch/arm/boot/dts/at91sam9263ek.dts         | 20 ++++++++++----------
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 28 ++++++++++++++--------------
 arch/arm/boot/dts/at91sam9g25ek.dts         | 12 ++++++++++++
 arch/arm/boot/dts/at91sam9m10g45ek.dts      | 14 ++++++++++++++
 arch/arm/boot/dts/at91sam9n12ek.dts         |  8 ++++++++
 5 files changed, 58 insertions(+), 24 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
index f86ac4b..772ab75 100644
--- a/arch/arm/boot/dts/at91sam9263ek.dts
+++ b/arch/arm/boot/dts/at91sam9263ek.dts
@@ -50,6 +50,16 @@
 				atmel,vbus-gpio = <&pioA 25 0>;
 				status = "okay";
 			};
+
+			i2c0: i2c at fff88000 {
+				status = "okay";
+
+				24c512 at 50 {
+					compatible = "24c512";
+					reg = <0x50>;
+					pagesize = <128>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
@@ -143,14 +153,4 @@
 			gpio-key,wakeup;
 		};
 	};
-
-	i2c at 0 {
-		status = "okay";
-
-		24c512 at 50 {
-			compatible = "24c512";
-			reg = <0x50>;
-			pagesize = <128>;
-		};
-	};
 };
diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index b06c0db..712106b 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -51,6 +51,20 @@
 				atmel,vbus-gpio = <&pioC 5 0>;
 				status = "okay";
 			};
+
+			i2c0: i2c at fffac000 {
+				status = "okay";
+
+				24c512 at 50 {
+					compatible = "24c512";
+					reg = <0x50>;
+				};
+
+				wm8731 at 1b {
+					compatible = "wm8731";
+					reg = <0x1b>;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
@@ -106,20 +120,6 @@
 		};
 	};
 
-	i2c at 0 {
-		status = "okay";
-
-		24c512 at 50 {
-			compatible = "24c512";
-			reg = <0x50>;
-		};
-
-		wm8731 at 1b {
-			compatible = "wm8731";
-			reg = <0x1b>;
-		};
-	};
-
 	gpio_keys {
 		compatible = "gpio-keys";
 		#address-cells = <1>;
diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
index 7829a4d..3b0adbc 100644
--- a/arch/arm/boot/dts/at91sam9g25ek.dts
+++ b/arch/arm/boot/dts/at91sam9g25ek.dts
@@ -32,6 +32,18 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			i2c0: i2c at f8010000 {
+				status = "okay";
+			};
+
+			i2c1: i2c at f8014000 {
+				status = "okay";
+			};
+
+			i2c2: i2c at f8018000 {
+				status = "okay";
+			};
 		};
 
 		usb0: ohci at 00600000 {
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index a3633bd..4f94f23 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -46,6 +46,20 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			i2c0: i2c at fff84000 {
+				status = "okay";
+
+				24c512 at 50 {
+					compatible = "24c512";
+					reg = <0x50>;
+					pagesize = <128>;
+				};
+			};
+			
+			i2c1: i2c at fff88000 {
+				status = "okay";
+			};
 		};
 
 		nand0: nand at 40000000 {
diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
index f4e43e3..912b2c2 100644
--- a/arch/arm/boot/dts/at91sam9n12ek.dts
+++ b/arch/arm/boot/dts/at91sam9n12ek.dts
@@ -37,6 +37,14 @@
 			dbgu: serial at fffff200 {
 				status = "okay";
 			};
+
+			i2c0: i2c at f8010000 {
+				status = "okay";
+			};
+
+			i2c1: i2c at f8014000 {
+				status = "okay";
+			};
 		};
 
 		nand0: nand at 40000000 {
-- 
1.7.11.3

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

* Re: [PATCH 1/5] i2c: at91: add new fixes for some TWI ip versions
  2012-08-21 14:29     ` ludovic.desroches at atmel.com
@ 2012-08-21 16:04         ` Nicolas Ferre
  -1 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:04 UTC (permalink / raw)
  To: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  Cc: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	plagnioj-sclMFOaUSTBWk0Htik3J/w

On 08/21/2012 04:29 PM, ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org :
> From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> 
> The at91sam9261 TWI ip version requires also some fixes. The id_entry
> field from the platform device structure has been replaced by the use
> of cpu_is_xxx function to determine when to use these fixes.

No, for this one. The current tendency is to remove the use of
cpu_is_xxx() functions.

So yes, you will have to keep the use of struct platform_device_id in
this driver and extend it with the device tree information.

> Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> ---
>  arch/arm/mach-at91/at91rm9200_devices.c |  9 -------
>  drivers/i2c/busses/i2c-at91.c           | 42 +++++++++++++++++++--------------
>  2 files changed, 24 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
> index 2b9b493..e6b7d05 100644
> --- a/arch/arm/mach-at91/at91rm9200_devices.c
> +++ b/arch/arm/mach-at91/at91rm9200_devices.c
> @@ -494,18 +494,9 @@ static struct resource twi_resources[] = {
>  	},
>  };
>  
> -static const struct platform_device_id twi_id = {
> -	/*
> -	 * driver_data is "1" for hardware with ckdiv upper limit == 5
> -	 * (AT91RM9200 erratum 22), "0" for twi modules without this bug
> -	 */
> -	.driver_data	= 1,
> -};
> -
>  static struct platform_device at91rm9200_twi_device = {
>  	.name		= "at91_i2c",
>  	.id		= -1,
> -	.id_entry	= &twi_id,
>  	.resource	= twi_resources,
>  	.num_resources	= ARRAY_SIZE(twi_resources),
>  };
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index b1cb780..4599522 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -27,6 +27,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  
> +#include <mach/cpu.h>
> +
>  #define TWI_CLK_HZ		100000			/* max 400 Kbits/s */
>  #define AT91_I2C_TIMEOUT	msecs_to_jiffies(100)	/* transfer timeout */
>  
> @@ -72,7 +74,6 @@ struct at91_twi_dev {
>  	int			irq;
>  	unsigned		transfer_status;
>  	struct i2c_adapter	adapter;
> -	bool			is_rm9200;
>  	unsigned		twi_cwgr_reg;
>  };
>  
> @@ -111,20 +112,28 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
>   */
>  static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  {
> -	const int offset = dev->is_rm9200 ? 3 : 4;
> -	const int div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
> -						 2 * twi_clk) - offset);
> -	int ckdiv = fls(div >> 8);
> -	int cdiv = div >> ckdiv;
> -
> -	if (dev->is_rm9200 && (ckdiv > 5)) {
> -		dev_warn(dev->dev, "AT91RM9200 erratum 22: using ckdiv = 5.\n");
> -		ckdiv = 5;
> -		cdiv = 255;
> -	} else if (ckdiv > 7) {
> -		dev_warn(dev->dev, "%d exceeds 3 bits for ckdiv, limiting.\n",
> -			 ckdiv);
> -		ckdiv = 7;
> +	int offset, div, max_ckdiv, ckdiv, cdiv;
> +
> +	if (cpu_is_at91rm9200()) {
> +		offset = 3;
> +		max_ckdiv = 5;
> +	} else if (cpu_is_at91sam9261()) {
> +		offset = 4;
> +		max_ckdiv = 5;
> +	} else {
> +		offset = 4;
> +		max_ckdiv = 7;
> +	}
> +
> +	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
> +				       2 * twi_clk) - offset);
> +	ckdiv = fls(div >> 8);
> +	cdiv = div >> ckdiv;
> +
> +	if (ckdiv > max_ckdiv) {
> +		dev_warn(dev->dev, "%d exceeds ckdiv max value which is %d.\n",
> +			 ckdiv, max_ckdiv);
> +		ckdiv = max_ckdiv;
>  		cdiv = 255;
>  	}
>  
> @@ -331,9 +340,6 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
>  		goto err_release_region;
>  	}
>  
> -	if (pdev->id_entry && pdev->id_entry->driver_data == 1)
> -		dev->is_rm9200 = 1;
> -
>  	init_completion(&dev->cmd_complete);
>  
>  	dev->dev = &pdev->dev;
> 


-- 
Nicolas Ferre

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

* [PATCH 1/5] i2c: at91: add new fixes for some TWI ip versions
@ 2012-08-21 16:04         ` Nicolas Ferre
  0 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:04 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/21/2012 04:29 PM, ludovic.desroches at atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> The at91sam9261 TWI ip version requires also some fixes. The id_entry
> field from the platform device structure has been replaced by the use
> of cpu_is_xxx function to determine when to use these fixes.

No, for this one. The current tendency is to remove the use of
cpu_is_xxx() functions.

So yes, you will have to keep the use of struct platform_device_id in
this driver and extend it with the device tree information.

> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/mach-at91/at91rm9200_devices.c |  9 -------
>  drivers/i2c/busses/i2c-at91.c           | 42 +++++++++++++++++++--------------
>  2 files changed, 24 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
> index 2b9b493..e6b7d05 100644
> --- a/arch/arm/mach-at91/at91rm9200_devices.c
> +++ b/arch/arm/mach-at91/at91rm9200_devices.c
> @@ -494,18 +494,9 @@ static struct resource twi_resources[] = {
>  	},
>  };
>  
> -static const struct platform_device_id twi_id = {
> -	/*
> -	 * driver_data is "1" for hardware with ckdiv upper limit == 5
> -	 * (AT91RM9200 erratum 22), "0" for twi modules without this bug
> -	 */
> -	.driver_data	= 1,
> -};
> -
>  static struct platform_device at91rm9200_twi_device = {
>  	.name		= "at91_i2c",
>  	.id		= -1,
> -	.id_entry	= &twi_id,
>  	.resource	= twi_resources,
>  	.num_resources	= ARRAY_SIZE(twi_resources),
>  };
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index b1cb780..4599522 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -27,6 +27,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  
> +#include <mach/cpu.h>
> +
>  #define TWI_CLK_HZ		100000			/* max 400 Kbits/s */
>  #define AT91_I2C_TIMEOUT	msecs_to_jiffies(100)	/* transfer timeout */
>  
> @@ -72,7 +74,6 @@ struct at91_twi_dev {
>  	int			irq;
>  	unsigned		transfer_status;
>  	struct i2c_adapter	adapter;
> -	bool			is_rm9200;
>  	unsigned		twi_cwgr_reg;
>  };
>  
> @@ -111,20 +112,28 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
>   */
>  static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  {
> -	const int offset = dev->is_rm9200 ? 3 : 4;
> -	const int div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
> -						 2 * twi_clk) - offset);
> -	int ckdiv = fls(div >> 8);
> -	int cdiv = div >> ckdiv;
> -
> -	if (dev->is_rm9200 && (ckdiv > 5)) {
> -		dev_warn(dev->dev, "AT91RM9200 erratum 22: using ckdiv = 5.\n");
> -		ckdiv = 5;
> -		cdiv = 255;
> -	} else if (ckdiv > 7) {
> -		dev_warn(dev->dev, "%d exceeds 3 bits for ckdiv, limiting.\n",
> -			 ckdiv);
> -		ckdiv = 7;
> +	int offset, div, max_ckdiv, ckdiv, cdiv;
> +
> +	if (cpu_is_at91rm9200()) {
> +		offset = 3;
> +		max_ckdiv = 5;
> +	} else if (cpu_is_at91sam9261()) {
> +		offset = 4;
> +		max_ckdiv = 5;
> +	} else {
> +		offset = 4;
> +		max_ckdiv = 7;
> +	}
> +
> +	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
> +				       2 * twi_clk) - offset);
> +	ckdiv = fls(div >> 8);
> +	cdiv = div >> ckdiv;
> +
> +	if (ckdiv > max_ckdiv) {
> +		dev_warn(dev->dev, "%d exceeds ckdiv max value which is %d.\n",
> +			 ckdiv, max_ckdiv);
> +		ckdiv = max_ckdiv;
>  		cdiv = 255;
>  	}
>  
> @@ -331,9 +340,6 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
>  		goto err_release_region;
>  	}
>  
> -	if (pdev->id_entry && pdev->id_entry->driver_data == 1)
> -		dev->is_rm9200 = 1;
> -
>  	init_completion(&dev->cmd_complete);
>  
>  	dev->dev = &pdev->dev;
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 2/5] i2c: at91: add dt support to i2c-at91
  2012-08-21 14:29     ` ludovic.desroches at atmel.com
@ 2012-08-21 16:08         ` Nicolas Ferre
  -1 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:08 UTC (permalink / raw)
  To: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  Cc: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	plagnioj-sclMFOaUSTBWk0Htik3J/w

On 08/21/2012 04:29 PM, ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org :
> From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> ---
>  .../devicetree/bindings/i2c/atmel-i2c.txt          | 29 +++++++++++++
>  drivers/i2c/busses/i2c-at91.c                      | 49 +++++++++++++++++-----
>  2 files changed, 68 insertions(+), 10 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt
> 
> diff --git a/Documentation/devicetree/bindings/i2c/atmel-i2c.txt b/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
> new file mode 100644
> index 0000000..9e46289
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
> @@ -0,0 +1,29 @@
> +I2C for Atmel platforms
> +
> +Required properties :
> +- compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c" or
> +     "atmel,at91sam9g20-i2c"
> +- reg: physical base address of the controller and length of memory mapped
> +     region.
> +- interrupts: interrupt number to the cpu.
> +- #address-cells = <1>;
> +- #size-cells = <0>;
> +
> +Optional properties:
> +- Child nodes conforming to i2c bus binding
> +
> +Examples :
> +
> +i2c0: i2c@fff84000 {
> +	compatible = "atmel,at91sam9g20-i2c";
> +	reg = <0xfff84000 0x100>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	24c512@50 {
> +		compatible = "24c512";
> +		reg = <0x50>;
> +		pagesize = <128>;
> +	}
> +}
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 4599522..1c86b24 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -24,6 +24,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_i2c.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  
> @@ -112,17 +115,27 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
>   */
>  static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  {
> -	int offset, div, max_ckdiv, ckdiv, cdiv;
> -
> -	if (cpu_is_at91rm9200()) {
> -		offset = 3;
> -		max_ckdiv = 5;
> -	} else if (cpu_is_at91sam9261()) {
> -		offset = 4;
> -		max_ckdiv = 5;
> +	int offset = 4, max_ckdiv = 7;
> +	int div, ckdiv, cdiv;
> +
> +	if (dev->dev->of_node) {
> +		if (of_device_is_compatible(dev->dev->of_node,
> +					    "atmel,at91rm9200-i2c")) {
> +			offset = 3;
> +			max_ckdiv = 5;
> +		} else if (of_device_is_compatible(dev->dev->of_node,
> +						   "atmel,at91sam9261-i2c")) {
> +			offset = 4;
> +			max_ckdiv = 5;
> +		}
>  	} else {
> -		offset = 4;
> -		max_ckdiv = 7;
> +		if (cpu_is_at91rm9200()) {
> +			offset = 3;
> +			max_ckdiv = 5;
> +		} else if (cpu_is_at91sam9261()) {

Héhé ;-) here also, you will have to review this part...

> +			offset = 4;
> +			max_ckdiv = 5;
> +		}
>  	}
>  
>  	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
> @@ -379,6 +392,7 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
>  	dev->adapter.dev.parent = dev->dev;
>  	dev->adapter.nr = pdev->id;
>  	dev->adapter.timeout = AT91_I2C_TIMEOUT;
> +	dev->adapter.dev.of_node = pdev->dev.of_node;
>  
>  	rc = i2c_add_numbered_adapter(&dev->adapter);
>  	if (rc) {
> @@ -387,6 +401,8 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
>  		goto err_free_irq;
>  	}
>  
> +	of_i2c_register_devices(&dev->adapter);
> +
>  	dev_info(dev->dev, "AT91 i2c bus driver.\n");
>  	return 0;
>  
> @@ -454,12 +470,25 @@ static const struct dev_pm_ops at91_twi_pm = {
>  #define at91_twi_pm_ops NULL
>  #endif
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id at91_twi_dt_ids[] = {
> +	{ .compatible = "atmel,at91rm9200-i2c", },
> +	{ .compatible = "atmel,at91sam9260-i2c", },
> +	{ .compatible = "atmel,at91sam9261-i2c", },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, at91_twi_dt_ids);
> +#else
> +#define at91_twi_dt_ids NULL
> +#endif
> +
>  static struct platform_driver at91_twi_driver = {
>  	.probe		= at91_twi_probe,
>  	.remove		= __devexit_p(at91_twi_remove),
>  	.driver		= {
>  		.name	= "at91_i2c",
>  		.owner	= THIS_MODULE,
> +		.of_match_table = at91_twi_dt_ids,
>  		.pm	= at91_twi_pm_ops,
>  	},
>  };
> 


-- 
Nicolas Ferre

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

* [PATCH 2/5] i2c: at91: add dt support to i2c-at91
@ 2012-08-21 16:08         ` Nicolas Ferre
  0 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:08 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/21/2012 04:29 PM, ludovic.desroches at atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  .../devicetree/bindings/i2c/atmel-i2c.txt          | 29 +++++++++++++
>  drivers/i2c/busses/i2c-at91.c                      | 49 +++++++++++++++++-----
>  2 files changed, 68 insertions(+), 10 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt
> 
> diff --git a/Documentation/devicetree/bindings/i2c/atmel-i2c.txt b/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
> new file mode 100644
> index 0000000..9e46289
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
> @@ -0,0 +1,29 @@
> +I2C for Atmel platforms
> +
> +Required properties :
> +- compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c" or
> +     "atmel,at91sam9g20-i2c"
> +- reg: physical base address of the controller and length of memory mapped
> +     region.
> +- interrupts: interrupt number to the cpu.
> +- #address-cells = <1>;
> +- #size-cells = <0>;
> +
> +Optional properties:
> +- Child nodes conforming to i2c bus binding
> +
> +Examples :
> +
> +i2c0: i2c at fff84000 {
> +	compatible = "atmel,at91sam9g20-i2c";
> +	reg = <0xfff84000 0x100>;
> +	interrupts = <12 4>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	24c512 at 50 {
> +		compatible = "24c512";
> +		reg = <0x50>;
> +		pagesize = <128>;
> +	}
> +}
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 4599522..1c86b24 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -24,6 +24,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_i2c.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  
> @@ -112,17 +115,27 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
>   */
>  static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  {
> -	int offset, div, max_ckdiv, ckdiv, cdiv;
> -
> -	if (cpu_is_at91rm9200()) {
> -		offset = 3;
> -		max_ckdiv = 5;
> -	} else if (cpu_is_at91sam9261()) {
> -		offset = 4;
> -		max_ckdiv = 5;
> +	int offset = 4, max_ckdiv = 7;
> +	int div, ckdiv, cdiv;
> +
> +	if (dev->dev->of_node) {
> +		if (of_device_is_compatible(dev->dev->of_node,
> +					    "atmel,at91rm9200-i2c")) {
> +			offset = 3;
> +			max_ckdiv = 5;
> +		} else if (of_device_is_compatible(dev->dev->of_node,
> +						   "atmel,at91sam9261-i2c")) {
> +			offset = 4;
> +			max_ckdiv = 5;
> +		}
>  	} else {
> -		offset = 4;
> -		max_ckdiv = 7;
> +		if (cpu_is_at91rm9200()) {
> +			offset = 3;
> +			max_ckdiv = 5;
> +		} else if (cpu_is_at91sam9261()) {

H?h? ;-) here also, you will have to review this part...

> +			offset = 4;
> +			max_ckdiv = 5;
> +		}
>  	}
>  
>  	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
> @@ -379,6 +392,7 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
>  	dev->adapter.dev.parent = dev->dev;
>  	dev->adapter.nr = pdev->id;
>  	dev->adapter.timeout = AT91_I2C_TIMEOUT;
> +	dev->adapter.dev.of_node = pdev->dev.of_node;
>  
>  	rc = i2c_add_numbered_adapter(&dev->adapter);
>  	if (rc) {
> @@ -387,6 +401,8 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
>  		goto err_free_irq;
>  	}
>  
> +	of_i2c_register_devices(&dev->adapter);
> +
>  	dev_info(dev->dev, "AT91 i2c bus driver.\n");
>  	return 0;
>  
> @@ -454,12 +470,25 @@ static const struct dev_pm_ops at91_twi_pm = {
>  #define at91_twi_pm_ops NULL
>  #endif
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id at91_twi_dt_ids[] = {
> +	{ .compatible = "atmel,at91rm9200-i2c", },
> +	{ .compatible = "atmel,at91sam9260-i2c", },
> +	{ .compatible = "atmel,at91sam9261-i2c", },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, at91_twi_dt_ids);
> +#else
> +#define at91_twi_dt_ids NULL
> +#endif
> +
>  static struct platform_driver at91_twi_driver = {
>  	.probe		= at91_twi_probe,
>  	.remove		= __devexit_p(at91_twi_remove),
>  	.driver		= {
>  		.name	= "at91_i2c",
>  		.owner	= THIS_MODULE,
> +		.of_match_table = at91_twi_dt_ids,
>  		.pm	= at91_twi_pm_ops,
>  	},
>  };
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 3/5] ARM: at91: add clocks for i2c DT entries
  2012-08-21 14:29     ` ludovic.desroches at atmel.com
@ 2012-08-21 16:08         ` Nicolas Ferre
  -1 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:08 UTC (permalink / raw)
  To: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  Cc: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	plagnioj-sclMFOaUSTBWk0Htik3J/w

On 08/21/2012 04:29 PM, ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org :
> From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

> ---
>  arch/arm/mach-at91/at91sam9260.c | 1 +
>  arch/arm/mach-at91/at91sam9263.c | 1 +
>  arch/arm/mach-at91/at91sam9g45.c | 2 ++
>  arch/arm/mach-at91/at91sam9n12.c | 2 ++
>  arch/arm/mach-at91/at91sam9x5.c  | 3 +++
>  5 files changed, 9 insertions(+)
> 
> diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
> index 2e56321..f3fdca7 100644
> --- a/arch/arm/mach-at91/at91sam9260.c
> +++ b/arch/arm/mach-at91/at91sam9260.c
> @@ -227,6 +227,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
>  	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
>  	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "fffac000.i2c", &twi_clk),
>  	/* fake hclk clock */
>  	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
>  	CLKDEV_CON_ID("pioA", &pioA_clk),
> diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
> index 71305fa..15458ad 100644
> --- a/arch/arm/mach-at91/at91sam9263.c
> +++ b/arch/arm/mach-at91/at91sam9263.c
> @@ -210,6 +210,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("hclk", "a00000.ohci", &ohci_clk),
>  	CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk),
>  	CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi_clk),
>  };
>  
>  static struct clk_lookup usart_clocks_lookups[] = {
> diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
> index 2944fc7..dcc4e3c 100644
> --- a/arch/arm/mach-at91/at91sam9g45.c
> +++ b/arch/arm/mach-at91/at91sam9g45.c
> @@ -244,6 +244,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
>  	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
>  	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "fff84000.i2c", &twi0_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi1_clk),
>  	/* fake hclk clock */
>  	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
>  	CLKDEV_CON_ID("pioA", &pioA_clk),
> diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
> index 0849466..732d3d3 100644
> --- a/arch/arm/mach-at91/at91sam9n12.c
> +++ b/arch/arm/mach-at91/at91sam9n12.c
> @@ -169,6 +169,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb_clk),
>  	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
>  	CLKDEV_CON_ID("pioA", &pioAB_clk),
>  	CLKDEV_CON_ID("pioB", &pioAB_clk),
>  	CLKDEV_CON_ID("pioC", &pioCD_clk),
> diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
> index 1b144b4..744ffc2 100644
> --- a/arch/arm/mach-at91/at91sam9x5.c
> +++ b/arch/arm/mach-at91/at91sam9x5.c
> @@ -231,6 +231,9 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8018000.i2c", &twi2_clk),
>  	CLKDEV_CON_ID("pioA", &pioAB_clk),
>  	CLKDEV_CON_ID("pioB", &pioAB_clk),
>  	CLKDEV_CON_ID("pioC", &pioCD_clk),
> 


-- 
Nicolas Ferre

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

* [PATCH 3/5] ARM: at91: add clocks for i2c DT entries
@ 2012-08-21 16:08         ` Nicolas Ferre
  0 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:08 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/21/2012 04:29 PM, ludovic.desroches at atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>  arch/arm/mach-at91/at91sam9260.c | 1 +
>  arch/arm/mach-at91/at91sam9263.c | 1 +
>  arch/arm/mach-at91/at91sam9g45.c | 2 ++
>  arch/arm/mach-at91/at91sam9n12.c | 2 ++
>  arch/arm/mach-at91/at91sam9x5.c  | 3 +++
>  5 files changed, 9 insertions(+)
> 
> diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
> index 2e56321..f3fdca7 100644
> --- a/arch/arm/mach-at91/at91sam9260.c
> +++ b/arch/arm/mach-at91/at91sam9260.c
> @@ -227,6 +227,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
>  	CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
>  	CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "fffac000.i2c", &twi_clk),
>  	/* fake hclk clock */
>  	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
>  	CLKDEV_CON_ID("pioA", &pioA_clk),
> diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
> index 71305fa..15458ad 100644
> --- a/arch/arm/mach-at91/at91sam9263.c
> +++ b/arch/arm/mach-at91/at91sam9263.c
> @@ -210,6 +210,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("hclk", "a00000.ohci", &ohci_clk),
>  	CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk),
>  	CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi_clk),
>  };
>  
>  static struct clk_lookup usart_clocks_lookups[] = {
> diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
> index 2944fc7..dcc4e3c 100644
> --- a/arch/arm/mach-at91/at91sam9g45.c
> +++ b/arch/arm/mach-at91/at91sam9g45.c
> @@ -244,6 +244,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
>  	CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
>  	CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "fff84000.i2c", &twi0_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi1_clk),
>  	/* fake hclk clock */
>  	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
>  	CLKDEV_CON_ID("pioA", &pioA_clk),
> diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
> index 0849466..732d3d3 100644
> --- a/arch/arm/mach-at91/at91sam9n12.c
> +++ b/arch/arm/mach-at91/at91sam9n12.c
> @@ -169,6 +169,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb_clk),
>  	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
>  	CLKDEV_CON_ID("pioA", &pioAB_clk),
>  	CLKDEV_CON_ID("pioB", &pioAB_clk),
>  	CLKDEV_CON_ID("pioC", &pioCD_clk),
> diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
> index 1b144b4..744ffc2 100644
> --- a/arch/arm/mach-at91/at91sam9x5.c
> +++ b/arch/arm/mach-at91/at91sam9x5.c
> @@ -231,6 +231,9 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
>  	CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
> +	CLKDEV_CON_DEV_ID(NULL, "f8018000.i2c", &twi2_clk),
>  	CLKDEV_CON_ID("pioA", &pioAB_clk),
>  	CLKDEV_CON_ID("pioB", &pioAB_clk),
>  	CLKDEV_CON_ID("pioC", &pioCD_clk),
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 4/5] ARM: dts: add twi nodes for atmel SOCs
  2012-08-21 14:29     ` ludovic.desroches at atmel.com
@ 2012-08-21 16:10         ` Nicolas Ferre
  -1 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:10 UTC (permalink / raw)
  To: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  Cc: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	plagnioj-sclMFOaUSTBWk0Htik3J/w

On 08/21/2012 04:29 PM, ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org :
> From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> 
> Add twi nodes for atmel SOCs and remove i2c-gpio ones.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

Yes, we will move to it once people test it a little bit...

Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

> ---
>  arch/arm/boot/dts/at91sam9260.dtsi | 23 ++++++-------
>  arch/arm/boot/dts/at91sam9263.dtsi | 23 ++++++-------
>  arch/arm/boot/dts/at91sam9g45.dtsi | 33 +++++++++++-------
>  arch/arm/boot/dts/at91sam9n12.dtsi | 33 +++++++++++-------
>  arch/arm/boot/dts/at91sam9x5.dtsi  | 69 +++++++++++++++++---------------------
>  5 files changed, 90 insertions(+), 91 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
> index f449efc..0ab7a3c 100644
> --- a/arch/arm/boot/dts/at91sam9260.dtsi
> +++ b/arch/arm/boot/dts/at91sam9260.dtsi
> @@ -28,6 +28,7 @@
>  		gpio2 = &pioC;
>  		tcb0 = &tcb0;
>  		tcb1 = &tcb1;
> +		i2c0 = &i2c0;
>  	};
>  	cpus {
>  		cpu@0 {
> @@ -198,6 +199,15 @@
>  				status = "disabled";
>  			};
>  
> +			i2c0: i2c@fffac000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xfffac000 0x100>;
> +				interrupts = <11 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
>  			adc0: adc@fffe0000 {
>  				compatible = "atmel,at91sam9260-adc";
>  				reg = <0xfffe0000 0x100>;
> @@ -257,17 +267,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c@0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioA 23 0 /* sda */
> -			 &pioA 24 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
> index 0209913..efb86dd 100644
> --- a/arch/arm/boot/dts/at91sam9263.dtsi
> +++ b/arch/arm/boot/dts/at91sam9263.dtsi
> @@ -24,6 +24,7 @@
>  		gpio3 = &pioD;
>  		gpio4 = &pioE;
>  		tcb0 = &tcb0;
> +		i2c0 = &i2c0;
>  	};
>  	cpus {
>  		cpu@0 {
> @@ -179,6 +180,15 @@
>  				interrupts = <24 4>;
>  				status = "disabled";
>  			};
> +
> +			i2c0: i2c@fff88000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xfff88000 0x100>;
> +				interrupts = <13 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
>  		};
>  
>  		nand0: nand@40000000 {
> @@ -204,17 +214,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c@0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioB 4 0 /* sda */
> -			 &pioB 5 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
> index 7dbccaf..8dd3ff8 100644
> --- a/arch/arm/boot/dts/at91sam9g45.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g45.dtsi
> @@ -29,6 +29,8 @@
>  		gpio4 = &pioE;
>  		tcb0 = &tcb0;
>  		tcb1 = &tcb1;
> +		i2c0 = &i2c0;
> +		i2c1 = &i2c1;
>  	};
>  	cpus {
>  		cpu@0 {
> @@ -200,6 +202,24 @@
>  				status = "disabled";
>  			};
>  
> +			i2c0: i2c@fff84000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xfff84000 0x100>;
> +				interrupts = <12 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
> +			i2c1: i2c@fff88000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xfff88000 0x100>;
> +				interrupts = <13 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
>  			adc0: adc@fffb0000 {
>  				compatible = "atmel,at91sam9260-adc";
>  				reg = <0xfffb0000 0x100>;
> @@ -268,17 +288,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c@0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioA 20 0 /* sda */
> -			 &pioA 21 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <5>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
> index cb84de7..8a1969d 100644
> --- a/arch/arm/boot/dts/at91sam9n12.dtsi
> +++ b/arch/arm/boot/dts/at91sam9n12.dtsi
> @@ -26,6 +26,8 @@
>  		gpio3 = &pioD;
>  		tcb0 = &tcb0;
>  		tcb1 = &tcb1;
> +		i2c0 = &i2c0;
> +		i2c1 = &i2c1;
>  	};
>  	cpus {
>  		cpu@0 {
> @@ -178,6 +180,24 @@
>  				atmel,use-dma-tx;
>  				status = "disabled";
>  			};
> +
> +			i2c0: i2c@f8010000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8010000 0x100>;
> +				interrupts = <9 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
> +			i2c1: i2c@f8014000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8014000 0x100>;
> +				interrupts = <10 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
>  		};
>  
>  		nand0: nand@40000000 {
> @@ -205,17 +225,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c@0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioA 30 0 /* sda */
> -			 &pioA 31 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
> index 6b3ef43..ec56eaf 100644
> --- a/arch/arm/boot/dts/at91sam9x5.dtsi
> +++ b/arch/arm/boot/dts/at91sam9x5.dtsi
> @@ -27,6 +27,9 @@
>  		gpio3 = &pioD;
>  		tcb0 = &tcb0;
>  		tcb1 = &tcb1;
> +		i2c0 = &i2c0;
> +		i2c1 = &i2c1;
> +		i2c2 = &i2c2;
>  	};
>  	cpus {
>  		cpu@0 {
> @@ -191,6 +194,33 @@
>  				status = "disabled";
>  			};
>  
> +			i2c0: i2c@f8010000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8010000 0x100>;
> +				interrupts = <9 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
> +			i2c1: i2c@f8014000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8014000 0x100>;
> +				interrupts = <10 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
> +			i2c2: i2c@f8018000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8018000 0x100>;
> +				interrupts = <11 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
>  			adc0: adc@f804c000 {
>  				compatible = "atmel,at91sam9260-adc";
>  				reg = <0xf804c000 0x100>;
> @@ -259,43 +289,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c@0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioA 30 0 /* sda */
> -			 &pioA 31 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
> -
> -	i2c@1 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioC 0 0 /* sda */
> -			 &pioC 1 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
> -
> -	i2c@2 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioB 4 0 /* sda */
> -			 &pioB 5 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> 


-- 
Nicolas Ferre

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

* [PATCH 4/5] ARM: dts: add twi nodes for atmel SOCs
@ 2012-08-21 16:10         ` Nicolas Ferre
  0 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:10 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/21/2012 04:29 PM, ludovic.desroches at atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Add twi nodes for atmel SOCs and remove i2c-gpio ones.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Yes, we will move to it once people test it a little bit...

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>  arch/arm/boot/dts/at91sam9260.dtsi | 23 ++++++-------
>  arch/arm/boot/dts/at91sam9263.dtsi | 23 ++++++-------
>  arch/arm/boot/dts/at91sam9g45.dtsi | 33 +++++++++++-------
>  arch/arm/boot/dts/at91sam9n12.dtsi | 33 +++++++++++-------
>  arch/arm/boot/dts/at91sam9x5.dtsi  | 69 +++++++++++++++++---------------------
>  5 files changed, 90 insertions(+), 91 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
> index f449efc..0ab7a3c 100644
> --- a/arch/arm/boot/dts/at91sam9260.dtsi
> +++ b/arch/arm/boot/dts/at91sam9260.dtsi
> @@ -28,6 +28,7 @@
>  		gpio2 = &pioC;
>  		tcb0 = &tcb0;
>  		tcb1 = &tcb1;
> +		i2c0 = &i2c0;
>  	};
>  	cpus {
>  		cpu at 0 {
> @@ -198,6 +199,15 @@
>  				status = "disabled";
>  			};
>  
> +			i2c0: i2c at fffac000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xfffac000 0x100>;
> +				interrupts = <11 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
>  			adc0: adc at fffe0000 {
>  				compatible = "atmel,at91sam9260-adc";
>  				reg = <0xfffe0000 0x100>;
> @@ -257,17 +267,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c at 0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioA 23 0 /* sda */
> -			 &pioA 24 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
> index 0209913..efb86dd 100644
> --- a/arch/arm/boot/dts/at91sam9263.dtsi
> +++ b/arch/arm/boot/dts/at91sam9263.dtsi
> @@ -24,6 +24,7 @@
>  		gpio3 = &pioD;
>  		gpio4 = &pioE;
>  		tcb0 = &tcb0;
> +		i2c0 = &i2c0;
>  	};
>  	cpus {
>  		cpu at 0 {
> @@ -179,6 +180,15 @@
>  				interrupts = <24 4>;
>  				status = "disabled";
>  			};
> +
> +			i2c0: i2c at fff88000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xfff88000 0x100>;
> +				interrupts = <13 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {
> @@ -204,17 +214,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c at 0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioB 4 0 /* sda */
> -			 &pioB 5 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
> index 7dbccaf..8dd3ff8 100644
> --- a/arch/arm/boot/dts/at91sam9g45.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g45.dtsi
> @@ -29,6 +29,8 @@
>  		gpio4 = &pioE;
>  		tcb0 = &tcb0;
>  		tcb1 = &tcb1;
> +		i2c0 = &i2c0;
> +		i2c1 = &i2c1;
>  	};
>  	cpus {
>  		cpu at 0 {
> @@ -200,6 +202,24 @@
>  				status = "disabled";
>  			};
>  
> +			i2c0: i2c at fff84000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xfff84000 0x100>;
> +				interrupts = <12 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
> +			i2c1: i2c at fff88000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xfff88000 0x100>;
> +				interrupts = <13 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
>  			adc0: adc at fffb0000 {
>  				compatible = "atmel,at91sam9260-adc";
>  				reg = <0xfffb0000 0x100>;
> @@ -268,17 +288,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c at 0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioA 20 0 /* sda */
> -			 &pioA 21 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <5>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
> index cb84de7..8a1969d 100644
> --- a/arch/arm/boot/dts/at91sam9n12.dtsi
> +++ b/arch/arm/boot/dts/at91sam9n12.dtsi
> @@ -26,6 +26,8 @@
>  		gpio3 = &pioD;
>  		tcb0 = &tcb0;
>  		tcb1 = &tcb1;
> +		i2c0 = &i2c0;
> +		i2c1 = &i2c1;
>  	};
>  	cpus {
>  		cpu at 0 {
> @@ -178,6 +180,24 @@
>  				atmel,use-dma-tx;
>  				status = "disabled";
>  			};
> +
> +			i2c0: i2c at f8010000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8010000 0x100>;
> +				interrupts = <9 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
> +			i2c1: i2c at f8014000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8014000 0x100>;
> +				interrupts = <10 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {
> @@ -205,17 +225,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c at 0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioA 30 0 /* sda */
> -			 &pioA 31 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
> index 6b3ef43..ec56eaf 100644
> --- a/arch/arm/boot/dts/at91sam9x5.dtsi
> +++ b/arch/arm/boot/dts/at91sam9x5.dtsi
> @@ -27,6 +27,9 @@
>  		gpio3 = &pioD;
>  		tcb0 = &tcb0;
>  		tcb1 = &tcb1;
> +		i2c0 = &i2c0;
> +		i2c1 = &i2c1;
> +		i2c2 = &i2c2;
>  	};
>  	cpus {
>  		cpu at 0 {
> @@ -191,6 +194,33 @@
>  				status = "disabled";
>  			};
>  
> +			i2c0: i2c at f8010000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8010000 0x100>;
> +				interrupts = <9 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
> +			i2c1: i2c at f8014000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8014000 0x100>;
> +				interrupts = <10 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
> +			i2c2: i2c at f8018000 {
> +				compatible = "atmel,at91sam9260-i2c";
> +				reg = <0xf8018000 0x100>;
> +				interrupts = <11 4>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				status = "disabled";
> +			};
> +
>  			adc0: adc at f804c000 {
>  				compatible = "atmel,at91sam9260-adc";
>  				reg = <0xf804c000 0x100>;
> @@ -259,43 +289,4 @@
>  			status = "disabled";
>  		};
>  	};
> -
> -	i2c at 0 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioA 30 0 /* sda */
> -			 &pioA 31 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
> -
> -	i2c at 1 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioC 0 0 /* sda */
> -			 &pioC 1 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
> -
> -	i2c at 2 {
> -		compatible = "i2c-gpio";
> -		gpios = <&pioB 4 0 /* sda */
> -			 &pioB 5 0 /* scl */
> -			>;
> -		i2c-gpio,sda-open-drain;
> -		i2c-gpio,scl-open-drain;
> -		i2c-gpio,delay-us = <2>;	/* ~100 kHz */
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -		status = "disabled";
> -	};
>  };
> 


-- 
Nicolas Ferre

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

* Re: [PATCH 5/5] ARM: dts: add twi nodes for atmel boards
  2012-08-21 14:32     ` ludovic.desroches at atmel.com
@ 2012-08-21 16:13         ` Nicolas Ferre
  -1 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:13 UTC (permalink / raw)
  To: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  Cc: n.voss-+umVssTZoCsb1SvskN2V4Q, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	plagnioj-sclMFOaUSTBWk0Htik3J/w

On 08/21/2012 04:32 PM, ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org :
> From: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
> 
> Use the atmel twi instead of gpio for i2c stuff.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

Seems good. Maybe we will have to test wm8731 a little bit more.

Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

> ---
>  arch/arm/boot/dts/at91sam9263ek.dts         | 20 ++++++++++----------
>  arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 28 ++++++++++++++--------------
>  arch/arm/boot/dts/at91sam9g25ek.dts         | 12 ++++++++++++
>  arch/arm/boot/dts/at91sam9m10g45ek.dts      | 14 ++++++++++++++
>  arch/arm/boot/dts/at91sam9n12ek.dts         |  8 ++++++++
>  5 files changed, 58 insertions(+), 24 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
> index f86ac4b..772ab75 100644
> --- a/arch/arm/boot/dts/at91sam9263ek.dts
> +++ b/arch/arm/boot/dts/at91sam9263ek.dts
> @@ -50,6 +50,16 @@
>  				atmel,vbus-gpio = <&pioA 25 0>;
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c@fff88000 {
> +				status = "okay";
> +
> +				24c512@50 {
> +					compatible = "24c512";
> +					reg = <0x50>;
> +					pagesize = <128>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand@40000000 {
> @@ -143,14 +153,4 @@
>  			gpio-key,wakeup;
>  		};
>  	};
> -
> -	i2c@0 {
> -		status = "okay";
> -
> -		24c512@50 {
> -			compatible = "24c512";
> -			reg = <0x50>;
> -			pagesize = <128>;
> -		};
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
> index b06c0db..712106b 100644
> --- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
> @@ -51,6 +51,20 @@
>  				atmel,vbus-gpio = <&pioC 5 0>;
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c@fffac000 {
> +				status = "okay";
> +
> +				24c512@50 {
> +					compatible = "24c512";
> +					reg = <0x50>;
> +				};
> +
> +				wm8731@1b {
> +					compatible = "wm8731";
> +					reg = <0x1b>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand@40000000 {
> @@ -106,20 +120,6 @@
>  		};
>  	};
>  
> -	i2c@0 {
> -		status = "okay";
> -
> -		24c512@50 {
> -			compatible = "24c512";
> -			reg = <0x50>;
> -		};
> -
> -		wm8731@1b {
> -			compatible = "wm8731";
> -			reg = <0x1b>;
> -		};
> -	};
> -
>  	gpio_keys {
>  		compatible = "gpio-keys";
>  		#address-cells = <1>;
> diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
> index 7829a4d..3b0adbc 100644
> --- a/arch/arm/boot/dts/at91sam9g25ek.dts
> +++ b/arch/arm/boot/dts/at91sam9g25ek.dts
> @@ -32,6 +32,18 @@
>  				phy-mode = "rmii";
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c@f8010000 {
> +				status = "okay";
> +			};
> +
> +			i2c1: i2c@f8014000 {
> +				status = "okay";
> +			};
> +
> +			i2c2: i2c@f8018000 {
> +				status = "okay";
> +			};
>  		};
>  
>  		usb0: ohci@00600000 {
> diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> index a3633bd..4f94f23 100644
> --- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
> +++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> @@ -46,6 +46,20 @@
>  				phy-mode = "rmii";
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c@fff84000 {
> +				status = "okay";
> +
> +				24c512@50 {
> +					compatible = "24c512";
> +					reg = <0x50>;
> +					pagesize = <128>;
> +				};
> +			};
> +			
> +			i2c1: i2c@fff88000 {
> +				status = "okay";
> +			};
>  		};
>  
>  		nand0: nand@40000000 {
> diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
> index f4e43e3..912b2c2 100644
> --- a/arch/arm/boot/dts/at91sam9n12ek.dts
> +++ b/arch/arm/boot/dts/at91sam9n12ek.dts
> @@ -37,6 +37,14 @@
>  			dbgu: serial@fffff200 {
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c@f8010000 {
> +				status = "okay";
> +			};
> +
> +			i2c1: i2c@f8014000 {
> +				status = "okay";
> +			};
>  		};
>  
>  		nand0: nand@40000000 {
> 


-- 
Nicolas Ferre

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

* [PATCH 5/5] ARM: dts: add twi nodes for atmel boards
@ 2012-08-21 16:13         ` Nicolas Ferre
  0 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2012-08-21 16:13 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/21/2012 04:32 PM, ludovic.desroches at atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> Use the atmel twi instead of gpio for i2c stuff.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Seems good. Maybe we will have to test wm8731 a little bit more.

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>  arch/arm/boot/dts/at91sam9263ek.dts         | 20 ++++++++++----------
>  arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 28 ++++++++++++++--------------
>  arch/arm/boot/dts/at91sam9g25ek.dts         | 12 ++++++++++++
>  arch/arm/boot/dts/at91sam9m10g45ek.dts      | 14 ++++++++++++++
>  arch/arm/boot/dts/at91sam9n12ek.dts         |  8 ++++++++
>  5 files changed, 58 insertions(+), 24 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
> index f86ac4b..772ab75 100644
> --- a/arch/arm/boot/dts/at91sam9263ek.dts
> +++ b/arch/arm/boot/dts/at91sam9263ek.dts
> @@ -50,6 +50,16 @@
>  				atmel,vbus-gpio = <&pioA 25 0>;
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c at fff88000 {
> +				status = "okay";
> +
> +				24c512 at 50 {
> +					compatible = "24c512";
> +					reg = <0x50>;
> +					pagesize = <128>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {
> @@ -143,14 +153,4 @@
>  			gpio-key,wakeup;
>  		};
>  	};
> -
> -	i2c at 0 {
> -		status = "okay";
> -
> -		24c512 at 50 {
> -			compatible = "24c512";
> -			reg = <0x50>;
> -			pagesize = <128>;
> -		};
> -	};
>  };
> diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
> index b06c0db..712106b 100644
> --- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
> @@ -51,6 +51,20 @@
>  				atmel,vbus-gpio = <&pioC 5 0>;
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c at fffac000 {
> +				status = "okay";
> +
> +				24c512 at 50 {
> +					compatible = "24c512";
> +					reg = <0x50>;
> +				};
> +
> +				wm8731 at 1b {
> +					compatible = "wm8731";
> +					reg = <0x1b>;
> +				};
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {
> @@ -106,20 +120,6 @@
>  		};
>  	};
>  
> -	i2c at 0 {
> -		status = "okay";
> -
> -		24c512 at 50 {
> -			compatible = "24c512";
> -			reg = <0x50>;
> -		};
> -
> -		wm8731 at 1b {
> -			compatible = "wm8731";
> -			reg = <0x1b>;
> -		};
> -	};
> -
>  	gpio_keys {
>  		compatible = "gpio-keys";
>  		#address-cells = <1>;
> diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
> index 7829a4d..3b0adbc 100644
> --- a/arch/arm/boot/dts/at91sam9g25ek.dts
> +++ b/arch/arm/boot/dts/at91sam9g25ek.dts
> @@ -32,6 +32,18 @@
>  				phy-mode = "rmii";
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c at f8010000 {
> +				status = "okay";
> +			};
> +
> +			i2c1: i2c at f8014000 {
> +				status = "okay";
> +			};
> +
> +			i2c2: i2c at f8018000 {
> +				status = "okay";
> +			};
>  		};
>  
>  		usb0: ohci at 00600000 {
> diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> index a3633bd..4f94f23 100644
> --- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
> +++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> @@ -46,6 +46,20 @@
>  				phy-mode = "rmii";
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c at fff84000 {
> +				status = "okay";
> +
> +				24c512 at 50 {
> +					compatible = "24c512";
> +					reg = <0x50>;
> +					pagesize = <128>;
> +				};
> +			};
> +			
> +			i2c1: i2c at fff88000 {
> +				status = "okay";
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {
> diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
> index f4e43e3..912b2c2 100644
> --- a/arch/arm/boot/dts/at91sam9n12ek.dts
> +++ b/arch/arm/boot/dts/at91sam9n12ek.dts
> @@ -37,6 +37,14 @@
>  			dbgu: serial at fffff200 {
>  				status = "okay";
>  			};
> +
> +			i2c0: i2c at f8010000 {
> +				status = "okay";
> +			};
> +
> +			i2c1: i2c at f8014000 {
> +				status = "okay";
> +			};
>  		};
>  
>  		nand0: nand at 40000000 {
> 


-- 
Nicolas Ferre

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

* RE: [PATCH 1/5] i2c: at91: add new fixes for some TWI ip versions
  2012-08-21 14:29     ` ludovic.desroches at atmel.com
@ 2012-08-22  6:55       ` Voss, Nikolaus
  -1 siblings, 0 replies; 28+ messages in thread
From: Voss, Nikolaus @ 2012-08-22  6:55 UTC (permalink / raw)
  To: 'ludovic.desroches@atmel.com',
	'linux-i2c@vger.kernel.org',
	'linux-arm-kernel@lists.infradead.org'
  Cc: 'plagnioj@jcrosoft.com', 'nicolas.ferre@atmel.com'

Hi Ludovic,

ludovic.desroches@atmel.com wrote on Tuesday, August 21, 2012 4:29 PM
> The at91sam9261 TWI ip version requires also some fixes. The id_entry
> field from the platform device structure has been replaced by the use
> of cpu_is_xxx function to determine when to use these fixes.

I applied your calc_twi_clock() fix using the id_entry stuff instead of
cpu_is_xxx functions as those are deprecated...

I will post the complete series later on. Please test it!

Niko

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

* [PATCH 1/5] i2c: at91: add new fixes for some TWI ip versions
@ 2012-08-22  6:55       ` Voss, Nikolaus
  0 siblings, 0 replies; 28+ messages in thread
From: Voss, Nikolaus @ 2012-08-22  6:55 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ludovic,

ludovic.desroches at atmel.com wrote on Tuesday, August 21, 2012 4:29 PM
> The at91sam9261 TWI ip version requires also some fixes. The id_entry
> field from the platform device structure has been replaced by the use
> of cpu_is_xxx function to determine when to use these fixes.

I applied your calc_twi_clock() fix using the id_entry stuff instead of
cpu_is_xxx functions as those are deprecated...

I will post the complete series later on. Please test it!

Niko

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

* Re: [PATCH 1/5] i2c: at91: add new fixes for some TWI ip versions
  2012-08-21 14:29     ` ludovic.desroches at atmel.com
@ 2012-08-22 12:32       ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-22 12:32 UTC (permalink / raw)
  To: ludovic.desroches; +Cc: n.voss, nicolas.ferre, linux-i2c, linux-arm-kernel

On 16:29 Tue 21 Aug     , ludovic.desroches@atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> The at91sam9261 TWI ip version requires also some fixes. The id_entry
> field from the platform device structure has been replaced by the use
> of cpu_is_xxx function to determine when to use these fixes.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/mach-at91/at91rm9200_devices.c |  9 -------
>  drivers/i2c/busses/i2c-at91.c           | 42 +++++++++++++++++++--------------
>  2 files changed, 24 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
> index 2b9b493..e6b7d05 100644
> --- a/arch/arm/mach-at91/at91rm9200_devices.c
> +++ b/arch/arm/mach-at91/at91rm9200_devices.c
> @@ -494,18 +494,9 @@ static struct resource twi_resources[] = {
>  	},
>  };
>  
> -static const struct platform_device_id twi_id = {
> -	/*
> -	 * driver_data is "1" for hardware with ckdiv upper limit == 5
> -	 * (AT91RM9200 erratum 22), "0" for twi modules without this bug
> -	 */
> -	.driver_data	= 1,
> -};
> -
>  static struct platform_device at91rm9200_twi_device = {
>  	.name		= "at91_i2c",
>  	.id		= -1,
> -	.id_entry	= &twi_id,
>  	.resource	= twi_resources,
>  	.num_resources	= ARRAY_SIZE(twi_resources),
>  };
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index b1cb780..4599522 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -27,6 +27,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  
> +#include <mach/cpu.h>
> +
>  #define TWI_CLK_HZ		100000			/* max 400 Kbits/s */
>  #define AT91_I2C_TIMEOUT	msecs_to_jiffies(100)	/* transfer timeout */
>  
> @@ -72,7 +74,6 @@ struct at91_twi_dev {
>  	int			irq;
>  	unsigned		transfer_status;
>  	struct i2c_adapter	adapter;
> -	bool			is_rm9200;
>  	unsigned		twi_cwgr_reg;
>  };
>  
> @@ -111,20 +112,28 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
>   */
>  static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  {
> -	const int offset = dev->is_rm9200 ? 3 : 4;
> -	const int div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
> -						 2 * twi_clk) - offset);
> -	int ckdiv = fls(div >> 8);
> -	int cdiv = div >> ckdiv;
> -
> -	if (dev->is_rm9200 && (ckdiv > 5)) {
> -		dev_warn(dev->dev, "AT91RM9200 erratum 22: using ckdiv = 5.\n");
> -		ckdiv = 5;
> -		cdiv = 255;
> -	} else if (ckdiv > 7) {
> -		dev_warn(dev->dev, "%d exceeds 3 bits for ckdiv, limiting.\n",
> -			 ckdiv);
> -		ckdiv = 7;
> +	int offset, div, max_ckdiv, ckdiv, cdiv;
> +
> +	if (cpu_is_at91rm9200()) {
> +		offset = 3;
> +		max_ckdiv = 5;
> +	} else if (cpu_is_at91sam9261()) {
> +		offset = 4;
> +		max_ckdiv = 5;
> +	} else {
> +		offset = 4;
> +		max_ckdiv = 7;
> +	}
can you read this from the IP version?

I do not like the cpu_is outside of the mach-at91

Best Regards,
J.

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

* [PATCH 1/5] i2c: at91: add new fixes for some TWI ip versions
@ 2012-08-22 12:32       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-22 12:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 16:29 Tue 21 Aug     , ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> The at91sam9261 TWI ip version requires also some fixes. The id_entry
> field from the platform device structure has been replaced by the use
> of cpu_is_xxx function to determine when to use these fixes.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  arch/arm/mach-at91/at91rm9200_devices.c |  9 -------
>  drivers/i2c/busses/i2c-at91.c           | 42 +++++++++++++++++++--------------
>  2 files changed, 24 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
> index 2b9b493..e6b7d05 100644
> --- a/arch/arm/mach-at91/at91rm9200_devices.c
> +++ b/arch/arm/mach-at91/at91rm9200_devices.c
> @@ -494,18 +494,9 @@ static struct resource twi_resources[] = {
>  	},
>  };
>  
> -static const struct platform_device_id twi_id = {
> -	/*
> -	 * driver_data is "1" for hardware with ckdiv upper limit == 5
> -	 * (AT91RM9200 erratum 22), "0" for twi modules without this bug
> -	 */
> -	.driver_data	= 1,
> -};
> -
>  static struct platform_device at91rm9200_twi_device = {
>  	.name		= "at91_i2c",
>  	.id		= -1,
> -	.id_entry	= &twi_id,
>  	.resource	= twi_resources,
>  	.num_resources	= ARRAY_SIZE(twi_resources),
>  };
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index b1cb780..4599522 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -27,6 +27,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  
> +#include <mach/cpu.h>
> +
>  #define TWI_CLK_HZ		100000			/* max 400 Kbits/s */
>  #define AT91_I2C_TIMEOUT	msecs_to_jiffies(100)	/* transfer timeout */
>  
> @@ -72,7 +74,6 @@ struct at91_twi_dev {
>  	int			irq;
>  	unsigned		transfer_status;
>  	struct i2c_adapter	adapter;
> -	bool			is_rm9200;
>  	unsigned		twi_cwgr_reg;
>  };
>  
> @@ -111,20 +112,28 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
>   */
>  static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
>  {
> -	const int offset = dev->is_rm9200 ? 3 : 4;
> -	const int div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
> -						 2 * twi_clk) - offset);
> -	int ckdiv = fls(div >> 8);
> -	int cdiv = div >> ckdiv;
> -
> -	if (dev->is_rm9200 && (ckdiv > 5)) {
> -		dev_warn(dev->dev, "AT91RM9200 erratum 22: using ckdiv = 5.\n");
> -		ckdiv = 5;
> -		cdiv = 255;
> -	} else if (ckdiv > 7) {
> -		dev_warn(dev->dev, "%d exceeds 3 bits for ckdiv, limiting.\n",
> -			 ckdiv);
> -		ckdiv = 7;
> +	int offset, div, max_ckdiv, ckdiv, cdiv;
> +
> +	if (cpu_is_at91rm9200()) {
> +		offset = 3;
> +		max_ckdiv = 5;
> +	} else if (cpu_is_at91sam9261()) {
> +		offset = 4;
> +		max_ckdiv = 5;
> +	} else {
> +		offset = 4;
> +		max_ckdiv = 7;
> +	}
can you read this from the IP version?

I do not like the cpu_is outside of the mach-at91

Best Regards,
J.

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

end of thread, other threads:[~2012-08-22 12:32 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-21 14:29 [RFC PATCH 0/5] fixes and DT support based on Nikolaus TWI driver ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-08-21 14:29 ` ludovic.desroches at atmel.com
     [not found] ` <1345559345-13988-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-08-21 14:29   ` [PATCH 1/5] i2c: at91: add new fixes for some TWI ip versions ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-08-21 14:29     ` ludovic.desroches at atmel.com
     [not found]     ` <1345559345-13988-2-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-08-21 16:04       ` Nicolas Ferre
2012-08-21 16:04         ` Nicolas Ferre
2012-08-22  6:55     ` Voss, Nikolaus
2012-08-22  6:55       ` Voss, Nikolaus
2012-08-22 12:32     ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-22 12:32       ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-21 14:29   ` [PATCH 2/5] i2c: at91: add dt support to i2c-at91 ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-08-21 14:29     ` ludovic.desroches at atmel.com
     [not found]     ` <1345559345-13988-3-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-08-21 16:08       ` Nicolas Ferre
2012-08-21 16:08         ` Nicolas Ferre
2012-08-21 14:29   ` [PATCH 3/5] ARM: at91: add clocks for i2c DT entries ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-08-21 14:29     ` ludovic.desroches at atmel.com
     [not found]     ` <1345559345-13988-4-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-08-21 16:08       ` Nicolas Ferre
2012-08-21 16:08         ` Nicolas Ferre
2012-08-21 14:29   ` [PATCH 4/5] ARM: dts: add twi nodes for atmel SOCs ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-08-21 14:29     ` ludovic.desroches at atmel.com
     [not found]     ` <1345559345-13988-5-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-08-21 14:30       ` ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-08-21 14:30         ` ludovic.desroches at atmel.com
2012-08-21 16:10       ` Nicolas Ferre
2012-08-21 16:10         ` Nicolas Ferre
2012-08-21 14:32   ` [PATCH 5/5] ARM: dts: add twi nodes for atmel boards ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-08-21 14:32     ` ludovic.desroches at atmel.com
     [not found]     ` <1345559520-14074-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-08-21 16:13       ` Nicolas Ferre
2012-08-21 16:13         ` Nicolas Ferre

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.