diff options
-rw-r--r-- | board/st/u8500/u8500.c | 3 | ||||
-rw-r--r-- | board/st/u8500/u8500_i2c.c | 19 |
2 files changed, 18 insertions, 4 deletions
diff --git a/board/st/u8500/u8500.c b/board/st/u8500/u8500.c index 37f81211d..41325124d 100644 --- a/board/st/u8500/u8500.c +++ b/board/st/u8500/u8500.c @@ -586,9 +586,6 @@ static void init_regs(void) u8500_clock_enable(3, 6, 6); /* UART2 */ - gpio_altfuncenable(GPIO_ALT_I2C_0, "I2C0"); - u8500_clock_enable(3, 3, 3); /* I2C0 */ - { /* UART2: 29, 30 */ struct gpio_register *p_gpio_register = (void *) IO_ADDRESS(CFG_GPIO_0_BASE); 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; } |