9 * Increment a bus_loc structure to the next possible EISA location.
10 * Leave the structure zeroed and return 0 if there are no more valid
14 static int eisa_next_location ( struct bus_loc *bus_loc ) {
15 struct eisa_loc *eisa_loc = ( struct eisa_loc * ) bus_loc;
18 * Ensure that there is sufficient space in the shared bus
19 * structures for a struct isa_loc and a struct
20 * isa_dev, as mandated by bus.h.
23 BUS_LOC_CHECK ( struct eisa_loc );
24 BUS_DEV_CHECK ( struct eisa_device );
26 return ( eisa_loc->slot = ( ++eisa_loc->slot & EISA_MAX_SLOT ) );
30 * Fill in parameters for an EISA device based on slot number
32 * Return 1 if device present, 0 otherwise
35 static int eisa_fill_device ( struct bus_dev *bus_dev,
36 struct bus_loc *bus_loc ) {
37 struct eisa_loc *eisa_loc = ( struct eisa_loc * ) bus_loc;
38 struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
41 /* Copy slot number to struct eisa, set default values */
42 eisa->slot = eisa_loc->slot;
45 /* Slot 0 is never valid */
50 eisa->ioaddr = EISA_SLOT_BASE ( eisa->slot );
52 /* Test for board present */
53 outb ( 0xff, eisa->ioaddr + EISA_MFG_ID_HI );
54 present = inb ( eisa->ioaddr + EISA_MFG_ID_HI );
55 if ( present & 0x80 ) {
56 /* No board present */
60 /* Read mfg and product IDs. Yes, the resulting uint16_ts
61 * will be upside-down. This appears to be by design.
63 eisa->mfg_id = ( inb ( eisa->ioaddr + EISA_MFG_ID_LO ) << 8 )
65 eisa->prod_id = ( inb ( eisa->ioaddr + EISA_PROD_ID_LO ) << 8 )
66 + inb ( eisa->ioaddr + EISA_PROD_ID_HI );
68 DBG ( "EISA found slot %hhx (base %#hx) ID %hx:%hx (\"%s\")\n",
69 eisa->slot, eisa->ioaddr, eisa->mfg_id, eisa->prod_id,
70 isa_id_string ( eisa->mfg_id, eisa->prod_id ) );
76 * Test whether or not a driver is capable of driving the device.
79 static int eisa_check_driver ( struct bus_dev *bus_dev,
80 struct device_driver *device_driver ) {
81 struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
82 struct eisa_driver *driver
83 = ( struct eisa_driver * ) device_driver->bus_driver_info;
86 /* Compare against driver's ID list */
87 for ( i = 0 ; i < driver->id_count ; i++ ) {
88 struct eisa_id *id = &driver->ids[i];
90 if ( ( eisa->mfg_id == id->mfg_id ) &&
91 ( ISA_PROD_ID ( eisa->prod_id ) ==
92 ISA_PROD_ID ( id->prod_id ) ) ) {
93 DBG ( "EISA found ID %hx:%hx (\"%s\") "
94 "(device %s) matching driver %s\n",
95 eisa->mfg_id, eisa->prod_id,
96 isa_id_string ( eisa->mfg_id,
98 id->name, driver->name );
99 eisa->name = id->name;
104 /* No device found */
109 * Describe an EISA device
112 static char * eisa_describe_device ( struct bus_dev *bus_dev ) {
113 struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
114 static char eisa_description[] = "EISA 00";
116 sprintf ( eisa_description + 5, "%hhx", eisa->slot );
117 return eisa_description;
121 * Name an EISA device
124 static const char * eisa_name_device ( struct bus_dev *bus_dev ) {
125 struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
131 * EISA bus operations table
134 struct bus_driver eisa_driver __bus_driver = {
136 .next_location = eisa_next_location,
137 .fill_device = eisa_fill_device,
138 .check_driver = eisa_check_driver,
139 .describe_device = eisa_describe_device,
140 .name_device = eisa_name_device,
144 * Fill in a nic structure
147 void eisa_fill_nic ( struct nic *nic, struct eisa_device *eisa ) {
149 /* Fill in ioaddr and irqno */
150 nic->ioaddr = eisa->ioaddr;
153 /* Fill in DHCP device ID structure */
154 nic->dhcp_dev_id.bus_type = ISA_BUS_TYPE;
155 nic->dhcp_dev_id.vendor_id = htons ( eisa->mfg_id );
156 nic->dhcp_dev_id.device_id = htons ( eisa->prod_id );
160 * Reset and enable/disable an EISA device
163 void eisa_device_enabled ( struct eisa_device *eisa, int enabled ) {
164 /* Set reset line high for 1000 µs. Spec says 500 µs, but
165 * this doesn't work for all cards, so we are conservative.
167 outb ( EISA_CMD_RESET, eisa->ioaddr + EISA_GLOBAL_CONFIG );
168 udelay ( 1000 ); /* Must wait 800 */
170 /* Set reset low and write a 1 to ENABLE. Delay again, in
171 * case the card takes a while to wake up.
173 outb ( enabled ? EISA_CMD_ENABLE : 0,
174 eisa->ioaddr + EISA_GLOBAL_CONFIG );
175 udelay ( 1000 ); /* Must wait 800 */
177 DBG ( "EISA %s device %hhx\n", ( enabled ? "enabled" : "disabled" ),