mca.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Header for Microchannel Architecture Bus
  3. * Written by Martin Kolinek, February 1996
  4. */
  5. #ifndef _LINUX_MCA_H
  6. #define _LINUX_MCA_H
  7. #include <linux/device.h>
  8. #ifdef CONFIG_MCA
  9. #include <asm/mca.h>
  10. extern int MCA_bus;
  11. #else
  12. #define MCA_bus 0
  13. #endif
  14. /* This sets up an information callback for /proc/mca/slot?. The
  15. * function is called with the buffer, slot, and device pointer (or
  16. * some equally informative context information, or nothing, if you
  17. * prefer), and is expected to put useful information into the
  18. * buffer. The adapter name, id, and POS registers get printed
  19. * before this is called though, so don't do it again.
  20. *
  21. * This should be called with a NULL procfn when a module
  22. * unregisters, thus preventing kernel crashes and other such
  23. * nastiness.
  24. */
  25. typedef int (*MCA_ProcFn)(char* buf, int slot, void* dev);
  26. /* Should only be called by the NMI interrupt handler, this will do some
  27. * fancy stuff to figure out what might have generated a NMI.
  28. */
  29. extern void mca_handle_nmi(void);
  30. enum MCA_AdapterStatus {
  31. MCA_ADAPTER_NORMAL = 0,
  32. MCA_ADAPTER_NONE = 1,
  33. MCA_ADAPTER_DISABLED = 2,
  34. MCA_ADAPTER_ERROR = 3
  35. };
  36. struct mca_device {
  37. u64 dma_mask;
  38. int pos_id;
  39. int slot;
  40. /* index into id_table, set by the bus match routine */
  41. int index;
  42. /* is there a driver installed? 0 - No, 1 - Yes */
  43. int driver_loaded;
  44. /* POS registers */
  45. unsigned char pos[8];
  46. /* if a pseudo adapter of the motherboard, this is the motherboard
  47. * register value to use for setup cycles */
  48. short pos_register;
  49. enum MCA_AdapterStatus status;
  50. #ifdef CONFIG_MCA_PROC_FS
  51. /* name of the proc/mca file */
  52. char procname[8];
  53. /* /proc info callback */
  54. MCA_ProcFn procfn;
  55. /* device/context info for proc callback */
  56. void *proc_dev;
  57. #endif
  58. struct device dev;
  59. char name[32];
  60. };
  61. #define to_mca_device(mdev) container_of(mdev, struct mca_device, dev)
  62. struct mca_bus_accessor_functions {
  63. unsigned char (*mca_read_pos)(struct mca_device *, int reg);
  64. void (*mca_write_pos)(struct mca_device *, int reg,
  65. unsigned char byte);
  66. int (*mca_transform_irq)(struct mca_device *, int irq);
  67. int (*mca_transform_ioport)(struct mca_device *,
  68. int region);
  69. void * (*mca_transform_memory)(struct mca_device *,
  70. void *memory);
  71. };
  72. struct mca_bus {
  73. u64 default_dma_mask;
  74. int number;
  75. struct mca_bus_accessor_functions f;
  76. struct device dev;
  77. char name[32];
  78. };
  79. #define to_mca_bus(mdev) container_of(mdev, struct mca_bus, dev)
  80. struct mca_driver {
  81. const short *id_table;
  82. void *driver_data;
  83. struct device_driver driver;
  84. };
  85. #define to_mca_driver(mdriver) container_of(mdriver, struct mca_driver, driver)
  86. /* Ongoing supported API functions */
  87. extern struct mca_device *mca_find_device_by_slot(int slot);
  88. extern int mca_system_init(void);
  89. extern struct mca_bus *mca_attach_bus(int);
  90. extern unsigned char mca_device_read_stored_pos(struct mca_device *mca_dev,
  91. int reg);
  92. extern unsigned char mca_device_read_pos(struct mca_device *mca_dev, int reg);
  93. extern void mca_device_write_pos(struct mca_device *mca_dev, int reg,
  94. unsigned char byte);
  95. extern int mca_device_transform_irq(struct mca_device *mca_dev, int irq);
  96. extern int mca_device_transform_ioport(struct mca_device *mca_dev, int port);
  97. extern void *mca_device_transform_memory(struct mca_device *mca_dev,
  98. void *mem);
  99. extern int mca_device_claimed(struct mca_device *mca_dev);
  100. extern void mca_device_set_claim(struct mca_device *mca_dev, int val);
  101. extern void mca_device_set_name(struct mca_device *mca_dev, const char *name);
  102. static inline char *mca_device_get_name(struct mca_device *mca_dev)
  103. {
  104. return mca_dev ? mca_dev->name : NULL;
  105. }
  106. extern enum MCA_AdapterStatus mca_device_status(struct mca_device *mca_dev);
  107. extern struct bus_type mca_bus_type;
  108. extern int mca_register_driver(struct mca_driver *drv);
  109. extern void mca_unregister_driver(struct mca_driver *drv);
  110. /* WARNING: only called by the boot time device setup */
  111. extern int mca_register_device(int bus, struct mca_device *mca_dev);
  112. #ifdef CONFIG_MCA_PROC_FS
  113. extern void mca_do_proc_init(void);
  114. extern void mca_set_adapter_procfn(int slot, MCA_ProcFn, void* dev);
  115. #else
  116. static inline void mca_do_proc_init(void)
  117. {
  118. }
  119. static inline void mca_set_adapter_procfn(int slot, MCA_ProcFn fn, void* dev)
  120. {
  121. }
  122. #endif
  123. #endif /* _LINUX_MCA_H */