cardslotvar.h revision 1.11 1 1.11 ad /* $NetBSD: cardslotvar.h,v 1.11 2007/07/09 21:00:31 ad 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 char *caa_busname;
49 1.1 haya
50 1.6 haya int caa_slot;
51 1.1 haya
52 1.6 haya /* for cardbus... */
53 1.6 haya struct cbslot_attach_args *caa_cb_attach;
54 1.1 haya
55 1.6 haya /* for 16-bit pcmcia */
56 1.6 haya struct pcmciabus_attach_args *caa_16_attach;
57 1.1 haya
58 1.6 haya /*
59 1.6 haya * XXX: for 16-bit pcmcia. dirty! This should be removed to
60 1.6 haya * achieve MI.
61 1.6 haya */
62 1.6 haya struct pcic_handle *caa_ph;
63 1.1 haya };
64 1.1 haya
65 1.1 haya
66 1.1 haya /*
67 1.1 haya * The data structure cardslot_attach_args is the attach argument for
68 1.1 haya * PCMCIA (including CardBus and 16-bit card) slot.
69 1.1 haya */
70 1.1 haya struct cardslot_softc {
71 1.6 haya struct device sc_dev;
72 1.1 haya
73 1.6 haya int sc_slot; /* slot number */
74 1.6 haya int sc_status; /* the status of slot */
75 1.1 haya
76 1.6 haya struct cardbus_softc *sc_cb_softc;
77 1.6 haya struct pcmcia_softc *sc_16_softc;
78 1.1 haya
79 1.11 ad struct lwp *sc_event_thread;
80 1.6 haya int sc_th_enable; /* true if the thread is enabled */
81 1.1 haya
82 1.6 haya /* An event queue for the thread which processes slot state events. */
83 1.1 haya
84 1.6 haya SIMPLEQ_HEAD(, cardslot_event) sc_events;
85 1.1 haya };
86 1.1 haya
87 1.1 haya #define CARDSLOT_STATUS_CARD_MASK 0x07
88 1.1 haya #define CARDSLOT_STATUS_CARD_NONE 0x00 /* NO card inserted */
89 1.1 haya #define CARDSLOT_STATUS_CARD_16 0x01 /* 16-bit pcmcia card inserted */
90 1.1 haya #define CARDSLOT_STATUS_CARD_CB 0x02 /* CardBus pcmcia card inserted */
91 1.1 haya #define CARDSLOT_STATUS_UNKNOWN 0x07 /* Unknown card inserted */
92 1.1 haya
93 1.1 haya #define CARDSLOT_CARDTYPE(x) ((x) & CARDSLOT_STATUS_CARD_MASK)
94 1.1 haya #define CARDSLOT_SET_CARDTYPE(x, type) \
95 1.1 haya do {(x) &= ~CARDSLOT_STATUS_CARD_MASK;\
96 1.1 haya (x) |= (CARDSLOT_STATUS_CARD_MASK & (type));} while(0)
97 1.1 haya
98 1.1 haya #define CARDSLOT_STATUS_WORK_MASK 0x08
99 1.1 haya #define CARDSLOT_STATUS_WORKING 0x08 /* at least one function works */
100 1.1 haya #define CARDSLOT_STATUS_NOTWORK 0x00 /* no functions are working */
101 1.3 haya
102 1.3 haya #define CARDSLOT_WORK(x) ((x) & CARDSLOT_STATUS_WORK_MASK)
103 1.3 haya #define CARDSLOT_SET_WORK(x, type) \
104 1.3 haya do {(x) &= ~CARDSLOT_STATUS_WORK_MASK;\
105 1.3 haya (x) |= (CARDSLOT_STATUS_WORK_MASK & (type));} while(0)
106 1.1 haya
107 1.1 haya
108 1.1 haya struct cardslot_event {
109 1.6 haya SIMPLEQ_ENTRY(cardslot_event) ce_q;
110 1.1 haya
111 1.6 haya int ce_type;
112 1.1 haya };
113 1.1 haya
114 1.1 haya typedef struct cardslot_softc *cardslot_t;
115 1.1 haya
116 1.1 haya /* ce_type */
117 1.1 haya #define CARDSLOT_EVENT_INSERTION_16 0
118 1.1 haya #define CARDSLOT_EVENT_REMOVAL_16 1
119 1.1 haya
120 1.1 haya #define CARDSLOT_EVENT_INSERTION_CB 2
121 1.1 haya #define CARDSLOT_EVENT_REMOVAL_CB 3
122 1.1 haya
123 1.1 haya #define IS_CARDSLOT_INSERT_REMOVE_EV(x) (0 <= (x) && (x) <= 3)
124 1.1 haya
125 1.9 perry void cardslot_event_throw(cardslot_t, int);
126 1.1 haya
127 1.4 kleink #endif /* !_DEV_CARDBUS_CARDSLOTVAR_H_ */
128