usb probing again

usbnet initial support
This commit is contained in:
Sergey Bolshakov 2005-02-07 17:55:26 +00:00
parent 74b6fa7a73
commit a8abfdd837

View File

@ -187,20 +187,15 @@ static void pci_probe(enum driver_type type)
int that_class;
switch (type) {
#ifndef DISABLE_MEDIAS
case SCSI_ADAPTERS:
that_class = PCI_CLASS_STORAGE_SCSI << 8;
break;
#endif
#ifndef DISABLE_NETWORK
case NETWORK_DEVICES:
that_class = PCI_CLASS_NETWORK_ETHERNET << 8;
break;
#endif
case USB_CONTROLLERS:
that_class = PCI_CLASS_SERIAL_USB << 8;
break;
default:
return;
}
@ -216,7 +211,7 @@ static void pci_probe(enum driver_type type)
}
while (NULL != fgets(buf, sizeof(buf), f)) {
int i, dfn, vendor, device, class, subv, subid;
int i, matched, dfn, vendor, device, class, subv, subid;
struct pci_module_map * pcidb;
sscanf(buf, "%x %x", &dfn, &vendor);
@ -237,13 +232,15 @@ static void pci_probe(enum driver_type type)
subv = devdata[0x2c] | (devdata[0x2d] << 8);
subid = devdata[0x2e] | (devdata[0x2f] << 8);
if (that_class != (class & 0xffff00)) continue;
log_message("found pci device: %04x %04x %06x %04x %04x",
vendor, device, class, subv, subid);
for (pcidb = pci_ids; pcidb; pcidb = pcidb->next) {
if (that_class == (class & 0xffff00) &&
pcidb->vendor == vendor && pcidb->device == device) {
log_message("module is \"%s\"", pcidb->module);
for (matched = 0, pcidb = pci_ids; pcidb; pcidb = pcidb->next) {
if (pcidb->vendor == vendor && pcidb->device == device) {
/* vendor & device matched */
log_message("(pcimap) module is \"%s\"", pcidb->module);
#ifndef DISABLE_MEDIAS
if (type == SCSI_ADAPTERS) {
int wait_msg = 0;
@ -272,34 +269,35 @@ static void pci_probe(enum driver_type type)
/* found explicitly declared module */
for (i=0; i < HCD_NUM; i++) {
if(ptr_begins_static_str(pcidb->module, usb_hcd[i])) {
log_message("found explicit %s", usb_hcd[i]);
need_usb_hcd[i] = 1;
break;
}
}
}
} /* vendor & device matched */
else {
/* no module found, trying to identify one by class:
HCD: PCI Class:
uhci-hcd 0x000c0300
ohci-hcd 0x000c0310
ehci-hcd 0x000c0320
*/
if (type == USB_CONTROLLERS && (class & 0xffff0f) == 0x0c0300) {
log_message("found by class %s", usb_hcd[(class & 0xf0)>>4]);
need_usb_hcd[(class & 0xf0)>>4] = 1;
}
matched = 1;
break;
}
} /* end of this vendor & device */
} /* end of pci device list */
} /* end of pcidb table */
if (!matched && type == USB_CONTROLLERS && (class & 0xffff0f) == 0x0c0300) {
/* no module found, trying to identify one by class:
HCD: PCI Class:
uhci-hcd 0x000c0300
ohci-hcd 0x000c0310
ehci-hcd 0x000c0320
*/
log_message("(guess) module is \"%s\"", usb_hcd[(class & 0xf0)>>4]);
need_usb_hcd[(class & 0xf0)>>4] = 1;
}
} /* end of this vendor & device */
fclose(f);
/* load all usb controller modules now, starting from possible ehci-hcd */
/* to prevent case when old-timed module sitting on newer host controller */
if (type == USB_CONTROLLERS) {
for (n=HCD_NUM-1; n; n--) {
for (n=HCD_NUM-1; n >= 0; n--) {
if (need_usb_hcd[n]) {
stg1_info_message("About to load driver for usb controller: %s", usb_hcd[n]);
my_insmod(usb_hcd[n], USB_CONTROLLERS, NULL);
@ -351,12 +349,19 @@ static void usb_probe(enum driver_type type)
remove_wait_message();
}
/* dirty hack */
/* dirty hacks */
if (type == SCSI_ADAPTERS) {
stg1_info_message("About to load driver for usb storage device: usb-storage");
my_insmod("usb-storage", ANY_DRIVER_TYPE, NULL);
}
#ifdef ENABLE_USBNET
if (type == NETWORK_DEVICES) {
stg1_info_message("About to load driver for usb network device: usbnet");
my_insmod("usbnet", ANY_DRIVER_TYPE, NULL);
}
#endif
if (!(f = fopen("/proc/bus/usb/devices", "rb"))) {
log_message("USB: could not open proc file");
return;