Ignore:
Timestamp:
2018-02-28T16:37:50Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b20da0
Parents:
f5e5f73 (diff), b2dca8de (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.
git-author:
Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
git-committer:
Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
Message:

Merge github.com:helenos-xhci-team/helenos

This commit merges support for USB 3 and generally refactors, fixes,
extends and cleans up the existing USB framework.

Notable additions and features:

  • new host controller driver has been implemented to control various xHC models (among others, NEC Renesas uPD720200)
  • isochronous data transfer mode
  • support for explicit USB device removal
  • USB tablet driver
File:
1 edited

Legend:

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

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2010 Matus Dekanek
     3 * Copyright (c) 2018 Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    4849        USB_HUB_FEATURE_HUB_OVER_CURRENT = 1,
    4950        USB_HUB_FEATURE_PORT_CONNECTION = 0,
    50         USB_HUB_FEATURE_PORT_ENABLE = 1,
    51         USB_HUB_FEATURE_PORT_SUSPEND = 2,
     51        USB2_HUB_FEATURE_PORT_ENABLE = 1,
     52        USB2_HUB_FEATURE_PORT_SUSPEND = 2,
    5253        USB_HUB_FEATURE_PORT_OVER_CURRENT = 3,
    5354        USB_HUB_FEATURE_PORT_RESET = 4,
     55        USB3_HUB_FEATURE_PORT_LINK_STATE = 5,
    5456        USB_HUB_FEATURE_PORT_POWER = 8,
    55         USB_HUB_FEATURE_PORT_LOW_SPEED = 9,
    56         USB_HUB_FEATURE_PORT_HIGH_SPEED = 10,
     57        USB2_HUB_FEATURE_PORT_LOW_SPEED = 9,
    5758        USB_HUB_FEATURE_C_PORT_CONNECTION = 16,
    58         USB_HUB_FEATURE_C_PORT_ENABLE = 17,
    59         USB_HUB_FEATURE_C_PORT_SUSPEND = 18,
     59        USB2_HUB_FEATURE_C_PORT_ENABLE = 17,
     60        USB2_HUB_FEATURE_C_PORT_SUSPEND = 18,
    6061        USB_HUB_FEATURE_C_PORT_OVER_CURRENT = 19,
    6162        USB_HUB_FEATURE_C_PORT_RESET = 20,
    62         USB_HUB_FEATURE_PORT_TEST = 21,
    63         USB_HUB_FEATURE_PORT_INDICATOR = 22
     63        USB2_HUB_FEATURE_PORT_TEST = 21,
     64        USB2_HUB_FEATURE_PORT_INDICATOR = 22,
     65        USB3_HUB_FEATURE_C_PORT_LINK_STATE = 25,
     66        USB3_HUB_FEATURE_BH_PORT_RESET = 28,
     67        USB3_HUB_FEATURE_C_BH_PORT_RESET = 29,
    6468        /* USB_HUB_FEATURE_ = , */
    6569} usb_hub_class_feature_t;
    6670
     71/**
     72 * Dword holding port status and changes flags.
     73 *
     74 * For more information refer to tables 11-15 and 11-16 in
     75 * "Universal Serial Bus Specification Revision 1.1" pages 274 and 277
     76 * (290 and 293 in pdf)
     77 *
     78 * Beware that definition of bits changed between USB 2 and 3,
     79 * so some fields are prefixed with USB2 or USB3 instead.
     80 */
     81typedef uint32_t usb_port_status_t;
     82
     83#define USB_HUB_PORT_STATUS_BIT(bit)  (uint32_usb2host(1 << (bit)))
     84#define USB_HUB_PORT_STATUS_CONNECTION          USB_HUB_PORT_STATUS_BIT(0)
     85#define USB_HUB_PORT_STATUS_ENABLE              USB_HUB_PORT_STATUS_BIT(1)
     86#define USB2_HUB_PORT_STATUS_SUSPEND            USB_HUB_PORT_STATUS_BIT(2)
     87#define USB_HUB_PORT_STATUS_OC                  USB_HUB_PORT_STATUS_BIT(3)
     88#define USB_HUB_PORT_STATUS_RESET               USB_HUB_PORT_STATUS_BIT(4)
     89
     90#define USB2_HUB_PORT_STATUS_POWER              USB_HUB_PORT_STATUS_BIT(8)
     91#define USB2_HUB_PORT_STATUS_LOW_SPEED          USB_HUB_PORT_STATUS_BIT(9)
     92#define USB3_HUB_PORT_STATUS_POWER              USB_HUB_PORT_STATUS_BIT(9)
     93#define USB2_HUB_PORT_STATUS_HIGH_SPEED         USB_HUB_PORT_STATUS_BIT(10)
     94#define USB2_HUB_PORT_STATUS_TEST               USB_HUB_PORT_STATUS_BIT(11)
     95#define USB2_HUB_PORT_STATUS_INDICATOR          USB_HUB_PORT_STATUS_BIT(12)
     96
     97#define USB_HUB_PORT_STATUS_C_CONNECTION        USB_HUB_PORT_STATUS_BIT(16)
     98#define USB2_HUB_PORT_STATUS_C_ENABLE           USB_HUB_PORT_STATUS_BIT(17)
     99#define USB2_HUB_PORT_STATUS_C_SUSPEND          USB_HUB_PORT_STATUS_BIT(18)
     100#define USB_HUB_PORT_STATUS_C_OC                USB_HUB_PORT_STATUS_BIT(19)
     101#define USB_HUB_PORT_STATUS_C_RESET             USB_HUB_PORT_STATUS_BIT(20)
     102#define USB3_HUB_PORT_STATUS_C_BH_RESET         USB_HUB_PORT_STATUS_BIT(21)
     103#define USB3_HUB_PORT_STATUS_C_LINK_STATE       USB_HUB_PORT_STATUS_BIT(22)
     104#define USB3_HUB_PORT_STATUS_C_CONFIG_ERROR     USB_HUB_PORT_STATUS_BIT(23)
    67105
    68106/** Header of standard hub descriptor without the "variadic" part. */
     
    71109        uint8_t length;
    72110
    73         /** Descriptor type (0x29). */
     111        /** Descriptor type (0x29 or 0x2a for superspeed hub). */
    74112        uint8_t descriptor_type;
    75113
     
    116154#define HUB_CHAR_OC_PER_PORT_FLAG       (1 << 3)
    117155#define HUB_CHAR_NO_OC_FLAG             (1 << 4)
     156
     157/* These are invalid for superspeed hub */
    118158#define HUB_CHAR_TT_THINK_16            (1 << 5)
    119159#define HUB_CHAR_TT_THINK_8             (1 << 6)
     
    138178         */
    139179        uint8_t max_current;
    140 } __attribute__ ((packed)) usb_hub_descriptor_header_t;
     180} __attribute__((packed)) usb_hub_descriptor_header_t;
    141181
    142182/** One bit for the device and one bit for every port */
    143183#define STATUS_BYTES(ports) ((1 + ports + 7) / 8)
    144184
    145 /**     @brief usb hub specific request types.
    146  *
    147  *      For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
     185/**
     186 * @brief usb hub specific request types.
    148187 */
    149188typedef enum {
    150     /** This request resets a value reported in the hub status. */
    151     USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
    152     /** This request resets a value reported in the port status. */
    153     USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
    154     /** This is an optional per-port diagnostic request that returns the bus state value, as sampled at the last EOF2 point. */
    155     USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
    156     /** This request returns the hub descriptor. */
    157     USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
    158     /** This request returns the current hub status and the states that have changed since the previous acknowledgment. */
    159     USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
    160     /** This request returns the current port status and the current value of the port status change bits. */
    161     USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
    162     /** This request overwrites the hub descriptor. */
    163     USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
    164     /** This request sets a value reported in the hub status. */
    165     USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
    166     /** This request sets a value reported in the port status. */
    167     USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23
     189        /** This request resets a value reported in the hub status. */
     190        USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
     191        /** This request resets a value reported in the port status. */
     192        USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
     193        /**
     194         * This is an optional per-port diagnostic request that returns the bus
     195         * state value, as sampled at the last EOF2 point.
     196         */
     197        USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
     198        /** This request returns the hub descriptor. */
     199        USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
     200        /**
     201         * This request returns the current hub status and the states that have
     202         * changed since the previous acknowledgment.
     203         */
     204        USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
     205        /**
     206         * This request returns the current port status and the current value of the
     207         * port status change bits.
     208         */
     209        USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
     210        /** This request overwrites the hub descriptor. */
     211        USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
     212        /** This request sets a value reported in the hub status. */
     213        USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
     214        /**
     215         * This request sets the value that the hub uses to determine the index
     216         * into the Route String Index for the hub.
     217         */
     218        USB_HUB_REQ_TYPE_SET_HUB_DEPTH = 0x20,
     219        /** This request sets a value reported in the port status. */
     220        USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23,
    168221} usb_hub_bm_request_type_t;
    169222
    170 /** @brief hub class request codes*/
    171 /// \TODO these are duplicit to standart descriptors
     223/**
     224 * @brief hub class request codes
     225 */
    172226typedef enum {
    173     /**  */
    174     USB_HUB_REQUEST_GET_STATUS = 0,
    175     /** */
    176     USB_HUB_REQUEST_CLEAR_FEATURE = 1,
    177     /** USB 1.0 only */
    178     USB_HUB_REQUEST_GET_STATE = 2,
    179     /** */
    180     USB_HUB_REQUEST_SET_FEATURE = 3,
    181     /** */
    182     USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
    183     /** */
    184     USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
    185     /** */
    186     USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8,
    187     /** */
    188     USB_HUB_REQUEST_RESET_TT = 9,
    189     /** */
    190     USB_HUB_GET_TT_STATE = 10,
    191     /** */
    192     USB_HUB_STOP_TT = 11,
     227        USB_HUB_REQUEST_GET_STATUS = 0,
     228        USB_HUB_REQUEST_CLEAR_FEATURE = 1,
     229        /** USB 1.0 only */
     230        USB_HUB_REQUEST_GET_STATE = 2,
     231        USB_HUB_REQUEST_SET_FEATURE = 3,
     232        USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
     233        USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
     234        USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8,
     235        USB_HUB_REQUEST_RESET_TT = 9,
     236        USB_HUB_GET_TT_STATE = 10,
     237        USB_HUB_STOP_TT = 11,
     238        /** USB 3+ only */
     239        USB_HUB_REQUEST_SET_HUB_DEPTH = 12,
    193240} usb_hub_request_t;
    194241
    195242/**
    196  *      Maximum size of usb hub descriptor in bytes
     243 * Maximum size of usb hub descriptor in bytes
    197244 */
    198245/* 7 (basic size) + 2*32 (port bitmasks) */
Note: See TracChangeset for help on using the changeset viewer.