ss.h 7.0 KB

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