linux/include/uapi/linux/usb/ch11.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 * This file holds Hub protocol constants and data structures that are
 * defined in chapter 11 (Hub Specification) of the USB 2.0 specification.
 *
 * It is used/shared between the USB core, the HCDs and couple of other USB
 * drivers.
 */

#ifndef __LINUX_CH11_H
#define __LINUX_CH11_H

#include <linux/types.h>	/* __u8 etc */

/* This is arbitrary.
 * From USB 2.0 spec Table 11-13, offset 7, a hub can
 * have up to 255 ports. The most yet reported is 10.
 * Upcoming hardware might raise that limit.
 * Because the arrays need to add a bit for hub status data, we
 * use 31, so plus one evens out to four bytes.
 */
#define USB_MAXCHILDREN

/* See USB 3.1 spec Table 10-5 */
#define USB_SS_MAXPORTS

/*
 * Hub request types
 */

#define USB_RT_HUB
#define USB_RT_PORT

/*
 * Port status type for GetPortStatus requests added in USB 3.1
 * See USB 3.1 spec Table 10-12
 */
#define HUB_PORT_STATUS
#define HUB_PORT_PD_STATUS
#define HUB_EXT_PORT_STATUS

/*
 * Hub class requests
 * See USB 2.0 spec Table 11-16
 */
#define HUB_CLEAR_TT_BUFFER
#define HUB_RESET_TT
#define HUB_GET_TT_STATE
#define HUB_STOP_TT

/*
 * Hub class additional requests defined by USB 3.0 spec
 * See USB 3.0 spec Table 10-6
 */
#define HUB_SET_DEPTH
#define HUB_GET_PORT_ERR_COUNT

/*
 * Hub Class feature numbers
 * See USB 2.0 spec Table 11-17
 */
#define C_HUB_LOCAL_POWER
#define C_HUB_OVER_CURRENT

/*
 * Port feature numbers
 * See USB 2.0 spec Table 11-17
 */
#define USB_PORT_FEAT_CONNECTION
#define USB_PORT_FEAT_ENABLE
#define USB_PORT_FEAT_SUSPEND
#define USB_PORT_FEAT_OVER_CURRENT
#define USB_PORT_FEAT_RESET
#define USB_PORT_FEAT_L1
#define USB_PORT_FEAT_POWER
#define USB_PORT_FEAT_LOWSPEED
#define USB_PORT_FEAT_C_CONNECTION
#define USB_PORT_FEAT_C_ENABLE
#define USB_PORT_FEAT_C_SUSPEND
#define USB_PORT_FEAT_C_OVER_CURRENT
#define USB_PORT_FEAT_C_RESET
#define USB_PORT_FEAT_TEST
#define USB_PORT_FEAT_INDICATOR
#define USB_PORT_FEAT_C_PORT_L1

/*
 * Port feature selectors added by USB 3.0 spec.
 * See USB 3.0 spec Table 10-7
 */
#define USB_PORT_FEAT_LINK_STATE
#define USB_PORT_FEAT_U1_TIMEOUT
#define USB_PORT_FEAT_U2_TIMEOUT
#define USB_PORT_FEAT_C_PORT_LINK_STATE
#define USB_PORT_FEAT_C_PORT_CONFIG_ERROR
#define USB_PORT_FEAT_REMOTE_WAKE_MASK
#define USB_PORT_FEAT_BH_PORT_RESET
#define USB_PORT_FEAT_C_BH_PORT_RESET
#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT

#define USB_PORT_LPM_TIMEOUT(p)

/* USB 3.0 hub remote wake mask bits, see table 10-14 */
#define USB_PORT_FEAT_REMOTE_WAKE_CONNECT
#define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT
#define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT

/*
 * Hub Status and Hub Change results
 * See USB 2.0 spec Table 11-19 and Table 11-20
 * USB 3.1 extends the port status request and may return 4 additional bytes.
 * See USB 3.1 spec section 10.16.2.6 Table 10-12 and 10-15
 */
struct usb_port_status {} __attribute__ ((packed));

/*
 * wPortStatus bit field
 * See USB 2.0 spec Table 11-21
 */
#define USB_PORT_STAT_CONNECTION
#define USB_PORT_STAT_ENABLE
#define USB_PORT_STAT_SUSPEND
#define USB_PORT_STAT_OVERCURRENT
#define USB_PORT_STAT_RESET
#define USB_PORT_STAT_L1
/* bits 6 to 7 are reserved */
#define USB_PORT_STAT_POWER
#define USB_PORT_STAT_LOW_SPEED
#define USB_PORT_STAT_HIGH_SPEED
#define USB_PORT_STAT_TEST
#define USB_PORT_STAT_INDICATOR
/* bits 13 to 15 are reserved */

