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