xref: /openbsd/sys/dev/pci/vga_pci_common.c (revision 771fbea0)
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 #include <sys/malloc.h>
25 
26 #include <machine/bus.h>
27 
28 #include <dev/pci/pcireg.h>
29 #include <dev/pci/pcivar.h>
30 #include <dev/pci/pcidevs.h>
31 
32 #include <dev/ic/mc6845reg.h>
33 #include <dev/ic/pcdisplayvar.h>
34 #include <dev/ic/vgareg.h>
35 
36 #include <dev/wscons/wsdisplayvar.h>
37 #include <dev/ic/vgavar.h>
38 #include <dev/pci/vga_pcivar.h>
39 
40 #include <dev/pci/drm/i915/i915_devlist.h>
41 #include <dev/pci/drm/radeon/radeon_devlist.h>
42 #include <dev/pci/drm/amd/amdgpu/amdgpu_devlist.h>
43 
44 #ifdef RAMDISK_HOOKS
45 static const struct pci_matchid aperture_blacklist[] = {
46 	/* server adapters found in mga200 drm driver */
47 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200E_SE },
48 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200E_SE_B },
49 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200EH },
50 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200ER },
51 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200EV },
52 	{ PCI_VENDOR_MATROX,	PCI_PRODUCT_MATROX_G200EW },
53 
54 	/* server adapters found in ast drm driver */
55 	{ PCI_VENDOR_ASPEED,	PCI_PRODUCT_ASPEED_AST2000 },
56 	{ PCI_VENDOR_ASPEED,	PCI_PRODUCT_ASPEED_AST2100 },
57 
58 	/* ati adapters found in servers */
59 	{ PCI_VENDOR_ATI,		PCI_PRODUCT_ATI_RAGEXL },
60 	{ PCI_VENDOR_ATI,		PCI_PRODUCT_ATI_ES1000 },
61 
62 	/* xgi found in some poweredges/supermicros/tyans */
63 	{ PCI_VENDOR_XGI,		PCI_PRODUCT_XGI_VOLARI_Z7 },
64 	{ PCI_VENDOR_XGI,		PCI_PRODUCT_XGI_VOLARI_Z9 },
65 };
66 
67 int
68 vga_aperture_needed(struct pci_attach_args *pa)
69 {
70 	if (pci_matchbyid(pa, i915_devices, nitems(i915_devices)) ||
71 	    pci_matchbyid(pa, aperture_blacklist, nitems(aperture_blacklist)))
72 		return (0);
73 #if defined(__amd64__) || defined(__i386__) || defined(__loongson__) || \
74     defined(__macppc__) || defined(__sparc64__)
75 	if (pci_matchbyid(pa, radeon_devices, nitems(radeon_devices)))
76 		return (0);
77 #endif
78 #ifdef __amd64__
79 	if (pci_matchbyid(pa, amdgpu_devices, nitems(amdgpu_devices)))
80 		return (0);
81 #endif
82 	return (1);
83 }
84 #endif /* RAMDISK_HOOKS */
85