summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2017-11-23 14:22:16 +1030
committerAlistair Popple <alistair@popple.id.au>2017-11-24 11:33:12 +1100
commit5373c4bee9eeb1c8fb91266e3fed581ace397666 (patch)
treec448edfa3466674db55befd7f9eca3d983fbfce5
parentf97b554064f4c7c37edf4dd6eae1ddf56df746da (diff)
downloadpdbg-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.c12
1 files changed, 11 insertions, 1 deletions
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"))
OpenPOWER on IntegriCloud