Merge branch 'docs-next' of git://git.lwn.net/linux-2.6
[linux-2.6/next.git] / include / linux / isapnp.h
blobcd5a269fdb5e3a5280002c6dd767ee4efe331a48
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/errno.h>
26 #include <linux/pnp.h>
32 #define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
33 ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
34 ((((c)-'A'+1)&0x1f)<<8))
35 #define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
36 (((x)&0x0f00)>>8)|\
37 (((x)&0x00f0)<<8)|\
38 (((x)&0x000f)<<8))
39 #define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
45 #ifdef __KERNEL__
47 #define DEVICE_COUNT_COMPATIBLE 4
49 #define ISAPNP_ANY_ID 0xffff
50 #define ISAPNP_CARD_DEVS 8
52 #define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
53 .card_vendor = ISAPNP_VENDOR(_va, _vb, _vc), .card_device = ISAPNP_DEVICE(_device)
54 #define ISAPNP_CARD_END \
55 .card_vendor = 0, .card_device = 0
56 #define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
57 { .vendor = ISAPNP_VENDOR(_va, _vb, _vc), .function = ISAPNP_FUNCTION(_function) }
59 /* export used IDs outside module */
60 #define ISAPNP_CARD_TABLE(name) \
61 MODULE_GENERIC_TABLE(isapnp_card, name)
63 struct isapnp_card_id {
64 unsigned long driver_data; /* data private to the driver */
65 unsigned short card_vendor, card_device;
66 struct {
67 unsigned short vendor, function;
68 } devs[ISAPNP_CARD_DEVS]; /* logical devices */
71 #define ISAPNP_DEVICE_SINGLE(_cva, _cvb, _cvc, _cdevice, _dva, _dvb, _dvc, _dfunction) \
72 .card_vendor = ISAPNP_VENDOR(_cva, _cvb, _cvc), .card_device = ISAPNP_DEVICE(_cdevice), \
73 .vendor = ISAPNP_VENDOR(_dva, _dvb, _dvc), .function = ISAPNP_FUNCTION(_dfunction)
74 #define ISAPNP_DEVICE_SINGLE_END \
75 .card_vendor = 0, .card_device = 0
77 struct isapnp_device_id {
78 unsigned short card_vendor, card_device;
79 unsigned short vendor, function;
80 unsigned long driver_data; /* data private to the driver */
83 #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
85 #define __ISAPNP__
87 /* lowlevel configuration */
88 int isapnp_present(void);
89 int isapnp_cfg_begin(int csn, int device);
90 int isapnp_cfg_end(void);
91 unsigned char isapnp_read_byte(unsigned char idx);
92 void isapnp_write_byte(unsigned char idx, unsigned char val);
94 #ifdef CONFIG_PROC_FS
95 int isapnp_proc_init(void);
96 int isapnp_proc_done(void);
97 #else
98 static inline int isapnp_proc_init(void) { return 0; }
99 static inline int isapnp_proc_done(void) { return 0; }
100 #endif
102 /* compat */
103 struct pnp_card *pnp_find_card(unsigned short vendor,
104 unsigned short device,
105 struct pnp_card *from);
106 struct pnp_dev *pnp_find_dev(struct pnp_card *card,
107 unsigned short vendor,
108 unsigned short function,
109 struct pnp_dev *from);
111 #else /* !CONFIG_ISAPNP */
113 /* lowlevel configuration */
114 static inline int isapnp_present(void) { return 0; }
115 static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
116 static inline int isapnp_cfg_end(void) { return -ENODEV; }
117 static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
118 static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
120 static inline struct pnp_card *pnp_find_card(unsigned short vendor,
121 unsigned short device,
122 struct pnp_card *from) { return NULL; }
123 static inline struct pnp_dev *pnp_find_dev(struct pnp_card *card,
124 unsigned short vendor,
125 unsigned short function,
126 struct pnp_dev *from) { return NULL; }
128 #endif /* CONFIG_ISAPNP */
130 #endif /* __KERNEL__ */
131 #endif /* LINUX_ISAPNP_H */