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
69enum {
70 PCMCIA_IOPORT_0,
71 PCMCIA_IOPORT_1,
72 PCMCIA_IOMEM_0,
73 PCMCIA_IOMEM_1,
74 PCMCIA_IOMEM_2,
75 PCMCIA_IOMEM_3,
76 PCMCIA_NUM_RESOURCES,
77};
78
79struct pcmcia_device {
80
81
82 struct pcmcia_socket *socket;
83
84 char *devname;
85
86 u8 device_no;
87
88
89
90 u8 func;
91 struct config_t *function_config;
92
93 struct list_head socket_device_list;
94
95
96 unsigned int irq;
97 struct resource *resource[PCMCIA_NUM_RESOURCES];
98 resource_size_t card_addr;
99 unsigned int vpp;
100
101 unsigned int config_flags;
102 unsigned int config_base;
103 unsigned int config_index;
104 unsigned int config_regs;
105 unsigned int io_lines;
106
107
108 u16 suspended:1;
109
110
111
112 u16 _irq:1;
113 u16 _io:1;
114 u16 _win:4;
115 u16 _locked:1;
116
117
118
119 u16 allow_func_id_match:1;
120
121
122 u16 has_manf_id:1;
123 u16 has_card_id:1;
124 u16 has_func_id:1;
125
126 u16 reserved:4;
127
128 u8 func_id;
129 u16 manf_id;
130 u16 card_id;
131
132 char *prod_id[4];
133
134 u64 dma_mask;
135 struct device dev;
136
137
138 void *priv;
139 unsigned int open;
140};
141
142#define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev)
143#define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv)
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code,
161 u8 **buf);
162
163
164int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
165 int (*loop_tuple) (struct pcmcia_device *p_dev,
166 tuple_t *tuple,
167 void *priv_data),
168 void *priv_data);
169
170
171int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev,
172 struct net_device *dev);
173
174
175
176int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse);
177
178
179int pcmcia_loop_config(struct pcmcia_device *p_dev,
180 int (*conf_check) (struct pcmcia_device *p_dev,
181 void *priv_data),
182 void *priv_data);
183
184
185struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev);
186
187
188int pcmcia_reset_card(struct pcmcia_socket *skt);
189
190
191int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val);
192int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val);
193
194
195int pcmcia_request_io(struct pcmcia_device *p_dev);
196
197int __must_check
198__pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
199 irq_handler_t handler);
200static inline __must_check __deprecated int
201pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
202 irq_handler_t handler)
203{
204 return __pcmcia_request_exclusive_irq(p_dev, handler);
205}
206
207int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
208 irq_handler_t handler);
209
210int pcmcia_enable_device(struct pcmcia_device *p_dev);
211
212int pcmcia_request_window(struct pcmcia_device *p_dev, struct resource *res,
213 unsigned int speed);
214int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res);
215int pcmcia_map_mem_page(struct pcmcia_device *p_dev, struct resource *res,
216 unsigned int offset);
217
218int pcmcia_fixup_vpp(struct pcmcia_device *p_dev, unsigned char new_vpp);
219int pcmcia_fixup_iowidth(struct pcmcia_device *p_dev);
220
221void pcmcia_disable_device(struct pcmcia_device *p_dev);
222
223
224#define IO_DATA_PATH_WIDTH 0x18
225#define IO_DATA_PATH_WIDTH_8 0x00
226#define IO_DATA_PATH_WIDTH_16 0x08
227#define IO_DATA_PATH_WIDTH_AUTO 0x10
228
229
230#define WIN_MEMORY_TYPE_CM 0x00
231#define WIN_MEMORY_TYPE_AM 0x20
232#define WIN_DATA_WIDTH_8 0x00
233#define WIN_DATA_WIDTH_16 0x02
234#define WIN_ENABLE 0x01
235#define WIN_USE_WAIT 0x40
236
237#define WIN_FLAGS_MAP 0x63
238
239#define WIN_FLAGS_REQ 0x1c
240
241
242
243
244
245
246#define PRESENT_OPTION 0x001
247#define PRESENT_STATUS 0x002
248#define PRESENT_PIN_REPLACE 0x004
249#define PRESENT_COPY 0x008
250#define PRESENT_EXT_STATUS 0x010
251#define PRESENT_IOBASE_0 0x020
252#define PRESENT_IOBASE_1 0x040
253#define PRESENT_IOBASE_2 0x080
254#define PRESENT_IOBASE_3 0x100
255#define PRESENT_IOSIZE 0x200
256
257
258#define CONF_ENABLE_IRQ 0x0001
259#define CONF_ENABLE_SPKR 0x0002
260#define CONF_ENABLE_PULSE_IRQ 0x0004
261#define CONF_ENABLE_ESR 0x0008
262#define CONF_ENABLE_IOCARD 0x0010
263
264#define CONF_ENABLE_ZVCARD 0x0020
265
266
267#define CONF_AUTO_CHECK_VCC 0x0100
268#define CONF_AUTO_SET_VPP 0x0200
269#define CONF_AUTO_AUDIO 0x0400
270#define CONF_AUTO_SET_IO 0x0800
271#define CONF_AUTO_SET_IOMEM 0x1000
272
273#endif
274
275#endif
276