cs.h 11 KB

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