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/descriptor.h

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2010 Vojtech Horky
     3 * Copyright (c) 2018 Michal Staruch, Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    4950        USB_DESCTYPE_OTHER_SPEED_CONFIGURATION = 7,
    5051        USB_DESCTYPE_INTERFACE_POWER = 8,
     52        /* USB 3.0 types */
     53        USB_DESCTYPE_OTG = 9,
     54        USB_DESCTYPE_DEBUG = 0xa,
     55        USB_DESCTYPE_IFACE_ASSOC = 0xb,
     56        USB_DESCTYPE_BOS = 0xf,
     57        USB_DESCTYPE_DEVICE_CAP = 0x10,
    5158        /* Class specific */
    5259        USB_DESCTYPE_HID = 0x21,
     
    5461        USB_DESCTYPE_HID_PHYSICAL = 0x23,
    5562        USB_DESCTYPE_HUB = 0x29,
     63        USB_DESCTYPE_SSPEED_HUB = 0x2a,
     64        USB_DESCTYPE_SSPEED_EP_COMPANION = 0x30
    5665        /* USB_DESCTYPE_ = */
    5766} usb_descriptor_type_t;
     
    92101        /** Number of possible configurations. */
    93102        uint8_t configuration_count;
    94 } __attribute__ ((packed)) usb_standard_device_descriptor_t;
     103} __attribute__((packed)) usb_standard_device_descriptor_t;
    95104
    96105/** USB device qualifier decriptor is basically a cut down version of the device
     
    120129        uint8_t configuration_count;
    121130        uint8_t reserved;
    122 } __attribute__ ((packed)) usb_standard_device_qualifier_descriptor_t;
     131} __attribute__((packed)) usb_standard_device_qualifier_descriptor_t;
    123132
    124133/** Standard USB configuration descriptor.
     
    147156         */
    148157        uint8_t max_power;
    149 } __attribute__ ((packed)) usb_standard_configuration_descriptor_t;
     158} __attribute__((packed)) usb_standard_configuration_descriptor_t;
    150159
    151160/** USB Other Speed Configuration descriptor shows values that would change
     
    182191        /** String descriptor describing this interface. */
    183192        uint8_t str_interface;
    184 } __attribute__ ((packed)) usb_standard_interface_descriptor_t;
     193} __attribute__((packed)) usb_standard_interface_descriptor_t;
    185194
    186195/** Standard USB endpoint descriptor.
     
    193202        /** Endpoint address together with data flow direction. */
    194203        uint8_t endpoint_address;
     204#define USB_ED_GET_EP(ed)       ((ed).endpoint_address & 0xf)
     205#define USB_ED_GET_DIR(ed)      (!(((ed).endpoint_address >> 7) & 0x1))
     206
    195207        /** Endpoint attributes.
    196208         * Includes transfer type (usb_transfer_type_t).
    197209         */
    198210        uint8_t attributes;
     211#define USB_ED_GET_TRANSFER_TYPE(ed)    ((ed).attributes & 0x3)
    199212        /** Maximum packet size.
    200213         * Lower 10 bits represent the actuall size
     
    202215         * HS INT and ISO transfers. */
    203216        uint16_t max_packet_size;
    204 
    205 #define ED_MPS_PACKET_SIZE_MASK  0x3ff
    206 #define ED_MPS_PACKET_SIZE_GET(value) \
    207         ((value) & ED_MPS_PACKET_SIZE_MASK)
    208 #define ED_MPS_TRANS_OPPORTUNITIES_GET(value) \
    209         ((((value) >> 10) & 0x3) + 1)
    210 
    211         /** Polling interval in milliseconds.
    212          * Ignored for bulk and control endpoints.
    213          * Isochronous endpoints must use value 1.
    214          * Interrupt endpoints any value from 1 to 255.
     217#define USB_ED_GET_MPS(ed) \
     218        (uint16_usb2host((ed).max_packet_size) & 0x7ff)
     219#define USB_ED_GET_ADD_OPPS(ed) \
     220        ((uint16_usb2host((ed).max_packet_size) >> 11) & 0x3)
     221        /** Polling interval. Different semantics for various (speed, type)
     222         * pairs.
    215223         */
    216224        uint8_t poll_interval;
    217 } __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;
     225} __attribute__((packed)) usb_standard_endpoint_descriptor_t;
     226
     227/** Superspeed USB endpoint companion descriptor.
     228 * See USB 3 specification, section 9.6.7.
     229 */
     230typedef struct {
     231        /** Size of this descriptor in bytes */
     232        uint8_t length;
     233        /** Descriptor type (USB_DESCTYPE_SSPEED_EP_COMPANION). */
     234        uint8_t descriptor_type;
     235        /** The maximum number of packets the endpoint can send
     236         * or receive as part of a burst. Valid values are from 0 to 15.
     237         * The endpoint can only burst max_burst + 1 packets at a time.
     238         */
     239        uint8_t max_burst;
     240        /** Valid only for bulk and isochronous endpoints.
     241         * For bulk endpoints, this field contains the amount of streams
     242         * supported by the endpoint.
     243         * For isochronous endpoints, this field contains maximum
     244         * number of packets supported within a service interval.
     245         * Warning: the values returned by macros may not make any sense
     246         * for specific endpoint types.
     247         */
     248        uint8_t attributes;
     249#define USB_SSC_MAX_STREAMS(sscd) ((sscd).attributes & 0x1f)
     250#define USB_SSC_MULT(sscd) ((sscd).attributes & 0x3)
     251        /** The total number of bytes this endpoint will transfer
     252         * every service interval (SI).
     253         * This field is only valid for periodic endpoints.
     254         */
     255        uint16_t bytes_per_interval;
     256} __attribute__((packed)) usb_superspeed_endpoint_companion_descriptor_t;
    218257
    219258/** Part of standard USB HID descriptor specifying one class descriptor.
     
    226265        /** Length of class-specific descriptor in bytes. */
    227266        uint16_t length;
    228 } __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t;
     267} __attribute__((packed)) usb_standard_hid_class_descriptor_info_t;
    229268
    230269/** Standard USB HID descriptor.
     
    257296        /** First mandatory class descriptor (Report) info. */
    258297        usb_standard_hid_class_descriptor_info_t report_desc_info;
    259 } __attribute__ ((packed)) usb_standard_hid_descriptor_t;
     298} __attribute__((packed)) usb_standard_hid_descriptor_t;
    260299
    261300#endif
Note: See TracChangeset for help on using the changeset viewer.