aboutsummaryrefslogtreecommitdiffstats
path: root/include/pcmcia
diff options
context:
space:
mode:
Diffstat (limited to 'include/pcmcia')
-rw-r--r--include/pcmcia/cs.h16
-rw-r--r--include/pcmcia/cs_types.h3
-rw-r--r--include/pcmcia/device_id.h5
-rw-r--r--include/pcmcia/ds.h103
-rw-r--r--include/pcmcia/mem_op.h2
-rw-r--r--include/pcmcia/ss.h75
6 files changed, 86 insertions, 118 deletions
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
index 904468a191ef..75fa3530345b 100644
--- a/include/pcmcia/cs.h
+++ b/include/pcmcia/cs.h
@@ -15,6 +15,10 @@
15#ifndef _LINUX_CS_H 15#ifndef _LINUX_CS_H
16#define _LINUX_CS_H 16#define _LINUX_CS_H
17 17
18#ifdef __KERNEL__
19#include <linux/interrupt.h>
20#endif
21
18/* For AccessConfigurationRegister */ 22/* For AccessConfigurationRegister */
19typedef struct conf_reg_t { 23typedef struct conf_reg_t {
20 u_char Function; 24 u_char Function;
@@ -111,11 +115,9 @@ typedef struct io_req_t {
111 115
112/* For RequestIRQ and ReleaseIRQ */ 116/* For RequestIRQ and ReleaseIRQ */
113typedef struct irq_req_t { 117typedef struct irq_req_t {
114 u_int Attributes; 118 u_int Attributes;
115 u_int AssignedIRQ; 119 u_int AssignedIRQ;
116 u_int IRQInfo1, IRQInfo2; /* IRQInfo2 is ignored */ 120 irq_handler_t Handler;
117 void *Handler;
118 void *Instance;
119} irq_req_t; 121} irq_req_t;
120 122
121/* Attributes for RequestIRQ and ReleaseIRQ */ 123/* Attributes for RequestIRQ and ReleaseIRQ */
@@ -124,8 +126,8 @@ typedef struct irq_req_t {
124#define IRQ_TYPE_TIME 0x01 126#define IRQ_TYPE_TIME 0x01
125#define IRQ_TYPE_DYNAMIC_SHARING 0x02 127#define IRQ_TYPE_DYNAMIC_SHARING 0x02
126#define IRQ_FORCED_PULSE 0x04 128#define IRQ_FORCED_PULSE 0x04
127#define IRQ_FIRST_SHARED 0x08 129#define IRQ_FIRST_SHARED 0x08 /* unused */
128#define IRQ_HANDLE_PRESENT 0x10 130#define IRQ_HANDLE_PRESENT 0x10 /* unused */
129#define IRQ_PULSE_ALLOCATED 0x100 131#define IRQ_PULSE_ALLOCATED 0x100
130 132
131/* Bits in IRQInfo1 field */ 133/* Bits in IRQInfo1 field */
diff --git a/include/pcmcia/cs_types.h b/include/pcmcia/cs_types.h
index 315965a37930..f5e3b8386c8f 100644
--- a/include/pcmcia/cs_types.h
+++ b/include/pcmcia/cs_types.h
@@ -26,8 +26,7 @@ typedef u_int event_t;
26typedef u_char cisdata_t; 26typedef u_char cisdata_t;
27typedef u_short page_t; 27typedef u_short page_t;
28 28
29struct window_t; 29typedef unsigned long window_handle_t;
30typedef struct window_t *window_handle_t;
31 30
32struct region_t; 31struct region_t;
33typedef struct region_t *memory_handle_t; 32typedef struct region_t *memory_handle_t;
diff --git a/include/pcmcia/device_id.h b/include/pcmcia/device_id.h
index c33ea08352b8..63e5b8f6b7dd 100644
--- a/include/pcmcia/device_id.h
+++ b/include/pcmcia/device_id.h
@@ -34,6 +34,11 @@
34 .prod_id = { NULL, (v2), NULL, NULL }, \ 34 .prod_id = { NULL, (v2), NULL, NULL }, \
35 .prod_id_hash = { 0, (vh2), 0, 0 }, } 35 .prod_id_hash = { 0, (vh2), 0, 0 }, }
36 36
37#define PCMCIA_DEVICE_PROD_ID3(v3, vh3) { \
38 .match_flags = PCMCIA_DEV_ID_MATCH_PROD_ID3, \
39 .prod_id = { NULL, NULL, (v3), NULL }, \
40 .prod_id_hash = { 0, 0, (vh3), 0 }, }
41
37#define PCMCIA_DEVICE_PROD_ID12(v1, v2, vh1, vh2) { \ 42#define PCMCIA_DEVICE_PROD_ID12(v1, v2, vh1, vh2) { \
38 .match_flags = PCMCIA_DEV_ID_MATCH_PROD_ID1| \ 43 .match_flags = PCMCIA_DEV_ID_MATCH_PROD_ID1| \
39 PCMCIA_DEV_ID_MATCH_PROD_ID2, \ 44 PCMCIA_DEV_ID_MATCH_PROD_ID2, \
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index a2be80b9a095..aab3c13dc310 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -26,6 +26,7 @@
26#ifdef __KERNEL__ 26#ifdef __KERNEL__
27#include <linux/device.h> 27#include <linux/device.h>
28#include <pcmcia/ss.h> 28#include <pcmcia/ss.h>
29#include <asm/atomic.h>
29 30
30/* 31/*
31 * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus 32 * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus
@@ -34,12 +35,13 @@
34struct pcmcia_socket; 35struct pcmcia_socket;
35struct pcmcia_device; 36struct pcmcia_device;
36struct config_t; 37struct config_t;
38struct net_device;
37 39
38/* dynamic device IDs for PCMCIA device drivers. See 40/* dynamic device IDs for PCMCIA device drivers. See
39 * Documentation/pcmcia/driver.txt for details. 41 * Documentation/pcmcia/driver.txt for details.
40*/ 42*/
41struct pcmcia_dynids { 43struct pcmcia_dynids {
42 spinlock_t lock; 44 struct mutex lock;
43 struct list_head list; 45 struct list_head list;
44}; 46};
45 47
@@ -81,7 +83,7 @@ struct pcmcia_device {
81 /* the hardware "function" device; certain subdevices can 83 /* the hardware "function" device; certain subdevices can
82 * share one hardware "function" device. */ 84 * share one hardware "function" device. */
83 u8 func; 85 u8 func;
84 struct config_t* function_config; 86 struct config_t *function_config;
85 87
86 struct list_head socket_device_list; 88 struct list_head socket_device_list;
87 89
@@ -93,10 +95,8 @@ struct pcmcia_device {
93 config_req_t conf; 95 config_req_t conf;
94 window_handle_t win; 96 window_handle_t win;
95 97
96 /* Is the device suspended, or in the process of 98 /* Is the device suspended? */
97 * being removed? */
98 u16 suspended:1; 99 u16 suspended:1;
99 u16 _removed:1;
100 100
101 /* Flags whether io, irq, win configurations were 101 /* Flags whether io, irq, win configurations were
102 * requested, and whether the configuration is "locked" */ 102 * requested, and whether the configuration is "locked" */
@@ -114,20 +114,20 @@ struct pcmcia_device {
114 u16 has_card_id:1; 114 u16 has_card_id:1;
115 u16 has_func_id:1; 115 u16 has_func_id:1;
116 116
117 u16 reserved:3; 117 u16 reserved:4;
118 118
119 u8 func_id; 119 u8 func_id;
120 u16 manf_id; 120 u16 manf_id;
121 u16 card_id; 121 u16 card_id;
122 122
123 char * prod_id[4]; 123 char *prod_id[4];
124 124
125 u64 dma_mask; 125 u64 dma_mask;
126 struct device dev; 126 struct device dev;
127 127
128#ifdef CONFIG_PCMCIA_IOCTL 128#ifdef CONFIG_PCMCIA_IOCTL
129 /* device driver wanted by cardmgr */ 129 /* device driver wanted by cardmgr */
130 struct pcmcia_driver * cardmgr; 130 struct pcmcia_driver *cardmgr;
131#endif 131#endif
132 132
133 /* data private to drivers */ 133 /* data private to drivers */
@@ -137,65 +137,39 @@ struct pcmcia_device {
137#define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) 137#define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev)
138#define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv) 138#define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv)
139 139
140/* deprecated -- don't use! */
141#define handle_to_dev(handle) (handle->dev)
142 140
143 141/*
144/* (deprecated) error reporting by PCMCIA devices. Use dev_printk() 142 * CIS access.
145 * or dev_dbg() directly in the driver, without referring to pcmcia_error_func() 143 *
146 * and/or pcmcia_error_ret() for those functions will go away soon. 144 * Please use the following functions to access CIS tuples:
147 */ 145 * - pcmcia_get_tuple()
148enum service { 146 * - pcmcia_loop_tuple()
149 AccessConfigurationRegister, AddSocketServices, 147 * - pcmcia_get_mac_from_cis()
150 AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory, 148 *
151 DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo, 149 * To parse a tuple_t, pcmcia_parse_tuple() exists. Its interface
152 GetClientInfo, GetConfigurationInfo, GetEventMask, 150 * might change in future.
153 GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple,
154 GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple,
155 GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage,
156 MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow,
157 OpenMemory, ParseTuple, ReadMemory, RegisterClient,
158 RegisterEraseQueue, RegisterMTD, RegisterTimer,
159 ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ,
160 ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices,
161 RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ,
162 RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry,
163 SetEventMask, SetRegion, ValidateCIS, VendorSpecific,
164 WriteMemory, BindDevice, BindMTD, ReportError,
165 SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS,
166 GetFirstWindow, GetNextWindow, GetMemPage
167};
168const char *pcmcia_error_func(int func);
169const char *pcmcia_error_ret(int ret);
170
171#define cs_error(p_dev, func, ret) \
172 { \
173 dev_printk(KERN_NOTICE, &p_dev->dev, \
174 "%s : %s\n", \
175 pcmcia_error_func(func), \
176 pcmcia_error_ret(ret)); \
177 }
178
179/* CIS access.
180 * Use the pcmcia_* versions in PCMCIA drivers
181 */ 151 */
182int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse);
183 152
184int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, 153/* get the very first CIS entry of type @code. Note that buf is pointer
185 tuple_t *tuple); 154 * to u8 *buf; and that you need to kfree(buf) afterwards. */
186#define pcmcia_get_first_tuple(p_dev, tuple) \ 155size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code,
187 pccard_get_first_tuple(p_dev->socket, p_dev->func, tuple) 156 u8 **buf);
188 157
189int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, 158/* loop over CIS entries */
190 tuple_t *tuple); 159int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
191#define pcmcia_get_next_tuple(p_dev, tuple) \ 160 int (*loop_tuple) (struct pcmcia_device *p_dev,
192 pccard_get_next_tuple(p_dev->socket, p_dev->func, tuple) 161 tuple_t *tuple,
162 void *priv_data),
163 void *priv_data);
193 164
194int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); 165/* get the MAC address from CISTPL_FUNCE */
195#define pcmcia_get_tuple_data(p_dev, tuple) \ 166int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev,
196 pccard_get_tuple_data(p_dev->socket, tuple) 167 struct net_device *dev);
197 168
198 169
170/* parse a tuple_t */
171int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse);
172
199/* loop CIS entries for valid configuration */ 173/* loop CIS entries for valid configuration */
200int pcmcia_loop_config(struct pcmcia_device *p_dev, 174int pcmcia_loop_config(struct pcmcia_device *p_dev,
201 int (*conf_check) (struct pcmcia_device *p_dev, 175 int (*conf_check) (struct pcmcia_device *p_dev,
@@ -221,12 +195,11 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req);
221int pcmcia_request_configuration(struct pcmcia_device *p_dev, 195int pcmcia_request_configuration(struct pcmcia_device *p_dev,
222 config_req_t *req); 196 config_req_t *req);
223 197
224int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, 198int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req,
225 window_handle_t *wh); 199 window_handle_t *wh);
226int pcmcia_release_window(window_handle_t win); 200int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t win);
227 201int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t win,
228int pcmcia_get_mem_page(window_handle_t win, memreq_t *req); 202 memreq_t *req);
229int pcmcia_map_mem_page(window_handle_t win, memreq_t *req);
230 203
231int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); 204int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod);
232void pcmcia_disable_device(struct pcmcia_device *p_dev); 205void pcmcia_disable_device(struct pcmcia_device *p_dev);
diff --git a/include/pcmcia/mem_op.h b/include/pcmcia/mem_op.h
index 8d19b9401a5b..0fa06e5d5376 100644
--- a/include/pcmcia/mem_op.h
+++ b/include/pcmcia/mem_op.h
@@ -15,8 +15,8 @@
15#ifndef _LINUX_MEM_OP_H 15#ifndef _LINUX_MEM_OP_H
16#define _LINUX_MEM_OP_H 16#define _LINUX_MEM_OP_H
17 17
18#include <linux/io.h>
18#include <asm/uaccess.h> 19#include <asm/uaccess.h>
19#include <asm/io.h>
20 20
21/* 21/*
22 If UNSAFE_MEMCPY is defined, we use the (optimized) system routines 22 If UNSAFE_MEMCPY is defined, we use the (optimized) system routines
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index e0f6feb8588c..344705cb42f4 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -107,15 +107,6 @@ typedef struct io_window_t {
107 struct resource *res; 107 struct resource *res;
108} io_window_t; 108} io_window_t;
109 109
110#define WINDOW_MAGIC 0xB35C
111typedef struct window_t {
112 u_short magic;
113 u_short index;
114 struct pcmcia_device *handle;
115 struct pcmcia_socket *sock;
116 pccard_mem_map ctl;
117} window_t;
118
119/* Maximum number of IO windows per socket */ 110/* Maximum number of IO windows per socket */
120#define MAX_IO_WIN 2 111#define MAX_IO_WIN 2
121 112
@@ -143,9 +134,9 @@ struct pccard_operations {
143 134
144struct pcmcia_socket { 135struct pcmcia_socket {
145 struct module *owner; 136 struct module *owner;
146 spinlock_t lock;
147 socket_state_t socket; 137 socket_state_t socket;
148 u_int state; 138 u_int state;
139 u_int suspended_state; /* state before suspend */
149 u_short functions; 140 u_short functions;
150 u_short lock_count; 141 u_short lock_count;
151 pccard_mem_map cis_mem; 142 pccard_mem_map cis_mem;
@@ -155,7 +146,7 @@ struct pcmcia_socket {
155 u_int Config; 146 u_int Config;
156 } irq; 147 } irq;
157 io_window_t io[MAX_IO_WIN]; 148 io_window_t io[MAX_IO_WIN];
158 window_t win[MAX_WIN]; 149 pccard_mem_map win[MAX_WIN];
159 struct list_head cis_cache; 150 struct list_head cis_cache;
160 size_t fake_cis_len; 151 size_t fake_cis_len;
161 u8 *fake_cis; 152 u8 *fake_cis;
@@ -163,7 +154,7 @@ struct pcmcia_socket {
163 struct list_head socket_list; 154 struct list_head socket_list;
164 struct completion socket_released; 155 struct completion socket_released;
165 156
166 /* deprecated */ 157 /* deprecated */
167 unsigned int sock; /* socket number */ 158 unsigned int sock; /* socket number */
168 159
169 160
@@ -172,8 +163,8 @@ struct pcmcia_socket {
172 u_int irq_mask; 163 u_int irq_mask;
173 u_int map_size; 164 u_int map_size;
174 u_int io_offset; 165 u_int io_offset;
175 u_char pci_irq; 166 u_int pci_irq;
176 struct pci_dev * cb_dev; 167 struct pci_dev *cb_dev;
177 168
178 169
179 /* socket setup is done so resources should be able to be allocated. 170 /* socket setup is done so resources should be able to be allocated.
@@ -188,9 +179,9 @@ struct pcmcia_socket {
188 u8 reserved:5; 179 u8 reserved:5;
189 180
190 /* socket operations */ 181 /* socket operations */
191 struct pccard_operations * ops; 182 struct pccard_operations *ops;
192 struct pccard_resource_ops * resource_ops; 183 struct pccard_resource_ops *resource_ops;
193 void * resource_data; 184 void *resource_data;
194 185
195 /* Zoom video behaviour is so chip specific its not worth adding 186 /* Zoom video behaviour is so chip specific its not worth adding
196 this to _ops */ 187 this to _ops */
@@ -209,9 +200,14 @@ struct pcmcia_socket {
209 struct task_struct *thread; 200 struct task_struct *thread;
210 struct completion thread_done; 201 struct completion thread_done;
211 unsigned int thread_events; 202 unsigned int thread_events;
212 /* protects socket h/w state */ 203 unsigned int sysfs_events;
204
205 /* For the non-trivial interaction between these locks,
206 * see Documentation/pcmcia/locking.txt */
213 struct mutex skt_mutex; 207 struct mutex skt_mutex;
214 /* protects thread_events */ 208 struct mutex ops_mutex;
209
210 /* protects thread_events and sysfs_events */
215 spinlock_t thread_lock; 211 spinlock_t thread_lock;
216 212
217 /* pcmcia (16-bit) */ 213 /* pcmcia (16-bit) */
@@ -228,23 +224,16 @@ struct pcmcia_socket {
228 224
229 /* 16-bit state: */ 225 /* 16-bit state: */
230 struct { 226 struct {
231 /* PCMCIA card is present in socket */
232 u8 present:1;
233 /* "master" ioctl is used */ 227 /* "master" ioctl is used */
234 u8 busy:1; 228 u8 busy:1;
235 /* pcmcia module is being unloaded */ 229 /* the PCMCIA card consists of two pseudo devices */
236 u8 dead:1; 230 u8 has_pfc:1;
237 /* a multifunction-device add event is pending */
238 u8 device_add_pending:1;
239 /* the pending event adds a mfc (1) or pfc (0) */
240 u8 mfc_pfc:1;
241
242 u8 reserved:3;
243 } pcmcia_state;
244 231
232 u8 reserved:6;
233 } pcmcia_state;
245 234
246 /* for adding further pseudo-multifunction devices */ 235 /* non-zero if PCMCIA card is present */
247 struct work_struct device_add; 236 atomic_t present;
248 237
249#ifdef CONFIG_PCMCIA_IOCTL 238#ifdef CONFIG_PCMCIA_IOCTL
250 struct user_info_t *user; 239 struct user_info_t *user;
@@ -252,12 +241,6 @@ struct pcmcia_socket {
252#endif /* CONFIG_PCMCIA_IOCTL */ 241#endif /* CONFIG_PCMCIA_IOCTL */
253#endif /* CONFIG_PCMCIA */ 242#endif /* CONFIG_PCMCIA */
254 243
255 /* cardbus (32-bit) */
256#ifdef CONFIG_CARDBUS
257 struct resource * cb_cis_res;
258 void __iomem *cb_cis_virt;
259#endif /* CONFIG_CARDBUS */
260
261 /* socket device */ 244 /* socket device */
262 struct device dev; 245 struct device dev;
263 /* data internal to the socket driver */ 246 /* data internal to the socket driver */
@@ -272,19 +255,25 @@ struct pcmcia_socket {
272 * - pccard_static_ops iomem and ioport areas are assigned statically 255 * - pccard_static_ops iomem and ioport areas are assigned statically
273 * - pccard_iodyn_ops iomem areas is assigned statically, ioport 256 * - pccard_iodyn_ops iomem areas is assigned statically, ioport
274 * areas dynamically 257 * areas dynamically
258 * If this option is selected, use
259 * "select PCCARD_IODYN" in Kconfig.
275 * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically. 260 * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically.
276 * If this option is selected, use 261 * If this option is selected, use
277 * "select PCCARD_NONSTATIC" in Kconfig. 262 * "select PCCARD_NONSTATIC" in Kconfig.
263 *
278 */ 264 */
279extern struct pccard_resource_ops pccard_static_ops; 265extern struct pccard_resource_ops pccard_static_ops;
266#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
280extern struct pccard_resource_ops pccard_iodyn_ops; 267extern struct pccard_resource_ops pccard_iodyn_ops;
281extern struct pccard_resource_ops pccard_nonstatic_ops; 268extern struct pccard_resource_ops pccard_nonstatic_ops;
269#else
270/* If PCMCIA is not used, but only CARDBUS, these functions are not used
271 * at all. Therefore, do not use the large (240K!) rsrc_nonstatic module
272 */
273#define pccard_iodyn_ops pccard_static_ops
274#define pccard_nonstatic_ops pccard_static_ops
275#endif
282 276
283/* socket drivers are expected to use these callbacks in their .drv struct */
284extern int pcmcia_socket_dev_suspend(struct device *dev);
285extern void pcmcia_socket_dev_early_resume(struct device *dev);
286extern void pcmcia_socket_dev_late_resume(struct device *dev);
287extern int pcmcia_socket_dev_resume(struct device *dev);
288 277
289/* socket drivers use this callback in their IRQ handler */ 278/* socket drivers use this callback in their IRQ handler */
290extern void pcmcia_parse_events(struct pcmcia_socket *socket, 279extern void pcmcia_parse_events(struct pcmcia_socket *socket,