xref: /dragonfly/sys/dev/pccard/pccbb/pccbbvar.h (revision 49781055)
1 /*
2  * Copyright (c) 2000,2001 Jonathan Chen.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions, and the following disclaimer,
10  *    without modification, immediately at the beginning of the file.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in
13  *    the documentation and/or other materials provided with the
14  *    distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD: src/sys/dev/pccbb/pccbbvar.h,v 1.15 2002/10/07 23:11:29 imp Exp $
29  * $DragonFly: src/sys/dev/pccard/pccbb/pccbbvar.h,v 1.2 2005/12/19 01:18:58 dillon Exp $
30  */
31 
32 /*
33  * Structure definitions for the Cardbus Bridge driver
34  */
35 
36 struct cbb_intrhand {
37 	driver_intr_t *intr;
38 	void	*arg;
39 	struct lwkt_serialize *serializer;
40 	STAILQ_ENTRY(cbb_intrhand) entries;
41 };
42 
43 struct cbb_reslist {
44 	SLIST_ENTRY(cbb_reslist) link;
45 	struct	resource *res;
46 	int	type;
47 	int	rid;
48 		/* note: unlike the regular resource list, there can be
49 		 * duplicate rid's in the same list.  However, the
50 		 * combination of rid and res->r_dev should be unique.
51 		 */
52 	bus_addr_t cardaddr; /* for 16-bit pccard memory */
53 };
54 
55 #define	CBB_AUTO_OPEN_SMALLHOLE 0x100
56 
57 struct cbb_softc {
58 	device_t	dev;
59 	struct exca_softc exca;
60 	struct		resource *base_res;
61 	struct		resource *irq_res;
62 	void		*intrhand;
63 	bus_space_tag_t bst;
64 	bus_space_handle_t bsh;
65 	u_int8_t	secbus;
66 	u_int8_t	subbus;
67 	struct lock	lock;
68 	u_int32_t	flags;
69 #define CBB_CARD_OK		0x08000000
70 #define	CBB_KLUDGE_ALLOC	0x10000000
71 #define	CBB_16BIT_CARD		0x20000000
72 #define	CBB_KTHREAD_RUNNING	0x40000000
73 #define	CBB_KTHREAD_DONE	0x80000000
74 	int		chipset;		/* chipset id */
75 #define	CB_UNKNOWN	0		/* NOT Cardbus-PCI bridge */
76 #define	CB_TI113X	1		/* TI PCI1130/1131 */
77 #define	CB_TI12XX	2		/* TI PCI12xx/14xx/44xx/15xx/45xx */
78 #define	CB_TI125X	3		/* TI PCI1250/1251(B)/1450 */
79 #define	CB_RF5C47X	4		/* RICOH RF5C475/476/477 */
80 #define	CB_RF5C46X	5		/* RICOH RF5C465/466/467 */
81 #define	CB_CIRRUS	6		/* Cirrus Logic CLPD683x */
82 #define	CB_TOPIC95	7		/* Toshiba ToPIC95 */
83 #define	CB_TOPIC97	8		/* Toshiba ToPIC97/100 */
84 	SLIST_HEAD(, cbb_reslist) rl;
85 	STAILQ_HEAD(, cbb_intrhand) intr_handlers;
86 
87 	device_t	cbdev;
88 	device_t	pccarddev;
89 
90 	struct thread	*event_thread;
91 };
92 
93 /* result of detect_card */
94 #define	CARD_UKN_CARD	0x00
95 #define	CARD_5V_CARD	0x01
96 #define	CARD_3V_CARD	0x02
97 #define	CARD_XV_CARD	0x04
98 #define	CARD_YV_CARD	0x08
99 
100 /* for power_socket */
101 #define	CARD_VCC_UC	0x0000
102 #define	CARD_VCC_3V	0x0001
103 #define	CARD_VCC_XV	0x0002
104 #define	CARD_VCC_YV	0x0003
105 #define	CARD_VCC_0V	0x0004
106 #define	CARD_VCC_5V	0x0005
107 #define	CARD_VCCMASK	0x000f
108 #define	CARD_VPP_UC	0x0000
109 #define	CARD_VPP_VCC	0x0010
110 #define	CARD_VPP_12V	0x0030
111 #define	CARD_VPP_0V	0x0040
112 #define	CARD_VPPMASK	0x00f0
113