iPXE
Data Structures | Defines | Functions
usbhub.h File Reference

USB hubs. More...

#include <ipxe/usb.h>
#include <ipxe/list.h>
#include <ipxe/process.h>

Go to the source code of this file.

Data Structures

struct  usb_hub_descriptor_basic
 A basic USB hub descriptor. More...
struct  usb_hub_descriptor_enhanced
 An enhanced USB hub descriptor. More...
union  usb_hub_descriptor
 A USB hub descriptor. More...
struct  usb_hub_port_status
 Port status. More...
struct  usb_hub_device
 A USB hub device. More...

Defines

#define USB_HUB_RECIP_PORT   ( 3 << 0 )
 Request recipient is a port.
#define USB_HUB_DESCRIPTOR   41
 A basic USB hub descriptor.
#define USB_HUB_DESCRIPTOR_ENHANCED   42
 An enhanced USB hub descriptor.
#define USB_HUB_PORT_CONNECTION   0
 Current connect status feature.
#define USB_HUB_PORT_ENABLE   1
 Port enabled/disabled feature.
#define USB_HUB_PORT_RESET   4
 Port reset feature.
#define USB_HUB_PORT_POWER   8
 Port power feature.
#define USB_HUB_PORT_LOW_SPEED   9
 Low-speed device attached.
#define USB_HUB_PORT_HIGH_SPEED   10
 High-speed device attached.
#define USB_HUB_C_PORT_CONNECTION   16
 Connect status changed.
#define USB_HUB_C_PORT_ENABLE   17
 Port enable/disable changed.
#define USB_HUB_C_PORT_SUSPEND   18
 Suspend changed.
#define USB_HUB_C_PORT_OVER_CURRENT   19
 Over-current indicator changed.
#define USB_HUB_C_PORT_RESET   20
 Reset changed.
#define USB_HUB_C_PORT_LINK_STATE   25
 Link state changed.
#define USB_HUB_C_PORT_CONFIG_ERROR   26
 Configuration error.
#define USB_HUB_C_FEATURE(bit)   ( 16 + (bit) )
 Calculate feature from change bit number.
#define USB_HUB_FEATURES
 USB features.
#define USB_HUB_FEATURES_ENHANCED
 USB features for enhanced hubs.
#define USB_HUB_SET_HUB_DEPTH
 Set hub depth.
#define USB_HUB_CLEAR_TT_BUFFER
 Clear transaction translator buffer.
#define USB_HUB_TT_SINGLE   1
 Transaction translator port value for single-TT hubs.
#define USB_HUB_SLOW_START   0x0001
 Hub requires additional settling delay.
#define USB_HUB_SLOW_START_DELAY_MS   500
 Additional setting delay for out-of-spec hubs.
#define USB_HUB_INTR_FILL   4
 Interrupt ring fill level.
#define USB_HUB_ENABLE_MAX_WAIT_MS   100
 Maximum time to wait for port to become enabled.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int usb_hub_get_descriptor (struct usb_device *usb, int enhanced, union usb_hub_descriptor *data)
 Get hub descriptor.
static int usb_hub_get_port_status (struct usb_device *usb, unsigned int port, struct usb_hub_port_status *status)
 Get port status.
static int usb_hub_clear_port_feature (struct usb_device *usb, unsigned int port, unsigned int feature, unsigned int index)
 Clear port feature.
static int usb_hub_set_port_feature (struct usb_device *usb, unsigned int port, unsigned int feature, unsigned int index)
 Set port feature.
static int usb_hub_set_hub_depth (struct usb_device *usb, unsigned int depth)
 Set hub depth.
static int usb_hub_clear_tt_buffer (struct usb_device *usb, unsigned int device, unsigned int endpoint, unsigned int attributes, unsigned int tt_port)
 Clear transaction translator buffer.

Detailed Description

USB hubs.

Definition in file usbhub.h.


Define Documentation

#define USB_HUB_RECIP_PORT   ( 3 << 0 )

Request recipient is a port.

Definition at line 17 of file usbhub.h.

Referenced by usb_hub_clear_port_feature(), usb_hub_get_port_status(), and usb_hub_set_port_feature().

#define USB_HUB_DESCRIPTOR   41

A basic USB hub descriptor.

Definition at line 34 of file usbhub.h.

Referenced by usb_hub_get_descriptor().

#define USB_HUB_DESCRIPTOR_ENHANCED   42

