From 5373c4bee9eeb1c8fb91266e3fed581ace397666 Mon Sep 17 00:00:00 2001 From: Joel Stanley Date: Thu, 23 Nov 2017 14:22:16 +1030 Subject: i2c: Update i2c device node in dt when specified When the user specifies a device node on the command line, use that value to update the entry in the pib node. Signed-off-by: Joel Stanley Signed-off-by: Alistair Popple --- src/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 66097ab..07df78b 100644 --- a/src/main.c +++ b/src/main.c @@ -321,7 +321,6 @@ static bool parse_options(int argc, char *argv[]) device_node = "p9w"; } else if (strcmp(optarg, "i2c") == 0) { backend = I2C; - device_node = "/dev/i2c4"; } else if (strcmp(optarg, "kernel") == 0) { backend = KERNEL; /* TODO: use device node to point at a slave @@ -917,8 +916,19 @@ static int target_select(void) * to walk the tree and disabled nodes we don't care about * prior to probing. */ for_each_class_target("pib", pib) { + struct dt_property *p; int proc_index = pib->index; + if (backend == I2C && device_node) { + if ((p = dt_find_property(pib->dn, "bus"))) { + if (strlen(device_node) > p->len) + dt_resize_property(&p, strlen(device_node) + 1); + strcpy(p->prop, device_node); + } else { + dt_add_property(pib->dn, "bus", device_node, strlen(device_node) + 1); + } + } + if (processorsel[proc_index]) { enable_dn(pib->dn); if (!find_target_class("chiplet")) -- cgit v1.2.1