Chaithrika U S | b67f448 | 2009-06-05 06:28:40 -0400 | [diff] [blame] | 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 | #include <linux/io.h> |
Hebbar, Gururaja | 896f66b | 2012-08-27 18:56:41 +0530 | [diff] [blame] | 22 | #include <linux/platform_data/davinci_asp.h> |
| 23 | |
Chaithrika U S | b67f448 | 2009-06-05 06:28:40 -0400 | [diff] [blame] | 24 | #include "davinci-pcm.h" |
| 25 | |
Peter Ujfalusi | 02e08d9 | 2013-11-14 11:35:25 +0200 | [diff] [blame^] | 26 | /* |
| 27 | * McASP register definitions |
| 28 | */ |
| 29 | #define DAVINCI_MCASP_PID_REG 0x00 |
| 30 | #define DAVINCI_MCASP_PWREMUMGT_REG 0x04 |
| 31 | |
| 32 | #define DAVINCI_MCASP_PFUNC_REG 0x10 |
| 33 | #define DAVINCI_MCASP_PDIR_REG 0x14 |
| 34 | #define DAVINCI_MCASP_PDOUT_REG 0x18 |
| 35 | #define DAVINCI_MCASP_PDSET_REG 0x1c |
| 36 | |
| 37 | #define DAVINCI_MCASP_PDCLR_REG 0x20 |
| 38 | |
| 39 | #define DAVINCI_MCASP_TLGC_REG 0x30 |
| 40 | #define DAVINCI_MCASP_TLMR_REG 0x34 |
| 41 | |
| 42 | #define DAVINCI_MCASP_GBLCTL_REG 0x44 |
| 43 | #define DAVINCI_MCASP_AMUTE_REG 0x48 |
| 44 | #define DAVINCI_MCASP_LBCTL_REG 0x4c |
| 45 | |
| 46 | #define DAVINCI_MCASP_TXDITCTL_REG 0x50 |
| 47 | |
| 48 | #define DAVINCI_MCASP_GBLCTLR_REG 0x60 |
| 49 | #define DAVINCI_MCASP_RXMASK_REG 0x64 |
| 50 | #define DAVINCI_MCASP_RXFMT_REG 0x68 |
| 51 | #define DAVINCI_MCASP_RXFMCTL_REG 0x6c |
| 52 | |
| 53 | #define DAVINCI_MCASP_ACLKRCTL_REG 0x70 |
| 54 | #define DAVINCI_MCASP_AHCLKRCTL_REG 0x74 |
| 55 | #define DAVINCI_MCASP_RXTDM_REG 0x78 |
| 56 | #define DAVINCI_MCASP_EVTCTLR_REG 0x7c |
| 57 | |
| 58 | #define DAVINCI_MCASP_RXSTAT_REG 0x80 |
| 59 | #define DAVINCI_MCASP_RXTDMSLOT_REG 0x84 |
| 60 | #define DAVINCI_MCASP_RXCLKCHK_REG 0x88 |
| 61 | #define DAVINCI_MCASP_REVTCTL_REG 0x8c |
| 62 | |
| 63 | #define DAVINCI_MCASP_GBLCTLX_REG 0xa0 |
| 64 | #define DAVINCI_MCASP_TXMASK_REG 0xa4 |
| 65 | #define DAVINCI_MCASP_TXFMT_REG 0xa8 |
| 66 | #define DAVINCI_MCASP_TXFMCTL_REG 0xac |
| 67 | |
| 68 | #define DAVINCI_MCASP_ACLKXCTL_REG 0xb0 |
| 69 | #define DAVINCI_MCASP_AHCLKXCTL_REG 0xb4 |
| 70 | #define DAVINCI_MCASP_TXTDM_REG 0xb8 |
| 71 | #define DAVINCI_MCASP_EVTCTLX_REG 0xbc |
| 72 | |
| 73 | #define DAVINCI_MCASP_TXSTAT_REG 0xc0 |
| 74 | #define DAVINCI_MCASP_TXTDMSLOT_REG 0xc4 |
| 75 | #define DAVINCI_MCASP_TXCLKCHK_REG 0xc8 |
| 76 | #define DAVINCI_MCASP_XEVTCTL_REG 0xcc |
| 77 | |
| 78 | /* Left(even TDM Slot) Channel Status Register File */ |
| 79 | #define DAVINCI_MCASP_DITCSRA_REG 0x100 |
| 80 | /* Right(odd TDM slot) Channel Status Register File */ |
| 81 | #define DAVINCI_MCASP_DITCSRB_REG 0x118 |
| 82 | /* Left(even TDM slot) User Data Register File */ |
| 83 | #define DAVINCI_MCASP_DITUDRA_REG 0x130 |
| 84 | /* Right(odd TDM Slot) User Data Register File */ |
| 85 | #define DAVINCI_MCASP_DITUDRB_REG 0x148 |
| 86 | |
| 87 | /* Serializer n Control Register */ |
| 88 | #define DAVINCI_MCASP_XRSRCTL_BASE_REG 0x180 |
| 89 | #define DAVINCI_MCASP_XRSRCTL_REG(n) (DAVINCI_MCASP_XRSRCTL_BASE_REG + \ |
| 90 | (n << 2)) |
| 91 | |
| 92 | /* Transmit Buffer for Serializer n */ |
| 93 | #define DAVINCI_MCASP_TXBUF_REG 0x200 |
| 94 | /* Receive Buffer for Serializer n */ |
| 95 | #define DAVINCI_MCASP_RXBUF_REG 0x280 |
| 96 | |
| 97 | /* McASP FIFO Registers */ |
| 98 | #define DAVINCI_MCASP_WFIFOCTL (0x1010) |
| 99 | #define DAVINCI_MCASP_WFIFOSTS (0x1014) |
| 100 | #define DAVINCI_MCASP_RFIFOCTL (0x1018) |
| 101 | #define DAVINCI_MCASP_RFIFOSTS (0x101C) |
| 102 | #define MCASP_VER3_WFIFOCTL (0x1000) |
| 103 | #define MCASP_VER3_WFIFOSTS (0x1004) |
| 104 | #define MCASP_VER3_RFIFOCTL (0x1008) |
| 105 | #define MCASP_VER3_RFIFOSTS (0x100C) |
| 106 | |
| 107 | /* |
| 108 | * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management |
| 109 | * Register Bits |
| 110 | */ |
| 111 | #define MCASP_FREE BIT(0) |
| 112 | #define MCASP_SOFT BIT(1) |
| 113 | |
| 114 | /* |
| 115 | * DAVINCI_MCASP_PFUNC_REG - Pin Function / GPIO Enable Register Bits |
| 116 | */ |
| 117 | #define AXR(n) (1<<n) |
| 118 | #define PFUNC_AMUTE BIT(25) |
| 119 | #define ACLKX BIT(26) |
| 120 | #define AHCLKX BIT(27) |
| 121 | #define AFSX BIT(28) |
| 122 | #define ACLKR BIT(29) |
| 123 | #define AHCLKR BIT(30) |
| 124 | #define AFSR BIT(31) |
| 125 | |
| 126 | /* |
| 127 | * DAVINCI_MCASP_PDIR_REG - Pin Direction Register Bits |
| 128 | */ |
| 129 | #define AXR(n) (1<<n) |
| 130 | #define PDIR_AMUTE BIT(25) |
| 131 | #define ACLKX BIT(26) |
| 132 | #define AHCLKX BIT(27) |
| 133 | #define AFSX BIT(28) |
| 134 | #define ACLKR BIT(29) |
| 135 | #define AHCLKR BIT(30) |
| 136 | #define AFSR BIT(31) |
| 137 | |
| 138 | /* |
| 139 | * DAVINCI_MCASP_TXDITCTL_REG - Transmit DIT Control Register Bits |
| 140 | */ |
| 141 | #define DITEN BIT(0) /* Transmit DIT mode enable/disable */ |
| 142 | #define VA BIT(2) |
| 143 | #define VB BIT(3) |
| 144 | |
| 145 | /* |
| 146 | * DAVINCI_MCASP_TXFMT_REG - Transmit Bitstream Format Register Bits |
| 147 | */ |
| 148 | #define TXROT(val) (val) |
| 149 | #define TXSEL BIT(3) |
| 150 | #define TXSSZ(val) (val<<4) |
| 151 | #define TXPBIT(val) (val<<8) |
| 152 | #define TXPAD(val) (val<<13) |
| 153 | #define TXORD BIT(15) |
| 154 | #define FSXDLY(val) (val<<16) |
| 155 | |
| 156 | /* |
| 157 | * DAVINCI_MCASP_RXFMT_REG - Receive Bitstream Format Register Bits |
| 158 | */ |
| 159 | #define RXROT(val) (val) |
| 160 | #define RXSEL BIT(3) |
| 161 | #define RXSSZ(val) (val<<4) |
| 162 | #define RXPBIT(val) (val<<8) |
| 163 | #define RXPAD(val) (val<<13) |
| 164 | #define RXORD BIT(15) |
| 165 | #define FSRDLY(val) (val<<16) |
| 166 | |
| 167 | /* |
| 168 | * DAVINCI_MCASP_TXFMCTL_REG - Transmit Frame Control Register Bits |
| 169 | */ |
| 170 | #define FSXPOL BIT(0) |
| 171 | #define AFSXE BIT(1) |
| 172 | #define FSXDUR BIT(4) |
| 173 | #define FSXMOD(val) (val<<7) |
| 174 | |
| 175 | /* |
| 176 | * DAVINCI_MCASP_RXFMCTL_REG - Receive Frame Control Register Bits |
| 177 | */ |
| 178 | #define FSRPOL BIT(0) |
| 179 | #define AFSRE BIT(1) |
| 180 | #define FSRDUR BIT(4) |
| 181 | #define FSRMOD(val) (val<<7) |
| 182 | |
| 183 | /* |
| 184 | * DAVINCI_MCASP_ACLKXCTL_REG - Transmit Clock Control Register Bits |
| 185 | */ |
| 186 | #define ACLKXDIV(val) (val) |
| 187 | #define ACLKXE BIT(5) |
| 188 | #define TX_ASYNC BIT(6) |
| 189 | #define ACLKXPOL BIT(7) |
| 190 | #define ACLKXDIV_MASK 0x1f |
| 191 | |
| 192 | /* |
| 193 | * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits |
| 194 | */ |
| 195 | #define ACLKRDIV(val) (val) |
| 196 | #define ACLKRE BIT(5) |
| 197 | #define RX_ASYNC BIT(6) |
| 198 | #define ACLKRPOL BIT(7) |
| 199 | #define ACLKRDIV_MASK 0x1f |
| 200 | |
| 201 | /* |
| 202 | * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control |
| 203 | * Register Bits |
| 204 | */ |
| 205 | #define AHCLKXDIV(val) (val) |
| 206 | #define AHCLKXPOL BIT(14) |
| 207 | #define AHCLKXE BIT(15) |
| 208 | #define AHCLKXDIV_MASK 0xfff |
| 209 | |
| 210 | /* |
| 211 | * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control |
| 212 | * Register Bits |
| 213 | */ |
| 214 | #define AHCLKRDIV(val) (val) |
| 215 | #define AHCLKRPOL BIT(14) |
| 216 | #define AHCLKRE BIT(15) |
| 217 | #define AHCLKRDIV_MASK 0xfff |
| 218 | |
| 219 | /* |
| 220 | * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits |
| 221 | */ |
| 222 | #define MODE(val) (val) |
| 223 | #define DISMOD (val)(val<<2) |
| 224 | #define TXSTATE BIT(4) |
| 225 | #define RXSTATE BIT(5) |
| 226 | #define SRMOD_MASK 3 |
| 227 | #define SRMOD_INACTIVE 0 |
| 228 | |
| 229 | /* |
| 230 | * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits |
| 231 | */ |
| 232 | #define LBEN BIT(0) |
| 233 | #define LBORD BIT(1) |
| 234 | #define LBGENMODE(val) (val<<2) |
| 235 | |
| 236 | /* |
| 237 | * DAVINCI_MCASP_TXTDMSLOT_REG - Transmit TDM Slot Register configuration |
| 238 | */ |
| 239 | #define TXTDMS(n) (1<<n) |
| 240 | |
| 241 | /* |
| 242 | * DAVINCI_MCASP_RXTDMSLOT_REG - Receive TDM Slot Register configuration |
| 243 | */ |
| 244 | #define RXTDMS(n) (1<<n) |
| 245 | |
| 246 | /* |
| 247 | * DAVINCI_MCASP_GBLCTL_REG - Global Control Register Bits |
| 248 | */ |
| 249 | #define RXCLKRST BIT(0) /* Receiver Clock Divider Reset */ |
| 250 | #define RXHCLKRST BIT(1) /* Receiver High Frequency Clock Divider */ |
| 251 | #define RXSERCLR BIT(2) /* Receiver Serializer Clear */ |
| 252 | #define RXSMRST BIT(3) /* Receiver State Machine Reset */ |
| 253 | #define RXFSRST BIT(4) /* Frame Sync Generator Reset */ |
| 254 | #define TXCLKRST BIT(8) /* Transmitter Clock Divider Reset */ |
| 255 | #define TXHCLKRST BIT(9) /* Transmitter High Frequency Clock Divider*/ |
| 256 | #define TXSERCLR BIT(10) /* Transmit Serializer Clear */ |
| 257 | #define TXSMRST BIT(11) /* Transmitter State Machine Reset */ |
| 258 | #define TXFSRST BIT(12) /* Frame Sync Generator Reset */ |
| 259 | |
| 260 | /* |
| 261 | * DAVINCI_MCASP_AMUTE_REG - Mute Control Register Bits |
| 262 | */ |
| 263 | #define MUTENA(val) (val) |
| 264 | #define MUTEINPOL BIT(2) |
| 265 | #define MUTEINENA BIT(3) |
| 266 | #define MUTEIN BIT(4) |
| 267 | #define MUTER BIT(5) |
| 268 | #define MUTEX BIT(6) |
| 269 | #define MUTEFSR BIT(7) |
| 270 | #define MUTEFSX BIT(8) |
| 271 | #define MUTEBADCLKR BIT(9) |
| 272 | #define MUTEBADCLKX BIT(10) |
| 273 | #define MUTERXDMAERR BIT(11) |
| 274 | #define MUTETXDMAERR BIT(12) |
| 275 | |
| 276 | /* |
| 277 | * DAVINCI_MCASP_REVTCTL_REG - Receiver DMA Event Control Register bits |
| 278 | */ |
| 279 | #define RXDATADMADIS BIT(0) |
| 280 | |
| 281 | /* |
| 282 | * DAVINCI_MCASP_XEVTCTL_REG - Transmitter DMA Event Control Register bits |
| 283 | */ |
| 284 | #define TXDATADMADIS BIT(0) |
| 285 | |
| 286 | /* |
| 287 | * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits |
| 288 | */ |
| 289 | #define FIFO_ENABLE BIT(16) |
| 290 | #define NUMEVT_MASK (0xFF << 8) |
| 291 | #define NUMDMA_MASK (0xFF) |
| 292 | |
Chaithrika U S | b67f448 | 2009-06-05 06:28:40 -0400 | [diff] [blame] | 293 | struct davinci_audio_dev { |
Troy Kisky | 92e2a6f | 2009-09-11 14:29:03 -0700 | [diff] [blame] | 294 | struct davinci_pcm_dma_params dma_params[2]; |
Chaithrika U S | b67f448 | 2009-06-05 06:28:40 -0400 | [diff] [blame] | 295 | void __iomem *base; |
Hebbar, Gururaja | 1088434 | 2012-08-08 20:40:32 +0530 | [diff] [blame] | 296 | struct device *dev; |
Chaithrika U S | b67f448 | 2009-06-05 06:28:40 -0400 | [diff] [blame] | 297 | |
| 298 | /* McASP specific data */ |
| 299 | int tdm_slots; |
| 300 | u8 op_mode; |
| 301 | u8 num_serializer; |
| 302 | u8 *serial_dir; |
Chaithrika U S | 6a99fb5 | 2009-08-11 16:58:52 -0400 | [diff] [blame] | 303 | u8 version; |
Michal Bachraty | d486fea | 2013-04-19 15:28:44 +0200 | [diff] [blame] | 304 | u16 bclk_lrclk_ratio; |
Chaithrika U S | 6a99fb5 | 2009-08-11 16:58:52 -0400 | [diff] [blame] | 305 | |
| 306 | /* McASP FIFO related */ |
| 307 | u8 txnumevt; |
| 308 | u8 rxnumevt; |
Daniel Mack | a85e419 | 2013-10-01 14:50:02 +0200 | [diff] [blame] | 309 | |
| 310 | #ifdef CONFIG_PM_SLEEP |
| 311 | struct { |
| 312 | u32 txfmtctl; |
| 313 | u32 rxfmtctl; |
| 314 | u32 txfmt; |
| 315 | u32 rxfmt; |
| 316 | u32 aclkxctl; |
| 317 | u32 aclkrctl; |
| 318 | u32 pdir; |
| 319 | } context; |
| 320 | #endif |
Chaithrika U S | b67f448 | 2009-06-05 06:28:40 -0400 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | #endif /* DAVINCI_MCASP_H */ |