10 static struct eisa_driver eisa_drivers
[0]
11 __table_start ( struct eisa_driver
, eisa_drivers
);
12 static struct eisa_driver eisa_drivers_end
[0]
13 __table_end ( struct eisa_driver
, eisa_drivers
);
15 static void eisabus_remove ( struct root_device
*rootdev
);
18 * Reset and enable/disable an EISA device
21 * @v enabled 1=enable, 0=disable
23 void eisa_device_enabled ( struct eisa_device
*eisa
, int enabled
) {
24 /* Set reset line high for 1000 µs. Spec says 500 µs, but
25 * this doesn't work for all cards, so we are conservative.
27 outb ( EISA_CMD_RESET
, eisa
->ioaddr
+ EISA_GLOBAL_CONFIG
);
28 udelay ( 1000 ); /* Must wait 800 */
30 /* Set reset low and write a 1 to ENABLE. Delay again, in
31 * case the card takes a while to wake up.
33 outb ( enabled
? EISA_CMD_ENABLE
: 0,
34 eisa
->ioaddr
+ EISA_GLOBAL_CONFIG
);
35 udelay ( 1000 ); /* Must wait 800 */
37 DBG ( "EISA %s device %02x\n", ( enabled
? "enabled" : "disabled" ),
42 * Probe an EISA device
45 * @ret rc Return status code
47 * Searches for a driver for the EISA device. If a driver is found,
48 * its probe() routine is called.
50 static int eisa_probe ( struct eisa_device
*eisa
) {
51 struct eisa_driver
*driver
;
52 struct eisa_device_id
*id
;
56 DBG ( "Adding EISA device %02x (%04x:%04x (\"%s\") io %x)\n",
57 eisa
->slot
, eisa
->vendor_id
, eisa
->prod_id
,
58 isa_id_string ( eisa
->vendor_id
, eisa
->prod_id
), eisa
->ioaddr
);
60 for ( driver
= eisa_drivers
; driver
< eisa_drivers_end
; driver
++ ) {
61 for ( i
= 0 ; i
< driver
->id_count
; i
++ ) {
63 if ( id
->vendor_id
!= eisa
->vendor_id
)
65 if ( ISA_PROD_ID ( id
->prod_id
) !=
66 ISA_PROD_ID ( eisa
->prod_id
) )
68 eisa
->driver
= driver
;
69 eisa
->driver_name
= id
->name
;
70 DBG ( "...using driver %s\n", eisa
->driver_name
);
71 if ( ( rc
= driver
->probe ( eisa
, id
) ) != 0 ) {
72 DBG ( "......probe failed\n" );
79 DBG ( "...no driver found\n" );
84 * Remove an EISA device
88 static void eisa_remove ( struct eisa_device
*eisa
) {
89 eisa
->driver
->remove ( eisa
);
90 DBG ( "Removed EISA device %02x\n", eisa
->slot
);
96 * @v rootdev EISA bus root device
98 * Scans the EISA bus for devices and registers all devices it can
101 static int eisabus_probe ( struct root_device
*rootdev
) {
102 struct eisa_device
*eisa
= NULL
;
106 for ( slot
= EISA_MIN_SLOT
; slot
<= EISA_MAX_SLOT
; slot
++ ) {
107 /* Allocate struct eisa_device */
109 eisa
= malloc ( sizeof ( *eisa
) );
114 memset ( eisa
, 0, sizeof ( *eisa
) );
116 eisa
->ioaddr
= EISA_SLOT_BASE ( eisa
->slot
);
118 /* Test for board present */
119 outb ( 0xff, eisa
->ioaddr
+ EISA_VENDOR_ID
);
121 le16_to_cpu ( inw ( eisa
->ioaddr
+ EISA_VENDOR_ID
) );
123 le16_to_cpu ( inw ( eisa
->ioaddr
+ EISA_PROD_ID
) );
124 if ( eisa
->vendor_id
& 0x80 ) {
125 /* No board present */
129 /* Add to device hierarchy */
130 snprintf ( eisa
->dev
.name
, sizeof ( eisa
->dev
.name
),
132 eisa
->dev
.desc
.bus_type
= BUS_TYPE_EISA
;
133 eisa
->dev
.desc
.vendor
= eisa
->vendor_id
;
134 eisa
->dev
.desc
.device
= eisa
->prod_id
;
135 eisa
->dev
.parent
= &rootdev
->dev
;
136 list_add ( &eisa
->dev
.siblings
, &rootdev
->dev
.children
);
137 INIT_LIST_HEAD ( &eisa
->dev
.children
);
139 /* Look for a driver */
140 if ( eisa_probe ( eisa
) == 0 ) {
141 /* eisadev registered, we can drop our ref */
144 /* Not registered; re-use struct */
145 list_del ( &eisa
->dev
.siblings
);
154 eisabus_remove ( rootdev
);
159 * Remove EISA root bus
161 * @v rootdev EISA bus root device
163 static void eisabus_remove ( struct root_device
*rootdev
) {
164 struct eisa_device
*eisa
;
165 struct eisa_device
*tmp
;
167 list_for_each_entry_safe ( eisa
, tmp
, &rootdev
->dev
.children
,
169 eisa_remove ( eisa
);
170 list_del ( &eisa
->dev
.siblings
);
175 /** EISA bus root device driver */
176 static struct root_driver eisa_root_driver
= {
177 .probe
= eisabus_probe
,
178 .remove
= eisabus_remove
,
181 /** EISA bus root device */
182 struct root_device eisa_root_device __root_device
= {
183 .dev
= { .name
= "EISA" },
184 .driver
= &eisa_root_driver
,