]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/mcbsp-lld.git/blob - device/c674x/device_mcbsp_loopback.c
removing osal.c from previous example/k2g path.
[keystone-rtos/mcbsp-lld.git] / device / c674x / 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 /* CSL Chip Functional Layer */
53 // #include <ti/csl/csl_chip.h> // no functional CSL for Freon
55 #include <ti/csl/soc_OMAPL138.h>
58 /*============================================================================*/
59 /*                           IMPORTED VARIABLES                               */
60 /*============================================================================*/
62 extern Mcbsp_HwInfo Mcbsp_deviceInstInfo[CSL_MCBSP_PER_CNT];
63 extern Mcbsp_TempBuffer Mcbsp_muteBuf[CSL_MCBSP_PER_CNT];
65 #ifdef MCBSP_LOOPJOB_ENABLE
66 extern Mcbsp_TempBuffer Mcbsp_loopDstBuf[CSL_MCBSP_PER_CNT];
67 extern Mcbsp_TempBuffer Mcbsp_loopSrcBuf[CSL_MCBSP_PER_CNT];
68 #endif /* MCBSP_LOOPJOB_ENABLE */
70 /* ========================================================================== */
71 /*                           MODULE FUNCTIONS                                 */
72 /* ========================================================================== */
73 /**
74  * \brief   Initializes McBSP driver's data structures
75  *
76  *          This function initializes the McBSP driver's data structures
77  *          including instance objects and channel objects. This is the 
78  *          MCBSP Driver Initialization API which needs to be invoked by 
79  *          the users to initialize the MCBSP peripheral. This call is 
80  *          *mandatory* and should be called before calling any of the 
81  *          other driver API's.  This can be modified by customers for 
82  *          their application and configuration.
83  *
84  * \return  None
85  */
86 void McbspDevice_init(void)
87 {
88     int32_t devId = 0;
89     void *key;
91     /* Begin Critical Section before accessing shared resources. */
92     key = Mcbsp_osalEnterMultipleCoreCriticalSection ();
94     /* Invalidate the Cache Contents */
95     Mcbsp_osalBeginMemAccess ((void *)Mcbsp_deviceInstInfo, sizeof(Mcbsp_deviceInstInfo));
97     /* initialize the loop job buffers and the mute buffers for all instances  */
98 #ifdef MCBSP_LOOPJOB_ENABLE
99     Mcbsp_osalBeginMemAccess ((void *)Mcbsp_loopDstBuf, sizeof(Mcbsp_loopDstBuf));
100     Mcbsp_osalBeginMemAccess ((void *)Mcbsp_loopSrcBuf, sizeof(Mcbsp_loopSrcBuf));
101     memset((void *)Mcbsp_loopDstBuf,0x0,
102         sizeof(Mcbsp_TempBuffer) * CSL_MCBSP_PER_CNT);
103     memset((void *)Mcbsp_loopSrcBuf,0x0,
104         sizeof(Mcbsp_TempBuffer) * CSL_MCBSP_PER_CNT);
105 #endif /* MCBSP_LOOPJOB_ENABLE */
106     Mcbsp_osalBeginMemAccess ((void *)Mcbsp_muteBuf, sizeof(Mcbsp_muteBuf));
107     memset((void *)Mcbsp_muteBuf,0x0,
108         sizeof(Mcbsp_TempBuffer) * CSL_MCBSP_PER_CNT);
110     /* initialize the information for all the device instances                */
111     for (devId = 0; devId < CSL_MCBSP_PER_CNT; devId++)
112     {
113         if (0 == devId)
114         {
115             /* instance 0 initialisation                                      */
116                  /* instance 0 initialisation                                      */
117                             Mcbsp_deviceInstInfo[devId].obj.instNum = (uint32_t)devId;
118                             Mcbsp_deviceInstInfo[devId].obj.regs =
119                                 (CSL_McbspRegsOvly)CSL_MCBSP_0_CTRL_REGS;
120                             Mcbsp_deviceInstInfo[devId].obj.fifoRegs =
121                                 (CSL_BfifoRegsOvly)CSL_MCBSP_0_FIFO_REGS;
122                             Mcbsp_deviceInstInfo[devId].obj.dataAddress =
123                                 (CSL_BdataRegsOvly)CSL_MCBSP_0_DATA_REGS;
124                             Mcbsp_deviceInstInfo[devId].obj.edmaTxEventNum =
125                                 (uint32_t)CSL_EDMA3_CHA_MCBSP0_TX;
126                             Mcbsp_deviceInstInfo[devId].obj.edmaRxEventNum =
127                                 (uint32_t)CSL_EDMA3_CHA_MCBSP0_RX;
128                             Mcbsp_deviceInstInfo[devId].obj.cpuTxEventNum =
129                                 (uint32_t)CSL_INTC_EVENTID_MCBSP0_TXINT ;
130                             Mcbsp_deviceInstInfo[devId].obj.cpuRxEventNum =
131                                 (uint32_t)CSL_INTC_EVENTID_MCBSP0_RXINT ;
132                         }
133                         else if (1 == devId)
134                         {
135                             /* instance 1 initialisation                                      */
136                             Mcbsp_deviceInstInfo[devId].obj.instNum = (uint32_t)devId;
137                             Mcbsp_deviceInstInfo[devId].obj.regs =
138                                 (CSL_McbspRegsOvly)CSL_MCBSP_1_CTRL_REGS;
139                             Mcbsp_deviceInstInfo[devId].obj.fifoRegs =
140                                 (CSL_BfifoRegsOvly)CSL_MCBSP_1_FIFO_REGS;
141                             Mcbsp_deviceInstInfo[devId].obj.dataAddress =
142                                 (CSL_BdataRegsOvly)CSL_MCBSP_1_DATA_REGS;
143                             Mcbsp_deviceInstInfo[devId].obj.edmaTxEventNum =
144                                 (uint32_t)CSL_EDMA3_CHA_MCBSP1_TX;
145                             Mcbsp_deviceInstInfo[devId].obj.edmaRxEventNum =
146                                 (uint32_t)CSL_EDMA3_CHA_MCBSP1_RX;
147                             Mcbsp_deviceInstInfo[devId].obj.cpuTxEventNum =
148                                 (uint32_t)CSL_INTC_EVENTID_MCBSP1_TXINT ;
149                             Mcbsp_deviceInstInfo[devId].obj.cpuRxEventNum =
150                                 (uint32_t)CSL_INTC_EVENTID_MCBSP1_RXINT ;
151                         }
152                         else
153                         {
154                             /* do nothing                                                     */
155                         }
157 #ifdef MCBSP_LOOPJOB_ENABLE
158         /* align the buffers to the cache line size                           */
159         Mcbsp_loopSrcBuf[devId].scratchBuffer = (uint32_t *)
160             (((uint32_t)Mcbsp_loopSrcBuf[devId].scratchBuf + 0x7F) & ~0x7F);
162         Mcbsp_loopDstBuf[devId].scratchBuffer = (uint32_t *)
163             (((uint32_t)Mcbsp_loopDstBuf[devId].scratchBuf + 0x7F) & ~0x7F);
165         Mcbsp_osalEndMemAccess ((void *)Mcbsp_loopSrcBuf, sizeof(Mcbsp_loopSrcBuf));
166         Mcbsp_osalEndMemAccess ((void *)Mcbsp_loopDstBuf, sizeof(Mcbsp_loopDstBuf));
167 #endif /* MCBSP_LOOPJOB_ENABLE */
168         Mcbsp_muteBuf[devId].scratchBuffer = (uint32_t *)
169             (((uint32_t)Mcbsp_muteBuf[devId].scratchBuf + 0x7F) & ~0x7F);
170         Mcbsp_osalEndMemAccess ((void *)Mcbsp_muteBuf, sizeof(Mcbsp_muteBuf));
171     }
173     /* Writeback Global Objects */
174     Mcbsp_osalEndMemAccess ((void *)Mcbsp_deviceInstInfo, sizeof(Mcbsp_deviceInstInfo));
176     /* End Critical Section */
177     Mcbsp_osalExitMultipleCoreCriticalSection (key);
179     return;
182 /* ========================================================================== */
183 /*                              END OF FILE                                   */
184 /* ========================================================================== */