summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--payloads/libpayload/drivers/usb/usb.c20
-rw-r--r--payloads/libpayload/include/usb/usb.h19
2 files changed, 39 insertions, 0 deletions
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);
+}
diff --git a/payloads/libpayload/include/usb/usb.h b/payloads/libpayload/include/usb/usb.h
index d862182148..d82ce2710f 100644
--- a/payloads/libpayload/include/usb/usb.h
+++ b/payloads/libpayload/include/usb/usb.h
@@ -238,6 +238,7 @@ void usb_nop_init (usbdev_t *dev);
void usb_hub_init (usbdev_t *dev);
void usb_hid_init (usbdev_t *dev);
void usb_msc_init (usbdev_t *dev);
+void usb_generic_init (usbdev_t *dev);
u8 *get_descriptor (usbdev_t *dev, unsigned char bmRequestType,
int descType, int descIdx, int langID);
@@ -276,4 +277,22 @@ static inline void usb_debug(const char *fmt, ...)
#endif
}
+/**
+ * To be implemented by libpayload-client. It's called by the USB stack
+ * when a new USB device is found which isn't claimed by a built in driver,
+ * so the client has the chance to know about it.
+ *
+ * @param dev descriptor for the USB device
+ */
+void __attribute__((weak)) usb_generic_create (usbdev_t *dev);
+
+/**
+ * To be implemented by libpayload-client. It's called by the USB stack
+ * when it finds out that a USB device is removed which wasn't claimed by a
+ * built in driver.
+ *
+ * @param dev descriptor for the USB device
+ */
+void __attribute__((weak)) usb_generic_remove (usbdev_t *dev);
+
#endif