PDK API Guide for AM65xx
mcasp_drv.h
Go to the documentation of this file.
1 /*
2  * Mcasp_drv.h
3  *
4  * This file contains Application programming interface for the McASP driver and
5  * command/macro definitions used by the McASP driver.
6  *
7  * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
8  *
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  *
17  * Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the
20  * distribution.
21  *
22  * Neither the name of Texas Instruments Incorporated nor the names of
23  * its contributors may be used to endorse or promote products derived
24  * from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  *
38 */
39 
45  /* @} */
46 
68 #ifndef MCASP_H
69 #define MCASP_H
70 
71 #include "mcasp_types.h"
72 #include <ti/osal/osal.h>
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
77 /*============================================================================*/
78 /* MACRO TYPES */
79 /*============================================================================*/
80 
81 #define Mcasp_CACHE_LENGTH (128u)
82 
84 #define Mcasp_NUMSERIALIZERS (16u)
85 
87 #define Mcasp_GBLCTL_TIMEOUT (30000U)
88 
92 /* McASP return values */
93 #define MCASP_EBADIO (-(1)) /* Generic failure condition */
94 #define MCASP_ETIMEOUT (-(2)) /* Timeout occurred */
95 #define MCASP_ENOPACKETS (-(3)) /* No packets available for I/O */
96 #define MCASP_EFREE (-(4)) /* Unable to free resources */
97 #define MCASP_EALLOC (-(5)) /* Unable to alloc resource */
98 #define MCASP_EABORT (-(6)) /* I/O was aborted before completed */
99 #define MCASP_EBADMODE (-(7)) /* Illegal device mode */
100 #define MCASP_EOF (-(8)) /* End-of-File was encountered */
101 #define MCASP_ENOTIMPL (-(9)) /* Operation not implemented or supported */
102 #define MCASP_EBADARGS (-(10)) /* Illegal arguments specified */
103 #define MCASP_ETIMEOUTUNREC (-(11)) /* Unrecoverable timeout occurred */
104 #define MCASP_EINUSE (-(12)) /* Device already in use */
105 #define MCASP_EINVALIDVAL (-(13)) /* Invalid value encountered (Unexpected) */
106 #define MCASP_COMPLETED (0) /* I/O completed successfully */
107 #define MCASP_PENDING (1) /* I/O queued and pending */
108 
109 /*
110  * I/O request flushed. Queued writes will be completed w/ MCASP_COMPLETED.
111  * Queued read requests return w/ MCASP_FLUSHED.
112  */
113 #define MCASP_FLUSHED 2
114 /*
115  * I/O aborted. Non-completed read or write requests return w/ MCASP_ABORTED.
116  */
117 #define MCASP_ABORTED 3
118 /*============================================================================*/
119 /* ENUMERATED DATA TYPES */
120 /*============================================================================*/
124 typedef enum Mcasp_chanMode_e {
125  MCASP_INPUT = 0x0001,
126  MCASP_OUTPUT = 0x0002,
129 
133 typedef enum Mcasp_IOcmd_e {
142 typedef enum Mcasp_OpMode_e {
145 }Mcasp_OpMode;
146 
150 typedef enum Mcasp_SerializerNum_e {
168 
172 typedef enum Mcasp_WordLength_e {
180 
184 typedef enum Mcasp_WordBitsSelect_e {
191 typedef enum Mcasp_pllDomain_t
192 {
203 
204 
211 typedef enum Mcasp_BufferFormat_e
212 {
213  /* This mode is used for buffer containing the data in continous *
214  * memory locations where each sample is "wordWidth" long. This *
215  * format is supported for following configurations *
216  *
217  * Single serializer in DSP mode.DIT mode also can use this format *
218  * *
219  * Note : interleaved and non interleaved does not apply for this *
220  * buffer format */
222 
223  /* This is used for transfer of data on a single serializer with *
224  * multiple slots.please note that the slot data is not interleaved *
225  * in this format. *
226  * *
227  * TDM with single serializer and slots > 1 uses this format.DIT can *
228  * also use this format */
230  /* This is used for transfer of data on a single serializer with *
231  * multiple slots.please note that the slot data is interleaved *
232  * in this format. *
233  * *
234  * TDM with single serializer and slots > 1 uses this format. DIT *
235  * mode can also be supported here */
237 
238  /* This is used for transfer of data on a single slot with multiple *
239  * serializers enabled.please note that the serializer data is *
240  * interleaved in this format. *
241  * *
242  * DSP and DIT mode with multiple serializer uses this format */
244 
245  /* This is used for transfer of data on a single slot with multiple *
246  * serializers enabled.please note that the serializer data is *
247  * interleaved in this format. *
248  * *
249  * DSP and DIT mode with multiple serializer uses this format */
251 
252  /* This is used for transfer of data with multiple serializers and *
253  * also multiple slots enabled.please note that the serializer data is*
254  * interleaved in this format. The slot data is also interleaved *
255  * Refer to the user guide to view the sample data format. *
256  *
257  * TDM and DIT mode with multiple serializer and multiple slots uses *
258  * this format */
260 
261  /* This is used for transfer of data with multiple serializers and *
262  * also multiple slots enabled.please note that the serializer data is*
263  * NOT interleaved in this format. The slot data is interleaved *
264  * Refer to the user guide to view the sample data format. *
265  *
266  * TDM and DIT mode with multiple serializer and multiple slots uses *
267  * this format */
269 
270  /* we are unable to support this buffer format because the MCASP gives*
271  * tx underrun error.
272  * When 2 serializers are configured in 2 slot mode each. The MCASP *
273  * even though it receives two 16 bit samples it considers it as only *
274  * one 32 bit sample because of which it will always give an underrun *
275  * error. Hence this buffer format cannot be supported *
276  * This is used for transfer of data with multiple serializers and *
277  * also multiple slots enabled.please note that the slot data is *
278  * NOT interleaved in this format. The serializer data is interleaved *
279  * Refer to the user guide to view the sample data format. *
280  *
281  * TDM and DIT mode with multiple serializer and multiple slots uses *
282  * this format *
283  BufferFormat_MULTISER_MULTISLOT_SEMI_INTERLEAVED_3,
284  */
286 
287 /* -------- typedefs -------- */
295 typedef struct
296 {
297  bool isDMAErr;
303  bool isSyncErr;
305  uint32_t retVal;
315 typedef void (*Mcasp_GblCallback)(Mcasp_errCbStatus errCbStat);
316 
323 typedef void (*Mcasp_Isr)(void *arg);
324 
325 /* -------- structs -------- */
326 
330 typedef struct Mcasp_HwSetupDataClk_s {
331  uint32_t clkSetupClk;
332  uint32_t clkSetupHiClk;
333  uint32_t clkChk;
335 
339 typedef struct Mcasp_HwSetupGbl_s {
340  uint32_t pfunc;
341  uint32_t pdir;
342  uint32_t ctl;
343  uint32_t ditCtl;
344  uint32_t dlbMode;
345  uint32_t amute;
346  uint32_t serSetup[16u];
348 
352 typedef struct Mcasp_HwSetupData_s {
353  uint32_t mask;
354  uint32_t fmt;
355  uint32_t frSyncCtl;
356  uint32_t tdm;
357  uint32_t intCtl;
358  uint32_t stat;
360  uint32_t evtCtl;
363 
367 typedef struct Mcasp_HwSetup_s {
371  uint32_t emu;
373 
374 
377 typedef struct Mcasp_AudioDevData_s
378 {
379  uint16_t isMaster;
383 
389 typedef struct Mcasp_ChanParams_s {
393  uint32_t indexOfSersRequested[16u];
399  uint16_t isDmaDriven;
406  uint16_t wordWidth;
425  void * edmaHandle;
432  uint32_t noOfChannels;
443  uint16_t enableHwFifo;
454  uint16_t isDataPacked;
463 
467 typedef struct Mcasp_ChStatusRam_s {
468  uint32_t chStatusLeft[6];
471  uint32_t chStatusRight[6];
474 
478 typedef struct Mcasp_UserDataRam_s {
479  uint32_t userDataLeft[6];
482  uint32_t userDataRight[6];
485 
500 typedef struct Mcasp_PktAddrPayload_s {
507  uint16_t writeDitParams;
511  uint32_t* addr;
516 
524 
533 typedef struct Mcasp_IOBuf_t
534 {
538  void* addr;
541  uint32_t size;
544  uintptr_t arg;
550  int32_t status;
553  uint32_t misc;
555 } MCASP_Packet;
556 
557 /*============================================================================*/
558 /* TYPEDEFS */
559 /*============================================================================*/
560 
561 
562 
583 typedef void (*MCASP_TiomCallback)(void * arg, MCASP_Packet *packet);
584 
585 /*============================================================================*/
586 /* IOCTL COMMANDS */
587 /*============================================================================*/
588 
594 typedef enum Mcasp_ioctlCmd_e {
597 
600 
605 
608 
611 
614 
617 
620 
623 
626 
629 
632 
635 
638 
641 
644 
647 
650 
653 
656 
659 
663 
666 
670 
674 
678 
685 
689 
697 
698 /* -------- per-instance configs -------- */
699 
700 typedef struct Mcasp_Params_s
701 {
702 
703  uint16_t enablecache;
716  uint16_t pscPwrmEnable;
718 }Mcasp_Params;
719 
720 
721 extern const Mcasp_Params Mcasp_PARAMS;
722 
723 /**********************************************************************
724  **************************** EXPORTED API ****************************
725  **********************************************************************/
726 
727 int32_t mcaspBindDev(void* *devp, int32_t devId, void* devParams);
728 int32_t mcaspUnBindDev(void* devp);
729 int32_t mcaspCreateChan(void* *chanp, void* devp,
730  Mcasp_chanMode_e mode, void* chanParams, MCASP_TiomCallback cbFxn,
731  void* cbArg);
732 int32_t mcaspSubmitChan(void* chanp, MCASP_Packet *ioPacket);
733 int32_t mcaspDeleteChan(void* chanp);
734 int32_t mcaspControlChan(void* chanp, Mcasp_ioctlCmd cmd, void* cmdArgs);
735 
736 #ifdef __cplusplus
737 }
738 #endif
739 
740 #endif /*MCASP_H */
741 /* @} */
742 
uint16_t writeDitParams
Definition: mcasp_drv.h:507
void * edmaHandle
Definition: mcasp_drv.h:425
Definition: mcasp_drv.h:637
uint32_t dlbMode
Definition: mcasp_drv.h:344
Mcasp_ChStatusRam * chStat
Definition: mcasp_drv.h:501
Definition: mcasp_drv.h:155
int32_t mcaspSubmitChan(void *chanp, MCASP_Packet *ioPacket)
OS Abstraction Layer header.
bool isSyncErr
Definition: mcasp_drv.h:303
Definition: mcasp_drv.h:628
Definition: mcasp_drv.h:649
DIT channel status register structure.
Definition: mcasp_drv.h:467
Definition: mcasp_drv.h:604
int32_t mcaspDeleteChan(void *chanp)
Definition: mcasp_drv.h:173
Definition: mcasp_drv.h:166
Definition: mcasp_drv.h:137
Definition: mcasp_drv.h:125
Definition: mcasp_drv.h:178
bool isRcvOvrRunOrTxUndRunErr
Definition: mcasp_drv.h:299
int32_t mcaspUnBindDev(void *devp)
uint16_t enableHwFifo
Definition: mcasp_drv.h:443
void(* Mcasp_Isr)(void *arg)
Mcasp Interrupt service routine.
Definition: mcasp_drv.h:323
Structure passed through DriverTypes_Packet addr field.
Definition: mcasp_drv.h:500
Definition: mcasp_drv.h:164
Definition: mcasp_drv.h:607
Definition: mcasp_drv.h:175
Definition: mcasp_drv.h:599
Definition: mcasp_drv.h:643
structure to store the audio device related information
Definition: mcasp_drv.h:377
uint32_t evtCtl
Definition: mcasp_drv.h:360
Mcasp_HwSetupData * mcaspSetup
Definition: mcasp_drv.h:396
uint32_t noOfChannels
Definition: mcasp_drv.h:432
Mcasp_OpMode
enumerated constants for the Transfer modes supported by Mcasp
Definition: mcasp_drv.h:142
Definition: mcasp_drv.h:158
Definition: mcasp_drv.h:596
Hardware setup data clock structure.
Definition: mcasp_drv.h:330
uint32_t tdm
Definition: mcasp_drv.h:356
uintptr_t arg
Definition: mcasp_drv.h:544
Mcasp_SerializerNum
Enumeration for the MCASP serializer numbers.
Definition: mcasp_drv.h:150
Definition: mcasp_drv.h:602
Definition: mcasp_drv.h:616
uint32_t mask
Definition: mcasp_drv.h:353
uint32_t amute
Definition: mcasp_drv.h:345
Mcasp_HwSetupData tx
Definition: mcasp_drv.h:370
uint32_t stat
Definition: mcasp_drv.h:358
Mcasp_WordBitsSelect
Enumerated constant for selecting MSB/LSB word in the slot bits.
Definition: mcasp_drv.h:184
int32_t mcaspCreateChan(void **chanp, void *devp, Mcasp_chanMode_e mode, void *chanParams, MCASP_TiomCallback cbFxn, void *cbArg)
uint16_t pscPwrmEnable
Definition: mcasp_drv.h:716
void(* Mcasp_GblCallback)(Mcasp_errCbStatus errCbStat)
Global error callback function protype.
Definition: mcasp_drv.h:315
uint16_t isDmaDriven
Definition: mcasp_drv.h:399
Definition: mcasp_drv.h:677
Mcasp_HwSetup mcaspHwSetup
Definition: mcasp_drv.h:713
void * addr
Definition: mcasp_drv.h:538
Mcasp_WordBitsSelect wordBitsSelect
Definition: mcasp_drv.h:458
Definition: mcasp_drv.h:152
Mcasp_IOcmd_e cmd
Definition: mcasp_drv.h:547
int32_t mcaspControlChan(void *chanp, Mcasp_ioctlCmd cmd, void *cmdArgs)
Definition: mcasp_drv.h:151
Definition: mcasp_drv.h:159
Mcasp_HwSetupData rx
Definition: mcasp_drv.h:369
Definition: mcasp_drv.h:625
Definition: mcasp_drv.h:700
Mcasp_OpMode channelMode
Definition: mcasp_drv.h:403
Definition: mcasp_drv.h:165
int32_t status
Definition: mcasp_drv.h:550
Definition: mcasp_drv.h:196
Definition: mcasp_drv.h:126
uint16_t isDataBufferPayloadStructure
Definition: mcasp_drv.h:706
Definition: mcasp_drv.h:634
uint32_t pfunc
Definition: mcasp_drv.h:340
uint16_t wordWidth
Definition: mcasp_drv.h:406
Mcasp_WordLength
Enumerated constant for wordlength supported by the MCASP device.
Definition: mcasp_drv.h:172
Definition: mcasp_drv.h:176
Definition: mcasp_drv.h:665
Definition: mcasp_drv.h:144
uint16_t userLoopJobLength
Definition: mcasp_drv.h:419
void(* MCASP_TiomCallback)(void *arg, MCASP_Packet *packet)
EDMA TC callback function prototype This function is the call back function provided by the applicati...
Definition: mcasp_drv.h:583
uint16_t noOfSerRequested
Definition: mcasp_drv.h:390
Definition: mcasp_drv.h:199
Definition: mcasp_drv.h:193
channel Parameters to initialize channel Object
Definition: mcasp_drv.h:389
Hardware setup data structure.
Definition: mcasp_drv.h:352
Definition: mcasp_drv.h:610
uint32_t clkSetupHiClk
Definition: mcasp_drv.h:332
const Mcasp_Params Mcasp_PARAMS
Definition: mcasp_drv.h:162
Definition: mcasp_drv.h:619
Definition: mcasp_drv.h:613
Opaque QueueP element.
Definition: QueueP.h:98
Mcasp_HwSetupDataClk clk
Definition: mcasp_drv.h:361
Mcasp_BufferFormat
Enum to specify the supported buffer formats.
Definition: mcasp_drv.h:211
Mcasp_chanMode_e
enumerated constants for the channel modes supported by Mcasp
Definition: mcasp_drv.h:124
Definition: mcasp_drv.h:136
Definition: mcasp_drv.h:669
char mode[32]
Definition: tisci_pm_core.h:130
uint16_t enablecache
Definition: mcasp_drv.h:703
bool isDMAErr
Definition: mcasp_drv.h:297
Definition: mcasp_drv.h:652
structure to hold the error condition and the status
Definition: mcasp_drv.h:295
Definition: mcasp_drv.h:185
Definition: mcasp_drv.h:655
Definition: mcasp_drv.h:640
Definition: mcasp_drv.h:622
Definition: mcasp_drv.h:143
Definition: mcasp_drv.h:673
Mcasp_UserDataRam * userData
Definition: mcasp_drv.h:504
McASP frame object params.
Definition: mcasp_drv.h:533
Definition: mcasp_drv.h:135
Definition: mcasp_drv.h:161
uint32_t * addr
Definition: mcasp_drv.h:511
uint32_t misc
Definition: mcasp_drv.h:553
Definition: mcasp_drv.h:154
Mcasp_GblCallback gblCbk
Definition: mcasp_drv.h:428
uint32_t clkSetupClk
Definition: mcasp_drv.h:331
Definition: mcasp_drv.h:221
Definition: mcasp_drv.h:163
bool isClkFailErr
Definition: mcasp_drv.h:301
uint32_t fmt
Definition: mcasp_drv.h:354
Definition: mcasp_drv.h:658
Hardware setup global structure.
Definition: mcasp_drv.h:339
QueueP_Elem Mcasp_QueueElem
McASP queue element.
Definition: mcasp_drv.h:523
Mcasp_ioctlCmd
Mcasp Ioctl commands.
Definition: mcasp_drv.h:594
uint32_t ctl
Definition: mcasp_drv.h:342
Definition: mcasp_drv.h:157
Mcasp_BufferFormat dataFormat
Definition: mcasp_drv.h:440
Definition: mcasp_drv.h:646
int32_t mcaspBindDev(void **devp, int32_t devId, void *devParams)
uint32_t retVal
Definition: mcasp_drv.h:305
uint32_t emu
Definition: mcasp_drv.h:371
Mcasp_HwSetupGbl glb
Definition: mcasp_drv.h:368
Definition: mcasp_drv.h:127
Definition: mcasp_drv.h:177
uint32_t intCtl
Definition: mcasp_drv.h:357
uint32_t clkChk
Definition: mcasp_drv.h:333
Definition: mcasp_drv.h:160
Definition: mcasp_drv.h:153
Definition: mcasp_drv.h:156
uint32_t pdir
Definition: mcasp_drv.h:341
DIT channel user data register structure.
Definition: mcasp_drv.h:478
Mcasp_IOcmd_e
enumerated constants for the commands supported by Mcasp
Definition: mcasp_drv.h:133
uint16_t isDataPacked
Definition: mcasp_drv.h:454
Definition: mcasp_drv.h:662
uint32_t ditCtl
Definition: mcasp_drv.h:343
void * userLoopJobBuffer
Definition: mcasp_drv.h:413
Mcasp_pllDomain
PLL domain to be used by the device.
Definition: mcasp_drv.h:191
Hardware setup structure.
Definition: mcasp_drv.h:367
uint16_t hwFifoEventDMARatio
Definition: mcasp_drv.h:446
uint32_t frSyncCtl
Definition: mcasp_drv.h:355
Definition: mcasp_drv.h:174
Definition: mcasp_drv.h:186
Definition: mcasp_drv.h:134
Definition: mcasp_drv.h:631
Definition: mcasp_drv.h:684
uint16_t isMaster
Definition: mcasp_drv.h:379
uint32_t size
Definition: mcasp_drv.h:541
Mcasp_QueueElem link
Definition: mcasp_drv.h:535