otg_whitelist.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 Whitelist is the OTG "Targeted Peripheral List". It should
  13. * 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. /* possible in developer configs only! */
  45. if (!dev->bus->otg_port)
  46. return 1;
  47. /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */
  48. if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
  49. le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
  50. return 0;
  51. /* NOTE: can't use usb_match_id() since interface caches
  52. * aren't set up yet. this is cut/paste from that code.
  53. */
  54. for (id = whitelist_table; id->match_flags; id++) {
  55. if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
  56. id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
  57. continue;
  58. if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
  59. id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
  60. continue;
  61. /* No need to test id->bcdDevice_lo != 0, since 0 is never
  62. greater than any unsigned number. */
  63. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
  64. (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
  65. continue;
  66. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
  67. (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
  68. continue;
  69. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
  70. (id->bDeviceClass != dev->descriptor.bDeviceClass))
  71. continue;
  72. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
  73. (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
  74. continue;
  75. if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
  76. (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
  77. continue;
  78. return 1;
  79. }
  80. /* add other match criteria here ... */
  81. /* OTG MESSAGE: report errors here, customize to match your product */
  82. dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
  83. le16_to_cpu(dev->descriptor.idVendor),
  84. le16_to_cpu(dev->descriptor.idProduct));
  85. #ifdef CONFIG_USB_OTG_WHITELIST
  86. return 0;
  87. #else
  88. return 1;
  89. #endif
  90. }