0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef _UAPI__LINUX_USB_CH9_H
0035 #define _UAPI__LINUX_USB_CH9_H
0036
0037 #include <linux/types.h> /* __u8 etc */
0038 #include <asm/byteorder.h> /* le16_to_cpu */
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 #define USB_DIR_OUT 0
0051 #define USB_DIR_IN 0x80
0052
0053
0054
0055
0056 #define USB_TYPE_MASK (0x03 << 5)
0057 #define USB_TYPE_STANDARD (0x00 << 5)
0058 #define USB_TYPE_CLASS (0x01 << 5)
0059 #define USB_TYPE_VENDOR (0x02 << 5)
0060 #define USB_TYPE_RESERVED (0x03 << 5)
0061
0062
0063
0064
0065 #define USB_RECIP_MASK 0x1f
0066 #define USB_RECIP_DEVICE 0x00
0067 #define USB_RECIP_INTERFACE 0x01
0068 #define USB_RECIP_ENDPOINT 0x02
0069 #define USB_RECIP_OTHER 0x03
0070
0071 #define USB_RECIP_PORT 0x04
0072 #define USB_RECIP_RPIPE 0x05
0073
0074
0075
0076
0077
0078
0079
0080
0081 #define USB_REQ_GET_STATUS 0x00
0082 #define USB_REQ_CLEAR_FEATURE 0x01
0083 #define USB_REQ_SET_FEATURE 0x03
0084 #define USB_REQ_SET_ADDRESS 0x05
0085 #define USB_REQ_GET_DESCRIPTOR 0x06
0086 #define USB_REQ_SET_DESCRIPTOR 0x07
0087 #define USB_REQ_GET_CONFIGURATION 0x08
0088 #define USB_REQ_SET_CONFIGURATION 0x09
0089 #define USB_REQ_GET_INTERFACE 0x0A
0090 #define USB_REQ_SET_INTERFACE 0x0B
0091 #define USB_REQ_SYNCH_FRAME 0x0C
0092 #define USB_REQ_SET_SEL 0x30
0093 #define USB_REQ_SET_ISOCH_DELAY 0x31
0094
0095 #define USB_REQ_SET_ENCRYPTION 0x0D
0096 #define USB_REQ_GET_ENCRYPTION 0x0E
0097 #define USB_REQ_RPIPE_ABORT 0x0E
0098 #define USB_REQ_SET_HANDSHAKE 0x0F
0099 #define USB_REQ_RPIPE_RESET 0x0F
0100 #define USB_REQ_GET_HANDSHAKE 0x10
0101 #define USB_REQ_SET_CONNECTION 0x11
0102 #define USB_REQ_SET_SECURITY_DATA 0x12
0103 #define USB_REQ_GET_SECURITY_DATA 0x13
0104 #define USB_REQ_SET_WUSB_DATA 0x14
0105 #define USB_REQ_LOOPBACK_DATA_WRITE 0x15
0106 #define USB_REQ_LOOPBACK_DATA_READ 0x16
0107 #define USB_REQ_SET_INTERFACE_DS 0x17
0108
0109
0110 #define USB_REQ_GET_PARTNER_PDO 20
0111 #define USB_REQ_GET_BATTERY_STATUS 21
0112 #define USB_REQ_SET_PDO 22
0113 #define USB_REQ_GET_VDM 23
0114 #define USB_REQ_SEND_VDM 24
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127 #define USB_DEVICE_SELF_POWERED 0
0128 #define USB_DEVICE_REMOTE_WAKEUP 1
0129 #define USB_DEVICE_TEST_MODE 2
0130 #define USB_DEVICE_BATTERY 2
0131 #define USB_DEVICE_B_HNP_ENABLE 3
0132 #define USB_DEVICE_WUSB_DEVICE 3
0133 #define USB_DEVICE_A_HNP_SUPPORT 4
0134 #define USB_DEVICE_A_ALT_HNP_SUPPORT 5
0135 #define USB_DEVICE_DEBUG_MODE 6
0136
0137
0138
0139
0140
0141 #define USB_TEST_J 1
0142 #define USB_TEST_K 2
0143 #define USB_TEST_SE0_NAK 3
0144 #define USB_TEST_PACKET 4
0145 #define USB_TEST_FORCE_ENABLE 5
0146
0147
0148 #define USB_STATUS_TYPE_STANDARD 0
0149 #define USB_STATUS_TYPE_PTM 1
0150
0151
0152
0153
0154
0155 #define USB_DEVICE_U1_ENABLE 48
0156 #define USB_DEVICE_U2_ENABLE 49
0157 #define USB_DEVICE_LTM_ENABLE 50
0158 #define USB_INTRF_FUNC_SUSPEND 0
0159
0160 #define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
0161
0162
0163
0164 #define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
0165 #define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
0166
0167
0168
0169
0170 #define USB_INTRF_STAT_FUNC_RW_CAP 1
0171 #define USB_INTRF_STAT_FUNC_RW 2
0172
0173 #define USB_ENDPOINT_HALT 0
0174
0175
0176 #define USB_DEV_STAT_U1_ENABLED 2
0177 #define USB_DEV_STAT_U2_ENABLED 3
0178 #define USB_DEV_STAT_LTM_ENABLED 4
0179
0180
0181
0182
0183 #define USB_DEVICE_BATTERY_WAKE_MASK 40
0184 #define USB_DEVICE_OS_IS_PD_AWARE 41
0185 #define USB_DEVICE_POLICY_MODE 42
0186 #define USB_PORT_PR_SWAP 43
0187 #define USB_PORT_GOTO_MIN 44
0188 #define USB_PORT_RETURN_POWER 45
0189 #define USB_PORT_ACCEPT_PD_REQUEST 46
0190 #define USB_PORT_REJECT_PD_REQUEST 47
0191 #define USB_PORT_PORT_PD_RESET 48
0192 #define USB_PORT_C_PORT_PD_CHANGE 49
0193 #define USB_PORT_CABLE_PD_RESET 50
0194 #define USB_DEVICE_CHARGING_POLICY 54
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213 struct usb_ctrlrequest {
0214 __u8 bRequestType;
0215 __u8 bRequest;
0216 __le16 wValue;
0217 __le16 wIndex;
0218 __le16 wLength;
0219 } __attribute__ ((packed));
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240 #define USB_DT_DEVICE 0x01
0241 #define USB_DT_CONFIG 0x02
0242 #define USB_DT_STRING 0x03
0243 #define USB_DT_INTERFACE 0x04
0244 #define USB_DT_ENDPOINT 0x05
0245 #define USB_DT_DEVICE_QUALIFIER 0x06
0246 #define USB_DT_OTHER_SPEED_CONFIG 0x07
0247 #define USB_DT_INTERFACE_POWER 0x08
0248
0249 #define USB_DT_OTG 0x09
0250 #define USB_DT_DEBUG 0x0a
0251 #define USB_DT_INTERFACE_ASSOCIATION 0x0b
0252
0253 #define USB_DT_SECURITY 0x0c
0254 #define USB_DT_KEY 0x0d
0255 #define USB_DT_ENCRYPTION_TYPE 0x0e
0256 #define USB_DT_BOS 0x0f
0257 #define USB_DT_DEVICE_CAPABILITY 0x10
0258 #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
0259 #define USB_DT_WIRE_ADAPTER 0x21
0260 #define USB_DT_RPIPE 0x22
0261 #define USB_DT_CS_RADIO_CONTROL 0x23
0262
0263 #define USB_DT_PIPE_USAGE 0x24
0264
0265 #define USB_DT_SS_ENDPOINT_COMP 0x30
0266
0267 #define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31
0268
0269
0270
0271
0272
0273 #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
0274 #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
0275 #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
0276 #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
0277 #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
0278
0279
0280 struct usb_descriptor_header {
0281 __u8 bLength;
0282 __u8 bDescriptorType;
0283 } __attribute__ ((packed));
0284
0285
0286
0287
0288
0289 struct usb_device_descriptor {
0290 __u8 bLength;
0291 __u8 bDescriptorType;
0292
0293 __le16 bcdUSB;
0294 __u8 bDeviceClass;
0295 __u8 bDeviceSubClass;
0296 __u8 bDeviceProtocol;
0297 __u8 bMaxPacketSize0;
0298 __le16 idVendor;
0299 __le16 idProduct;
0300 __le16 bcdDevice;
0301 __u8 iManufacturer;
0302 __u8 iProduct;
0303 __u8 iSerialNumber;
0304 __u8 bNumConfigurations;
0305 } __attribute__ ((packed));
0306
0307 #define USB_DT_DEVICE_SIZE 18
0308
0309
0310
0311
0312
0313
0314
0315 #define USB_CLASS_PER_INTERFACE 0
0316 #define USB_CLASS_AUDIO 1
0317 #define USB_CLASS_COMM 2
0318 #define USB_CLASS_HID 3
0319 #define USB_CLASS_PHYSICAL 5
0320 #define USB_CLASS_STILL_IMAGE 6
0321 #define USB_CLASS_PRINTER 7
0322 #define USB_CLASS_MASS_STORAGE 8
0323 #define USB_CLASS_HUB 9
0324 #define USB_CLASS_CDC_DATA 0x0a
0325 #define USB_CLASS_CSCID 0x0b
0326 #define USB_CLASS_CONTENT_SEC 0x0d
0327 #define USB_CLASS_VIDEO 0x0e
0328 #define USB_CLASS_WIRELESS_CONTROLLER 0xe0
0329 #define USB_CLASS_PERSONAL_HEALTHCARE 0x0f
0330 #define USB_CLASS_AUDIO_VIDEO 0x10
0331 #define USB_CLASS_BILLBOARD 0x11
0332 #define USB_CLASS_USB_TYPE_C_BRIDGE 0x12
0333 #define USB_CLASS_MISC 0xef
0334 #define USB_CLASS_APP_SPEC 0xfe
0335 #define USB_CLASS_VENDOR_SPEC 0xff
0336
0337 #define USB_SUBCLASS_VENDOR_SPEC 0xff
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349 struct usb_config_descriptor {
0350 __u8 bLength;
0351 __u8 bDescriptorType;
0352
0353 __le16 wTotalLength;
0354 __u8 bNumInterfaces;
0355 __u8 bConfigurationValue;
0356 __u8 iConfiguration;
0357 __u8 bmAttributes;
0358 __u8 bMaxPower;
0359 } __attribute__ ((packed));
0360
0361 #define USB_DT_CONFIG_SIZE 9
0362
0363
0364 #define USB_CONFIG_ATT_ONE (1 << 7)
0365 #define USB_CONFIG_ATT_SELFPOWER (1 << 6)
0366 #define USB_CONFIG_ATT_WAKEUP (1 << 5)
0367 #define USB_CONFIG_ATT_BATTERY (1 << 4)
0368
0369
0370
0371
0372 #define USB_MAX_STRING_LEN 126
0373
0374
0375 struct usb_string_descriptor {
0376 __u8 bLength;
0377 __u8 bDescriptorType;
0378
0379 __le16 wData[1];
0380 } __attribute__ ((packed));
0381
0382
0383
0384
0385
0386
0387
0388
0389 struct usb_interface_descriptor {
0390 __u8 bLength;
0391 __u8 bDescriptorType;
0392
0393 __u8 bInterfaceNumber;
0394 __u8 bAlternateSetting;
0395 __u8 bNumEndpoints;
0396 __u8 bInterfaceClass;
0397 __u8 bInterfaceSubClass;
0398 __u8 bInterfaceProtocol;
0399 __u8 iInterface;
0400 } __attribute__ ((packed));
0401
0402 #define USB_DT_INTERFACE_SIZE 9
0403
0404
0405
0406
0407 struct usb_endpoint_descriptor {
0408 __u8 bLength;
0409 __u8 bDescriptorType;
0410
0411 __u8 bEndpointAddress;
0412 __u8 bmAttributes;
0413 __le16 wMaxPacketSize;
0414 __u8 bInterval;
0415
0416
0417
0418 __u8 bRefresh;
0419 __u8 bSynchAddress;
0420 } __attribute__ ((packed));
0421
0422 #define USB_DT_ENDPOINT_SIZE 7
0423 #define USB_DT_ENDPOINT_AUDIO_SIZE 9
0424
0425
0426
0427
0428
0429 #define USB_ENDPOINT_NUMBER_MASK 0x0f
0430 #define USB_ENDPOINT_DIR_MASK 0x80
0431
0432 #define USB_ENDPOINT_XFERTYPE_MASK 0x03
0433 #define USB_ENDPOINT_XFER_CONTROL 0
0434 #define USB_ENDPOINT_XFER_ISOC 1
0435 #define USB_ENDPOINT_XFER_BULK 2
0436 #define USB_ENDPOINT_XFER_INT 3
0437 #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
0438
0439 #define USB_ENDPOINT_MAXP_MASK 0x07ff
0440 #define USB_EP_MAXP_MULT_SHIFT 11
0441 #define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT)
0442 #define USB_EP_MAXP_MULT(m) \
0443 (((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT)
0444
0445
0446 #define USB_ENDPOINT_INTRTYPE 0x30
0447 #define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
0448 #define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
0449
0450 #define USB_ENDPOINT_SYNCTYPE 0x0c
0451 #define USB_ENDPOINT_SYNC_NONE (0 << 2)
0452 #define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
0453 #define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
0454 #define USB_ENDPOINT_SYNC_SYNC (3 << 2)
0455
0456 #define USB_ENDPOINT_USAGE_MASK 0x30
0457 #define USB_ENDPOINT_USAGE_DATA 0x00
0458 #define USB_ENDPOINT_USAGE_FEEDBACK 0x10
0459 #define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469 static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
0470 {
0471 return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
0472 }
0473
0474
0475
0476
0477
0478
0479
0480
0481 static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
0482 {
0483 return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
0484 }
0485
0486
0487
0488
0489
0490
0491
0492 static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
0493 {
0494 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
0495 }
0496
0497
0498
0499
0500
0501
0502
0503 static inline int usb_endpoint_dir_out(
0504 const struct usb_endpoint_descriptor *epd)
0505 {
0506 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
0507 }
0508
0509
0510
0511
0512
0513
0514
0515 static inline int usb_endpoint_xfer_bulk(
0516 const struct usb_endpoint_descriptor *epd)
0517 {
0518 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
0519 USB_ENDPOINT_XFER_BULK);
0520 }
0521
0522
0523
0524
0525
0526
0527
0528 static inline int usb_endpoint_xfer_control(
0529 const struct usb_endpoint_descriptor *epd)
0530 {
0531 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
0532 USB_ENDPOINT_XFER_CONTROL);
0533 }
0534
0535
0536
0537
0538
0539
0540
0541
0542 static inline int usb_endpoint_xfer_int(
0543 const struct usb_endpoint_descriptor *epd)
0544 {
0545 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
0546 USB_ENDPOINT_XFER_INT);
0547 }
0548
0549
0550
0551
0552
0553
0554
0555
0556 static inline int usb_endpoint_xfer_isoc(
0557 const struct usb_endpoint_descriptor *epd)
0558 {
0559 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
0560 USB_ENDPOINT_XFER_ISOC);
0561 }
0562
0563
0564
0565
0566
0567
0568
0569
0570 static inline int usb_endpoint_is_bulk_in(
0571 const struct usb_endpoint_descriptor *epd)
0572 {
0573 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
0574 }
0575
0576
0577
0578
0579
0580
0581
0582
0583 static inline int usb_endpoint_is_bulk_out(
0584 const struct usb_endpoint_descriptor *epd)
0585 {
0586 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
0587 }
0588
0589
0590
0591
0592
0593
0594
0595
0596 static inline int usb_endpoint_is_int_in(
0597 const struct usb_endpoint_descriptor *epd)
0598 {
0599 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
0600 }
0601
0602
0603
0604
0605
0606
0607
0608
0609 static inline int usb_endpoint_is_int_out(
0610 const struct usb_endpoint_descriptor *epd)
0611 {
0612 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
0613 }
0614
0615
0616
0617
0618
0619
0620
0621
0622 static inline int usb_endpoint_is_isoc_in(
0623 const struct usb_endpoint_descriptor *epd)
0624 {
0625 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
0626 }
0627
0628
0629
0630
0631
0632
0633
0634
0635 static inline int usb_endpoint_is_isoc_out(
0636 const struct usb_endpoint_descriptor *epd)
0637 {
0638 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
0639 }
0640
0641
0642
0643
0644
0645
0646
0647 static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
0648 {
0649 return __le16_to_cpu(epd->wMaxPacketSize) & USB_ENDPOINT_MAXP_MASK;
0650 }
0651
0652
0653
0654
0655
0656
0657
0658 static inline int
0659 usb_endpoint_maxp_mult(const struct usb_endpoint_descriptor *epd)
0660 {
0661 int maxp = __le16_to_cpu(epd->wMaxPacketSize);
0662
0663 return USB_EP_MAXP_MULT(maxp) + 1;
0664 }
0665
0666 static inline int usb_endpoint_interrupt_type(
0667 const struct usb_endpoint_descriptor *epd)
0668 {
0669 return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
0670 }
0671
0672
0673
0674
0675
0676
0677 struct usb_ssp_isoc_ep_comp_descriptor {
0678 __u8 bLength;
0679 __u8 bDescriptorType;
0680 __le16 wReseved;
0681 __le32 dwBytesPerInterval;
0682 } __attribute__ ((packed));
0683
0684 #define USB_DT_SSP_ISOC_EP_COMP_SIZE 8
0685
0686
0687
0688
0689 struct usb_ss_ep_comp_descriptor {
0690 __u8 bLength;
0691 __u8 bDescriptorType;
0692
0693 __u8 bMaxBurst;
0694 __u8 bmAttributes;
0695 __le16 wBytesPerInterval;
0696 } __attribute__ ((packed));
0697
0698 #define USB_DT_SS_EP_COMP_SIZE 6
0699
0700
0701 static inline int
0702 usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
0703 {
0704 int max_streams;
0705
0706 if (!comp)
0707 return 0;
0708
0709 max_streams = comp->bmAttributes & 0x1f;
0710
0711 if (!max_streams)
0712 return 0;
0713
0714 max_streams = 1 << max_streams;
0715
0716 return max_streams;
0717 }
0718
0719
0720 #define USB_SS_MULT(p) (1 + ((p) & 0x3))
0721
0722 #define USB_SS_SSP_ISOC_COMP(p) ((p) & (1 << 7))
0723
0724
0725
0726
0727 struct usb_qualifier_descriptor {
0728 __u8 bLength;
0729 __u8 bDescriptorType;
0730
0731 __le16 bcdUSB;
0732 __u8 bDeviceClass;
0733 __u8 bDeviceSubClass;
0734 __u8 bDeviceProtocol;
0735 __u8 bMaxPacketSize0;
0736 __u8 bNumConfigurations;
0737 __u8 bRESERVED;
0738 } __attribute__ ((packed));
0739
0740
0741
0742
0743
0744 struct usb_otg_descriptor {
0745 __u8 bLength;
0746 __u8 bDescriptorType;
0747
0748 __u8 bmAttributes;
0749 } __attribute__ ((packed));
0750
0751
0752 struct usb_otg20_descriptor {
0753 __u8 bLength;
0754 __u8 bDescriptorType;
0755
0756 __u8 bmAttributes;
0757 __le16 bcdOTG;
0758
0759
0760 } __attribute__ ((packed));
0761
0762
0763 #define USB_OTG_SRP (1 << 0)
0764 #define USB_OTG_HNP (1 << 1)
0765 #define USB_OTG_ADP (1 << 2)
0766
0767 #define OTG_STS_SELECTOR 0xF000
0768
0769
0770
0771 struct usb_debug_descriptor {
0772 __u8 bLength;
0773 __u8 bDescriptorType;
0774
0775
0776 __u8 bDebugInEndpoint;
0777 __u8 bDebugOutEndpoint;
0778 } __attribute__((packed));
0779
0780
0781
0782
0783 struct usb_interface_assoc_descriptor {
0784 __u8 bLength;
0785 __u8 bDescriptorType;
0786
0787 __u8 bFirstInterface;
0788 __u8 bInterfaceCount;
0789 __u8 bFunctionClass;
0790 __u8 bFunctionSubClass;
0791 __u8 bFunctionProtocol;
0792 __u8 iFunction;
0793 } __attribute__ ((packed));
0794
0795 #define USB_DT_INTERFACE_ASSOCIATION_SIZE 8
0796
0797
0798
0799
0800
0801
0802 struct usb_security_descriptor {
0803 __u8 bLength;
0804 __u8 bDescriptorType;
0805
0806 __le16 wTotalLength;
0807 __u8 bNumEncryptionTypes;
0808 } __attribute__((packed));
0809
0810
0811
0812
0813
0814
0815 struct usb_key_descriptor {
0816 __u8 bLength;
0817 __u8 bDescriptorType;
0818
0819 __u8 tTKID[3];
0820 __u8 bReserved;
0821 __u8 bKeyData[];
0822 } __attribute__((packed));
0823
0824
0825
0826
0827 struct usb_encryption_descriptor {
0828 __u8 bLength;
0829 __u8 bDescriptorType;
0830
0831 __u8 bEncryptionType;
0832 #define USB_ENC_TYPE_UNSECURE 0
0833 #define USB_ENC_TYPE_WIRED 1
0834 #define USB_ENC_TYPE_CCM_1 2
0835 #define USB_ENC_TYPE_RSA_1 3
0836 __u8 bEncryptionValue;
0837 __u8 bAuthKeyIndex;
0838 } __attribute__((packed));
0839
0840
0841
0842
0843
0844 struct usb_bos_descriptor {
0845 __u8 bLength;
0846 __u8 bDescriptorType;
0847
0848 __le16 wTotalLength;
0849 __u8 bNumDeviceCaps;
0850 } __attribute__((packed));
0851
0852 #define USB_DT_BOS_SIZE 5
0853
0854
0855
0856 struct usb_dev_cap_header {
0857 __u8 bLength;
0858 __u8 bDescriptorType;
0859 __u8 bDevCapabilityType;
0860 } __attribute__((packed));
0861
0862 #define USB_CAP_TYPE_WIRELESS_USB 1
0863
0864 struct usb_wireless_cap_descriptor {
0865 __u8 bLength;
0866 __u8 bDescriptorType;
0867 __u8 bDevCapabilityType;
0868
0869 __u8 bmAttributes;
0870 #define USB_WIRELESS_P2P_DRD (1 << 1)
0871 #define USB_WIRELESS_BEACON_MASK (3 << 2)
0872 #define USB_WIRELESS_BEACON_SELF (1 << 2)
0873 #define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
0874 #define USB_WIRELESS_BEACON_NONE (3 << 2)
0875 __le16 wPHYRates;
0876 #define USB_WIRELESS_PHY_53 (1 << 0)
0877 #define USB_WIRELESS_PHY_80 (1 << 1)
0878 #define USB_WIRELESS_PHY_107 (1 << 2)
0879 #define USB_WIRELESS_PHY_160 (1 << 3)
0880 #define USB_WIRELESS_PHY_200 (1 << 4)
0881 #define USB_WIRELESS_PHY_320 (1 << 5)
0882 #define USB_WIRELESS_PHY_400 (1 << 6)
0883 #define USB_WIRELESS_PHY_480 (1 << 7)
0884 __u8 bmTFITXPowerInfo;
0885 __u8 bmFFITXPowerInfo;
0886 __le16 bmBandGroup;
0887 __u8 bReserved;
0888 } __attribute__((packed));
0889
0890 #define USB_DT_USB_WIRELESS_CAP_SIZE 11
0891
0892
0893 #define USB_CAP_TYPE_EXT 2
0894
0895 struct usb_ext_cap_descriptor {
0896 __u8 bLength;
0897 __u8 bDescriptorType;
0898 __u8 bDevCapabilityType;
0899 __le32 bmAttributes;
0900 #define USB_LPM_SUPPORT (1 << 1)
0901 #define USB_BESL_SUPPORT (1 << 2)
0902 #define USB_BESL_BASELINE_VALID (1 << 3)
0903 #define USB_BESL_DEEP_VALID (1 << 4)
0904 #define USB_SET_BESL_BASELINE(p) (((p) & 0xf) << 8)
0905 #define USB_SET_BESL_DEEP(p) (((p) & 0xf) << 12)
0906 #define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
0907 #define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
0908 } __attribute__((packed));
0909
0910 #define USB_DT_USB_EXT_CAP_SIZE 7
0911
0912
0913
0914
0915
0916 #define USB_SS_CAP_TYPE 3
0917 struct usb_ss_cap_descriptor {
0918 __u8 bLength;
0919 __u8 bDescriptorType;
0920 __u8 bDevCapabilityType;
0921 __u8 bmAttributes;
0922 #define USB_LTM_SUPPORT (1 << 1)
0923 __le16 wSpeedSupported;
0924 #define USB_LOW_SPEED_OPERATION (1)
0925 #define USB_FULL_SPEED_OPERATION (1 << 1)
0926 #define USB_HIGH_SPEED_OPERATION (1 << 2)
0927 #define USB_5GBPS_OPERATION (1 << 3)
0928 __u8 bFunctionalitySupport;
0929 __u8 bU1devExitLat;
0930 __le16 bU2DevExitLat;
0931 } __attribute__((packed));
0932
0933 #define USB_DT_USB_SS_CAP_SIZE 10
0934
0935
0936
0937
0938
0939 #define CONTAINER_ID_TYPE 4
0940 struct usb_ss_container_id_descriptor {
0941 __u8 bLength;
0942 __u8 bDescriptorType;
0943 __u8 bDevCapabilityType;
0944 __u8 bReserved;
0945 __u8 ContainerID[16];
0946 } __attribute__((packed));
0947
0948 #define USB_DT_USB_SS_CONTN_ID_SIZE 20
0949
0950
0951
0952
0953
0954 #define USB_SSP_CAP_TYPE 0xa
0955 struct usb_ssp_cap_descriptor {
0956 __u8 bLength;
0957 __u8 bDescriptorType;
0958 __u8 bDevCapabilityType;
0959 __u8 bReserved;
0960 __le32 bmAttributes;
0961 #define USB_SSP_SUBLINK_SPEED_ATTRIBS (0x1f << 0)
0962 #define USB_SSP_SUBLINK_SPEED_IDS (0xf << 5)
0963 __le16 wFunctionalitySupport;
0964 #define USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID (0xf)
0965 #define USB_SSP_MIN_RX_LANE_COUNT (0xf << 8)
0966 #define USB_SSP_MIN_TX_LANE_COUNT (0xf << 12)
0967 __le16 wReserved;
0968 __le32 bmSublinkSpeedAttr[1];
0969 #define USB_SSP_SUBLINK_SPEED_SSID (0xf)
0970 #define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4)
0971 #define USB_SSP_SUBLINK_SPEED_LSE_BPS 0
0972 #define USB_SSP_SUBLINK_SPEED_LSE_KBPS 1
0973 #define USB_SSP_SUBLINK_SPEED_LSE_MBPS 2
0974 #define USB_SSP_SUBLINK_SPEED_LSE_GBPS 3
0975
0976 #define USB_SSP_SUBLINK_SPEED_ST (0x3 << 6)
0977 #define USB_SSP_SUBLINK_SPEED_ST_SYM_RX 0
0978 #define USB_SSP_SUBLINK_SPEED_ST_ASYM_RX 1
0979 #define USB_SSP_SUBLINK_SPEED_ST_SYM_TX 2
0980 #define USB_SSP_SUBLINK_SPEED_ST_ASYM_TX 3
0981
0982 #define USB_SSP_SUBLINK_SPEED_RSVD (0x3f << 8)
0983 #define USB_SSP_SUBLINK_SPEED_LP (0x3 << 14)
0984 #define USB_SSP_SUBLINK_SPEED_LP_SS 0
0985 #define USB_SSP_SUBLINK_SPEED_LP_SSP 1
0986
0987 #define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16)
0988 } __attribute__((packed));
0989
0990
0991
0992
0993
0994
0995 #define USB_PD_POWER_DELIVERY_CAPABILITY 0x06
0996
0997 #define USB_PD_BATTERY_INFO_CAPABILITY 0x07
0998
0999 #define USB_PD_PD_CONSUMER_PORT_CAPABILITY 0x08
1000
1001 #define USB_PD_PD_PROVIDER_PORT_CAPABILITY 0x09
1002
1003 struct usb_pd_cap_descriptor {
1004 __u8 bLength;
1005 __u8 bDescriptorType;
1006 __u8 bDevCapabilityType;
1007 __u8 bReserved;
1008 __le32 bmAttributes;
1009 #define USB_PD_CAP_BATTERY_CHARGING (1 << 1)
1010 #define USB_PD_CAP_USB_PD (1 << 2)
1011 #define USB_PD_CAP_PROVIDER (1 << 3)
1012 #define USB_PD_CAP_CONSUMER (1 << 4)
1013 #define USB_PD_CAP_CHARGING_POLICY (1 << 5)
1014 #define USB_PD_CAP_TYPE_C_CURRENT (1 << 6)
1015
1016 #define USB_PD_CAP_PWR_AC (1 << 8)
1017 #define USB_PD_CAP_PWR_BAT (1 << 9)
1018 #define USB_PD_CAP_PWR_USE_V_BUS (1 << 14)
1019
1020 __le16 bmProviderPorts;
1021 __le16 bmConsumerPorts;
1022 __le16 bcdBCVersion;
1023 __le16 bcdPDVersion;
1024 __le16 bcdUSBTypeCVersion;
1025 } __attribute__((packed));
1026
1027 struct usb_pd_cap_battery_info_descriptor {
1028 __u8 bLength;
1029 __u8 bDescriptorType;
1030 __u8 bDevCapabilityType;
1031
1032 __u8 iBattery;
1033
1034 __u8 iSerial;
1035 __u8 iManufacturer;
1036 __u8 bBatteryId;
1037 __u8 bReserved;
1038
1039
1040
1041
1042
1043 __le32 dwChargedThreshold;
1044
1045
1046
1047
1048
1049 __le32 dwWeakThreshold;
1050 __le32 dwBatteryDesignCapacity;
1051 __le32 dwBatteryLastFullchargeCapacity;
1052 } __attribute__((packed));
1053
1054 struct usb_pd_cap_consumer_port_descriptor {
1055 __u8 bLength;
1056 __u8 bDescriptorType;
1057 __u8 bDevCapabilityType;
1058 __u8 bReserved;
1059 __u8 bmCapabilities;
1060
1061 #define USB_PD_CAP_CONSUMER_BC (1 << 0)
1062 #define USB_PD_CAP_CONSUMER_PD (1 << 1)
1063 #define USB_PD_CAP_CONSUMER_TYPE_C (1 << 2)
1064 __le16 wMinVoltage;
1065 __le16 wMaxVoltage;
1066 __u16 wReserved;
1067 __le32 dwMaxOperatingPower;
1068 __le32 dwMaxPeakPower;
1069 __le32 dwMaxPeakPowerTime;
1070 #define USB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0xffff
1071 } __attribute__((packed));
1072
1073 struct usb_pd_cap_provider_port_descriptor {
1074 __u8 bLength;
1075 __u8 bDescriptorType;
1076 __u8 bDevCapabilityType;
1077 __u8 bReserved1;
1078 __u8 bmCapabilities;
1079
1080 #define USB_PD_CAP_PROVIDER_BC (1 << 0)
1081 #define USB_PD_CAP_PROVIDER_PD (1 << 1)
1082 #define USB_PD_CAP_PROVIDER_TYPE_C (1 << 2)
1083 __u8 bNumOfPDObjects;
1084 __u8 bReserved2;
1085 __le32 wPowerDataObject[];
1086 } __attribute__((packed));
1087
1088
1089
1090
1091
1092 #define USB_PTM_CAP_TYPE 0xb
1093 struct usb_ptm_cap_descriptor {
1094 __u8 bLength;
1095 __u8 bDescriptorType;
1096 __u8 bDevCapabilityType;
1097 } __attribute__((packed));
1098
1099 #define USB_DT_USB_PTM_ID_SIZE 3
1100
1101
1102
1103
1104 #define USB_DT_USB_SSP_CAP_SIZE(ssac) (12 + (ssac + 1) * 4)
1105
1106
1107
1108
1109
1110
1111 struct usb_wireless_ep_comp_descriptor {
1112 __u8 bLength;
1113 __u8 bDescriptorType;
1114
1115 __u8 bMaxBurst;
1116 __u8 bMaxSequence;
1117 __le16 wMaxStreamDelay;
1118 __le16 wOverTheAirPacketSize;
1119 __u8 bOverTheAirInterval;
1120 __u8 bmCompAttributes;
1121 #define USB_ENDPOINT_SWITCH_MASK 0x03
1122 #define USB_ENDPOINT_SWITCH_NO 0
1123 #define USB_ENDPOINT_SWITCH_SWITCH 1
1124 #define USB_ENDPOINT_SWITCH_SCALE 2
1125 } __attribute__((packed));
1126
1127
1128
1129
1130
1131
1132
1133 struct usb_handshake {
1134 __u8 bMessageNumber;
1135 __u8 bStatus;
1136 __u8 tTKID[3];
1137 __u8 bReserved;
1138 __u8 CDID[16];
1139 __u8 nonce[16];
1140 __u8 MIC[8];
1141 } __attribute__((packed));
1142
1143
1144
1145
1146
1147
1148
1149 struct usb_connection_context {
1150 __u8 CHID[16];
1151 __u8 CDID[16];
1152 __u8 CK[16];
1153 } __attribute__((packed));
1154
1155
1156
1157
1158
1159 enum usb_device_speed {
1160 USB_SPEED_UNKNOWN = 0,
1161 USB_SPEED_LOW, USB_SPEED_FULL,
1162 USB_SPEED_HIGH,
1163 USB_SPEED_WIRELESS,
1164 USB_SPEED_SUPER,
1165 USB_SPEED_SUPER_PLUS,
1166 };
1167
1168
1169 enum usb_device_state {
1170
1171
1172
1173 USB_STATE_NOTATTACHED = 0,
1174
1175
1176 USB_STATE_ATTACHED,
1177 USB_STATE_POWERED,
1178 USB_STATE_RECONNECTING,
1179 USB_STATE_UNAUTHENTICATED,
1180 USB_STATE_DEFAULT,
1181 USB_STATE_ADDRESS,
1182 USB_STATE_CONFIGURED,
1183
1184 USB_STATE_SUSPENDED
1185
1186
1187
1188
1189
1190
1191
1192 };
1193
1194 enum usb3_link_state {
1195 USB3_LPM_U0 = 0,
1196 USB3_LPM_U1,
1197 USB3_LPM_U2,
1198 USB3_LPM_U3
1199 };
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219 #define USB3_LPM_DISABLED 0x0
1220 #define USB3_LPM_U1_MAX_TIMEOUT 0x7F
1221 #define USB3_LPM_U2_MAX_TIMEOUT 0xFE
1222 #define USB3_LPM_DEVICE_INITIATED 0xFF
1223
1224 struct usb_set_sel_req {
1225 __u8 u1_sel;
1226 __u8 u1_pel;
1227 __le16 u2_sel;
1228 __le16 u2_pel;
1229 } __attribute__ ((packed));
1230
1231
1232
1233
1234
1235
1236 #define USB3_LPM_MAX_U1_SEL_PEL 0xFF
1237 #define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247 #define USB_SELF_POWER_VBUS_MAX_DRAW 100
1248
1249 #endif