1
2
3
4
5
6
7#ifndef LINUX_ISAPNP_H
8#define LINUX_ISAPNP_H
9
10#include <linux/errno.h>
11#include <linux/pnp.h>
12
13
14
15
16
17#define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
18 ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
19 ((((c)-'A'+1)&0x1f)<<8))
20#define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
21 (((x)&0x0f00)>>8)|\
22 (((x)&0x00f0)<<8)|\
23 (((x)&0x000f)<<8))
24#define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
25
26
27
28
29
30#ifdef __KERNEL__
31#include <linux/mod_devicetable.h>
32
33#define DEVICE_COUNT_COMPATIBLE 4
34
35#define ISAPNP_CARD_DEVS 8
36
37#define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
38 .card_vendor = ISAPNP_VENDOR(_va, _vb, _vc), .card_device = ISAPNP_DEVICE(_device)
39#define ISAPNP_CARD_END \
40 .card_vendor = 0, .card_device = 0
41#define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
42 { .vendor = ISAPNP_VENDOR(_va, _vb, _vc), .function = ISAPNP_FUNCTION(_function) }
43
44struct isapnp_card_id {
45 unsigned long driver_data;
46 unsigned short card_vendor, card_device;
47 struct {
48 unsigned short vendor, function;
49 } devs[ISAPNP_CARD_DEVS];
50};
51
52#define ISAPNP_DEVICE_SINGLE(_cva, _cvb, _cvc, _cdevice, _dva, _dvb, _dvc, _dfunction) \
53 .card_vendor = ISAPNP_VENDOR(_cva, _cvb, _cvc), .card_device = ISAPNP_DEVICE(_cdevice), \
54 .vendor = ISAPNP_VENDOR(_dva, _dvb, _dvc), .function = ISAPNP_FUNCTION(_dfunction)
55#define ISAPNP_DEVICE_SINGLE_END \
56 .card_vendor = 0, .card_device = 0
57
58#if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
59
60#define __ISAPNP__
61
62
63int isapnp_present(void);
64int isapnp_cfg_begin(int csn, int device);
65int isapnp_cfg_end(void);
66unsigned char isapnp_read_byte(unsigned char idx);
67void isapnp_write_byte(unsigned char idx, unsigned char val);
68
69#ifdef CONFIG_PROC_FS
70int isapnp_proc_init(void);
71int isapnp_proc_done(void);
72#else
73static inline int isapnp_proc_init(void) { return 0; }
74static inline int isapnp_proc_done(void) { return 0; }
75#endif
76
77
78struct pnp_card *pnp_find_card(unsigned short vendor,
79 unsigned short device,
80 struct pnp_card *from);
81struct pnp_dev *pnp_find_dev(struct pnp_card *card,
82 unsigned short vendor,
83 unsigned short function,
84 struct pnp_dev *from);
85
86#else
87
88
89static inline int isapnp_present(void) { return 0; }
90static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
91static inline int isapnp_cfg_end(void) { return -ENODEV; }
92static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
93static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
94
95static inline struct pnp_card *pnp_find_card(unsigned short vendor,
96 unsigned short device,
97 struct pnp_card *from) { return NULL; }
98static inline struct pnp_dev *pnp_find_dev(struct pnp_card *card,
99 unsigned short vendor,
100 unsigned short function,
101 struct pnp_dev *from) { return NULL; }
102
103#endif
104
105#endif
106#endif
107