otg_productlist.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /* Copyright (C) 2004 Texas Instruments */
  3. /*
  4. * This OTG and Embedded Host list is "Targeted Peripheral List".
  5. * It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
  6. *
  7. * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!
  8. */
  9. static struct usb_device_id productlist_table[] = {
  10. /* hubs are optional in OTG, but very handy ... */
  11. { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), },
  12. { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), },
  13. #ifdef CONFIG_USB_PRINTER /* ignoring nonstatic linkage! */
  14. /* FIXME actually, printers are NOT supposed to use device classes;
  15. * they're supposed to use interface classes...
  16. */
  17. { USB_DEVICE_INFO(7, 1, 1) },
  18. { USB_DEVICE_INFO(7, 1, 2) },
  19. { USB_DEVICE_INFO(7, 1, 3) },
  20. #endif
  21. #ifdef CONFIG_USB_NET_CDCETHER
  22. /* Linux-USB CDC Ethernet gadget */
  23. { USB_DEVICE(0x0525, 0xa4a1), },
  24. /* Linux-USB CDC Ethernet + RNDIS gadget */
  25. { USB_DEVICE(0x0525, 0xa4a2), },
  26. #endif
  27. #if IS_ENABLED(CONFIG_USB_TEST)
  28. /* gadget zero, for testing */
  29. { USB_DEVICE(0x0525, 0xa4a0), },
  30. #endif
  31. { } /* Terminating entry */
  32. };
  33. static int is_targeted(struct usb_device *dev)
  34. {
  35. struct usb_device_id *id = productlist_table;
  36. /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */
  37. if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
  38. le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
  39. return 0;
  40. /* OTG PET device is always targeted (see OTG 2.0 ECN 6.4.2) */
  41. if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
  42. le16_to_cpu(dev->descriptor.idProduct) == 0x0200))
  43. return 1;
  44. /* NOTE: can't use usb_match_id() since interface caches
  45. * aren't set up yet. this is cut/paste from that code.
  46. */
  47. for (id = productlist_table; id->match_flags; id++) {
  48. if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
  49. id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
  50. continue;
  51. if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
  52. id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
  53. continue;
  54. /* No need to test id->bcdDevice_lo != 0, since 0 is never
  55. greater than any unsigned number. */
  56. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
  57. (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
  58. continue;
  59. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
  60. (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
  61. continue;
  62. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
  63. (id->bDeviceClass != dev->descriptor.bDeviceClass))
  64. continue;
  65. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
  66. (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
  67. continue;
  68. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
  69. (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
  70. continue;
  71. return 1;
  72. }
  73. /* add other match criteria here ... */
  74. /* OTG MESSAGE: report errors here, customize to match your product */
  75. dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
  76. le16_to_cpu(dev->descriptor.idVendor),
  77. le16_to_cpu(dev->descriptor.idProduct));
  78. return 0;
  79. }