Tue Jan 26 01:23:08 2021 UTC ()
Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings.  Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.


(thorpej)
diff -r1.10 -r1.11 src/sys/dev/acpi/acpi_i2c.c
diff -r1.15 -r1.16 src/sys/dev/i2c/ihidev.c
diff -r1.6 -r1.7 src/sys/dev/i2c/pcai2cmux.c

cvs diff -r1.10 -r1.11 src/sys/dev/acpi/acpi_i2c.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi_i2c.c 2021/01/26 00:19:53 1.10
+++ src/sys/dev/acpi/acpi_i2c.c 2021/01/26 01:23:08 1.11
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1/* $NetBSD: acpi_i2c.c,v 1.10 2021/01/26 00:19:53 jmcneill Exp $ */ 1/* $NetBSD: acpi_i2c.c,v 1.11 2021/01/26 01:23:08 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2017 The NetBSD Foundation, Inc. 4 * Copyright (c) 2017, 2021 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Manuel Bouyer. 8 * by Manuel Bouyer.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
@@ -20,133 +20,38 @@ @@ -20,133 +20,38 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.10 2021/01/26 00:19:53 jmcneill Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.11 2021/01/26 01:23:08 thorpej Exp $");
34 34
35#include <dev/acpi/acpireg.h> 35#include <dev/acpi/acpireg.h>
36#include <dev/acpi/acpivar.h> 36#include <dev/acpi/acpivar.h>
37#include <dev/acpi/acpi_i2c.h> 37#include <dev/acpi/acpi_i2c.h>
38#include <dev/i2c/i2cvar.h> 38#include <dev/i2c/i2cvar.h>
39 39
 40#include <sys/kmem.h>
 41
40#define _COMPONENT ACPI_BUS_COMPONENT 42#define _COMPONENT ACPI_BUS_COMPONENT
41ACPI_MODULE_NAME ("acpi_i2c") 43ACPI_MODULE_NAME ("acpi_i2c")
42 44
43static void 
44acpi_enter_i2c_hid(struct acpi_devnode *devnode, prop_dictionary_t dev) 
45{ 
46 ACPI_OBJECT_LIST arg; 
47 ACPI_OBJECT obj[4]; 
48 ACPI_OBJECT *osc; 
49 ACPI_BUFFER buf; 
50 ACPI_STATUS rv; 
51 /* 3cdff6f7-4267-4555-ad05-b30a3d8938de */ 
52 static uint8_t i2c_hid_guid[] = { 
53 0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45, 
54 0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE, 
55 }; 
56 
57 arg.Count = 4; 
58 arg.Pointer = obj; 
59 
60 obj[0].Type = ACPI_TYPE_BUFFER; 
61 obj[0].Buffer.Length = sizeof(i2c_hid_guid); 
62 obj[0].Buffer.Pointer = i2c_hid_guid; 
63 
64 /* rev */ 
65 obj[1].Type = ACPI_TYPE_INTEGER; 
66 obj[1].Integer.Value = 1; 
67 
68 /* func */ 
69 obj[2].Type = ACPI_TYPE_INTEGER; 
70 obj[2].Integer.Value = 1; 
71 
72 obj[3].Type = ACPI_TYPE_PACKAGE; 
73 obj[3].Buffer.Length = 0; 
74 
75 buf.Pointer = NULL; 
76 buf.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 
77 
78 rv = AcpiEvaluateObject(devnode->ad_handle, "_DSM", &arg, &buf); 
79 
80 if (ACPI_FAILURE(rv)) { 
81 aprint_error("failed to evaluate _DSM for %s: %s\n", 
82 devnode->ad_name, AcpiFormatException(rv)); 
83 return; 
84 } 
85 
86 osc = buf.Pointer; 
87 if (osc->Type != ACPI_TYPE_INTEGER) { 
88 aprint_error("bad _DSM return type %d for %s\n", 
89 osc->Type, devnode->ad_name); 
90 return; 
91 } 
92 prop_dictionary_set_uint32(dev, "hid-descr-addr", osc->Integer.Value); 
93} 
94 
95struct acpi_i2c_id { 
96 const char *id; 
97 const char *compat; 
98 const int compatlen; 
99 void (*parse)(struct acpi_devnode *, prop_dictionary_t); 
100}; 
101 
102static const struct acpi_i2c_id acpi_i2c_ids[] = { 
103 { 
104 .id = "PNP0C50", 
105 .compat = "hid-over-i2c", 
106 .compatlen = 13, 
107 .parse = acpi_enter_i2c_hid 
108 }, 
109 { 
110 .id = "ACPI0C50", 
111 .compat = "hid-over-i2c", 
112 .compatlen = 13, 
113 .parse = acpi_enter_i2c_hid 
114 }, 
115 { 
116 .id = "NXP0002", 
117 .compat = "nxp,pca9547", 
118 .compatlen = 12, 
119 .parse = NULL 
120 }, 
121 { 
122 .id = NULL, 
123 .compat = NULL, 
124 .compatlen = 0, 
125 .parse = NULL 
126 } 
127}; 
128 
129static const struct acpi_i2c_id * 
130acpi_i2c_search(const char *name) 
131{ 
132 int i; 
133 for (i = 0; acpi_i2c_ids[i].id != NULL; i++) { 
134 if (strcmp(name, acpi_i2c_ids[i].id) == 0) 
135 return &acpi_i2c_ids[i]; 
136 } 
137 return NULL; 
138} 
139 
140struct acpi_i2c_context { 45struct acpi_i2c_context {
141 uint16_t i2c_addr; 46 uint16_t i2c_addr;
142}; 47};
143 48
144static ACPI_STATUS 49static ACPI_STATUS
145acpi_i2c_resource_parse_callback(ACPI_RESOURCE *res, void *context) 50acpi_i2c_resource_parse_callback(ACPI_RESOURCE *res, void *context)
146{ 51{
147 struct acpi_i2c_context *i2cc = context; 52 struct acpi_i2c_context *i2cc = context;
148 53
149 switch (res->Type) { 54 switch (res->Type) {
150 case ACPI_RESOURCE_TYPE_END_TAG: 55 case ACPI_RESOURCE_TYPE_END_TAG:
151 break; 56 break;
152 case ACPI_RESOURCE_TYPE_SERIAL_BUS: 57 case ACPI_RESOURCE_TYPE_SERIAL_BUS:
@@ -160,80 +65,69 @@ acpi_i2c_resource_parse_callback(ACPI_RE @@ -160,80 +65,69 @@ acpi_i2c_resource_parse_callback(ACPI_RE
160 break; 65 break;
161 default: 66 default:
162 printf("resource type 0x%x ignored\n", res->Type); 67 printf("resource type 0x%x ignored\n", res->Type);
163 } 68 }
164 return_ACPI_STATUS(AE_OK); 69 return_ACPI_STATUS(AE_OK);
165} 70}
166 71
167static void 72static void
168acpi_enter_i2c_device(struct acpi_devnode *ad, prop_array_t array) 73acpi_enter_i2c_device(struct acpi_devnode *ad, prop_array_t array)
169{ 74{
170 prop_dictionary_t dev; 75 prop_dictionary_t dev;
171 struct acpi_i2c_context i2cc; 76 struct acpi_i2c_context i2cc;
172 ACPI_STATUS rv; 77 ACPI_STATUS rv;
173 int cidi; 
174 ACPI_PNP_DEVICE_ID_LIST *idlist; 
175 const char *name; 78 const char *name;
176 static const struct acpi_i2c_id *i2c_id; 79 char *clist;
 80 size_t clist_size;
177 81
178 memset(&i2cc, 0, sizeof(i2cc)); 82 memset(&i2cc, 0, sizeof(i2cc));
179 rv = AcpiWalkResources(ad->ad_handle, "_CRS", 83 rv = AcpiWalkResources(ad->ad_handle, "_CRS",
180 acpi_i2c_resource_parse_callback, &i2cc); 84 acpi_i2c_resource_parse_callback, &i2cc);
181 if (ACPI_FAILURE(rv)) { 85 if (ACPI_FAILURE(rv)) {
182 aprint_error("ACPI: unable to get resources " 86 aprint_error("ACPI: unable to get resources "
183 "for %s: %s\n", ad->ad_name, 87 "for %s: %s\n", ad->ad_name,
184 AcpiFormatException(rv)); 88 AcpiFormatException(rv));
185 return; 89 return;
186 } 90 }
187 if (i2cc.i2c_addr == 0) 91 if (i2cc.i2c_addr == 0)
188 return; 92 return;
189 dev = prop_dictionary_create(); 93 dev = prop_dictionary_create();
190 if (dev == NULL) { 94 if (dev == NULL) {
191 aprint_error("ignoring device %s (no memory)\n", 95 aprint_error("ignoring device %s (no memory)\n",
192 ad->ad_name); 96 ad->ad_name);
193 return; 97 return;
194 } 98 }
195 if ((ad->ad_devinfo->Valid & ACPI_VALID_HID) == 0) 99 clist = acpi_pack_compat_list(ad->ad_devinfo, &clist_size);
 100 if (clist == NULL) {
 101 prop_object_release(dev);
 102 aprint_error("ignoring device %s (no _HID or _CID)\n",
 103 ad->ad_name);
 104 return;
 105 }
 106 if ((ad->ad_devinfo->Valid & ACPI_VALID_HID) == 0)
196 name = ad->ad_name; 107 name = ad->ad_name;
197 else 108 else
198 name = ad->ad_devinfo->HardwareId.String; 109 name = ad->ad_devinfo->HardwareId.String;
199 prop_dictionary_set_string(dev, "name", name); 110 prop_dictionary_set_string(dev, "name", name);
200 prop_dictionary_set_uint32(dev, "addr", i2cc.i2c_addr); 111 prop_dictionary_set_uint32(dev, "addr", i2cc.i2c_addr);
201 prop_dictionary_set_uint64(dev, "cookie", (uintptr_t)ad->ad_handle); 112 prop_dictionary_set_uint64(dev, "cookie", (uintptr_t)ad->ad_handle);
202 prop_dictionary_set_uint32(dev, "cookietype", I2C_COOKIE_ACPI); 113 prop_dictionary_set_uint32(dev, "cookietype", I2C_COOKIE_ACPI);
203 /* first search by name, then by CID */ 114 prop_dictionary_set_data(dev, "compatible", clist, clist_size);
204 i2c_id = acpi_i2c_search(name); 115 kmem_free(clist, clist_size);
205 idlist = &ad->ad_devinfo->CompatibleIdList; 116
206 for (cidi = 0; 
207 cidi < idlist->Count && i2c_id == NULL; 
208 cidi++) { 
209 i2c_id = acpi_i2c_search(idlist->Ids[cidi].String); 
210 } 
211 if (i2c_id != NULL) { 
212 if (i2c_id->compat != NULL) { 
213 prop_data_t data; 
214 data = prop_data_create_copy(i2c_id->compat, 
215 i2c_id->compatlen); 
216 prop_dictionary_set(dev, "compatible", data); 
217 prop_object_release(data); 
218 } 
219 if (i2c_id->parse != NULL) 
220 i2c_id->parse(ad, dev); 
221 } 
222 prop_array_add(array, dev); 117 prop_array_add(array, dev);
223 prop_object_release(dev); 118 prop_object_release(dev);
224} 119}
225 120
226 
227prop_array_t 121prop_array_t
228acpi_enter_i2c_devs(device_t dev, struct acpi_devnode *devnode) 122acpi_enter_i2c_devs(device_t dev, struct acpi_devnode *devnode)
229{ 123{
230 struct acpi_devnode *ad; 124 struct acpi_devnode *ad;
231 prop_array_t array = prop_array_create(); 125 prop_array_t array = prop_array_create();
232 126
233 if (array == NULL) 127 if (array == NULL)
234 return NULL; 128 return NULL;
235 129
236 SIMPLEQ_FOREACH(ad, &devnode->ad_child_head, ad_child_list) { 130 SIMPLEQ_FOREACH(ad, &devnode->ad_child_head, ad_child_list) {
237 if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE) 131 if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE)
238 continue; 132 continue;
239 if (!acpi_device_present(ad->ad_handle)) 133 if (!acpi_device_present(ad->ad_handle))

cvs diff -r1.15 -r1.16 src/sys/dev/i2c/ihidev.c (expand / switch to unified diff)

--- src/sys/dev/i2c/ihidev.c 2021/01/26 01:15:39 1.15
+++ src/sys/dev/i2c/ihidev.c 2021/01/26 01:23:08 1.16
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ihidev.c,v 1.15 2021/01/26 01:15:39 thorpej Exp $ */ 1/* $NetBSD: ihidev.c,v 1.16 2021/01/26 01:23:08 thorpej Exp $ */
2/* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */ 2/* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2017 The NetBSD Foundation, Inc. 5 * Copyright (c) 2017 The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Manuel Bouyer. 9 * by Manuel Bouyer.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -44,27 +44,27 @@ @@ -44,27 +44,27 @@
44 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 44 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
45 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 45 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
46 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 46 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
47 */ 47 */
48 48
49/* 49/*
50 * HID-over-i2c driver 50 * HID-over-i2c driver
51 * 51 *
52 * https://msdn.microsoft.com/en-us/library/windows/hardware/dn642101%28v=vs.85%29.aspx 52 * https://msdn.microsoft.com/en-us/library/windows/hardware/dn642101%28v=vs.85%29.aspx
53 * 53 *
54 */ 54 */
55 55
56#include <sys/cdefs.h> 56#include <sys/cdefs.h>
57__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.15 2021/01/26 01:15:39 thorpej Exp $"); 57__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.16 2021/01/26 01:23:08 thorpej Exp $");
58 58
59#include <sys/param.h> 59#include <sys/param.h>
60#include <sys/systm.h> 60#include <sys/systm.h>
61#include <sys/device.h> 61#include <sys/device.h>
62#include <sys/kmem.h> 62#include <sys/kmem.h>
63 63
64 64
65#include <dev/i2c/i2cvar.h> 65#include <dev/i2c/i2cvar.h>
66#include <dev/i2c/ihidev.h> 66#include <dev/i2c/ihidev.h>
67 67
68#include <dev/hid/hid.h> 68#include <dev/hid/hid.h>
69 69
70#if defined(__i386__) || defined(__amd64__) 70#if defined(__i386__) || defined(__amd64__)
@@ -116,26 +116,28 @@ static void ihiddev_intr_fini(struct ihi @@ -116,26 +116,28 @@ static void ihiddev_intr_fini(struct ihi
116static bool ihidev_suspend(device_t, const pmf_qual_t *); 116static bool ihidev_suspend(device_t, const pmf_qual_t *);
117static bool ihidev_resume(device_t, const pmf_qual_t *); 117static bool ihidev_resume(device_t, const pmf_qual_t *);
118static int ihidev_hid_command(struct ihidev_softc *, int, void *, bool); 118static int ihidev_hid_command(struct ihidev_softc *, int, void *, bool);
119static int ihidev_intr(void *); 119static int ihidev_intr(void *);
120static void ihidev_softintr(void *); 120static void ihidev_softintr(void *);
121static int ihidev_reset(struct ihidev_softc *, bool); 121static int ihidev_reset(struct ihidev_softc *, bool);
122static int ihidev_hid_desc_parse(struct ihidev_softc *); 122static int ihidev_hid_desc_parse(struct ihidev_softc *);
123 123
124static int ihidev_maxrepid(void *, int); 124static int ihidev_maxrepid(void *, int);
125static int ihidev_print(void *, const char *); 125static int ihidev_print(void *, const char *);
126static int ihidev_submatch(device_t, cfdata_t, const int *, void *); 126static int ihidev_submatch(device_t, cfdata_t, const int *, void *);
127 127
128static const struct device_compatible_entry compat_data[] = { 128static const struct device_compatible_entry compat_data[] = {
 129 { .compat = "PNP0C50" },
 130 { .compat = "ACPI0C50" },
129 { .compat = "hid-over-i2c" }, 131 { .compat = "hid-over-i2c" },
130 { } 132 { }
131}; 133};
132 134
133static int 135static int
134ihidev_match(device_t parent, cfdata_t match, void *aux) 136ihidev_match(device_t parent, cfdata_t match, void *aux)
135{ 137{
136 struct i2c_attach_args * const ia = aux; 138 struct i2c_attach_args * const ia = aux;
137 int match_result; 139 int match_result;
138 140
139 if (iic_use_direct_match(ia, match, compat_data, &match_result)) 141 if (iic_use_direct_match(ia, match, compat_data, &match_result))
140 return I2C_MATCH_DIRECT_COMPATIBLE; 142 return I2C_MATCH_DIRECT_COMPATIBLE;
141 143

cvs diff -r1.6 -r1.7 src/sys/dev/i2c/pcai2cmux.c (expand / switch to unified diff)

--- src/sys/dev/i2c/pcai2cmux.c 2021/01/25 12:18:18 1.6
+++ src/sys/dev/i2c/pcai2cmux.c 2021/01/26 01:23:08 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pcai2cmux.c,v 1.6 2021/01/25 12:18:18 jmcneill Exp $ */ 1/* $NetBSD: pcai2cmux.c,v 1.7 2021/01/26 01:23:08 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2020 The NetBSD Foundation, Inc. 4 * Copyright (c) 2020 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe. 8 * by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#if defined(__i386__) || defined(__amd64__) || defined(__aarch64__) 32#if defined(__i386__) || defined(__amd64__) || defined(__aarch64__)
33#include "acpica.h" 33#include "acpica.h"
34#endif 34#endif
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: pcai2cmux.c,v 1.6 2021/01/25 12:18:18 jmcneill Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: pcai2cmux.c,v 1.7 2021/01/26 01:23:08 thorpej Exp $");
38 38
39/* 39/*
40 * Driver for NXP PCA954x / PCA984x I2C switches and multiplexers. 40 * Driver for NXP PCA954x / PCA984x I2C switches and multiplexers.
41 * 41 *
42 * There are two flavors of this device: 42 * There are two flavors of this device:
43 * 43 *
44 * - Multiplexers, which connect the upstream bus to one downstream bus 44 * - Multiplexers, which connect the upstream bus to one downstream bus
45 * at a time. 45 * at a time.
46 * 46 *
47 * - Switches, which can connect the upstream bus to one or more downstream 47 * - Switches, which can connect the upstream bus to one or more downstream
48 * busses at a time (which is useful when using an all-call address for 48 * busses at a time (which is useful when using an all-call address for
49 * a large array of PCA9685 LED controllers, for example). 49 * a large array of PCA9685 LED controllers, for example).
50 * 50 *
@@ -123,48 +123,50 @@ static const struct device_compatible_en @@ -123,48 +123,50 @@ static const struct device_compatible_en
123 .data = &mux4_type }, 123 .data = &mux4_type },
124 124
125 /* PCA9545 - 4 channel i2c switch with interrupts */ 125 /* PCA9545 - 4 channel i2c switch with interrupts */
126 { .compat = "nxp,pca9545", 126 { .compat = "nxp,pca9545",
127 .data = &switch4_type }, 127 .data = &switch4_type },
128 128
129 /* PCA9546 - 4 channel i2c switch */ 129 /* PCA9546 - 4 channel i2c switch */
130 { .compat = "nxp,pca9546", 130 { .compat = "nxp,pca9546",
131 .data = &switch4_type }, 131 .data = &switch4_type },
132 132
133 /* PCA9547 - 8 channel i2c mux */ 133 /* PCA9547 - 8 channel i2c mux */
134 { .compat = "nxp,pca9547", 134 { .compat = "nxp,pca9547",
135 .data = &mux8_type }, 135 .data = &mux8_type },
 136 { .compat = "NXP0002",
 137 .data = &mux8_type },
136 138
137 /* PCA9548 - 8 channel i2c switch */ 139 /* PCA9548 - 8 channel i2c switch */
138 { .compat = "nxp,pca9548", 140 { .compat = "nxp,pca9548",
139 .data = &switch8_type }, 141 .data = &switch8_type },
140 142
141 /* PCA9846 - 4 channel i2c switch */ 143 /* PCA9846 - 4 channel i2c switch */
142 { .compat = "nxp,pca9846", 144 { .compat = "nxp,pca9846",
143 .data = &switch4_type }, 145 .data = &switch4_type },
144 146
145 /* PCA9847 - 8 channel i2c mux */ 147 /* PCA9847 - 8 channel i2c mux */
146 { .compat = "nxp,pca9847", 148 { .compat = "nxp,pca9847",
147 .data = &mux8_type }, 149 .data = &mux8_type },
148 150
149 /* PCA9848 - 8 channel i2c switch */ 151 /* PCA9848 - 8 channel i2c switch */
150 { .compat = "nxp,pca9848", 152 { .compat = "nxp,pca9848",
151 .data = &switch8_type }, 153 .data = &switch8_type },
152 154
153 /* PCA9849 - 4 channel i2c mux */ 155 /* PCA9849 - 4 channel i2c mux */
154 { .compat = "nxp,pca9849", 156 { .compat = "nxp,pca9849",
155 .data = &mux4_type }, 157 .data = &mux4_type },
156 158
157 { 0 } 159 { }
158}; 160};
159 161
160struct pcaiicmux_softc { 162struct pcaiicmux_softc {
161 struct iicmux_softc sc_iicmux; 163 struct iicmux_softc sc_iicmux;
162 164
163 i2c_addr_t sc_addr; 165 i2c_addr_t sc_addr;
164 int sc_cur_value; 166 int sc_cur_value;
165 167
166 const struct pcaiicmux_type *sc_type; 168 const struct pcaiicmux_type *sc_type;
167 struct fdtbus_gpio_pin *sc_reset_gpio; 169 struct fdtbus_gpio_pin *sc_reset_gpio;
168 170
169 bool sc_idle_disconnect; 171 bool sc_idle_disconnect;
170 172