aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pcmcia/cs_internal.h27
-rw-r--r--include/pcmcia/ss.h198
2 files changed, 118 insertions, 107 deletions
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index 8e43c4d563d1..2df8d8be1ff9 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -50,6 +50,30 @@ struct cis_cache_entry {
50 unsigned char cache[0]; 50 unsigned char cache[0];
51}; 51};
52 52
53struct pccard_resource_ops {
54 int (*validate_mem) (struct pcmcia_socket *s);
55 int (*adjust_io_region) (struct resource *res,
56 unsigned long r_start,
57 unsigned long r_end,
58 struct pcmcia_socket *s);
59 struct resource* (*find_io) (unsigned long base, int num,
60 unsigned long align,
61 struct pcmcia_socket *s);
62 struct resource* (*find_mem) (unsigned long base, unsigned long num,
63 unsigned long align, int low,
64 struct pcmcia_socket *s);
65 int (*add_io) (struct pcmcia_socket *s,
66 unsigned int action,
67 unsigned long r_start,
68 unsigned long r_end);
69 int (*add_mem) (struct pcmcia_socket *s,
70 unsigned int action,
71 unsigned long r_start,
72 unsigned long r_end);
73 int (*init) (struct pcmcia_socket *s);
74 void (*exit) (struct pcmcia_socket *s);
75};
76
53/* Flags in config state */ 77/* Flags in config state */
54#define CONFIG_LOCKED 0x01 78#define CONFIG_LOCKED 0x01
55#define CONFIG_IRQ_REQ 0x02 79#define CONFIG_IRQ_REQ 0x02
@@ -144,12 +168,15 @@ struct pcmcia_callback{
144/* cs.c */ 168/* cs.c */
145extern struct rw_semaphore pcmcia_socket_list_rwsem; 169extern struct rw_semaphore pcmcia_socket_list_rwsem;
146extern struct list_head pcmcia_socket_list; 170extern struct list_head pcmcia_socket_list;
171extern struct class pcmcia_socket_class;
172
147int pcmcia_get_window(struct pcmcia_socket *s, 173int pcmcia_get_window(struct pcmcia_socket *s,
148 window_handle_t *handle, 174 window_handle_t *handle,
149 int idx, 175 int idx,
150 win_req_t *req); 176 win_req_t *req);
151int pccard_reset_card(struct pcmcia_socket *skt); 177int pccard_reset_card(struct pcmcia_socket *skt);
152int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); 178int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
179struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr);
153 180
154/* cistpl.c */ 181/* cistpl.c */
155int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, 182int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr,
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index e34bef0fc74f..9b4ac9385f5d 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -53,10 +53,10 @@
53 53
54/* for GetSocket, SetSocket */ 54/* for GetSocket, SetSocket */
55typedef struct socket_state_t { 55typedef struct socket_state_t {
56 u_int flags; 56 u_int flags;
57 u_int csc_mask; 57 u_int csc_mask;
58 u_char Vcc, Vpp; 58 u_char Vcc, Vpp;
59 u_char io_irq; 59 u_char io_irq;
60} socket_state_t; 60} socket_state_t;
61 61
62extern socket_state_t dead_socket; 62extern socket_state_t dead_socket;
@@ -86,79 +86,22 @@ extern socket_state_t dead_socket;
86#define HOOK_POWER_PRE 0x01 86#define HOOK_POWER_PRE 0x01
87#define HOOK_POWER_POST 0x02 87#define HOOK_POWER_POST 0x02
88 88
89
90typedef struct pccard_io_map { 89typedef struct pccard_io_map {
91 u_char map; 90 u_char map;
92 u_char flags; 91 u_char flags;
93 u_short speed; 92 u_short speed;
94 u_int start, stop; 93 u_int start, stop;
95} pccard_io_map; 94} pccard_io_map;
96 95
97typedef struct pccard_mem_map { 96typedef struct pccard_mem_map {
98 u_char map; 97 u_char map;
99 u_char flags; 98 u_char flags;
100 u_short speed; 99 u_short speed;
101 u_long static_start; 100 u_long static_start;
102 u_int card_start; 101 u_int card_start;
103 struct resource *res; 102 struct resource *res;
104} pccard_mem_map; 103} pccard_mem_map;
105 104
106typedef struct cb_bridge_map {
107 u_char map;
108 u_char flags;
109 u_int start, stop;
110} cb_bridge_map;
111
112/*
113 * Socket operations.
114 */
115struct pcmcia_socket;
116
117struct pccard_operations {
118 int (*init)(struct pcmcia_socket *sock);
119 int (*suspend)(struct pcmcia_socket *sock);
120 int (*get_status)(struct pcmcia_socket *sock, u_int *value);
121 int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state);
122 int (*set_io_map)(struct pcmcia_socket *sock, struct pccard_io_map *io);
123 int (*set_mem_map)(struct pcmcia_socket *sock, struct pccard_mem_map *mem);
124};
125
126struct pccard_resource_ops {
127 int (*validate_mem) (struct pcmcia_socket *s);
128 int (*adjust_io_region) (struct resource *res,
129 unsigned long r_start,
130 unsigned long r_end,
131 struct pcmcia_socket *s);
132 struct resource* (*find_io) (unsigned long base, int num,
133 unsigned long align,
134 struct pcmcia_socket *s);
135 struct resource* (*find_mem) (unsigned long base, unsigned long num,
136 unsigned long align, int low,
137 struct pcmcia_socket *s);
138 int (*add_io) (struct pcmcia_socket *s,
139 unsigned int action,
140 unsigned long r_start,
141 unsigned long r_end);
142 int (*add_mem) (struct pcmcia_socket *s,
143 unsigned int action,
144 unsigned long r_start,
145 unsigned long r_end);
146 int (*init) (struct pcmcia_socket *s);
147 void (*exit) (struct pcmcia_socket *s);
148};
149/* SS_CAP_STATIC_MAP */
150extern struct pccard_resource_ops pccard_static_ops;
151/* !SS_CAP_STATIC_MAP */
152extern struct pccard_resource_ops pccard_nonstatic_ops;
153
154/* static mem, dynamic IO sockets */
155extern struct pccard_resource_ops pccard_iodyn_ops;
156
157/*
158 * Calls to set up low-level "Socket Services" drivers
159 */
160struct pcmcia_socket;
161
162typedef struct io_window_t { 105typedef struct io_window_t {
163 u_int InUse, Config; 106 u_int InUse, Config;
164 struct resource *res; 107 struct resource *res;
@@ -179,10 +122,25 @@ typedef struct window_t {
179/* Maximum number of memory windows per socket */ 122/* Maximum number of memory windows per socket */
180#define MAX_WIN 4 123#define MAX_WIN 4
181 124
125
126/*
127 * Socket operations.
128 */
129struct pcmcia_socket;
130struct pccard_resource_ops;
182struct config_t; 131struct config_t;
183struct pcmcia_callback; 132struct pcmcia_callback;
184struct user_info_t; 133struct user_info_t;
185 134
135struct pccard_operations {
136 int (*init)(struct pcmcia_socket *s);
137 int (*suspend)(struct pcmcia_socket *s);
138 int (*get_status)(struct pcmcia_socket *s, u_int *value);
139 int (*set_socket)(struct pcmcia_socket *s, socket_state_t *state);
140 int (*set_io_map)(struct pcmcia_socket *s, struct pccard_io_map *io);
141 int (*set_mem_map)(struct pcmcia_socket *s, struct pccard_mem_map *mem);
142};
143
186struct pcmcia_socket { 144struct pcmcia_socket {
187 struct module *owner; 145 struct module *owner;
188 spinlock_t lock; 146 spinlock_t lock;
@@ -218,12 +176,12 @@ struct pcmcia_socket {
218 struct pci_dev * cb_dev; 176 struct pci_dev * cb_dev;
219 177
220 178
221 /* socket setup is done so resources should be able to be allocated. Only 179 /* socket setup is done so resources should be able to be allocated.
222 * if set to 1, calls to find_{io,mem}_region are handled, and insertion 180 * Only if set to 1, calls to find_{io,mem}_region are handled, and
223 * events are actually managed by the PCMCIA layer.*/ 181 * insertio events are actually managed by the PCMCIA layer.*/
224 u8 resource_setup_done:1; 182 u8 resource_setup_done:1;
225 183
226 /* is set to one if resource setup is done using adjust_resource_info() */ 184 /* It's old if resource setup is done using adjust_resource_info() */
227 u8 resource_setup_old:1; 185 u8 resource_setup_old:1;
228 u8 resource_setup_new:1; 186 u8 resource_setup_new:1;
229 187
@@ -236,75 +194,101 @@ struct pcmcia_socket {
236 194
237 /* Zoom video behaviour is so chip specific its not worth adding 195 /* Zoom video behaviour is so chip specific its not worth adding
238 this to _ops */ 196 this to _ops */
239 void (*zoom_video)(struct pcmcia_socket *, int); 197 void (*zoom_video)(struct pcmcia_socket *,
198 int);
240 199
241 /* so is power hook */ 200 /* so is power hook */
242 int (*power_hook)(struct pcmcia_socket *sock, int operation); 201 int (*power_hook)(struct pcmcia_socket *sock, int operation);
243#ifdef CONFIG_CARDBUS 202
244 /* allows tuning the CB bridge before loading driver for the CB card */ 203 /* allows tuning the CB bridge before loading driver for the CB card */
204#ifdef CONFIG_CARDBUS
245 void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus); 205 void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus);
246#endif 206#endif
247 207
248 /* state thread */ 208 /* state thread */
249 struct mutex skt_mutex; /* protects socket h/w state */
250
251 struct task_struct *thread; 209 struct task_struct *thread;
252 struct completion thread_done; 210 struct completion thread_done;
253 spinlock_t thread_lock; /* protects thread_events */
254 unsigned int thread_events; 211 unsigned int thread_events;
212 /* protects socket h/w state */
213 struct mutex skt_mutex;
214 /* protects thread_events */
215 spinlock_t thread_lock;
255 216
256 /* pcmcia (16-bit) */ 217 /* pcmcia (16-bit) */
257 struct pcmcia_callback *callback; 218 struct pcmcia_callback *callback;
258 219
259#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) 220#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
260 struct list_head devices_list; /* PCMCIA devices */ 221 /* The following elements refer to 16-bit PCMCIA devices inserted
261 u8 device_count; /* the number of devices, used 222 * into the socket */
262 * only internally and subject 223 struct list_head devices_list;
263 * to incorrectness and change */ 224
225 /* the number of devices, used only internally and subject to
226 * incorrectness and change */
227 u8 device_count;
264 228
229 /* 16-bit state: */
265 struct { 230 struct {
266 u8 present:1, /* PCMCIA card is present in socket */ 231 /* PCMCIA card is present in socket */
267 busy:1, /* "master" ioctl is used */ 232 u8 present:1;
268 dead:1, /* pcmcia module is being unloaded */ 233 /* "master" ioctl is used */
269 device_add_pending:1, /* a multifunction-device 234 u8 busy:1;
270 * add event is pending */ 235 /* pcmcia module is being unloaded */
271 mfc_pfc:1, /* the pending event adds a mfc (1) or pfc (0) */ 236 u8 dead:1;
272 reserved:3; 237 /* a multifunction-device add event is pending */
273 } pcmcia_state; 238 u8 device_add_pending:1;
274 239 /* the pending event adds a mfc (1) or pfc (0) */
275 struct work_struct device_add; /* for adding further pseudo-multifunction 240 u8 mfc_pfc:1;
276 * devices */ 241
242 u8 reserved:3;
243 } pcmcia_state;
244
245
246 /* for adding further pseudo-multifunction devices */
247 struct work_struct device_add;
277 248
278#ifdef CONFIG_PCMCIA_IOCTL 249#ifdef CONFIG_PCMCIA_IOCTL
279 struct user_info_t *user; 250 struct user_info_t *user;
280 wait_queue_head_t queue; 251 wait_queue_head_t queue;
281#endif 252#endif /* CONFIG_PCMCIA_IOCTL */
282#endif 253#endif /* CONFIG_PCMCIA */
283 254
284 /* cardbus (32-bit) */ 255 /* cardbus (32-bit) */
285#ifdef CONFIG_CARDBUS 256#ifdef CONFIG_CARDBUS
286 struct resource * cb_cis_res; 257 struct resource * cb_cis_res;
287 void __iomem *cb_cis_virt; 258 void __iomem *cb_cis_virt;
288#endif 259#endif /* CONFIG_CARDBUS */
289 260
290 /* socket device */ 261 /* socket device */
291 struct device dev; 262 struct device dev;
292 void *driver_data; /* data internal to the socket driver */ 263 /* data internal to the socket driver */
293 264 void *driver_data;
294}; 265};
295 266
296struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr);
297 267
268/* socket drivers must define the resource operations type they use. There
269 * are three options:
270 * - pccard_static_ops iomem and ioport areas are assigned statically
271 * - pccard_iodyn_ops iomem areas is assigned statically, ioport
272 * areas dynamically
273 * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically.
274 * If this option is selected, use
275 * "select PCCARD_NONSTATIC" in Kconfig.
276 */
277extern struct pccard_resource_ops pccard_static_ops;
278extern struct pccard_resource_ops pccard_iodyn_ops;
279extern struct pccard_resource_ops pccard_nonstatic_ops;
298 280
281/* socket drivers are expected to use these callbacks in their .drv struct */
282extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state);
283extern int pcmcia_socket_dev_resume(struct device *dev);
284
285/* socket drivers use this callback in their IRQ handler */
286extern void pcmcia_parse_events(struct pcmcia_socket *socket,
287 unsigned int events);
299 288
300extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events); 289/* to register and unregister a socket */
301extern int pcmcia_register_socket(struct pcmcia_socket *socket); 290extern int pcmcia_register_socket(struct pcmcia_socket *socket);
302extern void pcmcia_unregister_socket(struct pcmcia_socket *socket); 291extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
303 292
304extern struct class pcmcia_socket_class;
305
306/* socket drivers are expected to use these callbacks in their .drv struct */
307extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state);
308extern int pcmcia_socket_dev_resume(struct device *dev);
309 293
310#endif /* _LINUX_SS_H */ 294#endif /* _LINUX_SS_H */