diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
| commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
| tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/linux/usb | |
| parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) | |
Patched in Tegra support.
Diffstat (limited to 'include/linux/usb')
35 files changed, 1955 insertions, 1451 deletions
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h index ed13053153f..964cb603f7c 100644 --- a/include/linux/usb/audio-v2.h +++ b/include/linux/usb/audio-v2.h | |||
| @@ -43,27 +43,6 @@ static inline bool uac2_control_is_writeable(u32 bmControls, u8 control) | |||
| 43 | return (bmControls >> (control * 2)) & 0x2; | 43 | return (bmControls >> (control * 2)) & 0x2; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | /* 4.7.2 Class-Specific AC Interface Descriptor */ | ||
| 47 | struct uac2_ac_header_descriptor { | ||
| 48 | __u8 bLength; /* 9 */ | ||
| 49 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
| 50 | __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ | ||
| 51 | __le16 bcdADC; /* 0x0200 */ | ||
| 52 | __u8 bCategory; | ||
| 53 | __le16 wTotalLength; /* includes Unit and Terminal desc. */ | ||
| 54 | __u8 bmControls; | ||
| 55 | } __packed; | ||
| 56 | |||
| 57 | /* 2.3.1.6 Type I Format Type Descriptor (Frmts20 final.pdf)*/ | ||
| 58 | struct uac2_format_type_i_descriptor { | ||
| 59 | __u8 bLength; /* in bytes: 6 */ | ||
| 60 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
| 61 | __u8 bDescriptorSubtype; /* FORMAT_TYPE */ | ||
| 62 | __u8 bFormatType; /* FORMAT_TYPE_1 */ | ||
| 63 | __u8 bSubslotSize; /* {1,2,3,4} */ | ||
| 64 | __u8 bBitResolution; | ||
| 65 | } __packed; | ||
| 66 | |||
| 67 | /* 4.7.2.1 Clock Source Descriptor */ | 46 | /* 4.7.2.1 Clock Source Descriptor */ |
| 68 | 47 | ||
| 69 | struct uac_clock_source_descriptor { | 48 | struct uac_clock_source_descriptor { |
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h index 3d84619110a..a54b8255d75 100644 --- a/include/linux/usb/audio.h +++ b/include/linux/usb/audio.h | |||
| @@ -17,11 +17,531 @@ | |||
| 17 | * Types and defines in this file are either specific to version 1.0 of | 17 | * Types and defines in this file are either specific to version 1.0 of |
| 18 | * this standard or common for newer versions. | 18 | * this standard or common for newer versions. |
| 19 | */ | 19 | */ |
| 20 | |||
| 20 | #ifndef __LINUX_USB_AUDIO_H | 21 | #ifndef __LINUX_USB_AUDIO_H |
| 21 | #define __LINUX_USB_AUDIO_H | 22 | #define __LINUX_USB_AUDIO_H |
| 22 | 23 | ||
| 23 | #include <uapi/linux/usb/audio.h> | 24 | #include <linux/types.h> |
| 25 | |||
| 26 | /* bInterfaceProtocol values to denote the version of the standard used */ | ||
| 27 | #define UAC_VERSION_1 0x00 | ||
| 28 | #define UAC_VERSION_2 0x20 | ||
| 29 | |||
| 30 | /* A.2 Audio Interface Subclass Codes */ | ||
| 31 | #define USB_SUBCLASS_AUDIOCONTROL 0x01 | ||
| 32 | #define USB_SUBCLASS_AUDIOSTREAMING 0x02 | ||
| 33 | #define USB_SUBCLASS_MIDISTREAMING 0x03 | ||
| 34 | |||
| 35 | /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */ | ||
| 36 | #define UAC_HEADER 0x01 | ||
| 37 | #define UAC_INPUT_TERMINAL 0x02 | ||
| 38 | #define UAC_OUTPUT_TERMINAL 0x03 | ||
| 39 | #define UAC_MIXER_UNIT 0x04 | ||
| 40 | #define UAC_SELECTOR_UNIT 0x05 | ||
| 41 | #define UAC_FEATURE_UNIT 0x06 | ||
| 42 | #define UAC1_PROCESSING_UNIT 0x07 | ||
| 43 | #define UAC1_EXTENSION_UNIT 0x08 | ||
| 44 | |||
| 45 | /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ | ||
| 46 | #define UAC_AS_GENERAL 0x01 | ||
| 47 | #define UAC_FORMAT_TYPE 0x02 | ||
| 48 | #define UAC_FORMAT_SPECIFIC 0x03 | ||
| 49 | |||
| 50 | /* A.7 Processing Unit Process Types */ | ||
| 51 | #define UAC_PROCESS_UNDEFINED 0x00 | ||
| 52 | #define UAC_PROCESS_UP_DOWNMIX 0x01 | ||
| 53 | #define UAC_PROCESS_DOLBY_PROLOGIC 0x02 | ||
| 54 | #define UAC_PROCESS_STEREO_EXTENDER 0x03 | ||
| 55 | #define UAC_PROCESS_REVERB 0x04 | ||
| 56 | #define UAC_PROCESS_CHORUS 0x05 | ||
| 57 | #define UAC_PROCESS_DYN_RANGE_COMP 0x06 | ||
| 58 | |||
| 59 | /* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */ | ||
| 60 | #define UAC_EP_GENERAL 0x01 | ||
| 61 | |||
| 62 | /* A.9 Audio Class-Specific Request Codes */ | ||
| 63 | #define UAC_SET_ 0x00 | ||
| 64 | #define UAC_GET_ 0x80 | ||
| 65 | |||
| 66 | #define UAC__CUR 0x1 | ||
| 67 | #define UAC__MIN 0x2 | ||
| 68 | #define UAC__MAX 0x3 | ||
| 69 | #define UAC__RES 0x4 | ||
| 70 | #define UAC__MEM 0x5 | ||
| 71 | |||
| 72 | #define UAC_SET_CUR (UAC_SET_ | UAC__CUR) | ||
| 73 | #define UAC_GET_CUR (UAC_GET_ | UAC__CUR) | ||
| 74 | #define UAC_SET_MIN (UAC_SET_ | UAC__MIN) | ||
| 75 | #define UAC_GET_MIN (UAC_GET_ | UAC__MIN) | ||
| 76 | #define UAC_SET_MAX (UAC_SET_ | UAC__MAX) | ||
| 77 | #define UAC_GET_MAX (UAC_GET_ | UAC__MAX) | ||
| 78 | #define UAC_SET_RES (UAC_SET_ | UAC__RES) | ||
| 79 | #define UAC_GET_RES (UAC_GET_ | UAC__RES) | ||
| 80 | #define UAC_SET_MEM (UAC_SET_ | UAC__MEM) | ||
| 81 | #define UAC_GET_MEM (UAC_GET_ | UAC__MEM) | ||
| 82 | |||
| 83 | #define UAC_GET_STAT 0xff | ||
| 84 | |||
| 85 | /* A.10 Control Selector Codes */ | ||
| 86 | |||
| 87 | /* A.10.1 Terminal Control Selectors */ | ||
| 88 | #define UAC_TERM_COPY_PROTECT 0x01 | ||
| 89 | |||
| 90 | /* A.10.2 Feature Unit Control Selectors */ | ||
| 91 | #define UAC_FU_MUTE 0x01 | ||
| 92 | #define UAC_FU_VOLUME 0x02 | ||
| 93 | #define UAC_FU_BASS 0x03 | ||
| 94 | #define UAC_FU_MID 0x04 | ||
| 95 | #define UAC_FU_TREBLE 0x05 | ||
| 96 | #define UAC_FU_GRAPHIC_EQUALIZER 0x06 | ||
| 97 | #define UAC_FU_AUTOMATIC_GAIN 0x07 | ||
| 98 | #define UAC_FU_DELAY 0x08 | ||
| 99 | #define UAC_FU_BASS_BOOST 0x09 | ||
| 100 | #define UAC_FU_LOUDNESS 0x0a | ||
| 101 | |||
| 102 | #define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1)) | ||
| 103 | |||
| 104 | /* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */ | ||
| 105 | #define UAC_UD_ENABLE 0x01 | ||
| 106 | #define UAC_UD_MODE_SELECT 0x02 | ||
| 107 | |||
| 108 | /* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */ | ||
| 109 | #define UAC_DP_ENABLE 0x01 | ||
| 110 | #define UAC_DP_MODE_SELECT 0x02 | ||
| 111 | |||
| 112 | /* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */ | ||
| 113 | #define UAC_3D_ENABLE 0x01 | ||
| 114 | #define UAC_3D_SPACE 0x02 | ||
| 115 | |||
| 116 | /* A.10.3.4 Reverberation Processing Unit Control Selectors */ | ||
| 117 | #define UAC_REVERB_ENABLE 0x01 | ||
| 118 | #define UAC_REVERB_LEVEL 0x02 | ||
| 119 | #define UAC_REVERB_TIME 0x03 | ||
| 120 | #define UAC_REVERB_FEEDBACK 0x04 | ||
| 121 | |||
| 122 | /* A.10.3.5 Chorus Processing Unit Control Selectors */ | ||
| 123 | #define UAC_CHORUS_ENABLE 0x01 | ||
| 124 | #define UAC_CHORUS_LEVEL 0x02 | ||
| 125 | #define UAC_CHORUS_RATE 0x03 | ||
| 126 | #define UAC_CHORUS_DEPTH 0x04 | ||
| 127 | |||
| 128 | /* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */ | ||
| 129 | #define UAC_DCR_ENABLE 0x01 | ||
| 130 | #define UAC_DCR_RATE 0x02 | ||
| 131 | #define UAC_DCR_MAXAMPL 0x03 | ||
| 132 | #define UAC_DCR_THRESHOLD 0x04 | ||
| 133 | #define UAC_DCR_ATTACK_TIME 0x05 | ||
| 134 | #define UAC_DCR_RELEASE_TIME 0x06 | ||
| 135 | |||
| 136 | /* A.10.4 Extension Unit Control Selectors */ | ||
| 137 | #define UAC_XU_ENABLE 0x01 | ||
| 138 | |||
| 139 | /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ | ||
| 140 | #define UAC_MS_HEADER 0x01 | ||
| 141 | #define UAC_MIDI_IN_JACK 0x02 | ||
| 142 | #define UAC_MIDI_OUT_JACK 0x03 | ||
| 143 | |||
| 144 | /* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */ | ||
| 145 | #define UAC_MS_GENERAL 0x01 | ||
| 146 | |||
| 147 | /* Terminals - 2.1 USB Terminal Types */ | ||
| 148 | #define UAC_TERMINAL_UNDEFINED 0x100 | ||
| 149 | #define UAC_TERMINAL_STREAMING 0x101 | ||
| 150 | #define UAC_TERMINAL_VENDOR_SPEC 0x1FF | ||
| 151 | |||
| 152 | /* Terminal Control Selectors */ | ||
| 153 | /* 4.3.2 Class-Specific AC Interface Descriptor */ | ||
| 154 | struct uac1_ac_header_descriptor { | ||
| 155 | __u8 bLength; /* 8 + n */ | ||
| 156 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
| 157 | __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ | ||
| 158 | __le16 bcdADC; /* 0x0100 */ | ||
| 159 | __le16 wTotalLength; /* includes Unit and Terminal desc. */ | ||
| 160 | __u8 bInCollection; /* n */ | ||
| 161 | __u8 baInterfaceNr[]; /* [n] */ | ||
| 162 | } __attribute__ ((packed)); | ||
| 163 | |||
| 164 | #define UAC_DT_AC_HEADER_SIZE(n) (8 + (n)) | ||
| 165 | |||
| 166 | /* As above, but more useful for defining your own descriptors: */ | ||
| 167 | #define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ | ||
| 168 | struct uac1_ac_header_descriptor_##n { \ | ||
| 169 | __u8 bLength; \ | ||
| 170 | __u8 bDescriptorType; \ | ||
| 171 | __u8 bDescriptorSubtype; \ | ||
| 172 | __le16 bcdADC; \ | ||
| 173 | __le16 wTotalLength; \ | ||
| 174 | __u8 bInCollection; \ | ||
| 175 | __u8 baInterfaceNr[n]; \ | ||
| 176 | } __attribute__ ((packed)) | ||
| 177 | |||
| 178 | /* 4.3.2.1 Input Terminal Descriptor */ | ||
| 179 | struct uac_input_terminal_descriptor { | ||
| 180 | __u8 bLength; /* in bytes: 12 */ | ||
| 181 | __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ | ||
| 182 | __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */ | ||
| 183 | __u8 bTerminalID; /* Constant uniquely terminal ID */ | ||
| 184 | __le16 wTerminalType; /* USB Audio Terminal Types */ | ||
| 185 | __u8 bAssocTerminal; /* ID of the Output Terminal associated */ | ||
| 186 | __u8 bNrChannels; /* Number of logical output channels */ | ||
| 187 | __le16 wChannelConfig; | ||
| 188 | __u8 iChannelNames; | ||
| 189 | __u8 iTerminal; | ||
| 190 | } __attribute__ ((packed)); | ||
| 191 | |||
| 192 | #define UAC_DT_INPUT_TERMINAL_SIZE 12 | ||
| 193 | |||
| 194 | /* Terminals - 2.2 Input Terminal Types */ | ||
| 195 | #define UAC_INPUT_TERMINAL_UNDEFINED 0x200 | ||
| 196 | #define UAC_INPUT_TERMINAL_MICROPHONE 0x201 | ||
| 197 | #define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202 | ||
| 198 | #define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203 | ||
| 199 | #define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204 | ||
| 200 | #define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205 | ||
| 201 | #define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206 | ||
| 202 | |||
| 203 | /* Terminals - control selectors */ | ||
| 204 | |||
| 205 | #define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01 | ||
| 206 | |||
| 207 | /* 4.3.2.2 Output Terminal Descriptor */ | ||
| 208 | struct uac1_output_terminal_descriptor { | ||
| 209 | __u8 bLength; /* in bytes: 9 */ | ||
| 210 | __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ | ||
| 211 | __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */ | ||
| 212 | __u8 bTerminalID; /* Constant uniquely terminal ID */ | ||
| 213 | __le16 wTerminalType; /* USB Audio Terminal Types */ | ||
| 214 | __u8 bAssocTerminal; /* ID of the Input Terminal associated */ | ||
| 215 | __u8 bSourceID; /* ID of the connected Unit or Terminal*/ | ||
| 216 | __u8 iTerminal; | ||
| 217 | } __attribute__ ((packed)); | ||
| 218 | |||
| 219 | #define UAC_DT_OUTPUT_TERMINAL_SIZE 9 | ||
| 220 | |||
| 221 | /* Terminals - 2.3 Output Terminal Types */ | ||
| 222 | #define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300 | ||
| 223 | #define UAC_OUTPUT_TERMINAL_SPEAKER 0x301 | ||
| 224 | #define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302 | ||
| 225 | #define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303 | ||
| 226 | #define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304 | ||
| 227 | #define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305 | ||
| 228 | #define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306 | ||
| 229 | #define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307 | ||
| 230 | |||
| 231 | /* Set bControlSize = 2 as default setting */ | ||
| 232 | #define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2) | ||
| 233 | |||
| 234 | /* As above, but more useful for defining your own descriptors: */ | ||
| 235 | #define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \ | ||
| 236 | struct uac_feature_unit_descriptor_##ch { \ | ||
| 237 | __u8 bLength; \ | ||
| 238 | __u8 bDescriptorType; \ | ||
| 239 | __u8 bDescriptorSubtype; \ | ||
| 240 | __u8 bUnitID; \ | ||
| 241 | __u8 bSourceID; \ | ||
| 242 | __u8 bControlSize; \ | ||
| 243 | __le16 bmaControls[ch + 1]; \ | ||
| 244 | __u8 iFeature; \ | ||
| 245 | } __attribute__ ((packed)) | ||
| 246 | |||
| 247 | /* 4.3.2.3 Mixer Unit Descriptor */ | ||
| 248 | struct uac_mixer_unit_descriptor { | ||
| 249 | __u8 bLength; | ||
| 250 | __u8 bDescriptorType; | ||
| 251 | __u8 bDescriptorSubtype; | ||
| 252 | __u8 bUnitID; | ||
| 253 | __u8 bNrInPins; | ||
| 254 | __u8 baSourceID[]; | ||
| 255 | } __attribute__ ((packed)); | ||
| 24 | 256 | ||
| 257 | static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc) | ||
| 258 | { | ||
| 259 | return desc->baSourceID[desc->bNrInPins]; | ||
| 260 | } | ||
| 261 | |||
| 262 | static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc, | ||
| 263 | int protocol) | ||
| 264 | { | ||
| 265 | if (protocol == UAC_VERSION_1) | ||
| 266 | return (desc->baSourceID[desc->bNrInPins + 2] << 8) | | ||
| 267 | desc->baSourceID[desc->bNrInPins + 1]; | ||
| 268 | else | ||
| 269 | return (desc->baSourceID[desc->bNrInPins + 4] << 24) | | ||
| 270 | (desc->baSourceID[desc->bNrInPins + 3] << 16) | | ||
| 271 | (desc->baSourceID[desc->bNrInPins + 2] << 8) | | ||
| 272 | (desc->baSourceID[desc->bNrInPins + 1]); | ||
| 273 | } | ||
| 274 | |||
| 275 | static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc, | ||
| 276 | int protocol) | ||
| 277 | { | ||
| 278 | return (protocol == UAC_VERSION_1) ? | ||
| 279 | desc->baSourceID[desc->bNrInPins + 3] : | ||
| 280 | desc->baSourceID[desc->bNrInPins + 5]; | ||
| 281 | } | ||
| 282 | |||
| 283 | static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc, | ||
| 284 | int protocol) | ||
| 285 | { | ||
| 286 | return (protocol == UAC_VERSION_1) ? | ||
| 287 | &desc->baSourceID[desc->bNrInPins + 4] : | ||
| 288 | &desc->baSourceID[desc->bNrInPins + 6]; | ||
| 289 | } | ||
| 290 | |||
| 291 | static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc) | ||
| 292 | { | ||
| 293 | __u8 *raw = (__u8 *) desc; | ||
| 294 | return raw[desc->bLength - 1]; | ||
| 295 | } | ||
| 296 | |||
| 297 | /* 4.3.2.4 Selector Unit Descriptor */ | ||
| 298 | struct uac_selector_unit_descriptor { | ||
| 299 | __u8 bLength; | ||
| 300 | __u8 bDescriptorType; | ||
| 301 | __u8 bDescriptorSubtype; | ||
| 302 | __u8 bUintID; | ||
| 303 | __u8 bNrInPins; | ||
| 304 | __u8 baSourceID[]; | ||
| 305 | } __attribute__ ((packed)); | ||
| 306 | |||
| 307 | static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc) | ||
| 308 | { | ||
| 309 | __u8 *raw = (__u8 *) desc; | ||
| 310 | return raw[desc->bLength - 1]; | ||
| 311 | } | ||
| 312 | |||
| 313 | /* 4.3.2.5 Feature Unit Descriptor */ | ||
| 314 | struct uac_feature_unit_descriptor { | ||
| 315 | __u8 bLength; | ||
| 316 | __u8 bDescriptorType; | ||
| 317 | __u8 bDescriptorSubtype; | ||
| 318 | __u8 bUnitID; | ||
| 319 | __u8 bSourceID; | ||
| 320 | __u8 bControlSize; | ||
| 321 | __u8 bmaControls[0]; /* variable length */ | ||
| 322 | } __attribute__((packed)); | ||
| 323 | |||
| 324 | static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc) | ||
| 325 | { | ||
| 326 | __u8 *raw = (__u8 *) desc; | ||
| 327 | return raw[desc->bLength - 1]; | ||
| 328 | } | ||
| 329 | |||
| 330 | /* 4.3.2.6 Processing Unit Descriptors */ | ||
| 331 | struct uac_processing_unit_descriptor { | ||
| 332 | __u8 bLength; | ||
| 333 | __u8 bDescriptorType; | ||
| 334 | __u8 bDescriptorSubtype; | ||
| 335 | __u8 bUnitID; | ||
| 336 | __u16 wProcessType; | ||
| 337 | __u8 bNrInPins; | ||
| 338 | __u8 baSourceID[]; | ||
| 339 | } __attribute__ ((packed)); | ||
| 340 | |||
| 341 | static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc) | ||
| 342 | { | ||
| 343 | return desc->baSourceID[desc->bNrInPins]; | ||
| 344 | } | ||
| 345 | |||
| 346 | static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc, | ||
| 347 | int protocol) | ||
| 348 | { | ||
| 349 | if (protocol == UAC_VERSION_1) | ||
| 350 | return (desc->baSourceID[desc->bNrInPins + 2] << 8) | | ||
| 351 | desc->baSourceID[desc->bNrInPins + 1]; | ||
| 352 | else | ||
| 353 | return (desc->baSourceID[desc->bNrInPins + 4] << 24) | | ||
| 354 | (desc->baSourceID[desc->bNrInPins + 3] << 16) | | ||
| 355 | (desc->baSourceID[desc->bNrInPins + 2] << 8) | | ||
| 356 | (desc->baSourceID[desc->bNrInPins + 1]); | ||
| 357 | } | ||
| 358 | |||
| 359 | static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc, | ||
| 360 | int protocol) | ||
| 361 | { | ||
| 362 | return (protocol == UAC_VERSION_1) ? | ||
| 363 | desc->baSourceID[desc->bNrInPins + 3] : | ||
| 364 | desc->baSourceID[desc->bNrInPins + 5]; | ||
| 365 | } | ||
| 366 | |||
| 367 | static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc, | ||
| 368 | int protocol) | ||
| 369 | { | ||
| 370 | return (protocol == UAC_VERSION_1) ? | ||
| 371 | desc->baSourceID[desc->bNrInPins + 4] : | ||
| 372 | desc->baSourceID[desc->bNrInPins + 6]; | ||
| 373 | } | ||
| 374 | |||
| 375 | static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc, | ||
| 376 | int protocol) | ||
| 377 | { | ||
| 378 | return (protocol == UAC_VERSION_1) ? | ||
| 379 | &desc->baSourceID[desc->bNrInPins + 5] : | ||
| 380 | &desc->baSourceID[desc->bNrInPins + 7]; | ||
| 381 | } | ||
| 382 | |||
| 383 | static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc, | ||
| 384 | int protocol) | ||
| 385 | { | ||
| 386 | __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); | ||
| 387 | return desc->baSourceID[desc->bNrInPins + control_size]; | ||
| 388 | } | ||
| 389 | |||
| 390 | static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc, | ||
| 391 | int protocol) | ||
| 392 | { | ||
| 393 | __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); | ||
| 394 | return &desc->baSourceID[desc->bNrInPins + control_size + 1]; | ||
| 395 | } | ||
| 396 | |||
| 397 | /* 4.5.2 Class-Specific AS Interface Descriptor */ | ||
| 398 | struct uac1_as_header_descriptor { | ||
| 399 | __u8 bLength; /* in bytes: 7 */ | ||
| 400 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
| 401 | __u8 bDescriptorSubtype; /* AS_GENERAL */ | ||
| 402 | __u8 bTerminalLink; /* Terminal ID of connected Terminal */ | ||
| 403 | __u8 bDelay; /* Delay introduced by the data path */ | ||
| 404 | __le16 wFormatTag; /* The Audio Data Format */ | ||
| 405 | } __attribute__ ((packed)); | ||
| 406 | |||
| 407 | #define UAC_DT_AS_HEADER_SIZE 7 | ||
| 408 | |||
| 409 | /* Formats - A.1.1 Audio Data Format Type I Codes */ | ||
| 410 | #define UAC_FORMAT_TYPE_I_UNDEFINED 0x0 | ||
| 411 | #define UAC_FORMAT_TYPE_I_PCM 0x1 | ||
| 412 | #define UAC_FORMAT_TYPE_I_PCM8 0x2 | ||
| 413 | #define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3 | ||
| 414 | #define UAC_FORMAT_TYPE_I_ALAW 0x4 | ||
| 415 | #define UAC_FORMAT_TYPE_I_MULAW 0x5 | ||
| 416 | |||
| 417 | struct uac_format_type_i_continuous_descriptor { | ||
| 418 | __u8 bLength; /* in bytes: 8 + (ns * 3) */ | ||
| 419 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
| 420 | __u8 bDescriptorSubtype; /* FORMAT_TYPE */ | ||
| 421 | __u8 bFormatType; /* FORMAT_TYPE_1 */ | ||
| 422 | __u8 bNrChannels; /* physical channels in the stream */ | ||
| 423 | __u8 bSubframeSize; /* */ | ||
| 424 | __u8 bBitResolution; | ||
| 425 | __u8 bSamFreqType; | ||
| 426 | __u8 tLowerSamFreq[3]; | ||
| 427 | __u8 tUpperSamFreq[3]; | ||
| 428 | } __attribute__ ((packed)); | ||
| 429 | |||
| 430 | #define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14 | ||
| 431 | |||
| 432 | struct uac_format_type_i_discrete_descriptor { | ||
| 433 | __u8 bLength; /* in bytes: 8 + (ns * 3) */ | ||
| 434 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
| 435 | __u8 bDescriptorSubtype; /* FORMAT_TYPE */ | ||
| 436 | __u8 bFormatType; /* FORMAT_TYPE_1 */ | ||
| 437 | __u8 bNrChannels; /* physical channels in the stream */ | ||
| 438 | __u8 bSubframeSize; /* */ | ||
| 439 | __u8 bBitResolution; | ||
| 440 | __u8 bSamFreqType; | ||
| 441 | __u8 tSamFreq[][3]; | ||
| 442 | } __attribute__ ((packed)); | ||
| 443 | |||
| 444 | #define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \ | ||
| 445 | struct uac_format_type_i_discrete_descriptor_##n { \ | ||
| 446 | __u8 bLength; \ | ||
| 447 | __u8 bDescriptorType; \ | ||
| 448 | __u8 bDescriptorSubtype; \ | ||
| 449 | __u8 bFormatType; \ | ||
| 450 | __u8 bNrChannels; \ | ||
| 451 | __u8 bSubframeSize; \ | ||
| 452 | __u8 bBitResolution; \ | ||
| 453 | __u8 bSamFreqType; \ | ||
| 454 | __u8 tSamFreq[n][3]; \ | ||
| 455 | } __attribute__ ((packed)) | ||
| 456 | |||
| 457 | #define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3)) | ||
| 458 | |||
| 459 | struct uac_format_type_i_ext_descriptor { | ||
| 460 | __u8 bLength; | ||
| 461 | __u8 bDescriptorType; | ||
| 462 | __u8 bDescriptorSubtype; | ||
| 463 | __u8 bFormatType; | ||
| 464 | __u8 bSubslotSize; | ||
| 465 | __u8 bBitResolution; | ||
| 466 | __u8 bHeaderLength; | ||
| 467 | __u8 bControlSize; | ||
| 468 | __u8 bSideBandProtocol; | ||
| 469 | } __attribute__((packed)); | ||
| 470 | |||
| 471 | /* Formats - Audio Data Format Type I Codes */ | ||
| 472 | |||
| 473 | #define UAC_FORMAT_TYPE_II_MPEG 0x1001 | ||
| 474 | #define UAC_FORMAT_TYPE_II_AC3 0x1002 | ||
| 475 | |||
| 476 | struct uac_format_type_ii_discrete_descriptor { | ||
| 477 | __u8 bLength; | ||
| 478 | __u8 bDescriptorType; | ||
| 479 | __u8 bDescriptorSubtype; | ||
| 480 | __u8 bFormatType; | ||
| 481 | __le16 wMaxBitRate; | ||
| 482 | __le16 wSamplesPerFrame; | ||
| 483 | __u8 bSamFreqType; | ||
| 484 | __u8 tSamFreq[][3]; | ||
| 485 | } __attribute__((packed)); | ||
| 486 | |||
| 487 | struct uac_format_type_ii_ext_descriptor { | ||
| 488 | __u8 bLength; | ||
| 489 | __u8 bDescriptorType; | ||
| 490 | __u8 bDescriptorSubtype; | ||
| 491 | __u8 bFormatType; | ||
| 492 | __u16 wMaxBitRate; | ||
| 493 | __u16 wSamplesPerFrame; | ||
| 494 | __u8 bHeaderLength; | ||
| 495 | __u8 bSideBandProtocol; | ||
| 496 | } __attribute__((packed)); | ||
| 497 | |||
| 498 | /* type III */ | ||
| 499 | #define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001 | ||
| 500 | #define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002 | ||
| 501 | #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003 | ||
| 502 | #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004 | ||
| 503 | #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005 | ||
| 504 | #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006 | ||
| 505 | |||
| 506 | /* Formats - A.2 Format Type Codes */ | ||
| 507 | #define UAC_FORMAT_TYPE_UNDEFINED 0x0 | ||
| 508 | #define UAC_FORMAT_TYPE_I 0x1 | ||
| 509 | #define UAC_FORMAT_TYPE_II 0x2 | ||
| 510 | #define UAC_FORMAT_TYPE_III 0x3 | ||
| 511 | #define UAC_EXT_FORMAT_TYPE_I 0x81 | ||
| 512 | #define UAC_EXT_FORMAT_TYPE_II 0x82 | ||
| 513 | #define UAC_EXT_FORMAT_TYPE_III 0x83 | ||
| 514 | |||
| 515 | struct uac_iso_endpoint_descriptor { | ||
| 516 | __u8 bLength; /* in bytes: 7 */ | ||
| 517 | __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ | ||
| 518 | __u8 bDescriptorSubtype; /* EP_GENERAL */ | ||
| 519 | __u8 bmAttributes; | ||
| 520 | __u8 bLockDelayUnits; | ||
| 521 | __le16 wLockDelay; | ||
| 522 | } __attribute__((packed)); | ||
| 523 | #define UAC_ISO_ENDPOINT_DESC_SIZE 7 | ||
| 524 | |||
| 525 | #define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01 | ||
| 526 | #define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 | ||
| 527 | #define UAC_EP_CS_ATTR_FILL_MAX 0x80 | ||
| 528 | |||
| 529 | /* status word format (3.7.1.1) */ | ||
| 530 | |||
| 531 | #define UAC1_STATUS_TYPE_ORIG_MASK 0x0f | ||
| 532 | #define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0 | ||
| 533 | #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1 | ||
| 534 | #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2 | ||
| 535 | |||
| 536 | #define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7) | ||
| 537 | #define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6) | ||
| 538 | |||
| 539 | struct uac1_status_word { | ||
| 540 | __u8 bStatusType; | ||
| 541 | __u8 bOriginator; | ||
| 542 | } __attribute__((packed)); | ||
| 543 | |||
| 544 | #ifdef __KERNEL__ | ||
| 25 | 545 | ||
| 26 | struct usb_audio_control { | 546 | struct usb_audio_control { |
| 27 | struct list_head list; | 547 | struct list_head list; |
| @@ -41,4 +561,6 @@ struct usb_audio_control_selector { | |||
| 41 | struct usb_descriptor_header *desc; | 561 | struct usb_descriptor_header *desc; |
| 42 | }; | 562 | }; |
| 43 | 563 | ||
| 564 | #endif /* __KERNEL__ */ | ||
| 565 | |||
| 44 | #endif /* __LINUX_USB_AUDIO_H */ | 566 | #endif /* __LINUX_USB_AUDIO_H */ |
diff --git a/include/linux/usb/cdc-wdm.h b/include/linux/usb/cdc-wdm.h deleted file mode 100644 index 719c332620f..00000000000 --- a/include/linux/usb/cdc-wdm.h +++ /dev/null | |||
| @@ -1,19 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * USB CDC Device Management subdriver | ||
| 3 | * | ||
| 4 | * Copyright (c) 2012 Bjørn Mork <bjorn@mork.no> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License | ||
| 8 | * version 2 as published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #ifndef __LINUX_USB_CDC_WDM_H | ||
| 12 | #define __LINUX_USB_CDC_WDM_H | ||
| 13 | |||
| 14 | extern struct usb_driver *usb_cdc_wdm_register(struct usb_interface *intf, | ||
| 15 | struct usb_endpoint_descriptor *ep, | ||
| 16 | int bufsize, | ||
| 17 | int (*manage_power)(struct usb_interface *, int)); | ||
| 18 | |||
| 19 | #endif /* __LINUX_USB_CDC_WDM_H */ | ||
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h deleted file mode 100644 index 3b8f9d4fc3f..00000000000 --- a/include/linux/usb/cdc_ncm.h +++ /dev/null | |||
| @@ -1,134 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) ST-Ericsson 2010-2012 | ||
| 3 | * Contact: Alexey Orishko <alexey.orishko@stericsson.com> | ||
| 4 | * Original author: Hans Petter Selasky <hans.petter.selasky@stericsson.com> | ||
| 5 | * | ||
| 6 | * USB Host Driver for Network Control Model (NCM) | ||
| 7 | * http://www.usb.org/developers/devclass_docs/NCM10.zip | ||
| 8 | * | ||
| 9 | * The NCM encoding, decoding and initialization logic | ||
| 10 | * derives from FreeBSD 8.x. if_cdce.c and if_cdcereg.h | ||
| 11 | * | ||
| 12 | * This software is available to you under a choice of one of two | ||
| 13 | * licenses. You may choose this file to be licensed under the terms | ||
| 14 | * of the GNU General Public License (GPL) Version 2 or the 2-clause | ||
| 15 | * BSD license listed below: | ||
| 16 | * | ||
| 17 | * Redistribution and use in source and binary forms, with or without | ||
| 18 | * modification, are permitted provided that the following conditions | ||
| 19 | * are met: | ||
| 20 | * 1. Redistributions of source code must retain the above copyright | ||
| 21 | * notice, this list of conditions and the following disclaimer. | ||
| 22 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 23 | * notice, this list of conditions and the following disclaimer in the | ||
| 24 | * documentation and/or other materials provided with the distribution. | ||
| 25 | * | ||
| 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
| 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 36 | * SUCH DAMAGE. | ||
| 37 | */ | ||
| 38 | |||
| 39 | #define CDC_NCM_COMM_ALTSETTING_NCM 0 | ||
| 40 | #define CDC_NCM_COMM_ALTSETTING_MBIM 1 | ||
| 41 | |||
| 42 | #define CDC_NCM_DATA_ALTSETTING_NCM 1 | ||
| 43 | #define CDC_NCM_DATA_ALTSETTING_MBIM 2 | ||
| 44 | |||
| 45 | /* CDC NCM subclass 3.2.1 */ | ||
| 46 | #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 | ||
| 47 | |||
| 48 | /* Maximum NTB length */ | ||
| 49 | #define CDC_NCM_NTB_MAX_SIZE_TX 32768 /* bytes */ | ||
| 50 | #define CDC_NCM_NTB_MAX_SIZE_RX 32768 /* bytes */ | ||
| 51 | |||
| 52 | /* Minimum value for MaxDatagramSize, ch. 6.2.9 */ | ||
| 53 | #define CDC_NCM_MIN_DATAGRAM_SIZE 1514 /* bytes */ | ||
| 54 | |||
| 55 | /* Minimum value for MaxDatagramSize, ch. 8.1.3 */ | ||
| 56 | #define CDC_MBIM_MIN_DATAGRAM_SIZE 2048 /* bytes */ | ||
| 57 | |||
| 58 | #define CDC_NCM_MIN_TX_PKT 512 /* bytes */ | ||
| 59 | |||
| 60 | /* Default value for MaxDatagramSize */ | ||
| 61 | #define CDC_NCM_MAX_DATAGRAM_SIZE 8192 /* bytes */ | ||
| 62 | |||
| 63 | /* | ||
| 64 | * Maximum amount of datagrams in NCM Datagram Pointer Table, not counting | ||
| 65 | * the last NULL entry. | ||
| 66 | */ | ||
| 67 | #define CDC_NCM_DPT_DATAGRAMS_MAX 40 | ||
| 68 | |||
| 69 | /* Restart the timer, if amount of datagrams is less than given value */ | ||
| 70 | #define CDC_NCM_RESTART_TIMER_DATAGRAM_CNT 3 | ||
| 71 | #define CDC_NCM_TIMER_PENDING_CNT 2 | ||
| 72 | #define CDC_NCM_TIMER_INTERVAL (400UL * NSEC_PER_USEC) | ||
| 73 | |||
| 74 | /* The following macro defines the minimum header space */ | ||
| 75 | #define CDC_NCM_MIN_HDR_SIZE \ | ||
| 76 | (sizeof(struct usb_cdc_ncm_nth16) + sizeof(struct usb_cdc_ncm_ndp16) + \ | ||
| 77 | (CDC_NCM_DPT_DATAGRAMS_MAX + 1) * sizeof(struct usb_cdc_ncm_dpe16)) | ||
| 78 | |||
| 79 | #define CDC_NCM_NDP_SIZE \ | ||
| 80 | (sizeof(struct usb_cdc_ncm_ndp16) + \ | ||
| 81 | (CDC_NCM_DPT_DATAGRAMS_MAX + 1) * sizeof(struct usb_cdc_ncm_dpe16)) | ||
| 82 | |||
| 83 | #define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \ | ||
| 84 | (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE) | ||
| 85 | #define cdc_ncm_data_intf_is_mbim(x) ((x)->desc.bInterfaceProtocol == USB_CDC_MBIM_PROTO_NTB) | ||
| 86 | |||
| 87 | struct cdc_ncm_ctx { | ||
| 88 | struct usb_cdc_ncm_ntb_parameters ncm_parm; | ||
| 89 | struct hrtimer tx_timer; | ||
| 90 | struct tasklet_struct bh; | ||
| 91 | |||
| 92 | const struct usb_cdc_ncm_desc *func_desc; | ||
| 93 | const struct usb_cdc_mbim_desc *mbim_desc; | ||
| 94 | const struct usb_cdc_header_desc *header_desc; | ||
| 95 | const struct usb_cdc_union_desc *union_desc; | ||
| 96 | const struct usb_cdc_ether_desc *ether_desc; | ||
| 97 | |||
| 98 | struct net_device *netdev; | ||
| 99 | struct usb_device *udev; | ||
| 100 | struct usb_host_endpoint *in_ep; | ||
| 101 | struct usb_host_endpoint *out_ep; | ||
| 102 | struct usb_host_endpoint *status_ep; | ||
| 103 | struct usb_interface *intf; | ||
| 104 | struct usb_interface *control; | ||
| 105 | struct usb_interface *data; | ||
| 106 | |||
| 107 | struct sk_buff *tx_curr_skb; | ||
| 108 | struct sk_buff *tx_rem_skb; | ||
| 109 | __le32 tx_rem_sign; | ||
| 110 | |||
| 111 | spinlock_t mtx; | ||
| 112 | atomic_t stop; | ||
| 113 | |||
| 114 | u32 tx_timer_pending; | ||
| 115 | u32 tx_curr_frame_num; | ||
| 116 | u32 rx_speed; | ||
| 117 | u32 tx_speed; | ||
| 118 | u32 rx_max; | ||
| 119 | u32 tx_max; | ||
| 120 | u32 max_datagram_size; | ||
| 121 | u16 tx_max_datagrams; | ||
| 122 | u16 tx_remainder; | ||
| 123 | u16 tx_modulus; | ||
| 124 | u16 tx_ndp_modulus; | ||
| 125 | u16 tx_seq; | ||
| 126 | u16 rx_seq; | ||
| 127 | u16 connected; | ||
| 128 | }; | ||
| 129 | |||
| 130 | extern int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting); | ||
| 131 | extern void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf); | ||
| 132 | extern struct sk_buff *cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb, __le32 sign); | ||
| 133 | extern int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in); | ||
| 134 | extern int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset); | ||
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index 9c210f2283d..cf65b5cff72 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h | |||
| @@ -29,18 +29,879 @@ | |||
| 29 | * someone that the two other points are non-issues for that | 29 | * someone that the two other points are non-issues for that |
| 30 | * particular descriptor type. | 30 | * particular descriptor type. |
| 31 | */ | 31 | */ |
| 32 | |||
| 32 | #ifndef __LINUX_USB_CH9_H | 33 | #ifndef __LINUX_USB_CH9_H |
| 33 | #define __LINUX_USB_CH9_H | 34 | #define __LINUX_USB_CH9_H |
| 34 | 35 | ||
| 35 | #include <uapi/linux/usb/ch9.h> | 36 | #include <linux/types.h> /* __u8 etc */ |
| 37 | |||
| 38 | /*-------------------------------------------------------------------------*/ | ||
| 39 | |||
| 40 | /* CONTROL REQUEST SUPPORT */ | ||
| 41 | |||
| 42 | /* | ||
| 43 | * USB directions | ||
| 44 | * | ||
| 45 | * This bit flag is used in endpoint descriptors' bEndpointAddress field. | ||
| 46 | * It's also one of three fields in control requests bRequestType. | ||
| 47 | */ | ||
| 48 | #define USB_DIR_OUT 0 /* to device */ | ||
| 49 | #define USB_DIR_IN 0x80 /* to host */ | ||
| 50 | |||
| 51 | /* | ||
| 52 | * USB types, the second of three bRequestType fields | ||
| 53 | */ | ||
| 54 | #define USB_TYPE_MASK (0x03 << 5) | ||
| 55 | #define USB_TYPE_STANDARD (0x00 << 5) | ||
| 56 | #define USB_TYPE_CLASS (0x01 << 5) | ||
| 57 | #define USB_TYPE_VENDOR (0x02 << 5) | ||
| 58 | #define USB_TYPE_RESERVED (0x03 << 5) | ||
| 59 | |||
| 60 | /* | ||
| 61 | * USB recipients, the third of three bRequestType fields | ||
| 62 | */ | ||
| 63 | #define USB_RECIP_MASK 0x1f | ||
| 64 | #define USB_RECIP_DEVICE 0x00 | ||
| 65 | #define USB_RECIP_INTERFACE 0x01 | ||
| 66 | #define USB_RECIP_ENDPOINT 0x02 | ||
| 67 | #define USB_RECIP_OTHER 0x03 | ||
| 68 | /* From Wireless USB 1.0 */ | ||
| 69 | #define USB_RECIP_PORT 0x04 | ||
| 70 | #define USB_RECIP_RPIPE 0x05 | ||
| 71 | |||
| 72 | /* | ||
| 73 | * Standard requests, for the bRequest field of a SETUP packet. | ||
| 74 | * | ||
| 75 | * These are qualified by the bRequestType field, so that for example | ||
| 76 | * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved | ||
| 77 | * by a GET_STATUS request. | ||
| 78 | */ | ||
| 79 | #define USB_REQ_GET_STATUS 0x00 | ||
| 80 | #define USB_REQ_CLEAR_FEATURE 0x01 | ||
| 81 | #define USB_REQ_SET_FEATURE 0x03 | ||
| 82 | #define USB_REQ_SET_ADDRESS 0x05 | ||
| 83 | #define USB_REQ_GET_DESCRIPTOR 0x06 | ||
| 84 | #define USB_REQ_SET_DESCRIPTOR 0x07 | ||
| 85 | #define USB_REQ_GET_CONFIGURATION 0x08 | ||
| 86 | #define USB_REQ_SET_CONFIGURATION 0x09 | ||
| 87 | #define USB_REQ_GET_INTERFACE 0x0A | ||
| 88 | #define USB_REQ_SET_INTERFACE 0x0B | ||
| 89 | #define USB_REQ_SYNCH_FRAME 0x0C | ||
| 90 | |||
| 91 | #define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */ | ||
| 92 | #define USB_REQ_GET_ENCRYPTION 0x0E | ||
| 93 | #define USB_REQ_RPIPE_ABORT 0x0E | ||
| 94 | #define USB_REQ_SET_HANDSHAKE 0x0F | ||
| 95 | #define USB_REQ_RPIPE_RESET 0x0F | ||
| 96 | #define USB_REQ_GET_HANDSHAKE 0x10 | ||
| 97 | #define USB_REQ_SET_CONNECTION 0x11 | ||
| 98 | #define USB_REQ_SET_SECURITY_DATA 0x12 | ||
| 99 | #define USB_REQ_GET_SECURITY_DATA 0x13 | ||
| 100 | #define USB_REQ_SET_WUSB_DATA 0x14 | ||
| 101 | #define USB_REQ_LOOPBACK_DATA_WRITE 0x15 | ||
| 102 | #define USB_REQ_LOOPBACK_DATA_READ 0x16 | ||
| 103 | #define USB_REQ_SET_INTERFACE_DS 0x17 | ||
| 104 | |||
| 105 | /* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, | ||
| 106 | * used by hubs to put ports into a new L1 suspend state, except that it | ||
| 107 | * forgot to define its number ... | ||
| 108 | */ | ||
| 109 | |||
| 110 | /* | ||
| 111 | * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and | ||
| 112 | * are read as a bit array returned by USB_REQ_GET_STATUS. (So there | ||
| 113 | * are at most sixteen features of each type.) Hubs may also support a | ||
| 114 | * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. | ||
| 115 | */ | ||
| 116 | #define USB_DEVICE_SELF_POWERED 0 /* (read only) */ | ||
| 117 | #define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ | ||
| 118 | #define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */ | ||
| 119 | #define USB_DEVICE_BATTERY 2 /* (wireless) */ | ||
| 120 | #define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */ | ||
| 121 | #define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/ | ||
| 122 | #define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */ | ||
| 123 | #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ | ||
| 124 | #define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ | ||
| 125 | |||
| 126 | /* | ||
| 127 | * Test Mode Selectors | ||
| 128 | * See USB 2.0 spec Table 9-7 | ||
| 129 | */ | ||
| 130 | #define TEST_J 1 | ||
| 131 | #define TEST_K 2 | ||
| 132 | #define TEST_SE0_NAK 3 | ||
| 133 | #define TEST_PACKET 4 | ||
| 134 | #define TEST_FORCE_EN 5 | ||
| 135 | |||
| 136 | /* | ||
| 137 | * New Feature Selectors as added by USB 3.0 | ||
| 138 | * See USB 3.0 spec Table 9-6 | ||
| 139 | */ | ||
| 140 | #define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ | ||
| 141 | #define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */ | ||
| 142 | #define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */ | ||
| 143 | #define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */ | ||
| 144 | |||
| 145 | #define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00 | ||
| 146 | |||
| 147 | #define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */ | ||
| 148 | |||
| 149 | /* Bit array elements as returned by the USB_REQ_GET_STATUS request. */ | ||
| 150 | #define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */ | ||
| 151 | #define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */ | ||
| 152 | #define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */ | ||
| 153 | |||
| 154 | /** | ||
| 155 | * struct usb_ctrlrequest - SETUP data for a USB device control request | ||
| 156 | * @bRequestType: matches the USB bmRequestType field | ||
| 157 | * @bRequest: matches the USB bRequest field | ||
| 158 | * @wValue: matches the USB wValue field (le16 byte order) | ||
| 159 | * @wIndex: matches the USB wIndex field (le16 byte order) | ||
| 160 | * @wLength: matches the USB wLength field (le16 byte order) | ||
| 161 | * | ||
| 162 | * This structure is used to send control requests to a USB device. It matches | ||
| 163 | * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the | ||
| 164 | * USB spec for a fuller description of the different fields, and what they are | ||
| 165 | * used for. | ||
| 166 | * | ||
| 167 | * Note that the driver for any interface can issue control requests. | ||
| 168 | * For most devices, interfaces don't coordinate with each other, so | ||
| 169 | * such requests may be made at any time. | ||
| 170 | */ | ||
| 171 | struct usb_ctrlrequest { | ||
| 172 | __u8 bRequestType; | ||
| 173 | __u8 bRequest; | ||
| 174 | __le16 wValue; | ||
| 175 | __le16 wIndex; | ||
| 176 | __le16 wLength; | ||
| 177 | } __attribute__ ((packed)); | ||
| 178 | |||
| 179 | /*-------------------------------------------------------------------------*/ | ||
| 180 | |||
| 181 | /* | ||
| 182 | * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or | ||
| 183 | * (rarely) accepted by SET_DESCRIPTOR. | ||
| 184 | * | ||
| 185 | * Note that all multi-byte values here are encoded in little endian | ||
| 186 | * byte order "on the wire". Within the kernel and when exposed | ||
| 187 | * through the Linux-USB APIs, they are not converted to cpu byte | ||
| 188 | * order; it is the responsibility of the client code to do this. | ||
| 189 | * The single exception is when device and configuration descriptors (but | ||
| 190 | * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD); | ||
| 191 | * in this case the fields are converted to host endianness by the kernel. | ||
| 192 | */ | ||
| 193 | |||
| 194 | /* | ||
| 195 | * Descriptor types ... USB 2.0 spec table 9.5 | ||
| 196 | */ | ||
| 197 | #define USB_DT_DEVICE 0x01 | ||
| 198 | #define USB_DT_CONFIG 0x02 | ||
| 199 | #define USB_DT_STRING 0x03 | ||
| 200 | #define USB_DT_INTERFACE 0x04 | ||
| 201 | #define USB_DT_ENDPOINT 0x05 | ||
| 202 | #define USB_DT_DEVICE_QUALIFIER 0x06 | ||
| 203 | #define USB_DT_OTHER_SPEED_CONFIG 0x07 | ||
| 204 | #define USB_DT_INTERFACE_POWER 0x08 | ||
| 205 | /* these are from a minor usb 2.0 revision (ECN) */ | ||
| 206 | #define USB_DT_OTG 0x09 | ||
| 207 | #define USB_DT_DEBUG 0x0a | ||
| 208 | #define USB_DT_INTERFACE_ASSOCIATION 0x0b | ||
| 209 | /* these are from the Wireless USB spec */ | ||
| 210 | #define USB_DT_SECURITY 0x0c | ||
| 211 | #define USB_DT_KEY 0x0d | ||
| 212 | #define USB_DT_ENCRYPTION_TYPE 0x0e | ||
| 213 | #define USB_DT_BOS 0x0f | ||
| 214 | #define USB_DT_DEVICE_CAPABILITY 0x10 | ||
| 215 | #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 | ||
| 216 | #define USB_DT_WIRE_ADAPTER 0x21 | ||
| 217 | #define USB_DT_RPIPE 0x22 | ||
| 218 | #define USB_DT_CS_RADIO_CONTROL 0x23 | ||
| 219 | /* From the T10 UAS specification */ | ||
| 220 | #define USB_DT_PIPE_USAGE 0x24 | ||
| 221 | /* From the USB 3.0 spec */ | ||
| 222 | #define USB_DT_SS_ENDPOINT_COMP 0x30 | ||
| 223 | |||
| 224 | /* Conventional codes for class-specific descriptors. The convention is | ||
| 225 | * defined in the USB "Common Class" Spec (3.11). Individual class specs | ||
| 226 | * are authoritative for their usage, not the "common class" writeup. | ||
| 227 | */ | ||
| 228 | #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE) | ||
| 229 | #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG) | ||
| 230 | #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING) | ||
| 231 | #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE) | ||
| 232 | #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT) | ||
| 233 | |||
| 234 | /* All standard descriptors have these 2 fields at the beginning */ | ||
| 235 | struct usb_descriptor_header { | ||
| 236 | __u8 bLength; | ||
| 237 | __u8 bDescriptorType; | ||
| 238 | } __attribute__ ((packed)); | ||
| 239 | |||
| 240 | |||
| 241 | /*-------------------------------------------------------------------------*/ | ||
| 242 | |||
| 243 | /* USB_DT_DEVICE: Device descriptor */ | ||
| 244 | struct usb_device_descriptor { | ||
| 245 | __u8 bLength; | ||
| 246 | __u8 bDescriptorType; | ||
| 247 | |||
| 248 | __le16 bcdUSB; | ||
| 249 | __u8 bDeviceClass; | ||
| 250 | __u8 bDeviceSubClass; | ||
| 251 | __u8 bDeviceProtocol; | ||
| 252 | __u8 bMaxPacketSize0; | ||
| 253 | __le16 idVendor; | ||
| 254 | __le16 idProduct; | ||
| 255 | __le16 bcdDevice; | ||
| 256 | __u8 iManufacturer; | ||
| 257 | __u8 iProduct; | ||
| 258 | __u8 iSerialNumber; | ||
| 259 | __u8 bNumConfigurations; | ||
| 260 | } __attribute__ ((packed)); | ||
| 261 | |||
| 262 | #define USB_DT_DEVICE_SIZE 18 | ||
| 263 | |||
| 36 | 264 | ||
| 265 | /* | ||
| 266 | * Device and/or Interface Class codes | ||
| 267 | * as found in bDeviceClass or bInterfaceClass | ||
| 268 | * and defined by www.usb.org documents | ||
| 269 | */ | ||
| 270 | #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ | ||
| 271 | #define USB_CLASS_AUDIO 1 | ||
| 272 | #define USB_CLASS_COMM 2 | ||
| 273 | #define USB_CLASS_HID 3 | ||
| 274 | #define USB_CLASS_PHYSICAL 5 | ||
| 275 | #define USB_CLASS_STILL_IMAGE 6 | ||
| 276 | #define USB_CLASS_PRINTER 7 | ||
| 277 | #define USB_CLASS_MASS_STORAGE 8 | ||
| 278 | #define USB_CLASS_HUB 9 | ||
| 279 | #define USB_CLASS_CDC_DATA 0x0a | ||
| 280 | #define USB_CLASS_CSCID 0x0b /* chip+ smart card */ | ||
| 281 | #define USB_CLASS_CONTENT_SEC 0x0d /* content security */ | ||
| 282 | #define USB_CLASS_VIDEO 0x0e | ||
| 283 | #define USB_CLASS_WIRELESS_CONTROLLER 0xe0 | ||
| 284 | #define USB_CLASS_MISC 0xef | ||
| 285 | #define USB_CLASS_APP_SPEC 0xfe | ||
| 286 | #define USB_CLASS_VENDOR_SPEC 0xff | ||
| 287 | |||
| 288 | #define USB_SUBCLASS_VENDOR_SPEC 0xff | ||
| 289 | |||
| 290 | /*-------------------------------------------------------------------------*/ | ||
| 291 | |||
| 292 | /* USB_DT_CONFIG: Configuration descriptor information. | ||
| 293 | * | ||
| 294 | * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the | ||
| 295 | * descriptor type is different. Highspeed-capable devices can look | ||
| 296 | * different depending on what speed they're currently running. Only | ||
| 297 | * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG | ||
| 298 | * descriptors. | ||
| 299 | */ | ||
| 300 | struct usb_config_descriptor { | ||
| 301 | __u8 bLength; | ||
| 302 | __u8 bDescriptorType; | ||
| 303 | |||
| 304 | __le16 wTotalLength; | ||
| 305 | __u8 bNumInterfaces; | ||
| 306 | __u8 bConfigurationValue; | ||
| 307 | __u8 iConfiguration; | ||
| 308 | __u8 bmAttributes; | ||
| 309 | __u8 bMaxPower; | ||
| 310 | } __attribute__ ((packed)); | ||
| 311 | |||
| 312 | #define USB_DT_CONFIG_SIZE 9 | ||
| 313 | |||
| 314 | /* from config descriptor bmAttributes */ | ||
| 315 | #define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */ | ||
| 316 | #define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */ | ||
| 317 | #define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */ | ||
| 318 | #define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */ | ||
| 319 | |||
| 320 | /*-------------------------------------------------------------------------*/ | ||
| 321 | |||
| 322 | /* USB_DT_STRING: String descriptor */ | ||
| 323 | struct usb_string_descriptor { | ||
| 324 | __u8 bLength; | ||
| 325 | __u8 bDescriptorType; | ||
| 326 | |||
| 327 | __le16 wData[1]; /* UTF-16LE encoded */ | ||
| 328 | } __attribute__ ((packed)); | ||
| 329 | |||
| 330 | /* note that "string" zero is special, it holds language codes that | ||
| 331 | * the device supports, not Unicode characters. | ||
| 332 | */ | ||
| 333 | |||
| 334 | /*-------------------------------------------------------------------------*/ | ||
| 335 | |||
| 336 | /* USB_DT_INTERFACE: Interface descriptor */ | ||
| 337 | struct usb_interface_descriptor { | ||
| 338 | __u8 bLength; | ||
| 339 | __u8 bDescriptorType; | ||
| 340 | |||
| 341 | __u8 bInterfaceNumber; | ||
| 342 | __u8 bAlternateSetting; | ||
| 343 | __u8 bNumEndpoints; | ||
| 344 | __u8 bInterfaceClass; | ||
| 345 | __u8 bInterfaceSubClass; | ||
| 346 | __u8 bInterfaceProtocol; | ||
| 347 | __u8 iInterface; | ||
| 348 | } __attribute__ ((packed)); | ||
| 349 | |||
| 350 | #define USB_DT_INTERFACE_SIZE 9 | ||
| 351 | |||
| 352 | /*-------------------------------------------------------------------------*/ | ||
| 353 | |||
| 354 | /* USB_DT_ENDPOINT: Endpoint descriptor */ | ||
| 355 | struct usb_endpoint_descriptor { | ||
| 356 | __u8 bLength; | ||
| 357 | __u8 bDescriptorType; | ||
| 358 | |||
| 359 | __u8 bEndpointAddress; | ||
| 360 | __u8 bmAttributes; | ||
| 361 | __le16 wMaxPacketSize; | ||
| 362 | __u8 bInterval; | ||
| 363 | |||
| 364 | /* NOTE: these two are _only_ in audio endpoints. */ | ||
| 365 | /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ | ||
| 366 | __u8 bRefresh; | ||
| 367 | __u8 bSynchAddress; | ||
| 368 | } __attribute__ ((packed)); | ||
| 369 | |||
| 370 | #define USB_DT_ENDPOINT_SIZE 7 | ||
| 371 | #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ | ||
| 372 | |||
| 373 | |||
| 374 | /* | ||
| 375 | * Endpoints | ||
| 376 | */ | ||
| 377 | #define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */ | ||
| 378 | #define USB_ENDPOINT_DIR_MASK 0x80 | ||
| 379 | |||
| 380 | #define USB_ENDPOINT_SYNCTYPE 0x0c | ||
| 381 | #define USB_ENDPOINT_SYNC_NONE (0 << 2) | ||
| 382 | #define USB_ENDPOINT_SYNC_ASYNC (1 << 2) | ||
| 383 | #define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) | ||
| 384 | #define USB_ENDPOINT_SYNC_SYNC (3 << 2) | ||
| 385 | |||
| 386 | #define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ | ||
| 387 | #define USB_ENDPOINT_XFER_CONTROL 0 | ||
| 388 | #define USB_ENDPOINT_XFER_ISOC 1 | ||
| 389 | #define USB_ENDPOINT_XFER_BULK 2 | ||
| 390 | #define USB_ENDPOINT_XFER_INT 3 | ||
| 391 | #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 | ||
| 392 | |||
| 393 | /*-------------------------------------------------------------------------*/ | ||
| 394 | |||
| 395 | /** | ||
| 396 | * usb_endpoint_num - get the endpoint's number | ||
| 397 | * @epd: endpoint to be checked | ||
| 398 | * | ||
| 399 | * Returns @epd's number: 0 to 15. | ||
| 400 | */ | ||
| 401 | static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) | ||
| 402 | { | ||
| 403 | return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | ||
| 404 | } | ||
| 37 | 405 | ||
| 38 | /** | 406 | /** |
| 39 | * usb_speed_string() - Returns human readable-name of the speed. | 407 | * usb_endpoint_type - get the endpoint's transfer type |
| 40 | * @speed: The speed to return human-readable name for. If it's not | 408 | * @epd: endpoint to be checked |
| 41 | * any of the speeds defined in usb_device_speed enum, string for | 409 | * |
| 42 | * USB_SPEED_UNKNOWN will be returned. | 410 | * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according |
| 411 | * to @epd's transfer type. | ||
| 412 | */ | ||
| 413 | static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd) | ||
| 414 | { | ||
| 415 | return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | ||
| 416 | } | ||
| 417 | |||
| 418 | /** | ||
| 419 | * usb_endpoint_dir_in - check if the endpoint has IN direction | ||
| 420 | * @epd: endpoint to be checked | ||
| 421 | * | ||
| 422 | * Returns true if the endpoint is of type IN, otherwise it returns false. | ||
| 423 | */ | ||
| 424 | static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) | ||
| 425 | { | ||
| 426 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); | ||
| 427 | } | ||
| 428 | |||
| 429 | /** | ||
| 430 | * usb_endpoint_dir_out - check if the endpoint has OUT direction | ||
| 431 | * @epd: endpoint to be checked | ||
| 432 | * | ||
| 433 | * Returns true if the endpoint is of type OUT, otherwise it returns false. | ||
| 434 | */ | ||
| 435 | static inline int usb_endpoint_dir_out( | ||
| 436 | const struct usb_endpoint_descriptor *epd) | ||
| 437 | { | ||
| 438 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); | ||
| 439 | } | ||
| 440 | |||
| 441 | /** | ||
| 442 | * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type | ||
| 443 | * @epd: endpoint to be checked | ||
| 444 | * | ||
| 445 | * Returns true if the endpoint is of type bulk, otherwise it returns false. | ||
| 446 | */ | ||
| 447 | static inline int usb_endpoint_xfer_bulk( | ||
| 448 | const struct usb_endpoint_descriptor *epd) | ||
| 449 | { | ||
| 450 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 451 | USB_ENDPOINT_XFER_BULK); | ||
| 452 | } | ||
| 453 | |||
| 454 | /** | ||
| 455 | * usb_endpoint_xfer_control - check if the endpoint has control transfer type | ||
| 456 | * @epd: endpoint to be checked | ||
| 457 | * | ||
| 458 | * Returns true if the endpoint is of type control, otherwise it returns false. | ||
| 459 | */ | ||
| 460 | static inline int usb_endpoint_xfer_control( | ||
| 461 | const struct usb_endpoint_descriptor *epd) | ||
| 462 | { | ||
| 463 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 464 | USB_ENDPOINT_XFER_CONTROL); | ||
| 465 | } | ||
| 466 | |||
| 467 | /** | ||
| 468 | * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type | ||
| 469 | * @epd: endpoint to be checked | ||
| 470 | * | ||
| 471 | * Returns true if the endpoint is of type interrupt, otherwise it returns | ||
| 472 | * false. | ||
| 473 | */ | ||
| 474 | static inline int usb_endpoint_xfer_int( | ||
| 475 | const struct usb_endpoint_descriptor *epd) | ||
| 476 | { | ||
| 477 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 478 | USB_ENDPOINT_XFER_INT); | ||
| 479 | } | ||
| 480 | |||
| 481 | /** | ||
| 482 | * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type | ||
| 483 | * @epd: endpoint to be checked | ||
| 484 | * | ||
| 485 | * Returns true if the endpoint is of type isochronous, otherwise it returns | ||
| 486 | * false. | ||
| 487 | */ | ||
| 488 | static inline int usb_endpoint_xfer_isoc( | ||
| 489 | const struct usb_endpoint_descriptor *epd) | ||
| 490 | { | ||
| 491 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 492 | USB_ENDPOINT_XFER_ISOC); | ||
| 493 | } | ||
| 494 | |||
| 495 | /** | ||
| 496 | * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN | ||
| 497 | * @epd: endpoint to be checked | ||
| 498 | * | ||
| 499 | * Returns true if the endpoint has bulk transfer type and IN direction, | ||
| 500 | * otherwise it returns false. | ||
| 501 | */ | ||
| 502 | static inline int usb_endpoint_is_bulk_in( | ||
| 503 | const struct usb_endpoint_descriptor *epd) | ||
| 504 | { | ||
| 505 | return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd); | ||
| 506 | } | ||
| 507 | |||
| 508 | /** | ||
| 509 | * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT | ||
| 510 | * @epd: endpoint to be checked | ||
| 511 | * | ||
| 512 | * Returns true if the endpoint has bulk transfer type and OUT direction, | ||
| 513 | * otherwise it returns false. | ||
| 514 | */ | ||
| 515 | static inline int usb_endpoint_is_bulk_out( | ||
| 516 | const struct usb_endpoint_descriptor *epd) | ||
| 517 | { | ||
| 518 | return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd); | ||
| 519 | } | ||
| 520 | |||
| 521 | /** | ||
| 522 | * usb_endpoint_is_int_in - check if the endpoint is interrupt IN | ||
| 523 | * @epd: endpoint to be checked | ||
| 524 | * | ||
| 525 | * Returns true if the endpoint has interrupt transfer type and IN direction, | ||
| 526 | * otherwise it returns false. | ||
| 527 | */ | ||
| 528 | static inline int usb_endpoint_is_int_in( | ||
| 529 | const struct usb_endpoint_descriptor *epd) | ||
| 530 | { | ||
| 531 | return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd); | ||
| 532 | } | ||
| 533 | |||
| 534 | /** | ||
| 535 | * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT | ||
| 536 | * @epd: endpoint to be checked | ||
| 537 | * | ||
| 538 | * Returns true if the endpoint has interrupt transfer type and OUT direction, | ||
| 539 | * otherwise it returns false. | ||
| 540 | */ | ||
| 541 | static inline int usb_endpoint_is_int_out( | ||
| 542 | const struct usb_endpoint_descriptor *epd) | ||
| 543 | { | ||
| 544 | return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd); | ||
| 545 | } | ||
| 546 | |||
| 547 | /** | ||
| 548 | * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN | ||
| 549 | * @epd: endpoint to be checked | ||
| 550 | * | ||
| 551 | * Returns true if the endpoint has isochronous transfer type and IN direction, | ||
| 552 | * otherwise it returns false. | ||
| 553 | */ | ||
| 554 | static inline int usb_endpoint_is_isoc_in( | ||
| 555 | const struct usb_endpoint_descriptor *epd) | ||
| 556 | { | ||
| 557 | return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd); | ||
| 558 | } | ||
| 559 | |||
| 560 | /** | ||
| 561 | * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT | ||
| 562 | * @epd: endpoint to be checked | ||
| 563 | * | ||
| 564 | * Returns true if the endpoint has isochronous transfer type and OUT direction, | ||
| 565 | * otherwise it returns false. | ||
| 566 | */ | ||
| 567 | static inline int usb_endpoint_is_isoc_out( | ||
| 568 | const struct usb_endpoint_descriptor *epd) | ||
| 569 | { | ||
| 570 | return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd); | ||
| 571 | } | ||
| 572 | |||
| 573 | /*-------------------------------------------------------------------------*/ | ||
| 574 | |||
| 575 | /* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */ | ||
| 576 | struct usb_ss_ep_comp_descriptor { | ||
| 577 | __u8 bLength; | ||
| 578 | __u8 bDescriptorType; | ||
| 579 | |||
| 580 | __u8 bMaxBurst; | ||
| 581 | __u8 bmAttributes; | ||
| 582 | __le16 wBytesPerInterval; | ||
| 583 | } __attribute__ ((packed)); | ||
| 584 | |||
| 585 | #define USB_DT_SS_EP_COMP_SIZE 6 | ||
| 586 | |||
| 587 | /* Bits 4:0 of bmAttributes if this is a bulk endpoint */ | ||
| 588 | static inline int | ||
| 589 | usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp) | ||
| 590 | { | ||
| 591 | int max_streams; | ||
| 592 | |||
| 593 | if (!comp) | ||
| 594 | return 0; | ||
| 595 | |||
| 596 | max_streams = comp->bmAttributes & 0x1f; | ||
| 597 | |||
| 598 | if (!max_streams) | ||
| 599 | return 0; | ||
| 600 | |||
| 601 | max_streams = 1 << max_streams; | ||
| 602 | |||
| 603 | return max_streams; | ||
| 604 | } | ||
| 605 | |||
| 606 | /* Bits 1:0 of bmAttributes if this is an isoc endpoint */ | ||
| 607 | #define USB_SS_MULT(p) (1 + ((p) & 0x3)) | ||
| 608 | |||
| 609 | /*-------------------------------------------------------------------------*/ | ||
| 610 | |||
| 611 | /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */ | ||
| 612 | struct usb_qualifier_descriptor { | ||
| 613 | __u8 bLength; | ||
| 614 | __u8 bDescriptorType; | ||
| 615 | |||
| 616 | __le16 bcdUSB; | ||
| 617 | __u8 bDeviceClass; | ||
| 618 | __u8 bDeviceSubClass; | ||
| 619 | __u8 bDeviceProtocol; | ||
| 620 | __u8 bMaxPacketSize0; | ||
| 621 | __u8 bNumConfigurations; | ||
| 622 | __u8 bRESERVED; | ||
| 623 | } __attribute__ ((packed)); | ||
| 624 | |||
| 625 | |||
| 626 | /*-------------------------------------------------------------------------*/ | ||
| 627 | |||
| 628 | /* USB_DT_OTG (from OTG 1.0a supplement) */ | ||
| 629 | struct usb_otg_descriptor { | ||
| 630 | __u8 bLength; | ||
| 631 | __u8 bDescriptorType; | ||
| 632 | |||
| 633 | __u8 bmAttributes; /* support for HNP, SRP, etc */ | ||
| 634 | } __attribute__ ((packed)); | ||
| 635 | |||
| 636 | /* from usb_otg_descriptor.bmAttributes */ | ||
| 637 | #define USB_OTG_SRP (1 << 0) | ||
| 638 | #define USB_OTG_HNP (1 << 1) /* swap host/device roles */ | ||
| 639 | |||
| 640 | /*-------------------------------------------------------------------------*/ | ||
| 641 | |||
| 642 | /* USB_DT_DEBUG: for special highspeed devices, replacing serial console */ | ||
| 643 | struct usb_debug_descriptor { | ||
| 644 | __u8 bLength; | ||
| 645 | __u8 bDescriptorType; | ||
| 646 | |||
| 647 | /* bulk endpoints with 8 byte maxpacket */ | ||
| 648 | __u8 bDebugInEndpoint; | ||
| 649 | __u8 bDebugOutEndpoint; | ||
| 650 | } __attribute__((packed)); | ||
| 651 | |||
| 652 | /*-------------------------------------------------------------------------*/ | ||
| 653 | |||
| 654 | /* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */ | ||
| 655 | struct usb_interface_assoc_descriptor { | ||
| 656 | __u8 bLength; | ||
| 657 | __u8 bDescriptorType; | ||
| 658 | |||
| 659 | __u8 bFirstInterface; | ||
| 660 | __u8 bInterfaceCount; | ||
| 661 | __u8 bFunctionClass; | ||
| 662 | __u8 bFunctionSubClass; | ||
| 663 | __u8 bFunctionProtocol; | ||
| 664 | __u8 iFunction; | ||
| 665 | } __attribute__ ((packed)); | ||
| 666 | |||
| 667 | |||
| 668 | /*-------------------------------------------------------------------------*/ | ||
| 669 | |||
| 670 | /* USB_DT_SECURITY: group of wireless security descriptors, including | ||
| 671 | * encryption types available for setting up a CC/association. | ||
| 672 | */ | ||
| 673 | struct usb_security_descriptor { | ||
| 674 | __u8 bLength; | ||
| 675 | __u8 bDescriptorType; | ||
| 676 | |||
| 677 | __le16 wTotalLength; | ||
| 678 | __u8 bNumEncryptionTypes; | ||
| 679 | } __attribute__((packed)); | ||
| 680 | |||
| 681 | /*-------------------------------------------------------------------------*/ | ||
| 682 | |||
| 683 | /* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys | ||
| 684 | * may be retrieved. | ||
| 685 | */ | ||
| 686 | struct usb_key_descriptor { | ||
| 687 | __u8 bLength; | ||
| 688 | __u8 bDescriptorType; | ||
| 689 | |||
| 690 | __u8 tTKID[3]; | ||
| 691 | __u8 bReserved; | ||
| 692 | __u8 bKeyData[0]; | ||
| 693 | } __attribute__((packed)); | ||
| 694 | |||
| 695 | /*-------------------------------------------------------------------------*/ | ||
| 696 | |||
| 697 | /* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */ | ||
| 698 | struct usb_encryption_descriptor { | ||
| 699 | __u8 bLength; | ||
| 700 | __u8 bDescriptorType; | ||
| 701 | |||
| 702 | __u8 bEncryptionType; | ||
| 703 | #define USB_ENC_TYPE_UNSECURE 0 | ||
| 704 | #define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */ | ||
| 705 | #define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */ | ||
| 706 | #define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */ | ||
| 707 | __u8 bEncryptionValue; /* use in SET_ENCRYPTION */ | ||
| 708 | __u8 bAuthKeyIndex; | ||
| 709 | } __attribute__((packed)); | ||
| 710 | |||
| 711 | |||
| 712 | /*-------------------------------------------------------------------------*/ | ||
| 713 | |||
| 714 | /* USB_DT_BOS: group of device-level capabilities */ | ||
| 715 | struct usb_bos_descriptor { | ||
| 716 | __u8 bLength; | ||
| 717 | __u8 bDescriptorType; | ||
| 718 | |||
| 719 | __le16 wTotalLength; | ||
| 720 | __u8 bNumDeviceCaps; | ||
| 721 | } __attribute__((packed)); | ||
| 722 | |||
| 723 | #define USB_DT_BOS_SIZE 5 | ||
| 724 | /*-------------------------------------------------------------------------*/ | ||
| 725 | |||
| 726 | /* USB_DT_DEVICE_CAPABILITY: grouped with BOS */ | ||
| 727 | struct usb_dev_cap_header { | ||
| 728 | __u8 bLength; | ||
| 729 | __u8 bDescriptorType; | ||
| 730 | __u8 bDevCapabilityType; | ||
| 731 | } __attribute__((packed)); | ||
| 732 | |||
| 733 | #define USB_CAP_TYPE_WIRELESS_USB 1 | ||
| 734 | |||
| 735 | struct usb_wireless_cap_descriptor { /* Ultra Wide Band */ | ||
| 736 | __u8 bLength; | ||
| 737 | __u8 bDescriptorType; | ||
| 738 | __u8 bDevCapabilityType; | ||
| 739 | |||
| 740 | __u8 bmAttributes; | ||
| 741 | #define USB_WIRELESS_P2P_DRD (1 << 1) | ||
| 742 | #define USB_WIRELESS_BEACON_MASK (3 << 2) | ||
| 743 | #define USB_WIRELESS_BEACON_SELF (1 << 2) | ||
| 744 | #define USB_WIRELESS_BEACON_DIRECTED (2 << 2) | ||
| 745 | #define USB_WIRELESS_BEACON_NONE (3 << 2) | ||
| 746 | __le16 wPHYRates; /* bit rates, Mbps */ | ||
| 747 | #define USB_WIRELESS_PHY_53 (1 << 0) /* always set */ | ||
| 748 | #define USB_WIRELESS_PHY_80 (1 << 1) | ||
| 749 | #define USB_WIRELESS_PHY_107 (1 << 2) /* always set */ | ||
| 750 | #define USB_WIRELESS_PHY_160 (1 << 3) | ||
| 751 | #define USB_WIRELESS_PHY_200 (1 << 4) /* always set */ | ||
| 752 | #define USB_WIRELESS_PHY_320 (1 << 5) | ||
| 753 | #define USB_WIRELESS_PHY_400 (1 << 6) | ||
| 754 | #define USB_WIRELESS_PHY_480 (1 << 7) | ||
| 755 | __u8 bmTFITXPowerInfo; /* TFI power levels */ | ||
| 756 | __u8 bmFFITXPowerInfo; /* FFI power levels */ | ||
| 757 | __le16 bmBandGroup; | ||
| 758 | __u8 bReserved; | ||
| 759 | } __attribute__((packed)); | ||
| 760 | |||
| 761 | /* USB 2.0 Extension descriptor */ | ||
| 762 | #define USB_CAP_TYPE_EXT 2 | ||
| 763 | |||
| 764 | struct usb_ext_cap_descriptor { /* Link Power Management */ | ||
| 765 | __u8 bLength; | ||
| 766 | __u8 bDescriptorType; | ||
| 767 | __u8 bDevCapabilityType; | ||
| 768 | __le32 bmAttributes; | ||
| 769 | #define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ | ||
| 770 | } __attribute__((packed)); | ||
| 771 | |||
| 772 | #define USB_DT_USB_EXT_CAP_SIZE 7 | ||
| 773 | |||
| 774 | /* | ||
| 775 | * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB | ||
| 776 | * specific device level capabilities | ||
| 777 | */ | ||
| 778 | #define USB_SS_CAP_TYPE 3 | ||
| 779 | struct usb_ss_cap_descriptor { /* Link Power Management */ | ||
| 780 | __u8 bLength; | ||
| 781 | __u8 bDescriptorType; | ||
| 782 | __u8 bDevCapabilityType; | ||
| 783 | __u8 bmAttributes; | ||
| 784 | #define USB_LTM_SUPPORT (1 << 1) /* supports LTM */ | ||
| 785 | __le16 wSpeedSupported; | ||
| 786 | #define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */ | ||
| 787 | #define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */ | ||
| 788 | #define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */ | ||
| 789 | #define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */ | ||
| 790 | __u8 bFunctionalitySupport; | ||
| 791 | __u8 bU1devExitLat; | ||
| 792 | __le16 bU2DevExitLat; | ||
| 793 | } __attribute__((packed)); | ||
| 794 | |||
| 795 | #define USB_DT_USB_SS_CAP_SIZE 10 | ||
| 796 | |||
| 797 | /* | ||
| 798 | * Container ID Capability descriptor: Defines the instance unique ID used to | ||
| 799 | * identify the instance across all operating modes | ||
| 800 | */ | ||
| 801 | #define CONTAINER_ID_TYPE 4 | ||
| 802 | struct usb_ss_container_id_descriptor { | ||
| 803 | __u8 bLength; | ||
| 804 | __u8 bDescriptorType; | ||
| 805 | __u8 bDevCapabilityType; | ||
| 806 | __u8 bReserved; | ||
| 807 | __u8 ContainerID[16]; /* 128-bit number */ | ||
| 808 | } __attribute__((packed)); | ||
| 809 | |||
| 810 | #define USB_DT_USB_SS_CONTN_ID_SIZE 20 | ||
| 811 | /*-------------------------------------------------------------------------*/ | ||
| 812 | |||
| 813 | /* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with | ||
| 814 | * each endpoint descriptor for a wireless device | ||
| 815 | */ | ||
| 816 | struct usb_wireless_ep_comp_descriptor { | ||
| 817 | __u8 bLength; | ||
| 818 | __u8 bDescriptorType; | ||
| 819 | |||
| 820 | __u8 bMaxBurst; | ||
| 821 | __u8 bMaxSequence; | ||
| 822 | __le16 wMaxStreamDelay; | ||
| 823 | __le16 wOverTheAirPacketSize; | ||
| 824 | __u8 bOverTheAirInterval; | ||
| 825 | __u8 bmCompAttributes; | ||
| 826 | #define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */ | ||
| 827 | #define USB_ENDPOINT_SWITCH_NO 0 | ||
| 828 | #define USB_ENDPOINT_SWITCH_SWITCH 1 | ||
| 829 | #define USB_ENDPOINT_SWITCH_SCALE 2 | ||
| 830 | } __attribute__((packed)); | ||
| 831 | |||
| 832 | /*-------------------------------------------------------------------------*/ | ||
| 833 | |||
| 834 | /* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless | ||
| 835 | * host and a device for connection set up, mutual authentication, and | ||
| 836 | * exchanging short lived session keys. The handshake depends on a CC. | ||
| 837 | */ | ||
| 838 | struct usb_handshake { | ||
| 839 | __u8 bMessageNumber; | ||
| 840 | __u8 bStatus; | ||
| 841 | __u8 tTKID[3]; | ||
| 842 | __u8 bReserved; | ||
| 843 | __u8 CDID[16]; | ||
| 844 | __u8 nonce[16]; | ||
| 845 | __u8 MIC[8]; | ||
| 846 | } __attribute__((packed)); | ||
| 847 | |||
| 848 | /*-------------------------------------------------------------------------*/ | ||
| 849 | |||
| 850 | /* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC). | ||
| 851 | * A CC may also be set up using non-wireless secure channels (including | ||
| 852 | * wired USB!), and some devices may support CCs with multiple hosts. | ||
| 853 | */ | ||
| 854 | struct usb_connection_context { | ||
| 855 | __u8 CHID[16]; /* persistent host id */ | ||
| 856 | __u8 CDID[16]; /* device id (unique w/in host context) */ | ||
| 857 | __u8 CK[16]; /* connection key */ | ||
| 858 | } __attribute__((packed)); | ||
| 859 | |||
| 860 | /*-------------------------------------------------------------------------*/ | ||
| 861 | |||
| 862 | /* USB 2.0 defines three speeds, here's how Linux identifies them */ | ||
| 863 | |||
| 864 | enum usb_device_speed { | ||
| 865 | USB_SPEED_UNKNOWN = 0, /* enumerating */ | ||
| 866 | USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ | ||
| 867 | USB_SPEED_HIGH, /* usb 2.0 */ | ||
| 868 | USB_SPEED_WIRELESS, /* wireless (usb 2.5) */ | ||
| 869 | USB_SPEED_SUPER, /* usb 3.0 */ | ||
| 870 | }; | ||
| 871 | |||
| 872 | enum usb_device_state { | ||
| 873 | /* NOTATTACHED isn't in the USB spec, and this state acts | ||
| 874 | * the same as ATTACHED ... but it's clearer this way. | ||
| 875 | */ | ||
| 876 | USB_STATE_NOTATTACHED = 0, | ||
| 877 | |||
| 878 | /* chapter 9 and authentication (wireless) device states */ | ||
| 879 | USB_STATE_ATTACHED, | ||
| 880 | USB_STATE_POWERED, /* wired */ | ||
| 881 | USB_STATE_RECONNECTING, /* auth */ | ||
| 882 | USB_STATE_UNAUTHENTICATED, /* auth */ | ||
| 883 | USB_STATE_DEFAULT, /* limited function */ | ||
| 884 | USB_STATE_ADDRESS, | ||
| 885 | USB_STATE_CONFIGURED, /* most functions */ | ||
| 886 | |||
| 887 | USB_STATE_SUSPENDED | ||
| 888 | |||
| 889 | /* NOTE: there are actually four different SUSPENDED | ||
| 890 | * states, returning to POWERED, DEFAULT, ADDRESS, or | ||
| 891 | * CONFIGURED respectively when SOF tokens flow again. | ||
| 892 | * At this level there's no difference between L1 and L2 | ||
| 893 | * suspend states. (L2 being original USB 1.1 suspend.) | ||
| 894 | */ | ||
| 895 | }; | ||
| 896 | |||
| 897 | /*-------------------------------------------------------------------------*/ | ||
| 898 | |||
| 899 | /* | ||
| 900 | * As per USB compliance update, a device that is actively drawing | ||
| 901 | * more than 100mA from USB must report itself as bus-powered in | ||
| 902 | * the GetStatus(DEVICE) call. | ||
| 903 | * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34 | ||
| 43 | */ | 904 | */ |
| 44 | extern const char *usb_speed_string(enum usb_device_speed speed); | 905 | #define USB_SELF_POWER_VBUS_MAX_DRAW 100 |
| 45 | 906 | ||
| 46 | #endif /* __LINUX_USB_CH9_H */ | 907 | #endif /* __LINUX_USB_CH9_H */ |
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h deleted file mode 100644 index 544825dde82..00000000000 --- a/include/linux/usb/chipidea.h +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Platform data for the chipidea USB dual role controller | ||
| 3 | */ | ||
| 4 | |||
| 5 | #ifndef __LINUX_USB_CHIPIDEA_H | ||
| 6 | #define __LINUX_USB_CHIPIDEA_H | ||
| 7 | |||
| 8 | #include <linux/usb/otg.h> | ||
| 9 | |||
| 10 | struct ci13xxx; | ||
| 11 | struct ci13xxx_platform_data { | ||
| 12 | const char *name; | ||
| 13 | /* offset of the capability registers */ | ||
| 14 | uintptr_t capoffset; | ||
| 15 | unsigned power_budget; | ||
| 16 | struct usb_phy *phy; | ||
| 17 | unsigned long flags; | ||
| 18 | #define CI13XXX_REGS_SHARED BIT(0) | ||
| 19 | #define CI13XXX_REQUIRE_TRANSCEIVER BIT(1) | ||
| 20 | #define CI13XXX_PULLUP_ON_VBUS BIT(2) | ||
| 21 | #define CI13XXX_DISABLE_STREAMING BIT(3) | ||
| 22 | |||
| 23 | #define CI13XXX_CONTROLLER_RESET_EVENT 0 | ||
| 24 | #define CI13XXX_CONTROLLER_STOPPED_EVENT 1 | ||
| 25 | void (*notify_event) (struct ci13xxx *ci, unsigned event); | ||
| 26 | }; | ||
| 27 | |||
| 28 | /* Default offset of capability registers */ | ||
| 29 | #define DEF_CAPOFFSET 0x100 | ||
| 30 | |||
| 31 | /* Add ci13xxx device */ | ||
| 32 | struct platform_device *ci13xxx_add_device(struct device *dev, | ||
| 33 | struct resource *res, int nres, | ||
| 34 | struct ci13xxx_platform_data *platdata); | ||
| 35 | /* Remove ci13xxx device */ | ||
| 36 | void ci13xxx_remove_device(struct platform_device *pdev); | ||
| 37 | |||
| 38 | #endif | ||
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index b09c37e04a9..6938a8608cf 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
| @@ -34,11 +34,8 @@ | |||
| 34 | * the composite model the host can use both functions at the same time. | 34 | * the composite model the host can use both functions at the same time. |
| 35 | */ | 35 | */ |
| 36 | 36 | ||
| 37 | #include <linux/bcd.h> | ||
| 38 | #include <linux/version.h> | ||
| 39 | #include <linux/usb/ch9.h> | 37 | #include <linux/usb/ch9.h> |
| 40 | #include <linux/usb/gadget.h> | 38 | #include <linux/usb/gadget.h> |
| 41 | #include <linux/log2.h> | ||
| 42 | 39 | ||
| 43 | /* | 40 | /* |
| 44 | * USB function drivers should return USB_GADGET_DELAYED_STATUS if they | 41 | * USB function drivers should return USB_GADGET_DELAYED_STATUS if they |
| @@ -49,10 +46,6 @@ | |||
| 49 | */ | 46 | */ |
| 50 | #define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */ | 47 | #define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */ |
| 51 | 48 | ||
| 52 | /* big enough to hold our biggest descriptor */ | ||
| 53 | #define USB_COMP_EP0_BUFSIZ 1024 | ||
| 54 | |||
| 55 | #define USB_MS_TO_HS_INTERVAL(x) (ilog2((x * 1000 / 125)) + 1) | ||
| 56 | struct usb_configuration; | 49 | struct usb_configuration; |
| 57 | 50 | ||
| 58 | /** | 51 | /** |
| @@ -119,7 +112,7 @@ struct usb_configuration; | |||
| 119 | struct usb_function { | 112 | struct usb_function { |
| 120 | const char *name; | 113 | const char *name; |
| 121 | struct usb_gadget_strings **strings; | 114 | struct usb_gadget_strings **strings; |
| 122 | struct usb_descriptor_header **fs_descriptors; | 115 | struct usb_descriptor_header **descriptors; |
| 123 | struct usb_descriptor_header **hs_descriptors; | 116 | struct usb_descriptor_header **hs_descriptors; |
| 124 | struct usb_descriptor_header **ss_descriptors; | 117 | struct usb_descriptor_header **ss_descriptors; |
| 125 | 118 | ||
| @@ -249,34 +242,25 @@ int usb_add_config(struct usb_composite_dev *, | |||
| 249 | struct usb_configuration *, | 242 | struct usb_configuration *, |
| 250 | int (*)(struct usb_configuration *)); | 243 | int (*)(struct usb_configuration *)); |
| 251 | 244 | ||
| 252 | void usb_remove_config(struct usb_composite_dev *, | 245 | int usb_remove_config(struct usb_composite_dev *, |
| 253 | struct usb_configuration *); | 246 | struct usb_configuration *); |
| 254 | 247 | ||
| 255 | /* predefined index for usb_composite_driver */ | ||
| 256 | enum { | ||
| 257 | USB_GADGET_MANUFACTURER_IDX = 0, | ||
| 258 | USB_GADGET_PRODUCT_IDX, | ||
| 259 | USB_GADGET_SERIAL_IDX, | ||
| 260 | USB_GADGET_FIRST_AVAIL_IDX, | ||
| 261 | }; | ||
| 262 | |||
| 263 | /** | 248 | /** |
| 264 | * struct usb_composite_driver - groups configurations into a gadget | 249 | * struct usb_composite_driver - groups configurations into a gadget |
| 265 | * @name: For diagnostics, identifies the driver. | 250 | * @name: For diagnostics, identifies the driver. |
| 251 | * @iProduct: Used as iProduct override if @dev->iProduct is not set. | ||
| 252 | * If NULL value of @name is taken. | ||
| 253 | * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is | ||
| 254 | * not set. If NULL a default "<system> <release> with <udc>" value | ||
| 255 | * will be used. | ||
| 266 | * @dev: Template descriptor for the device, including default device | 256 | * @dev: Template descriptor for the device, including default device |
| 267 | * identifiers. | 257 | * identifiers. |
| 268 | * @strings: tables of strings, keyed by identifiers assigned during @bind | 258 | * @strings: tables of strings, keyed by identifiers assigned during bind() |
| 269 | * and language IDs provided in control requests. Note: The first entries | 259 | * and language IDs provided in control requests |
| 270 | * are predefined. The first entry that may be used is | ||
| 271 | * USB_GADGET_FIRST_AVAIL_IDX | ||
| 272 | * @max_speed: Highest speed the driver supports. | 260 | * @max_speed: Highest speed the driver supports. |
| 273 | * @needs_serial: set to 1 if the gadget needs userspace to provide | 261 | * @needs_serial: set to 1 if the gadget needs userspace to provide |
| 274 | * a serial number. If one is not provided, warning will be printed. | 262 | * a serial number. If one is not provided, warning will be printed. |
| 275 | * @bind: (REQUIRED) Used to allocate resources that are shared across the | 263 | * @unbind: Reverses bind; called as a side effect of unregistering |
| 276 | * whole device, such as string IDs, and add its configurations using | ||
| 277 | * @usb_add_config(). This may fail by returning a negative errno | ||
| 278 | * value; it should return zero on successful initialization. | ||
| 279 | * @unbind: Reverses @bind; called as a side effect of unregistering | ||
| 280 | * this driver. | 264 | * this driver. |
| 281 | * @disconnect: optional driver disconnect method | 265 | * @disconnect: optional driver disconnect method |
| 282 | * @suspend: Notifies when the host stops sending USB traffic, | 266 | * @suspend: Notifies when the host stops sending USB traffic, |
| @@ -285,9 +269,9 @@ enum { | |||
| 285 | * before function notifications | 269 | * before function notifications |
| 286 | * | 270 | * |
| 287 | * Devices default to reporting self powered operation. Devices which rely | 271 | * Devices default to reporting self powered operation. Devices which rely |
| 288 | * on bus powered operation should report this in their @bind method. | 272 | * on bus powered operation should report this in their @bind() method. |
| 289 | * | 273 | * |
| 290 | * Before returning from @bind, various fields in the template descriptor | 274 | * Before returning from bind, various fields in the template descriptor |
| 291 | * may be overridden. These include the idVendor/idProduct/bcdDevice values | 275 | * may be overridden. These include the idVendor/idProduct/bcdDevice values |
| 292 | * normally to bind the appropriate host side driver, and the three strings | 276 | * normally to bind the appropriate host side driver, and the three strings |
| 293 | * (iManufacturer, iProduct, iSerialNumber) normally used to provide user | 277 | * (iManufacturer, iProduct, iSerialNumber) normally used to provide user |
| @@ -297,12 +281,13 @@ enum { | |||
| 297 | */ | 281 | */ |
| 298 | struct usb_composite_driver { | 282 | struct usb_composite_driver { |
| 299 | const char *name; | 283 | const char *name; |
| 284 | const char *iProduct; | ||
| 285 | const char *iManufacturer; | ||
| 300 | const struct usb_device_descriptor *dev; | 286 | const struct usb_device_descriptor *dev; |
| 301 | struct usb_gadget_strings **strings; | 287 | struct usb_gadget_strings **strings; |
| 302 | enum usb_device_speed max_speed; | 288 | enum usb_device_speed max_speed; |
| 303 | unsigned needs_serial:1; | 289 | unsigned needs_serial:1; |
| 304 | 290 | ||
| 305 | int (*bind)(struct usb_composite_dev *cdev); | ||
| 306 | int (*unbind)(struct usb_composite_dev *); | 291 | int (*unbind)(struct usb_composite_dev *); |
| 307 | 292 | ||
| 308 | void (*disconnect)(struct usb_composite_dev *); | 293 | void (*disconnect)(struct usb_composite_dev *); |
| @@ -310,10 +295,10 @@ struct usb_composite_driver { | |||
| 310 | /* global suspend hooks */ | 295 | /* global suspend hooks */ |
| 311 | void (*suspend)(struct usb_composite_dev *); | 296 | void (*suspend)(struct usb_composite_dev *); |
| 312 | void (*resume)(struct usb_composite_dev *); | 297 | void (*resume)(struct usb_composite_dev *); |
| 313 | struct usb_gadget_driver gadget_driver; | ||
| 314 | }; | 298 | }; |
| 315 | 299 | ||
| 316 | extern int usb_composite_probe(struct usb_composite_driver *driver); | 300 | extern int usb_composite_probe(struct usb_composite_driver *driver, |
| 301 | int (*bind)(struct usb_composite_dev *cdev)); | ||
| 317 | extern void usb_composite_unregister(struct usb_composite_driver *driver); | 302 | extern void usb_composite_unregister(struct usb_composite_driver *driver); |
| 318 | extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); | 303 | extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); |
| 319 | 304 | ||
| @@ -322,6 +307,7 @@ extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); | |||
| 322 | * struct usb_composite_device - represents one composite usb gadget | 307 | * struct usb_composite_device - represents one composite usb gadget |
| 323 | * @gadget: read-only, abstracts the gadget's usb peripheral controller | 308 | * @gadget: read-only, abstracts the gadget's usb peripheral controller |
| 324 | * @req: used for control responses; buffer is pre-allocated | 309 | * @req: used for control responses; buffer is pre-allocated |
| 310 | * @bufsiz: size of buffer pre-allocated in @req | ||
| 325 | * @config: the currently active configuration | 311 | * @config: the currently active configuration |
| 326 | * | 312 | * |
| 327 | * One of these devices is allocated and initialized before the | 313 | * One of these devices is allocated and initialized before the |
| @@ -352,6 +338,7 @@ extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); | |||
| 352 | struct usb_composite_dev { | 338 | struct usb_composite_dev { |
| 353 | struct usb_gadget *gadget; | 339 | struct usb_gadget *gadget; |
| 354 | struct usb_request *req; | 340 | struct usb_request *req; |
| 341 | unsigned bufsiz; | ||
| 355 | 342 | ||
| 356 | struct usb_configuration *config; | 343 | struct usb_configuration *config; |
| 357 | 344 | ||
| @@ -362,7 +349,9 @@ struct usb_composite_dev { | |||
| 362 | struct list_head configs; | 349 | struct list_head configs; |
| 363 | struct usb_composite_driver *driver; | 350 | struct usb_composite_driver *driver; |
| 364 | u8 next_string_id; | 351 | u8 next_string_id; |
| 365 | char *def_manufacturer; | 352 | u8 manufacturer_override; |
| 353 | u8 product_override; | ||
| 354 | u8 serial_override; | ||
| 366 | 355 | ||
| 367 | /* the gadget driver won't enable the data pullup | 356 | /* the gadget driver won't enable the data pullup |
| 368 | * while the deactivation count is nonzero. | 357 | * while the deactivation count is nonzero. |
| @@ -383,53 +372,6 @@ extern int usb_string_ids_tab(struct usb_composite_dev *c, | |||
| 383 | struct usb_string *str); | 372 | struct usb_string *str); |
| 384 | extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); | 373 | extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); |
| 385 | 374 | ||
| 386 | /* | ||
| 387 | * Some systems will need runtime overrides for the product identifiers | ||
| 388 | * published in the device descriptor, either numbers or strings or both. | ||
| 389 | * String parameters are in UTF-8 (superset of ASCII's 7 bit characters). | ||
| 390 | */ | ||
| 391 | struct usb_composite_overwrite { | ||
| 392 | u16 idVendor; | ||
| 393 | u16 idProduct; | ||
| 394 | u16 bcdDevice; | ||
| 395 | char *serial_number; | ||
| 396 | char *manufacturer; | ||
| 397 | char *product; | ||
| 398 | }; | ||
| 399 | #define USB_GADGET_COMPOSITE_OPTIONS() \ | ||
| 400 | static struct usb_composite_overwrite coverwrite; \ | ||
| 401 | \ | ||
| 402 | module_param_named(idVendor, coverwrite.idVendor, ushort, S_IRUGO); \ | ||
| 403 | MODULE_PARM_DESC(idVendor, "USB Vendor ID"); \ | ||
| 404 | \ | ||
| 405 | module_param_named(idProduct, coverwrite.idProduct, ushort, S_IRUGO); \ | ||
| 406 | MODULE_PARM_DESC(idProduct, "USB Product ID"); \ | ||
| 407 | \ | ||
| 408 | module_param_named(bcdDevice, coverwrite.bcdDevice, ushort, S_IRUGO); \ | ||
| 409 | MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); \ | ||
| 410 | \ | ||
| 411 | module_param_named(iSerialNumber, coverwrite.serial_number, charp, \ | ||
| 412 | S_IRUGO); \ | ||
| 413 | MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); \ | ||
| 414 | \ | ||
| 415 | module_param_named(iManufacturer, coverwrite.manufacturer, charp, \ | ||
| 416 | S_IRUGO); \ | ||
| 417 | MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); \ | ||
| 418 | \ | ||
| 419 | module_param_named(iProduct, coverwrite.product, charp, S_IRUGO); \ | ||
| 420 | MODULE_PARM_DESC(iProduct, "USB Product string") | ||
| 421 | |||
| 422 | void usb_composite_overwrite_options(struct usb_composite_dev *cdev, | ||
| 423 | struct usb_composite_overwrite *covr); | ||
| 424 | |||
| 425 | static inline u16 get_default_bcdDevice(void) | ||
| 426 | { | ||
| 427 | u16 bcdDevice; | ||
| 428 | |||
| 429 | bcdDevice = bin2bcd((LINUX_VERSION_CODE >> 16 & 0xff)) << 8; | ||
| 430 | bcdDevice |= bin2bcd((LINUX_VERSION_CODE >> 8 & 0xff)); | ||
| 431 | return bcdDevice; | ||
| 432 | } | ||
| 433 | 375 | ||
| 434 | /* messaging utils */ | 376 | /* messaging utils */ |
| 435 | #define DBG(d, fmt, args...) \ | 377 | #define DBG(d, fmt, args...) \ |
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h index daec99af5d5..7cc95ee3606 100644 --- a/include/linux/usb/ehci_def.h +++ b/include/linux/usb/ehci_def.h | |||
| @@ -111,13 +111,7 @@ struct ehci_regs { | |||
| 111 | /* ASYNCLISTADDR: offset 0x18 */ | 111 | /* ASYNCLISTADDR: offset 0x18 */ |
| 112 | u32 async_next; /* address of next async queue head */ | 112 | u32 async_next; /* address of next async queue head */ |
| 113 | 113 | ||
| 114 | u32 reserved1[2]; | 114 | u32 reserved[9]; |
| 115 | |||
| 116 | /* TXFILLTUNING: offset 0x24 */ | ||
| 117 | u32 txfill_tuning; /* TX FIFO Tuning register */ | ||
| 118 | #define TXFIFO_DEFAULT (8<<16) /* FIFO burst threshold 8 */ | ||
| 119 | |||
| 120 | u32 reserved2[6]; | ||
| 121 | 115 | ||
| 122 | /* CONFIGFLAG: offset 0x40 */ | 116 | /* CONFIGFLAG: offset 0x40 */ |
| 123 | u32 configured_flag; | 117 | u32 configured_flag; |
| @@ -161,34 +155,26 @@ struct ehci_regs { | |||
| 161 | #define PORT_CSC (1<<1) /* connect status change */ | 155 | #define PORT_CSC (1<<1) /* connect status change */ |
| 162 | #define PORT_CONNECT (1<<0) /* device connected */ | 156 | #define PORT_CONNECT (1<<0) /* device connected */ |
| 163 | #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) | 157 | #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) |
| 158 | }; | ||
| 164 | 159 | ||
| 165 | u32 reserved3[9]; | 160 | #define USBMODE 0x68 /* USB Device mode */ |
| 166 | |||
| 167 | /* USBMODE: offset 0x68 */ | ||
| 168 | u32 usbmode; /* USB Device mode */ | ||
| 169 | #define USBMODE_SDIS (1<<3) /* Stream disable */ | 161 | #define USBMODE_SDIS (1<<3) /* Stream disable */ |
| 170 | #define USBMODE_BE (1<<2) /* BE/LE endianness select */ | 162 | #define USBMODE_BE (1<<2) /* BE/LE endianness select */ |
| 171 | #define USBMODE_CM_HC (3<<0) /* host controller mode */ | 163 | #define USBMODE_CM_HC (3<<0) /* host controller mode */ |
| 172 | #define USBMODE_CM_IDLE (0<<0) /* idle state */ | 164 | #define USBMODE_CM_IDLE (0<<0) /* idle state */ |
| 173 | 165 | ||
| 174 | u32 reserved4[6]; | ||
| 175 | |||
| 176 | /* Moorestown has some non-standard registers, partially due to the fact that | 166 | /* Moorestown has some non-standard registers, partially due to the fact that |
| 177 | * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to | 167 | * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to |
| 178 | * PORTSCx | 168 | * PORTSCx |
| 179 | */ | 169 | */ |
| 180 | /* HOSTPC: offset 0x84 */ | 170 | #define HOSTPC0 0x84 /* HOSTPC extension */ |
| 181 | u32 hostpc[1]; /* HOSTPC extension */ | ||
| 182 | #define HOSTPC_PHCD (1<<22) /* Phy clock disable */ | 171 | #define HOSTPC_PHCD (1<<22) /* Phy clock disable */ |
| 183 | #define HOSTPC_PSPD (3<<25) /* Port speed detection */ | 172 | #define HOSTPC_PSPD (3<<25) /* Port speed detection */ |
| 184 | 173 | #define USBMODE_EX 0xc8 /* USB Device mode extension */ | |
| 185 | u32 reserved5[16]; | ||
| 186 | |||
| 187 | /* USBMODE_EX: offset 0xc8 */ | ||
| 188 | u32 usbmode_ex; /* USB Device mode extension */ | ||
| 189 | #define USBMODE_EX_VBPS (1<<5) /* VBus Power Select On */ | 174 | #define USBMODE_EX_VBPS (1<<5) /* VBus Power Select On */ |
| 190 | #define USBMODE_EX_HC (3<<0) /* host controller mode */ | 175 | #define USBMODE_EX_HC (3<<0) /* host controller mode */ |
| 191 | }; | 176 | #define TXFILLTUNING 0x24 /* TX FIFO Tuning register */ |
| 177 | #define TXFIFO_DEFAULT (8<<16) /* FIFO burst threshold 8 */ | ||
| 192 | 178 | ||
| 193 | /* Appendix C, Debug port ... intended for use with special "debug devices" | 179 | /* Appendix C, Debug port ... intended for use with special "debug devices" |
| 194 | * that can help if there's no serial console. (nonstandard enumeration.) | 180 | * that can help if there's no serial console. (nonstandard enumeration.) |
| @@ -221,35 +207,18 @@ extern int __init early_dbgp_init(char *s); | |||
| 221 | extern struct console early_dbgp_console; | 207 | extern struct console early_dbgp_console; |
| 222 | #endif /* CONFIG_EARLY_PRINTK_DBGP */ | 208 | #endif /* CONFIG_EARLY_PRINTK_DBGP */ |
| 223 | 209 | ||
| 224 | struct usb_hcd; | ||
| 225 | |||
| 226 | #ifdef CONFIG_XEN_DOM0 | ||
| 227 | extern int xen_dbgp_reset_prep(struct usb_hcd *); | ||
| 228 | extern int xen_dbgp_external_startup(struct usb_hcd *); | ||
| 229 | #else | ||
| 230 | static inline int xen_dbgp_reset_prep(struct usb_hcd *hcd) | ||
| 231 | { | ||
| 232 | return 1; /* Shouldn't this be 0? */ | ||
| 233 | } | ||
| 234 | |||
| 235 | static inline int xen_dbgp_external_startup(struct usb_hcd *hcd) | ||
| 236 | { | ||
| 237 | return -1; | ||
| 238 | } | ||
| 239 | #endif | ||
| 240 | |||
| 241 | #ifdef CONFIG_EARLY_PRINTK_DBGP | 210 | #ifdef CONFIG_EARLY_PRINTK_DBGP |
| 242 | /* Call backs from ehci host driver to ehci debug driver */ | 211 | /* Call backs from ehci host driver to ehci debug driver */ |
| 243 | extern int dbgp_external_startup(struct usb_hcd *); | 212 | extern int dbgp_external_startup(void); |
| 244 | extern int dbgp_reset_prep(struct usb_hcd *hcd); | 213 | extern int dbgp_reset_prep(void); |
| 245 | #else | 214 | #else |
| 246 | static inline int dbgp_reset_prep(struct usb_hcd *hcd) | 215 | static inline int dbgp_reset_prep(void) |
| 247 | { | 216 | { |
| 248 | return xen_dbgp_reset_prep(hcd); | 217 | return 1; |
| 249 | } | 218 | } |
| 250 | static inline int dbgp_external_startup(struct usb_hcd *hcd) | 219 | static inline int dbgp_external_startup(void) |
| 251 | { | 220 | { |
| 252 | return xen_dbgp_external_startup(hcd); | 221 | return -1; |
| 253 | } | 222 | } |
| 254 | #endif | 223 | #endif |
| 255 | 224 | ||
diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h deleted file mode 100644 index 99238b096f7..00000000000 --- a/include/linux/usb/ehci_pdriver.h +++ /dev/null | |||
| @@ -1,55 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de> | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms of the GNU General Public License as published by the | ||
| 6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 7 | * option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, but | ||
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| 11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 12 | * for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write to the Free Software Foundation, | ||
| 16 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef __USB_CORE_EHCI_PDRIVER_H | ||
| 20 | #define __USB_CORE_EHCI_PDRIVER_H | ||
| 21 | |||
| 22 | /** | ||
| 23 | * struct usb_ehci_pdata - platform_data for generic ehci driver | ||
| 24 | * | ||
| 25 | * @caps_offset: offset of the EHCI Capability Registers to the start of | ||
| 26 | * the io memory region provided to the driver. | ||
| 27 | * @has_tt: set to 1 if TT is integrated in root hub. | ||
| 28 | * @port_power_on: set to 1 if the controller needs a power up after | ||
| 29 | * initialization. | ||
| 30 | * @port_power_off: set to 1 if the controller needs to be powered down | ||
| 31 | * after initialization. | ||
| 32 | * @no_io_watchdog: set to 1 if the controller does not need the I/O | ||
| 33 | * watchdog to run. | ||
| 34 | * | ||
| 35 | * These are general configuration options for the EHCI controller. All of | ||
| 36 | * these options are activating more or less workarounds for some hardware. | ||
| 37 | */ | ||
| 38 | struct usb_ehci_pdata { | ||
| 39 | int caps_offset; | ||
| 40 | unsigned has_tt:1; | ||
| 41 | unsigned has_synopsys_hc_bug:1; | ||
| 42 | unsigned big_endian_desc:1; | ||
| 43 | unsigned big_endian_mmio:1; | ||
| 44 | unsigned no_io_watchdog:1; | ||
| 45 | |||
| 46 | /* Turn on all power and clocks */ | ||
| 47 | int (*power_on)(struct platform_device *pdev); | ||
| 48 | /* Turn off all power and clocks */ | ||
| 49 | void (*power_off)(struct platform_device *pdev); | ||
| 50 | /* Turn on only VBUS suspend power and hotplug detection, | ||
| 51 | * turn off everything else */ | ||
| 52 | void (*power_suspend)(struct platform_device *pdev); | ||
| 53 | }; | ||
| 54 | |||
| 55 | #endif /* __USB_CORE_EHCI_PDRIVER_H */ | ||
diff --git a/include/linux/usb/ezusb.h b/include/linux/usb/ezusb.h deleted file mode 100644 index 639ee45779f..00000000000 --- a/include/linux/usb/ezusb.h +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | #ifndef __EZUSB_H | ||
| 2 | #define __EZUSB_H | ||
| 3 | |||
| 4 | extern int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit); | ||
| 5 | extern int ezusb_fx1_ihex_firmware_download(struct usb_device *dev, | ||
| 6 | const char *firmware_path); | ||
| 7 | |||
| 8 | #endif /* __EZUSB_H */ | ||
diff --git a/include/linux/usb/functionfs.h b/include/linux/usb/functionfs.h index 65d0a88dbc6..7587ef934ba 100644 --- a/include/linux/usb/functionfs.h +++ b/include/linux/usb/functionfs.h | |||
| @@ -1,8 +1,171 @@ | |||
| 1 | #ifndef __LINUX_FUNCTIONFS_H__ | 1 | #ifndef __LINUX_FUNCTIONFS_H__ |
| 2 | #define __LINUX_FUNCTIONFS_H__ 1 | 2 | #define __LINUX_FUNCTIONFS_H__ 1 |
| 3 | 3 | ||
| 4 | #include <uapi/linux/usb/functionfs.h> | ||
| 5 | 4 | ||
| 5 | #include <linux/types.h> | ||
| 6 | #include <linux/ioctl.h> | ||
| 7 | |||
| 8 | #include <linux/usb/ch9.h> | ||
| 9 | |||
| 10 | |||
| 11 | enum { | ||
| 12 | FUNCTIONFS_DESCRIPTORS_MAGIC = 1, | ||
| 13 | FUNCTIONFS_STRINGS_MAGIC = 2 | ||
| 14 | }; | ||
| 15 | |||
| 16 | |||
| 17 | #ifndef __KERNEL__ | ||
| 18 | |||
| 19 | /* Descriptor of an non-audio endpoint */ | ||
| 20 | struct usb_endpoint_descriptor_no_audio { | ||
| 21 | __u8 bLength; | ||
| 22 | __u8 bDescriptorType; | ||
| 23 | |||
| 24 | __u8 bEndpointAddress; | ||
| 25 | __u8 bmAttributes; | ||
| 26 | __le16 wMaxPacketSize; | ||
| 27 | __u8 bInterval; | ||
| 28 | } __attribute__((packed)); | ||
| 29 | |||
| 30 | |||
| 31 | /* | ||
| 32 | * All numbers must be in little endian order. | ||
| 33 | */ | ||
| 34 | |||
| 35 | struct usb_functionfs_descs_head { | ||
| 36 | __le32 magic; | ||
| 37 | __le32 length; | ||
| 38 | __le32 fs_count; | ||
| 39 | __le32 hs_count; | ||
| 40 | } __attribute__((packed)); | ||
| 41 | |||
| 42 | /* | ||
| 43 | * Descriptors format: | ||
| 44 | * | ||
| 45 | * | off | name | type | description | | ||
| 46 | * |-----+-----------+--------------+--------------------------------------| | ||
| 47 | * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC | | ||
| 48 | * | 4 | length | LE32 | length of the whole data chunk | | ||
| 49 | * | 8 | fs_count | LE32 | number of full-speed descriptors | | ||
| 50 | * | 12 | hs_count | LE32 | number of high-speed descriptors | | ||
| 51 | * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors | | ||
| 52 | * | | hs_descrs | Descriptor[] | list of high-speed descriptors | | ||
| 53 | * | ||
| 54 | * descs are just valid USB descriptors and have the following format: | ||
| 55 | * | ||
| 56 | * | off | name | type | description | | ||
| 57 | * |-----+-----------------+------+--------------------------| | ||
| 58 | * | 0 | bLength | U8 | length of the descriptor | | ||
| 59 | * | 1 | bDescriptorType | U8 | descriptor type | | ||
| 60 | * | 2 | payload | | descriptor's payload | | ||
| 61 | */ | ||
| 62 | |||
| 63 | struct usb_functionfs_strings_head { | ||
| 64 | __le32 magic; | ||
| 65 | __le32 length; | ||
| 66 | __le32 str_count; | ||
| 67 | __le32 lang_count; | ||
| 68 | } __attribute__((packed)); | ||
| 69 | |||
| 70 | /* | ||
| 71 | * Strings format: | ||
| 72 | * | ||
| 73 | * | off | name | type | description | | ||
| 74 | * |-----+------------+-----------------------+----------------------------| | ||
| 75 | * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC | | ||
| 76 | * | 4 | length | LE32 | length of the data chunk | | ||
| 77 | * | 8 | str_count | LE32 | number of strings | | ||
| 78 | * | 12 | lang_count | LE32 | number of languages | | ||
| 79 | * | 16 | stringtab | StringTab[lang_count] | table of strings per lang | | ||
| 80 | * | ||
| 81 | * For each language there is one stringtab entry (ie. there are lang_count | ||
| 82 | * stringtab entires). Each StringTab has following format: | ||
| 83 | * | ||
| 84 | * | off | name | type | description | | ||
| 85 | * |-----+---------+-------------------+------------------------------------| | ||
| 86 | * | 0 | lang | LE16 | language code | | ||
| 87 | * | 2 | strings | String[str_count] | array of strings in given language | | ||
| 88 | * | ||
| 89 | * For each string there is one strings entry (ie. there are str_count | ||
| 90 | * string entries). Each String is a NUL terminated string encoded in | ||
| 91 | * UTF-8. | ||
| 92 | */ | ||
| 93 | |||
| 94 | #endif | ||
| 95 | |||
| 96 | |||
| 97 | /* | ||
| 98 | * Events are delivered on the ep0 file descriptor, when the user mode driver | ||
| 99 | * reads from this file descriptor after writing the descriptors. Don't | ||
| 100 | * stop polling this descriptor. | ||
| 101 | */ | ||
| 102 | |||
| 103 | enum usb_functionfs_event_type { | ||
| 104 | FUNCTIONFS_BIND, | ||
| 105 | FUNCTIONFS_UNBIND, | ||
| 106 | |||
| 107 | FUNCTIONFS_ENABLE, | ||
| 108 | FUNCTIONFS_DISABLE, | ||
| 109 | |||
| 110 | FUNCTIONFS_SETUP, | ||
| 111 | |||
| 112 | FUNCTIONFS_SUSPEND, | ||
| 113 | FUNCTIONFS_RESUME | ||
| 114 | }; | ||
| 115 | |||
| 116 | /* NOTE: this structure must stay the same size and layout on | ||
| 117 | * both 32-bit and 64-bit kernels. | ||
| 118 | */ | ||
| 119 | struct usb_functionfs_event { | ||
| 120 | union { | ||
| 121 | /* SETUP: packet; DATA phase i/o precedes next event | ||
| 122 | *(setup.bmRequestType & USB_DIR_IN) flags direction */ | ||
| 123 | struct usb_ctrlrequest setup; | ||
| 124 | } __attribute__((packed)) u; | ||
| 125 | |||
| 126 | /* enum usb_functionfs_event_type */ | ||
| 127 | __u8 type; | ||
| 128 | __u8 _pad[3]; | ||
| 129 | } __attribute__((packed)); | ||
| 130 | |||
| 131 | |||
| 132 | /* Endpoint ioctls */ | ||
| 133 | /* The same as in gadgetfs */ | ||
| 134 | |||
| 135 | /* IN transfers may be reported to the gadget driver as complete | ||
| 136 | * when the fifo is loaded, before the host reads the data; | ||
| 137 | * OUT transfers may be reported to the host's "client" driver as | ||
| 138 | * complete when they're sitting in the FIFO unread. | ||
| 139 | * THIS returns how many bytes are "unclaimed" in the endpoint fifo | ||
| 140 | * (needed for precise fault handling, when the hardware allows it) | ||
| 141 | */ | ||
| 142 | #define FUNCTIONFS_FIFO_STATUS _IO('g', 1) | ||
| 143 | |||
| 144 | /* discards any unclaimed data in the fifo. */ | ||
| 145 | #define FUNCTIONFS_FIFO_FLUSH _IO('g', 2) | ||
| 146 | |||
| 147 | /* resets endpoint halt+toggle; used to implement set_interface. | ||
| 148 | * some hardware (like pxa2xx) can't support this. | ||
| 149 | */ | ||
| 150 | #define FUNCTIONFS_CLEAR_HALT _IO('g', 3) | ||
| 151 | |||
| 152 | /* Specific for functionfs */ | ||
| 153 | |||
| 154 | /* | ||
| 155 | * Returns reverse mapping of an interface. Called on EP0. If there | ||
| 156 | * is no such interface returns -EDOM. If function is not active | ||
| 157 | * returns -ENODEV. | ||
| 158 | */ | ||
| 159 | #define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128) | ||
| 160 | |||
| 161 | /* | ||
| 162 | * Returns real bEndpointAddress of an endpoint. If function is not | ||
| 163 | * active returns -ENODEV. | ||
| 164 | */ | ||
| 165 | #define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129) | ||
| 166 | |||
| 167 | |||
| 168 | #ifdef __KERNEL__ | ||
| 6 | 169 | ||
| 7 | struct ffs_data; | 170 | struct ffs_data; |
| 8 | struct usb_composite_dev; | 171 | struct usb_composite_dev; |
| @@ -27,10 +190,10 @@ static int functionfs_ready_callback(struct ffs_data *ffs) | |||
| 27 | __attribute__((warn_unused_result, nonnull)); | 190 | __attribute__((warn_unused_result, nonnull)); |
| 28 | static void functionfs_closed_callback(struct ffs_data *ffs) | 191 | static void functionfs_closed_callback(struct ffs_data *ffs) |
| 29 | __attribute__((nonnull)); | 192 | __attribute__((nonnull)); |
| 30 | static void *functionfs_acquire_dev_callback(const char *dev_name) | 193 | static int functionfs_check_dev_callback(const char *dev_name) |
| 31 | __attribute__((warn_unused_result, nonnull)); | 194 | __attribute__((warn_unused_result, nonnull)); |
| 32 | static void functionfs_release_dev_callback(struct ffs_data *ffs_data) | ||
| 33 | __attribute__((nonnull)); | ||
| 34 | 195 | ||
| 35 | 196 | ||
| 36 | #endif | 197 | #endif |
| 198 | |||
| 199 | #endif | ||
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 0af6569b8cc..087f4b93183 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
| @@ -20,7 +20,6 @@ | |||
| 20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
| 22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
| 23 | #include <linux/scatterlist.h> | ||
| 24 | #include <linux/types.h> | 23 | #include <linux/types.h> |
| 25 | #include <linux/usb/ch9.h> | 24 | #include <linux/usb/ch9.h> |
| 26 | 25 | ||
| @@ -33,9 +32,6 @@ struct usb_ep; | |||
| 33 | * @dma: DMA address corresponding to 'buf'. If you don't set this | 32 | * @dma: DMA address corresponding to 'buf'. If you don't set this |
| 34 | * field, and the usb controller needs one, it is responsible | 33 | * field, and the usb controller needs one, it is responsible |
| 35 | * for mapping and unmapping the buffer. | 34 | * for mapping and unmapping the buffer. |
| 36 | * @sg: a scatterlist for SG-capable controllers. | ||
| 37 | * @num_sgs: number of SG entries | ||
| 38 | * @num_mapped_sgs: number of SG entries mapped to DMA (internal) | ||
| 39 | * @length: Length of that data | 35 | * @length: Length of that data |
| 40 | * @stream_id: The stream id, when USB3.0 bulk streams are being used | 36 | * @stream_id: The stream id, when USB3.0 bulk streams are being used |
| 41 | * @no_interrupt: If true, hints that no completion irq is needed. | 37 | * @no_interrupt: If true, hints that no completion irq is needed. |
| @@ -92,10 +88,6 @@ struct usb_request { | |||
| 92 | unsigned length; | 88 | unsigned length; |
| 93 | dma_addr_t dma; | 89 | dma_addr_t dma; |
| 94 | 90 | ||
| 95 | struct scatterlist *sg; | ||
| 96 | unsigned num_sgs; | ||
| 97 | unsigned num_mapped_sgs; | ||
| 98 | |||
| 99 | unsigned stream_id:16; | 91 | unsigned stream_id:16; |
| 100 | unsigned no_interrupt:1; | 92 | unsigned no_interrupt:1; |
| 101 | unsigned zero:1; | 93 | unsigned zero:1; |
| @@ -172,7 +164,7 @@ struct usb_ep { | |||
| 172 | unsigned maxpacket:16; | 164 | unsigned maxpacket:16; |
| 173 | unsigned max_streams:16; | 165 | unsigned max_streams:16; |
| 174 | unsigned mult:2; | 166 | unsigned mult:2; |
| 175 | unsigned maxburst:5; | 167 | unsigned maxburst:4; |
| 176 | u8 address; | 168 | u8 address; |
| 177 | const struct usb_endpoint_descriptor *desc; | 169 | const struct usb_endpoint_descriptor *desc; |
| 178 | const struct usb_ss_ep_comp_descriptor *comp_desc; | 170 | const struct usb_ss_ep_comp_descriptor *comp_desc; |
| @@ -445,9 +437,9 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep) | |||
| 445 | 437 | ||
| 446 | struct usb_dcd_config_params { | 438 | struct usb_dcd_config_params { |
| 447 | __u8 bU1devExitLat; /* U1 Device exit Latency */ | 439 | __u8 bU1devExitLat; /* U1 Device exit Latency */ |
| 448 | #define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01 /* Less then 1 microsec */ | 440 | #define USB_DEFULT_U1_DEV_EXIT_LAT 0x01 /* Less then 1 microsec */ |
| 449 | __le16 bU2DevExitLat; /* U2 Device exit Latency */ | 441 | __le16 bU2DevExitLat; /* U2 Device exit Latency */ |
| 450 | #define USB_DEFAULT_U2_DEV_EXIT_LAT 0x1F4 /* Less then 500 microsec */ | 442 | #define USB_DEFULT_U2_DEV_EXIT_LAT 0x1F4 /* Less then 500 microsec */ |
| 451 | }; | 443 | }; |
| 452 | 444 | ||
| 453 | 445 | ||
| @@ -474,8 +466,7 @@ struct usb_gadget_ops { | |||
| 474 | 466 | ||
| 475 | /* Those two are deprecated */ | 467 | /* Those two are deprecated */ |
| 476 | int (*start)(struct usb_gadget_driver *, | 468 | int (*start)(struct usb_gadget_driver *, |
| 477 | int (*bind)(struct usb_gadget *, | 469 | int (*bind)(struct usb_gadget *)); |
| 478 | struct usb_gadget_driver *driver)); | ||
| 479 | int (*stop)(struct usb_gadget_driver *); | 470 | int (*stop)(struct usb_gadget_driver *); |
| 480 | }; | 471 | }; |
| 481 | 472 | ||
| @@ -486,9 +477,8 @@ struct usb_gadget_ops { | |||
| 486 | * driver setup() requests | 477 | * driver setup() requests |
| 487 | * @ep_list: List of other endpoints supported by the device. | 478 | * @ep_list: List of other endpoints supported by the device. |
| 488 | * @speed: Speed of current connection to USB host. | 479 | * @speed: Speed of current connection to USB host. |
| 489 | * @max_speed: Maximal speed the UDC can handle. UDC must support this | 480 | * @is_dualspeed: True if the controller supports both high and full speed |
| 490 | * and all slower speeds. | 481 | * operation. If it does, the gadget driver must also support both. |
| 491 | * @sg_supported: true if we can handle scatter-gather | ||
| 492 | * @is_otg: True if the USB device port uses a Mini-AB jack, so that the | 482 | * @is_otg: True if the USB device port uses a Mini-AB jack, so that the |
| 493 | * gadget driver must provide a USB OTG descriptor. | 483 | * gadget driver must provide a USB OTG descriptor. |
| 494 | * @is_a_peripheral: False unless is_otg, the "A" end of a USB cable | 484 | * @is_a_peripheral: False unless is_otg, the "A" end of a USB cable |
| @@ -503,8 +493,6 @@ struct usb_gadget_ops { | |||
| 503 | * @name: Identifies the controller hardware type. Used in diagnostics | 493 | * @name: Identifies the controller hardware type. Used in diagnostics |
| 504 | * and sometimes configuration. | 494 | * and sometimes configuration. |
| 505 | * @dev: Driver model state for this abstract device. | 495 | * @dev: Driver model state for this abstract device. |
| 506 | * @out_epnum: last used out ep number | ||
| 507 | * @in_epnum: last used in ep number | ||
| 508 | * | 496 | * |
| 509 | * Gadgets have a mostly-portable "gadget driver" implementing device | 497 | * Gadgets have a mostly-portable "gadget driver" implementing device |
| 510 | * functions, handling all usb configurations and interfaces. Gadget | 498 | * functions, handling all usb configurations and interfaces. Gadget |
| @@ -530,8 +518,7 @@ struct usb_gadget { | |||
| 530 | struct usb_ep *ep0; | 518 | struct usb_ep *ep0; |
| 531 | struct list_head ep_list; /* of usb_ep */ | 519 | struct list_head ep_list; /* of usb_ep */ |
| 532 | enum usb_device_speed speed; | 520 | enum usb_device_speed speed; |
| 533 | enum usb_device_speed max_speed; | 521 | unsigned is_dualspeed:1; |
| 534 | unsigned sg_supported:1; | ||
| 535 | unsigned is_otg:1; | 522 | unsigned is_otg:1; |
| 536 | unsigned is_a_peripheral:1; | 523 | unsigned is_a_peripheral:1; |
| 537 | unsigned b_hnp_enable:1; | 524 | unsigned b_hnp_enable:1; |
| @@ -539,8 +526,6 @@ struct usb_gadget { | |||
| 539 | unsigned a_alt_hnp_support:1; | 526 | unsigned a_alt_hnp_support:1; |
| 540 | const char *name; | 527 | const char *name; |
| 541 | struct device dev; | 528 | struct device dev; |
| 542 | unsigned out_epnum; | ||
| 543 | unsigned in_epnum; | ||
| 544 | }; | 529 | }; |
| 545 | 530 | ||
| 546 | static inline void set_gadget_data(struct usb_gadget *gadget, void *data) | 531 | static inline void set_gadget_data(struct usb_gadget *gadget, void *data) |
| @@ -563,7 +548,14 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) | |||
| 563 | */ | 548 | */ |
| 564 | static inline int gadget_is_dualspeed(struct usb_gadget *g) | 549 | static inline int gadget_is_dualspeed(struct usb_gadget *g) |
| 565 | { | 550 | { |
| 566 | return g->max_speed >= USB_SPEED_HIGH; | 551 | #ifdef CONFIG_USB_GADGET_DUALSPEED |
| 552 | /* runtime test would check "g->is_dualspeed" ... that might be | ||
| 553 | * useful to work around hardware bugs, but is mostly pointless | ||
| 554 | */ | ||
| 555 | return 1; | ||
| 556 | #else | ||
| 557 | return 0; | ||
| 558 | #endif | ||
| 567 | } | 559 | } |
| 568 | 560 | ||
| 569 | /** | 561 | /** |
| @@ -573,7 +565,15 @@ static inline int gadget_is_dualspeed(struct usb_gadget *g) | |||
| 573 | */ | 565 | */ |
| 574 | static inline int gadget_is_superspeed(struct usb_gadget *g) | 566 | static inline int gadget_is_superspeed(struct usb_gadget *g) |
| 575 | { | 567 | { |
| 576 | return g->max_speed >= USB_SPEED_SUPER; | 568 | #ifdef CONFIG_USB_GADGET_SUPERSPEED |
| 569 | /* | ||
| 570 | * runtime test would check "g->is_superspeed" ... that might be | ||
| 571 | * useful to work around hardware bugs, but is mostly pointless | ||
| 572 | */ | ||
| 573 | return 1; | ||
| 574 | #else | ||
| 575 | return 0; | ||
| 576 | #endif | ||
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | /** | 579 | /** |
| @@ -760,7 +760,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget) | |||
| 760 | /** | 760 | /** |
| 761 | * struct usb_gadget_driver - driver for usb 'slave' devices | 761 | * struct usb_gadget_driver - driver for usb 'slave' devices |
| 762 | * @function: String describing the gadget's function | 762 | * @function: String describing the gadget's function |
| 763 | * @max_speed: Highest speed the driver handles. | 763 | * @speed: Highest speed the driver handles. |
| 764 | * @setup: Invoked for ep0 control requests that aren't handled by | 764 | * @setup: Invoked for ep0 control requests that aren't handled by |
| 765 | * the hardware level driver. Most calls must be handled by | 765 | * the hardware level driver. Most calls must be handled by |
| 766 | * the gadget driver, including descriptor and configuration | 766 | * the gadget driver, including descriptor and configuration |
| @@ -771,7 +771,6 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget) | |||
| 771 | * when the host is disconnected. May be called in_interrupt; this | 771 | * when the host is disconnected. May be called in_interrupt; this |
| 772 | * may not sleep. Some devices can't detect disconnect, so this might | 772 | * may not sleep. Some devices can't detect disconnect, so this might |
| 773 | * not be called except as part of controller shutdown. | 773 | * not be called except as part of controller shutdown. |
| 774 | * @bind: the driver's bind callback | ||
| 775 | * @unbind: Invoked when the driver is unbound from a gadget, | 774 | * @unbind: Invoked when the driver is unbound from a gadget, |
| 776 | * usually from rmmod (after a disconnect is reported). | 775 | * usually from rmmod (after a disconnect is reported). |
| 777 | * Called in a context that permits sleeping. | 776 | * Called in a context that permits sleeping. |
| @@ -825,9 +824,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget) | |||
| 825 | */ | 824 | */ |
| 826 | struct usb_gadget_driver { | 825 | struct usb_gadget_driver { |
| 827 | char *function; | 826 | char *function; |
| 828 | enum usb_device_speed max_speed; | 827 | enum usb_device_speed speed; |
| 829 | int (*bind)(struct usb_gadget *gadget, | ||
| 830 | struct usb_gadget_driver *driver); | ||
| 831 | void (*unbind)(struct usb_gadget *); | 828 | void (*unbind)(struct usb_gadget *); |
| 832 | int (*setup)(struct usb_gadget *, | 829 | int (*setup)(struct usb_gadget *, |
| 833 | const struct usb_ctrlrequest *); | 830 | const struct usb_ctrlrequest *); |
| @@ -853,6 +850,7 @@ struct usb_gadget_driver { | |||
| 853 | /** | 850 | /** |
| 854 | * usb_gadget_probe_driver - probe a gadget driver | 851 | * usb_gadget_probe_driver - probe a gadget driver |
| 855 | * @driver: the driver being registered | 852 | * @driver: the driver being registered |
| 853 | * @bind: the driver's bind callback | ||
| 856 | * Context: can sleep | 854 | * Context: can sleep |
| 857 | * | 855 | * |
| 858 | * Call this in your gadget driver's module initialization function, | 856 | * Call this in your gadget driver's module initialization function, |
| @@ -861,7 +859,8 @@ struct usb_gadget_driver { | |||
| 861 | * registration call returns. It's expected that the @bind() function will | 859 | * registration call returns. It's expected that the @bind() function will |
| 862 | * be in init sections. | 860 | * be in init sections. |
| 863 | */ | 861 | */ |
| 864 | int usb_gadget_probe_driver(struct usb_gadget_driver *driver); | 862 | int usb_gadget_probe_driver(struct usb_gadget_driver *driver, |
| 863 | int (*bind)(struct usb_gadget *)); | ||
| 865 | 864 | ||
| 866 | /** | 865 | /** |
| 867 | * usb_gadget_unregister_driver - unregister a gadget driver | 866 | * usb_gadget_unregister_driver - unregister a gadget driver |
| @@ -939,23 +938,6 @@ static inline void usb_free_descriptors(struct usb_descriptor_header **v) | |||
| 939 | kfree(v); | 938 | kfree(v); |
| 940 | } | 939 | } |
| 941 | 940 | ||
| 942 | struct usb_function; | ||
| 943 | int usb_assign_descriptors(struct usb_function *f, | ||
| 944 | struct usb_descriptor_header **fs, | ||
| 945 | struct usb_descriptor_header **hs, | ||
| 946 | struct usb_descriptor_header **ss); | ||
| 947 | void usb_free_all_descriptors(struct usb_function *f); | ||
| 948 | |||
| 949 | /*-------------------------------------------------------------------------*/ | ||
| 950 | |||
| 951 | /* utility to simplify map/unmap of usb_requests to/from DMA */ | ||
| 952 | |||
| 953 | extern int usb_gadget_map_request(struct usb_gadget *gadget, | ||
| 954 | struct usb_request *req, int is_in); | ||
| 955 | |||
| 956 | extern void usb_gadget_unmap_request(struct usb_gadget *gadget, | ||
| 957 | struct usb_request *req, int is_in); | ||
| 958 | |||
| 959 | /*-------------------------------------------------------------------------*/ | 941 | /*-------------------------------------------------------------------------*/ |
| 960 | 942 | ||
| 961 | /* utility wrapping a simple endpoint selection policy */ | 943 | /* utility wrapping a simple endpoint selection policy */ |
diff --git a/include/linux/usb/gpio_vbus.h b/include/linux/usb/gpio_vbus.h index 837bba604a0..d9f03ccc2d6 100644 --- a/include/linux/usb/gpio_vbus.h +++ b/include/linux/usb/gpio_vbus.h | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | * @gpio_pullup: optional D+ or D- pullup GPIO (else negative/invalid) | 17 | * @gpio_pullup: optional D+ or D- pullup GPIO (else negative/invalid) |
| 18 | * @gpio_vbus_inverted: true if gpio_vbus is active low | 18 | * @gpio_vbus_inverted: true if gpio_vbus is active low |
| 19 | * @gpio_pullup_inverted: true if gpio_pullup is active low | 19 | * @gpio_pullup_inverted: true if gpio_pullup is active low |
| 20 | * @wakeup: configure gpio_vbus as a wake-up source | ||
| 21 | * | 20 | * |
| 22 | * The VBUS sensing GPIO should have a pulldown, which will normally be | 21 | * The VBUS sensing GPIO should have a pulldown, which will normally be |
| 23 | * part of a resistor ladder turning a 4.0V-5.25V level on VBUS into a | 22 | * part of a resistor ladder turning a 4.0V-5.25V level on VBUS into a |
| @@ -28,5 +27,4 @@ struct gpio_vbus_mach_info { | |||
| 28 | int gpio_pullup; | 27 | int gpio_pullup; |
| 29 | bool gpio_vbus_inverted; | 28 | bool gpio_vbus_inverted; |
| 30 | bool gpio_pullup_inverted; | 29 | bool gpio_pullup_inverted; |
| 31 | bool wakeup; | ||
| 32 | }; | 30 | }; |
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 608050b2545..c0ecc5a2ef9 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h | |||
| @@ -93,18 +93,13 @@ struct usb_hcd { | |||
| 93 | */ | 93 | */ |
| 94 | const struct hc_driver *driver; /* hw-specific hooks */ | 94 | const struct hc_driver *driver; /* hw-specific hooks */ |
| 95 | 95 | ||
| 96 | /* | ||
| 97 | * OTG and some Host controllers need software interaction with phys; | ||
| 98 | * other external phys should be software-transparent | ||
| 99 | */ | ||
| 100 | struct usb_phy *phy; | ||
| 101 | |||
| 102 | /* Flags that need to be manipulated atomically because they can | 96 | /* Flags that need to be manipulated atomically because they can |
| 103 | * change while the host controller is running. Always use | 97 | * change while the host controller is running. Always use |
| 104 | * set_bit() or clear_bit() to change their values. | 98 | * set_bit() or clear_bit() to change their values. |
| 105 | */ | 99 | */ |
| 106 | unsigned long flags; | 100 | unsigned long flags; |
| 107 | #define HCD_FLAG_HW_ACCESSIBLE 0 /* at full power */ | 101 | #define HCD_FLAG_HW_ACCESSIBLE 0 /* at full power */ |
| 102 | #define HCD_FLAG_SAW_IRQ 1 | ||
| 108 | #define HCD_FLAG_POLL_RH 2 /* poll for rh status? */ | 103 | #define HCD_FLAG_POLL_RH 2 /* poll for rh status? */ |
| 109 | #define HCD_FLAG_POLL_PENDING 3 /* status has changed? */ | 104 | #define HCD_FLAG_POLL_PENDING 3 /* status has changed? */ |
| 110 | #define HCD_FLAG_WAKEUP_PENDING 4 /* root hub is resuming? */ | 105 | #define HCD_FLAG_WAKEUP_PENDING 4 /* root hub is resuming? */ |
| @@ -115,6 +110,7 @@ struct usb_hcd { | |||
| 115 | * be slightly faster than test_bit(). | 110 | * be slightly faster than test_bit(). |
| 116 | */ | 111 | */ |
| 117 | #define HCD_HW_ACCESSIBLE(hcd) ((hcd)->flags & (1U << HCD_FLAG_HW_ACCESSIBLE)) | 112 | #define HCD_HW_ACCESSIBLE(hcd) ((hcd)->flags & (1U << HCD_FLAG_HW_ACCESSIBLE)) |
| 113 | #define HCD_SAW_IRQ(hcd) ((hcd)->flags & (1U << HCD_FLAG_SAW_IRQ)) | ||
| 118 | #define HCD_POLL_RH(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_RH)) | 114 | #define HCD_POLL_RH(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_RH)) |
| 119 | #define HCD_POLL_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_PENDING)) | 115 | #define HCD_POLL_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_PENDING)) |
| 120 | #define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING)) | 116 | #define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING)) |
| @@ -133,10 +129,10 @@ struct usb_hcd { | |||
| 133 | unsigned authorized_default:1; | 129 | unsigned authorized_default:1; |
| 134 | unsigned has_tt:1; /* Integrated TT in root hub */ | 130 | unsigned has_tt:1; /* Integrated TT in root hub */ |
| 135 | 131 | ||
| 136 | unsigned int irq; /* irq allocated */ | 132 | int irq; /* irq allocated */ |
| 137 | void __iomem *regs; /* device memory/io */ | 133 | void __iomem *regs; /* device memory/io */ |
| 138 | resource_size_t rsrc_start; /* memory/io resource start */ | 134 | u64 rsrc_start; /* memory/io resource start */ |
| 139 | resource_size_t rsrc_len; /* memory/io resource length */ | 135 | u64 rsrc_len; /* memory/io resource length */ |
| 140 | unsigned power_budget; /* in mA, 0 = no limit */ | 136 | unsigned power_budget; /* in mA, 0 = no limit */ |
| 141 | 137 | ||
| 142 | /* bandwidth_mutex should be taken before adding or removing | 138 | /* bandwidth_mutex should be taken before adding or removing |
| @@ -347,16 +343,6 @@ struct hc_driver { | |||
| 347 | * address is set | 343 | * address is set |
| 348 | */ | 344 | */ |
| 349 | int (*update_device)(struct usb_hcd *, struct usb_device *); | 345 | int (*update_device)(struct usb_hcd *, struct usb_device *); |
| 350 | int (*set_usb2_hw_lpm)(struct usb_hcd *, struct usb_device *, int); | ||
| 351 | /* USB 3.0 Link Power Management */ | ||
| 352 | /* Returns the USB3 hub-encoded value for the U1/U2 timeout. */ | ||
| 353 | int (*enable_usb3_lpm_timeout)(struct usb_hcd *, | ||
| 354 | struct usb_device *, enum usb3_link_state state); | ||
| 355 | /* The xHCI host controller can still fail the command to | ||
| 356 | * disable the LPM timeouts, so this can return an error code. | ||
| 357 | */ | ||
| 358 | int (*disable_usb3_lpm_timeout)(struct usb_hcd *, | ||
| 359 | struct usb_device *, enum usb3_link_state state); | ||
| 360 | }; | 346 | }; |
| 361 | 347 | ||
| 362 | extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); | 348 | extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); |
| @@ -427,8 +413,6 @@ extern irqreturn_t usb_hcd_irq(int irq, void *__hcd); | |||
| 427 | 413 | ||
| 428 | extern void usb_hc_died(struct usb_hcd *hcd); | 414 | extern void usb_hc_died(struct usb_hcd *hcd); |
| 429 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); | 415 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); |
| 430 | extern void usb_wakeup_notification(struct usb_device *hdev, | ||
| 431 | unsigned int portnum); | ||
| 432 | 416 | ||
| 433 | /* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ | 417 | /* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ |
| 434 | #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) | 418 | #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) |
| @@ -597,6 +581,29 @@ static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) | |||
| 597 | } | 581 | } |
| 598 | #endif /* CONFIG_USB_SUSPEND */ | 582 | #endif /* CONFIG_USB_SUSPEND */ |
| 599 | 583 | ||
| 584 | |||
| 585 | /* | ||
| 586 | * USB device fs stuff | ||
| 587 | */ | ||
| 588 | |||
| 589 | #ifdef CONFIG_USB_DEVICEFS | ||
| 590 | |||
| 591 | /* | ||
| 592 | * these are expected to be called from the USB core/hub thread | ||
| 593 | * with the kernel lock held | ||
| 594 | */ | ||
| 595 | extern void usbfs_update_special(void); | ||
| 596 | extern int usbfs_init(void); | ||
| 597 | extern void usbfs_cleanup(void); | ||
| 598 | |||
| 599 | #else /* CONFIG_USB_DEVICEFS */ | ||
| 600 | |||
| 601 | static inline void usbfs_update_special(void) {} | ||
| 602 | static inline int usbfs_init(void) { return 0; } | ||
| 603 | static inline void usbfs_cleanup(void) { } | ||
| 604 | |||
| 605 | #endif /* CONFIG_USB_DEVICEFS */ | ||
| 606 | |||
| 600 | /*-------------------------------------------------------------------------*/ | 607 | /*-------------------------------------------------------------------------*/ |
| 601 | 608 | ||
| 602 | #if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE) | 609 | #if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE) |
diff --git a/include/linux/usb/intel_mid_otg.h b/include/linux/usb/intel_mid_otg.h index 756cf5543ff..a0ccf795f36 100644 --- a/include/linux/usb/intel_mid_otg.h +++ b/include/linux/usb/intel_mid_otg.h | |||
| @@ -104,11 +104,11 @@ struct iotg_ulpi_access_ops { | |||
| 104 | /* | 104 | /* |
| 105 | * the Intel MID (Langwell/Penwell) otg transceiver driver needs to interact | 105 | * the Intel MID (Langwell/Penwell) otg transceiver driver needs to interact |
| 106 | * with device and host drivers to implement the USB OTG related feature. More | 106 | * with device and host drivers to implement the USB OTG related feature. More |
| 107 | * function members are added based on usb_phy data structure for this | 107 | * function members are added based on otg_transceiver data structure for this |
| 108 | * purpose. | 108 | * purpose. |
| 109 | */ | 109 | */ |
| 110 | struct intel_mid_otg_xceiv { | 110 | struct intel_mid_otg_xceiv { |
| 111 | struct usb_phy otg; | 111 | struct otg_transceiver otg; |
| 112 | struct otg_hsm hsm; | 112 | struct otg_hsm hsm; |
| 113 | 113 | ||
| 114 | /* base address */ | 114 | /* base address */ |
| @@ -147,7 +147,7 @@ struct intel_mid_otg_xceiv { | |||
| 147 | 147 | ||
| 148 | }; | 148 | }; |
| 149 | static inline | 149 | static inline |
| 150 | struct intel_mid_otg_xceiv *otg_to_mid_xceiv(struct usb_phy *otg) | 150 | struct intel_mid_otg_xceiv *otg_to_mid_xceiv(struct otg_transceiver *otg) |
| 151 | { | 151 | { |
| 152 | return container_of(otg, struct intel_mid_otg_xceiv, otg); | 152 | return container_of(otg, struct intel_mid_otg_xceiv, otg); |
| 153 | } | 153 | } |
diff --git a/include/linux/usb/isp1301.h b/include/linux/usb/isp1301.h deleted file mode 100644 index d3a851c28b6..00000000000 --- a/include/linux/usb/isp1301.h +++ /dev/null | |||
| @@ -1,80 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * NXP ISP1301 USB transceiver driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2012 Roland Stigge <stigge@antcom.de> | ||
| 5 | * | ||
| 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; version 2 of the License. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef __LINUX_USB_ISP1301_H | ||
| 18 | #define __LINUX_USB_ISP1301_H | ||
| 19 | |||
| 20 | #include <linux/of.h> | ||
| 21 | |||
| 22 | /* I2C Register definitions: */ | ||
| 23 | |||
| 24 | #define ISP1301_I2C_MODE_CONTROL_1 0x04 /* u8 read, set, +1 clear */ | ||
| 25 | |||
| 26 | #define MC1_SPEED_REG (1 << 0) | ||
| 27 | #define MC1_SUSPEND_REG (1 << 1) | ||
| 28 | #define MC1_DAT_SE0 (1 << 2) | ||
| 29 | #define MC1_TRANSPARENT (1 << 3) | ||
| 30 | #define MC1_BDIS_ACON_EN (1 << 4) | ||
| 31 | #define MC1_OE_INT_EN (1 << 5) | ||
| 32 | #define MC1_UART_EN (1 << 6) | ||
| 33 | #define MC1_MASK 0x7f | ||
| 34 | |||
| 35 | #define ISP1301_I2C_MODE_CONTROL_2 0x12 /* u8 read, set, +1 clear */ | ||
| 36 | |||
| 37 | #define MC2_GLOBAL_PWR_DN (1 << 0) | ||
| 38 | #define MC2_SPD_SUSP_CTRL (1 << 1) | ||
| 39 | #define MC2_BI_DI (1 << 2) | ||
| 40 | #define MC2_TRANSP_BDIR0 (1 << 3) | ||
| 41 | #define MC2_TRANSP_BDIR1 (1 << 4) | ||
| 42 | #define MC2_AUDIO_EN (1 << 5) | ||
| 43 | #define MC2_PSW_EN (1 << 6) | ||
| 44 | #define MC2_EN2V7 (1 << 7) | ||
| 45 | |||
| 46 | #define ISP1301_I2C_OTG_CONTROL_1 0x06 /* u8 read, set, +1 clear */ | ||
| 47 | |||
| 48 | #define OTG1_DP_PULLUP (1 << 0) | ||
| 49 | #define OTG1_DM_PULLUP (1 << 1) | ||
| 50 | #define OTG1_DP_PULLDOWN (1 << 2) | ||
| 51 | #define OTG1_DM_PULLDOWN (1 << 3) | ||
| 52 | #define OTG1_ID_PULLDOWN (1 << 4) | ||
| 53 | #define OTG1_VBUS_DRV (1 << 5) | ||
| 54 | #define OTG1_VBUS_DISCHRG (1 << 6) | ||
| 55 | #define OTG1_VBUS_CHRG (1 << 7) | ||
| 56 | |||
| 57 | #define ISP1301_I2C_OTG_CONTROL_2 0x10 /* u8 readonly */ | ||
| 58 | |||
| 59 | #define OTG_B_SESS_END (1 << 6) | ||
| 60 | #define OTG_B_SESS_VLD (1 << 7) | ||
| 61 | |||
| 62 | #define ISP1301_I2C_INTERRUPT_SOURCE 0x8 | ||
| 63 | #define ISP1301_I2C_INTERRUPT_LATCH 0xA | ||
| 64 | #define ISP1301_I2C_INTERRUPT_FALLING 0xC | ||
| 65 | #define ISP1301_I2C_INTERRUPT_RISING 0xE | ||
| 66 | |||
| 67 | #define INT_VBUS_VLD (1 << 0) | ||
| 68 | #define INT_SESS_VLD (1 << 1) | ||
| 69 | #define INT_DP_HI (1 << 2) | ||
| 70 | #define INT_ID_GND (1 << 3) | ||
| 71 | #define INT_DM_HI (1 << 4) | ||
| 72 | #define INT_ID_FLOAT (1 << 5) | ||
| 73 | #define INT_BDIS_ACON (1 << 6) | ||
| 74 | #define INT_CR_INT (1 << 7) | ||
| 75 | |||
| 76 | #define ISP1301_I2C_REG_CLEAR_ADDR 1 /* Register Address Modifier */ | ||
| 77 | |||
| 78 | struct i2c_client *isp1301_get_client(struct device_node *node); | ||
| 79 | |||
| 80 | #endif /* __LINUX_USB_ISP1301_H */ | ||
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index 22a396c13f3..00311fe9d0d 100644 --- a/include/linux/usb/msm_hsusb.h +++ b/include/linux/usb/msm_hsusb.h | |||
| @@ -160,7 +160,7 @@ struct msm_otg_platform_data { | |||
| 160 | * detection process. | 160 | * detection process. |
| 161 | */ | 161 | */ |
| 162 | struct msm_otg { | 162 | struct msm_otg { |
| 163 | struct usb_phy phy; | 163 | struct otg_transceiver otg; |
| 164 | struct msm_otg_platform_data *pdata; | 164 | struct msm_otg_platform_data *pdata; |
| 165 | int irq; | 165 | int irq; |
| 166 | struct clk *clk; | 166 | struct clk *clk; |
diff --git a/include/linux/usb/musb-omap.h b/include/linux/usb/musb-omap.h deleted file mode 100644 index 7774c5986f0..00000000000 --- a/include/linux/usb/musb-omap.h +++ /dev/null | |||
| @@ -1,30 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2011-2012 by Texas Instruments | ||
| 3 | * | ||
| 4 | * The Inventra Controller Driver for Linux is free software; you | ||
| 5 | * can redistribute it and/or modify it under the terms of the GNU | ||
| 6 | * General Public License version 2 as published by the Free Software | ||
| 7 | * Foundation. | ||
| 8 | */ | ||
| 9 | |||
| 10 | #ifndef __MUSB_OMAP_H__ | ||
| 11 | #define __MUSB_OMAP_H__ | ||
| 12 | |||
| 13 | enum omap_musb_vbus_id_status { | ||
| 14 | OMAP_MUSB_UNKNOWN = 0, | ||
| 15 | OMAP_MUSB_ID_GROUND, | ||
| 16 | OMAP_MUSB_ID_FLOAT, | ||
| 17 | OMAP_MUSB_VBUS_VALID, | ||
| 18 | OMAP_MUSB_VBUS_OFF, | ||
| 19 | }; | ||
| 20 | |||
| 21 | #if (defined(CONFIG_USB_MUSB_OMAP2PLUS) || \ | ||
| 22 | defined(CONFIG_USB_MUSB_OMAP2PLUS_MODULE)) | ||
| 23 | void omap_musb_mailbox(enum omap_musb_vbus_id_status status); | ||
| 24 | #else | ||
| 25 | static inline void omap_musb_mailbox(enum omap_musb_vbus_id_status status) | ||
| 26 | { | ||
| 27 | } | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #endif /* __MUSB_OMAP_H__ */ | ||
diff --git a/include/linux/usb/nop-usb-xceiv.h b/include/linux/usb/nop-usb-xceiv.h deleted file mode 100644 index 28884c71741..00000000000 --- a/include/linux/usb/nop-usb-xceiv.h +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | #ifndef __LINUX_USB_NOP_XCEIV_H | ||
| 2 | #define __LINUX_USB_NOP_XCEIV_H | ||
| 3 | |||
| 4 | #include <linux/usb/otg.h> | ||
| 5 | |||
| 6 | struct nop_usb_xceiv_platform_data { | ||
| 7 | enum usb_phy_type type; | ||
| 8 | }; | ||
| 9 | |||
| 10 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) | ||
| 11 | /* sometimes transceivers are accessed only through e.g. ULPI */ | ||
| 12 | extern void usb_nop_xceiv_register(void); | ||
| 13 | extern void usb_nop_xceiv_unregister(void); | ||
| 14 | #else | ||
| 15 | static inline void usb_nop_xceiv_register(void) | ||
| 16 | { | ||
| 17 | } | ||
| 18 | |||
| 19 | static inline void usb_nop_xceiv_unregister(void) | ||
| 20 | { | ||
| 21 | } | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #endif /* __LINUX_USB_NOP_XCEIV_H */ | ||
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h deleted file mode 100644 index 012f2b7eb2b..00000000000 --- a/include/linux/usb/ohci_pdriver.h +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de> | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms of the GNU General Public License as published by the | ||
| 6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 7 | * option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, but | ||
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| 11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 12 | * for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write to the Free Software Foundation, | ||
| 16 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef __USB_CORE_OHCI_PDRIVER_H | ||
| 20 | #define __USB_CORE_OHCI_PDRIVER_H | ||
| 21 | |||
| 22 | /** | ||
| 23 | * struct usb_ohci_pdata - platform_data for generic ohci driver | ||
| 24 | * | ||
| 25 | * @big_endian_desc: BE descriptors | ||
| 26 | * @big_endian_mmio: BE registers | ||
| 27 | * @no_big_frame_no: no big endian frame_no shift | ||
| 28 | * @num_ports: number of ports | ||
| 29 | * | ||
| 30 | * These are general configuration options for the OHCI controller. All of | ||
| 31 | * these options are activating more or less workarounds for some hardware. | ||
| 32 | */ | ||
| 33 | struct usb_ohci_pdata { | ||
| 34 | unsigned big_endian_desc:1; | ||
| 35 | unsigned big_endian_mmio:1; | ||
| 36 | unsigned no_big_frame_no:1; | ||
| 37 | unsigned int num_ports; | ||
| 38 | |||
| 39 | /* Turn on all power and clocks */ | ||
| 40 | int (*power_on)(struct platform_device *pdev); | ||
| 41 | /* Turn off all power and clocks */ | ||
| 42 | void (*power_off)(struct platform_device *pdev); | ||
| 43 | /* Turn on only VBUS suspend power and hotplug detection, | ||
| 44 | * turn off everything else */ | ||
| 45 | void (*power_suspend)(struct platform_device *pdev); | ||
| 46 | }; | ||
| 47 | |||
| 48 | #endif /* __USB_CORE_OHCI_PDRIVER_H */ | ||
diff --git a/include/linux/usb/omap_usb.h b/include/linux/usb/omap_usb.h deleted file mode 100644 index 0ea17f8ae82..00000000000 --- a/include/linux/usb/omap_usb.h +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * omap_usb.h -- omap usb2 phy header file | ||
| 3 | * | ||
| 4 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef __DRIVERS_OMAP_USB2_H | ||
| 20 | #define __DRIVERS_OMAP_USB2_H | ||
| 21 | |||
| 22 | #include <linux/usb/otg.h> | ||
| 23 | |||
| 24 | struct omap_usb { | ||
| 25 | struct usb_phy phy; | ||
| 26 | struct phy_companion *comparator; | ||
| 27 | struct device *dev; | ||
| 28 | u32 __iomem *control_dev; | ||
| 29 | struct clk *wkupclk; | ||
| 30 | u8 is_suspended:1; | ||
| 31 | }; | ||
| 32 | |||
| 33 | #define PHY_PD 0x1 | ||
| 34 | |||
| 35 | #define phy_to_omapusb(x) container_of((x), struct omap_usb, phy) | ||
| 36 | |||
| 37 | #if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE) | ||
| 38 | extern int omap_usb2_set_comparator(struct phy_companion *comparator); | ||
| 39 | #else | ||
| 40 | static inline int omap_usb2_set_comparator(struct phy_companion *comparator) | ||
| 41 | { | ||
| 42 | return -ENODEV; | ||
| 43 | } | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #endif /* __DRIVERS_OMAP_USB_H */ | ||
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index e8a5fe87c6b..d87f44f5b04 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h | |||
| @@ -9,36 +9,176 @@ | |||
| 9 | #ifndef __LINUX_USB_OTG_H | 9 | #ifndef __LINUX_USB_OTG_H |
| 10 | #define __LINUX_USB_OTG_H | 10 | #define __LINUX_USB_OTG_H |
| 11 | 11 | ||
| 12 | #include <linux/usb/phy.h> | 12 | #include <linux/notifier.h> |
| 13 | |||
| 14 | /* OTG defines lots of enumeration states before device reset */ | ||
| 15 | enum usb_otg_state { | ||
| 16 | OTG_STATE_UNDEFINED = 0, | ||
| 17 | |||
| 18 | /* single-role peripheral, and dual-role default-b */ | ||
| 19 | OTG_STATE_B_IDLE, | ||
| 20 | OTG_STATE_B_SRP_INIT, | ||
| 21 | OTG_STATE_B_PERIPHERAL, | ||
| 22 | |||
| 23 | /* extra dual-role default-b states */ | ||
| 24 | OTG_STATE_B_WAIT_ACON, | ||
| 25 | OTG_STATE_B_HOST, | ||
| 26 | |||
| 27 | /* dual-role default-a */ | ||
| 28 | OTG_STATE_A_IDLE, | ||
| 29 | OTG_STATE_A_WAIT_VRISE, | ||
| 30 | OTG_STATE_A_WAIT_BCON, | ||
| 31 | OTG_STATE_A_HOST, | ||
| 32 | OTG_STATE_A_SUSPEND, | ||
| 33 | OTG_STATE_A_PERIPHERAL, | ||
| 34 | OTG_STATE_A_WAIT_VFALL, | ||
| 35 | OTG_STATE_A_VBUS_ERR, | ||
| 36 | }; | ||
| 37 | |||
| 38 | enum usb_xceiv_events { | ||
| 39 | USB_EVENT_NONE, /* no events or cable disconnected */ | ||
| 40 | USB_EVENT_VBUS, /* vbus valid event */ | ||
| 41 | USB_EVENT_ID, /* id was grounded */ | ||
| 42 | USB_EVENT_CHARGER, /* usb dedicated charger */ | ||
| 43 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct otg_transceiver; | ||
| 47 | |||
| 48 | /* for transceivers connected thru an ULPI interface, the user must | ||
| 49 | * provide access ops | ||
| 50 | */ | ||
| 51 | struct otg_io_access_ops { | ||
| 52 | int (*read)(struct otg_transceiver *otg, u32 reg); | ||
| 53 | int (*write)(struct otg_transceiver *otg, u32 val, u32 reg); | ||
| 54 | }; | ||
| 55 | |||
| 56 | /* | ||
| 57 | * the otg driver needs to interact with both device side and host side | ||
| 58 | * usb controllers. it decides which controller is active at a given | ||
| 59 | * moment, using the transceiver, ID signal, HNP and sometimes static | ||
| 60 | * configuration information (including "board isn't wired for otg"). | ||
| 61 | */ | ||
| 62 | struct otg_transceiver { | ||
| 63 | struct device *dev; | ||
| 64 | const char *label; | ||
| 65 | unsigned int flags; | ||
| 13 | 66 | ||
| 14 | struct usb_otg { | ||
| 15 | u8 default_a; | 67 | u8 default_a; |
| 68 | enum usb_otg_state state; | ||
| 69 | enum usb_xceiv_events last_event; | ||
| 16 | 70 | ||
| 17 | struct usb_phy *phy; | ||
| 18 | struct usb_bus *host; | 71 | struct usb_bus *host; |
| 19 | struct usb_gadget *gadget; | 72 | struct usb_gadget *gadget; |
| 20 | 73 | ||
| 74 | struct otg_io_access_ops *io_ops; | ||
| 75 | void __iomem *io_priv; | ||
| 76 | |||
| 77 | /* for notification of usb_xceiv_events */ | ||
| 78 | struct atomic_notifier_head notifier; | ||
| 79 | |||
| 80 | /* to pass extra port status to the root hub */ | ||
| 81 | u16 port_status; | ||
| 82 | u16 port_change; | ||
| 83 | |||
| 84 | /* initialize/shutdown the OTG controller */ | ||
| 85 | int (*init)(struct otg_transceiver *otg); | ||
| 86 | void (*shutdown)(struct otg_transceiver *otg); | ||
| 87 | |||
| 21 | /* bind/unbind the host controller */ | 88 | /* bind/unbind the host controller */ |
| 22 | int (*set_host)(struct usb_otg *otg, struct usb_bus *host); | 89 | int (*set_host)(struct otg_transceiver *otg, |
| 90 | struct usb_bus *host); | ||
| 23 | 91 | ||
| 24 | /* bind/unbind the peripheral controller */ | 92 | /* bind/unbind the peripheral controller */ |
| 25 | int (*set_peripheral)(struct usb_otg *otg, | 93 | int (*set_peripheral)(struct otg_transceiver *otg, |
| 26 | struct usb_gadget *gadget); | 94 | struct usb_gadget *gadget); |
| 95 | |||
| 96 | /* effective for B devices, ignored for A-peripheral */ | ||
| 97 | int (*set_power)(struct otg_transceiver *otg, | ||
| 98 | unsigned mA); | ||
| 27 | 99 | ||
| 28 | /* effective for A-peripheral, ignored for B devices */ | 100 | /* effective for A-peripheral, ignored for B devices */ |
| 29 | int (*set_vbus)(struct usb_otg *otg, bool enabled); | 101 | int (*set_vbus)(struct otg_transceiver *otg, |
| 102 | bool enabled); | ||
| 103 | |||
| 104 | /* for non-OTG B devices: set transceiver into suspend mode */ | ||
| 105 | int (*set_suspend)(struct otg_transceiver *otg, | ||
| 106 | int suspend); | ||
| 30 | 107 | ||
| 31 | /* for B devices only: start session with A-Host */ | 108 | /* for B devices only: start session with A-Host */ |
| 32 | int (*start_srp)(struct usb_otg *otg); | 109 | int (*start_srp)(struct otg_transceiver *otg); |
| 33 | 110 | ||
| 34 | /* start or continue HNP role switch */ | 111 | /* start or continue HNP role switch */ |
| 35 | int (*start_hnp)(struct usb_otg *otg); | 112 | int (*start_hnp)(struct otg_transceiver *otg); |
| 36 | 113 | ||
| 37 | }; | 114 | }; |
| 38 | 115 | ||
| 116 | |||
| 117 | /* for board-specific init logic */ | ||
| 118 | extern int otg_set_transceiver(struct otg_transceiver *); | ||
| 119 | |||
| 120 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) | ||
| 121 | /* sometimes transceivers are accessed only through e.g. ULPI */ | ||
| 122 | extern void usb_nop_xceiv_register(void); | ||
| 123 | extern void usb_nop_xceiv_unregister(void); | ||
| 124 | #else | ||
| 125 | static inline void usb_nop_xceiv_register(void) | ||
| 126 | { | ||
| 127 | } | ||
| 128 | |||
| 129 | static inline void usb_nop_xceiv_unregister(void) | ||
| 130 | { | ||
| 131 | } | ||
| 132 | #endif | ||
| 133 | |||
| 134 | /* helpers for direct access thru low-level io interface */ | ||
| 135 | static inline int otg_io_read(struct otg_transceiver *otg, u32 reg) | ||
| 136 | { | ||
| 137 | if (otg->io_ops && otg->io_ops->read) | ||
| 138 | return otg->io_ops->read(otg, reg); | ||
| 139 | |||
| 140 | return -EINVAL; | ||
| 141 | } | ||
| 142 | |||
| 143 | static inline int otg_io_write(struct otg_transceiver *otg, u32 val, u32 reg) | ||
| 144 | { | ||
| 145 | if (otg->io_ops && otg->io_ops->write) | ||
| 146 | return otg->io_ops->write(otg, val, reg); | ||
| 147 | |||
| 148 | return -EINVAL; | ||
| 149 | } | ||
| 150 | |||
| 151 | static inline int | ||
| 152 | otg_init(struct otg_transceiver *otg) | ||
| 153 | { | ||
| 154 | if (otg->init) | ||
| 155 | return otg->init(otg); | ||
| 156 | |||
| 157 | return 0; | ||
| 158 | } | ||
| 159 | |||
| 160 | static inline void | ||
| 161 | otg_shutdown(struct otg_transceiver *otg) | ||
| 162 | { | ||
| 163 | if (otg->shutdown) | ||
| 164 | otg->shutdown(otg); | ||
| 165 | } | ||
| 166 | |||
| 167 | /* for usb host and peripheral controller drivers */ | ||
| 39 | #ifdef CONFIG_USB_OTG_UTILS | 168 | #ifdef CONFIG_USB_OTG_UTILS |
| 169 | extern struct otg_transceiver *otg_get_transceiver(void); | ||
| 170 | extern void otg_put_transceiver(struct otg_transceiver *); | ||
| 40 | extern const char *otg_state_string(enum usb_otg_state state); | 171 | extern const char *otg_state_string(enum usb_otg_state state); |
| 41 | #else | 172 | #else |
| 173 | static inline struct otg_transceiver *otg_get_transceiver(void) | ||
| 174 | { | ||
| 175 | return NULL; | ||
| 176 | } | ||
| 177 | |||
| 178 | static inline void otg_put_transceiver(struct otg_transceiver *x) | ||
| 179 | { | ||
| 180 | } | ||
| 181 | |||
| 42 | static inline const char *otg_state_string(enum usb_otg_state state) | 182 | static inline const char *otg_state_string(enum usb_otg_state state) |
| 43 | { | 183 | { |
| 44 | return NULL; | 184 | return NULL; |
| @@ -47,53 +187,67 @@ static inline const char *otg_state_string(enum usb_otg_state state) | |||
| 47 | 187 | ||
| 48 | /* Context: can sleep */ | 188 | /* Context: can sleep */ |
| 49 | static inline int | 189 | static inline int |
| 50 | otg_start_hnp(struct usb_otg *otg) | 190 | otg_start_hnp(struct otg_transceiver *otg) |
| 51 | { | 191 | { |
| 52 | if (otg && otg->start_hnp) | 192 | return otg->start_hnp(otg); |
| 53 | return otg->start_hnp(otg); | ||
| 54 | |||
| 55 | return -ENOTSUPP; | ||
| 56 | } | 193 | } |
| 57 | 194 | ||
| 58 | /* Context: can sleep */ | 195 | /* Context: can sleep */ |
| 59 | static inline int | 196 | static inline int |
| 60 | otg_set_vbus(struct usb_otg *otg, bool enabled) | 197 | otg_set_vbus(struct otg_transceiver *otg, bool enabled) |
| 61 | { | 198 | { |
| 62 | if (otg && otg->set_vbus) | 199 | return otg->set_vbus(otg, enabled); |
| 63 | return otg->set_vbus(otg, enabled); | ||
| 64 | |||
| 65 | return -ENOTSUPP; | ||
| 66 | } | 200 | } |
| 67 | 201 | ||
| 68 | /* for HCDs */ | 202 | /* for HCDs */ |
| 69 | static inline int | 203 | static inline int |
| 70 | otg_set_host(struct usb_otg *otg, struct usb_bus *host) | 204 | otg_set_host(struct otg_transceiver *otg, struct usb_bus *host) |
| 71 | { | 205 | { |
| 72 | if (otg && otg->set_host) | 206 | return otg->set_host(otg, host); |
| 73 | return otg->set_host(otg, host); | ||
| 74 | |||
| 75 | return -ENOTSUPP; | ||
| 76 | } | 207 | } |
| 77 | 208 | ||
| 78 | /* for usb peripheral controller drivers */ | 209 | /* for usb peripheral controller drivers */ |
| 79 | 210 | ||
| 80 | /* Context: can sleep */ | 211 | /* Context: can sleep */ |
| 81 | static inline int | 212 | static inline int |
| 82 | otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph) | 213 | otg_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *periph) |
| 83 | { | 214 | { |
| 84 | if (otg && otg->set_peripheral) | 215 | return otg->set_peripheral(otg, periph); |
| 85 | return otg->set_peripheral(otg, periph); | 216 | } |
| 86 | 217 | ||
| 87 | return -ENOTSUPP; | 218 | static inline int |
| 219 | otg_set_power(struct otg_transceiver *otg, unsigned mA) | ||
| 220 | { | ||
| 221 | return otg->set_power(otg, mA); | ||
| 88 | } | 222 | } |
| 89 | 223 | ||
| 224 | /* Context: can sleep */ | ||
| 90 | static inline int | 225 | static inline int |
| 91 | otg_start_srp(struct usb_otg *otg) | 226 | otg_set_suspend(struct otg_transceiver *otg, int suspend) |
| 92 | { | 227 | { |
| 93 | if (otg && otg->start_srp) | 228 | if (otg->set_suspend != NULL) |
| 94 | return otg->start_srp(otg); | 229 | return otg->set_suspend(otg, suspend); |
| 230 | else | ||
| 231 | return 0; | ||
| 232 | } | ||
| 95 | 233 | ||
| 96 | return -ENOTSUPP; | 234 | static inline int |
| 235 | otg_start_srp(struct otg_transceiver *otg) | ||
| 236 | { | ||
| 237 | return otg->start_srp(otg); | ||
| 238 | } | ||
| 239 | |||
| 240 | /* notifiers */ | ||
| 241 | static inline int | ||
| 242 | otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb) | ||
| 243 | { | ||
| 244 | return atomic_notifier_chain_register(&otg->notifier, nb); | ||
| 245 | } | ||
| 246 | |||
| 247 | static inline void | ||
| 248 | otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb) | ||
| 249 | { | ||
| 250 | atomic_notifier_chain_unregister(&otg->notifier, nb); | ||
| 97 | } | 251 | } |
| 98 | 252 | ||
| 99 | /* for OTG controller drivers (and maybe other stuff) */ | 253 | /* for OTG controller drivers (and maybe other stuff) */ |
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h deleted file mode 100644 index a29ae1eb934..00000000000 --- a/include/linux/usb/phy.h +++ /dev/null | |||
| @@ -1,236 +0,0 @@ | |||
| 1 | /* USB OTG (On The Go) defines */ | ||
| 2 | /* | ||
| 3 | * | ||
| 4 | * These APIs may be used between USB controllers. USB device drivers | ||
| 5 | * (for either host or peripheral roles) don't use these calls; they | ||
| 6 | * continue to use just usb_device and usb_gadget. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __LINUX_USB_PHY_H | ||
| 10 | #define __LINUX_USB_PHY_H | ||
| 11 | |||
| 12 | #include <linux/notifier.h> | ||
| 13 | #include <linux/usb.h> | ||
| 14 | |||
| 15 | enum usb_phy_events { | ||
| 16 | USB_EVENT_NONE, /* no events or cable disconnected */ | ||
| 17 | USB_EVENT_VBUS, /* vbus valid event */ | ||
| 18 | USB_EVENT_ID, /* id was grounded */ | ||
| 19 | USB_EVENT_CHARGER, /* usb dedicated charger */ | ||
| 20 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ | ||
| 21 | }; | ||
| 22 | |||
| 23 | /* associate a type with PHY */ | ||
| 24 | enum usb_phy_type { | ||
| 25 | USB_PHY_TYPE_UNDEFINED, | ||
| 26 | USB_PHY_TYPE_USB2, | ||
| 27 | USB_PHY_TYPE_USB3, | ||
| 28 | }; | ||
| 29 | |||
| 30 | /* OTG defines lots of enumeration states before device reset */ | ||
| 31 | enum usb_otg_state { | ||
| 32 | OTG_STATE_UNDEFINED = 0, | ||
| 33 | |||
| 34 | /* single-role peripheral, and dual-role default-b */ | ||
| 35 | OTG_STATE_B_IDLE, | ||
| 36 | OTG_STATE_B_SRP_INIT, | ||
| 37 | OTG_STATE_B_PERIPHERAL, | ||
| 38 | |||
| 39 | /* extra dual-role default-b states */ | ||
| 40 | OTG_STATE_B_WAIT_ACON, | ||
| 41 | OTG_STATE_B_HOST, | ||
| 42 | |||
| 43 | /* dual-role default-a */ | ||
| 44 | OTG_STATE_A_IDLE, | ||
| 45 | OTG_STATE_A_WAIT_VRISE, | ||
| 46 | OTG_STATE_A_WAIT_BCON, | ||
| 47 | OTG_STATE_A_HOST, | ||
| 48 | OTG_STATE_A_SUSPEND, | ||
| 49 | OTG_STATE_A_PERIPHERAL, | ||
| 50 | OTG_STATE_A_WAIT_VFALL, | ||
| 51 | OTG_STATE_A_VBUS_ERR, | ||
| 52 | }; | ||
| 53 | |||
| 54 | struct usb_phy; | ||
| 55 | struct usb_otg; | ||
| 56 | |||
| 57 | /* for transceivers connected thru an ULPI interface, the user must | ||
| 58 | * provide access ops | ||
| 59 | */ | ||
| 60 | struct usb_phy_io_ops { | ||
| 61 | int (*read)(struct usb_phy *x, u32 reg); | ||
| 62 | int (*write)(struct usb_phy *x, u32 val, u32 reg); | ||
| 63 | }; | ||
| 64 | |||
| 65 | struct usb_phy { | ||
| 66 | struct device *dev; | ||
| 67 | const char *label; | ||
| 68 | unsigned int flags; | ||
| 69 | |||
| 70 | enum usb_phy_type type; | ||
| 71 | enum usb_otg_state state; | ||
| 72 | enum usb_phy_events last_event; | ||
| 73 | |||
| 74 | struct usb_otg *otg; | ||
| 75 | |||
| 76 | struct device *io_dev; | ||
| 77 | struct usb_phy_io_ops *io_ops; | ||
| 78 | void __iomem *io_priv; | ||
| 79 | |||
| 80 | /* for notification of usb_phy_events */ | ||
| 81 | struct atomic_notifier_head notifier; | ||
| 82 | |||
| 83 | /* to pass extra port status to the root hub */ | ||
| 84 | u16 port_status; | ||
| 85 | u16 port_change; | ||
| 86 | |||
| 87 | /* to support controllers that have multiple transceivers */ | ||
| 88 | struct list_head head; | ||
| 89 | |||
| 90 | /* initialize/shutdown the OTG controller */ | ||
| 91 | int (*init)(struct usb_phy *x); | ||
| 92 | void (*shutdown)(struct usb_phy *x); | ||
| 93 | |||
| 94 | /* effective for B devices, ignored for A-peripheral */ | ||
| 95 | int (*set_power)(struct usb_phy *x, | ||
| 96 | unsigned mA); | ||
| 97 | |||
| 98 | /* for non-OTG B devices: set transceiver into suspend mode */ | ||
| 99 | int (*set_suspend)(struct usb_phy *x, | ||
| 100 | int suspend); | ||
| 101 | |||
| 102 | /* notify phy connect status change */ | ||
| 103 | int (*notify_connect)(struct usb_phy *x, | ||
| 104 | enum usb_device_speed speed); | ||
| 105 | int (*notify_disconnect)(struct usb_phy *x, | ||
| 106 | enum usb_device_speed speed); | ||
| 107 | }; | ||
| 108 | |||
| 109 | |||
| 110 | /* for board-specific init logic */ | ||
| 111 | extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); | ||
| 112 | extern void usb_remove_phy(struct usb_phy *); | ||
| 113 | |||
| 114 | /* helpers for direct access thru low-level io interface */ | ||
| 115 | static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) | ||
| 116 | { | ||
| 117 | if (x->io_ops && x->io_ops->read) | ||
| 118 | return x->io_ops->read(x, reg); | ||
| 119 | |||
| 120 | return -EINVAL; | ||
| 121 | } | ||
| 122 | |||
| 123 | static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) | ||
| 124 | { | ||
| 125 | if (x->io_ops && x->io_ops->write) | ||
| 126 | return x->io_ops->write(x, val, reg); | ||
| 127 | |||
| 128 | return -EINVAL; | ||
| 129 | } | ||
| 130 | |||
| 131 | static inline int | ||
| 132 | usb_phy_init(struct usb_phy *x) | ||
| 133 | { | ||
| 134 | if (x->init) | ||
| 135 | return x->init(x); | ||
| 136 | |||
| 137 | return 0; | ||
| 138 | } | ||
| 139 | |||
| 140 | static inline void | ||
| 141 | usb_phy_shutdown(struct usb_phy *x) | ||
| 142 | { | ||
| 143 | if (x->shutdown) | ||
| 144 | x->shutdown(x); | ||
| 145 | } | ||
| 146 | |||
| 147 | /* for usb host and peripheral controller drivers */ | ||
| 148 | #ifdef CONFIG_USB_OTG_UTILS | ||
| 149 | extern struct usb_phy *usb_get_phy(enum usb_phy_type type); | ||
| 150 | extern struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
| 151 | enum usb_phy_type type); | ||
| 152 | extern void usb_put_phy(struct usb_phy *); | ||
| 153 | extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x); | ||
| 154 | #else | ||
| 155 | static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) | ||
| 156 | { | ||
| 157 | return NULL; | ||
| 158 | } | ||
| 159 | |||
| 160 | static inline struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
| 161 | enum usb_phy_type type) | ||
| 162 | { | ||
| 163 | return NULL; | ||
| 164 | } | ||
| 165 | |||
| 166 | static inline void usb_put_phy(struct usb_phy *x) | ||
| 167 | { | ||
| 168 | } | ||
| 169 | |||
| 170 | static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) | ||
| 171 | { | ||
| 172 | } | ||
| 173 | |||
| 174 | #endif | ||
| 175 | |||
| 176 | static inline int | ||
| 177 | usb_phy_set_power(struct usb_phy *x, unsigned mA) | ||
| 178 | { | ||
| 179 | if (x && x->set_power) | ||
| 180 | return x->set_power(x, mA); | ||
| 181 | return 0; | ||
| 182 | } | ||
| 183 | |||
| 184 | /* Context: can sleep */ | ||
| 185 | static inline int | ||
| 186 | usb_phy_set_suspend(struct usb_phy *x, int suspend) | ||
| 187 | { | ||
| 188 | if (x->set_suspend != NULL) | ||
| 189 | return x->set_suspend(x, suspend); | ||
| 190 | else | ||
| 191 | return 0; | ||
| 192 | } | ||
| 193 | |||
| 194 | static inline int | ||
| 195 | usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed) | ||
| 196 | { | ||
| 197 | if (x->notify_connect) | ||
| 198 | return x->notify_connect(x, speed); | ||
| 199 | else | ||
| 200 | return 0; | ||
| 201 | } | ||
| 202 | |||
| 203 | static inline int | ||
| 204 | usb_phy_notify_disconnect(struct usb_phy *x, enum usb_device_speed speed) | ||
| 205 | { | ||
| 206 | if (x->notify_disconnect) | ||
| 207 | return x->notify_disconnect(x, speed); | ||
| 208 | else | ||
| 209 | return 0; | ||
| 210 | } | ||
| 211 | |||
| 212 | /* notifiers */ | ||
| 213 | static inline int | ||
| 214 | usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
| 215 | { | ||
| 216 | return atomic_notifier_chain_register(&x->notifier, nb); | ||
| 217 | } | ||
| 218 | |||
| 219 | static inline void | ||
| 220 | usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
| 221 | { | ||
| 222 | atomic_notifier_chain_unregister(&x->notifier, nb); | ||
| 223 | } | ||
| 224 | |||
| 225 | static inline const char *usb_phy_type_string(enum usb_phy_type type) | ||
| 226 | { | ||
| 227 | switch (type) { | ||
| 228 | case USB_PHY_TYPE_USB2: | ||
| 229 | return "USB2 PHY"; | ||
| 230 | case USB_PHY_TYPE_USB3: | ||
| 231 | return "USB3 PHY"; | ||
| 232 | default: | ||
| 233 | return "UNKNOWN PHY TYPE"; | ||
| 234 | } | ||
| 235 | } | ||
| 236 | #endif /* __LINUX_USB_PHY_H */ | ||
diff --git a/include/linux/usb/phy_companion.h b/include/linux/usb/phy_companion.h deleted file mode 100644 index edd2ec23d28..00000000000 --- a/include/linux/usb/phy_companion.h +++ /dev/null | |||
| @@ -1,34 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * phy-companion.h -- phy companion to indicate the comparator part of PHY | ||
| 3 | * | ||
| 4 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef __DRIVERS_PHY_COMPANION_H | ||
| 20 | #define __DRIVERS_PHY_COMPANION_H | ||
| 21 | |||
| 22 | #include <linux/usb/otg.h> | ||
| 23 | |||
| 24 | /* phy_companion to take care of VBUS, ID and srp capabilities */ | ||
| 25 | struct phy_companion { | ||
| 26 | |||
| 27 | /* effective for A-peripheral, ignored for B devices */ | ||
| 28 | int (*set_vbus)(struct phy_companion *x, bool enabled); | ||
| 29 | |||
| 30 | /* for B devices only: start session with A-Host */ | ||
| 31 | int (*start_srp)(struct phy_companion *x); | ||
| 32 | }; | ||
| 33 | |||
| 34 | #endif /* __DRIVERS_PHY_COMPANION_H */ | ||
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h index 52f944dfe2f..3e93de7ecbc 100644 --- a/include/linux/usb/quirks.h +++ b/include/linux/usb/quirks.h | |||
| @@ -19,8 +19,8 @@ | |||
| 19 | /* device can't handle its Configuration or Interface strings */ | 19 | /* device can't handle its Configuration or Interface strings */ |
| 20 | #define USB_QUIRK_CONFIG_INTF_STRINGS 0x00000008 | 20 | #define USB_QUIRK_CONFIG_INTF_STRINGS 0x00000008 |
| 21 | 21 | ||
| 22 | /* device can't be reset(e.g morph devices), don't use reset */ | 22 | /*device will morph if reset, don't use reset for handling errors */ |
| 23 | #define USB_QUIRK_RESET 0x00000010 | 23 | #define USB_QUIRK_RESET_MORPHS 0x00000010 |
| 24 | 24 | ||
| 25 | /* device has more interface descriptions than the bNumInterfaces count, | 25 | /* device has more interface descriptions than the bNumInterfaces count, |
| 26 | and can't handle talking to these interfaces */ | 26 | and can't handle talking to these interfaces */ |
diff --git a/include/linux/usb/r8a66597.h b/include/linux/usb/r8a66597.h index 55805f9dcf2..b6b8660d0c6 100644 --- a/include/linux/usb/r8a66597.h +++ b/include/linux/usb/r8a66597.h | |||
| @@ -48,9 +48,6 @@ struct r8a66597_platdata { | |||
| 48 | 48 | ||
| 49 | /* (external controller only) set one = WR0_N shorted to WR1_N */ | 49 | /* (external controller only) set one = WR0_N shorted to WR1_N */ |
| 50 | unsigned wr0_shorted_to_wr1:1; | 50 | unsigned wr0_shorted_to_wr1:1; |
| 51 | |||
| 52 | /* set one = using SUDMAC */ | ||
| 53 | unsigned sudmac:1; | ||
| 54 | }; | 51 | }; |
| 55 | 52 | ||
| 56 | /* Register definitions */ | 53 | /* Register definitions */ |
| @@ -420,62 +417,5 @@ struct r8a66597_platdata { | |||
| 420 | #define USBSPD 0x00C0 | 417 | #define USBSPD 0x00C0 |
| 421 | #define RTPORT 0x0001 | 418 | #define RTPORT 0x0001 |
| 422 | 419 | ||
| 423 | /* SUDMAC registers */ | ||
| 424 | #define CH0CFG 0x00 | ||
| 425 | #define CH1CFG 0x04 | ||
| 426 | #define CH0BA 0x10 | ||
| 427 | #define CH1BA 0x14 | ||
| 428 | #define CH0BBC 0x18 | ||
| 429 | #define CH1BBC 0x1C | ||
| 430 | #define CH0CA 0x20 | ||
| 431 | #define CH1CA 0x24 | ||
| 432 | #define CH0CBC 0x28 | ||
| 433 | #define CH1CBC 0x2C | ||
| 434 | #define CH0DEN 0x30 | ||
| 435 | #define CH1DEN 0x34 | ||
| 436 | #define DSTSCLR 0x38 | ||
| 437 | #define DBUFCTRL 0x3C | ||
| 438 | #define DINTCTRL 0x40 | ||
| 439 | #define DINTSTS 0x44 | ||
| 440 | #define DINTSTSCLR 0x48 | ||
| 441 | #define CH0SHCTRL 0x50 | ||
| 442 | #define CH1SHCTRL 0x54 | ||
| 443 | |||
| 444 | /* SUDMAC Configuration Registers */ | ||
| 445 | #define SENDBUFM 0x1000 /* b12: Transmit Buffer Mode */ | ||
| 446 | #define RCVENDM 0x0100 /* b8: Receive Data Transfer End Mode */ | ||
| 447 | #define LBA_WAIT 0x0030 /* b5-4: Local Bus Access Wait */ | ||
| 448 | |||
| 449 | /* DMA Enable Registers */ | ||
| 450 | #define DEN 0x0001 /* b1: DMA Transfer Enable */ | ||
| 451 | |||
| 452 | /* DMA Status Clear Register */ | ||
| 453 | #define CH1STCLR 0x0002 /* b2: Ch1 DMA Status Clear */ | ||
| 454 | #define CH0STCLR 0x0001 /* b1: Ch0 DMA Status Clear */ | ||
| 455 | |||
| 456 | /* DMA Buffer Control Register */ | ||
| 457 | #define CH1BUFW 0x0200 /* b9: Ch1 DMA Buffer Data Transfer Enable */ | ||
| 458 | #define CH0BUFW 0x0100 /* b8: Ch0 DMA Buffer Data Transfer Enable */ | ||
| 459 | #define CH1BUFS 0x0002 /* b2: Ch1 DMA Buffer Data Status */ | ||
| 460 | #define CH0BUFS 0x0001 /* b1: Ch0 DMA Buffer Data Status */ | ||
| 461 | |||
| 462 | /* DMA Interrupt Control Register */ | ||
| 463 | #define CH1ERRE 0x0200 /* b9: Ch1 SHwy Res Err Detect Int Enable */ | ||
| 464 | #define CH0ERRE 0x0100 /* b8: Ch0 SHwy Res Err Detect Int Enable */ | ||
| 465 | #define CH1ENDE 0x0002 /* b2: Ch1 DMA Transfer End Int Enable */ | ||
| 466 | #define CH0ENDE 0x0001 /* b1: Ch0 DMA Transfer End Int Enable */ | ||
| 467 | |||
| 468 | /* DMA Interrupt Status Register */ | ||
| 469 | #define CH1ERRS 0x0200 /* b9: Ch1 SHwy Res Err Detect Int Status */ | ||
| 470 | #define CH0ERRS 0x0100 /* b8: Ch0 SHwy Res Err Detect Int Status */ | ||
| 471 | #define CH1ENDS 0x0002 /* b2: Ch1 DMA Transfer End Int Status */ | ||
| 472 | #define CH0ENDS 0x0001 /* b1: Ch0 DMA Transfer End Int Status */ | ||
| 473 | |||
| 474 | /* DMA Interrupt Status Clear Register */ | ||
| 475 | #define CH1ERRC 0x0200 /* b9: Ch1 SHwy Res Err Detect Int Stat Clear */ | ||
| 476 | #define CH0ERRC 0x0100 /* b8: Ch0 SHwy Res Err Detect Int Stat Clear */ | ||
| 477 | #define CH1ENDC 0x0002 /* b2: Ch1 DMA Transfer End Int Stat Clear */ | ||
| 478 | #define CH0ENDC 0x0001 /* b1: Ch0 DMA Transfer End Int Stat Clear */ | ||
| 479 | |||
| 480 | #endif /* __LINUX_USB_R8A66597_H */ | 420 | #endif /* __LINUX_USB_R8A66597_H */ |
| 481 | 421 | ||
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index c5d36c65c33..8977431259c 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h | |||
| @@ -67,14 +67,6 @@ struct renesas_usbhs_platform_callback { | |||
| 67 | /* | 67 | /* |
| 68 | * option: | 68 | * option: |
| 69 | * | 69 | * |
| 70 | * for board specific clock control | ||
| 71 | */ | ||
| 72 | void (*power_ctrl)(struct platform_device *pdev, | ||
| 73 | void __iomem *base, int enable); | ||
| 74 | |||
| 75 | /* | ||
| 76 | * option: | ||
| 77 | * | ||
| 78 | * Phy reset for platform | 70 | * Phy reset for platform |
| 79 | */ | 71 | */ |
| 80 | void (*phy_reset)(struct platform_device *pdev); | 72 | void (*phy_reset)(struct platform_device *pdev); |
| @@ -90,13 +82,6 @@ struct renesas_usbhs_platform_callback { | |||
| 90 | * get VBUS status function. | 82 | * get VBUS status function. |
| 91 | */ | 83 | */ |
| 92 | int (*get_vbus)(struct platform_device *pdev); | 84 | int (*get_vbus)(struct platform_device *pdev); |
| 93 | |||
| 94 | /* | ||
| 95 | * option: | ||
| 96 | * | ||
| 97 | * VBUS control is needed for Host | ||
| 98 | */ | ||
| 99 | int (*set_vbus)(struct platform_device *pdev, int enable); | ||
| 100 | }; | 85 | }; |
| 101 | 86 | ||
| 102 | /* | 87 | /* |
| @@ -116,8 +101,6 @@ struct renesas_usbhs_driver_param { | |||
| 116 | * option: | 101 | * option: |
| 117 | * | 102 | * |
| 118 | * for BUSWAIT :: BWAIT | 103 | * for BUSWAIT :: BWAIT |
| 119 | * see | ||
| 120 | * renesas_usbhs/common.c :: usbhsc_set_buswait() | ||
| 121 | * */ | 104 | * */ |
| 122 | int buswait_bwait; | 105 | int buswait_bwait; |
| 123 | 106 | ||
| @@ -126,20 +109,12 @@ struct renesas_usbhs_driver_param { | |||
| 126 | * | 109 | * |
| 127 | * delay time from notify_hotplug callback | 110 | * delay time from notify_hotplug callback |
| 128 | */ | 111 | */ |
| 129 | int detection_delay; /* msec */ | 112 | int detection_delay; |
| 130 | 113 | ||
| 131 | /* | 114 | /* |
| 132 | * option: | 115 | * option: |
| 133 | * | 116 | * |
| 134 | * dma id for dmaengine | 117 | * dma id for dmaengine |
| 135 | * The data transfer direction on D0FIFO/D1FIFO should be | ||
| 136 | * fixed for keeping consistency. | ||
| 137 | * So, the platform id settings will be.. | ||
| 138 | * .d0_tx_id = xx_TX, | ||
| 139 | * .d1_rx_id = xx_RX, | ||
| 140 | * or | ||
| 141 | * .d1_tx_id = xx_TX, | ||
| 142 | * .d0_rx_id = xx_RX, | ||
| 143 | */ | 118 | */ |
| 144 | int d0_tx_id; | 119 | int d0_tx_id; |
| 145 | int d0_rx_id; | 120 | int d0_rx_id; |
| @@ -152,12 +127,6 @@ struct renesas_usbhs_driver_param { | |||
| 152 | * pio <--> dma border. | 127 | * pio <--> dma border. |
| 153 | */ | 128 | */ |
| 154 | int pio_dma_border; /* default is 64byte */ | 129 | int pio_dma_border; /* default is 64byte */ |
| 155 | |||
| 156 | /* | ||
| 157 | * option: | ||
| 158 | */ | ||
| 159 | u32 has_otg:1; /* for controlling PWEN/EXTLP */ | ||
| 160 | u32 has_sudmac:1; /* for SUDMAC */ | ||
| 161 | }; | 130 | }; |
| 162 | 131 | ||
| 163 | /* | 132 | /* |
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h index d44ef85db17..88fceb718c7 100644 --- a/include/linux/usb/rndis_host.h +++ b/include/linux/usb/rndis_host.h | |||
| @@ -20,8 +20,6 @@ | |||
| 20 | #ifndef __LINUX_USB_RNDIS_HOST_H | 20 | #ifndef __LINUX_USB_RNDIS_HOST_H |
| 21 | #define __LINUX_USB_RNDIS_HOST_H | 21 | #define __LINUX_USB_RNDIS_HOST_H |
| 22 | 22 | ||
| 23 | #include <linux/rndis.h> | ||
| 24 | |||
| 25 | /* | 23 | /* |
| 26 | * CONTROL uses CDC "encapsulated commands" with funky notifications. | 24 | * CONTROL uses CDC "encapsulated commands" with funky notifications. |
| 27 | * - control-out: SEND_ENCAPSULATED | 25 | * - control-out: SEND_ENCAPSULATED |
| @@ -51,6 +49,47 @@ struct rndis_msg_hdr { | |||
| 51 | */ | 49 | */ |
| 52 | #define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000) | 50 | #define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000) |
| 53 | 51 | ||
| 52 | #define RNDIS_MSG_COMPLETION cpu_to_le32(0x80000000) | ||
| 53 | |||
| 54 | /* codes for "msg_type" field of rndis messages; | ||
| 55 | * only the data channel uses packet messages (maybe batched); | ||
| 56 | * everything else goes on the control channel. | ||
| 57 | */ | ||
| 58 | #define RNDIS_MSG_PACKET cpu_to_le32(0x00000001) /* 1-N packets */ | ||
| 59 | #define RNDIS_MSG_INIT cpu_to_le32(0x00000002) | ||
| 60 | #define RNDIS_MSG_INIT_C (RNDIS_MSG_INIT|RNDIS_MSG_COMPLETION) | ||
| 61 | #define RNDIS_MSG_HALT cpu_to_le32(0x00000003) | ||
| 62 | #define RNDIS_MSG_QUERY cpu_to_le32(0x00000004) | ||
| 63 | #define RNDIS_MSG_QUERY_C (RNDIS_MSG_QUERY|RNDIS_MSG_COMPLETION) | ||
| 64 | #define RNDIS_MSG_SET cpu_to_le32(0x00000005) | ||
| 65 | #define RNDIS_MSG_SET_C (RNDIS_MSG_SET|RNDIS_MSG_COMPLETION) | ||
| 66 | #define RNDIS_MSG_RESET cpu_to_le32(0x00000006) | ||
| 67 | #define RNDIS_MSG_RESET_C (RNDIS_MSG_RESET|RNDIS_MSG_COMPLETION) | ||
| 68 | #define RNDIS_MSG_INDICATE cpu_to_le32(0x00000007) | ||
| 69 | #define RNDIS_MSG_KEEPALIVE cpu_to_le32(0x00000008) | ||
| 70 | #define RNDIS_MSG_KEEPALIVE_C (RNDIS_MSG_KEEPALIVE|RNDIS_MSG_COMPLETION) | ||
| 71 | |||
| 72 | /* codes for "status" field of completion messages */ | ||
| 73 | #define RNDIS_STATUS_SUCCESS cpu_to_le32(0x00000000) | ||
| 74 | #define RNDIS_STATUS_FAILURE cpu_to_le32(0xc0000001) | ||
| 75 | #define RNDIS_STATUS_INVALID_DATA cpu_to_le32(0xc0010015) | ||
| 76 | #define RNDIS_STATUS_NOT_SUPPORTED cpu_to_le32(0xc00000bb) | ||
| 77 | #define RNDIS_STATUS_MEDIA_CONNECT cpu_to_le32(0x4001000b) | ||
| 78 | #define RNDIS_STATUS_MEDIA_DISCONNECT cpu_to_le32(0x4001000c) | ||
| 79 | #define RNDIS_STATUS_MEDIA_SPECIFIC_INDICATION cpu_to_le32(0x40010012) | ||
| 80 | |||
| 81 | /* codes for OID_GEN_PHYSICAL_MEDIUM */ | ||
| 82 | #define RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED cpu_to_le32(0x00000000) | ||
| 83 | #define RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN cpu_to_le32(0x00000001) | ||
| 84 | #define RNDIS_PHYSICAL_MEDIUM_CABLE_MODEM cpu_to_le32(0x00000002) | ||
| 85 | #define RNDIS_PHYSICAL_MEDIUM_PHONE_LINE cpu_to_le32(0x00000003) | ||
| 86 | #define RNDIS_PHYSICAL_MEDIUM_POWER_LINE cpu_to_le32(0x00000004) | ||
| 87 | #define RNDIS_PHYSICAL_MEDIUM_DSL cpu_to_le32(0x00000005) | ||
| 88 | #define RNDIS_PHYSICAL_MEDIUM_FIBRE_CHANNEL cpu_to_le32(0x00000006) | ||
| 89 | #define RNDIS_PHYSICAL_MEDIUM_1394 cpu_to_le32(0x00000007) | ||
| 90 | #define RNDIS_PHYSICAL_MEDIUM_WIRELESS_WAN cpu_to_le32(0x00000008) | ||
| 91 | #define RNDIS_PHYSICAL_MEDIUM_MAX cpu_to_le32(0x00000009) | ||
| 92 | |||
| 54 | struct rndis_data_hdr { | 93 | struct rndis_data_hdr { |
| 55 | __le32 msg_type; /* RNDIS_MSG_PACKET */ | 94 | __le32 msg_type; /* RNDIS_MSG_PACKET */ |
| 56 | __le32 msg_len; /* rndis_data_hdr + data_len + pad */ | 95 | __le32 msg_len; /* rndis_data_hdr + data_len + pad */ |
| @@ -183,6 +222,29 @@ struct rndis_keepalive_c { /* IN (optionally OUT) */ | |||
| 183 | __le32 status; | 222 | __le32 status; |
| 184 | } __attribute__ ((packed)); | 223 | } __attribute__ ((packed)); |
| 185 | 224 | ||
| 225 | /* NOTE: about 30 OIDs are "mandatory" for peripherals to support ... and | ||
| 226 | * there are gobs more that may optionally be supported. We'll avoid as much | ||
| 227 | * of that mess as possible. | ||
| 228 | */ | ||
| 229 | #define OID_802_3_PERMANENT_ADDRESS cpu_to_le32(0x01010101) | ||
| 230 | #define OID_GEN_MAXIMUM_FRAME_SIZE cpu_to_le32(0x00010106) | ||
| 231 | #define OID_GEN_CURRENT_PACKET_FILTER cpu_to_le32(0x0001010e) | ||
| 232 | #define OID_GEN_PHYSICAL_MEDIUM cpu_to_le32(0x00010202) | ||
| 233 | |||
| 234 | /* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */ | ||
| 235 | #define RNDIS_PACKET_TYPE_DIRECTED cpu_to_le32(0x00000001) | ||
| 236 | #define RNDIS_PACKET_TYPE_MULTICAST cpu_to_le32(0x00000002) | ||
| 237 | #define RNDIS_PACKET_TYPE_ALL_MULTICAST cpu_to_le32(0x00000004) | ||
| 238 | #define RNDIS_PACKET_TYPE_BROADCAST cpu_to_le32(0x00000008) | ||
| 239 | #define RNDIS_PACKET_TYPE_SOURCE_ROUTING cpu_to_le32(0x00000010) | ||
| 240 | #define RNDIS_PACKET_TYPE_PROMISCUOUS cpu_to_le32(0x00000020) | ||
| 241 | #define RNDIS_PACKET_TYPE_SMT cpu_to_le32(0x00000040) | ||
| 242 | #define RNDIS_PACKET_TYPE_ALL_LOCAL cpu_to_le32(0x00000080) | ||
| 243 | #define RNDIS_PACKET_TYPE_GROUP cpu_to_le32(0x00001000) | ||
| 244 | #define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL cpu_to_le32(0x00002000) | ||
| 245 | #define RNDIS_PACKET_TYPE_FUNCTIONAL cpu_to_le32(0x00004000) | ||
| 246 | #define RNDIS_PACKET_TYPE_MAC_FRAME cpu_to_le32(0x00008000) | ||
| 247 | |||
| 186 | /* default filter used with RNDIS devices */ | 248 | /* default filter used with RNDIS devices */ |
| 187 | #define RNDIS_DEFAULT_FILTER ( \ | 249 | #define RNDIS_DEFAULT_FILTER ( \ |
| 188 | RNDIS_PACKET_TYPE_DIRECTED | \ | 250 | RNDIS_PACKET_TYPE_DIRECTED | \ |
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index ef9be7e1e19..b29f70b2eca 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * USB Serial Converter stuff | 2 | * USB Serial Converter stuff |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 1999 - 2012 | 4 | * Copyright (C) 1999 - 2005 |
| 5 | * Greg Kroah-Hartman (greg@kroah.com) | 5 | * Greg Kroah-Hartman (greg@kroah.com) |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
| @@ -28,6 +28,13 @@ | |||
| 28 | /* parity check flag */ | 28 | /* parity check flag */ |
| 29 | #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) | 29 | #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) |
| 30 | 30 | ||
| 31 | enum port_dev_state { | ||
| 32 | PORT_UNREGISTERED, | ||
| 33 | PORT_REGISTERING, | ||
| 34 | PORT_REGISTERED, | ||
| 35 | PORT_UNREGISTERING, | ||
| 36 | }; | ||
| 37 | |||
| 31 | /* USB serial flags */ | 38 | /* USB serial flags */ |
| 32 | #define USB_SERIAL_WRITE_BUSY 0 | 39 | #define USB_SERIAL_WRITE_BUSY 0 |
| 33 | 40 | ||
| @@ -51,13 +58,11 @@ | |||
| 51 | * @read_urb: pointer to the bulk in struct urb for this port. | 58 | * @read_urb: pointer to the bulk in struct urb for this port. |
| 52 | * @bulk_in_endpointAddress: endpoint address for the bulk in pipe for this | 59 | * @bulk_in_endpointAddress: endpoint address for the bulk in pipe for this |
| 53 | * port. | 60 | * port. |
| 54 | * @bulk_in_buffers: pointers to the bulk in buffers for this port | ||
| 55 | * @read_urbs: pointers to the bulk in urbs for this port | ||
| 56 | * @read_urbs_free: status bitmap the for bulk in urbs | ||
| 57 | * @bulk_out_buffer: pointer to the bulk out buffer for this port. | 61 | * @bulk_out_buffer: pointer to the bulk out buffer for this port. |
| 58 | * @bulk_out_size: the size of the bulk_out_buffer, in bytes. | 62 | * @bulk_out_size: the size of the bulk_out_buffer, in bytes. |
| 59 | * @write_urb: pointer to the bulk out struct urb for this port. | 63 | * @write_urb: pointer to the bulk out struct urb for this port. |
| 60 | * @write_fifo: kfifo used to buffer outgoing data | 64 | * @write_fifo: kfifo used to buffer outgoing data |
| 65 | * @write_urb_busy: port`s writing status | ||
| 61 | * @bulk_out_buffers: pointers to the bulk out buffers for this port | 66 | * @bulk_out_buffers: pointers to the bulk out buffers for this port |
| 62 | * @write_urbs: pointers to the bulk out urbs for this port | 67 | * @write_urbs: pointers to the bulk out urbs for this port |
| 63 | * @write_urbs_free: status bitmap the for bulk out urbs | 68 | * @write_urbs_free: status bitmap the for bulk out urbs |
| @@ -94,14 +99,11 @@ struct usb_serial_port { | |||
| 94 | struct urb *read_urb; | 99 | struct urb *read_urb; |
| 95 | __u8 bulk_in_endpointAddress; | 100 | __u8 bulk_in_endpointAddress; |
| 96 | 101 | ||
| 97 | unsigned char *bulk_in_buffers[2]; | ||
| 98 | struct urb *read_urbs[2]; | ||
| 99 | unsigned long read_urbs_free; | ||
| 100 | |||
| 101 | unsigned char *bulk_out_buffer; | 102 | unsigned char *bulk_out_buffer; |
| 102 | int bulk_out_size; | 103 | int bulk_out_size; |
| 103 | struct urb *write_urb; | 104 | struct urb *write_urb; |
| 104 | struct kfifo write_fifo; | 105 | struct kfifo write_fifo; |
| 106 | int write_urb_busy; | ||
| 105 | 107 | ||
| 106 | unsigned char *bulk_out_buffers[2]; | 108 | unsigned char *bulk_out_buffers[2]; |
| 107 | struct urb *write_urbs[2]; | 109 | struct urb *write_urbs[2]; |
| @@ -117,6 +119,7 @@ struct usb_serial_port { | |||
| 117 | char throttle_req; | 119 | char throttle_req; |
| 118 | unsigned long sysrq; /* sysrq timeout */ | 120 | unsigned long sysrq; /* sysrq timeout */ |
| 119 | struct device dev; | 121 | struct device dev; |
| 122 | enum port_dev_state dev_state; | ||
| 120 | }; | 123 | }; |
| 121 | #define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev) | 124 | #define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev) |
| 122 | 125 | ||
| @@ -249,7 +252,6 @@ struct usb_serial_driver { | |||
| 249 | 252 | ||
| 250 | int (*suspend)(struct usb_serial *serial, pm_message_t message); | 253 | int (*suspend)(struct usb_serial *serial, pm_message_t message); |
| 251 | int (*resume)(struct usb_serial *serial); | 254 | int (*resume)(struct usb_serial *serial); |
| 252 | int (*reset_resume)(struct usb_serial *serial); | ||
| 253 | 255 | ||
| 254 | /* serial function calls */ | 256 | /* serial function calls */ |
| 255 | /* Called by console and by the tty layer */ | 257 | /* Called by console and by the tty layer */ |
| @@ -293,21 +295,28 @@ struct usb_serial_driver { | |||
| 293 | #define to_usb_serial_driver(d) \ | 295 | #define to_usb_serial_driver(d) \ |
| 294 | container_of(d, struct usb_serial_driver, driver) | 296 | container_of(d, struct usb_serial_driver, driver) |
| 295 | 297 | ||
| 296 | extern int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[], | 298 | extern int usb_serial_register(struct usb_serial_driver *driver); |
| 297 | const char *name, const struct usb_device_id *id_table); | 299 | extern void usb_serial_deregister(struct usb_serial_driver *driver); |
| 298 | extern void usb_serial_deregister_drivers(struct usb_serial_driver *const serial_drivers[]); | ||
| 299 | extern void usb_serial_port_softint(struct usb_serial_port *port); | 300 | extern void usb_serial_port_softint(struct usb_serial_port *port); |
| 300 | 301 | ||
| 302 | extern int usb_serial_probe(struct usb_interface *iface, | ||
| 303 | const struct usb_device_id *id); | ||
| 304 | extern void usb_serial_disconnect(struct usb_interface *iface); | ||
| 305 | |||
| 301 | extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); | 306 | extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); |
| 302 | extern int usb_serial_resume(struct usb_interface *intf); | 307 | extern int usb_serial_resume(struct usb_interface *intf); |
| 303 | 308 | ||
| 309 | extern int ezusb_writememory(struct usb_serial *serial, int address, | ||
| 310 | unsigned char *data, int length, __u8 bRequest); | ||
| 311 | extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit); | ||
| 312 | |||
| 304 | /* USB Serial console functions */ | 313 | /* USB Serial console functions */ |
| 305 | #ifdef CONFIG_USB_SERIAL_CONSOLE | 314 | #ifdef CONFIG_USB_SERIAL_CONSOLE |
| 306 | extern void usb_serial_console_init(int minor); | 315 | extern void usb_serial_console_init(int debug, int minor); |
| 307 | extern void usb_serial_console_exit(void); | 316 | extern void usb_serial_console_exit(void); |
| 308 | extern void usb_serial_console_disconnect(struct usb_serial *serial); | 317 | extern void usb_serial_console_disconnect(struct usb_serial *serial); |
| 309 | #else | 318 | #else |
| 310 | static inline void usb_serial_console_init(int minor) { } | 319 | static inline void usb_serial_console_init(int debug, int minor) { } |
| 311 | static inline void usb_serial_console_exit(void) { } | 320 | static inline void usb_serial_console_exit(void) { } |
| 312 | static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} | 321 | static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} |
| 313 | #endif | 322 | #endif |
| @@ -329,9 +338,9 @@ extern void usb_serial_generic_throttle(struct tty_struct *tty); | |||
| 329 | extern void usb_serial_generic_unthrottle(struct tty_struct *tty); | 338 | extern void usb_serial_generic_unthrottle(struct tty_struct *tty); |
| 330 | extern void usb_serial_generic_disconnect(struct usb_serial *serial); | 339 | extern void usb_serial_generic_disconnect(struct usb_serial *serial); |
| 331 | extern void usb_serial_generic_release(struct usb_serial *serial); | 340 | extern void usb_serial_generic_release(struct usb_serial *serial); |
| 332 | extern int usb_serial_generic_register(void); | 341 | extern int usb_serial_generic_register(int debug); |
| 333 | extern void usb_serial_generic_deregister(void); | 342 | extern void usb_serial_generic_deregister(void); |
| 334 | extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, | 343 | extern int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, |
| 335 | gfp_t mem_flags); | 344 | gfp_t mem_flags); |
| 336 | extern void usb_serial_generic_process_read_urb(struct urb *urb); | 345 | extern void usb_serial_generic_process_read_urb(struct urb *urb); |
| 337 | extern int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port, | 346 | extern int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port, |
| @@ -351,55 +360,29 @@ extern struct usb_serial_driver usb_serial_generic_device; | |||
| 351 | extern struct bus_type usb_serial_bus_type; | 360 | extern struct bus_type usb_serial_bus_type; |
| 352 | extern struct tty_driver *usb_serial_tty_driver; | 361 | extern struct tty_driver *usb_serial_tty_driver; |
| 353 | 362 | ||
| 354 | static inline void usb_serial_debug_data(struct device *dev, | 363 | static inline void usb_serial_debug_data(int debug, |
| 364 | struct device *dev, | ||
| 355 | const char *function, int size, | 365 | const char *function, int size, |
| 356 | const unsigned char *data) | 366 | const unsigned char *data) |
| 357 | { | 367 | { |
| 358 | dev_dbg(dev, "%s - length = %d, data = %*ph\n", | 368 | int i; |
| 359 | function, size, size, data); | 369 | |
| 370 | if (debug) { | ||
| 371 | dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", | ||
| 372 | function, size); | ||
| 373 | for (i = 0; i < size; ++i) | ||
| 374 | printk("%.2x ", data[i]); | ||
| 375 | printk("\n"); | ||
| 376 | } | ||
| 360 | } | 377 | } |
| 361 | 378 | ||
| 362 | /* | 379 | /* Use our own dbg macro */ |
| 363 | * Macro for reporting errors in write path to avoid inifinite loop | 380 | #undef dbg |
| 364 | * when port is used as a console. | 381 | #define dbg(format, arg...) \ |
| 365 | */ | ||
| 366 | #define dev_err_console(usport, fmt, ...) \ | ||
| 367 | do { \ | 382 | do { \ |
| 368 | static bool __print_once; \ | 383 | if (debug) \ |
| 369 | struct usb_serial_port *__port = (usport); \ | 384 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ |
| 370 | \ | ||
| 371 | if (!__port->port.console || !__print_once) { \ | ||
| 372 | __print_once = true; \ | ||
| 373 | dev_err(&__port->dev, fmt, ##__VA_ARGS__); \ | ||
| 374 | } \ | ||
| 375 | } while (0) | 385 | } while (0) |
| 376 | 386 | ||
| 377 | /* | ||
| 378 | * module_usb_serial_driver() - Helper macro for registering a USB Serial driver | ||
| 379 | * @__serial_drivers: list of usb_serial drivers to register | ||
| 380 | * @__ids: all device ids that @__serial_drivers bind to | ||
| 381 | * | ||
| 382 | * Helper macro for USB serial drivers which do not do anything special | ||
| 383 | * in module init/exit. This eliminates a lot of boilerplate. Each | ||
| 384 | * module may only use this macro once, and calling it replaces | ||
| 385 | * module_init() and module_exit() | ||
| 386 | * | ||
| 387 | */ | ||
| 388 | #define usb_serial_module_driver(__name, __serial_drivers, __ids) \ | ||
| 389 | static int __init usb_serial_module_init(void) \ | ||
| 390 | { \ | ||
| 391 | return usb_serial_register_drivers(__serial_drivers, \ | ||
| 392 | __name, __ids); \ | ||
| 393 | } \ | ||
| 394 | module_init(usb_serial_module_init); \ | ||
| 395 | static void __exit usb_serial_module_exit(void) \ | ||
| 396 | { \ | ||
| 397 | usb_serial_deregister_drivers(__serial_drivers); \ | ||
| 398 | } \ | ||
| 399 | module_exit(usb_serial_module_exit); | ||
| 400 | |||
| 401 | #define module_usb_serial_driver(__serial_drivers, __ids) \ | ||
| 402 | usb_serial_module_driver(KBUILD_MODNAME, __serial_drivers, __ids) | ||
| 403 | |||
| 404 | #endif /* __LINUX_USB_SERIAL_H */ | 387 | #endif /* __LINUX_USB_SERIAL_H */ |
| 405 | 388 | ||
diff --git a/include/linux/usb/storage.h b/include/linux/usb/storage.h index cb33fff2ba0..d7fc910f1dc 100644 --- a/include/linux/usb/storage.h +++ b/include/linux/usb/storage.h | |||
| @@ -45,42 +45,4 @@ | |||
| 45 | 45 | ||
| 46 | #define USB_PR_DEVICE 0xff /* Use device's value */ | 46 | #define USB_PR_DEVICE 0xff /* Use device's value */ |
| 47 | 47 | ||
| 48 | /* | ||
| 49 | * Bulk only data structures | ||
| 50 | */ | ||
| 51 | |||
| 52 | /* command block wrapper */ | ||
| 53 | struct bulk_cb_wrap { | ||
| 54 | __le32 Signature; /* contains 'USBC' */ | ||
| 55 | __u32 Tag; /* unique per command id */ | ||
| 56 | __le32 DataTransferLength; /* size of data */ | ||
| 57 | __u8 Flags; /* direction in bit 0 */ | ||
| 58 | __u8 Lun; /* LUN normally 0 */ | ||
| 59 | __u8 Length; /* of of the CDB */ | ||
| 60 | __u8 CDB[16]; /* max command */ | ||
| 61 | }; | ||
| 62 | |||
| 63 | #define US_BULK_CB_WRAP_LEN 31 | ||
| 64 | #define US_BULK_CB_SIGN 0x43425355 /*spells out USBC */ | ||
| 65 | #define US_BULK_FLAG_IN (1 << 7) | ||
| 66 | #define US_BULK_FLAG_OUT 0 | ||
| 67 | |||
| 68 | /* command status wrapper */ | ||
| 69 | struct bulk_cs_wrap { | ||
| 70 | __le32 Signature; /* should = 'USBS' */ | ||
| 71 | __u32 Tag; /* same as original command */ | ||
| 72 | __le32 Residue; /* amount not transferred */ | ||
| 73 | __u8 Status; /* see below */ | ||
| 74 | }; | ||
| 75 | |||
| 76 | #define US_BULK_CS_WRAP_LEN 13 | ||
| 77 | #define US_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */ | ||
| 78 | #define US_BULK_STAT_OK 0 | ||
| 79 | #define US_BULK_STAT_FAIL 1 | ||
| 80 | #define US_BULK_STAT_PHASE 2 | ||
| 81 | |||
| 82 | /* bulk-only class specific requests */ | ||
| 83 | #define US_BULK_RESET_REQUEST 0xff | ||
| 84 | #define US_BULK_GET_MAX_LUN 0xfe | ||
| 85 | |||
| 86 | #endif | 48 | #endif |
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h deleted file mode 100644 index 176b1ca06ae..00000000000 --- a/include/linux/usb/tegra_usb_phy.h +++ /dev/null | |||
| @@ -1,80 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2010 Google, Inc. | ||
| 3 | * | ||
| 4 | * This software is licensed under the terms of the GNU General Public | ||
| 5 | * License version 2, as published by the Free Software Foundation, and | ||
| 6 | * may be copied, distributed, and modified under those terms. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef __TEGRA_USB_PHY_H | ||
| 16 | #define __TEGRA_USB_PHY_H | ||
| 17 | |||
| 18 | #include <linux/clk.h> | ||
| 19 | #include <linux/usb/otg.h> | ||
| 20 | |||
| 21 | struct tegra_utmip_config { | ||
| 22 | u8 hssync_start_delay; | ||
| 23 | u8 elastic_limit; | ||
| 24 | u8 idle_wait_delay; | ||
| 25 | u8 term_range_adj; | ||
| 26 | u8 xcvr_setup; | ||
| 27 | u8 xcvr_lsfslew; | ||
| 28 | u8 xcvr_lsrslew; | ||
| 29 | }; | ||
| 30 | |||
| 31 | struct tegra_ulpi_config { | ||
| 32 | int reset_gpio; | ||
| 33 | const char *clk; | ||
| 34 | }; | ||
| 35 | |||
| 36 | enum tegra_usb_phy_port_speed { | ||
| 37 | TEGRA_USB_PHY_PORT_SPEED_FULL = 0, | ||
| 38 | TEGRA_USB_PHY_PORT_SPEED_LOW, | ||
| 39 | TEGRA_USB_PHY_PORT_SPEED_HIGH, | ||
| 40 | }; | ||
| 41 | |||
| 42 | enum tegra_usb_phy_mode { | ||
| 43 | TEGRA_USB_PHY_MODE_DEVICE, | ||
| 44 | TEGRA_USB_PHY_MODE_HOST, | ||
| 45 | }; | ||
| 46 | |||
| 47 | struct tegra_xtal_freq; | ||
| 48 | |||
| 49 | struct tegra_usb_phy { | ||
| 50 | int instance; | ||
| 51 | const struct tegra_xtal_freq *freq; | ||
| 52 | void __iomem *regs; | ||
| 53 | void __iomem *pad_regs; | ||
| 54 | struct clk *clk; | ||
| 55 | struct clk *pll_u; | ||
| 56 | struct clk *pad_clk; | ||
| 57 | enum tegra_usb_phy_mode mode; | ||
| 58 | void *config; | ||
| 59 | struct usb_phy *ulpi; | ||
| 60 | struct usb_phy u_phy; | ||
| 61 | struct device *dev; | ||
| 62 | }; | ||
| 63 | |||
| 64 | struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance, | ||
| 65 | void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode); | ||
| 66 | |||
| 67 | void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy); | ||
| 68 | |||
| 69 | void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy); | ||
| 70 | |||
| 71 | void tegra_usb_phy_preresume(struct tegra_usb_phy *phy); | ||
| 72 | |||
| 73 | void tegra_usb_phy_postresume(struct tegra_usb_phy *phy); | ||
| 74 | |||
| 75 | void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy, | ||
| 76 | enum tegra_usb_phy_port_speed port_speed); | ||
| 77 | |||
| 78 | void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy); | ||
| 79 | |||
| 80 | #endif /* __TEGRA_USB_PHY_H */ | ||
diff --git a/include/linux/usb/tilegx.h b/include/linux/usb/tilegx.h deleted file mode 100644 index 2d65e343568..00000000000 --- a/include/linux/usb/tilegx.h +++ /dev/null | |||
| @@ -1,34 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2012 Tilera Corporation. All Rights Reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU General Public License | ||
| 6 | * as published by the Free Software Foundation, version 2. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, but | ||
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
| 11 | * NON INFRINGEMENT. See the GNU General Public License for | ||
| 12 | * more details. | ||
| 13 | * | ||
| 14 | * Structure to contain platform-specific data related to Tile-Gx USB | ||
| 15 | * controllers. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef _LINUX_USB_TILEGX_H | ||
| 19 | #define _LINUX_USB_TILEGX_H | ||
| 20 | |||
| 21 | #include <gxio/usb_host.h> | ||
| 22 | |||
| 23 | struct tilegx_usb_platform_data { | ||
| 24 | /* GXIO device index. */ | ||
| 25 | int dev_index; | ||
| 26 | |||
| 27 | /* GXIO device context. */ | ||
| 28 | gxio_usb_host_context_t usb_ctx; | ||
| 29 | |||
| 30 | /* Device IRQ. */ | ||
| 31 | unsigned int irq; | ||
| 32 | }; | ||
| 33 | |||
| 34 | #endif /* _LINUX_USB_TILEGX_H */ | ||
diff --git a/include/linux/usb/uas.h b/include/linux/usb/uas.h deleted file mode 100644 index 5499ab5c94b..00000000000 --- a/include/linux/usb/uas.h +++ /dev/null | |||
| @@ -1,109 +0,0 @@ | |||
| 1 | #ifndef __USB_UAS_H__ | ||
| 2 | #define __USB_UAS_H__ | ||
| 3 | |||
| 4 | #include <scsi/scsi.h> | ||
| 5 | #include <scsi/scsi_cmnd.h> | ||
| 6 | |||
| 7 | /* Common header for all IUs */ | ||
| 8 | struct iu { | ||
| 9 | __u8 iu_id; | ||
| 10 | __u8 rsvd1; | ||
| 11 | __be16 tag; | ||
| 12 | }; | ||
| 13 | |||
| 14 | enum { | ||
| 15 | IU_ID_COMMAND = 0x01, | ||
| 16 | IU_ID_STATUS = 0x03, | ||
| 17 | IU_ID_RESPONSE = 0x04, | ||
| 18 | IU_ID_TASK_MGMT = 0x05, | ||
| 19 | IU_ID_READ_READY = 0x06, | ||
| 20 | IU_ID_WRITE_READY = 0x07, | ||
| 21 | }; | ||
| 22 | |||
| 23 | enum { | ||
| 24 | TMF_ABORT_TASK = 0x01, | ||
| 25 | TMF_ABORT_TASK_SET = 0x02, | ||
| 26 | TMF_CLEAR_TASK_SET = 0x04, | ||
| 27 | TMF_LOGICAL_UNIT_RESET = 0x08, | ||
| 28 | TMF_I_T_NEXUS_RESET = 0x10, | ||
| 29 | TMF_CLEAR_ACA = 0x40, | ||
| 30 | TMF_QUERY_TASK = 0x80, | ||
| 31 | TMF_QUERY_TASK_SET = 0x81, | ||
| 32 | TMF_QUERY_ASYNC_EVENT = 0x82, | ||
| 33 | }; | ||
| 34 | |||
| 35 | enum { | ||
| 36 | RC_TMF_COMPLETE = 0x00, | ||
| 37 | RC_INVALID_INFO_UNIT = 0x02, | ||
| 38 | RC_TMF_NOT_SUPPORTED = 0x04, | ||
| 39 | RC_TMF_FAILED = 0x05, | ||
| 40 | RC_TMF_SUCCEEDED = 0x08, | ||
| 41 | RC_INCORRECT_LUN = 0x09, | ||
| 42 | RC_OVERLAPPED_TAG = 0x0a, | ||
| 43 | }; | ||
| 44 | |||
| 45 | struct command_iu { | ||
| 46 | __u8 iu_id; | ||
| 47 | __u8 rsvd1; | ||
| 48 | __be16 tag; | ||
| 49 | __u8 prio_attr; | ||
| 50 | __u8 rsvd5; | ||
| 51 | __u8 len; | ||
| 52 | __u8 rsvd7; | ||
| 53 | struct scsi_lun lun; | ||
| 54 | __u8 cdb[16]; /* XXX: Overflow-checking tools may misunderstand */ | ||
| 55 | }; | ||
| 56 | |||
| 57 | struct task_mgmt_iu { | ||
| 58 | __u8 iu_id; | ||
| 59 | __u8 rsvd1; | ||
| 60 | __be16 tag; | ||
| 61 | __u8 function; | ||
| 62 | __u8 rsvd2; | ||
| 63 | __be16 task_tag; | ||
| 64 | struct scsi_lun lun; | ||
| 65 | }; | ||
| 66 | |||
| 67 | /* | ||
| 68 | * Also used for the Read Ready and Write Ready IUs since they have the | ||
| 69 | * same first four bytes | ||
| 70 | */ | ||
| 71 | struct sense_iu { | ||
| 72 | __u8 iu_id; | ||
| 73 | __u8 rsvd1; | ||
| 74 | __be16 tag; | ||
| 75 | __be16 status_qual; | ||
| 76 | __u8 status; | ||
| 77 | __u8 rsvd7[7]; | ||
| 78 | __be16 len; | ||
| 79 | __u8 sense[SCSI_SENSE_BUFFERSIZE]; | ||
| 80 | }; | ||
| 81 | |||
| 82 | struct response_ui { | ||
| 83 | __u8 iu_id; | ||
| 84 | __u8 rsvd1; | ||
| 85 | __be16 tag; | ||
| 86 | __be16 add_response_info; | ||
| 87 | __u8 response_code; | ||
| 88 | }; | ||
| 89 | |||
| 90 | struct usb_pipe_usage_descriptor { | ||
| 91 | __u8 bLength; | ||
| 92 | __u8 bDescriptorType; | ||
| 93 | |||
| 94 | __u8 bPipeID; | ||
| 95 | __u8 Reserved; | ||
| 96 | } __attribute__((__packed__)); | ||
| 97 | |||
| 98 | enum { | ||
| 99 | CMD_PIPE_ID = 1, | ||
| 100 | STATUS_PIPE_ID = 2, | ||
| 101 | DATA_IN_PIPE_ID = 3, | ||
| 102 | DATA_OUT_PIPE_ID = 4, | ||
| 103 | |||
| 104 | UAS_SIMPLE_TAG = 0, | ||
| 105 | UAS_HEAD_TAG = 1, | ||
| 106 | UAS_ORDERED_TAG = 2, | ||
| 107 | UAS_ACA = 4, | ||
| 108 | }; | ||
| 109 | #endif | ||
diff --git a/include/linux/usb/ulpi.h b/include/linux/usb/ulpi.h index 6f033a415ec..9595796d62e 100644 --- a/include/linux/usb/ulpi.h +++ b/include/linux/usb/ulpi.h | |||
| @@ -181,12 +181,12 @@ | |||
| 181 | 181 | ||
| 182 | /*-------------------------------------------------------------------------*/ | 182 | /*-------------------------------------------------------------------------*/ |
| 183 | 183 | ||
| 184 | struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, | 184 | struct otg_transceiver *otg_ulpi_create(struct otg_io_access_ops *ops, |
| 185 | unsigned int flags); | 185 | unsigned int flags); |
| 186 | 186 | ||
| 187 | #ifdef CONFIG_USB_ULPI_VIEWPORT | 187 | #ifdef CONFIG_USB_ULPI_VIEWPORT |
| 188 | /* access ops for controllers with a viewport register */ | 188 | /* access ops for controllers with a viewport register */ |
| 189 | extern struct usb_phy_io_ops ulpi_viewport_access_ops; | 189 | extern struct otg_io_access_ops ulpi_viewport_access_ops; |
| 190 | #endif | 190 | #endif |
| 191 | 191 | ||
| 192 | #endif /* __LINUX_USB_ULPI_H */ | 192 | #endif /* __LINUX_USB_ULPI_H */ |
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index bd45eb7bedc..6939637e787 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h | |||
| @@ -66,10 +66,9 @@ struct usbnet { | |||
| 66 | # define EVENT_STS_SPLIT 3 | 66 | # define EVENT_STS_SPLIT 3 |
| 67 | # define EVENT_LINK_RESET 4 | 67 | # define EVENT_LINK_RESET 4 |
| 68 | # define EVENT_RX_PAUSED 5 | 68 | # define EVENT_RX_PAUSED 5 |
| 69 | # define EVENT_DEV_ASLEEP 6 | 69 | # define EVENT_DEV_WAKING 6 |
| 70 | # define EVENT_DEV_OPEN 7 | 70 | # define EVENT_DEV_ASLEEP 7 |
| 71 | # define EVENT_DEVICE_REPORT_IDLE 8 | 71 | # define EVENT_DEV_OPEN 8 |
| 72 | # define EVENT_NO_RUNTIME_PM 9 | ||
| 73 | }; | 72 | }; |
| 74 | 73 | ||
| 75 | static inline struct usb_driver *driver_of(struct usb_interface *intf) | 74 | static inline struct usb_driver *driver_of(struct usb_interface *intf) |
| @@ -99,7 +98,7 @@ struct driver_info { | |||
| 99 | 98 | ||
| 100 | #define FLAG_LINK_INTR 0x0800 /* updates link (carrier) status */ | 99 | #define FLAG_LINK_INTR 0x0800 /* updates link (carrier) status */ |
| 101 | 100 | ||
| 102 | #define FLAG_POINTTOPOINT 0x1000 /* possibly use "usb%d" names */ | 101 | #define FLAG_POINTTOPOINT 0x1000 /* possibly use "usb%d" names */ |
| 103 | 102 | ||
| 104 | /* | 103 | /* |
| 105 | * Indicates to usbnet, that USB driver accumulates multiple IP packets. | 104 | * Indicates to usbnet, that USB driver accumulates multiple IP packets. |
| @@ -107,6 +106,7 @@ struct driver_info { | |||
| 107 | */ | 106 | */ |
| 108 | #define FLAG_MULTI_PACKET 0x2000 | 107 | #define FLAG_MULTI_PACKET 0x2000 |
| 109 | #define FLAG_RX_ASSEMBLE 0x4000 /* rx packets may span >1 frames */ | 108 | #define FLAG_RX_ASSEMBLE 0x4000 /* rx packets may span >1 frames */ |
| 109 | #define FLAG_RMNET 0x8000 /* use "rmnet%d" names */ | ||
| 110 | 110 | ||
| 111 | /* init device ... can sleep, or cause probe() failure */ | 111 | /* init device ... can sleep, or cause probe() failure */ |
| 112 | int (*bind)(struct usbnet *, struct usb_interface *); | 112 | int (*bind)(struct usbnet *, struct usb_interface *); |
| @@ -162,18 +162,7 @@ extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *); | |||
| 162 | extern int usbnet_suspend(struct usb_interface *, pm_message_t); | 162 | extern int usbnet_suspend(struct usb_interface *, pm_message_t); |
| 163 | extern int usbnet_resume(struct usb_interface *); | 163 | extern int usbnet_resume(struct usb_interface *); |
| 164 | extern void usbnet_disconnect(struct usb_interface *); | 164 | extern void usbnet_disconnect(struct usb_interface *); |
| 165 | extern void usbnet_device_suggests_idle(struct usbnet *dev); | 165 | |
| 166 | |||
| 167 | extern int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
| 168 | u16 value, u16 index, void *data, u16 size); | ||
| 169 | extern int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
| 170 | u16 value, u16 index, const void *data, u16 size); | ||
| 171 | extern int usbnet_read_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
| 172 | u16 value, u16 index, void *data, u16 size); | ||
| 173 | extern int usbnet_write_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
| 174 | u16 value, u16 index, const void *data, u16 size); | ||
| 175 | extern int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
| 176 | u16 value, u16 index, const void *data, u16 size); | ||
| 177 | 166 | ||
| 178 | /* Drivers that reuse some of the standard USB CDC infrastructure | 167 | /* Drivers that reuse some of the standard USB CDC infrastructure |
| 179 | * (notably, using multiple interfaces according to the CDC | 168 | * (notably, using multiple interfaces according to the CDC |
| @@ -203,8 +192,7 @@ extern void usbnet_cdc_status(struct usbnet *, struct urb *); | |||
| 203 | enum skb_state { | 192 | enum skb_state { |
| 204 | illegal = 0, | 193 | illegal = 0, |
| 205 | tx_start, tx_done, | 194 | tx_start, tx_done, |
| 206 | rx_start, rx_done, rx_cleanup, | 195 | rx_start, rx_done, rx_cleanup |
| 207 | unlink_start | ||
| 208 | }; | 196 | }; |
| 209 | 197 | ||
| 210 | struct skb_data { /* skb->cb is one of these */ | 198 | struct skb_data { /* skb->cb is one of these */ |
| @@ -241,6 +229,4 @@ extern void usbnet_set_msglevel(struct net_device *, u32); | |||
| 241 | extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *); | 229 | extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *); |
| 242 | extern int usbnet_nway_reset(struct net_device *net); | 230 | extern int usbnet_nway_reset(struct net_device *net); |
| 243 | 231 | ||
| 244 | extern int usbnet_manage_power(struct usbnet *, int); | ||
| 245 | |||
| 246 | #endif /* __LINUX_USB_USBNET_H */ | 232 | #endif /* __LINUX_USB_USBNET_H */ |
