2005-04-17 10:51:05 +00:00
|
|
|
|
#include "string.h"
|
2005-04-13 12:45:38 +00:00
|
|
|
|
#include "io.h"
|
|
|
|
|
#include "timer.h"
|
2005-04-22 02:28:16 +00:00
|
|
|
|
#include "console.h"
|
2006-06-05 15:41:22 +00:00
|
|
|
|
#include "dev.h"
|
2005-04-13 12:45:38 +00:00
|
|
|
|
#include "eisa.h"
|
|
|
|
|
|
2005-04-14 10:10:54 +00:00
|
|
|
|
/*
|
2005-04-22 02:28:16 +00:00
|
|
|
|
* Increment a bus_loc structure to the next possible EISA location.
|
|
|
|
|
* Leave the structure zeroed and return 0 if there are no more valid
|
|
|
|
|
* locations.
|
2005-04-14 10:10:54 +00:00
|
|
|
|
*
|
|
|
|
|
*/
|
2005-04-22 02:28:16 +00:00
|
|
|
|
static int eisa_next_location ( struct bus_loc *bus_loc ) {
|
|
|
|
|
struct eisa_loc *eisa_loc = ( struct eisa_loc * ) bus_loc;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Ensure that there is sufficient space in the shared bus
|
|
|
|
|
* structures for a struct isa_loc and a struct
|
|
|
|
|
* isa_dev, as mandated by bus.h.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
BUS_LOC_CHECK ( struct eisa_loc );
|
|
|
|
|
BUS_DEV_CHECK ( struct eisa_device );
|
|
|
|
|
|
2005-04-22 15:33:35 +00:00
|
|
|
|
return ( eisa_loc->slot = ( ++eisa_loc->slot & EISA_MAX_SLOT ) );
|
2005-04-22 02:28:16 +00:00
|
|
|
|
}
|
2005-04-14 10:10:54 +00:00
|
|
|
|
|
2005-04-13 12:45:38 +00:00
|
|
|
|
/*
|
|
|
|
|
* Fill in parameters for an EISA device based on slot number
|
|
|
|
|
*
|
|
|
|
|
* Return 1 if device present, 0 otherwise
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-04-22 02:28:16 +00:00
|
|
|
|
static int eisa_fill_device ( struct bus_dev *bus_dev,
|
|
|
|
|
struct bus_loc *bus_loc ) {
|
|
|
|
|
struct eisa_loc *eisa_loc = ( struct eisa_loc * ) bus_loc;
|
|
|
|
|
struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
|
2005-04-13 12:45:38 +00:00
|
|
|
|
uint8_t present;
|
|
|
|
|
|
2005-04-22 02:28:16 +00:00
|
|
|
|
/* Copy slot number to struct eisa, set default values */
|
|
|
|
|
eisa->slot = eisa_loc->slot;
|
|
|
|
|
eisa->name = "?";
|
|
|
|
|
|
|
|
|
|
/* Slot 0 is never valid */
|
|
|
|
|
if ( ! eisa->slot )
|
|
|
|
|
return 0;
|
|
|
|
|
|
2005-04-13 12:45:38 +00:00
|
|
|
|
/* Set ioaddr */
|
|
|
|
|
eisa->ioaddr = EISA_SLOT_BASE ( eisa->slot );
|
|
|
|
|
|
|
|
|
|
/* Test for board present */
|
|
|
|
|
outb ( 0xff, eisa->ioaddr + EISA_MFG_ID_HI );
|
|
|
|
|
present = inb ( eisa->ioaddr + EISA_MFG_ID_HI );
|
|
|
|
|
if ( present & 0x80 ) {
|
|
|
|
|
/* No board present */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read mfg and product IDs. Yes, the resulting uint16_ts
|
|
|
|
|
* will be upside-down. This appears to be by design.
|
|
|
|
|
*/
|
|
|
|
|
eisa->mfg_id = ( inb ( eisa->ioaddr + EISA_MFG_ID_LO ) << 8 )
|
|
|
|
|
+ present;
|
|
|
|
|
eisa->prod_id = ( inb ( eisa->ioaddr + EISA_PROD_ID_LO ) << 8 )
|
|
|
|
|
+ inb ( eisa->ioaddr + EISA_PROD_ID_HI );
|
|
|
|
|
|
2005-04-22 02:28:16 +00:00
|
|
|
|
DBG ( "EISA found slot %hhx (base %#hx) ID %hx:%hx (\"%s\")\n",
|
2005-04-13 12:45:38 +00:00
|
|
|
|
eisa->slot, eisa->ioaddr, eisa->mfg_id, eisa->prod_id,
|
|
|
|
|
isa_id_string ( eisa->mfg_id, eisa->prod_id ) );
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2005-04-22 02:28:16 +00:00
|
|
|
|
* Test whether or not a driver is capable of driving the device.
|
2005-04-13 12:45:38 +00:00
|
|
|
|
*
|
|
|
|
|
*/
|
2005-04-22 02:28:16 +00:00
|
|
|
|
static int eisa_check_driver ( struct bus_dev *bus_dev,
|
|
|
|
|
struct device_driver *device_driver ) {
|
|
|
|
|
struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
|
|
|
|
|
struct eisa_driver *driver
|
|
|
|
|
= ( struct eisa_driver * ) device_driver->bus_driver_info;
|
2005-04-14 13:44:07 +00:00
|
|
|
|
unsigned int i;
|
2005-04-13 12:45:38 +00:00
|
|
|
|
|
2005-04-22 02:28:16 +00:00
|
|
|
|
/* Compare against driver's ID list */
|
|
|
|
|
for ( i = 0 ; i < driver->id_count ; i++ ) {
|
|
|
|
|
struct eisa_id *id = &driver->ids[i];
|
|
|
|
|
|
|
|
|
|
if ( ( eisa->mfg_id == id->mfg_id ) &&
|
|
|
|
|
( ISA_PROD_ID ( eisa->prod_id ) ==
|
|
|
|
|
ISA_PROD_ID ( id->prod_id ) ) ) {
|
|
|
|
|
DBG ( "EISA found ID %hx:%hx (\"%s\") "
|
|
|
|
|
"(device %s) matching driver %s\n",
|
|
|
|
|
eisa->mfg_id, eisa->prod_id,
|
|
|
|
|
isa_id_string ( eisa->mfg_id,
|
|
|
|
|
eisa->prod_id ),
|
|
|
|
|
id->name, driver->name );
|
|
|
|
|
eisa->name = id->name;
|
|
|
|
|
return 1;
|
2005-04-13 12:45:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* No device found */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-14 13:44:07 +00:00
|
|
|
|
/*
|
2005-04-22 02:28:16 +00:00
|
|
|
|
* Describe an EISA device
|
2005-04-14 13:44:07 +00:00
|
|
|
|
*
|
|
|
|
|
*/
|
2005-04-25 18:54:15 +00:00
|
|
|
|
static char * eisa_describe_device ( struct bus_dev *bus_dev ) {
|
2005-04-22 02:28:16 +00:00
|
|
|
|
struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
|
|
|
|
|
static char eisa_description[] = "EISA 00";
|
2005-04-14 13:44:07 +00:00
|
|
|
|
|
2005-04-22 02:28:16 +00:00
|
|
|
|
sprintf ( eisa_description + 5, "%hhx", eisa->slot );
|
|
|
|
|
return eisa_description;
|
|
|
|
|
}
|
2005-04-14 13:44:07 +00:00
|
|
|
|
|
2005-04-22 02:28:16 +00:00
|
|
|
|
/*
|
|
|
|
|
* Name an EISA device
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-04-25 18:54:15 +00:00
|
|
|
|
static const char * eisa_name_device ( struct bus_dev *bus_dev ) {
|
2005-04-22 02:28:16 +00:00
|
|
|
|
struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
|
|
|
|
|
|
|
|
|
|
return eisa->name;
|
|
|
|
|
}
|
2005-04-14 13:44:07 +00:00
|
|
|
|
|
2005-04-22 02:28:16 +00:00
|
|
|
|
/*
|
|
|
|
|
* EISA bus operations table
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
struct bus_driver eisa_driver __bus_driver = {
|
2005-04-25 18:54:15 +00:00
|
|
|
|
.name = "EISA",
|
|
|
|
|
.next_location = eisa_next_location,
|
|
|
|
|
.fill_device = eisa_fill_device,
|
|
|
|
|
.check_driver = eisa_check_driver,
|
|
|
|
|
.describe_device = eisa_describe_device,
|
|
|
|
|
.name_device = eisa_name_device,
|
2005-04-22 02:28:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Fill in a nic structure
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void eisa_fill_nic ( struct nic *nic, struct eisa_device *eisa ) {
|
|
|
|
|
|
|
|
|
|
/* Fill in ioaddr and irqno */
|
|
|
|
|
nic->ioaddr = eisa->ioaddr;
|
|
|
|
|
nic->irqno = 0;
|
|
|
|
|
|
|
|
|
|
/* Fill in DHCP device ID structure */
|
|
|
|
|
nic->dhcp_dev_id.bus_type = ISA_BUS_TYPE;
|
|
|
|
|
nic->dhcp_dev_id.vendor_id = htons ( eisa->mfg_id );
|
|
|
|
|
nic->dhcp_dev_id.device_id = htons ( eisa->prod_id );
|
2005-04-14 13:44:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-13 12:45:38 +00:00
|
|
|
|
/*
|
2005-04-22 02:43:24 +00:00
|
|
|
|
* Reset and enable/disable an EISA device
|
2005-04-13 12:45:38 +00:00
|
|
|
|
*
|
|
|
|
|
*/
|
2005-04-22 02:43:24 +00:00
|
|
|
|
void eisa_device_enabled ( struct eisa_device *eisa, int enabled ) {
|
2005-04-13 12:45:38 +00:00
|
|
|
|
/* Set reset line high for 1000 <20>s. Spec says 500 <20>s, but
|
|
|
|
|
* this doesn't work for all cards, so we are conservative.
|
|
|
|
|
*/
|
|
|
|
|
outb ( EISA_CMD_RESET, eisa->ioaddr + EISA_GLOBAL_CONFIG );
|
|
|
|
|
udelay ( 1000 ); /* Must wait 800 */
|
|
|
|
|
|
|
|
|
|
/* Set reset low and write a 1 to ENABLE. Delay again, in
|
|
|
|
|
* case the card takes a while to wake up.
|
|
|
|
|
*/
|
2005-04-22 02:43:24 +00:00
|
|
|
|
outb ( enabled ? EISA_CMD_ENABLE : 0,
|
|
|
|
|
eisa->ioaddr + EISA_GLOBAL_CONFIG );
|
2005-04-13 12:45:38 +00:00
|
|
|
|
udelay ( 1000 ); /* Must wait 800 */
|
2005-04-22 15:56:57 +00:00
|
|
|
|
|
|
|
|
|
DBG ( "EISA %s device %hhx\n", ( enabled ? "enabled" : "disabled" ),
|
|
|
|
|
eisa->slot );
|
2005-04-13 12:45:38 +00:00
|
|
|
|
}
|