1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016 NXP
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  *   of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  *   list of conditions and the following disclaimer in the documentation and/or
13  *   other materials provided with the distribution.
14  *
15  * o Neither the name of the copyright holder nor the names of its
16  *   contributors may be used to endorse or promote products derived from this
17  *   software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef __USB_EHCI_H__
32 #define __USB_EHCI_H__
33 
34 /*******************************************************************************
35  * Definitions
36  ******************************************************************************/
37 
38 /* Device QH */
39 #define USB_DEVICE_EHCI_QH_POINTER_MASK (0xFFFFFFC0U)
40 #define USB_DEVICE_EHCI_QH_MULT_MASK (0xC0000000U)
41 #define USB_DEVICE_EHCI_QH_ZLT_MASK (0x20000000U)
42 #define USB_DEVICE_EHCI_QH_MAX_PACKET_SIZE_MASK (0x07FF0000U)
43 #define USB_DEVICE_EHCI_QH_MAX_PACKET_SIZE (0x00000800U)
44 #define USB_DEVICE_EHCI_QH_IOS_MASK (0x00008000U)
45 
46 /* Device DTD */
47 #define USB_DEVICE_ECHI_DTD_POINTER_MASK (0xFFFFFFE0U)
48 #define USB_DEVICE_ECHI_DTD_TERMINATE_MASK (0x00000001U)
49 #define USB_DEVICE_ECHI_DTD_PAGE_MASK (0xFFFFF000U)
50 #define USB_DEVICE_ECHI_DTD_PAGE_OFFSET_MASK (0x00000FFFU)
51 #define USB_DEVICE_ECHI_DTD_PAGE_BLOCK (0x00001000U)
52 #define USB_DEVICE_ECHI_DTD_TOTAL_BYTES_MASK (0x7FFF0000U)
53 #define USB_DEVICE_ECHI_DTD_TOTAL_BYTES (0x00004000U)
54 #define USB_DEVICE_ECHI_DTD_IOC_MASK (0x00008000U)
55 #define USB_DEVICE_ECHI_DTD_MULTIO_MASK (0x00000C00U)
56 #define USB_DEVICE_ECHI_DTD_STATUS_MASK (0x000000FFU)
57 #define USB_DEVICE_EHCI_DTD_STATUS_ERROR_MASK (0x00000068U)
58 #define USB_DEVICE_ECHI_DTD_STATUS_ACTIVE (0x00000080U)
59 #define USB_DEVICE_ECHI_DTD_STATUS_HALTED (0x00000040U)
60 #define USB_DEVICE_ECHI_DTD_STATUS_DATA_BUFFER_ERROR (0x00000020U)
61 #define USB_DEVICE_ECHI_DTD_STATUS_TRANSACTION_ERROR (0x00000008U)
62 
63 typedef struct _usb_device_ehci_qh_struct
64 {
65     union
66     {
67         volatile uint32_t capabilttiesCharacteristics;
68         struct
69         {
70             volatile uint32_t reserved1 : 15;
71             volatile uint32_t ios : 1;
72             volatile uint32_t maxPacketSize : 11;
73             volatile uint32_t reserved2 : 2;
74             volatile uint32_t zlt : 1;
75             volatile uint32_t mult : 2;
76         } capabilttiesCharacteristicsBitmap;
77     } capabilttiesCharacteristicsUnion;
78     volatile uint32_t currentDtdPointer;
79     volatile uint32_t nextDtdPointer;
80     union
81     {
82         volatile uint32_t dtdToken;
83         struct
84         {
85             volatile uint32_t status : 8;
86             volatile uint32_t reserved1 : 2;
87             volatile uint32_t multiplierOverride : 2;
88             volatile uint32_t reserved2 : 3;
89             volatile uint32_t ioc : 1;
90             volatile uint32_t totalBytes : 15;
91             volatile uint32_t reserved3 : 1;
92         } dtdTokenBitmap;
93     } dtdTokenUnion;
94     volatile uint32_t bufferPointerPage[5];
95     volatile uint32_t reserved1;
96     uint32_t setupBuffer[2];
97     uint32_t setupBufferBack[2];
98     union
99     {
100         uint32_t endpointStatus;
101         struct
102         {
103             uint32_t isOpened : 1;
104             uint32_t : 31;
105         } endpointStatusBitmap;
106     } endpointStatusUnion;
107     uint32_t reserved2;
108 } usb_device_ehci_qh_struct_t;
109 
110 typedef struct _usb_device_ehci_dtd_struct
111 {
112     volatile uint32_t nextDtdPointer;
113     union
114     {
115         volatile uint32_t dtdToken;
116         struct
117         {
118             volatile uint32_t status : 8;
119             volatile uint32_t reserved1 : 2;
120             volatile uint32_t multiplierOverride : 2;
121             volatile uint32_t reserved2 : 3;
122             volatile uint32_t ioc : 1;
123             volatile uint32_t totalBytes : 15;
124             volatile uint32_t reserved3 : 1;
125         } dtdTokenBitmap;
126     } dtdTokenUnion;
127     volatile uint32_t bufferPointerPage[5];
128     union
129     {
130         volatile uint32_t reserved;
131         struct
132         {
133             uint32_t originalBufferOffest : 12;
134             uint32_t originalBufferLength : 19;
135             uint32_t dtdInvalid : 1;
136         } originalBufferInfo;
137     } reservedUnion;
138 } usb_device_ehci_dtd_struct_t;
139 
140 #endif /* __USB_EHCI_H__ */
141