An enhanced USB hub descriptor.

Definition at line 49 of file usbhub.h.

Referenced by usb_hub_get_descriptor().

#define USB_HUB_PORT_CONNECTION   0

Current connect status feature.

Definition at line 70 of file usbhub.h.

Referenced by hub_speed().

#define USB_HUB_PORT_ENABLE   1

Port enabled/disabled feature.

Definition at line 73 of file usbhub.h.

Referenced by hub_disable(), and hub_enable().

#define USB_HUB_PORT_RESET   4

Port reset feature.

Definition at line 76 of file usbhub.h.

Referenced by hub_enable().

#define USB_HUB_PORT_POWER   8

Port power feature.

Definition at line 79 of file usbhub.h.

Referenced by hub_open().

#define USB_HUB_PORT_LOW_SPEED   9

Low-speed device attached.

Definition at line 82 of file usbhub.h.

Referenced by hub_speed().

#define USB_HUB_PORT_HIGH_SPEED   10

High-speed device attached.

Definition at line 85 of file usbhub.h.

Referenced by hub_speed().

#define USB_HUB_C_PORT_CONNECTION   16

Connect status changed.

Definition at line 88 of file usbhub.h.

#define USB_HUB_C_PORT_ENABLE   17

Port enable/disable changed.

Definition at line 91 of file usbhub.h.

#define USB_HUB_C_PORT_SUSPEND   18

Suspend changed.

Definition at line 94 of file usbhub.h.

#define USB_HUB_C_PORT_OVER_CURRENT   19

Over-current indicator changed.

Definition at line 97 of file usbhub.h.

#define USB_HUB_C_PORT_RESET   20

Reset changed.

Definition at line 100 of file usbhub.h.

#define USB_HUB_C_PORT_LINK_STATE   25

Link state changed.

Definition at line 103 of file usbhub.h.

#define USB_HUB_C_PORT_CONFIG_ERROR   26

Configuration error.

Definition at line 106 of file usbhub.h.

#define USB_HUB_C_FEATURE (   bit)    ( 16 + (bit) )

Calculate feature from change bit number.

Definition at line 109 of file usbhub.h.

Referenced by hub_clear_changes().

Value:

USB features.

Definition at line 112 of file usbhub.h.

Referenced by hub_probe().

Value:

USB features for enhanced hubs.

Definition at line 120 of file usbhub.h.

Referenced by hub_probe().

Value:
( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE |             \
          USB_REQUEST_TYPE ( 12 ) )

Set hub depth.

Definition at line 128 of file usbhub.h.

Referenced by usb_hub_set_hub_depth().

Value:
( USB_DIR_OUT | USB_TYPE_CLASS | USB_HUB_RECIP_PORT |           \
          USB_REQUEST_TYPE ( 8 ) )

Clear transaction translator buffer.

Definition at line 133 of file usbhub.h.

Referenced by usb_hub_clear_tt_buffer().

#define USB_HUB_TT_SINGLE   1

Transaction translator port value for single-TT hubs.

Definition at line 248 of file usbhub.h.

Referenced by hub_clear_tt().

#define USB_HUB_SLOW_START   0x0001

Hub requires additional settling delay.

Definition at line 270 of file usbhub.h.

Referenced by hub_open().

#define USB_HUB_SLOW_START_DELAY_MS   500

Additional setting delay for out-of-spec hubs.

Definition at line 273 of file usbhub.h.

Referenced by hub_open().

#define USB_HUB_INTR_FILL   4

Interrupt ring fill level.

This is a policy decision.

Definition at line 279 of file usbhub.h.

Referenced by hub_probe().

#define USB_HUB_ENABLE_MAX_WAIT_MS   100

Maximum time to wait for port to become enabled.

This is a policy decision.

Definition at line 285 of file usbhub.h.

Referenced by hub_enable().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int usb_hub_get_descriptor ( struct usb_device usb,
int  enhanced,
union usb_hub_descriptor data 
) [inline, static]

Get hub descriptor.

Parameters:
usbUSB device
enhancedHub is an enhanced hub
dataHub descriptor to fill in
Return values:
rcReturn status code

Definition at line 146 of file usbhub.h.

References len, usb_get_descriptor(), USB_HUB_DESCRIPTOR, USB_HUB_DESCRIPTOR_ENHANCED, and USB_TYPE_CLASS.

