i2c: at91: cleanup and dt support
Subsystems (5)
v3 cover i2c: at91: cleanup and dt support
From: Ludovic Desroches <[email protected]>
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
Signature · 1 line
1.7.11.3
PATCH v3 1/8 i2c: at91: use managed resources
From: Ludovic Desroches <[email protected]>
Use managed resources to ease the cleanup.
--- drivers/i2c/busses/i2c-at91.c | 85 +++++++++++++------------------------------ 1 file changed, 25 insertions(+), 60 deletions(-)
drivers/i2c/busses/i2c-at91.c +25 -60
@@ -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; }
Signature · 1 line
1.7.11.3
PATCH v3 2/8 i2c: at91: add warning about transmission issues for some devices
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
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.
--- drivers/i2c/busses/Kconfig | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/i2c/busses/Kconfig +6 -0
@@ -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
Signature · 1 line
1.7.11.3
PATCH v3 3/8 i2c: at91: use an id table for SoC dependent parameters
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
Use the id_table to store configuration structures which are depending on SoC.
--- 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(-)
arch/arm/mach-at91/at91rm9200.c +1 -1
@@ -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),
arch/arm/mach-at91/at91rm9200_devices.c +1 -10
@@ -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), };
arch/arm/mach-at91/at91sam9260.c +2 -1
@@ -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),
arch/arm/mach-at91/at91sam9260_devices.c +7 -1
@@ -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 );
arch/arm/mach-at91/at91sam9261.c +2 -1
@@ -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),
arch/arm/mach-at91/at91sam9261_devices.c +7 -10
@@ -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 );
arch/arm/mach-at91/at91sam9263.c +1 -1
@@ -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),
arch/arm/mach-at91/at91sam9263_devices.c +1 -1
@@ -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),
arch/arm/mach-at91/at91sam9g45.c +2 -2
@@ -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),
arch/arm/mach-at91/at91sam9g45_devices.c +2 -2
@@ -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),
arch/arm/mach-at91/at91sam9rl.c +2 -2
@@ -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),
arch/arm/mach-at91/at91sam9rl_devices.c +1 -1
@@ -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),
drivers/i2c/busses/i2c-at91.c +66 -19
140 lines not on this page · raw message
Signature · 1 line
1.7.11.3
PATCH v3 4/8 ARM: at91: do not configure at91sam9g10 twi pio as open-drain
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
As indicated in the datasheet, TWD and TWCK must not be programmed as open-drain.
--- arch/arm/mach-at91/at91sam9261_devices.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-at91/at91sam9261_devices.c +3 -3
@@ -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);
Signature · 1 line
1.7.11.3
PATCH v3 5/8 i2c: at91: add dt support to i2c-at91
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
--- .../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
Documentation/devicetree/bindings/i2c/atmel-i2c.txt new file +30 -0
@@ -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>; + } +}
drivers/i2c/busses/i2c-at91.c +49 -0
85 lines not on this page · raw message
Signature · 1 line
1.7.11.3
PATCH v3 6/8 ARM: at91: add clocks for I2C DT entries
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
--- 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(-)
arch/arm/mach-at91/at91sam9260.c +1 -0
@@ -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),
arch/arm/mach-at91/at91sam9263.c +1 -0
@@ -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[] = {
arch/arm/mach-at91/at91sam9g45.c +2 -0
@@ -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),
arch/arm/mach-at91/at91sam9n12.c +2 -0
@@ -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),
arch/arm/mach-at91/at91sam9x5.c +3 -3
@@ -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),
Signature · 1 line
1.7.11.3
PATCH v3 7/8 ARM: dts: add twi nodes for atmel SoCs
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
Add TWI nodes for atmel SoCs but keep i2c-gpio ones in order to let the choice to the user in dts files.
--- 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(+)
arch/arm/boot/dts/at91sam9260.dtsi +10 -0
@@ -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>;
arch/arm/boot/dts/at91sam9263.dtsi +10 -0
@@ -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 {
arch/arm/boot/dts/at91sam9g20.dtsi +4 -0
@@ -18,6 +18,10 @@ ahb { apb { + i2c0: i2c at fffac000 { + compatible = "atmel,at91sam9g20-i2c"; + }; + adc0: adc at fffe0000 { atmel,adc-startup-time = <40>; };
arch/arm/boot/dts/at91sam9g45.dtsi +20 -0
@@ -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>;
arch/arm/boot/dts/at91sam9n12.dtsi +20 -0
@@ -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 {
arch/arm/boot/dts/at91sam9x5.dtsi +30 -0
@@ -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>;
Signature · 1 line
1.7.11.3
PATCH v3 8/8 ARM: dts: add twi nodes for atmel boards
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
Still use i2c-gpio on boards which have a SoC with a TWI IP which doesn't have clock stretching in transmission mode.
--- 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(+)
arch/arm/boot/dts/at91sam9g25ek.dts +12 -0
@@ -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 {
arch/arm/boot/dts/at91sam9m10g45ek.dts +8 -0
@@ -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 {
arch/arm/boot/dts/at91sam9n12ek.dts +8 -0
@@ -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 {
Signature · 1 line
1.7.11.3
v3 cover i2c: at91: cleanup and dt support
In reply to ludovic.desroches at atmel.comOn 09/12/2012 08:42 AM, ludovic.desroches at atmel.com :
Quoted 10 lines
From: Ludovic Desroches <[email protected]>
Hi,
This set of patches is based on Nikolaus
at91_i2cdriver.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,
Quoted 45 lines
v2:
- change driver name fromxxx_i2cto 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 modeLudovic 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
Signature · 1 line
Nicolas Ferre
v3 cover i2c: at91: cleanup and dt support
Quoted 12 lines · Nicolas Ferre
On 09/12/2012 08:42 AM, ludovic.desroches at atmel.com :
Quoted 10 lines
From: Ludovic Desroches <[email protected]>
Hi,
This set of patches is based on Nikolaus
at91_i2cdriver.Changes:
v3:
- only put multi-drive lines in the if...else statement (suggested by Warner Losh)
Quoted 8 lines
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
Signature · 9 lines
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>
v3 cover i2c: at91: cleanup and dt support
Wolfram Sang wrote on Wednesday, September 12, 2012 12:16 PM:
Quoted 8 lines
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
Quoted 8 lines
It is especially the last patch I am mostly interested in. The
id_tableapproach is what I like, while the originalid_entrymechanism 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
v3 cover i2c: at91: cleanup and dt support
In reply to Wolfram SangHi Wolfram,
Le 09/12/2012 12:16 PM, Wolfram Sang a ?crit :
Quoted 35 lines · Nicolas Ferre
Quoted 12 lines
On 09/12/2012 08:42 AM, ludovic.desroches at atmel.com :
Quoted 10 lines
From: Ludovic Desroches <[email protected]>
Hi,
This set of patches is based on Nikolaus
at91_i2cdriver.Changes:
v3:
- only put multi-drive lines in the if...else statement (suggested by Warner Losh)Quoted 8 lines
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
Quoted 9 lines
It is especially the last patch I am mostly interested in. The
id_tableapproach is what I like, while the originalid_entrymechanism 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
Quoted 4 lines
Thanks,
Wolfram
v3 cover i2c: at91: cleanup and dt support
In reply to ludovic.desroches at atmel.comQuoted 5 lines · ludovic.desroches at atmel.com
From: Ludovic Desroches <[email protected]>
Hi,
This set of patches is based on Nikolaus
at91_i2cdriver.
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!
Signature · 9 lines
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>