| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: hdaudio_pci.c,v 1.5 2010/02/24 22:38:08 dyoung Exp $ */ | | 1 | /* $NetBSD: hdaudio_pci.c,v 1.6 2010/08/07 16:59:48 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2009 Precedence Technologies Ltd <support@precedence.co.uk> | | 4 | * Copyright (c) 2009 Precedence Technologies Ltd <support@precedence.co.uk> |
5 | * Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca> | | 5 | * Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca> |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Precedence Technologies Ltd | | 9 | * by Precedence Technologies Ltd |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -24,41 +24,42 @@ | | | @@ -24,41 +24,42 @@ |
24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Intel High Definition Audio (Revision 1.0) device driver. | | 33 | * Intel High Definition Audio (Revision 1.0) device driver. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | __KERNEL_RCSID(0, "$NetBSD: hdaudio_pci.c,v 1.5 2010/02/24 22:38:08 dyoung Exp $"); | | 37 | __KERNEL_RCSID(0, "$NetBSD: hdaudio_pci.c,v 1.6 2010/08/07 16:59:48 jmcneill Exp $"); |
38 | | | 38 | |
39 | #include <sys/types.h> | | 39 | #include <sys/types.h> |
40 | #include <sys/param.h> | | 40 | #include <sys/param.h> |
41 | #include <sys/systm.h> | | 41 | #include <sys/systm.h> |
42 | #include <sys/device.h> | | 42 | #include <sys/device.h> |
43 | #include <sys/conf.h> | | 43 | #include <sys/conf.h> |
44 | #include <sys/bus.h> | | 44 | #include <sys/bus.h> |
45 | #include <sys/intr.h> | | 45 | #include <sys/intr.h> |
46 | | | 46 | |
47 | #include <dev/pci/pcidevs.h> | | 47 | #include <dev/pci/pcidevs.h> |
48 | #include <dev/pci/pcivar.h> | | 48 | #include <dev/pci/pcivar.h> |
49 | | | 49 | |
50 | #include <dev/pci/hdaudio/hdaudioreg.h> | | 50 | #include <dev/pci/hdaudio/hdaudioreg.h> |
51 | #include <dev/pci/hdaudio/hdaudiovar.h> | | 51 | #include <dev/pci/hdaudio/hdaudiovar.h> |
| | | 52 | #include <dev/pci/hdaudio/hdaudio_pci.h> |
52 | | | 53 | |
53 | struct hdaudio_pci_softc { | | 54 | struct hdaudio_pci_softc { |
54 | struct hdaudio_softc sc_hdaudio; /* must be first */ | | 55 | struct hdaudio_softc sc_hdaudio; /* must be first */ |
55 | pcitag_t sc_tag; | | 56 | pcitag_t sc_tag; |
56 | pci_chipset_tag_t sc_pc; | | 57 | pci_chipset_tag_t sc_pc; |
57 | void *sc_ih; | | 58 | void *sc_ih; |
58 | }; | | 59 | }; |
59 | | | 60 | |
60 | static int hdaudio_pci_match(device_t, cfdata_t, void *); | | 61 | static int hdaudio_pci_match(device_t, cfdata_t, void *); |
61 | static void hdaudio_pci_attach(device_t, device_t, void *); | | 62 | static void hdaudio_pci_attach(device_t, device_t, void *); |
62 | static int hdaudio_pci_detach(device_t, int); | | 63 | static int hdaudio_pci_detach(device_t, int); |
63 | static void hdaudio_pci_childdet(device_t, device_t); | | 64 | static void hdaudio_pci_childdet(device_t, device_t); |
64 | | | 65 | |
| @@ -143,26 +144,38 @@ hdaudio_pci_attach(device_t parent, devi | | | @@ -143,26 +144,38 @@ hdaudio_pci_attach(device_t parent, devi |
143 | hdaudio_pci_intr, sc); | | 144 | hdaudio_pci_intr, sc); |
144 | if (sc->sc_ih == NULL) { | | 145 | if (sc->sc_ih == NULL) { |
145 | aprint_error_dev(self, "couldn't establish interrupt"); | | 146 | aprint_error_dev(self, "couldn't establish interrupt"); |
146 | if (intrstr) | | 147 | if (intrstr) |
147 | aprint_error(" at %s", intrstr); | | 148 | aprint_error(" at %s", intrstr); |
148 | aprint_error("\n"); | | 149 | aprint_error("\n"); |
149 | return; | | 150 | return; |
150 | } | | 151 | } |
151 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | | 152 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); |
152 | | | 153 | |
153 | if (!pmf_device_register(self, NULL, hdaudio_pci_resume)) | | 154 | if (!pmf_device_register(self, NULL, hdaudio_pci_resume)) |
154 | aprint_error_dev(self, "couldn't establish power handler\n"); | | 155 | aprint_error_dev(self, "couldn't establish power handler\n"); |
155 | | | 156 | |
| | | 157 | switch (PCI_VENDOR(pa->pa_id)) { |
| | | 158 | case PCI_VENDOR_NVIDIA: |
| | | 159 | /* enable snooping */ |
| | | 160 | csr = pci_conf_read(sc->sc_pc, sc->sc_tag, |
| | | 161 | HDAUDIO_NV_REG_SNOOP); |
| | | 162 | csr &= ~HDAUDIO_NV_SNOOP_MASK; |
| | | 163 | csr |= HDAUDIO_NV_SNOOP_ENABLE; |
| | | 164 | pci_conf_write(sc->sc_pc, sc->sc_tag, |
| | | 165 | HDAUDIO_NV_REG_SNOOP, csr); |
| | | 166 | break; |
| | | 167 | } |
| | | 168 | |
156 | /* Attach bus-independent HD audio layer */ | | 169 | /* Attach bus-independent HD audio layer */ |
157 | hdaudio_attach(self, &sc->sc_hdaudio); | | 170 | hdaudio_attach(self, &sc->sc_hdaudio); |
158 | } | | 171 | } |
159 | | | 172 | |
160 | void | | 173 | void |
161 | hdaudio_pci_childdet(device_t self, device_t child) | | 174 | hdaudio_pci_childdet(device_t self, device_t child) |
162 | { | | 175 | { |
163 | #if notyet | | 176 | #if notyet |
164 | struct hdaudio_pci_softc *sc = device_private(self); | | 177 | struct hdaudio_pci_softc *sc = device_private(self); |
165 | | | 178 | |
166 | hdaudio_childdet(&sc->sc_hdaudio, child); | | 179 | hdaudio_childdet(&sc->sc_hdaudio, child); |
167 | #endif | | 180 | #endif |
168 | } | | 181 | } |