2 /*
3 Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 #ifndef SAP_CSL_MCASP_H_
37 #define SAP_CSL_MCASP_H_
39 #include "sap_csl_mcasphal.h"
41 /******************************************************************************\
42 * global macro declarations
43 \******************************************************************************/
45 /* MCASP_open() flags */
46 #define MCASP_OPEN_RESET (0x00000001)
47 #define MCASP_OPEN (0x00000000)
49 /* device identifiers for MCASP_open() */
50 #define MCASP_DEV0 (0)
51 #define MCASP_DEV1 (1)
52 #define MCASP_DEV2 (2)
55 /* device identifiers for MCASP_open() */
56 #define MCASP_PORT0 MCASP_DEV0
57 #define MCASP_PORT1 MCASP_DEV1
58 #define MCASP_PORT2 MCASP_DEV2
60 /* select DIT vs. TDM mode */
61 #define MCASP_XMT_DIT 1
62 #define MCASP_XMT_TDM 0
64 /* direction = (transmitter only) MCASP_XMT or (receiver only) MCASP_RCV */
65 /* or (both) MCASP_RCVXMT / MCASP_XMTRCV */
66 #define MCASP_RCV 1
67 #define MCASP_XMT 2
68 #define MCASP_RCVXMT 3
69 #define MCASP_XMTRCV 3
71 /* Mode for clk */
72 #define MCASP_CLK_ASYNC 1
73 #define MCASP_CLK_SYNC 0
75 /* define Mode BURST or TDM for format*/
76 #define MCASP_MODE_BURST 0
77 #define MCASP_MODE_TDM 1
79 /* define Mode MSB/LSB first */
80 #define MCASP_FORMAT_LSB 0
81 #define MCASP_FORMAT_MSB 1
83 /* define Align */
84 #define MCASP_FORMAT_LEFT 0
85 #define MCASP_FORMAT_RIGHT 1
87 /* Address Incrementation */
88 #define MCASP_XBUF_BUFSIZE 4
89 #define MCASP_RBUF_BUFSIZE 4
90 #define MCASP_DITCSR_NUMCHANNELS 6
91 #define MCASP_DITCSR_BUFSIZE 4
92 #define MCASP_DITCSR_RIGHT_OFFSET (MCASP_DITCSR_BUFSIZE*MCASP_DITCSR_NUMCHANNELS)
94 #define MCASP_DITUDR_NUMCHANNELS 6
95 #define MCASP_DITUDR_BUFSIZE 4
96 #define MCASP_DITUDR_RIGHT_OFFSET (MCASP_DITUDR_BUFSIZE*MCASP_DITUDR_NUMCHANNELS)
98 /* Status clear */
99 #define MCASP_RSTAT_ROVRN 0
100 #define MCASP_RSTAT_RSYNCERR 1
101 #define MCASP_RSTAT_RCKFAIL 2
102 #define MCASP_RSTAT_REVENSLOT 3
103 #define MCASP_RSTAT_RLAST 4
104 #define MCASP_RSTAT_RDATA 5
105 #define MCASP_RSTAT_RSTAFRM 6
106 #define MCASP_RSTAT_RDMAERR 7
107 #define MCASP_RSTAT_RERR 8
109 #define MCASP_XSTAT_XUNDRN 0
110 #define MCASP_XSTAT_XSYNCERR 1
111 #define MCASP_XSTAT_XCKFAIL 2
112 #define MCASP_XSTAT_XEVENSLOT 3
113 #define MCASP_XSTAT_XLAST 4
114 #define MCASP_XSTAT_XDATA 5
115 #define MCASP_XSTAT_XSTAFRM 6
116 #define MCASP_XSTAT_XDMAERR 7
117 #define MCASP_XSTAT_XERR 8
120 #define MCASP_XBUF0 0
121 #define MCASP_XBUF1 1
122 #define MCASP_XBUF2 2
123 #define MCASP_XBUF3 3
124 #define MCASP_XBUF4 4
125 #define MCASP_XBUF5 5
126 #define MCASP_XBUF6 6
127 #define MCASP_XBUF7 7
128 #define MCASP_XBUF8 8
129 #define MCASP_XBUF9 9
130 #define MCASP_XBUF10 10
131 #define MCASP_XBUF11 11
132 #define MCASP_XBUF12 12
133 #define MCASP_XBUF13 13
134 #define MCASP_XBUF14 14
135 #define MCASP_XBUF15 15
137 #define MCASP_RBUF0 0
138 #define MCASP_RBUF1 1
139 #define MCASP_RBUF2 2
140 #define MCASP_RBUF3 3
141 #define MCASP_RBUF4 4
142 #define MCASP_RBUF5 5
143 #define MCASP_RBUF6 6
144 #define MCASP_RBUF7 7
145 #define MCASP_RBUF8 8
146 #define MCASP_RBUF9 9
147 #define MCASP_RBUF10 10
148 #define MCASP_RBUF11 11
149 #define MCASP_RBUF12 12
150 #define MCASP_RBUF13 13
151 #define MCASP_RBUF14 14
152 #define MCASP_RBUF15 15
154 /******************************************************************************\
155 * global typedef declarations
156 \******************************************************************************/
158 /* device handle object */
159 typedef struct {
160 Uint32 allocated;
161 volatile Uint32 *baseAddr;
162 Uint32 xbufAddr;
163 Uint32 xbufAddrCfg;
164 Uint32 rbufAddr;
165 Uint32 rbufAddrCfg;
166 Uint32 ditcsrAddr;
167 Uint32 ditudrAddr;
168 } MCASP_Obj, *MCASP_Handle;
170 /* device configuration structure */
172 typedef struct {
173 Uint32 rmask;
174 Uint32 rfmt;
175 Uint32 afsrctl;
176 Uint32 aclkrctl;
177 Uint32 ahclkrctl;
178 Uint32 rtdm;
179 Uint32 rintctl;
180 Uint32 rclkchk;
181 } MCASP_ConfigRcv;
183 typedef struct {
184 Uint32 xmask;
185 Uint32 xfmt;
186 Uint32 afsxctl;
187 Uint32 aclkxctl;
188 Uint32 ahclkxctl;
189 Uint32 xtdm;
190 Uint32 xintctl;
191 Uint32 xclkchk;
192 } MCASP_ConfigXmt;
195 /******************************************************************************\
196 * global function declarations
197 \******************************************************************************/
198 void MCASP_reset(MCASP_Handle hMcasp);
199 void MCASP_resetAll();
200 MCASP_Handle MCASP_open(int devNum, Uint32 flags);
202 void MCASP_configRcv(MCASP_Handle hMcasp, MCASP_ConfigRcv *config);
203 void MCASP_configXmt(MCASP_Handle hMcasp, MCASP_ConfigXmt *config);
205 #endif //SAP_CSL_MCASP_H_