Changeset b4b534ac in mainline for uspace/lib/usb/include
- Timestamp:
- 2016-07-22T08:24:47Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f76d2c2
- Parents:
- 5b18137 (diff), 8351f9a4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/lib/usb/include/usb
- Files:
-
- 1 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/classes/hub.h
r5b18137 rb4b534ac 43 43 */ 44 44 typedef enum { 45 USB_HUB_FEATURE_C_HUB_LOCAL_POWER = 0, 46 USB_HUB_FEATURE_C_HUB_OVER_CURRENT = 1, 45 47 USB_HUB_FEATURE_HUB_LOCAL_POWER = 0, 46 48 USB_HUB_FEATURE_HUB_OVER_CURRENT = 1, 47 USB_HUB_FEATURE_C_HUB_LOCAL_POWER = 0,48 USB_HUB_FEATURE_C_HUB_OVER_CURRENT = 1,49 49 USB_HUB_FEATURE_PORT_CONNECTION = 0, 50 50 USB_HUB_FEATURE_PORT_ENABLE = 1, … … 54 54 USB_HUB_FEATURE_PORT_POWER = 8, 55 55 USB_HUB_FEATURE_PORT_LOW_SPEED = 9, 56 USB_HUB_FEATURE_PORT_HIGH_SPEED = 10, 56 57 USB_HUB_FEATURE_C_PORT_CONNECTION = 16, 57 58 USB_HUB_FEATURE_C_PORT_ENABLE = 17, … … 59 60 USB_HUB_FEATURE_C_PORT_OVER_CURRENT = 19, 60 61 USB_HUB_FEATURE_C_PORT_RESET = 20, 62 USB_HUB_FEATURE_PORT_TEST = 21, 63 USB_HUB_FEATURE_PORT_INDICATOR = 22 61 64 /* USB_HUB_FEATURE_ = , */ 62 65 } usb_hub_class_feature_t; … … 67 70 /** Descriptor length. */ 68 71 uint8_t length; 72 69 73 /** Descriptor type (0x29). */ 70 74 uint8_t descriptor_type; 75 71 76 /** Number of downstream ports. */ 72 77 uint8_t port_count; 73 /** Characteristics bitmask. */ 78 79 /** Characteristics bitmask. 80 * 81 * D1..D0: Logical Power Switching Mode 82 * 00: Ganged power switching (all ports power at 83 * once) 84 * 01: Individual port power switching 85 * 1X: Reserved. Used only on 1.0 compliant hubs 86 * that implement no power switching. 87 * D2: Identifies a Compound Device 88 * 0: Hub is not part of a compound device 89 * 1: Hub is part of a compound device 90 * D4..D3: Over-current Protection Mode 91 * 00: Global Over-current Protection. The hub 92 * reports over-current as a summation of all 93 * ports current draw, without a breakdown of 94 * individual port over-current status. 95 * 01: Individual Port Over-current Protection. The 96 * hub reports over-current on a per-port basis. 97 * Each port has an over-current indicator. 98 * 1X: No Over-current Protection. This option is 99 * allowed only for bus-powered hubs that do not 100 * implement over-current protection. 101 * D6..D5: TT think time 102 * 00: At most 8 FS bit times 103 * 01: At most 16 FS bit times 104 * 10: At most 24 FS bit times 105 * 11: At most 32 FS bit times 106 * D7: Port indicators 107 * 0: Not supported 108 * 1: Supported 109 * D15...D8: Reserved 110 */ 74 111 uint8_t characteristics; 75 #define HUB_CHAR_POWER_PER_PORT_FLAG (1 << 0) 76 #define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1) 77 /* Unused part of characteristics field */ 112 #define HUB_CHAR_POWER_PER_PORT_FLAG (1 << 0) 113 #define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1) 114 #define HUB_CHAR_COMPOUND_DEVICE (1 << 2) 115 #define HUB_CHAR_OC_PER_PORT_FLAG (1 << 3) 116 #define HUB_CHAR_NO_OC_FLAG (1 << 4) 117 #define HUB_CHAR_TT_THINK_16 (1 << 5) 118 #define HUB_CHAR_TT_THINK_8 (1 << 6) 119 #define HUB_CHAR_INDICATORS_FLAG (1 << 7) 120 121 /** Unused part of characteristics field */ 78 122 uint8_t characteristics_reserved; 79 /** Time from power-on to stabilization of current on the port. */ 123 124 /** Time from power-on to stabilization of current on the port. 125 * 126 * Time (in 2ms intervals) from the time the power-on 127 * sequence begins on a port until power is good on that 128 * port. The USB System Software uses this value to 129 * determine how long to wait before accessing a 130 * powered-on port. 131 */ 80 132 uint8_t power_good_time; 81 /** Maximum current requirements in mA. */ 133 /** Maximum current requirements in mA. 134 * 135 * Maximum current requirements of the Hub Controller 136 * electronics in mA. 137 */ 82 138 uint8_t max_current; 83 139 } __attribute__ ((packed)) usb_hub_descriptor_header_t; 84 140 85 /** 86 * @brief usb hub descriptor 87 * 88 * For more information see Universal Serial Bus Specification Revision 1.1 89 * chapter 11.16.2 90 */ 91 typedef struct usb_hub_descriptor_type { 92 /** Number of bytes in this descriptor, including this byte */ 93 //uint8_t bDescLength; 94 95 /** Descriptor Type, value: 29H for hub descriptor */ 96 //uint8_t bDescriptorType; 97 98 /** Number of downstream ports that this hub supports */ 99 uint8_t port_count; 100 101 /** 102 D1...D0: Logical Power Switching Mode 103 00: Ganged power switching (all ports power at 104 once) 105 01: Individual port power switching 106 1X: Reserved. Used only on 1.0 compliant hubs 107 that implement no power switching. 108 D2: Identifies a Compound Device 109 0: Hub is not part of a compound device 110 1: Hub is part of a compound device 111 D4...D3: Over-current Protection Mode 112 00: Global Over-current Protection. The hub 113 reports over-current as a summation of all 114 ports current draw, without a breakdown of 115 individual port over-current status. 116 01: Individual Port Over-current Protection. The 117 hub reports over-current on a per-port basis. 118 Each port has an over-current indicator. 119 1X: No Over-current Protection. This option is 120 allowed only for bus-powered hubs that do not 121 implement over-current protection. 122 D15...D5: 123 Reserved 124 */ 125 uint16_t hub_characteristics; 126 127 /** 128 Time (in 2ms intervals) from the time the power-on 129 sequence begins on a port until power is good on that 130 port. The USB System Software uses this value to 131 determine how long to wait before accessing a 132 powered-on port. 133 */ 134 uint8_t pwr_on_2_good_time; 135 136 /** 137 Maximum current requirements of the Hub Controller 138 electronics in mA. 139 */ 140 uint8_t current_requirement; 141 142 /** 143 Indicates if a port has a removable device attached. 144 This field is reported on byte-granularity. Within a 145 byte, if no port exists for a given location, the field 146 representing the port characteristics returns 0. 147 Bit value definition: 148 0B - Device is removable 149 1B - Device is non-removable 150 This is a bitmap corresponding to the individual ports 151 on the hub: 152 Bit 0: Reserved for future use 153 Bit 1: Port 1 154 Bit 2: Port 2 155 .... 156 Bit n: Port n (implementation-dependent, up to a 157 maximum of 255 ports). 158 */ 159 uint8_t devices_removable[32]; 160 161 /** 162 This field exists for reasons of compatibility with 163 software written for 1.0 compliant devices. All bits in 164 this field should be set to 1B. This field has one bit for 165 each port on the hub with additional pad bits, if 166 necessary, to make the number of bits in the field an 167 integer multiple of 8. 168 */ 169 //uint8_t * port_pwr_ctrl_mask; 170 } usb_hub_descriptor_t; 171 172 141 /** One bit for the device and one bit for every port */ 142 #define STATUS_BYTES(ports) ((1 + ports + 7) / 8) 173 143 174 144 /** @brief usb hub specific request types. … … 204 174 /** */ 205 175 USB_HUB_REQUEST_CLEAR_FEATURE = 1, 206 /** */176 /** USB 1.0 only */ 207 177 USB_HUB_REQUEST_GET_STATE = 2, 208 178 /** */ … … 211 181 USB_HUB_REQUEST_GET_DESCRIPTOR = 6, 212 182 /** */ 213 USB_HUB_REQUEST_SET_DESCRIPTOR = 7 183 USB_HUB_REQUEST_SET_DESCRIPTOR = 7, 184 /** */ 185 USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8, 186 /** */ 187 USB_HUB_REQUEST_RESET_TT = 9, 188 /** */ 189 USB_HUB_GET_TT_STATE = 10, 190 /** */ 191 USB_HUB_STOP_TT = 11, 214 192 } usb_hub_request_t; 215 193 … … 218 196 */ 219 197 /* 7 (basic size) + 2*32 (port bitmasks) */ 220 #define USB_HUB_MAX_DESCRIPTOR_SIZE 71198 #define USB_HUB_MAX_DESCRIPTOR_SIZE (7 + 2 * 32) 221 199 222 200 #endif -
uspace/lib/usb/include/usb/classes/massstor.h
r5b18137 rb4b534ac 36 36 #define LIBUSB_CLASS_MASSSTOR_H_ 37 37 38 #include <sys/types.h>39 40 38 /** USB mass storage subclasses. */ 41 39 typedef enum { -
uspace/lib/usb/include/usb/debug.h
r5b18137 rb4b534ac 36 36 #define LIBUSB_DEBUG_H_ 37 37 #include <stdio.h> 38 #include <inttypes.h> 39 #include <usb/usb.h> 38 #include <sys/types.h> 40 39 #include <io/log.h> 41 #include <assert.h> 40 42 41 43 42 void usb_dump_standard_descriptor(FILE *, const char *, const char *, -
uspace/lib/usb/include/usb/descriptor.h
r5b18137 rb4b534ac 36 36 #define LIBUSB_DESCRIPTOR_H_ 37 37 38 #include < async.h>38 #include <sys/types.h> 39 39 40 40 /** Descriptor type. */ … … 45 45 USB_DESCTYPE_INTERFACE = 4, 46 46 USB_DESCTYPE_ENDPOINT = 5, 47 /* New in USB2.0 */ 48 USB_DESCTYPE_DEVICE_QUALIFIER = 6, 49 USB_DESCTYPE_OTHER_SPEED_CONFIGURATION = 7, 50 USB_DESCTYPE_INTERFACE_POWER = 8, 51 /* Class specific */ 47 52 USB_DESCTYPE_HID = 0x21, 48 53 USB_DESCTYPE_HID_REPORT = 0x22, … … 89 94 } __attribute__ ((packed)) usb_standard_device_descriptor_t; 90 95 96 /** USB device qualifier decriptor is basically a cut down version of the device 97 * descriptor with values that would be valid if the device operated on the 98 * other speed (HIGH vs. FULL) 99 */ 100 typedef struct { 101 /** Size of this descriptor in bytes */ 102 uint8_t length; 103 /** Descriptor type (USB_DESCTYPE_DEVICE_QUALIFIER) */ 104 uint8_t descriptor_type; 105 /** USB specification release number. 106 * The number shall be coded as binary-coded decimal (BCD). 107 */ 108 uint16_t usb_spec_version; 109 /** Device class. */ 110 uint8_t device_class; 111 /** Device sub-class. */ 112 uint8_t device_subclass; 113 /** Device protocol. */ 114 uint8_t device_protocol; 115 /** Maximum packet size for endpoint zero. 116 * Valid values are only 8, 16, 32, 64). 117 */ 118 uint8_t max_packet_size; 119 /** Number of possible configurations. */ 120 uint8_t configuration_count; 121 uint8_t reserved; 122 } __attribute__ ((packed)) usb_standard_device_qualifier_descriptor_t; 123 91 124 /** Standard USB configuration descriptor. 92 125 */ … … 116 149 } __attribute__ ((packed)) usb_standard_configuration_descriptor_t; 117 150 151 /** USB Other Speed Configuration descriptor shows values that would change 152 * in the configuration descriptor if the device operated at its other 153 * possible speed (HIGH vs. FULL) 154 */ 155 typedef usb_standard_configuration_descriptor_t 156 usb_other_speed_configuration_descriptor_t; 157 118 158 /** Standard USB interface descriptor. 119 159 */ … … 157 197 */ 158 198 uint8_t attributes; 159 /** Maximum packet size. */ 199 /** Maximum packet size. 200 * Lower 10 bits represent the actuall size 201 * Bits 11,12 specify addtional transfer opportunitities for 202 * HS INT and ISO transfers. */ 160 203 uint16_t max_packet_size; 204 #define ED_MPS_PACKET_SIZE_MASK 0x3ff 205 #define ED_MPS_PACKET_SIZE_GET(value) \ 206 ((value) & ED_MPS_PACKET_SIZE_MASK) 207 #define ED_MPS_TRANS_OPPORTUNITIES_GET(value) \ 208 ((((value) >> 10) & 0x3) + 1) 161 209 /** Polling interval in milliseconds. 162 210 * Ignored for bulk and control endpoints. -
uspace/lib/usb/include/usb/dev.h
r5b18137 rb4b534ac 36 36 37 37 #include <devman.h> 38 #include <usb/usb.h>39 38 40 int usb_get_info_by_handle(devman_handle_t, 41 devman_handle_t *, usb_address_t *, int *); 42 43 static inline int usb_get_hc_by_handle(devman_handle_t dev, devman_handle_t *hc) 44 { 45 return usb_get_info_by_handle(dev, hc, NULL, NULL); 46 } 47 48 static inline int usb_get_address_by_handle( 49 devman_handle_t dev, usb_address_t *address) 50 { 51 return usb_get_info_by_handle(dev, NULL, address, NULL); 52 } 53 54 static inline int usb_get_iface_by_handle(devman_handle_t dev, int *iface) 55 { 56 return usb_get_info_by_handle(dev, NULL, NULL, iface); 57 } 58 59 int usb_resolve_device_handle(const char *, devman_handle_t *, usb_address_t *, 60 devman_handle_t *); 39 int usb_resolve_device_handle(const char *, devman_handle_t *); 61 40 #endif 62 41 /** -
uspace/lib/usb/include/usb/usb.h
r5b18137 rb4b534ac 84 84 } usb_speed_t; 85 85 86 static inline bool usb_speed_is_11(const usb_speed_t s) 87 { 88 return (s == USB_SPEED_FULL) || (s == USB_SPEED_LOW); 89 } 90 86 91 const char *usb_str_speed(usb_speed_t); 87 92 … … 110 115 #define USB_ADDRESS_DEFAULT 0 111 116 /** Maximum address number in USB 1.1. */ 112 #define USB11_ADDRESS_MAX 128 117 #define USB11_ADDRESS_MAX 127 118 #define USB_ADDRESS_COUNT (USB11_ADDRESS_MAX + 1) 119 120 /** Check USB address for allowed values. 121 * 122 * @param ep USB address. 123 * @return True, if value is wihtin limits, false otherwise. 124 */ 125 static inline bool usb_address_is_valid(usb_address_t a) 126 { 127 return (a >= USB_ADDRESS_DEFAULT) && (a <= USB11_ADDRESS_MAX); 128 } 113 129 114 130 /** USB endpoint number type. … … 117 133 typedef int16_t usb_endpoint_t; 118 134 119 /** Maximum endpoint number in USB 1.1. 120 */ 135 /** Default control endpoint */ 136 #define USB_ENDPOINT_DEFAULT_CONTROL 0 137 /** Maximum endpoint number in USB 1.1. */ 121 138 #define USB11_ENDPOINT_MAX 16 139 140 /** Check USB endpoint for allowed values. 141 * 142 * @param ep USB endpoint number. 143 * @return True, if value is wihtin limits, false otherwise. 144 */ 145 static inline bool usb_endpoint_is_valid(usb_endpoint_t ep) 146 { 147 return (ep >= USB_ENDPOINT_DEFAULT_CONTROL) && 148 (ep < USB11_ENDPOINT_MAX); 149 } 122 150 123 151 … … 133 161 } usb_target_t; 134 162 163 135 164 /** Check USB target for allowed values (address and endpoint). 136 165 * … … 140 169 static inline bool usb_target_is_valid(usb_target_t target) 141 170 { 142 return !(target.endpoint > 15 || target.endpoint < 0143 || target.address >= USB11_ADDRESS_MAX || target.address < 0);171 return usb_address_is_valid(target.address) && 172 usb_endpoint_is_valid(target.endpoint); 144 173 } 145 174
Note:
See TracChangeset
for help on using the changeset viewer.