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