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