Sun Jan 24 19:37:45 2021 UTC ()
trailing whitespace


(jmcneill)
diff -r1.3 -r1.4 src/sys/dev/i2c/pcai2cmux.c

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

--- src/sys/dev/i2c/pcai2cmux.c 2021/01/18 15:28:21 1.3
+++ src/sys/dev/i2c/pcai2cmux.c 2021/01/24 19:37:45 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pcai2cmux.c,v 1.3 2021/01/18 15:28:21 thorpej Exp $ */ 1/* $NetBSD: pcai2cmux.c,v 1.4 2021/01/24 19:37:45 jmcneill 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.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
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: pcai2cmux.c,v 1.3 2021/01/18 15:28:21 thorpej Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: pcai2cmux.c,v 1.4 2021/01/24 19:37:45 jmcneill Exp $");
34 34
35/* 35/*
36 * Driver for NXP PCA954x / PCA984x I2C switches and multiplexers. 36 * Driver for NXP PCA954x / PCA984x I2C switches and multiplexers.
37 * 37 *
38 * There are two flavors of this device: 38 * There are two flavors of this device:
39 * 39 *
40 * - Multiplexers, which connect the upstream bus to one downstream bus 40 * - Multiplexers, which connect the upstream bus to one downstream bus
41 * at a time. 41 * at a time.
42 * 42 *
43 * - Switches, which can connect the upstream bus to one or more downstream 43 * - Switches, which can connect the upstream bus to one or more downstream
44 * busses at a time (which is useful when using an all-call address for 44 * busses at a time (which is useful when using an all-call address for
45 * a large array of PCA9685 LED controllers, for example). 45 * a large array of PCA9685 LED controllers, for example).
46 * 46 *
@@ -116,26 +116,30 @@ static const struct device_compatible_en @@ -116,26 +116,30 @@ static const struct device_compatible_en
116 116
117 /* PCA9545 - 4 channel i2c switch with interrupts */ 117 /* PCA9545 - 4 channel i2c switch with interrupts */
118 { .compat = "nxp,pca9545", 118 { .compat = "nxp,pca9545",
119 .data = &switch4_type }, 119 .data = &switch4_type },
120 120
121 /* PCA9546 - 4 channel i2c switch */ 121 /* PCA9546 - 4 channel i2c switch */
122 { .compat = "nxp,pca9546", 122 { .compat = "nxp,pca9546",
123 .data = &switch4_type }, 123 .data = &switch4_type },
124 124
125 /* PCA9547 - 8 channel i2c mux */ 125 /* PCA9547 - 8 channel i2c mux */
126 { .compat = "nxp,pca9547", 126 { .compat = "nxp,pca9547",
127 .data = &mux8_type }, 127 .data = &mux8_type },
128 128
 129 /* PCA9547 - 8 channel i2c mux (NXP Layerscape ACPI) */
 130 { .compat = "NXP0002",
 131 .data = &mux8_type },
 132
129 /* PCA9548 - 8 channel i2c switch */ 133 /* PCA9548 - 8 channel i2c switch */
130 { .compat = "nxp,pca9548", 134 { .compat = "nxp,pca9548",
131 .data = &switch8_type }, 135 .data = &switch8_type },
132 136
133 /* PCA9846 - 4 channel i2c switch */ 137 /* PCA9846 - 4 channel i2c switch */
134 { .compat = "nxp,pca9846", 138 { .compat = "nxp,pca9846",
135 .data = &switch4_type }, 139 .data = &switch4_type },
136 140
137 /* PCA9847 - 8 channel i2c mux */ 141 /* PCA9847 - 8 channel i2c mux */
138 { .compat = "nxp,pca9847", 142 { .compat = "nxp,pca9847",
139 .data = &mux8_type }, 143 .data = &mux8_type },
140 144
141 /* PCA9848 - 8 channel i2c switch */ 145 /* PCA9848 - 8 channel i2c switch */
@@ -281,27 +285,27 @@ pcaiicmux_type_by_compat(const struct i2 @@ -281,27 +285,27 @@ pcaiicmux_type_by_compat(const struct i2
281 285
282 return type; 286 return type;
283} 287}
284 288
285static int 289static int
286pcaiicmux_match(device_t parent, cfdata_t cf, void *aux) 290pcaiicmux_match(device_t parent, cfdata_t cf, void *aux)
287{ 291{
288 struct i2c_attach_args * const ia = aux; 292 struct i2c_attach_args * const ia = aux;
289 int match_result; 293 int match_result;
290 294
291 if (iic_use_direct_match(ia, cf, compat_data, &match_result)) { 295 if (iic_use_direct_match(ia, cf, compat_data, &match_result)) {
292 return match_result; 296 return match_result;
293 } 297 }
294  298
295 /* This device is direct-config only. */ 299 /* This device is direct-config only. */
296 300
297 return 0; 301 return 0;
298} 302}
299 303
300static void 304static void
301pcaiicmux_attach(device_t parent, device_t self, void *aux) 305pcaiicmux_attach(device_t parent, device_t self, void *aux)
302{ 306{
303 struct pcaiicmux_softc * const sc = device_private(self); 307 struct pcaiicmux_softc * const sc = device_private(self);
304 struct i2c_attach_args * const ia = aux; 308 struct i2c_attach_args * const ia = aux;
305 const int phandle = (int)ia->ia_cookie; 309 const int phandle = (int)ia->ia_cookie;
306 int error; 310 int error;
307 311