summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-08-26 17:33:59 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2014-10-11 01:08:16 +0200
commit2ca50f89b3b7de836d5491c16beb4e4e7f77fa60 (patch)
tree45ff59bf3f153a86f69078894067b06783e60210
parentea3202b23728c2191b25c74096a13c562977c30d (diff)
i2c: Initialize the correct bus
i2c_bus_init() takes a bus number but relies on the currently selected bus to determine which adapter to initialize. Make the function use the bus passed in as parameter rather than the currently selected bus. While at it, keep a pointer to the specified bus to avoid having to look it up repeatedly. Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/i2c/i2c_core.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
index 18d6736601..cca455bc9c 100644
--- a/drivers/i2c/i2c_core.c
+++ b/drivers/i2c/i2c_core.c
@@ -214,17 +214,20 @@ static int i2c_mux_disconnet_all(void)
* Initializes one bus. Will initialize the parent adapter. No current bus
* changes, no mux (if any) setup.
*/
-static void i2c_init_bus(unsigned int bus_no, int speed, int slaveaddr)
+static void i2c_init_bus(unsigned int bus, int speed, int slaveaddr)
{
- if (bus_no >= CONFIG_SYS_NUM_I2C_BUSES)
+ struct i2c_adapter *adapter;
+
+ if (bus >= CONFIG_SYS_NUM_I2C_BUSES)
return;
- I2C_ADAP->init(I2C_ADAP, speed, slaveaddr);
+ adapter = i2c_get_adapter(I2C_ADAPTER(bus));
+ adapter->init(adapter, speed, slaveaddr);
if (gd->flags & GD_FLG_RELOC) {
- I2C_ADAP->init_done = 1;
- I2C_ADAP->speed = speed;
- I2C_ADAP->slaveaddr = slaveaddr;
+ adapter->init_done = 1;
+ adapter->speed = speed;
+ adapter->slaveaddr = slaveaddr;
}
}