Merge with Linux 2.5.74.
[linux-2.6/linux-mips.git] / include / pcmcia / ss.h
blobc0891855a0b10a93d4bae2c60aa156ccb79e1158
1 /*
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.
30 #ifndef _LINUX_SS_H
31 #define _LINUX_SS_H
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
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
55 /* InquireSocket capabilities */
56 #define SS_CAP_PAGE_REGS 0x0001
57 #define SS_CAP_VIRTUAL_BUS 0x0002
58 #define SS_CAP_MEM_ALIGN 0x0004
59 #define SS_CAP_STATIC_MAP 0x0008
60 #define SS_CAP_PCCARD 0x4000
61 #define SS_CAP_CARDBUS 0x8000
63 /* for GetSocket, SetSocket */
64 typedef struct socket_state_t {
65 u_int flags;
66 u_int csc_mask;
67 u_char Vcc, Vpp;
68 u_char io_irq;
69 } socket_state_t;
71 extern socket_state_t dead_socket;
73 /* Socket configuration flags */
74 #define SS_PWR_AUTO 0x0010
75 #define SS_IOCARD 0x0020
76 #define SS_RESET 0x0040
77 #define SS_DMA_MODE 0x0080
78 #define SS_SPKR_ENA 0x0100
79 #define SS_OUTPUT_ENA 0x0200
80 #define SS_DEBOUNCED 0x0400 /* Tell driver that the debounce delay has ended */
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
92 /* Use this just for bridge windows */
93 #define MAP_IOSPACE 0x20
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;
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;
110 typedef struct cb_bridge_map {
111 u_char map;
112 u_char flags;
113 u_int start, stop;
114 } cb_bridge_map;
117 * Socket operations.
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;
142 } erase_busy_t;
144 typedef struct io_window_t {
145 u_int Attributes;
146 ioaddr_t BasePort, NumPorts;
147 ioaddr_t InUse, Config;
148 } io_window_t;
150 #define WINDOW_MAGIC 0xB35C
151 typedef struct window_t {
152 u_short magic;
153 u_short index;
154 client_handle_t handle;
155 struct pcmcia_socket *sock;
156 u_long base;
157 u_long size;
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 region_t;
170 struct pcmcia_socket {
171 struct module *owner;
172 spinlock_t lock;
173 struct pccard_operations * ss_entry;
174 socket_state_t socket;
175 u_int state;
176 u_short functions;
177 u_short lock_count;
178 client_handle_t clients;
179 u_int real_clients;
180 pccard_mem_map cis_mem;
181 u_char *cis_virt;
182 struct config_t *config;
183 struct {
184 u_int AssignedIRQ;
185 u_int Config;
186 } irq;
187 io_window_t io[MAX_IO_WIN];
188 window_t win[MAX_WIN];
189 struct region_t *c_region, *a_region;
190 erase_busy_t erase_busy;
191 struct list_head cis_cache;
192 u_int fake_cis_len;
193 char *fake_cis;
195 struct list_head socket_list;
196 struct completion socket_released;
198 /* deprecated */
199 unsigned int sock; /* socket number */
202 /* socket capabilities */
203 u_int features;
204 u_int irq_mask;
205 u_int map_size;
206 ioaddr_t io_offset;
207 u_char pci_irq;
208 struct pci_dev * cb_dev;
210 /* state thread */
211 struct semaphore skt_sem; /* protects socket h/w state */
213 struct task_struct *thread;
214 struct completion thread_done;
215 wait_queue_head_t thread_wait;
216 spinlock_t thread_lock; /* protects thread_events */
217 unsigned int thread_events;
219 /* pcmcia (16-bit) */
220 struct pcmcia_bus_socket *pcmcia;
222 /* cardbus (32-bit) */
223 #ifdef CONFIG_CARDBUS
224 struct resource * cb_cis_res;
225 u_char *cb_cis_virt;
226 #endif
228 /* socket device */
229 struct class_device dev;
230 void *driver_data; /* data internal to the socket driver */
234 struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr);
238 extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events);
239 extern int pcmcia_register_socket(struct pcmcia_socket *socket);
240 extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
242 extern struct class pcmcia_socket_class;
244 /* socket drivers are expected to use these callbacks in their .drv struct */
245 extern int pcmcia_socket_dev_suspend(struct device *dev, u32 state, u32 level);
246 extern int pcmcia_socket_dev_resume(struct device *dev, u32 level);
248 #endif /* _LINUX_SS_H */