]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/mcbsp-lld.git/blob - device/omapl138/src/device_mcbsp_loopback.c
PRSDK-3513 Addressed build errors
[keystone-rtos/mcbsp-lld.git] / device / omapl138 / src / device_mcbsp_loopback.c
1 /*
2  * mcbsp_device.c
3  *
4  * This file contains MCBSP IP related EVM (platform) specific routines
5  * implementation. This file contains the board specific code for enabling 
6  * the use of mcbsp driver, and may contain related device pre-driver 
7  * initialization routines. The file is provided as a sample configuration 
8  * and should be modified by customers for their own platforms and 
9  * configurations.
10  *
11  * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
12  *
13  *
14  *  Redistribution and use in source and binary forms, with or without
15  *  modification, are permitted provided that the following conditions
16  *  are met:
17  *
18  *    Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions and the following disclaimer.
20  *
21  *    Redistributions in binary form must reproduce the above copyright
22  *    notice, this list of conditions and the following disclaimer in the
23  *    documentation and/or other materials provided with the
24  *    distribution.
25  *
26  *    Neither the name of Texas Instruments Incorporated nor the names of
27  *    its contributors may be used to endorse or promote products derived
28  *    from this software without specific prior written permission.
29  *
30  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  *
42 */
44 /* MCBSP Driver Includes. */
45 #include <ti/drv/mcbsp/mcbsp_types.h>
46 #include <ti/drv/mcbsp/mcbsp_drv.h>
47 #include <ti/drv/mcbsp/mcbsp_osal.h>
49 /* CSL MCBSP Register Layer */
50 #include <ti/csl/cslr_mcbsp.h>
52 #include <ti/csl/cslr_device.h>
54 #include <ti/csl/soc.h>
56 /*============================================================================*/
57 /*                           IMPORTED VARIABLES                               */
58 /*============================================================================*/
60 extern Mcbsp_HwInfo Mcbsp_deviceInstInfo[CSL_MCBSP_CNT];
61 extern Mcbsp_TempBuffer Mcbsp_muteBuf[CSL_MCBSP_CNT];
63 #ifdef MCBSP_LOOPJOB_ENABLE
64 extern Mcbsp_TempBuffer Mcbsp_loopDstBuf[CSL_MCBSP_CNT];
65 extern Mcbsp_TempBuffer Mcbsp_loopSrcBuf[CSL_MCBSP_CNT];
66 #endif /* MCBSP_LOOPJOB_ENABLE */
68 /* ========================================================================== */
69 /*                           MODULE FUNCTIONS                                 */
70 /* ========================================================================== */
71 /**
72  * \brief   Initializes McBSP driver's data structures
73  *
74  *          This function initializes the McBSP driver's data structures
75  *          including instance objects and channel objects. This is the 
76  *          MCBSP Driver Initialization API which needs to be invoked by 
77  *          the users to initialize the MCBSP peripheral. This call is 
78  *          *mandatory* and should be called before calling any of the 
79  *          other driver API's.  This can be modified by customers for 
80  *          their application and configuration.
81  *
82  * \return  None
83  */
84 void McbspDevice_init(void)
85 {
86     int32_t devId = 0;
87     void *key;
89     /* Begin Critical Section before accessing shared resources. */
90     key = Mcbsp_osalEnterMultipleCoreCriticalSection ();
92     /* Invalidate the Cache Contents */
93     Mcbsp_osalBeginMemAccess ((void *)Mcbsp_deviceInstInfo, sizeof(Mcbsp_deviceInstInfo));
95     /* initialize the loop job buffers and the mute buffers for all instances  */
96 #ifdef MCBSP_LOOPJOB_ENABLE
97     Mcbsp_osalBeginMemAccess ((void *)Mcbsp_loopDstBuf, sizeof(Mcbsp_loopDstBuf));
98     Mcbsp_osalBeginMemAccess ((void *)Mcbsp_loopSrcBuf, sizeof(Mcbsp_loopSrcBuf));
99     memset((void *)Mcbsp_loopDstBuf,0x0,
100         sizeof(Mcbsp_TempBuffer) * CSL_MCBSP_CNT);
101     memset((void *)Mcbsp_loopSrcBuf,0x0,
102         sizeof(Mcbsp_TempBuffer) * CSL_MCBSP_CNT);
103 #endif /* MCBSP_LOOPJOB_ENABLE */
104     Mcbsp_osalBeginMemAccess ((void *)Mcbsp_muteBuf, sizeof(Mcbsp_muteBuf));
105     memset((void *)Mcbsp_muteBuf,0x0,
106         sizeof(Mcbsp_TempBuffer) * CSL_MCBSP_CNT);
108     /* initialize the information for all the device instances                */
109     for (devId = 0; devId < CSL_MCBSP_CNT; devId++)
110     {
111         if (0 == devId)
112         {
113             /* instance 0 initialisation                                      */
114                  /* instance 0 initialisation                                      */
115                             Mcbsp_deviceInstInfo[devId].obj.instNum = (uint32_t)devId;
116                             Mcbsp_deviceInstInfo[devId].obj.regs =
117                                 (CSL_McbspRegsOvly)CSL_MCBSP_0_CTRL_REGS;
118                             Mcbsp_deviceInstInfo[devId].obj.fifoRegs =
119                                 (CSL_BfifoRegsOvly)CSL_MCBSP_0_FIFO_REGS;
120                             Mcbsp_deviceInstInfo[devId].obj.dataAddress =
121                                 (CSL_BdataRegsOvly)CSL_MCBSP_0_DATA_REGS;
122                             Mcbsp_deviceInstInfo[devId].obj.edmaTxEventNum =
123                                 (uint32_t)CSL_EDMA3_CHA_MCBSP0_TX;
124                             Mcbsp_deviceInstInfo[devId].obj.edmaRxEventNum =
125                                 (uint32_t)CSL_EDMA3_CHA_MCBSP0_RX;
126                             Mcbsp_deviceInstInfo[devId].obj.cpuTxEventNum =
127                                 (uint32_t)CSL_INTC_EVENTID_MCBSP0_TXINT ;
128                             Mcbsp_deviceInstInfo[devId].obj.cpuRxEventNum =
129                                 (uint32_t)CSL_INTC_EVENTID_MCBSP0_RXINT ;
130                         }
131                         else if (1 == devId)
132                         {
133                             /* instance 1 initialisation                                      */
134                             Mcbsp_deviceInstInfo[devId].obj.instNum = (uint32_t)devId;
135                             Mcbsp_deviceInstInfo[devId].obj.regs =
136                                 (CSL_McbspRegsOvly)CSL_MCBSP_1_CTRL_REGS;
137                             Mcbsp_deviceInstInfo[devId].obj.fifoRegs =
138                                 (CSL_BfifoRegsOvly)CSL_MCBSP_1_FIFO_REGS;
139                             Mcbsp_deviceInstInfo[devId].obj.dataAddress =
140                                 (CSL_BdataRegsOvly)CSL_MCBSP_1_DATA_REGS;
141                             Mcbsp_deviceInstInfo[devId].obj.edmaTxEventNum =
142                                 (uint32_t)CSL_EDMA3_CHA_MCBSP1_TX;
143                             Mcbsp_deviceInstInfo[devId].obj.edmaRxEventNum =
144                                 (uint32_t)CSL_EDMA3_CHA_MCBSP1_RX;
145                             Mcbsp_deviceInstInfo[devId].obj.cpuTxEventNum =
146                                 (uint32_t)CSL_INTC_EVENTID_MCBSP1_TXINT ;
147                             Mcbsp_deviceInstInfo[devId].obj.cpuRxEventNum =
148                                 (uint32_t)CSL_INTC_EVENTID_MCBSP1_RXINT ;
149                         }
150                         else
151                         {
152                             /* do nothing                                                     */
153                         }
155 #ifdef MCBSP_LOOPJOB_ENABLE
156         /* align the buffers to the cache line size                           */
157         Mcbsp_loopSrcBuf[devId].scratchBuffer = (uint32_t *)
158             (((uint32_t)Mcbsp_loopSrcBuf[devId].scratchBuf + 0x7F) & ~0x7F);
160         Mcbsp_loopDstBuf[devId].scratchBuffer = (uint32_t *)
161             (((uint32_t)Mcbsp_loopDstBuf[devId].scratchBuf + 0x7F) & ~0x7F);
163         Mcbsp_osalEndMemAccess ((void *)Mcbsp_loopSrcBuf, sizeof(Mcbsp_loopSrcBuf));
164         Mcbsp_osalEndMemAccess ((void *)Mcbsp_loopDstBuf, sizeof(Mcbsp_loopDstBuf));
165 #endif /* MCBSP_LOOPJOB_ENABLE */
166         Mcbsp_muteBuf[devId].scratchBuffer = (uint32_t *)
167             (((uint32_t)Mcbsp_muteBuf[devId].scratchBuf + 0x7F) & ~0x7F);
168         Mcbsp_osalEndMemAccess ((void *)Mcbsp_muteBuf, sizeof(Mcbsp_muteBuf));
169     }
171     /* Writeback Global Objects */
172     Mcbsp_osalEndMemAccess ((void *)Mcbsp_deviceInstInfo, sizeof(Mcbsp_deviceInstInfo));
174     /* End Critical Section */
175     Mcbsp_osalExitMultipleCoreCriticalSection (key);
177     return;
180 /* ========================================================================== */
181 /*                              END OF FILE                                   */
182 /* ========================================================================== */