1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef _LINUX_DS_H
17#define _LINUX_DS_H
18
19#ifdef __KERNEL__
20#include <linux/mod_devicetable.h>
21#endif
22
23#include <pcmcia/device_id.h>
24
25#ifdef __KERNEL__
26#include <linux/device.h>
27#include <linux/interrupt.h>
28#include <pcmcia/ss.h>
29#include <linux/atomic.h>
30
31
32
33
34
35
36struct pcmcia_socket;
37struct pcmcia_device;
38struct config_t;
39struct net_device;
40
41
42
43
44struct pcmcia_dynids {
45 struct mutex lock;
46 struct list_head list;
47};
48
49struct pcmcia_driver {
50 const char *name;
51
52 int (*probe) (struct pcmcia_device *dev);
53 void (*remove) (struct pcmcia_device *dev);
54
55 int (*suspend) (struct pcmcia_device *dev);
56 int (*resume) (struct pcmcia_device *dev);
57
58 struct module *owner;
59 const struct pcmcia_device_id *id_table;
60 struct device_driver drv;
61 struct pcmcia_dynids dynids;
62};
63
64
65int pcmcia_register_driver(struct pcmcia_driver *driver);
66void pcmcia_unregister_driver(struct pcmcia_driver *driver);
67
68
69
70
71
72
73
74
75
76#define module_pcmcia_driver(__pcmcia_driver) \
77 module_driver(__pcmcia_driver, pcmcia_register_driver, \
78 pcmcia_unregister_driver)
79
80
81enum {
82 PCMCIA_IOPORT_0,
83 PCMCIA_IOPORT_1,
84 PCMCIA_IOMEM_0,
85 PCMCIA_IOMEM_1,
86 PCMCIA_IOMEM_2,
87 PCMCIA_IOMEM_3,
88 PCMCIA_NUM_RESOURCES,
89};
90
91struct pcmcia_device {
92
93
94 struct pcmcia_socket *socket;
95
96 char *devname;
97
98 u8 device_no;
99
100
101
102 u8 func;
103 struct config_t *function_config;
104
105 struct list_head socket_device_list;
106
107
108 unsigned int irq;
109 struct resource *resource[PCMCIA_NUM_RESOURCES];
110 resource_size_t card_addr;
111 unsigned int vpp;
112
113 unsigned int config_flags;
114 unsigned int config_base;
115 unsigned int config_index;
116 unsigned int config_regs;
117 unsigned int io_lines;
118
119
120 u16 suspended:1;
121
122
123
124 u16 _irq:1;
125 u16 _io:1;
126 u16 _win:4;
127 u16 _locked:1;
128
129
130
131 u16 allow_func_id_match:1;
132
133
134 u16 has_manf_id:1;
135 u16 has_card_id:1;
136 u16 has_func_id:1;
137
138 u16 reserved:4;
139
140 u8 func_id;
141 u16 manf_id;
142 u16 card_id;
143
144 char *prod_id[4];
145
146 u64 dma_mask;
147 struct device dev;
148
149
150 void *priv;
151 unsigned int open;
152};
153
154#define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev)
155#define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv)
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code,
173 u8 **buf);
174
175
176int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
177 int (*loop_tuple) (struct pcmcia_device *p_dev,
178 tuple_t *tuple,
179 void *priv_data),
180 void *priv_data);
181
182
183int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev,
184 struct net_device *dev);
185
186
187
188int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse);
189
190
191int pcmcia_loop_config(struct pcmcia_device *p_dev,
192 int (*conf_check) (struct pcmcia_device *p_dev,
193 void *priv_data),
194 void *priv_data);
195
196
197struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev);
198
199
200int pcmcia_reset_card(struct pcmcia_socket *skt);
201
202
203int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val);
204int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val);
205
206
207int pcmcia_request_io(struct pcmcia_device *p_dev);
208
209int __must_check
210__pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
211 irq_handler_t handler);
212static inline __must_check __deprecated int
213pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
214 irq_handler_t handler)
215{
216 return __pcmcia_request_exclusive_irq(p_dev, handler);
217}
218
219int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
220 irq_handler_t handler);
221
222int pcmcia_enable_device(struct pcmcia_device *p_dev);
223
224int pcmcia_request_window(struct pcmcia_device *p_dev, struct resource *res,
225 unsigned int speed);
226int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res);
227int pcmcia_map_mem_page(struct pcmcia_device *p_dev, struct resource *res,
228 unsigned int offset);
229
230int pcmcia_fixup_vpp(struct pcmcia_device *p_dev, unsigned char new_vpp);
231int pcmcia_fixup_iowidth(struct pcmcia_device *p_dev);
232
233void pcmcia_disable_device(struct pcmcia_device *p_dev);
234
235
236#define IO_DATA_PATH_WIDTH 0x18
237#define IO_DATA_PATH_WIDTH_8 0x00
238#define IO_DATA_PATH_WIDTH_16 0x08
239#define IO_DATA_PATH_WIDTH_AUTO 0x10
240
241
242#define WIN_MEMORY_TYPE_CM 0x00
243#define WIN_MEMORY_TYPE_AM 0x20
244#define WIN_DATA_WIDTH_8 0x00
245#define WIN_DATA_WIDTH_16 0x02
246#define WIN_ENABLE 0x01
247#define WIN_USE_WAIT 0x40
248
249#define WIN_FLAGS_MAP 0x63
250
251#define WIN_FLAGS_REQ 0x1c
252
253
254
255
256
257
258#define PRESENT_OPTION 0x001
259#define PRESENT_STATUS 0x002
260#define PRESENT_PIN_REPLACE 0x004
261#define PRESENT_COPY 0x008
262#define PRESENT_EXT_STATUS 0x010
263#define PRESENT_IOBASE_0 0x020
264#define PRESENT_IOBASE_1 0x040
265#define PRESENT_IOBASE_2 0x080
266#define PRESENT_IOBASE_3 0x100
267#define PRESENT_IOSIZE 0x200
268
269
270#define CONF_ENABLE_IRQ 0x0001
271#define CONF_ENABLE_SPKR 0x0002
272#define CONF_ENABLE_PULSE_IRQ 0x0004
273#define CONF_ENABLE_ESR 0x0008
274#define CONF_ENABLE_IOCARD 0x0010
275
276#define CONF_ENABLE_ZVCARD 0x0020
277
278
279#define CONF_AUTO_CHECK_VCC 0x0100
280#define CONF_AUTO_SET_VPP 0x0200
281#define CONF_AUTO_AUDIO 0x0400
282#define CONF_AUTO_SET_IO 0x0800
283#define CONF_AUTO_SET_IOMEM 0x1000
284
285#endif
286
287#endif
288