1 #ifndef __USB3_H__ 2 #define __USB3_H__ 3 4 #include "asm/types.h" 5 #include "types.h" 6 7 #define UCONSTW(x) { (x) & 0xff, ((x) >> 8) & 0xff } 8 #define UCONSTDW(x) { (x) & 0xff, ((x) >> 8) & 0xff, \ 9 ((x) >> 16) & 0xff, ((x) >> 24) & 0xff } 10 11 #define HUAWEI_VENDOR_ID 0x12D1 12 #define HUAWEI_PRODUCT_ID 0xD001 13 //#define HUAWEI_PRODUCT_ID 0x3609 14 15 #define STRING_LANGUAGE 0 16 #define STRING_MANUFACTURER 1 17 #define STRING_PRODUCT 2 18 19 #define USB_SPEED_UNKNOWN 0x00 20 #define USB_SPEED_LOW 0x01 21 #define USB_SPEED_FULL 0x02 22 #define USB_SPEED_HIGH 0x03 23 #define USB_SPEED_VARIABLE 0x04 24 #define USB_SPEED_SUPER 0x05 25 26 #define UDESC_DEVICE 0x01 27 #define UDESC_CONFIG 0x02 28 #define UDESC_STRING 0x03 29 #define UDESC_INTERFACE 0x04 30 #define UDESC_ENDPOINT 0x05 31 #define UDESC_SS_USB_COMPANION 0x30 32 #define UDESC_DEVICE_QUALIFIER 0x06 33 #define UDESC_BOS 0x0f 34 #define UDESC_DEVICE_CAPABILITY 0x10 35 36 #define UT_GET_DIR(a) ((a) & 0x80) 37 #define UT_WRITE 0x00 38 #define UT_READ 0x80 39 40 #define UT_GET_TYPE(a) ((a) & 0x60) 41 #define UT_STANDARD 0x00 42 #define UT_CLASS 0x20 43 #define UT_VENDOR 0x40 44 45 #define UT_GET_RECIPIENT(a) ((a) & 0x1f) 46 #define UT_DEVICE 0x00 47 #define UT_INTERFACE 0x01 48 #define UT_ENDPOINT 0x02 49 #define UT_OTHER 0x03 50 51 #define UR_GET_STATUS 0x00 52 #define UR_CLEAR_FEATURE 0x01 53 #define UR_SET_FEATURE 0x03 54 #define UR_SET_ADDRESS 0x05 55 #define UR_GET_DESCRIPTOR 0x06 56 #define UR_SET_DESCRIPTOR 0x07 57 #define UR_GET_CONFIG 0x08 58 #define UR_SET_CONFIG 0x09 59 #define UR_GET_INTERFACE 0x0a 60 #define UR_SET_INTERFACE 0x0b 61 #define UR_SYNCH_FRAME 0x0c 62 #define UR_SET_SEL 0x30 63 #define UR_SET_ISOC_DELAY 0x31 64 65 /* Feature numbers */ 66 #define UF_ENDPOINT_HALT 0 67 #define UF_DEVICE_REMOTE_WAKEUP 1 68 #define UF_TEST_MODE 2 69 #define UF_DEVICE_B_HNP_ENABLE 3 70 #define UF_DEVICE_A_HNP_SUPPORT 4 71 #define UF_DEVICE_A_ALT_HNP_SUPPORT 5 72 #define UF_FUNCTION_SUSPEND 0 73 #define UF_U1_ENABLE 48 74 #define UF_U2_ENABLE 49 75 #define UF_LTM_ENABLE 50 76 77 /* OTG feature selectors */ 78 #define UOTG_B_HNP_ENABLE 3 79 #define UOTG_A_HNP_SUPPORT 4 80 #define UOTG_A_ALT_HNP_SUPPORT 5 81 #define UOTG_NTF_HOST_REL 51 82 #define UOTG_B3_RSP_ENABLE 52 83 84 #define UE_GET_DIR(a) ((a) & 0x80) 85 #define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7)) 86 #define UE_DIR_IN 0x80 87 #define UE_DIR_OUT 0x00 88 #define UE_ADDR 0x0f 89 #define UE_GET_ADDR(a) ((a) & UE_ADDR) 90 91 /** Maxpacket size for EP0, defined by USB3 spec */ 92 #define USB3_MAX_EP0_SIZE 512 93 94 /** Maxpacket size for any EP, defined by USB3 spec */ 95 #define USB3_MAX_PACKET_SIZE 1024 96 #define USB2_HS_MAX_PACKET_SIZE 512 97 #define USB2_FS_MAX_PACKET_SIZE 64 98 99 #define USB3_BULK_IN_EP 1 100 #define USB3_BULK_OUT_EP 1 101 102 typedef struct usb_device_request { 103 uint8_t bmRequestType; 104 uint8_t bRequest; 105 uint16_t wValue; 106 uint16_t wIndex; 107 uint16_t wLength; 108 } usb_device_request_t; 109 110 #pragma pack(1) 111 /** USB_DT_DEVICE: Device descriptor */ 112 typedef struct usb_device_descriptor { 113 uint8_t bLength; 114 uint8_t bDescriptorType; 115 116 uint16_t bcdUSB; 117 #define USB_CLASS_COMM 0x02 118 #define USB_CLASS_VENDOR_SPEC 0xFF 119 #define USB_SC_VENDOR_SPEC 0xFF 120 #define USB_PR_VENDOR_SPEC 0xFF 121 uint8_t bDeviceClass; 122 uint8_t bDeviceSubClass; 123 uint8_t bDeviceProtocol; 124 uint8_t bMaxPacketSize0; 125 uint16_t idVendor; 126 uint16_t idProduct; 127 uint16_t bcdDevice; 128 uint8_t iManufacturer; 129 uint8_t iProduct; 130 uint8_t iSerialNumber; 131 uint8_t bNumConfigurations; 132 } usb_device_descriptor_t; 133 134 /* USB_DT_CONFIG: Config descriptor */ 135 typedef struct usb_config_descriptor { 136 uint8_t bLength; 137 uint8_t bDescriptorType; 138 139 uint16_t wTotalLength; 140 uint8_t bNumInterfaces; 141 #define CONFIG_VALUE 1 142 uint8_t bConfigurationValue; 143 uint8_t iConfiguration; 144 #define USB_CONFIG_ATT_ONE (1 << 7) 145 uint8_t bmAttributes; 146 #define USB_CONFIG_VBUS_DRAW (0xFA) 147 uint8_t bMaxPower; 148 } usb_config_descriptor_t; 149 150 /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */ 151 typedef struct usb_qualifier_descriptor { 152 uint8_t bLength; 153 uint8_t bDescriptorType; 154 155 uint16_t bcdUSB; 156 uint8_t bDeviceClass; 157 uint8_t bDeviceSubClass; 158 uint8_t bDeviceProtocol; 159 uint8_t bMaxPacketSize0; 160 uint8_t bNumConfigurations; 161 uint8_t bRESERVED; 162 } usb_qualifier_descriptor_t; 163 164 /* USB_DT_INTERFACE: Interface descriptor */ 165 typedef struct usb_interface_descriptor { 166 uint8_t bLength; 167 uint8_t bDescriptorType; 168 169 uint8_t bInterfaceNumber; 170 uint8_t bAlternateSetting; 171 uint8_t bNumEndpoints; 172 uint8_t bInterfaceClass; 173 uint8_t bInterfaceSubClass; 174 uint8_t bInterfaceProtocol; 175 uint8_t iInterface; 176 } usb_interface_descriptor_t; 177 178 /* USB_DT_ENDPOINT: Endpoint descriptor */ 179 typedef struct usb_endpoint_descriptor { 180 uint8_t bLength; 181 uint8_t bDescriptorType; 182 183 uint8_t bEndpointAddress; 184 uint8_t bmAttributes; 185 #define USB_ENDPOINT_XFER_CONTROL 0x00 186 #define USB_ENDPOINT_XFER_ISOC 0x01 187 #define USB_ENDPOINT_XFER_BULK 0x02 188 #define USB_ENDPOINT_XFER_INT 0x03 189 uint16_t wMaxPacketSize; 190 uint8_t bInterval; 191 } usb_endpoint_descriptor_t; 192 193 /* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */ 194 typedef struct usb_ss_ep_comp_descriptor { 195 uint8_t bLength; 196 uint8_t bDescriptorType; 197 198 uint8_t bMaxBurst; 199 uint8_t bmAttributes; 200 uint16_t wBytesPerInterval; 201 } usb_ss_ep_comp_descriptor_t; 202 203 /* WUSB BOS Descriptor (Binary device Object Store) */ 204 typedef struct wusb_bos_desc { 205 uint8_t bLength; 206 uint8_t bDescriptorType; 207 uint16_t wTotalLength; 208 uint8_t bNumDeviceCaps; 209 } wusb_bos_desc_t; 210 211 #define USB_DEVICE_CAPABILITY_20_EXTENSION 0x02 212 typedef struct usb_dev_cap_20_ext_desc { 213 uint8_t bLength; 214 uint8_t bDescriptorType; 215 uint8_t bDevCapabilityType; 216 #define USB_20_EXT_LPM 0x02 217 uint32_t bmAttributes; 218 } usb_dev_cap_20_ext_desc_t; 219 220 #define USB_DEVICE_CAPABILITY_SS_USB 0x03 221 typedef struct usb_dev_cap_ss_usb { 222 uint8_t bLength; 223 uint8_t bDescriptorType; 224 uint8_t bDevCapabilityType; 225 #define USB_DC_SS_USB_LTM_CAPABLE 0x02 226 uint8_t bmAttributes; 227 #define USB_DC_SS_USB_SPEED_SUPPORT_LOW 0x01 228 #define USB_DC_SS_USB_SPEED_SUPPORT_FULL 0x02 229 #define USB_DC_SS_USB_SPEED_SUPPORT_HIGH 0x04 230 #define USB_DC_SS_USB_SPEED_SUPPORT_SS 0x08 231 uint32_t wSpeedsSupported; 232 uint8_t bFunctionalitySupport; 233 uint8_t bU1DevExitLat; 234 uint32_t wU2DevExitLat; 235 } usb_dev_cap_ss_usb_t; 236 237 #define USB_DEVICE_CAPABILITY_CONTAINER_ID 0x04 238 typedef struct usb_dev_cap_container_id { 239 uint8_t bLength; 240 uint8_t bDescriptorType; 241 uint8_t bDevCapabilityType; 242 uint8_t bReserved; 243 uint8_t containerID[16]; 244 } usb_dev_cap_container_id_t; 245 #pragma pack() 246 247 #endif /* __USB3_H__ */ 248 249