4 * Abstracted from 3c509.c.
15 * Increment a bus_loc structure to the next possible MCA location.
16 * Leave the structure zeroed and return 0 if there are no more valid
20 static int mca_next_location ( struct bus_loc *bus_loc ) {
21 struct mca_loc *mca_loc = ( struct mca_loc * ) bus_loc;
24 * Ensure that there is sufficient space in the shared bus
25 * structures for a struct mca_loc and a struct
26 * mca_dev, as mandated by bus.h.
29 BUS_LOC_CHECK ( struct mca_loc );
30 BUS_DEV_CHECK ( struct mca_device );
32 return ( mca_loc->slot = ( ++mca_loc->slot & MCA_MAX_SLOT_NR ) );
36 * Fill in parameters for an MCA device based on slot number
39 static int mca_fill_device ( struct bus_dev *bus_dev,
40 struct bus_loc *bus_loc ) {
41 struct mca_loc *mca_loc = ( struct mca_loc * ) bus_loc;
42 struct mca_device *mca = ( struct mca_device * ) bus_dev;
43 unsigned int i, seen_non_ff;
45 /* Store slot in struct mca, set default values */
46 mca->slot = mca_loc->slot;
49 /* Make sure motherboard setup is off */
50 outb_p ( 0xff, MCA_MOTHERBOARD_SETUP_REG );
53 outb_p ( 0x8 | ( mca->slot & 0xf ), MCA_ADAPTER_SETUP_REG );
55 /* Read the POS registers */
57 for ( i = 0 ; i < ( sizeof ( mca->pos ) / sizeof ( mca->pos[0] ) ) ;
59 mca->pos[i] = inb_p ( MCA_POS_REG ( i ) );
60 if ( mca->pos[i] != 0xff )
64 /* If all POS registers are 0xff, this means there's no device
70 /* Kill all setup modes */
71 outb_p ( 0, MCA_ADAPTER_SETUP_REG );
73 DBG ( "MCA found slot %d id %hx "
74 "(POS %hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx)\n",
75 mca->slot, MCA_ID ( mca ),
76 mca->pos[0], mca->pos[1], mca->pos[2], mca->pos[3],
77 mca->pos[4], mca->pos[5], mca->pos[6], mca->pos[7] );
83 * Test whether or not a driver is capable of driving the device.
86 static int mca_check_driver ( struct bus_dev *bus_dev,
87 struct device_driver *device_driver ) {
88 struct mca_device *mca = ( struct mca_device * ) bus_dev;
89 struct mca_driver *driver
90 = ( struct mca_driver * ) device_driver->bus_driver_info;
93 /* Compare against driver's ID list */
94 for ( i = 0 ; i < driver->id_count ; i++ ) {
95 struct mca_id *id = &driver->ids[i];
97 if ( MCA_ID ( mca ) == id->id ) {
98 DBG ( "MCA found ID %hx (device %s) "
99 "matching driver %s\n",
100 id->name, id->id, device_driver->name );
101 mca->name = id->name;
106 /* No device found */
111 * Describe an MCA device
114 static char * mca_describe_device ( struct bus_dev *bus_dev ) {
115 struct mca_device *mca = ( struct mca_device * ) bus_dev;
116 static char mca_description[] = "MCA 00";
118 sprintf ( mca_description + 4, "%hhx", mca->slot );
119 return mca_description;
126 static const char * mca_name_device ( struct bus_dev *bus_dev ) {
127 struct mca_device *mca = ( struct mca_device * ) bus_dev;
133 * MCA bus operations table
136 struct bus_driver mca_driver __bus_driver = {
138 .next_location = mca_next_location,
139 .fill_device = mca_fill_device,
140 .check_driver = mca_check_driver,
141 .describe_device = mca_describe_device,
142 .name_device = mca_name_device,
146 * Fill in a nic structure
149 void mca_fill_nic ( struct nic *nic, struct mca_device *mca ) {
151 /* ioaddr and irqno must be read in a device-dependent way
152 * from the POS registers
157 /* Fill in DHCP device ID structure */
158 nic->dhcp_dev_id.bus_type = MCA_BUS_TYPE;
159 nic->dhcp_dev_id.vendor_id = htons ( GENERIC_MCA_VENDOR );
160 nic->dhcp_dev_id.device_id = htons ( MCA_ID ( mca ) );