xref: /freebsd/sys/dev/cardbus/cardbusvar.h (revision 718cf2ccb9956613756ab15d7a0e28f2c8e91cab)
1098ca2bdSWarner Losh /*-
2*718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*718cf2ccSPedro F. Giffuni  *
4a7de0b74SWarner Losh  * Copyright (c) 2008, M. Warner Losh
50db7e66cSJonathan Chen  * Copyright (c) 2000,2001 Jonathan Chen.
60db7e66cSJonathan Chen  * All rights reserved.
7c6793aa8SWarner Losh  *
8c6793aa8SWarner Losh  * Redistribution and use in source and binary forms, with or without
9c6793aa8SWarner Losh  * modification, are permitted provided that the following conditions
10c6793aa8SWarner Losh  * are met:
11c6793aa8SWarner Losh  * 1. Redistributions of source code must retain the above copyright
122dd5c91eSWarner Losh  *    notice, this list of conditions and the following disclaimer.
13c6793aa8SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
142dd5c91eSWarner Losh  *    notice, this list of conditions and the following disclaimer in the
152dd5c91eSWarner Losh  *    documentation and/or other materials provided with the distribution.
16c6793aa8SWarner Losh  *
170db7e66cSJonathan Chen  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
180db7e66cSJonathan Chen  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
190db7e66cSJonathan Chen  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
202dd5c91eSWarner Losh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
212dd5c91eSWarner Losh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
220db7e66cSJonathan Chen  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
230db7e66cSJonathan Chen  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
240db7e66cSJonathan Chen  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
250db7e66cSJonathan Chen  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
260db7e66cSJonathan Chen  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
270db7e66cSJonathan Chen  * SUCH DAMAGE.
28c6793aa8SWarner Losh  *
290db7e66cSJonathan Chen  * $FreeBSD$
30c6793aa8SWarner Losh  */
31c6793aa8SWarner Losh 
320db7e66cSJonathan Chen /*
330db7e66cSJonathan Chen  * Structure definitions for the Cardbus Bus driver
340db7e66cSJonathan Chen  */
35a7de0b74SWarner Losh 
36a7de0b74SWarner Losh /*
37a7de0b74SWarner Losh  * Static copy of the CIS buffer.  Technically, you aren't supposed
38a7de0b74SWarner Losh  * to do this.  In practice, however, it works well.
39a7de0b74SWarner Losh  */
40a7de0b74SWarner Losh struct cis_buffer
41a7de0b74SWarner Losh {
42a7de0b74SWarner Losh 	size_t	len;			/* Actual length of the CIS */
43a7de0b74SWarner Losh 	uint8_t buffer[2040];		/* small enough to be 2k */
44a7de0b74SWarner Losh };
45a7de0b74SWarner Losh 
46a7de0b74SWarner Losh /*
47a7de0b74SWarner Losh  * Per child information for the PCI device.  Cardbus layers on some
48a7de0b74SWarner Losh  * additional data.
49a7de0b74SWarner Losh  */
50abca52f4SWarner Losh struct cardbus_devinfo
51abca52f4SWarner Losh {
527ba175acSWarner Losh 	struct pci_devinfo pci;
5366e390feSWarner Losh 	uint8_t        mprefetchable; /* bit mask of prefetchable BARs */
5466e390feSWarner Losh 	uint8_t        mbelow1mb; /* bit mask of BARs which require below 1Mb */
5566e390feSWarner Losh 	uint16_t	mfrid;		/* manufacturer id */
5666e390feSWarner Losh 	uint16_t	prodid;		/* product id */
57fbe9cff1SWarner Losh 	u_int		funcid;		/* function id */
58fbe9cff1SWarner Losh 	union {
59fbe9cff1SWarner Losh 		struct {
6066e390feSWarner Losh 			uint8_t	nid[6];		/* MAC address */
61fbe9cff1SWarner Losh 		} lan;
62fbe9cff1SWarner Losh 	} funce;
6366e390feSWarner Losh 	uint32_t	fepresent;	/* bit mask of funce values present */
64a7de0b74SWarner Losh 	struct cdev 	*sc_cisdev;
65a7de0b74SWarner Losh 	struct cis_buffer sc_cis;
66c6793aa8SWarner Losh };
6747147ce7SWarner Losh 
68a7de0b74SWarner Losh /*
69a7de0b74SWarner Losh  * Per cardbus soft info.  Not sure why we even keep this around...
70a7de0b74SWarner Losh  */
7147147ce7SWarner Losh struct cardbus_softc
7247147ce7SWarner Losh {
7347147ce7SWarner Losh 	device_t	sc_dev;
744edef187SJohn Baldwin #ifdef PCI_RES_BUS
754edef187SJohn Baldwin 	struct resource *sc_bus;
764edef187SJohn Baldwin #endif
7747147ce7SWarner Losh };
7847147ce7SWarner Losh 
79a7de0b74SWarner Losh /*
80a7de0b74SWarner Losh  * Per node callback structures.
81a7de0b74SWarner Losh  */
8247147ce7SWarner Losh struct tuple_callbacks;
8347147ce7SWarner Losh typedef int (tuple_cb) (device_t cbdev, device_t child, int id, int len,
8447147ce7SWarner Losh 		 uint8_t *tupledata, uint32_t start, uint32_t *off,
8547147ce7SWarner Losh 		 struct tuple_callbacks *info, void *);
8647147ce7SWarner Losh struct tuple_callbacks {
8747147ce7SWarner Losh 	int	id;
8847147ce7SWarner Losh 	char	*name;
8947147ce7SWarner Losh 	tuple_cb *func;
9047147ce7SWarner Losh };
9147147ce7SWarner Losh 
92a7de0b74SWarner Losh int	cardbus_device_create(struct cardbus_softc *sc,
93a7de0b74SWarner Losh 	    struct cardbus_devinfo *devi, device_t parent, device_t child);
94a7de0b74SWarner Losh int	cardbus_device_destroy(struct cardbus_devinfo *devi);
9547147ce7SWarner Losh int	cardbus_parse_cis(device_t cbdev, device_t child,
9647147ce7SWarner Losh 	    struct tuple_callbacks *callbacks, void *);
97