Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Add "cookietype" to i2c attach args, so the consumer...



details:   https://anonhg.NetBSD.org/src/rev/0a4aab182aa3
branches:  trunk
changeset: 958933:0a4aab182aa3
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon Jan 25 12:15:32 2021 +0000

description:
Add "cookietype" to i2c attach args, so the consumer knows if ia_cookie
is either an OF phandle or an ACPI_HANDLE. Add NXP0002 compatible mapping
while here.

diffstat:

 sys/dev/acpi/acpi_i2c.c |  12 ++++++++++--
 sys/dev/i2c/i2cvar.h    |  12 ++++++++++--
 sys/dev/ofw/ofw_subr.c  |   6 ++++--
 3 files changed, 24 insertions(+), 6 deletions(-)

diffs (113 lines):

diff -r 82e86484aad4 -r 0a4aab182aa3 sys/dev/acpi/acpi_i2c.c
--- a/sys/dev/acpi/acpi_i2c.c   Mon Jan 25 12:09:58 2021 +0000
+++ b/sys/dev/acpi/acpi_i2c.c   Mon Jan 25 12:15:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_i2c.c,v 1.8 2020/08/24 05:37:41 msaitoh Exp $ */
+/* $NetBSD: acpi_i2c.c,v 1.9 2021/01/25 12:15:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,11 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.8 2020/08/24 05:37:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.9 2021/01/25 12:15:32 jmcneill Exp $");
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
 #include <dev/acpi/acpi_i2c.h>
+#include <dev/i2c/i2cvar.h>
 
 #define _COMPONENT     ACPI_BUS_COMPONENT
 ACPI_MODULE_NAME       ("acpi_i2c")
@@ -112,6 +113,12 @@
                .parse = acpi_enter_i2c_hid
        },
        {
+               .id = "NXP0002",
+               .compat = "nxp,pca9547",
+               .compatlen = 12,
+               .parse = NULL
+       },
+       {
                .id = NULL,
                .compat = NULL,
                .compatlen = 0,
@@ -192,6 +199,7 @@
        prop_dictionary_set_string(dev, "name", name);
        prop_dictionary_set_uint32(dev, "addr", i2cc.i2c_addr);
        prop_dictionary_set_uint64(dev, "cookie", (uintptr_t)ad->ad_handle);
+       prop_dictionary_set_uint32(dev, "cookietype", I2C_COOKIE_ACPI);
        /* first search by name, then by CID */
        i2c_id = acpi_i2c_search(name);
        idlist = &ad->ad_devinfo->CompatibleIdList;
diff -r 82e86484aad4 -r 0a4aab182aa3 sys/dev/i2c/i2cvar.h
--- a/sys/dev/i2c/i2cvar.h      Mon Jan 25 12:09:58 2021 +0000
+++ b/sys/dev/i2c/i2cvar.h      Mon Jan 25 12:15:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i2cvar.h,v 1.22 2021/01/18 15:28:21 thorpej Exp $      */
+/*     $NetBSD: i2cvar.h,v 1.23 2021/01/25 12:15:32 jmcneill Exp $     */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -134,6 +134,13 @@
        prop_array_t iba_child_devices; /* child devices (direct config) */
 };
 
+/* Type of value stored in "ia_cookie" */
+enum i2c_cookie_type {
+       I2C_COOKIE_NONE,                /* Cookie is not valid */
+       I2C_COOKIE_OF,                  /* Cookie is an OF node phandle */
+       I2C_COOKIE_ACPI,                /* Cookie is an ACPI handle */
+};
+
 /* Used to attach devices on the i2c bus. */
 struct i2c_attach_args {
        i2c_tag_t       ia_tag;         /* our controller */
@@ -154,10 +161,11 @@
         * may be present. Example: on OpenFirmware machines the device
         * tree OF node - if available. This info is hard to transport
         * down to MD drivers through the MI i2c bus otherwise.
-        * 
+        *
         * On ACPI platforms this is the ACPI_HANDLE of the device.
         */
        uintptr_t       ia_cookie;      /* OF node in openfirmware machines */
+       enum i2c_cookie_type ia_cookietype; /* Value type of cookie */
 };
 
 /*
diff -r 82e86484aad4 -r 0a4aab182aa3 sys/dev/ofw/ofw_subr.c
--- a/sys/dev/ofw/ofw_subr.c    Mon Jan 25 12:09:58 2021 +0000
+++ b/sys/dev/ofw/ofw_subr.c    Mon Jan 25 12:15:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofw_subr.c,v 1.48 2021/01/24 21:48:38 thorpej Exp $    */
+/*     $NetBSD: ofw_subr.c,v 1.49 2021/01/25 12:15:33 jmcneill Exp $   */
 
 /*
  * Copyright 1998
@@ -34,13 +34,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.48 2021/01/24 21:48:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.49 2021/01/25 12:15:33 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/kmem.h>
 #include <sys/systm.h>
 #include <dev/ofw/openfirm.h>
+#include <dev/i2c/i2cvar.h>
 
 #define        OFW_MAX_STACK_BUF_SIZE  256
 #define        OFW_PATH_BUF_SIZE       512
@@ -508,6 +509,7 @@
                prop_dictionary_set_string(dev, "name", name);
                prop_dictionary_set_uint32(dev, "addr", addr);
                prop_dictionary_set_uint64(dev, "cookie", node);
+               prop_dictionary_set_uint32(dev, "cookietype", I2C_COOKIE_OF);
                of_to_dataprop(dev, node, "compatible", "compatible");
                prop_array_add(array, dev);
                prop_object_release(dev);



Home | Main Index | Thread Index | Old Index