* [PATCH v3 0/8] i2c: at91: cleanup and dt support
@ 2012-09-12 6:42 ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 1/8] i2c: at91: use managed resources ludovic.desroches at atmel.com
` (9 more replies)
0 siblings, 10 replies; 14+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-09-12 6:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Ludovic Desroches <ludovic.desroches@atmel.com>
Hi,
This set of patches is based on Nikolaus at91_i2c driver.
Changes:
v3:
- only put multi-drive lines in the if...else statement (suggested
by Warner Losh)
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 | 23 +--
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, 338 insertions(+), 117 deletions(-)
create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt
--
1.7.11.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 1/8] i2c: at91: use managed resources
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
@ 2012-09-12 6:42 ` ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 2/8] i2c: at91: add warning about transmission issues for some devices ludovic.desroches at atmel.com
` (8 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-09-12 6:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Ludovic Desroches <ludovic.desroches@atmel.com>
Use managed resources to ease the cleanup.
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Nikolaus Voss <n.voss@weinmann.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
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] 14+ messages in thread
* [PATCH v3 2/8] i2c: at91: add warning about transmission issues for some devices
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 1/8] i2c: at91: use managed resources ludovic.desroches at atmel.com
@ 2012-09-12 6:42 ` ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 3/8] i2c: at91: use an id table for SoC dependent parameters ludovic.desroches at atmel.com
` (7 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-09-12 6:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Ludovic Desroches <ludovic.desroches@atmel.com>
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@atmel.com>
Acked-by: Nikolaus Voss <n.voss@weinmann.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
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] 14+ messages in thread
* [PATCH v3 3/8] i2c: at91: use an id table for SoC dependent parameters
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 1/8] i2c: at91: use managed resources ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 2/8] i2c: at91: add warning about transmission issues for some devices ludovic.desroches at atmel.com
@ 2012-09-12 6:42 ` ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 4/8] ARM: at91: do not configure at91sam9g10 twi pio as open-drain ludovic.desroches at atmel.com
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-09-12 6:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Ludovic Desroches <ludovic.desroches@atmel.com>
Use the id_table to store configuration structures which are depending
on SoC.
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Nikolaus Voss <n.voss@weinmann.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
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 bce572a..95fc23a 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 3b44731..29188ef 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 9b6ca73..3f5288e 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 b5a6cb9..0fcd871 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 b3d365d..0794954 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] 14+ messages in thread
* [PATCH v3 4/8] ARM: at91: do not configure at91sam9g10 twi pio as open-drain
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
` (2 preceding siblings ...)
2012-09-12 6:42 ` [PATCH v3 3/8] i2c: at91: use an id table for SoC dependent parameters ludovic.desroches at atmel.com
@ 2012-09-12 6:42 ` ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 5/8] i2c: at91: add dt support to i2c-at91 ludovic.desroches at atmel.com
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-09-12 6:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Ludovic Desroches <ludovic.desroches@atmel.com>
As indicated in the datasheet, TWD and TWCK must not be programmed as
open-drain.
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Nikolaus Voss <n.voss@weinmann.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
arch/arm/mach-at91/at91sam9261_devices.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 29188ef..50d3179 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -327,16 +327,16 @@ 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";
+ /* I2C PIO must not be configured as open-drain on this chip */
} else {
at91sam9261_twi_device.name = "i2c-at91sam9261";
+ at91_set_multi_drive(AT91_PIN_PA7, 1);
+ 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] 14+ messages in thread
* [PATCH v3 5/8] i2c: at91: add dt support to i2c-at91
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
` (3 preceding siblings ...)
2012-09-12 6:42 ` [PATCH v3 4/8] ARM: at91: do not configure at91sam9g10 twi pio as open-drain ludovic.desroches at atmel.com
@ 2012-09-12 6:42 ` ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 6/8] ARM: at91: add clocks for I2C DT entries ludovic.desroches at atmel.com
` (4 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-09-12 6:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Nikolaus Voss <n.voss@weinmann.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
.../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 at fff84000 {
+ compatible = "atmel,at91sam9g20-i2c";
+ reg = <0xfff84000 0x100>;
+ interrupts = <12 4 6>;
+ #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 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] 14+ messages in thread
* [PATCH v3 6/8] ARM: at91: add clocks for I2C DT entries
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
` (4 preceding siblings ...)
2012-09-12 6:42 ` [PATCH v3 5/8] i2c: at91: add dt support to i2c-at91 ludovic.desroches at atmel.com
@ 2012-09-12 6:42 ` ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 7/8] ARM: dts: add twi nodes for atmel SoCs ludovic.desroches at atmel.com
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-09-12 6:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Nikolaus Voss <n.voss@weinmann.de>
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 | 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] 14+ messages in thread
* [PATCH v3 7/8] ARM: dts: add twi nodes for atmel SoCs
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
` (5 preceding siblings ...)
2012-09-12 6:42 ` [PATCH v3 6/8] ARM: at91: add clocks for I2C DT entries ludovic.desroches at atmel.com
@ 2012-09-12 6:42 ` ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 8/8] ARM: dts: add twi nodes for atmel boards ludovic.desroches at atmel.com
` (2 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-09-12 6:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Ludovic Desroches <ludovic.desroches@atmel.com>
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@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
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 at 0 {
@@ -199,6 +200,15 @@
status = "disabled";
};
+ i2c0: i2c at fffac000 {
+ compatible = "atmel,at91sam9260-i2c";
+ reg = <0xfffac000 0x100>;
+ interrupts = <11 4 6>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
adc0: adc at 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 at 0 {
@@ -180,6 +181,15 @@
interrupts = <24 4 2>;
status = "disabled";
};
+
+ i2c0: i2c at fff88000 {
+ compatible = "atmel,at91sam9263-i2c";
+ reg = <0xfff88000 0x100>;
+ interrupts = <13 4 6>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
};
nand0: nand at 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 at fffac000 {
+ compatible = "atmel,at91sam9g20-i2c";
+ };
+
adc0: adc at 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 at 0 {
@@ -201,6 +203,24 @@
status = "disabled";
};
+ i2c0: i2c at fff84000 {
+ compatible = "atmel,at91sam9g10-i2c";
+ reg = <0xfff84000 0x100>;
+ interrupts = <12 4 6>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
+ i2c1: i2c at fff88000 {
+ compatible = "atmel,at91sam9g10-i2c";
+ reg = <0xfff88000 0x100>;
+ interrupts = <13 4 6>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
adc0: adc at 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 at 0 {
@@ -178,6 +180,24 @@
atmel,use-dma-tx;
status = "disabled";
};
+
+ i2c0: i2c at f8010000 {
+ compatible = "atmel,at91sam9x5-i2c";
+ reg = <0xf8010000 0x100>;
+ interrupts = <9 4 6>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
+ i2c1: i2c at f8014000 {
+ compatible = "atmel,at91sam9x5-i2c";
+ reg = <0xf8014000 0x100>;
+ interrupts = <10 4 6>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
};
nand0: nand at 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 at 0 {
@@ -192,6 +195,33 @@
status = "disabled";
};
+ i2c0: i2c at f8010000 {
+ compatible = "atmel,at91sam9x5-i2c";
+ reg = <0xf8010000 0x100>;
+ interrupts = <9 4 6>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
+ i2c1: i2c at f8014000 {
+ compatible = "atmel,at91sam9x5-i2c";
+ reg = <0xf8014000 0x100>;
+ interrupts = <10 4 6>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
+ i2c2: i2c at f8018000 {
+ compatible = "atmel,at91sam9x5-i2c";
+ reg = <0xf8018000 0x100>;
+ interrupts = <11 4 6>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
adc0: adc at f804c000 {
compatible = "atmel,at91sam9260-adc";
reg = <0xf804c000 0x100>;
--
1.7.11.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v3 8/8] ARM: dts: add twi nodes for atmel boards
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
` (6 preceding siblings ...)
2012-09-12 6:42 ` [PATCH v3 7/8] ARM: dts: add twi nodes for atmel SoCs ludovic.desroches at atmel.com
@ 2012-09-12 6:42 ` ludovic.desroches at atmel.com
2012-09-12 8:03 ` [PATCH v3 0/8] i2c: at91: cleanup and dt support Nicolas Ferre
2012-09-12 12:58 ` Wolfram Sang
9 siblings, 0 replies; 14+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-09-12 6:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Ludovic Desroches <ludovic.desroches@atmel.com>
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@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
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 96514c1..877c08f 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..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 at fff84000 {
+ status = "okay";
+ };
+
+ 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] 14+ messages in thread
* [PATCH v3 0/8] i2c: at91: cleanup and dt support
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
` (7 preceding siblings ...)
2012-09-12 6:42 ` [PATCH v3 8/8] ARM: dts: add twi nodes for atmel boards ludovic.desroches at atmel.com
@ 2012-09-12 8:03 ` Nicolas Ferre
2012-09-12 10:16 ` Wolfram Sang
2012-09-12 12:58 ` Wolfram Sang
9 siblings, 1 reply; 14+ messages in thread
From: Nicolas Ferre @ 2012-09-12 8:03 UTC (permalink / raw)
To: linux-arm-kernel
On 09/12/2012 08:42 AM, ludovic.desroches at atmel.com :
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
>
> Hi,
>
> This set of patches is based on Nikolaus at91_i2c driver.
>
> Changes:
> v3:
> - only put multi-drive lines in the if...else statement (suggested
> by Warner Losh)
Hi Wolfram,
As said by Ludovic, this series goes on top of Nikolaus' one.
My Acked-by is already set on this one, so I think that I have nothing
more to do ;-)
BTW, in case you need help to sort all this, do not hesitate to contact
us... we can setup a git tree for this...
Bye,
> 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 | 23 +--
> 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, 338 insertions(+), 117 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 0/8] i2c: at91: cleanup and dt support
2012-09-12 8:03 ` [PATCH v3 0/8] i2c: at91: cleanup and dt support Nicolas Ferre
@ 2012-09-12 10:16 ` Wolfram Sang
2012-09-12 10:39 ` Voss, Nikolaus
2012-09-12 11:12 ` ludovic.desroches
0 siblings, 2 replies; 14+ messages in thread
From: Wolfram Sang @ 2012-09-12 10:16 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Sep 12, 2012 at 10:03:59AM +0200, Nicolas Ferre wrote:
> On 09/12/2012 08:42 AM, ludovic.desroches at atmel.com :
> > From: Ludovic Desroches <ludovic.desroches@atmel.com>
> >
> > Hi,
> >
> > This set of patches is based on Nikolaus at91_i2c driver.
> >
> > Changes:
> > v3:
> > - only put multi-drive lines in the if...else statement (suggested
> > by Warner Losh)
>
> Hi Wolfram,
>
> As said by Ludovic, this series goes on top of Nikolaus' one.
> My Acked-by is already set on this one, so I think that I have nothing
> more to do ;-)
>
> BTW, in case you need help to sort all this, do not hesitate to contact
> us... we can setup a git tree for this...
I think I am fine. Patches look good. I wondered a bit about first
removing the old driver, then adding the new one with regard to
bisectability. But as the old driver depends on BROKEN, I think this is
OK to do.
One thing I'd like to make, though. I'd like to squash the following
patches into one:
drivers/i2c/busses/i2c-at91.c: add new driver
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
It is especially the last patch I am mostly interested in. The id_table
approach is what I like, while the original id_entry mechanism looks
fishy. I'd was good for reviewing to have the patches split like this;
yet for hitting mainline, I'd prefer to have the driver proper on first
occasion. I already did the squashing in a test-branch and the result
looks good to me.
Nikolaus, Ludovic: Are you fine with this?
Thanks,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120912/f3eb127a/attachment.sig>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 0/8] i2c: at91: cleanup and dt support
2012-09-12 10:16 ` Wolfram Sang
@ 2012-09-12 10:39 ` Voss, Nikolaus
2012-09-12 11:12 ` ludovic.desroches
1 sibling, 0 replies; 14+ messages in thread
From: Voss, Nikolaus @ 2012-09-12 10:39 UTC (permalink / raw)
To: linux-arm-kernel
Wolfram Sang wrote on Wednesday, September 12, 2012 12:16 PM:
> One thing I'd like to make, though. I'd like to squash the following
> patches into one:
>
> drivers/i2c/busses/i2c-at91.c: add new driver
> 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
>
> It is especially the last patch I am mostly interested in. The id_table
> approach is what I like, while the original id_entry mechanism looks
> fishy. I'd was good for reviewing to have the patches split like this;
> yet for hitting mainline, I'd prefer to have the driver proper on first
> occasion. I already did the squashing in a test-branch and the result
> looks good to me.
>
> Nikolaus, Ludovic: Are you fine with this?
Absolutely.
Niko
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 0/8] i2c: at91: cleanup and dt support
2012-09-12 10:16 ` Wolfram Sang
2012-09-12 10:39 ` Voss, Nikolaus
@ 2012-09-12 11:12 ` ludovic.desroches
1 sibling, 0 replies; 14+ messages in thread
From: ludovic.desroches @ 2012-09-12 11:12 UTC (permalink / raw)
To: linux-arm-kernel
Hi Wolfram,
Le 09/12/2012 12:16 PM, Wolfram Sang a ?crit :
> On Wed, Sep 12, 2012 at 10:03:59AM +0200, Nicolas Ferre wrote:
>> On 09/12/2012 08:42 AM, ludovic.desroches at atmel.com :
>>> From: Ludovic Desroches <ludovic.desroches@atmel.com>
>>>
>>> Hi,
>>>
>>> This set of patches is based on Nikolaus at91_i2c driver.
>>>
>>> Changes:
>>> v3:
>>> - only put multi-drive lines in the if...else statement (suggested
>>> by Warner Losh)
>>
>> Hi Wolfram,
>>
>> As said by Ludovic, this series goes on top of Nikolaus' one.
>> My Acked-by is already set on this one, so I think that I have nothing
>> more to do ;-)
>>
>> BTW, in case you need help to sort all this, do not hesitate to contact
>> us... we can setup a git tree for this...
>
> I think I am fine. Patches look good. I wondered a bit about first
> removing the old driver, then adding the new one with regard to
> bisectability. But as the old driver depends on BROKEN, I think this is
> OK to do.
>
> One thing I'd like to make, though. I'd like to squash the following
> patches into one:
>
> drivers/i2c/busses/i2c-at91.c: add new driver
> 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
>
> It is especially the last patch I am mostly interested in. The id_table
> approach is what I like, while the original id_entry mechanism looks
> fishy. I'd was good for reviewing to have the patches split like this;
> yet for hitting mainline, I'd prefer to have the driver proper on first
> occasion. I already did the squashing in a test-branch and the result
> looks good to me.
>
> Nikolaus, Ludovic: Are you fine with this?
>
No problem on my side.
Regards
Ludovic
> Thanks,
>
> Wolfram
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 0/8] i2c: at91: cleanup and dt support
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
` (8 preceding siblings ...)
2012-09-12 8:03 ` [PATCH v3 0/8] i2c: at91: cleanup and dt support Nicolas Ferre
@ 2012-09-12 12:58 ` Wolfram Sang
9 siblings, 0 replies; 14+ messages in thread
From: Wolfram Sang @ 2012-09-12 12:58 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Sep 12, 2012 at 08:42:09AM +0200, ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
>
> Hi,
>
> This set of patches is based on Nikolaus at91_i2c driver.
Pushed both series with the discussed squashing to:
git://git.pengutronix.de/git/wsa/linux.git i2c-embedded/for-next
You might want to have a look if everything looks good to you.
Thanks to everyone involved!
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120912/a4fa181e/attachment.sig>
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2012-09-12 12:58 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-12 6:42 [PATCH v3 0/8] i2c: at91: cleanup and dt support ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 1/8] i2c: at91: use managed resources ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 2/8] i2c: at91: add warning about transmission issues for some devices ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 3/8] i2c: at91: use an id table for SoC dependent parameters ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 4/8] ARM: at91: do not configure at91sam9g10 twi pio as open-drain ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 5/8] i2c: at91: add dt support to i2c-at91 ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 6/8] ARM: at91: add clocks for I2C DT entries ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 7/8] ARM: dts: add twi nodes for atmel SoCs ludovic.desroches at atmel.com
2012-09-12 6:42 ` [PATCH v3 8/8] ARM: dts: add twi nodes for atmel boards ludovic.desroches at atmel.com
2012-09-12 8:03 ` [PATCH v3 0/8] i2c: at91: cleanup and dt support Nicolas Ferre
2012-09-12 10:16 ` Wolfram Sang
2012-09-12 10:39 ` Voss, Nikolaus
2012-09-12 11:12 ` ludovic.desroches
2012-09-12 12:58 ` Wolfram Sang
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).