xref: /freebsd/sys/dev/cardbus/cardbusvar.h (revision 4edef187b8acc2ca09a38cb6bb6969ff5ead938b)
1098ca2bdSWarner Losh /*-
2a7de0b74SWarner Losh  * Copyright (c) 2008, M. Warner Losh
30db7e66cSJonathan Chen  * Copyright (c) 2000,2001 Jonathan Chen.
40db7e66cSJonathan Chen  * All rights reserved.
5c6793aa8SWarner Losh  *
6c6793aa8SWarner Losh  * Redistribution and use in source and binary forms, with or without
7c6793aa8SWarner Losh  * modification, are permitted provided that the following conditions
8c6793aa8SWarner Losh  * are met:
9c6793aa8SWarner Losh  * 1. Redistributions of source code must retain the above copyright
102dd5c91eSWarner Losh  *    notice, this list of conditions and the following disclaimer.
11c6793aa8SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
122dd5c91eSWarner Losh  *    notice, this list of conditions and the following disclaimer in the
132dd5c91eSWarner Losh  *    documentation and/or other materials provided with the distribution.
14c6793aa8SWarner Losh  *
150db7e66cSJonathan Chen  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
160db7e66cSJonathan Chen  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
170db7e66cSJonathan Chen  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
182dd5c91eSWarner Losh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
192dd5c91eSWarner Losh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
200db7e66cSJonathan Chen  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
210db7e66cSJonathan Chen  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
220db7e66cSJonathan Chen  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
230db7e66cSJonathan Chen  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
240db7e66cSJonathan Chen  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
250db7e66cSJonathan Chen  * SUCH DAMAGE.
26c6793aa8SWarner Losh  *
270db7e66cSJonathan Chen  * $FreeBSD$
28c6793aa8SWarner Losh  */
29c6793aa8SWarner Losh 
300db7e66cSJonathan Chen /*
310db7e66cSJonathan Chen  * Structure definitions for the Cardbus Bus driver
320db7e66cSJonathan Chen  */
33a7de0b74SWarner Losh 
34a7de0b74SWarner Losh /*
35a7de0b74SWarner Losh  * Static copy of the CIS buffer.  Technically, you aren't supposed
36a7de0b74SWarner Losh  * to do this.  In practice, however, it works well.
37a7de0b74SWarner Losh  */
38a7de0b74SWarner Losh struct cis_buffer
39a7de0b74SWarner Losh {
40a7de0b74SWarner Losh 	size_t	len;			/* Actual length of the CIS */
41a7de0b74SWarner Losh 	uint8_t buffer[2040];		/* small enough to be 2k */
42a7de0b74SWarner Losh };
43a7de0b74SWarner Losh 
44a7de0b74SWarner Losh /*
45a7de0b74SWarner Losh  * Per child information for the PCI device.  Cardbus layers on some
46a7de0b74SWarner Losh  * additional data.
47a7de0b74SWarner Losh  */
48abca52f4SWarner Losh struct cardbus_devinfo
49abca52f4SWarner Losh {
507ba175acSWarner Losh 	struct pci_devinfo pci;
5166e390feSWarner Losh 	uint8_t        mprefetchable; /* bit mask of prefetchable BARs */
5266e390feSWarner Losh 	uint8_t        mbelow1mb; /* bit mask of BARs which require below 1Mb */
5366e390feSWarner Losh 	uint16_t	mfrid;		/* manufacturer id */
5466e390feSWarner Losh 	uint16_t	prodid;		/* product id */
55fbe9cff1SWarner Losh 	u_int		funcid;		/* function id */
56fbe9cff1SWarner Losh 	union {
57fbe9cff1SWarner Losh 		struct {
5866e390feSWarner Losh 			uint8_t	nid[6];		/* MAC address */
59fbe9cff1SWarner Losh 		} lan;
60fbe9cff1SWarner Losh 	} funce;
6166e390feSWarner Losh 	uint32_t	fepresent;	/* bit mask of funce values present */
62a7de0b74SWarner Losh 	struct cdev 	*sc_cisdev;
63a7de0b74SWarner Losh 	struct cis_buffer sc_cis;
64c6793aa8SWarner Losh };
6547147ce7SWarner Losh 
66a7de0b74SWarner Losh /*
67a7de0b74SWarner Losh  * Per cardbus soft info.  Not sure why we even keep this around...
68a7de0b74SWarner Losh  */
6947147ce7SWarner Losh struct cardbus_softc
7047147ce7SWarner Losh {
7147147ce7SWarner Losh 	device_t	sc_dev;
72*4edef187SJohn Baldwin #ifdef PCI_RES_BUS
73*4edef187SJohn Baldwin 	struct resource *sc_bus;
74*4edef187SJohn Baldwin #endif
7547147ce7SWarner Losh };
7647147ce7SWarner Losh 
77a7de0b74SWarner Losh /*
78a7de0b74SWarner Losh  * Per node callback structures.
79a7de0b74SWarner Losh  */
8047147ce7SWarner Losh struct tuple_callbacks;
8147147ce7SWarner Losh typedef int (tuple_cb) (device_t cbdev, device_t child, int id, int len,
8247147ce7SWarner Losh 		 uint8_t *tupledata, uint32_t start, uint32_t *off,
8347147ce7SWarner Losh 		 struct tuple_callbacks *info, void *);
8447147ce7SWarner Losh struct tuple_callbacks {
8547147ce7SWarner Losh 	int	id;
8647147ce7SWarner Losh 	char	*name;
8747147ce7SWarner Losh 	tuple_cb *func;
8847147ce7SWarner Losh };
8947147ce7SWarner Losh 
90a7de0b74SWarner Losh int	cardbus_device_create(struct cardbus_softc *sc,
91a7de0b74SWarner Losh 	    struct cardbus_devinfo *devi, device_t parent, device_t child);
92a7de0b74SWarner Losh int	cardbus_device_destroy(struct cardbus_devinfo *devi);
9347147ce7SWarner Losh int	cardbus_parse_cis(device_t cbdev, device_t child,
9447147ce7SWarner Losh 	    struct tuple_callbacks *callbacks, void *);
95