cs.h 8.8 KB

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