| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: nouveau_pci.c,v 1.24 2019/07/03 20:47:22 wiz Exp $ */ | | 1 | /* $NetBSD: nouveau_pci.c,v 1.25 2019/10/05 22:37:49 mrg Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2015 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2015 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 Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
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: nouveau_pci.c,v 1.24 2019/07/03 20:47:22 wiz Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: nouveau_pci.c,v 1.25 2019/10/05 22:37:49 mrg Exp $"); |
34 | | | 34 | |
35 | #include <sys/types.h> | | 35 | #include <sys/types.h> |
36 | #include <sys/device.h> | | 36 | #include <sys/device.h> |
37 | #include <sys/queue.h> | | 37 | #include <sys/queue.h> |
38 | #include <sys/workqueue.h> | | 38 | #include <sys/workqueue.h> |
39 | #include <sys/module.h> | | 39 | #include <sys/module.h> |
40 | | | 40 | |
41 | #include <drm/drmP.h> | | 41 | #include <drm/drmP.h> |
42 | | | 42 | |
43 | #include <core/device.h> | | 43 | #include <core/device.h> |
44 | #include <core/pci.h> | | 44 | #include <core/pci.h> |
45 | | | 45 | |
46 | #include "nouveau_drm.h" | | 46 | #include "nouveau_drm.h" |
| @@ -87,54 +87,48 @@ nouveau_pci_match(device_t parent, cfdat | | | @@ -87,54 +87,48 @@ nouveau_pci_match(device_t parent, cfdat |
87 | { | | 87 | { |
88 | const struct pci_attach_args *const pa = aux; | | 88 | const struct pci_attach_args *const pa = aux; |
89 | struct pci_dev pdev; | | 89 | struct pci_dev pdev; |
90 | struct nvkm_device *device; | | 90 | struct nvkm_device *device; |
91 | int ret; | | 91 | int ret; |
92 | | | 92 | |
93 | if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_NVIDIA && | | 93 | if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_NVIDIA && |
94 | PCI_VENDOR(pa->pa_id) != PCI_VENDOR_NVIDIA_SGS) | | 94 | PCI_VENDOR(pa->pa_id) != PCI_VENDOR_NVIDIA_SGS) |
95 | return 0; | | 95 | return 0; |
96 | | | 96 | |
97 | if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY) | | 97 | if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY) |
98 | return 0; | | 98 | return 0; |
99 | | | 99 | |
100 | #define IS_BETWEEN(x,y) \ | | | |
101 | (PCI_PRODUCT(pa->pa_id) >= (x) && PCI_PRODUCT(pa->pa_id) <= (y)) | | | |
102 | /* | | 100 | /* |
103 | * NetBSD drm2 doesn't support Pascal, Volta or Turing based cards: | | 101 | * NetBSD drm2 doesn't support Pascal, Volta or Turing based cards: |
104 | * 0x1580-0x15ff GP100 | | 102 | * 0x1580-0x15ff GP100 |
105 | * 0x1b00-0x1b7f GP102 | | 103 | * 0x1b00-0x1b7f GP102 |
106 | * 0x1b80-0x1bff GP104 | | 104 | * 0x1b80-0x1bff GP104 |
107 | * 0x1c00-0x1c7f GP106 | | 105 | * 0x1c00-0x1c7f GP106 |
108 | * 0x1c80-0x1cff GP107 | | 106 | * 0x1c80-0x1cff GP107 |
109 | * 0x1d00-0x1d7f GP108 | | 107 | * 0x1d00-0x1d7f GP108 |
110 | * 0x1d80-0x1dff GV100 | | 108 | * 0x1d80-0x1dff GV100 |
111 | * 0x1e00-0x1e7f TU102 | | 109 | * 0x1e00-0x1e7f TU102 |
112 | * 0x1e80-0x1eff TU104 | | 110 | * 0x1e80-0x1eff TU104 |
113 | * 0x1f00-0x1f7f TU106 | | 111 | * 0x1f00-0x1f7f TU106 |
| | | 112 | * 0x1f80-0x1fff TU117 |
| | | 113 | * 0x2180-0x21ff TU116 |
| | | 114 | * |
| | | 115 | * reduce this to >= 1580, so that new chipsets not explictly |
| | | 116 | * listed above will be picked up. |
| | | 117 | * |
| | | 118 | * XXX perhaps switch this to explicitly match known list. |
114 | */ | | 119 | */ |
115 | | | 120 | if (PCI_PRODUCT(pa->pa_id) >= 0x1580) |
116 | if (IS_BETWEEN(0x1580, 0x15ff) || | | | |
117 | IS_BETWEEN(0x1b00, 0x1b7f) || | | | |
118 | IS_BETWEEN(0x1b80, 0x1bff) || | | | |
119 | IS_BETWEEN(0x1c00, 0x1c7f) || | | | |
120 | IS_BETWEEN(0x1c80, 0x1cff) || | | | |
121 | IS_BETWEEN(0x1d00, 0x1d7f) || | | | |
122 | IS_BETWEEN(0x1d80, 0x1dff) || | | | |
123 | IS_BETWEEN(0x1e00, 0x1e7f) || | | | |
124 | IS_BETWEEN(0x1e80, 0x1eff) || | | | |
125 | IS_BETWEEN(0x1f00, 0x1f7f)) | | | |
126 | return 0; | | 121 | return 0; |
127 | #undef IS_BETWEEN | | | |
128 | | | 122 | |
129 | linux_pci_dev_init(&pdev, parent /* XXX bogus */, parent, pa, 0); | | 123 | linux_pci_dev_init(&pdev, parent /* XXX bogus */, parent, pa, 0); |
130 | ret = nvkm_device_pci_new(&pdev, NULL, "error", | | 124 | ret = nvkm_device_pci_new(&pdev, NULL, "error", |
131 | /* detect */ true, /* mmio */ false, /* subdev_mask */ 0, &device); | | 125 | /* detect */ true, /* mmio */ false, /* subdev_mask */ 0, &device); |
132 | if (ret == 0) /* don't want to hang onto it */ | | 126 | if (ret == 0) /* don't want to hang onto it */ |
133 | nvkm_device_del(&device); | | 127 | nvkm_device_del(&device); |
134 | linux_pci_dev_destroy(&pdev); | | 128 | linux_pci_dev_destroy(&pdev); |
135 | if (ret) /* failure */ | | 129 | if (ret) /* failure */ |
136 | return 0; | | 130 | return 0; |
137 | | | 131 | |
138 | return 6; /* XXX Beat genfb_pci... */ | | 132 | return 6; /* XXX Beat genfb_pci... */ |
139 | } | | 133 | } |
140 | | | 134 | |