pci_private.h revision 232472
156893Sfenner/*-
256893Sfenner * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
356893Sfenner * Copyright (c) 2000, Michael Smith <msmith@freebsd.org>
456893Sfenner * Copyright (c) 2000, BSDi
5127668Sbms * All rights reserved.
656893Sfenner *
756893Sfenner * Redistribution and use in source and binary forms, with or without
856893Sfenner * modification, are permitted provided that the following conditions
9127668Sbms * are met:
1056893Sfenner * 1. Redistributions of source code must retain the above copyright
1156893Sfenner *    notice unmodified, this list of conditions, and the following
12127668Sbms *    disclaimer.
1356893Sfenner * 2. Redistributions in binary form must reproduce the above copyright
1456893Sfenner *    notice, this list of conditions and the following disclaimer in the
1556893Sfenner *    documentation and/or other materials provided with the distribution.
16127668Sbms *
1756893Sfenner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1856893Sfenner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1956893Sfenner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2056893Sfenner * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21127668Sbms * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2256893Sfenner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2356893Sfenner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2456893Sfenner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25127668Sbms * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2656893Sfenner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2756893Sfenner *
2856893Sfenner * $FreeBSD: head/sys/dev/pci/pci_private.h 232472 2012-03-03 18:08:57Z jhb $
2956893Sfenner *
3056893Sfenner */
3156893Sfenner
3256893Sfenner#ifndef _PCI_PRIVATE_H_
3356893Sfenner#define	_PCI_PRIVATE_H_
3456893Sfenner
3556893Sfenner/*
3656893Sfenner * Export definitions of the pci bus so that we can more easily share
3756893Sfenner * it with "subclass" busses.
3856893Sfenner */
39190207SrpauloDECLARE_CLASS(pci_driver);
4056893Sfenner
4156893Sfennerstruct pci_softc {
42127668Sbms	bus_dma_tag_t sc_dma_tag;
43190207Srpaulo	int	sc_dma_tag_valid;
4456893Sfenner};
4556893Sfenner
46127668Sbmsextern int 	pci_do_power_resume;
47127668Sbmsextern int 	pci_do_power_suspend;
4856893Sfenner
4956893Sfennervoid		pci_add_children(device_t dev, int domain, int busno,
5056893Sfenner		    size_t dinfo_size);
5156893Sfennervoid		pci_add_child(device_t bus, struct pci_devinfo *dinfo);
5256893Sfennervoid		pci_add_resources(device_t bus, device_t dev, int force,
5356893Sfenner		    uint32_t prefetchmask);
5456893Sfennerint		pci_attach_common(device_t dev);
55146775Ssamvoid		pci_delete_child(device_t dev, device_t child);
56146775Ssamvoid		pci_driver_added(device_t dev, driver_t *driver);
5756893Sfennerint		pci_print_child(device_t dev, device_t child);
5856893Sfennervoid		pci_probe_nomatch(device_t dev, device_t child);
59146775Ssamint		pci_read_ivar(device_t dev, device_t child, int which,
60146775Ssam		    uintptr_t *result);
61146775Ssamint		pci_write_ivar(device_t dev, device_t child, int which,
62146775Ssam		    uintptr_t value);
6356893Sfennerint		pci_setup_intr(device_t dev, device_t child,
6456893Sfenner		    struct resource *irq, int flags, driver_filter_t *filter,
6556893Sfenner		    driver_intr_t *intr, void *arg, void **cookiep);
6656893Sfennerint		pci_teardown_intr(device_t dev, device_t child,
6756893Sfenner		    struct resource *irq, void *cookie);
6856893Sfennerint		pci_get_vpd_ident_method(device_t dev, device_t child,
6956893Sfenner		    const char **identptr);
7056893Sfennerint		pci_get_vpd_readonly_method(device_t dev, device_t child,
7156893Sfenner		    const char *kw, const char **vptr);
7256893Sfennerint		pci_set_powerstate_method(device_t dev, device_t child,
7356893Sfenner		    int state);
7456893Sfennerint		pci_get_powerstate_method(device_t dev, device_t child);
7556893Sfenneruint32_t	pci_read_config_method(device_t dev, device_t child,
7656893Sfenner		    int reg, int width);
7756893Sfennervoid		pci_write_config_method(device_t dev, device_t child,
7856893Sfenner		    int reg, uint32_t val, int width);
7956893Sfennerint		pci_enable_busmaster_method(device_t dev, device_t child);
8056893Sfennerint		pci_disable_busmaster_method(device_t dev, device_t child);
8156893Sfennerint		pci_enable_io_method(device_t dev, device_t child, int space);
8256893Sfennerint		pci_disable_io_method(device_t dev, device_t child, int space);
8356893Sfennerint		pci_find_cap_method(device_t dev, device_t child,
8456893Sfenner		    int capability, int *capreg);
8556893Sfennerint		pci_find_extcap_method(device_t dev, device_t child,
8656893Sfenner		    int capability, int *capreg);
8756893Sfennerint		pci_find_htcap_method(device_t dev, device_t child,
8856893Sfenner		    int capability, int *capreg);
8956893Sfennerint		pci_alloc_msi_method(device_t dev, device_t child, int *count);
9056893Sfennerint		pci_alloc_msix_method(device_t dev, device_t child, int *count);
9156893Sfennerint		pci_remap_msix_method(device_t dev, device_t child,
9256893Sfenner		    int count, const u_int *vectors);
9356893Sfennerint		pci_release_msi_method(device_t dev, device_t child);
9456893Sfennerint		pci_msi_count_method(device_t dev, device_t child);
9556893Sfennerint		pci_msix_count_method(device_t dev, device_t child);
9656893Sfennerstruct resource	*pci_alloc_resource(device_t dev, device_t child,
9756893Sfenner		    int type, int *rid, u_long start, u_long end, u_long count,
98146775Ssam		    u_int flags);
99146775Ssamint		pci_activate_resource(device_t dev, device_t child, int type,
100146775Ssam		    int rid, struct resource *r);
101146775Ssamint		pci_deactivate_resource(device_t dev, device_t child, int type,
102146775Ssam		    int rid, struct resource *r);
103146775Ssamvoid		pci_delete_resource(device_t dev, device_t child,
104146775Ssam		    int type, int rid);
105146775Ssamstruct resource_list *pci_get_resource_list (device_t dev, device_t child);
106146775Ssamstruct pci_devinfo *pci_read_device(device_t pcib, int d, int b, int s, int f,
107146775Ssam		    size_t size);
108146775Ssamvoid		pci_print_verbose(struct pci_devinfo *dinfo);
109146775Ssamint		pci_freecfg(struct pci_devinfo *dinfo);
110146775Ssamint		pci_child_location_str_method(device_t cbdev, device_t child,
111146775Ssam		    char *buf, size_t buflen);
112146775Ssamint		pci_child_pnpinfo_str_method(device_t cbdev, device_t child,
113146775Ssam		    char *buf, size_t buflen);
114146775Ssamint		pci_assign_interrupt_method(device_t dev, device_t child);
115146775Ssamint		pci_resume(device_t dev);
116146775Ssamint		pci_suspend(device_t dev);
117146775Ssam
118146775Ssam/** Restore the config register state.  The state must be previously
119146775Ssam * saved with pci_cfg_save.  However, the pci bus driver takes care of
120146775Ssam * that.  This function will also return the device to PCI_POWERSTATE_D0
121146775Ssam * if it is currently in a lower power mode.
122146775Ssam */
123146775Ssamvoid		pci_cfg_restore(device_t, struct pci_devinfo *);
124146775Ssam
125146775Ssam/** Save the config register state.  Optionally set the power state to D3
126146775Ssam * if the third argument is non-zero.
127146775Ssam */
128146775Ssamvoid		pci_cfg_save(device_t, struct pci_devinfo *, int);
129146775Ssam
130146775Ssam#endif /* _PCI_PRIVATE_H_ */
131146775Ssam