1 #
2 # Copyright (c) 1999 M. Warner Losh.
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 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 # SUCH DAMAGE.
25 #
26 # $FreeBSD: releng/5.1/sys/dev/pccard/card_if.m 106362 2002-11-02 23:00:28Z imp $
27 #
28
29 #include <sys/bus.h>
30 #include <dev/pccard/pccardvar.h>
31
32 INTERFACE card;
33
34 # WARNING: THIS FILE IS USED BY BOTH OLDCARD AND NEWCARD. MAKE SURE
35 # YOU TEST BOTH KERNELS IF CHANGING THIS FILE.
36
37 #
38 # Companion interface for pccard. We need to set attributes for memory
39 # and i/o port mappings (as well as other types of attributes) that have
40 # a well defined meaning inside the pccard/cardbus system. The bus
41 # methods are inadequate for this because this must be done at the time the
42 # resources are set for the device, which predates their activation. Also,
43 # the driver activating the resources doesn't necessarily know or need to know
44 # these attributes.
45 #
46 METHOD int set_res_flags {
47 device_t dev;
48 device_t child;
49 int restype;
50 int rid;
51 u_long value;
52 };
53
54 METHOD int get_res_flags {
55 device_t dev;
56 device_t child;
57 int restype;
58 int rid;
59 u_long *value;
60 };
61
62 #
63 # Sets the memory offset of the pccard bridge's window into attribute
64 # or common memory space.
65 #
66 METHOD int set_memory_offset {
67 device_t dev;
68 device_t child;
69 int rid;
70 u_int32_t cardaddr;
71 u_int32_t *deltap;
72 }
73
74 METHOD int get_memory_offset {
75 device_t dev;
76 device_t child;
77 int rid;
78 u_int32_t *offset;
79 }
80
81 #
82 # pccard bridges call this method to initate the attachment of a card
83 #
84 METHOD int attach_card {
85 device_t dev;
86 }
87
88 #
89 # pccard bridges call this to detach a card.
90 #
91 METHOD int detach_card {
92 device_t dev;
93 }
94
95 #
96 # Returns the type of card this is. Maybe we don't need this.
97 #
98 METHOD int get_type {
99 device_t dev;
100 int *type;
101 }
102
103 #
104 # Returns the function number for this device.
105 #
106 METHOD int get_function {
107 device_t dev;
108 device_t child;
109 int *func;
110 }
111
112 #
113 # Activates (and powers up if necessary) the card's nth function
114 # since each function gets its own device, there is no need to
115 # to specify a function number
116 #
117 METHOD int activate_function {
118 device_t dev;
119 device_t child;
120 }
121
122 METHOD int deactivate_function {
123 device_t dev;
124 device_t child;
125 }
126
127 #
128 # Compatibility methods for OLDCARD drivers. We use these routines to make
129 # it possible to call the OLDCARD driver's probe routine in the context that
130 # it expects. For OLDCARD these are implemented as pass throughs to the
131 # device_{probe,attach} routines. For NEWCARD they are implemented such
132 # such that probe becomes strictly a matching routine and attach does both
133 # the old probe and old attach.
134 #
135 # compat devices should use the following:
136 #
137 # /* Device interface */
138 # DEVMETHOD(device_probe), pccard_compat_probe),
139 # DEVMETHOD(device_attach), pccard_compat_attach),
140 # /* Card interface */
141 # DEVMETHOD(card_compat_match, foo_match), /* newly written */
142 # DEVMETHOD(card_compat_probe, foo_probe), /* old probe */
143 # DEVMETHOD(card_compat_attach, foo_attach), /* old attach */
144 #
145 # This will allow a single driver binary image to be used for both
146 # OLDCARD and NEWCARD.
147 #
148 # Drivers wishing to not retain OLDCARD compatibility needn't do this.
149 #
150 # The compat_do_* versions are so that we can make the pccard_compat_probe
151 # and _attach static lines and have the bus system pick the right version
152 # to use so we don't enshrine pccard_* symbols in the driver's module.
153 #
154 METHOD int compat_probe {
155 device_t dev;
156 }
157
158 METHOD int compat_attach {
159 device_t dev;
160 }
161
162 CODE {
163 static int null_do_probe(device_t bus, device_t dev)
164 {
165 return (CARD_COMPAT_DO_PROBE(device_get_parent(bus), dev));
166 }
167
168 static int null_do_attach(device_t bus, device_t dev)
169 {
170 return (CARD_COMPAT_DO_ATTACH(device_get_parent(bus), dev));
171 }
172 }
173
174 METHOD int compat_do_probe {
175 device_t bus;
176 device_t dev;
177 } DEFAULT null_do_probe;
178
179 METHOD int compat_do_attach {
180 device_t bus;
181 device_t dev;
182 } DEFAULT null_do_attach;
183
184 #
185 # Find "dev" in the passed table of devices. Return it or NULL.
186 #
187 METHOD struct pccard_product * do_product_lookup {
188 device_t bus;
189 device_t dev;
190 const struct pccard_product *tab;
191 size_t ent_size;
192 pccard_product_match_fn matchfn;
193 }
194
195 #
196 # Helper method for the above. When a compatibility driver is converted,
197 # one must write a match routine. This routine is unused on OLDCARD but
198 # is used as a discriminator for NEWCARD.
199 #
200 METHOD int compat_match {
201 device_t dev;
202 }
203
204 #
205 # Method for devices to ask its CIS-enabled parent bus for CIS info.
206 # Device driver requests all tuples if type 'id', the routine places
207 # 'nret' number of tuples in 'buff'. Returns 0 if all tuples processed,
208 # or an error code if processing was aborted.
209 # Users of this method will be responsible for freeing the memory allocated
210 # by calling the cis_free method.
211 #
212
213 HEADER {
214 struct cis_tupleinfo {
215 u_int8_t id;
216 int len;
217 char *data;
218 };
219 };
220
221 CODE {
222 static int
223 null_cis_read(device_t dev, device_t child, u_int8_t id,
224 struct cis_tupleinfo **buff, int *nret)
225 {
226 *nret = 0;
227 *buff = NULL;
228 return ENXIO;
229 }
230
231 static void
232 null_cis_free(device_t dev, struct cis_tupleinfo *buff, int *nret)
233 {
234 return;
235 }
236 };
237
238 METHOD int cis_read {
239 device_t dev;
240 device_t child;
241 u_int8_t id;
242 struct cis_tupleinfo **buff;
243 int *nret;
244 } DEFAULT null_cis_read;
245
246 METHOD int cis_free {
247 device_t dev;
248 struct cis_tupleinfo *buff;
249 int nret;
250 } DEFAULT null_cis_free;
251
Cache object: 47e84e73cd9e86f8b98bf701ec773388
|