xref: /openbmc/linux/sound/soc/ti/davinci-mcasp.h (revision 176f011b)
1 /*
2  * ALSA SoC McASP Audio Layer for TI DAVINCI processor
3  *
4  * MCASP related definitions
5  *
6  * Author: Nirmal Pandey <n-pandey@ti.com>,
7  *         Suresh Rajashekara <suresh.r@ti.com>
8  *         Steve Chen <schen@.mvista.com>
9  *
10  * Copyright:   (C) 2009 MontaVista Software, Inc., <source@mvista.com>
11  * Copyright:   (C) 2009  Texas Instruments, India
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License version 2 as
15  * published by the Free Software Foundation.
16  */
17 
18 #ifndef DAVINCI_MCASP_H
19 #define DAVINCI_MCASP_H
20 
21 /*
22  * McASP register definitions
23  */
24 #define DAVINCI_MCASP_PID_REG		0x00
25 #define DAVINCI_MCASP_PWREMUMGT_REG	0x04
26 
27 #define DAVINCI_MCASP_PFUNC_REG		0x10
28 #define DAVINCI_MCASP_PDIR_REG		0x14
29 #define DAVINCI_MCASP_PDOUT_REG		0x18
30 #define DAVINCI_MCASP_PDSET_REG		0x1c
31 
32 #define DAVINCI_MCASP_PDCLR_REG		0x20
33 
34 #define DAVINCI_MCASP_TLGC_REG		0x30
35 #define DAVINCI_MCASP_TLMR_REG		0x34
36 
37 #define DAVINCI_MCASP_GBLCTL_REG	0x44
38 #define DAVINCI_MCASP_AMUTE_REG		0x48
39 #define DAVINCI_MCASP_LBCTL_REG		0x4c
40 
41 #define DAVINCI_MCASP_TXDITCTL_REG	0x50
42 
43 #define DAVINCI_MCASP_GBLCTLR_REG	0x60
44 #define DAVINCI_MCASP_RXMASK_REG	0x64
45 #define DAVINCI_MCASP_RXFMT_REG		0x68
46 #define DAVINCI_MCASP_RXFMCTL_REG	0x6c
47 
48 #define DAVINCI_MCASP_ACLKRCTL_REG	0x70
49 #define DAVINCI_MCASP_AHCLKRCTL_REG	0x74
50 #define DAVINCI_MCASP_RXTDM_REG		0x78
51 #define DAVINCI_MCASP_EVTCTLR_REG	0x7c
52 
53 #define DAVINCI_MCASP_RXSTAT_REG	0x80
54 #define DAVINCI_MCASP_RXTDMSLOT_REG	0x84
55 #define DAVINCI_MCASP_RXCLKCHK_REG	0x88
56 #define DAVINCI_MCASP_REVTCTL_REG	0x8c
57 
58 #define DAVINCI_MCASP_GBLCTLX_REG	0xa0
59 #define DAVINCI_MCASP_TXMASK_REG	0xa4
60 #define DAVINCI_MCASP_TXFMT_REG		0xa8
61 #define DAVINCI_MCASP_TXFMCTL_REG	0xac
62 
63 #define DAVINCI_MCASP_ACLKXCTL_REG	0xb0
64 #define DAVINCI_MCASP_AHCLKXCTL_REG	0xb4
65 #define DAVINCI_MCASP_TXTDM_REG		0xb8
66 #define DAVINCI_MCASP_EVTCTLX_REG	0xbc
67 
68 #define DAVINCI_MCASP_TXSTAT_REG	0xc0
69 #define DAVINCI_MCASP_TXTDMSLOT_REG	0xc4
70 #define DAVINCI_MCASP_TXCLKCHK_REG	0xc8
71 #define DAVINCI_MCASP_XEVTCTL_REG	0xcc
72 
73 /* Left(even TDM Slot) Channel Status Register File */
74 #define DAVINCI_MCASP_DITCSRA_REG	0x100
75 /* Right(odd TDM slot) Channel Status Register File */
76 #define DAVINCI_MCASP_DITCSRB_REG	0x118
77 /* Left(even TDM slot) User Data Register File */
78 #define DAVINCI_MCASP_DITUDRA_REG	0x130
79 /* Right(odd TDM Slot) User Data Register File */
80 #define DAVINCI_MCASP_DITUDRB_REG	0x148
81 
82 /* Serializer n Control Register */
83 #define DAVINCI_MCASP_XRSRCTL_BASE_REG	0x180
84 #define DAVINCI_MCASP_XRSRCTL_REG(n)	(DAVINCI_MCASP_XRSRCTL_BASE_REG + \
85 						(n << 2))
86 
87 /* Transmit Buffer for Serializer n */
88 #define DAVINCI_MCASP_TXBUF_REG(n)	(0x200 + (n << 2))
89 /* Receive Buffer for Serializer n */
90 #define DAVINCI_MCASP_RXBUF_REG(n)	(0x280 + (n << 2))
91 
92 /* McASP FIFO Registers */
93 #define DAVINCI_MCASP_V2_AFIFO_BASE	(0x1010)
94 #define DAVINCI_MCASP_V3_AFIFO_BASE	(0x1000)
95 
96 /* FIFO register offsets from AFIFO base */
97 #define MCASP_WFIFOCTL_OFFSET		(0x0)
98 #define MCASP_WFIFOSTS_OFFSET		(0x4)
99 #define MCASP_RFIFOCTL_OFFSET		(0x8)
100 #define MCASP_RFIFOSTS_OFFSET		(0xc)
101 
102 /*
103  * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management
104  *     Register Bits
105  */
106 #define MCASP_FREE	BIT(0)
107 #define MCASP_SOFT	BIT(1)
108 
109 /*
110  * DAVINCI_MCASP_PFUNC_REG - Pin Function / GPIO Enable Register Bits
111  * DAVINCI_MCASP_PDIR_REG - Pin Direction Register Bits
112  * DAVINCI_MCASP_PDOUT_REG - Pin output in GPIO mode
113  * DAVINCI_MCASP_PDSET_REG - Pin input in GPIO mode
114  */
115 #define PIN_BIT_AXR(n)	(n)
116 #define PIN_BIT_AMUTE	25
117 #define PIN_BIT_ACLKX	26
118 #define PIN_BIT_AHCLKX	27
119 #define PIN_BIT_AFSX	28
120 #define PIN_BIT_ACLKR	29
121 #define PIN_BIT_AHCLKR	30
122 #define PIN_BIT_AFSR	31
123 
124 /*
125  * DAVINCI_MCASP_TXDITCTL_REG - Transmit DIT Control Register Bits
126  */
127 #define DITEN	BIT(0)	/* Transmit DIT mode enable/disable */
128 #define VA	BIT(2)
129 #define VB	BIT(3)
130 
131 /*
132  * DAVINCI_MCASP_TXFMT_REG - Transmit Bitstream Format Register Bits
133  */
134 #define TXROT(val)	(val)
135 #define TXSEL		BIT(3)
136 #define TXSSZ(val)	(val<<4)
137 #define TXPBIT(val)	(val<<8)
138 #define TXPAD(val)	(val<<13)
139 #define TXORD		BIT(15)
140 #define FSXDLY(val)	(val<<16)
141 
142 /*
143  * DAVINCI_MCASP_RXFMT_REG - Receive Bitstream Format Register Bits
144  */
145 #define RXROT(val)	(val)
146 #define RXSEL		BIT(3)
147 #define RXSSZ(val)	(val<<4)
148 #define RXPBIT(val)	(val<<8)
149 #define RXPAD(val)	(val<<13)
150 #define RXORD		BIT(15)
151 #define FSRDLY(val)	(val<<16)
152 
153 /*
154  * DAVINCI_MCASP_TXFMCTL_REG -  Transmit Frame Control Register Bits
155  */
156 #define FSXPOL		BIT(0)
157 #define AFSXE		BIT(1)
158 #define FSXDUR		BIT(4)
159 #define FSXMOD(val)	(val<<7)
160 
161 /*
162  * DAVINCI_MCASP_RXFMCTL_REG - Receive Frame Control Register Bits
163  */
164 #define FSRPOL		BIT(0)
165 #define AFSRE		BIT(1)
166 #define FSRDUR		BIT(4)
167 #define FSRMOD(val)	(val<<7)
168 
169 /*
170  * DAVINCI_MCASP_ACLKXCTL_REG - Transmit Clock Control Register Bits
171  */
172 #define ACLKXDIV(val)	(val)
173 #define ACLKXE		BIT(5)
174 #define TX_ASYNC	BIT(6)
175 #define ACLKXPOL	BIT(7)
176 #define ACLKXDIV_MASK	0x1f
177 
178 /*
179  * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits
180  */
181 #define ACLKRDIV(val)	(val)
182 #define ACLKRE		BIT(5)
183 #define RX_ASYNC	BIT(6)
184 #define ACLKRPOL	BIT(7)
185 #define ACLKRDIV_MASK	0x1f
186 
187 /*
188  * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control
189  *     Register Bits
190  */
191 #define AHCLKXDIV(val)	(val)
192 #define AHCLKXPOL	BIT(14)
193 #define AHCLKXE		BIT(15)
194 #define AHCLKXDIV_MASK	0xfff
195 
196 /*
197  * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control
198  *     Register Bits
199  */
200 #define AHCLKRDIV(val)	(val)
201 #define AHCLKRPOL	BIT(14)
202 #define AHCLKRE		BIT(15)
203 #define AHCLKRDIV_MASK	0xfff
204 
205 /*
206  * DAVINCI_MCASP_XRSRCTL_BASE_REG -  Serializer Control Register Bits
207  */
208 #define MODE(val)	(val)
209 #define DISMOD_3STATE	(0x0)
210 #define DISMOD_LOW	(0x2 << 2)
211 #define DISMOD_HIGH	(0x3 << 2)
212 #define DISMOD_VAL(x)	((x) << 2)
213 #define DISMOD_MASK	DISMOD_HIGH
214 #define TXSTATE		BIT(4)
215 #define RXSTATE		BIT(5)
216 #define SRMOD_MASK	3
217 #define SRMOD_INACTIVE	0
218 
219 /*
220  * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits
221  */
222 #define LBEN		BIT(0)
223 #define LBORD		BIT(1)
224 #define LBGENMODE(val)	(val<<2)
225 
226 /*
227  * DAVINCI_MCASP_TXTDMSLOT_REG - Transmit TDM Slot Register configuration
228  */
229 #define TXTDMS(n)	(1<<n)
230 
231 /*
232  * DAVINCI_MCASP_RXTDMSLOT_REG - Receive TDM Slot Register configuration
233  */
234 #define RXTDMS(n)	(1<<n)
235 
236 /*
237  * DAVINCI_MCASP_GBLCTL_REG -  Global Control Register Bits
238  */
239 #define RXCLKRST	BIT(0)	/* Receiver Clock Divider Reset */
240 #define RXHCLKRST	BIT(1)	/* Receiver High Frequency Clock Divider */
241 #define RXSERCLR	BIT(2)	/* Receiver Serializer Clear */
242 #define RXSMRST		BIT(3)	/* Receiver State Machine Reset */
243 #define RXFSRST		BIT(4)	/* Frame Sync Generator Reset */
244 #define TXCLKRST	BIT(8)	/* Transmitter Clock Divider Reset */
245 #define TXHCLKRST	BIT(9)	/* Transmitter High Frequency Clock Divider*/
246 #define TXSERCLR	BIT(10)	/* Transmit Serializer Clear */
247 #define TXSMRST		BIT(11)	/* Transmitter State Machine Reset */
248 #define TXFSRST		BIT(12)	/* Frame Sync Generator Reset */
249 
250 /*
251  * DAVINCI_MCASP_TXSTAT_REG - Transmitter Status Register Bits
252  * DAVINCI_MCASP_RXSTAT_REG - Receiver Status Register Bits
253  */
254 #define XRERR		BIT(8) /* Transmit/Receive error */
255 #define XRDATA		BIT(5) /* Transmit/Receive data ready */
256 
257 /*
258  * DAVINCI_MCASP_AMUTE_REG -  Mute Control Register Bits
259  */
260 #define MUTENA(val)	(val)
261 #define MUTEINPOL	BIT(2)
262 #define MUTEINENA	BIT(3)
263 #define MUTEIN		BIT(4)
264 #define MUTER		BIT(5)
265 #define MUTEX		BIT(6)
266 #define MUTEFSR		BIT(7)
267 #define MUTEFSX		BIT(8)
268 #define MUTEBADCLKR	BIT(9)
269 #define MUTEBADCLKX	BIT(10)
270 #define MUTERXDMAERR	BIT(11)
271 #define MUTETXDMAERR	BIT(12)
272 
273 /*
274  * DAVINCI_MCASP_REVTCTL_REG - Receiver DMA Event Control Register bits
275  */
276 #define RXDATADMADIS	BIT(0)
277 
278 /*
279  * DAVINCI_MCASP_XEVTCTL_REG - Transmitter DMA Event Control Register bits
280  */
281 #define TXDATADMADIS	BIT(0)
282 
283 /*
284  * DAVINCI_MCASP_EVTCTLR_REG - Receiver Interrupt Control Register Bits
285  */
286 #define ROVRN		BIT(0)
287 
288 /*
289  * DAVINCI_MCASP_EVTCTLX_REG - Transmitter Interrupt Control Register Bits
290  */
291 #define XUNDRN		BIT(0)
292 
293 /*
294  * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits
295  */
296 #define FIFO_ENABLE	BIT(16)
297 #define NUMEVT_MASK	(0xFF << 8)
298 #define NUMEVT(x)	(((x) & 0xFF) << 8)
299 #define NUMDMA_MASK	(0xFF)
300 
301 /* clock divider IDs */
302 #define MCASP_CLKDIV_AUXCLK		0 /* HCLK divider from AUXCLK */
303 #define MCASP_CLKDIV_BCLK		1 /* BCLK divider from HCLK */
304 #define MCASP_CLKDIV_BCLK_FS_RATIO	2 /* to set BCLK FS ration */
305 
306 #endif	/* DAVINCI_MCASP_H */
307