1139749Simp/*-
2185015Simp * Copyright (c) 2008, M. Warner Losh
367276Sjon * Copyright (c) 2000,2001 Jonathan Chen.
467276Sjon * All rights reserved.
553343Simp *
653343Simp * Redistribution and use in source and binary forms, with or without
753343Simp * modification, are permitted provided that the following conditions
853343Simp * are met:
953343Simp * 1. Redistributions of source code must retain the above copyright
10140198Simp *    notice, this list of conditions and the following disclaimer.
1153343Simp * 2. Redistributions in binary form must reproduce the above copyright
12140198Simp *    notice, this list of conditions and the following disclaimer in the
13140198Simp *    documentation and/or other materials provided with the distribution.
1453343Simp *
1567276Sjon * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1667276Sjon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1767276Sjon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18140198Simp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19140198Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2067276Sjon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2167276Sjon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2267276Sjon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2367276Sjon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2467276Sjon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2567276Sjon * SUCH DAMAGE.
2653343Simp *
2767276Sjon * $FreeBSD: releng/10.3/sys/dev/cardbus/cardbusvar.h 280970 2015-04-01 21:48:54Z jhb $
2853343Simp */
2953343Simp
3067276Sjon/*
3167276Sjon * Structure definitions for the Cardbus Bus driver
3267276Sjon */
33185015Simp
34185015Simp/*
35185015Simp * Static copy of the CIS buffer.  Technically, you aren't supposed
36185015Simp * to do this.  In practice, however, it works well.
37185015Simp */
38185015Simpstruct cis_buffer
39185015Simp{
40185015Simp	size_t	len;			/* Actual length of the CIS */
41185015Simp	uint8_t buffer[2040];		/* small enough to be 2k */
42185015Simp};
43185015Simp
44185015Simp/*
45185015Simp * Per child information for the PCI device.  Cardbus layers on some
46185015Simp * additional data.
47185015Simp */
48151782Simpstruct cardbus_devinfo
49151782Simp{
5091355Simp	struct pci_devinfo pci;
51109925Simp	uint8_t        mprefetchable; /* bit mask of prefetchable BARs */
52109925Simp	uint8_t        mbelow1mb; /* bit mask of BARs which require below 1Mb */
53109925Simp	uint16_t	mfrid;		/* manufacturer id */
54109925Simp	uint16_t	prodid;		/* product id */
55107301Simp	u_int		funcid;		/* function id */
56107301Simp	union {
57107301Simp		struct {
58109925Simp			uint8_t	nid[6];		/* MAC address */
59107301Simp		} lan;
60107301Simp	} funce;
61109925Simp	uint32_t	fepresent;	/* bit mask of funce values present */
62185015Simp	struct cdev 	*sc_cisdev;
63185015Simp	struct cis_buffer sc_cis;
6453343Simp};
65153811Simp
66185015Simp/*
67185015Simp * Per cardbus soft info.  Not sure why we even keep this around...
68185015Simp */
69153811Simpstruct cardbus_softc
70153811Simp{
71153811Simp	device_t	sc_dev;
72280970Sjhb#ifdef PCI_RES_BUS
73280970Sjhb	struct resource *sc_bus;
74280970Sjhb#endif
75153811Simp};
76153811Simp
77185015Simp/*
78185015Simp * Per node callback structures.
79185015Simp */
80153811Simpstruct tuple_callbacks;
81153811Simptypedef int (tuple_cb) (device_t cbdev, device_t child, int id, int len,
82153811Simp		 uint8_t *tupledata, uint32_t start, uint32_t *off,
83153811Simp		 struct tuple_callbacks *info, void *);
84153811Simpstruct tuple_callbacks {
85153811Simp	int	id;
86153811Simp	char	*name;
87153811Simp	tuple_cb *func;
88153811Simp};
89153811Simp
90185015Simpint	cardbus_device_create(struct cardbus_softc *sc,
91185015Simp	    struct cardbus_devinfo *devi, device_t parent, device_t child);
92185015Simpint	cardbus_device_destroy(struct cardbus_devinfo *devi);
93153811Simpint	cardbus_parse_cis(device_t cbdev, device_t child,
94153811Simp	    struct tuple_callbacks *callbacks, void *);
95