*
* The ISA probe address list can be overridden by config.h; if the
* user specifies ISA_PROBE_ADDRS then that list will be used first.
- * (If ISA_PROBE_ADDRS ends with a zero, the driver's own list will
- * never be used).
+ * (If ISA_PROBE_ONLY is defined, the driver's own list will never be
+ * used).
*/
/*
( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )
#ifdef ISA_PROBE_ONLY
-# define ISA_PROBE_IDX_LIMIT isa_extra_probe_addr_count
+#define ISA_PROBE_ADDR_COUNT(driver) ( isa_extra_probe_addr_count )
#else
-# define ISA_PROBE_IDX_LIMIT ( ISA_MAX_PROBE_IDX + 1 )
+#define ISA_PROBE_ADDR_COUNT(driver) \
+ ( isa_extra_probe_addr_count + (driver)->addr_count )
#endif
+/*
+ * Symbols defined by linker
+ *
+ */
+extern struct isa_driver isa_drivers[];
+extern struct isa_driver isa_drivers_end[];
+
/*
* Increment a bus_loc structure to the next possible ISA location.
* Leave the structure zeroed and return 0 if there are no more valid
* locations.
*
+ * There is no sensible concept of a device location on an ISA bus, so
+ * we use the probe address list for each ISA driver to define the
+ * list of ISA locations.
+ *
*/
static int isa_next_location ( struct bus_loc *bus_loc ) {
struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
-
+ struct isa_driver *driver;
+
/*
* Ensure that there is sufficient space in the shared bus
* structures for a struct isa_loc and a struct
BUS_LOC_CHECK ( struct isa_loc );
BUS_DEV_CHECK ( struct isa_device );
- return ( ( ++isa_loc->probe_idx < ISA_PROBE_IDX_LIMIT ) ?
- 1 : ( isa_loc->probe_idx = 0 ) );
+ /* Move to next probe address within this driver */
+ driver = &isa_drivers[isa_loc->driver];
+ if ( ++isa_loc->probe_idx < ISA_PROBE_ADDR_COUNT ( driver ) )
+ return 1;
+
+ /* Move to next driver */
+ isa_loc->probe_idx = 0;
+ if ( ( ++isa_loc->driver, ++driver ) < isa_drivers_end )
+ return 1;
+
+ isa_loc->driver = 0;
+ return 0;
}
/*
struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
struct isa_device *isa = ( struct isa_device * ) bus_dev;
signed int driver_probe_idx;
-
+
+ /* Fill in struct isa from struct isa_loc */
+ isa->driver = &isa_drivers[isa_loc->driver];
driver_probe_idx = isa_loc->probe_idx - isa_extra_probe_addr_count;
if ( driver_probe_idx < 0 ) {
isa->ioaddr = isa_extra_probe_addrs[isa_loc->probe_idx];
} else {
- isa->ioaddr = 0;
- isa->driver_probe_idx = driver_probe_idx;
+ isa->ioaddr = isa->driver->probe_addrs[driver_probe_idx];
+ }
+
+ /* Call driver's probe_addr method to determine if a device is
+ * physically present
+ */
+ if ( isa->driver->probe_addr ( isa->ioaddr ) ) {
+ isa->name = isa->driver->name;
+ isa->mfg_id = isa->driver->mfg_id;
+ isa->prod_id = isa->driver->prod_id;
+ DBG ( "ISA found %s device at address %hx\n",
+ isa->name, isa->ioaddr );
+ return 1;
}
- isa->mfg_id = isa->prod_id = 0;
- isa->name = "?";
- return 1;
+
+ return 0;
}
/*
struct isa_driver *driver
= ( struct isa_driver * ) device_driver->bus_driver_info;
- /* If ioaddr is zero, it means we're using a driver-specified
- * ioaddr
- */
- if ( ! isa->ioaddr ) {
- if ( isa->driver_probe_idx >= driver->addr_count )
- return 0;
- isa->ioaddr = driver->probe_addrs[isa->driver_probe_idx];
- }
-
- /* Use probe_addr method to see if there's a device
- * present at this address.
- */
- if ( driver->probe_addr ( isa->ioaddr ) ) {
- DBG ( "ISA found %s device at address %hx\n",
- driver->name, isa->ioaddr );
- isa->name = driver->name;
- isa->mfg_id = driver->mfg_id;
- isa->prod_id = driver->prod_id;
- return 1;
- }
-
- /* No device found */
- return 0;
+ return ( driver == isa->driver );
}
/*
*/
static char * isa_describe_device ( struct bus_dev *bus_dev ) {
struct isa_device *isa = ( struct isa_device * ) bus_dev;
- static char isa_description[] = "ISA 0000";
+ static char isa_description[] = "ISA 0000 (00)";
- sprintf ( isa_description + 4, "%hx", isa->ioaddr );
+ sprintf ( isa_description + 4, "%hx (%hhx)", isa->ioaddr,
+ isa->driver - isa_drivers );
return isa_description;
}
* A location on an ISA bus
*
*/
+struct isa_driver;
struct isa_loc {
+ unsigned int driver;
unsigned int probe_idx;
};
-#define ISA_MAX_PROBE_IDX 255 /* Unlikely to ever be more than ~20 */
/*
* A physical ISA device
*/
struct isa_device {
const char *name;
- unsigned int driver_probe_idx;
+ struct isa_driver *driver;
uint16_t ioaddr;
uint16_t mfg_id;
uint16_t prod_id;
uint16_t mfg_id;
uint16_t prod_id;
};
+#define __isa_driver __attribute__ (( section ( ".drivers.isa" ) ))
/*
* Define an ISA driver
*
*/
-#define ISA_DRIVER( _probe_addrs, _probe_addr, _mfg_id, _prod_id ) { \
+#define ISA_DRIVER( _name, _probe_addrs, _probe_addr, _mfg_id, _prod_id ) \
+static struct isa_driver _name __isa_driver = { \
.probe_addrs = _probe_addrs, \
.addr_count = sizeof ( _probe_addrs ) / sizeof ( _probe_addrs[0] ), \
.probe_addr = _probe_addr, \