1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * ISA Plug & Play support
4 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
10 #include <linux/errno.h>
11 #include <linux/pnp.h>
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)|\
24 #define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
31 #include <linux/mod_devicetable.h>
33 #define DEVICE_COUNT_COMPATIBLE 4
35 #define ISAPNP_CARD_DEVS 8
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) }
44 struct isapnp_card_id {
45 unsigned long driver_data; /* data private to the driver */
46 unsigned short card_vendor, card_device;
48 unsigned short vendor, function;
49 } devs[ISAPNP_CARD_DEVS]; /* logical devices */
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
58 #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
62 /* lowlevel configuration */
63 int isapnp_present(void);
64 int isapnp_cfg_begin(int csn, int device);
65 int isapnp_cfg_end(void);
66 unsigned char isapnp_read_byte(unsigned char idx);
67 void isapnp_write_byte(unsigned char idx, unsigned char val);
70 int isapnp_proc_init(void);
71 int isapnp_proc_done(void);
73 static inline int isapnp_proc_init(void) { return 0; }
74 static inline int isapnp_proc_done(void) { return 0; }
78 struct pnp_dev *pnp_find_dev(struct pnp_card *card,
79 unsigned short vendor,
80 unsigned short function,
81 struct pnp_dev *from);
83 #else /* !CONFIG_ISAPNP */
85 /* lowlevel configuration */
86 static inline int isapnp_present(void) { return 0; }
87 static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
88 static inline int isapnp_cfg_end(void) { return -ENODEV; }
89 static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
90 static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
92 static inline struct pnp_dev *pnp_find_dev(struct pnp_card *card,
93 unsigned short vendor,
94 unsigned short function,
95 struct pnp_dev *from) { return NULL; }
97 #endif /* CONFIG_ISAPNP */
99 #endif /* __KERNEL__ */
100 #endif /* LINUX_ISAPNP_H */