From dc9e77f45135452166cdd9fb96c2234753febed6 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 1 Feb 2013 20:19:27 -0800 Subject: libpayload: Add usb_generic_(create|remove) functions for unrecognized devices It might be useful to provide a USB driver in the payload itself instead of in libpayload. For example there are multiple payloads being built and linked against the same libpayload, and they might not need or even want to have the same set of drivers installed. This change adds two new functions, usb_generic_create and usb_generic_remove, which behave like the usbdisk_create and usbdisk_remove functions which are defined for USB mass storage devices. If a USB device isn't recognized and claimed by one of the built in USB class drivers (currently hub, hid, and msc) and the create function is defined, then it will be called to give the payload a chance to use the device. Once it's removed, if usb_generic_remove is defined it will be called, effectively giving the payload notice. Built and booted depthcharge on Link. Built depthcharge for Daisy. Built a netbooting payload, called usb_poll() with those functions implemented, and verified that they were called and that the devices they were told about were reasonable and the same as what was reported by lsusb in the booted system. Change-Id: Ief7c0a513b60849fbf2986ef4ae5c9e7825fef16 Signed-off-by: Gabe Black Reviewed-on: http://review.coreboot.org/2666 Tested-by: build bot (Jenkins) Reviewed-by: Kimarie Hoot Reviewed-by: Ronald G. Minnich --- payloads/libpayload/drivers/usb/usb.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'payloads/libpayload/drivers/usb') diff --git a/payloads/libpayload/drivers/usb/usb.c b/payloads/libpayload/drivers/usb/usb.c index ff67e0c5cd..0448d38ad8 100644 --- a/payloads/libpayload/drivers/usb/usb.c +++ b/payloads/libpayload/drivers/usb/usb.c @@ -402,6 +402,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr) usb_debug ("HID\n"); #ifdef CONFIG_USB_HID controller->devices[adr]->init = usb_hid_init; + return adr; #else usb_debug ("NOTICE: USB HID support not compiled in\n"); #endif @@ -419,6 +420,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr) usb_debug ("MSC\n"); #ifdef CONFIG_USB_MSC controller->devices[adr]->init = usb_msc_init; + return adr; #else usb_debug ("NOTICE: USB MSC support not compiled in\n"); #endif @@ -427,6 +429,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr) usb_debug ("hub\n"); #ifdef CONFIG_USB_HUB controller->devices[adr]->init = usb_hub_init; + return adr; #else usb_debug ("NOTICE: USB hub support not compiled in.\n"); #endif @@ -456,6 +459,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr) usb_debug("unsupported class %x\n", class); break; } + controller->devices[adr]->init = usb_generic_init; return adr; } @@ -491,3 +495,19 @@ usb_attach_device(hci_t *controller, int hubaddress, int port, int speed) return controller->devices[newdev] ? newdev : -1; } +static void +usb_generic_destroy (usbdev_t *dev) +{ + if (usb_generic_remove) + usb_generic_remove(dev); +} + +void +usb_generic_init (usbdev_t *dev) +{ + dev->data = NULL; + dev->destroy = usb_generic_destroy; + + if (usb_generic_create) + usb_generic_create(dev); +} -- cgit v1.2.3