diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2021-03-11 08:56:00 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2021-03-11 08:56:00 +0000 |
commit | 2dd1f9a09c267d8453bf98a603b8094c22295fe3 (patch) | |
tree | 479d00bd1a94c5c906d53d244d9c7ce60f09fd5d /sys | |
parent | 06fac23f9bf9a2981c311d8446e3f471fffaf997 (diff) |
Make sure to skip attaching disabled I2C devices. This can happen on
hardware which include a common parent block in their device trees and
only enable the components that were actually implemented, as seen on
e.g. the NanoPi R4S.
ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/fdt/rkiic.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/dev/fdt/rkiic.c b/sys/dev/fdt/rkiic.c index 7655f52b693..ef4557090f5 100644 --- a/sys/dev/fdt/rkiic.c +++ b/sys/dev/fdt/rkiic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rkiic.c,v 1.5 2020/03/01 10:18:19 kettenis Exp $ */ +/* $OpenBSD: rkiic.c,v 1.6 2021/03/11 08:55:59 patrick Exp $ */ /* * Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org> * @@ -376,12 +376,13 @@ rkiic_bus_scan(struct device *self, struct i2cbus_attach_args *iba, void *arg) { int iba_node = *(int *)arg; struct i2c_attach_args ia; - char name[32]; + char name[32], status[32]; uint32_t reg[1]; int node; for (node = OF_child(iba_node); node; node = OF_peer(node)) { memset(name, 0, sizeof(name)); + memset(status, 0, sizeof(status)); memset(reg, 0, sizeof(reg)); if (OF_getprop(node, "compatible", name, sizeof(name)) == -1) @@ -389,6 +390,10 @@ rkiic_bus_scan(struct device *self, struct i2cbus_attach_args *iba, void *arg) if (name[0] == '\0') continue; + if (OF_getprop(node, "status", status, sizeof(status)) > 0 && + strcmp(status, "disabled") == 0) + continue; + if (OF_getprop(node, "reg", ®, sizeof(reg)) != sizeof(reg)) continue; |