PDK API Guide for J721E
udma_proxy.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2019
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 
48 #ifndef UDMA_PROXY_H_
49 #define UDMA_PROXY_H_
50 
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 
55 /* None */
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 /* ========================================================================== */
62 /* Macros & Typedefs */
63 /* ========================================================================== */
64 
68 #define UDMA_PROXY_INVALID ((uint16_t) 0xFFFFU)
69 
73 #define UDMA_PROXY_ANY ((uint16_t) 0xFFFEU)
74 
75 /* ========================================================================== */
76 /* Structure Declarations */
77 /* ========================================================================== */
78 
83 typedef struct
84 {
85  uint32_t proxyMode;
87  uint32_t elemSize;
90  uint16_t ringNum;
93 
94 /* ========================================================================== */
95 /* Function Declarations */
96 /* ========================================================================== */
97 
119 int32_t Udma_proxyAlloc(Udma_DrvHandle drvHandle,
120  Udma_ProxyHandle proxyHandle,
121  uint16_t proxyNum);
122 
138 int32_t Udma_proxyFree(Udma_ProxyHandle proxyHandle);
139 
165 int32_t Udma_proxyConfig(Udma_ProxyHandle proxyHandle,
166  const Udma_ProxyCfg *proxyCfg);
167 
186 static inline void Udma_proxyQueue(Udma_ProxyHandle proxyHandle,
187  uint64_t phyDescMem);
188 
208 static inline void Udma_proxyDequeue(Udma_ProxyHandle proxyHandle,
209  uint64_t *phyDescMem);
210 
220 static inline void Udma_proxyWrite64(uintptr_t proxyAddr, uint64_t data);
221 
232 static inline void Udma_proxyRead64(uintptr_t proxyAddr, uint64_t *data);
233 
234 /* ========================================================================== */
235 /* Internal/Private Structure Declarations */
236 /* ========================================================================== */
237 
245 {
246  Udma_DrvHandle drvHandle;
248  uint16_t proxyNum;
251  /* Proxy address for the ring operation. Calculated at config time to reduce
252  * cycles at runtime */
253  uintptr_t proxyAddr;
256  uint32_t proxyInitDone;
258 };
259 
260 /* ========================================================================== */
261 /* Static Function Definitions */
262 /* ========================================================================== */
263 
264 static inline void Udma_proxyWrite64(uintptr_t proxyAddr, uint64_t data)
265 {
266 #if defined (__aarch64__) || defined (__C7100__)
267  CSL_REG64_WR((uint64_t *) proxyAddr, data);
268 #else
269  /* For 32-bit cores enforce the order as the compiler may not guarantee
270  * the order */
271  volatile uint32_t *proxyAddr32 = (volatile uint32_t *) proxyAddr;
272  uint32_t wordLow, wordHigh;
273 
274  /* Write low word first and then the high word which triggers the actual
275  * write from proxy */
276  wordLow = (uint32_t) data;
277  wordHigh = (uint32_t) (data >> 32U);
278  CSL_REG32_WR(proxyAddr32, wordLow);
279  CSL_REG32_WR(proxyAddr32 + 1U, wordHigh);
280 #endif
281 
282  return;
283 }
284 
285 static inline void Udma_proxyRead64(uintptr_t proxyAddr, uint64_t *data)
286 {
287 #if defined (__aarch64__) || defined (__C7100__)
288  *data = CSL_REG64_RD((uint64_t *) proxyAddr);
289 #else
290  /* For 32-bit cores enforce the order as the compiler may not guarantee
291  * the order */
292  volatile uint32_t *proxyAddr32 = (volatile uint32_t *) proxyAddr;
293  uint32_t wordLow, wordHigh;
294 
295  /* Read low word first (this triggers the entire proxy read) and then the
296  * high word which ends the proxy read */
297  wordLow = CSL_REG32_RD(proxyAddr32);
298  wordHigh = CSL_REG32_RD(proxyAddr32 + 1U);
299  *data = ((uint64_t) wordLow) | (((uint64_t) wordHigh) << 32U);
300 #endif
301 
302  return;
303 }
304 
305 static inline void Udma_proxyQueue(Udma_ProxyHandle proxyHandle,
306  uint64_t phyDescMem)
307 {
308  Udma_proxyWrite64(proxyHandle->proxyAddr, phyDescMem);
309 }
310 
311 static inline void Udma_proxyDequeue(Udma_ProxyHandle proxyHandle,
312  uint64_t *phyDescMem)
313 {
314  Udma_proxyRead64(proxyHandle->proxyAddr, phyDescMem);
315 }
316 
317 #ifdef __cplusplus
318 }
319 #endif
320 
321 #endif /* #ifndef UDMA_PROXY_H_ */
322 
323 /* @} */
static void Udma_proxyQueue(Udma_ProxyHandle proxyHandle, uint64_t phyDescMem)
UDMA queue descriptor to a proxy which is pre-configured to queue to a ring.
Definition: udma_proxy.h:305
uint32_t proxyInitDone
Definition: udma_proxy.h:256
uint16_t proxyNum
Definition: udma_proxy.h:248
uint32_t elemSize
Definition: udma_proxy.h:87
uint16_t ringNum
Definition: udma_proxy.h:90
int32_t Udma_proxyFree(Udma_ProxyHandle proxyHandle)
UDMA free proxy.
uint32_t proxyMode
Definition: udma_proxy.h:85
static void Udma_proxyDequeue(Udma_ProxyHandle proxyHandle, uint64_t *phyDescMem)
UDMA dequeue descriptor from a proxy which is pre-configured to dequeue from a ring.
Definition: udma_proxy.h:311
Udma_DrvHandle drvHandle
Definition: udma_proxy.h:246
UDMA proxy object.
Definition: udma_proxy.h:244
uint32_t data[13]
Definition: csl_udmap_tr.h:628
static void Udma_proxyWrite64(uintptr_t proxyAddr, uint64_t data)
API to write 64-bit data to proxy.
Definition: udma_proxy.h:264
int32_t Udma_proxyConfig(Udma_ProxyHandle proxyHandle, const Udma_ProxyCfg *proxyCfg)
UDMA proxy config API.
This structure contains configuration parameters for each proxy thread.
Definition: udma_proxy.h:83
int32_t Udma_proxyAlloc(Udma_DrvHandle drvHandle, Udma_ProxyHandle proxyHandle, uint16_t proxyNum)
UDMA proxy allocation API.
uintptr_t proxyAddr
Definition: udma_proxy.h:253
static void Udma_proxyRead64(uintptr_t proxyAddr, uint64_t *data)
API to read 64-bit data from proxy.
Definition: udma_proxy.h:285