| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: spi.c,v 1.22 2022/01/19 12:58:06 thorpej Exp $ */ | | 1 | /* $NetBSD: spi.c,v 1.23 2022/01/19 13:33:11 thorpej Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | | 4 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. |
5 | * Copyright (c) 2006 Garrett D'Amore. | | 5 | * Copyright (c) 2006 Garrett D'Amore. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Portions of this code were written by Garrett D'Amore for the | | 8 | * Portions of this code were written by Garrett D'Amore for the |
9 | * Champaign-Urbana Community Wireless Network Project. | | 9 | * Champaign-Urbana Community Wireless Network Project. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or | | 11 | * Redistribution and use in source and binary forms, with or |
12 | * without modification, are permitted provided that the following | | 12 | * without modification, are permitted provided that the following |
13 | * conditions are met: | | 13 | * conditions are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -32,27 +32,27 @@ | | | @@ -32,27 +32,27 @@ |
32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT | | 33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT |
34 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, | | 34 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, |
35 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 35 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
36 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 36 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | | 37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
38 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | | 38 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | | 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
41 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 41 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
42 | */ | | 42 | */ |
43 | | | 43 | |
44 | #include <sys/cdefs.h> | | 44 | #include <sys/cdefs.h> |
45 | __KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.22 2022/01/19 12:58:06 thorpej Exp $"); | | 45 | __KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.23 2022/01/19 13:33:11 thorpej Exp $"); |
46 | | | 46 | |
47 | #include "locators.h" | | 47 | #include "locators.h" |
48 | | | 48 | |
49 | #include <sys/param.h> | | 49 | #include <sys/param.h> |
50 | #include <sys/systm.h> | | 50 | #include <sys/systm.h> |
51 | #include <sys/device.h> | | 51 | #include <sys/device.h> |
52 | #include <sys/conf.h> | | 52 | #include <sys/conf.h> |
53 | #include <sys/malloc.h> | | 53 | #include <sys/malloc.h> |
54 | #include <sys/mutex.h> | | 54 | #include <sys/mutex.h> |
55 | #include <sys/condvar.h> | | 55 | #include <sys/condvar.h> |
56 | #include <sys/errno.h> | | 56 | #include <sys/errno.h> |
57 | | | 57 | |
58 | #include <dev/spi/spivar.h> | | 58 | #include <dev/spi/spivar.h> |
| @@ -262,26 +262,34 @@ spi_direct_attach_child_devices(device_t | | | @@ -262,26 +262,34 @@ spi_direct_attach_child_devices(device_t |
262 | } | | 262 | } |
263 | | | 263 | |
264 | int | | 264 | int |
265 | spi_compatible_match(const struct spi_attach_args *sa, const cfdata_t cf, | | 265 | spi_compatible_match(const struct spi_attach_args *sa, const cfdata_t cf, |
266 | const struct device_compatible_entry *compats) | | 266 | const struct device_compatible_entry *compats) |
267 | { | | 267 | { |
268 | if (sa->sa_ncompat > 0) | | 268 | if (sa->sa_ncompat > 0) |
269 | return device_compatible_match(sa->sa_compat, sa->sa_ncompat, | | 269 | return device_compatible_match(sa->sa_compat, sa->sa_ncompat, |
270 | compats); | | 270 | compats); |
271 | | | 271 | |
272 | return 1; | | 272 | return 1; |
273 | } | | 273 | } |
274 | | | 274 | |
| | | 275 | const struct device_compatible_entry * |
| | | 276 | spi_compatible_lookup(const struct spi_attach_args *sa, |
| | | 277 | const struct device_compatible_entry *compats) |
| | | 278 | { |
| | | 279 | return device_compatible_lookup(sa->sa_compat, sa->sa_ncompat, |
| | | 280 | compats); |
| | | 281 | } |
| | | 282 | |
275 | /* | | 283 | /* |
276 | * API for device drivers. | | 284 | * API for device drivers. |
277 | * | | 285 | * |
278 | * We provide wrapper routines to decouple the ABI for the SPI | | 286 | * We provide wrapper routines to decouple the ABI for the SPI |
279 | * device drivers from the ABI for the SPI bus drivers. | | 287 | * device drivers from the ABI for the SPI bus drivers. |
280 | */ | | 288 | */ |
281 | static void | | 289 | static void |
282 | spi_attach(device_t parent, device_t self, void *aux) | | 290 | spi_attach(device_t parent, device_t self, void *aux) |
283 | { | | 291 | { |
284 | struct spi_softc *sc = device_private(self); | | 292 | struct spi_softc *sc = device_private(self); |
285 | struct spibus_attach_args *sba = aux; | | 293 | struct spibus_attach_args *sba = aux; |
286 | int i; | | 294 | int i; |
287 | | | 295 | |