vserver 1.9.3
[linux-2.6.git] / include / pcmcia / ss.h
1 /*
2  * ss.h 1.28 2000/06/12 21:55:40
3  *
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/
8  *
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. 
13  *
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.
17  *
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.
28  */
29
30 #ifndef _LINUX_SS_H
31 #define _LINUX_SS_H
32
33 #include <pcmcia/cs_types.h>
34 #include <pcmcia/cs.h>
35 #include <pcmcia/bulkmem.h>
36 #include <linux/device.h>
37
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
48 #define SS_GPI          0x0200
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
55
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
63
64 /* for GetSocket, SetSocket */
65 typedef struct socket_state_t {
66     u_int       flags;
67     u_int       csc_mask;
68     u_char      Vcc, Vpp;
69     u_char      io_irq;
70 } socket_state_t;
71
72 extern socket_state_t dead_socket;
73
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
81
82 /* Flags for I/O port and memory windows */
83 #define MAP_ACTIVE      0x01
84 #define MAP_16BIT       0x02
85 #define MAP_AUTOSZ      0x04
86 #define MAP_0WS         0x08
87 #define MAP_WRPROT      0x10
88 #define MAP_ATTRIB      0x20
89 #define MAP_USE_WAIT    0x40
90 #define MAP_PREFETCH    0x80
91
92 /* Use this just for bridge windows */
93 #define MAP_IOSPACE     0x20
94
95 typedef struct pccard_io_map {
96     u_char      map;
97     u_char      flags;
98     u_short     speed;
99     ioaddr_t    start, stop;
100 } pccard_io_map;
101
102 typedef struct pccard_mem_map {
103     u_char      map;
104     u_char      flags;
105     u_short     speed;
106     u_long      static_start;
107     u_int       card_start;
108     struct resource *res;
109 } pccard_mem_map;
110
111 typedef struct cb_bridge_map {
112     u_char      map;
113     u_char      flags;
114     u_int       start, stop;
115 } cb_bridge_map;
116
117 /*
118  * Socket operations.
119  */
120 struct pcmcia_socket;
121
122 struct pccard_operations {
123         int (*init)(struct pcmcia_socket *sock);
124         int (*suspend)(struct pcmcia_socket *sock);
125         int (*register_callback)(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info);
126         int (*get_status)(struct pcmcia_socket *sock, u_int *value);
127         int (*get_socket)(struct pcmcia_socket *sock, socket_state_t *state);
128         int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state);
129         int (*set_io_map)(struct pcmcia_socket *sock, struct pccard_io_map *io);
130         int (*set_mem_map)(struct pcmcia_socket *sock, struct pccard_mem_map *mem);
131 };
132
133 /*
134  *  Calls to set up low-level "Socket Services" drivers
135  */
136 struct pcmcia_socket;
137
138 typedef struct erase_busy_t {
139         eraseq_entry_t          *erase;
140         client_handle_t         client;
141         struct timer_list       timeout;
142         struct erase_busy_t     *prev, *next;
143 } erase_busy_t;
144
145 typedef struct io_window_t {
146         u_int                   Attributes;
147         ioaddr_t                BasePort, NumPorts;
148         ioaddr_t                InUse, Config;
149         struct resource         *res;
150 } io_window_t;
151
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;
160
161 /* Maximum number of IO windows per socket */
162 #define MAX_IO_WIN 2
163
164 /* Maximum number of memory windows per socket */
165 #define MAX_WIN 4
166
167 struct config_t;
168 struct region_t;
169
170 struct pcmcia_socket {
171         struct module                   *owner;
172         spinlock_t                      lock;
173         socket_state_t                  socket;
174         u_int                           state;
175         u_short                         functions;
176         u_short                         lock_count;
177         client_handle_t                 clients;
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 region_t                 *c_region, *a_region;
188         erase_busy_t                    erase_busy;
189         struct list_head                cis_cache;
190         u_int                           fake_cis_len;
191         char                            *fake_cis;
192
193         struct list_head                socket_list;
194         struct completion               socket_released;
195
196         /* deprecated */
197         unsigned int                    sock;           /* socket number */
198
199
200         /* socket capabilities */
201         u_int                           features;
202         u_int                           irq_mask;
203         u_int                           map_size;
204         ioaddr_t                        io_offset;
205         u_char                          pci_irq;
206         struct pci_dev *                cb_dev;
207
208         /* socket operations */
209         struct pccard_operations *      ops;
210
211         /* Zoom video behaviour is so chip specific its not worth adding
212            this to _ops */
213         void                            (*zoom_video)(struct pcmcia_socket *, int);
214                            
215         /* state thread */
216         struct semaphore                skt_sem;        /* protects socket h/w state */
217
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;
223
224         /* pcmcia (16-bit) */
225         struct pcmcia_bus_socket        *pcmcia;
226
227         /* cardbus (32-bit) */
228 #ifdef CONFIG_CARDBUS
229         struct resource *               cb_cis_res;
230         void __iomem                    *cb_cis_virt;
231 #endif
232
233         /* socket device */
234         struct class_device             dev;
235         void                            *driver_data;   /* data internal to the socket driver */
236
237 };
238
239 struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr);
240
241
242
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);
246
247 extern struct class pcmcia_socket_class;
248
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);
252
253 #endif /* _LINUX_SS_H */