diff options
author | Joel Stanley <joel@jms.id.au> | 2017-11-23 14:22:16 +1030 |
---|---|---|
committer | Alistair Popple <alistair@popple.id.au> | 2017-11-24 11:33:12 +1100 |
commit | 5373c4bee9eeb1c8fb91266e3fed581ace397666 (patch) | |
tree | c448edfa3466674db55befd7f9eca3d983fbfce5 | |
parent | f97b554064f4c7c37edf4dd6eae1ddf56df746da (diff) | |
download | pdbg-5373c4bee9eeb1c8fb91266e3fed581ace397666.tar.gz pdbg-5373c4bee9eeb1c8fb91266e3fed581ace397666.zip |
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 <joel@jms.id.au>
Signed-off-by: Alistair Popple <alistair@popple.id.au>
-rw-r--r-- | src/main.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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")) |