xref: /openbsd-src/sys/dev/pci/vga_pci_common.c (revision 7c0ec4b8992567abb1e1536622dc789a9a39d9f1)
1 /*
2  * Copyright (c) 2008 Owain G. Ainsworth <oga@nicotinebsd.org>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #include "vga.h"
18 #if defined(__i386__) || defined(__amd64__)
19 #include "acpi.h"
20 #endif
21 
22 #include <sys/param.h>
23 #include <sys/systm.h>
24 
25 #include <machine/bus.h>
26 
27 #include <dev/pci/pcireg.h>
28 #include <dev/pci/pcivar.h>
29 #include <dev/pci/pcidevs.h>
30 
31 #include <dev/ic/mc6845reg.h>
32 #include <dev/ic/pcdisplayvar.h>
33 #include <dev/ic/vgareg.h>
34 
35 #include <dev/wscons/wsdisplayvar.h>
36 #include <dev/ic/vgavar.h>
37 #include <dev/pci/vga_pcivar.h>
38 
39 #include <dev/pci/drm/i915/i915_devlist.h>
40 #include <dev/pci/drm/radeon/radeon_devlist.h>
41 #include <dev/pci/drm/amd/amdgpu/amdgpu_devlist.h>
42 
43 #ifdef RAMDISK_HOOKS
44 static const struct pci_matchid aperture_blacklist[] = {
45 	/* server adapters found in mga200 drm driver */
46 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200E_SE },
47 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200E_SE_B },
48 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200EH },
49 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200ER },
50 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200EV },
51 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200EW },
52 
53 	/* server adapters found in ast drm driver */
54 	{ PCI_VENDOR_ASPEED,	PCI_PRODUCT_ASPEED_AST2000 },
55 	{ PCI_VENDOR_ASPEED,	PCI_PRODUCT_ASPEED_AST2100 },
56 
57 	/* ati adapters found in servers */
58 	{ PCI_VENDOR_ATI,		PCI_PRODUCT_ATI_RAGEXL },
59 	{ PCI_VENDOR_ATI,		PCI_PRODUCT_ATI_ES1000 },
60 
61 	/* xgi found in some poweredges/supermicros/tyans */
62 	{ PCI_VENDOR_XGI,		PCI_PRODUCT_XGI_VOLARI_Z7 },
63 	{ PCI_VENDOR_XGI,		PCI_PRODUCT_XGI_VOLARI_Z9 },
64 };
65 
66 int
67 vga_aperture_needed(struct pci_attach_args *pa)
68 {
69 	if (pci_matchbyid(pa, i915_devices, nitems(i915_devices)) ||
70 	    pci_matchbyid(pa, aperture_blacklist, nitems(aperture_blacklist)))
71 		return (0);
72 #if defined(__amd64__) || defined(__i386__) || defined(__loongson__) || \
73     defined(__macppc__) || defined(__sparc64__)
74 	if (pci_matchbyid(pa, radeon_devices, nitems(radeon_devices)))
75 		return (0);
76 #endif
77 #ifdef __amd64__
78 	if (pci_matchbyid(pa, amdgpu_devices, nitems(amdgpu_devices)))
79 		return (0);
80 #endif
81 	return (1);
82 }
83 #endif /* RAMDISK_HOOKS */
84