123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542 |
- #ifndef _IPXE_EHCI_H
- #define _IPXE_EHCI_H
-
-
-
- FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
-
- #include <ipxe/pci.h>
- #include <ipxe/usb.h>
-
-
- #define EHCI_MIN_ALIGN 32
-
-
- #define EHCI_MTU 16384
-
-
- #define EHCI_PAGE_ALIGN 4096
-
-
- #define EHCI_BAR PCI_BASE_ADDRESS_0
-
-
- #define EHCI_CAP_CAPLENGTH 0x00
-
-
- #define EHCI_CAP_HCIVERSION 0x02
-
-
- #define EHCI_CAP_HCSPARAMS 0x04
-
-
- #define EHCI_HCSPARAMS_PORTS(params) ( ( (params) >> 0 ) & 0x0f )
-
-
- #define EHCI_CAP_HCCPARAMS 0x08
-
-
- #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_OP_USBCMD 0x00
-
-
- #define EHCI_USBCMD_RUN 0x00000001UL
-
-
- #define EHCI_USBCMD_HCRST 0x00000002UL
-
-
- #define EHCI_USBCMD_FLSIZE(flsize) ( (flsize) << 2 )
-
-
- #define EHCI_USBCMD_FLSIZE_MASK EHCI_USBCMD_FLSIZE ( 3 )
-
-
- #define EHCI_FLSIZE_DEFAULT 0
-
-
- #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_OP_USBSTS 0x04
-
-
- #define EHCI_USBSTS_USBINT 0x00000001UL
-
-
- #define EHCI_USBSTS_USBERRINT 0x00000002UL
-
-
- #define EHCI_USBSTS_PORT 0x00000004UL
-
-
- #define EHCI_USBSTS_ROLLOVER 0x00000008UL
-
-
- #define EHCI_USBSTS_SYSERR 0x00000010UL
-
-
- #define EHCI_USBSTS_ASYNC_ADVANCE 0x00000020UL
-
-
- #define EHCI_USBSTS_PERIODIC 0x00004000UL
-
-
- #define EHCI_USBSTS_ASYNC 0x00008000UL
-
-
- #define EHCI_USBSTS_HCH 0x00001000UL
-
-
- #define EHCI_USBSTS_CHANGE \
- ( EHCI_USBSTS_USBINT | EHCI_USBSTS_USBERRINT | \
- EHCI_USBSTS_PORT | EHCI_USBSTS_ROLLOVER | \
- EHCI_USBSTS_SYSERR | EHCI_USBSTS_ASYNC_ADVANCE )
-
-
- #define EHCI_OP_USBINTR 0x08
-
-
- #define EHCI_OP_FRINDEX 0x0c
-
-
- #define EHCI_OP_CTRLDSSEGMENT 0x10
-
-
- #define EHCI_OP_PERIODICLISTBASE 0x14
-
-
- #define EHCI_OP_ASYNCLISTADDR 0x18
-
-
- #define EHCI_OP_CONFIGFLAG 0x40
-
-
- #define EHCI_CONFIGFLAG_CF 0x00000001UL
-
-
- #define EHCI_OP_PORTSC(port) ( 0x40 + ( (port) << 2 ) )
-
-
- #define EHCI_PORTSC_CCS 0x00000001UL
-
-
- #define EHCI_PORTSC_CSC 0x00000002UL
-
-
- #define EHCI_PORTSC_PED 0x00000004UL
-
-
- #define EHCI_PORTSC_PEC 0x00000008UL
-
-
- #define EHCI_PORTSC_OCC 0x00000020UL
-
-
- #define EHCI_PORTSC_PR 0x00000100UL
-
-
- #define EHCI_PORTSC_LINE_STATUS(portsc) ( ( (portsc) >> 10 ) & 0x3 )
-
-
- #define EHCI_PORTSC_LINE_STATUS_LOW 0x1
-
-
- #define EHCI_PORTSC_PP 0x00001000UL
-
-
- #define EHCI_PORTSC_OWNER 0x00002000UL
-
-
- #define EHCI_PORTSC_CHANGE \
- ( EHCI_PORTSC_CSC | EHCI_PORTSC_PEC | EHCI_PORTSC_OCC )
-
-
- #define EHCI_LINK_TERMINATE 0x00000001UL
-
-
- #define EHCI_LINK_TYPE(type) ( (type) << 1 )
-
-
- #define EHCI_LINK_TYPE_QH EHCI_LINK_TYPE ( 1 )
-
-
- struct ehci_periodic_frame {
-
- uint32_t link;
- } __attribute__ (( packed ));
-
-
- struct ehci_transfer_descriptor {
-
- uint32_t next;
-
- uint32_t alt;
-
- uint8_t status;
-
- uint8_t flags;
-
- uint16_t len;
-
- uint32_t low[5];
-
- uint32_t high[5];
-
- uint8_t reserved[12];
- } __attribute__ (( packed ));
-
-
- #define EHCI_STATUS_XACT_ERR 0x08
-
-
- #define EHCI_STATUS_BABBLE 0x10
-
-
- #define EHCI_STATUS_BUFFER 0x20
-
-
- #define EHCI_STATUS_HALTED 0x40
-
-
- #define EHCI_STATUS_ACTIVE 0x80
-
-
- #define EHCI_FL_PID(code) ( (code) << 0 )
-
-
- #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( count ) ( (count) << 2 )
-
-
- #define EHCI_FL_CERR_MAX EHCI_FL_CERR ( 3 )
-
-
- #define EHCI_FL_IOC 0x80
-
-
- #define EHCI_LEN_MASK 0x7fff
-
-
- #define EHCI_LEN_TOGGLE 0x8000
-
-
- struct ehci_queue_head {
-
- uint32_t link;
-
- uint32_t chr;
-
- uint32_t cap;
-
- uint32_t current;
-
- struct ehci_transfer_descriptor cache;
- } __attribute__ (( packed ));
-
-
- #define EHCI_CHR_ADDRESS( address ) ( (address) << 0 )
-
-
- #define EHCI_CHR_ENDPOINT( address ) ( ( (address) & 0xf ) << 8 )
-
-
- #define EHCI_CHR_EPS( eps ) ( (eps) << 12 )
-
-
- #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_TOGGLE 0x00004000UL
-
-
- #define EHCI_CHR_HEAD 0x00008000UL
-
-
- #define EHCI_CHR_MAX_LEN( len ) ( (len) << 16 )
-
-
- #define EHCI_CHR_CONTROL 0x08000000UL
-
-
- #define EHCI_CAP_INTR_SCHED( uframe ) ( 1 << ( (uframe) + 0 ) )
-
-
- #define EHCI_CAP_SPLIT_SCHED( uframe ) ( 1 << ( (uframe) + 8 ) )
-
-
- #define EHCI_CAP_SPLIT_SCHED_DEFAULT \
- ( EHCI_CAP_SPLIT_SCHED ( 2 ) | EHCI_CAP_SPLIT_SCHED ( 3 ) | \
- EHCI_CAP_SPLIT_SCHED ( 4 ) | EHCI_CAP_SPLIT_SCHED ( 5 ) | \
- EHCI_CAP_SPLIT_SCHED ( 6 ) | EHCI_CAP_SPLIT_SCHED ( 7 ) )
-
-
- #define EHCI_CAP_TT_HUB( address ) ( (address) << 16 )
-
-
- #define EHCI_CAP_TT_PORT( port ) ( (port) << 23 )
-
-
- #define EHCI_CAP_MULT( mult ) ( (mult) << 30 )
-
-
- struct ehci_ring {
-
- unsigned int prod;
-
- unsigned int cons;
-
-
- size_t residual;
-
-
- struct io_buffer **iobuf;
-
-
- struct ehci_queue_head *head;
-
- struct ehci_transfer_descriptor *desc;
- };
-
-
- #define EHCI_RING_COUNT 64
-
-
- static inline __attribute__ (( always_inline )) unsigned int
- ehci_ring_fill ( struct ehci_ring *ring ) {
- unsigned int fill;
-
- fill = ( ring->prod - ring->cons );
- assert ( fill <= EHCI_RING_COUNT );
- return fill;
- }
-
-
- static inline __attribute__ (( always_inline )) unsigned int
- ehci_ring_remaining ( struct ehci_ring *ring ) {
- unsigned int fill = ehci_ring_fill ( ring );
-
- return ( EHCI_RING_COUNT - fill );
- }
-
-
- #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
-
-
- struct ehci_transfer {
-
- void *data;
-
- size_t len;
-
-
- unsigned int flags;
- };
-
-
- #define EHCI_FL_TOGGLE 0x8000
-
-
- struct ehci_device {
-
- void *regs;
-
-
- void *cap;
-
- void *op;
-
-
- unsigned int ports;
-
- int addr64;
-
- unsigned int flsize;
-
- unsigned int eecp;
-
-
- unsigned int legacy;
-
-
- uint32_t ctrldssegment;
-
- struct ehci_queue_head *head;
-
- struct ehci_periodic_frame *frame;
-
-
- struct list_head endpoints;
-
- struct list_head async;
-
-
- struct list_head periodic;
-
-
- struct usb_bus *bus;
- };
-
-
- struct ehci_endpoint {
-
- struct ehci_device *ehci;
-
- struct usb_endpoint *ep;
-
- struct list_head list;
-
- struct list_head schedule;
-
-
- struct ehci_ring ring;
- };
-
- extern unsigned int ehci_companion ( struct pci_device *pci );
-
- #endif
|