1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#ifndef _UAPI__LINUX_USB_CH9_H
34#define _UAPI__LINUX_USB_CH9_H
35
36#include <linux/types.h>
37#include <asm/byteorder.h>
38
39
40
41
42
43
44
45
46
47
48
49#define USB_DIR_OUT 0
50#define USB_DIR_IN 0x80
51
52
53
54
55#define USB_TYPE_MASK (0x03 << 5)
56#define USB_TYPE_STANDARD (0x00 << 5)
57#define USB_TYPE_CLASS (0x01 << 5)
58#define USB_TYPE_VENDOR (0x02 << 5)
59#define USB_TYPE_RESERVED (0x03 << 5)
60
61
62
63
64#define USB_RECIP_MASK 0x1f
65#define USB_RECIP_DEVICE 0x00
66#define USB_RECIP_INTERFACE 0x01
67#define USB_RECIP_ENDPOINT 0x02
68#define USB_RECIP_OTHER 0x03
69
70#define USB_RECIP_PORT 0x04
71#define USB_RECIP_RPIPE 0x05
72
73
74
75
76
77
78
79
80#define USB_REQ_GET_STATUS 0x00
81#define USB_REQ_CLEAR_FEATURE 0x01
82#define USB_REQ_SET_FEATURE 0x03
83#define USB_REQ_SET_ADDRESS 0x05
84#define USB_REQ_GET_DESCRIPTOR 0x06
85#define USB_REQ_SET_DESCRIPTOR 0x07
86#define USB_REQ_GET_CONFIGURATION 0x08
87#define USB_REQ_SET_CONFIGURATION 0x09
88#define USB_REQ_GET_INTERFACE 0x0A
89#define USB_REQ_SET_INTERFACE 0x0B
90#define USB_REQ_SYNCH_FRAME 0x0C
91#define USB_REQ_SET_SEL 0x30
92#define USB_REQ_SET_ISOCH_DELAY 0x31
93
94#define USB_REQ_SET_ENCRYPTION 0x0D
95#define USB_REQ_GET_ENCRYPTION 0x0E
96#define USB_REQ_RPIPE_ABORT 0x0E
97#define USB_REQ_SET_HANDSHAKE 0x0F
98#define USB_REQ_RPIPE_RESET 0x0F
99#define USB_REQ_GET_HANDSHAKE 0x10
100#define USB_REQ_SET_CONNECTION 0x11
101#define USB_REQ_SET_SECURITY_DATA 0x12
102#define USB_REQ_GET_SECURITY_DATA 0x13
103#define USB_REQ_SET_WUSB_DATA 0x14
104#define USB_REQ_LOOPBACK_DATA_WRITE 0x15
105#define USB_REQ_LOOPBACK_DATA_READ 0x16
106#define USB_REQ_SET_INTERFACE_DS 0x17
107
108
109
110
111
112
113
114
115
116
117
118
119#define USB_DEVICE_SELF_POWERED 0
120#define USB_DEVICE_REMOTE_WAKEUP 1
121#define USB_DEVICE_TEST_MODE 2
122#define USB_DEVICE_BATTERY 2
123#define USB_DEVICE_B_HNP_ENABLE 3
124#define USB_DEVICE_WUSB_DEVICE 3
125#define USB_DEVICE_A_HNP_SUPPORT 4
126#define USB_DEVICE_A_ALT_HNP_SUPPORT 5
127#define USB_DEVICE_DEBUG_MODE 6
128
129
130
131
132
133#define TEST_J 1
134#define TEST_K 2
135#define TEST_SE0_NAK 3
136#define TEST_PACKET 4
137#define TEST_FORCE_EN 5
138
139
140
141
142
143#define USB_DEVICE_U1_ENABLE 48
144#define USB_DEVICE_U2_ENABLE 49
145#define USB_DEVICE_LTM_ENABLE 50
146#define USB_INTRF_FUNC_SUSPEND 0
147
148#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
149
150
151
152#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
153#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
154
155
156
157
158#define USB_INTRF_STAT_FUNC_RW_CAP 1
159#define USB_INTRF_STAT_FUNC_RW 2
160
161#define USB_ENDPOINT_HALT 0
162
163
164#define USB_DEV_STAT_U1_ENABLED 2
165#define USB_DEV_STAT_U2_ENABLED 3
166#define USB_DEV_STAT_LTM_ENABLED 4
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185struct usb_ctrlrequest {
186 __u8 bRequestType;
187 __u8 bRequest;
188 __le16 wValue;
189 __le16 wIndex;
190 __le16 wLength;
191} __attribute__ ((packed));
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211#define USB_DT_DEVICE 0x01
212#define USB_DT_CONFIG 0x02
213#define USB_DT_STRING 0x03
214#define USB_DT_INTERFACE 0x04
215#define USB_DT_ENDPOINT 0x05
216#define USB_DT_DEVICE_QUALIFIER 0x06
217#define USB_DT_OTHER_SPEED_CONFIG 0x07
218#define USB_DT_INTERFACE_POWER 0x08
219
220#define USB_DT_OTG 0x09
221#define USB_DT_DEBUG 0x0a
222#define USB_DT_INTERFACE_ASSOCIATION 0x0b
223
224#define USB_DT_SECURITY 0x0c
225#define USB_DT_KEY 0x0d
226#define USB_DT_ENCRYPTION_TYPE 0x0e
227#define USB_DT_BOS 0x0f
228#define USB_DT_DEVICE_CAPABILITY 0x10
229#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
230#define USB_DT_WIRE_ADAPTER 0x21
231#define USB_DT_RPIPE 0x22
232#define USB_DT_CS_RADIO_CONTROL 0x23
233
234#define USB_DT_PIPE_USAGE 0x24
235
236#define USB_DT_SS_ENDPOINT_COMP 0x30
237
238#define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31
239
240
241
242
243
244#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
245#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
246#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
247#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
248#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
249
250
251struct usb_descriptor_header {
252 __u8 bLength;
253 __u8 bDescriptorType;
254} __attribute__ ((packed));
255
256
257
258
259
260struct usb_device_descriptor {
261 __u8 bLength;
262 __u8 bDescriptorType;
263
264 __le16 bcdUSB;
265 __u8 bDeviceClass;
266 __u8 bDeviceSubClass;
267 __u8 bDeviceProtocol;
268 __u8 bMaxPacketSize0;
269 __le16 idVendor;
270 __le16 idProduct;
271 __le16 bcdDevice;
272 __u8 iManufacturer;
273 __u8 iProduct;
274 __u8 iSerialNumber;
275 __u8 bNumConfigurations;
276} __attribute__ ((packed));
277
278#define USB_DT_DEVICE_SIZE 18
279
280
281
282
283
284
285
286#define USB_CLASS_PER_INTERFACE 0
287#define USB_CLASS_AUDIO 1
288#define USB_CLASS_COMM 2
289#define USB_CLASS_HID 3
290#define USB_CLASS_PHYSICAL 5
291#define USB_CLASS_STILL_IMAGE 6
292#define USB_CLASS_PRINTER 7
293#define USB_CLASS_MASS_STORAGE 8
294#define USB_CLASS_HUB 9
295#define USB_CLASS_CDC_DATA 0x0a
296#define USB_CLASS_CSCID 0x0b
297#define USB_CLASS_CONTENT_SEC 0x0d
298#define USB_CLASS_VIDEO 0x0e
299#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
300#define USB_CLASS_MISC 0xef
301#define USB_CLASS_APP_SPEC 0xfe
302#define USB_CLASS_VENDOR_SPEC 0xff
303
304#define USB_SUBCLASS_VENDOR_SPEC 0xff
305
306
307
308
309
310
311
312
313
314
315
316struct usb_config_descriptor {
317 __u8 bLength;
318 __u8 bDescriptorType;
319
320 __le16 wTotalLength;
321 __u8 bNumInterfaces;
322 __u8 bConfigurationValue;
323 __u8 iConfiguration;
324 __u8 bmAttributes;
325 __u8 bMaxPower;
326} __attribute__ ((packed));
327
328#define USB_DT_CONFIG_SIZE 9
329
330
331#define USB_CONFIG_ATT_ONE (1 << 7)
332#define USB_CONFIG_ATT_SELFPOWER (1 << 6)
333#define USB_CONFIG_ATT_WAKEUP (1 << 5)
334#define USB_CONFIG_ATT_BATTERY (1 << 4)
335
336
337
338
339struct usb_string_descriptor {
340 __u8 bLength;
341 __u8 bDescriptorType;
342
343 __le16 wData[1];
344} __attribute__ ((packed));
345
346
347
348
349
350
351
352
353struct usb_interface_descriptor {
354 __u8 bLength;
355 __u8 bDescriptorType;
356
357 __u8 bInterfaceNumber;
358 __u8 bAlternateSetting;
359 __u8 bNumEndpoints;
360 __u8 bInterfaceClass;
361 __u8 bInterfaceSubClass;
362 __u8 bInterfaceProtocol;
363 __u8 iInterface;
364} __attribute__ ((packed));
365
366#define USB_DT_INTERFACE_SIZE 9
367
368
369
370
371struct usb_endpoint_descriptor {
372 __u8 bLength;
373 __u8 bDescriptorType;
374
375 __u8 bEndpointAddress;
376 __u8 bmAttributes;
377 __le16 wMaxPacketSize;
378 __u8 bInterval;
379
380
381
382 __u8 bRefresh;
383 __u8 bSynchAddress;
384} __attribute__ ((packed));
385
386#define USB_DT_ENDPOINT_SIZE 7
387#define USB_DT_ENDPOINT_AUDIO_SIZE 9
388
389
390
391
392
393#define USB_ENDPOINT_NUMBER_MASK 0x0f
394#define USB_ENDPOINT_DIR_MASK 0x80
395
396#define USB_ENDPOINT_XFERTYPE_MASK 0x03
397#define USB_ENDPOINT_XFER_CONTROL 0
398#define USB_ENDPOINT_XFER_ISOC 1
399#define USB_ENDPOINT_XFER_BULK 2
400#define USB_ENDPOINT_XFER_INT 3
401#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
402
403
404#define USB_ENDPOINT_INTRTYPE 0x30
405#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
406#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
407
408#define USB_ENDPOINT_SYNCTYPE 0x0c
409#define USB_ENDPOINT_SYNC_NONE (0 << 2)
410#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
411#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
412#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
413
414#define USB_ENDPOINT_USAGE_MASK 0x30
415#define USB_ENDPOINT_USAGE_DATA 0x00
416#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
417#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20
418
419
420
421
422
423
424
425
426
427static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
428{
429 return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
430}
431
432
433
434
435
436
437
438
439static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
440{
441 return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
442}
443
444
445
446
447
448
449
450static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
451{
452 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
453}
454
455
456
457
458
459
460
461static inline int usb_endpoint_dir_out(
462 const struct usb_endpoint_descriptor *epd)
463{
464 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
465}
466
467
468
469
470
471
472
473static inline int usb_endpoint_xfer_bulk(
474 const struct usb_endpoint_descriptor *epd)
475{
476 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
477 USB_ENDPOINT_XFER_BULK);
478}
479
480
481
482
483
484
485
486static inline int usb_endpoint_xfer_control(
487 const struct usb_endpoint_descriptor *epd)
488{
489 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
490 USB_ENDPOINT_XFER_CONTROL);
491}
492
493
494
495
496
497
498
499
500static inline int usb_endpoint_xfer_int(
501 const struct usb_endpoint_descriptor *epd)
502{
503 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
504 USB_ENDPOINT_XFER_INT);
505}
506
507
508
509
510
511
512
513
514static inline int usb_endpoint_xfer_isoc(
515 const struct usb_endpoint_descriptor *epd)
516{
517 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
518 USB_ENDPOINT_XFER_ISOC);
519}
520
521
522
523
524
525
526
527
528static inline int usb_endpoint_is_bulk_in(
529 const struct usb_endpoint_descriptor *epd)
530{
531 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
532}
533
534
535
536
537
538
539
540
541static inline int usb_endpoint_is_bulk_out(
542 const struct usb_endpoint_descriptor *epd)
543{
544 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
545}
546
547
548
549
550
551
552
553
554static inline int usb_endpoint_is_int_in(
555 const struct usb_endpoint_descriptor *epd)
556{
557 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
558}
559
560
561
562
563
564
565
566
567static inline int usb_endpoint_is_int_out(
568 const struct usb_endpoint_descriptor *epd)
569{
570 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
571}
572
573
574
575
576
577
578
579
580static inline int usb_endpoint_is_isoc_in(
581 const struct usb_endpoint_descriptor *epd)
582{
583 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
584}
585
586
587
588
589
590
591
592
593static inline int usb_endpoint_is_isoc_out(
594 const struct usb_endpoint_descriptor *epd)
595{
596 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
597}
598
599
600
601
602
603
604
605static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
606{
607 return __le16_to_cpu(epd->wMaxPacketSize);
608}
609
610static inline int usb_endpoint_interrupt_type(
611 const struct usb_endpoint_descriptor *epd)
612{
613 return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
614}
615
616
617
618
619
620
621struct usb_ssp_isoc_ep_comp_descriptor {
622 __u8 bLength;
623 __u8 bDescriptorType;
624 __le16 wReseved;
625 __le32 dwBytesPerInterval;
626} __attribute__ ((packed));
627
628#define USB_DT_SSP_ISOC_EP_COMP_SIZE 8
629
630
631
632
633struct usb_ss_ep_comp_descriptor {
634 __u8 bLength;
635 __u8 bDescriptorType;
636
637 __u8 bMaxBurst;
638 __u8 bmAttributes;
639 __le16 wBytesPerInterval;
640} __attribute__ ((packed));
641
642#define USB_DT_SS_EP_COMP_SIZE 6
643
644
645static inline int
646usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
647{
648 int max_streams;
649
650 if (!comp)
651 return 0;
652
653 max_streams = comp->bmAttributes & 0x1f;
654
655 if (!max_streams)
656 return 0;
657
658 max_streams = 1 << max_streams;
659
660 return max_streams;
661}
662
663
664#define USB_SS_MULT(p) (1 + ((p) & 0x3))
665
666#define USB_SS_SSP_ISOC_COMP(p) ((p) & (1 << 7))
667
668
669
670
671struct usb_qualifier_descriptor {
672 __u8 bLength;
673 __u8 bDescriptorType;
674
675 __le16 bcdUSB;
676 __u8 bDeviceClass;
677 __u8 bDeviceSubClass;
678 __u8 bDeviceProtocol;
679 __u8 bMaxPacketSize0;
680 __u8 bNumConfigurations;
681 __u8 bRESERVED;
682} __attribute__ ((packed));
683
684
685
686
687
688struct usb_otg_descriptor {
689 __u8 bLength;
690 __u8 bDescriptorType;
691
692 __u8 bmAttributes;
693} __attribute__ ((packed));
694
695
696struct usb_otg20_descriptor {
697 __u8 bLength;
698 __u8 bDescriptorType;
699
700 __u8 bmAttributes;
701 __le16 bcdOTG;
702
703
704} __attribute__ ((packed));
705
706
707#define USB_OTG_SRP (1 << 0)
708#define USB_OTG_HNP (1 << 1)
709#define USB_OTG_ADP (1 << 2)
710
711#define OTG_STS_SELECTOR 0xF000
712
713
714
715struct usb_debug_descriptor {
716 __u8 bLength;
717 __u8 bDescriptorType;
718
719
720 __u8 bDebugInEndpoint;
721 __u8 bDebugOutEndpoint;
722} __attribute__((packed));
723
724
725
726
727struct usb_interface_assoc_descriptor {
728 __u8 bLength;
729 __u8 bDescriptorType;
730
731 __u8 bFirstInterface;
732 __u8 bInterfaceCount;
733 __u8 bFunctionClass;
734 __u8 bFunctionSubClass;
735 __u8 bFunctionProtocol;
736 __u8 iFunction;
737} __attribute__ ((packed));
738
739
740
741
742
743
744
745struct usb_security_descriptor {
746 __u8 bLength;
747 __u8 bDescriptorType;
748
749 __le16 wTotalLength;
750 __u8 bNumEncryptionTypes;
751} __attribute__((packed));
752
753
754
755
756
757
758struct usb_key_descriptor {
759 __u8 bLength;
760 __u8 bDescriptorType;
761
762 __u8 tTKID[3];
763 __u8 bReserved;
764 __u8 bKeyData[0];
765} __attribute__((packed));
766
767
768
769
770struct usb_encryption_descriptor {
771 __u8 bLength;
772 __u8 bDescriptorType;
773
774 __u8 bEncryptionType;
775#define USB_ENC_TYPE_UNSECURE 0
776#define USB_ENC_TYPE_WIRED 1
777#define USB_ENC_TYPE_CCM_1 2
778#define USB_ENC_TYPE_RSA_1 3
779 __u8 bEncryptionValue;
780 __u8 bAuthKeyIndex;
781} __attribute__((packed));
782
783
784
785
786
787struct usb_bos_descriptor {
788 __u8 bLength;
789 __u8 bDescriptorType;
790
791 __le16 wTotalLength;
792 __u8 bNumDeviceCaps;
793} __attribute__((packed));
794
795#define USB_DT_BOS_SIZE 5
796
797
798
799struct usb_dev_cap_header {
800 __u8 bLength;
801 __u8 bDescriptorType;
802 __u8 bDevCapabilityType;
803} __attribute__((packed));
804
805#define USB_CAP_TYPE_WIRELESS_USB 1
806
807struct usb_wireless_cap_descriptor {
808 __u8 bLength;
809 __u8 bDescriptorType;
810 __u8 bDevCapabilityType;
811
812 __u8 bmAttributes;
813#define USB_WIRELESS_P2P_DRD (1 << 1)
814#define USB_WIRELESS_BEACON_MASK (3 << 2)
815#define USB_WIRELESS_BEACON_SELF (1 << 2)
816#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
817#define USB_WIRELESS_BEACON_NONE (3 << 2)
818 __le16 wPHYRates;
819#define USB_WIRELESS_PHY_53 (1 << 0)
820#define USB_WIRELESS_PHY_80 (1 << 1)
821#define USB_WIRELESS_PHY_107 (1 << 2)
822#define USB_WIRELESS_PHY_160 (1 << 3)
823#define USB_WIRELESS_PHY_200 (1 << 4)
824#define USB_WIRELESS_PHY_320 (1 << 5)
825#define USB_WIRELESS_PHY_400 (1 << 6)
826#define USB_WIRELESS_PHY_480 (1 << 7)
827 __u8 bmTFITXPowerInfo;
828 __u8 bmFFITXPowerInfo;
829 __le16 bmBandGroup;
830 __u8 bReserved;
831} __attribute__((packed));
832
833
834#define USB_CAP_TYPE_EXT 2
835
836struct usb_ext_cap_descriptor {
837 __u8 bLength;
838 __u8 bDescriptorType;
839 __u8 bDevCapabilityType;
840 __le32 bmAttributes;
841#define USB_LPM_SUPPORT (1 << 1)
842#define USB_BESL_SUPPORT (1 << 2)
843#define USB_BESL_BASELINE_VALID (1 << 3)
844#define USB_BESL_DEEP_VALID (1 << 4)
845#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
846#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
847} __attribute__((packed));
848
849#define USB_DT_USB_EXT_CAP_SIZE 7
850
851
852
853
854
855#define USB_SS_CAP_TYPE 3
856struct usb_ss_cap_descriptor {
857 __u8 bLength;
858 __u8 bDescriptorType;
859 __u8 bDevCapabilityType;
860 __u8 bmAttributes;
861#define USB_LTM_SUPPORT (1 << 1)
862 __le16 wSpeedSupported;
863#define USB_LOW_SPEED_OPERATION (1)
864#define USB_FULL_SPEED_OPERATION (1 << 1)
865#define USB_HIGH_SPEED_OPERATION (1 << 2)
866#define USB_5GBPS_OPERATION (1 << 3)
867 __u8 bFunctionalitySupport;
868 __u8 bU1devExitLat;
869 __le16 bU2DevExitLat;
870} __attribute__((packed));
871
872#define USB_DT_USB_SS_CAP_SIZE 10
873
874
875
876
877
878#define CONTAINER_ID_TYPE 4
879struct usb_ss_container_id_descriptor {
880 __u8 bLength;
881 __u8 bDescriptorType;
882 __u8 bDevCapabilityType;
883 __u8 bReserved;
884 __u8 ContainerID[16];
885} __attribute__((packed));
886
887#define USB_DT_USB_SS_CONTN_ID_SIZE 20
888
889
890
891
892
893#define USB_SSP_CAP_TYPE 0xa
894struct usb_ssp_cap_descriptor {
895 __u8 bLength;
896 __u8 bDescriptorType;
897 __u8 bDevCapabilityType;
898 __u8 bReserved;
899 __le32 bmAttributes;
900#define USB_SSP_SUBLINK_SPEED_ATTRIBS (0x1f << 0)
901#define USB_SSP_SUBLINK_SPEED_IDS (0xf << 5)
902 __le16 wFunctionalitySupport;
903#define USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID (0xf)
904#define USB_SSP_MIN_RX_LANE_COUNT (0xf << 8)
905#define USB_SSP_MIN_TX_LANE_COUNT (0xf << 12)
906 __le16 wReserved;
907 __le32 bmSublinkSpeedAttr[1];
908#define USB_SSP_SUBLINK_SPEED_SSID (0xf)
909#define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4)
910#define USB_SSP_SUBLINK_SPEED_ST (0x3 << 6)
911#define USB_SSP_SUBLINK_SPEED_RSVD (0x3f << 8)
912#define USB_SSP_SUBLINK_SPEED_LP (0x3 << 14)
913#define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16)
914} __attribute__((packed));
915
916
917
918
919
920#define USB_PTM_CAP_TYPE 0xb
921struct usb_ptm_cap_descriptor {
922 __u8 bLength;
923 __u8 bDescriptorType;
924 __u8 bDevCapabilityType;
925} __attribute__((packed));
926
927
928
929
930
931#define USB_DT_USB_SSP_CAP_SIZE(ssac) (16 + ssac * 4)
932
933
934
935
936
937
938struct usb_wireless_ep_comp_descriptor {
939 __u8 bLength;
940 __u8 bDescriptorType;
941
942 __u8 bMaxBurst;
943 __u8 bMaxSequence;
944 __le16 wMaxStreamDelay;
945 __le16 wOverTheAirPacketSize;
946 __u8 bOverTheAirInterval;
947 __u8 bmCompAttributes;
948#define USB_ENDPOINT_SWITCH_MASK 0x03
949#define USB_ENDPOINT_SWITCH_NO 0
950#define USB_ENDPOINT_SWITCH_SWITCH 1
951#define USB_ENDPOINT_SWITCH_SCALE 2
952} __attribute__((packed));
953
954
955
956
957
958
959
960struct usb_handshake {
961 __u8 bMessageNumber;
962 __u8 bStatus;
963 __u8 tTKID[3];
964 __u8 bReserved;
965 __u8 CDID[16];
966 __u8 nonce[16];
967 __u8 MIC[8];
968} __attribute__((packed));
969
970
971
972
973
974
975
976struct usb_connection_context {
977 __u8 CHID[16];
978 __u8 CDID[16];
979 __u8 CK[16];
980} __attribute__((packed));
981
982
983
984
985
986enum usb_device_speed {
987 USB_SPEED_UNKNOWN = 0,
988 USB_SPEED_LOW, USB_SPEED_FULL,
989 USB_SPEED_HIGH,
990 USB_SPEED_WIRELESS,
991 USB_SPEED_SUPER,
992 USB_SPEED_SUPER_PLUS,
993};
994
995
996enum usb_device_state {
997
998
999
1000 USB_STATE_NOTATTACHED = 0,
1001
1002
1003 USB_STATE_ATTACHED,
1004 USB_STATE_POWERED,
1005 USB_STATE_RECONNECTING,
1006 USB_STATE_UNAUTHENTICATED,
1007 USB_STATE_DEFAULT,
1008 USB_STATE_ADDRESS,
1009 USB_STATE_CONFIGURED,
1010
1011 USB_STATE_SUSPENDED
1012
1013
1014
1015
1016
1017
1018
1019};
1020
1021enum usb3_link_state {
1022 USB3_LPM_U0 = 0,
1023 USB3_LPM_U1,
1024 USB3_LPM_U2,
1025 USB3_LPM_U3
1026};
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046#define USB3_LPM_DISABLED 0x0
1047#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
1048#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
1049#define USB3_LPM_DEVICE_INITIATED 0xFF
1050
1051struct usb_set_sel_req {
1052 __u8 u1_sel;
1053 __u8 u1_pel;
1054 __le16 u2_sel;
1055 __le16 u2_pel;
1056} __attribute__ ((packed));
1057
1058
1059
1060
1061
1062
1063#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
1064#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074#define USB_SELF_POWER_VBUS_MAX_DRAW 100
1075
1076#endif
1077