otg_whitelist.h 3.3 KB

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