1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * ISA Plug & Play support
4 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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
44 struct isapnp_card_id {
45 unsigned long driver_data; /* data private to the driver */
46 unsigned short card_vendor, card_device;
47 struct {
48 unsigned short vendor, function;
49 } devs[ISAPNP_CARD_DEVS]; /* logical devices */
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 /* 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);
68
69 #ifdef CONFIG_PROC_FS
70 int isapnp_proc_init(void);
71 int isapnp_proc_done(void);
72 #else
isapnp_proc_init(void)73 static inline int isapnp_proc_init(void) { return 0; }
isapnp_proc_done(void)74 static inline int isapnp_proc_done(void) { return 0; }
75 #endif
76
77 /* compat */
78 struct pnp_dev *pnp_find_dev(struct pnp_card *card,
79 unsigned short vendor,
80 unsigned short function,
81 struct pnp_dev *from);
82
83 #else /* !CONFIG_ISAPNP */
84
85 /* lowlevel configuration */
isapnp_present(void)86 static inline int isapnp_present(void) { return 0; }
isapnp_cfg_begin(int csn,int device)87 static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
isapnp_cfg_end(void)88 static inline int isapnp_cfg_end(void) { return -ENODEV; }
isapnp_read_byte(unsigned char idx)89 static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
isapnp_write_byte(unsigned char idx,unsigned char val)90 static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
91
pnp_find_dev(struct pnp_card * card,unsigned short vendor,unsigned short function,struct pnp_dev * from)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; }
96
97 #endif /* CONFIG_ISAPNP */
98
99 #endif /* __KERNEL__ */
100 #endif /* LINUX_ISAPNP_H */
101