vga_pci.c revision 255571
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 255571 2013-09-14 17:17:32Z dumbbell $"); 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> 43153577Sjhb#include <sys/kernel.h> 44153577Sjhb#include <sys/module.h> 45189373Sjhb#include <sys/rman.h> 46198251Sjkim#include <sys/sysctl.h> 47189373Sjhb#include <sys/systm.h> 48153577Sjhb 49254882Sdumbbell#if defined(__amd64__) || defined(__i386__) || defined(__ia64__) 50254882Sdumbbell#include <vm/vm.h> 51254882Sdumbbell#include <vm/pmap.h> 52254882Sdumbbell#endif 53254882Sdumbbell 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. */ 64249315Sjhb struct vga_resource vga_bars[PCIR_MAX_BAR_0 + 1]; 65249315Sjhb struct vga_resource vga_bios; 66183095Sjhb}; 67183095Sjhb 68198251SjkimSYSCTL_DECL(_hw_pci); 69198251Sjkim 70255571Sdumbbellstatic struct vga_resource *lookup_res(struct vga_pci_softc *sc, int rid); 71255571Sdumbbellstatic struct resource *vga_pci_alloc_resource(device_t dev, device_t child, 72255571Sdumbbell int type, int *rid, u_long start, u_long end, u_long count, u_int flags); 73255571Sdumbbellstatic int vga_pci_release_resource(device_t dev, device_t child, int type, 74255571Sdumbbell int rid, struct resource *r); 75255571Sdumbbell 76198251Sjkimint vga_pci_default_unit = -1; 77198251SjkimTUNABLE_INT("hw.pci.default_vgapci_unit", &vga_pci_default_unit); 78198964SjkimSYSCTL_INT(_hw_pci, OID_AUTO, default_vgapci_unit, CTLFLAG_RDTUN, 79198251Sjkim &vga_pci_default_unit, -1, "Default VGA-compatible display"); 80198251Sjkim 81254882Sdumbbellint 82254882Sdumbbellvga_pci_is_boot_display(device_t dev) 83254882Sdumbbell{ 84254882Sdumbbell 85254882Sdumbbell /* 86254882Sdumbbell * Return true if the given device is the default display used 87254882Sdumbbell * at boot time. 88254882Sdumbbell */ 89254882Sdumbbell return ( 90254882Sdumbbell (pci_get_class(dev) == PCIC_DISPLAY || 91254882Sdumbbell (pci_get_class(dev) == PCIC_OLD && 92254882Sdumbbell pci_get_subclass(dev) == PCIS_OLD_VGA)) && 93254882Sdumbbell device_get_unit(dev) == vga_pci_default_unit); 94254882Sdumbbell} 95254882Sdumbbell 96254882Sdumbbellvoid * 97254882Sdumbbellvga_pci_map_bios(device_t dev, size_t *size) 98254882Sdumbbell{ 99254882Sdumbbell int rid; 100254882Sdumbbell struct resource *res; 101254882Sdumbbell 102254882Sdumbbell#if defined(__amd64__) || defined(__i386__) || defined(__ia64__) 103254882Sdumbbell if (vga_pci_is_boot_display(dev)) { 104254882Sdumbbell /* 105254882Sdumbbell * On x86, the System BIOS copy the default display 106254882Sdumbbell * device's Video BIOS at a fixed location in system 107254882Sdumbbell * memory (0xC0000, 128 kBytes long) at boot time. 108254882Sdumbbell * 109254882Sdumbbell * We use this copy for the default boot device, because 110254882Sdumbbell * the original ROM may not be valid after boot. 111254882Sdumbbell */ 112254882Sdumbbell 113254882Sdumbbell *size = VGA_PCI_BIOS_SHADOW_SIZE; 114254882Sdumbbell return (pmap_mapbios(VGA_PCI_BIOS_SHADOW_ADDR, *size)); 115254882Sdumbbell } 116254882Sdumbbell#endif 117254882Sdumbbell 118254882Sdumbbell rid = PCIR_BIOS; 119255571Sdumbbell res = vga_pci_alloc_resource(dev, NULL, SYS_RES_MEMORY, &rid, 0ul, 120255571Sdumbbell ~0ul, 1, RF_ACTIVE); 121254882Sdumbbell if (res == NULL) { 122254882Sdumbbell return (NULL); 123254882Sdumbbell } 124254882Sdumbbell 125254882Sdumbbell *size = rman_get_size(res); 126254882Sdumbbell return (rman_get_virtual(res)); 127254882Sdumbbell} 128254882Sdumbbell 129254882Sdumbbellvoid 130254882Sdumbbellvga_pci_unmap_bios(device_t dev, void *bios) 131254882Sdumbbell{ 132255571Sdumbbell struct vga_resource *vr; 133254882Sdumbbell 134254882Sdumbbell if (bios == NULL) { 135254882Sdumbbell return; 136254882Sdumbbell } 137254882Sdumbbell 138254882Sdumbbell#if defined(__amd64__) || defined(__i386__) || defined(__ia64__) 139254882Sdumbbell if (vga_pci_is_boot_display(dev)) { 140254882Sdumbbell /* We mapped the BIOS shadow copy located at 0xC0000. */ 141254882Sdumbbell pmap_unmapdev((vm_offset_t)bios, VGA_PCI_BIOS_SHADOW_SIZE); 142254882Sdumbbell 143254882Sdumbbell return; 144254882Sdumbbell } 145254882Sdumbbell#endif 146254882Sdumbbell 147254882Sdumbbell /* 148255571Sdumbbell * Look up the PCIR_BIOS resource in our softc. It should match 149255571Sdumbbell * the address we returned previously. 150254882Sdumbbell */ 151255571Sdumbbell vr = lookup_res(device_get_softc(dev), PCIR_BIOS); 152255571Sdumbbell KASSERT(vr->vr_res != NULL, ("vga_pci_unmap_bios: bios not mapped")); 153255571Sdumbbell KASSERT(rman_get_virtual(vr->vr_res) == bios, 154255571Sdumbbell ("vga_pci_unmap_bios: mismatch")); 155255571Sdumbbell vga_pci_release_resource(dev, NULL, SYS_RES_MEMORY, PCIR_BIOS, 156255571Sdumbbell vr->vr_res); 157254882Sdumbbell} 158254882Sdumbbell 159153577Sjhbstatic int 160153577Sjhbvga_pci_probe(device_t dev) 161153577Sjhb{ 162198251Sjkim device_t bdev; 163198251Sjkim int unit; 164198251Sjkim uint16_t bctl; 165153577Sjhb 166153577Sjhb switch (pci_get_class(dev)) { 167153577Sjhb case PCIC_DISPLAY: 168153577Sjhb break; 169153577Sjhb case PCIC_OLD: 170153577Sjhb if (pci_get_subclass(dev) != PCIS_OLD_VGA) 171153577Sjhb return (ENXIO); 172153577Sjhb break; 173153577Sjhb default: 174153577Sjhb return (ENXIO); 175153577Sjhb } 176198251Sjkim 177198251Sjkim /* Probe default display. */ 178198251Sjkim unit = device_get_unit(dev); 179198251Sjkim bdev = device_get_parent(device_get_parent(dev)); 180198251Sjkim bctl = pci_read_config(bdev, PCIR_BRIDGECTL_1, 2); 181198251Sjkim if (vga_pci_default_unit < 0 && (bctl & PCIB_BCR_VGA_ENABLE) != 0) 182198251Sjkim vga_pci_default_unit = unit; 183198251Sjkim if (vga_pci_default_unit == unit) 184198251Sjkim device_set_flags(dev, 1); 185198251Sjkim 186153577Sjhb device_set_desc(dev, "VGA-compatible display"); 187153646Sjhb return (BUS_PROBE_GENERIC); 188153577Sjhb} 189153577Sjhb 190153577Sjhbstatic int 191153577Sjhbvga_pci_attach(device_t dev) 192153577Sjhb{ 193153577Sjhb 194153577Sjhb bus_generic_probe(dev); 195153577Sjhb 196153577Sjhb /* Always create a drm child for now to make it easier on drm. */ 197153577Sjhb device_add_child(dev, "drm", -1); 198235846Skib device_add_child(dev, "drmn", -1); 199153577Sjhb bus_generic_attach(dev); 200153577Sjhb return (0); 201153577Sjhb} 202153577Sjhb 203153577Sjhbstatic int 204153577Sjhbvga_pci_suspend(device_t dev) 205153577Sjhb{ 206153577Sjhb 207199002Sjkim return (bus_generic_suspend(dev)); 208153577Sjhb} 209153577Sjhb 210153577Sjhbstatic int 211153577Sjhbvga_pci_resume(device_t dev) 212153577Sjhb{ 213153577Sjhb 214153577Sjhb return (bus_generic_resume(dev)); 215153577Sjhb} 216153577Sjhb 217153577Sjhb/* Bus interface. */ 218153577Sjhb 219153577Sjhbstatic int 220153577Sjhbvga_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) 221153577Sjhb{ 222153577Sjhb 223153577Sjhb return (BUS_READ_IVAR(device_get_parent(dev), dev, which, result)); 224153577Sjhb} 225153577Sjhb 226153577Sjhbstatic int 227153577Sjhbvga_pci_write_ivar(device_t dev, device_t child, int which, uintptr_t value) 228153577Sjhb{ 229153577Sjhb 230153577Sjhb return (EINVAL); 231153577Sjhb} 232153577Sjhb 233183194Srnolandstatic int 234183194Srnolandvga_pci_setup_intr(device_t dev, device_t child, struct resource *irq, 235183194Srnoland int flags, driver_filter_t *filter, driver_intr_t *intr, void *arg, 236183194Srnoland void **cookiep) 237183194Srnoland{ 238183194Srnoland return (BUS_SETUP_INTR(device_get_parent(dev), dev, irq, flags, 239183194Srnoland filter, intr, arg, cookiep)); 240183194Srnoland} 241183194Srnoland 242183194Srnolandstatic int 243183194Srnolandvga_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, 244183194Srnoland void *cookie) 245183194Srnoland{ 246183194Srnoland return (BUS_TEARDOWN_INTR(device_get_parent(dev), dev, irq, cookie)); 247183194Srnoland} 248183194Srnoland 249249315Sjhbstatic struct vga_resource * 250249315Sjhblookup_res(struct vga_pci_softc *sc, int rid) 251249315Sjhb{ 252249315Sjhb int bar; 253249315Sjhb 254249315Sjhb if (rid == PCIR_BIOS) 255249315Sjhb return (&sc->vga_bios); 256249315Sjhb bar = PCI_RID2BAR(rid); 257249315Sjhb if (bar >= 0 && bar <= PCIR_MAX_BAR_0) 258249315Sjhb return (&sc->vga_bars[bar]); 259249315Sjhb return (NULL); 260249315Sjhb} 261249315Sjhb 262153577Sjhbstatic struct resource * 263153577Sjhbvga_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, 264153577Sjhb u_long start, u_long end, u_long count, u_int flags) 265153577Sjhb{ 266249315Sjhb struct vga_resource *vr; 267153577Sjhb 268189373Sjhb switch (type) { 269189373Sjhb case SYS_RES_MEMORY: 270189373Sjhb case SYS_RES_IOPORT: 271189373Sjhb /* 272189373Sjhb * For BARs, we cache the resource so that we only allocate it 273189373Sjhb * from the PCI bus once. 274189373Sjhb */ 275249315Sjhb vr = lookup_res(device_get_softc(dev), *rid); 276249315Sjhb if (vr == NULL) 277189373Sjhb return (NULL); 278249315Sjhb if (vr->vr_res == NULL) 279249315Sjhb vr->vr_res = bus_alloc_resource(dev, type, rid, start, 280249315Sjhb end, count, flags); 281249315Sjhb if (vr->vr_res != NULL) 282249315Sjhb vr->vr_refs++; 283249315Sjhb return (vr->vr_res); 284189373Sjhb } 285153577Sjhb return (bus_alloc_resource(dev, type, rid, start, end, count, flags)); 286153577Sjhb} 287153577Sjhb 288153577Sjhbstatic int 289153577Sjhbvga_pci_release_resource(device_t dev, device_t child, int type, int rid, 290153577Sjhb struct resource *r) 291153577Sjhb{ 292249315Sjhb struct vga_resource *vr; 293249315Sjhb int error; 294153577Sjhb 295189373Sjhb switch (type) { 296189373Sjhb case SYS_RES_MEMORY: 297189373Sjhb case SYS_RES_IOPORT: 298189373Sjhb /* 299189373Sjhb * For BARs, we release the resource from the PCI bus 300189373Sjhb * when the last child reference goes away. 301189373Sjhb */ 302249315Sjhb vr = lookup_res(device_get_softc(dev), rid); 303249315Sjhb if (vr == NULL) 304189373Sjhb return (EINVAL); 305249315Sjhb if (vr->vr_res == NULL) 306189373Sjhb return (EINVAL); 307249315Sjhb KASSERT(vr->vr_res == r, ("vga_pci resource mismatch")); 308249315Sjhb if (vr->vr_refs > 1) { 309249315Sjhb vr->vr_refs--; 310189373Sjhb return (0); 311189373Sjhb } 312249315Sjhb KASSERT(vr->vr_refs > 0, 313189373Sjhb ("vga_pci resource reference count underflow")); 314189373Sjhb error = bus_release_resource(dev, type, rid, r); 315189373Sjhb if (error == 0) { 316249315Sjhb vr->vr_res = NULL; 317249315Sjhb vr->vr_refs = 0; 318189373Sjhb } 319189373Sjhb return (error); 320189373Sjhb } 321189373Sjhb 322153577Sjhb return (bus_release_resource(dev, type, rid, r)); 323153577Sjhb} 324153577Sjhb 325153577Sjhb/* PCI interface. */ 326153577Sjhb 327153577Sjhbstatic uint32_t 328153577Sjhbvga_pci_read_config(device_t dev, device_t child, int reg, int width) 329153577Sjhb{ 330153577Sjhb 331153577Sjhb return (pci_read_config(dev, reg, width)); 332153577Sjhb} 333153577Sjhb 334153577Sjhbstatic void 335205018Sjhbvga_pci_write_config(device_t dev, device_t child, int reg, 336153577Sjhb uint32_t val, int width) 337153577Sjhb{ 338153577Sjhb 339153577Sjhb pci_write_config(dev, reg, val, width); 340153577Sjhb} 341153577Sjhb 342153577Sjhbstatic int 343153577Sjhbvga_pci_enable_busmaster(device_t dev, device_t child) 344153577Sjhb{ 345153577Sjhb 346153577Sjhb return (pci_enable_busmaster(dev)); 347153577Sjhb} 348153577Sjhb 349153577Sjhbstatic int 350153577Sjhbvga_pci_disable_busmaster(device_t dev, device_t child) 351153577Sjhb{ 352153577Sjhb 353153577Sjhb return (pci_disable_busmaster(dev)); 354153577Sjhb} 355153577Sjhb 356153577Sjhbstatic int 357153577Sjhbvga_pci_enable_io(device_t dev, device_t child, int space) 358153577Sjhb{ 359153577Sjhb 360153577Sjhb device_printf(dev, "child %s requested pci_enable_io\n", 361153577Sjhb device_get_nameunit(child)); 362153577Sjhb return (pci_enable_io(dev, space)); 363153577Sjhb} 364153577Sjhb 365153577Sjhbstatic int 366153577Sjhbvga_pci_disable_io(device_t dev, device_t child, int space) 367153577Sjhb{ 368153577Sjhb 369153577Sjhb device_printf(dev, "child %s requested pci_disable_io\n", 370153577Sjhb device_get_nameunit(child)); 371153577Sjhb return (pci_disable_io(dev, space)); 372153577Sjhb} 373153577Sjhb 374153577Sjhbstatic int 375183095Sjhbvga_pci_get_vpd_ident(device_t dev, device_t child, const char **identptr) 376183095Sjhb{ 377183095Sjhb 378183095Sjhb return (pci_get_vpd_ident(dev, identptr)); 379183095Sjhb} 380183095Sjhb 381183095Sjhbstatic int 382183095Sjhbvga_pci_get_vpd_readonly(device_t dev, device_t child, const char *kw, 383183095Sjhb const char **vptr) 384183095Sjhb{ 385183095Sjhb 386183095Sjhb return (pci_get_vpd_readonly(dev, kw, vptr)); 387183095Sjhb} 388183095Sjhb 389183095Sjhbstatic int 390153577Sjhbvga_pci_set_powerstate(device_t dev, device_t child, int state) 391153577Sjhb{ 392153577Sjhb 393153577Sjhb device_printf(dev, "child %s requested pci_set_powerstate\n", 394153577Sjhb device_get_nameunit(child)); 395153577Sjhb return (pci_set_powerstate(dev, state)); 396153577Sjhb} 397153577Sjhb 398153577Sjhbstatic int 399153577Sjhbvga_pci_get_powerstate(device_t dev, device_t child) 400153577Sjhb{ 401153577Sjhb 402153577Sjhb device_printf(dev, "child %s requested pci_get_powerstate\n", 403153577Sjhb device_get_nameunit(child)); 404153577Sjhb return (pci_get_powerstate(dev)); 405153577Sjhb} 406153577Sjhb 407153577Sjhbstatic int 408153577Sjhbvga_pci_assign_interrupt(device_t dev, device_t child) 409153577Sjhb{ 410153577Sjhb 411153577Sjhb device_printf(dev, "child %s requested pci_assign_interrupt\n", 412153577Sjhb device_get_nameunit(child)); 413153577Sjhb return (PCI_ASSIGN_INTERRUPT(device_get_parent(dev), dev)); 414153577Sjhb} 415153577Sjhb 416153577Sjhbstatic int 417232472Sjhbvga_pci_find_cap(device_t dev, device_t child, int capability, 418232472Sjhb int *capreg) 419232472Sjhb{ 420232472Sjhb 421232472Sjhb return (pci_find_cap(dev, capability, capreg)); 422232472Sjhb} 423232472Sjhb 424232472Sjhbstatic int 425153577Sjhbvga_pci_find_extcap(device_t dev, device_t child, int capability, 426153577Sjhb int *capreg) 427153577Sjhb{ 428153577Sjhb 429153577Sjhb return (pci_find_extcap(dev, capability, capreg)); 430153577Sjhb} 431153577Sjhb 432183095Sjhbstatic int 433232472Sjhbvga_pci_find_htcap(device_t dev, device_t child, int capability, 434232472Sjhb int *capreg) 435232472Sjhb{ 436232472Sjhb 437232472Sjhb return (pci_find_htcap(dev, capability, capreg)); 438232472Sjhb} 439232472Sjhb 440232472Sjhbstatic int 441183095Sjhbvga_pci_alloc_msi(device_t dev, device_t child, int *count) 442183095Sjhb{ 443183095Sjhb struct vga_pci_softc *sc; 444183095Sjhb int error; 445183095Sjhb 446183095Sjhb sc = device_get_softc(dev); 447183095Sjhb if (sc->vga_msi_child != NULL) 448183095Sjhb return (EBUSY); 449183095Sjhb error = pci_alloc_msi(dev, count); 450183095Sjhb if (error == 0) 451183095Sjhb sc->vga_msi_child = child; 452183095Sjhb return (error); 453183095Sjhb} 454183095Sjhb 455183095Sjhbstatic int 456183095Sjhbvga_pci_alloc_msix(device_t dev, device_t child, int *count) 457183095Sjhb{ 458183095Sjhb struct vga_pci_softc *sc; 459183095Sjhb int error; 460183095Sjhb 461183095Sjhb sc = device_get_softc(dev); 462183095Sjhb if (sc->vga_msi_child != NULL) 463183095Sjhb return (EBUSY); 464183095Sjhb error = pci_alloc_msix(dev, count); 465183095Sjhb if (error == 0) 466183095Sjhb sc->vga_msi_child = child; 467183095Sjhb return (error); 468183095Sjhb} 469183095Sjhb 470183095Sjhbstatic int 471183095Sjhbvga_pci_remap_msix(device_t dev, device_t child, int count, 472183095Sjhb const u_int *vectors) 473183095Sjhb{ 474183095Sjhb struct vga_pci_softc *sc; 475183095Sjhb 476183095Sjhb sc = device_get_softc(dev); 477183095Sjhb if (sc->vga_msi_child != child) 478183095Sjhb return (ENXIO); 479183095Sjhb return (pci_remap_msix(dev, count, vectors)); 480183095Sjhb} 481183095Sjhb 482183095Sjhbstatic int 483183095Sjhbvga_pci_release_msi(device_t dev, device_t child) 484183095Sjhb{ 485183095Sjhb struct vga_pci_softc *sc; 486183095Sjhb int error; 487183095Sjhb 488183095Sjhb sc = device_get_softc(dev); 489183095Sjhb if (sc->vga_msi_child != child) 490183095Sjhb return (ENXIO); 491183095Sjhb error = pci_release_msi(dev); 492183095Sjhb if (error == 0) 493183095Sjhb sc->vga_msi_child = NULL; 494183095Sjhb return (error); 495183095Sjhb} 496183095Sjhb 497183095Sjhbstatic int 498183095Sjhbvga_pci_msi_count(device_t dev, device_t child) 499183095Sjhb{ 500183095Sjhb 501183095Sjhb return (pci_msi_count(dev)); 502183095Sjhb} 503183095Sjhb 504183095Sjhbstatic int 505183095Sjhbvga_pci_msix_count(device_t dev, device_t child) 506183095Sjhb{ 507183095Sjhb 508183095Sjhb return (pci_msix_count(dev)); 509183095Sjhb} 510183095Sjhb 511249476Skibstatic bus_dma_tag_t 512249476Skibvga_pci_get_dma_tag(device_t bus, device_t child) 513249476Skib{ 514249476Skib 515249476Skib return (bus_get_dma_tag(bus)); 516249476Skib} 517249476Skib 518153577Sjhbstatic device_method_t vga_pci_methods[] = { 519153577Sjhb /* Device interface */ 520153577Sjhb DEVMETHOD(device_probe, vga_pci_probe), 521153577Sjhb DEVMETHOD(device_attach, vga_pci_attach), 522153577Sjhb DEVMETHOD(device_shutdown, bus_generic_shutdown), 523153577Sjhb DEVMETHOD(device_suspend, vga_pci_suspend), 524153577Sjhb DEVMETHOD(device_resume, vga_pci_resume), 525153577Sjhb 526153577Sjhb /* Bus interface */ 527153577Sjhb DEVMETHOD(bus_read_ivar, vga_pci_read_ivar), 528153577Sjhb DEVMETHOD(bus_write_ivar, vga_pci_write_ivar), 529183194Srnoland DEVMETHOD(bus_setup_intr, vga_pci_setup_intr), 530183194Srnoland DEVMETHOD(bus_teardown_intr, vga_pci_teardown_intr), 531153577Sjhb DEVMETHOD(bus_alloc_resource, vga_pci_alloc_resource), 532153577Sjhb DEVMETHOD(bus_release_resource, vga_pci_release_resource), 533153577Sjhb DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 534153577Sjhb DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 535249476Skib DEVMETHOD(bus_get_dma_tag, vga_pci_get_dma_tag), 536153577Sjhb 537153577Sjhb /* PCI interface */ 538153577Sjhb DEVMETHOD(pci_read_config, vga_pci_read_config), 539153577Sjhb DEVMETHOD(pci_write_config, vga_pci_write_config), 540153577Sjhb DEVMETHOD(pci_enable_busmaster, vga_pci_enable_busmaster), 541153577Sjhb DEVMETHOD(pci_disable_busmaster, vga_pci_disable_busmaster), 542153577Sjhb DEVMETHOD(pci_enable_io, vga_pci_enable_io), 543153577Sjhb DEVMETHOD(pci_disable_io, vga_pci_disable_io), 544183095Sjhb DEVMETHOD(pci_get_vpd_ident, vga_pci_get_vpd_ident), 545183095Sjhb DEVMETHOD(pci_get_vpd_readonly, vga_pci_get_vpd_readonly), 546153577Sjhb DEVMETHOD(pci_get_powerstate, vga_pci_get_powerstate), 547153577Sjhb DEVMETHOD(pci_set_powerstate, vga_pci_set_powerstate), 548153577Sjhb DEVMETHOD(pci_assign_interrupt, vga_pci_assign_interrupt), 549232472Sjhb DEVMETHOD(pci_find_cap, vga_pci_find_cap), 550153577Sjhb DEVMETHOD(pci_find_extcap, vga_pci_find_extcap), 551232472Sjhb DEVMETHOD(pci_find_htcap, vga_pci_find_htcap), 552183095Sjhb DEVMETHOD(pci_alloc_msi, vga_pci_alloc_msi), 553183095Sjhb DEVMETHOD(pci_alloc_msix, vga_pci_alloc_msix), 554183095Sjhb DEVMETHOD(pci_remap_msix, vga_pci_remap_msix), 555183095Sjhb DEVMETHOD(pci_release_msi, vga_pci_release_msi), 556183095Sjhb DEVMETHOD(pci_msi_count, vga_pci_msi_count), 557183095Sjhb DEVMETHOD(pci_msix_count, vga_pci_msix_count), 558153577Sjhb 559153577Sjhb { 0, 0 } 560153577Sjhb}; 561153577Sjhb 562153577Sjhbstatic driver_t vga_pci_driver = { 563153577Sjhb "vgapci", 564153577Sjhb vga_pci_methods, 565183095Sjhb sizeof(struct vga_pci_softc), 566153577Sjhb}; 567153577Sjhb 568153577Sjhbstatic devclass_t vga_devclass; 569153577Sjhb 570153577SjhbDRIVER_MODULE(vgapci, pci, vga_pci_driver, vga_devclass, 0, 0); 571