2 * ISA Plug & Play support
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef LINUX_ISAPNP_H
23 #define LINUX_ISAPNP_H
25 #include <linux/config.h>
26 #include <linux/errno.h>
29 * Configuration registers (TODO: change by specification)
32 #define ISAPNP_CFG_ACTIVATE 0x30 /* byte */
33 #define ISAPNP_CFG_MEM 0x40 /* 4 * dword */
34 #define ISAPNP_CFG_PORT 0x60 /* 8 * word */
35 #define ISAPNP_CFG_IRQ 0x70 /* 2 * word */
36 #define ISAPNP_CFG_DMA 0x74 /* 2 * byte */
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)|\
49 #define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
57 #include <linux/pci.h>
59 #define ISAPNP_PORT_FLAG_16BITADDR (1<<0)
60 #define ISAPNP_PORT_FLAG_FIXED (1<<1)
63 unsigned short min
; /* min base number */
64 unsigned short max
; /* max base number */
65 unsigned char align
; /* align boundary */
66 unsigned char size
; /* size of range */
67 unsigned char flags
; /* port flags */
68 unsigned char pad
; /* pad */
69 struct isapnp_resources
*res
; /* parent */
70 struct isapnp_port
*next
; /* next port */
74 unsigned short map
; /* bitmaks for IRQ lines */
75 unsigned char flags
; /* IRQ flags */
76 unsigned char pad
; /* pad */
77 struct isapnp_resources
*res
; /* parent */
78 struct isapnp_irq
*next
; /* next IRQ */
82 unsigned char map
; /* bitmask for DMA channels */
83 unsigned char flags
; /* DMA flags */
84 struct isapnp_resources
*res
; /* parent */
85 struct isapnp_dma
*next
; /* next port */
89 unsigned int min
; /* min base number */
90 unsigned int max
; /* max base number */
91 unsigned int align
; /* align boundary */
92 unsigned int size
; /* size of range */
93 unsigned char flags
; /* memory flags */
94 unsigned char pad
; /* pad */
95 struct isapnp_resources
*res
; /* parent */
96 struct isapnp_mem
*next
; /* next memory resource */
101 unsigned char data
[17];
102 struct isapnp_resources
*res
; /* parent */
103 struct isapnp_mem32
*next
; /* next 32-bit memory resource */
106 struct isapnp_fixup
{
107 unsigned short vendor
; /* matching vendor */
108 unsigned short device
; /* matching device */
109 void (*quirk_function
)(struct pci_dev
*dev
); /* fixup function */
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
118 struct isapnp_resources
{
119 unsigned short priority
; /* priority */
120 unsigned short dependent
; /* dependent resources */
121 struct isapnp_port
*port
; /* first port */
122 struct isapnp_irq
*irq
; /* first IRQ */
123 struct isapnp_dma
*dma
; /* first DMA */
124 struct isapnp_mem
*mem
; /* first memory resource */
125 struct isapnp_mem32
*mem32
; /* first 32-bit memory */
126 struct pci_dev
*dev
; /* parent */
127 struct isapnp_resources
*alt
; /* alternative resource (aka dependent resources) */
128 struct isapnp_resources
*next
; /* next resource */
131 #define ISAPNP_ANY_ID 0xffff
132 #define ISAPNP_CARD_DEVS 8
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) }
141 /* export used IDs outside module */
142 #define ISAPNP_CARD_TABLE(name) \
143 MODULE_GENERIC_TABLE(isapnp_card, name)
145 struct isapnp_card_id
{
146 unsigned long driver_data
; /* data private to the driver */
147 unsigned short card_vendor
, card_device
;
149 unsigned short vendor
, function
;
150 } devs
[ISAPNP_CARD_DEVS
]; /* logical devices */
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
159 struct isapnp_device_id
{
160 unsigned short card_vendor
, card_device
;
161 unsigned short vendor
, function
;
162 unsigned long driver_data
; /* data private to the driver */
165 #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
169 /* lowlevel configuration */
170 int isapnp_present(void);
171 int isapnp_cfg_begin(int csn
, int device
);
172 int isapnp_cfg_end(void);
173 unsigned char isapnp_read_byte(unsigned char idx
);
174 unsigned short isapnp_read_word(unsigned char idx
);
175 unsigned int isapnp_read_dword(unsigned char idx
);
176 void isapnp_write_byte(unsigned char idx
, unsigned char val
);
177 void isapnp_write_word(unsigned char idx
, unsigned short val
);
178 void isapnp_write_dword(unsigned char idx
, unsigned int val
);
179 void isapnp_wake(unsigned char csn
);
180 void isapnp_device(unsigned char device
);
181 void isapnp_activate(unsigned char device
);
182 void isapnp_deactivate(unsigned char device
);
183 void isapnp_fixup_device(struct pci_dev
*dev
);
184 void *isapnp_alloc(long size
);
185 int isapnp_proc_init(void);
186 int isapnp_proc_done(void);
188 struct pci_bus
*isapnp_find_card(unsigned short vendor
,
189 unsigned short device
,
190 struct pci_bus
*from
);
191 struct pci_dev
*isapnp_find_dev(struct pci_bus
*card
,
192 unsigned short vendor
,
193 unsigned short function
,
194 struct pci_dev
*from
);
195 int isapnp_probe_cards(const struct isapnp_card_id
*ids
,
196 int (*probe
)(struct pci_bus
*card
,
197 const struct isapnp_card_id
*id
));
198 int isapnp_probe_devs(const struct isapnp_device_id
*ids
,
199 int (*probe
)(struct pci_dev
*dev
,
200 const struct isapnp_device_id
*id
));
202 void isapnp_resource_change(struct resource
*resource
,
205 int isapnp_activate_dev(struct pci_dev
*dev
, const char *name
);
207 int isapnp_init(void);
209 extern struct list_head isapnp_cards
;
210 extern struct list_head isapnp_devices
;
212 #define isapnp_for_each_card(card) \
213 for(card = pci_bus_b(isapnp_cards.next); card != pci_bus_b(&isapnp_cards); card = pci_bus_b(card->node.next))
214 #define isapnp_for_each_dev(dev) \
215 for(dev = pci_dev_g(isapnp_devices.next); dev != pci_dev_g(&isapnp_devices); dev = pci_dev_g(dev->global_list.next))
217 #else /* !CONFIG_ISAPNP */
219 /* lowlevel configuration */
220 extern inline int isapnp_present(void) { return 0; }
221 extern inline int isapnp_cfg_begin(int csn
, int device
) { return -ENODEV
; }
222 extern inline int isapnp_cfg_end(void) { return -ENODEV
; }
223 extern inline unsigned char isapnp_read_byte(unsigned char idx
) { return 0xff; }
224 extern inline unsigned short isapnp_read_word(unsigned char idx
) { return 0xffff; }
225 extern inline unsigned int isapnp_read_dword(unsigned char idx
) { return 0xffffffff; }
226 extern inline void isapnp_write_byte(unsigned char idx
, unsigned char val
) { ; }
227 extern inline void isapnp_write_word(unsigned char idx
, unsigned short val
) { ; }
228 extern inline void isapnp_write_dword(unsigned char idx
, unsigned int val
) { ; }
229 extern inline void isapnp_wake(unsigned char csn
) { ; }
230 extern inline void isapnp_device(unsigned char device
) { ; }
231 extern inline void isapnp_activate(unsigned char device
) { ; }
232 extern inline void isapnp_deactivate(unsigned char device
) { ; }
234 extern inline struct pci_bus
*isapnp_find_card(unsigned short vendor
,
235 unsigned short device
,
236 struct pci_bus
*from
) { return NULL
; }
237 extern inline struct pci_dev
*isapnp_find_dev(struct pci_bus
*card
,
238 unsigned short vendor
,
239 unsigned short function
,
240 struct pci_dev
*from
) { return NULL
; }
241 extern inline int isapnp_probe_cards(const struct isapnp_card_id
*ids
,
242 int (*probe
)(struct pci_bus
*card
,
243 const struct isapnp_card_id
*id
)) { return -ENODEV
; }
244 extern inline int isapnp_probe_devs(const struct isapnp_device_id
*ids
,
245 int (*probe
)(struct pci_dev
*dev
,
246 const struct isapnp_device_id
*id
)) { return -ENODEV
; }
247 extern inline void isapnp_resource_change(struct resource
*resource
,
249 unsigned long size
) { ; }
250 extern inline int isapnp_activate_dev(struct pci_dev
*dev
, const char *name
) { return -ENODEV
; }
252 #endif /* CONFIG_ISAPNP */
254 #endif /* __KERNEL__ */
255 #endif /* LINUX_ISAPNP_H */