Merge tag 'v5.15.57' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / drivers / usb / core / otg_productlist.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (C) 2004 Texas Instruments */
3
4 /*
5  * This OTG and Embedded Host list is "Targeted Peripheral List".
6  * It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
7  *
8  * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!
9  */
10
11 static struct usb_device_id productlist_table[] = {
12
13 /* hubs are optional in OTG, but very handy ... */
14 #define CERT_WITHOUT_HUBS
15 #if defined(CERT_WITHOUT_HUBS)
16 { USB_DEVICE( 0x0000, 0x0000 ), }, /* Root HUB Only*/
17 #else
18 { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), },
19 { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), },
20 { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 2), },
21 #endif
22
23 #ifdef  CONFIG_USB_PRINTER              /* ignoring nonstatic linkage! */
24 /* FIXME actually, printers are NOT supposed to use device classes;
25  * they're supposed to use interface classes...
26  */
27 //{ USB_DEVICE_INFO(7, 1, 1) },
28 //{ USB_DEVICE_INFO(7, 1, 2) },
29 //{ USB_DEVICE_INFO(7, 1, 3) },
30 #endif
31
32 #ifdef  CONFIG_USB_NET_CDCETHER
33 /* Linux-USB CDC Ethernet gadget */
34 //{ USB_DEVICE(0x0525, 0xa4a1), },
35 /* Linux-USB CDC Ethernet + RNDIS gadget */
36 //{ USB_DEVICE(0x0525, 0xa4a2), },
37 #endif
38
39 #if     IS_ENABLED(CONFIG_USB_TEST)
40 /* gadget zero, for testing */
41 //{ USB_DEVICE(0x0525, 0xa4a0), },
42 #endif
43
44 /* OPT Tester */
45 { USB_DEVICE( 0x1a0a, 0x0101 ), }, /* TEST_SE0_NAK */
46 { USB_DEVICE( 0x1a0a, 0x0102 ), }, /* Test_J */
47 { USB_DEVICE( 0x1a0a, 0x0103 ), }, /* Test_K */
48 { USB_DEVICE( 0x1a0a, 0x0104 ), }, /* Test_PACKET */
49 { USB_DEVICE( 0x1a0a, 0x0105 ), }, /* Test_FORCE_ENABLE */
50 { USB_DEVICE( 0x1a0a, 0x0106 ), }, /* HS_PORT_SUSPEND_RESUME  */
51 { USB_DEVICE( 0x1a0a, 0x0107 ), }, /* SINGLE_STEP_GET_DESCRIPTOR setup */
52 { USB_DEVICE( 0x1a0a, 0x0108 ), }, /* SINGLE_STEP_GET_DESCRIPTOR execute */
53
54 /* Sony cameras */
55 { USB_DEVICE_VER(0x054c,0x0010,0x0410, 0x0500), },
56
57 /* Memory Devices */
58 //{ USB_DEVICE( 0x0781, 0x5150 ), }, /* SanDisk */
59 //{ USB_DEVICE( 0x05DC, 0x0080 ), }, /* Lexar */
60 //{ USB_DEVICE( 0x4146, 0x9281 ), }, /* IOMEGA */
61 //{ USB_DEVICE( 0x067b, 0x2507 ), }, /* Hammer 20GB External HD  */
62 { USB_DEVICE( 0x0EA0, 0x2168 ), }, /* Ours Technology Inc. (BUFFALO ClipDrive)*/
63 //{ USB_DEVICE( 0x0457, 0x0150 ), }, /* Silicon Integrated Systems Corp. */
64
65 /* HP Printers */
66 //{ USB_DEVICE( 0x03F0, 0x1102 ), }, /* HP Photosmart 245 */
67 //{ USB_DEVICE( 0x03F0, 0x1302 ), }, /* HP Photosmart 370 Series */
68
69 /* Speakers */
70 //{ USB_DEVICE( 0x0499, 0x3002 ), }, /* YAMAHA YST-MS35D USB Speakers */
71 //{ USB_DEVICE( 0x0672, 0x1041 ), }, /* Labtec USB Headset */
72
73 { }     /* Terminating entry */
74 };
75
76 static inline void report_errors(struct usb_device *dev)
77 {
78         /* OTG MESSAGE: report errors here, customize to match your product */
79         dev_info(&dev->dev, "device Vendor:%04x Product:%04x is not supported\n",
80                  le16_to_cpu(dev->descriptor.idVendor),
81                  le16_to_cpu(dev->descriptor.idProduct));
82         if (USB_CLASS_HUB == dev->descriptor.bDeviceClass){
83                 dev_printk(KERN_CRIT, &dev->dev, "Unsupported Hub Topology\n");
84         } else {
85                 dev_printk(KERN_CRIT, &dev->dev, "Attached Device is not Supported\n");
86         }
87 }
88
89
90 static int is_targeted(struct usb_device *dev)
91 {
92         struct usb_device_id    *id = productlist_table;
93
94         /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */
95         if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
96              le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
97                 return 0;
98
99         /* OTG PET device is always targeted (see OTG 2.0 ECN 6.4.2) */
100         if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
101              le16_to_cpu(dev->descriptor.idProduct) == 0x0200))
102                 return 1;
103
104         /* NOTE: can't use usb_match_id() since interface caches
105          * aren't set up yet. this is cut/paste from that code.
106          */
107         for (id = productlist_table; id->match_flags; id++) {
108                 if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
109                     id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
110                         continue;
111
112                 if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
113                     id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
114                         continue;
115
116                 /* No need to test id->bcdDevice_lo != 0, since 0 is never
117                    greater than any unsigned number. */
118                 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
119                     (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
120                         continue;
121
122                 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
123                     (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
124                         continue;
125
126                 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
127                     (id->bDeviceClass != dev->descriptor.bDeviceClass))
128                         continue;
129
130                 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
131                     (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
132                         continue;
133
134                 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
135                     (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
136                         continue;
137
138                 return 1;
139                 /* NOTE: can't use usb_match_id() since interface caches
140                  * aren't set up yet. this is cut/paste from that code.
141                  */
142                 for (id = productlist_table; id->match_flags; id++) {
143 #ifdef DEBUG
144                         dev_dbg(&dev->dev,
145                                 "ID: V:%04x P:%04x DC:%04x SC:%04x PR:%04x \n",
146                                 id->idVendor,
147                                 id->idProduct,
148                                 id->bDeviceClass,
149                                 id->bDeviceSubClass,
150                                 id->bDeviceProtocol);
151 #endif
152
153                         if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
154                             id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
155                                 continue;
156
157                         if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
158                             id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
159                                 continue;
160
161                         /* No need to test id->bcdDevice_lo != 0, since 0 is never
162                            greater than any unsigned number. */
163                         if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
164                             (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
165                                 continue;
166
167                         if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
168                             (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
169                                 continue;
170
171                         if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
172                             (id->bDeviceClass != dev->descriptor.bDeviceClass))
173                                 continue;
174
175                         if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
176                             (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
177                                 continue;
178
179                         if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
180                             (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
181                                 continue;
182
183                         return 1;
184                 }
185         }
186
187         /* add other match criteria here ... */
188
189         report_errors(dev);
190         return 0;
191 }
192