1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef LINUX_ISAPNP_H
23#define LINUX_ISAPNP_H
24
25#include <linux/config.h>
26#include <linux/errno.h>
27
28
29
30
31
32#define ISAPNP_CFG_ACTIVATE 0x30
33#define ISAPNP_CFG_MEM 0x40
34#define ISAPNP_CFG_PORT 0x60
35#define ISAPNP_CFG_IRQ 0x70
36#define ISAPNP_CFG_DMA 0x74
37
38
39
40
41
42#define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
43 ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
44 ((((c)-'A'+1)&0x1f)<<8))
45#define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
46 (((x)&0x0f00)>>8)|\
47 (((x)&0x00f0)<<8)|\
48 (((x)&0x000f)<<8))
49#define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
50
51
52
53
54
55#ifdef __KERNEL__
56
57#include <linux/pci.h>
58
59#define ISAPNP_PORT_FLAG_16BITADDR (1<<0)
60#define ISAPNP_PORT_FLAG_FIXED (1<<1)
61
62struct isapnp_port {
63 unsigned short min;
64 unsigned short max;
65 unsigned char align;
66 unsigned char size;
67 unsigned char flags;
68 unsigned char pad;
69 struct isapnp_resources *res;
70 struct isapnp_port *next;
71};
72
73struct isapnp_irq {
74 unsigned short map;
75 unsigned char flags;
76 unsigned char pad;
77 struct isapnp_resources *res;
78 struct isapnp_irq *next;
79};
80
81struct isapnp_dma {
82 unsigned char map;
83 unsigned char flags;
84 struct isapnp_resources *res;
85 struct isapnp_dma *next;
86};
87
88struct isapnp_mem {
89 unsigned int min;
90 unsigned int max;
91 unsigned int align;
92 unsigned int size;
93 unsigned char flags;
94 unsigned char pad;
95 struct isapnp_resources *res;
96 struct isapnp_mem *next;
97};
98
99struct isapnp_mem32 {
100
101 unsigned char data[17];
102 struct isapnp_resources *res;
103 struct isapnp_mem32 *next;
104};
105
106struct isapnp_fixup {
107 unsigned short vendor;
108 unsigned short device;
109 void (*quirk_function)(struct pci_dev *dev);
110};
111
112
113#define ISAPNP_RES_PRIORITY_PREFERRED 0
114#define ISAPNP_RES_PRIORITY_ACCEPTABLE 1
115#define ISAPNP_RES_PRIORITY_FUNCTIONAL 2
116#define ISAPNP_RES_PRIORITY_INVALID 65535
117
118struct isapnp_resources {
119 unsigned short priority;
120 unsigned short dependent;
121 struct isapnp_port *port;
122 struct isapnp_irq *irq;
123 struct isapnp_dma *dma;
124 struct isapnp_mem *mem;
125 struct isapnp_mem32 *mem32;
126 struct pci_dev *dev;
127 struct isapnp_resources *alt;
128 struct isapnp_resources *next;
129};
130
131#define ISAPNP_ANY_ID 0xffff
132#define ISAPNP_CARD_DEVS 8
133
134#define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
135 card_vendor: ISAPNP_VENDOR(_va, _vb, _vc), card_device: ISAPNP_DEVICE(_device)
136#define ISAPNP_CARD_END \
137 card_vendor: 0, card_device: 0
138#define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
139 { vendor: ISAPNP_VENDOR(_va, _vb, _vc), function: ISAPNP_FUNCTION(_function) }
140
141
142#define ISAPNP_CARD_TABLE(name) \
143 MODULE_GENERIC_TABLE(isapnp_card, name)
144
145struct isapnp_card_id {
146 unsigned long driver_data;
147 unsigned short card_vendor, card_device;
148 struct {
149 unsigned short vendor, function;
150 } devs[ISAPNP_CARD_DEVS];
151};
152
153#define ISAPNP_DEVICE_SINGLE(_cva, _cvb, _cvc, _cdevice, _dva, _dvb, _dvc, _dfunction) \
154 card_vendor: ISAPNP_VENDOR(_cva, _cvb, _cvc), card_device: ISAPNP_DEVICE(_cdevice), \
155 vendor: ISAPNP_VENDOR(_dva, _dvb, _dvc), function: ISAPNP_FUNCTION(_dfunction)
156#define ISAPNP_DEVICE_SINGLE_END \
157 card_vendor: 0, card_device: 0
158
159struct isapnp_device_id {
160 unsigned short card_vendor, card_device;
161 unsigned short vendor, function;
162 unsigned long driver_data;
163};
164
165struct isapnp_driver {
166 struct list_head node;
167 char *name;
168 const struct isapnp_device_id *id_table;
169 int (*probe) (struct pci_dev *dev, const struct isapnp_device_id *id);
170 void (*remove) (struct pci_dev *dev);
171};
172
173#if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
174
175#define __ISAPNP__
176
177
178int isapnp_present(void);
179int isapnp_cfg_begin(int csn, int device);
180int isapnp_cfg_end(void);
181unsigned char isapnp_read_byte(unsigned char idx);
182unsigned short isapnp_read_word(unsigned char idx);
183unsigned int isapnp_read_dword(unsigned char idx);
184void isapnp_write_byte(unsigned char idx, unsigned char val);
185void isapnp_write_word(unsigned char idx, unsigned short val);
186void isapnp_write_dword(unsigned char idx, unsigned int val);
187void isapnp_wake(unsigned char csn);
188void isapnp_device(unsigned char device);
189void isapnp_activate(unsigned char device);
190void isapnp_deactivate(unsigned char device);
191void isapnp_fixup_device(struct pci_dev *dev);
192void *isapnp_alloc(long size);
193int isapnp_proc_init(void);
194int isapnp_proc_done(void);
195
196struct pci_bus *isapnp_find_card(unsigned short vendor,
197 unsigned short device,
198 struct pci_bus *from);
199struct pci_dev *isapnp_find_dev(struct pci_bus *card,
200 unsigned short vendor,
201 unsigned short function,
202 struct pci_dev *from);
203int isapnp_probe_cards(const struct isapnp_card_id *ids,
204 int (*probe)(struct pci_bus *card,
205 const struct isapnp_card_id *id));
206int isapnp_probe_devs(const struct isapnp_device_id *ids,
207 int (*probe)(struct pci_dev *dev,
208 const struct isapnp_device_id *id));
209
210void isapnp_resource_change(struct resource *resource,
211 unsigned long start,
212 unsigned long size);
213int isapnp_activate_dev(struct pci_dev *dev, const char *name);
214
215int isapnp_init(void);
216
217extern struct list_head isapnp_cards;
218extern struct list_head isapnp_devices;
219
220#define isapnp_for_each_card(card) \
221 for(card = pci_bus_b(isapnp_cards.next); card != pci_bus_b(&isapnp_cards); card = pci_bus_b(card->node.next))
222#define isapnp_for_each_dev(dev) \
223 for(dev = pci_dev_g(isapnp_devices.next); dev != pci_dev_g(&isapnp_devices); dev = pci_dev_g(dev->global_list.next))
224
225int isapnp_register_driver(struct isapnp_driver *drv);
226void isapnp_unregister_driver(struct isapnp_driver *drv);
227
228#else
229
230
231static inline int isapnp_present(void) { return 0; }
232static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
233static inline int isapnp_cfg_end(void) { return -ENODEV; }
234static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
235static inline unsigned short isapnp_read_word(unsigned char idx) { return 0xffff; }
236static inline unsigned int isapnp_read_dword(unsigned char idx) { return 0xffffffff; }
237static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
238static inline void isapnp_write_word(unsigned char idx, unsigned short val) { ; }
239static inline void isapnp_write_dword(unsigned char idx, unsigned int val) { ; }
240static inline void isapnp_wake(unsigned char csn) { ; }
241static inline void isapnp_device(unsigned char device) { ; }
242static inline void isapnp_activate(unsigned char device) { ; }
243static inline void isapnp_deactivate(unsigned char device) { ; }
244
245static inline struct pci_bus *isapnp_find_card(unsigned short vendor,
246 unsigned short device,
247 struct pci_bus *from) { return NULL; }
248static inline struct pci_dev *isapnp_find_dev(struct pci_bus *card,
249 unsigned short vendor,
250 unsigned short function,
251 struct pci_dev *from) { return NULL; }
252static inline int isapnp_probe_cards(const struct isapnp_card_id *ids,
253 int (*probe)(struct pci_bus *card,
254 const struct isapnp_card_id *id)) { return -ENODEV; }
255static inline int isapnp_probe_devs(const struct isapnp_device_id *ids,
256 int (*probe)(struct pci_dev *dev,
257 const struct isapnp_device_id *id)) { return -ENODEV; }
258static inline void isapnp_resource_change(struct resource *resource,
259 unsigned long start,
260 unsigned long size) { ; }
261static inline int isapnp_activate_dev(struct pci_dev *dev, const char *name) { return -ENODEV; }
262
263static inline int isapnp_register_driver(struct isapnp_driver *drv) { return 0; }
264
265static inline void isapnp_unregister_driver(struct isapnp_driver *drv) { }
266
267#endif
268
269#endif
270#endif
271