This is just a rough patch to show how this might be done. Not to be applied, please.
Signed-off-by: Simon Glass <s...@chromium.org> --- drivers/i2c/tegra2_i2c.c | 53 +++++++++++++++++++------------------------ include/configs/seaboard.h | 2 + 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/drivers/i2c/tegra2_i2c.c b/drivers/i2c/tegra2_i2c.c index b42d9ac..93f3269 100644 --- a/drivers/i2c/tegra2_i2c.c +++ b/drivers/i2c/tegra2_i2c.c @@ -30,7 +30,9 @@ #include <asm/arch/gpio.h> #include <asm/arch/pinmux.h> #include <asm/arch/tegra2_i2c.h> + #include <fdtdec.h> +#include <i2c.h> DECLARE_GLOBAL_DATA_PTR; @@ -296,12 +298,7 @@ static int tegra2_i2c_read_data(u32 addr, u8 *data, u32 len) #error "Please enable device tree support to use this driver" #endif -unsigned int i2c_get_bus_speed(void) -{ - return i2c_controllers[i2c_bus_num].speed; -} - -int i2c_set_bus_speed(unsigned int speed) +uint tegra_i2c_set_bus_speed(unsigned int speed) { struct i2c_bus *i2c_bus; @@ -309,7 +306,7 @@ int i2c_set_bus_speed(unsigned int speed) i2c_bus->speed = speed; i2c_init_controller(i2c_bus); - return 0; + return 0; /* TODO: return actual speed */ } static int i2c_get_config(const void *blob, int node, struct i2c_bus *i2c_bus) @@ -404,7 +401,7 @@ int i2c_init_board(void) return 0; } -void i2c_init(int speed, int slaveaddr) +void tegra_i2c_init(int speed, int slaveaddr) { debug("i2c_init(speed=%u, slaveaddr=0x%x)\n", speed, slaveaddr); } @@ -450,7 +447,7 @@ int i2c_read_data(uchar chip, uchar *buffer, int len) } /* Probe to see if a chip is present. */ -int i2c_probe(uchar chip) +int tegra_i2c_probe(uchar chip) { int rc; uchar reg; @@ -472,7 +469,7 @@ static int i2c_addr_ok(const uint addr, const int alen) } /* Read bytes */ -int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) +int tegra_i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) { uint offset; int i; @@ -506,7 +503,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) } /* Write bytes */ -int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) +int tegra_i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) { uint offset; int i; @@ -531,25 +528,6 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) return 0; } -#if defined(CONFIG_I2C_MULTI_BUS) -/* - * Functions for multiple I2C bus handling - */ -unsigned int i2c_get_bus_num(void) -{ - return i2c_bus_num; -} - -int i2c_set_bus_num(unsigned int bus) -{ - if (bus >= CONFIG_SYS_MAX_I2C_BUS || !i2c_controllers[bus].inited) - return -1; - i2c_bus_num = bus; - - return 0; -} -#endif - int tegra_i2c_get_dvc_bus_num(void) { int i; @@ -563,3 +541,18 @@ int tegra_i2c_get_dvc_bus_num(void) return -1; } + +struct i2c_adapter tegra_i2c_adap[] = { + { + .init = tegra_i2c_init, + .probe = tegra_i2c_probe, + .read = tegra_i2c_read, + .write = tegra_i2c_write, + .set_bus_speed = tegra_i2c_set_bus_speed, + .speed = 100000, + .slaveaddr = 0, + .name = "tegra-i2c", + .init_done = 0, + .hwadapnr = 0, + } +}; diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h index d2d0115..64c804a 100644 --- a/include/configs/seaboard.h +++ b/include/configs/seaboard.h @@ -79,6 +79,8 @@ #define CONFIG_SYS_MAX_I2C_BUS 4 #define CONFIG_SYS_I2C_SPEED 100000 #define CONFIG_CMD_I2C +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_ADAPTERS {&tegra_i2c_adap} /* SD/MMC */ #define CONFIG_MMC -- 1.7.7.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot