]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/linux/isapnp.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[mirror_ubuntu-jammy-kernel.git] / include / linux / isapnp.h
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
73 static inline int isapnp_proc_init(void) { return 0; }
74 static inline int isapnp_proc_done(void) { return 0; }
75 #endif
76
77 /* compat */
78 struct pnp_card *pnp_find_card(unsigned short vendor,
79 unsigned short device,
80 struct pnp_card *from);
81 struct 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 /* !CONFIG_ISAPNP */
87
88 /* lowlevel configuration */
89 static inline int isapnp_present(void) { return 0; }
90 static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
91 static inline int isapnp_cfg_end(void) { return -ENODEV; }
92 static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
93 static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
94
95 static inline struct pnp_card *pnp_find_card(unsigned short vendor,
96 unsigned short device,
97 struct pnp_card *from) { return NULL; }
98 static 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 /* CONFIG_ISAPNP */
104
105 #endif /* __KERNEL__ */
106 #endif /* LINUX_ISAPNP_H */