patch-2_6_7-vs1_9_1_12
[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      sys_start, sys_stop;
107     u_int       card_start;
108 } pccard_mem_map;
109
110 typedef struct cb_bridge_map {
111     u_char      map;
112     u_char      flags;
113     u_int       start, stop;
114 } cb_bridge_map;
115
116 /*
117  * Socket operations.
118  */
119 struct pcmcia_socket;
120
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);
130 };
131
132 /*
133  *  Calls to set up low-level "Socket Services" drivers
134  */
135 struct pcmcia_socket;
136
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;
142 } erase_busy_t;
143
144 typedef struct io_window_t {
145         u_int                   Attributes;
146         ioaddr_t                BasePort, NumPorts;
147         ioaddr_t                InUse, Config;
148         struct resource         *res;
149 } io_window_t;
150
151 #define WINDOW_MAGIC    0xB35C
152 typedef struct window_t {
153         u_short                 magic;
154         u_short                 index;
155         client_handle_t         handle;
156         struct pcmcia_socket    *sock;
157         u_long                  base;
158         u_long                  size;
159         pccard_mem_map          ctl;
160 } window_t;
161
162 /* Maximum number of IO windows per socket */
163 #define MAX_IO_WIN 2
164
165 /* Maximum number of memory windows per socket */
166 #define MAX_WIN 4
167
168 struct config_t;
169 struct region_t;
170
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         client_handle_t                 clients;
179         pccard_mem_map                  cis_mem;
180         u_char                          *cis_virt;
181         struct config_t                 *config;
182         struct {
183                 u_int                   AssignedIRQ;
184                 u_int                   Config;
185         } irq;
186         io_window_t                     io[MAX_IO_WIN];
187         window_t                        win[MAX_WIN];
188         struct region_t                 *c_region, *a_region;
189         erase_busy_t                    erase_busy;
190         struct list_head                cis_cache;
191         u_int                           fake_cis_len;
192         char                            *fake_cis;
193
194         struct list_head                socket_list;
195         struct completion               socket_released;
196
197         /* deprecated */
198         unsigned int                    sock;           /* socket number */
199
200
201         /* socket capabilities */
202         u_int                           features;
203         u_int                           irq_mask;
204         u_int                           map_size;
205         ioaddr_t                        io_offset;
206         u_char                          pci_irq;
207         struct pci_dev *                cb_dev;
208
209         /* socket operations */
210         struct pccard_operations *      ops;
211
212         /* Zoom video behaviour is so chip specific its not worth adding
213            this to _ops */
214         void                            (*zoom_video)(struct pcmcia_socket *, int);
215                            
216         /* state thread */
217         struct semaphore                skt_sem;        /* protects socket h/w state */
218
219         struct task_struct              *thread;
220         struct completion               thread_done;
221         wait_queue_head_t               thread_wait;
222         spinlock_t                      thread_lock;    /* protects thread_events */
223         unsigned int                    thread_events;
224
225         /* pcmcia (16-bit) */
226         struct pcmcia_bus_socket        *pcmcia;
227
228         /* cardbus (32-bit) */
229 #ifdef CONFIG_CARDBUS
230         struct resource *               cb_cis_res;
231         u_char                          *cb_cis_virt;
232 #endif
233
234         /* socket device */
235         struct class_device             dev;
236         void                            *driver_data;   /* data internal to the socket driver */
237
238 };
239
240 struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr);
241
242
243
244 extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events);
245 extern int pcmcia_register_socket(struct pcmcia_socket *socket);
246 extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
247
248 extern struct class pcmcia_socket_class;
249
250 /* socket drivers are expected to use these callbacks in their .drv struct */
251 extern int pcmcia_socket_dev_suspend(struct device *dev, u32 state);
252 extern int pcmcia_socket_dev_resume(struct device *dev);
253
254 #endif /* _LINUX_SS_H */