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 event_callback_args_t {
72 struct pcmcia_device *client_handle;
74 } event_callback_args_t;
76 /* For CardValues field */
77 #define CV_OPTION_VALUE 0x01
78 #define CV_STATUS_VALUE 0x02
79 #define CV_PIN_REPLACEMENT 0x04
80 #define CV_COPY_VALUE 0x08
81 #define CV_EXT_STATUS 0x10
83 /* For GetFirst/NextClient */
84 typedef struct client_req_t {
89 #define CLIENT_THIS_SOCKET 0x01
91 /* ModifyConfiguration */
92 typedef struct modconf_t {
94 u_int Vcc, Vpp1, Vpp2;
97 /* Attributes for ModifyConfiguration */
98 #define CONF_IRQ_CHANGE_VALID 0x0100
99 #define CONF_VCC_CHANGE_VALID 0x0200
100 #define CONF_VPP1_CHANGE_VALID 0x0400
101 #define CONF_VPP2_CHANGE_VALID 0x0800
102 #define CONF_IO_CHANGE_WIDTH 0x1000
104 /* For RequestConfiguration */
105 typedef struct config_req_t {
107 u_int Vpp; /* both Vpp1 and Vpp2 */
110 u_char Status, Pin, Copy, ExtStatus;
115 /* Attributes for RequestConfiguration */
116 #define CONF_ENABLE_IRQ 0x01
117 #define CONF_ENABLE_DMA 0x02
118 #define CONF_ENABLE_SPKR 0x04
119 #define CONF_VALID_CLIENT 0x100
122 #define INT_MEMORY 0x01
123 #define INT_MEMORY_AND_IO 0x02
124 #define INT_CARDBUS 0x04
125 #define INT_ZOOMED_VIDEO 0x08
127 /* For RequestIO and ReleaseIO */
128 typedef struct io_req_t {
138 /* Attributes for RequestIO and ReleaseIO */
139 #define IO_SHARED 0x01
140 #define IO_FIRST_SHARED 0x02
141 #define IO_FORCE_ALIAS_ACCESS 0x04
142 #define IO_DATA_PATH_WIDTH 0x18
143 #define IO_DATA_PATH_WIDTH_8 0x00
144 #define IO_DATA_PATH_WIDTH_16 0x08
145 #define IO_DATA_PATH_WIDTH_AUTO 0x10
147 /* For RequestIRQ and ReleaseIRQ */
148 typedef struct irq_req_t {
151 u_int IRQInfo1, IRQInfo2; /* IRQInfo2 is ignored */
156 /* Attributes for RequestIRQ and ReleaseIRQ */
157 #define IRQ_TYPE 0x03
158 #define IRQ_TYPE_EXCLUSIVE 0x00
159 #define IRQ_TYPE_TIME 0x01
160 #define IRQ_TYPE_DYNAMIC_SHARING 0x02
161 #define IRQ_FORCED_PULSE 0x04
162 #define IRQ_FIRST_SHARED 0x08
163 #define IRQ_HANDLE_PRESENT 0x10
164 #define IRQ_PULSE_ALLOCATED 0x100
166 /* Bits in IRQInfo1 field */
167 #define IRQ_MASK 0x0f
168 #define IRQ_NMI_ID 0x01
169 #define IRQ_IOCK_ID 0x02
170 #define IRQ_BERR_ID 0x04
171 #define IRQ_VEND_ID 0x08
172 #define IRQ_INFO2_VALID 0x10
173 #define IRQ_LEVEL_ID 0x20
174 #define IRQ_PULSE_ID 0x40
175 #define IRQ_SHARE_ID 0x80
177 typedef struct eventmask_t {
182 #define CONF_EVENT_MASK_VALID 0x01
184 /* Configuration registers present */
185 #define PRESENT_OPTION 0x001
186 #define PRESENT_STATUS 0x002
187 #define PRESENT_PIN_REPLACE 0x004
188 #define PRESENT_COPY 0x008
189 #define PRESENT_EXT_STATUS 0x010
190 #define PRESENT_IOBASE_0 0x020
191 #define PRESENT_IOBASE_1 0x040
192 #define PRESENT_IOBASE_2 0x080
193 #define PRESENT_IOBASE_3 0x100
194 #define PRESENT_IOSIZE 0x200
196 /* For GetMemPage, MapMemPage */
197 typedef struct memreq_t {
202 /* For ModifyWindow */
203 typedef struct modwin_t {
208 /* For RequestWindow */
209 typedef struct win_req_t {
216 /* Attributes for RequestWindow */
217 #define WIN_ADDR_SPACE 0x0001
218 #define WIN_ADDR_SPACE_MEM 0x0000
219 #define WIN_ADDR_SPACE_IO 0x0001
220 #define WIN_MEMORY_TYPE 0x0002
221 #define WIN_MEMORY_TYPE_CM 0x0000
222 #define WIN_MEMORY_TYPE_AM 0x0002
223 #define WIN_ENABLE 0x0004
224 #define WIN_DATA_WIDTH 0x0018
225 #define WIN_DATA_WIDTH_8 0x0000
226 #define WIN_DATA_WIDTH_16 0x0008
227 #define WIN_DATA_WIDTH_32 0x0010
228 #define WIN_PAGED 0x0020
229 #define WIN_SHARED 0x0040
230 #define WIN_FIRST_SHARED 0x0080
231 #define WIN_USE_WAIT 0x0100
232 #define WIN_STRICT_ALIGN 0x0200
233 #define WIN_MAP_BELOW_1MB 0x0400
234 #define WIN_PREFETCH 0x0800
235 #define WIN_CACHEABLE 0x1000
236 #define WIN_BAR_MASK 0xe000
237 #define WIN_BAR_SHIFT 13
239 /* Attributes for RegisterClient -- UNUSED -- */
240 #define INFO_MASTER_CLIENT 0x01
241 #define INFO_IO_CLIENT 0x02
242 #define INFO_MTD_CLIENT 0x04
243 #define INFO_MEM_CLIENT 0x08
244 #define MAX_NUM_CLIENTS 3
246 #define INFO_CARD_SHARE 0x10
247 #define INFO_CARD_EXCL 0x20
249 typedef struct cs_status_t {
255 typedef struct error_info_t {
260 /* Flag to bind to all functions */
261 #define BIND_FN_ALL 0xff
264 #define CS_EVENT_PRI_LOW 0
265 #define CS_EVENT_PRI_HIGH 1
267 #define CS_EVENT_WRITE_PROTECT 0x000001
268 #define CS_EVENT_CARD_LOCK 0x000002
269 #define CS_EVENT_CARD_INSERTION 0x000004
270 #define CS_EVENT_CARD_REMOVAL 0x000008
271 #define CS_EVENT_BATTERY_DEAD 0x000010
272 #define CS_EVENT_BATTERY_LOW 0x000020
273 #define CS_EVENT_READY_CHANGE 0x000040
274 #define CS_EVENT_CARD_DETECT 0x000080
275 #define CS_EVENT_RESET_REQUEST 0x000100
276 #define CS_EVENT_RESET_PHYSICAL 0x000200
277 #define CS_EVENT_CARD_RESET 0x000400
278 #define CS_EVENT_REGISTRATION_COMPLETE 0x000800
279 #define CS_EVENT_PM_SUSPEND 0x002000
280 #define CS_EVENT_PM_RESUME 0x004000
281 #define CS_EVENT_INSERTION_REQUEST 0x008000
282 #define CS_EVENT_EJECTION_REQUEST 0x010000
283 #define CS_EVENT_MTD_REQUEST 0x020000
284 #define CS_EVENT_ERASE_COMPLETE 0x040000
285 #define CS_EVENT_REQUEST_ATTENTION 0x080000
286 #define CS_EVENT_CB_DETECT 0x100000
287 #define CS_EVENT_3VCARD 0x200000
288 #define CS_EVENT_XVCARD 0x400000
291 #define CS_SUCCESS 0x00
292 #define CS_BAD_ADAPTER -ENODEV
293 #define CS_BAD_ATTRIBUTE 0x02
294 #define CS_BAD_BASE 0x03
295 #define CS_BAD_EDC -ENODEV
296 #define CS_BAD_IRQ 0x06
297 #define CS_BAD_OFFSET 0x07
298 #define CS_BAD_PAGE 0x08
299 #define CS_READ_FAILURE -EIO
300 #define CS_BAD_SIZE 0x0a
301 #define CS_BAD_SOCKET -EINVAL
302 #define CS_BAD_TYPE 0x0d
303 #define CS_BAD_VCC -EINVAL
304 #define CS_BAD_VPP -EINVAL
305 #define CS_BAD_WINDOW -ENODEV
306 #define CS_WRITE_FAILURE -EIO
307 #define CS_NO_CARD -ENODEV
308 #define CS_UNSUPPORTED_FUNCTION -ENODEV
309 #define CS_UNSUPPORTED_MODE -ENODEV
310 #define CS_BAD_SPEED -ENODEV
311 #define CS_BUSY -ENODEV
312 #define CS_GENERAL_FAILURE 0x19
313 #define CS_WRITE_PROTECTED -EPERM
314 #define CS_BAD_ARG_LENGTH -ENODEV
315 #define CS_BAD_ARGS 0x1c
316 #define CS_CONFIGURATION_LOCKED 0x1d
317 #define CS_IN_USE 0x1e
318 #define CS_NO_MORE_ITEMS 0x1f
319 #define CS_OUT_OF_RESOURCE -ENOMEM
320 #define CS_BAD_HANDLE 0x21
322 #define CS_BAD_TUPLE 0x40
327 * The main Card Services entry point
331 AccessConfigurationRegister, AddSocketServices,
332 AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory,
333 DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo,
334 GetClientInfo, GetConfigurationInfo, GetEventMask,
335 GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple,
336 GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple,
337 GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage,
338 MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow,
339 OpenMemory, ParseTuple, ReadMemory, RegisterClient,
340 RegisterEraseQueue, RegisterMTD, RegisterTimer,
341 ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ,
342 ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices,
343 RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ,
344 RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry,
345 SetEventMask, SetRegion, ValidateCIS, VendorSpecific,
346 WriteMemory, BindDevice, BindMTD, ReportError,
347 SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS,
348 GetFirstWindow, GetNextWindow, GetMemPage
351 struct pcmcia_socket;
353 int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, conf_reg_t *reg);
354 int pcmcia_get_mem_page(window_handle_t win, memreq_t *req);
355 int pcmcia_map_mem_page(window_handle_t win, memreq_t *req);
356 int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod);
357 int pcmcia_release_window(window_handle_t win);
358 int pcmcia_request_configuration(struct pcmcia_device *p_dev, config_req_t *req);
359 int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req);
360 int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req);
361 int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh);
362 int pcmcia_suspend_card(struct pcmcia_socket *skt);
363 int pcmcia_resume_card(struct pcmcia_socket *skt);
364 int pcmcia_eject_card(struct pcmcia_socket *skt);
365 int pcmcia_insert_card(struct pcmcia_socket *skt);
366 int pccard_reset_card(struct pcmcia_socket *skt);
368 struct pcmcia_device * pcmcia_dev_present(struct pcmcia_device *p_dev);
369 void pcmcia_disable_device(struct pcmcia_device *p_dev);
371 struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt);
372 void pcmcia_put_socket(struct pcmcia_socket *skt);
374 /* compatibility functions */
375 #define pcmcia_reset_card(p_dev, req) \
376 pccard_reset_card(p_dev->socket)
378 #endif /* __KERNEL__ */
380 #endif /* _LINUX_CS_H */