[U-Boot] [PATCH v2 43/80] dm: usb: Bind generic USB devices when there is no driver
Simon Glass
sjg at chromium.org
Wed Mar 25 19:22:31 CET 2015
At present USB devices with no driver model driver cannot be seen in the
device list, and we fail to set them up correctly. This means they cannot
be used.
While having real drivers that support driver model for all USB devices
is the eventual goal, we are not there yet.
As a stop-gap, add a generic USB driver which is bound when we do not have
a real driver. This allows the device to be set up and shown on the bus.
It also allows ad-hoc code (such as usb_ether) to find these devices and
set them up.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2: None
drivers/usb/host/usb-uclass.c | 18 +++++++++++++++++-
include/dm/uclass-id.h | 1 +
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index a86e905..fa5f14e 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -384,7 +384,13 @@ static int usb_find_and_bind_driver(struct udevice *parent,
}
}
- ret = -ENOENT;
+ /* Bind a generic driver so that the device can be used */
+ snprintf(name, sizeof(name), "generic_bus_%x_dev_%x", bus_seq, devnum);
+ str = strdup(name);
+ if (!str)
+ return -ENOMEM;
+ ret = device_bind_driver(parent, "usb_dev_generic_drv", str, devp);
+
error:
debug("%s: No match found: %d\n", __func__, ret);
return ret;
@@ -592,3 +598,13 @@ UCLASS_DRIVER(usb) = {
.child_pre_probe = usb_child_pre_probe,
.per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata),
};
+
+UCLASS_DRIVER(usb_dev_generic) = {
+ .id = UCLASS_USB_DEV_GENERIC,
+ .name = "usb_dev_generic",
+};
+
+U_BOOT_DRIVER(usb_dev_generic_drv) = {
+ .id = UCLASS_USB_DEV_GENERIC,
+ .name = "usb_dev_generic_drv",
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index acec938..42a6f1f 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -41,6 +41,7 @@ enum uclass_id {
UCLASS_ETH, /* Ethernet device */
UCLASS_USB, /* USB bus */
UCLASS_USB_HUB, /* USB hub */
+ UCLASS_USB_DEV_GENERIC, /* USB generic device */
UCLASS_COUNT,
UCLASS_INVALID = -1,
--
2.2.0.rc0.207.ga3a616c
More information about the U-Boot
mailing list