xref: /freebsd/sys/dev/cardbus/cardbusvar.h (revision e1d442a6db14adcfc11fc204225037da4332dd21)
1098ca2bdSWarner Losh /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
4f86e6000SWarner Losh  * Copyright (c) 2000,2001 Jonathan Chen. All rights reserved.
5f86e6000SWarner Losh  * Copyright (c) 2008 M. Warner Losh <imp@FreeBSD.org>
6c6793aa8SWarner Losh  *
7c6793aa8SWarner Losh  * Redistribution and use in source and binary forms, with or without
8c6793aa8SWarner Losh  * modification, are permitted provided that the following conditions
9c6793aa8SWarner Losh  * are met:
10c6793aa8SWarner Losh  * 1. Redistributions of source code must retain the above copyright
112dd5c91eSWarner Losh  *    notice, this list of conditions and the following disclaimer.
12c6793aa8SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
132dd5c91eSWarner Losh  *    notice, this list of conditions and the following disclaimer in the
142dd5c91eSWarner Losh  *    documentation and/or other materials provided with the distribution.
15c6793aa8SWarner Losh  *
160db7e66cSJonathan Chen  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
170db7e66cSJonathan Chen  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
180db7e66cSJonathan Chen  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
192dd5c91eSWarner Losh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
202dd5c91eSWarner Losh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
210db7e66cSJonathan Chen  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
220db7e66cSJonathan Chen  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
230db7e66cSJonathan Chen  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
240db7e66cSJonathan Chen  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
250db7e66cSJonathan Chen  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
260db7e66cSJonathan Chen  * SUCH DAMAGE.
27c6793aa8SWarner Losh  */
28c6793aa8SWarner Losh 
290db7e66cSJonathan Chen /*
300db7e66cSJonathan Chen  * Structure definitions for the Cardbus Bus driver
310db7e66cSJonathan Chen  */
32a7de0b74SWarner Losh 
33a7de0b74SWarner Losh /*
34a7de0b74SWarner Losh  * Static copy of the CIS buffer.  Technically, you aren't supposed
35a7de0b74SWarner Losh  * to do this.  In practice, however, it works well.
36a7de0b74SWarner Losh  */
37a7de0b74SWarner Losh struct cis_buffer
38a7de0b74SWarner Losh {
39a7de0b74SWarner Losh 	size_t	len;			/* Actual length of the CIS */
40a7de0b74SWarner Losh 	uint8_t buffer[2040];		/* small enough to be 2k */
41a7de0b74SWarner Losh };
42a7de0b74SWarner Losh 
43a7de0b74SWarner Losh /*
44a7de0b74SWarner Losh  * Per child information for the PCI device.  Cardbus layers on some
45a7de0b74SWarner Losh  * additional data.
46a7de0b74SWarner Losh  */
47abca52f4SWarner Losh struct cardbus_devinfo
48abca52f4SWarner Losh {
497ba175acSWarner Losh 	struct pci_devinfo pci;
5066e390feSWarner Losh 	uint8_t        mprefetchable; /* bit mask of prefetchable BARs */
5166e390feSWarner Losh 	uint8_t        mbelow1mb; /* bit mask of BARs which require below 1Mb */
5266e390feSWarner Losh 	uint16_t	mfrid;		/* manufacturer id */
5366e390feSWarner Losh 	uint16_t	prodid;		/* product id */
54fbe9cff1SWarner Losh 	u_int		funcid;		/* function id */
55fbe9cff1SWarner Losh 	union {
56fbe9cff1SWarner Losh 		struct {
5766e390feSWarner Losh 			uint8_t	nid[6];		/* MAC address */
58fbe9cff1SWarner Losh 		} lan;
59fbe9cff1SWarner Losh 	} funce;
6066e390feSWarner Losh 	uint32_t	fepresent;	/* bit mask of funce values present */
61a7de0b74SWarner Losh 	struct cdev 	*sc_cisdev;
62a7de0b74SWarner Losh 	struct cis_buffer sc_cis;
63c6793aa8SWarner Losh };
6447147ce7SWarner Losh 
65a7de0b74SWarner Losh /*
66a7de0b74SWarner Losh  * Per cardbus soft info.  Not sure why we even keep this around...
67a7de0b74SWarner Losh  */
6847147ce7SWarner Losh struct cardbus_softc
6947147ce7SWarner Losh {
7047147ce7SWarner Losh 	device_t	sc_dev;
714edef187SJohn Baldwin 	struct resource *sc_bus;
7247147ce7SWarner Losh };
7347147ce7SWarner Losh 
74a7de0b74SWarner Losh /*
75a7de0b74SWarner Losh  * Per node callback structures.
76a7de0b74SWarner Losh  */
7747147ce7SWarner Losh struct tuple_callbacks;
7847147ce7SWarner Losh typedef int (tuple_cb) (device_t cbdev, device_t child, int id, int len,
7947147ce7SWarner Losh 		 uint8_t *tupledata, uint32_t start, uint32_t *off,
8047147ce7SWarner Losh 		 struct tuple_callbacks *info, void *);
8147147ce7SWarner Losh struct tuple_callbacks {
8247147ce7SWarner Losh 	int	id;
8347147ce7SWarner Losh 	char	*name;
8447147ce7SWarner Losh 	tuple_cb *func;
8547147ce7SWarner Losh };
8647147ce7SWarner Losh 
87a7de0b74SWarner Losh int	cardbus_device_create(struct cardbus_softc *sc,
88a7de0b74SWarner Losh 	    struct cardbus_devinfo *devi, device_t parent, device_t child);
89a7de0b74SWarner Losh int	cardbus_device_destroy(struct cardbus_devinfo *devi);
9047147ce7SWarner Losh int	cardbus_parse_cis(device_t cbdev, device_t child,
9147147ce7SWarner Losh 	    struct tuple_callbacks *callbacks, void *);
92