diff options
| author | jmcneill <jmcneill@NetBSD.org> | 2021-01-25 12:15:32 +0000 |
|---|---|---|
| committer | jmcneill <jmcneill@NetBSD.org> | 2021-01-25 12:15:32 +0000 |
| commit | 552d0b4439c79753e217619a04ee360c8a18e2df (patch) | |
| tree | 859635694a0196abbe4c5a5a2156061d3f0c7f41 /sys/dev | |
| parent | 2657c071e0a5d509e87cad18c9ff46917fe21c12 (diff) | |
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 (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/acpi/acpi_i2c.c | 12 | ||||
| -rw-r--r-- | sys/dev/i2c/i2cvar.h | 12 | ||||
| -rw-r--r-- | sys/dev/ofw/ofw_subr.c | 6 |
3 files changed, 24 insertions, 6 deletions
diff --git a/sys/dev/acpi/acpi_i2c.c b/sys/dev/acpi/acpi_i2c.c index d986df90878..b10dbaf63f6 100644 --- a/sys/dev/acpi/acpi_i2c.c +++ b/sys/dev/acpi/acpi_i2c.c @@ -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 @@ static const struct acpi_i2c_id acpi_i2c_ids[] = { .parse = acpi_enter_i2c_hid }, { + .id = "NXP0002", + .compat = "nxp,pca9547", + .compatlen = 12, + .parse = NULL + }, + { .id = NULL, .compat = NULL, .compatlen = 0, @@ -192,6 +199,7 @@ acpi_enter_i2c_device(struct acpi_devnode *ad, prop_array_t array) 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 --git a/sys/dev/i2c/i2cvar.h b/sys/dev/i2c/i2cvar.h index 392c83b358e..4b80f479f91 100644 --- a/sys/dev/i2c/i2cvar.h +++ b/sys/dev/i2c/i2cvar.h @@ -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 @@ struct i2cbus_attach_args { 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 @@ struct i2c_attach_args { * 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 --git a/sys/dev/ofw/ofw_subr.c b/sys/dev/ofw/ofw_subr.c index 68f0e1105e3..7b964699ab1 100644 --- a/sys/dev/ofw/ofw_subr.c +++ b/sys/dev/ofw/ofw_subr.c @@ -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 @@ of_enter_i2c_devs(prop_dictionary_t props, int ofnode, size_t cell_size, 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); |
