ehci.h
来自「linux 内核源代码」· C头文件 代码 · 共 822 行 · 第 1/2 页
H
822 行
union ehci_shadow { struct ehci_qh *qh; /* Q_TYPE_QH */ struct ehci_itd *itd; /* Q_TYPE_ITD */ struct ehci_sitd *sitd; /* Q_TYPE_SITD */ struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ __hc32 *hw_next; /* (all types) */ void *ptr;};/*-------------------------------------------------------------------------*//* * EHCI Specification 0.95 Section 3.6 * QH: describes control/bulk/interrupt endpoints * See Fig 3-7 "Queue Head Structure Layout". * * These appear in both the async and (for interrupt) periodic schedules. */struct ehci_qh { /* first part defined by EHCI spec */ __hc32 hw_next; /* see EHCI 3.6.1 */ __hc32 hw_info1; /* see EHCI 3.6.2 */#define QH_HEAD 0x00008000 __hc32 hw_info2; /* see EHCI 3.6.2 */#define QH_SMASK 0x000000ff#define QH_CMASK 0x0000ff00#define QH_HUBADDR 0x007f0000#define QH_HUBPORT 0x3f800000#define QH_MULT 0xc0000000 __hc32 hw_current; /* qtd list - see EHCI 3.6.4 */ /* qtd overlay (hardware parts of a struct ehci_qtd) */ __hc32 hw_qtd_next; __hc32 hw_alt_next; __hc32 hw_token; __hc32 hw_buf [5]; __hc32 hw_buf_hi [5]; /* the rest is HCD-private */ dma_addr_t qh_dma; /* address of qh */ union ehci_shadow qh_next; /* ptr to qh; or periodic */ struct list_head qtd_list; /* sw qtd list */ struct ehci_qtd *dummy; struct ehci_qh *reclaim; /* next to reclaim */ struct ehci_hcd *ehci; /* * Do NOT use atomic operations for QH refcounting. On some CPUs * (PPC7448 for example), atomic operations cannot be performed on * memory that is cache-inhibited (i.e. being used for DMA). * Spinlocks are used to protect all QH fields. */ u32 refcount; unsigned stamp; u8 qh_state;#define QH_STATE_LINKED 1 /* HC sees this */#define QH_STATE_UNLINK 2 /* HC may still see this */#define QH_STATE_IDLE 3 /* HC doesn't see this */#define QH_STATE_UNLINK_WAIT 4 /* LINKED and on reclaim q */#define QH_STATE_COMPLETING 5 /* don't touch token.HALT */ /* periodic schedule info */ u8 usecs; /* intr bandwidth */ u8 gap_uf; /* uframes split/csplit gap */ u8 c_usecs; /* ... split completion bw */ u16 tt_usecs; /* tt downstream bandwidth */ unsigned short period; /* polling interval */ unsigned short start; /* where polling starts */#define NO_FRAME ((unsigned short)~0) /* pick new start */ struct usb_device *dev; /* access to TT */} __attribute__ ((aligned (32)));/*-------------------------------------------------------------------------*//* description of one iso transaction (up to 3 KB data if highspeed) */struct ehci_iso_packet { /* These will be copied to iTD when scheduling */ u64 bufp; /* itd->hw_bufp{,_hi}[pg] |= */ __hc32 transaction; /* itd->hw_transaction[i] |= */ u8 cross; /* buf crosses pages */ /* for full speed OUT splits */ u32 buf1;};/* temporary schedule data for packets from iso urbs (both speeds) * each packet is one logical usb transaction to the device (not TT), * beginning at stream->next_uframe */struct ehci_iso_sched { struct list_head td_list; unsigned span; struct ehci_iso_packet packet [0];};/* * ehci_iso_stream - groups all (s)itds for this endpoint. * acts like a qh would, if EHCI had them for ISO. */struct ehci_iso_stream { /* first two fields match QH, but info1 == 0 */ __hc32 hw_next; __hc32 hw_info1; u32 refcount; u8 bEndpointAddress; u8 highspeed; u16 depth; /* depth in uframes */ struct list_head td_list; /* queued itds/sitds */ struct list_head free_list; /* list of unused itds/sitds */ struct usb_device *udev; struct usb_host_endpoint *ep; /* output of (re)scheduling */ unsigned long start; /* jiffies */ unsigned long rescheduled; int next_uframe; __hc32 splits; /* the rest is derived from the endpoint descriptor, * trusting urb->interval == f(epdesc->bInterval) and * including the extra info for hw_bufp[0..2] */ u8 interval; u8 usecs, c_usecs; u16 tt_usecs; u16 maxp; u16 raw_mask; unsigned bandwidth; /* This is used to initialize iTD's hw_bufp fields */ __hc32 buf0; __hc32 buf1; __hc32 buf2; /* this is used to initialize sITD's tt info */ __hc32 address;};/*-------------------------------------------------------------------------*//* * EHCI Specification 0.95 Section 3.3 * Fig 3-4 "Isochronous Transaction Descriptor (iTD)" * * Schedule records for high speed iso xfers */struct ehci_itd { /* first part defined by EHCI spec */ __hc32 hw_next; /* see EHCI 3.3.1 */ __hc32 hw_transaction [8]; /* see EHCI 3.3.2 */#define EHCI_ISOC_ACTIVE (1<<31) /* activate transfer this slot */#define EHCI_ISOC_BUF_ERR (1<<30) /* Data buffer error */#define EHCI_ISOC_BABBLE (1<<29) /* babble detected */#define EHCI_ISOC_XACTERR (1<<28) /* XactErr - transaction error */#define EHCI_ITD_LENGTH(tok) (((tok)>>16) & 0x0fff)#define EHCI_ITD_IOC (1 << 15) /* interrupt on complete */#define ITD_ACTIVE(ehci) cpu_to_hc32(ehci, EHCI_ISOC_ACTIVE) __hc32 hw_bufp [7]; /* see EHCI 3.3.3 */ __hc32 hw_bufp_hi [7]; /* Appendix B */ /* the rest is HCD-private */ dma_addr_t itd_dma; /* for this itd */ union ehci_shadow itd_next; /* ptr to periodic q entry */ struct urb *urb; struct ehci_iso_stream *stream; /* endpoint's queue */ struct list_head itd_list; /* list of stream's itds */ /* any/all hw_transactions here may be used by that urb */ unsigned frame; /* where scheduled */ unsigned pg; unsigned index[8]; /* in urb->iso_frame_desc */ u8 usecs[8];} __attribute__ ((aligned (32)));/*-------------------------------------------------------------------------*//* * EHCI Specification 0.95 Section 3.4 * siTD, aka split-transaction isochronous Transfer Descriptor * ... describe full speed iso xfers through TT in hubs * see Figure 3-5 "Split-transaction Isochronous Transaction Descriptor (siTD) */struct ehci_sitd { /* first part defined by EHCI spec */ __hc32 hw_next;/* uses bit field macros above - see EHCI 0.95 Table 3-8 */ __hc32 hw_fullspeed_ep; /* EHCI table 3-9 */ __hc32 hw_uframe; /* EHCI table 3-10 */ __hc32 hw_results; /* EHCI table 3-11 */#define SITD_IOC (1 << 31) /* interrupt on completion */#define SITD_PAGE (1 << 30) /* buffer 0/1 */#define SITD_LENGTH(x) (0x3ff & ((x)>>16))#define SITD_STS_ACTIVE (1 << 7) /* HC may execute this */#define SITD_STS_ERR (1 << 6) /* error from TT */#define SITD_STS_DBE (1 << 5) /* data buffer error (in HC) */#define SITD_STS_BABBLE (1 << 4) /* device was babbling */#define SITD_STS_XACT (1 << 3) /* illegal IN response */#define SITD_STS_MMF (1 << 2) /* incomplete split transaction */#define SITD_STS_STS (1 << 1) /* split transaction state */#define SITD_ACTIVE(ehci) cpu_to_hc32(ehci, SITD_STS_ACTIVE) __hc32 hw_buf [2]; /* EHCI table 3-12 */ __hc32 hw_backpointer; /* EHCI table 3-13 */ __hc32 hw_buf_hi [2]; /* Appendix B */ /* the rest is HCD-private */ dma_addr_t sitd_dma; union ehci_shadow sitd_next; /* ptr to periodic q entry */ struct urb *urb; struct ehci_iso_stream *stream; /* endpoint's queue */ struct list_head sitd_list; /* list of stream's sitds */ unsigned frame; unsigned index;} __attribute__ ((aligned (32)));/*-------------------------------------------------------------------------*//* * EHCI Specification 0.96 Section 3.7 * Periodic Frame Span Traversal Node (FSTN) * * Manages split interrupt transactions (using TT) that span frame boundaries * into uframes 0/1; see 4.12.2.2. In those uframes, a "save place" FSTN * makes the HC jump (back) to a QH to scan for fs/ls QH completions until * it hits a "restore" FSTN; then it returns to finish other uframe 0/1 work. */struct ehci_fstn { __hc32 hw_next; /* any periodic q entry */ __hc32 hw_prev; /* qh or EHCI_LIST_END */ /* the rest is HCD-private */ dma_addr_t fstn_dma; union ehci_shadow fstn_next; /* ptr to periodic q entry */} __attribute__ ((aligned (32)));/*-------------------------------------------------------------------------*/#ifdef CONFIG_USB_EHCI_ROOT_HUB_TT/* * Some EHCI controllers have a Transaction Translator built into the * root hub. This is a non-standard feature. Each controller will need * to add code to the following inline functions, and call them as * needed (mostly in root hub code). */#define ehci_is_TDI(e) ((e)->is_tdi_rh_tt)/* Returns the speed of a device attached to a port on the root hub. */static inline unsigned intehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc){ if (ehci_is_TDI(ehci)) { switch ((portsc>>26)&3) { case 0: return 0; case 1: return (1<<USB_PORT_FEAT_LOWSPEED); case 2: default: return (1<<USB_PORT_FEAT_HIGHSPEED); } } return (1<<USB_PORT_FEAT_HIGHSPEED);}#else#define ehci_is_TDI(e) (0)#define ehci_port_speed(ehci, portsc) (1<<USB_PORT_FEAT_HIGHSPEED)#endif/*-------------------------------------------------------------------------*/#ifdef CONFIG_PPC_83xx/* Some Freescale processors have an erratum in which the TT * port number in the queue head was 0..N-1 instead of 1..N. */#define ehci_has_fsl_portno_bug(e) ((e)->has_fsl_port_bug)#else#define ehci_has_fsl_portno_bug(e) (0)#endif/* * While most USB host controllers implement their registers in * little-endian format, a minority (celleb companion chip) implement * them in big endian format. * * This attempts to support either format at compile time without a * runtime penalty, or both formats with the additional overhead * of checking a flag bit. */#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO#define ehci_big_endian_mmio(e) ((e)->big_endian_mmio)#else#define ehci_big_endian_mmio(e) 0#endif/* * Big-endian read/write functions are arch-specific. * Other arches can be added if/when they're needed. * * REVISIT: arch/powerpc now has readl/writel_be, so the * definition below can die once the 4xx support is * finally ported over. */#if defined(CONFIG_PPC)#define readl_be(addr) in_be32((__force unsigned *)addr)#define writel_be(val, addr) out_be32((__force unsigned *)addr, val)#endifstatic inline unsigned int ehci_readl(const struct ehci_hcd *ehci, __u32 __iomem * regs){#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO return ehci_big_endian_mmio(ehci) ? readl_be(regs) : readl(regs);#else return readl(regs);#endif}static inline void ehci_writel(const struct ehci_hcd *ehci, const unsigned int val, __u32 __iomem *regs){#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO ehci_big_endian_mmio(ehci) ? writel_be(val, regs) : writel(val, regs);#else writel(val, regs);#endif}/*-------------------------------------------------------------------------*//* * The AMCC 440EPx not only implements its EHCI registers in big-endian * format, but also its DMA data structures (descriptors). * * EHCI controllers accessed through PCI work normally (little-endian * everywhere), so we won't bother supporting a BE-only mode for now. */#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_DESC#define ehci_big_endian_desc(e) ((e)->big_endian_desc)/* cpu to ehci */static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x){ return ehci_big_endian_desc(ehci) ? (__force __hc32)cpu_to_be32(x) : (__force __hc32)cpu_to_le32(x);}/* ehci to cpu */static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x){ return ehci_big_endian_desc(ehci) ? be32_to_cpu((__force __be32)x) : le32_to_cpu((__force __le32)x);}static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x){ return ehci_big_endian_desc(ehci) ? be32_to_cpup((__force __be32 *)x) : le32_to_cpup((__force __le32 *)x);}#else/* cpu to ehci */static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x){ return cpu_to_le32(x);}/* ehci to cpu */static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x){ return le32_to_cpu(x);}static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x){ return le32_to_cpup(x);}#endif/*-------------------------------------------------------------------------*/#ifndef DEBUG#define STUB_DEBUG_FILES#endif /* DEBUG *//*-------------------------------------------------------------------------*/#endif /* __LINUX_EHCI_HCD_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?