Ignore:
Timestamp:
2010-11-24T14:27:33Z (13 years ago)
Author:
smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2e15ac40, bbe7848
Parents:
8cd1aa5e
Message:

basic hub driver structures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/classes/hub.h

    r8cd1aa5e r03171de  
    3636#define LIBUSB_HUB_H_
    3737
    38 /** Hub class request. */
    39 typedef enum {
    40         USB_HUB_REQUEST_GET_STATUS = 0,
    41         USB_HUB_REQUEST_CLEAR_FEATURE = 1,
    42         USB_HUB_REQUEST_GET_STATE = 2,
    43         USB_HUB_REQUEST_SET_FEATURE = 3,
    44         USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
    45         USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
    46         /* USB_HUB_REQUEST_ = , */
    47 } usb_hub_class_request_t;
     38#include <sys/types.h>
     39
    4840
    4941/** Hub class feature selector.
     
    6961} usb_hub_class_feature_t;
    7062
     63
     64/**
     65 *      @brief usb hub descriptor
     66 *
     67 *      For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
     68 */
     69typedef struct hub_descriptor_type{
     70    /** Number of bytes in this descriptor, including this byte */
     71    //uint8_t bDescLength;
     72
     73    /** Descriptor Type, value: 29H for hub descriptor */
     74    //uint8_t bDescriptorType;
     75
     76    /** Number of downstream ports that this hub supports */
     77    uint8_t ports_count;
     78
     79    /**
     80            D1...D0: Logical Power Switching Mode
     81            00: Ganged power switching (all ports’ power at
     82            once)
     83            01: Individual port power switching
     84            1X: Reserved. Used only on 1.0 compliant hubs
     85            that implement no power switching.
     86            D2: Identifies a Compound Device
     87            0: Hub is not part of a compound device
     88            1: Hub is part of a compound device
     89            D4...D3: Over-current Protection Mode
     90            00: Global Over-current Protection. The hub
     91            reports over-current as a summation of all
     92            ports’ current draw, without a breakdown of
     93            individual port over-current status.
     94            01: Individual Port Over-current Protection. The
     95            hub reports over-current on a per-port basis.
     96            Each port has an over-current indicator.
     97            1X: No Over-current Protection. This option is
     98            allowed only for bus-powered hubs that do not
     99            implement over-current protection.
     100            D15...D5:
     101            Reserved
     102     */
     103    uint16_t hub_characteristics;
     104
     105    /**
     106            Time (in 2ms intervals) from the time the power-on
     107            sequence begins on a port until power is good on that
     108            port. The USB System Software uses this value to
     109            determine how long to wait before accessing a
     110            powered-on port.
     111     */
     112    uint8_t pwr_on_2_good_time;
     113
     114    /**
     115            Maximum current requirements of the Hub Controller
     116            electronics in mA.
     117     */
     118    uint8_t current_requirement;
     119
     120    /**
     121            Indicates if a port has a removable device attached.
     122            This field is reported on byte-granularity. Within a
     123            byte, if no port exists for a given location, the field
     124            representing the port characteristics returns 0.
     125            Bit value definition:
     126            0B - Device is removable
     127            1B - Device is non-removable
     128            This is a bitmap corresponding to the individual ports
     129            on the hub:
     130            Bit 0: Reserved for future use
     131            Bit 1: Port 1
     132            Bit 2: Port 2
     133            ....
     134            Bit n: Port n (implementation-dependent, up to a
     135            maximum of 255 ports).
     136     */
     137    uint8_t * devices_removable;
     138
     139    /**
     140            This field exists for reasons of compatibility with
     141            software written for 1.0 compliant devices. All bits in
     142            this field should be set to 1B. This field has one bit for
     143            each port on the hub with additional pad bits, if
     144            necessary, to make the number of bits in the field an
     145            integer multiple of 8.
     146     */
     147    //uint8_t * port_pwr_ctrl_mask;
     148} usb_hub_descriptor_t;
     149
     150/**
     151 *      Maximum size of usb hub descriptor in bytes
     152 */
     153extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE;
     154
     155/**
     156 *      hub descriptor type
     157 */
     158extern uint8_t USB_HUB_DESCRIPTOR_TYPE;
     159
     160/**
     161 * @brief create uint8_t array with serialized descriptor
     162 *
     163 * @param descriptor
     164 */
     165void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
     166
     167/**
     168 * @brief create deserialized desriptor structure out of serialized descriptor
     169 *
     170 * The serialized descriptor must be proper usb hub descriptor, otherwise an eerror might occur.
     171 *
     172 * @param sdescriptor serialized descriptor
     173 */
     174usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
     175
     176/**     @brief usb hub specific request types.
     177 *
     178 *      For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
     179 */
     180typedef enum {
     181    /** This request resets a value reported in the hub status. */
     182    USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
     183    /** This request resets a value reported in the port status. */
     184    USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
     185    /** This is an optional per-port diagnostic request that returns the bus state value, as sampled at the last EOF2 point. */
     186    USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
     187    /** This request returns the hub descriptor. */
     188    USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
     189    /** This request returns the current hub status and the states that have changed since the previous acknowledgment. */
     190    USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
     191    /** This request returns the current port status and the current value of the port status change bits. */
     192    USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
     193    /** This request overwrites the hub descriptor. */
     194    USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
     195    /** This request sets a value reported in the hub status. */
     196    USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
     197    /** This request sets a value reported in the port status. */
     198    USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23
     199} usb_hub_bm_request_type_t;
     200
     201/** @brief hub class request codes*/
     202typedef enum {
     203    /**  */
     204    USB_HUB_REQUEST_GET_STATUS = 0,
     205    /** */
     206    USB_HUB_REQUEST_CLEAR_FEATURE = 1,
     207    /** */
     208    USB_HUB_REQUEST_GET_STATE = 2,
     209    /** */
     210    USB_HUB_REQUEST_SET_FEATURE = 3,
     211    /** */
     212    USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
     213    /** */
     214    USB_HUB_REQUEST_SET_DESCRIPTOR = 7
     215} usb_hub_request_t;
     216
     217
     218
     219
     220
    71221#endif
    72222/**
Note: See TracChangeset for help on using the changeset viewer.