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