iPXE
|
USB Enhanced Host Controller Interface (EHCI) driver. More...
Go to the source code of this file.
Data Structures | |
struct | ehci_periodic_frame |
A periodic frame list entry. More... | |
struct | ehci_transfer_descriptor |
A transfer descriptor. More... | |
struct | ehci_queue_head |
A queue head. More... | |
struct | ehci_ring |
A transfer descriptor ring. More... | |
struct | ehci_transfer |
An EHCI transfer. More... | |
struct | ehci_device |
An EHCI device. More... | |
struct | ehci_endpoint |
An EHCI endpoint. More... | |
Macros | |
#define | EHCI_MIN_ALIGN 32 |
Minimum alignment required for data structures. More... | |
#define | EHCI_MTU 16384 |
Maximum transfer size. More... | |
#define | EHCI_PAGE_ALIGN 4096 |
Page-alignment required for some data structures. More... | |
#define | EHCI_BAR PCI_BASE_ADDRESS_0 |
EHCI PCI BAR. More... | |
#define | EHCI_CAP_CAPLENGTH 0x00 |
Capability register length. More... | |
#define | EHCI_CAP_HCIVERSION 0x02 |
Host controller interface version number. More... | |
#define | EHCI_CAP_HCSPARAMS 0x04 |
Structural parameters. More... | |
#define | EHCI_HCSPARAMS_PORTS(params) ( ( (params) >> 0 ) & 0x0f ) |
Number of ports. More... | |
#define | EHCI_CAP_HCCPARAMS 0x08 |
Capability parameters. More... | |
#define | EHCI_HCCPARAMS_ADDR64(params) ( ( (params) >> 0 ) & 0x1 ) |
64-bit addressing capability More... | |
#define | EHCI_HCCPARAMS_FLSIZE(params) ( ( (params) >> 1 ) & 0x1 ) |
Programmable frame list flag. More... | |
#define | EHCI_HCCPARAMS_EECP(params) ( ( ( (params) >> 8 ) & 0xff ) ) |
EHCI extended capabilities pointer. More... | |
#define | EHCI_EECP_ID(eecp) ( ( (eecp) >> 0 ) & 0xff ) |
EHCI extended capability ID. More... | |
#define | EHCI_EECP_NEXT(eecp) ( ( ( (eecp) >> 8 ) & 0xff ) ) |
Next EHCI extended capability pointer. More... | |
#define | EHCI_EECP_ID_LEGACY 1 |
USB legacy support extended capability. More... | |
#define | EHCI_USBLEGSUP_BIOS 0x02 |
USB legacy support BIOS owned semaphore. More... | |
#define | EHCI_USBLEGSUP_BIOS_OWNED 0x01 |
USB legacy support BIOS ownership flag. More... | |
#define | EHCI_USBLEGSUP_OS 0x03 |
USB legacy support OS owned semaphore. More... | |
#define | EHCI_USBLEGSUP_OS_OWNED 0x01 |
USB legacy support OS ownership flag. More... | |
#define | EHCI_USBLEGSUP_CTLSTS 0x04 |
USB legacy support control/status. More... | |
#define | EHCI_OP_USBCMD 0x00 |
USB command register. More... | |
#define | EHCI_USBCMD_RUN 0x00000001UL |
Run/stop. More... | |
#define | EHCI_USBCMD_HCRST 0x00000002UL |
Host controller reset. More... | |
#define | EHCI_USBCMD_FLSIZE(flsize) ( (flsize) << 2 ) |
Frame list size. More... | |
#define | EHCI_USBCMD_FLSIZE_MASK EHCI_USBCMD_FLSIZE ( 3 ) |
Frame list size mask. More... | |
#define | EHCI_FLSIZE_DEFAULT 0 |
Default frame list size. More... | |
#define | EHCI_FLSIZE_SMALL 2 |
Smallest allowed frame list size. More... | |
#define | EHCI_PERIODIC_FRAMES(flsize) ( 1024 >> (flsize) ) |
Number of elements in frame list. More... | |
#define | EHCI_USBCMD_PERIODIC 0x00000010UL |
Periodic schedule enable. More... | |
#define | EHCI_USBCMD_ASYNC 0x00000020UL |
Asynchronous schedule enable. More... | |
#define | EHCI_USBCMD_ASYNC_ADVANCE 0x000040UL |
Asyncchronous schedule advance doorbell. More... | |
#define | EHCI_OP_USBSTS 0x04 |
USB status register. More... | |
#define | EHCI_USBSTS_USBINT 0x00000001UL |
USB interrupt. More... | |
#define | EHCI_USBSTS_USBERRINT 0x00000002UL |
USB error interrupt. More... | |
#define | EHCI_USBSTS_PORT 0x00000004UL |
Port change detect. More... | |
#define | EHCI_USBSTS_ROLLOVER 0x00000008UL |
Frame list rollover. More... | |
#define | EHCI_USBSTS_SYSERR 0x00000010UL |
Host system error. More... | |
#define | EHCI_USBSTS_ASYNC_ADVANCE 0x00000020UL |
Asynchronous schedule advanced. More... | |
#define | EHCI_USBSTS_PERIODIC 0x00004000UL |
Periodic schedule enabled. More... | |
#define | EHCI_USBSTS_ASYNC 0x00008000UL |
Asynchronous schedule enabled. More... | |
#define | EHCI_USBSTS_HCH 0x00001000UL |
Host controller halted. More... | |
#define | EHCI_USBSTS_CHANGE |
USB status change mask. More... | |
#define | EHCI_OP_USBINTR 0x08 |
USB interrupt enable register. More... | |
#define | EHCI_OP_FRINDEX 0x0c |
Frame index register. More... | |
#define | EHCI_OP_CTRLDSSEGMENT 0x10 |
Control data structure segment register. More... | |
#define | EHCI_OP_PERIODICLISTBASE 0x14 |
Periodic frame list base address register. More... | |
#define | EHCI_OP_ASYNCLISTADDR 0x18 |
Current asynchronous list address register. More... | |
#define | EHCI_OP_CONFIGFLAG 0x40 |
Configure flag register. More... | |
#define | EHCI_CONFIGFLAG_CF 0x00000001UL |
Configure flag. More... | |
#define | EHCI_OP_PORTSC(port) ( 0x40 + ( (port) << 2 ) ) |
Port status and control register. More... | |
#define | EHCI_PORTSC_CCS 0x00000001UL |
Current connect status. More... | |
#define | EHCI_PORTSC_CSC 0x00000002UL |
Connect status change. More... | |
#define | EHCI_PORTSC_PED 0x00000004UL |
Port enabled. More... | |
#define | EHCI_PORTSC_PEC 0x00000008UL |
Port enabled/disabled change. More... | |
#define | EHCI_PORTSC_OCC 0x00000020UL |
Over-current change. More... | |
#define | EHCI_PORTSC_PR 0x00000100UL |
Port reset. More... | |
#define | EHCI_PORTSC_LINE_STATUS(portsc) ( ( (portsc) >> 10 ) & 0x3 ) |
Line status. More... | |
#define | EHCI_PORTSC_LINE_STATUS_LOW 0x1 |
Line status: low-speed device. More... | |
#define | EHCI_PORTSC_PP 0x00001000UL |
Port power. More... | |
#define | EHCI_PORTSC_OWNER 0x00002000UL |
Port owner. More... | |
#define | EHCI_PORTSC_CHANGE ( EHCI_PORTSC_CSC | EHCI_PORTSC_PEC | EHCI_PORTSC_OCC ) |
Port status change mask. More... | |
#define | EHCI_LINK_TERMINATE 0x00000001UL |
List terminator. More... | |
#define | EHCI_LINK_TYPE(type) ( (type) << 1 ) |
Frame list type. More... | |
#define | EHCI_LINK_TYPE_QH EHCI_LINK_TYPE ( 1 ) |
Queue head type. More... | |
#define | EHCI_STATUS_XACT_ERR 0x08 |
Transaction error. More... | |
#define | EHCI_STATUS_BABBLE 0x10 |
Babble detected. More... | |
#define | EHCI_STATUS_BUFFER 0x20 |
Data buffer error. More... | |
#define | EHCI_STATUS_HALTED 0x40 |
Halted. More... | |
#define | EHCI_STATUS_ACTIVE 0x80 |
Active. More... | |
#define | EHCI_FL_PID(code) ( (code) << 0 ) |
PID code. More... | |
#define | EHCI_FL_PID_OUT EHCI_FL_PID ( 0 ) |
OUT token. More... | |
#define | EHCI_FL_PID_IN EHCI_FL_PID ( 1 ) |
IN token. More... | |
#define | EHCI_FL_PID_SETUP EHCI_FL_PID ( 2 ) |
SETUP token. More... | |
#define | EHCI_FL_CERR(count) ( (count) << 2 ) |
Error counter. More... | |
#define | EHCI_FL_CERR_MAX EHCI_FL_CERR ( 3 ) |
Error counter maximum value. More... | |
#define | EHCI_FL_IOC 0x80 |
Interrupt on completion. More... | |
#define | EHCI_LEN_MASK 0x7fff |
Length mask. More... | |
#define | EHCI_LEN_TOGGLE 0x8000 |
Data toggle. More... | |
#define | EHCI_CHR_ADDRESS(address) ( (address) << 0 ) |
Device address. More... | |
#define | EHCI_CHR_ENDPOINT(address) ( ( (address) & 0xf ) << 8 ) |
Endpoint number. More... | |
#define | EHCI_CHR_EPS(eps) ( (eps) << 12 ) |
Endpoint speed. More... | |
#define | EHCI_CHR_EPS_FULL EHCI_CHR_EPS ( 0 ) |
Full-speed endpoint. More... | |
#define | EHCI_CHR_EPS_LOW EHCI_CHR_EPS ( 1 ) |
Low-speed endpoint. More... | |
#define | EHCI_CHR_EPS_HIGH EHCI_CHR_EPS ( 2 ) |
High-speed endpoint. More... | |
#define | EHCI_CHR_TOGGLE 0x00004000UL |
Explicit data toggles. More... | |
#define | EHCI_CHR_HEAD 0x00008000UL |
Head of reclamation list flag. More... | |
#define | EHCI_CHR_MAX_LEN(len) ( (len) << 16 ) |
Maximum packet length. More... | |
#define | EHCI_CHR_CONTROL 0x08000000UL |
Control endpoint flag. More... | |
#define | EHCI_CAP_INTR_SCHED(uframe) ( 1 << ( (uframe) + 0 ) ) |
Interrupt schedule mask. More... | |
#define | EHCI_CAP_SPLIT_SCHED(uframe) ( 1 << ( (uframe) + 8 ) ) |
Split completion schedule mask. More... | |
#define | EHCI_CAP_SPLIT_SCHED_DEFAULT |
Default split completion schedule mask. More... | |
#define | EHCI_CAP_TT_HUB(address) ( (address) << 16 ) |
Transaction translator hub address. More... | |
#define | EHCI_CAP_TT_PORT(port) ( (port) << 23 ) |
Transaction translator port number. More... | |
#define | EHCI_CAP_MULT(mult) ( (mult) << 30 ) |
High-bandwidth pipe multiplier. More... | |
#define | EHCI_RING_COUNT 64 |
Number of transfer descriptors in a ring. More... | |
#define | EHCI_PORT_POWER_DELAY_MS 20 |
Time to delay after enabling power to a port. More... | |
#define | EHCI_DISOWN_DELAY_MS 100 |
Time to delay after releasing ownership of a port. More... | |
#define | EHCI_USBLEGSUP_MAX_WAIT_MS 100 |
Maximum time to wait for BIOS to release ownership. More... | |
#define | EHCI_ASYNC_ADVANCE_MAX_WAIT_MS 100 |
Maximum time to wait for asynchronous schedule to advance. More... | |
#define | EHCI_STOP_MAX_WAIT_MS 100 |
Maximum time to wait for host controller to stop. More... | |
#define | EHCI_RESET_MAX_WAIT_MS 500 |
Maximum time to wait for reset to complete. More... | |
#define | EHCI_PORT_RESET_MAX_WAIT_MS 500 |
Maximum time to wait for a port reset to complete. More... | |
#define | EHCI_FL_TOGGLE 0x8000 |
Set initial data toggle. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static unsigned int | ehci_ring_fill (struct ehci_ring *ring) |
Calculate space used in transfer descriptor ring. More... | |
static unsigned int | ehci_ring_remaining (struct ehci_ring *ring) |
Calculate space remaining in transfer descriptor ring. More... | |
unsigned int | ehci_companion (struct pci_device *pci) |
Locate EHCI companion controller. More... | |
USB Enhanced Host Controller Interface (EHCI) driver.
Definition in file ehci.h.
#define EHCI_MIN_ALIGN 32 |
Minimum alignment required for data structures.
With the exception of the periodic frame list (which is page-aligned), data structures used by EHCI generally require 32-byte alignment and must not cross a 4kB page boundary. We simplify this requirement by aligning each structure on its own size, with a minimum of a 32 byte alignment.
#define EHCI_MTU 16384 |
#define EHCI_PAGE_ALIGN 4096 |
#define EHCI_BAR PCI_BASE_ADDRESS_0 |
#define EHCI_CAP_HCIVERSION 0x02 |
#define EHCI_HCSPARAMS_PORTS | ( | params | ) | ( ( (params) >> 0 ) & 0x0f ) |
#define EHCI_HCCPARAMS_ADDR64 | ( | params | ) | ( ( (params) >> 0 ) & 0x1 ) |
#define EHCI_HCCPARAMS_FLSIZE | ( | params | ) | ( ( (params) >> 1 ) & 0x1 ) |
#define EHCI_HCCPARAMS_EECP | ( | params | ) | ( ( ( (params) >> 8 ) & 0xff ) ) |
#define EHCI_EECP_ID | ( | eecp | ) | ( ( (eecp) >> 0 ) & 0xff ) |
#define EHCI_EECP_NEXT | ( | eecp | ) | ( ( ( (eecp) >> 8 ) & 0xff ) ) |
#define EHCI_EECP_ID_LEGACY 1 |
#define EHCI_USBLEGSUP_BIOS 0x02 |
#define EHCI_USBLEGSUP_BIOS_OWNED 0x01 |
#define EHCI_USBLEGSUP_OS 0x03 |
#define EHCI_USBLEGSUP_OS_OWNED 0x01 |
#define EHCI_USBLEGSUP_CTLSTS 0x04 |
#define EHCI_USBCMD_FLSIZE | ( | flsize | ) | ( (flsize) << 2 ) |
#define EHCI_USBCMD_FLSIZE_MASK EHCI_USBCMD_FLSIZE ( 3 ) |
#define EHCI_FLSIZE_SMALL 2 |
#define EHCI_PERIODIC_FRAMES | ( | flsize | ) | ( 1024 >> (flsize) ) |
#define EHCI_USBCMD_PERIODIC 0x00000010UL |
#define EHCI_USBCMD_ASYNC 0x00000020UL |
#define EHCI_USBCMD_ASYNC_ADVANCE 0x000040UL |
#define EHCI_USBSTS_USBERRINT 0x00000002UL |
#define EHCI_USBSTS_ROLLOVER 0x00000008UL |
#define EHCI_USBSTS_ASYNC_ADVANCE 0x00000020UL |
#define EHCI_USBSTS_PERIODIC 0x00004000UL |
#define EHCI_USBSTS_ASYNC 0x00008000UL |
#define EHCI_USBSTS_CHANGE |
USB status change mask.
#define EHCI_OP_CTRLDSSEGMENT 0x10 |
#define EHCI_OP_PERIODICLISTBASE 0x14 |
#define EHCI_OP_ASYNCLISTADDR 0x18 |
#define EHCI_OP_PORTSC | ( | port | ) | ( 0x40 + ( (port) << 2 ) ) |
#define EHCI_PORTSC_PEC 0x00000008UL |
#define EHCI_PORTSC_LINE_STATUS | ( | portsc | ) | ( ( (portsc) >> 10 ) & 0x3 ) |
#define EHCI_PORTSC_LINE_STATUS_LOW 0x1 |
#define EHCI_PORTSC_CHANGE ( EHCI_PORTSC_CSC | EHCI_PORTSC_PEC | EHCI_PORTSC_OCC ) |
#define EHCI_LINK_TYPE_QH EHCI_LINK_TYPE ( 1 ) |
#define EHCI_FL_PID_OUT EHCI_FL_PID ( 0 ) |
#define EHCI_FL_PID_IN EHCI_FL_PID ( 1 ) |
#define EHCI_FL_PID_SETUP EHCI_FL_PID ( 2 ) |
#define EHCI_FL_CERR_MAX EHCI_FL_CERR ( 3 ) |
#define EHCI_CHR_EPS_FULL EHCI_CHR_EPS ( 0 ) |
#define EHCI_CHR_EPS_LOW EHCI_CHR_EPS ( 1 ) |
#define EHCI_CHR_EPS_HIGH EHCI_CHR_EPS ( 2 ) |
#define EHCI_CHR_HEAD 0x00008000UL |
#define EHCI_CAP_INTR_SCHED | ( | uframe | ) | ( 1 << ( (uframe) + 0 ) ) |
#define EHCI_CAP_SPLIT_SCHED | ( | uframe | ) | ( 1 << ( (uframe) + 8 ) ) |
#define EHCI_CAP_SPLIT_SCHED_DEFAULT |
Default split completion schedule mask.
We schedule all split starts in microframe 0, on the assumption that we will never have to deal with more than sixteen actively interrupting devices via the same transaction translator. We schedule split completions for all remaining microframes after microframe 1 (in which the low-speed or full-speed transaction is assumed to execute). This is a very crude approximation designed to avoid the need for calculating exactly when low-speed and full-speed transactions will execute. Since we only ever deal with interrupt endpoints (rather than isochronous endpoints), the volume of periodic traffic is extremely low, and this approximation should remain valid.
#define EHCI_CAP_MULT | ( | mult | ) | ( (mult) << 30 ) |
#define EHCI_RING_COUNT 64 |
#define EHCI_PORT_POWER_DELAY_MS 20 |
#define EHCI_DISOWN_DELAY_MS 100 |
#define EHCI_USBLEGSUP_MAX_WAIT_MS 100 |
#define EHCI_ASYNC_ADVANCE_MAX_WAIT_MS 100 |
#define EHCI_STOP_MAX_WAIT_MS 100 |
#define EHCI_RESET_MAX_WAIT_MS 500 |
#define EHCI_PORT_RESET_MAX_WAIT_MS 500 |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
Calculate space used in transfer descriptor ring.
ring | Transfer descriptor ring |
fill | Number of entries used |
Definition at line 400 of file ehci.h.
References assert(), ehci_ring::cons, EHCI_RING_COUNT, fill, and ehci_ring::prod.
Referenced by ehci_dequeue(), ehci_endpoint_close(), ehci_endpoint_poll(), ehci_ring_free(), and ehci_ring_remaining().
|
inlinestatic |
Calculate space remaining in transfer descriptor ring.
ring | Transfer descriptor ring |
remaining | Number of entries remaining |
Definition at line 415 of file ehci.h.
References EHCI_RING_COUNT, ehci_ring_fill(), and fill.
Referenced by ehci_enqueue().
unsigned int ehci_companion | ( | struct pci_device * | pci | ) |
Locate EHCI companion controller.
pci | PCI device |
busdevfn | EHCI companion controller bus:dev.fn (if any) |
Definition at line 420 of file ehci.c.
References busdevfn, pci_device::busdevfn, PCI_CLASS, PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB, PCI_CLASS_SERIAL_USB_EHCI, pci_init(), PCI_LAST_FUNC, pci_read_config(), rc, and tmp.