[PATCH] pcmcia: make PCMCIA status a bitfield
[deliverable/linux.git] / include / pcmcia / ss.h
CommitLineData
1da177e4
LT
1/*
2 * ss.h
3 *
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.
7 *
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.
11 *
12 * (C) 1999 David A. Hinds
13 */
14
15#ifndef _LINUX_SS_H
16#define _LINUX_SS_H
17
18#include <pcmcia/cs_types.h>
19#include <pcmcia/cs.h>
20#include <pcmcia/bulkmem.h>
21#include <linux/device.h>
22
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
40
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
48
49/* for GetSocket, SetSocket */
50typedef 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;
56
57extern socket_state_t dead_socket;
58
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
66
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
76
77/* Use this just for bridge windows */
78#define MAP_IOSPACE 0x20
79
fa912bcb
DR
80/* power hook operations */
81#define HOOK_POWER_PRE 0x01
82#define HOOK_POWER_POST 0x02
83
84
1da177e4
LT
85typedef struct pccard_io_map {
86 u_char map;
87 u_char flags;
88 u_short speed;
89 kio_addr_t start, stop;
90} pccard_io_map;
91
92typedef struct pccard_mem_map {
93 u_char map;
94 u_char flags;
95 u_short speed;
96 u_long static_start;
97 u_int card_start;
98 struct resource *res;
99} pccard_mem_map;
100
101typedef struct cb_bridge_map {
102 u_char map;
103 u_char flags;
104 u_int start, stop;
105} cb_bridge_map;
106
107/*
108 * Socket operations.
109 */
110struct pcmcia_socket;
111
112struct pccard_operations {
113 int (*init)(struct pcmcia_socket *sock);
114 int (*suspend)(struct pcmcia_socket *sock);
115 int (*register_callback)(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info);
116 int (*get_status)(struct pcmcia_socket *sock, u_int *value);
117 int (*get_socket)(struct pcmcia_socket *sock, socket_state_t *state);
118 int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state);
119 int (*set_io_map)(struct pcmcia_socket *sock, struct pccard_io_map *io);
120 int (*set_mem_map)(struct pcmcia_socket *sock, struct pccard_mem_map *mem);
121};
122
123struct pccard_resource_ops {
124 void (*validate_mem) (struct pcmcia_socket *s);
125 int (*adjust_io_region) (struct resource *res,
126 unsigned long r_start,
127 unsigned long r_end,
128 struct pcmcia_socket *s);
129 struct resource* (*find_io) (unsigned long base, int num,
130 unsigned long align,
131 struct pcmcia_socket *s);
132 struct resource* (*find_mem) (unsigned long base, unsigned long num,
133 unsigned long align, int low,
134 struct pcmcia_socket *s);
135 int (*adjust_resource) (struct pcmcia_socket *s,
136 adjust_t *adj);
137 int (*init) (struct pcmcia_socket *s);
138 void (*exit) (struct pcmcia_socket *s);
139};
140/* SS_CAP_STATIC_MAP */
141extern struct pccard_resource_ops pccard_static_ops;
142/* !SS_CAP_STATIC_MAP */
143extern struct pccard_resource_ops pccard_nonstatic_ops;
144
145/*
146 * Calls to set up low-level "Socket Services" drivers
147 */
148struct pcmcia_socket;
149
150typedef struct io_window_t {
151 u_int Attributes;
152 kio_addr_t BasePort, NumPorts;
153 kio_addr_t InUse, Config;
154 struct resource *res;
155} io_window_t;
156
157#define WINDOW_MAGIC 0xB35C
158typedef struct window_t {
159 u_short magic;
160 u_short index;
161 client_handle_t handle;
162 struct pcmcia_socket *sock;
163 pccard_mem_map ctl;
164} window_t;
165
166/* Maximum number of IO windows per socket */
167#define MAX_IO_WIN 2
168
169/* Maximum number of memory windows per socket */
170#define MAX_WIN 4
171
172struct config_t;
173struct pcmcia_callback;
174
175
176struct pcmcia_socket {
177 struct module *owner;
178 spinlock_t lock;
179 socket_state_t socket;
180 u_int state;
181 u_short functions;
182 u_short lock_count;
183 pccard_mem_map cis_mem;
184 void __iomem *cis_virt;
185 struct config_t *config;
186 struct {
187 u_int AssignedIRQ;
188 u_int Config;
189 } irq;
190 io_window_t io[MAX_IO_WIN];
191 window_t win[MAX_WIN];
192 struct list_head cis_cache;
193 u_int fake_cis_len;
194 char *fake_cis;
195
196 struct list_head socket_list;
197 struct completion socket_released;
198
199 /* deprecated */
200 unsigned int sock; /* socket number */
201
202
203 /* socket capabilities */
204 u_int features;
205 u_int irq_mask;
206 u_int map_size;
207 kio_addr_t io_offset;
208 u_char pci_irq;
209 struct pci_dev * cb_dev;
210
211
212 /* socket setup is done so resources should be able to be allocated. Only
213 * if set to 1, calls to find_{io,mem}_region are handled, and insertion
214 * events are actually managed by the PCMCIA layer.*/
215 u8 resource_setup_done:1;
216
217 /* is set to one if resource setup is done using adjust_resource_info() */
218 u8 resource_setup_old:1;
3c29976a 219 u8 resource_setup_new:1;
1da177e4 220
3c29976a 221 u8 reserved:5;
1da177e4
LT
222
223 /* socket operations */
224 struct pccard_operations * ops;
225 struct pccard_resource_ops * resource_ops;
226 void * resource_data;
227
228 /* Zoom video behaviour is so chip specific its not worth adding
229 this to _ops */
230 void (*zoom_video)(struct pcmcia_socket *, int);
fa912bcb
DR
231
232 /* so is power hook */
233 int (*power_hook)(struct pcmcia_socket *sock, int operation);
1da177e4
LT
234
235 /* state thread */
236 struct semaphore skt_sem; /* protects socket h/w state */
237
238 struct task_struct *thread;
239 struct completion thread_done;
240 wait_queue_head_t thread_wait;
241 spinlock_t thread_lock; /* protects thread_events */
242 unsigned int thread_events;
243
244 /* pcmcia (16-bit) */
245 struct pcmcia_bus_socket *pcmcia;
246 struct pcmcia_callback *callback;
247
248 /* cardbus (32-bit) */
249#ifdef CONFIG_CARDBUS
250 struct resource * cb_cis_res;
251 void __iomem *cb_cis_virt;
252#endif
253
254 /* socket device */
255 struct class_device dev;
256 void *driver_data; /* data internal to the socket driver */
257
258};
259
260struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr);
261
262
263
264extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events);
265extern int pcmcia_register_socket(struct pcmcia_socket *socket);
266extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
267
268extern struct class pcmcia_socket_class;
269
270/* socket drivers are expected to use these callbacks in their .drv struct */
271extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state);
272extern int pcmcia_socket_dev_resume(struct device *dev);
273
274#endif /* _LINUX_SS_H */
This page took 0.054188 seconds and 5 git commands to generate.