vga_pci.c revision 198964
1153577Sjhb/*-
2153577Sjhb * Copyright (c) 2005 John Baldwin <jhb@FreeBSD.org>
3153577Sjhb * All rights reserved.
4153577Sjhb *
5153577Sjhb * Redistribution and use in source and binary forms, with or without
6153577Sjhb * modification, are permitted provided that the following conditions
7153577Sjhb * are met:
8153577Sjhb * 1. Redistributions of source code must retain the above copyright
9153577Sjhb *    notice, this list of conditions and the following disclaimer.
10153577Sjhb * 2. Redistributions in binary form must reproduce the above copyright
11153577Sjhb *    notice, this list of conditions and the following disclaimer in the
12153577Sjhb *    documentation and/or other materials provided with the distribution.
13153577Sjhb * 3. Neither the name of the author nor the names of any co-contributors
14153577Sjhb *    may be used to endorse or promote products derived from this software
15153577Sjhb *    without specific prior written permission.
16153577Sjhb *
17153577Sjhb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18153577Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19153577Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20153577Sjhb * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21153577Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22153577Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23153577Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24153577Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25153577Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26153577Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27153577Sjhb * SUCH DAMAGE.
28153577Sjhb */
29153577Sjhb
30153577Sjhb#include <sys/cdefs.h>
31153577Sjhb__FBSDID("$FreeBSD: head/sys/dev/pci/vga_pci.c 198964 2009-11-05 22:58:50Z jkim $");
32153577Sjhb
33153577Sjhb/*
34153577Sjhb * Simple driver for PCI VGA display devices.  Drivers such as agp(4) and
35153577Sjhb * drm(4) should attach as children of this device.
36153577Sjhb *
37153577Sjhb * XXX: The vgapci name is a hack until we somehow merge the isa vga driver
38153577Sjhb * in or rename it.
39153577Sjhb */
40153577Sjhb
41153577Sjhb#include <sys/param.h>
42153577Sjhb#include <sys/bus.h>
43198964Sjkim#include <sys/fbio.h>
44153577Sjhb#include <sys/kernel.h>
45198964Sjkim#include <sys/malloc.h>
46153577Sjhb#include <sys/module.h>
47189373Sjhb#include <sys/rman.h>
48198251Sjkim#include <sys/sysctl.h>
49189373Sjhb#include <sys/systm.h>
50153577Sjhb
51198964Sjkim#include <dev/fb/fbreg.h>
52198964Sjkim#include <dev/fb/vgareg.h>
53198964Sjkim
54153577Sjhb#include <dev/pci/pcireg.h>
55153577Sjhb#include <dev/pci/pcivar.h>
56153577Sjhb
57189373Sjhbstruct vga_resource {
58189373Sjhb	struct resource	*vr_res;
59189373Sjhb	int	vr_refs;
60189373Sjhb};
61189373Sjhb
62183095Sjhbstruct vga_pci_softc {
63183095Sjhb	device_t	vga_msi_child;	/* Child driver using MSI. */
64189373Sjhb	struct vga_resource vga_res[PCIR_MAX_BAR_0 + 1];
65183095Sjhb};
66183095Sjhb
67198251SjkimSYSCTL_DECL(_hw_pci);
68198251Sjkim
69198251Sjkimint vga_pci_default_unit = -1;
70198251SjkimTUNABLE_INT("hw.pci.default_vgapci_unit", &vga_pci_default_unit);
71198964SjkimSYSCTL_INT(_hw_pci, OID_AUTO, default_vgapci_unit, CTLFLAG_RDTUN,
72198251Sjkim    &vga_pci_default_unit, -1, "Default VGA-compatible display");
73198251Sjkim
74153577Sjhbstatic int
75153577Sjhbvga_pci_probe(device_t dev)
76153577Sjhb{
77198251Sjkim	device_t bdev;
78198251Sjkim	int unit;
79198251Sjkim	uint16_t bctl;
80153577Sjhb
81153577Sjhb	switch (pci_get_class(dev)) {
82153577Sjhb	case PCIC_DISPLAY:
83153577Sjhb		break;
84153577Sjhb	case PCIC_OLD:
85153577Sjhb		if (pci_get_subclass(dev) != PCIS_OLD_VGA)
86153577Sjhb			return (ENXIO);
87153577Sjhb		break;
88153577Sjhb	default:
89153577Sjhb		return (ENXIO);
90153577Sjhb	}
91198251Sjkim
92198251Sjkim	/* Probe default display. */
93198251Sjkim	unit = device_get_unit(dev);
94198251Sjkim	bdev = device_get_parent(device_get_parent(dev));
95198251Sjkim	bctl = pci_read_config(bdev, PCIR_BRIDGECTL_1, 2);
96198251Sjkim	if (vga_pci_default_unit < 0 && (bctl & PCIB_BCR_VGA_ENABLE) != 0)
97198251Sjkim		vga_pci_default_unit = unit;
98198251Sjkim	if (vga_pci_default_unit == unit)
99198251Sjkim		device_set_flags(dev, 1);
100198251Sjkim
101153577Sjhb	device_set_desc(dev, "VGA-compatible display");
102153646Sjhb	return (BUS_PROBE_GENERIC);
103153577Sjhb}
104153577Sjhb
105153577Sjhbstatic int
106153577Sjhbvga_pci_attach(device_t dev)
107153577Sjhb{
108153577Sjhb
109153577Sjhb	bus_generic_probe(dev);
110153577Sjhb
111153577Sjhb	/* Always create a drm child for now to make it easier on drm. */
112153577Sjhb	device_add_child(dev, "drm", -1);
113153577Sjhb	bus_generic_attach(dev);
114153577Sjhb	return (0);
115153577Sjhb}
116153577Sjhb
117153577Sjhbstatic int
118153577Sjhbvga_pci_suspend(device_t dev)
119153577Sjhb{
120198964Sjkim	vga_softc_t *sc;
121198964Sjkim	devclass_t dc;
122198964Sjkim	int err, nbytes;
123153577Sjhb
124198964Sjkim	err = bus_generic_suspend(dev);
125198964Sjkim	if (err)
126198964Sjkim		return (err);
127198964Sjkim
128198964Sjkim	sc = NULL;
129198964Sjkim	if (device_get_unit(dev) == vga_pci_default_unit) {
130198964Sjkim		dc = devclass_find(VGA_DRIVER_NAME);
131198964Sjkim		if (dc != NULL)
132198964Sjkim			sc = devclass_get_softc(dc, 0);
133198964Sjkim	}
134198964Sjkim	if (sc == NULL)
135198964Sjkim		return (0);
136198964Sjkim
137198964Sjkim	/* Save the video state across the suspend. */
138198964Sjkim	if (sc->state_buf != NULL)
139198964Sjkim		goto save_palette;
140198964Sjkim	nbytes = vidd_save_state(sc->adp, NULL, 0);
141198964Sjkim	if (nbytes <= 0)
142198964Sjkim		goto save_palette;
143198964Sjkim	sc->state_buf = malloc(nbytes, M_TEMP, M_NOWAIT);
144198964Sjkim	if (sc->state_buf == NULL)
145198964Sjkim		goto save_palette;
146198964Sjkim	if (bootverbose)
147198964Sjkim		device_printf(dev, "saving %d bytes of video state\n", nbytes);
148198964Sjkim	if (vidd_save_state(sc->adp, sc->state_buf, nbytes) != 0) {
149198964Sjkim		device_printf(dev, "failed to save state (nbytes=%d)\n",
150198964Sjkim		    nbytes);
151198964Sjkim		free(sc->state_buf, M_TEMP);
152198964Sjkim		sc->state_buf = NULL;
153198964Sjkim	}
154198964Sjkim
155198964Sjkimsave_palette:
156198964Sjkim	/* Save the color palette across the suspend. */
157198964Sjkim	if (sc->pal_buf != NULL)
158198964Sjkim		return (0);
159198964Sjkim	sc->pal_buf = malloc(256 * 3, M_TEMP, M_NOWAIT);
160198964Sjkim	if (sc->pal_buf != NULL) {
161198964Sjkim		if (bootverbose)
162198964Sjkim			device_printf(dev, "saving color palette\n");
163198964Sjkim		if (vidd_save_palette(sc->adp, sc->pal_buf) != 0) {
164198964Sjkim			device_printf(dev, "failed to save palette\n");
165198964Sjkim			free(sc->pal_buf, M_TEMP);
166198964Sjkim			sc->pal_buf = NULL;
167198964Sjkim		}
168198964Sjkim	}
169198964Sjkim
170198964Sjkim	return (0);
171153577Sjhb}
172153577Sjhb
173153577Sjhbstatic int
174153577Sjhbvga_pci_resume(device_t dev)
175153577Sjhb{
176198964Sjkim	vga_softc_t *sc;
177198964Sjkim	devclass_t dc;
178153577Sjhb
179198964Sjkim	sc = NULL;
180198964Sjkim	if (device_get_unit(dev) == vga_pci_default_unit) {
181198964Sjkim		dc = devclass_find(VGA_DRIVER_NAME);
182198964Sjkim		if (dc != NULL)
183198964Sjkim			sc = devclass_get_softc(dc, 0);
184198964Sjkim	}
185198964Sjkim	if (sc == NULL)
186198964Sjkim		return (bus_generic_resume(dev));
187198964Sjkim
188198964Sjkim	if (sc->state_buf != NULL) {
189198964Sjkim		if (vidd_load_state(sc->adp, sc->state_buf) != 0)
190198964Sjkim			device_printf(dev, "failed to reload state\n");
191198964Sjkim		free(sc->state_buf, M_TEMP);
192198964Sjkim		sc->state_buf = NULL;
193198964Sjkim	}
194198964Sjkim	if (sc->pal_buf != NULL) {
195198964Sjkim		if (vidd_load_palette(sc->adp, sc->pal_buf) != 0)
196198964Sjkim			device_printf(dev, "failed to reload palette\n");
197198964Sjkim		free(sc->pal_buf, M_TEMP);
198198964Sjkim		sc->pal_buf = NULL;
199198964Sjkim	}
200198964Sjkim
201153577Sjhb	return (bus_generic_resume(dev));
202153577Sjhb}
203153577Sjhb
204153577Sjhb/* Bus interface. */
205153577Sjhb
206153577Sjhbstatic int
207153577Sjhbvga_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
208153577Sjhb{
209153577Sjhb
210153577Sjhb	return (BUS_READ_IVAR(device_get_parent(dev), dev, which, result));
211153577Sjhb}
212153577Sjhb
213153577Sjhbstatic int
214153577Sjhbvga_pci_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
215153577Sjhb{
216153577Sjhb
217153577Sjhb	return (EINVAL);
218153577Sjhb}
219153577Sjhb
220183194Srnolandstatic int
221183194Srnolandvga_pci_setup_intr(device_t dev, device_t child, struct resource *irq,
222183194Srnoland    int flags, driver_filter_t *filter, driver_intr_t *intr, void *arg,
223183194Srnoland    void **cookiep)
224183194Srnoland{
225183194Srnoland	return (BUS_SETUP_INTR(device_get_parent(dev), dev, irq, flags,
226183194Srnoland	    filter, intr, arg, cookiep));
227183194Srnoland}
228183194Srnoland
229183194Srnolandstatic int
230183194Srnolandvga_pci_teardown_intr(device_t dev, device_t child, struct resource *irq,
231183194Srnoland    void *cookie)
232183194Srnoland{
233183194Srnoland	return (BUS_TEARDOWN_INTR(device_get_parent(dev), dev, irq, cookie));
234183194Srnoland}
235183194Srnoland
236153577Sjhbstatic struct resource *
237153577Sjhbvga_pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
238153577Sjhb    u_long start, u_long end, u_long count, u_int flags)
239153577Sjhb{
240189373Sjhb	struct vga_pci_softc *sc;
241189373Sjhb	int bar;
242153577Sjhb
243189373Sjhb	switch (type) {
244189373Sjhb	case SYS_RES_MEMORY:
245189373Sjhb	case SYS_RES_IOPORT:
246189373Sjhb		/*
247189373Sjhb		 * For BARs, we cache the resource so that we only allocate it
248189373Sjhb		 * from the PCI bus once.
249189373Sjhb		 */
250189373Sjhb		bar = PCI_RID2BAR(*rid);
251189373Sjhb		if (bar < 0 || bar > PCIR_MAX_BAR_0)
252189373Sjhb			return (NULL);
253189373Sjhb		sc = device_get_softc(dev);
254189373Sjhb		if (sc->vga_res[bar].vr_res == NULL)
255189373Sjhb			sc->vga_res[bar].vr_res = bus_alloc_resource(dev, type,
256189373Sjhb			    rid, start, end, count, flags);
257189373Sjhb		if (sc->vga_res[bar].vr_res != NULL)
258189373Sjhb			sc->vga_res[bar].vr_refs++;
259189373Sjhb		return (sc->vga_res[bar].vr_res);
260189373Sjhb	}
261153577Sjhb	return (bus_alloc_resource(dev, type, rid, start, end, count, flags));
262153577Sjhb}
263153577Sjhb
264153577Sjhbstatic int
265153577Sjhbvga_pci_release_resource(device_t dev, device_t child, int type, int rid,
266153577Sjhb    struct resource *r)
267153577Sjhb{
268189373Sjhb	struct vga_pci_softc *sc;
269189373Sjhb	int bar, error;
270153577Sjhb
271189373Sjhb	switch (type) {
272189373Sjhb	case SYS_RES_MEMORY:
273189373Sjhb	case SYS_RES_IOPORT:
274189373Sjhb		/*
275189373Sjhb		 * For BARs, we release the resource from the PCI bus
276189373Sjhb		 * when the last child reference goes away.
277189373Sjhb		 */
278189373Sjhb		bar = PCI_RID2BAR(rid);
279189373Sjhb		if (bar < 0 || bar > PCIR_MAX_BAR_0)
280189373Sjhb			return (EINVAL);
281189373Sjhb		sc = device_get_softc(dev);
282189373Sjhb		if (sc->vga_res[bar].vr_res == NULL)
283189373Sjhb			return (EINVAL);
284189373Sjhb		KASSERT(sc->vga_res[bar].vr_res == r,
285189373Sjhb		    ("vga_pci resource mismatch"));
286189373Sjhb		if (sc->vga_res[bar].vr_refs > 1) {
287189373Sjhb			sc->vga_res[bar].vr_refs--;
288189373Sjhb			return (0);
289189373Sjhb		}
290189373Sjhb		KASSERT(sc->vga_res[bar].vr_refs > 0,
291189373Sjhb		    ("vga_pci resource reference count underflow"));
292189373Sjhb		error = bus_release_resource(dev, type, rid, r);
293189373Sjhb		if (error == 0) {
294189373Sjhb			sc->vga_res[bar].vr_res = NULL;
295189373Sjhb			sc->vga_res[bar].vr_refs = 0;
296189373Sjhb		}
297189373Sjhb		return (error);
298189373Sjhb	}
299189373Sjhb
300153577Sjhb	return (bus_release_resource(dev, type, rid, r));
301153577Sjhb}
302153577Sjhb
303153577Sjhb/* PCI interface. */
304153577Sjhb
305153577Sjhbstatic uint32_t
306153577Sjhbvga_pci_read_config(device_t dev, device_t child, int reg, int width)
307153577Sjhb{
308153577Sjhb
309153577Sjhb	return (pci_read_config(dev, reg, width));
310153577Sjhb}
311153577Sjhb
312153577Sjhbstatic void
313153577Sjhbvga_pci_write_config(device_t dev, device_t child, int reg,
314153577Sjhb    uint32_t val, int width)
315153577Sjhb{
316153577Sjhb
317153577Sjhb	pci_write_config(dev, reg, val, width);
318153577Sjhb}
319153577Sjhb
320153577Sjhbstatic int
321153577Sjhbvga_pci_enable_busmaster(device_t dev, device_t child)
322153577Sjhb{
323153577Sjhb
324153577Sjhb	device_printf(dev, "child %s requested pci_enable_busmaster\n",
325153577Sjhb	    device_get_nameunit(child));
326153577Sjhb	return (pci_enable_busmaster(dev));
327153577Sjhb}
328153577Sjhb
329153577Sjhbstatic int
330153577Sjhbvga_pci_disable_busmaster(device_t dev, device_t child)
331153577Sjhb{
332153577Sjhb
333153577Sjhb	device_printf(dev, "child %s requested pci_disable_busmaster\n",
334153577Sjhb	    device_get_nameunit(child));
335153577Sjhb	return (pci_disable_busmaster(dev));
336153577Sjhb}
337153577Sjhb
338153577Sjhbstatic int
339153577Sjhbvga_pci_enable_io(device_t dev, device_t child, int space)
340153577Sjhb{
341153577Sjhb
342153577Sjhb	device_printf(dev, "child %s requested pci_enable_io\n",
343153577Sjhb	    device_get_nameunit(child));
344153577Sjhb	return (pci_enable_io(dev, space));
345153577Sjhb}
346153577Sjhb
347153577Sjhbstatic int
348153577Sjhbvga_pci_disable_io(device_t dev, device_t child, int space)
349153577Sjhb{
350153577Sjhb
351153577Sjhb	device_printf(dev, "child %s requested pci_disable_io\n",
352153577Sjhb	    device_get_nameunit(child));
353153577Sjhb	return (pci_disable_io(dev, space));
354153577Sjhb}
355153577Sjhb
356153577Sjhbstatic int
357183095Sjhbvga_pci_get_vpd_ident(device_t dev, device_t child, const char **identptr)
358183095Sjhb{
359183095Sjhb
360183095Sjhb	return (pci_get_vpd_ident(dev, identptr));
361183095Sjhb}
362183095Sjhb
363183095Sjhbstatic int
364183095Sjhbvga_pci_get_vpd_readonly(device_t dev, device_t child, const char *kw,
365183095Sjhb    const char **vptr)
366183095Sjhb{
367183095Sjhb
368183095Sjhb	return (pci_get_vpd_readonly(dev, kw, vptr));
369183095Sjhb}
370183095Sjhb
371183095Sjhbstatic int
372153577Sjhbvga_pci_set_powerstate(device_t dev, device_t child, int state)
373153577Sjhb{
374153577Sjhb
375153577Sjhb	device_printf(dev, "child %s requested pci_set_powerstate\n",
376153577Sjhb	    device_get_nameunit(child));
377153577Sjhb	return (pci_set_powerstate(dev, state));
378153577Sjhb}
379153577Sjhb
380153577Sjhbstatic int
381153577Sjhbvga_pci_get_powerstate(device_t dev, device_t child)
382153577Sjhb{
383153577Sjhb
384153577Sjhb	device_printf(dev, "child %s requested pci_get_powerstate\n",
385153577Sjhb	    device_get_nameunit(child));
386153577Sjhb	return (pci_get_powerstate(dev));
387153577Sjhb}
388153577Sjhb
389153577Sjhbstatic int
390153577Sjhbvga_pci_assign_interrupt(device_t dev, device_t child)
391153577Sjhb{
392153577Sjhb
393153577Sjhb	device_printf(dev, "child %s requested pci_assign_interrupt\n",
394153577Sjhb	    device_get_nameunit(child));
395153577Sjhb	return (PCI_ASSIGN_INTERRUPT(device_get_parent(dev), dev));
396153577Sjhb}
397153577Sjhb
398153577Sjhbstatic int
399153577Sjhbvga_pci_find_extcap(device_t dev, device_t child, int capability,
400153577Sjhb    int *capreg)
401153577Sjhb{
402153577Sjhb
403153577Sjhb	return (pci_find_extcap(dev, capability, capreg));
404153577Sjhb}
405153577Sjhb
406183095Sjhbstatic int
407183095Sjhbvga_pci_alloc_msi(device_t dev, device_t child, int *count)
408183095Sjhb{
409183095Sjhb	struct vga_pci_softc *sc;
410183095Sjhb	int error;
411183095Sjhb
412183095Sjhb	sc = device_get_softc(dev);
413183095Sjhb	if (sc->vga_msi_child != NULL)
414183095Sjhb		return (EBUSY);
415183095Sjhb	error = pci_alloc_msi(dev, count);
416183095Sjhb	if (error == 0)
417183095Sjhb		sc->vga_msi_child = child;
418183095Sjhb	return (error);
419183095Sjhb}
420183095Sjhb
421183095Sjhbstatic int
422183095Sjhbvga_pci_alloc_msix(device_t dev, device_t child, int *count)
423183095Sjhb{
424183095Sjhb	struct vga_pci_softc *sc;
425183095Sjhb	int error;
426183095Sjhb
427183095Sjhb	sc = device_get_softc(dev);
428183095Sjhb	if (sc->vga_msi_child != NULL)
429183095Sjhb		return (EBUSY);
430183095Sjhb	error = pci_alloc_msix(dev, count);
431183095Sjhb	if (error == 0)
432183095Sjhb		sc->vga_msi_child = child;
433183095Sjhb	return (error);
434183095Sjhb}
435183095Sjhb
436183095Sjhbstatic int
437183095Sjhbvga_pci_remap_msix(device_t dev, device_t child, int count,
438183095Sjhb    const u_int *vectors)
439183095Sjhb{
440183095Sjhb	struct vga_pci_softc *sc;
441183095Sjhb
442183095Sjhb	sc = device_get_softc(dev);
443183095Sjhb	if (sc->vga_msi_child != child)
444183095Sjhb		return (ENXIO);
445183095Sjhb	return (pci_remap_msix(dev, count, vectors));
446183095Sjhb}
447183095Sjhb
448183095Sjhbstatic int
449183095Sjhbvga_pci_release_msi(device_t dev, device_t child)
450183095Sjhb{
451183095Sjhb	struct vga_pci_softc *sc;
452183095Sjhb	int error;
453183095Sjhb
454183095Sjhb	sc = device_get_softc(dev);
455183095Sjhb	if (sc->vga_msi_child != child)
456183095Sjhb		return (ENXIO);
457183095Sjhb	error = pci_release_msi(dev);
458183095Sjhb	if (error == 0)
459183095Sjhb		sc->vga_msi_child = NULL;
460183095Sjhb	return (error);
461183095Sjhb}
462183095Sjhb
463183095Sjhbstatic int
464183095Sjhbvga_pci_msi_count(device_t dev, device_t child)
465183095Sjhb{
466183095Sjhb
467183095Sjhb	return (pci_msi_count(dev));
468183095Sjhb}
469183095Sjhb
470183095Sjhbstatic int
471183095Sjhbvga_pci_msix_count(device_t dev, device_t child)
472183095Sjhb{
473183095Sjhb
474183095Sjhb	return (pci_msix_count(dev));
475183095Sjhb}
476183095Sjhb
477153577Sjhbstatic device_method_t vga_pci_methods[] = {
478153577Sjhb	/* Device interface */
479153577Sjhb	DEVMETHOD(device_probe,		vga_pci_probe),
480153577Sjhb	DEVMETHOD(device_attach,	vga_pci_attach),
481153577Sjhb	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
482153577Sjhb	DEVMETHOD(device_suspend,	vga_pci_suspend),
483153577Sjhb	DEVMETHOD(device_resume,	vga_pci_resume),
484153577Sjhb
485153577Sjhb	/* Bus interface */
486153577Sjhb	DEVMETHOD(bus_read_ivar,	vga_pci_read_ivar),
487153577Sjhb	DEVMETHOD(bus_write_ivar,	vga_pci_write_ivar),
488183194Srnoland	DEVMETHOD(bus_setup_intr,	vga_pci_setup_intr),
489183194Srnoland	DEVMETHOD(bus_teardown_intr,	vga_pci_teardown_intr),
490153577Sjhb
491153577Sjhb	DEVMETHOD(bus_alloc_resource,	vga_pci_alloc_resource),
492153577Sjhb	DEVMETHOD(bus_release_resource,	vga_pci_release_resource),
493153577Sjhb	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
494153577Sjhb	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
495153577Sjhb
496153577Sjhb	/* PCI interface */
497153577Sjhb	DEVMETHOD(pci_read_config,	vga_pci_read_config),
498153577Sjhb	DEVMETHOD(pci_write_config,	vga_pci_write_config),
499153577Sjhb	DEVMETHOD(pci_enable_busmaster,	vga_pci_enable_busmaster),
500153577Sjhb	DEVMETHOD(pci_disable_busmaster, vga_pci_disable_busmaster),
501153577Sjhb	DEVMETHOD(pci_enable_io,	vga_pci_enable_io),
502153577Sjhb	DEVMETHOD(pci_disable_io,	vga_pci_disable_io),
503183095Sjhb	DEVMETHOD(pci_get_vpd_ident,	vga_pci_get_vpd_ident),
504183095Sjhb	DEVMETHOD(pci_get_vpd_readonly,	vga_pci_get_vpd_readonly),
505153577Sjhb	DEVMETHOD(pci_get_powerstate,	vga_pci_get_powerstate),
506153577Sjhb	DEVMETHOD(pci_set_powerstate,	vga_pci_set_powerstate),
507153577Sjhb	DEVMETHOD(pci_assign_interrupt,	vga_pci_assign_interrupt),
508153577Sjhb	DEVMETHOD(pci_find_extcap,	vga_pci_find_extcap),
509183095Sjhb	DEVMETHOD(pci_alloc_msi,	vga_pci_alloc_msi),
510183095Sjhb	DEVMETHOD(pci_alloc_msix,	vga_pci_alloc_msix),
511183095Sjhb	DEVMETHOD(pci_remap_msix,	vga_pci_remap_msix),
512183095Sjhb	DEVMETHOD(pci_release_msi,	vga_pci_release_msi),
513183095Sjhb	DEVMETHOD(pci_msi_count,	vga_pci_msi_count),
514183095Sjhb	DEVMETHOD(pci_msix_count,	vga_pci_msix_count),
515153577Sjhb
516153577Sjhb	{ 0, 0 }
517153577Sjhb};
518153577Sjhb
519153577Sjhbstatic driver_t vga_pci_driver = {
520153577Sjhb	"vgapci",
521153577Sjhb	vga_pci_methods,
522183095Sjhb	sizeof(struct vga_pci_softc),
523153577Sjhb};
524153577Sjhb
525153577Sjhbstatic devclass_t vga_devclass;
526153577Sjhb
527153577SjhbDRIVER_MODULE(vgapci, pci, vga_pci_driver, vga_devclass, 0, 0);
528