]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * ds.h -- 16-bit PCMCIA core support | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License version 2 as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * The initial developer of the original code is David A. Hinds | |
9 | * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds | |
10 | * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. | |
11 | * | |
12 | * (C) 1999 David A. Hinds | |
a5835786 | 13 | * (C) 2003 - 2008 Dominik Brodowski |
1da177e4 LT |
14 | */ |
15 | ||
16 | #ifndef _LINUX_DS_H | |
17 | #define _LINUX_DS_H | |
18 | ||
8e2f3b70 DB |
19 | #ifdef __KERNEL__ |
20 | #include <linux/mod_devicetable.h> | |
21 | #endif | |
22 | ||
1da177e4 | 23 | #include <pcmcia/cs_types.h> |
1ad275e3 | 24 | #include <pcmcia/device_id.h> |
1da177e4 | 25 | |
1da177e4 LT |
26 | #ifdef __KERNEL__ |
27 | #include <linux/device.h> | |
e2d40963 | 28 | #include <pcmcia/ss.h> |
04de0816 | 29 | #include <asm/atomic.h> |
1da177e4 | 30 | |
a5835786 DB |
31 | /* |
32 | * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus | |
33 | * a.k.a. PCI drivers | |
34 | */ | |
1da177e4 | 35 | struct pcmcia_socket; |
a5835786 | 36 | struct pcmcia_device; |
dbb22f0d | 37 | struct config_t; |
91284224 | 38 | struct net_device; |
1da177e4 | 39 | |
a5835786 DB |
40 | /* dynamic device IDs for PCMCIA device drivers. See |
41 | * Documentation/pcmcia/driver.txt for details. | |
42 | */ | |
6179b556 | 43 | struct pcmcia_dynids { |
3f565232 | 44 | struct mutex lock; |
6179b556 BW |
45 | struct list_head list; |
46 | }; | |
47 | ||
1da177e4 | 48 | struct pcmcia_driver { |
f8cfa618 | 49 | int (*probe) (struct pcmcia_device *dev); |
cc3b4866 DB |
50 | void (*remove) (struct pcmcia_device *dev); |
51 | ||
98e4c28b DB |
52 | int (*suspend) (struct pcmcia_device *dev); |
53 | int (*resume) (struct pcmcia_device *dev); | |
54 | ||
1da177e4 | 55 | struct module *owner; |
1ad275e3 | 56 | struct pcmcia_device_id *id_table; |
1da177e4 | 57 | struct device_driver drv; |
6179b556 | 58 | struct pcmcia_dynids dynids; |
1da177e4 LT |
59 | }; |
60 | ||
61 | /* driver registration */ | |
62 | int pcmcia_register_driver(struct pcmcia_driver *driver); | |
63 | void pcmcia_unregister_driver(struct pcmcia_driver *driver); | |
64 | ||
a5835786 DB |
65 | /* Some drivers use dev_node_t to store char or block device information. |
66 | * Don't use this in new drivers, though. | |
67 | */ | |
68 | typedef struct dev_node_t { | |
69 | char dev_name[DEV_NAME_LEN]; | |
70 | u_short major, minor; | |
71 | struct dev_node_t *next; | |
72 | } dev_node_t; | |
e2d40963 | 73 | |
1da177e4 LT |
74 | struct pcmcia_device { |
75 | /* the socket and the device_no [for multifunction devices] | |
76 | uniquely define a pcmcia_device */ | |
77 | struct pcmcia_socket *socket; | |
78 | ||
bd65a685 BG |
79 | char *devname; |
80 | ||
1da177e4 LT |
81 | u8 device_no; |
82 | ||
83 | /* the hardware "function" device; certain subdevices can | |
84 | * share one hardware "function" device. */ | |
85 | u8 func; | |
9fea84f4 | 86 | struct config_t *function_config; |
1da177e4 LT |
87 | |
88 | struct list_head socket_device_list; | |
89 | ||
fd238232 DB |
90 | /* deprecated, will be cleaned up soon */ |
91 | dev_node_t *dev_node; | |
fd238232 | 92 | u_int open; |
fd238232 DB |
93 | io_req_t io; |
94 | irq_req_t irq; | |
95 | config_req_t conf; | |
96 | window_handle_t win; | |
fd238232 | 97 | |
6f0f38c4 DB |
98 | /* device setup */ |
99 | unsigned int irq_v; /* do not use directly yet */ | |
100 | ||
04de0816 | 101 | /* Is the device suspended? */ |
e2d40963 DB |
102 | u16 suspended:1; |
103 | ||
104 | /* Flags whether io, irq, win configurations were | |
105 | * requested, and whether the configuration is "locked" */ | |
106 | u16 _irq:1; | |
107 | u16 _io:1; | |
108 | u16 _win:4; | |
109 | u16 _locked:1; | |
1da177e4 | 110 | |
e2d40963 DB |
111 | /* Flag whether a "fuzzy" func_id based match is |
112 | * allowed. */ | |
113 | u16 allow_func_id_match:1; | |
f6fbe01a | 114 | |
1da177e4 | 115 | /* information about this device */ |
e2d40963 DB |
116 | u16 has_manf_id:1; |
117 | u16 has_card_id:1; | |
118 | u16 has_func_id:1; | |
1ad275e3 | 119 | |
04de0816 | 120 | u16 reserved:4; |
1da177e4 LT |
121 | |
122 | u8 func_id; | |
123 | u16 manf_id; | |
124 | u16 card_id; | |
125 | ||
9fea84f4 | 126 | char *prod_id[4]; |
1da177e4 | 127 | |
43d9f7fd | 128 | u64 dma_mask; |
0e0fad8f DB |
129 | struct device dev; |
130 | ||
131 | #ifdef CONFIG_PCMCIA_IOCTL | |
1da177e4 | 132 | /* device driver wanted by cardmgr */ |
9fea84f4 | 133 | struct pcmcia_driver *cardmgr; |
0e0fad8f | 134 | #endif |
e2d40963 DB |
135 | |
136 | /* data private to drivers */ | |
137 | void *priv; | |
1da177e4 LT |
138 | }; |
139 | ||
140 | #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) | |
141 | #define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv) | |
142 | ||
a5835786 | 143 | |
91284224 DB |
144 | /* |
145 | * CIS access. | |
146 | * | |
147 | * Please use the following functions to access CIS tuples: | |
148 | * - pcmcia_get_tuple() | |
149 | * - pcmcia_loop_tuple() | |
150 | * - pcmcia_get_mac_from_cis() | |
151 | * | |
152 | * To parse a tuple_t, pcmcia_parse_tuple() exists. Its interface | |
153 | * might change in future. | |
272433e0 | 154 | */ |
272433e0 | 155 | |
91284224 DB |
156 | /* get the very first CIS entry of type @code. Note that buf is pointer |
157 | * to u8 *buf; and that you need to kfree(buf) afterwards. */ | |
158 | size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code, | |
159 | u8 **buf); | |
272433e0 | 160 | |
91284224 DB |
161 | /* loop over CIS entries */ |
162 | int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, | |
163 | int (*loop_tuple) (struct pcmcia_device *p_dev, | |
164 | tuple_t *tuple, | |
165 | void *priv_data), | |
166 | void *priv_data); | |
272433e0 | 167 | |
91284224 DB |
168 | /* get the MAC address from CISTPL_FUNCE */ |
169 | int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev, | |
170 | struct net_device *dev); | |
272433e0 DB |
171 | |
172 | ||
91284224 DB |
173 | /* parse a tuple_t */ |
174 | int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse); | |
175 | ||
272433e0 DB |
176 | /* loop CIS entries for valid configuration */ |
177 | int pcmcia_loop_config(struct pcmcia_device *p_dev, | |
178 | int (*conf_check) (struct pcmcia_device *p_dev, | |
179 | cistpl_cftable_entry_t *cf, | |
180 | cistpl_cftable_entry_t *dflt, | |
181 | unsigned int vcc, | |
182 | void *priv_data), | |
183 | void *priv_data); | |
1da177e4 | 184 | |
994917f8 DB |
185 | /* is the device still there? */ |
186 | struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev); | |
187 | ||
188 | /* low-level interface reset */ | |
189 | int pcmcia_reset_card(struct pcmcia_socket *skt); | |
190 | ||
191 | /* CIS config */ | |
192 | int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, | |
193 | conf_reg_t *reg); | |
194 | ||
195 | /* device configuration */ | |
196 | int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req); | |
197 | int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req); | |
198 | int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |
199 | config_req_t *req); | |
200 | ||
6838b03f | 201 | int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, |
994917f8 | 202 | window_handle_t *wh); |
f5560da5 | 203 | int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t win); |
868575d1 MD |
204 | int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t win, |
205 | memreq_t *req); | |
994917f8 DB |
206 | |
207 | int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); | |
208 | void pcmcia_disable_device(struct pcmcia_device *p_dev); | |
209 | ||
1da177e4 | 210 | #endif /* __KERNEL__ */ |
a5835786 DB |
211 | |
212 | ||
213 | ||
214 | /* Below, there are only definitions which are used by | |
215 | * - the PCMCIA ioctl | |
216 | * - deprecated PCMCIA userspace tools only | |
217 | * | |
218 | * here be dragons ... here be dragons ... here be dragons ... here be drag | |
219 | */ | |
220 | ||
221 | #if defined(CONFIG_PCMCIA_IOCTL) || !defined(__KERNEL__) | |
222 | ||
d39bd564 DB |
223 | #if defined(__arm__) || defined(__mips__) || defined(__avr32__) || \ |
224 | defined(__bfin__) | |
225 | /* This (ioaddr_t) is exposed to userspace & hence cannot be changed. */ | |
226 | typedef u_int ioaddr_t; | |
227 | #else | |
228 | typedef u_short ioaddr_t; | |
229 | #endif | |
230 | ||
a5835786 DB |
231 | /* for AdjustResourceInfo */ |
232 | typedef struct adjust_t { | |
233 | u_int Action; | |
234 | u_int Resource; | |
235 | u_int Attributes; | |
236 | union { | |
237 | struct memory { | |
238 | u_long Base; | |
239 | u_long Size; | |
240 | } memory; | |
241 | struct io { | |
242 | ioaddr_t BasePort; | |
243 | ioaddr_t NumPorts; | |
244 | u_int IOAddrLines; | |
245 | } io; | |
246 | struct irq { | |
247 | u_int IRQ; | |
248 | } irq; | |
249 | } resource; | |
250 | } adjust_t; | |
251 | ||
252 | /* Action field */ | |
253 | #define REMOVE_MANAGED_RESOURCE 1 | |
254 | #define ADD_MANAGED_RESOURCE 2 | |
255 | #define GET_FIRST_MANAGED_RESOURCE 3 | |
256 | #define GET_NEXT_MANAGED_RESOURCE 4 | |
257 | /* Resource field */ | |
258 | #define RES_MEMORY_RANGE 1 | |
259 | #define RES_IO_RANGE 2 | |
260 | #define RES_IRQ 3 | |
261 | /* Attribute field */ | |
262 | #define RES_IRQ_TYPE 0x03 | |
263 | #define RES_IRQ_TYPE_EXCLUSIVE 0 | |
264 | #define RES_IRQ_TYPE_TIME 1 | |
265 | #define RES_IRQ_TYPE_DYNAMIC 2 | |
266 | #define RES_IRQ_CSC 0x04 | |
267 | #define RES_SHARED 0x08 | |
268 | #define RES_RESERVED 0x10 | |
269 | #define RES_ALLOCATED 0x20 | |
270 | #define RES_REMOVED 0x40 | |
271 | ||
272 | ||
273 | typedef struct tuple_parse_t { | |
274 | tuple_t tuple; | |
275 | cisdata_t data[255]; | |
276 | cisparse_t parse; | |
277 | } tuple_parse_t; | |
278 | ||
279 | typedef struct win_info_t { | |
280 | window_handle_t handle; | |
281 | win_req_t window; | |
282 | memreq_t map; | |
283 | } win_info_t; | |
284 | ||
285 | typedef struct bind_info_t { | |
286 | dev_info_t dev_info; | |
287 | u_char function; | |
288 | struct pcmcia_device *instance; | |
289 | char name[DEV_NAME_LEN]; | |
290 | u_short major, minor; | |
291 | void *next; | |
292 | } bind_info_t; | |
293 | ||
294 | typedef struct mtd_info_t { | |
295 | dev_info_t dev_info; | |
296 | u_int Attributes; | |
297 | u_int CardOffset; | |
298 | } mtd_info_t; | |
299 | ||
300 | typedef struct region_info_t { | |
301 | u_int Attributes; | |
302 | u_int CardOffset; | |
303 | u_int RegionSize; | |
304 | u_int AccessSpeed; | |
305 | u_int BlockSize; | |
306 | u_int PartMultiple; | |
307 | u_char JedecMfr, JedecInfo; | |
308 | memory_handle_t next; | |
309 | } region_info_t; | |
310 | ||
311 | #define REGION_TYPE 0x0001 | |
312 | #define REGION_TYPE_CM 0x0000 | |
313 | #define REGION_TYPE_AM 0x0001 | |
314 | #define REGION_PREFETCH 0x0008 | |
315 | #define REGION_CACHEABLE 0x0010 | |
316 | #define REGION_BAR_MASK 0xe000 | |
317 | #define REGION_BAR_SHIFT 13 | |
318 | ||
319 | /* For ReplaceCIS */ | |
320 | typedef struct cisdump_t { | |
321 | u_int Length; | |
322 | cisdata_t Data[CISTPL_MAX_CIS_SIZE]; | |
323 | } cisdump_t; | |
324 | ||
325 | /* for GetConfigurationInfo */ | |
326 | typedef struct config_info_t { | |
327 | u_char Function; | |
328 | u_int Attributes; | |
329 | u_int Vcc, Vpp1, Vpp2; | |
330 | u_int IntType; | |
331 | u_int ConfigBase; | |
332 | u_char Status, Pin, Copy, Option, ExtStatus; | |
333 | u_int Present; | |
334 | u_int CardValues; | |
335 | u_int AssignedIRQ; | |
336 | u_int IRQAttributes; | |
337 | ioaddr_t BasePort1; | |
338 | ioaddr_t NumPorts1; | |
339 | u_int Attributes1; | |
340 | ioaddr_t BasePort2; | |
341 | ioaddr_t NumPorts2; | |
342 | u_int Attributes2; | |
343 | u_int IOAddrLines; | |
344 | } config_info_t; | |
a45b3fb1 DB |
345 | |
346 | /* For ValidateCIS */ | |
347 | typedef struct cisinfo_t { | |
348 | u_int Chains; | |
349 | } cisinfo_t; | |
350 | ||
351 | typedef struct cs_status_t { | |
352 | u_char Function; | |
353 | event_t CardState; | |
354 | event_t SocketState; | |
355 | } cs_status_t; | |
a5835786 DB |
356 | |
357 | typedef union ds_ioctl_arg_t { | |
358 | adjust_t adjust; | |
359 | config_info_t config; | |
360 | tuple_t tuple; | |
361 | tuple_parse_t tuple_parse; | |
362 | client_req_t client_req; | |
363 | cs_status_t status; | |
364 | conf_reg_t conf_reg; | |
365 | cisinfo_t cisinfo; | |
366 | region_info_t region; | |
367 | bind_info_t bind_info; | |
368 | mtd_info_t mtd_info; | |
369 | win_info_t win_info; | |
370 | cisdump_t cisdump; | |
371 | } ds_ioctl_arg_t; | |
372 | ||
373 | #define DS_ADJUST_RESOURCE_INFO _IOWR('d', 2, adjust_t) | |
374 | #define DS_GET_CONFIGURATION_INFO _IOWR('d', 3, config_info_t) | |
375 | #define DS_GET_FIRST_TUPLE _IOWR('d', 4, tuple_t) | |
376 | #define DS_GET_NEXT_TUPLE _IOWR('d', 5, tuple_t) | |
377 | #define DS_GET_TUPLE_DATA _IOWR('d', 6, tuple_parse_t) | |
378 | #define DS_PARSE_TUPLE _IOWR('d', 7, tuple_parse_t) | |
379 | #define DS_RESET_CARD _IO ('d', 8) | |
380 | #define DS_GET_STATUS _IOWR('d', 9, cs_status_t) | |
381 | #define DS_ACCESS_CONFIGURATION_REGISTER _IOWR('d', 10, conf_reg_t) | |
382 | #define DS_VALIDATE_CIS _IOR ('d', 11, cisinfo_t) | |
383 | #define DS_SUSPEND_CARD _IO ('d', 12) | |
384 | #define DS_RESUME_CARD _IO ('d', 13) | |
385 | #define DS_EJECT_CARD _IO ('d', 14) | |
386 | #define DS_INSERT_CARD _IO ('d', 15) | |
387 | #define DS_GET_FIRST_REGION _IOWR('d', 16, region_info_t) | |
388 | #define DS_GET_NEXT_REGION _IOWR('d', 17, region_info_t) | |
389 | #define DS_REPLACE_CIS _IOWR('d', 18, cisdump_t) | |
390 | #define DS_GET_FIRST_WINDOW _IOR ('d', 19, win_info_t) | |
391 | #define DS_GET_NEXT_WINDOW _IOWR('d', 20, win_info_t) | |
392 | #define DS_GET_MEM_PAGE _IOWR('d', 21, win_info_t) | |
393 | ||
394 | #define DS_BIND_REQUEST _IOWR('d', 60, bind_info_t) | |
395 | #define DS_GET_DEVICE_INFO _IOWR('d', 61, bind_info_t) | |
396 | #define DS_GET_NEXT_DEVICE _IOWR('d', 62, bind_info_t) | |
397 | #define DS_UNBIND_REQUEST _IOW ('d', 63, bind_info_t) | |
398 | #define DS_BIND_MTD _IOWR('d', 64, mtd_info_t) | |
399 | ||
400 | ||
401 | /* used in userspace only */ | |
402 | #define CS_IN_USE 0x1e | |
403 | ||
994917f8 DB |
404 | #define INFO_MASTER_CLIENT 0x01 |
405 | #define INFO_IO_CLIENT 0x02 | |
406 | #define INFO_MTD_CLIENT 0x04 | |
407 | #define INFO_MEM_CLIENT 0x08 | |
408 | #define MAX_NUM_CLIENTS 3 | |
409 | ||
410 | #define INFO_CARD_SHARE 0x10 | |
411 | #define INFO_CARD_EXCL 0x20 | |
412 | ||
a5835786 DB |
413 | |
414 | #endif /* !defined(__KERNEL__) || defined(CONFIG_PCMCIA_IOCTL) */ | |
415 | ||
1da177e4 | 416 | #endif /* _LINUX_DS_H */ |