1098ca2bdSWarner Losh /*- 27ba175acSWarner Losh * Copyright (c) 1997, Stefan Esser <se@freebsd.org> 37ba175acSWarner Losh * Copyright (c) 2000, Michael Smith <msmith@freebsd.org> 47ba175acSWarner Losh * Copyright (c) 2000, BSDi 57ba175acSWarner Losh * All rights reserved. 67ba175acSWarner Losh * 77ba175acSWarner Losh * Redistribution and use in source and binary forms, with or without 87ba175acSWarner Losh * modification, are permitted provided that the following conditions 97ba175acSWarner Losh * are met: 107ba175acSWarner Losh * 1. Redistributions of source code must retain the above copyright 117ba175acSWarner Losh * notice unmodified, this list of conditions, and the following 127ba175acSWarner Losh * disclaimer. 137ba175acSWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 147ba175acSWarner Losh * notice, this list of conditions and the following disclaimer in the 157ba175acSWarner Losh * documentation and/or other materials provided with the distribution. 167ba175acSWarner Losh * 177ba175acSWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 187ba175acSWarner Losh * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 197ba175acSWarner Losh * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 207ba175acSWarner Losh * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 217ba175acSWarner Losh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 227ba175acSWarner Losh * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 237ba175acSWarner Losh * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 247ba175acSWarner Losh * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 257ba175acSWarner Losh * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 267ba175acSWarner Losh * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 277ba175acSWarner Losh * 287ba175acSWarner Losh * $FreeBSD$ 297ba175acSWarner Losh * 307ba175acSWarner Losh */ 317ba175acSWarner Losh 327ba175acSWarner Losh #ifndef _PCI_PRIVATE_H_ 337ba175acSWarner Losh #define _PCI_PRIVATE_H_ 347ba175acSWarner Losh 357ba175acSWarner Losh /* 367ba175acSWarner Losh * Export definitions of the pci bus so that we can more easily share 375aa58b3eSJohn Baldwin * it with "subclass" busses. 387ba175acSWarner Losh */ 395aa58b3eSJohn Baldwin DECLARE_CLASS(pci_driver); 4042dbeaeeSJohn Baldwin 411b1596a3SJohn Baldwin struct pci_softc { 421b1596a3SJohn Baldwin bus_dma_tag_t sc_dma_tag; 43*4edef187SJohn Baldwin #ifdef PCI_RES_BUS 44*4edef187SJohn Baldwin struct resource *sc_bus; 45*4edef187SJohn Baldwin #endif 461b1596a3SJohn Baldwin }; 471b1596a3SJohn Baldwin 4862508c53SJohn Baldwin extern int pci_do_power_resume; 49f3e0b109SJung-uk Kim extern int pci_do_power_suspend; 5062508c53SJohn Baldwin 5155aaf894SMarius Strobl void pci_add_children(device_t dev, int domain, int busno, 5255aaf894SMarius Strobl size_t dinfo_size); 5342dbeaeeSJohn Baldwin void pci_add_child(device_t bus, struct pci_devinfo *dinfo); 54a9883bc8SWarner Losh void pci_add_resources(device_t bus, device_t dev, int force, 55a9883bc8SWarner Losh uint32_t prefetchmask); 561b1596a3SJohn Baldwin int pci_attach_common(device_t dev); 57af827f96SJohn Baldwin void pci_delete_child(device_t dev, device_t child); 58cd8b53edSWarner Losh void pci_driver_added(device_t dev, driver_t *driver); 597ba175acSWarner Losh int pci_print_child(device_t dev, device_t child); 607ba175acSWarner Losh void pci_probe_nomatch(device_t dev, device_t child); 617ba175acSWarner Losh int pci_read_ivar(device_t dev, device_t child, int which, 627ba175acSWarner Losh uintptr_t *result); 637ba175acSWarner Losh int pci_write_ivar(device_t dev, device_t child, int which, 647ba175acSWarner Losh uintptr_t value); 65e706f7f0SJohn Baldwin int pci_setup_intr(device_t dev, device_t child, 66e706f7f0SJohn Baldwin struct resource *irq, int flags, driver_filter_t *filter, 67e706f7f0SJohn Baldwin driver_intr_t *intr, void *arg, void **cookiep); 68e706f7f0SJohn Baldwin int pci_teardown_intr(device_t dev, device_t child, 69e706f7f0SJohn Baldwin struct resource *irq, void *cookie); 70667dc26eSJohn-Mark Gurney int pci_get_vpd_ident_method(device_t dev, device_t child, 71667dc26eSJohn-Mark Gurney const char **identptr); 72667dc26eSJohn-Mark Gurney int pci_get_vpd_readonly_method(device_t dev, device_t child, 73667dc26eSJohn-Mark Gurney const char *kw, const char **vptr); 747ba175acSWarner Losh int pci_set_powerstate_method(device_t dev, device_t child, 757ba175acSWarner Losh int state); 767ba175acSWarner Losh int pci_get_powerstate_method(device_t dev, device_t child); 77b0cb115fSWarner Losh uint32_t pci_read_config_method(device_t dev, device_t child, 787ba175acSWarner Losh int reg, int width); 797ba175acSWarner Losh void pci_write_config_method(device_t dev, device_t child, 80b0cb115fSWarner Losh int reg, uint32_t val, int width); 81c047e5b1SMatthew N. Dodd int pci_enable_busmaster_method(device_t dev, device_t child); 82c047e5b1SMatthew N. Dodd int pci_disable_busmaster_method(device_t dev, device_t child); 83c047e5b1SMatthew N. Dodd int pci_enable_io_method(device_t dev, device_t child, int space); 84c047e5b1SMatthew N. Dodd int pci_disable_io_method(device_t dev, device_t child, int space); 85c668000bSJohn Baldwin int pci_find_cap_method(device_t dev, device_t child, 86c668000bSJohn Baldwin int capability, int *capreg); 874f9795b9SJohn Baldwin int pci_find_extcap_method(device_t dev, device_t child, 884f9795b9SJohn Baldwin int capability, int *capreg); 89c668000bSJohn Baldwin int pci_find_htcap_method(device_t dev, device_t child, 90c668000bSJohn Baldwin int capability, int *capreg); 919bf4c9c1SJohn Baldwin int pci_alloc_msi_method(device_t dev, device_t child, int *count); 925fe82bcaSJohn Baldwin int pci_alloc_msix_method(device_t dev, device_t child, int *count); 935fe82bcaSJohn Baldwin int pci_remap_msix_method(device_t dev, device_t child, 94e706f7f0SJohn Baldwin int count, const u_int *vectors); 959bf4c9c1SJohn Baldwin int pci_release_msi_method(device_t dev, device_t child); 969bf4c9c1SJohn Baldwin int pci_msi_count_method(device_t dev, device_t child); 975fe82bcaSJohn Baldwin int pci_msix_count_method(device_t dev, device_t child); 987ba175acSWarner Losh struct resource *pci_alloc_resource(device_t dev, device_t child, 997ba175acSWarner Losh int type, int *rid, u_long start, u_long end, u_long count, 1007ba175acSWarner Losh u_int flags); 101c825d4dcSJohn Baldwin int pci_release_resource(device_t dev, device_t child, int type, 102c825d4dcSJohn Baldwin int rid, struct resource *r); 1036b0ff427SJohn Baldwin int pci_activate_resource(device_t dev, device_t child, int type, 1046b0ff427SJohn Baldwin int rid, struct resource *r); 1054e8790e9SJohn Baldwin int pci_deactivate_resource(device_t dev, device_t child, int type, 1064e8790e9SJohn Baldwin int rid, struct resource *r); 1077ba175acSWarner Losh void pci_delete_resource(device_t dev, device_t child, 1087ba175acSWarner Losh int type, int rid); 1097ba175acSWarner Losh struct resource_list *pci_get_resource_list (device_t dev, device_t child); 11055aaf894SMarius Strobl struct pci_devinfo *pci_read_device(device_t pcib, int d, int b, int s, int f, 11120fe0073SWarner Losh size_t size); 1127ba175acSWarner Losh void pci_print_verbose(struct pci_devinfo *dinfo); 1137ba175acSWarner Losh int pci_freecfg(struct pci_devinfo *dinfo); 114e35ce1f2SJohn Baldwin void pci_child_detached(device_t dev, device_t child); 1155794c593SWarner Losh int pci_child_location_str_method(device_t cbdev, device_t child, 1165794c593SWarner Losh char *buf, size_t buflen); 1175794c593SWarner Losh int pci_child_pnpinfo_str_method(device_t cbdev, device_t child, 1185794c593SWarner Losh char *buf, size_t buflen); 1193920999dSThomas Moestl int pci_assign_interrupt_method(device_t dev, device_t child); 120526b5e65SMitsuru IWASAKI int pci_resume(device_t dev); 121cd8b53edSWarner Losh int pci_suspend(device_t dev); 122c54a713fSKonstantin Belousov bus_dma_tag_t pci_get_dma_tag(device_t bus, device_t dev); 1237a528f5cSWarner Losh 1247a528f5cSWarner Losh /** Restore the config register state. The state must be previously 1257a528f5cSWarner Losh * saved with pci_cfg_save. However, the pci bus driver takes care of 1267a528f5cSWarner Losh * that. This function will also return the device to PCI_POWERSTATE_D0 1277a528f5cSWarner Losh * if it is currently in a lower power mode. 1287a528f5cSWarner Losh */ 129c3c08f30SWarner Losh void pci_cfg_restore(device_t, struct pci_devinfo *); 1307a528f5cSWarner Losh 1317a528f5cSWarner Losh /** Save the config register state. Optionally set the power state to D3 1327a528f5cSWarner Losh * if the third argument is non-zero. 1337a528f5cSWarner Losh */ 134c3c08f30SWarner Losh void pci_cfg_save(device_t, struct pci_devinfo *, int); 135d6592688SJohn Baldwin 1367ba175acSWarner Losh #endif /* _PCI_PRIVATE_H_ */ 137