source: mainline/uspace/lib/usb/include/usb/classes/hub.h@ f35b294

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f35b294 was f35b294, checked in by Matus Dekanek <smekideki@…>, 15 years ago

codelifting

  • Property mode set to 100644
File size: 7.8 KB
Line 
1/*
2 * Copyright (c) 2010 Matus Dekanek
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libusb
30 * @{
31 */
32/** @file
33 * @brief USB hub related structures.
34 */
35#ifndef LIBUSB_CLASS_HUB_H_
36#define LIBUSB_CLASS_HUB_H_
37
38#include <sys/types.h>
39
40/** Hub class feature selector.
41 * @warning The constants are not unique (feature selectors are used
42 * for hub and port).
43 */
44typedef enum {
45 USB_HUB_FEATURE_HUB_LOCAL_POWER = 0,
46 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 USB_HUB_FEATURE_PORT_CONNECTION = 0,
50 USB_HUB_FEATURE_PORT_ENABLE = 1,
51 USB_HUB_FEATURE_PORT_SUSPEND = 2,
52 USB_HUB_FEATURE_PORT_OVER_CURRENT = 3,
53 USB_HUB_FEATURE_PORT_RESET = 4,
54 USB_HUB_FEATURE_PORT_POWER = 8,
55 USB_HUB_FEATURE_PORT_LOW_SPEED = 9,
56 USB_HUB_FEATURE_C_PORT_CONNECTION = 16,
57 USB_HUB_FEATURE_C_PORT_ENABLE = 17,
58 USB_HUB_FEATURE_C_PORT_SUSPEND = 18,
59 USB_HUB_FEATURE_C_PORT_OVER_CURRENT = 19,
60 USB_HUB_FEATURE_C_PORT_RESET = 20,
61 /* USB_HUB_FEATURE_ = , */
62} usb_hub_class_feature_t;
63
64
65/** Header of standard hub descriptor without the "variadic" part. */
66typedef struct {
67 /** Descriptor length. */
68 uint8_t length;
69 /** Descriptor type (0x29). */
70 uint8_t descriptor_type;
71 /** Number of downstream ports. */
72 uint8_t port_count;
73 /** Characteristics bitmask. */
74 uint16_t characteristics;
75 /** Time from power-on to stabilization of current on the port. */
76 uint8_t power_good_time;
77 /** Maximum current requirements in mA. */
78 uint8_t max_current;
79} __attribute__ ((packed)) usb_hub_descriptor_header_t;
80
81/**
82 * @brief usb hub descriptor
83 *
84 * For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
85 */
86typedef struct usb_hub_descriptor_type {
87 /** Number of bytes in this descriptor, including this byte */
88 //uint8_t bDescLength;
89
90 /** Descriptor Type, value: 29H for hub descriptor */
91 //uint8_t bDescriptorType;
92
93 /** Number of downstream ports that this hub supports */
94 uint8_t ports_count;
95
96 /**
97 D1...D0: Logical Power Switching Mode
98 00: Ganged power switching (all ports power at
99 once)
100 01: Individual port power switching
101 1X: Reserved. Used only on 1.0 compliant hubs
102 that implement no power switching.
103 D2: Identifies a Compound Device
104 0: Hub is not part of a compound device
105 1: Hub is part of a compound device
106 D4...D3: Over-current Protection Mode
107 00: Global Over-current Protection. The hub
108 reports over-current as a summation of all
109 ports current draw, without a breakdown of
110 individual port over-current status.
111 01: Individual Port Over-current Protection. The
112 hub reports over-current on a per-port basis.
113 Each port has an over-current indicator.
114 1X: No Over-current Protection. This option is
115 allowed only for bus-powered hubs that do not
116 implement over-current protection.
117 D15...D5:
118 Reserved
119 */
120 uint16_t hub_characteristics;
121
122 /**
123 Time (in 2ms intervals) from the time the power-on
124 sequence begins on a port until power is good on that
125 port. The USB System Software uses this value to
126 determine how long to wait before accessing a
127 powered-on port.
128 */
129 uint8_t pwr_on_2_good_time;
130
131 /**
132 Maximum current requirements of the Hub Controller
133 electronics in mA.
134 */
135 uint8_t current_requirement;
136
137 /**
138 Indicates if a port has a removable device attached.
139 This field is reported on byte-granularity. Within a
140 byte, if no port exists for a given location, the field
141 representing the port characteristics returns 0.
142 Bit value definition:
143 0B - Device is removable
144 1B - Device is non-removable
145 This is a bitmap corresponding to the individual ports
146 on the hub:
147 Bit 0: Reserved for future use
148 Bit 1: Port 1
149 Bit 2: Port 2
150 ....
151 Bit n: Port n (implementation-dependent, up to a
152 maximum of 255 ports).
153 */
154 uint8_t * devices_removable;
155
156 /**
157 This field exists for reasons of compatibility with
158 software written for 1.0 compliant devices. All bits in
159 this field should be set to 1B. This field has one bit for
160 each port on the hub with additional pad bits, if
161 necessary, to make the number of bits in the field an
162 integer multiple of 8.
163 */
164 //uint8_t * port_pwr_ctrl_mask;
165} usb_hub_descriptor_t;
166
167
168
169/** @brief usb hub specific request types.
170 *
171 * For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
172 */
173typedef enum {
174 /** This request resets a value reported in the hub status. */
175 USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
176 /** This request resets a value reported in the port status. */
177 USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
178 /** This is an optional per-port diagnostic request that returns the bus state value, as sampled at the last EOF2 point. */
179 USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
180 /** This request returns the hub descriptor. */
181 USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
182 /** This request returns the current hub status and the states that have changed since the previous acknowledgment. */
183 USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
184 /** This request returns the current port status and the current value of the port status change bits. */
185 USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
186 /** This request overwrites the hub descriptor. */
187 USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
188 /** This request sets a value reported in the hub status. */
189 USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
190 /** This request sets a value reported in the port status. */
191 USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23
192} usb_hub_bm_request_type_t;
193
194/** @brief hub class request codes*/
195/// \TODO these are duplicit to standart descriptors
196typedef enum {
197 /** */
198 USB_HUB_REQUEST_GET_STATUS = 0,
199 /** */
200 USB_HUB_REQUEST_CLEAR_FEATURE = 1,
201 /** */
202 USB_HUB_REQUEST_GET_STATE = 2,
203 /** */
204 USB_HUB_REQUEST_SET_FEATURE = 3,
205 /** */
206 USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
207 /** */
208 USB_HUB_REQUEST_SET_DESCRIPTOR = 7
209} usb_hub_request_t;
210
211/**
212 * Maximum size of usb hub descriptor in bytes
213 */
214extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE;
215
216
217
218
219
220
221
222#endif
223/**
224 * @}
225 */
Note: See TracBrowser for help on using the repository browser.