1 /* 2 * Copyright (c) 2008 Travis Geiselbrecht 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files 6 * (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, merge, 8 * publish, distribute, sublicense, and/or sell copies of the Software, 9 * and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 #ifndef __HW_USB_H 24 #define __HW_USB_H 25 26 #include <sys/types.h> 27 #include <compiler.h> 28 29 /* GLOBAL STATUS VALUES */ 30 #define STD_COMMAND 0x00 31 #define SETUP_COMMAND_PHASE 0x40 32 #define FUNCTION_ERROR 0x7F /* Used when we are stalling the function EP0 */ 33 #define HUB_ERROR 0xFF /* Used when we are stalling the HUB EP0 */ 34 35 /* Request Types */ 36 #define DIR_OUT (0 << 7) 37 #define DIR_IN (1 << 7) 38 #define DIR_MASK (1 << 7) 39 #define TYPE_STANDARD (0 << 5) 40 #define TYPE_CLASS (1 << 5) 41 #define TYPE_VENDOR (2 << 5) 42 #define TYPE_MASK (3 << 5) 43 #define RECIP_DEVICE (0 << 0) 44 #define RECIP_INTERFACE (1 << 0) 45 #define RECIP_ENDPOINT (2 << 0) 46 #define RECIP_OTHER (3 << 0) 47 #define RECIP_MASK (0x1f << 0) 48 49 /* 1.0 Request Values */ 50 #define GET_STATUS 0x00 51 #define CLEAR_FEATURE 0x01 52 #define SET_FEATURE 0x03 53 #define SET_ADDRESS 0x05 54 #define GET_DESCRIPTOR 0x06 55 #define SET_DESCRIPTOR 0x07 56 #define GET_CONFIGURATION 0x08 57 #define SET_CONFIGURATION 0x09 58 #define GET_INTERFACE 0x0A 59 #define SET_INTERFACE 0x0B 60 #define SYNCH_FRAME 0x0C 61 62 /* Mass storage requests */ 63 #define MASS_STORAGE_GET_MAX_LUN 0xfe 64 #define MASS_STORAGE_RESET 0xff 65 66 /* DFU requests */ 67 #define DFU_DETACH 0x00 68 #define DFU_DNLOAD 0x01 69 #define DFU_UPLOAD 0x02 70 #define DFU_GETSTATUS 0x03 71 #define DFU_CLRSTATUS 0x04 72 #define DFU_GETSTATE 0x05 73 #define DFU_ABORT 0x06 74 75 /* HID Request Values */ 76 #define GET_REPORT 0x01 77 #define GET_IDLE 0x02 78 #define GET_PROTOCOL 0x03 79 #define SET_REPORT 0x09 80 #define SET_IDLE 0x0A 81 #define SET_PROTOCOL 0x0B 82 83 /* Descriptor Types */ 84 #define DEVICE 0x01 85 #define CONFIGURATION 0x02 86 #define STRING 0x03 87 #define INTERFACE 0x04 88 #define ENDPOINT 0x05 89 #define DEVICE_QUALIFIER 0x06 90 #define OTHER_SPEED_CONFIGURATION 0x07 91 #define INTERFACE_POWER 0x08 92 #define HID 0x21 93 #define HIDREPORT 0x22 94 #define HIDPHYSICAL 0x23 95 96 /* general USB defines */ 97 struct usb_setup { 98 uint8_t request_type; 99 uint8_t request; 100 uint16_t value; 101 uint16_t index; 102 uint16_t length; 103 } __PACKED; 104 105 #endif 106 107