source: GPL/alsa-kernel/include/sound/isapnp.h@ 18

Last change on this file since 18 was 18, checked in by vladest, 20 years ago

initial import

File size: 13.2 KB
Line 
1/*
2 * ISA Plug & Play support
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
4 *
5 *
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.
10 *
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.
15 *
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.
19 *
20 */
21
22#ifndef LINUX_ISAPNP_H
23#define LINUX_ISAPNP_H
24
25/*
26 * Configuration registers (TODO: change by specification)
27 */
28
29#define ISAPNP_CFG_ACTIVATE 0x30 /* byte */
30#define ISAPNP_CFG_MEM 0x40 /* 4 * dword */
31#define ISAPNP_CFG_PORT 0x60 /* 8 * word */
32#define ISAPNP_CFG_IRQ 0x70 /* 2 * word */
33#define ISAPNP_CFG_DMA 0x74 /* 2 * byte */
34
35/*
36 *
37 */
38
39#define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
40 ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
41 ((((c)-'A'+1)&0x1f)<<8))
42#define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
43 (((x)&0x0f00)>>8)|\
44 (((x)&0x00f0)<<8)|\
45 (((x)&0x000f)<<8))
46#define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
47
48/*
49 *
50 */
51
52#ifdef __KERNEL__
53
54#define ISAPNP_PORT_FLAG_16BITADDR (1<<0)
55#define ISAPNP_PORT_FLAG_FIXED (1<<1)
56
57struct isapnp_port {
58 unsigned short min; /* min base number */
59 unsigned short max; /* max base number */
60 unsigned char align; /* align boundary */
61 unsigned char size; /* size of range */
62 unsigned char flags; /* port flags */
63 unsigned char pad; /* pad */
64 struct isapnp_resources *res; /* parent */
65 struct isapnp_port *next; /* next port */
66};
67
68struct isapnp_irq {
69 unsigned short map; /* bitmaks for IRQ lines */
70 unsigned char flags; /* IRQ flags */
71 unsigned char pad; /* pad */
72 struct isapnp_resources *res; /* parent */
73 struct isapnp_irq *next; /* next IRQ */
74};
75
76struct isapnp_dma {
77 unsigned char map; /* bitmask for DMA channels */
78 unsigned char flags; /* DMA flags */
79 struct isapnp_resources *res; /* parent */
80 struct isapnp_dma *next; /* next port */
81};
82
83struct isapnp_mem {
84 unsigned int min; /* min base number */
85 unsigned int max; /* max base number */
86 unsigned int align; /* align boundary */
87 unsigned int size; /* size of range */
88 unsigned char flags; /* memory flags */
89 unsigned char pad; /* pad */
90 struct isapnp_resources *res; /* parent */
91 struct isapnp_mem *next; /* next memory resource */
92};
93
94struct isapnp_mem32 {
95 /* TODO */
96 unsigned char data[17];
97 struct isapnp_resources *res; /* parent */
98 struct isapnp_mem32 *next; /* next 32-bit memory resource */
99};
100
101#define ISAPNP_RES_PRIORITY_PREFERRED 0
102#define ISAPNP_RES_PRIORITY_ACCEPTABLE 1
103#define ISAPNP_RES_PRIORITY_FUNCTIONAL 2
104#define ISAPNP_RES_PRIORITY_INVALID 65535
105
106struct isapnp_resources {
107 unsigned short priority; /* priority */
108 unsigned short dependent; /* dependent resources */
109 struct isapnp_port *port; /* first port */
110 struct isapnp_irq *irq; /* first IRQ */
111 struct isapnp_dma *dma; /* first DMA */
112 struct isapnp_mem *mem; /* first memory resource */
113 struct isapnp_mem32 *mem32; /* first 32-bit memory */
114 struct isapnp_dev *dev; /* parent */
115 struct isapnp_resources *alt; /* alternative resource (aka dependent resources) */
116 struct isapnp_resources *next; /* next resource */
117};
118
119struct isapnp_fixup {
120 unsigned short vendor; /* matching vendor */
121 unsigned short device; /* matching device */
122 void (*quirk_function)(struct isapnp_dev *dev); /* fixup function */
123};
124
125
126#ifndef LINUX_VERSION_CODE
127#include <linux/version.h>
128#endif
129
130#include <linux/pci.h>
131
132#if LINUX_VERSION_CODE == KERNEL_VERSION(2, 3, 14)
133#error "Please, upgrade to 2.3.15 kernel."
134#endif
135
136#ifndef IORESOURCE_IO
137struct resource {
138 const char *name;
139 unsigned long start, end;
140 unsigned long flags;
141 struct resource *parent, *sibling, *child;
142};
143#endif
144
145/*
146 * IO resources have these defined flags.
147 */
148#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
149
150#define IORESOURCE_IO 0x00000100 /* Resource type */
151#define IORESOURCE_MEM 0x00000200
152#define IORESOURCE_IRQ 0x00000400
153#define IORESOURCE_DMA 0x00000800
154
155#define IORESOURCE_PREFETCH 0x00001000 /* No side effects */
156#define IORESOURCE_READONLY 0x00002000
157#define IORESOURCE_CACHEABLE 0x00004000
158#define IORESOURCE_RANGELENGTH 0x00008000
159#define IORESOURCE_SHADOWABLE 0x00010000
160
161#define IORESOURCE_UNSET 0x20000000
162#define IORESOURCE_AUTO 0x40000000
163#define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */
164
165/* ISA PnP IRQ specific bits (IORESOURCE_BITS) */
166#define IORESOURCE_IRQ_HIGHEDGE (1<<0)
167#define IORESOURCE_IRQ_LOWEDGE (1<<1)
168#define IORESOURCE_IRQ_HIGHLEVEL (1<<2)
169#define IORESOURCE_IRQ_LOWLEVEL (1<<3)
170
171/* ISA PnP DMA specific bits (IORESOURCE_BITS) */
172#define IORESOURCE_DMA_TYPE_MASK (3<<0)
173#define IORESOURCE_DMA_8BIT (0<<0)
174#define IORESOURCE_DMA_8AND16BIT (1<<0)
175#define IORESOURCE_DMA_16BIT (2<<0)
176
177#define IORESOURCE_DMA_MASTER (1<<2)
178#define IORESOURCE_DMA_BYTE (1<<3)
179#define IORESOURCE_DMA_WORD (1<<4)
180
181#define IORESOURCE_DMA_SPEED_MASK (3<<6)
182#define IORESOURCE_DMA_COMPATIBLE (0<<6)
183#define IORESOURCE_DMA_TYPEA (1<<6)
184#define IORESOURCE_DMA_TYPEB (2<<6)
185#define IORESOURCE_DMA_TYPEF (3<<6)
186
187/* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */
188#define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */
189#define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */
190#define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */
191#define IORESOURCE_MEM_TYPE_MASK (3<<3)
192#define IORESOURCE_MEM_8BIT (0<<3)
193#define IORESOURCE_MEM_16BIT (1<<3)
194#define IORESOURCE_MEM_8AND16BIT (2<<3)
195#define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */
196#define IORESOURCE_MEM_EXPANSIONROM (1<<6)
197
198
199#define DEVICE_COUNT_COMPATIBLE 4
200#define DEVICE_COUNT_IRQ 2
201#define DEVICE_COUNT_DMA 2
202#define DEVICE_COUNT_RESOURCE 12
203
204/*
205 * The pci_dev structure is used to describe both PCI and ISAPnP devices.
206 */
207struct isapnp_dev {
208 int active; /* device is active */
209 int ro; /* Read/Only */
210
211 struct isapnp_card *bus; /* bus this device is on */
212 struct isapnp_dev *sibling; /* next device on this bus */
213 struct isapnp_dev *next; /* chain of all devices */
214
215 void *sysdata; /* hook for sys-specific extension */
216 struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
217
218 unsigned int devfn; /* encoded device & function index */
219 unsigned short vendor;
220 unsigned short device;
221 unsigned short subsystem_vendor;
222 unsigned short subsystem_device;
223 unsigned int class; /* 3 bytes: (base,sub,prog-if) */
224 unsigned int hdr_type; /* PCI header type */
225 unsigned int master : 1; /* set if device is master capable */
226
227 unsigned short regs;
228
229 /* device is compatible with these IDs */
230 unsigned short vendor_compatible[DEVICE_COUNT_COMPATIBLE];
231 unsigned short device_compatible[DEVICE_COUNT_COMPATIBLE];
232
233 /*
234 * Instead of touching interrupt line and base address registers
235 * directly, use the values stored here. They might be different!
236 */
237 unsigned int irq;
238 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
239 struct resource dma_resource[DEVICE_COUNT_DMA];
240 struct resource irq_resource[DEVICE_COUNT_IRQ];
241
242 char name[48]; /* Device name */
243
244 int (*prepare)(struct isapnp_dev *dev);
245 int (*activate)(struct isapnp_dev *dev);
246 int (*deactivate)(struct isapnp_dev *dev);
247};
248
249struct isapnp_card {
250 struct isapnp_card *parent; /* parent bus this bridge is on */
251 struct isapnp_card *children; /* chain of P2P bridges on this bus */
252 struct isapnp_card *next; /* chain of all PCI buses */
253 struct pci_ops *ops; /* configuration access functions */
254
255 struct isapnp_dev *self; /* bridge device as seen by parent */
256 struct isapnp_dev *devices; /* devices behind this bridge */
257
258 void *sysdata; /* hook for sys-specific extension */
259 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
260
261 unsigned char number; /* bus number */
262 unsigned char primary; /* number of primary bridge */
263 unsigned char secondary; /* number of secondary bridge */
264 unsigned char subordinate; /* max number of subordinate buses */
265
266 char name[48];
267 unsigned short vendor;
268 unsigned short device;
269 unsigned int serial; /* serial number */
270 unsigned char pnpver; /* Plug & Play version */
271 unsigned char productver; /* product version */
272 unsigned char checksum; /* if zero - checksum passed */
273 unsigned char pad1;
274};
275
276#define ISAPNP_ANY_ID 0xffff
277#define ISAPNP_CARD_DEVS 8
278
279#ifdef TARGET_OS2
280#define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
281 ISAPNP_VENDOR(_va, _vb, _vc), ISAPNP_DEVICE(_device)
282#define ISAPNP_CARD_END \
283 0, 0
284#define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
285 { ISAPNP_VENDOR(_va, _vb, _vc), ISAPNP_FUNCTION(_function) }
286
287#define ISAPNP_CARD_TABLE(name)
288
289struct isapnp_card_id {
290 unsigned long driver_data; /* data private to the driver */
291 unsigned short card_vendor, card_device;
292 struct {
293 unsigned short vendor, function;
294 } devs[ISAPNP_CARD_DEVS]; /* logical devices */
295};
296
297#else
298#define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
299 card_vendor: ISAPNP_VENDOR(_va, _vb, _vc), card_device: ISAPNP_DEVICE(_device)
300#define ISAPNP_CARD_END \
301 card_vendor: 0, card_device: 0
302#define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
303 { vendor: ISAPNP_VENDOR(_va, _vb, _vc), function: ISAPNP_FUNCTION(_function) }
304
305#define ISAPNP_CARD_TABLE(name) \
306 MODULE_GENERIC_TABLE(isapnp_card, name)
307
308struct isapnp_card_id {
309 unsigned long driver_data; /* data private to the driver */
310 unsigned short card_vendor, card_device;
311 struct {
312 unsigned short vendor, function;
313 } devs[ISAPNP_CARD_DEVS]; /* logical devices */
314};
315
316#endif
317
318#ifdef CONFIG_ISAPNP
319
320#ifndef __ISAPNP__
321#define __ISAPNP__
322#endif
323
324/* lowlevel configuration */
325int isapnp_present(void);
326int isapnp_cfg_begin(int csn, int device);
327int isapnp_cfg_end(void);
328unsigned char isapnp_read_byte(unsigned char idx);
329unsigned short isapnp_read_word(unsigned char idx);
330unsigned int isapnp_read_dword(unsigned char idx);
331void isapnp_write_byte(unsigned char idx, unsigned char val);
332void isapnp_write_word(unsigned char idx, unsigned short val);
333void isapnp_write_dword(unsigned char idx, unsigned int val);
334void isapnp_wake(unsigned char csn);
335void isapnp_device(unsigned char device);
336void isapnp_activate(unsigned char device);
337void isapnp_deactivate(unsigned char device);
338/* manager */
339struct isapnp_card *isapnp_find_card(unsigned short vendor,
340 unsigned short device,
341 struct isapnp_card *from);
342struct isapnp_dev *isapnp_find_dev(struct isapnp_card *card,
343 unsigned short vendor,
344 unsigned short function,
345 struct isapnp_dev *from);
346int isapnp_probe_cards(const struct isapnp_card_id *ids,
347 int (*probe)(struct isapnp_card *card,
348 const struct isapnp_card_id *id));
349/* misc */
350void isapnp_resource_change(struct resource *resource,
351 unsigned long start,
352 unsigned long size);
353/* init/main.c */
354int isapnp_init(void);
355
356#else /* !CONFIG_ISAPNP */
357
358/* lowlevel configuration */
359extern inline int isapnp_present(void) { return 0; }
360extern inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
361extern inline int isapnp_cfg_end(void) { return -ENODEV; }
362extern inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
363extern inline unsigned short isapnp_read_word(unsigned char idx) { return 0xffff; }
364extern inline unsigned int isapnp_read_dword(unsigned char idx) { return 0xffffffff; }
365extern inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
366extern inline void isapnp_write_word(unsigned char idx, unsigned short val) { ; }
367extern inline void isapnp_write_dword(unsigned char idx, unsigned int val) { ; }
368extern void isapnp_wake(unsigned char csn) { ; }
369extern void isapnp_device(unsigned char device) { ; }
370extern void isapnp_activate(unsigned char device) { ; }
371extern void isapnp_deactivate(unsigned char device) { ; }
372/* manager */
373extern struct isapnp_card *isapnp_find_card(unsigned short vendor,
374 unsigned short device,
375 struct isapnp_card *from) { return NULL; }
376extern struct isapnp_dev *isapnp_find_dev(struct isapnp_card *card,
377 unsigned short vendor,
378 unsigned short function,
379 struct isapnp_dev *from) { return NULL; }
380int isapnp_probe_cards(const struct isapnp_card_id *ids,
381 int (*probe)(struct isapnp_card *card,
382 const struct isapnp_card_id *id)) { return 0; }
383/* misc */
384extern void isapnp_resource_change(struct resource *resource,
385 unsigned long start,
386 unsigned long size) { ; }
387
388#endif /* CONFIG_ISAPNP */
389
390#endif /* __KERNEL__ */
391#endif /* LINUX_ISAPNP_H */
Note: See TracBrowser for help on using the repository browser.