dm: usb: Bind generic USB devices when there is no driver
authorSimon Glass <sjg@chromium.org>
Wed, 25 Mar 2015 18:22:31 +0000 (12:22 -0600)
committerSimon Glass <sjg@chromium.org>
Sat, 18 Apr 2015 17:11:25 +0000 (11:11 -0600)
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@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
drivers/usb/host/usb-uclass.c
include/dm/uclass-id.h

index a86e905b487d74c149c48f8cf5008233d2c515f4..fa5f14e7e27a9d8ad83ce31c6e135dd6c1a28dc5 100644 (file)
@@ -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",
+};
index 967efec8c4bc7cafa5f3a0e54703db2fd2042488..6fe366996860ca8744db415fe598548f12eb081c 100644 (file)
@@ -42,6 +42,7 @@ enum uclass_id {
        UCLASS_LPC,             /* x86 'low pin count' interface */
        UCLASS_USB,             /* USB bus */
        UCLASS_USB_HUB,         /* USB hub */
+       UCLASS_USB_DEV_GENERIC, /* USB generic device */
 
        UCLASS_COUNT,
        UCLASS_INVALID = -1,