i2c: at91: cleanup and dt support
Subsystems (5)
cover i2c: at91: cleanup and dt support
From: Ludovic Desroches <[email protected]>
Hi,
This set of patches is based on Nikolaus at91_i2c driver.
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 | 23 +-- arch/arm/boot/dts/at91sam9263.dtsi | 23 +-- arch/arm/boot/dts/at91sam9263ek.dts | 20 +- arch/arm/boot/dts/at91sam9g20.dtsi | 4 + arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 28 +-- arch/arm/boot/dts/at91sam9g25ek.dts | 12 ++ arch/arm/boot/dts/at91sam9g45.dtsi | 33 ++-- arch/arm/boot/dts/at91sam9m10g45ek.dts | 8 + arch/arm/boot/dts/at91sam9n12.dtsi | 33 ++-- arch/arm/boot/dts/at91sam9n12ek.dts | 8 + arch/arm/boot/dts/at91sam9x5.dtsi | 69 +++---- arch/arm/mach-at91/at91rm9200.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 +++++++++++++-------- 28 files changed, 367 insertions(+), 235 deletions(-) create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt
Signature · 1 line
1.7.11.3
PATCH 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 1/8 i2c: at91: use managed resources
ludovic.desroches at atmel.com wrote on Friday, August 31, 2012 11:21 AM:
Quoted 5 lines
From: Ludovic Desroches <[email protected]>
Use managed resources to ease the cleanup.
Signed-off-by Ludovic Desroches <[email protected]>
Quoted 145 lines
--- drivers/i2c/busses/i2c-at91.c | 85 +++++++++++++------------------------------ 1 file changed, 25 insertions(+), 60 deletions(-)drivers/i2c/busses/i2c-at91.c +22
-34@@ -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" );drivers/i2c/busses/i2c-at91.c +3
-26i2c_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
PATCH 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 2/8 i2c: at91: add warning about transmission issues for some devices
ludovic.desroches at atmel.com wrote on Friday, August 31, 2012 11:21 AM
Quoted 8 lines
From: 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.
Signed-off-by Ludovic Desroches <[email protected]>
Quoted 25 lines
--- drivers/i2c/busses/Kconfig | 6 ++++++ 1 file changed, 6 insertions(+)drivers/i2c/busses/Kconfig +1
-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, at91sam9263devices
drivers/i2c/busses/Kconfig +2
-0+ don't have clock stretching in transmission mode. For that reason, + you can encounter underrun issues causing premature stopsendings if
drivers/i2c/busses/Kconfig +3
-1+ 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
PATCH 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 ,"at91rm9200_i2c" , &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 ="at91rm9200_i2c" , .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 ,"at91sam9260_i2c" , &twi_clk), +CLKDEV_CON_DEV_ID (NULL ,"at91sam9g20_i2c" , &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 ="at91sam9g20_i2c" ; + }else { + at91sam9260_twi_device.name ="at91sam9260_i2c" ; + } +/* 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 ,"at91sam9261_i2c" , &twi_clk), +CLKDEV_CON_DEV_ID (NULL ,"at91sam9g10_i2c" , &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 ="at91sam9g10_i2c" ; + }else { + at91sam9261_twi_device.name ="at91sam9261_i2c" ; + } +/* 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 ,"at91sam9260_i2c" , &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 ="at91sam9260_i2c" , .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 ,"at91sam9g10_i2c.0" , &twi0_clk), +CLKDEV_CON_DEV_ID (NULL ,"at91sam9g10_i2c.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 ="at91sam9g10_i2c" , .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 ="at91sam9g10_i2c" , .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 ,"at91sam9g20_i2c.0" , &twi0_clk), +CLKDEV_CON_DEV_ID (NULL ,"at91sam9g20_i2c.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 ="at91sam9g20_i2c" , .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 3/8 i2c: at91: use an id table for SoC dependent parameters
Quoted 27 lines · ludovic.desroches at atmel.com
From: Ludovic Desroches <[email protected]>
Use the
id_tableto store configuration structures which are depending on SoC.Signed-off-by Ludovic Desroches <[email protected]>--- 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 +0
-0
arch/arm/mach-at91/at91rm9200.c static struct clk_lookup periph_clocks_lookups[] = { · line 190
Quoted 5 lines
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, "at91rm9200_i2c", &twi_clk),
use i2c-xxx as on other drivers
and I do not like to have platform_device_id
as we need to touch the driver to add a new soc
please use platform data
Best Regards,
J.
PATCH 3/8 i2c: at91: use an id table for SoC dependent parameters
On 08/31/2012 04:29 PM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 35 lines · ludovic.desroches at atmel.com
Quoted 27 lines
From: Ludovic Desroches <[email protected]>
Use the
id_tableto store configuration structures which are depending on SoC.Signed-off-by Ludovic Desroches <[email protected]>--- 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 +0
-0arch/arm/mach-at91/at91rm9200.c static struct clk_lookup periph_clocks_lookups[] = { · line 190
Quoted 5 lines
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, "at91rm9200_i2c", &twi_clk),use i2c-xxx as on other drivers
Quoted 1 line
and I do not like to have
platform_device_id
Me, I like it and find this implementation very elegant.
Quoted 1 line
as we need to touch the driver to add a new soc
So what? We still keep the compatibility if the new SoC has it compatibility assured with previous revision: there is nothing to modify.
Quoted 1 line
please use platform data
No, it does not have to be exposed to the user: these data are highly dependent on the actual hardware (IP revision in fact). So, no need to mess with platform data.
So I will acknowledge Ludo's patches.
Bye,
Signature · 1 line
Nicolas Ferre
PATCH 3/8 i2c: at91: use an id table for SoC dependent parameters
Quoted 12 lines · Nicolas Ferre
Quoted 12 lines
arch/arm/mach-at91/at91rm9200.c static struct clk_lookup periph_clocks_lookups[] = { · line 190
Quoted 10 lines
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, "at91rm9200_i2c",&twi_clk),use i2c-xxx as on other drivers
Quoted 8 lines
Quoted 1 line
and I do not like to have
platform_device_idMe, I like it and find this implementation very elegant.
Quoted 1 line
as we need to touch the driver to add a new soc
So what? We still keep the compatibility if the new SoC has it compatibility assured with previous revision: there is nothing to modify.
I agree. The driver would need to be touched to support new SoC only if the IP there have had some differences, which would have needed to be resolved anyway.
Quoted 1 line
Quoted 1 line
please use platform data
Using platform data for the dt platforms would have been more troublesome, wouldn't it ? I like Ludovic's approach which handles both: dt and non-dt cases in uniform way from the driver's POV.
Quoted 3 lines
No, it does not have to be exposed to the user: these data are highly dependent on the actual hardware (IP revision in fact). So, no need to mess with platform data.
Agreed.
Quoted 3 lines
So I will acknowledge Ludo's patches.
Bye,
--
Regards,
Sylwester
PATCH 3/8 i2c: at91: use an id table for SoC dependent parameters
Quoted 26 lines · Sylwester Nawrocki
Quoted 12 lines · Nicolas Ferre
Quoted 12 lines
arch/arm/mach-at91/at91rm9200.c static struct clk_lookup periph_clocks_lookups[] = { · line 190
Quoted 10 lines
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, "at91rm9200_i2c",&twi_clk),use i2c-xxx as on other drivers
Quoted 8 lines
Quoted 1 line
and I do not like to have
platform_device_idMe, I like it and find this implementation very elegant.
Quoted 1 line
as we need to touch the driver to add a new soc
So what? We still keep the compatibility if the new SoC has it compatibility assured with previous revision: there is nothing to modify.
I agree. The driver would need to be touched to support new SoC only if the IP there have had some differences, which would have needed to be resolved anyway.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
please use platform data
Using platform data for the dt platforms would have been more troublesome, wouldn't it ? I like Ludovic's approach which handles both: dt and non-dt cases in uniform way from the driver's POV.
no you will describe it via DT as done on all the other drivers
Quoted 4 lines
Quoted 4 lines
No, it does not have to be exposed to the user: these data are highly dependent on the actual hardware (IP revision in fact). So, no need to mess with platform data.
no I really see no point on these list of platform_id it's does not look more nice just more huggly to have x names. This is at the end the same as passing platform data via soc info (add_xx or dtsi)
And here you just do the same as cpu_is via names.
The driver need to read IP revision instead
Best Regards,
J.
PATCH 3/8 i2c: at91: use an id table for SoC dependent parameters
Quoted 27 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 26 lines · Sylwester Nawrocki
Quoted 12 lines · Nicolas Ferre
Quoted 12 lines
arch/arm/mach-at91/at91rm9200.c static struct clk_lookup periph_clocks_lookups[] = { · line 190
Quoted 10 lines
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, "at91rm9200_i2c",&twi_clk),use i2c-xxx as on other drivers
Quoted 8 lines
Quoted 1 line
and I do not like to have
platform_device_idMe, I like it and find this implementation very elegant.
Quoted 1 line
as we need to touch the driver to add a new soc
So what? We still keep the compatibility if the new SoC has it compatibility assured with previous revision: there is nothing to modify.
I agree. The driver would need to be touched to support new SoC only if the IP there have had some differences, which would have needed to be resolved anyway.
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
please use platform data
Using platform data for the dt platforms would have been more troublesome, wouldn't it ? I like Ludovic's approach which handles both: dt and non-dt cases in uniform way from the driver's POV.
no you will describe it via DT as done on all the other drivers
Yeah, makes sense. However there are drivers that deduce some parameters only from the 'compatible' property, let's take drivers/dma/mxs-dma.c as an example. I'm just trying to understand if there is a general preference on how to handle those things. Of course we could have all detail properties listed in a .dtsi file. But since we can derive these from a single property, it might be more sensible to avoid parsing ?
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
No, it does not have to be exposed to the user: these data are highly dependent on the actual hardware (IP revision in fact). So, no need to mess with platform data.
no I really see no point on these list of
platform_idit's does not look more nice just more huggly to have x names. This is at the end the same as passing platform data via soc info (add_xxor dtsi)And here you just do the same as
cpu_isvia names.The driver need to read IP revision instead
OK, but wouldn't it be needed to resolve an IP revision at run time, e.g. with soc_is_*() anyway ? Having it set at each board doesn't look like an optimal method either.
--
Regards,
Sylwester
PATCH 3/8 i2c: at91: use an id table for SoC dependent parameters
Quoted 10 lines · Sylwester Nawrocki
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Sylwester Nawrocki
Quoted 3 lines · Nicolas Ferre
No, it does not have to be exposed to the user: these data are highly dependent on the actual hardware (IP revision in fact). So, no need to mess with platform data.
no I really see no point on these list of
platform_idit's does not look more nice just more huggly to have x names. This is at the end the same as passing platform data via soc info (add_xxor dtsi)
Quoted 7 lines
Quoted 3 lines
And here you just do the same as
cpu_isvia names.The driver need to read IP revision instead
OK, but wouldn't it be needed to resolve an IP revision at run time, e.g. with soc_is_*() anyway ? Having it set at each board doesn't look like an optimal method either.
I'd much rather have a DT setting that gives the IP version in some manner, so I can key work arounds off of that. Not so important for legacy devices where the Errata are well known (since you could do the same thing with some kind of property that's a boolean like for the AT91RM9200's mci controller that needs to swap bytes). However, given my experience of bringing the FreeBSD at91rm9200 port to life and taking a product to market with it, I'd anticipate that the Errata will evolve over time, as will the need for workarounds. Having an IP version helps deploy new drivers to the field without needing new DT files.
As you can tell, I'm not a big soc_is_* fan...
Warner
PATCH 3/8 i2c: at91: use an id table for SoC dependent parameters
In reply to Jean-Christophe PLAGNIOL-VILLARDJean-Christophe PLAGNIOL-VILLARD wrote on Saturday, September 01, 2012 11:11 AM:
Quoted 40 lines · Sylwester Nawrocki
Quoted 2 lines · Nicolas Ferre
Quoted 1 line
Quoted 1 line
arch/arm/mach-
Quoted 1 line
arch/arm/mach- renamed from arch/arm/mach-at91/at91rm9200.c +0
-0
at91/at91rm9200.cQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-at91/at91rm9200.c static struct clk_lookup periph_clocks_lookups[]
Quoted 4 lines
index f2112f9..0bc91e5 100644
arch/arm/mach-at91/at91rm9200.c +0
-0@@ -187,7 +187,7 @@ static struct clk_lookup periph_clocks_lookups[]= {
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
arch/arm/mach-at91/at91rm9200.c static struct clk_lookup periph_clocks_lookups[] · line 190
Quoted 5 lines
arch/arm/mach-at91/at91rm9200.c +1
-1CLKDEV_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, "at91rm9200_i2c",&twi_clk),use i2c-xxx as on other drivers
Quoted 8 lines
Quoted 1 line
and I do not like to have
platform_device_idMe, I like it and find this implementation very elegant.
Quoted 1 line
as we need to touch the driver to add a new soc
So what? We still keep the compatibility if the new SoC has it compatibility assured with previous revision: there is nothing to modify.
Quoted 7 lines
I agree. The driver would need to be touched to support new SoC only if the IP there have had some differences, which would have needed to be resolved anyway.
Quoted 1 line
Quoted 1 line
please use platform data
Using platform data for the dt platforms would have been more
troublesome,
Quoted 2 lines
wouldn't it ? I like Ludovic's approach which handles both: dt and non-dt cases in uniform way from the driver's POV.
no you will describe it via DT as done on all the other drivers
Quoted 4 lines
Quoted 4 lines
No, it does not have to be exposed to the user: these data are highly dependent on the actual hardware (IP revision in fact). So, no need to mess with platform data.
Quoted 6 lines
no I really see no point on these list of
platform_idit's does not look more nice just more huggly to have x names. This is at the end the same as passing
platform data via soc info (add_xxor dtsi)And here you just do the same as
cpu_isvia names.
That's what the names suggest, but it's not the case. What the DEV_IDs stand for is actually an IP version which cannot be read out from the IP directly. So the version information is coded at a place where it should be available: in the SoC setup code (not in the driver code, as with the cpu_is() variant). Example: the name at91sam9g10 does not stand for the cpu type but for the IP class which is also used on g45 SoC.
Quoted 2 lines
The driver need to read IP revision instead
That would be the easiest solution, but the IP does not know it's version. The DEV_ID approach is a workaround for this limitation.
Regards,
Niko
PATCH 3/8 i2c: at91: use an id table for SoC dependent parameters
In reply to Jean-Christophe PLAGNIOL-VILLARDLe 09/01/2012 11:10 AM, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
Quoted 37 lines · Sylwester Nawrocki
Quoted 26 lines · Nicolas Ferre
Quoted 12 lines
Quoted 12 lines
arch/arm/mach-at91/at91rm9200.c static struct clk_lookup periph_clocks_lookups[] = { · line 190
Quoted 10 lines
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, "at91rm9200_i2c",&twi_clk),use i2c-xxx as on other drivers
Quoted 8 lines
Quoted 1 line
and I do not like to have
platform_device_idMe, I like it and find this implementation very elegant.
Quoted 1 line
as we need to touch the driver to add a new soc
So what? We still keep the compatibility if the new SoC has it compatibility assured with previous revision: there is nothing to modify.
I agree. The driver would need to be touched to support new SoC only if the IP there have had some differences, which would have needed to be resolved anyway.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
please use platform data
Using platform data for the dt platforms would have been more troublesome, wouldn't it ? I like Ludovic's approach which handles both: dt and non-dt cases in uniform way from the driver's POV.
no you will describe it via DT as done on all the other drivers
Quoted 4 lines
Quoted 4 lines
No, it does not have to be exposed to the user: these data are highly dependent on the actual hardware (IP revision in fact). So, no need to mess with platform data.
Quoted 8 lines
no I really see no point on these list of
platform_idit's does not look more nice just more huggly to have x names. This is at the end the same as passing platform data via soc info (add_xxor dtsi)And here you just do the same as
cpu_isvia names.The driver need to read IP revision instead
At the beginning it was planned to do this but:
- a new SoC, with a new IP version lead to update the driver also
- with the MCI driver which uses IP version, I have some cases where using the version was not enough, a SoC approach would be better. For instance, the IP version tells that we can use PDC feature but PDC is not connected.
Quoted 4 lines
Best Regards,
J.
Regards
Ludovic
PATCH 3/8 i2c: at91: use an id table for SoC dependent parameters
On 09/03/2012 09:24 AM, ludovic.desroches :
Quoted 54 lines
Le 09/01/2012 11:10 AM, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
Quoted 48 lines · Sylwester Nawrocki
Quoted 29 lines · Nicolas Ferre
Quoted 16 lines
Quoted 14 lines
arch/arm/mach-at91/at91rm9200.c static struct clk_lookup · line 191
Quoted 12 lines
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, "at91rm9200_i2c",&twi_clk),use i2c-xxx as on other drivers
Quoted 1 line
and I do not like to have
platform_device_idQuoted 7 lines
Me, I like it and find this implementation very elegant.
Quoted 1 line
as we need to touch the driver to add a new soc
So what? We still keep the compatibility if the new SoC has it compatibility assured with previous revision: there is nothing to modify.
I agree. The driver would need to be touched to support new SoC only if the IP there have had some differences, which would have needed to be resolved anyway.
Quoted 7 lines
Quoted 1 line
Quoted 1 line
please use platform data
Using platform data for the dt platforms would have been more troublesome,
wouldn't it ? I like Ludovic's approach which handles both: dt and non-dt
cases in uniform way from the driver's POV.no you will describe it via DT as done on all the other drivers
Quoted 4 lines
Quoted 4 lines
No, it does not have to be exposed to the user: these data are highly dependent on the actual hardware (IP revision in fact). So, no need to mess with platform data.
no I really see no point on these list of
platform_idit's does not look more
nice just more huggly to have x names. This is at the end the same as passing
platform data via soc info (add_xxor dtsi)Quoted 4 lines
And here you just do the same as
cpu_isvia names.The driver need to read IP revision instead
Quoted 6 lines
At the beginning it was planned to do this but:
- a new SoC, with a new IP version lead to update the driver also
- with the MCI driver which uses IP version, I have some cases where using the version was not enough, a SoC approach would be better. For instance, the IP version tells that we can use PDC feature but PDC is not connected.
Absolutely. Nikolaus and you have summarized clearly the situation.
I think there is a consensus here.
So, we can move to a v2 patch series...
Bye,
Signature · 1 line
Nicolas Ferre
PATCH 3/8 i2c: at91: use an id table for SoC dependent parameters
In reply to ludovic.desroches at atmel.comludovic.desroches at atmel.com wrote on Friday, August 31, 2012 11:21 AM
Quoted 6 lines
From: Ludovic Desroches <[email protected]>
Use the
id_tableto store configuration structures which are depending on SoC.Signed-off-by Ludovic Desroches <[email protected]>
Nice solution!
Quoted 414 lines
--- 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- renamed from arch/arm/mach-at91/at91rm9200.c +0
-0
at91/at91rm9200.c
index f2112f9..0bc91e5 100644arch/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 ,"at91rm9200_i2c" , &twi_clk),/* fake hclk clock */ CLKDEV_CON_DEV_ID ("hclk" ,"at91_ohci" , &ohci_clk), CLKDEV_CON_ID("pioA", &pioA_clk),arch/arm/mach- renamed from arch/arm/mach-at91/at91rm9200_devices.c +0
-0
at91/at91rm9200_devices.c
index 71e7387..cddfe02 100644arch/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 ="at91rm9200_i2c" , .id =-1 , - .id_entry = &twi_ip_type, .resource = twi_resources, .num_resources =ARRAY_SIZE (twi_resources), };arch/arm/mach- renamed from arch/arm/mach-at91/at91sam9260.c +0
-0
at91/at91sam9260.c
index 57c79ee..5f86e71 100644arch/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 ,"at91sam9260_i2c" , &twi_clk), +CLKDEV_CON_DEV_ID (NULL ,"at91sam9g20_i2c" , &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- renamed from arch/arm/mach-at91/at91sam9260_devices.c +0
-0
at91/at91sam9260_devices.c
index 7b9c2ba..ed02171 100644arch/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 ="at91sam9g20_i2c" ; + }else { + at91sam9260_twi_device.name ="at91sam9260_i2c" ; + } +/* 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- renamed from arch/arm/mach-at91/at91sam9261.c +0
-0
at91/at91sam9261.c
index 71ca1e0..0ccf63c 100644arch/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 ,"at91sam9261_i2c" , &twi_clk), +CLKDEV_CON_DEV_ID (NULL ,"at91sam9g10_i2c" , &twi_clk),CLKDEV_CON_ID ("pioA" , &pioA_clk),CLKDEV_CON_ID ("pioB" , &pioB_clk), CLKDEV_CON_ID("pioC", &pioC_clk),arch/arm/mach- renamed from arch/arm/mach-at91/at91sam9261_devices.c +0
-0
at91/at91sam9261_devices.c
index d830724..c94495d 100644arch/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 ="at91sam9g10_i2c" ; + }else { + at91sam9261_twi_device.name ="at91sam9261_i2c" ; + } +/* 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- renamed from arch/arm/mach-at91/at91sam9263.c +0
-0
at91/at91sam9263.c
index 2a08305..a4d760c 100644arch/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 ,"at91sam9260_i2c" , &twi_clk),/* fake hclk clock */ CLKDEV_CON_DEV_ID ("hclk" ,"at91_ohci" , &ohci_clk), CLKDEV_CON_ID("pioA", &pioA_clk),arch/arm/mach- renamed from arch/arm/mach-at91/at91sam9263_devices.c +0
-0
at91/at91sam9263_devices.c
index eb6bbf8..7cff86c 100644arch/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 ="at91sam9260_i2c" , .id =-1 , .resource = twi_resources, .num_resources =ARRAY_SIZE (twi_resources),arch/arm/mach- renamed from arch/arm/mach-at91/at91sam9g45.c +0
-0
at91/at91sam9g45.c
index ddf3d37..15e62b9 100644arch/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 ,"at91sam9g10_i2c.0" , &twi0_clk), +CLKDEV_CON_DEV_ID (NULL ,"at91sam9g10_i2c.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- renamed from arch/arm/mach-at91/at91sam9g45_devices.c +0
-0
at91/at91sam9g45_devices.c
index f001305..a61c7ec 100644arch/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 ="at91sam9g10_i2c" , .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 ="at91sam9g10_i2c" , .id =1 , .resource = twi1_resources, .num_resources =ARRAY_SIZE (twi1_resources),arch/arm/mach- renamed from arch/arm/mach-at91/at91sam9rl.c +0
-0
at91/at91sam9rl.c
index bf79c1f..d708dfa 100644arch/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 ,"at91sam9g20_i2c.0" , &twi0_clk), +CLKDEV_CON_DEV_ID (NULL ,"at91sam9g20_i2c.1" , &twi1_clk),CLKDEV_CON_ID ("pioA" , &pioA_clk),CLKDEV_CON_ID ("pioB" , &pioB_clk), CLKDEV_CON_ID("pioC", &pioC_clk),arch/arm/mach- renamed from arch/arm/mach-at91/at91sam9rl_devices.c +0
-0
at91/at91sam9rl_devices.c
index f09fff9..2df7411 100644arch/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 ="at91sam9g20_i2c" , .id =-1 , .resource = twi_resources, .num_resources =ARRAY_SIZE (twi_resources),drivers/i2c/busses/i2c-at91.c +0
-0@@ -61,10 +61,10 @@#define AT91_TWI_RHR 0x0030/* Receive Holding Register */
#defineAT91_TWI_THR0x0034/* Transmit Holding Register
*/drivers/i2c/busses/i2c-at91.c +8
-15-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);drivers/i2c/busses/i2c-at91.c +1
-0@@ -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-Quoted 1 line
buf_len);drivers/i2c/busses/i2c-at91.c +1
-1@@ -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; }drivers/i2c/busses/i2c-at91.c +55
-0@@ -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 ="at91rm9200_i2c" , + .driver_data = (unsigned long ) &at91rm9200_config, + }, { + .name ="at91sam9261_i2c" , + .driver_data = (unsigned long ) &at91sam9261_config, + }, { + .name ="at91sam9260_i2c" , + .driver_data = (unsigned long ) &at91sam9260_config, + }, { + .name ="at91sam9g20_i2c" , + .driver_data = (unsigned long ) &at91sam9g20_config, + }, { + .name ="at91sam9g10_i2c" , + .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;drivers/i2c/busses/i2c-at91.c +0
-3@@ -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);drivers/i2c/busses/i2c-at91.c +1
-1@@ -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
PATCH 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 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
arch/arm/mach-at91/at91sam9261_devices.c +10 -8
@@ -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 ="at91sam9g10_i2c" ; +at91_set_A_periph (AT91_PIN_PA7 ,0 );/* TWD */ +at91_set_A_periph (AT91_PIN_PA8 ,0 );/* TWCK */ }else { at91sam9261_twi_device.name ="at91sam9261_i2c" ; +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); }
Signature · 1 line
1.7.11.3
PATCH 4/8 ARM: at91: do not configure at91sam9g10 twi pio as open-drain
ludovic.desroches at atmel.com wrote on Friday, August 31, 2012 11:21 AM
Quoted 6 lines
From: Ludovic Desroches <[email protected]>
As indicated in the datasheet, TWD and TWCK must not be programmed as open-drain.
Signed-off-by Ludovic Desroches <[email protected]>
Quoted 48 lines
--- arch/arm/mach-at91/at91sam9261_devices.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)arch/arm/mach- renamed from arch/arm/mach-at91/at91sam9261_devices.c +0
-0
at91/at91sam9261_devices.c
index c94495d..405f603 100644arch/arm/mach-at91/at91sam9261_devices.c +6
-1@@ -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 ="at91sam9g10_i2c" ; +at91_set_A_periph (AT91_PIN_PA7 ,0 );/* TWD */ +at91_set_A_periph (AT91_PIN_PA8 ,0 );/* TWCK */
arch/arm/mach-at91/at91sam9261_devices.c +1
-0}else { at91sam9261_twi_device.name ="at91sam9261_i2c" ; +at91_set_A_periph (AT91_PIN_PA7 ,0 );/* TWD */
arch/arm/mach-at91/at91sam9261_devices.c +2
-0+at91_set_multi_drive (AT91_PIN_PA7 ,1 ); +at91_set_A_periph (AT91_PIN_PA8 ,0 );/* TWCK */
arch/arm/mach-at91/at91sam9261_devices.c +1
-8+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
A message that is not in the archive (sent off-list or not yet received): 1346404884-18451-5-git-send-email-ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org
Re: [PATCH 4/8] ARM: at91: do not configure at91sam9g10 twi pio as open-drain
Quoted 15 lines · On Aug 31, 2012, at 3:21 AM, <[email protected]…
From: Ludovic Desroches <[email protected]>
As indicated in the datasheet, TWD and TWCK must not be programmed as open-drain.
Signed-off-by Ludovic Desroches <[email protected]>---
arch/arm/mach-at91/at91sam9261_devices.c| 18 ++++++++++--------1 file changed, 10 insertions(+), 8 deletions(-)arch/arm/mach-at91/at91sam9261_devices.c +0
-0
arch/arm/mach-at91/at91sam9261_devices.c static struct platform_device at91sam9261_twi_device = { · line 329
Quoted 7 lines
arch/arm/mach-at91/at91sam9261_devices.c +3
-1@@ -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.
"The IP version is not the same on the 9261 and g10. Only the 9261
requires PIO configured as open-drain."
would be a better way to say this.
Quoted 10 lines
arch/arm/mach-at91/at91sam9261_devices.c +6
-0+*/ if (cpu_is_at91sam9g10 ()) { at91sam9261_twi_device.name ="at91sam9g10_i2c" ; +at91_set_A_periph (AT91_PIN_PA7 ,0 );/* TWD */ +at91_set_A_periph (AT91_PIN_PA8 ,0 );/* TWCK */ }else { at91sam9261_twi_device.name ="at91sam9261_i2c" ; +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 */
arch/arm/mach-at91/at91sam9261_devices.c static struct platform_device at91sam9261_twi_device = { · line 340
Quoted 10 lines
arch/arm/mach-at91/at91sam9261_devices.c +1
-7+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 ); -
You could just move the two multi-drive lines up into the 9261 branch of the above if. That would make it clearer that it is a workaround just for the 9261.
Quoted 10 lines
arch/arm/mach-at91/at91sam9261_devices.c +0
-0i2c_register_board_info (0 , devices, nr_devices);platform_device_register (&at91sam9261_twi_device); }Signature · 6 lines
1.7.11.3 _______________________________________________ devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected] https://lists.ozlabs.org/listinfo/devicetree-discuss
PATCH 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 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
arch/arm/mach-at91/at91sam9261_devices.c +10 -8
@@ -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 ="at91sam9g10_i2c" ; +at91_set_A_periph (AT91_PIN_PA7 ,0 );/* TWD */ +at91_set_A_periph (AT91_PIN_PA8 ,0 );/* TWCK */ }else { at91sam9261_twi_device.name ="at91sam9261_i2c" ; +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); }
Signature · 1 line
1.7.11.3
PATCH 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 5/8 i2c: at91: add dt support to i2c-at91
ludovic.desroches at atmel.com wrote on Friday, August 31, 2012 11:24 AM
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Signed-off-by Ludovic Desroches <[email protected]>
Quoted 147 lines
--- .../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.txtDocumentation/devicetree/bindings/i2c/atmel-i2c.txt new file +5
-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 mappedDocumentation/devicetree/bindings/i2c/atmel-i2c.txt new file +23
-0+ 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 +45
-0@@ -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 ="at91rm9200_i2c" ,@@ -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
__devinitat91_twi_probe(struct platform_device *pdev){drivers/i2c/busses/i2c-at91.c +1
-0struct 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);drivers/i2c/busses/i2c-at91.c +2
-0if (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 ;}
drivers/i2c/busses/i2c-at91.c +1
-1@@ -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
PATCH 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 6/8 ARM: at91: add clocks for I2C DT entries
ludovic.desroches at atmel.com wrote on Friday, August 31, 2012 11:24 AM
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Signed-off-by Ludovic Desroches <[email protected]>
Quoted 85 lines
--- 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- renamed from arch/arm/mach-at91/at91sam9260.c +0
-0
at91/at91sam9260.c
index 5f86e71..43f529a 100644arch/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- renamed from arch/arm/mach-at91/at91sam9263.c +0
-0
at91/at91sam9263.c
index a4d760c..514757e 100644arch/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- renamed from arch/arm/mach-at91/at91sam9g45.c +0
-0
at91/at91sam9g45.c
index 15e62b9..9f3beba 100644arch/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- renamed from arch/arm/mach-at91/at91sam9n12.c +0
-0
at91/at91sam9n12.c
index 0849466..732d3d3 100644arch/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),arch/arm/mach-at91/at91sam9n12.c +0
-0CLKDEV_CON_ID("pioC", &pioCD_clk),arch/arm/mach- renamed from arch/arm/mach-at91/at91sam9x5.c +0
-0
at91/at91sam9x5.c
index 4bad4a2..e503538 100644arch/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),arch/arm/mach-at91/at91sam9x5.c +0
-1CLKDEV_CON_ID ("pioB" , &pioAB_clk), CLKDEV_CON_ID("pioC", &pioCD_clk), --1.7.11.3
PATCH 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 and remove i2c-gpio ones.
--- arch/arm/boot/dts/at91sam9260.dtsi | 23 ++++++------- arch/arm/boot/dts/at91sam9263.dtsi | 23 ++++++------- arch/arm/boot/dts/at91sam9g20.dtsi | 4 +++ arch/arm/boot/dts/at91sam9g45.dtsi | 33 +++++++++++------- arch/arm/boot/dts/at91sam9n12.dtsi | 33 +++++++++++------- arch/arm/boot/dts/at91sam9x5.dtsi | 69 +++++++++++++++++--------------------- 6 files changed, 94 insertions(+), 91 deletions(-)
arch/arm/boot/dts/at91sam9260.dtsi +10 -13
@@ -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>;
@@ -258,17 +268,4 @@ status = "disabled"; }; }; - - i2c at 0 { - compatible = "i2c-gpio"; - gpios = <&pioA 23 0 /* sda */ - &pioA 24 0 /* scl */ - >; - i2c-gpio,sda-open-drain; - i2c-gpio,scl-open-drain; - i2c-gpio,delay-us = <2>; /* ~100 kHz */ - #address-cells = <1>; - #size-cells = <0>; - status = "disabled"; - }; };
arch/arm/boot/dts/at91sam9263.dtsi +10 -13
@@ -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 {
@@ -205,17 +215,4 @@ status = "disabled"; }; }; - - i2c at 0 { - compatible = "i2c-gpio"; - gpios = <&pioB 4 0 /* sda */ - &pioB 5 0 /* scl */ - >; - i2c-gpio,sda-open-drain; - i2c-gpio,scl-open-drain; - i2c-gpio,delay-us = <2>; /* ~100 kHz */ - #address-cells = <1>; - #size-cells = <0>; - status = "disabled"; - }; };
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 -13
@@ -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>;
@@ -269,17 +289,4 @@ status = "disabled"; }; }; - - i2c at 0 { - compatible = "i2c-gpio"; - gpios = <&pioA 20 0 /* sda */ - &pioA 21 0 /* scl */ - >; - i2c-gpio,sda-open-drain; - i2c-gpio,scl-open-drain; - i2c-gpio,delay-us = <5>; /* ~100 kHz */ - #address-cells = <1>; - #size-cells = <0>; - status = "disabled"; - }; };
arch/arm/boot/dts/at91sam9n12.dtsi +20 -13
@@ -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 {
@@ -205,17 +225,4 @@ status = "disabled"; }; }; - - i2c at 0 { - compatible = "i2c-gpio"; - gpios = <&pioA 30 0 /* sda */ - &pioA 31 0 /* scl */ - >; - i2c-gpio,sda-open-drain; - i2c-gpio,scl-open-drain; - i2c-gpio,delay-us = <2>; /* ~100 kHz */ - #address-cells = <1>; - #size-cells = <0>; - status = "disabled"; - }; };
arch/arm/boot/dts/at91sam9x5.dtsi +30 -39
85 lines not on this page · raw message
Signature · 1 line
1.7.11.3
PATCH 7/8 ARM: dts: add twi nodes for atmel SOCs
Quoted 3 lines · ludovic.desroches at atmel.com
From: Ludovic Desroches <[email protected]>
Add twi nodes for atmel SOCs and remove i2c-gpio ones.
Only drop the i2c-gpio on the soc that are kn own to have no issue on the hw IP. For hte onther one keep both in the dtsi
Best Regards,
J.
PATCH 7/8 ARM: dts: add twi nodes for atmel SOCs
Le 08/31/2012 04:41 PM, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
Quoted 7 lines · ludovic.desroches at atmel.com
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Add twi nodes for atmel SOCs and remove i2c-gpio ones.
Only drop the i2c-gpio on the soc that are kn own to have no issue on the hw IP. For hte onther one keep both in the dtsi
Ok I'll keep it.
Regards
Ludovic
Quoted 4 lines
Best Regards,
J.
PATCH 7/8 ARM: dts: add twi nodes for atmel SOCs
In reply to Jean-Christophe PLAGNIOL-VILLARDOn 08/31/2012 04:41 PM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 6 lines · ludovic.desroches at atmel.com
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Add twi nodes for atmel SOCs and remove i2c-gpio ones.
Only drop the i2c-gpio on the soc that are kn own to have no issue on the hw IP. For hte onther one keep both in the dtsi
Yes, I agree with this.
Bye,
Signature · 1 line
Nicolas Ferre
PATCH 8/8 ARM: dts: add twi nodes for atmel boards
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
Use the atmel twi instead of gpio for i2c stuff.
--- arch/arm/boot/dts/at91sam9263ek.dts | 20 ++++++++++---------- arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 28 ++++++++++++++-------------- arch/arm/boot/dts/at91sam9g25ek.dts | 12 ++++++++++++ arch/arm/boot/dts/at91sam9m10g45ek.dts | 8 ++++++++ arch/arm/boot/dts/at91sam9n12ek.dts | 8 ++++++++ 5 files changed, 52 insertions(+), 24 deletions(-)
arch/arm/boot/dts/at91sam9263ek.dts +10 -10
@@ -50,6 +50,16 @@ atmel,vbus-gpio = <&pioA 25 0>; status = "okay"; }; + + i2c0: i2c at fff88000 { + status = "okay"; + + 24c512 at 50 { + compatible = "24c512"; + reg = <0x50>; + pagesize = <128>; + }; + }; }; nand0: nand at 40000000 {
@@ -143,14 +153,4 @@ gpio-key,wakeup; }; }; - - i2c at 0 { - status = "okay"; - - 24c512 at 50 { - compatible = "24c512"; - reg = <0x50>; - pagesize = <128>; - }; - }; };
arch/arm/boot/dts/at91sam9g20ek_common.dtsi +14 -14
@@ -51,6 +51,20 @@ atmel,vbus-gpio = <&pioC 5 0>; status = "okay"; }; + + i2c0: i2c at fffac000 { + status = "okay"; + + 24c512 at 50 { + compatible = "24c512"; + reg = <0x50>; + }; + + wm8731 at 1b { + compatible = "wm8731"; + reg = <0x1b>; + }; + }; }; nand0: nand at 40000000 {
@@ -106,20 +120,6 @@ }; }; - i2c at 0 { - status = "okay"; - - 24c512 at 50 { - compatible = "24c512"; - reg = <0x50>; - }; - - wm8731 at 1b { - compatible = "wm8731"; - reg = <0x1b>; - }; - }; - gpio_keys { compatible = "gpio-keys"; #address-cells = <1>;
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
PATCH 8/8 ARM: dts: add twi nodes for atmel boards
Quoted 3 lines · ludovic.desroches at atmel.com
From: Ludovic Desroches <[email protected]>
Use the atmel twi instead of gpio for i2c stuff.
NACK as you do not update al the platform at the same time and break the Calao
Best Regards,
J.
PATCH 8/8 ARM: dts: add twi nodes for atmel boards
On 08/31/2012 04:42 PM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 5 lines · ludovic.desroches at atmel.com
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Use the atmel twi instead of gpio for i2c stuff.
NACK as you do not update al the platform at the same time and break the Calao
Yes, Ludovic shall keep i2c-gpio at the side of the new twi driver.
But for the platform, the platform maintainer will have to choose the one or the other.
Bye,
Signature · 1 line
Nicolas Ferre
PATCH 8/8 ARM: dts: add twi nodes for atmel boards
Quoted 11 lines · Nicolas Ferre
On 08/31/2012 04:42 PM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 5 lines · ludovic.desroches at atmel.com
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Use the atmel twi instead of gpio for i2c stuff.
NACK as you do not update al the platform at the same time and break the Calao
Yes, Ludovic shall keep i2c-gpio at the side of the new twi driver.
But for the platform, the platform maintainer will have to choose the one or the other.
agreed the platform maintianer need to choose to switch or not
Best Regards,
J.
cover i2c: at91: cleanup and dt support
In reply to ludovic.desroches at atmel.comOn 08/31/2012 11:21 AM, ludovic.desroches at atmel.com :
Quoted 6 lines
From: Ludovic Desroches <[email protected]>
Hi,
This set of patches is based on Nikolaus
at91_i2cdriver.
Quoted 9 lines
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
For the whole patch series (with Jean-Christophe remarks about *dts modifications*):
Quoted 31 lines
.../devicetree/bindings/i2c/atmel-i2c.txt | 30 +++ arch/arm/boot/dts/at91sam9260.dtsi | 23 +-- arch/arm/boot/dts/at91sam9263.dtsi | 23 +-- arch/arm/boot/dts/at91sam9263ek.dts | 20 +- arch/arm/boot/dts/at91sam9g20.dtsi | 4 + arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 28 +-- arch/arm/boot/dts/at91sam9g25ek.dts | 12 ++ arch/arm/boot/dts/at91sam9g45.dtsi | 33 ++-- arch/arm/boot/dts/at91sam9m10g45ek.dts | 8 + arch/arm/boot/dts/at91sam9n12.dtsi | 33 ++-- arch/arm/boot/dts/at91sam9n12ek.dts | 8 + arch/arm/boot/dts/at91sam9x5.dtsi | 69 +++---- arch/arm/mach-at91/at91rm9200.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 +++++++++++++-------- 28 files changed, 367 insertions(+), 235 deletions(-) create mode 100644 Documentation/devicetree/bindings/i2c/atmel-i2c.txt
Signature · 1 line
Nicolas Ferre