[TG3]: Add tagged status support.
[linux-2.6/verdex.git] / include / pcmcia / ss.h
blob6d3413a567081a6f6a95b03dcee6b26796814a79
1 /*
2 * ss.h
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.
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.
12 * (C) 1999 David A. Hinds
15 #ifndef _LINUX_SS_H
16 #define _LINUX_SS_H
18 #include <pcmcia/cs_types.h>
19 #include <pcmcia/cs.h>
20 #include <pcmcia/bulkmem.h>
21 #include <linux/device.h>
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
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
49 /* for GetSocket, SetSocket */
50 typedef struct socket_state_t {
51 u_int flags;
52 u_int csc_mask;
53 u_char Vcc, Vpp;
54 u_char io_irq;
55 } socket_state_t;
57 extern socket_state_t dead_socket;
59 /* Socket configuration flags */
60 #define SS_PWR_AUTO 0x0010
61 #define SS_IOCARD 0x0020
62 #define SS_RESET 0x0040
63 #define SS_DMA_MODE 0x0080
64 #define SS_SPKR_ENA 0x0100
65 #define SS_OUTPUT_ENA 0x0200
67 /* Flags for I/O port and memory windows */
68 #define MAP_ACTIVE 0x01
69 #define MAP_16BIT 0x02
70 #define MAP_AUTOSZ 0x04
71 #define MAP_0WS 0x08
72 #define MAP_WRPROT 0x10
73 #define MAP_ATTRIB 0x20
74 #define MAP_USE_WAIT 0x40
75 #define MAP_PREFETCH 0x80
77 /* Use this just for bridge windows */
78 #define MAP_IOSPACE 0x20
80 typedef struct pccard_io_map {
81 u_char map;
82 u_char flags;
83 u_short speed;
84 kio_addr_t start, stop;
85 } pccard_io_map;
87 typedef struct pccard_mem_map {
88 u_char map;
89 u_char flags;
90 u_short speed;
91 u_long static_start;
92 u_int card_start;
93 struct resource *res;
94 } pccard_mem_map;
96 typedef struct cb_bridge_map {
97 u_char map;
98 u_char flags;
99 u_int start, stop;
100 } cb_bridge_map;
103 * Socket operations.
105 struct pcmcia_socket;
107 struct pccard_operations {
108 int (*init)(struct pcmcia_socket *sock);
109 int (*suspend)(struct pcmcia_socket *sock);
110 int (*register_callback)(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info);
111 int (*get_status)(struct pcmcia_socket *sock, u_int *value);
112 int (*get_socket)(struct pcmcia_socket *sock, socket_state_t *state);
113 int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state);
114 int (*set_io_map)(struct pcmcia_socket *sock, struct pccard_io_map *io);
115 int (*set_mem_map)(struct pcmcia_socket *sock, struct pccard_mem_map *mem);
118 struct pccard_resource_ops {
119 void (*validate_mem) (struct pcmcia_socket *s);
120 int (*adjust_io_region) (struct resource *res,
121 unsigned long r_start,
122 unsigned long r_end,
123 struct pcmcia_socket *s);
124 struct resource* (*find_io) (unsigned long base, int num,
125 unsigned long align,
126 struct pcmcia_socket *s);
127 struct resource* (*find_mem) (unsigned long base, unsigned long num,
128 unsigned long align, int low,
129 struct pcmcia_socket *s);
130 int (*adjust_resource) (struct pcmcia_socket *s,
131 adjust_t *adj);
132 int (*init) (struct pcmcia_socket *s);
133 void (*exit) (struct pcmcia_socket *s);
135 /* SS_CAP_STATIC_MAP */
136 extern struct pccard_resource_ops pccard_static_ops;
137 /* !SS_CAP_STATIC_MAP */
138 extern struct pccard_resource_ops pccard_nonstatic_ops;
141 * Calls to set up low-level "Socket Services" drivers
143 struct pcmcia_socket;
145 typedef struct io_window_t {
146 u_int Attributes;
147 kio_addr_t BasePort, NumPorts;
148 kio_addr_t InUse, Config;
149 struct resource *res;
150 } io_window_t;
152 #define WINDOW_MAGIC 0xB35C
153 typedef struct window_t {
154 u_short magic;
155 u_short index;
156 client_handle_t handle;
157 struct pcmcia_socket *sock;
158 pccard_mem_map ctl;
159 } window_t;
161 /* Maximum number of IO windows per socket */
162 #define MAX_IO_WIN 2
164 /* Maximum number of memory windows per socket */
165 #define MAX_WIN 4
167 struct config_t;
168 struct pcmcia_callback;
171 struct pcmcia_socket {
172 struct module *owner;
173 spinlock_t lock;
174 socket_state_t socket;
175 u_int state;
176 u_short functions;
177 u_short lock_count;
178 pccard_mem_map cis_mem;
179 void __iomem *cis_virt;
180 struct config_t *config;
181 struct {
182 u_int AssignedIRQ;
183 u_int Config;
184 } irq;
185 io_window_t io[MAX_IO_WIN];
186 window_t win[MAX_WIN];
187 struct list_head cis_cache;
188 u_int fake_cis_len;
189 char *fake_cis;
191 struct list_head socket_list;
192 struct completion socket_released;
194 /* deprecated */
195 unsigned int sock; /* socket number */
198 /* socket capabilities */
199 u_int features;
200 u_int irq_mask;
201 u_int map_size;
202 kio_addr_t io_offset;
203 u_char pci_irq;
204 struct pci_dev * cb_dev;
207 /* socket setup is done so resources should be able to be allocated. Only
208 * if set to 1, calls to find_{io,mem}_region are handled, and insertion
209 * events are actually managed by the PCMCIA layer.*/
210 u8 resource_setup_done:1;
212 /* is set to one if resource setup is done using adjust_resource_info() */
213 u8 resource_setup_old:1;
215 u8 reserved:6;
217 /* socket operations */
218 struct pccard_operations * ops;
219 struct pccard_resource_ops * resource_ops;
220 void * resource_data;
222 /* Zoom video behaviour is so chip specific its not worth adding
223 this to _ops */
224 void (*zoom_video)(struct pcmcia_socket *, int);
226 /* state thread */
227 struct semaphore skt_sem; /* protects socket h/w state */
229 struct task_struct *thread;
230 struct completion thread_done;
231 wait_queue_head_t thread_wait;
232 spinlock_t thread_lock; /* protects thread_events */
233 unsigned int thread_events;
235 /* pcmcia (16-bit) */
236 struct pcmcia_bus_socket *pcmcia;
237 struct pcmcia_callback *callback;
239 /* cardbus (32-bit) */
240 #ifdef CONFIG_CARDBUS
241 struct resource * cb_cis_res;
242 void __iomem *cb_cis_virt;
243 #endif
245 /* socket device */
246 struct class_device dev;
247 void *driver_data; /* data internal to the socket driver */
251 struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr);
255 extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events);
256 extern int pcmcia_register_socket(struct pcmcia_socket *socket);
257 extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
259 extern struct class pcmcia_socket_class;
261 /* socket drivers are expected to use these callbacks in their .drv struct */
262 extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state);
263 extern int pcmcia_socket_dev_resume(struct device *dev);
265 #endif /* _LINUX_SS_H */