All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
@ 2014-02-25  1:50 Marek Roszko
       [not found] ` <1393293045-31849-1-git-send-email-mark.roszko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Roszko @ 2014-02-25  1:50 UTC (permalink / raw)
  To: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, 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 <mark.roszko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
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(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
index 4fade84..388f0a2 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
@@ -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";
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 843d012..a407050 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -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

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

* Re: [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
       [not found] ` <1393293045-31849-1-git-send-email-mark.roszko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2014-02-28 11:05   ` Ludovic Desroches
  2014-03-06 13:48       ` Mark Roszko
  2014-03-10 16:29   ` Wolfram Sang
  1 sibling, 1 reply; 13+ messages in thread
From: Ludovic Desroches @ 2014-02-28 11:05 UTC (permalink / raw)
  To: Marek Roszko; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA

On Mon, Feb 24, 2014 at 08:50:45PM -0500, Marek Roszko wrote:
> 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 <mark.roszko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

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

Thanks

> ---
> 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(-)
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> index 4fade84..388f0a2 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
> @@ -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";
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 843d012..a407050 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
  2014-02-28 11:05   ` Ludovic Desroches
@ 2014-03-06 13:48       ` Mark Roszko
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Roszko @ 2014-03-06 13:48 UTC (permalink / raw)
  To: Marek Roszko, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	wsa-z923LK4zBo2bacvFa/9K2g
  Cc: Ludovic Desroches

CCing the subsystem maintainer because I left him out on the initial send.

On Fri, Feb 28, 2014 at 6:05 AM, Ludovic Desroches
<ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org> wrote:
> On Mon, Feb 24, 2014 at 08:50:45PM -0500, Marek Roszko wrote:
>> 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 <mark.roszko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> Acked-by: Ludovic Desroches <ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
>
> Thanks
>
>> ---
>> 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(-)
>>
>> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>> index 4fade84..388f0a2 100644
>> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>> @@ -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";
>> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
>> index 843d012..a407050 100644
>> --- a/drivers/i2c/busses/i2c-at91.c
>> +++ b/drivers/i2c/busses/i2c-at91.c
>> @@ -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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Mark

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

* [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
@ 2014-03-06 13:48       ` Mark Roszko
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Roszko @ 2014-03-06 13:48 UTC (permalink / raw)
  To: linux-arm-kernel

CCing the subsystem maintainer because I left him out on the initial send.

On Fri, Feb 28, 2014 at 6:05 AM, Ludovic Desroches
<ludovic.desroches@atmel.com> wrote:
> On Mon, Feb 24, 2014 at 08:50:45PM -0500, Marek Roszko wrote:
>> 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 <mark.roszko@gmail.com>
>
> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
>
> Thanks
>
>> ---
>> 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(-)
>>
>> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>> index 4fade84..388f0a2 100644
>> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>> @@ -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";
>> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
>> index 843d012..a407050 100644
>> --- a/drivers/i2c/busses/i2c-at91.c
>> +++ b/drivers/i2c/busses/i2c-at91.c
>> @@ -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



-- 
Mark

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

