/kern_oII/include/linux/isapnp.h

http://omnia2droid.googlecode.com/ · C++ Header · 131 lines · 78 code · 23 blank · 30 comment · 2 complexity · 07f2700f33811a315e02a9c8f1bc3fd8 MD5 · raw file

  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. *
  27. */
  28. #define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
  29. ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
  30. ((((c)-'A'+1)&0x1f)<<8))
  31. #define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
  32. (((x)&0x0f00)>>8)|\
  33. (((x)&0x00f0)<<8)|\
  34. (((x)&0x000f)<<8))
  35. #define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
  36. /*
  37. *
  38. */
  39. #ifdef __KERNEL__
  40. #define DEVICE_COUNT_COMPATIBLE 4
  41. #define ISAPNP_ANY_ID 0xffff
  42. #define ISAPNP_CARD_DEVS 8
  43. #define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
  44. .card_vendor = ISAPNP_VENDOR(_va, _vb, _vc), .card_device = ISAPNP_DEVICE(_device)
  45. #define ISAPNP_CARD_END \
  46. .card_vendor = 0, .card_device = 0
  47. #define ISAPNP_DEVICE_ID(_va, _vb, _vc, _function) \
  48. { .vendor = ISAPNP_VENDOR(_va, _vb, _vc), .function = ISAPNP_FUNCTION(_function) }
  49. /* export used IDs outside module */
  50. #define ISAPNP_CARD_TABLE(name) \
  51. MODULE_GENERIC_TABLE(isapnp_card, name)
  52. struct isapnp_card_id {
  53. unsigned long driver_data; /* data private to the driver */
  54. unsigned short card_vendor, card_device;
  55. struct {
  56. unsigned short vendor, function;
  57. } devs[ISAPNP_CARD_DEVS]; /* logical devices */
  58. };
  59. #define ISAPNP_DEVICE_SINGLE(_cva, _cvb, _cvc, _cdevice, _dva, _dvb, _dvc, _dfunction) \
  60. .card_vendor = ISAPNP_VENDOR(_cva, _cvb, _cvc), .card_device = ISAPNP_DEVICE(_cdevice), \
  61. .vendor = ISAPNP_VENDOR(_dva, _dvb, _dvc), .function = ISAPNP_FUNCTION(_dfunction)
  62. #define ISAPNP_DEVICE_SINGLE_END \
  63. .card_vendor = 0, .card_device = 0
  64. struct isapnp_device_id {
  65. unsigned short card_vendor, card_device;
  66. unsigned short vendor, function;
  67. unsigned long driver_data; /* data private to the driver */
  68. };
  69. #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
  70. #define __ISAPNP__
  71. /* lowlevel configuration */
  72. int isapnp_present(void);
  73. int isapnp_cfg_begin(int csn, int device);
  74. int isapnp_cfg_end(void);
  75. unsigned char isapnp_read_byte(unsigned char idx);
  76. void isapnp_write_byte(unsigned char idx, unsigned char val);
  77. #ifdef CONFIG_PROC_FS
  78. int isapnp_proc_init(void);
  79. int isapnp_proc_done(void);
  80. #else
  81. static inline int isapnp_proc_init(void) { return 0; }
  82. static inline int isapnp_proc_done(void) { return 0; }
  83. #endif
  84. /* compat */
  85. struct pnp_card *pnp_find_card(unsigned short vendor,
  86. unsigned short device,
  87. struct pnp_card *from);
  88. struct pnp_dev *pnp_find_dev(struct pnp_card *card,
  89. unsigned short vendor,
  90. unsigned short function,
  91. struct pnp_dev *from);
  92. #else /* !CONFIG_ISAPNP */
  93. /* lowlevel configuration */
  94. static inline int isapnp_present(void) { return 0; }
  95. static inline int isapnp_cfg_begin(int csn, int device) { return -ENODEV; }
  96. static inline int isapnp_cfg_end(void) { return -ENODEV; }
  97. static inline unsigned char isapnp_read_byte(unsigned char idx) { return 0xff; }
  98. static inline void isapnp_write_byte(unsigned char idx, unsigned char val) { ; }
  99. static inline struct pnp_card *pnp_find_card(unsigned short vendor,
  100. unsigned short device,
  101. struct pnp_card *from) { return NULL; }
  102. static inline struct pnp_dev *pnp_find_dev(struct pnp_card *card,
  103. unsigned short vendor,
  104. unsigned short function,
  105. struct pnp_dev *from) { return NULL; }
  106. #endif /* CONFIG_ISAPNP */
  107. #endif /* __KERNEL__ */
  108. #endif /* LINUX_ISAPNP_H */