Module Name:    src
Committed By:   jmcneill
Date:           Mon Jan 25 12:15:33 UTC 2021

Modified Files:
        src/sys/dev/acpi: acpi_i2c.c
        src/sys/dev/i2c: i2cvar.h
        src/sys/dev/ofw: ofw_subr.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/acpi/acpi_i2c.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/i2c/i2cvar.h
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/ofw/ofw_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/acpi_i2c.c
diff -u src/sys/dev/acpi/acpi_i2c.c:1.8 src/sys/dev/acpi/acpi_i2c.c:1.9
--- src/sys/dev/acpi/acpi_i2c.c:1.8	Mon Aug 24 05:37:41 2020
+++ src/sys/dev/acpi/acpi_i2c.c	Mon Jan 25 12:15:32 2021
@@ -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
 		.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_devnod
 	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;

Index: src/sys/dev/i2c/i2cvar.h
diff -u src/sys/dev/i2c/i2cvar.h:1.22 src/sys/dev/i2c/i2cvar.h:1.23
--- src/sys/dev/i2c/i2cvar.h:1.22	Mon Jan 18 15:28:21 2021
+++ src/sys/dev/i2c/i2cvar.h	Mon Jan 25 12:15:32 2021
@@ -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 */
 };
 
 /*

Index: src/sys/dev/ofw/ofw_subr.c
diff -u src/sys/dev/ofw/ofw_subr.c:1.48 src/sys/dev/ofw/ofw_subr.c:1.49
--- src/sys/dev/ofw/ofw_subr.c:1.48	Sun Jan 24 21:48:38 2021
+++ src/sys/dev/ofw/ofw_subr.c	Mon Jan 25 12:15:33 2021
@@ -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 prop
 		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);

Reply via email to