isapnp.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * ISA Plug & Play support
  4. * Copyright (c) by Jaroslav Kysela <[email protected]>
  5. */
  6. #ifndef LINUX_ISAPNP_H
  7. #define LINUX_ISAPNP_H
  8. #include <linux/errno.h>
  9. #include <linux/pnp.h>
  10. /*
  11. *
  12. */
  13. #define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
  14. ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
  15. ((((c)-'A'+1)&0x1f)<<8))
  16. #define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
  17. (((x)&0x0f00)>>8)|\
  18. (((x)&0x00f0)<<8)|\
  19. (((x)&0x000f)<<8))
  20. #define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
  21. /*
  22. *
  23. */
  24. #ifdef __KERNEL__
  25. #include <linux/mod_devicetable.h>
  26. #define DEVICE_COUNT_COMPATIBLE 4
  27. #define ISAPNP_CARD_DEVS 8
  28. #define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
  29. .card_vendor = ISAPNP_VENDOR(_va, _vb, _vc), .card_device = ISAPNP_DEVICE(_device)
  30. #define ISAPNP_CARD_END \
  31. .card_vendor = 0, .card_device = 0
  32. #define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
  33. { .vendor = ISAPNP_VENDOR(_va, _vb, _vc), .function = ISAPNP_FUNCTION(_function) }
  34. struct isapnp_card_id {
  35. unsigned long driver_data; /* data private to the driver */
  36. unsigned short card_vendor, card_device;
  37. struct {
  38. unsigned short vendor, function;
  39. } devs[ISAPNP_CARD_DEVS]; /* logical devices */
  40. };
  41. #define ISAPNP_DEVICE_SINGLE(_cva, _cvb, _cvc, _cdevice, _dva, _dvb, _dvc, _dfunction) \
  42. .card_vendor = ISAPNP_VENDOR(_cva, _cvb, _cvc), .card_device = ISAPNP_DEVICE(_cdevice), \
  43. .vendor = ISAPNP_VENDOR(_dva, _dvb, _dvc), .function = ISAPNP_FUNCTION(_dfunction)
  44. #define ISAPNP_DEVICE_SINGLE_END \
  45. .card_vendor = 0, .card_device = 0
  46. #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
  47. #define __ISAPNP__
  48. /* lowlevel configuration */
  49. int isapnp_present(void);
  50. int isapnp_cfg_begin(int csn, int device);
  51. int isapnp_cfg_end(void);
  52. unsigned char isapnp_read_byte(unsigned char idx);
  53. void isapnp_write_byte(unsigned char idx, unsigned char val);
  54. #ifdef CONFIG_PROC_FS
  55. int isapnp_proc_init(void);
  56. int isapnp_proc_done(void);
  57. #else
  58. static inline int isapnp_proc_init(void) { return 0; }
  59. static inline int isapnp_proc_done(void) { return 0; }
  60. #endif
  61. /* compat */
  62. struct pnp_dev *pnp_find_dev(struct pnp_card *card,
  63. unsigned short vendor,
  64. unsigned short function,
  65. struct pnp_dev *from);
  66. #else /* !CONFIG_ISAPNP */
  67. /* lowlevel configuration */
  68. static inline int isapnp_present(void) { return 0; }
  69. static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
  70. static inline int isapnp_cfg_end(void) { return -ENODEV; }
  71. static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
  72. static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
  73. static inline struct pnp_dev *pnp_find_dev(struct pnp_card *card,
  74. unsigned short vendor,
  75. unsigned short function,
  76. struct pnp_dev *from) { return NULL; }
  77. #endif /* CONFIG_ISAPNP */
  78. #endif /* __KERNEL__ */
  79. #endif /* LINUX_ISAPNP_H */