isapnp.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * ISA Plug & Play support
  3. * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
  4. *
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. */
  21. #ifndef LINUX_ISAPNP_H
  22. #define LINUX_ISAPNP_H
  23. #include <linux/errno.h>
  24. #include <linux/pnp.h>
  25. /*
  26. * Configuration registers (TODO: change by specification)
  27. */
  28. #define ISAPNP_CFG_ACTIVATE 0x30 /* byte */
  29. #define ISAPNP_CFG_MEM 0x40 /* 4 * dword */
  30. #define ISAPNP_CFG_PORT 0x60 /* 8 * word */
  31. #define ISAPNP_CFG_IRQ 0x70 /* 2 * word */
  32. #define ISAPNP_CFG_DMA 0x74 /* 2 * byte */
  33. /*
  34. *
  35. */
  36. #define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
  37. ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
  38. ((((c)-'A'+1)&0x1f)<<8))
  39. #define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
  40. (((x)&0x0f00)>>8)|\
  41. (((x)&0x00f0)<<8)|\
  42. (((x)&0x000f)<<8))
  43. #define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
  44. /*
  45. *
  46. */
  47. #ifdef __KERNEL__
  48. #define DEVICE_COUNT_COMPATIBLE 4
  49. #define ISAPNP_ANY_ID 0xffff
  50. #define ISAPNP_CARD_DEVS 8
  51. #define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
  52. .card_vendor = ISAPNP_VENDOR(_va, _vb, _vc), .card_device = ISAPNP_DEVICE(_device)
  53. #define ISAPNP_CARD_END \
  54. .card_vendor = 0, .card_device = 0
  55. #define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
  56. { .vendor = ISAPNP_VENDOR(_va, _vb, _vc), .function = ISAPNP_FUNCTION(_function) }
  57. /* export used IDs outside module */
  58. #define ISAPNP_CARD_TABLE(name) \
  59. MODULE_GENERIC_TABLE(isapnp_card, name)
  60. struct isapnp_card_id {
  61. unsigned long driver_data; /* data private to the driver */
  62. unsigned short card_vendor, card_device;
  63. struct {
  64. unsigned short vendor, function;
  65. } devs[ISAPNP_CARD_DEVS]; /* logical devices */
  66. };
  67. #define ISAPNP_DEVICE_SINGLE(_cva, _cvb, _cvc, _cdevice, _dva, _dvb, _dvc, _dfunction) \
  68. .card_vendor = ISAPNP_VENDOR(_cva, _cvb, _cvc), .card_device = ISAPNP_DEVICE(_cdevice), \
  69. .vendor = ISAPNP_VENDOR(_dva, _dvb, _dvc), .function = ISAPNP_FUNCTION(_dfunction)
  70. #define ISAPNP_DEVICE_SINGLE_END \
  71. .card_vendor = 0, .card_device = 0
  72. struct isapnp_device_id {
  73. unsigned short card_vendor, card_device;
  74. unsigned short vendor, function;
  75. unsigned long driver_data; /* data private to the driver */
  76. };
  77. #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
  78. #define __ISAPNP__
  79. /* lowlevel configuration */
  80. int isapnp_present(void);
  81. int isapnp_cfg_begin(int csn, int device);
  82. int isapnp_cfg_end(void);
  83. unsigned char isapnp_read_byte(unsigned char idx);
  84. void isapnp_write_byte(unsigned char idx, unsigned char val);
  85. #ifdef CONFIG_PROC_FS
  86. int isapnp_proc_init(void);
  87. int isapnp_proc_done(void);
  88. #else
  89. static inline int isapnp_proc_init(void) { return 0; }
  90. static inline int isapnp_proc_done(void) { return 0; }
  91. #endif
  92. /* compat */
  93. struct pnp_card *pnp_find_card(unsigned short vendor,
  94. unsigned short device,
  95. struct pnp_card *from);
  96. struct pnp_dev *pnp_find_dev(struct pnp_card *card,
  97. unsigned short vendor,
  98. unsigned short function,
  99. struct pnp_dev *from);
  100. #else /* !CONFIG_ISAPNP */
  101. /* lowlevel configuration */
  102. static inline int isapnp_present(void) { return 0; }
  103. static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
  104. static inline int isapnp_cfg_end(void) { return -ENODEV; }
  105. static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
  106. static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
  107. static inline struct pnp_card *pnp_find_card(unsigned short vendor,
  108. unsigned short device,
  109. struct pnp_card *from) { return NULL; }
  110. static inline struct pnp_dev *pnp_find_dev(struct pnp_card *card,
  111. unsigned short vendor,
  112. unsigned short function,
  113. struct pnp_dev *from) { return NULL; }
  114. #endif /* CONFIG_ISAPNP */
  115. #endif /* __KERNEL__ */
  116. #endif /* LINUX_ISAPNP_H */