cardslotvar.h revision 1.15 1 1.15 drochner /* $NetBSD: cardslotvar.h,v 1.15 2008/07/03 18:57:52 drochner Exp $ */
2 1.1 haya
3 1.1 haya /*
4 1.1 haya * Copyright (c) 1999
5 1.1 haya * HAYAKAWA Koichi. All rights reserved.
6 1.1 haya *
7 1.1 haya * Redistribution and use in source and binary forms, with or without
8 1.1 haya * modification, are permitted provided that the following conditions
9 1.1 haya * are met:
10 1.1 haya * 1. Redistributions of source code must retain the above copyright
11 1.1 haya * notice, this list of conditions and the following disclaimer.
12 1.1 haya * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 haya * notice, this list of conditions and the following disclaimer in the
14 1.1 haya * documentation and/or other materials provided with the distribution.
15 1.1 haya * 3. All advertising materials mentioning features or use of this software
16 1.1 haya * must display the following acknowledgement:
17 1.1 haya * This product includes software developed by the author.
18 1.1 haya * 4. The name of the author may not be used to endorse or promote products
19 1.1 haya * derived from this software without specific prior written permission.
20 1.1 haya *
21 1.1 haya *
22 1.1 haya * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 haya * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 1.1 haya * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 1.1 haya * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
26 1.1 haya * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 1.1 haya * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 1.1 haya * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 haya * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 1.1 haya * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 1.1 haya * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 1.1 haya * POSSIBILITY OF SUCH DAMAGE.
33 1.1 haya */
34 1.1 haya
35 1.4 kleink #ifndef _DEV_CARDBUS_CARDSLOTVAR_H_
36 1.4 kleink #define _DEV_CARDBUS_CARDSLOTVAR_H_
37 1.1 haya
38 1.1 haya /* require sys/device.h */
39 1.1 haya /* require sys/queue.h */
40 1.1 haya
41 1.1 haya struct cardslot_event;
42 1.1 haya
43 1.1 haya /*
44 1.1 haya * The data structure cardslot_attach_args is the attach argument for
45 1.1 haya * PCMCIA (including CardBus and 16-bit card) slot.
46 1.1 haya */
47 1.1 haya struct cardslot_attach_args {
48 1.6 haya /* for cardbus... */
49 1.6 haya struct cbslot_attach_args *caa_cb_attach;
50 1.1 haya
51 1.6 haya /* for 16-bit pcmcia */
52 1.6 haya struct pcmciabus_attach_args *caa_16_attach;
53 1.1 haya };
54 1.1 haya
55 1.1 haya
56 1.1 haya /*
57 1.1 haya * The data structure cardslot_attach_args is the attach argument for
58 1.1 haya * PCMCIA (including CardBus and 16-bit card) slot.
59 1.1 haya */
60 1.1 haya struct cardslot_softc {
61 1.13 drochner device_t sc_dev;
62 1.1 haya
63 1.6 haya int sc_status; /* the status of slot */
64 1.1 haya
65 1.6 haya struct cardbus_softc *sc_cb_softc;
66 1.15 drochner device_t sc_16_softc;
67 1.1 haya
68 1.11 ad struct lwp *sc_event_thread;
69 1.6 haya int sc_th_enable; /* true if the thread is enabled */
70 1.1 haya
71 1.6 haya /* An event queue for the thread which processes slot state events. */
72 1.1 haya
73 1.6 haya SIMPLEQ_HEAD(, cardslot_event) sc_events;
74 1.1 haya };
75 1.1 haya
76 1.1 haya #define CARDSLOT_STATUS_CARD_MASK 0x07
77 1.1 haya #define CARDSLOT_STATUS_CARD_NONE 0x00 /* NO card inserted */
78 1.1 haya #define CARDSLOT_STATUS_CARD_16 0x01 /* 16-bit pcmcia card inserted */
79 1.1 haya #define CARDSLOT_STATUS_CARD_CB 0x02 /* CardBus pcmcia card inserted */
80 1.1 haya #define CARDSLOT_STATUS_UNKNOWN 0x07 /* Unknown card inserted */
81 1.1 haya
82 1.1 haya #define CARDSLOT_CARDTYPE(x) ((x) & CARDSLOT_STATUS_CARD_MASK)
83 1.1 haya #define CARDSLOT_SET_CARDTYPE(x, type) \
84 1.1 haya do {(x) &= ~CARDSLOT_STATUS_CARD_MASK;\
85 1.1 haya (x) |= (CARDSLOT_STATUS_CARD_MASK & (type));} while(0)
86 1.1 haya
87 1.1 haya #define CARDSLOT_STATUS_WORK_MASK 0x08
88 1.1 haya #define CARDSLOT_STATUS_WORKING 0x08 /* at least one function works */
89 1.1 haya #define CARDSLOT_STATUS_NOTWORK 0x00 /* no functions are working */
90 1.3 haya
91 1.3 haya #define CARDSLOT_WORK(x) ((x) & CARDSLOT_STATUS_WORK_MASK)
92 1.3 haya #define CARDSLOT_SET_WORK(x, type) \
93 1.3 haya do {(x) &= ~CARDSLOT_STATUS_WORK_MASK;\
94 1.3 haya (x) |= (CARDSLOT_STATUS_WORK_MASK & (type));} while(0)
95 1.1 haya
96 1.1 haya
97 1.1 haya struct cardslot_event {
98 1.6 haya SIMPLEQ_ENTRY(cardslot_event) ce_q;
99 1.1 haya
100 1.6 haya int ce_type;
101 1.1 haya };
102 1.1 haya
103 1.1 haya /* ce_type */
104 1.1 haya #define CARDSLOT_EVENT_INSERTION_16 0
105 1.1 haya #define CARDSLOT_EVENT_REMOVAL_16 1
106 1.1 haya
107 1.1 haya #define CARDSLOT_EVENT_INSERTION_CB 2
108 1.1 haya #define CARDSLOT_EVENT_REMOVAL_CB 3
109 1.1 haya
110 1.1 haya #define IS_CARDSLOT_INSERT_REMOVE_EV(x) (0 <= (x) && (x) <= 3)
111 1.1 haya
112 1.13 drochner void cardslot_event_throw(struct cardslot_softc *, int);
113 1.1 haya
114 1.4 kleink #endif /* !_DEV_CARDBUS_CARDSLOTVAR_H_ */
115