Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child acpi_devnodes will be claimed by that device so we don't later try to attach a duplicate device to that node at acpinodebus.diff -r1.1 -r1.2 src/sys/arch/arm/broadcom/bcm2835_bsc_acpi.c
(jmcneill)
--- src/sys/arch/arm/broadcom/bcm2835_bsc_acpi.c 2020/03/31 12:23:17 1.1
+++ src/sys/arch/arm/broadcom/bcm2835_bsc_acpi.c 2021/01/26 00:19:52 1.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bcm2835_bsc_acpi.c,v 1.1 2020/03/31 12:23:17 jmcneill Exp $ */ | 1 | /* $NetBSD: bcm2835_bsc_acpi.c,v 1.2 2021/01/26 00:19:52 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc_acpi.c,v 1.1 2020/03/31 12:23:17 jmcneill Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc_acpi.c,v 1.2 2021/01/26 00:19:52 jmcneill Exp $"); | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/bus.h> | 33 | #include <sys/bus.h> | |
34 | #include <sys/cpu.h> | 34 | #include <sys/cpu.h> | |
35 | #include <sys/device.h> | 35 | #include <sys/device.h> | |
36 | 36 | |||
37 | #include <dev/acpi/acpireg.h> | 37 | #include <dev/acpi/acpireg.h> | |
38 | #include <dev/acpi/acpivar.h> | 38 | #include <dev/acpi/acpivar.h> | |
39 | #include <dev/acpi/acpi_intr.h> | 39 | #include <dev/acpi/acpi_intr.h> | |
40 | #include <dev/acpi/acpi_i2c.h> | 40 | #include <dev/acpi/acpi_i2c.h> | |
41 | 41 | |||
42 | #include <arm/broadcom/bcm2835var.h> | 42 | #include <arm/broadcom/bcm2835var.h> | |
43 | #include <arm/broadcom/bcm2835_mbox.h> | 43 | #include <arm/broadcom/bcm2835_mbox.h> | |
@@ -150,27 +150,27 @@ bsciic_acpi_attach(device_t parent, devi | @@ -150,27 +150,27 @@ bsciic_acpi_attach(device_t parent, devi | |||
150 | if (ih == NULL) { | 150 | if (ih == NULL) { | |
151 | aprint_error_dev(self, "couldn't install interrupt handler\n"); | 151 | aprint_error_dev(self, "couldn't install interrupt handler\n"); | |
152 | goto done; | 152 | goto done; | |
153 | } | 153 | } | |
154 | 154 | |||
155 | iic_tag_init(&sc->sc_i2c); | 155 | iic_tag_init(&sc->sc_i2c); | |
156 | sc->sc_i2c.ic_cookie = sc; | 156 | sc->sc_i2c.ic_cookie = sc; | |
157 | sc->sc_i2c.ic_acquire_bus = bsciic_acquire_bus; | 157 | sc->sc_i2c.ic_acquire_bus = bsciic_acquire_bus; | |
158 | sc->sc_i2c.ic_release_bus = bsciic_release_bus; | 158 | sc->sc_i2c.ic_release_bus = bsciic_release_bus; | |
159 | sc->sc_i2c.ic_exec = bsciic_exec; | 159 | sc->sc_i2c.ic_exec = bsciic_exec; | |
160 | 160 | |||
161 | memset(&iba, 0, sizeof(iba)); | 161 | memset(&iba, 0, sizeof(iba)); | |
162 | iba.iba_tag = &sc->sc_i2c; | 162 | iba.iba_tag = &sc->sc_i2c; | |
163 | iba.iba_child_devices = acpi_enter_i2c_devs(aa->aa_node); | 163 | iba.iba_child_devices = acpi_enter_i2c_devs(self, aa->aa_node); | |
164 | config_found_ia(self, "i2cbus", &iba, iicbus_print); | 164 | config_found_ia(self, "i2cbus", &iba, iicbus_print); | |
165 | 165 | |||
166 | done: | 166 | done: | |
167 | acpi_resource_cleanup(&res); | 167 | acpi_resource_cleanup(&res); | |
168 | } | 168 | } | |
169 | 169 | |||
170 | static u_int | 170 | static u_int | |
171 | bsciic_acpi_vpu_clock_rate(void) | 171 | bsciic_acpi_vpu_clock_rate(void) | |
172 | { | 172 | { | |
173 | uint32_t res; | 173 | uint32_t res; | |
174 | int error; | 174 | int error; | |
175 | 175 | |||
176 | error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_vpu, | 176 | error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_vpu, |
--- src/sys/arch/x86/pci/dwiic_pci.c 2018/09/26 19:06:33 1.2
+++ src/sys/arch/x86/pci/dwiic_pci.c 2021/01/26 00:19:52 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dwiic_pci.c,v 1.2 2018/09/26 19:06:33 jakllsch Exp $ */ | 1 | /* $NetBSD: dwiic_pci.c,v 1.3 2021/01/26 00:19:52 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2017 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2017 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. | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
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 | * Synopsys DesignWare I2C controller, PCI front-end | 32 | * Synopsys DesignWare I2C controller, PCI front-end | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | __KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.2 2018/09/26 19:06:33 jakllsch Exp $"); | 36 | __KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.3 2021/01/26 00:19:52 jmcneill Exp $"); | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | 40 | |||
41 | #include <dev/pci/pcireg.h> | 41 | #include <dev/pci/pcireg.h> | |
42 | #include <dev/pci/pcivar.h> | 42 | #include <dev/pci/pcivar.h> | |
43 | #include <dev/pci/pcidevs.h> | 43 | #include <dev/pci/pcidevs.h> | |
44 | 44 | |||
45 | #include <dev/acpi/acpivar.h> | 45 | #include <dev/acpi/acpivar.h> | |
46 | #include <dev/acpi/acpi_pci.h> | 46 | #include <dev/acpi/acpi_pci.h> | |
47 | #include <dev/acpi/acpi_util.h> | 47 | #include <dev/acpi/acpi_util.h> | |
48 | #include <dev/acpi/acpi_i2c.h> | 48 | #include <dev/acpi/acpi_i2c.h> | |
49 | 49 | |||
@@ -160,27 +160,27 @@ pci_dwiic_attach(device_t parent, device | @@ -160,27 +160,27 @@ pci_dwiic_attach(device_t parent, device | |||
160 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | 160 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | |
161 | 161 | |||
162 | lpss_write(sc, LPSS_RESET, LPSS_RESET_CTRL_REL); | 162 | lpss_write(sc, LPSS_RESET, LPSS_RESET_CTRL_REL); | |
163 | lpss_write(sc, LPSS_REMAP_LO, | 163 | lpss_write(sc, LPSS_REMAP_LO, | |
164 | pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_BAR0)); | 164 | pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_BAR0)); | |
165 | lpss_write(sc, LPSS_REMAP_HI, | 165 | lpss_write(sc, LPSS_REMAP_HI, | |
166 | pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_BAR0 + 0x4)); | 166 | pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_BAR0 + 0x4)); | |
167 | 167 | |||
168 | sc->sc_acpinode = acpi_pcidev_find(0 /*XXX segment*/, | 168 | sc->sc_acpinode = acpi_pcidev_find(0 /*XXX segment*/, | |
169 | pa->pa_bus, pa->pa_device, pa->pa_function); | 169 | pa->pa_bus, pa->pa_device, pa->pa_function); | |
170 | 170 | |||
171 | if (sc->sc_acpinode) { | 171 | if (sc->sc_acpinode) { | |
172 | sc->sc_dwiic.sc_iba.iba_child_devices = | 172 | sc->sc_dwiic.sc_iba.iba_child_devices = | |
173 | acpi_enter_i2c_devs(sc->sc_acpinode); | 173 | acpi_enter_i2c_devs(NULL, sc->sc_acpinode); | |
174 | } else { | 174 | } else { | |
175 | aprint_verbose_dev(self, "no matching ACPI node\n"); | 175 | aprint_verbose_dev(self, "no matching ACPI node\n"); | |
176 | } | 176 | } | |
177 | 177 | |||
178 | dwiic_attach(&sc->sc_dwiic); | 178 | dwiic_attach(&sc->sc_dwiic); | |
179 | 179 | |||
180 | config_found_ia(self, "i2cbus", &sc->sc_dwiic.sc_iba, iicbus_print); | 180 | config_found_ia(self, "i2cbus", &sc->sc_dwiic.sc_iba, iicbus_print); | |
181 | 181 | |||
182 | pmf_device_register(self, dwiic_suspend, dwiic_resume); | 182 | pmf_device_register(self, dwiic_suspend, dwiic_resume); | |
183 | 183 | |||
184 | out: | 184 | out: | |
185 | return; | 185 | return; | |
186 | } | 186 | } |
--- src/sys/dev/acpi/acpi_i2c.c 2021/01/25 12:15:32 1.9
+++ src/sys/dev/acpi/acpi_i2c.c 2021/01/26 00:19:53 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_i2c.c,v 1.9 2021/01/25 12:15:32 jmcneill Exp $ */ | 1 | /* $NetBSD: acpi_i2c.c,v 1.10 2021/01/26 00:19:53 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2017 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2017 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. | |
@@ -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: acpi_i2c.c,v 1.9 2021/01/25 12:15:32 jmcneill Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.10 2021/01/26 00:19:53 jmcneill 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 | #define _COMPONENT ACPI_BUS_COMPONENT | 40 | #define _COMPONENT ACPI_BUS_COMPONENT | |
41 | ACPI_MODULE_NAME ("acpi_i2c") | 41 | ACPI_MODULE_NAME ("acpi_i2c") | |
42 | 42 | |||
43 | static void | 43 | static void | |
44 | acpi_enter_i2c_hid(struct acpi_devnode *devnode, prop_dictionary_t dev) | 44 | acpi_enter_i2c_hid(struct acpi_devnode *devnode, prop_dictionary_t dev) | |
45 | { | 45 | { | |
46 | ACPI_OBJECT_LIST arg; | 46 | ACPI_OBJECT_LIST arg; | |
@@ -215,30 +215,35 @@ acpi_enter_i2c_device(struct acpi_devnod | @@ -215,30 +215,35 @@ acpi_enter_i2c_device(struct acpi_devnod | |||
215 | i2c_id->compatlen); | 215 | i2c_id->compatlen); | |
216 | prop_dictionary_set(dev, "compatible", data); | 216 | prop_dictionary_set(dev, "compatible", data); | |
217 | prop_object_release(data); | 217 | prop_object_release(data); | |
218 | } | 218 | } | |
219 | if (i2c_id->parse != NULL) | 219 | if (i2c_id->parse != NULL) | |
220 | i2c_id->parse(ad, dev); | 220 | i2c_id->parse(ad, dev); | |
221 | } | 221 | } | |
222 | prop_array_add(array, dev); | 222 | prop_array_add(array, dev); | |
223 | prop_object_release(dev); | 223 | prop_object_release(dev); | |
224 | } | 224 | } | |
225 | 225 | |||
226 | 226 | |||
227 | prop_array_t | 227 | prop_array_t | |
228 | acpi_enter_i2c_devs(struct acpi_devnode *devnode) | 228 | acpi_enter_i2c_devs(device_t dev, struct acpi_devnode *devnode) | |
229 | { | 229 | { | |
230 | struct acpi_devnode *ad; | 230 | struct acpi_devnode *ad; | |
231 | prop_array_t array = prop_array_create(); | 231 | prop_array_t array = prop_array_create(); | |
232 | 232 | |||
233 | if (array == NULL) | 233 | if (array == NULL) | |
234 | return NULL; | 234 | return NULL; | |
235 | 235 | |||
236 | SIMPLEQ_FOREACH(ad, &devnode->ad_child_head, ad_child_list) { | 236 | SIMPLEQ_FOREACH(ad, &devnode->ad_child_head, ad_child_list) { | |
237 | if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE) | 237 | if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE) | |
238 | continue; | 238 | continue; | |
239 | if (!acpi_device_present(ad->ad_handle)) | 239 | if (!acpi_device_present(ad->ad_handle)) | |
240 | continue; | 240 | continue; | |
241 | acpi_enter_i2c_device(ad, array); | 241 | acpi_enter_i2c_device(ad, array); | |
242 | } | 242 | } | |
243 | ||||
244 | if (dev != NULL) { | |||
245 | acpi_claim_childdevs(dev, devnode); | |||
246 | } | |||
247 | ||||
243 | return array; | 248 | return array; | |
244 | } | 249 | } |
--- src/sys/dev/acpi/acpi_util.h 2021/01/14 14:35:53 1.9
+++ src/sys/dev/acpi/acpi_util.h 2021/01/26 00:19:53 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_util.h,v 1.9 2021/01/14 14:35:53 thorpej Exp $ */ | 1 | /* $NetBSD: acpi_util.h,v 1.10 2021/01/26 00:19:53 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2003, 2007 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 Charles M. Hannum of By Noon Software, Inc. | 8 | * by Charles M. Hannum of By Noon Software, Inc. | |
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. | |
@@ -92,14 +92,16 @@ char *acpi_pack_compat_list(ACPI_DEVICE | @@ -92,14 +92,16 @@ char *acpi_pack_compat_list(ACPI_DEVICE | |||
92 | 92 | |||
93 | ACPI_STATUS acpi_dsd_integer(ACPI_HANDLE, const char *, ACPI_INTEGER *); | 93 | ACPI_STATUS acpi_dsd_integer(ACPI_HANDLE, const char *, ACPI_INTEGER *); | |
94 | ACPI_STATUS acpi_dsd_string(ACPI_HANDLE, const char *, char **); | 94 | ACPI_STATUS acpi_dsd_string(ACPI_HANDLE, const char *, char **); | |
95 | 95 | |||
96 | ACPI_STATUS acpi_dsm(ACPI_HANDLE, uint8_t *, ACPI_INTEGER, | 96 | ACPI_STATUS acpi_dsm(ACPI_HANDLE, uint8_t *, ACPI_INTEGER, | |
97 | ACPI_INTEGER, const ACPI_OBJECT *, ACPI_OBJECT **); | 97 | ACPI_INTEGER, const ACPI_OBJECT *, ACPI_OBJECT **); | |
98 | ACPI_STATUS acpi_dsm_typed(ACPI_HANDLE, uint8_t *, ACPI_INTEGER, | 98 | ACPI_STATUS acpi_dsm_typed(ACPI_HANDLE, uint8_t *, ACPI_INTEGER, | |
99 | ACPI_INTEGER, const ACPI_OBJECT *, | 99 | ACPI_INTEGER, const ACPI_OBJECT *, | |
100 | ACPI_OBJECT_TYPE, ACPI_OBJECT **); | 100 | ACPI_OBJECT_TYPE, ACPI_OBJECT **); | |
101 | ACPI_STATUS acpi_dsm_integer(ACPI_HANDLE, uint8_t *, ACPI_INTEGER, | 101 | ACPI_STATUS acpi_dsm_integer(ACPI_HANDLE, uint8_t *, ACPI_INTEGER, | |
102 | ACPI_INTEGER, const ACPI_OBJECT *, | 102 | ACPI_INTEGER, const ACPI_OBJECT *, | |
103 | ACPI_INTEGER *); | 103 | ACPI_INTEGER *); | |
104 | 104 | |||
105 | ACPI_STATUS acpi_claim_childdevs(device_t, struct acpi_devnode *); | |||
106 | ||||
105 | #endif /* !_SYS_DEV_ACPI_ACPI_UTIL_H */ | 107 | #endif /* !_SYS_DEV_ACPI_ACPI_UTIL_H */ |
--- src/sys/dev/acpi/acpi_i2c.h 2017/12/10 16:51:30 1.1
+++ src/sys/dev/acpi/acpi_i2c.h 2021/01/26 00:19:53 1.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_i2c.h,v 1.1 2017/12/10 16:51:30 bouyer Exp $ */ | 1 | /* $NetBSD: acpi_i2c.h,v 1.2 2021/01/26 00:19:53 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2017 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2017 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. | |
@@ -24,15 +24,15 @@ | @@ -24,15 +24,15 @@ | |||
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 | 32 | |||
33 | #ifndef _SYS_DEV_ACPI_ACPI_I2C_H | 33 | #ifndef _SYS_DEV_ACPI_ACPI_I2C_H | |
34 | #define _SYS_DEV_ACPI_ACPI_I2C_H | 34 | #define _SYS_DEV_ACPI_ACPI_I2C_H | |
35 | #include <prop/proplib.h> | 35 | #include <prop/proplib.h> | |
36 | 36 | |||
37 | prop_array_t acpi_enter_i2c_devs(struct acpi_devnode *); | 37 | prop_array_t acpi_enter_i2c_devs(device_t, struct acpi_devnode *); | |
38 | #endif /* _SYS_DEV_ACPI_ACPI_I2C_H */ | 38 | #endif /* _SYS_DEV_ACPI_ACPI_I2C_H */ |
--- src/sys/dev/acpi/acpi_util.c 2021/01/14 14:35:53 1.20
+++ src/sys/dev/acpi/acpi_util.c 2021/01/26 00:19:53 1.21
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_util.c,v 1.20 2021/01/14 14:35:53 thorpej Exp $ */ | 1 | /* $NetBSD: acpi_util.c,v 1.21 2021/01/26 00:19:53 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2003, 2007, 2021 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2003, 2007, 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 Charles M. Hannum of By Noon Software, Inc. | 8 | * by Charles M. Hannum of By Noon Software, Inc. | |
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. | |
@@ -55,27 +55,27 @@ | @@ -55,27 +55,27 @@ | |||
55 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 55 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
56 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 56 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
57 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | 57 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | |
58 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 58 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
59 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 59 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
60 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 60 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
61 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 61 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
62 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 62 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
63 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 63 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
64 | * POSSIBILITY OF SUCH DAMAGE. | 64 | * POSSIBILITY OF SUCH DAMAGE. | |
65 | */ | 65 | */ | |
66 | 66 | |||
67 | #include <sys/cdefs.h> | 67 | #include <sys/cdefs.h> | |
68 | __KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.20 2021/01/14 14:35:53 thorpej Exp $"); | 68 | __KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.21 2021/01/26 00:19:53 jmcneill Exp $"); | |
69 | 69 | |||
70 | #include <sys/param.h> | 70 | #include <sys/param.h> | |
71 | #include <sys/kmem.h> | 71 | #include <sys/kmem.h> | |
72 | #include <sys/cpu.h> | 72 | #include <sys/cpu.h> | |
73 | 73 | |||
74 | #include <dev/acpi/acpireg.h> | 74 | #include <dev/acpi/acpireg.h> | |
75 | #include <dev/acpi/acpivar.h> | 75 | #include <dev/acpi/acpivar.h> | |
76 | #include <dev/acpi/acpi_intr.h> | 76 | #include <dev/acpi/acpi_intr.h> | |
77 | 77 | |||
78 | #include <machine/acpi_machdep.h> | 78 | #include <machine/acpi_machdep.h> | |
79 | 79 | |||
80 | #define _COMPONENT ACPI_BUS_COMPONENT | 80 | #define _COMPONENT ACPI_BUS_COMPONENT | |
81 | ACPI_MODULE_NAME ("acpi_util") | 81 | ACPI_MODULE_NAME ("acpi_util") | |
@@ -854,13 +854,29 @@ acpi_dsm_integer(ACPI_HANDLE handle, uin | @@ -854,13 +854,29 @@ acpi_dsm_integer(ACPI_HANDLE handle, uin | |||
854 | *ret = obj->Integer.Value; | 854 | *ret = obj->Integer.Value; | |
855 | ACPI_FREE(obj); | 855 | ACPI_FREE(obj); | |
856 | 856 | |||
857 | return AE_OK; | 857 | return AE_OK; | |
858 | } | 858 | } | |
859 | 859 | |||
860 | ACPI_STATUS | 860 | ACPI_STATUS | |
861 | acpi_dsm(ACPI_HANDLE handle, uint8_t *uuid, ACPI_INTEGER rev, | 861 | acpi_dsm(ACPI_HANDLE handle, uint8_t *uuid, ACPI_INTEGER rev, | |
862 | ACPI_INTEGER func, const ACPI_OBJECT *arg3, ACPI_OBJECT **return_obj) | 862 | ACPI_INTEGER func, const ACPI_OBJECT *arg3, ACPI_OBJECT **return_obj) | |
863 | { | 863 | { | |
864 | return acpi_dsm_typed(handle, uuid, rev, func, arg3, ACPI_TYPE_ANY, | 864 | return acpi_dsm_typed(handle, uuid, rev, func, arg3, ACPI_TYPE_ANY, | |
865 | return_obj); | 865 | return_obj); | |
866 | } | 866 | } | |
867 | ||||
868 | ACPI_STATUS | |||
869 | acpi_claim_childdevs(device_t dev, struct acpi_devnode *devnode) | |||
870 | { | |||
871 | struct acpi_devnode *ad; | |||
872 | ||||
873 | SIMPLEQ_FOREACH(ad, &devnode->ad_child_head, ad_child_list) { | |||
874 | if (ad->ad_device != NULL) | |||
875 | continue; | |||
876 | aprint_debug(dev, "claiming %s\n", acpi_name(ad->ad_handle)); | |||
877 | ad->ad_device = dev; | |||
878 | acpi_claim_childdevs(dev, ad); | |||
879 | } | |||
880 | ||||
881 | return AE_OK; | |||
882 | } |
--- src/sys/dev/acpi/dwiic_acpi.c 2021/01/24 16:33:48 1.5
+++ src/sys/dev/acpi/dwiic_acpi.c 2021/01/26 00:19:53 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dwiic_acpi.c,v 1.5 2021/01/24 16:33:48 jmcneill Exp $ */ | 1 | /* $NetBSD: dwiic_acpi.c,v 1.6 2021/01/26 00:19:53 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2018 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 Jared McNeill <jmcneill@invisible.ca>. | 8 | * by Jared McNeill <jmcneill@invisible.ca>. | |
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: dwiic_acpi.c,v 1.5 2021/01/24 16:33:48 jmcneill Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: dwiic_acpi.c,v 1.6 2021/01/26 00:19:53 jmcneill Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/bus.h> | 36 | #include <sys/bus.h> | |
37 | #include <sys/cpu.h> | 37 | #include <sys/cpu.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | 39 | |||
40 | #include <dev/acpi/acpireg.h> | 40 | #include <dev/acpi/acpireg.h> | |
41 | #include <dev/acpi/acpivar.h> | 41 | #include <dev/acpi/acpivar.h> | |
42 | #include <dev/acpi/acpi_intr.h> | 42 | #include <dev/acpi/acpi_intr.h> | |
43 | #include <dev/acpi/acpi_i2c.h> | 43 | #include <dev/acpi/acpi_i2c.h> | |
44 | 44 | |||
45 | #include <dev/ic/dwiic_var.h> | 45 | #include <dev/ic/dwiic_var.h> | |
46 | 46 | |||
@@ -118,27 +118,27 @@ dwiic_acpi_attach(device_t parent, devic | @@ -118,27 +118,27 @@ dwiic_acpi_attach(device_t parent, devic | |||
118 | } | 118 | } | |
119 | 119 | |||
120 | ih = acpi_intr_establish(self, | 120 | ih = acpi_intr_establish(self, | |
121 | (uint64_t)(uintptr_t)aa->aa_node->ad_handle, | 121 | (uint64_t)(uintptr_t)aa->aa_node->ad_handle, | |
122 | IPL_VM, true, dwiic_intr, sc, device_xname(self)); | 122 | IPL_VM, true, dwiic_intr, sc, device_xname(self)); | |
123 | if (ih == NULL) { | 123 | if (ih == NULL) { | |
124 | aprint_error_dev(self, "couldn't install interrupt handler\n"); | 124 | aprint_error_dev(self, "couldn't install interrupt handler\n"); | |
125 | bus_space_unmap(sc->sc_iot, sc->sc_ioh, mem->ar_length); | 125 | bus_space_unmap(sc->sc_iot, sc->sc_ioh, mem->ar_length); | |
126 | goto done; | 126 | goto done; | |
127 | } | 127 | } | |
128 | 128 | |||
129 | dwiic_acpi_configure(sc, aa->aa_node->ad_handle); | 129 | dwiic_acpi_configure(sc, aa->aa_node->ad_handle); | |
130 | 130 | |||
131 | sc->sc_iba.iba_child_devices = acpi_enter_i2c_devs(aa->aa_node); | 131 | sc->sc_iba.iba_child_devices = acpi_enter_i2c_devs(self, aa->aa_node); | |
132 | 132 | |||
133 | dwiic_attach(sc); | 133 | dwiic_attach(sc); | |
134 | 134 | |||
135 | config_found_ia(self, "i2cbus", &sc->sc_iba, iicbus_print); | 135 | config_found_ia(self, "i2cbus", &sc->sc_iba, iicbus_print); | |
136 | 136 | |||
137 | pmf_device_register(self, dwiic_suspend, dwiic_resume); | 137 | pmf_device_register(self, dwiic_suspend, dwiic_resume); | |
138 | 138 | |||
139 | done: | 139 | done: | |
140 | acpi_resource_cleanup(&res); | 140 | acpi_resource_cleanup(&res); | |
141 | } | 141 | } | |
142 | 142 | |||
143 | static void | 143 | static void | |
144 | dwiic_acpi_parse_param(struct dwiic_softc *sc, ACPI_HANDLE handle, const char *path, | 144 | dwiic_acpi_parse_param(struct dwiic_softc *sc, ACPI_HANDLE handle, const char *path, |
--- src/sys/dev/acpi/nxpiic_acpi.c 2021/01/25 12:09:58 1.2
+++ src/sys/dev/acpi/nxpiic_acpi.c 2021/01/26 00:19:53 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: nxpiic_acpi.c,v 1.2 2021/01/25 12:09:58 jmcneill Exp $ */ | 1 | /* $NetBSD: nxpiic_acpi.c,v 1.3 2021/01/26 00:19:53 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2021 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 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 Jared McNeill <jmcneill@invisible.ca>. | 8 | * by Jared McNeill <jmcneill@invisible.ca>. | |
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: nxpiic_acpi.c,v 1.2 2021/01/25 12:09:58 jmcneill Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: nxpiic_acpi.c,v 1.3 2021/01/26 00:19:53 jmcneill Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/bus.h> | 36 | #include <sys/bus.h> | |
37 | #include <sys/cpu.h> | 37 | #include <sys/cpu.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | 39 | |||
40 | #include <dev/acpi/acpireg.h> | 40 | #include <dev/acpi/acpireg.h> | |
41 | #include <dev/acpi/acpivar.h> | 41 | #include <dev/acpi/acpivar.h> | |
42 | #include <dev/acpi/acpi_intr.h> | 42 | #include <dev/acpi/acpi_intr.h> | |
43 | #include <dev/acpi/acpi_i2c.h> | 43 | #include <dev/acpi/acpi_i2c.h> | |
44 | 44 | |||
45 | #include <dev/i2c/motoi2cvar.h> | 45 | #include <dev/i2c/motoi2cvar.h> | |
46 | #include <dev/i2c/motoi2creg.h> | 46 | #include <dev/i2c/motoi2creg.h> | |
@@ -141,27 +141,27 @@ nxpiic_acpi_attach(device_t parent, devi | @@ -141,27 +141,27 @@ nxpiic_acpi_attach(device_t parent, devi | |||
141 | } | 141 | } | |
142 | 142 | |||
143 | settings.i2c_adr = MOTOI2C_ADR_DEFAULT; | 143 | settings.i2c_adr = MOTOI2C_ADR_DEFAULT; | |
144 | settings.i2c_dfsrr = MOTOI2C_DFSRR_DEFAULT; | 144 | settings.i2c_dfsrr = MOTOI2C_DFSRR_DEFAULT; | |
145 | for (n = 0; n < __arraycount(nxpiic_clk_div) - 1; n++) { | 145 | for (n = 0; n < __arraycount(nxpiic_clk_div) - 1; n++) { | |
146 | if (clock_freq / nxpiic_clk_div[n].scl_div < NXPIIC_SPEED_STD) | 146 | if (clock_freq / nxpiic_clk_div[n].scl_div < NXPIIC_SPEED_STD) | |
147 | break; | 147 | break; | |
148 | } | 148 | } | |
149 | settings.i2c_fdr = nxpiic_clk_div[n].ibc; | 149 | settings.i2c_fdr = nxpiic_clk_div[n].ibc; | |
150 | 150 | |||
151 | msc->sc_flags |= MOTOI2C_F_ENABLE_INV | MOTOI2C_F_STATUS_W1C; | 151 | msc->sc_flags |= MOTOI2C_F_ENABLE_INV | MOTOI2C_F_STATUS_W1C; | |
152 | msc->sc_iord = nxpiic_acpi_iord; | 152 | msc->sc_iord = nxpiic_acpi_iord; | |
153 | msc->sc_iowr = nxpiic_acpi_iowr; | 153 | msc->sc_iowr = nxpiic_acpi_iowr; | |
154 | msc->sc_child_devices = acpi_enter_i2c_devs(aa->aa_node); | 154 | msc->sc_child_devices = acpi_enter_i2c_devs(self, aa->aa_node); | |
155 | 155 | |||
156 | motoi2c_attach_common(self, msc, &settings); | 156 | motoi2c_attach_common(self, msc, &settings); | |
157 | 157 | |||
158 | done: | 158 | done: | |
159 | acpi_resource_cleanup(&res); | 159 | acpi_resource_cleanup(&res); | |
160 | 160 | |||
161 | } | 161 | } | |
162 | 162 | |||
163 | static uint8_t | 163 | static uint8_t | |
164 | nxpiic_acpi_iord(struct motoi2c_softc *msc, bus_size_t off) | 164 | nxpiic_acpi_iord(struct motoi2c_softc *msc, bus_size_t off) | |
165 | { | 165 | { | |
166 | KASSERT((off & 3) == 0); | 166 | KASSERT((off & 3) == 0); | |
167 | 167 |
--- src/sys/dev/i2c/i2cmux.c 2021/01/25 12:18:18 1.3
+++ src/sys/dev/i2c/i2cmux.c 2021/01/26 00:19:53 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: i2cmux.c,v 1.3 2021/01/25 12:18:18 jmcneill Exp $ */ | 1 | /* $NetBSD: i2cmux.c,v 1.4 2021/01/26 00:19:53 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. | |
@@ -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: i2cmux.c,v 1.3 2021/01/25 12:18:18 jmcneill Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.4 2021/01/26 00:19:53 jmcneill Exp $"); | |
38 | 38 | |||
39 | #include <sys/types.h> | 39 | #include <sys/types.h> | |
40 | #include <sys/device.h> | 40 | #include <sys/device.h> | |
41 | #include <sys/kernel.h> | 41 | #include <sys/kernel.h> | |
42 | #include <sys/kmem.h> | 42 | #include <sys/kmem.h> | |
43 | 43 | |||
44 | #include <dev/fdt/fdtvar.h> | 44 | #include <dev/fdt/fdtvar.h> | |
45 | #include <dev/i2c/i2cvar.h> | 45 | #include <dev/i2c/i2cvar.h> | |
46 | #include <dev/i2c/i2cmuxvar.h> | 46 | #include <dev/i2c/i2cmuxvar.h> | |
47 | 47 | |||
48 | #if NACPICA > 0 | 48 | #if NACPICA > 0 | |
49 | #include <dev/acpi/acpivar.h> | 49 | #include <dev/acpi/acpivar.h> | |
50 | #include <dev/acpi/acpi_i2c.h> | 50 | #include <dev/acpi/acpi_i2c.h> | |
@@ -189,27 +189,27 @@ iicmux_attach_bus(struct iicmux_softc * | @@ -189,27 +189,27 @@ iicmux_attach_bus(struct iicmux_softc * | |||
189 | case I2C_COOKIE_OF: | 189 | case I2C_COOKIE_OF: | |
190 | fdtbus_register_i2c_controller(&bus->controller, | 190 | fdtbus_register_i2c_controller(&bus->controller, | |
191 | (int)bus->handle); | 191 | (int)bus->handle); | |
192 | 192 | |||
193 | fdtbus_attach_i2cbus(sc->sc_dev, (int)bus->handle, | 193 | fdtbus_attach_i2cbus(sc->sc_dev, (int)bus->handle, | |
194 | &bus->controller, iicmux_print); | 194 | &bus->controller, iicmux_print); | |
195 | break; | 195 | break; | |
196 | #if NACPICA > 0 | 196 | #if NACPICA > 0 | |
197 | case I2C_COOKIE_ACPI: { | 197 | case I2C_COOKIE_ACPI: { | |
198 | struct acpi_devnode *ad = acpi_match_node((ACPI_HANDLE)handle); | 198 | struct acpi_devnode *ad = acpi_match_node((ACPI_HANDLE)handle); | |
199 | KASSERT(ad != NULL); | 199 | KASSERT(ad != NULL); | |
200 | struct i2cbus_attach_args iba = { | 200 | struct i2cbus_attach_args iba = { | |
201 | .iba_tag = &bus->controller, | 201 | .iba_tag = &bus->controller, | |
202 | .iba_child_devices = acpi_enter_i2c_devs(ad) | 202 | .iba_child_devices = acpi_enter_i2c_devs(NULL, ad) | |
203 | }; | 203 | }; | |
204 | config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print); | 204 | config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print); | |
205 | } break; | 205 | } break; | |
206 | #endif | 206 | #endif | |
207 | default: | 207 | default: | |
208 | aprint_error_dev(sc->sc_dev, "unknown handle type\n"); | 208 | aprint_error_dev(sc->sc_dev, "unknown handle type\n"); | |
209 | break; | 209 | break; | |
210 | } | 210 | } | |
211 | } | 211 | } | |
212 | 212 | |||
213 | static void | 213 | static void | |
214 | iicmux_attach_fdt(struct iicmux_softc * const sc) | 214 | iicmux_attach_fdt(struct iicmux_softc * const sc) | |
215 | { | 215 | { |