AM62Px MCU+ SDK  09.02.01
udma_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2023 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
47 #ifndef UDMA_UTILS_H_
48 #define UDMA_UTILS_H_
49 
50 /* ========================================================================== */
51 /* Include Files */
52 /* ========================================================================== */
53 
54 /* None */
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 /* ========================================================================== */
61 /* Macros & Typedefs */
62 /* ========================================================================== */
63 
72 #define UDMA_TR_TYPE_0 (CSL_UDMAP_TR_FLAGS_TYPE_1D_DATA_MOVE)
73 #define UDMA_TR_TYPE_1 (CSL_UDMAP_TR_FLAGS_TYPE_2D_DATA_MOVE)
74 #define UDMA_TR_TYPE_2 (CSL_UDMAP_TR_FLAGS_TYPE_3D_DATA_MOVE)
75 #define UDMA_TR_TYPE_3 (CSL_UDMAP_TR_FLAGS_TYPE_4D_DATA_MOVE)
76 #define UDMA_TR_TYPE_4 (CSL_UDMAP_TR_FLAGS_TYPE_4D_DATA_MOVE_FORMATTING)
77 #define UDMA_TR_TYPE_5 (CSL_UDMAP_TR_FLAGS_TYPE_4D_CACHE_WARM)
78 #define UDMA_TR_TYPE_8 (CSL_UDMAP_TR_FLAGS_TYPE_4D_BLOCK_MOVE)
79 #define UDMA_TR_TYPE_9 (CSL_UDMAP_TR_FLAGS_TYPE_4D_BLOCK_MOVE_REPACKING)
80 #define UDMA_TR_TYPE_10 (CSL_UDMAP_TR_FLAGS_TYPE_2D_BLOCK_MOVE)
81 #define UDMA_TR_TYPE_11 (CSL_UDMAP_TR_FLAGS_TYPE_2D_BLOCK_MOVE_REPACKING)
82 #define UDMA_TR_TYPE_15 (CSL_UDMAP_TR_FLAGS_TYPE_4D_BLOCK_MOVE_REPACKING_INDIRECTION)
83 
94 #define UDMA_GET_TRPD_TR15_SIZE(n) (UDMA_ALIGN_SIZE(sizeof(CSL_UdmapTR15) + ((n) * (sizeof(CSL_UdmapTR15) + 4U))))
95 
105 #define UDMA_GET_TRPD_TR3_SIZE(n) (UDMA_ALIGN_SIZE(sizeof(CSL_UdmapTR3) + ((n) * (sizeof(CSL_UdmapTR3) + 4U))))
106 
110 #define UDMA_TR1_OFFSET (32U)
111 
115 #define UDMA_TR3_OFFSET (32U)
116 
117 /* ========================================================================== */
118 /* Structure Declarations */
119 /* ========================================================================== */
120 
121 /* None */
122 
123 /* ========================================================================== */
124 /* Function Declarations */
125 /* ========================================================================== */
126 
137  uint32_t elemCnt,
138  uint8_t elemSize);
139 
152 void UdmaUtils_makeTrpdTr15(uint8_t *trpdMem, uint32_t trCnt, uint32_t cqRingNum);
153 
167 void UdmaUtils_makeTrpd(uint8_t *trpdMem,
168  uint32_t trType,
169  uint32_t trCnt,
170  uint32_t cqRingNum);
171 
179 uint32_t UdmaUtils_getTrSizeEncoded(uint32_t trType);
180 
188 uint32_t UdmaUtils_getTrSizeBytes(uint32_t trType);
189 
207  uint32_t localeventID, uint32_t eventMode);
208 
216 int32_t UdmaUtils_setTrpdReload(uint8_t *trpdMem,
217  uint32_t reloadEnable, uint32_t reloadIdx);
218 
228 static inline uint32_t UdmaUtils_getTrpdTr15Response(const uint8_t *trpdMem,
229  uint32_t trCnt,
230  uint32_t trIndex);
231 
240 static inline CSL_UdmapTR15 *UdmaUtils_getTrpdTr15Pointer(uint8_t *trpdMem,
241  uint32_t trIndex);
242 
251 static inline CSL_UdmapTR1 *UdmaUtils_getTrpdTr1Pointer(uint8_t *trpdMem,
252  uint32_t trIndex);
253 
254 /* ========================================================================== */
255 /* Static Function Definitions */
256 /* ========================================================================== */
257 
258 static inline uint32_t UdmaUtils_getTrpdTr15Response(const uint8_t *trpdMem,
259  uint32_t trCnt,
260  uint32_t trIndex)
261 {
262  uint32_t trRespStatus;
263  const uint32_t *pTrResp;;
264 
265  /* Get TR index */
266  pTrResp = (const uint32_t *) (trpdMem +
267  (sizeof(CSL_UdmapTR15) +
268  (sizeof(CSL_UdmapTR15) * trCnt) +
269  (sizeof(uint32_t) * trIndex)));
270  trRespStatus = CSL_FEXT(*pTrResp, UDMAP_TR_RESPONSE_STATUS_TYPE);
271 
272  return (trRespStatus);
273 }
274 
275 static inline CSL_UdmapTR15 *UdmaUtils_getTrpdTr15Pointer(uint8_t *trpdMem,
276  uint32_t trIndex)
277 {
278  CSL_UdmapTR15 *pTr;
279 
280  pTr = (CSL_UdmapTR15 *)(trpdMem + sizeof(CSL_UdmapTR15) + (sizeof(CSL_UdmapTR15) * trIndex));
281 
282  return (pTr);
283 }
284 
285 static inline CSL_UdmapTR1 *UdmaUtils_getTrpdTr1Pointer(uint8_t *trpdMem,
286  uint32_t trIndex)
287 {
288  CSL_UdmapTR1 *pTr;
289 
290  pTr = (CSL_UdmapTR1 *)(trpdMem + UDMA_TR1_OFFSET + (UDMA_TR1_OFFSET * trIndex));
291 
292  return (pTr);
293 }
294 
295 static inline CSL_UdmapTR3 *UdmaUtils_getTrpdTr3Pointer(uint8_t *trpdMem,
296  uint32_t trIndex)
297 {
298  CSL_UdmapTR3 *pTr;
299 
300  pTr = (CSL_UdmapTR3 *)(trpdMem + UDMA_TR3_OFFSET + (UDMA_TR3_OFFSET * trIndex));
301 
302  return (pTr);
303 }
304 
305 #ifdef __cplusplus
306 }
307 #endif
308 
309 #endif /* #ifndef UDMA_UTILS_H_ */
310 
Udma_ChHandle
void * Udma_ChHandle
UDMA channel handle.
Definition: udma_types.h:67
UdmaUtils_getTrSizeEncoded
uint32_t UdmaUtils_getTrSizeEncoded(uint32_t trType)
Returns the size of TR (encoded) based on the type.
UdmaUtils_setTrpdReload
int32_t UdmaUtils_setTrpdReload(uint8_t *trpdMem, uint32_t reloadEnable, uint32_t reloadIdx)
Sets the reload count and index for the TRPD.
UdmaUtils_getTrpdTr1Pointer
static CSL_UdmapTR1 * UdmaUtils_getTrpdTr1Pointer(uint8_t *trpdMem, uint32_t trIndex)
Returns the TR1 pointer in the TRPD memory based on the index.
Definition: udma_utils.h:285
UdmaUtils_makeTrpd
void UdmaUtils_makeTrpd(uint8_t *trpdMem, uint32_t trType, uint32_t trCnt, uint32_t cqRingNum)
UDMA utility API to make TRPD. Other TRPD make APIs should be called only after this API.
UdmaUtils_makeTrpdTr15
void UdmaUtils_makeTrpdTr15(uint8_t *trpdMem, uint32_t trCnt, uint32_t cqRingNum)
UDMA utility API to make TRPD with TR15 TR type. Other TRPD make APIs should be called only after thi...
UDMA_TR3_OFFSET
#define UDMA_TR3_OFFSET
Offset for TR3 type TR from TRPD start address.
Definition: udma_utils.h:115
mode
char mode[32]
Definition: tisci_pm_core.h:1
UDMA_TR1_OFFSET
#define UDMA_TR1_OFFSET
Offset for TR1 type TR from TRPD start address.
Definition: udma_utils.h:110
UdmaUtils_getTrSizeBytes
uint32_t UdmaUtils_getTrSizeBytes(uint32_t trType)
Returns the size of TR in bytes based on the type.
UdmaUtils_getTrpdTr3Pointer
static CSL_UdmapTR3 * UdmaUtils_getTrpdTr3Pointer(uint8_t *trpdMem, uint32_t trIndex)
Definition: udma_utils.h:295
Udma_DrvHandle
void * Udma_DrvHandle
UDMA driver handle.
Definition: udma_types.h:65
UdmaUtils_getTrpdTr15Response
static uint32_t UdmaUtils_getTrpdTr15Response(const uint8_t *trpdMem, uint32_t trCnt, uint32_t trIndex)
Returns the TR response in the TRPD memory based on the index.
Definition: udma_utils.h:258
UdmaUtils_getRingMemSize
uint32_t UdmaUtils_getRingMemSize(uint8_t mode, uint32_t elemCnt, uint8_t elemSize)
UDMA get ring size utility API.
UdmaUtils_mapLocaltoGlobalEvent
int32_t UdmaUtils_mapLocaltoGlobalEvent(Udma_DrvHandle drvHandle, Udma_ChHandle chHandle, uint32_t localeventID, uint32_t eventMode)
Map L2G event for BCDMA trigger.
UdmaUtils_getTrpdTr15Pointer
static CSL_UdmapTR15 * UdmaUtils_getTrpdTr15Pointer(uint8_t *trpdMem, uint32_t trIndex)
Returns the TR15 pointer in the TRPD memory based on the index.
Definition: udma_utils.h:275