EISA bus support¶
| Author: | Marc Zyngier <maz@wild-wind.fr.eu.org> |
|---|
This document groups random notes about porting EISA drivers to thenew EISA/sysfs API.
Starting from version 2.5.59, the EISA bus is almost given the samestatus as other much more mainstream busses such as PCI or USB. Thishas been possible through sysfs, which defines a nice enough set ofabstractions to manage busses, devices and drivers.
Although the new API is quite simple to use, converting existingdrivers to the new infrastructure is not an easy task (mostly becausedetection code is generally also used to probe ISA cards). Moreover,most EISA drivers are among the oldest Linux drivers so, as you canimagine, some dust has settled here over the years.
The EISA infrastructure is made up of three parts:
- The bus code implements most of the generic code. It is sharedamong all the architectures that the EISA code runs on. Itimplements bus probing (detecting EISA cards available on the bus),allocates I/O resources, allows fancy naming through sysfs, andoffers interfaces for driver to register.
- The bus root driver implements the glue between the bus hardwareand the generic bus code. It is responsible for discovering thedevice implementing the bus, and setting it up to be latter probedby the bus code. This can go from something as simple as reservingan I/O region on x86, to the rather more complex, like the hppaEISA code. This is the part to implement in order to have EISArunning on an “new” platform.
- The driver offers the bus a list of devices that it manages, andimplements the necessary callbacks to probe and release deviceswhenever told to.
Every function/structure below lives in <linux/eisa.h>, which dependsheavily on <linux/device.h>.
Bus root driver¶
int eisa_root_register (struct eisa_root_device *root);
The eisa_root_register function is used to declare a device as theroot of an EISA bus. The eisa_root_device structure holds a referenceto this device, as well as some parameters for probing purposes:
struct eisa_root_device { struct device *dev; /* Pointer to bridge device */ struct resource *res; unsigned long bus_base_addr; int slots; /* Max slot number */ int force_probe; /* Probe even when no slot 0 */ u64 dma_mask; /* from bridge device */ int bus_nr; /* Set by eisa_root_register */ struct resource eisa_root_res; /* ditto */};| node | used for eisa_root_register internal purpose |
| dev | pointer to the root device |
| res | root device I/O resource |
| bus_base_addr | slot 0 address on this bus |
| slots | max slot number to probe |
| force_probe | Probe even when slot 0 is empty (no EISA mainboard) |
| dma_mask | Default DMA mask. Usually the bridge device dma_mask. |
| bus_nr | unique bus id, set by eisa_root_register |
Driver¶
int eisa_driver_register (struct eisa_driver *edrv);void eisa_driver_unregister (struct eisa_driver *edrv);
Clear enough ?
struct eisa_device_id { char sig[EISA_SIG_LEN]; unsigned long driver_data;};struct eisa_driver { const struct eisa_device_id *id_table; struct device_driver driver;};| id_table | an array of NULL terminated EISA id strings,followed by an empty string. Each string canoptionally be paired with a driver-dependent value(driver_data). |
| driver | a generic driver, such as described inDocumentation/driver-api/driver-model/driver.rst. Only .name,.probe and .remove members are mandatory. |
An example is the 3c59x driver:
static struct eisa_device_id vortex_eisa_ids[] = { { "TCM5920", EISA_3C592_OFFSET }, { "TCM5970", EISA_3C597_OFFSET }, { "" }};static struct eisa_driver vortex_eisa_driver = { .id_table = vortex_eisa_ids, .driver = { .name = "3c59x", .probe = vortex_eisa_probe, .remove = vortex_eisa_remove }};Device¶
The sysfs framework calls .probe and .remove functions upon devicediscovery and removal (note that the .remove function is only calledwhen driver is built as a module).
Both functions are passed a pointer to a ‘struct device’, which isencapsulated in a ‘struct eisa_device’ described as follows:
struct eisa_device { struct eisa_device_id id; int slot; int state; unsigned long base_addr; struct resource res[EISA_MAX_RESOURCES]; u64 dma_mask; struct device dev; /* generic device */};| id | EISA id, as read from device. id.driver_data is set from thematching driver EISA id. |
| slot | slot number which the device was detected on |
| state | set of flags indicating the state of the device. Currentflags are EISA_CONFIG_ENABLED and EISA_CONFIG_FORCED. |
| res | set of four 256 bytes I/O regions allocated to this device |
| dma_mask | DMA mask set from the parent device. |
| dev | generic device (see Documentation/driver-api/driver-model/device.rst) |
You can get the ‘struct eisa_device’ from ‘struct device’ using the‘to_eisa_device’ macro.
Misc stuff¶
void eisa_set_drvdata (struct eisa_device *edev, void *data);
Stores data into the device’s driver_data area.
void *eisa_get_drvdata (struct eisa_device *edev):
Gets the pointer previously stored into the device’s driver_data area.
int eisa_get_region_index (void *addr);
Returns the region number (0 <= x < EISA_MAX_RESOURCES) of a givenaddress.
Kernel parameters¶
- eisa_bus.enable_dev
- A comma-separated list of slots to be enabled, even if the firmwareset the card as disabled. The driver must be able to properlyinitialize the device in such conditions.
- eisa_bus.disable_dev
- A comma-separated list of slots to be enabled, even if the firmwareset the card as enabled. The driver won’t be called to handle thisdevice.
- virtual_root.force_probe
- Force the probing code to probe EISA slots even when it cannot find anEISA compliant mainboard (nothing appears on slot 0). Defaults to 0(don’t force), and set to 1 (force probing) when eitherCONFIG_ALPHA_JENSEN or CONFIG_EISA_VLB_PRIMING are set.
Random notes¶
Converting an EISA driver to the new API mostly involvesdeletingcode (since probing is now in the core EISA code). Unfortunately, mostdrivers share their probing routine between ISA, and EISA. Specialcare must be taken when ripping out the EISA code, so other busseswon’t suffer from these surgical strikes…
Youmust not expect any EISA device to be detected when returningfrom eisa_driver_register, since the chances are that the bus has notyet been probed. In fact, that’s what happens most of the time (thebus root driver usually kicks in rather late in the boot process).Unfortunately, most drivers are doing the probing by themselves, andexpect to have explored the whole machine when they exit their proberoutine.
For example, switching your favorite EISA SCSI card to the “hotplug”model is “the right thing”(tm).
Thanks¶
I’d like to thank the following people for their help:
- Xavier Benigni for lending me a wonderful Alpha Jensen,
- James Bottomley, Jeff Garzik for getting this stuff into the kernel,
- Andries Brouwer for contributing numerous EISA ids,
- Catrin Jones for coping with far too many machines at home.