aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorMarek Roszko <mark.roszko@gmail.com>2014-03-11 00:25:38 -0400
committerWolfram Sang <wsa@the-dreams.de>2014-03-12 03:26:04 -0400
commit75b6c4b68f0b4cb94b1780f1863766a589aebc95 (patch)
tree34757b34ef8c9e222a66424127a9c287690b3754 /drivers/i2c
parent6808b002520de85aaa77237f4a9d33376fa393e9 (diff)
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: Marek Roszko <mark.roszko@gmail.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-at91.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 56baf48fb996..e95f9ba96790 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -32,7 +32,7 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/platform_data/dma-atmel.h> 33#include <linux/platform_data/dma-atmel.h>
34 34
35#define TWI_CLK_HZ 100000 /* max 400 Kbits/s */ 35#define DEFAULT_TWI_CLK_HZ 100000 /* max 400 Kbits/s */
36#define AT91_I2C_TIMEOUT msecs_to_jiffies(100) /* transfer timeout */ 36#define AT91_I2C_TIMEOUT msecs_to_jiffies(100) /* transfer timeout */
37#define AT91_I2C_DMA_THRESHOLD 8 /* enable DMA if transfer size is bigger than this threshold */ 37#define AT91_I2C_DMA_THRESHOLD 8 /* enable DMA if transfer size is bigger than this threshold */
38 38
@@ -711,6 +711,7 @@ static int at91_twi_probe(struct platform_device *pdev)
711 struct resource *mem; 711 struct resource *mem;
712 int rc; 712 int rc;
713 u32 phy_addr; 713 u32 phy_addr;
714 u32 bus_clk_rate;
714 715
715 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); 716 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
716 if (!dev) 717 if (!dev)
@@ -756,7 +757,12 @@ static int at91_twi_probe(struct platform_device *pdev)
756 dev->use_dma = true; 757 dev->use_dma = true;
757 } 758 }
758 759
759 at91_calc_twi_clock(dev, TWI_CLK_HZ); 760 rc = of_property_read_u32(dev->dev->of_node, "clock-frequency",
761 &bus_clk_rate);
762 if (rc)
763 bus_clk_rate = DEFAULT_TWI_CLK_HZ;
764
765 at91_calc_twi_clock(dev, bus_clk_rate);
760 at91_init_twi_bus(dev); 766 at91_init_twi_bus(dev);
761 767
762 snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91"); 768 snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91");