i2c:at91: Add device tree property to set clock-frequency
PATCH v2 1/1 i2c:at91: Add device tree property to set clock-frequency
This adds the ability to set "clock-frequency" in the device tree for the i2c bus following the naming of other i2c bus implementations. If the property is not set, the clock frequency will default to the previously used define of 100KHz.
---
v2:
-fixed return code usage and check to not compare agaisnt less than zero
--- Documentation/devicetree/bindings/i2c/i2c-at91.txt | 2 ++ drivers/i2c/busses/i2c-at91.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/i2c/i2c-at91.txt +2 -0
@@ -12,6 +12,7 @@ Required properties : - clocks: phandles to input clocks. Optional properties: +- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 100000 - Child nodes conforming to i2c bus binding Examples :
@@ -23,6 +24,7 @@ i2c0: i2c@fff84000 { #address-cells = <1>; #size-cells = <0>; clocks = <&twi0_clk>; + clock-frequency = <400000>; 24c512@50 { compatible = "24c512";
drivers/i2c/busses/i2c-at91.c +8 -2
@@ -32,7 +32,7 @@#include <linux/slab.h> #include <linux/platform_data/dma-atmel.h> -#define TWI_CLK_HZ 100000/* max 400 Kbits/s */ +#define DEFAULT_TWI_CLK_HZ 100000/* max 400 Kbits/s */ #define AT91_I2C_TIMEOUT msecs_to_jiffies(100)/* transfer timeout */ #define AT91_I2C_DMA_THRESHOLD 8/* enable DMA if transfer size is bigger than this threshold */
@@ -711,6 +711,7 @@ static int at91_twi_probe(struct platform_device *pdev)struct resource *mem;int rc;u32 phy_addr; +int bus_clk_rate; dev =devm_kzalloc (&pdev->dev,sizeof (*dev),GFP_KERNEL );if (!dev)
@@ -756,7 +757,12 @@ static int at91_twi_probe(struct platform_device *pdev) dev->use_dma = true; } -at91_calc_twi_clock (dev,TWI_CLK_HZ ); + rc =of_property_read_u32 (dev->dev->of_node,"clock-frequency" , + &bus_clk_rate); +if (rc) + bus_clk_rate =DEFAULT_TWI_CLK_HZ ; + +at91_calc_twi_clock (dev, bus_clk_rate);at91_init_twi_bus (dev);snprintf (dev->adapter.name,sizeof (dev->adapter.name),"AT91" );
Signature · 1 line
1.7.10.4
A message that is not in the archive (sent off-list or not yet received): 1393293045-31849-1-git-send-email-mark.roszko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Ludovic Desroches
Acked-byQuoted 5 lines · Marek Roszko
This adds the ability to set "clock-frequency" in the device tree for the i2c bus following the naming of other i2c bus implementations. If the property is not set, the clock frequency will default to the previously used define of 100KHz.
Signed-off-by Marek Roszko <[email protected]>
Thanks
Quoted 71 lines
---
v2:
-fixed return code usage and check to not compare agaisnt less than zero--- Documentation/devicetree/bindings/i2c/i2c-at91.txt | 2 ++ drivers/i2c/busses/i2c-at91.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/i2c/i2c-at91.txt +2
-0@@ -12,6 +12,7 @@ Required properties : - clocks: phandles to input clocks. Optional properties: +- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 100000 - Child nodes conforming to i2c bus binding Examples :@@ -23,6 +24,7 @@ i2c0: i2c@fff84000 { #address-cells = <1>; #size-cells = <0>; clocks = <&twi0_clk>; + clock-frequency = <400000>; 24c512@50 { compatible = "24c512";drivers/i2c/busses/i2c-at91.c +8
-2@@ -32,7 +32,7 @@#include <linux/slab.h> #include <linux/platform_data/dma-atmel.h> -#define TWI_CLK_HZ 100000/* max 400 Kbits/s */ +#define DEFAULT_TWI_CLK_HZ 100000/* max 400 Kbits/s */ #define AT91_I2C_TIMEOUT msecs_to_jiffies(100)/* transfer timeout */ #define AT91_I2C_DMA_THRESHOLD 8/* enable DMA if transfer size is bigger than this threshold */ @@ -711,6 +711,7 @@ static int at91_twi_probe(struct platform_device *pdev)struct resource *mem;int rc;u32 phy_addr; +int bus_clk_rate; dev =devm_kzalloc (&pdev->dev,sizeof (*dev),GFP_KERNEL );if (!dev)@@ -756,7 +757,12 @@ static int at91_twi_probe(struct platform_device *pdev) dev->use_dma = true; } -at91_calc_twi_clock (dev,TWI_CLK_HZ ); + rc =of_property_read_u32 (dev->dev->of_node,"clock-frequency" , + &bus_clk_rate); +if (rc) + bus_clk_rate =DEFAULT_TWI_CLK_HZ ; + +at91_calc_twi_clock (dev, bus_clk_rate);at91_init_twi_bus (dev);snprintf (dev->adapter.name,sizeof (dev->adapter.name),"AT91" );Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 i2c:at91: Add device tree property to set clock-frequency
CCing the subsystem maintainer because I left him out on the initial send.
Quoted 82 lines · Ludovic Desroches
Quoted 5 lines · Marek Roszko
This adds the ability to set "clock-frequency" in the device tree for the i2c bus following the naming of other i2c bus implementations. If the property is not set, the clock frequency will default to the previously used define of 100KHz.
Signed-off-by Marek Roszko <[email protected]>Thanks
Quoted 71 lines
---
v2:
-fixed return code usage and check to not compare agaisnt less than zero--- Documentation/devicetree/bindings/i2c/i2c-at91.txt | 2 ++ drivers/i2c/busses/i2c-at91.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/i2c/i2c-at91.txt +2
-0@@ -12,6 +12,7 @@ Required properties : - clocks: phandles to input clocks. Optional properties: +- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 100000 - Child nodes conforming to i2c bus binding Examples :@@ -23,6 +24,7 @@ i2c0: i2c at fff84000 { #address-cells = <1>; #size-cells = <0>; clocks = <&twi0_clk>; + clock-frequency = <400000>; 24c512 at 50 { compatible = "24c512";drivers/i2c/busses/i2c-at91.c +8
-3@@ -32,7 +32,7 @@#include <linux/slab.h> #include <linux/platform_data/dma-atmel.h> -#define TWI_CLK_HZ 100000/* max 400 Kbits/s */ +#define DEFAULT_TWI_CLK_HZ 100000/* max 400 Kbits/s */ #define AT91_I2C_TIMEOUT msecs_to_jiffies(100)/* transfer timeout */ #define AT91_I2C_DMA_THRESHOLD 8/* enable DMA if transfer size is bigger than this threshold */ @@ -711,6 +711,7 @@ static int at91_twi_probe(struct platform_device *pdev)struct resource *mem;int rc;u32 phy_addr; +int bus_clk_rate; dev =devm_kzalloc (&pdev->dev,sizeof (*dev),GFP_KERNEL );if (!dev)@@ -756,7 +757,12 @@ static int at91_twi_probe(struct platform_device *pdev) dev->use_dma = true; } -at91_calc_twi_clock (dev,TWI_CLK_HZ ); + rc =of_property_read_u32 (dev->dev->of_node,"clock-frequency" , + &bus_clk_rate); +if (rc) + bus_clk_rate =DEFAULT_TWI_CLK_HZ ; + +at91_calc_twi_clock (dev, bus_clk_rate);at91_init_twi_bus (dev);snprintf (dev->adapter.name,sizeof (dev->adapter.name),"AT91" ); --1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Mark
PATCH v2 1/1 i2c:at91: Add device tree property to set clock-frequency
I never like that
the clock-frequency = <400000>; need to be set on each i2c device and then the i2c subsystem need to choose the slowest
Best Regards,
J.
Quoted 96 lines · Mark Roszko
CCing the subsystem maintainer because I left him out on the initial send.
Quoted 82 lines · Ludovic Desroches
Quoted 5 lines · Marek Roszko
This adds the ability to set "clock-frequency" in the device tree for the i2c bus following the naming of other i2c bus implementations. If the property is not set, the clock frequency will default to the previously used define of 100KHz.
Signed-off-by Marek Roszko <[email protected]>Thanks
Quoted 71 lines
---
v2:
-fixed return code usage and check to not compare agaisnt less than zero---
Documentation/devicetree/bindings/i2c/i2c-at91.txt| 2 ++drivers/i2c/busses/i2c-at91.c| 10 ++++++++--2 files changed, 10 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/i2c/i2c-at91.txt +0
-1@@ -12,6 +12,7 @@ Required properties : - clocks: phandles to input clocks.Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 100000
- Child nodes conforming to i2c bus bindingExamples :
Documentation/devicetree/bindings/i2c/i2c-at91.txt +1
-0@@ -23,6 +24,7 @@ i2c0: i2c at fff84000 { #address-cells = <1>; #size-cells = <0>; clocks = <&twi0_clk>; + clock-frequency = <400000>; 24c512 at 50 { compatible = "24c512";drivers/i2c/busses/i2c-at91.c +8
-3@@ -32,7 +32,7 @@#include <linux/slab.h> #include <linux/platform_data/dma-atmel.h> -#define TWI_CLK_HZ 100000/* max 400 Kbits/s */ +#define DEFAULT_TWI_CLK_HZ 100000/* max 400 Kbits/s */ #define AT91_I2C_TIMEOUT msecs_to_jiffies(100)/* transfer timeout */ #define AT91_I2C_DMA_THRESHOLD 8/* enable DMA if transfer size is bigger than this threshold */ @@ -711,6 +711,7 @@ static int at91_twi_probe(struct platform_device *pdev)struct resource *mem;int rc;u32 phy_addr; +int bus_clk_rate; dev =devm_kzalloc (&pdev->dev,sizeof (*dev),GFP_KERNEL );if (!dev)@@ -756,7 +757,12 @@ static int at91_twi_probe(struct platform_device *pdev) dev->use_dma = true; } -at91_calc_twi_clock (dev,TWI_CLK_HZ ); + rc =of_property_read_u32 (dev->dev->of_node,"clock-frequency" , + &bus_clk_rate); +if (rc) + bus_clk_rate =DEFAULT_TWI_CLK_HZ ; + +at91_calc_twi_clock (dev, bus_clk_rate);at91_init_twi_bus (dev);snprintf (dev->adapter.name,sizeof (dev->adapter.name),"AT91" ); --1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 6 lines
Mark _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/1 i2c:at91: Add device tree property to set clock-frequency
Unless I'm misunderstanding your reply, it doesn't need to be set on each i2c device. It's meant to be an option to override the currently hardcoded 100khz for all the at91 devices.
PATCH v2 1/1 i2c:at91: Add device tree property to set clock-frequency
Quoted 3 lines · Mark Roszko
Unless I'm misunderstanding your reply, it doesn't need to be set on each i2c device. It's meant to be an option to override the currently hardcoded 100khz for all the at91 devices.
yes you do need to set it on each device
as in the DT you describe the hw you set the speed of each device and then the bus based on the present device will use the appropriate one
Best Regards,
J.
Quoted 5 lines
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/1 i2c:at91: Add device tree property to set clock-frequency
Ah, you are talking about the individual slave devices within an device tree i2c bus like the i2c eeproms? Yea, it would be nicer if one could define it as such to deal with having slave devices that can't handle certain speeds such as I have. This patch does work though nicely for my needs with an SAMA5 with three i2c buses running at 50kHz, 100kHz and 400kHz separately.
Quoted 10 lines
drivers/i2c/busses/i2c-at91.c +1
-0@@ -711,6 +711,7 @@ static int at91_twi_probe(struct platform_device *pdev)struct resource *mem;int rc;u32 phy_addr; +int bus_clk_rate; dev =devm_kzalloc (&pdev->dev,sizeof (*dev),GFP_KERNEL );if (!dev)
drivers/i2c/busses/i2c-at91.c static int at91_twi_probe(struct platform_device *pdev) · line 761
Quoted 6 lines
drivers/i2c/busses/i2c-at91.c +2
-1@@ -756,7 +757,12 @@ static int at91_twi_probe(struct platform_device *pdev) dev->use_dma = true; } -at91_calc_twi_clock (dev,TWI_CLK_HZ ); + rc =of_property_read_u32 (dev->dev->of_node,"clock-frequency" , + &bus_clk_rate);
The function is named read_u32, so the variable used should be u32.