Commit 75b6c4b6 authored by Marek Roszko's avatar Marek Roszko Committed by Wolfram Sang

i2c: at91: Add device tree property to set clock-frequency

This adds the ability to set "clock-frequency" in the device tree for the at91
i2cbus 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: default avatarMarek Roszko <mark.roszko@gmail.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 6808b002
...@@ -12,6 +12,7 @@ Required properties : ...@@ -12,6 +12,7 @@ Required properties :
- clocks: phandles to input clocks. - clocks: phandles to input clocks.
Optional properties: Optional properties:
- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 100000
- Child nodes conforming to i2c bus binding - Child nodes conforming to i2c bus binding
Examples : Examples :
...@@ -23,6 +24,7 @@ i2c0: i2c@fff84000 { ...@@ -23,6 +24,7 @@ i2c0: i2c@fff84000 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
clocks = <&twi0_clk>; clocks = <&twi0_clk>;
clock-frequency = <400000>;
24c512@50 { 24c512@50 {
compatible = "24c512"; compatible = "24c512";
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/platform_data/dma-atmel.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_TIMEOUT msecs_to_jiffies(100) /* transfer timeout */
#define AT91_I2C_DMA_THRESHOLD 8 /* enable DMA if transfer size is bigger than this threshold */ #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) ...@@ -711,6 +711,7 @@ static int at91_twi_probe(struct platform_device *pdev)
struct resource *mem; struct resource *mem;
int rc; int rc;
u32 phy_addr; u32 phy_addr;
u32 bus_clk_rate;
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev) if (!dev)
...@@ -756,7 +757,12 @@ static int at91_twi_probe(struct platform_device *pdev) ...@@ -756,7 +757,12 @@ static int at91_twi_probe(struct platform_device *pdev)
dev->use_dma = true; 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); at91_init_twi_bus(dev);
snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91"); snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment