blob: 42c8759f0bdc79f7f0399c65cea0012b5b3362a1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * cs.h
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
13 */
14
15#ifndef _LINUX_CS_H
16#define _LINUX_CS_H
17
18/* For AccessConfigurationRegister */
19typedef struct conf_reg_t {
20 u_char Function;
21 u_int Action;
22 off_t Offset;
23 u_int Value;
24} conf_reg_t;
25
26/* Actions */
27#define CS_READ 1
28#define CS_WRITE 2
29
30/* for AdjustResourceInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -070031/* Action field */
32#define REMOVE_MANAGED_RESOURCE 1
33#define ADD_MANAGED_RESOURCE 2
Dominik Brodowskia5835782008-08-28 00:41:16 +020034
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Linus Torvalds1da177e2005-04-16 15:20:36 -070036typedef struct event_callback_args_t {
Dominik Brodowski2bc5a9b2005-07-07 17:59:02 -070037 struct pcmcia_device *client_handle;
38 void *client_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039} event_callback_args_t;
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041/* For CardValues field */
42#define CV_OPTION_VALUE 0x01
43#define CV_STATUS_VALUE 0x02
44#define CV_PIN_REPLACEMENT 0x04
45#define CV_COPY_VALUE 0x08
46#define CV_EXT_STATUS 0x10
47
48/* For GetFirst/NextClient */
49typedef struct client_req_t {
50 socket_t Socket;
51 u_int Attributes;
52} client_req_t;
53
54#define CLIENT_THIS_SOCKET 0x01
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056/* ModifyConfiguration */
57typedef struct modconf_t {
58 u_int Attributes;
59 u_int Vcc, Vpp1, Vpp2;
60} modconf_t;
61
62/* Attributes for ModifyConfiguration */
Dominik Brodowski4bbed522006-01-15 11:18:12 +010063#define CONF_IRQ_CHANGE_VALID 0x0100
64#define CONF_VCC_CHANGE_VALID 0x0200
65#define CONF_VPP1_CHANGE_VALID 0x0400
66#define CONF_VPP2_CHANGE_VALID 0x0800
67#define CONF_IO_CHANGE_WIDTH 0x1000
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69/* For RequestConfiguration */
70typedef struct config_req_t {
71 u_int Attributes;
Dominik Brodowski70294b42006-01-15 12:43:16 +010072 u_int Vpp; /* both Vpp1 and Vpp2 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 u_int IntType;
74 u_int ConfigBase;
75 u_char Status, Pin, Copy, ExtStatus;
76 u_char ConfigIndex;
77 u_int Present;
78} config_req_t;
79
80/* Attributes for RequestConfiguration */
81#define CONF_ENABLE_IRQ 0x01
82#define CONF_ENABLE_DMA 0x02
83#define CONF_ENABLE_SPKR 0x04
84#define CONF_VALID_CLIENT 0x100
85
86/* IntType field */
87#define INT_MEMORY 0x01
88#define INT_MEMORY_AND_IO 0x02
89#define INT_CARDBUS 0x04
90#define INT_ZOOMED_VIDEO 0x08
91
92/* For RequestIO and ReleaseIO */
93typedef struct io_req_t {
Olof Johanssonecb8a842008-02-04 22:27:34 -080094 u_int BasePort1;
95 u_int NumPorts1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 u_int Attributes1;
Olof Johanssonecb8a842008-02-04 22:27:34 -080097 u_int BasePort2;
98 u_int NumPorts2;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 u_int Attributes2;
100 u_int IOAddrLines;
101} io_req_t;
102
103/* Attributes for RequestIO and ReleaseIO */
104#define IO_SHARED 0x01
105#define IO_FIRST_SHARED 0x02
106#define IO_FORCE_ALIAS_ACCESS 0x04
107#define IO_DATA_PATH_WIDTH 0x18
108#define IO_DATA_PATH_WIDTH_8 0x00
109#define IO_DATA_PATH_WIDTH_16 0x08
110#define IO_DATA_PATH_WIDTH_AUTO 0x10
111
112/* For RequestIRQ and ReleaseIRQ */
113typedef struct irq_req_t {
114 u_int Attributes;
115 u_int AssignedIRQ;
116 u_int IRQInfo1, IRQInfo2; /* IRQInfo2 is ignored */
117 void *Handler;
118 void *Instance;
119} irq_req_t;
120
121/* Attributes for RequestIRQ and ReleaseIRQ */
122#define IRQ_TYPE 0x03
123#define IRQ_TYPE_EXCLUSIVE 0x00
124#define IRQ_TYPE_TIME 0x01
125#define IRQ_TYPE_DYNAMIC_SHARING 0x02
126#define IRQ_FORCED_PULSE 0x04
127#define IRQ_FIRST_SHARED 0x08
128#define IRQ_HANDLE_PRESENT 0x10
129#define IRQ_PULSE_ALLOCATED 0x100
130
131/* Bits in IRQInfo1 field */
132#define IRQ_MASK 0x0f
133#define IRQ_NMI_ID 0x01
134#define IRQ_IOCK_ID 0x02
135#define IRQ_BERR_ID 0x04
136#define IRQ_VEND_ID 0x08
137#define IRQ_INFO2_VALID 0x10
138#define IRQ_LEVEL_ID 0x20
139#define IRQ_PULSE_ID 0x40
140#define IRQ_SHARE_ID 0x80
141
142typedef struct eventmask_t {
143 u_int Attributes;
144 u_int EventMask;
145} eventmask_t;
146
147#define CONF_EVENT_MASK_VALID 0x01
148
149/* Configuration registers present */
150#define PRESENT_OPTION 0x001
151#define PRESENT_STATUS 0x002
152#define PRESENT_PIN_REPLACE 0x004
153#define PRESENT_COPY 0x008
154#define PRESENT_EXT_STATUS 0x010
155#define PRESENT_IOBASE_0 0x020
156#define PRESENT_IOBASE_1 0x040
157#define PRESENT_IOBASE_2 0x080
158#define PRESENT_IOBASE_3 0x100
159#define PRESENT_IOSIZE 0x200
160
161/* For GetMemPage, MapMemPage */
162typedef struct memreq_t {
163 u_int CardOffset;
164 page_t Page;
165} memreq_t;
166
167/* For ModifyWindow */
168typedef struct modwin_t {
169 u_int Attributes;
170 u_int AccessSpeed;
171} modwin_t;
172
173/* For RequestWindow */
174typedef struct win_req_t {
175 u_int Attributes;
176 u_long Base;
177 u_int Size;
178 u_int AccessSpeed;
179} win_req_t;
180
181/* Attributes for RequestWindow */
182#define WIN_ADDR_SPACE 0x0001
183#define WIN_ADDR_SPACE_MEM 0x0000
184#define WIN_ADDR_SPACE_IO 0x0001
185#define WIN_MEMORY_TYPE 0x0002
186#define WIN_MEMORY_TYPE_CM 0x0000
187#define WIN_MEMORY_TYPE_AM 0x0002
188#define WIN_ENABLE 0x0004
189#define WIN_DATA_WIDTH 0x0018
190#define WIN_DATA_WIDTH_8 0x0000
191#define WIN_DATA_WIDTH_16 0x0008
192#define WIN_DATA_WIDTH_32 0x0010
193#define WIN_PAGED 0x0020
194#define WIN_SHARED 0x0040
195#define WIN_FIRST_SHARED 0x0080
196#define WIN_USE_WAIT 0x0100
197#define WIN_STRICT_ALIGN 0x0200
198#define WIN_MAP_BELOW_1MB 0x0400
199#define WIN_PREFETCH 0x0800
200#define WIN_CACHEABLE 0x1000
201#define WIN_BAR_MASK 0xe000
202#define WIN_BAR_SHIFT 13
203
204/* Attributes for RegisterClient -- UNUSED -- */
205#define INFO_MASTER_CLIENT 0x01
206#define INFO_IO_CLIENT 0x02
207#define INFO_MTD_CLIENT 0x04
208#define INFO_MEM_CLIENT 0x08
209#define MAX_NUM_CLIENTS 3
210
211#define INFO_CARD_SHARE 0x10
212#define INFO_CARD_EXCL 0x20
213
214typedef struct cs_status_t {
215 u_char Function;
216 event_t CardState;
217 event_t SocketState;
218} cs_status_t;
219
220typedef struct error_info_t {
221 int func;
222 int retcode;
223} error_info_t;
224
225/* Flag to bind to all functions */
226#define BIND_FN_ALL 0xff
227
228/* Events */
229#define CS_EVENT_PRI_LOW 0
230#define CS_EVENT_PRI_HIGH 1
231
232#define CS_EVENT_WRITE_PROTECT 0x000001
233#define CS_EVENT_CARD_LOCK 0x000002
234#define CS_EVENT_CARD_INSERTION 0x000004
235#define CS_EVENT_CARD_REMOVAL 0x000008
236#define CS_EVENT_BATTERY_DEAD 0x000010
237#define CS_EVENT_BATTERY_LOW 0x000020
238#define CS_EVENT_READY_CHANGE 0x000040
239#define CS_EVENT_CARD_DETECT 0x000080
240#define CS_EVENT_RESET_REQUEST 0x000100
241#define CS_EVENT_RESET_PHYSICAL 0x000200
242#define CS_EVENT_CARD_RESET 0x000400
243#define CS_EVENT_REGISTRATION_COMPLETE 0x000800
244#define CS_EVENT_PM_SUSPEND 0x002000
245#define CS_EVENT_PM_RESUME 0x004000
246#define CS_EVENT_INSERTION_REQUEST 0x008000
247#define CS_EVENT_EJECTION_REQUEST 0x010000
248#define CS_EVENT_MTD_REQUEST 0x020000
249#define CS_EVENT_ERASE_COMPLETE 0x040000
250#define CS_EVENT_REQUEST_ATTENTION 0x080000
251#define CS_EVENT_CB_DETECT 0x100000
252#define CS_EVENT_3VCARD 0x200000
253#define CS_EVENT_XVCARD 0x400000
254
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
256#ifdef __KERNEL__
257
258/*
259 * The main Card Services entry point
260 */
261
262enum service {
263 AccessConfigurationRegister, AddSocketServices,
264 AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory,
265 DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo,
266 GetClientInfo, GetConfigurationInfo, GetEventMask,
267 GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple,
268 GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple,
269 GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage,
270 MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow,
271 OpenMemory, ParseTuple, ReadMemory, RegisterClient,
272 RegisterEraseQueue, RegisterMTD, RegisterTimer,
273 ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ,
274 ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices,
275 RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ,
276 RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry,
277 SetEventMask, SetRegion, ValidateCIS, VendorSpecific,
278 WriteMemory, BindDevice, BindMTD, ReportError,
279 SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS,
280 GetFirstWindow, GetNextWindow, GetMemPage
281};
282
283struct pcmcia_socket;
284
Dominik Brodowski2bc5a9b2005-07-07 17:59:02 -0700285int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, conf_reg_t *reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286int pcmcia_get_mem_page(window_handle_t win, memreq_t *req);
287int pcmcia_map_mem_page(window_handle_t win, memreq_t *req);
Dominik Brodowski2bc5a9b2005-07-07 17:59:02 -0700288int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289int pcmcia_release_window(window_handle_t win);
Dominik Brodowski2bc5a9b2005-07-07 17:59:02 -0700290int pcmcia_request_configuration(struct pcmcia_device *p_dev, config_req_t *req);
291int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req);
292int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req);
293int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294int pcmcia_suspend_card(struct pcmcia_socket *skt);
295int pcmcia_resume_card(struct pcmcia_socket *skt);
296int pcmcia_eject_card(struct pcmcia_socket *skt);
297int pcmcia_insert_card(struct pcmcia_socket *skt);
Dominik Brodowski1540eec2006-01-15 00:51:53 +0100298int pccard_reset_card(struct pcmcia_socket *skt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
Dominik Brodowski9940ec32006-03-05 11:04:33 +0100300struct pcmcia_device * pcmcia_dev_present(struct pcmcia_device *p_dev);
Dominik Brodowski5f2a71f2006-01-15 09:32:39 +0100301void pcmcia_disable_device(struct pcmcia_device *p_dev);
302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt);
304void pcmcia_put_socket(struct pcmcia_socket *skt);
305
Dominik Brodowski1540eec2006-01-15 00:51:53 +0100306/* compatibility functions */
307#define pcmcia_reset_card(p_dev, req) \
308 pccard_reset_card(p_dev->socket)
309
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310#endif /* __KERNEL__ */
311
312#endif /* _LINUX_CS_H */