Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/status.h

    rcd3fa47 r78188e5  
    3838
    3939/**
     40 * structure holding port status and changes flags.
     41 * should not be accessed directly, use supplied getter/setter methods.
     42 *
     43 * For more information refer to tables 11-15 and 11-16 in
     44 * "Universal Serial Bus Specification Revision 1.1" pages 274 and 277
     45 * (290 and 293 in pdf)
     46 *
     47 */
     48typedef uint32_t usb_port_status_t;
     49#define USB_HUB_PORT_STATUS_CONNECTION \
     50    (uint32_usb2host(1 << (USB_HUB_FEATURE_PORT_CONNECTION)))
     51#define USB_HUB_PORT_STATUS_ENABLED \
     52    (uint32_usb2host(1 << (USB_HUB_FEATURE_PORT_ENABLE)))
     53#define USB_HUB_PORT_STATUS_SUSPEND \
     54    (uint32_usb2host(1 << (USB_HUB_FEATURE_PORT_SUSPEND)))
     55#define USB_HUB_PORT_STATUS_OC \
     56    (uint32_usb2host(1 << (USB_HUB_FEATURE_PORT_OVER_CURRENT)))
     57#define USB_HUB_PORT_STATUS_RESET \
     58    (uint32_usb2host(1 << (USB_HUB_FEATURE_PORT_RESET)))
     59#define USB_HUB_PORT_STATUS_POWER \
     60    (uint32_usb2host(1 << (USB_HUB_FEATURE_PORT_POWER)))
     61#define USB_HUB_PORT_STATUS_LOW_SPEED \
     62    (uint32_usb2host(1 << (USB_HUB_FEATURE_PORT_LOW_SPEED)))
     63#define USB_HUB_PORT_STATUS_HIGH_SPEED \
     64    (uint32_usb2host(1 << 10))
     65#define USB_HUB_PORT_STATUS_TEST_MODE \
     66    (uint32_usb2host(1 << 11))
     67#define USB_HUB_PORT_INDICATOR_CONTROL \
     68    (uint32_usb2host(1 << 12))
     69
     70#define USB_HUB_PORT_C_STATUS_CONNECTION \
     71    (uint32_usb2host(1 << (USB_HUB_FEATURE_C_PORT_CONNECTION)))
     72#define USB_HUB_PORT_C_STATUS_ENABLED \
     73    (uint32_usb2host(1 << (USB_HUB_FEATURE_C_PORT_ENABLE)))
     74#define USB_HUB_PORT_C_STATUS_SUSPEND \
     75    (uint32_usb2host(1 << (USB_HUB_FEATURE_C_PORT_SUSPEND)))
     76#define USB_HUB_PORT_C_STATUS_OC \
     77    (uint32_usb2host(1 << (USB_HUB_FEATURE_C_PORT_OVER_CURRENT)))
     78#define USB_HUB_PORT_C_STATUS_RESET \
     79    (uint32_usb2host(1 << (USB_HUB_FEATURE_C_PORT_RESET)))
     80
     81/**
    4082 * structure holding hub status and changes flags.
    4183 *
     
    5597    (uint32_usb2host(1 << (16 + USB_HUB_FEATURE_C_HUB_LOCAL_POWER)))
    5698
    57 static inline usb_speed_t usb_port_speed(usb_speed_t hub_speed, uint32_t status)
     99
     100/**
     101 * speed getter for port status
     102 *
     103 * @param status
     104 * @return speed of usb device (for more see usb specification)
     105 */
     106static inline usb_speed_t usb_port_speed(usb_port_status_t status)
    58107{
    59         if (hub_speed == USB_SPEED_SUPER)
    60                 return USB_SPEED_SUPER;
    61         if (hub_speed == USB_SPEED_HIGH && (status & USB2_HUB_PORT_STATUS_HIGH_SPEED))
     108        if ((status & USB_HUB_PORT_STATUS_LOW_SPEED) != 0)
     109                return USB_SPEED_LOW;
     110        if ((status & USB_HUB_PORT_STATUS_HIGH_SPEED) != 0)
    62111                return USB_SPEED_HIGH;
    63         if ((status & USB2_HUB_PORT_STATUS_LOW_SPEED) != 0)
    64                 return USB_SPEED_LOW;
    65112        return USB_SPEED_FULL;
    66113}
Note: See TracChangeset for help on using the changeset viewer.