| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: virtio_acpi.c,v 1.2 2018/11/16 23:18:17 jmcneill Exp $ */ | | 1 | /* $NetBSD: virtio_acpi.c,v 1.3 2020/10/24 07:21:01 skrll 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: virtio_acpi.c,v 1.2 2018/11/16 23:18:17 jmcneill Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: virtio_acpi.c,v 1.3 2020/10/24 07:21:01 skrll 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 | | | 43 | |
44 | #define VIRTIO_PRIVATE | | 44 | #define VIRTIO_PRIVATE |
45 | #include <dev/virtio/virtio_mmiovar.h> | | 45 | #include <dev/virtio/virtio_mmiovar.h> |
46 | | | 46 | |
| @@ -85,27 +85,34 @@ virtio_acpi_attach(device_t parent, devi | | | @@ -85,27 +85,34 @@ virtio_acpi_attach(device_t parent, devi |
85 | struct virtio_acpi_softc * const sc = device_private(self); | | 85 | struct virtio_acpi_softc * const sc = device_private(self); |
86 | struct virtio_mmio_softc * const msc = &sc->sc_msc; | | 86 | struct virtio_mmio_softc * const msc = &sc->sc_msc; |
87 | struct virtio_softc * const vsc = &msc->sc_sc; | | 87 | struct virtio_softc * const vsc = &msc->sc_sc; |
88 | struct acpi_attach_args *aa = aux; | | 88 | struct acpi_attach_args *aa = aux; |
89 | struct acpi_resources res; | | 89 | struct acpi_resources res; |
90 | struct acpi_mem *mem; | | 90 | struct acpi_mem *mem; |
91 | struct acpi_irq *irq; | | 91 | struct acpi_irq *irq; |
92 | ACPI_STATUS rv; | | 92 | ACPI_STATUS rv; |
93 | int error; | | 93 | int error; |
94 | | | 94 | |
95 | sc->sc_handle = aa->aa_node->ad_handle; | | 95 | sc->sc_handle = aa->aa_node->ad_handle; |
96 | msc->sc_iot = aa->aa_memt; | | 96 | msc->sc_iot = aa->aa_memt; |
97 | vsc->sc_dev = self; | | 97 | vsc->sc_dev = self; |
98 | vsc->sc_dmat = aa->aa_dmat; | | 98 | |
| | | 99 | if (BUS_DMA_TAG_VALID(aa->aa_dmat64)) { |
| | | 100 | aprint_verbose(": using 64-bit DMA"); |
| | | 101 | vsc->sc_dmat = aa->aa_dmat64; |
| | | 102 | } else { |
| | | 103 | aprint_verbose(": using 32-bit DMA"); |
| | | 104 | vsc->sc_dmat = aa->aa_dmat; |
| | | 105 | } |
99 | | | 106 | |
100 | rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", | | 107 | rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", |
101 | &res, &acpi_resource_parse_ops_default); | | 108 | &res, &acpi_resource_parse_ops_default); |
102 | if (ACPI_FAILURE(rv)) | | 109 | if (ACPI_FAILURE(rv)) |
103 | return; | | 110 | return; |
104 | | | 111 | |
105 | mem = acpi_res_mem(&res, 0); | | 112 | mem = acpi_res_mem(&res, 0); |
106 | if (mem == NULL) { | | 113 | if (mem == NULL) { |
107 | aprint_error_dev(self, "couldn't find mem resource\n"); | | 114 | aprint_error_dev(self, "couldn't find mem resource\n"); |
108 | goto done; | | 115 | goto done; |
109 | } | | 116 | } |
110 | | | 117 | |
111 | irq = acpi_res_irq(&res, 0); | | 118 | irq = acpi_res_irq(&res, 0); |