1 #ifndef __BESTCOMM_API_H 2 #define __BESTCOMM_API_H 1 41 #include "include/ppctypes.h" 42 #include "include/mgt5200/sdma.h" 43 #include "task_api/tasksetup_bdtable.h" 44 #include "task_api/bestcomm_cntrl.h" 45 #include "task_api/bestcomm_api_mem.h" 65 #define DEBUG_BESTCOMM_API 0 77 # define NULL ((void *)0) 87 #define DEBUG_INTR_ID SDMA_INT_BIT_DBG 90 #define TEA_INTR_ID SDMA_INT_BIT_TEA 93 #define TASK_AUTOSTART_ENABLE 1 96 #define TASK_AUTOSTART_DISABLE 0 99 #define TASK_INTERRUPT_ENABLE 1 102 #define TASK_INTERRUPT_DISABLE 0 108 #define TASK_BD_TFD (1 << SDMA_DRD_BIT_TFD) 111 #define TASK_BD_INT (1 << SDMA_DRD_BIT_INT) 149 INITIATOR_ALWAYS = 0,
150 INITIATOR_SCTMR_0 = 1,
151 INITIATOR_SCTMR_1 = 2,
152 INITIATOR_FEC_RX = 3,
153 INITIATOR_FEC_TX = 4,
154 INITIATOR_ATA_RX = 5,
155 INITIATOR_ATA_TX = 6,
156 INITIATOR_SCPCI_RX = 7,
157 INITIATOR_SCPCI_TX = 8,
158 INITIATOR_PSC3_RX = 9,
159 INITIATOR_PSC3_TX = 10,
160 INITIATOR_PSC2_RX = 11,
161 INITIATOR_PSC2_TX = 12,
162 INITIATOR_PSC1_RX = 13,
163 INITIATOR_PSC1_TX = 14,
164 INITIATOR_SCTMR_2 = 15,
166 INITIATOR_SCLPC = 16,
167 INITIATOR_PSC5_RX = 17,
168 INITIATOR_PSC5_TX = 18,
169 INITIATOR_PSC4_RX = 19,
170 INITIATOR_PSC4_TX = 20,
171 INITIATOR_I2C2_RX = 21,
172 INITIATOR_I2C2_TX = 22,
173 INITIATOR_I2C1_RX = 23,
174 INITIATOR_I2C1_TX = 24,
175 INITIATOR_PSC6_RX = 25,
176 INITIATOR_PSC6_TX = 26,
177 INITIATOR_IRDA_RX = 25,
178 INITIATOR_IRDA_TX = 26,
179 INITIATOR_SCTMR_3 = 27,
180 INITIATOR_SCTMR_4 = 28,
181 INITIATOR_SCTMR_5 = 29,
182 INITIATOR_SCTMR_6 = 30,
183 INITIATOR_SCTMR_7 = 31
254 #include "bestcomm_priv.h" 255 #include "dma_image.capi.h" 280 #define TaskSetupHelper(TaskName, TaskSetupParams) \ 281 TaskSetup_ ## TaskName (TaskName ## _api, TaskSetupParams) 282 #define TaskSetup(TaskName, TaskSetupParams) \ 283 TaskSetupHelper(TaskName, TaskSetupParams) 294 int TaskStart(TaskId taskId, uint32 autoStartEnable,
295 TaskId autoStartTask, uint32 intrEnable);
297 static int TaskStatus(TaskId taskId);
298 BDIdx
TaskBDAssign(TaskId taskId,
void *buffer0,
void *buffer1,
299 int size, uint32 bdFlags);
302 static TaskBD_t *TaskGetBD(TaskId taskId, BDIdx bd);
303 static TaskBD_t *TaskGetBDRing(TaskId taskId);
305 static int TaskIntClear(TaskId taskId);
306 static TaskId TaskIntStatus(TaskId taskId);
307 static int TaskIntPending(TaskId taskId);
308 static TaskId TaskIntSource(
void);
309 static uint16 TaskBDInUse(TaskId taskId);
318 static inline int TaskStatus(TaskId taskId)
320 return SDMA_TASK_STATUS(SDMA_TCR, taskId) & 0x8000;
333 static inline TaskBD_t *TaskGetBD(TaskId taskId, BDIdx bd)
337 bdTab = TaskBDIdxTable[taskId].BDTablePtr;
338 if (TaskBDIdxTable[taskId].numPtr == 1) {
356 static inline TaskBD_t *TaskGetBDRing(TaskId taskId)
358 return (
TaskBD_t *) TaskBDIdxTable[taskId].BDTablePtr;
366 static inline int TaskIntClear(TaskId taskId)
368 SDMA_CLEAR_IEVENT(SDMA_INT_PEND, taskId);
381 static inline TaskId TaskIntStatus(TaskId taskId)
385 pending = SDMA_INT_PENDING(SDMA_INT_PEND, SDMA_INT_MASK);
387 if (SDMA_INT_TEST(pending, taskId)) {
404 static inline int TaskIntPending(TaskId taskId)
408 pending = SDMA_INT_PENDING(SDMA_INT_PEND, SDMA_INT_MASK);
409 if (SDMA_INT_TEST(pending, taskId)) {
425 static inline TaskId TaskIntSource(
void)
431 pending = SDMA_INT_PENDING(SDMA_INT_PEND, SDMA_INT_MASK);
433 if (SDMA_INT_TEST(pending, SDMA_INT_BIT_TEA)) {
434 return (TaskId)SDMA_TEA_SOURCE(SDMA_INT_PEND);
437 for (i = (
MAX_TASKS - 1); i >= 0; --i, mask >>= 1) {
438 if (pending & mask) {
451 static inline uint16 TaskBDInUse(TaskId taskId)
453 return TaskBDIdxTable[taskId].currBDInUse;
#define TEA_INTR_ID
TEA interrupt "task ID".
Definition: bestcomm_api.h:90
uint32 StartAddrSrc
Definition: bestcomm_api.h:204
Definition: bestcomm_api.h:117
Single buffer descriptor.
Definition: bestcomm_api.h:235
#define MAX_TASKS
Maximum number of tasks in the system. This number is hardware-dependent and not user configuration...
Definition: bestcomm_api.h:71
sint16 IncrDst
Definition: bestcomm_api.h:208
MPC5200Initiator_t Initiator
Definition: bestcomm_api.h:203
const char * TaskVersion(void)
Get a string containing API version information.
Definition: bestcomm_api.c:81
Sz_t SzDst
Definition: bestcomm_api.h:209
uint32 StartAddrDst
Definition: bestcomm_api.h:207
uint32 NumBytes
Definition: bestcomm_api.h:199
Definition: bestcomm_api.h:118
uint32 Status
Definition: bestcomm_api.h:236
Definition: bestcomm_api.h:136
int TaskStart(TaskId taskId, uint32 autoStartEnable, TaskId autoStartTask, uint32 intrEnable)
Start an initialized task running.
Definition: bestcomm_api.c:187
Definition: bestcomm_api.h:127
Definition: bestcomm_api.h:130
int TasksInitAPI_VM(uint8 *MBarRef, uint8 *MBarPhys)
Initialize the API when virtual memory is used.
Definition: bestcomm_api.c:142
Definition: bestcomm_api.h:120
uint32 NumBD
Definition: bestcomm_api.h:195
Parameters for TaskSetup()
Definition: bestcomm_api.h:194
BDIdx TaskBDRelease(TaskId taskId)
Release last buffer in the buffer descriptor ring.
Definition: bestcomm_api.c:346
int TaskDebug(TaskId taskId, TaskDebugParamSet_t *paramSet)
Return BestComm debug information.
Definition: bestcomm_api.c:442
Definition: bestcomm_api.h:135
int TaskStop(TaskId taskId)
Stop a running task.
Definition: bestcomm_api.c:217
Definition: bestcomm_api.h:138
Generic buffer descriptor.
Definition: bestcomm_api.h:228
#define DEBUG_INTR_ID
Debug interrupt "task ID".
Definition: bestcomm_api.h:87
TaskErr_t
API error codes.
Definition: bestcomm_api.h:126
BDIdx TaskBDReset(TaskId taskId)
Release all buffers.
Definition: bestcomm_api.c:404
uint32 Status
Definition: bestcomm_api.h:244
Definition: bestcomm_api.h:132
sint16 IncrSrc
Definition: bestcomm_api.h:205
Parameters for TaskDebug()
Definition: bestcomm_api.h:218
int TasksAttachImage(sdma_regs *sdma)
Deprecated
Definition: bestcomm_api.c:170
Sz_t SzSrc
Definition: bestcomm_api.h:206
Dual buffer descriptor.
Definition: bestcomm_api.h:243
int TasksInitAPI(uint8 *MBarRef)
Initialize the API.
Definition: bestcomm_api.c:100
Sz_t
Data transfer size.
Definition: bestcomm_api.h:116
Definition: bestcomm_api.h:134
uint32 MaxBuf
Definition: bestcomm_api.h:198
MPC5200Initiator_t
BestComm initiators.
Definition: bestcomm_api.h:147
Definition: bestcomm_api.h:131
Definition: bestcomm_api.h:128
unsigned size
Definition: tte.h:74
uint32 Status
Definition: bestcomm_api.h:229
BDIdx TaskBDAssign(TaskId taskId, void *buffer0, void *buffer1, int size, uint32 bdFlags)
Assign a buffer to a buffer descriptor.
Definition: bestcomm_api.c:247
void TasksLoadImage(sdma_regs *sdma)
Load BestComm tasks into SRAM.
Definition: load_task.c:68
Definition: bestcomm_api.h:119