Merge with Linux 2.4.0-test5-pre3.
[linux-2.6/linux-mips.git] / include / linux / isapnp.h
blob0985c29fbfaa15ea372dd058b883ad81008ca94d
1 /*
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)
30 */
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)|\
46 (((x)&0x0f00)>>8)|\
47 (((x)&0x00f0)<<8)|\
48 (((x)&0x000f)<<8))
49 #define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
55 #ifdef __KERNEL__
57 #include <linux/pci.h>
59 #define ISAPNP_PORT_FLAG_16BITADDR (1<<0)
60 #define ISAPNP_PORT_FLAG_FIXED (1<<1)
62 struct isapnp_port {
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 */
73 struct isapnp_irq {
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 */
81 struct isapnp_dma {
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 */
88 struct isapnp_mem {
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 */
99 struct isapnp_mem32 {
100 /* TODO */
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 vendor: ISAPNP_VENDOR(_va, _vb, _vc), device: ISAPNP_DEVICE(_device)
136 #define ISAPNP_CARD_END \
137 vendor: 0, device: 0
138 #define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
139 { vendor: ISAPNP_VENDOR(_va, _vb, _vc), function: ISAPNP_FUNCTION(_function) }
141 struct isapnp_card_id {
142 unsigned short vendor, device;
143 struct {
144 unsigned short vendor, function;
145 } devs[ISAPNP_CARD_DEVS]; /* logical devices */
146 unsigned long driver_data; /* data private to the driver */
149 #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
151 #define __ISAPNP__
153 /* lowlevel configuration */
154 int isapnp_present(void);
155 int isapnp_cfg_begin(int csn, int device);
156 int isapnp_cfg_end(void);
157 unsigned char isapnp_read_byte(unsigned char idx);
158 unsigned short isapnp_read_word(unsigned char idx);
159 unsigned int isapnp_read_dword(unsigned char idx);
160 void isapnp_write_byte(unsigned char idx, unsigned char val);
161 void isapnp_write_word(unsigned char idx, unsigned short val);
162 void isapnp_write_dword(unsigned char idx, unsigned int val);
163 void isapnp_wake(unsigned char csn);
164 void isapnp_device(unsigned char device);
165 void isapnp_activate(unsigned char device);
166 void isapnp_deactivate(unsigned char device);
167 void isapnp_fixup_device(struct pci_dev *dev);
168 void *isapnp_alloc(long size);
169 int isapnp_proc_init(void);
170 int isapnp_proc_done(void);
171 /* manager */
172 struct pci_bus *isapnp_find_card(unsigned short vendor,
173 unsigned short device,
174 struct pci_bus *from);
175 struct pci_dev *isapnp_find_dev(struct pci_bus *card,
176 unsigned short vendor,
177 unsigned short function,
178 struct pci_dev *from);
179 int isapnp_probe_cards(const struct isapnp_card_id *ids,
180 int (*probe)(struct pci_bus *card,
181 const struct isapnp_card_id *id));
182 /* misc */
183 void isapnp_resource_change(struct resource *resource,
184 unsigned long start,
185 unsigned long size);
186 /* init/main.c */
187 int isapnp_init(void);
189 extern struct list_head isapnp_cards;
190 extern struct list_head isapnp_devices;
192 #define isapnp_for_each_card(card) \
193 for(card = pci_bus_b(isapnp_cards.next); card != pci_bus_b(&isapnp_cards); card = pci_bus_b(card->node.next))
194 #define isapnp_for_each_dev(dev) \
195 for(dev = pci_dev_g(isapnp_devices.next); dev != pci_dev_g(&isapnp_devices); dev = pci_dev_g(dev->global_list.next))
197 #else /* !CONFIG_ISAPNP */
199 /* lowlevel configuration */
200 extern inline int isapnp_present(void) { return 0; }
201 extern inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
202 extern inline int isapnp_cfg_end(void) { return -ENODEV; }
203 extern inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
204 extern inline unsigned short isapnp_read_word(unsigned char idx) { return 0xffff; }
205 extern inline unsigned int isapnp_read_dword(unsigned char idx) { return 0xffffffff; }
206 extern inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
207 extern inline void isapnp_write_word(unsigned char idx, unsigned short val) { ; }
208 extern inline void isapnp_write_dword(unsigned char idx, unsigned int val) { ; }
209 extern inline void isapnp_wake(unsigned char csn) { ; }
210 extern inline void isapnp_device(unsigned char device) { ; }
211 extern inline void isapnp_activate(unsigned char device) { ; }
212 extern inline void isapnp_deactivate(unsigned char device) { ; }
213 /* manager */
214 extern inline struct pci_bus *isapnp_find_card(unsigned short vendor,
215 unsigned short device,
216 struct pci_bus *from) { return NULL; }
217 extern inline struct pci_dev *isapnp_find_dev(struct pci_bus *card,
218 unsigned short vendor,
219 unsigned short function,
220 struct pci_dev *from) { return NULL; }
221 extern inline int isapnp_probe_cards(const struct isapnp_card_id *ids,
222 int (*probe)(struct pci_bus *card,
223 const struct isapnp_card_id *id)) { return -ENODEV; }
224 extern inline void isapnp_resource_change(struct resource *resource,
225 unsigned long start,
226 unsigned long size) { ; }
228 #endif /* CONFIG_ISAPNP */
230 #endif /* __KERNEL__ */
231 #endif /* LINUX_ISAPNP_H */