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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since e8d82cb was e8d82cb, checked in by Jan Vesely <jano.vesely@…>, 14 years ago

libusb: c99 array initialization. Comment fix.

  • Property mode set to 100644
File size: 8.0 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 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 */
78 uint8_t characteristics_reserved;
79 /** Time from power-on to stabilization of current on the port. */
80 uint8_t power_good_time;
81 /** Maximum current requirements in mA. */
82 uint8_t max_current;
83} __attribute__ ((packed)) usb_hub_descriptor_header_t;
84
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 */
91typedef 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
173
174/** @brief usb hub specific request types.
175 *
176 * For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
177 */
178typedef enum {
179 /** This request resets a value reported in the hub status. */
180 USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
181 /** This request resets a value reported in the port status. */
182 USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
183 /** This is an optional per-port diagnostic request that returns the bus state value, as sampled at the last EOF2 point. */
184 USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
185 /** This request returns the hub descriptor. */
186 USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
187 /** This request returns the current hub status and the states that have changed since the previous acknowledgment. */
188 USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
189 /** This request returns the current port status and the current value of the port status change bits. */
190 USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
191 /** This request overwrites the hub descriptor. */
192 USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
193 /** This request sets a value reported in the hub status. */
194 USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
195 /** This request sets a value reported in the port status. */
196 USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23
197} usb_hub_bm_request_type_t;
198
199/** @brief hub class request codes*/
200/// \TODO these are duplicit to standart descriptors
201typedef enum {
202 /** */
203 USB_HUB_REQUEST_GET_STATUS = 0,
204 /** */
205 USB_HUB_REQUEST_CLEAR_FEATURE = 1,
206 /** */
207 USB_HUB_REQUEST_GET_STATE = 2,
208 /** */
209 USB_HUB_REQUEST_SET_FEATURE = 3,
210 /** */
211 USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
212 /** */
213 USB_HUB_REQUEST_SET_DESCRIPTOR = 7
214} usb_hub_request_t;
215
216/**
217 * Maximum size of usb hub descriptor in bytes
218 */
219/* 7 (basic size) + 2*32 (port bitmasks) */
220#define USB_HUB_MAX_DESCRIPTOR_SIZE 71
221
222#endif
223/**
224 * @}
225 */
Note: See TracBrowser for help on using the repository browser.