Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/thorpej-i2c-spi-conf]: src/sys/dev/ofw Do that again, but slightly diffe...



details:   https://anonhg.NetBSD.org/src/rev/53c3f545c837
branches:  thorpej-i2c-spi-conf
changeset: 1020805:53c3f545c837
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri May 14 03:05:52 2021 +0000

description:
Do that again, but slightly differently: a "compatible" property is
required by the Device Tree i2c bindings, and is present on all of
the Sun i2c device nodes that are useful (the notable exception being
the i2c "idprom" nodes, which are actually duplicates of a regular
serial eeprom node).  However, Apple's older OpenFirmware implementations
are rife with i2c nodes that lack a "compatible" property.  So, define
a OFW_I2C_ALLOW_MISSING_COMPATIBLE_PROPERTY quirk, and enable it in
the __HAVE_OPENFIRMWARE_VARIANT_AAPL case.

diffstat:

 sys/dev/ofw/ofw_i2c_subr.c |  15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diffs (43 lines):

diff -r 24b7699d25f3 -r 53c3f545c837 sys/dev/ofw/ofw_i2c_subr.c
--- a/sys/dev/ofw/ofw_i2c_subr.c        Fri May 14 02:51:43 2021 +0000
+++ b/sys/dev/ofw/ofw_i2c_subr.c        Fri May 14 03:05:52 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofw_i2c_subr.c,v 1.1.6.6 2021/05/14 02:51:43 thorpej Exp $     */
+/*     $NetBSD: ofw_i2c_subr.c,v 1.1.6.7 2021/05/14 03:05:52 thorpej Exp $     */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_i2c_subr.c,v 1.1.6.6 2021/05/14 02:51:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_i2c_subr.c,v 1.1.6.7 2021/05/14 03:05:52 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -79,6 +79,12 @@
  */
 #define        OFW_I2C_ADDRESS_MASK    __BITS(0,7)
 #define        OFW_I2C_ADDRESS_SHIFT   1
+
+/*
+ * Some of Apple's older OpenFirmware implementations are rife with
+ * nodes lacking "compatible" properties.
+ */
+#define        OFW_I2C_ALLOW_MISSING_COMPATIBLE_PROPERTY
 #endif /* __HAVE_OPENFIRMWARE_VARIANT_AAPL */
 
 #ifdef __HAVE_OPENFIRMWARE_VARIANT_SUNW
@@ -176,6 +182,11 @@
                }
 
                clist_size = OF_getproplen(node, "compatible");
+#ifndef OFW_I2C_ALLOW_MISSING_COMPATIBLE_PROPERTY
+               if (clist_size <= 0) {
+                       continue;
+               }
+#endif
                clist = kmem_tmpbuf_alloc(clist_size,
                    compat_buf, sizeof(compat_buf), KM_SLEEP);
                if (OF_getprop(node, "compatible", clist, clist_size) <



Home | Main Index | Thread Index | Old Index