Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/plat-omap/include/mach/mcbsp.h |
| 3 | * |
| 4 | * Defines for Multi-Channel Buffered Serial Port |
| 5 | * |
| 6 | * Copyright (C) 2002 RidgeRun, Inc. |
| 7 | * Author: Steve Johnson |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | */ |
| 24 | #ifndef __ASM_ARCH_OMAP_MCBSP_H |
| 25 | #define __ASM_ARCH_OMAP_MCBSP_H |
| 26 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 27 | #include <linux/spinlock.h> |
| 28 | |
| 29 | #include <mach/hardware.h> |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 30 | #include <plat/clock.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 31 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 32 | /* macro for building platform_device for McBSP ports */ |
| 33 | #define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \ |
| 34 | static struct platform_device omap_mcbsp##port_nr = { \ |
| 35 | .name = "omap-mcbsp-dai", \ |
Jarkko Nikula | fd1ee39 | 2011-07-01 08:52:27 +0000 | [diff] [blame] | 36 | .id = port_nr - 1, \ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Charulatha V | 37801b3 | 2011-02-24 12:51:46 -0800 | [diff] [blame] | 39 | #define MCBSP_CONFIG_TYPE2 0x2 |
Charulatha V | dc48e5f | 2011-02-24 15:16:49 +0530 | [diff] [blame] | 40 | #define MCBSP_CONFIG_TYPE3 0x3 |
Kishon Vijay Abraham I | cb7e9de | 2011-02-24 15:16:50 +0530 | [diff] [blame] | 41 | #define MCBSP_CONFIG_TYPE4 0x4 |
Charulatha V | 37801b3 | 2011-02-24 12:51:46 -0800 | [diff] [blame] | 42 | |
Alistair Buxton | 7c00692 | 2009-09-22 10:02:58 +0100 | [diff] [blame] | 43 | #define OMAP7XX_MCBSP1_BASE 0xfffb1000 |
| 44 | #define OMAP7XX_MCBSP2_BASE 0xfffb1800 |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 45 | |
| 46 | #define OMAP1510_MCBSP1_BASE 0xe1011800 |
| 47 | #define OMAP1510_MCBSP2_BASE 0xfffb1000 |
| 48 | #define OMAP1510_MCBSP3_BASE 0xe1017000 |
| 49 | |
| 50 | #define OMAP1610_MCBSP1_BASE 0xe1011800 |
| 51 | #define OMAP1610_MCBSP2_BASE 0xfffb1000 |
| 52 | #define OMAP1610_MCBSP3_BASE 0xe1017000 |
| 53 | |
Jarkko Nikula | cdc71514 | 2011-09-26 10:45:39 +0300 | [diff] [blame^] | 54 | /* McBSP register numbers. Register address offset = num * reg_step */ |
| 55 | enum { |
| 56 | /* Common registers */ |
| 57 | OMAP_MCBSP_REG_SPCR2 = 4, |
| 58 | OMAP_MCBSP_REG_SPCR1, |
| 59 | OMAP_MCBSP_REG_RCR2, |
| 60 | OMAP_MCBSP_REG_RCR1, |
| 61 | OMAP_MCBSP_REG_XCR2, |
| 62 | OMAP_MCBSP_REG_XCR1, |
| 63 | OMAP_MCBSP_REG_SRGR2, |
| 64 | OMAP_MCBSP_REG_SRGR1, |
| 65 | OMAP_MCBSP_REG_MCR2, |
| 66 | OMAP_MCBSP_REG_MCR1, |
| 67 | OMAP_MCBSP_REG_RCERA, |
| 68 | OMAP_MCBSP_REG_RCERB, |
| 69 | OMAP_MCBSP_REG_XCERA, |
| 70 | OMAP_MCBSP_REG_XCERB, |
| 71 | OMAP_MCBSP_REG_PCR0, |
| 72 | OMAP_MCBSP_REG_RCERC, |
| 73 | OMAP_MCBSP_REG_RCERD, |
| 74 | OMAP_MCBSP_REG_XCERC, |
| 75 | OMAP_MCBSP_REG_XCERD, |
| 76 | OMAP_MCBSP_REG_RCERE, |
| 77 | OMAP_MCBSP_REG_RCERF, |
| 78 | OMAP_MCBSP_REG_XCERE, |
| 79 | OMAP_MCBSP_REG_XCERF, |
| 80 | OMAP_MCBSP_REG_RCERG, |
| 81 | OMAP_MCBSP_REG_RCERH, |
| 82 | OMAP_MCBSP_REG_XCERG, |
| 83 | OMAP_MCBSP_REG_XCERH, |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 84 | |
Jarkko Nikula | cdc71514 | 2011-09-26 10:45:39 +0300 | [diff] [blame^] | 85 | /* OMAP1-OMAP2420 registers */ |
| 86 | OMAP_MCBSP_REG_DRR2 = 0, |
| 87 | OMAP_MCBSP_REG_DRR1, |
| 88 | OMAP_MCBSP_REG_DXR2, |
| 89 | OMAP_MCBSP_REG_DXR1, |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 90 | |
Jarkko Nikula | cdc71514 | 2011-09-26 10:45:39 +0300 | [diff] [blame^] | 91 | /* OMAP2430 and onwards */ |
| 92 | OMAP_MCBSP_REG_DRR = 0, |
| 93 | OMAP_MCBSP_REG_DXR = 2, |
| 94 | OMAP_MCBSP_REG_SYSCON = 35, |
| 95 | OMAP_MCBSP_REG_THRSH2, |
| 96 | OMAP_MCBSP_REG_THRSH1, |
| 97 | OMAP_MCBSP_REG_IRQST = 40, |
| 98 | OMAP_MCBSP_REG_IRQEN, |
| 99 | OMAP_MCBSP_REG_WAKEUPEN, |
| 100 | OMAP_MCBSP_REG_XCCR, |
| 101 | OMAP_MCBSP_REG_RCCR, |
| 102 | OMAP_MCBSP_REG_XBUFFSTAT, |
| 103 | OMAP_MCBSP_REG_RBUFFSTAT, |
| 104 | OMAP_MCBSP_REG_SSELCR, |
| 105 | }; |
Tony Lindgren | 3127f8f | 2009-01-15 13:09:54 +0200 | [diff] [blame] | 106 | |
Jarkko Nikula | cdc71514 | 2011-09-26 10:45:39 +0300 | [diff] [blame^] | 107 | /* OMAP3 sidetone control registers */ |
Eero Nurkkala | d912fa9 | 2010-02-22 12:21:11 +0000 | [diff] [blame] | 108 | #define OMAP_ST_REG_REV 0x00 |
| 109 | #define OMAP_ST_REG_SYSCONFIG 0x10 |
| 110 | #define OMAP_ST_REG_IRQSTATUS 0x18 |
| 111 | #define OMAP_ST_REG_IRQENABLE 0x1C |
| 112 | #define OMAP_ST_REG_SGAINCR 0x24 |
| 113 | #define OMAP_ST_REG_SFIRCR 0x28 |
| 114 | #define OMAP_ST_REG_SSELCR 0x2C |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 115 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 116 | /************************** McBSP SPCR1 bit definitions ***********************/ |
| 117 | #define RRST 0x0001 |
| 118 | #define RRDY 0x0002 |
| 119 | #define RFULL 0x0004 |
| 120 | #define RSYNC_ERR 0x0008 |
| 121 | #define RINTM(value) ((value)<<4) /* bits 4:5 */ |
| 122 | #define ABIS 0x0040 |
| 123 | #define DXENA 0x0080 |
| 124 | #define CLKSTP(value) ((value)<<11) /* bits 11:12 */ |
| 125 | #define RJUST(value) ((value)<<13) /* bits 13:14 */ |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 126 | #define ALB 0x8000 |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 127 | #define DLB 0x8000 |
| 128 | |
| 129 | /************************** McBSP SPCR2 bit definitions ***********************/ |
| 130 | #define XRST 0x0001 |
| 131 | #define XRDY 0x0002 |
| 132 | #define XEMPTY 0x0004 |
| 133 | #define XSYNC_ERR 0x0008 |
| 134 | #define XINTM(value) ((value)<<4) /* bits 4:5 */ |
| 135 | #define GRST 0x0040 |
| 136 | #define FRST 0x0080 |
| 137 | #define SOFT 0x0100 |
| 138 | #define FREE 0x0200 |
| 139 | |
| 140 | /************************** McBSP PCR bit definitions *************************/ |
| 141 | #define CLKRP 0x0001 |
| 142 | #define CLKXP 0x0002 |
| 143 | #define FSRP 0x0004 |
| 144 | #define FSXP 0x0008 |
| 145 | #define DR_STAT 0x0010 |
| 146 | #define DX_STAT 0x0020 |
| 147 | #define CLKS_STAT 0x0040 |
| 148 | #define SCLKME 0x0080 |
| 149 | #define CLKRM 0x0100 |
| 150 | #define CLKXM 0x0200 |
| 151 | #define FSRM 0x0400 |
| 152 | #define FSXM 0x0800 |
| 153 | #define RIOEN 0x1000 |
| 154 | #define XIOEN 0x2000 |
| 155 | #define IDLE_EN 0x4000 |
| 156 | |
| 157 | /************************** McBSP RCR1 bit definitions ************************/ |
| 158 | #define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */ |
| 159 | #define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */ |
| 160 | |
| 161 | /************************** McBSP XCR1 bit definitions ************************/ |
| 162 | #define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */ |
| 163 | #define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */ |
| 164 | |
| 165 | /*************************** McBSP RCR2 bit definitions ***********************/ |
| 166 | #define RDATDLY(value) (value) /* Bits 0:1 */ |
| 167 | #define RFIG 0x0004 |
| 168 | #define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */ |
| 169 | #define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */ |
| 170 | #define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */ |
| 171 | #define RPHASE 0x8000 |
| 172 | |
| 173 | /*************************** McBSP XCR2 bit definitions ***********************/ |
| 174 | #define XDATDLY(value) (value) /* Bits 0:1 */ |
| 175 | #define XFIG 0x0004 |
| 176 | #define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */ |
| 177 | #define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */ |
| 178 | #define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */ |
| 179 | #define XPHASE 0x8000 |
| 180 | |
| 181 | /************************* McBSP SRGR1 bit definitions ************************/ |
| 182 | #define CLKGDV(value) (value) /* Bits 0:7 */ |
| 183 | #define FWID(value) ((value)<<8) /* Bits 8:15 */ |
| 184 | |
| 185 | /************************* McBSP SRGR2 bit definitions ************************/ |
| 186 | #define FPER(value) (value) /* Bits 0:11 */ |
| 187 | #define FSGM 0x1000 |
| 188 | #define CLKSM 0x2000 |
| 189 | #define CLKSP 0x4000 |
| 190 | #define GSYNC 0x8000 |
| 191 | |
| 192 | /************************* McBSP MCR1 bit definitions *************************/ |
| 193 | #define RMCM 0x0001 |
| 194 | #define RCBLK(value) ((value)<<2) /* Bits 2:4 */ |
| 195 | #define RPABLK(value) ((value)<<5) /* Bits 5:6 */ |
| 196 | #define RPBBLK(value) ((value)<<7) /* Bits 7:8 */ |
| 197 | |
| 198 | /************************* McBSP MCR2 bit definitions *************************/ |
| 199 | #define XMCM(value) (value) /* Bits 0:1 */ |
| 200 | #define XCBLK(value) ((value)<<2) /* Bits 2:4 */ |
| 201 | #define XPABLK(value) ((value)<<5) /* Bits 5:6 */ |
| 202 | #define XPBBLK(value) ((value)<<7) /* Bits 7:8 */ |
| 203 | |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 204 | /*********************** McBSP XCCR bit definitions *************************/ |
Tony Lindgren | 3127f8f | 2009-01-15 13:09:54 +0200 | [diff] [blame] | 205 | #define EXTCLKGATE 0x8000 |
| 206 | #define PPCONNECT 0x4000 |
| 207 | #define DXENDLY(value) ((value)<<12) /* Bits 12:13 */ |
| 208 | #define XFULL_CYCLE 0x0800 |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 209 | #define DILB 0x0020 |
| 210 | #define XDMAEN 0x0008 |
| 211 | #define XDISABLE 0x0001 |
| 212 | |
| 213 | /********************** McBSP RCCR bit definitions *************************/ |
Tony Lindgren | 3127f8f | 2009-01-15 13:09:54 +0200 | [diff] [blame] | 214 | #define RFULL_CYCLE 0x0800 |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 215 | #define RDMAEN 0x0008 |
| 216 | #define RDISABLE 0x0001 |
| 217 | |
| 218 | /********************** McBSP SYSCONFIG bit definitions ********************/ |
Eero Nurkkala | 2ba93f8 | 2009-08-20 16:18:17 +0300 | [diff] [blame] | 219 | #define CLOCKACTIVITY(value) ((value)<<8) |
Eero Nurkkala | 2122fdc | 2009-08-20 16:18:15 +0300 | [diff] [blame] | 220 | #define SIDLEMODE(value) ((value)<<3) |
| 221 | #define ENAWAKEUP 0x0004 |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 222 | #define SOFTRST 0x0002 |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 223 | |
Eero Nurkkala | d912fa9 | 2010-02-22 12:21:11 +0000 | [diff] [blame] | 224 | /********************** McBSP SSELCR bit definitions ***********************/ |
| 225 | #define SIDETONEEN 0x0400 |
| 226 | |
| 227 | /********************** McBSP Sidetone SYSCONFIG bit definitions ***********/ |
| 228 | #define ST_AUTOIDLE 0x0001 |
| 229 | |
| 230 | /********************** McBSP Sidetone SGAINCR bit definitions *************/ |
| 231 | #define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */ |
| 232 | #define ST_CH0GAIN(value) (value) /* Bits 0:15 */ |
| 233 | |
| 234 | /********************** McBSP Sidetone SFIRCR bit definitions **************/ |
| 235 | #define ST_FIRCOEFF(value) (value) /* Bits 0:15 */ |
| 236 | |
| 237 | /********************** McBSP Sidetone SSELCR bit definitions **************/ |
| 238 | #define ST_COEFFWRDONE 0x0004 |
| 239 | #define ST_COEFFWREN 0x0002 |
| 240 | #define ST_SIDETONEEN 0x0001 |
| 241 | |
Peter Ujfalusi | 98cb20e | 2009-08-20 16:18:14 +0300 | [diff] [blame] | 242 | /********************** McBSP DMA operating modes **************************/ |
| 243 | #define MCBSP_DMA_MODE_ELEMENT 0 |
| 244 | #define MCBSP_DMA_MODE_THRESHOLD 1 |
| 245 | #define MCBSP_DMA_MODE_FRAME 2 |
| 246 | |
Eero Nurkkala | 2122fdc | 2009-08-20 16:18:15 +0300 | [diff] [blame] | 247 | /********************** McBSP WAKEUPEN bit definitions *********************/ |
| 248 | #define XEMPTYEOFEN 0x4000 |
| 249 | #define XRDYEN 0x0400 |
| 250 | #define XEOFEN 0x0200 |
| 251 | #define XFSXEN 0x0100 |
| 252 | #define XSYNCERREN 0x0080 |
| 253 | #define RRDYEN 0x0008 |
| 254 | #define REOFEN 0x0004 |
| 255 | #define RFSREN 0x0002 |
| 256 | #define RSYNCERREN 0x0001 |
Eero Nurkkala | 2122fdc | 2009-08-20 16:18:15 +0300 | [diff] [blame] | 257 | |
Paul Walmsley | cf4c87a | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 258 | /* CLKR signal muxing options */ |
| 259 | #define CLKR_SRC_CLKR 0 |
| 260 | #define CLKR_SRC_CLKX 1 |
| 261 | |
| 262 | /* FSR signal muxing options */ |
| 263 | #define FSR_SRC_FSR 0 |
| 264 | #define FSR_SRC_FSX 1 |
| 265 | |
Paul Walmsley | d135865 | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 266 | /* McBSP functional clock sources */ |
Jarkko Nikula | e4cc41d | 2010-10-08 11:40:21 -0600 | [diff] [blame] | 267 | #define MCBSP_CLKS_PRCM_SRC 0 |
| 268 | #define MCBSP_CLKS_PAD_SRC 1 |
Paul Walmsley | d135865 | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 269 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 270 | /* we don't do multichannel for now */ |
| 271 | struct omap_mcbsp_reg_cfg { |
| 272 | u16 spcr2; |
| 273 | u16 spcr1; |
| 274 | u16 rcr2; |
| 275 | u16 rcr1; |
| 276 | u16 xcr2; |
| 277 | u16 xcr1; |
| 278 | u16 srgr2; |
| 279 | u16 srgr1; |
| 280 | u16 mcr2; |
| 281 | u16 mcr1; |
| 282 | u16 pcr0; |
| 283 | u16 rcerc; |
| 284 | u16 rcerd; |
| 285 | u16 xcerc; |
| 286 | u16 xcerd; |
| 287 | u16 rcere; |
| 288 | u16 rcerf; |
| 289 | u16 xcere; |
| 290 | u16 xcerf; |
| 291 | u16 rcerg; |
| 292 | u16 rcerh; |
| 293 | u16 xcerg; |
| 294 | u16 xcerh; |
Tony Lindgren | 3127f8f | 2009-01-15 13:09:54 +0200 | [diff] [blame] | 295 | u16 xccr; |
| 296 | u16 rccr; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 297 | }; |
| 298 | |
| 299 | typedef enum { |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 300 | OMAP_MCBSP_WORD_8 = 0, |
| 301 | OMAP_MCBSP_WORD_12, |
| 302 | OMAP_MCBSP_WORD_16, |
| 303 | OMAP_MCBSP_WORD_20, |
| 304 | OMAP_MCBSP_WORD_24, |
| 305 | OMAP_MCBSP_WORD_32, |
| 306 | } omap_mcbsp_word_length; |
| 307 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 308 | /* Platform specific configuration */ |
| 309 | struct omap_mcbsp_ops { |
| 310 | void (*request)(unsigned int); |
| 311 | void (*free)(unsigned int); |
Paul Walmsley | d135865 | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 312 | int (*set_clks_src)(u8, u8); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 313 | }; |
| 314 | |
| 315 | struct omap_mcbsp_platform_data { |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 316 | struct omap_mcbsp_ops *ops; |
Kishon Vijay Abraham I | 64bcbd3 | 2011-02-24 15:16:52 +0530 | [diff] [blame] | 317 | u16 buffer_size; |
Jarkko Nikula | cdc71514 | 2011-09-26 10:45:39 +0300 | [diff] [blame^] | 318 | u8 reg_size; |
| 319 | u8 reg_step; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 320 | }; |
| 321 | |
Eero Nurkkala | d912fa9 | 2010-02-22 12:21:11 +0000 | [diff] [blame] | 322 | struct omap_mcbsp_st_data { |
| 323 | void __iomem *io_base_st; |
| 324 | bool running; |
| 325 | bool enabled; |
| 326 | s16 taps[128]; /* Sidetone filter coefficients */ |
| 327 | int nr_taps; /* Number of filter coefficients in use */ |
| 328 | s16 ch0gain; |
| 329 | s16 ch1gain; |
| 330 | }; |
| 331 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 332 | struct omap_mcbsp { |
| 333 | struct device *dev; |
Russell King | 6584690 | 2008-09-03 23:46:18 +0100 | [diff] [blame] | 334 | unsigned long phys_base; |
Kishon Vijay Abraham I | 3cf32bb | 2011-02-24 12:51:45 -0800 | [diff] [blame] | 335 | unsigned long phys_dma_base; |
Russell King | d592dd1 | 2008-09-04 14:25:42 +0100 | [diff] [blame] | 336 | void __iomem *io_base; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 337 | u8 id; |
| 338 | u8 free; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 339 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 340 | int rx_irq; |
| 341 | int tx_irq; |
| 342 | |
| 343 | /* DMA stuff */ |
| 344 | u8 dma_rx_sync; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 345 | u8 dma_tx_sync; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 346 | |
| 347 | /* Protect the field .free, while checking if the mcbsp is in use */ |
| 348 | spinlock_t lock; |
| 349 | struct omap_mcbsp_platform_data *pdata; |
Russell King | b820ce4 | 2009-01-23 10:26:46 +0000 | [diff] [blame] | 350 | struct clk *fclk; |
Tony Lindgren | a8eb7ca | 2010-02-12 12:26:48 -0800 | [diff] [blame] | 351 | #ifdef CONFIG_ARCH_OMAP3 |
Eero Nurkkala | d912fa9 | 2010-02-22 12:21:11 +0000 | [diff] [blame] | 352 | struct omap_mcbsp_st_data *st_data; |
Peter Ujfalusi | 98cb20e | 2009-08-20 16:18:14 +0300 | [diff] [blame] | 353 | int dma_op_mode; |
Eduardo Valentin | a1a56f5f | 2009-08-20 16:18:11 +0300 | [diff] [blame] | 354 | u16 max_tx_thres; |
| 355 | u16 max_rx_thres; |
| 356 | #endif |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 357 | void *reg_cache; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 358 | }; |
Kishon Vijay Abraham I | 8b1906f | 2011-02-24 15:16:51 +0530 | [diff] [blame] | 359 | |
| 360 | /** |
| 361 | * omap_mcbsp_dev_attr - OMAP McBSP device attributes for omap_hwmod |
| 362 | * @sidetone: name of the sidetone device |
| 363 | */ |
| 364 | struct omap_mcbsp_dev_attr { |
| 365 | const char *sidetone; |
| 366 | }; |
| 367 | |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 368 | extern struct omap_mcbsp **mcbsp_ptr; |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 369 | extern int omap_mcbsp_count, omap_mcbsp_cache_size; |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 370 | |
Paul Walmsley | d135865 | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 371 | #define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count) |
| 372 | #define id_to_mcbsp_ptr(id) mcbsp_ptr[id]; |
| 373 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 374 | int omap_mcbsp_init(void); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 375 | void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config); |
Tony Lindgren | a8eb7ca | 2010-02-12 12:26:48 -0800 | [diff] [blame] | 376 | #ifdef CONFIG_ARCH_OMAP3 |
Eduardo Valentin | 7aa9ff5 | 2009-08-20 16:18:10 +0300 | [diff] [blame] | 377 | void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold); |
| 378 | void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold); |
Eduardo Valentin | a1a56f5f | 2009-08-20 16:18:11 +0300 | [diff] [blame] | 379 | u16 omap_mcbsp_get_max_tx_threshold(unsigned int id); |
| 380 | u16 omap_mcbsp_get_max_rx_threshold(unsigned int id); |
Peter Ujfalusi | 0acce82 | 2010-06-03 07:39:32 +0300 | [diff] [blame] | 381 | u16 omap_mcbsp_get_fifo_size(unsigned int id); |
Peter Ujfalusi | 7dc976e | 2010-03-03 15:08:08 +0200 | [diff] [blame] | 382 | u16 omap_mcbsp_get_tx_delay(unsigned int id); |
| 383 | u16 omap_mcbsp_get_rx_delay(unsigned int id); |
Peter Ujfalusi | 98cb20e | 2009-08-20 16:18:14 +0300 | [diff] [blame] | 384 | int omap_mcbsp_get_dma_op_mode(unsigned int id); |
Eduardo Valentin | 7aa9ff5 | 2009-08-20 16:18:10 +0300 | [diff] [blame] | 385 | #else |
| 386 | static inline void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold) |
| 387 | { } |
| 388 | static inline void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold) |
| 389 | { } |
Eduardo Valentin | a1a56f5f | 2009-08-20 16:18:11 +0300 | [diff] [blame] | 390 | static inline u16 omap_mcbsp_get_max_tx_threshold(unsigned int id) { return 0; } |
| 391 | static inline u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) { return 0; } |
Peter Ujfalusi | 0acce82 | 2010-06-03 07:39:32 +0300 | [diff] [blame] | 392 | static inline u16 omap_mcbsp_get_fifo_size(unsigned int id) { return 0; } |
Peter Ujfalusi | 7dc976e | 2010-03-03 15:08:08 +0200 | [diff] [blame] | 393 | static inline u16 omap_mcbsp_get_tx_delay(unsigned int id) { return 0; } |
| 394 | static inline u16 omap_mcbsp_get_rx_delay(unsigned int id) { return 0; } |
Peter Ujfalusi | 98cb20e | 2009-08-20 16:18:14 +0300 | [diff] [blame] | 395 | static inline int omap_mcbsp_get_dma_op_mode(unsigned int id) { return 0; } |
Eduardo Valentin | 7aa9ff5 | 2009-08-20 16:18:10 +0300 | [diff] [blame] | 396 | #endif |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 397 | int omap_mcbsp_request(unsigned int id); |
| 398 | void omap_mcbsp_free(unsigned int id); |
Jarkko Nikula | c12abc0 | 2009-08-07 09:59:47 +0300 | [diff] [blame] | 399 | void omap_mcbsp_start(unsigned int id, int tx, int rx); |
| 400 | void omap_mcbsp_stop(unsigned int id, int tx, int rx); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 401 | |
Paul Walmsley | d135865 | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 402 | /* McBSP functional clock source changing function */ |
| 403 | extern int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 404 | |
Paul Walmsley | cf4c87a | 2010-10-08 11:40:19 -0600 | [diff] [blame] | 405 | /* McBSP signal muxing API */ |
| 406 | void omap2_mcbsp1_mux_clkr_src(u8 mux); |
| 407 | void omap2_mcbsp1_mux_fsr_src(u8 mux); |
| 408 | |
Kishon Vijay Abraham I | 9504ba6 | 2011-02-24 15:16:55 +0530 | [diff] [blame] | 409 | int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream); |
| 410 | int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream); |
| 411 | |
Eero Nurkkala | d912fa9 | 2010-02-22 12:21:11 +0000 | [diff] [blame] | 412 | #ifdef CONFIG_ARCH_OMAP3 |
| 413 | /* Sidetone specific API */ |
| 414 | int omap_st_set_chgain(unsigned int id, int channel, s16 chgain); |
| 415 | int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain); |
| 416 | int omap_st_enable(unsigned int id); |
| 417 | int omap_st_disable(unsigned int id); |
| 418 | int omap_st_is_enabled(unsigned int id); |
| 419 | #else |
| 420 | static inline int omap_st_set_chgain(unsigned int id, int channel, |
| 421 | s16 chgain) { return 0; } |
| 422 | static inline int omap_st_get_chgain(unsigned int id, int channel, |
| 423 | s16 *chgain) { return 0; } |
| 424 | static inline int omap_st_enable(unsigned int id) { return 0; } |
| 425 | static inline int omap_st_disable(unsigned int id) { return 0; } |
| 426 | static inline int omap_st_is_enabled(unsigned int id) { return 0; } |
| 427 | #endif |
| 428 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 429 | #endif |