ss.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /*
  2. * ss.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_SS_H
  15. #define _LINUX_SS_H
  16. #include <linux/device.h>
  17. #include <linux/sched.h> /* task_struct, completion */
  18. #include <linux/mutex.h>
  19. #include <pcmcia/cs_types.h>
  20. #include <pcmcia/cs.h>
  21. #ifdef CONFIG_CARDBUS
  22. #include <linux/pci.h>
  23. #endif
  24. /* Definitions for card status flags for GetStatus */
  25. #define SS_WRPROT 0x0001
  26. #define SS_CARDLOCK 0x0002
  27. #define SS_EJECTION 0x0004
  28. #define SS_INSERTION 0x0008
  29. #define SS_BATDEAD 0x0010
  30. #define SS_BATWARN 0x0020
  31. #define SS_READY 0x0040
  32. #define SS_DETECT 0x0080
  33. #define SS_POWERON 0x0100
  34. #define SS_GPI 0x0200
  35. #define SS_STSCHG 0x0400
  36. #define SS_CARDBUS 0x0800
  37. #define SS_3VCARD 0x1000
  38. #define SS_XVCARD 0x2000
  39. #define SS_PENDING 0x4000
  40. #define SS_ZVCARD 0x8000
  41. /* InquireSocket capabilities */
  42. #define SS_CAP_PAGE_REGS 0x0001
  43. #define SS_CAP_VIRTUAL_BUS 0x0002
  44. #define SS_CAP_MEM_ALIGN 0x0004
  45. #define SS_CAP_STATIC_MAP 0x0008
  46. #define SS_CAP_PCCARD 0x4000
  47. #define SS_CAP_CARDBUS 0x8000
  48. /* for GetSocket, SetSocket */
  49. typedef struct socket_state_t {
  50. u_int flags;
  51. u_int csc_mask;
  52. u_char Vcc, Vpp;
  53. u_char io_irq;
  54. } socket_state_t;
  55. extern socket_state_t dead_socket;
  56. /* Socket configuration flags */
  57. #define SS_PWR_AUTO 0x0010
  58. #define SS_IOCARD 0x0020
  59. #define SS_RESET 0x0040
  60. #define SS_DMA_MODE 0x0080
  61. #define SS_SPKR_ENA 0x0100
  62. #define SS_OUTPUT_ENA 0x0200
  63. /* Flags for I/O port and memory windows */
  64. #define MAP_ACTIVE 0x01
  65. #define MAP_16BIT 0x02
  66. #define MAP_AUTOSZ 0x04
  67. #define MAP_0WS 0x08
  68. #define MAP_WRPROT 0x10
  69. #define MAP_ATTRIB 0x20
  70. #define MAP_USE_WAIT 0x40
  71. #define MAP_PREFETCH 0x80
  72. /* Use this just for bridge windows */
  73. #define MAP_IOSPACE 0x20
  74. /* power hook operations */
  75. #define HOOK_POWER_PRE 0x01
  76. #define HOOK_POWER_POST 0x02
  77. typedef struct pccard_io_map {
  78. u_char map;
  79. u_char flags;
  80. u_short speed;
  81. phys_addr_t start, stop;
  82. } pccard_io_map;
  83. typedef struct pccard_mem_map {
  84. u_char map;
  85. u_char flags;
  86. u_short speed;
  87. phys_addr_t static_start;
  88. u_int card_start;
  89. struct resource *res;
  90. } pccard_mem_map;
  91. typedef struct io_window_t {
  92. u_int InUse, Config;
  93. struct resource *res;
  94. } io_window_t;
  95. /* Maximum number of IO windows per socket */
  96. #define MAX_IO_WIN 2
  97. /* Maximum number of memory windows per socket */
  98. #define MAX_WIN 4
  99. /*
  100. * Socket operations.
  101. */
  102. struct pcmcia_socket;
  103. struct pccard_resource_ops;
  104. struct config_t;
  105. struct pcmcia_callback;
  106. struct user_info_t;
  107. struct pccard_operations {
  108. int (*init)(struct pcmcia_socket *s);
  109. int (*suspend)(struct pcmcia_socket *s);
  110. int (*get_status)(struct pcmcia_socket *s, u_int *value);
  111. int (*set_socket)(struct pcmcia_socket *s, socket_state_t *state);
  112. int (*set_io_map)(struct pcmcia_socket *s, struct pccard_io_map *io);
  113. int (*set_mem_map)(struct pcmcia_socket *s, struct pccard_mem_map *mem);
  114. };
  115. struct pcmcia_socket {
  116. struct module *owner;
  117. spinlock_t lock;
  118. socket_state_t socket;
  119. u_int state;
  120. u_short functions;
  121. u_short lock_count;
  122. pccard_mem_map cis_mem;
  123. void __iomem *cis_virt;
  124. struct {
  125. u_int AssignedIRQ;
  126. u_int Config;
  127. } irq;
  128. io_window_t io[MAX_IO_WIN];
  129. pccard_mem_map win[MAX_WIN];
  130. struct list_head cis_cache;
  131. size_t fake_cis_len;
  132. u8 *fake_cis;
  133. struct list_head socket_list;
  134. struct completion socket_released;
  135. /* deprecated */
  136. unsigned int sock; /* socket number */
  137. /* socket capabilities */
  138. u_int features;
  139. u_int irq_mask;
  140. u_int map_size;
  141. u_int io_offset;
  142. u_int pci_irq;
  143. struct pci_dev *cb_dev;
  144. /* socket setup is done so resources should be able to be allocated.
  145. * Only if set to 1, calls to find_{io,mem}_region are handled, and
  146. * insertio events are actually managed by the PCMCIA layer.*/
  147. u8 resource_setup_done:1;
  148. /* It's old if resource setup is done using adjust_resource_info() */
  149. u8 resource_setup_old:1;
  150. u8 resource_setup_new:1;
  151. u8 reserved:5;
  152. /* socket operations */
  153. struct pccard_operations *ops;
  154. struct pccard_resource_ops *resource_ops;
  155. void *resource_data;
  156. /* Zoom video behaviour is so chip specific its not worth adding
  157. this to _ops */
  158. void (*zoom_video)(struct pcmcia_socket *,
  159. int);
  160. /* so is power hook */
  161. int (*power_hook)(struct pcmcia_socket *sock, int operation);
  162. /* allows tuning the CB bridge before loading driver for the CB card */
  163. #ifdef CONFIG_CARDBUS
  164. void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus);
  165. #endif
  166. /* state thread */
  167. struct task_struct *thread;
  168. struct completion thread_done;
  169. unsigned int thread_events;
  170. /* protects socket h/w state */
  171. struct mutex skt_mutex;
  172. /* protects thread_events */
  173. spinlock_t thread_lock;
  174. /* pcmcia (16-bit) */
  175. struct pcmcia_callback *callback;
  176. #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
  177. /* The following elements refer to 16-bit PCMCIA devices inserted
  178. * into the socket */
  179. struct list_head devices_list;
  180. /* the number of devices, used only internally and subject to
  181. * incorrectness and change */
  182. u8 device_count;
  183. /* 16-bit state: */
  184. struct {
  185. /* PCMCIA card is present in socket */
  186. u8 present:1;
  187. /* "master" ioctl is used */
  188. u8 busy:1;
  189. /* pcmcia module is being unloaded */
  190. u8 dead:1;
  191. /* a multifunction-device add event is pending */
  192. u8 device_add_pending:1;
  193. /* the pending event adds a mfc (1) or pfc (0) */
  194. u8 mfc_pfc:1;
  195. u8 reserved:3;
  196. } pcmcia_state;
  197. /* for adding further pseudo-multifunction devices */
  198. struct work_struct device_add;
  199. #ifdef CONFIG_PCMCIA_IOCTL
  200. struct user_info_t *user;
  201. wait_queue_head_t queue;
  202. #endif /* CONFIG_PCMCIA_IOCTL */
  203. #endif /* CONFIG_PCMCIA */
  204. /* cardbus (32-bit) */
  205. #ifdef CONFIG_CARDBUS
  206. struct resource *cb_cis_res;
  207. void __iomem *cb_cis_virt;
  208. #endif /* CONFIG_CARDBUS */
  209. /* socket device */
  210. struct device dev;
  211. /* data internal to the socket driver */
  212. void *driver_data;
  213. /* status of the card during resume from a system sleep state */
  214. int resume_status;
  215. };
  216. /* socket drivers must define the resource operations type they use. There
  217. * are three options:
  218. * - pccard_static_ops iomem and ioport areas are assigned statically
  219. * - pccard_iodyn_ops iomem areas is assigned statically, ioport
  220. * areas dynamically
  221. * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically.
  222. * If this option is selected, use
  223. * "select PCCARD_NONSTATIC" in Kconfig.
  224. */
  225. extern struct pccard_resource_ops pccard_static_ops;
  226. extern struct pccard_resource_ops pccard_iodyn_ops;
  227. extern struct pccard_resource_ops pccard_nonstatic_ops;
  228. /* socket drivers are expected to use these callbacks in their .drv struct */
  229. extern int pcmcia_socket_dev_suspend(struct device *dev);
  230. extern void pcmcia_socket_dev_early_resume(struct device *dev);
  231. extern void pcmcia_socket_dev_late_resume(struct device *dev);
  232. extern int pcmcia_socket_dev_resume(struct device *dev);
  233. /* socket drivers use this callback in their IRQ handler */
  234. extern void pcmcia_parse_events(struct pcmcia_socket *socket,
  235. unsigned int events);
  236. /* to register and unregister a socket */
  237. extern int pcmcia_register_socket(struct pcmcia_socket *socket);
  238. extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
  239. #endif /* _LINUX_SS_H */