eisa.txt 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. ================
  2. EISA bus support
  3. ================
  4. :Author: Marc Zyngier <maz@wild-wind.fr.eu.org>
  5. This document groups random notes about porting EISA drivers to the
  6. new EISA/sysfs API.
  7. Starting from version 2.5.59, the EISA bus is almost given the same
  8. status as other much more mainstream busses such as PCI or USB. This
  9. has been possible through sysfs, which defines a nice enough set of
  10. abstractions to manage busses, devices and drivers.
  11. Although the new API is quite simple to use, converting existing
  12. drivers to the new infrastructure is not an easy task (mostly because
  13. detection code is generally also used to probe ISA cards). Moreover,
  14. most EISA drivers are among the oldest Linux drivers so, as you can
  15. imagine, some dust has settled here over the years.
  16. The EISA infrastructure is made up of three parts:
  17. - The bus code implements most of the generic code. It is shared
  18. among all the architectures that the EISA code runs on. It
  19. implements bus probing (detecting EISA cards available on the bus),
  20. allocates I/O resources, allows fancy naming through sysfs, and
  21. offers interfaces for driver to register.
  22. - The bus root driver implements the glue between the bus hardware
  23. and the generic bus code. It is responsible for discovering the
  24. device implementing the bus, and setting it up to be latter probed
  25. by the bus code. This can go from something as simple as reserving
  26. an I/O region on x86, to the rather more complex, like the hppa
  27. EISA code. This is the part to implement in order to have EISA
  28. running on an "new" platform.
  29. - The driver offers the bus a list of devices that it manages, and
  30. implements the necessary callbacks to probe and release devices
  31. whenever told to.
  32. Every function/structure below lives in <linux/eisa.h>, which depends
  33. heavily on <linux/device.h>.
  34. Bus root driver
  35. ===============
  36. ::
  37. int eisa_root_register (struct eisa_root_device *root);
  38. The eisa_root_register function is used to declare a device as the
  39. root of an EISA bus. The eisa_root_device structure holds a reference
  40. to this device, as well as some parameters for probing purposes::
  41. struct eisa_root_device {
  42. struct device *dev; /* Pointer to bridge device */
  43. struct resource *res;
  44. unsigned long bus_base_addr;
  45. int slots; /* Max slot number */
  46. int force_probe; /* Probe even when no slot 0 */
  47. u64 dma_mask; /* from bridge device */
  48. int bus_nr; /* Set by eisa_root_register */
  49. struct resource eisa_root_res; /* ditto */
  50. };
  51. ============= ======================================================
  52. node used for eisa_root_register internal purpose
  53. dev pointer to the root device
  54. res root device I/O resource
  55. bus_base_addr slot 0 address on this bus
  56. slots max slot number to probe
  57. force_probe Probe even when slot 0 is empty (no EISA mainboard)
  58. dma_mask Default DMA mask. Usually the bridge device dma_mask.
  59. bus_nr unique bus id, set by eisa_root_register
  60. ============= ======================================================
  61. Driver
  62. ======
  63. ::
  64. int eisa_driver_register (struct eisa_driver *edrv);
  65. void eisa_driver_unregister (struct eisa_driver *edrv);
  66. Clear enough ?
  67. ::
  68. struct eisa_device_id {
  69. char sig[EISA_SIG_LEN];
  70. unsigned long driver_data;
  71. };
  72. struct eisa_driver {
  73. const struct eisa_device_id *id_table;
  74. struct device_driver driver;
  75. };
  76. =============== ====================================================
  77. id_table an array of NULL terminated EISA id strings,
  78. followed by an empty string. Each string can
  79. optionally be paired with a driver-dependent value
  80. (driver_data).
  81. driver a generic driver, such as described in
  82. Documentation/driver-model/driver.txt. Only .name,
  83. .probe and .remove members are mandatory.
  84. =============== ====================================================
  85. An example is the 3c59x driver::
  86. static struct eisa_device_id vortex_eisa_ids[] = {
  87. { "TCM5920", EISA_3C592_OFFSET },
  88. { "TCM5970", EISA_3C597_OFFSET },
  89. { "" }
  90. };
  91. static struct eisa_driver vortex_eisa_driver = {
  92. .id_table = vortex_eisa_ids,
  93. .driver = {
  94. .name = "3c59x",
  95. .probe = vortex_eisa_probe,
  96. .remove = vortex_eisa_remove
  97. }
  98. };
  99. Device
  100. ======
  101. The sysfs framework calls .probe and .remove functions upon device
  102. discovery and removal (note that the .remove function is only called
  103. when driver is built as a module).
  104. Both functions are passed a pointer to a 'struct device', which is
  105. encapsulated in a 'struct eisa_device' described as follows::
  106. struct eisa_device {
  107. struct eisa_device_id id;
  108. int slot;
  109. int state;
  110. unsigned long base_addr;
  111. struct resource res[EISA_MAX_RESOURCES];
  112. u64 dma_mask;
  113. struct device dev; /* generic device */
  114. };
  115. ======== ============================================================
  116. id EISA id, as read from device. id.driver_data is set from the
  117. matching driver EISA id.
  118. slot slot number which the device was detected on
  119. state set of flags indicating the state of the device. Current
  120. flags are EISA_CONFIG_ENABLED and EISA_CONFIG_FORCED.
  121. res set of four 256 bytes I/O regions allocated to this device
  122. dma_mask DMA mask set from the parent device.
  123. dev generic device (see Documentation/driver-model/device.txt)
  124. ======== ============================================================
  125. You can get the 'struct eisa_device' from 'struct device' using the
  126. 'to_eisa_device' macro.
  127. Misc stuff
  128. ==========
  129. ::
  130. void eisa_set_drvdata (struct eisa_device *edev, void *data);
  131. Stores data into the device's driver_data area.
  132. ::
  133. void *eisa_get_drvdata (struct eisa_device *edev):
  134. Gets the pointer previously stored into the device's driver_data area.
  135. ::
  136. int eisa_get_region_index (void *addr);
  137. Returns the region number (0 <= x < EISA_MAX_RESOURCES) of a given
  138. address.
  139. Kernel parameters
  140. =================
  141. eisa_bus.enable_dev
  142. A comma-separated list of slots to be enabled, even if the firmware
  143. set the card as disabled. The driver must be able to properly
  144. initialize the device in such conditions.
  145. eisa_bus.disable_dev
  146. A comma-separated list of slots to be enabled, even if the firmware
  147. set the card as enabled. The driver won't be called to handle this
  148. device.
  149. virtual_root.force_probe
  150. Force the probing code to probe EISA slots even when it cannot find an
  151. EISA compliant mainboard (nothing appears on slot 0). Defaults to 0
  152. (don't force), and set to 1 (force probing) when either
  153. CONFIG_ALPHA_JENSEN or CONFIG_EISA_VLB_PRIMING are set.
  154. Random notes
  155. ============
  156. Converting an EISA driver to the new API mostly involves *deleting*
  157. code (since probing is now in the core EISA code). Unfortunately, most
  158. drivers share their probing routine between ISA, and EISA. Special
  159. care must be taken when ripping out the EISA code, so other busses
  160. won't suffer from these surgical strikes...
  161. You *must not* expect any EISA device to be detected when returning
  162. from eisa_driver_register, since the chances are that the bus has not
  163. yet been probed. In fact, that's what happens most of the time (the
  164. bus root driver usually kicks in rather late in the boot process).
  165. Unfortunately, most drivers are doing the probing by themselves, and
  166. expect to have explored the whole machine when they exit their probe
  167. routine.
  168. For example, switching your favorite EISA SCSI card to the "hotplug"
  169. model is "the right thing"(tm).
  170. Thanks
  171. ======
  172. I'd like to thank the following people for their help:
  173. - Xavier Benigni for lending me a wonderful Alpha Jensen,
  174. - James Bottomley, Jeff Garzik for getting this stuff into the kernel,
  175. - Andries Brouwer for contributing numerous EISA ids,
  176. - Catrin Jones for coping with far too many machines at home.