8 * Increment a bus_loc structure to the next possible EISA location.
9 * Leave the structure zeroed and return 0 if there are no more valid
13 static int eisa_next_location ( struct bus_loc *bus_loc ) {
14 struct eisa_loc *eisa_loc = ( struct eisa_loc * ) bus_loc;
17 * Ensure that there is sufficient space in the shared bus
18 * structures for a struct isa_loc and a struct
19 * isa_dev, as mandated by bus.h.
22 BUS_LOC_CHECK ( struct eisa_loc );
23 BUS_DEV_CHECK ( struct eisa_device );
25 return ( eisa_loc->slot = ( ++eisa_loc->slot & EISA_MAX_SLOT ) );
29 * Fill in parameters for an EISA device based on slot number
31 * Return 1 if device present, 0 otherwise
34 static int eisa_fill_device ( struct bus_dev *bus_dev,
35 struct bus_loc *bus_loc ) {
36 struct eisa_loc *eisa_loc = ( struct eisa_loc * ) bus_loc;
37 struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
40 /* Copy slot number to struct eisa, set default values */
41 eisa->slot = eisa_loc->slot;
44 /* Slot 0 is never valid */
49 eisa->ioaddr = EISA_SLOT_BASE ( eisa->slot );
51 /* Test for board present */
52 outb ( 0xff, eisa->ioaddr + EISA_MFG_ID_HI );
53 present = inb ( eisa->ioaddr + EISA_MFG_ID_HI );
54 if ( present & 0x80 ) {
55 /* No board present */
59 /* Read mfg and product IDs. Yes, the resulting uint16_ts
60 * will be upside-down. This appears to be by design.
62 eisa->mfg_id = ( inb ( eisa->ioaddr + EISA_MFG_ID_LO ) << 8 )
64 eisa->prod_id = ( inb ( eisa->ioaddr + EISA_PROD_ID_LO ) << 8 )
65 + inb ( eisa->ioaddr + EISA_PROD_ID_HI );
67 DBG ( "EISA found slot %hhx (base %#hx) ID %hx:%hx (\"%s\")\n",
68 eisa->slot, eisa->ioaddr, eisa->mfg_id, eisa->prod_id,
69 isa_id_string ( eisa->mfg_id, eisa->prod_id ) );
75 * Test whether or not a driver is capable of driving the device.
78 static int eisa_check_driver ( struct bus_dev *bus_dev,
79 struct device_driver *device_driver ) {
80 struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
81 struct eisa_driver *driver
82 = ( struct eisa_driver * ) device_driver->bus_driver_info;
85 /* Compare against driver's ID list */
86 for ( i = 0 ; i < driver->id_count ; i++ ) {
87 struct eisa_id *id = &driver->ids[i];
89 if ( ( eisa->mfg_id == id->mfg_id ) &&
90 ( ISA_PROD_ID ( eisa->prod_id ) ==
91 ISA_PROD_ID ( id->prod_id ) ) ) {
92 DBG ( "EISA found ID %hx:%hx (\"%s\") "
93 "(device %s) matching driver %s\n",
94 eisa->mfg_id, eisa->prod_id,
95 isa_id_string ( eisa->mfg_id,
97 id->name, driver->name );
98 eisa->name = id->name;
103 /* No device found */
108 * Describe an EISA device
111 static char * eisa_describe_device ( struct bus_dev *bus_dev ) {
112 struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
113 static char eisa_description[] = "EISA 00";
115 sprintf ( eisa_description + 5, "%hhx", eisa->slot );
116 return eisa_description;
120 * Name an EISA device
123 static const char * eisa_name_device ( struct bus_dev *bus_dev ) {
124 struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
130 * EISA bus operations table
133 struct bus_driver eisa_driver __bus_driver = {
135 .next_location = eisa_next_location,
136 .fill_device = eisa_fill_device,
137 .check_driver = eisa_check_driver,
138 .describe_device = eisa_describe_device,
139 .name_device = eisa_name_device,
143 * Fill in a nic structure
146 void eisa_fill_nic ( struct nic *nic, struct eisa_device *eisa ) {
148 /* Fill in ioaddr and irqno */
149 nic->ioaddr = eisa->ioaddr;
152 /* Fill in DHCP device ID structure */
153 nic->dhcp_dev_id.bus_type = ISA_BUS_TYPE;
154 nic->dhcp_dev_id.vendor_id = htons ( eisa->mfg_id );
155 nic->dhcp_dev_id.device_id = htons ( eisa->prod_id );
159 * Reset and enable/disable an EISA device
162 void eisa_device_enabled ( struct eisa_device *eisa, int enabled ) {
163 /* Set reset line high for 1000 µs. Spec says 500 µs, but
164 * this doesn't work for all cards, so we are conservative.
166 outb ( EISA_CMD_RESET, eisa->ioaddr + EISA_GLOBAL_CONFIG );
167 udelay ( 1000 ); /* Must wait 800 */
169 /* Set reset low and write a 1 to ENABLE. Delay again, in
170 * case the card takes a while to wake up.
172 outb ( enabled ? EISA_CMD_ENABLE : 0,
173 eisa->ioaddr + EISA_GLOBAL_CONFIG );
174 udelay ( 1000 ); /* Must wait 800 */
176 DBG ( "EISA %s device %hhx\n", ( enabled ? "enabled" : "disabled" ),