summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-08-26 17:34:02 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2014-10-11 01:08:58 +0200
commitf112c1c557f908844ffcf2da8de867c2a8a96b9d (patch)
tree05169734122088cf3684441433989e8ff6661c6a
parent8f8a5a20b7475551bbd7d732e50ac3c9017dfb38 (diff)
i2c: tegra: Implement i2c_get_bus_num_fdt()
This is useful to retrieve the U-Boot bus number of an I2C controller given a device tree node. Signed-off-by: Thierry Reding <treding@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/i2c/tegra_i2c.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 257b72f0f7c..94453765369 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -21,6 +21,7 @@ DECLARE_GLOBAL_DATA_PTR;
/* Information about i2c controller */
struct i2c_bus {
+ int node;
int id;
enum periph_id periph_id;
int speed;
@@ -400,6 +401,7 @@ static int process_nodes(const void *blob, int node_list[], int count,
continue;
i2c_bus = &i2c_controllers[i];
+ i2c_bus->node = node;
i2c_bus->id = i;
if (i2c_get_config(blob, node, i2c_bus)) {
@@ -624,6 +626,17 @@ int tegra_i2c_get_dvc_bus_num(void)
return -1;
}
+int i2c_get_bus_num_fdt(int node)
+{
+ unsigned int i;
+
+ for (i = 0; i < TEGRA_I2C_NUM_CONTROLLERS; i++)
+ if (node == i2c_controllers[i].node)
+ return i;
+
+ return -1;
+}
+
/*
* Register soft i2c adapters
*/