Linux 4.2.1
[linux/fpc-iii.git] / drivers / usb / core / otg_whitelist.h
bloba6315abe7b7cec272f28265157f1e65a24f71ddb
1 /*
2 * drivers/usb/core/otg_whitelist.h
4 * Copyright (C) 2004 Texas Instruments
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.
13 * This OTG and Embedded Host Whitelist is "Targeted Peripheral List".
14 * It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
16 * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!
19 static struct usb_device_id whitelist_table [] = {
21 /* hubs are optional in OTG, but very handy ... */
22 { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), },
23 { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), },
25 #ifdef CONFIG_USB_PRINTER /* ignoring nonstatic linkage! */
26 /* FIXME actually, printers are NOT supposed to use device classes;
27 * they're supposed to use interface classes...
29 { USB_DEVICE_INFO(7, 1, 1) },
30 { USB_DEVICE_INFO(7, 1, 2) },
31 { USB_DEVICE_INFO(7, 1, 3) },
32 #endif
34 #ifdef CONFIG_USB_NET_CDCETHER
35 /* Linux-USB CDC Ethernet gadget */
36 { USB_DEVICE(0x0525, 0xa4a1), },
37 /* Linux-USB CDC Ethernet + RNDIS gadget */
38 { USB_DEVICE(0x0525, 0xa4a2), },
39 #endif
41 #if defined(CONFIG_USB_TEST) || defined(CONFIG_USB_TEST_MODULE)
42 /* gadget zero, for testing */
43 { USB_DEVICE(0x0525, 0xa4a0), },
44 #endif
46 { } /* Terminating entry */
49 static int is_targeted(struct usb_device *dev)
51 struct usb_device_id *id = whitelist_table;
53 /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */
54 if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
55 le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
56 return 0;
58 /* OTG PET device is always targeted (see OTG 2.0 ECN 6.4.2) */
59 if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
60 le16_to_cpu(dev->descriptor.idProduct) == 0x0200))
61 return 1;
63 /* NOTE: can't use usb_match_id() since interface caches
64 * aren't set up yet. this is cut/paste from that code.
66 for (id = whitelist_table; id->match_flags; id++) {
67 if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
68 id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
69 continue;
71 if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
72 id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
73 continue;
75 /* No need to test id->bcdDevice_lo != 0, since 0 is never
76 greater than any unsigned number. */
77 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
78 (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
79 continue;
81 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
82 (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
83 continue;
85 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
86 (id->bDeviceClass != dev->descriptor.bDeviceClass))
87 continue;
89 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
90 (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
91 continue;
93 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
94 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
95 continue;
97 return 1;
100 /* add other match criteria here ... */
103 /* OTG MESSAGE: report errors here, customize to match your product */
104 dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
105 le16_to_cpu(dev->descriptor.idVendor),
106 le16_to_cpu(dev->descriptor.idProduct));
108 return 0;