1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Driver for onboard USB devices 4 * 5 * Copyright (c) 2022, Google LLC 6 */ 7 8 #include <linux/clk.h> 9 #include <linux/device.h> 10 #include <linux/export.h> 11 #include <linux/err.h> 12 #include <linux/gpio/consumer.h> 13 #include <linux/init.h> 14 #include <linux/i2c.h> 15 #include <linux/kernel.h> 16 #include <linux/list.h> 17 #include <linux/module.h> 18 #include <linux/mutex.h> 19 #include <linux/of.h> 20 #include <linux/of_platform.h> 21 #include <linux/platform_device.h> 22 #include <linux/regulator/consumer.h> 23 #include <linux/slab.h> 24 #include <linux/suspend.h> 25 #include <linux/sysfs.h> 26 #include <linux/usb.h> 27 #include <linux/usb/hcd.h> 28 #include <linux/usb/onboard_dev.h> 29 #include <linux/workqueue.h> 30 31 #include "onboard_usb_dev.h" 32 33 /* USB5744 register offset and mask */ 34 #define USB5744_CMD_ATTACH 0xAA 35 #define USB5744_CMD_ATTACH_LSB 0x56 36 #define USB5744_CMD_CREG_ACCESS 0x99 37 #define USB5744_CMD_CREG_ACCESS_LSB 0x37 38 #define USB5744_CREG_MEM_ADDR 0x00 39 #define USB5744_CREG_MEM_RD_ADDR 0x04 40 #define USB5744_CREG_WRITE 0x00 41 #define USB5744_CREG_READ 0x01 42 #define USB5744_CREG_RUNTIMEFLAGS2 0x411D 43 #define USB5744_CREG_BYPASS_UDC_SUSPEND BIT(3) 44 45 static void onboard_dev_attach_usb_driver(struct work_struct *work); 46 47 static struct usb_device_driver onboard_dev_usbdev_driver; 48 static DECLARE_WORK(attach_usb_driver_work, onboard_dev_attach_usb_driver); 49 50 /************************** Platform driver **************************/ 51 52 struct usbdev_node { 53 struct usb_device *udev; 54 struct list_head list; 55 }; 56 57 struct onboard_dev { 58 struct regulator_bulk_data supplies[MAX_SUPPLIES]; 59 struct device *dev; 60 const struct onboard_dev_pdata *pdata; 61 struct gpio_desc *reset_gpio; 62 bool always_powered_in_suspend; 63 bool is_powered_on; 64 bool going_away; 65 struct list_head udev_list; 66 struct mutex lock; 67 struct clk *clk; 68 }; 69 70 static int onboard_dev_get_regulators(struct onboard_dev *onboard_dev) 71 { 72 const char * const *supply_names = onboard_dev->pdata->supply_names; 73 unsigned int num_supplies = onboard_dev->pdata->num_supplies; 74 struct device *dev = onboard_dev->dev; 75 unsigned int i; 76 int err; 77 78 if (num_supplies > MAX_SUPPLIES) 79 return dev_err_probe(dev, -EINVAL, "max %d supplies supported!\n", 80 MAX_SUPPLIES); 81 82 for (i = 0; i < num_supplies; i++) 83 onboard_dev->supplies[i].supply = supply_names[i]; 84 85 err = devm_regulator_bulk_get(dev, num_supplies, onboard_dev->supplies); 86 if (err) 87 dev_err(dev, "Failed to get regulator supplies: %pe\n", 88 ERR_PTR(err)); 89 90 return err; 91 } 92 93 static int onboard_dev_power_on(struct onboard_dev *onboard_dev) 94 { 95 int err; 96 97 err = clk_prepare_enable(onboard_dev->clk); 98 if (err) { 99 dev_err(onboard_dev->dev, "failed to enable clock: %pe\n", 100 ERR_PTR(err)); 101 return err; 102 } 103 104 err = regulator_bulk_enable(onboard_dev->pdata->num_supplies, 105 onboard_dev->supplies); 106 if (err) { 107 dev_err(onboard_dev->dev, "failed to enable supplies: %pe\n", 108 ERR_PTR(err)); 109 goto disable_clk; 110 } 111 112 fsleep(onboard_dev->pdata->reset_us); 113 gpiod_set_value_cansleep(onboard_dev->reset_gpio, 0); 114 fsleep(onboard_dev->pdata->power_on_delay_us); 115 116 onboard_dev->is_powered_on = true; 117 118 return 0; 119 120 disable_clk: 121 clk_disable_unprepare(onboard_dev->clk); 122 return err; 123 } 124 125 static int onboard_dev_power_off(struct onboard_dev *onboard_dev) 126 { 127 int err; 128 129 gpiod_set_value_cansleep(onboard_dev->reset_gpio, 1); 130 131 err = regulator_bulk_disable(onboard_dev->pdata->num_supplies, 132 onboard_dev->supplies); 133 if (err) { 134 dev_err(onboard_dev->dev, "failed to disable supplies: %pe\n", 135 ERR_PTR(err)); 136 return err; 137 } 138 139 clk_disable_unprepare(onboard_dev->clk); 140 141 onboard_dev->is_powered_on = false; 142 143 return 0; 144 } 145 146 static int __maybe_unused onboard_dev_suspend(struct device *dev) 147 { 148 struct onboard_dev *onboard_dev = dev_get_drvdata(dev); 149 struct usbdev_node *node; 150 bool power_off = true; 151 152 if (onboard_dev->always_powered_in_suspend) 153 return 0; 154 155 mutex_lock(&onboard_dev->lock); 156 157 list_for_each_entry(node, &onboard_dev->udev_list, list) { 158 if (!device_may_wakeup(node->udev->bus->controller)) 159 continue; 160 161 if (usb_wakeup_enabled_descendants(node->udev)) { 162 power_off = false; 163 break; 164 } 165 } 166 167 mutex_unlock(&onboard_dev->lock); 168 169 if (!power_off) 170 return 0; 171 172 return onboard_dev_power_off(onboard_dev); 173 } 174 175 static int __maybe_unused onboard_dev_resume(struct device *dev) 176 { 177 struct onboard_dev *onboard_dev = dev_get_drvdata(dev); 178 179 if (onboard_dev->is_powered_on) 180 return 0; 181 182 return onboard_dev_power_on(onboard_dev); 183 } 184 185 static inline void get_udev_link_name(const struct usb_device *udev, char *buf, 186 size_t size) 187 { 188 snprintf(buf, size, "usb_dev.%s", dev_name(&udev->dev)); 189 } 190 191 static int onboard_dev_add_usbdev(struct onboard_dev *onboard_dev, 192 struct usb_device *udev) 193 { 194 struct usbdev_node *node; 195 char link_name[64]; 196 int err; 197 198 mutex_lock(&onboard_dev->lock); 199 200 if (onboard_dev->going_away) { 201 err = -EINVAL; 202 goto error; 203 } 204 205 node = kzalloc(sizeof(*node), GFP_KERNEL); 206 if (!node) { 207 err = -ENOMEM; 208 goto error; 209 } 210 211 node->udev = udev; 212 213 list_add(&node->list, &onboard_dev->udev_list); 214 215 mutex_unlock(&onboard_dev->lock); 216 217 get_udev_link_name(udev, link_name, sizeof(link_name)); 218 WARN_ON(sysfs_create_link(&onboard_dev->dev->kobj, &udev->dev.kobj, 219 link_name)); 220 221 return 0; 222 223 error: 224 mutex_unlock(&onboard_dev->lock); 225 226 return err; 227 } 228 229 static void onboard_dev_remove_usbdev(struct onboard_dev *onboard_dev, 230 const struct usb_device *udev) 231 { 232 struct usbdev_node *node; 233 char link_name[64]; 234 235 get_udev_link_name(udev, link_name, sizeof(link_name)); 236 sysfs_remove_link(&onboard_dev->dev->kobj, link_name); 237 238 mutex_lock(&onboard_dev->lock); 239 240 list_for_each_entry(node, &onboard_dev->udev_list, list) { 241 if (node->udev == udev) { 242 list_del(&node->list); 243 kfree(node); 244 break; 245 } 246 } 247 248 mutex_unlock(&onboard_dev->lock); 249 } 250 251 static ssize_t always_powered_in_suspend_show(struct device *dev, 252 struct device_attribute *attr, 253 char *buf) 254 { 255 const struct onboard_dev *onboard_dev = dev_get_drvdata(dev); 256 257 return sysfs_emit(buf, "%d\n", onboard_dev->always_powered_in_suspend); 258 } 259 260 static ssize_t always_powered_in_suspend_store(struct device *dev, 261 struct device_attribute *attr, 262 const char *buf, size_t count) 263 { 264 struct onboard_dev *onboard_dev = dev_get_drvdata(dev); 265 bool val; 266 int ret; 267 268 ret = kstrtobool(buf, &val); 269 if (ret < 0) 270 return ret; 271 272 onboard_dev->always_powered_in_suspend = val; 273 274 return count; 275 } 276 static DEVICE_ATTR_RW(always_powered_in_suspend); 277 278 static struct attribute *onboard_dev_attrs[] = { 279 &dev_attr_always_powered_in_suspend.attr, 280 NULL, 281 }; 282 283 static umode_t onboard_dev_attrs_are_visible(struct kobject *kobj, 284 struct attribute *attr, 285 int n) 286 { 287 struct device *dev = kobj_to_dev(kobj); 288 struct onboard_dev *onboard_dev = dev_get_drvdata(dev); 289 290 if (attr == &dev_attr_always_powered_in_suspend.attr && 291 !onboard_dev->pdata->is_hub) 292 return 0; 293 294 return attr->mode; 295 } 296 297 static const struct attribute_group onboard_dev_group = { 298 .is_visible = onboard_dev_attrs_are_visible, 299 .attrs = onboard_dev_attrs, 300 }; 301 __ATTRIBUTE_GROUPS(onboard_dev); 302 303 304 static void onboard_dev_attach_usb_driver(struct work_struct *work) 305 { 306 int err; 307 308 err = driver_attach(&onboard_dev_usbdev_driver.driver); 309 if (err) 310 pr_err("Failed to attach USB driver: %pe\n", ERR_PTR(err)); 311 } 312 313 static int onboard_dev_5744_i2c_read_byte(struct i2c_client *client, u16 addr, u8 *data) 314 { 315 struct i2c_msg msg[2]; 316 u8 rd_buf[3]; 317 int ret; 318 319 u8 wr_buf[7] = {0, USB5744_CREG_MEM_ADDR, 4, 320 USB5744_CREG_READ, 1, 321 addr >> 8 & 0xff, 322 addr & 0xff}; 323 msg[0].addr = client->addr; 324 msg[0].flags = 0; 325 msg[0].len = sizeof(wr_buf); 326 msg[0].buf = wr_buf; 327 328 ret = i2c_transfer(client->adapter, msg, 1); 329 if (ret < 0) 330 return ret; 331 332 wr_buf[0] = USB5744_CMD_CREG_ACCESS; 333 wr_buf[1] = USB5744_CMD_CREG_ACCESS_LSB; 334 wr_buf[2] = 0; 335 msg[0].len = 3; 336 337 ret = i2c_transfer(client->adapter, msg, 1); 338 if (ret < 0) 339 return ret; 340 341 wr_buf[0] = 0; 342 wr_buf[1] = USB5744_CREG_MEM_RD_ADDR; 343 msg[0].len = 2; 344 345 msg[1].addr = client->addr; 346 msg[1].flags = I2C_M_RD; 347 msg[1].len = 2; 348 msg[1].buf = rd_buf; 349 350 ret = i2c_transfer(client->adapter, msg, 2); 351 if (ret < 0) 352 return ret; 353 *data = rd_buf[1]; 354 355 return 0; 356 } 357 358 static int onboard_dev_5744_i2c_write_byte(struct i2c_client *client, u16 addr, u8 data) 359 { 360 struct i2c_msg msg[2]; 361 int ret; 362 363 u8 wr_buf[8] = {0, USB5744_CREG_MEM_ADDR, 5, 364 USB5744_CREG_WRITE, 1, 365 addr >> 8 & 0xff, 366 addr & 0xff, 367 data}; 368 msg[0].addr = client->addr; 369 msg[0].flags = 0; 370 msg[0].len = sizeof(wr_buf); 371 msg[0].buf = wr_buf; 372 373 ret = i2c_transfer(client->adapter, msg, 1); 374 if (ret < 0) 375 return ret; 376 377 msg[0].len = 3; 378 wr_buf[0] = USB5744_CMD_CREG_ACCESS; 379 wr_buf[1] = USB5744_CMD_CREG_ACCESS_LSB; 380 wr_buf[2] = 0; 381 382 ret = i2c_transfer(client->adapter, msg, 1); 383 if (ret < 0) 384 return ret; 385 386 return 0; 387 } 388 389 static int onboard_dev_5744_i2c_init(struct i2c_client *client) 390 { 391 #if IS_ENABLED(CONFIG_USB_ONBOARD_DEV_USB5744) 392 struct device *dev = &client->dev; 393 int ret; 394 u8 reg; 395 396 /* 397 * Set BYPASS_UDC_SUSPEND bit to ensure MCU is always enabled 398 * and ready to respond to SMBus runtime commands. 399 * The command writes 5 bytes to memory and single data byte in 400 * configuration register. 401 */ 402 ret = onboard_dev_5744_i2c_read_byte(client, 403 USB5744_CREG_RUNTIMEFLAGS2, ®); 404 if (ret) 405 return dev_err_probe(dev, ret, "CREG_RUNTIMEFLAGS2 read failed\n"); 406 407 reg |= USB5744_CREG_BYPASS_UDC_SUSPEND; 408 ret = onboard_dev_5744_i2c_write_byte(client, 409 USB5744_CREG_RUNTIMEFLAGS2, reg); 410 if (ret) 411 return dev_err_probe(dev, ret, "BYPASS_UDC_SUSPEND bit configuration failed\n"); 412 413 /* Send SMBus command to boot hub. */ 414 ret = i2c_smbus_write_word_data(client, USB5744_CMD_ATTACH, 415 USB5744_CMD_ATTACH_LSB); 416 if (ret < 0) 417 return dev_err_probe(dev, ret, "USB Attach with SMBus command failed\n"); 418 419 return ret; 420 #else 421 return -ENODEV; 422 #endif 423 } 424 425 static int onboard_dev_probe(struct platform_device *pdev) 426 { 427 struct device *dev = &pdev->dev; 428 struct onboard_dev *onboard_dev; 429 struct device_node *i2c_node; 430 int err; 431 432 onboard_dev = devm_kzalloc(dev, sizeof(*onboard_dev), GFP_KERNEL); 433 if (!onboard_dev) 434 return -ENOMEM; 435 436 onboard_dev->pdata = device_get_match_data(dev); 437 if (!onboard_dev->pdata) 438 return -EINVAL; 439 440 if (!onboard_dev->pdata->is_hub) 441 onboard_dev->always_powered_in_suspend = true; 442 443 onboard_dev->dev = dev; 444 445 err = onboard_dev_get_regulators(onboard_dev); 446 if (err) 447 return err; 448 449 onboard_dev->clk = devm_clk_get_optional(dev, NULL); 450 if (IS_ERR(onboard_dev->clk)) 451 return dev_err_probe(dev, PTR_ERR(onboard_dev->clk), 452 "failed to get clock\n"); 453 454 onboard_dev->reset_gpio = devm_gpiod_get_optional(dev, "reset", 455 GPIOD_OUT_HIGH); 456 if (IS_ERR(onboard_dev->reset_gpio)) 457 return dev_err_probe(dev, PTR_ERR(onboard_dev->reset_gpio), 458 "failed to get reset GPIO\n"); 459 460 mutex_init(&onboard_dev->lock); 461 INIT_LIST_HEAD(&onboard_dev->udev_list); 462 463 dev_set_drvdata(dev, onboard_dev); 464 465 err = onboard_dev_power_on(onboard_dev); 466 if (err) 467 return err; 468 469 i2c_node = of_parse_phandle(pdev->dev.of_node, "i2c-bus", 0); 470 if (i2c_node) { 471 struct i2c_client *client = NULL; 472 473 #if IS_ENABLED(CONFIG_USB_ONBOARD_DEV_USB5744) 474 client = of_find_i2c_device_by_node(i2c_node); 475 #endif 476 of_node_put(i2c_node); 477 478 if (!client) { 479 err = -EPROBE_DEFER; 480 goto err_power_off; 481 } 482 483 if (of_device_is_compatible(pdev->dev.of_node, "usb424,2744") || 484 of_device_is_compatible(pdev->dev.of_node, "usb424,5744")) { 485 err = onboard_dev_5744_i2c_init(client); 486 onboard_dev->always_powered_in_suspend = true; 487 } 488 489 put_device(&client->dev); 490 if (err < 0) 491 goto err_power_off; 492 } 493 494 /* 495 * The USB driver might have been detached from the USB devices by 496 * onboard_dev_remove() (e.g. through an 'unbind' by userspace), 497 * make sure to re-attach it if needed. 498 * 499 * This needs to be done deferred to avoid self-deadlocks on systems 500 * with nested onboard hubs. 501 */ 502 schedule_work(&attach_usb_driver_work); 503 504 return 0; 505 506 err_power_off: 507 onboard_dev_power_off(onboard_dev); 508 return err; 509 } 510 511 static void onboard_dev_remove(struct platform_device *pdev) 512 { 513 struct onboard_dev *onboard_dev = dev_get_drvdata(&pdev->dev); 514 struct usbdev_node *node; 515 struct usb_device *udev; 516 517 onboard_dev->going_away = true; 518 519 mutex_lock(&onboard_dev->lock); 520 521 /* unbind the USB devices to avoid dangling references to this device */ 522 while (!list_empty(&onboard_dev->udev_list)) { 523 node = list_first_entry(&onboard_dev->udev_list, 524 struct usbdev_node, list); 525 udev = node->udev; 526 527 /* 528 * Unbinding the driver will call onboard_dev_remove_usbdev(), 529 * which acquires onboard_dev->lock. We must release the lock 530 * first. 531 */ 532 get_device(&udev->dev); 533 mutex_unlock(&onboard_dev->lock); 534 device_release_driver(&udev->dev); 535 put_device(&udev->dev); 536 mutex_lock(&onboard_dev->lock); 537 } 538 539 mutex_unlock(&onboard_dev->lock); 540 541 onboard_dev_power_off(onboard_dev); 542 } 543 544 MODULE_DEVICE_TABLE(of, onboard_dev_match); 545 546 static const struct dev_pm_ops __maybe_unused onboard_dev_pm_ops = { 547 SET_LATE_SYSTEM_SLEEP_PM_OPS(onboard_dev_suspend, onboard_dev_resume) 548 }; 549 550 static struct platform_driver onboard_dev_driver = { 551 .probe = onboard_dev_probe, 552 .remove = onboard_dev_remove, 553 554 .driver = { 555 .name = "onboard-usb-dev", 556 .of_match_table = onboard_dev_match, 557 .pm = pm_ptr(&onboard_dev_pm_ops), 558 .dev_groups = onboard_dev_groups, 559 }, 560 }; 561 562 /************************** USB driver **************************/ 563 564 #define VENDOR_ID_CYPRESS 0x04b4 565 #define VENDOR_ID_GENESYS 0x05e3 566 #define VENDOR_ID_MICROCHIP 0x0424 567 #define VENDOR_ID_PARADE 0x1da0 568 #define VENDOR_ID_REALTEK 0x0bda 569 #define VENDOR_ID_TI 0x0451 570 #define VENDOR_ID_VIA 0x2109 571 #define VENDOR_ID_XMOS 0x20B1 572 573 /* 574 * Returns the onboard_dev platform device that is associated with the USB 575 * device passed as parameter. 576 */ 577 static struct onboard_dev *_find_onboard_dev(struct device *dev) 578 { 579 struct platform_device *pdev; 580 struct device_node *np; 581 struct onboard_dev *onboard_dev; 582 583 pdev = of_find_device_by_node(dev->of_node); 584 if (!pdev) { 585 np = of_parse_phandle(dev->of_node, "peer-hub", 0); 586 if (!np) { 587 dev_err(dev, "failed to find device node for peer hub\n"); 588 return ERR_PTR(-EINVAL); 589 } 590 591 pdev = of_find_device_by_node(np); 592 of_node_put(np); 593 594 if (!pdev) 595 return ERR_PTR(-ENODEV); 596 } 597 598 onboard_dev = dev_get_drvdata(&pdev->dev); 599 put_device(&pdev->dev); 600 601 /* 602 * The presence of drvdata indicates that the platform driver finished 603 * probing. This handles the case where (conceivably) we could be 604 * running at the exact same time as the platform driver's probe. If 605 * we detect the race we request probe deferral and we'll come back and 606 * try again. 607 */ 608 if (!onboard_dev) 609 return ERR_PTR(-EPROBE_DEFER); 610 611 return onboard_dev; 612 } 613 614 static bool onboard_dev_usbdev_match(struct usb_device *udev) 615 { 616 /* Onboard devices using this driver must have a device tree node */ 617 return !!udev->dev.of_node; 618 } 619 620 static int onboard_dev_usbdev_probe(struct usb_device *udev) 621 { 622 struct device *dev = &udev->dev; 623 struct onboard_dev *onboard_dev; 624 int err; 625 626 onboard_dev = _find_onboard_dev(dev); 627 if (IS_ERR(onboard_dev)) 628 return PTR_ERR(onboard_dev); 629 630 dev_set_drvdata(dev, onboard_dev); 631 632 err = onboard_dev_add_usbdev(onboard_dev, udev); 633 if (err) 634 return err; 635 636 return 0; 637 } 638 639 static void onboard_dev_usbdev_disconnect(struct usb_device *udev) 640 { 641 struct onboard_dev *onboard_dev = dev_get_drvdata(&udev->dev); 642 643 onboard_dev_remove_usbdev(onboard_dev, udev); 644 } 645 646 static const struct usb_device_id onboard_dev_id_table[] = { 647 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6500) }, /* CYUSB330x 3.0 HUB */ 648 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6502) }, /* CYUSB330x 2.0 HUB */ 649 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6503) }, /* CYUSB33{0,1}x 2.0 HUB, Vendor Mode */ 650 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6504) }, /* CYUSB331x 3.0 HUB */ 651 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6506) }, /* CYUSB331x 2.0 HUB */ 652 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6507) }, /* CYUSB332x 2.0 HUB, Vendor Mode */ 653 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6508) }, /* CYUSB332x 3.0 HUB */ 654 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x650a) }, /* CYUSB332x 2.0 HUB */ 655 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6570) }, /* CY7C6563x 2.0 HUB */ 656 { USB_DEVICE(VENDOR_ID_GENESYS, 0x0608) }, /* Genesys Logic GL850G USB 2.0 HUB */ 657 { USB_DEVICE(VENDOR_ID_GENESYS, 0x0610) }, /* Genesys Logic GL852G USB 2.0 HUB */ 658 { USB_DEVICE(VENDOR_ID_GENESYS, 0x0620) }, /* Genesys Logic GL3523 USB 3.1 HUB */ 659 { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x2412) }, /* USB2412 USB 2.0 HUB */ 660 { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x2514) }, /* USB2514B USB 2.0 HUB */ 661 { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x2517) }, /* USB2517 USB 2.0 HUB */ 662 { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x2744) }, /* USB5744 USB 2.0 HUB */ 663 { USB_DEVICE(VENDOR_ID_MICROCHIP, 0x5744) }, /* USB5744 USB 3.0 HUB */ 664 { USB_DEVICE(VENDOR_ID_PARADE, 0x5511) }, /* PS5511 USB 3.2 */ 665 { USB_DEVICE(VENDOR_ID_PARADE, 0x55a1) }, /* PS5511 USB 2.0 */ 666 { USB_DEVICE(VENDOR_ID_REALTEK, 0x0411) }, /* RTS5411 USB 3.1 HUB */ 667 { USB_DEVICE(VENDOR_ID_REALTEK, 0x5411) }, /* RTS5411 USB 2.1 HUB */ 668 { USB_DEVICE(VENDOR_ID_REALTEK, 0x0414) }, /* RTS5414 USB 3.2 HUB */ 669 { USB_DEVICE(VENDOR_ID_REALTEK, 0x5414) }, /* RTS5414 USB 2.1 HUB */ 670 { USB_DEVICE(VENDOR_ID_REALTEK, 0x0179) }, /* RTL8188ETV 2.4GHz WiFi */ 671 { USB_DEVICE(VENDOR_ID_TI, 0x8025) }, /* TI USB8020B 3.0 HUB */ 672 { USB_DEVICE(VENDOR_ID_TI, 0x8027) }, /* TI USB8020B 2.0 HUB */ 673 { USB_DEVICE(VENDOR_ID_TI, 0x8140) }, /* TI USB8041 3.0 HUB */ 674 { USB_DEVICE(VENDOR_ID_TI, 0x8142) }, /* TI USB8041 2.0 HUB */ 675 { USB_DEVICE(VENDOR_ID_TI, 0x8440) }, /* TI USB8044 3.0 HUB */ 676 { USB_DEVICE(VENDOR_ID_TI, 0x8442) }, /* TI USB8044 2.0 HUB */ 677 { USB_DEVICE(VENDOR_ID_VIA, 0x0817) }, /* VIA VL817 3.1 HUB */ 678 { USB_DEVICE(VENDOR_ID_VIA, 0x2817) }, /* VIA VL817 2.0 HUB */ 679 { USB_DEVICE(VENDOR_ID_XMOS, 0x0013) }, /* XMOS XVF3500 Voice Processor */ 680 {} 681 }; 682 MODULE_DEVICE_TABLE(usb, onboard_dev_id_table); 683 684 static struct usb_device_driver onboard_dev_usbdev_driver = { 685 .name = "onboard-usb-dev", 686 .match = onboard_dev_usbdev_match, 687 .probe = onboard_dev_usbdev_probe, 688 .disconnect = onboard_dev_usbdev_disconnect, 689 .generic_subclass = 1, 690 .supports_autosuspend = 1, 691 .id_table = onboard_dev_id_table, 692 }; 693 694 static int __init onboard_dev_init(void) 695 { 696 int ret; 697 698 ret = usb_register_device_driver(&onboard_dev_usbdev_driver, THIS_MODULE); 699 if (ret) 700 return ret; 701 702 ret = platform_driver_register(&onboard_dev_driver); 703 if (ret) 704 usb_deregister_device_driver(&onboard_dev_usbdev_driver); 705 706 return ret; 707 } 708 module_init(onboard_dev_init); 709 710 static void __exit onboard_dev_exit(void) 711 { 712 usb_deregister_device_driver(&onboard_dev_usbdev_driver); 713 platform_driver_unregister(&onboard_dev_driver); 714 715 cancel_work_sync(&attach_usb_driver_work); 716 } 717 module_exit(onboard_dev_exit); 718 719 MODULE_AUTHOR("Matthias Kaehlcke <mka@chromium.org>"); 720 MODULE_DESCRIPTION("Driver for discrete onboard USB devices"); 721 MODULE_LICENSE("GPL v2"); 722