* Re: [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
  2014-03-06 13:48       ` Mark Roszko
@ 2014-03-07  3:51         ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2014-03-07  3:51 UTC (permalink / raw)
  To: Mark Roszko
  Cc: Ludovic Desroches, Jean-Christophe PLAGNIOL-VILLARD, linux-i2c,
	<linux-arm-kernel@lists.infradead.org> mailing list, wsa

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.
On Mar 6, 2014, at 9:48 PM, Mark Roszko <mark.roszko@gmail.com> wrote:

> CCing the subsystem maintainer because I left him out on the initial send.
> 
> On Fri, Feb 28, 2014 at 6:05 AM, Ludovic Desroches
> <ludovic.desroches@atmel.com> wrote:
>> On Mon, Feb 24, 2014 at 08:50:45PM -0500, Marek Roszko wrote:
>>> 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 <mark.roszko@gmail.com>
>> 
>> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
>> 
>> Thanks
>> 
>>> ---
>>> 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(-)
>>> 
>>> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>>> index 4fade84..388f0a2 100644
>>> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>>> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>>> @@ -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";
>>> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
>>> index 843d012..a407050 100644
>>> --- a/drivers/i2c/busses/i2c-at91.c
>>> +++ b/drivers/i2c/busses/i2c-at91.c
>>> @@ -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@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 
> -- 
> Mark
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
@ 2014-03-07  3:51         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2014-03-07  3:51 UTC (permalink / raw)
  To: linux-arm-kernel

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.
On Mar 6, 2014, at 9:48 PM, Mark Roszko <mark.roszko@gmail.com> wrote:

> CCing the subsystem maintainer because I left him out on the initial send.
> 
> On Fri, Feb 28, 2014 at 6:05 AM, Ludovic Desroches
> <ludovic.desroches@atmel.com> wrote:
>> On Mon, Feb 24, 2014 at 08:50:45PM -0500, Marek Roszko wrote:
>>> 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 <mark.roszko@gmail.com>
>> 
>> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
>> 
>> Thanks
>> 
>>> ---
>>> 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(-)
>>> 
>>> diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>>> index 4fade84..388f0a2 100644
>>> --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>>> +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
>>> @@ -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";
>>> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
>>> index 843d012..a407050 100644
>>> --- a/drivers/i2c/busses/i2c-at91.c
>>> +++ b/drivers/i2c/busses/i2c-at91.c
>>> @@ -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
> 
> 
> 
> -- 
> Mark
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
  2014-03-07  3:51         ` Jean-Christophe PLAGNIOL-VILLARD
@ 2014-03-07  4:26             ` Mark Roszko
  -1 siblings, 0 replies; 13+ messages in thread
From: Mark Roszko @ 2014-03-07  4:26 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
	mailing list, wsa-z923LK4zBo2bacvFa/9K2g, Ludovic Desroches

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.

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

* [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
@ 2014-03-07  4:26             ` Mark Roszko
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Roszko @ 2014-03-07  4:26 UTC (permalink / raw)
  To: linux-arm-kernel

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.

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

* Re: [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
  2014-03-07  4:26             ` Mark Roszko
@ 2014-03-07  5:08               ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2014-03-07  5:08 UTC (permalink / raw)
  To: Mark Roszko
  Cc: Ludovic Desroches, Jean-Christophe PLAGNIOL-VILLARD, linux-i2c,
	<linux-arm-kernel@lists.infradead.org> mailing list, wsa


On Mar 7, 2014, at 12:26 PM, Mark Roszko <mark.roszko@gmail.com> wrote:

> 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.
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
@ 2014-03-07  5:08               ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2014-03-07  5:08 UTC (permalink / raw)
  To: linux-arm-kernel


On Mar 7, 2014, at 12:26 PM, Mark Roszko <mark.roszko@gmail.com> wrote:

> 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.
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
  2014-03-07  5:08               ` Jean-Christophe PLAGNIOL-VILLARD
@ 2014-03-07  5:30                   ` Mark Roszko
  -1 siblings, 0 replies; 13+ messages in thread
From: Mark Roszko @ 2014-03-07  5:30 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Ludovic Desroches, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
	mailing list, wsa-z923LK4zBo2bacvFa/9K2g

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.

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

* [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
@ 2014-03-07  5:30                   ` Mark Roszko
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Roszko @ 2014-03-07  5:30 UTC (permalink / raw)
  To: linux-arm-kernel

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.

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

* Re: [PATCH v2] i2c:at91: Add device tree property to set clock-frequency
       [not found] ` <1393293045-31849-1-git-send-email-mark.roszko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2014-02-28 11:05   ` Ludovic Desroches
@ 2014-03-10 16:29   ` Wolfram Sang
  1 sibling, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2014-03-10 16:29 UTC (permalink / raw)
  To: Marek Roszko
  Cc: ludovic.desroches-AIFe0yeh4nAAvxtiuMwx3w,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 574 bytes --]


> @@ -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);

The function is named read_u32, so the variable used should be u32.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2014-03-10 16:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-25  1:50 [PATCH v2] i2c:at91: Add device tree property to set clock-frequency Marek Roszko
     [not found] ` <1393293045-31849-1-git-send-email-mark.roszko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-02-28 11:05   ` Ludovic Desroches
2014-03-06 13:48     ` Mark Roszko
2014-03-06 13:48       ` Mark Roszko
2014-03-07  3:51       ` Jean-Christophe PLAGNIOL-VILLARD
2014-03-07  3:51         ` Jean-Christophe PLAGNIOL-VILLARD
     [not found]         ` <4A1E236E-E048-4E37-AFE8-C0AC283B73D0-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2014-03-07  4:26           ` Mark Roszko
2014-03-07  4:26             ` Mark Roszko
2014-03-07  5:08             ` Jean-Christophe PLAGNIOL-VILLARD
2014-03-07  5:08               ` Jean-Christophe PLAGNIOL-VILLARD
     [not found]               ` <05EF9B59-7009-49D2-B57F-5612C39F1FF0-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2014-03-07  5:30                 ` Mark Roszko
2014-03-07  5:30                   ` Mark Roszko
2014-03-10 16:29   ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.