From b5324791d9bf1658b76d15f0287b0d827269e332 Mon Sep 17 00:00:00 2001 From: Robert Rosengren Date: Mon, 1 Nov 2010 14:52:09 +0100 Subject: 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 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/8340 Reviewed-by: Markus HELGESSON Reviewed-by: Michael BRANDT --- board/st/u8500/u8500.c | 3 --- board/st/u8500/u8500_i2c.c | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'board') 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 +#include 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; } -- cgit v1.2.3