devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/8] i2c: at91: cleanup and dt support
@ 2012-09-03 10:15 ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
       [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-09-03 10:15 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, n.voss-+umVssTZoCsb1SvskN2V4Q,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Ludovic Desroches

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

Hi,

This set of patches is based on Nikolaus at91_i2c driver.

Changes:
v2:
  - change driver name from xxx_i2c to i2c-xxx
  - keep i2c-gpio nodes in dtsi files
  - don't enable TWI on boards whose TWI IP doesn't support clock
  stretching in tranmission mode

Ludovic Desroches (8):
  i2c: at91: use managed resources
  i2c: at91: add warning about transmission issues for some devices
  i2c: at91: use an id table for SoC dependent parameters
  ARM: at91: do not configure at91sam9g10 twi pio as open-drain
  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          |  30 +++
 arch/arm/boot/dts/at91sam9260.dtsi                 |  10 +
 arch/arm/boot/dts/at91sam9263.dtsi                 |  10 +
 arch/arm/boot/dts/at91sam9g20.dtsi                 |   4 +
 arch/arm/boot/dts/at91sam9g25ek.dts                |  12 ++
 arch/arm/boot/dts/at91sam9g45.dtsi                 |  20 ++
 arch/arm/boot/dts/at91sam9m10g45ek.dts             |   8 +
 arch/arm/boot/dts/at91sam9n12.dtsi                 |  20 ++
 arch/arm/boot/dts/at91sam9n12ek.dts                |   8 +
 arch/arm/boot/dts/at91sam9x5.dtsi                  |  30 +++
 arch/arm/mach-at91/at91rm9200.c                    |   2 +-
 arch/arm/mach-at91/at91rm9200_devices.c            |  11 +-
 arch/arm/mach-at91/at91sam9260.c                   |   4 +-
 arch/arm/mach-at91/at91sam9260_devices.c           |   8 +-
 arch/arm/mach-at91/at91sam9261.c                   |   3 +-
 arch/arm/mach-at91/at91sam9261_devices.c           |  31 ++-
 arch/arm/mach-at91/at91sam9263.c                   |   3 +-
 arch/arm/mach-at91/at91sam9263_devices.c           |   2 +-
 arch/arm/mach-at91/at91sam9g45.c                   |   6 +-
 arch/arm/mach-at91/at91sam9g45_devices.c           |   4 +-
 arch/arm/mach-at91/at91sam9n12.c                   |   2 +
 arch/arm/mach-at91/at91sam9rl.c                    |   4 +-
 arch/arm/mach-at91/at91sam9rl_devices.c            |   2 +-
 arch/arm/mach-at91/at91sam9x5.c                    |   6 +-
 drivers/i2c/busses/Kconfig                         |   6 +
 drivers/i2c/busses/i2c-at91.c                      | 217 +++++++++++++--------
 26 files changed, 343 insertions(+), 120 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt

-- 
1.7.11.3

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

* [PATCH v2 1/8] i2c: at91: use managed resources
       [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
@ 2012-09-03 10:16   ` ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  2012-09-03 10:16   ` [PATCH v2 2/8] i2c: at91: add warning about transmission issues for some devices ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-09-03 10:16 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, n.voss-+umVssTZoCsb1SvskN2V4Q,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Ludovic Desroches

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

Use managed resources to ease the cleanup.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nikolaus Voss <n.voss-+umVssTZoCsb1SvskN2V4Q@public.gmane.org>
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/i2c-at91.c | 85 +++++++++++++------------------------------
 1 file changed, 25 insertions(+), 60 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 2b8b2c2..08aaee7 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -326,61 +326,49 @@ static struct i2c_algorithm at91_twi_algorithm = {
 static int __devinit at91_twi_probe(struct platform_device *pdev)
 {
 	struct at91_twi_dev *dev;
-	struct resource *mem, *ioarea;
-	int irq, rc;
+	struct resource *mem;
+	int rc;
+
+	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return -ENOMEM;
+	init_completion(&dev->cmd_complete);
+	dev->dev = &pdev->dev;
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!mem)
 		return -ENODEV;
 
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return irq;
-
-	ioarea = request_mem_region(mem->start, resource_size(mem), pdev->name);
-	if (!ioarea)
+	dev->base = devm_request_and_ioremap(&pdev->dev, mem);
+	if (!dev->base)
 		return -EBUSY;
 
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev) {
-		rc = -ENOMEM;
-		goto err_release_region;
+	dev->irq = platform_get_irq(pdev, 0);
+	if (dev->irq < 0)
+		return dev->irq;
+
+	rc = devm_request_irq(&pdev->dev, dev->irq, atmel_twi_interrupt, 0,
+			 dev_name(dev->dev), dev);
+	if (rc) {
+		dev_err(dev->dev, "Cannot get irq %d: %d\n", dev->irq, rc);
+		return rc;
 	}
 
 	if (pdev->id_entry)
 		dev->ip_id = pdev->id_entry->driver_data;
 
-	init_completion(&dev->cmd_complete);
-
-	dev->dev = &pdev->dev;
-	dev->irq = irq;
 	platform_set_drvdata(pdev, dev);
 
-	dev->clk = clk_get(dev->dev, NULL);
+	dev->clk = devm_clk_get(dev->dev, NULL);
 	if (IS_ERR(dev->clk)) {
 		dev_err(dev->dev, "no clock defined\n");
-		rc = -ENODEV;
-		goto err_free_mem;
-	}
-	clk_prepare(dev->clk);
-	clk_enable(dev->clk);
-
-	dev->base = ioremap(mem->start, resource_size(mem));
-	if (!dev->base) {
-		rc = -EBUSY;
-		goto err_mem_ioremap;
+		return -ENODEV;
 	}
+	clk_prepare_enable(dev->clk);
 
 	at91_calc_twi_clock(dev, TWI_CLK_HZ);
 	at91_init_twi_bus(dev);
 
-	rc = request_irq(dev->irq, atmel_twi_interrupt, 0,
-			 dev_name(dev->dev), dev);
-	if (rc) {
-		dev_err(dev->dev, "Cannot get irq %d: %d\n", dev->irq, rc);
-		goto err_unuse_clocks;
-	}
-
 	snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91");
 	i2c_set_adapdata(&dev->adapter, dev);
 	dev->adapter.owner = THIS_MODULE;
@@ -394,44 +382,21 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 	if (rc) {
 		dev_err(dev->dev, "Adapter %s registration failed\n",
 			dev->adapter.name);
-		goto err_free_irq;
+		clk_disable_unprepare(dev->clk);
+		return rc;
 	}
 
 	dev_info(dev->dev, "AT91 i2c bus driver.\n");
 	return 0;
-
-err_free_irq:
-	free_irq(dev->irq, dev);
-err_unuse_clocks:
-	iounmap(dev->base);
-err_mem_ioremap:
-	clk_disable(dev->clk);
-	clk_unprepare(dev->clk);
-	clk_put(dev->clk);
-err_free_mem:
-	kfree(dev);
-err_release_region:
-	release_mem_region(mem->start, resource_size(mem));
-
-	return rc;
 }
 
 static int __devexit at91_twi_remove(struct platform_device *pdev)
 {
 	struct at91_twi_dev *dev = platform_get_drvdata(pdev);
-	struct resource *mem;
 	int rc;
 
 	rc = i2c_del_adapter(&dev->adapter);
-	clk_disable(dev->clk);
-	clk_unprepare(dev->clk);
-	clk_put(dev->clk);
-	free_irq(dev->irq, dev);
-	iounmap(dev->base);
-	kfree(dev);
-
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(mem->start, resource_size(mem));
+	clk_disable_unprepare(dev->clk);
 
 	return rc;
 }
-- 
1.7.11.3

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

* [PATCH v2 2/8] i2c: at91: add warning about transmission issues for some devices
       [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
  2012-09-03 10:16   ` [PATCH v2 1/8] i2c: at91: use managed resources ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
@ 2012-09-03 10:16   ` ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  2012-09-03 10:16   ` [PATCH v2 3/8] i2c: at91: use an id table for SoC dependent parameters ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-09-03 10:16 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, n.voss-+umVssTZoCsb1SvskN2V4Q,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Ludovic Desroches

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

Some devices don't have clock streching in transmission mode. It can
lead to premature stop sendings if the latency to write data in the
transmission register is too long. In this case, prefer the i2c-gpio
driver.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nikolaus Voss <n.voss-+umVssTZoCsb1SvskN2V4Q@public.gmane.org>
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index d9c4918..da77c37 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -300,6 +300,12 @@ config I2C_AT91
 	  to support combined I2C messages.  Use the i2c-gpio driver
 	  unless your system can cope with this limitation.
 
+	  Caution! at91rm9200, at91sam9261, at91sam9260, at91sam9263 devices
+	  don't have clock stretching in transmission mode. For that reason,
+	  you can encounter underrun issues causing premature stop sendings if
+	  the latency to fill the transmission register is too long. If you
+	  are facing this situation, use the i2c-gpio driver.
+
 config I2C_AU1550
 	tristate "Au1550/Au1200/Au1300 SMBus interface"
 	depends on MIPS_ALCHEMY
-- 
1.7.11.3

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

* [PATCH v2 3/8] i2c: at91: use an id table for SoC dependent parameters
       [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
  2012-09-03 10:16   ` [PATCH v2 1/8] i2c: at91: use managed resources ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  2012-09-03 10:16   ` [PATCH v2 2/8] i2c: at91: add warning about transmission issues for some devices ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
@ 2012-09-03 10:16   ` ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  2012-09-03 10:16   ` [PATCH v2 4/8] ARM: at91: do not configure at91sam9g10 twi pio as open-drain ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-09-03 10:16 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, n.voss-+umVssTZoCsb1SvskN2V4Q,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Ludovic Desroches

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

Use the id_table to store configuration structures which are depending
on SoC.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nikolaus Voss <n.voss-+umVssTZoCsb1SvskN2V4Q@public.gmane.org>
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/mach-at91/at91rm9200.c          |  2 +-
 arch/arm/mach-at91/at91rm9200_devices.c  | 11 +----
 arch/arm/mach-at91/at91sam9260.c         |  3 +-
 arch/arm/mach-at91/at91sam9260_devices.c |  8 ++-
 arch/arm/mach-at91/at91sam9261.c         |  3 +-
 arch/arm/mach-at91/at91sam9261_devices.c | 17 +++----
 arch/arm/mach-at91/at91sam9263.c         |  2 +-
 arch/arm/mach-at91/at91sam9263_devices.c |  2 +-
 arch/arm/mach-at91/at91sam9g45.c         |  4 +-
 arch/arm/mach-at91/at91sam9g45_devices.c |  4 +-
 arch/arm/mach-at91/at91sam9rl.c          |  4 +-
 arch/arm/mach-at91/at91sam9rl_devices.c  |  2 +-
 drivers/i2c/busses/i2c-at91.c            | 85 +++++++++++++++++++++++++-------
 13 files changed, 95 insertions(+), 52 deletions(-)

diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index f2112f9..b4f0565 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -187,7 +187,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
 	CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
 	CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91rm9200", &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/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 71e7387..0b972f2 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_ip_type = {
-	/*
-	 * driver_data is 1 for RM9200 compatible ip, see enum twi_ip_id in
-	 * drivers/i2c/busses/i2c-at91.c
-	 */
-	.driver_data	= 1,
-};
-
 static struct platform_device at91rm9200_twi_device = {
-	.name		= "at91_i2c",
+	.name		= "i2c-at91rm9200",
 	.id		= -1,
-	.id_entry	= &twi_ip_type,
 	.resource	= twi_resources,
 	.num_resources	= ARRAY_SIZE(twi_resources),
 };
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 57c79ee..5bd19a4 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -211,7 +211,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk),
 	CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk),
 	CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260", &twi_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20", &twi_clk),
 	/* more usart lookup table for DT entries */
 	CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
 	CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk),
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 7b9c2ba..7ddf3b2 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -503,7 +503,6 @@ static struct resource twi_resources[] = {
 };
 
 static struct platform_device at91sam9260_twi_device = {
-	.name		= "at91_i2c",
 	.id		= -1,
 	.resource	= twi_resources,
 	.num_resources	= ARRAY_SIZE(twi_resources),
@@ -511,6 +510,13 @@ static struct platform_device at91sam9260_twi_device = {
 
 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
 {
+	/* IP version is not the same on 9260 and g20 */
+	if (cpu_is_at91sam9g20()) {
+		at91sam9260_twi_device.name = "i2c-at91sam9g20";
+	} else {
+		at91sam9260_twi_device.name = "i2c-at91sam9260";
+	}
+
 	/* pins used for TWI interface */
 	at91_set_A_periph(AT91_PIN_PA23, 0);		/* TWD */
 	at91_set_multi_drive(AT91_PIN_PA23, 1);
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 71ca1e0..8d999eb 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -178,7 +178,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
 	CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &hck0),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9261", &twi_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10", &twi_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
 	CLKDEV_CON_ID("pioB", &pioB_clk),
 	CLKDEV_CON_ID("pioC", &pioC_clk),
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index d830724..fdb5675 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -316,24 +316,21 @@ static struct resource twi_resources[] = {
 	},
 };
 
-static const struct platform_device_id twi_ip_type = {
-	/*
-	 * driver_data is 2 for SAM9261 compatible ip, see enum twi_ip_id in
-	 * drivers/i2c/busses/i2c-at91.c
-	 */
-	.driver_data	= 2,
-};
-
 static struct platform_device at91sam9261_twi_device = {
-	.name		= "at91_i2c",
 	.id		= -1,
-	.id_entry	= &twi_ip_type,
 	.resource	= twi_resources,
 	.num_resources	= ARRAY_SIZE(twi_resources),
 };
 
 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
 {
+	/* IP version is not the same on 9261 and g10 */
+	if (cpu_is_at91sam9g10()) {
+		at91sam9261_twi_device.name = "i2c-at91sam9g10";
+	} else {
+		at91sam9261_twi_device.name = "i2c-at91sam9261";
+	}
+
 	/* pins used for TWI interface */
 	at91_set_A_periph(AT91_PIN_PA7, 0);		/* TWD */
 	at91_set_multi_drive(AT91_PIN_PA7, 1);
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 2a08305..e6b5956 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -193,7 +193,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
 	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c", &twi_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260", &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_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index eb6bbf8..c834e8f 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -574,7 +574,7 @@ static struct resource twi_resources[] = {
 };
 
 static struct platform_device at91sam9263_twi_device = {
-	.name		= "at91_i2c",
+	.name		= "i2c-at91sam9260",
 	.id		= -1,
 	.resource	= twi_resources,
 	.num_resources	= ARRAY_SIZE(twi_resources),
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index ddf3d37..858f032 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -237,8 +237,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
 	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb0_clk),
 	CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c.0", &twi0_clk),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c.1", &twi1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.1", &twi1_clk),
 	CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
 	CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
 	CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk),
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index f001305..cd349fd 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -653,7 +653,7 @@ static struct resource twi0_resources[] = {
 };
 
 static struct platform_device at91sam9g45_twi0_device = {
-	.name		= "at91_i2c",
+	.name		= "i2c-at91sam9g10",
 	.id		= 0,
 	.resource	= twi0_resources,
 	.num_resources	= ARRAY_SIZE(twi0_resources),
@@ -673,7 +673,7 @@ static struct resource twi1_resources[] = {
 };
 
 static struct platform_device at91sam9g45_twi1_device = {
-	.name		= "at91_i2c",
+	.name		= "i2c-at91sam9g10",
 	.id		= 1,
 	.resource	= twi1_resources,
 	.num_resources	= ARRAY_SIZE(twi1_resources),
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index bf79c1f..72e9084 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -186,8 +186,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk),
 	CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
 	CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c.0", &twi0_clk),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c.1", &twi1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.1", &twi1_clk),
 	CLKDEV_CON_ID("pioA", &pioA_clk),
 	CLKDEV_CON_ID("pioB", &pioB_clk),
 	CLKDEV_CON_ID("pioC", &pioC_clk),
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index f09fff9..977e88e 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -346,7 +346,7 @@ static struct resource twi_resources[] = {
 };
 
 static struct platform_device at91sam9rl_twi_device = {
-	.name		= "at91_i2c",
+	.name		= "i2c-at91sam9g20",
 	.id		= -1,
 	.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 08aaee7..78bcad0 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -61,10 +61,10 @@
 #define	AT91_TWI_RHR		0x0030	/* Receive Holding Register */
 #define	AT91_TWI_THR		0x0034	/* Transmit Holding Register */
 
-enum twi_ip_id {
-	DEFAULT		= 0, /* default ip, no known limitations */
-	RM9200		= 1,
-	SAM9261		= 2,
+struct at91_twi_pdata {
+	unsigned	clk_max_div;
+	unsigned	clk_offset;
+	bool		has_unre_flag;
 };
 
 struct at91_twi_dev {
@@ -78,8 +78,8 @@ struct at91_twi_dev {
 	int			irq;
 	unsigned		transfer_status;
 	struct i2c_adapter	adapter;
-	enum twi_ip_id		ip_id;
 	unsigned		twi_cwgr_reg;
+	struct at91_twi_pdata	*pdata;
 };
 
 static unsigned at91_twi_read(struct at91_twi_dev *dev, unsigned reg)
@@ -114,16 +114,9 @@ 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 ckdiv, cdiv, div;
-	int offset = 4;
-	int max_ckdiv = 7;
-
-	if (dev->ip_id == RM9200) {
-		offset = 3;
-		max_ckdiv = 5;
-	} else if (dev->ip_id == SAM9261) {
-		offset = 4;
-		max_ckdiv = 5;
-	}
+	struct at91_twi_pdata *pdata = dev->pdata;
+	int offset = pdata->clk_offset;
+	int max_ckdiv = pdata->clk_max_div;
 
 	div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
 				       2 * twi_clk) - offset);
@@ -209,6 +202,7 @@ static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id)
 static int at91_do_twi_transfer(struct at91_twi_dev *dev)
 {
 	int ret;
+	bool has_unre_flag = dev->pdata->has_unre_flag;
 
 	dev_dbg(dev->dev, "transfer: %s %d bytes.\n",
 		(dev->msg->flags & I2C_M_RD) ? "read" : "write", dev->buf_len);
@@ -250,7 +244,7 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
 		dev_err(dev->dev, "overrun while reading\n");
 		return -EIO;
 	}
-	if (dev->transfer_status & AT91_TWI_UNRE && dev->ip_id == RM9200) {
+	if (has_unre_flag && dev->transfer_status & AT91_TWI_UNRE) {
 		dev_err(dev->dev, "underrun while writing\n");
 		return -EIO;
 	}
@@ -323,6 +317,57 @@ static struct i2c_algorithm at91_twi_algorithm = {
 	.functionality	= at91_twi_func,
 };
 
+static struct at91_twi_pdata at91rm9200_config = {
+	.clk_max_div = 5,
+	.clk_offset = 3,
+	.has_unre_flag = true,
+};
+
+static struct at91_twi_pdata at91sam9261_config = {
+	.clk_max_div = 5,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+};
+
+static struct at91_twi_pdata at91sam9260_config = {
+	.clk_max_div = 7,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+};
+
+static struct at91_twi_pdata at91sam9g20_config = {
+	.clk_max_div = 7,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+};
+
+static struct at91_twi_pdata at91sam9g10_config = {
+	.clk_max_div = 7,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+};
+
+static const struct platform_device_id at91_twi_devtypes[] = {
+	{
+		.name = "i2c-at91rm9200",
+		.driver_data = (unsigned long) &at91rm9200_config,
+	}, {
+		.name = "i2c-at91sam9261",
+		.driver_data = (unsigned long) &at91sam9261_config,
+	}, {
+		.name = "i2c-at91sam9260",
+		.driver_data = (unsigned long) &at91sam9260_config,
+	}, {
+		.name = "i2c-at91sam9g20",
+		.driver_data = (unsigned long) &at91sam9g20_config,
+	}, {
+		.name = "i2c-at91sam9g10",
+		.driver_data = (unsigned long) &at91sam9g10_config,
+	}, {
+		/* sentinel */
+	}
+};
+
 static int __devinit at91_twi_probe(struct platform_device *pdev)
 {
 	struct at91_twi_dev *dev;
@@ -339,6 +384,10 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 	if (!mem)
 		return -ENODEV;
 
+	dev->pdata = at91_twi_get_driver_data(pdev);
+	if (!dev->pdata)
+		return -ENODEV;
+
 	dev->base = devm_request_and_ioremap(&pdev->dev, mem);
 	if (!dev->base)
 		return -EBUSY;
@@ -354,9 +403,6 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 		return rc;
 	}
 
-	if (pdev->id_entry)
-		dev->ip_id = pdev->id_entry->driver_data;
-
 	platform_set_drvdata(pdev, dev);
 
 	dev->clk = devm_clk_get(dev->dev, NULL);
@@ -432,6 +478,7 @@ static const struct dev_pm_ops at91_twi_pm = {
 static struct platform_driver at91_twi_driver = {
 	.probe		= at91_twi_probe,
 	.remove		= __devexit_p(at91_twi_remove),
+	.id_table	= at91_twi_devtypes,
 	.driver		= {
 		.name	= "at91_i2c",
 		.owner	= THIS_MODULE,
-- 
1.7.11.3

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

* [PATCH v2 4/8] ARM: at91: do not configure at91sam9g10 twi pio as open-drain
       [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2012-09-03 10:16   ` [PATCH v2 3/8] i2c: at91: use an id table for SoC dependent parameters ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
@ 2012-09-03 10:16   ` ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  2012-09-03 10:18   ` [PATCH v2 5/8] i2c: at91: add dt support to i2c-at91 ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-09-03 10:16 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, n.voss-+umVssTZoCsb1SvskN2V4Q,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Ludovic Desroches

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

As indicated in the datasheet, TWD and TWCK must not be programmed as
open-drain.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nikolaus Voss <n.voss-+umVssTZoCsb1SvskN2V4Q@public.gmane.org>
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/mach-at91/at91sam9261_devices.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index fdb5675..991a7e4 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -324,20 +324,22 @@ static struct platform_device at91sam9261_twi_device = {
 
 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
 {
-	/* IP version is not the same on 9261 and g10 */
+	/*
+	 * IP version is not the same on 9261 and g10 and only 9261 one
+	 * requires to configure PIO as open-drain.
+	 */
 	if (cpu_is_at91sam9g10()) {
 		at91sam9261_twi_device.name = "i2c-at91sam9g10";
+		at91_set_A_periph(AT91_PIN_PA7, 0);		/* TWD */
+		at91_set_A_periph(AT91_PIN_PA8, 0);		/* TWCK */
 	} else {
 		at91sam9261_twi_device.name = "i2c-at91sam9261";
+		at91_set_A_periph(AT91_PIN_PA7, 0);		/* TWD */
+		at91_set_multi_drive(AT91_PIN_PA7, 1);
+		at91_set_A_periph(AT91_PIN_PA8, 0);		/* TWCK */
+		at91_set_multi_drive(AT91_PIN_PA8, 1);
 	}
 
-	/* pins used for TWI interface */
-	at91_set_A_periph(AT91_PIN_PA7, 0);		/* TWD */
-	at91_set_multi_drive(AT91_PIN_PA7, 1);
-
-	at91_set_A_periph(AT91_PIN_PA8, 0);		/* TWCK */
-	at91_set_multi_drive(AT91_PIN_PA8, 1);
-
 	i2c_register_board_info(0, devices, nr_devices);
 	platform_device_register(&at91sam9261_twi_device);
 }
-- 
1.7.11.3

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

* [PATCH v2 5/8] i2c: at91: add dt support to i2c-at91
       [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2012-09-03 10:16   ` [PATCH v2 4/8] ARM: at91: do not configure at91sam9g10 twi pio as open-drain ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
@ 2012-09-03 10:18   ` ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  2012-09-03 10:19   ` [PATCH v2 6/8] ARM: at91: add clocks for I2C DT entries ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-09-03 10:18 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, n.voss-+umVssTZoCsb1SvskN2V4Q,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Ludovic Desroches

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

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nikolaus Voss <n.voss-+umVssTZoCsb1SvskN2V4Q@public.gmane.org>
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 .../devicetree/bindings/i2c/atmel-i2c.txt          | 30 +++++++++++++
 drivers/i2c/busses/i2c-at91.c                      | 49 ++++++++++++++++++++++
 2 files changed, 79 insertions(+)
 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..b689a0d
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
@@ -0,0 +1,30 @@
+I2C for Atmel platforms
+
+Required properties :
+- compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
+     "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c"
+     or "atmel,at91sam9x5-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 6>;
+	#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 78bcad0..aa59a25 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>
 
@@ -347,6 +350,12 @@ static struct at91_twi_pdata at91sam9g10_config = {
 	.has_unre_flag = false,
 };
 
+static struct at91_twi_pdata at91sam9x5_config = {
+	.clk_max_div = 7,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+};
+
 static const struct platform_device_id at91_twi_devtypes[] = {
 	{
 		.name = "i2c-at91rm9200",
@@ -368,6 +377,42 @@ static const struct platform_device_id at91_twi_devtypes[] = {
 	}
 };
 
+#if defined(CONFIG_OF)
+static const struct of_device_id atmel_twi_dt_ids[] = {
+	{
+		.compatible = "atmel,at91sam9260-i2c",
+		.data = &at91sam9260_config,
+	} , {
+		.compatible = "atmel,at91sam9g20-i2c",
+		.data = &at91sam9g20_config,
+	} , {
+		.compatible = "atmel,at91sam9g10-i2c",
+		.data = &at91sam9g10_config,
+	}, {
+		.compatible = "atmel,at91sam9x5-i2c",
+		.data = &at91sam9x5_config,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids);
+#else
+#define atmel_twi_dt_ids NULL
+#endif
+
+static struct at91_twi_pdata * __devinit at91_twi_get_driver_data(
+					struct platform_device *pdev)
+{
+	if (pdev->dev.of_node) {
+		const struct of_device_id *match;
+		match = of_match_node(atmel_twi_dt_ids, pdev->dev.of_node);
+		if (!match)
+			return NULL;
+		return match->data;
+	}
+	return (struct at91_twi_pdata *) platform_get_device_id(pdev)->driver_data;
+}
+
 static int __devinit at91_twi_probe(struct platform_device *pdev)
 {
 	struct at91_twi_dev *dev;
@@ -423,6 +468,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) {
@@ -432,6 +478,8 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
 		return rc;
 	}
 
+	of_i2c_register_devices(&dev->adapter);
+
 	dev_info(dev->dev, "AT91 i2c bus driver.\n");
 	return 0;
 }
@@ -482,6 +530,7 @@ static struct platform_driver at91_twi_driver = {
 	.driver		= {
 		.name	= "at91_i2c",
 		.owner	= THIS_MODULE,
+		.of_match_table = atmel_twi_dt_ids,
 		.pm	= at91_twi_pm_ops,
 	},
 };
-- 
1.7.11.3

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

* [PATCH v2 6/8] ARM: at91: add clocks for I2C DT entries
       [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
                     ` (4 preceding siblings ...)
  2012-09-03 10:18   ` [PATCH v2 5/8] i2c: at91: add dt support to i2c-at91 ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
@ 2012-09-03 10:19   ` ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  2012-09-03 10:19   ` [PATCH v2 7/8] ARM: dts: add twi nodes for atmel SoCs ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  2012-09-03 10:20   ` [PATCH v2 8/8] ARM: dts: add twi nodes for atmel boards ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  7 siblings, 0 replies; 9+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-09-03 10:19 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, n.voss-+umVssTZoCsb1SvskN2V4Q,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Ludovic Desroches

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

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nikolaus Voss <n.voss-+umVssTZoCsb1SvskN2V4Q@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  | 6 +++---
 5 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 5bd19a4..ad29f93 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -221,6 +221,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("usart", "fffd0000.serial", &usart3_clk),
 	CLKDEV_CON_DEV_ID("usart", "fffd4000.serial", &usart4_clk),
 	CLKDEV_CON_DEV_ID("usart", "fffd8000.serial", &usart5_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fffac000.i2c", &twi_clk),
 	/* more tc lookup table for DT entries */
 	CLKDEV_CON_DEV_ID("t0_clk", "fffa0000.timer", &tc0_clk),
 	CLKDEV_CON_DEV_ID("t1_clk", "fffa0000.timer", &tc1_clk),
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index e6b5956..200d5a7b 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -211,6 +211,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 858f032..84af1b5 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -256,6 +256,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 4bad4a2..e503538 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -231,9 +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, "at91_i2c.0", &twi0_clk),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c.1", &twi1_clk),
-	CLKDEV_CON_DEV_ID(NULL, "at91_i2c.2", &twi2_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] 9+ messages in thread

* [PATCH v2 7/8] ARM: dts: add twi nodes for atmel SoCs
       [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
                     ` (5 preceding siblings ...)
  2012-09-03 10:19   ` [PATCH v2 6/8] ARM: at91: add clocks for I2C DT entries ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
@ 2012-09-03 10:19   ` ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  2012-09-03 10:20   ` [PATCH v2 8/8] ARM: dts: add twi nodes for atmel boards ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  7 siblings, 0 replies; 9+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-09-03 10:19 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, n.voss-+umVssTZoCsb1SvskN2V4Q,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Ludovic Desroches

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

Add TWI nodes for atmel SoCs but keep i2c-gpio ones in order to let the
choice to the user in dts files.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/boot/dts/at91sam9260.dtsi | 10 ++++++++++
 arch/arm/boot/dts/at91sam9263.dtsi | 10 ++++++++++
 arch/arm/boot/dts/at91sam9g20.dtsi |  4 ++++
 arch/arm/boot/dts/at91sam9g45.dtsi | 20 ++++++++++++++++++++
 arch/arm/boot/dts/at91sam9n12.dtsi | 20 ++++++++++++++++++++
 arch/arm/boot/dts/at91sam9x5.dtsi  | 30 ++++++++++++++++++++++++++++++
 6 files changed, 94 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index 66389c1..edef452 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 {
@@ -199,6 +200,15 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c@fffac000 {
+				compatible = "atmel,at91sam9260-i2c";
+				reg = <0xfffac000 0x100>;
+				interrupts = <11 4 6>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc@fffe0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffe0000 0x100>;
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index b460d6c..e7942c7 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 {
@@ -180,6 +181,15 @@
 				interrupts = <24 4 2>;
 				status = "disabled";
 			};
+
+			i2c0: i2c@fff88000 {
+				compatible = "atmel,at91sam9263-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4 6>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
index 2a1d1ca..75ce6e7 100644
--- a/arch/arm/boot/dts/at91sam9g20.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20.dtsi
@@ -18,6 +18,10 @@
 
 	ahb {
 		apb {
+			i2c0: i2c@fffac000 {
+				compatible = "atmel,at91sam9g20-i2c";
+			};
+
 			adc0: adc@fffe0000 {
 				atmel,adc-startup-time = <40>;
 			};
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index bafa880..ae4bb6d 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 {
@@ -201,6 +203,24 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c@fff84000 {
+				compatible = "atmel,at91sam9g10-i2c";
+				reg = <0xfff84000 0x100>;
+				interrupts = <12 4 6>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@fff88000 {
+				compatible = "atmel,at91sam9g10-i2c";
+				reg = <0xfff88000 0x100>;
+				interrupts = <13 4 6>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc@fffb0000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xfffb0000 0x100>;
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index bfac0df..42e9fba 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,at91sam9x5-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4 6>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@f8014000 {
+				compatible = "atmel,at91sam9x5-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4 6>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		nand0: nand@40000000 {
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 4a18c39..e05afbc 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 {
@@ -192,6 +195,33 @@
 				status = "disabled";
 			};
 
+			i2c0: i2c@f8010000 {
+				compatible = "atmel,at91sam9x5-i2c";
+				reg = <0xf8010000 0x100>;
+				interrupts = <9 4 6>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@f8014000 {
+				compatible = "atmel,at91sam9x5-i2c";
+				reg = <0xf8014000 0x100>;
+				interrupts = <10 4 6>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
+			i2c2: i2c@f8018000 {
+				compatible = "atmel,at91sam9x5-i2c";
+				reg = <0xf8018000 0x100>;
+				interrupts = <11 4 6>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				status = "disabled";
+			};
+
 			adc0: adc@f804c000 {
 				compatible = "atmel,at91sam9260-adc";
 				reg = <0xf804c000 0x100>;
-- 
1.7.11.3

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

* [PATCH v2 8/8] ARM: dts: add twi nodes for atmel boards
       [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
                     ` (6 preceding siblings ...)
  2012-09-03 10:19   ` [PATCH v2 7/8] ARM: dts: add twi nodes for atmel SoCs ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
@ 2012-09-03 10:20   ` ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  7 siblings, 0 replies; 9+ messages in thread
From: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w @ 2012-09-03 10:20 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	plagnioj-sclMFOaUSTBWk0Htik3J/w, n.voss-+umVssTZoCsb1SvskN2V4Q,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, Ludovic Desroches

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

Still use i2c-gpio on boards which have a SoC with a TWI IP which
doesn't have clock stretching in transmission mode.

Signed-off-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Acked-by: Nicolas Ferre <nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
---
 arch/arm/boot/dts/at91sam9g25ek.dts    | 12 ++++++++++++
 arch/arm/boot/dts/at91sam9m10g45ek.dts |  8 ++++++++
 arch/arm/boot/dts/at91sam9n12ek.dts    |  8 ++++++++
 3 files changed, 28 insertions(+)

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..15e1dd4 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -46,6 +46,14 @@
 				phy-mode = "rmii";
 				status = "okay";
 			};
+
+			i2c0: i2c@fff84000 {
+				status = "okay";
+			};
+
+			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] 9+ messages in thread

end of thread, other threads:[~2012-09-03 10:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-03 10:15 [PATCH v2 0/8] i2c: at91: cleanup and dt support ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
     [not found] ` <1346667367-7969-1-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-09-03 10:16   ` [PATCH v2 1/8] i2c: at91: use managed resources ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-09-03 10:16   ` [PATCH v2 2/8] i2c: at91: add warning about transmission issues for some devices ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-09-03 10:16   ` [PATCH v2 3/8] i2c: at91: use an id table for SoC dependent parameters ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-09-03 10:16   ` [PATCH v2 4/8] ARM: at91: do not configure at91sam9g10 twi pio as open-drain ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-09-03 10:18   ` [PATCH v2 5/8] i2c: at91: add dt support to i2c-at91 ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-09-03 10:19   ` [PATCH v2 6/8] ARM: at91: add clocks for I2C DT entries ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-09-03 10:19   ` [PATCH v2 7/8] ARM: dts: add twi nodes for atmel SoCs ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
2012-09-03 10:20   ` [PATCH v2 8/8] ARM: dts: add twi nodes for atmel boards ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).