| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: i2c.c,v 1.25 2010/03/01 17:35:21 njoly Exp $ */ | | 1 | /* $NetBSD: i2c.c,v 1.26 2011/07/31 15:58:25 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2003 Wasabi Systems, Inc. | | 4 | * Copyright (c) 2003 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.25 2010/03/01 17:35:21 njoly Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.26 2011/07/31 15:58:25 jmcneill Exp $"); |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/systm.h> | | 42 | #include <sys/systm.h> |
43 | #include <sys/device.h> | | 43 | #include <sys/device.h> |
44 | #include <sys/event.h> | | 44 | #include <sys/event.h> |
45 | #include <sys/conf.h> | | 45 | #include <sys/conf.h> |
46 | #include <sys/malloc.h> | | 46 | #include <sys/malloc.h> |
47 | #include <sys/kthread.h> | | 47 | #include <sys/kthread.h> |
48 | #include <sys/proc.h> | | 48 | #include <sys/proc.h> |
49 | #include <sys/kernel.h> | | 49 | #include <sys/kernel.h> |
50 | | | 50 | |
51 | #include <dev/i2c/i2cvar.h> | | 51 | #include <dev/i2c/i2cvar.h> |
52 | | | 52 | |
| @@ -109,26 +109,33 @@ iic_search(device_t parent, cfdata_t cf, | | | @@ -109,26 +109,33 @@ iic_search(device_t parent, cfdata_t cf, |
109 | ia.ia_type = sc->sc_type; | | 109 | ia.ia_type = sc->sc_type; |
110 | | | 110 | |
111 | ia.ia_name = NULL; | | 111 | ia.ia_name = NULL; |
112 | ia.ia_ncompat = 0; | | 112 | ia.ia_ncompat = 0; |
113 | ia.ia_compat = NULL; | | 113 | ia.ia_compat = NULL; |
114 | | | 114 | |
115 | if (config_match(parent, cf, &ia) > 0) | | 115 | if (config_match(parent, cf, &ia) > 0) |
116 | config_attach(parent, cf, &ia, iic_print); | | 116 | config_attach(parent, cf, &ia, iic_print); |
117 | | | 117 | |
118 | return (0); | | 118 | return (0); |
119 | } | | 119 | } |
120 | | | 120 | |
121 | static int | | 121 | static int |
| | | 122 | iic_rescan(device_t self, const char *ifattr, const int *locators) |
| | | 123 | { |
| | | 124 | config_search_ia(iic_search, self, ifattr, NULL); |
| | | 125 | return 0; |
| | | 126 | } |
| | | 127 | |
| | | 128 | static int |
122 | iic_match(device_t parent, cfdata_t cf, void *aux) | | 129 | iic_match(device_t parent, cfdata_t cf, void *aux) |
123 | { | | 130 | { |
124 | | | 131 | |
125 | return (1); | | 132 | return (1); |
126 | } | | 133 | } |
127 | | | 134 | |
128 | static void | | 135 | static void |
129 | iic_attach(device_t parent, device_t self, void *aux) | | 136 | iic_attach(device_t parent, device_t self, void *aux) |
130 | { | | 137 | { |
131 | struct iic_softc *sc = device_private(self); | | 138 | struct iic_softc *sc = device_private(self); |
132 | struct i2cbus_attach_args *iba = aux; | | 139 | struct i2cbus_attach_args *iba = aux; |
133 | prop_array_t child_devices; | | 140 | prop_array_t child_devices; |
134 | char *buf; | | 141 | char *buf; |
| @@ -265,27 +272,27 @@ iic_attach(device_t parent, device_t sel | | | @@ -265,27 +272,27 @@ iic_attach(device_t parent, device_t sel |
265 | config_found_sm_loc(self, "iic", loc, &ia, | | 272 | config_found_sm_loc(self, "iic", loc, &ia, |
266 | iic_print_direct, NULL); | | 273 | iic_print_direct, NULL); |
267 | | | 274 | |
268 | if (ia.ia_compat) | | 275 | if (ia.ia_compat) |
269 | free(ia.ia_compat, M_TEMP); | | 276 | free(ia.ia_compat, M_TEMP); |
270 | if (buf) | | 277 | if (buf) |
271 | free(buf, M_TEMP); | | 278 | free(buf, M_TEMP); |
272 | } | | 279 | } |
273 | } else { | | 280 | } else { |
274 | /* | | 281 | /* |
275 | * Attach all i2c devices described in the kernel | | 282 | * Attach all i2c devices described in the kernel |
276 | * configuration file. | | 283 | * configuration file. |
277 | */ | | 284 | */ |
278 | config_search_ia(iic_search, self, "iic", NULL); | | 285 | iic_rescan(self, "iic", NULL); |
279 | } | | 286 | } |
280 | } | | 287 | } |
281 | | | 288 | |
282 | static void | | 289 | static void |
283 | iic_smbus_intr_thread(void *aux) | | 290 | iic_smbus_intr_thread(void *aux) |
284 | { | | 291 | { |
285 | i2c_tag_t ic; | | 292 | i2c_tag_t ic; |
286 | struct ic_intr_list *il; | | 293 | struct ic_intr_list *il; |
287 | int rv; | | 294 | int rv; |
288 | | | 295 | |
289 | ic = (i2c_tag_t)aux; | | 296 | ic = (i2c_tag_t)aux; |
290 | ic->ic_running = 1; | | 297 | ic->ic_running = 1; |
291 | ic->ic_pending = 0; | | 298 | ic->ic_pending = 0; |
| @@ -419,15 +426,15 @@ iic_compat_match(struct i2c_attach_args | | | @@ -419,15 +426,15 @@ iic_compat_match(struct i2c_attach_args |
419 | { | | 426 | { |
420 | int i; | | 427 | int i; |
421 | | | 428 | |
422 | for (; compats && *compats; compats++) { | | 429 | for (; compats && *compats; compats++) { |
423 | for (i = 0; i < ia->ia_ncompat; i++) { | | 430 | for (i = 0; i < ia->ia_ncompat; i++) { |
424 | if (strcmp(*compats, ia->ia_compat[i]) == 0) | | 431 | if (strcmp(*compats, ia->ia_compat[i]) == 0) |
425 | return 1; | | 432 | return 1; |
426 | } | | 433 | } |
427 | } | | 434 | } |
428 | return 0; | | 435 | return 0; |
429 | } | | 436 | } |
430 | | | 437 | |
431 | | | 438 | |
432 | CFATTACH_DECL_NEW(iic, sizeof(struct iic_softc), | | 439 | CFATTACH_DECL2_NEW(iic, sizeof(struct iic_softc), |
433 | iic_match, iic_attach, NULL, NULL); | | 440 | iic_match, iic_attach, NULL, NULL, iic_rescan, NULL); |