31#define UHCI_BAR_SIZE 0x14
34#define UHCI_USBCMD 0x00
37#define UHCI_USBCMD_MAX64 0x0080
40#define UHCI_USBCMD_HCRESET 0x0002
43#define UHCI_USBCMD_RUN 0x0001
46#define UHCI_USBSTS 0x02
49#define UHCI_USBSTS_HCHALTED 0x0020
52#define UHCI_USBSTS_USBINT 0x0001
55#define UHCI_FLBASEADD 0x08
58#define UHCI_PORTSC(port) ( 0x0e + ( (port) << 1 ) )
61#define UHCI_PORTSC_PR 0x0200
64#define UHCI_PORTSC_LS 0x0100
67#define UHCI_PORTSC_PEC 0x0008
70#define UHCI_PORTSC_PED 0x0004
73#define UHCI_PORTSC_CSC 0x0002
76#define UHCI_PORTSC_CCS 0x0001
79#define UHCI_PORTSC_CHANGE ( UHCI_PORTSC_CSC | UHCI_PORTSC_PEC )
82#define UHCI_LINK_DEPTH_FIRST 0x00000004UL
85#define UHCI_LINK_TYPE_QH 0x00000002UL
88#define UHCI_LINK_TERMINATE 0x00000001UL
91#define UHCI_FRAMES 1024
116#define UHCI_LEN_MASK 0x7ff
119#define UHCI_ACTUAL_LEN( actual ) ( ( (actual) + 1 ) & UHCI_LEN_MASK )
122#define UHCI_STATUS_ACTIVE 0x80
125#define UHCI_STATUS_STALLED 0x40
128#define UHCI_STATUS_BUFFER 0x20
131#define UHCI_STATUS_BABBLE 0x10
134#define UHCI_STATUS_NAK 0x08
137#define UHCI_STATUS_CRC_TIMEOUT 0x04
140#define UHCI_STATUS_BITSTUFF 0x02
143#define UHCI_FL_SPD 0x20
146#define UHCI_FL_CERR( count ) ( (count) << 3 )
149#define UHCI_FL_CERR_MAX UHCI_FL_CERR ( 3 )
152#define UHCI_FL_LS 0x04
155#define UHCI_FL_IOC 0x01
158#define UHCI_CONTROL_PID( pid ) ( (pid) << 0 )
161#define UHCI_CONTROL_PID_MASK UHCI_CONTROL_PID ( 0xff )
164#define UHCI_CONTROL_DEVICE( address ) ( (address) << 8 )
167#define UHCI_CONTROL_ENDPOINT( address ) ( (address) << 15 )
170#define UHCI_CONTROL_TOGGLE ( 1 << 19 )
173#define UHCI_CONTROL_LEN( len ) ( ( ( (len) - 1 ) & UHCI_LEN_MASK ) << 21 )
180#define UHCI_DATA_PACKET( control ) ( ! ( control & 0x04 ) )
183#define UHCI_SHORT_PACKET( control, actual ) \
184 ( ( ( (control) >> 21 ) ^ (actual) ) & UHCI_LEN_MASK )
187#define UHCI_USBLEGSUP 0xc0
190#define UHCI_USBLEGSUP_DEFAULT 0x2000
229#define UHCI_RING_COUNT 16
293#define UHCI_STOP_MAX_WAIT_MS 100
299#define UHCI_RESET_MAX_WAIT_MS 500
305#define UHCI_PORT_ENABLE_MAX_WAIT_MS 500
#define assert(condition)
Assert a condition at run-time.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Universal Serial Bus (USB)
A doubly-linked list entry (or list head)
struct list_head async
Asynchronous schedule.
struct uhci_queue_head * head
Asynchronous queue head.
struct usb_bus * bus
USB bus.
struct list_head periodic
Periodic schedule.
struct list_head endpoints
List of all endpoints.
unsigned int companion
EHCI companion controller bus:dev.fn address (if any)
struct uhci_frame_list * frame
Frame list.
unsigned long regs
Registers.
struct usb_endpoint * ep
USB endpoint.
struct uhci_device * uhci
UHCI device.
struct uhci_ring ring
Transfer ring.
struct list_head schedule
Endpoint schedule.
struct list_head list
List of all endpoints.
uint32_t link[UHCI_FRAMES]
Link pointer.
uint32_t current
Current transfer descriptor.
uint32_t link
Horizontal link pointer.
unsigned int prod
Producer counter.
struct uhci_transfer * xfer[UHCI_RING_COUNT]
Transfers.
size_t mtu
Maximum packet length.
struct uhci_queue_head * head
Queue head.
uint32_t control
Base control word.
struct uhci_transfer * end
End of transfer ring (if non-empty)
unsigned int cons
Consumer counter.
uint32_t link
Link pointer.
uint32_t data
Buffer pointer.
uint16_t actual
Actual length.
struct uhci_transfer_descriptor * desc
Transfer descriptors.
size_t len
Completed data length.
unsigned int prod
Producer counter.
unsigned int cons
Consumer counter.
struct io_buffer * iobuf
I/O buffer.
static unsigned int uhci_ring_remaining(struct uhci_ring *ring)
Calculate space remaining in transfer ring.
#define UHCI_RING_COUNT
Number of transfer descriptors in a ring.
#define UHCI_FRAMES
Number of frames in frame list.
static unsigned int uhci_ring_fill(struct uhci_ring *ring)
Calculate space used in transfer ring.