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

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

hub is successfully initialized

  • Property mode set to 100644
File size: 7.7 KB
Line 
1/*
2 * Copyright (c) 2010 Vojtech Horky
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 usb
30 * @{
31 */
32/** @file
33 * @brief USB hub related structures.
34 */
35#ifndef LIBUSB_HUB_H_
36#define LIBUSB_HUB_H_
37
38#include <sys/types.h>
39#include <usb/hcdhubd.h>
40
41
42/** Hub class feature selector.
43 * @warning The constants are not unique (feature selectors are used
44 * for hub and port).
45 */
46typedef enum {
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/**
66 * @brief usb hub descriptor
67 *
68 * For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
69 */
70typedef struct hub_descriptor_type{
71 /** Number of bytes in this descriptor, including this byte */
72 //uint8_t bDescLength;
73
74 /** Descriptor Type, value: 29H for hub descriptor */
75 //uint8_t bDescriptorType;
76
77 /** Number of downstream ports that this hub supports */
78 uint8_t ports_count;
79
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 D15...D5:
102 Reserved
103 */
104 uint16_t hub_characteristics;
105
106 /**
107 Time (in 2ms intervals) from the time the power-on
108 sequence begins on a port until power is good on that
109 port. The USB System Software uses this value to
110 determine how long to wait before accessing a
111 powered-on port.
112 */
113 uint8_t pwr_on_2_good_time;
114
115 /**
116 Maximum current requirements of the Hub Controller
117 electronics in mA.
118 */
119 uint8_t current_requirement;
120
121 /**
122 Indicates if a port has a removable device attached.
123 This field is reported on byte-granularity. Within a
124 byte, if no port exists for a given location, the field
125 representing the port characteristics returns 0.
126 Bit value definition:
127 0B - Device is removable
128 1B - Device is non-removable
129 This is a bitmap corresponding to the individual ports
130 on the hub:
131 Bit 0: Reserved for future use
132 Bit 1: Port 1
133 Bit 2: Port 2
134 ....
135 Bit n: Port n (implementation-dependent, up to a
136 maximum of 255 ports).
137 */
138 uint8_t * devices_removable;
139
140 /**
141 This field exists for reasons of compatibility with
142 software written for 1.0 compliant devices. All bits in
143 this field should be set to 1B. This field has one bit for
144 each port on the hub with additional pad bits, if
145 necessary, to make the number of bits in the field an
146 integer multiple of 8.
147 */
148 //uint8_t * port_pwr_ctrl_mask;
149} usb_hub_descriptor_t;
150
151
152
153/** @brief usb hub specific request types.
154 *
155 * For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
156 */
157typedef enum {
158 /** This request resets a value reported in the hub status. */
159 USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
160 /** This request resets a value reported in the port status. */
161 USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
162 /** This is an optional per-port diagnostic request that returns the bus state value, as sampled at the last EOF2 point. */
163 USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
164 /** This request returns the hub descriptor. */
165 USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
166 /** This request returns the current hub status and the states that have changed since the previous acknowledgment. */
167 USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
168 /** This request returns the current port status and the current value of the port status change bits. */
169 USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
170 /** This request overwrites the hub descriptor. */
171 USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
172 /** This request sets a value reported in the hub status. */
173 USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
174 /** This request sets a value reported in the port status. */
175 USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23
176} usb_hub_bm_request_type_t;
177
178/** @brief hub class request codes*/
179/// \TODO these are duplicit to standart descriptors
180typedef enum {
181 /** */
182 USB_HUB_REQUEST_GET_STATUS = 0,
183 /** */
184 USB_HUB_REQUEST_CLEAR_FEATURE = 1,
185 /** */
186 USB_HUB_REQUEST_GET_STATE = 2,
187 /** */
188 USB_HUB_REQUEST_SET_FEATURE = 3,
189 /** */
190 USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
191 /** */
192 USB_HUB_REQUEST_SET_DESCRIPTOR = 7
193} usb_hub_request_t;
194
195/**
196 * Maximum size of usb hub descriptor in bytes
197 */
198extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE;
199
200/**
201 * @brief create uint8_t array with serialized descriptor
202 *
203 * @param descriptor
204 */
205void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
206
207/**
208 * @brief create deserialized desriptor structure out of serialized descriptor
209 *
210 * The serialized descriptor must be proper usb hub descriptor, otherwise an eerror might occur.
211 *
212 * @param sdescriptor serialized descriptor
213 */
214usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
215
216
217
218
219
220
221#endif
222/**
223 * @}
224 */
Note: See TracBrowser for help on using the repository browser.