Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / lib / libusb / usb-ehci.h
1 /******************************************************************************
2  * Copyright (c) 2007, 2012, 2013 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12 /*
13  * Definitions for EHCI Controller
14  *
15  */
16
17 #ifndef USB_EHCI_H
18 #define USB_EHCI_H
19
20 #include <stdint.h>
21 #include "usb-core.h"
22
23 #define FL_SIZE 1024
24
25 struct ehci_cap_regs {
26         uint8_t  caplength;
27         uint8_t  reserved;
28         uint16_t hciversion;
29         uint32_t hcsparams;
30         uint32_t hccparams;
31         uint64_t portroute;
32 } __attribute__ ((packed));
33
34 struct ehci_op_regs {
35         uint32_t usbcmd;
36         uint32_t usbsts;
37         uint32_t usbintr;
38         uint32_t frindex;
39         uint32_t ctrldssegment;
40         uint32_t periodiclistbase;
41         uint32_t asynclistaddr;
42         uint32_t reserved[9];
43         uint32_t configflag;
44         uint32_t portsc[0];
45 } __attribute__ ((packed));
46
47 struct ehci_framelist {
48         uint32_t fl_ptr[FL_SIZE];
49 } __attribute__ ((packed));
50
51 struct ehci_hcd {
52         struct ehci_cap_regs *cap_regs;
53         struct ehci_op_regs  *op_regs;
54         struct usb_hcd_dev *hcidev;
55         struct ehci_qh *qh_async;
56         struct ehci_qh *qh_intr;
57         struct usb_pipe *freelist;
58         struct usb_pipe *end;
59         struct ehci_framelist *fl;
60         long qh_async_phys;
61         long qh_intr_phys;
62         long fl_phys;
63         void *pool;
64         long pool_phys;
65 };
66
67 struct ehci_qtd {
68         uint32_t next_qtd;
69         uint32_t alt_next_qtd;
70         uint32_t token;
71         uint32_t buffer[5];
72 } __attribute__ ((packed));
73
74 struct ehci_qh {
75         uint32_t qh_ptr;
76         uint32_t ep_cap1;
77         uint32_t ep_cap2;
78         uint32_t curr_qtd;
79         uint32_t next_qtd;
80         uint32_t alt_next_qtd;
81         uint32_t token;
82         uint32_t buffer[5];
83 } __attribute__ ((packed)) __attribute__((aligned(32)));
84
85 struct ehci_pipe {
86         struct ehci_qh qh;
87         struct usb_pipe pipe;
88         long qh_phys;
89 };
90
91 #define EHCI_PIPE_POOL_SIZE     4096
92
93 #define EHCI_TYP_ITD    0x00
94 #define EHCI_TYP_QH     0x02
95 #define EHCI_TYP_SITD   0x04
96 #define EHCI_TYP_FSTN   0x06
97
98 #define PID_OUT         0x00
99 #define PID_IN          0x01
100 #define PID_SETUP       0x02
101
102 #define HCS_NPORTS_MASK        0x000f
103
104 #define CMD_IAAD        (1 << 6)
105 #define CMD_ASE         (1 << 5)
106 #define CMD_PSE         (1 << 4)
107 #define CMD_FLS_MASK    (3 << 2)
108 #define CMD_HCRESET     (1 << 1)
109 #define CMD_RUN         (1 << 0)
110
111 #define STS_IAA         (1 << 5)
112
113 #define PORT_RESET      (1 << 8)
114 #define PORT_PE         (1 << 2)
115 #define PORT_CSC        (1 << 1)
116 #define PORT_CONNECT    (1 << 0)
117
118 #define QH_LOW_SPEED    0
119 #define QH_FULL_SPEED   1
120 #define QH_HIGH_SPEED   2
121
122 #define QH_RL_SHIFT     28
123 #define QH_CAP_C        (1 << 27)
124 #define QH_MPS_SHIFT    16
125 #define QH_CAP_H        (1 << 15)
126 #define QH_CAP_DTC      (1 << 14)
127 #define QH_EPS_SHIFT    12
128 #define QH_EP_SHIFT     8
129 #define QH_CAP_I        (1 << 7)
130 #define QH_DEV_ADDR_SHIFT       0
131
132 #define QH_PTR_TERM     __builtin_bswap32(1)
133 #define QH_SMASK_SHIFT  0
134 #define QH_STS_ACTIVE   (1 << 7)
135 #define QH_STS_HALTED   (1 << 6)
136 #define QH_STS_DBE      (1 << 5)
137 #define QH_STS_BABBLE   (1 << 4)
138 #define QH_STS_XACTERR  (1 << 3)
139 #define QH_STS_MMF      (1 << 2)
140 #define QH_STS_SXS      (1 << 1)
141 #define QH_STS_PING     (1 << 0)
142
143 #define NUM_BULK_QTDS           4
144 #define MAX_XFER_PER_QTD        (20 * 1024)
145 #define QTD_MAX_TRANSFER_LEN    (NUM_BULK_QTDS * MAX_XFER_PER_QTD)
146
147 #define TOKEN_DT_SHIFT          31
148 #define TOKEN_TBTT_SHIFT        16
149 #define TOKEN_IOC_SHIFT         15
150 #define TOKEN_CPAGE_SHIFT       12
151 #define TOKEN_CERR_SHIFT        10
152 #define TOKEN_PID_SHIFT         8
153 #define TOKEN_STATUS_SHIFT      0
154
155 #endif  /* USB_EHCI_H */