From 69575cce025f4fd12957b33fe8eed59c4ad7f5f2 Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 11 Mar 2021 08:55:59 +0000 Subject: [PATCH] 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@ --- sys/dev/fdt/rkiic.c | 9 +++++++-- 1 file 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 * @@ -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; -- 2.20.1