[U-Boot] [PATCH v2 14/40] i2c: tegra: Implement i2c_get_bus_num_fdt()
Thierry Reding
thierry.reding at gmail.com
Tue Aug 26 17:34:02 CEST 2014
From: Thierry Reding <treding at nvidia.com>
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 at nvidia.com>
---
drivers/i2c/tegra_i2c.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 257b72f0f7cd..94453765369d 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
*/
--
2.0.4
More information about the U-Boot
mailing list