1139749Simp/*-
291355Simp * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
391355Simp * Copyright (c) 2000, Michael Smith <msmith@freebsd.org>
491355Simp * Copyright (c) 2000, BSDi
591355Simp * All rights reserved.
691355Simp *
791355Simp * Redistribution and use in source and binary forms, with or without
891355Simp * modification, are permitted provided that the following conditions
991355Simp * are met:
1091355Simp * 1. Redistributions of source code must retain the above copyright
1191355Simp *    notice unmodified, this list of conditions, and the following
1291355Simp *    disclaimer.
1391355Simp * 2. Redistributions in binary form must reproduce the above copyright
1491355Simp *    notice, this list of conditions and the following disclaimer in the
1591355Simp *    documentation and/or other materials provided with the distribution.
1691355Simp *
1791355Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1891355Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1991355Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2091355Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2191355Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2291355Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2391355Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2491355Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2591355Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2691355Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2791355Simp *
2891355Simp * $FreeBSD: releng/10.2/sys/dev/pci/pci_private.h 280970 2015-04-01 21:48:54Z jhb $
2991355Simp *
3091355Simp */
3191355Simp
3291355Simp#ifndef _PCI_PRIVATE_H_
33165217Sjhb#define	_PCI_PRIVATE_H_
3491355Simp
3591355Simp/*
3691355Simp * Export definitions of the pci bus so that we can more easily share
37154599Sjhb * it with "subclass" busses.
3891355Simp */
39154599SjhbDECLARE_CLASS(pci_driver);
40102440Sjhb
41232403Sjhbstruct pci_softc {
42232403Sjhb	bus_dma_tag_t sc_dma_tag;
43280970Sjhb#ifdef PCI_RES_BUS
44280970Sjhb	struct resource *sc_bus;
45280970Sjhb#endif
46232403Sjhb};
47232403Sjhb
48211430Sjhbextern int 	pci_do_power_resume;
49214110Sjkimextern int 	pci_do_power_suspend;
50211430Sjhb
51172394Smariusvoid		pci_add_children(device_t dev, int domain, int busno,
52172394Smarius		    size_t dinfo_size);
53102440Sjhbvoid		pci_add_child(device_t bus, struct pci_devinfo *dinfo);
54153898Simpvoid		pci_add_resources(device_t bus, device_t dev, int force,
55153898Simp		    uint32_t prefetchmask);
56232403Sjhbint		pci_attach_common(device_t dev);
57201609Sjhbvoid		pci_delete_child(device_t dev, device_t child);
58128058Simpvoid		pci_driver_added(device_t dev, driver_t *driver);
5991355Simpint		pci_print_child(device_t dev, device_t child);
6091355Simpvoid		pci_probe_nomatch(device_t dev, device_t child);
6191355Simpint		pci_read_ivar(device_t dev, device_t child, int which,
6291355Simp		    uintptr_t *result);
6391355Simpint		pci_write_ivar(device_t dev, device_t child, int which,
6491355Simp		    uintptr_t value);
65169221Sjhbint		pci_setup_intr(device_t dev, device_t child,
66169221Sjhb		    struct resource *irq, int flags, driver_filter_t *filter,
67169221Sjhb		    driver_intr_t *intr, void *arg, void **cookiep);
68169221Sjhbint		pci_teardown_intr(device_t dev, device_t child,
69169221Sjhb		    struct resource *irq, void *cookie);
70163163Sjmgint		pci_get_vpd_ident_method(device_t dev, device_t child,
71163163Sjmg		    const char **identptr);
72163163Sjmgint		pci_get_vpd_readonly_method(device_t dev, device_t child,
73163163Sjmg		    const char *kw, const char **vptr);
7491355Simpint		pci_set_powerstate_method(device_t dev, device_t child,
7591355Simp		    int state);
7691355Simpint		pci_get_powerstate_method(device_t dev, device_t child);
77119266Simpuint32_t	pci_read_config_method(device_t dev, device_t child,
7891355Simp		    int reg, int width);
7991355Simpvoid		pci_write_config_method(device_t dev, device_t child,
80119266Simp		    int reg, uint32_t val, int width);
81113544Smdoddint		pci_enable_busmaster_method(device_t dev, device_t child);
82113544Smdoddint		pci_disable_busmaster_method(device_t dev, device_t child);
83113544Smdoddint		pci_enable_io_method(device_t dev, device_t child, int space);
84113544Smdoddint		pci_disable_io_method(device_t dev, device_t child, int space);
85232472Sjhbint		pci_find_cap_method(device_t dev, device_t child,
86232472Sjhb		    int capability, int *capreg);
87153560Sjhbint		pci_find_extcap_method(device_t dev, device_t child,
88153560Sjhb		    int capability, int *capreg);
89232472Sjhbint		pci_find_htcap_method(device_t dev, device_t child,
90232472Sjhb		    int capability, int *capreg);
91164264Sjhbint		pci_alloc_msi_method(device_t dev, device_t child, int *count);
92166176Sjhbint		pci_alloc_msix_method(device_t dev, device_t child, int *count);
93166176Sjhbint		pci_remap_msix_method(device_t dev, device_t child,
94169221Sjhb		    int count, const u_int *vectors);
95164264Sjhbint		pci_release_msi_method(device_t dev, device_t child);
96164264Sjhbint		pci_msi_count_method(device_t dev, device_t child);
97166176Sjhbint		pci_msix_count_method(device_t dev, device_t child);
9891355Simpstruct resource	*pci_alloc_resource(device_t dev, device_t child,
9991355Simp		    int type, int *rid, u_long start, u_long end, u_long count,
10091355Simp		    u_int flags);
101253450Sjhbint		pci_release_resource(device_t dev, device_t child, int type,
102253450Sjhb		    int rid, struct resource *r);
103189306Sjhbint		pci_activate_resource(device_t dev, device_t child, int type,
104189306Sjhb		    int rid, struct resource *r);
105201279Sjhbint		pci_deactivate_resource(device_t dev, device_t child, int type,
106201279Sjhb		    int rid, struct resource *r);
10791355Simpvoid		pci_delete_resource(device_t dev, device_t child,
10891355Simp		    int type, int rid);
10991355Simpstruct resource_list *pci_get_resource_list (device_t dev, device_t child);
110172394Smariusstruct pci_devinfo *pci_read_device(device_t pcib, int d, int b, int s, int f,
11192233Simp		    size_t size);
11291355Simpvoid		pci_print_verbose(struct pci_devinfo *dinfo);
11391355Simpint		pci_freecfg(struct pci_devinfo *dinfo);
114252315Sjhbvoid		pci_child_detached(device_t dev, device_t child);
115111056Simpint		pci_child_location_str_method(device_t cbdev, device_t child,
116111056Simp		    char *buf, size_t buflen);
117111056Simpint		pci_child_pnpinfo_str_method(device_t cbdev, device_t child,
118111056Simp		    char *buf, size_t buflen);
119117115Stmmint		pci_assign_interrupt_method(device_t dev, device_t child);
120120155Siwasakiint		pci_resume(device_t dev);
121128058Simpint		pci_suspend(device_t dev);
122257495Skibbus_dma_tag_t pci_get_dma_tag(device_t bus, device_t dev);
123169615Simp
124169615Simp/** Restore the config register state.  The state must be previously
125169615Simp * saved with pci_cfg_save.  However, the pci bus driver takes care of
126169615Simp * that.  This function will also return the device to PCI_POWERSTATE_D0
127169615Simp * if it is currently in a lower power mode.
128169615Simp */
129142735Simpvoid		pci_cfg_restore(device_t, struct pci_devinfo *);
130169615Simp
131169615Simp/** Save the config register state.  Optionally set the power state to D3
132169615Simp * if the third argument is non-zero.
133169615Simp */
134142735Simpvoid		pci_cfg_save(device_t, struct pci_devinfo *, int);
135164067Sjhb
13691355Simp#endif /* _PCI_PRIVATE_H_ */
137