cs.h 12 KB

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