2 * ss.h 1.28 2000/06/12 21:55:40
4 * The contents of this file are subject to the Mozilla Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License
7 * at http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific language governing rights and
12 * limitations under the License.
14 * The initial developer of the original code is David A. Hinds
15 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
16 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
18 * Alternatively, the contents of this file may be used under the
19 * terms of the GNU General Public License version 2 (the "GPL"), in which
20 * case the provisions of the GPL are applicable instead of the
21 * above. If you wish to allow the use of your version of this file
22 * only under the terms of the GPL and not to allow others to use
23 * your version of this file under the MPL, indicate your decision by
24 * deleting the provisions above and replace them with the notice and
25 * other provisions required by the GPL. If you do not delete the
26 * provisions above, a recipient may use your version of this file
27 * under either the MPL or the GPL.
33 #include <pcmcia/cs_types.h>
34 #include <pcmcia/cs.h>
35 #include <pcmcia/bulkmem.h>
36 #include <linux/device.h>
38 /* Definitions for card status flags for GetStatus */
39 #define SS_WRPROT 0x0001
40 #define SS_CARDLOCK 0x0002
41 #define SS_EJECTION 0x0004
42 #define SS_INSERTION 0x0008
43 #define SS_BATDEAD 0x0010
44 #define SS_BATWARN 0x0020
45 #define SS_READY 0x0040
46 #define SS_DETECT 0x0080
47 #define SS_POWERON 0x0100
49 #define SS_STSCHG 0x0400
50 #define SS_CARDBUS 0x0800
51 #define SS_3VCARD 0x1000
52 #define SS_XVCARD 0x2000
53 #define SS_PENDING 0x4000
54 #define SS_ZVCARD 0x8000
56 /* InquireSocket capabilities */
57 #define SS_CAP_PAGE_REGS 0x0001
58 #define SS_CAP_VIRTUAL_BUS 0x0002
59 #define SS_CAP_MEM_ALIGN 0x0004
60 #define SS_CAP_STATIC_MAP 0x0008
61 #define SS_CAP_PCCARD 0x4000
62 #define SS_CAP_CARDBUS 0x8000
64 /* for GetSocket, SetSocket */
65 typedef struct socket_state_t {
72 extern socket_state_t dead_socket;
74 /* Socket configuration flags */
75 #define SS_PWR_AUTO 0x0010
76 #define SS_IOCARD 0x0020
77 #define SS_RESET 0x0040
78 #define SS_DMA_MODE 0x0080
79 #define SS_SPKR_ENA 0x0100
80 #define SS_OUTPUT_ENA 0x0200
82 /* Flags for I/O port and memory windows */
83 #define MAP_ACTIVE 0x01
84 #define MAP_16BIT 0x02
85 #define MAP_AUTOSZ 0x04
87 #define MAP_WRPROT 0x10
88 #define MAP_ATTRIB 0x20
89 #define MAP_USE_WAIT 0x40
90 #define MAP_PREFETCH 0x80
92 /* Use this just for bridge windows */
93 #define MAP_IOSPACE 0x20
95 typedef struct pccard_io_map {
102 typedef struct pccard_mem_map {
106 u_long sys_start, sys_stop;
110 typedef struct cb_bridge_map {
119 struct pcmcia_socket;
121 struct pccard_operations {
122 int (*init)(struct pcmcia_socket *sock);
123 int (*suspend)(struct pcmcia_socket *sock);
124 int (*register_callback)(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info);
125 int (*get_status)(struct pcmcia_socket *sock, u_int *value);
126 int (*get_socket)(struct pcmcia_socket *sock, socket_state_t *state);
127 int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state);
128 int (*set_io_map)(struct pcmcia_socket *sock, struct pccard_io_map *io);
129 int (*set_mem_map)(struct pcmcia_socket *sock, struct pccard_mem_map *mem);
133 * Calls to set up low-level "Socket Services" drivers
135 struct pcmcia_socket;
137 typedef struct erase_busy_t {
138 eraseq_entry_t *erase;
139 client_handle_t client;
140 struct timer_list timeout;
141 struct erase_busy_t *prev, *next;
144 typedef struct io_window_t {
146 ioaddr_t BasePort, NumPorts;
147 ioaddr_t InUse, Config;
150 #define WINDOW_MAGIC 0xB35C
151 typedef struct window_t {
154 client_handle_t handle;
155 struct pcmcia_socket *sock;
161 /* Maximum number of IO windows per socket */
164 /* Maximum number of memory windows per socket */
170 struct pcmcia_socket {
171 struct module *owner;
173 socket_state_t socket;
177 client_handle_t clients;
178 pccard_mem_map cis_mem;
180 struct config_t *config;
185 io_window_t io[MAX_IO_WIN];
186 window_t win[MAX_WIN];
187 struct region_t *c_region, *a_region;
188 erase_busy_t erase_busy;
189 struct list_head cis_cache;
193 struct list_head socket_list;
194 struct completion socket_released;
197 unsigned int sock; /* socket number */
200 /* socket capabilities */
206 struct pci_dev * cb_dev;
208 /* socket operations */
209 struct pccard_operations * ops;
211 /* Zoom video behaviour is so chip specific its not worth adding
213 void (*zoom_video)(struct pcmcia_socket *, int);
216 struct semaphore skt_sem; /* protects socket h/w state */
218 struct task_struct *thread;
219 struct completion thread_done;
220 wait_queue_head_t thread_wait;
221 spinlock_t thread_lock; /* protects thread_events */
222 unsigned int thread_events;
224 /* pcmcia (16-bit) */
225 struct pcmcia_bus_socket *pcmcia;
227 /* cardbus (32-bit) */
228 #ifdef CONFIG_CARDBUS
229 struct resource * cb_cis_res;
234 struct class_device dev;
235 void *driver_data; /* data internal to the socket driver */
239 struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr);
243 extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events);
244 extern int pcmcia_register_socket(struct pcmcia_socket *socket);
245 extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
247 extern struct class pcmcia_socket_class;
249 /* socket drivers are expected to use these callbacks in their .drv struct */
250 extern int pcmcia_socket_dev_suspend(struct device *dev, u32 state);
251 extern int pcmcia_socket_dev_resume(struct device *dev);
253 #endif /* _LINUX_SS_H */