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.
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.
12 * (C) 1999 David A. Hinds
18 /* For AccessConfigurationRegister */
19 typedef struct conf_reg_t {
30 /* for AdjustResourceInfo */
31 typedef struct adjust_t {
52 #define REMOVE_MANAGED_RESOURCE 1
53 #define ADD_MANAGED_RESOURCE 2
54 #define GET_FIRST_MANAGED_RESOURCE 3
55 #define GET_NEXT_MANAGED_RESOURCE 4
57 #define RES_MEMORY_RANGE 1
58 #define RES_IO_RANGE 2
61 #define RES_IRQ_TYPE 0x03
62 #define RES_IRQ_TYPE_EXCLUSIVE 0
63 #define RES_IRQ_TYPE_TIME 1
64 #define RES_IRQ_TYPE_DYNAMIC 2
65 #define RES_IRQ_CSC 0x04
66 #define RES_SHARED 0x08
67 #define RES_RESERVED 0x10
68 #define RES_ALLOCATED 0x20
69 #define RES_REMOVED 0x40
71 typedef struct servinfo_t {
79 typedef struct event_callback_args_t {
80 struct pcmcia_device *client_handle;
82 } event_callback_args_t;
84 /* for GetConfigurationInfo */
85 typedef struct config_info_t {
88 u_int Vcc, Vpp1, Vpp2;
91 u_char Status, Pin, Copy, Option, ExtStatus;
105 /* For CardValues field */
106 #define CV_OPTION_VALUE 0x01
107 #define CV_STATUS_VALUE 0x02
108 #define CV_PIN_REPLACEMENT 0x04
109 #define CV_COPY_VALUE 0x08
110 #define CV_EXT_STATUS 0x10
112 /* For GetFirst/NextClient */
113 typedef struct client_req_t {
118 #define CLIENT_THIS_SOCKET 0x01
120 /* For RegisterClient */
121 typedef struct client_reg_t {
122 dev_info_t *dev_info;
123 u_int Attributes; /* UNUSED */
125 int (*event_handler)(event_t event, int priority,
126 event_callback_args_t *);
127 event_callback_args_t event_callback_args;
131 /* ModifyConfiguration */
132 typedef struct modconf_t {
134 u_int Vcc, Vpp1, Vpp2;
137 /* Attributes for ModifyConfiguration */
138 #define CONF_IRQ_CHANGE_VALID 0x100
139 #define CONF_VCC_CHANGE_VALID 0x200
140 #define CONF_VPP1_CHANGE_VALID 0x400
141 #define CONF_VPP2_CHANGE_VALID 0x800
143 /* For RequestConfiguration */
144 typedef struct config_req_t {
146 u_int Vcc, Vpp1, Vpp2;
149 u_char Status, Pin, Copy, ExtStatus;
154 /* Attributes for RequestConfiguration */
155 #define CONF_ENABLE_IRQ 0x01
156 #define CONF_ENABLE_DMA 0x02
157 #define CONF_ENABLE_SPKR 0x04
158 #define CONF_VALID_CLIENT 0x100
161 #define INT_MEMORY 0x01
162 #define INT_MEMORY_AND_IO 0x02
163 #define INT_CARDBUS 0x04
164 #define INT_ZOOMED_VIDEO 0x08
166 /* For RequestIO and ReleaseIO */
167 typedef struct io_req_t {
177 /* Attributes for RequestIO and ReleaseIO */
178 #define IO_SHARED 0x01
179 #define IO_FIRST_SHARED 0x02
180 #define IO_FORCE_ALIAS_ACCESS 0x04
181 #define IO_DATA_PATH_WIDTH 0x18
182 #define IO_DATA_PATH_WIDTH_8 0x00
183 #define IO_DATA_PATH_WIDTH_16 0x08
184 #define IO_DATA_PATH_WIDTH_AUTO 0x10
186 /* For RequestIRQ and ReleaseIRQ */
187 typedef struct irq_req_t {
190 u_int IRQInfo1, IRQInfo2; /* IRQInfo2 is ignored */
195 /* Attributes for RequestIRQ and ReleaseIRQ */
196 #define IRQ_TYPE 0x03
197 #define IRQ_TYPE_EXCLUSIVE 0x00
198 #define IRQ_TYPE_TIME 0x01
199 #define IRQ_TYPE_DYNAMIC_SHARING 0x02
200 #define IRQ_FORCED_PULSE 0x04
201 #define IRQ_FIRST_SHARED 0x08
202 #define IRQ_HANDLE_PRESENT 0x10
203 #define IRQ_PULSE_ALLOCATED 0x100
205 /* Bits in IRQInfo1 field */
206 #define IRQ_MASK 0x0f
207 #define IRQ_NMI_ID 0x01
208 #define IRQ_IOCK_ID 0x02
209 #define IRQ_BERR_ID 0x04
210 #define IRQ_VEND_ID 0x08
211 #define IRQ_INFO2_VALID 0x10
212 #define IRQ_LEVEL_ID 0x20
213 #define IRQ_PULSE_ID 0x40
214 #define IRQ_SHARE_ID 0x80
216 typedef struct eventmask_t {
221 #define CONF_EVENT_MASK_VALID 0x01
223 /* Configuration registers present */
224 #define PRESENT_OPTION 0x001
225 #define PRESENT_STATUS 0x002
226 #define PRESENT_PIN_REPLACE 0x004
227 #define PRESENT_COPY 0x008
228 #define PRESENT_EXT_STATUS 0x010
229 #define PRESENT_IOBASE_0 0x020
230 #define PRESENT_IOBASE_1 0x040
231 #define PRESENT_IOBASE_2 0x080
232 #define PRESENT_IOBASE_3 0x100
233 #define PRESENT_IOSIZE 0x200
235 /* For GetMemPage, MapMemPage */
236 typedef struct memreq_t {
241 /* For ModifyWindow */
242 typedef struct modwin_t {
247 /* For RequestWindow */
248 typedef struct win_req_t {
255 /* Attributes for RequestWindow */
256 #define WIN_ADDR_SPACE 0x0001
257 #define WIN_ADDR_SPACE_MEM 0x0000
258 #define WIN_ADDR_SPACE_IO 0x0001
259 #define WIN_MEMORY_TYPE 0x0002
260 #define WIN_MEMORY_TYPE_CM 0x0000
261 #define WIN_MEMORY_TYPE_AM 0x0002
262 #define WIN_ENABLE 0x0004
263 #define WIN_DATA_WIDTH 0x0018
264 #define WIN_DATA_WIDTH_8 0x0000
265 #define WIN_DATA_WIDTH_16 0x0008
266 #define WIN_DATA_WIDTH_32 0x0010
267 #define WIN_PAGED 0x0020
268 #define WIN_SHARED 0x0040
269 #define WIN_FIRST_SHARED 0x0080
270 #define WIN_USE_WAIT 0x0100
271 #define WIN_STRICT_ALIGN 0x0200
272 #define WIN_MAP_BELOW_1MB 0x0400
273 #define WIN_PREFETCH 0x0800
274 #define WIN_CACHEABLE 0x1000
275 #define WIN_BAR_MASK 0xe000
276 #define WIN_BAR_SHIFT 13
278 /* Attributes for RegisterClient -- UNUSED -- */
279 #define INFO_MASTER_CLIENT 0x01
280 #define INFO_IO_CLIENT 0x02
281 #define INFO_MTD_CLIENT 0x04
282 #define INFO_MEM_CLIENT 0x08
283 #define MAX_NUM_CLIENTS 3
285 #define INFO_CARD_SHARE 0x10
286 #define INFO_CARD_EXCL 0x20
288 typedef struct cs_status_t {
294 typedef struct error_info_t {
299 /* Flag to bind to all functions */
300 #define BIND_FN_ALL 0xff
303 #define CS_EVENT_PRI_LOW 0
304 #define CS_EVENT_PRI_HIGH 1
306 #define CS_EVENT_WRITE_PROTECT 0x000001
307 #define CS_EVENT_CARD_LOCK 0x000002
308 #define CS_EVENT_CARD_INSERTION 0x000004
309 #define CS_EVENT_CARD_REMOVAL 0x000008
310 #define CS_EVENT_BATTERY_DEAD 0x000010
311 #define CS_EVENT_BATTERY_LOW 0x000020
312 #define CS_EVENT_READY_CHANGE 0x000040
313 #define CS_EVENT_CARD_DETECT 0x000080
314 #define CS_EVENT_RESET_REQUEST 0x000100
315 #define CS_EVENT_RESET_PHYSICAL 0x000200
316 #define CS_EVENT_CARD_RESET 0x000400
317 #define CS_EVENT_REGISTRATION_COMPLETE 0x000800
318 #define CS_EVENT_PM_SUSPEND 0x002000
319 #define CS_EVENT_PM_RESUME 0x004000
320 #define CS_EVENT_INSERTION_REQUEST 0x008000
321 #define CS_EVENT_EJECTION_REQUEST 0x010000
322 #define CS_EVENT_MTD_REQUEST 0x020000
323 #define CS_EVENT_ERASE_COMPLETE 0x040000
324 #define CS_EVENT_REQUEST_ATTENTION 0x080000
325 #define CS_EVENT_CB_DETECT 0x100000
326 #define CS_EVENT_3VCARD 0x200000
327 #define CS_EVENT_XVCARD 0x400000
330 #define CS_SUCCESS 0x00
331 #define CS_BAD_ADAPTER 0x01
332 #define CS_BAD_ATTRIBUTE 0x02
333 #define CS_BAD_BASE 0x03
334 #define CS_BAD_EDC 0x04
335 #define CS_BAD_IRQ 0x06
336 #define CS_BAD_OFFSET 0x07
337 #define CS_BAD_PAGE 0x08
338 #define CS_READ_FAILURE 0x09
339 #define CS_BAD_SIZE 0x0a
340 #define CS_BAD_SOCKET 0x0b
341 #define CS_BAD_TYPE 0x0d
342 #define CS_BAD_VCC 0x0e
343 #define CS_BAD_VPP 0x0f
344 #define CS_BAD_WINDOW 0x11
345 #define CS_WRITE_FAILURE 0x12
346 #define CS_NO_CARD 0x14
347 #define CS_UNSUPPORTED_FUNCTION 0x15
348 #define CS_UNSUPPORTED_MODE 0x16
349 #define CS_BAD_SPEED 0x17
351 #define CS_GENERAL_FAILURE 0x19
352 #define CS_WRITE_PROTECTED 0x1a
353 #define CS_BAD_ARG_LENGTH 0x1b
354 #define CS_BAD_ARGS 0x1c
355 #define CS_CONFIGURATION_LOCKED 0x1d
356 #define CS_IN_USE 0x1e
357 #define CS_NO_MORE_ITEMS 0x1f
358 #define CS_OUT_OF_RESOURCE 0x20
359 #define CS_BAD_HANDLE 0x21
361 #define CS_BAD_TUPLE 0x40
366 * The main Card Services entry point
370 AccessConfigurationRegister, AddSocketServices,
371 AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory,
372 DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo,
373 GetClientInfo, GetConfigurationInfo, GetEventMask,
374 GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple,
375 GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple,
376 GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage,
377 MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow,
378 OpenMemory, ParseTuple, ReadMemory, RegisterClient,
379 RegisterEraseQueue, RegisterMTD, RegisterTimer,
380 ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ,
381 ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices,
382 RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ,
383 RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry,
384 SetEventMask, SetRegion, ValidateCIS, VendorSpecific,
385 WriteMemory, BindDevice, BindMTD, ReportError,
386 SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS,
387 GetFirstWindow, GetNextWindow, GetMemPage
390 struct pcmcia_socket;
392 int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, conf_reg_t *reg);
393 int pcmcia_deregister_client(struct pcmcia_device *p_dev);
394 int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, config_info_t *config);
395 int pcmcia_get_first_window(window_handle_t *win, win_req_t *req);
396 int pcmcia_get_next_window(window_handle_t *win, win_req_t *req);
397 int pcmcia_get_status(struct pcmcia_device *p_dev, cs_status_t *status);
398 int pcmcia_get_mem_page(window_handle_t win, memreq_t *req);
399 int pcmcia_map_mem_page(window_handle_t win, memreq_t *req);
400 int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod);
401 int pcmcia_register_client(client_handle_t *handle, client_reg_t *req);
402 int pcmcia_release_configuration(struct pcmcia_device *p_dev);
403 int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req);
404 int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req);
405 int pcmcia_release_window(window_handle_t win);
406 int pcmcia_request_configuration(struct pcmcia_device *p_dev, config_req_t *req);
407 int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req);
408 int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req);
409 int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh);
410 int pcmcia_reset_card(struct pcmcia_device *p_dev, client_req_t *req);
411 int pcmcia_suspend_card(struct pcmcia_socket *skt);
412 int pcmcia_resume_card(struct pcmcia_socket *skt);
413 int pcmcia_eject_card(struct pcmcia_socket *skt);
414 int pcmcia_insert_card(struct pcmcia_socket *skt);
416 struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt);
417 void pcmcia_put_socket(struct pcmcia_socket *skt);
419 #endif /* __KERNEL__ */
421 #endif /* _LINUX_CS_H */