ss.h 7.0 KB

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