Referenced by hub_probe().

                                                          {
        unsigned int desc;
        size_t len;

        /* Determine descriptor type and length */
        desc = ( enhanced ? USB_HUB_DESCRIPTOR_ENHANCED : USB_HUB_DESCRIPTOR );
        len = ( enhanced ? sizeof ( data->enhanced ) : sizeof ( data->basic ) );

        return usb_get_descriptor ( usb, USB_TYPE_CLASS, desc, 0, 0,
                                    &data->header, len );
}
static int usb_hub_get_port_status ( struct usb_device usb,
unsigned int  port,
struct usb_hub_port_status status 
) [inline, static]

Get port status.

Parameters:
usbUSB device
portPort address
statusPort status descriptor to fill in
Return values:
rcReturn status code

Definition at line 168 of file usbhub.h.

References usb_get_status(), USB_HUB_RECIP_PORT, and USB_TYPE_CLASS.

Referenced by hub_enable(), and hub_speed().

                                                               {

        return usb_get_status ( usb, ( USB_TYPE_CLASS | USB_HUB_RECIP_PORT ),
                                port, status, sizeof ( *status ) );
}
static int usb_hub_clear_port_feature ( struct usb_device usb,
unsigned int  port,
unsigned int  feature,
unsigned int  index 
) [inline, static]

Clear port feature.

Parameters:
usbUSB device
portPort address
featureFeature to clear
indexIndex (when clearing a port indicator)
Return values:
rcReturn status code

Definition at line 185 of file usbhub.h.

References usb_clear_feature(), USB_HUB_RECIP_PORT, and USB_TYPE_CLASS.

Referenced by hub_clear_changes(), and hub_disable().

                                                                        {

        return usb_clear_feature ( usb, ( USB_TYPE_CLASS | USB_HUB_RECIP_PORT ),
                                   feature, ( ( index << 8 ) | port ) );
}
static int usb_hub_set_port_feature ( struct usb_device usb,
unsigned int  port,
unsigned int  feature,
unsigned int  index 
) [inline, static]

Set port feature.

Parameters:
usbUSB device
portPort address
featureFeature to clear
indexIndex (when clearing a port indicator)
Return values:
rcReturn status code

Definition at line 202 of file usbhub.h.

References USB_HUB_RECIP_PORT, usb_set_feature(), and USB_TYPE_CLASS.

Referenced by hub_enable(), and hub_open().

                                                                      {

        return usb_set_feature ( usb, ( USB_TYPE_CLASS | USB_HUB_RECIP_PORT ),
                                 feature, ( ( index << 8 ) | port ) );
}
static int usb_hub_set_hub_depth ( struct usb_device usb,
unsigned int  depth 
) [inline, static]

Set hub depth.

Parameters:
usbUSB device
depthHub depth
Return values:
rcReturn status code

Definition at line 217 of file usbhub.h.

References NULL, usb_control(), and USB_HUB_SET_HUB_DEPTH.

Referenced by hub_probe().

                                                                     {

        return usb_control ( usb, USB_HUB_SET_HUB_DEPTH, depth, 0, NULL, 0 );
}
static int usb_hub_clear_tt_buffer ( struct usb_device usb,
unsigned int  device,
unsigned int  endpoint,
unsigned int  attributes,
unsigned int  tt_port 
) [inline, static]

Clear transaction translator buffer.

Parameters:
usbUSB device
deviceDevice address
endpointEndpoint address
attributesEndpoint attributes
tt_portTransaction translator port (or 1 for single-TT hubs)
Return values:
rcReturn status code

Definition at line 233 of file usbhub.h.

References NULL, usb_control(), USB_ENDPOINT_ATTR_TYPE_MASK, USB_ENDPOINT_IN, USB_ENDPOINT_MAX, USB_HUB_CLEAR_TT_BUFFER, and value.

Referenced by hub_clear_tt().

                                                 {
        unsigned int value;

        /* Calculate value */
        value = ( ( ( endpoint & USB_ENDPOINT_MAX ) << 0 ) | ( device << 4 ) |
                  ( ( attributes & USB_ENDPOINT_ATTR_TYPE_MASK ) << 11 ) |
                  ( ( endpoint & USB_ENDPOINT_IN ) << 8 ) );

        return usb_control ( usb, USB_HUB_CLEAR_TT_BUFFER, value,
                             tt_port, NULL, 0 );
}