Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2015 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
| 5 | * |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 6 | * usb_match_device() modified from Linux kernel v4.0. |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <dm.h> |
| 11 | #include <errno.h> |
Simon Glass | 2dd337a | 2015-09-02 17:24:58 -0600 | [diff] [blame] | 12 | #include <memalign.h> |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 13 | #include <usb.h> |
| 14 | #include <dm/device-internal.h> |
| 15 | #include <dm/lists.h> |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 16 | #include <dm/uclass-internal.h> |
| 17 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 18 | extern bool usb_started; /* flag for the started/stopped USB status */ |
| 19 | static bool asynch_allowed; |
| 20 | |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 21 | struct usb_uclass_priv { |
| 22 | int companion_device_count; |
| 23 | }; |
| 24 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 25 | int usb_disable_asynch(int disable) |
| 26 | { |
| 27 | int old_value = asynch_allowed; |
| 28 | |
| 29 | asynch_allowed = !disable; |
| 30 | return old_value; |
| 31 | } |
| 32 | |
| 33 | int submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, |
Michal Suchanek | 1c95b9f | 2019-08-18 10:55:27 +0200 | [diff] [blame] | 34 | int length, int interval, bool nonblock) |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 35 | { |
| 36 | struct udevice *bus = udev->controller_dev; |
| 37 | struct dm_usb_ops *ops = usb_get_ops(bus); |
| 38 | |
| 39 | if (!ops->interrupt) |
| 40 | return -ENOSYS; |
| 41 | |
Michal Suchanek | 1c95b9f | 2019-08-18 10:55:27 +0200 | [diff] [blame] | 42 | return ops->interrupt(bus, udev, pipe, buffer, length, interval, |
| 43 | nonblock); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | int submit_control_msg(struct usb_device *udev, unsigned long pipe, |
| 47 | void *buffer, int length, struct devrequest *setup) |
| 48 | { |
| 49 | struct udevice *bus = udev->controller_dev; |
| 50 | struct dm_usb_ops *ops = usb_get_ops(bus); |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 51 | struct usb_uclass_priv *uc_priv = bus->uclass->priv; |
| 52 | int err; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 53 | |
| 54 | if (!ops->control) |
| 55 | return -ENOSYS; |
| 56 | |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 57 | err = ops->control(bus, udev, pipe, buffer, length, setup); |
| 58 | if (setup->request == USB_REQ_SET_FEATURE && |
| 59 | setup->requesttype == USB_RT_PORT && |
| 60 | setup->value == cpu_to_le16(USB_PORT_FEAT_RESET) && |
| 61 | err == -ENXIO) { |
| 62 | /* Device handed over to companion after port reset */ |
| 63 | uc_priv->companion_device_count++; |
| 64 | } |
| 65 | |
| 66 | return err; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | int submit_bulk_msg(struct usb_device *udev, unsigned long pipe, void *buffer, |
| 70 | int length) |
| 71 | { |
| 72 | struct udevice *bus = udev->controller_dev; |
| 73 | struct dm_usb_ops *ops = usb_get_ops(bus); |
| 74 | |
| 75 | if (!ops->bulk) |
| 76 | return -ENOSYS; |
| 77 | |
| 78 | return ops->bulk(bus, udev, pipe, buffer, length); |
| 79 | } |
| 80 | |
Hans de Goede | 0a7fa27 | 2015-05-10 14:10:18 +0200 | [diff] [blame] | 81 | struct int_queue *create_int_queue(struct usb_device *udev, |
| 82 | unsigned long pipe, int queuesize, int elementsize, |
| 83 | void *buffer, int interval) |
| 84 | { |
| 85 | struct udevice *bus = udev->controller_dev; |
| 86 | struct dm_usb_ops *ops = usb_get_ops(bus); |
| 87 | |
| 88 | if (!ops->create_int_queue) |
| 89 | return NULL; |
| 90 | |
| 91 | return ops->create_int_queue(bus, udev, pipe, queuesize, elementsize, |
| 92 | buffer, interval); |
| 93 | } |
| 94 | |
| 95 | void *poll_int_queue(struct usb_device *udev, struct int_queue *queue) |
| 96 | { |
| 97 | struct udevice *bus = udev->controller_dev; |
| 98 | struct dm_usb_ops *ops = usb_get_ops(bus); |
| 99 | |
| 100 | if (!ops->poll_int_queue) |
| 101 | return NULL; |
| 102 | |
| 103 | return ops->poll_int_queue(bus, udev, queue); |
| 104 | } |
| 105 | |
| 106 | int destroy_int_queue(struct usb_device *udev, struct int_queue *queue) |
| 107 | { |
| 108 | struct udevice *bus = udev->controller_dev; |
| 109 | struct dm_usb_ops *ops = usb_get_ops(bus); |
| 110 | |
| 111 | if (!ops->destroy_int_queue) |
| 112 | return -ENOSYS; |
| 113 | |
| 114 | return ops->destroy_int_queue(bus, udev, queue); |
| 115 | } |
| 116 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 117 | int usb_alloc_device(struct usb_device *udev) |
| 118 | { |
| 119 | struct udevice *bus = udev->controller_dev; |
| 120 | struct dm_usb_ops *ops = usb_get_ops(bus); |
| 121 | |
| 122 | /* This is only requird by some controllers - current XHCI */ |
| 123 | if (!ops->alloc_device) |
| 124 | return 0; |
| 125 | |
| 126 | return ops->alloc_device(bus, udev); |
| 127 | } |
| 128 | |
Hans de Goede | a9e41f8 | 2015-06-17 21:33:52 +0200 | [diff] [blame] | 129 | int usb_reset_root_port(struct usb_device *udev) |
| 130 | { |
| 131 | struct udevice *bus = udev->controller_dev; |
| 132 | struct dm_usb_ops *ops = usb_get_ops(bus); |
| 133 | |
| 134 | if (!ops->reset_root_port) |
| 135 | return -ENOSYS; |
| 136 | |
| 137 | return ops->reset_root_port(bus, udev); |
| 138 | } |
| 139 | |
Bin Meng | 1f31f5a | 2017-07-19 21:51:17 +0800 | [diff] [blame] | 140 | int usb_update_hub_device(struct usb_device *udev) |
| 141 | { |
| 142 | struct udevice *bus = udev->controller_dev; |
| 143 | struct dm_usb_ops *ops = usb_get_ops(bus); |
| 144 | |
| 145 | if (!ops->update_hub_device) |
| 146 | return -ENOSYS; |
| 147 | |
| 148 | return ops->update_hub_device(bus, udev); |
| 149 | } |
| 150 | |
Bin Meng | 6840a34 | 2017-09-07 06:13:17 -0700 | [diff] [blame] | 151 | int usb_get_max_xfer_size(struct usb_device *udev, size_t *size) |
| 152 | { |
| 153 | struct udevice *bus = udev->controller_dev; |
| 154 | struct dm_usb_ops *ops = usb_get_ops(bus); |
| 155 | |
| 156 | if (!ops->get_max_xfer_size) |
| 157 | return -ENOSYS; |
| 158 | |
| 159 | return ops->get_max_xfer_size(bus, size); |
| 160 | } |
| 161 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 162 | int usb_stop(void) |
| 163 | { |
| 164 | struct udevice *bus; |
Bin Meng | 669ad84 | 2017-10-01 06:19:42 -0700 | [diff] [blame] | 165 | struct udevice *rh; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 166 | struct uclass *uc; |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 167 | struct usb_uclass_priv *uc_priv; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 168 | int err = 0, ret; |
| 169 | |
| 170 | /* De-activate any devices that have been activated */ |
| 171 | ret = uclass_get(UCLASS_USB, &uc); |
| 172 | if (ret) |
| 173 | return ret; |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 174 | |
| 175 | uc_priv = uc->priv; |
| 176 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 177 | uclass_foreach_dev(bus, uc) { |
Stefan Roese | 80b5bc9 | 2017-03-20 12:51:48 +0100 | [diff] [blame] | 178 | ret = device_remove(bus, DM_REMOVE_NORMAL); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 179 | if (ret && !err) |
| 180 | err = ret; |
Bin Meng | 669ad84 | 2017-10-01 06:19:42 -0700 | [diff] [blame] | 181 | |
| 182 | /* Locate root hub device */ |
| 183 | device_find_first_child(bus, &rh); |
| 184 | if (rh) { |
| 185 | /* |
| 186 | * All USB devices are children of root hub. |
| 187 | * Unbinding root hub will unbind all of its children. |
| 188 | */ |
| 189 | ret = device_unbind(rh); |
| 190 | if (ret && !err) |
| 191 | err = ret; |
| 192 | } |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 193 | } |
Bin Meng | dadc4c0 | 2017-10-01 06:19:43 -0700 | [diff] [blame] | 194 | |
Paul Kocialkowski | d449dd3 | 2015-08-04 17:04:12 +0200 | [diff] [blame] | 195 | #ifdef CONFIG_USB_STORAGE |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 196 | usb_stor_reset(); |
Paul Kocialkowski | d449dd3 | 2015-08-04 17:04:12 +0200 | [diff] [blame] | 197 | #endif |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 198 | uc_priv->companion_device_count = 0; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 199 | usb_started = 0; |
| 200 | |
| 201 | return err; |
| 202 | } |
| 203 | |
Hans de Goede | f8762f9 | 2015-05-10 14:10:19 +0200 | [diff] [blame] | 204 | static void usb_scan_bus(struct udevice *bus, bool recurse) |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 205 | { |
| 206 | struct usb_bus_priv *priv; |
| 207 | struct udevice *dev; |
| 208 | int ret; |
| 209 | |
| 210 | priv = dev_get_uclass_priv(bus); |
| 211 | |
| 212 | assert(recurse); /* TODO: Support non-recusive */ |
| 213 | |
Ismael Luceno Cortes | f58affe | 2019-03-19 09:19:44 +0000 | [diff] [blame] | 214 | printf("scanning bus %s for devices... ", bus->name); |
Hans de Goede | f8762f9 | 2015-05-10 14:10:19 +0200 | [diff] [blame] | 215 | debug("\n"); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 216 | ret = usb_scan_device(bus, 0, USB_SPEED_FULL, &dev); |
| 217 | if (ret) |
Hans de Goede | f8762f9 | 2015-05-10 14:10:19 +0200 | [diff] [blame] | 218 | printf("failed, error %d\n", ret); |
| 219 | else if (priv->next_addr == 0) |
| 220 | printf("No USB Device found\n"); |
| 221 | else |
| 222 | printf("%d USB Device(s) found\n", priv->next_addr); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 223 | } |
| 224 | |
Simon Glass | 35787d2 | 2015-11-08 23:48:00 -0700 | [diff] [blame] | 225 | static void remove_inactive_children(struct uclass *uc, struct udevice *bus) |
| 226 | { |
| 227 | uclass_foreach_dev(bus, uc) { |
| 228 | struct udevice *dev, *next; |
| 229 | |
| 230 | if (!device_active(bus)) |
| 231 | continue; |
| 232 | device_foreach_child_safe(dev, next, bus) { |
| 233 | if (!device_active(dev)) |
| 234 | device_unbind(dev); |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 239 | int usb_init(void) |
| 240 | { |
| 241 | int controllers_initialized = 0; |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 242 | struct usb_uclass_priv *uc_priv; |
Hans de Goede | 59a0dfc | 2015-05-10 14:10:20 +0200 | [diff] [blame] | 243 | struct usb_bus_priv *priv; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 244 | struct udevice *bus; |
| 245 | struct uclass *uc; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 246 | int ret; |
| 247 | |
| 248 | asynch_allowed = 1; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 249 | |
| 250 | ret = uclass_get(UCLASS_USB, &uc); |
| 251 | if (ret) |
| 252 | return ret; |
| 253 | |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 254 | uc_priv = uc->priv; |
| 255 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 256 | uclass_foreach_dev(bus, uc) { |
| 257 | /* init low_level USB */ |
Ismael Luceno Cortes | f58affe | 2019-03-19 09:19:44 +0000 | [diff] [blame] | 258 | printf("Bus %s: ", bus->name); |
Bin Meng | 669ad84 | 2017-10-01 06:19:42 -0700 | [diff] [blame] | 259 | |
| 260 | #ifdef CONFIG_SANDBOX |
| 261 | /* |
| 262 | * For Sandbox, we need scan the device tree each time when we |
| 263 | * start the USB stack, in order to re-create the emulated USB |
| 264 | * devices and bind drivers for them before we actually do the |
| 265 | * driver probe. |
| 266 | */ |
| 267 | ret = dm_scan_fdt_dev(bus); |
| 268 | if (ret) { |
| 269 | printf("Sandbox USB device scan failed (%d)\n", ret); |
| 270 | continue; |
| 271 | } |
| 272 | #endif |
| 273 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 274 | ret = device_probe(bus); |
| 275 | if (ret == -ENODEV) { /* No such device. */ |
| 276 | puts("Port not available.\n"); |
| 277 | controllers_initialized++; |
| 278 | continue; |
| 279 | } |
| 280 | |
| 281 | if (ret) { /* Other error. */ |
| 282 | printf("probe failed, error %d\n", ret); |
| 283 | continue; |
| 284 | } |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 285 | controllers_initialized++; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 286 | usb_started = true; |
| 287 | } |
| 288 | |
Hans de Goede | 59a0dfc | 2015-05-10 14:10:20 +0200 | [diff] [blame] | 289 | /* |
| 290 | * lowlevel init done, now scan the bus for devices i.e. search HUBs |
| 291 | * and configure them, first scan primary controllers. |
| 292 | */ |
| 293 | uclass_foreach_dev(bus, uc) { |
| 294 | if (!device_active(bus)) |
| 295 | continue; |
| 296 | |
| 297 | priv = dev_get_uclass_priv(bus); |
| 298 | if (!priv->companion) |
| 299 | usb_scan_bus(bus, true); |
| 300 | } |
| 301 | |
| 302 | /* |
| 303 | * Now that the primary controllers have been scanned and have handed |
| 304 | * over any devices they do not understand to their companions, scan |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 305 | * the companions if necessary. |
Hans de Goede | 59a0dfc | 2015-05-10 14:10:20 +0200 | [diff] [blame] | 306 | */ |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 307 | if (uc_priv->companion_device_count) { |
| 308 | uclass_foreach_dev(bus, uc) { |
| 309 | if (!device_active(bus)) |
| 310 | continue; |
Hans de Goede | 59a0dfc | 2015-05-10 14:10:20 +0200 | [diff] [blame] | 311 | |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 312 | priv = dev_get_uclass_priv(bus); |
| 313 | if (priv->companion) |
| 314 | usb_scan_bus(bus, true); |
| 315 | } |
Hans de Goede | 59a0dfc | 2015-05-10 14:10:20 +0200 | [diff] [blame] | 316 | } |
| 317 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 318 | debug("scan end\n"); |
Simon Glass | 35787d2 | 2015-11-08 23:48:00 -0700 | [diff] [blame] | 319 | |
| 320 | /* Remove any devices that were not found on this scan */ |
| 321 | remove_inactive_children(uc, bus); |
| 322 | |
| 323 | ret = uclass_get(UCLASS_USB_HUB, &uc); |
| 324 | if (ret) |
| 325 | return ret; |
| 326 | remove_inactive_children(uc, bus); |
| 327 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 328 | /* if we were not able to find at least one working bus, bail out */ |
Ismael Luceno Cortes | f58affe | 2019-03-19 09:19:44 +0000 | [diff] [blame] | 329 | if (controllers_initialized == 0) |
| 330 | printf("No working controllers found\n"); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 331 | |
| 332 | return usb_started ? 0 : -1; |
| 333 | } |
| 334 | |
Simon Glass | 5082c69 | 2015-11-08 23:47:59 -0700 | [diff] [blame] | 335 | /* |
| 336 | * TODO(sjg@chromium.org): Remove this legacy function. At present it is needed |
| 337 | * to support boards which use driver model for USB but not Ethernet, and want |
| 338 | * to use USB Ethernet. |
| 339 | * |
| 340 | * The #if clause is here to ensure that remains the only case. |
| 341 | */ |
| 342 | #if !defined(CONFIG_DM_ETH) && defined(CONFIG_USB_HOST_ETHER) |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 343 | static struct usb_device *find_child_devnum(struct udevice *parent, int devnum) |
| 344 | { |
| 345 | struct usb_device *udev; |
| 346 | struct udevice *dev; |
| 347 | |
| 348 | if (!device_active(parent)) |
| 349 | return NULL; |
Simon Glass | de44acf | 2015-09-28 23:32:01 -0600 | [diff] [blame] | 350 | udev = dev_get_parent_priv(parent); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 351 | if (udev->devnum == devnum) |
| 352 | return udev; |
| 353 | |
| 354 | for (device_find_first_child(parent, &dev); |
| 355 | dev; |
| 356 | device_find_next_child(&dev)) { |
| 357 | udev = find_child_devnum(dev, devnum); |
| 358 | if (udev) |
| 359 | return udev; |
| 360 | } |
| 361 | |
| 362 | return NULL; |
| 363 | } |
| 364 | |
| 365 | struct usb_device *usb_get_dev_index(struct udevice *bus, int index) |
| 366 | { |
Hans de Goede | 9c20359 | 2015-06-17 21:33:53 +0200 | [diff] [blame] | 367 | struct udevice *dev; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 368 | int devnum = index + 1; /* Addresses are allocated from 1 on USB */ |
| 369 | |
Hans de Goede | 9c20359 | 2015-06-17 21:33:53 +0200 | [diff] [blame] | 370 | device_find_first_child(bus, &dev); |
| 371 | if (!dev) |
| 372 | return NULL; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 373 | |
Hans de Goede | 9c20359 | 2015-06-17 21:33:53 +0200 | [diff] [blame] | 374 | return find_child_devnum(dev, devnum); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 375 | } |
Simon Glass | 5082c69 | 2015-11-08 23:47:59 -0700 | [diff] [blame] | 376 | #endif |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 377 | |
Simon Glass | 444b1e0 | 2015-03-25 12:22:32 -0600 | [diff] [blame] | 378 | int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp) |
| 379 | { |
| 380 | struct usb_platdata *plat; |
| 381 | struct udevice *dev; |
| 382 | int ret; |
| 383 | |
| 384 | /* Find the old device and remove it */ |
| 385 | ret = uclass_find_device_by_seq(UCLASS_USB, 0, true, &dev); |
| 386 | if (ret) |
| 387 | return ret; |
Stefan Roese | 80b5bc9 | 2017-03-20 12:51:48 +0100 | [diff] [blame] | 388 | ret = device_remove(dev, DM_REMOVE_NORMAL); |
Simon Glass | 444b1e0 | 2015-03-25 12:22:32 -0600 | [diff] [blame] | 389 | if (ret) |
| 390 | return ret; |
| 391 | |
| 392 | plat = dev_get_platdata(dev); |
| 393 | plat->init_type = USB_INIT_DEVICE; |
| 394 | ret = device_probe(dev); |
| 395 | if (ret) |
| 396 | return ret; |
| 397 | *ctlrp = dev_get_priv(dev); |
| 398 | |
| 399 | return 0; |
| 400 | } |
| 401 | |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 402 | /* returns 0 if no match, 1 if match */ |
Masahiro Yamada | 6d8e433 | 2017-06-22 16:35:14 +0900 | [diff] [blame] | 403 | static int usb_match_device(const struct usb_device_descriptor *desc, |
| 404 | const struct usb_device_id *id) |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 405 | { |
| 406 | if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && |
| 407 | id->idVendor != le16_to_cpu(desc->idVendor)) |
| 408 | return 0; |
| 409 | |
| 410 | if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && |
| 411 | id->idProduct != le16_to_cpu(desc->idProduct)) |
| 412 | return 0; |
| 413 | |
| 414 | /* No need to test id->bcdDevice_lo != 0, since 0 is never |
| 415 | greater than any unsigned number. */ |
| 416 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && |
| 417 | (id->bcdDevice_lo > le16_to_cpu(desc->bcdDevice))) |
| 418 | return 0; |
| 419 | |
| 420 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && |
| 421 | (id->bcdDevice_hi < le16_to_cpu(desc->bcdDevice))) |
| 422 | return 0; |
| 423 | |
| 424 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && |
| 425 | (id->bDeviceClass != desc->bDeviceClass)) |
| 426 | return 0; |
| 427 | |
| 428 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && |
| 429 | (id->bDeviceSubClass != desc->bDeviceSubClass)) |
| 430 | return 0; |
| 431 | |
| 432 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && |
| 433 | (id->bDeviceProtocol != desc->bDeviceProtocol)) |
| 434 | return 0; |
| 435 | |
| 436 | return 1; |
| 437 | } |
| 438 | |
| 439 | /* returns 0 if no match, 1 if match */ |
Masahiro Yamada | 6d8e433 | 2017-06-22 16:35:14 +0900 | [diff] [blame] | 440 | static int usb_match_one_id_intf(const struct usb_device_descriptor *desc, |
| 441 | const struct usb_interface_descriptor *int_desc, |
| 442 | const struct usb_device_id *id) |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 443 | { |
| 444 | /* The interface class, subclass, protocol and number should never be |
| 445 | * checked for a match if the device class is Vendor Specific, |
| 446 | * unless the match record specifies the Vendor ID. */ |
| 447 | if (desc->bDeviceClass == USB_CLASS_VENDOR_SPEC && |
| 448 | !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && |
| 449 | (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS | |
| 450 | USB_DEVICE_ID_MATCH_INT_SUBCLASS | |
| 451 | USB_DEVICE_ID_MATCH_INT_PROTOCOL | |
| 452 | USB_DEVICE_ID_MATCH_INT_NUMBER))) |
| 453 | return 0; |
| 454 | |
| 455 | if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && |
| 456 | (id->bInterfaceClass != int_desc->bInterfaceClass)) |
| 457 | return 0; |
| 458 | |
| 459 | if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) && |
| 460 | (id->bInterfaceSubClass != int_desc->bInterfaceSubClass)) |
| 461 | return 0; |
| 462 | |
| 463 | if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) && |
| 464 | (id->bInterfaceProtocol != int_desc->bInterfaceProtocol)) |
| 465 | return 0; |
| 466 | |
| 467 | if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_NUMBER) && |
| 468 | (id->bInterfaceNumber != int_desc->bInterfaceNumber)) |
| 469 | return 0; |
| 470 | |
| 471 | return 1; |
| 472 | } |
| 473 | |
| 474 | /* returns 0 if no match, 1 if match */ |
Masahiro Yamada | 6d8e433 | 2017-06-22 16:35:14 +0900 | [diff] [blame] | 475 | static int usb_match_one_id(struct usb_device_descriptor *desc, |
| 476 | struct usb_interface_descriptor *int_desc, |
| 477 | const struct usb_device_id *id) |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 478 | { |
| 479 | if (!usb_match_device(desc, id)) |
| 480 | return 0; |
| 481 | |
| 482 | return usb_match_one_id_intf(desc, int_desc, id); |
| 483 | } |
| 484 | |
| 485 | /** |
| 486 | * usb_find_and_bind_driver() - Find and bind the right USB driver |
| 487 | * |
| 488 | * This only looks at certain fields in the descriptor. |
| 489 | */ |
| 490 | static int usb_find_and_bind_driver(struct udevice *parent, |
| 491 | struct usb_device_descriptor *desc, |
| 492 | struct usb_interface_descriptor *iface, |
| 493 | int bus_seq, int devnum, |
| 494 | struct udevice **devp) |
| 495 | { |
| 496 | struct usb_driver_entry *start, *entry; |
| 497 | int n_ents; |
| 498 | int ret; |
| 499 | char name[30], *str; |
| 500 | |
| 501 | *devp = NULL; |
| 502 | debug("%s: Searching for driver\n", __func__); |
| 503 | start = ll_entry_start(struct usb_driver_entry, usb_driver_entry); |
| 504 | n_ents = ll_entry_count(struct usb_driver_entry, usb_driver_entry); |
| 505 | for (entry = start; entry != start + n_ents; entry++) { |
| 506 | const struct usb_device_id *id; |
| 507 | struct udevice *dev; |
| 508 | const struct driver *drv; |
| 509 | struct usb_dev_platdata *plat; |
| 510 | |
| 511 | for (id = entry->match; id->match_flags; id++) { |
| 512 | if (!usb_match_one_id(desc, iface, id)) |
| 513 | continue; |
| 514 | |
| 515 | drv = entry->driver; |
| 516 | /* |
| 517 | * We could pass the descriptor to the driver as |
| 518 | * platdata (instead of NULL) and allow its bind() |
| 519 | * method to return -ENOENT if it doesn't support this |
| 520 | * device. That way we could continue the search to |
| 521 | * find another driver. For now this doesn't seem |
| 522 | * necesssary, so just bind the first match. |
| 523 | */ |
| 524 | ret = device_bind(parent, drv, drv->name, NULL, -1, |
| 525 | &dev); |
| 526 | if (ret) |
| 527 | goto error; |
| 528 | debug("%s: Match found: %s\n", __func__, drv->name); |
| 529 | dev->driver_data = id->driver_info; |
| 530 | plat = dev_get_parent_platdata(dev); |
| 531 | plat->id = *id; |
| 532 | *devp = dev; |
| 533 | return 0; |
| 534 | } |
| 535 | } |
| 536 | |
Simon Glass | c79173e | 2015-03-25 12:22:31 -0600 | [diff] [blame] | 537 | /* Bind a generic driver so that the device can be used */ |
| 538 | snprintf(name, sizeof(name), "generic_bus_%x_dev_%x", bus_seq, devnum); |
| 539 | str = strdup(name); |
| 540 | if (!str) |
| 541 | return -ENOMEM; |
| 542 | ret = device_bind_driver(parent, "usb_dev_generic_drv", str, devp); |
| 543 | |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 544 | error: |
| 545 | debug("%s: No match found: %d\n", __func__, ret); |
| 546 | return ret; |
| 547 | } |
| 548 | |
| 549 | /** |
Simon Glass | d43d7e9 | 2015-11-08 23:47:56 -0700 | [diff] [blame] | 550 | * usb_find_child() - Find an existing device which matches our needs |
| 551 | * |
| 552 | * |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 553 | */ |
Simon Glass | d43d7e9 | 2015-11-08 23:47:56 -0700 | [diff] [blame] | 554 | static int usb_find_child(struct udevice *parent, |
| 555 | struct usb_device_descriptor *desc, |
| 556 | struct usb_interface_descriptor *iface, |
| 557 | struct udevice **devp) |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 558 | { |
| 559 | struct udevice *dev; |
| 560 | |
| 561 | *devp = NULL; |
| 562 | for (device_find_first_child(parent, &dev); |
| 563 | dev; |
| 564 | device_find_next_child(&dev)) { |
| 565 | struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); |
| 566 | |
| 567 | /* If this device is already in use, skip it */ |
| 568 | if (device_active(dev)) |
| 569 | continue; |
| 570 | debug(" %s: name='%s', plat=%d, desc=%d\n", __func__, |
| 571 | dev->name, plat->id.bDeviceClass, desc->bDeviceClass); |
| 572 | if (usb_match_one_id(desc, iface, &plat->id)) { |
| 573 | *devp = dev; |
| 574 | return 0; |
| 575 | } |
| 576 | } |
Simon Glass | d43d7e9 | 2015-11-08 23:47:56 -0700 | [diff] [blame] | 577 | |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 578 | return -ENOENT; |
| 579 | } |
| 580 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 581 | int usb_scan_device(struct udevice *parent, int port, |
| 582 | enum usb_device_speed speed, struct udevice **devp) |
| 583 | { |
| 584 | struct udevice *dev; |
| 585 | bool created = false; |
| 586 | struct usb_dev_platdata *plat; |
| 587 | struct usb_bus_priv *priv; |
| 588 | struct usb_device *parent_udev; |
| 589 | int ret; |
| 590 | ALLOC_CACHE_ALIGN_BUFFER(struct usb_device, udev, 1); |
| 591 | struct usb_interface_descriptor *iface = &udev->config.if_desc[0].desc; |
| 592 | |
| 593 | *devp = NULL; |
| 594 | memset(udev, '\0', sizeof(*udev)); |
Hans de Goede | 3b5ddd3 | 2015-05-05 11:54:31 +0200 | [diff] [blame] | 595 | udev->controller_dev = usb_get_bus(parent); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 596 | priv = dev_get_uclass_priv(udev->controller_dev); |
| 597 | |
| 598 | /* |
| 599 | * Somewhat nasty, this. We create a local device and use the normal |
| 600 | * USB stack to read its descriptor. Then we know what type of device |
| 601 | * to create for real. |
| 602 | * |
| 603 | * udev->dev is set to the parent, since we don't have a real device |
| 604 | * yet. The USB stack should not access udev.dev anyway, except perhaps |
| 605 | * to find the controller, and the controller will either be @parent, |
| 606 | * or some parent of @parent. |
| 607 | * |
| 608 | * Another option might be to create the device as a generic USB |
| 609 | * device, then morph it into the correct one when we know what it |
| 610 | * should be. This means that a generic USB device would morph into |
| 611 | * a network controller, or a USB flash stick, for example. However, |
| 612 | * we don't support such morphing and it isn't clear that it would |
| 613 | * be easy to do. |
| 614 | * |
| 615 | * Yet another option is to split out the USB stack parts of udev |
| 616 | * into something like a 'struct urb' (as Linux does) which can exist |
| 617 | * independently of any device. This feels cleaner, but calls for quite |
| 618 | * a big change to the USB stack. |
| 619 | * |
| 620 | * For now, the approach is to set up an empty udev, read its |
| 621 | * descriptor and assign it an address, then bind a real device and |
| 622 | * stash the resulting information into the device's parent |
| 623 | * platform data. Then when we probe it, usb_child_pre_probe() is called |
| 624 | * and it will pull the information out of the stash. |
| 625 | */ |
| 626 | udev->dev = parent; |
| 627 | udev->speed = speed; |
| 628 | udev->devnum = priv->next_addr + 1; |
| 629 | udev->portnr = port; |
| 630 | debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr); |
| 631 | parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ? |
Simon Glass | de44acf | 2015-09-28 23:32:01 -0600 | [diff] [blame] | 632 | dev_get_parent_priv(parent) : NULL; |
Hans de Goede | 778dc1c | 2015-06-17 21:33:46 +0200 | [diff] [blame] | 633 | ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 634 | debug("read_descriptor for '%s': ret=%d\n", parent->name, ret); |
| 635 | if (ret) |
| 636 | return ret; |
Simon Glass | d43d7e9 | 2015-11-08 23:47:56 -0700 | [diff] [blame] | 637 | ret = usb_find_child(parent, &udev->descriptor, iface, &dev); |
| 638 | debug("** usb_find_child returns %d\n", ret); |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 639 | if (ret) { |
| 640 | if (ret != -ENOENT) |
| 641 | return ret; |
| 642 | ret = usb_find_and_bind_driver(parent, &udev->descriptor, iface, |
| 643 | udev->controller_dev->seq, |
| 644 | udev->devnum, &dev); |
| 645 | if (ret) |
| 646 | return ret; |
| 647 | created = true; |
| 648 | } |
| 649 | plat = dev_get_parent_platdata(dev); |
| 650 | debug("%s: Probing '%s', plat=%p\n", __func__, dev->name, plat); |
| 651 | plat->devnum = udev->devnum; |
Hans de Goede | 8a0b4c2 | 2015-05-05 11:54:32 +0200 | [diff] [blame] | 652 | plat->udev = udev; |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 653 | priv->next_addr++; |
| 654 | ret = device_probe(dev); |
| 655 | if (ret) { |
| 656 | debug("%s: Device '%s' probe failed\n", __func__, dev->name); |
| 657 | priv->next_addr--; |
| 658 | if (created) |
| 659 | device_unbind(dev); |
| 660 | return ret; |
| 661 | } |
| 662 | *devp = dev; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 663 | |
Simon Glass | fc03a55 | 2015-03-25 12:22:30 -0600 | [diff] [blame] | 664 | return 0; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 665 | } |
| 666 | |
Simon Glass | fbb1494 | 2015-05-13 07:02:23 -0600 | [diff] [blame] | 667 | /* |
| 668 | * Detect if a USB device has been plugged or unplugged. |
| 669 | */ |
| 670 | int usb_detect_change(void) |
| 671 | { |
| 672 | struct udevice *hub; |
| 673 | struct uclass *uc; |
| 674 | int change = 0; |
| 675 | int ret; |
| 676 | |
| 677 | ret = uclass_get(UCLASS_USB_HUB, &uc); |
| 678 | if (ret) |
| 679 | return ret; |
| 680 | |
| 681 | uclass_foreach_dev(hub, uc) { |
| 682 | struct usb_device *udev; |
| 683 | struct udevice *dev; |
| 684 | |
| 685 | if (!device_active(hub)) |
| 686 | continue; |
| 687 | for (device_find_first_child(hub, &dev); |
| 688 | dev; |
| 689 | device_find_next_child(&dev)) { |
| 690 | struct usb_port_status status; |
| 691 | |
| 692 | if (!device_active(dev)) |
| 693 | continue; |
| 694 | |
Simon Glass | de44acf | 2015-09-28 23:32:01 -0600 | [diff] [blame] | 695 | udev = dev_get_parent_priv(dev); |
Simon Glass | fbb1494 | 2015-05-13 07:02:23 -0600 | [diff] [blame] | 696 | if (usb_get_port_status(udev, udev->portnr, &status) |
| 697 | < 0) |
| 698 | /* USB request failed */ |
| 699 | continue; |
| 700 | |
| 701 | if (le16_to_cpu(status.wPortChange) & |
| 702 | USB_PORT_STAT_C_CONNECTION) |
| 703 | change++; |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | return change; |
| 708 | } |
| 709 | |
Masahiro Yamada | 6d8e433 | 2017-06-22 16:35:14 +0900 | [diff] [blame] | 710 | static int usb_child_post_bind(struct udevice *dev) |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 711 | { |
| 712 | struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 713 | int val; |
| 714 | |
Simon Glass | 6deb8e2 | 2017-05-18 20:09:38 -0600 | [diff] [blame] | 715 | if (!dev_of_valid(dev)) |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 716 | return 0; |
| 717 | |
| 718 | /* We only support matching a few things */ |
Simon Glass | 6deb8e2 | 2017-05-18 20:09:38 -0600 | [diff] [blame] | 719 | val = dev_read_u32_default(dev, "usb,device-class", -1); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 720 | if (val != -1) { |
| 721 | plat->id.match_flags |= USB_DEVICE_ID_MATCH_DEV_CLASS; |
| 722 | plat->id.bDeviceClass = val; |
| 723 | } |
Simon Glass | 6deb8e2 | 2017-05-18 20:09:38 -0600 | [diff] [blame] | 724 | val = dev_read_u32_default(dev, "usb,interface-class", -1); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 725 | if (val != -1) { |
| 726 | plat->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS; |
| 727 | plat->id.bInterfaceClass = val; |
| 728 | } |
| 729 | |
| 730 | return 0; |
| 731 | } |
| 732 | |
Hans de Goede | 3b5ddd3 | 2015-05-05 11:54:31 +0200 | [diff] [blame] | 733 | struct udevice *usb_get_bus(struct udevice *dev) |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 734 | { |
| 735 | struct udevice *bus; |
| 736 | |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 737 | for (bus = dev; bus && device_get_uclass_id(bus) != UCLASS_USB; ) |
| 738 | bus = bus->parent; |
| 739 | if (!bus) { |
| 740 | /* By design this cannot happen */ |
| 741 | assert(bus); |
| 742 | debug("USB HUB '%s' does not have a controller\n", dev->name); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 743 | } |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 744 | |
Hans de Goede | 3b5ddd3 | 2015-05-05 11:54:31 +0200 | [diff] [blame] | 745 | return bus; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | int usb_child_pre_probe(struct udevice *dev) |
| 749 | { |
Simon Glass | de44acf | 2015-09-28 23:32:01 -0600 | [diff] [blame] | 750 | struct usb_device *udev = dev_get_parent_priv(dev); |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 751 | struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); |
| 752 | int ret; |
| 753 | |
Hans de Goede | 8a0b4c2 | 2015-05-05 11:54:32 +0200 | [diff] [blame] | 754 | if (plat->udev) { |
| 755 | /* |
| 756 | * Copy over all the values set in the on stack struct |
| 757 | * usb_device in usb_scan_device() to our final struct |
| 758 | * usb_device for this dev. |
| 759 | */ |
| 760 | *udev = *(plat->udev); |
| 761 | /* And clear plat->udev as it will not be valid for long */ |
| 762 | plat->udev = NULL; |
| 763 | udev->dev = dev; |
| 764 | } else { |
| 765 | /* |
| 766 | * This happens with devices which are explicitly bound |
| 767 | * instead of being discovered through usb_scan_device() |
| 768 | * such as sandbox emul devices. |
| 769 | */ |
| 770 | udev->dev = dev; |
| 771 | udev->controller_dev = usb_get_bus(dev); |
| 772 | udev->devnum = plat->devnum; |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 773 | |
Hans de Goede | 8a0b4c2 | 2015-05-05 11:54:32 +0200 | [diff] [blame] | 774 | /* |
| 775 | * udev did not go through usb_scan_device(), so we need to |
| 776 | * select the config and read the config descriptors. |
| 777 | */ |
| 778 | ret = usb_select_config(udev); |
| 779 | if (ret) |
| 780 | return ret; |
| 781 | } |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 782 | |
| 783 | return 0; |
| 784 | } |
| 785 | |
| 786 | UCLASS_DRIVER(usb) = { |
| 787 | .id = UCLASS_USB, |
| 788 | .name = "usb", |
| 789 | .flags = DM_UC_FLAG_SEQ_ALIAS, |
Simon Glass | 1823034 | 2016-07-05 17:10:10 -0600 | [diff] [blame] | 790 | .post_bind = dm_scan_fdt_dev, |
Hans de Goede | cebc5b7 | 2015-05-10 14:10:21 +0200 | [diff] [blame] | 791 | .priv_auto_alloc_size = sizeof(struct usb_uclass_priv), |
Simon Glass | 9b82eeb | 2015-03-25 12:21:59 -0600 | [diff] [blame] | 792 | .per_child_auto_alloc_size = sizeof(struct usb_device), |
| 793 | .per_device_auto_alloc_size = sizeof(struct usb_bus_priv), |
| 794 | .child_post_bind = usb_child_post_bind, |
| 795 | .child_pre_probe = usb_child_pre_probe, |
| 796 | .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata), |
| 797 | }; |
Simon Glass | c79173e | 2015-03-25 12:22:31 -0600 | [diff] [blame] | 798 | |
| 799 | UCLASS_DRIVER(usb_dev_generic) = { |
| 800 | .id = UCLASS_USB_DEV_GENERIC, |
| 801 | .name = "usb_dev_generic", |
| 802 | }; |
| 803 | |
| 804 | U_BOOT_DRIVER(usb_dev_generic_drv) = { |
| 805 | .id = UCLASS_USB_DEV_GENERIC, |
| 806 | .name = "usb_dev_generic_drv", |
| 807 | }; |