ss.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. u_int 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. u_long 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. #define WINDOW_MAGIC 0xB35C
  96. typedef struct window_t {
  97. u_short magic;
  98. u_short index;
  99. struct pcmcia_device *handle;
  100. struct pcmcia_socket *sock;
  101. pccard_mem_map ctl;
  102. } window_t;
  103. /* Maximum number of IO windows per socket */
  104. #define MAX_IO_WIN 2
  105. /* Maximum number of memory windows per socket */
  106. #define MAX_WIN 4
  107. /*
  108. * Socket operations.
  109. */
  110. struct pcmcia_socket;
  111. struct pccard_resource_ops;
  112. struct config_t;
  113. struct pcmcia_callback;
  114. struct user_info_t;
  115. struct pccard_operations {
  116. int (*init)(struct pcmcia_socket *s);
  117. int (*suspend)(struct pcmcia_socket *s);
  118. int (*get_status)(struct pcmcia_socket *s, u_int *value);
  119. int (*set_socket)(struct pcmcia_socket *s, socket_state_t *state);
  120. int (*set_io_map)(struct pcmcia_socket *s, struct pccard_io_map *io);
  121. int (*set_mem_map)(struct pcmcia_socket *s, struct pccard_mem_map *mem);
  122. };
  123. struct pcmcia_socket {
  124. struct module *owner;
  125. spinlock_t lock;
  126. socket_state_t socket;
  127. u_int state;
  128. u_short functions;
  129. u_short lock_count;
  130. pccard_mem_map cis_mem;
  131. void __iomem *cis_virt;
  132. struct {
  133. u_int AssignedIRQ;
  134. u_int Config;
  135. } irq;
  136. io_window_t io[MAX_IO_WIN];
  137. window_t win[MAX_WIN];
  138. struct list_head cis_cache;
  139. size_t fake_cis_len;
  140. u8 *fake_cis;
  141. struct list_head socket_list;
  142. struct completion socket_released;
  143. /* deprecated */
  144. unsigned int sock; /* socket number */
  145. /* socket capabilities */
  146. u_int features;
  147. u_int irq_mask;
  148. u_int map_size;
  149. u_int io_offset;
  150. u_char pci_irq;
  151. struct pci_dev * cb_dev;
  152. /* socket setup is done so resources should be able to be allocated.
  153. * Only if set to 1, calls to find_{io,mem}_region are handled, and
  154. * insertio events are actually managed by the PCMCIA layer.*/
  155. u8 resource_setup_done:1;
  156. /* It's old if resource setup is done using adjust_resource_info() */
  157. u8 resource_setup_old:1;
  158. u8 resource_setup_new:1;
  159. u8 reserved:5;
  160. /* socket operations */
  161. struct pccard_operations * ops;
  162. struct pccard_resource_ops * resource_ops;
  163. void * resource_data;
  164. /* Zoom video behaviour is so chip specific its not worth adding
  165. this to _ops */
  166. void (*zoom_video)(struct pcmcia_socket *,
  167. int);
  168. /* so is power hook */
  169. int (*power_hook)(struct pcmcia_socket *sock, int operation);
  170. /* allows tuning the CB bridge before loading driver for the CB card */
  171. #ifdef CONFIG_CARDBUS
  172. void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus);
  173. #endif
  174. /* state thread */
  175. struct task_struct *thread;
  176. struct completion thread_done;
  177. unsigned int thread_events;
  178. /* protects socket h/w state */
  179. struct mutex skt_mutex;
  180. /* protects thread_events */
  181. spinlock_t thread_lock;
  182. /* pcmcia (16-bit) */
  183. struct pcmcia_callback *callback;
  184. #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
  185. /* The following elements refer to 16-bit PCMCIA devices inserted
  186. * into the socket */
  187. struct list_head devices_list;
  188. /* the number of devices, used only internally and subject to
  189. * incorrectness and change */
  190. u8 device_count;
  191. /* 16-bit state: */
  192. struct {
  193. /* PCMCIA card is present in socket */
  194. u8 present:1;
  195. /* "master" ioctl is used */
  196. u8 busy:1;
  197. /* pcmcia module is being unloaded */
  198. u8 dead:1;
  199. /* a multifunction-device add event is pending */
  200. u8 device_add_pending:1;
  201. /* the pending event adds a mfc (1) or pfc (0) */
  202. u8 mfc_pfc:1;
  203. u8 reserved:3;
  204. } pcmcia_state;
  205. /* for adding further pseudo-multifunction devices */
  206. struct work_struct device_add;
  207. #ifdef CONFIG_PCMCIA_IOCTL
  208. struct user_info_t *user;
  209. wait_queue_head_t queue;
  210. #endif /* CONFIG_PCMCIA_IOCTL */
  211. #endif /* CONFIG_PCMCIA */
  212. /* cardbus (32-bit) */
  213. #ifdef CONFIG_CARDBUS
  214. struct resource * cb_cis_res;
  215. void __iomem *cb_cis_virt;
  216. #endif /* CONFIG_CARDBUS */
  217. /* socket device */
  218. struct device dev;
  219. /* data internal to the socket driver */
  220. void *driver_data;
  221. };
  222. /* socket drivers must define the resource operations type they use. There
  223. * are three options:
  224. * - pccard_static_ops iomem and ioport areas are assigned statically
  225. * - pccard_iodyn_ops iomem areas is assigned statically, ioport
  226. * areas dynamically
  227. * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically.
  228. * If this option is selected, use
  229. * "select PCCARD_NONSTATIC" in Kconfig.
  230. */
  231. extern struct pccard_resource_ops pccard_static_ops;
  232. extern struct pccard_resource_ops pccard_iodyn_ops;
  233. extern struct pccard_resource_ops pccard_nonstatic_ops;
  234. /* socket drivers are expected to use these callbacks in their .drv struct */
  235. extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state);
  236. extern int pcmcia_socket_dev_resume(struct device *dev);
  237. /* socket drivers use this callback in their IRQ handler */
  238. extern void pcmcia_parse_events(struct pcmcia_socket *socket,
  239. unsigned int events);
  240. /* to register and unregister a socket */
  241. extern int pcmcia_register_socket(struct pcmcia_socket *socket);
  242. extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
  243. #endif /* _LINUX_SS_H */