pcib_private.h revision 166176
1228072Sbapt/*-
2228072Sbapt * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier
3228072Sbapt * Copyright (c) 2000 Michael Smith <msmith@freebsd.org>
4228072Sbapt * Copyright (c) 2000 BSDi
5228072Sbapt * All rights reserved.
6228072Sbapt *
7228072Sbapt * Redistribution and use in source and binary forms, with or without
8228072Sbapt * modification, are permitted provided that the following conditions
9228072Sbapt * are met:
10228072Sbapt * 1. Redistributions of source code must retain the above copyright
11228072Sbapt *    notice, this list of conditions and the following disclaimer.
12228072Sbapt * 2. Redistributions in binary form must reproduce the above copyright
13228072Sbapt *    notice, this list of conditions and the following disclaimer in the
14228072Sbapt *    documentation and/or other materials provided with the distribution.
15228072Sbapt * 3. The name of the author may not be used to endorse or promote products
16228072Sbapt *    derived from this software without specific prior written permission.
17228072Sbapt *
18228072Sbapt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19228072Sbapt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20228072Sbapt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21228072Sbapt * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22228072Sbapt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23228072Sbapt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24228072Sbapt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25228072Sbapt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26228072Sbapt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27228072Sbapt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28228072Sbapt * SUCH DAMAGE.
29228072Sbapt *
30228072Sbapt * $FreeBSD: head/sys/dev/pci/pcib_private.h 166176 2007-01-22 21:48:44Z jhb $
31228072Sbapt */
32228072Sbapt
33228072Sbapt#ifndef __PCIB_PRIVATE_H__
34228072Sbapt#define	__PCIB_PRIVATE_H__
35228072Sbapt
36228072Sbapt/*
37228072Sbapt * Export portions of generic PCI:PCI bridge support so that it can be
38228072Sbapt * used by subclasses.
39228072Sbapt */
40228072Sbapt
41228072Sbapt/*
42228072Sbapt * Bridge-specific data.
43228072Sbapt */
44228072Sbaptstruct pcib_softc
45228072Sbapt{
46228072Sbapt    device_t	dev;
47228072Sbapt    uint32_t	flags;		/* flags */
48228072Sbapt#define	PCIB_SUBTRACTIVE	0x1
49228072Sbapt#define	PCIB_DISABLE_MSI	0x2
50228072Sbapt    uint16_t	command;	/* command register */
51228072Sbapt    uint8_t	secbus;		/* secondary bus number */
52228072Sbapt    uint8_t	subbus;		/* subordinate bus number */
53228072Sbapt    pci_addr_t	pmembase;	/* base address of prefetchable memory */
54228072Sbapt    pci_addr_t	pmemlimit;	/* topmost address of prefetchable memory */
55228072Sbapt    pci_addr_t	membase;	/* base address of memory window */
56228072Sbapt    pci_addr_t	memlimit;	/* topmost address of memory window */
57228072Sbapt    uint32_t	iobase;		/* base address of port window */
58228072Sbapt    uint32_t	iolimit;	/* topmost address of port window */
59228072Sbapt    uint16_t	secstat;	/* secondary bus status register */
60228072Sbapt    uint16_t	bridgectl;	/* bridge control register */
61228072Sbapt    uint8_t	seclat;		/* secondary bus latency timer */
62228072Sbapt};
63228072Sbapt
64228072Sbapttypedef uint32_t pci_read_config_fn(int b, int s, int f, int reg, int width);
65228072Sbapt
66228072Sbaptint		host_pcib_get_busno(pci_read_config_fn read_config, int bus,
67228072Sbapt    int slot, int func, uint8_t *busnum);
68228072Sbaptint		pcib_attach(device_t dev);
69228072Sbaptvoid		pcib_attach_common(device_t dev);
70228072Sbaptint		pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result);
71228072Sbaptint		pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value);
72228072Sbaptstruct resource *pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
73228072Sbapt					    u_long start, u_long end, u_long count, u_int flags);
74228072Sbaptint		pcib_maxslots(device_t dev);
75228072Sbaptuint32_t	pcib_read_config(device_t dev, int b, int s, int f, int reg, int width);
76228072Sbaptvoid		pcib_write_config(device_t dev, int b, int s, int f, int reg, uint32_t val, int width);
77228072Sbaptint		pcib_route_interrupt(device_t pcib, device_t dev, int pin);
78228072Sbaptint		pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs);
79228072Sbaptint		pcib_release_msi(device_t pcib, device_t dev, int count, int *irqs);
80228072Sbaptint		pcib_alloc_msix(device_t pcib, device_t dev, int index, int *irq);
81228072Sbaptint		pcib_remap_msix(device_t pcib, device_t dev, int index, int irq);
82228072Sbaptint		pcib_release_msix(device_t pcib, device_t dev, int irq);
83228072Sbapt
84228072Sbapt#endif
85228072Sbapt