cs.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. /*
  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. #ifndef _LINUX_CS_H
  15. #define _LINUX_CS_H
  16. /* For AccessConfigurationRegister */
  17. typedef struct conf_reg_t {
  18. u_char Function;
  19. u_int Action;
  20. off_t Offset;
  21. u_int Value;
  22. } conf_reg_t;
  23. /* Actions */
  24. #define CS_READ 1
  25. #define CS_WRITE 2
  26. /* for AdjustResourceInfo */
  27. typedef struct adjust_t {
  28. u_int Action;
  29. u_int Resource;
  30. u_int Attributes;
  31. union {
  32. struct memory {
  33. u_long Base;
  34. u_long Size;
  35. } memory;
  36. struct io {
  37. ioaddr_t BasePort;
  38. ioaddr_t NumPorts;
  39. u_int IOAddrLines;
  40. } io;
  41. struct irq {
  42. u_int IRQ;
  43. } irq;
  44. } resource;
  45. } adjust_t;
  46. /* Action field */
  47. #define REMOVE_MANAGED_RESOURCE 1
  48. #define ADD_MANAGED_RESOURCE 2
  49. #define GET_FIRST_MANAGED_RESOURCE 3
  50. #define GET_NEXT_MANAGED_RESOURCE 4
  51. /* Resource field */
  52. #define RES_MEMORY_RANGE 1
  53. #define RES_IO_RANGE 2
  54. #define RES_IRQ 3
  55. /* Attribute field */
  56. #define RES_IRQ_TYPE 0x03
  57. #define RES_IRQ_TYPE_EXCLUSIVE 0
  58. #define RES_IRQ_TYPE_TIME 1
  59. #define RES_IRQ_TYPE_DYNAMIC 2
  60. #define RES_IRQ_CSC 0x04
  61. #define RES_SHARED 0x08
  62. #define RES_RESERVED 0x10
  63. #define RES_ALLOCATED 0x20
  64. #define RES_REMOVED 0x40
  65. typedef struct servinfo_t {
  66. char Signature[2];
  67. u_int Count;
  68. u_int Revision;
  69. u_int CSLevel;
  70. char *VendorString;
  71. } servinfo_t;
  72. typedef struct event_callback_args_t {
  73. client_handle_t client_handle;
  74. void *info;
  75. void *mtdrequest;
  76. void *buffer;
  77. void *misc;
  78. void *client_data;
  79. } event_callback_args_t;
  80. /* for GetConfigurationInfo */
  81. typedef struct config_info_t {
  82. u_char Function;
  83. u_int Attributes;
  84. u_int Vcc, Vpp1, Vpp2;
  85. u_int IntType;
  86. u_int ConfigBase;
  87. u_char Status, Pin, Copy, Option, ExtStatus;
  88. u_int Present;
  89. u_int CardValues;
  90. u_int AssignedIRQ;
  91. u_int IRQAttributes;
  92. ioaddr_t BasePort1;
  93. ioaddr_t NumPorts1;
  94. u_int Attributes1;
  95. ioaddr_t BasePort2;
  96. ioaddr_t NumPorts2;
  97. u_int Attributes2;
  98. u_int IOAddrLines;
  99. } config_info_t;
  100. /* For CardValues field */
  101. #define CV_OPTION_VALUE 0x01
  102. #define CV_STATUS_VALUE 0x02
  103. #define CV_PIN_REPLACEMENT 0x04
  104. #define CV_COPY_VALUE 0x08
  105. #define CV_EXT_STATUS 0x10
  106. /* For GetFirst/NextClient */
  107. typedef struct client_req_t {
  108. socket_t Socket;
  109. u_int Attributes;
  110. } client_req_t;
  111. #define CLIENT_THIS_SOCKET 0x01
  112. /* For RegisterClient */
  113. typedef struct client_reg_t {
  114. dev_info_t *dev_info;
  115. u_int Attributes; /* UNUSED */
  116. u_int EventMask;
  117. int (*event_handler)(event_t event, int priority,
  118. event_callback_args_t *);
  119. event_callback_args_t event_callback_args;
  120. u_int Version;
  121. } client_reg_t;
  122. /* ModifyConfiguration */
  123. typedef struct modconf_t {
  124. u_int Attributes;
  125. u_int Vcc, Vpp1, Vpp2;
  126. } modconf_t;
  127. /* Attributes for ModifyConfiguration */
  128. #define CONF_IRQ_CHANGE_VALID 0x100
  129. #define CONF_VCC_CHANGE_VALID 0x200
  130. #define CONF_VPP1_CHANGE_VALID 0x400
  131. #define CONF_VPP2_CHANGE_VALID 0x800
  132. /* For RequestConfiguration */
  133. typedef struct config_req_t {
  134. u_int Attributes;
  135. u_int Vcc, Vpp1, Vpp2;
  136. u_int IntType;
  137. u_int ConfigBase;
  138. u_char Status, Pin, Copy, ExtStatus;
  139. u_char ConfigIndex;
  140. u_int Present;
  141. } config_req_t;
  142. /* Attributes for RequestConfiguration */
  143. #define CONF_ENABLE_IRQ 0x01
  144. #define CONF_ENABLE_DMA 0x02
  145. #define CONF_ENABLE_SPKR 0x04
  146. #define CONF_VALID_CLIENT 0x100
  147. /* IntType field */
  148. #define INT_MEMORY 0x01
  149. #define INT_MEMORY_AND_IO 0x02
  150. #define INT_CARDBUS 0x04
  151. #define INT_ZOOMED_VIDEO 0x08
  152. /* For RequestIO and ReleaseIO */
  153. typedef struct io_req_t {
  154. ioaddr_t BasePort1;
  155. ioaddr_t NumPorts1;
  156. u_int Attributes1;
  157. ioaddr_t BasePort2;
  158. ioaddr_t NumPorts2;
  159. u_int Attributes2;
  160. u_int IOAddrLines;
  161. } io_req_t;
  162. /* Attributes for RequestIO and ReleaseIO */
  163. #define IO_SHARED 0x01
  164. #define IO_FIRST_SHARED 0x02
  165. #define IO_FORCE_ALIAS_ACCESS 0x04
  166. #define IO_DATA_PATH_WIDTH 0x18
  167. #define IO_DATA_PATH_WIDTH_8 0x00
  168. #define IO_DATA_PATH_WIDTH_16 0x08
  169. #define IO_DATA_PATH_WIDTH_AUTO 0x10
  170. /* For RequestIRQ and ReleaseIRQ */
  171. typedef struct irq_req_t {
  172. u_int Attributes;
  173. u_int AssignedIRQ;
  174. u_int IRQInfo1, IRQInfo2; /* IRQInfo2 is ignored */
  175. void *Handler;
  176. void *Instance;
  177. } irq_req_t;
  178. /* Attributes for RequestIRQ and ReleaseIRQ */
  179. #define IRQ_TYPE 0x03
  180. #define IRQ_TYPE_EXCLUSIVE 0x00
  181. #define IRQ_TYPE_TIME 0x01
  182. #define IRQ_TYPE_DYNAMIC_SHARING 0x02
  183. #define IRQ_FORCED_PULSE 0x04
  184. #define IRQ_FIRST_SHARED 0x08
  185. #define IRQ_HANDLE_PRESENT 0x10
  186. #define IRQ_PULSE_ALLOCATED 0x100
  187. /* Bits in IRQInfo1 field */
  188. #define IRQ_MASK 0x0f
  189. #define IRQ_NMI_ID 0x01
  190. #define IRQ_IOCK_ID 0x02
  191. #define IRQ_BERR_ID 0x04
  192. #define IRQ_VEND_ID 0x08
  193. #define IRQ_INFO2_VALID 0x10
  194. #define IRQ_LEVEL_ID 0x20
  195. #define IRQ_PULSE_ID 0x40
  196. #define IRQ_SHARE_ID 0x80
  197. typedef struct eventmask_t {
  198. u_int Attributes;
  199. u_int EventMask;
  200. } eventmask_t;
  201. #define CONF_EVENT_MASK_VALID 0x01
  202. /* Configuration registers present */
  203. #define PRESENT_OPTION 0x001
  204. #define PRESENT_STATUS 0x002
  205. #define PRESENT_PIN_REPLACE 0x004
  206. #define PRESENT_COPY 0x008
  207. #define PRESENT_EXT_STATUS 0x010
  208. #define PRESENT_IOBASE_0 0x020
  209. #define PRESENT_IOBASE_1 0x040
  210. #define PRESENT_IOBASE_2 0x080
  211. #define PRESENT_IOBASE_3 0x100
  212. #define PRESENT_IOSIZE 0x200
  213. /* For GetMemPage, MapMemPage */
  214. typedef struct memreq_t {
  215. u_int CardOffset;
  216. page_t Page;
  217. } memreq_t;
  218. /* For ModifyWindow */
  219. typedef struct modwin_t {
  220. u_int Attributes;
  221. u_int AccessSpeed;
  222. } modwin_t;
  223. /* For RequestWindow */
  224. typedef struct win_req_t {
  225. u_int Attributes;
  226. u_long Base;
  227. u_int Size;
  228. u_int AccessSpeed;
  229. } win_req_t;
  230. /* Attributes for RequestWindow */
  231. #define WIN_ADDR_SPACE 0x0001
  232. #define WIN_ADDR_SPACE_MEM 0x0000
  233. #define WIN_ADDR_SPACE_IO 0x0001
  234. #define WIN_MEMORY_TYPE 0x0002
  235. #define WIN_MEMORY_TYPE_CM 0x0000
  236. #define WIN_MEMORY_TYPE_AM 0x0002
  237. #define WIN_ENABLE 0x0004
  238. #define WIN_DATA_WIDTH 0x0018
  239. #define WIN_DATA_WIDTH_8 0x0000
  240. #define WIN_DATA_WIDTH_16 0x0008
  241. #define WIN_DATA_WIDTH_32 0x0010
  242. #define WIN_PAGED 0x0020
  243. #define WIN_SHARED 0x0040
  244. #define WIN_FIRST_SHARED 0x0080
  245. #define WIN_USE_WAIT 0x0100
  246. #define WIN_STRICT_ALIGN 0x0200
  247. #define WIN_MAP_BELOW_1MB 0x0400
  248. #define WIN_PREFETCH 0x0800
  249. #define WIN_CACHEABLE 0x1000
  250. #define WIN_BAR_MASK 0xe000
  251. #define WIN_BAR_SHIFT 13
  252. /* Attributes for RegisterClient -- UNUSED -- */
  253. #define INFO_MASTER_CLIENT 0x01
  254. #define INFO_IO_CLIENT 0x02
  255. #define INFO_MTD_CLIENT 0x04
  256. #define INFO_MEM_CLIENT 0x08
  257. #define MAX_NUM_CLIENTS 3
  258. #define INFO_CARD_SHARE 0x10
  259. #define INFO_CARD_EXCL 0x20
  260. typedef struct cs_status_t {
  261. u_char Function;
  262. event_t CardState;
  263. event_t SocketState;
  264. } cs_status_t;
  265. typedef struct error_info_t {
  266. int func;
  267. int retcode;
  268. } error_info_t;
  269. /* Flag to bind to all functions */
  270. #define BIND_FN_ALL 0xff
  271. /* Events */
  272. #define CS_EVENT_PRI_LOW 0
  273. #define CS_EVENT_PRI_HIGH 1
  274. #define CS_EVENT_WRITE_PROTECT 0x000001
  275. #define CS_EVENT_CARD_LOCK 0x000002
  276. #define CS_EVENT_CARD_INSERTION 0x000004
  277. #define CS_EVENT_CARD_REMOVAL 0x000008
  278. #define CS_EVENT_BATTERY_DEAD 0x000010
  279. #define CS_EVENT_BATTERY_LOW 0x000020
  280. #define CS_EVENT_READY_CHANGE 0x000040
  281. #define CS_EVENT_CARD_DETECT 0x000080
  282. #define CS_EVENT_RESET_REQUEST 0x000100
  283. #define CS_EVENT_RESET_PHYSICAL 0x000200
  284. #define CS_EVENT_CARD_RESET 0x000400
  285. #define CS_EVENT_REGISTRATION_COMPLETE 0x000800
  286. #define CS_EVENT_PM_SUSPEND 0x002000
  287. #define CS_EVENT_PM_RESUME 0x004000
  288. #define CS_EVENT_INSERTION_REQUEST 0x008000
  289. #define CS_EVENT_EJECTION_REQUEST 0x010000
  290. #define CS_EVENT_MTD_REQUEST 0x020000
  291. #define CS_EVENT_ERASE_COMPLETE 0x040000
  292. #define CS_EVENT_REQUEST_ATTENTION 0x080000
  293. #define CS_EVENT_CB_DETECT 0x100000
  294. #define CS_EVENT_3VCARD 0x200000
  295. #define CS_EVENT_XVCARD 0x400000
  296. /* Return codes */
  297. #define CS_SUCCESS 0x00
  298. #define CS_BAD_ADAPTER 0x01
  299. #define CS_BAD_ATTRIBUTE 0x02
  300. #define CS_BAD_BASE 0x03
  301. #define CS_BAD_EDC 0x04
  302. #define CS_BAD_IRQ 0x06
  303. #define CS_BAD_OFFSET 0x07
  304. #define CS_BAD_PAGE 0x08
  305. #define CS_READ_FAILURE 0x09
  306. #define CS_BAD_SIZE 0x0a
  307. #define CS_BAD_SOCKET 0x0b
  308. #define CS_BAD_TYPE 0x0d
  309. #define CS_BAD_VCC 0x0e
  310. #define CS_BAD_VPP 0x0f
  311. #define CS_BAD_WINDOW 0x11
  312. #define CS_WRITE_FAILURE 0x12
  313. #define CS_NO_CARD 0x14
  314. #define CS_UNSUPPORTED_FUNCTION 0x15
  315. #define CS_UNSUPPORTED_MODE 0x16
  316. #define CS_BAD_SPEED 0x17
  317. #define CS_BUSY 0x18
  318. #define CS_GENERAL_FAILURE 0x19
  319. #define CS_WRITE_PROTECTED 0x1a
  320. #define CS_BAD_ARG_LENGTH 0x1b
  321. #define CS_BAD_ARGS 0x1c
  322. #define CS_CONFIGURATION_LOCKED 0x1d
  323. #define CS_IN_USE 0x1e
  324. #define CS_NO_MORE_ITEMS 0x1f
  325. #define CS_OUT_OF_RESOURCE 0x20
  326. #define CS_BAD_HANDLE 0x21
  327. #define CS_BAD_TUPLE 0x40
  328. #ifdef __KERNEL__
  329. /*
  330. * The main Card Services entry point
  331. */
  332. enum service {
  333. AccessConfigurationRegister, AddSocketServices,
  334. AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory,
  335. DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo,
  336. GetClientInfo, GetConfigurationInfo, GetEventMask,
  337. GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple,
  338. GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple,
  339. GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage,
  340. MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow,
  341. OpenMemory, ParseTuple, ReadMemory, RegisterClient,
  342. RegisterEraseQueue, RegisterMTD, RegisterTimer,
  343. ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ,
  344. ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices,
  345. RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ,
  346. RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry,
  347. SetEventMask, SetRegion, ValidateCIS, VendorSpecific,
  348. WriteMemory, BindDevice, BindMTD, ReportError,
  349. SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS,
  350. GetFirstWindow, GetNextWindow, GetMemPage
  351. };
  352. struct pcmcia_socket;
  353. int pcmcia_access_configuration_register(client_handle_t handle, conf_reg_t *reg);
  354. int pcmcia_deregister_client(client_handle_t handle);
  355. int pcmcia_get_configuration_info(client_handle_t handle, config_info_t *config);
  356. int pcmcia_get_first_window(window_handle_t *win, win_req_t *req);
  357. int pcmcia_get_next_window(window_handle_t *win, win_req_t *req);
  358. int pcmcia_get_status(client_handle_t handle, cs_status_t *status);
  359. int pcmcia_get_mem_page(window_handle_t win, memreq_t *req);
  360. int pcmcia_map_mem_page(window_handle_t win, memreq_t *req);
  361. int pcmcia_modify_configuration(client_handle_t handle, modconf_t *mod);
  362. int pcmcia_register_client(client_handle_t *handle, client_reg_t *req);
  363. int pcmcia_release_configuration(client_handle_t handle);
  364. int pcmcia_release_io(client_handle_t handle, io_req_t *req);
  365. int pcmcia_release_irq(client_handle_t handle, irq_req_t *req);
  366. int pcmcia_release_window(window_handle_t win);
  367. int pcmcia_request_configuration(client_handle_t handle, config_req_t *req);
  368. int pcmcia_request_io(client_handle_t handle, io_req_t *req);
  369. int pcmcia_request_irq(client_handle_t handle, irq_req_t *req);
  370. int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle_t *wh);
  371. int pcmcia_reset_card(client_handle_t handle, client_req_t *req);
  372. int pcmcia_suspend_card(struct pcmcia_socket *skt);
  373. int pcmcia_resume_card(struct pcmcia_socket *skt);
  374. int pcmcia_eject_card(struct pcmcia_socket *skt);
  375. int pcmcia_insert_card(struct pcmcia_socket *skt);
  376. struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt);
  377. void pcmcia_put_socket(struct pcmcia_socket *skt);
  378. #endif /* __KERNEL__ */
  379. #endif /* _LINUX_CS_H */