diff options
author | Robert Rosengren <robert.rosengren@stericsson.com> | 2010-11-01 14:52:09 +0100 |
---|---|---|
committer | Michael BRANDT <michael.brandt@stericsson.com> | 2010-11-12 09:32:34 +0100 |
commit | b5324791d9bf1658b76d15f0287b0d827269e332 (patch) | |
tree | 3c3827b78f4a0e1ca337510ab995b56210b558f2 /board/st/u8500/u8500_i2c.c | |
parent | e0269f4ccade16581df37ca6f486131d9f8228fd (diff) |
U8500: Enabled support for i2c1-3
Moved enabling of clocks into i2c driver, making it possible to use all i2c
from 0 to 3.
Changed sanity check of i2c_read function to make it possible read from
devices with 2 byte address.
ST-Ericsson ID: CR275232
Change-Id: I6c9c2efe20dcb6903419ba531a86228a5f4491ca
Signed-off-by: Robert Rosengren <robert.rosengren@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/8340
Reviewed-by: Markus HELGESSON <markus.helgesson@stericsson.com>
Reviewed-by: Michael BRANDT <michael.brandt@stericsson.com>
Diffstat (limited to 'board/st/u8500/u8500_i2c.c')
-rw-r--r-- | board/st/u8500/u8500_i2c.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/board/st/u8500/u8500_i2c.c b/board/st/u8500/u8500_i2c.c index e41f7ef51..5b88b263f 100644 --- a/board/st/u8500/u8500_i2c.c +++ b/board/st/u8500/u8500_i2c.c @@ -18,6 +18,7 @@ #include "i2c.h" #include "gpio.h" #include <asm/io.h> +#include <asm/arch/clock.h> typedef enum { I2C_NACK_ADDR, @@ -60,6 +61,17 @@ static struct { {GPIO_ALT_I2C_3, "i2c3"}, }; +static struct { + int periph; + int pcken; + int kcken; +} i2c_clock_bits[] = { + {3, 3, 3}, /* I2C0 */ + {1, 2, 2}, /* I2C1 */ + {1, 6, 6}, /* I2C2 */ + {2, 0, 0}, /* I2C3 */ +}; + static int __i2c_set_bus_speed(unsigned int speed) { u32 value; @@ -103,6 +115,10 @@ void i2c_init(int speed, int slaveaddr) (void) gpio_altfuncenable(i2c_gpio_altfunc[i2c_bus_num].altfunc, i2c_gpio_altfunc[i2c_bus_num].dev_name); + u8500_clock_enable(i2c_clock_bits[i2c_bus_num].periph, + i2c_clock_bits[i2c_bus_num].pcken, + i2c_clock_bits[i2c_bus_num].kcken); + p_i2c_registers = i2c_dev[i2c_bus_num]; /* Disable the controller */ @@ -525,7 +541,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) int rc; t_i2c_registers *p_i2c_registers; - if (alen > 1) { + if (alen > 2) { debug("I2C read: addr len %d not supported\n", alen); return 1; } @@ -564,6 +580,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) int i2c_set_bus_num(unsigned int bus) { if (bus > ARRAY_SIZE(i2c_dev) - 1) { + debug("i2c_set_bus_num: only up to bus %d supported\n", ARRAY_SIZE(i2c_dev)-1); return -1; } |