1 /******************************************************************************
3 * Copyright (C) 2016 Xilinx, Inc. All rights reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
31 ******************************************************************************/
32 /*****************************************************************************/
35 * @file xusbps_endpoint.h
36 * @addtogroup usbpsu_v1_0
39 * This is an internal file containing the definitions for endpoints. It is
40 * included by the xusbps_endpoint.c which is implementing the endpoint
41 * functions and by xusbps_intr.c.
44 * MODIFICATION HISTORY:
46 * Ver Who Date Changes
47 * ----- ---- -------- --------------------------------------------------------
48 * 1.0 sg 06/06/16 First release
51 ******************************************************************************/
52 #ifndef XUSBPSU_ENDPOINT_H
53 #define XUSBPSU_ENDPOINT_H
59 /***************************** Include Files *********************************/
61 #include "xil_cache.h"
63 #include "xil_types.h"
65 /**************************** Type Definitions *******************************/
67 /************************** Constant Definitions *****************************/
69 /* Device Generic Command Register */
70 #define XUSBPSU_DGCMD_SET_LMP 0x00000001U
71 #define XUSBPSU_DGCMD_SET_PERIODIC_PAR 0x00000002U
72 #define XUSBPSU_DGCMD_XMIT_FUNCTION 0x00000003U
74 /* These apply for core versions 1.94a and later */
75 #define XUSBPSU_DGCMD_SET_SCRATCHPAD_ADDR_LO 0x00000004U
76 #define XUSBPSU_DGCMD_SET_SCRATCHPAD_ADDR_HI 0x00000005U
78 #define XUSBPSU_DGCMD_SELECTED_FIFO_FLUSH 0x00000009U
79 #define XUSBPSU_DGCMD_ALL_FIFO_FLUSH 0x0000000aU
80 #define XUSBPSU_DGCMD_SET_ENDPOINT_NRDY 0x0000000cU
81 #define XUSBPSU_DGCMD_RUN_SOC_BUS_LOOPBACK 0x00000010U
83 #define XUSBPSU_DGCMD_STATUS(n) (((u32)(n) >> 15) & 1)
84 #define XUSBPSU_DGCMD_CMDACT (0x00000001U << 10)
85 #define XUSBPSU_DGCMD_CMDIOC (0x00000001U << 8)
87 /* Device Generic Command Parameter Register */
88 #define XUSBPSU_DGCMDPAR_FORCE_LINKPM_ACCEPT (0x00000001U << 0)
89 #define XUSBPSU_DGCMDPAR_FIFO_NUM(n) ((u32)(n) << 0)
90 #define XUSBPSU_DGCMDPAR_RX_FIFO (0x00000000U << 5)
91 #define XUSBPSU_DGCMDPAR_TX_FIFO (0x00000001U << 5)
92 #define XUSBPSU_DGCMDPAR_LOOPBACK_DIS (0x00000000U << 0)
93 #define XUSBPSU_DGCMDPAR_LOOPBACK_ENA (0x00000001U << 0)
95 /* Device Endpoint Command Register */
96 #define XUSBPSU_DEPCMD_PARAM_SHIFT 16U
97 #define XUSBPSU_DEPCMD_PARAM(x) ((u32)(x) << XUSBPSU_DEPCMD_PARAM_SHIFT)
98 #define XUSBPSU_DEPCMD_GET_RSC_IDX(x) (((u32)(x) >> XUSBPSU_DEPCMD_PARAM_SHIFT) & \
100 #define XUSBPSU_DEPCMD_STATUS(x) (((u32)(x) >> 12) & (u32)0xF)
101 #define XUSBPSU_DEPCMD_HIPRI_FORCERM (0x00000001U << 11)
102 #define XUSBPSU_DEPCMD_CMDACT (0x00000001U << 10)
103 #define XUSBPSU_DEPCMD_CMDIOC (0x00000001U << 8)
105 #define XUSBPSU_DEPCMD_DEPSTARTCFG 0x00000009U
106 #define XUSBPSU_DEPCMD_ENDTRANSFER 0x00000008U
107 #define XUSBPSU_DEPCMD_UPDATETRANSFER 0x00000007U
108 #define XUSBPSU_DEPCMD_STARTTRANSFER 0x00000006U
109 #define XUSBPSU_DEPCMD_CLEARSTALL 0x00000005U
110 #define XUSBPSU_DEPCMD_SETSTALL 0x00000004U
111 #define XUSBPSU_DEPCMD_GETEPSTATE 0x00000003U
112 #define XUSBPSU_DEPCMD_SETTRANSFRESOURCE 0x00000002U
113 #define XUSBPSU_DEPCMD_SETEPCONFIG 0x00000001U
115 /* The EP number goes 0..31 so ep0 is always out and ep1 is always in */
116 #define XUSBPSU_DALEPENA_EP(n) (0x00000001U << (n))
118 #define XUSBPSU_DEPCFG_INT_NUM(n) ((u32)(n) << 0)
119 #define XUSBPSU_DEPCFG_XFER_COMPLETE_EN (0x00000001U << 8)
120 #define XUSBPSU_DEPCFG_XFER_IN_PROGRESS_EN (0x00000001U << 9)
121 #define XUSBPSU_DEPCFG_XFER_NOT_READY_EN (0x00000001U << 10)
122 #define XUSBPSU_DEPCFG_FIFO_ERROR_EN (0x00000001U << 11)
123 #define XUSBPSU_DEPCFG_STREAM_EVENT_EN (0x00000001U << 13)
124 #define XUSBPSU_DEPCFG_BINTERVAL_M1(n) ((u32)(n) << 16)
125 #define XUSBPSU_DEPCFG_STREAM_CAPABLE (0x00000001U << 24)
126 #define XUSBPSU_DEPCFG_EP_NUMBER(n) ((u32)(n) << 25)
127 #define XUSBPSU_DEPCFG_BULK_BASED (0x00000001U << 30)
128 #define XUSBPSU_DEPCFG_FIFO_BASED (0x00000001U << 31)
130 /* DEPCFG parameter 0 */
131 #define XUSBPSU_DEPCFG_EP_TYPE(n) ((u32)(n) << 1)
132 #define XUSBPSU_DEPCFG_MAX_PACKET_SIZE(n) ((u32)(n) << 3)
133 #define XUSBPSU_DEPCFG_FIFO_NUMBER(n) ((u32)(n) << 17)
134 #define XUSBPSU_DEPCFG_BURST_SIZE(n) ((u32)(n) << 22)
135 #define XUSBPSU_DEPCFG_DATA_SEQ_NUM(n) ((u32)(n) << 26)
136 /* This applies for core versions earlier than 1.94a */
137 #define XUSBPSU_DEPCFG_IGN_SEQ_NUM (0x00000001U << 31)
138 /* These apply for core versions 1.94a and later */
139 #define XUSBPSU_DEPCFG_ACTION_INIT (0x00000000U << 30)
140 #define XUSBPSU_DEPCFG_ACTION_RESTORE (0x00000001U << 30)
141 #define XUSBPSU_DEPCFG_ACTION_MODIFY (0x00000002U << 30)
143 /* DEPXFERCFG parameter 0 */
144 #define XUSBPSU_DEPXFERCFG_NUM_XFER_RES(n) ((u32)(n) & (u32)0xffff)
146 #define XUSBPSU_DEPCMD_TYPE_BULK 2U
147 #define XUSBPSU_DEPCMD_TYPE_INTR 3U
149 /* TRB Length, PCM and Status */
150 #define XUSBPSU_TRB_SIZE_MASK (0x00ffffffU)
151 #define XUSBPSU_TRB_SIZE_LENGTH(n) ((u32)(n) & XUSBPSU_TRB_SIZE_MASK)
152 #define XUSBPSU_TRB_SIZE_PCM1(n) (((u32)(n) & (u32)0x03) << 24)
153 #define XUSBPSU_TRB_SIZE_TRBSTS(n) (((u32)(n) & ((u32)0x0f << 28)) >> 28)
155 #define XUSBPSU_TRBSTS_OK 0U
156 #define XUSBPSU_TRBSTS_MISSED_ISOC 1U
157 #define XUSBPSU_TRBSTS_SETUP_PENDING 2U
158 #define XUSBPSU_TRB_STS_XFER_IN_PROG 4U
161 #define XUSBPSU_TRB_CTRL_HWO ((u32)0x00000001U << 0)
162 #define XUSBPSU_TRB_CTRL_LST ((u32)0x00000001U << 1)
163 #define XUSBPSU_TRB_CTRL_CHN ((u32)0x00000001U << 2)
164 #define XUSBPSU_TRB_CTRL_CSP ((u32)0x00000001U << 3)
165 #define XUSBPSU_TRB_CTRL_TRBCTL(n) (((u32)(n) & (u32)0x3f) << 4)
166 #define XUSBPSU_TRB_CTRL_ISP_IMI (0x00000001U << 10)
167 #define XUSBPSU_TRB_CTRL_IOC (0x00000001U << 11)
168 #define XUSBPSU_TRB_CTRL_SID_SOFN(n) (((u32)(n) & (u32)0xffff) << 14)
170 #define XUSBPSU_TRBCTL_NORMAL XUSBPSU_TRB_CTRL_TRBCTL(1)
171 #define XUSBPSU_TRBCTL_CONTROL_SETUP XUSBPSU_TRB_CTRL_TRBCTL(2)
172 #define XUSBPSU_TRBCTL_CONTROL_STATUS2 XUSBPSU_TRB_CTRL_TRBCTL(3)
173 #define XUSBPSU_TRBCTL_CONTROL_STATUS3 XUSBPSU_TRB_CTRL_TRBCTL(4)
174 #define XUSBPSU_TRBCTL_CONTROL_DATA XUSBPSU_TRB_CTRL_TRBCTL(5)
175 #define XUSBPSU_TRBCTL_ISOCHRONOUS_FIRST XUSBPSU_TRB_CTRL_TRBCTL(6)
176 #define XUSBPSU_TRBCTL_ISOCHRONOUS XUSBPSU_TRB_CTRL_TRBCTL(7)
177 #define XUSBPSU_TRBCTL_LINK_TRB XUSBPSU_TRB_CTRL_TRBCTL(8)
183 #endif /* XUSBPSU_ENDPOINT_H */