/*
 * Additions to wPortStatus bit field from USB 3.0
 * See USB 3.0 spec Table 10-10
 */
#define USB_PORT_STAT_LINK_STATE
#define USB_SS_PORT_STAT_POWER
#define USB_SS_PORT_STAT_SPEED
#define USB_PORT_STAT_SPEED_5GBPS
/* Valid only if port is enabled */
/* Bits that are the same from USB 2.0 */
#define USB_SS_PORT_STAT_MASK

/*
 * Definitions for PORT_LINK_STATE values
 * (bits 5-8) in wPortStatus
 */
#define USB_SS_PORT_LS_U0
#define USB_SS_PORT_LS_U1
#define USB_SS_PORT_LS_U2
#define USB_SS_PORT_LS_U3
#define USB_SS_PORT_LS_SS_DISABLED
#define USB_SS_PORT_LS_RX_DETECT
#define USB_SS_PORT_LS_SS_INACTIVE
#define USB_SS_PORT_LS_POLLING
#define USB_SS_PORT_LS_RECOVERY
#define USB_SS_PORT_LS_HOT_RESET
#define USB_SS_PORT_LS_COMP_MOD
#define USB_SS_PORT_LS_LOOPBACK

/*
 * wPortChange bit field
 * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
 * Bits 0 to 5 shown, bits 6 to 15 are reserved
 */
#define USB_PORT_STAT_C_CONNECTION
#define USB_PORT_STAT_C_ENABLE
#define USB_PORT_STAT_C_SUSPEND
#define USB_PORT_STAT_C_OVERCURRENT
#define USB_PORT_STAT_C_RESET
#define USB_PORT_STAT_C_L1
/*
 * USB 3.0 wPortChange bit fields
 * See USB 3.0 spec Table 10-11
 */
#define USB_PORT_STAT_C_BH_RESET
#define USB_PORT_STAT_C_LINK_STATE
#define USB_PORT_STAT_C_CONFIG_ERROR

/*
 * USB 3.1 dwExtPortStatus field masks
 * See USB 3.1 spec 10.16.2.6.3 Table 10-15
 */

#define USB_EXT_PORT_STAT_RX_SPEED_ID
#define USB_EXT_PORT_STAT_TX_SPEED_ID
#define USB_EXT_PORT_STAT_RX_LANES
#define USB_EXT_PORT_STAT_TX_LANES

#define USB_EXT_PORT_RX_LANES(p)
#define USB_EXT_PORT_TX_LANES(p)

/*
 * wHubCharacteristics (masks)
 * See USB 2.0 spec Table 11-13, offset 3
 */
#define HUB_CHAR_LPSM
#define HUB_CHAR_COMMON_LPSM
#define HUB_CHAR_INDV_PORT_LPSM
#define HUB_CHAR_NO_LPSM

#define HUB_CHAR_COMPOUND

#define HUB_CHAR_OCPM
#define HUB_CHAR_COMMON_OCPM
#define HUB_CHAR_INDV_PORT_OCPM
#define HUB_CHAR_NO_OCPM

#define HUB_CHAR_TTTT
#define HUB_CHAR_PORTIND

struct usb_hub_status {} __attribute__ ((packed));

/*
 * Hub Status & Hub Change bit masks
 * See USB 2.0 spec Table 11-19 and Table 11-20
 * Bits 0 and 1 for wHubStatus and wHubChange
 * Bits 2 to 15 are reserved for both
 */
#define HUB_STATUS_LOCAL_POWER
#define HUB_STATUS_OVERCURRENT
#define HUB_CHANGE_LOCAL_POWER
#define HUB_CHANGE_OVERCURRENT


/*
 * Hub descriptor
 * See USB 2.0 spec Table 11-13
 */

#define USB_DT_HUB
#define USB_DT_SS_HUB
#define USB_DT_HUB_NONVAR_SIZE
#define USB_DT_SS_HUB_SIZE

/*
 * Hub Device descriptor
 * USB Hub class device protocols
 */

#define USB_HUB_PR_FS
#define USB_HUB_PR_HS_NO_TT
#define USB_HUB_PR_HS_SINGLE_TT
#define USB_HUB_PR_HS_MULTI_TT
#define USB_HUB_PR_SS

struct usb_hub_descriptor {} __attribute__ ((packed));

/* port indicator status selectors, tables 11-7 and 11-25 */
#define HUB_LED_AUTO
#define HUB_LED_AMBER
#define HUB_LED_GREEN
#define HUB_LED_OFF

enum hub_led_mode {} __attribute__ ((packed));

/* Transaction Translator Think Times, in bits */
#define HUB_TTTT_8_BITS
#define HUB_TTTT_16_BITS
#define HUB_TTTT_24_BITS
#define HUB_TTTT_32_BITS

#endif /* __LINUX_CH11_H */