
Hello Simon,
Simon Glass wrote:
This is just a rough patch to show how this might be done.
Not to be applied, please.
Signed-off-by: Simon Glass sjg@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)
static
{ 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)
static, add this for all functions
[...]
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
This define is no longer valid if using the new framework. Do you have really 4 busses with only one i2c adapter?
This works only, if you have i2c muxes! In this case you have to define
/* * how many muxes are maximal consecutively connected on * one i2c bus */ #define CONFIG_SYS_I2C_MAX_HOPS 1
and for example using a PCA9547 mux:
#define CONFIG_SYS_I2C_BUSSES { {0, {I2C_NULL_HOP}}, \ {0, {{I2C_MUX_PCA9547, 0x70, 1}}}, \ {0, {{I2C_MUX_PCA9547, 0x70, 2}}}, \ {0, {{I2C_MUX_PCA9547, 0x70, 3}}}, }
or you use other i2c adapters like soft_i2c, but I could not see this in your patch ... and in this case you must define CONFIG_SYS_NUM_I2C_ADAPTERS ...
#define CONFIG_SYS_I2C_SPEED 100000
should not longer be defined, instead you should make a option to define a i2c speed for your i2c driver ... for example #define CONFIG_SYS_I2C_TEGRA2_SPEED 100000
#define CONFIG_CMD_I2C +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_ADAPTERS {&tegra_i2c_adap}
You must have a define in drivers/i2c/Makefile which "activates" your drivers/i2c/tegra2_i2c.c ... this must defined in your board config file too (maybe a CONFIG_SYS_I2C_TEGRA2 ?)!
Also you must have a change in drivers/i2c/i2c_core.c
#ifdef CONFIG_SYS_I2C_TEGRA2 extern struct i2c_adap tegra_i2c_adap[]; #endif
or?
bye, Heiko