Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ALSA SoC I2S (McBSP) Audio Layer for TI DAVINCI processor |
| 3 | * |
Vladimir Barinov | d6b5203 | 2008-09-29 23:14:11 +0400 | [diff] [blame] | 4 | * Author: Vladimir Barinov, <vbarinov@embeddedalley.com> |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 5 | * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/device.h> |
| 15 | #include <linux/delay.h> |
| 16 | #include <linux/io.h> |
| 17 | #include <linux/clk.h> |
| 18 | |
| 19 | #include <sound/core.h> |
| 20 | #include <sound/pcm.h> |
| 21 | #include <sound/pcm_params.h> |
| 22 | #include <sound/initval.h> |
| 23 | #include <sound/soc.h> |
| 24 | |
| 25 | #include "davinci-pcm.h" |
| 26 | |
David Brownell | a62114c | 2009-05-14 12:47:42 -0700 | [diff] [blame] | 27 | |
| 28 | /* |
| 29 | * NOTE: terminology here is confusing. |
| 30 | * |
| 31 | * - This driver supports the "Audio Serial Port" (ASP), |
| 32 | * found on dm6446, dm355, and other DaVinci chips. |
| 33 | * |
| 34 | * - But it labels it a "Multi-channel Buffered Serial Port" |
| 35 | * (McBSP) as on older chips like the dm642 ... which was |
| 36 | * backward-compatible, possibly explaining that confusion. |
| 37 | * |
| 38 | * - OMAP chips have a controller called McBSP, which is |
| 39 | * incompatible with the DaVinci flavor of McBSP. |
| 40 | * |
| 41 | * - Newer DaVinci chips have a controller called McASP, |
| 42 | * incompatible with ASP and with either McBSP. |
| 43 | * |
| 44 | * In short: this uses ASP to implement I2S, not McBSP. |
| 45 | * And it won't be the only DaVinci implemention of I2S. |
| 46 | */ |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 47 | #define DAVINCI_MCBSP_DRR_REG 0x00 |
| 48 | #define DAVINCI_MCBSP_DXR_REG 0x04 |
| 49 | #define DAVINCI_MCBSP_SPCR_REG 0x08 |
| 50 | #define DAVINCI_MCBSP_RCR_REG 0x0c |
| 51 | #define DAVINCI_MCBSP_XCR_REG 0x10 |
| 52 | #define DAVINCI_MCBSP_SRGR_REG 0x14 |
| 53 | #define DAVINCI_MCBSP_PCR_REG 0x24 |
| 54 | |
| 55 | #define DAVINCI_MCBSP_SPCR_RRST (1 << 0) |
| 56 | #define DAVINCI_MCBSP_SPCR_RINTM(v) ((v) << 4) |
| 57 | #define DAVINCI_MCBSP_SPCR_XRST (1 << 16) |
| 58 | #define DAVINCI_MCBSP_SPCR_XINTM(v) ((v) << 20) |
| 59 | #define DAVINCI_MCBSP_SPCR_GRST (1 << 22) |
| 60 | #define DAVINCI_MCBSP_SPCR_FRST (1 << 23) |
| 61 | #define DAVINCI_MCBSP_SPCR_FREE (1 << 25) |
| 62 | |
| 63 | #define DAVINCI_MCBSP_RCR_RWDLEN1(v) ((v) << 5) |
| 64 | #define DAVINCI_MCBSP_RCR_RFRLEN1(v) ((v) << 8) |
| 65 | #define DAVINCI_MCBSP_RCR_RDATDLY(v) ((v) << 16) |
Troy Kisky | f5cfa95 | 2009-07-04 19:29:57 -0700 | [diff] [blame] | 66 | #define DAVINCI_MCBSP_RCR_RFIG (1 << 18) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 67 | #define DAVINCI_MCBSP_RCR_RWDLEN2(v) ((v) << 21) |
| 68 | |
| 69 | #define DAVINCI_MCBSP_XCR_XWDLEN1(v) ((v) << 5) |
| 70 | #define DAVINCI_MCBSP_XCR_XFRLEN1(v) ((v) << 8) |
| 71 | #define DAVINCI_MCBSP_XCR_XDATDLY(v) ((v) << 16) |
| 72 | #define DAVINCI_MCBSP_XCR_XFIG (1 << 18) |
| 73 | #define DAVINCI_MCBSP_XCR_XWDLEN2(v) ((v) << 21) |
| 74 | |
| 75 | #define DAVINCI_MCBSP_SRGR_FWID(v) ((v) << 8) |
| 76 | #define DAVINCI_MCBSP_SRGR_FPER(v) ((v) << 16) |
| 77 | #define DAVINCI_MCBSP_SRGR_FSGM (1 << 28) |
| 78 | |
| 79 | #define DAVINCI_MCBSP_PCR_CLKRP (1 << 0) |
| 80 | #define DAVINCI_MCBSP_PCR_CLKXP (1 << 1) |
| 81 | #define DAVINCI_MCBSP_PCR_FSRP (1 << 2) |
| 82 | #define DAVINCI_MCBSP_PCR_FSXP (1 << 3) |
Hugo Villeneuve | b402dff | 2008-11-08 13:26:09 -0500 | [diff] [blame] | 83 | #define DAVINCI_MCBSP_PCR_SCLKME (1 << 7) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 84 | #define DAVINCI_MCBSP_PCR_CLKRM (1 << 8) |
| 85 | #define DAVINCI_MCBSP_PCR_CLKXM (1 << 9) |
| 86 | #define DAVINCI_MCBSP_PCR_FSRM (1 << 10) |
| 87 | #define DAVINCI_MCBSP_PCR_FSXM (1 << 11) |
| 88 | |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 89 | enum { |
| 90 | DAVINCI_MCBSP_WORD_8 = 0, |
| 91 | DAVINCI_MCBSP_WORD_12, |
| 92 | DAVINCI_MCBSP_WORD_16, |
| 93 | DAVINCI_MCBSP_WORD_20, |
| 94 | DAVINCI_MCBSP_WORD_24, |
| 95 | DAVINCI_MCBSP_WORD_32, |
| 96 | }; |
| 97 | |
| 98 | static struct davinci_pcm_dma_params davinci_i2s_pcm_out = { |
| 99 | .name = "I2S PCM Stereo out", |
| 100 | }; |
| 101 | |
| 102 | static struct davinci_pcm_dma_params davinci_i2s_pcm_in = { |
| 103 | .name = "I2S PCM Stereo in", |
| 104 | }; |
| 105 | |
| 106 | struct davinci_mcbsp_dev { |
| 107 | void __iomem *base; |
Troy Kisky | f5cfa95 | 2009-07-04 19:29:57 -0700 | [diff] [blame] | 108 | #define MOD_DSP_A 0 |
| 109 | #define MOD_DSP_B 1 |
| 110 | int mode; |
Troy Kisky | c392bec | 2009-07-04 19:29:52 -0700 | [diff] [blame] | 111 | u32 pcr; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 112 | struct clk *clk; |
| 113 | struct davinci_pcm_dma_params *dma_params[2]; |
| 114 | }; |
| 115 | |
| 116 | static inline void davinci_mcbsp_write_reg(struct davinci_mcbsp_dev *dev, |
| 117 | int reg, u32 val) |
| 118 | { |
| 119 | __raw_writel(val, dev->base + reg); |
| 120 | } |
| 121 | |
| 122 | static inline u32 davinci_mcbsp_read_reg(struct davinci_mcbsp_dev *dev, int reg) |
| 123 | { |
| 124 | return __raw_readl(dev->base + reg); |
| 125 | } |
| 126 | |
Troy Kisky | c392bec | 2009-07-04 19:29:52 -0700 | [diff] [blame] | 127 | static void toggle_clock(struct davinci_mcbsp_dev *dev, int playback) |
| 128 | { |
| 129 | u32 m = playback ? DAVINCI_MCBSP_PCR_CLKXP : DAVINCI_MCBSP_PCR_CLKRP; |
| 130 | /* The clock needs to toggle to complete reset. |
| 131 | * So, fake it by toggling the clk polarity. |
| 132 | */ |
| 133 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, dev->pcr ^ m); |
| 134 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, dev->pcr); |
| 135 | } |
| 136 | |
Troy Kisky | f9af37c | 2009-07-04 19:29:53 -0700 | [diff] [blame] | 137 | static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, |
| 138 | struct snd_pcm_substream *substream) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 139 | { |
| 140 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Naresh Medisetty | fb0ef64 | 2008-11-12 10:26:31 +0530 | [diff] [blame] | 141 | struct snd_soc_device *socdev = rtd->socdev; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 142 | struct snd_soc_platform *platform = socdev->card->platform; |
Troy Kisky | c392bec | 2009-07-04 19:29:52 -0700 | [diff] [blame] | 143 | int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 144 | u32 spcr; |
Troy Kisky | c392bec | 2009-07-04 19:29:52 -0700 | [diff] [blame] | 145 | u32 mask = playback ? DAVINCI_MCBSP_SPCR_XRST : DAVINCI_MCBSP_SPCR_RRST; |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 146 | spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); |
Troy Kisky | c392bec | 2009-07-04 19:29:52 -0700 | [diff] [blame] | 147 | if (spcr & mask) { |
| 148 | /* start off disabled */ |
| 149 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, |
| 150 | spcr & ~mask); |
| 151 | toggle_clock(dev, playback); |
| 152 | } |
Troy Kisky | 1bef449 | 2009-07-04 19:29:55 -0700 | [diff] [blame] | 153 | if (dev->pcr & (DAVINCI_MCBSP_PCR_FSXM | DAVINCI_MCBSP_PCR_FSRM | |
| 154 | DAVINCI_MCBSP_PCR_CLKXM | DAVINCI_MCBSP_PCR_CLKRM)) { |
| 155 | /* Start the sample generator */ |
| 156 | spcr |= DAVINCI_MCBSP_SPCR_GRST; |
| 157 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); |
| 158 | } |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 159 | |
Troy Kisky | 1bef449 | 2009-07-04 19:29:55 -0700 | [diff] [blame] | 160 | if (playback) { |
Naresh Medisetty | fb0ef64 | 2008-11-12 10:26:31 +0530 | [diff] [blame] | 161 | /* Stop the DMA to avoid data loss */ |
| 162 | /* while the transmitter is out of reset to handle XSYNCERR */ |
| 163 | if (platform->pcm_ops->trigger) { |
Troy Kisky | eba575c | 2009-07-04 19:29:54 -0700 | [diff] [blame] | 164 | int ret = platform->pcm_ops->trigger(substream, |
Naresh Medisetty | fb0ef64 | 2008-11-12 10:26:31 +0530 | [diff] [blame] | 165 | SNDRV_PCM_TRIGGER_STOP); |
| 166 | if (ret < 0) |
| 167 | printk(KERN_DEBUG "Playback DMA stop failed\n"); |
| 168 | } |
| 169 | |
| 170 | /* Enable the transmitter */ |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 171 | spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); |
| 172 | spcr |= DAVINCI_MCBSP_SPCR_XRST; |
| 173 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); |
Naresh Medisetty | fb0ef64 | 2008-11-12 10:26:31 +0530 | [diff] [blame] | 174 | |
| 175 | /* wait for any unexpected frame sync error to occur */ |
| 176 | udelay(100); |
| 177 | |
| 178 | /* Disable the transmitter to clear any outstanding XSYNCERR */ |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 179 | spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); |
| 180 | spcr &= ~DAVINCI_MCBSP_SPCR_XRST; |
| 181 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); |
Troy Kisky | c392bec | 2009-07-04 19:29:52 -0700 | [diff] [blame] | 182 | toggle_clock(dev, playback); |
Naresh Medisetty | fb0ef64 | 2008-11-12 10:26:31 +0530 | [diff] [blame] | 183 | |
| 184 | /* Restart the DMA */ |
| 185 | if (platform->pcm_ops->trigger) { |
Troy Kisky | eba575c | 2009-07-04 19:29:54 -0700 | [diff] [blame] | 186 | int ret = platform->pcm_ops->trigger(substream, |
Naresh Medisetty | fb0ef64 | 2008-11-12 10:26:31 +0530 | [diff] [blame] | 187 | SNDRV_PCM_TRIGGER_START); |
| 188 | if (ret < 0) |
| 189 | printk(KERN_DEBUG "Playback DMA start failed\n"); |
| 190 | } |
Naresh Medisetty | fb0ef64 | 2008-11-12 10:26:31 +0530 | [diff] [blame] | 191 | } |
| 192 | |
Troy Kisky | 1bef449 | 2009-07-04 19:29:55 -0700 | [diff] [blame] | 193 | /* Enable transmitter or receiver */ |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 194 | spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); |
Troy Kisky | 1bef449 | 2009-07-04 19:29:55 -0700 | [diff] [blame] | 195 | spcr |= mask; |
| 196 | |
| 197 | if (dev->pcr & (DAVINCI_MCBSP_PCR_FSXM | DAVINCI_MCBSP_PCR_FSRM)) { |
| 198 | /* Start frame sync */ |
| 199 | spcr |= DAVINCI_MCBSP_SPCR_FRST; |
| 200 | } |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 201 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 202 | } |
| 203 | |
Troy Kisky | f9af37c | 2009-07-04 19:29:53 -0700 | [diff] [blame] | 204 | static void davinci_mcbsp_stop(struct davinci_mcbsp_dev *dev, int playback) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 205 | { |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 206 | u32 spcr; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 207 | |
| 208 | /* Reset transmitter/receiver and sample rate/frame sync generators */ |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 209 | spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); |
| 210 | spcr &= ~(DAVINCI_MCBSP_SPCR_GRST | DAVINCI_MCBSP_SPCR_FRST); |
Troy Kisky | c392bec | 2009-07-04 19:29:52 -0700 | [diff] [blame] | 211 | spcr &= playback ? ~DAVINCI_MCBSP_SPCR_XRST : ~DAVINCI_MCBSP_SPCR_RRST; |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 212 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); |
Troy Kisky | c392bec | 2009-07-04 19:29:52 -0700 | [diff] [blame] | 213 | toggle_clock(dev, playback); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 214 | } |
| 215 | |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 216 | static int davinci_i2s_startup(struct snd_pcm_substream *substream, |
Troy Kisky | 9333b59 | 2009-07-04 19:29:56 -0700 | [diff] [blame] | 217 | struct snd_soc_dai *cpu_dai) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 218 | { |
Troy Kisky | 9333b59 | 2009-07-04 19:29:56 -0700 | [diff] [blame] | 219 | struct davinci_mcbsp_dev *dev = cpu_dai->private_data; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 220 | cpu_dai->dma_data = dev->dma_params[substream->stream]; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 221 | return 0; |
| 222 | } |
| 223 | |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 224 | #define DEFAULT_BITPERSAMPLE 16 |
| 225 | |
Liam Girdwood | 9cb132d | 2008-07-07 16:07:42 +0100 | [diff] [blame] | 226 | static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 227 | unsigned int fmt) |
| 228 | { |
| 229 | struct davinci_mcbsp_dev *dev = cpu_dai->private_data; |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 230 | unsigned int pcr; |
| 231 | unsigned int srgr; |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 232 | srgr = DAVINCI_MCBSP_SRGR_FSGM | |
| 233 | DAVINCI_MCBSP_SRGR_FPER(DEFAULT_BITPERSAMPLE * 2 - 1) | |
| 234 | DAVINCI_MCBSP_SRGR_FWID(DEFAULT_BITPERSAMPLE - 1); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 235 | |
Troy Kisky | f5cfa95 | 2009-07-04 19:29:57 -0700 | [diff] [blame] | 236 | /* set master/slave audio interface */ |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 237 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 238 | case SND_SOC_DAIFMT_CBS_CFS: |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 239 | /* cpu is master */ |
| 240 | pcr = DAVINCI_MCBSP_PCR_FSXM | |
| 241 | DAVINCI_MCBSP_PCR_FSRM | |
| 242 | DAVINCI_MCBSP_PCR_CLKXM | |
| 243 | DAVINCI_MCBSP_PCR_CLKRM; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 244 | break; |
Hugo Villeneuve | b402dff | 2008-11-08 13:26:09 -0500 | [diff] [blame] | 245 | case SND_SOC_DAIFMT_CBM_CFS: |
| 246 | /* McBSP CLKR pin is the input for the Sample Rate Generator. |
| 247 | * McBSP FSR and FSX are driven by the Sample Rate Generator. */ |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 248 | pcr = DAVINCI_MCBSP_PCR_SCLKME | |
| 249 | DAVINCI_MCBSP_PCR_FSXM | |
| 250 | DAVINCI_MCBSP_PCR_FSRM; |
Hugo Villeneuve | b402dff | 2008-11-08 13:26:09 -0500 | [diff] [blame] | 251 | break; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 252 | case SND_SOC_DAIFMT_CBM_CFM: |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 253 | /* codec is master */ |
| 254 | pcr = 0; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 255 | break; |
| 256 | default: |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 257 | printk(KERN_ERR "%s:bad master\n", __func__); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 258 | return -EINVAL; |
| 259 | } |
| 260 | |
Troy Kisky | f5cfa95 | 2009-07-04 19:29:57 -0700 | [diff] [blame] | 261 | /* interface format */ |
Troy Kisky | 69ab820 | 2008-12-18 12:36:44 -0700 | [diff] [blame] | 262 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
Troy Kisky | 69ab820 | 2008-12-18 12:36:44 -0700 | [diff] [blame] | 263 | case SND_SOC_DAIFMT_I2S: |
Troy Kisky | 07d8d9d | 2008-12-19 13:05:24 -0700 | [diff] [blame] | 264 | /* Davinci doesn't support TRUE I2S, but some codecs will have |
| 265 | * the left and right channels contiguous. This allows |
| 266 | * dsp_a mode to be used with an inverted normal frame clk. |
| 267 | * If your codec is master and does not have contiguous |
| 268 | * channels, then you will have sound on only one channel. |
| 269 | * Try using a different mode, or codec as slave. |
| 270 | * |
| 271 | * The TLV320AIC33 is an example of a codec where this works. |
| 272 | * It has a variable bit clock frequency allowing it to have |
| 273 | * valid data on every bit clock. |
| 274 | * |
| 275 | * The TLV320AIC23 is an example of a codec where this does not |
| 276 | * work. It has a fixed bit clock frequency with progressively |
| 277 | * more empty bit clock slots between channels as the sample |
| 278 | * rate is lowered. |
| 279 | */ |
| 280 | fmt ^= SND_SOC_DAIFMT_NB_IF; |
| 281 | case SND_SOC_DAIFMT_DSP_A: |
Troy Kisky | f5cfa95 | 2009-07-04 19:29:57 -0700 | [diff] [blame] | 282 | dev->mode = MOD_DSP_A; |
| 283 | break; |
| 284 | case SND_SOC_DAIFMT_DSP_B: |
| 285 | dev->mode = MOD_DSP_B; |
Troy Kisky | 69ab820 | 2008-12-18 12:36:44 -0700 | [diff] [blame] | 286 | break; |
| 287 | default: |
| 288 | printk(KERN_ERR "%s:bad format\n", __func__); |
| 289 | return -EINVAL; |
| 290 | } |
| 291 | |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 292 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
Troy Kisky | 9e03162 | 2008-12-19 13:05:23 -0700 | [diff] [blame] | 293 | case SND_SOC_DAIFMT_NB_NF: |
Troy Kisky | 664b4af | 2008-12-18 12:36:41 -0700 | [diff] [blame] | 294 | /* CLKRP Receive clock polarity, |
| 295 | * 1 - sampled on rising edge of CLKR |
| 296 | * valid on rising edge |
| 297 | * CLKXP Transmit clock polarity, |
| 298 | * 1 - clocked on falling edge of CLKX |
| 299 | * valid on rising edge |
| 300 | * FSRP Receive frame sync pol, 0 - active high |
| 301 | * FSXP Transmit frame sync pol, 0 - active high |
| 302 | */ |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 303 | pcr |= (DAVINCI_MCBSP_PCR_CLKXP | DAVINCI_MCBSP_PCR_CLKRP); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 304 | break; |
Troy Kisky | 9e03162 | 2008-12-19 13:05:23 -0700 | [diff] [blame] | 305 | case SND_SOC_DAIFMT_IB_IF: |
Troy Kisky | 664b4af | 2008-12-18 12:36:41 -0700 | [diff] [blame] | 306 | /* CLKRP Receive clock polarity, |
| 307 | * 0 - sampled on falling edge of CLKR |
| 308 | * valid on falling edge |
| 309 | * CLKXP Transmit clock polarity, |
| 310 | * 0 - clocked on rising edge of CLKX |
| 311 | * valid on falling edge |
| 312 | * FSRP Receive frame sync pol, 1 - active low |
| 313 | * FSXP Transmit frame sync pol, 1 - active low |
| 314 | */ |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 315 | pcr |= (DAVINCI_MCBSP_PCR_FSXP | DAVINCI_MCBSP_PCR_FSRP); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 316 | break; |
Troy Kisky | 9e03162 | 2008-12-19 13:05:23 -0700 | [diff] [blame] | 317 | case SND_SOC_DAIFMT_NB_IF: |
Troy Kisky | 664b4af | 2008-12-18 12:36:41 -0700 | [diff] [blame] | 318 | /* CLKRP Receive clock polarity, |
| 319 | * 1 - sampled on rising edge of CLKR |
| 320 | * valid on rising edge |
| 321 | * CLKXP Transmit clock polarity, |
| 322 | * 1 - clocked on falling edge of CLKX |
| 323 | * valid on rising edge |
| 324 | * FSRP Receive frame sync pol, 1 - active low |
| 325 | * FSXP Transmit frame sync pol, 1 - active low |
| 326 | */ |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 327 | pcr |= (DAVINCI_MCBSP_PCR_CLKXP | DAVINCI_MCBSP_PCR_CLKRP | |
| 328 | DAVINCI_MCBSP_PCR_FSXP | DAVINCI_MCBSP_PCR_FSRP); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 329 | break; |
Troy Kisky | 9e03162 | 2008-12-19 13:05:23 -0700 | [diff] [blame] | 330 | case SND_SOC_DAIFMT_IB_NF: |
Troy Kisky | 664b4af | 2008-12-18 12:36:41 -0700 | [diff] [blame] | 331 | /* CLKRP Receive clock polarity, |
| 332 | * 0 - sampled on falling edge of CLKR |
| 333 | * valid on falling edge |
| 334 | * CLKXP Transmit clock polarity, |
| 335 | * 0 - clocked on rising edge of CLKX |
| 336 | * valid on falling edge |
| 337 | * FSRP Receive frame sync pol, 0 - active high |
| 338 | * FSXP Transmit frame sync pol, 0 - active high |
| 339 | */ |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 340 | break; |
| 341 | default: |
| 342 | return -EINVAL; |
| 343 | } |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 344 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, srgr); |
Troy Kisky | c392bec | 2009-07-04 19:29:52 -0700 | [diff] [blame] | 345 | dev->pcr = pcr; |
Troy Kisky | 21903c1 | 2008-12-18 12:36:43 -0700 | [diff] [blame] | 346 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, pcr); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 351 | struct snd_pcm_hw_params *params, |
| 352 | struct snd_soc_dai *dai) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 353 | { |
| 354 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 355 | struct davinci_pcm_dma_params *dma_params = rtd->dai->cpu_dai->dma_data; |
| 356 | struct davinci_mcbsp_dev *dev = rtd->dai->cpu_dai->private_data; |
| 357 | struct snd_interval *i = NULL; |
| 358 | int mcbsp_word_length; |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 359 | unsigned int rcr, xcr, srgr; |
| 360 | u32 spcr; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 361 | |
| 362 | /* general line settings */ |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 363 | spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); |
Naresh Medisetty | cb6e206 | 2008-11-18 11:01:03 +0530 | [diff] [blame] | 364 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 365 | spcr |= DAVINCI_MCBSP_SPCR_RINTM(3) | DAVINCI_MCBSP_SPCR_FREE; |
| 366 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); |
Naresh Medisetty | cb6e206 | 2008-11-18 11:01:03 +0530 | [diff] [blame] | 367 | } else { |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 368 | spcr |= DAVINCI_MCBSP_SPCR_XINTM(3) | DAVINCI_MCBSP_SPCR_FREE; |
| 369 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); |
Naresh Medisetty | cb6e206 | 2008-11-18 11:01:03 +0530 | [diff] [blame] | 370 | } |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 371 | |
| 372 | i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 373 | srgr = DAVINCI_MCBSP_SRGR_FSGM; |
| 374 | srgr |= DAVINCI_MCBSP_SRGR_FWID(snd_interval_value(i) - 1); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 375 | |
| 376 | i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_FRAME_BITS); |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 377 | srgr |= DAVINCI_MCBSP_SRGR_FPER(snd_interval_value(i) - 1); |
| 378 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, srgr); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 379 | |
Troy Kisky | f5cfa95 | 2009-07-04 19:29:57 -0700 | [diff] [blame] | 380 | rcr = DAVINCI_MCBSP_RCR_RFIG; |
| 381 | xcr = DAVINCI_MCBSP_XCR_XFIG; |
| 382 | if (dev->mode == MOD_DSP_B) { |
| 383 | rcr |= DAVINCI_MCBSP_RCR_RDATDLY(0); |
| 384 | xcr |= DAVINCI_MCBSP_XCR_XDATDLY(0); |
| 385 | } else { |
| 386 | rcr |= DAVINCI_MCBSP_RCR_RDATDLY(1); |
| 387 | xcr |= DAVINCI_MCBSP_XCR_XDATDLY(1); |
| 388 | } |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 389 | /* Determine xfer data type */ |
| 390 | switch (params_format(params)) { |
| 391 | case SNDRV_PCM_FORMAT_S8: |
| 392 | dma_params->data_type = 1; |
| 393 | mcbsp_word_length = DAVINCI_MCBSP_WORD_8; |
| 394 | break; |
| 395 | case SNDRV_PCM_FORMAT_S16_LE: |
| 396 | dma_params->data_type = 2; |
| 397 | mcbsp_word_length = DAVINCI_MCBSP_WORD_16; |
| 398 | break; |
| 399 | case SNDRV_PCM_FORMAT_S32_LE: |
| 400 | dma_params->data_type = 4; |
| 401 | mcbsp_word_length = DAVINCI_MCBSP_WORD_32; |
| 402 | break; |
| 403 | default: |
Jean Delvare | 9b6e12e | 2008-08-26 15:47:55 +0200 | [diff] [blame] | 404 | printk(KERN_WARNING "davinci-i2s: unsupported PCM format\n"); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 405 | return -EINVAL; |
| 406 | } |
| 407 | |
Troy Kisky | f5cfa95 | 2009-07-04 19:29:57 -0700 | [diff] [blame] | 408 | rcr |= DAVINCI_MCBSP_RCR_RFRLEN1(1); |
| 409 | xcr |= DAVINCI_MCBSP_XCR_XFRLEN1(1); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 410 | |
Troy Kisky | f5cfa95 | 2009-07-04 19:29:57 -0700 | [diff] [blame] | 411 | rcr |= DAVINCI_MCBSP_RCR_RWDLEN1(mcbsp_word_length) | |
| 412 | DAVINCI_MCBSP_RCR_RWDLEN2(mcbsp_word_length); |
| 413 | xcr |= DAVINCI_MCBSP_XCR_XWDLEN1(mcbsp_word_length) | |
| 414 | DAVINCI_MCBSP_XCR_XWDLEN2(mcbsp_word_length); |
| 415 | |
| 416 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
Troy Kisky | 35cf635 | 2009-07-04 19:29:51 -0700 | [diff] [blame] | 417 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_XCR_REG, xcr); |
Troy Kisky | f5cfa95 | 2009-07-04 19:29:57 -0700 | [diff] [blame] | 418 | else |
| 419 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_RCR_REG, rcr); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 420 | return 0; |
| 421 | } |
| 422 | |
Troy Kisky | af0adf3 | 2009-07-04 19:29:59 -0700 | [diff] [blame^] | 423 | static int davinci_i2s_prepare(struct snd_pcm_substream *substream, |
| 424 | struct snd_soc_dai *dai) |
| 425 | { |
| 426 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 427 | struct davinci_mcbsp_dev *dev = rtd->dai->cpu_dai->private_data; |
| 428 | int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); |
| 429 | davinci_mcbsp_stop(dev, playback); |
| 430 | if ((dev->pcr & DAVINCI_MCBSP_PCR_FSXM) == 0) { |
| 431 | /* codec is master */ |
| 432 | davinci_mcbsp_start(dev, substream); |
| 433 | } |
| 434 | return 0; |
| 435 | } |
| 436 | |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 437 | static int davinci_i2s_trigger(struct snd_pcm_substream *substream, int cmd, |
| 438 | struct snd_soc_dai *dai) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 439 | { |
Troy Kisky | f9af37c | 2009-07-04 19:29:53 -0700 | [diff] [blame] | 440 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 441 | struct davinci_mcbsp_dev *dev = rtd->dai->cpu_dai->private_data; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 442 | int ret = 0; |
Troy Kisky | f9af37c | 2009-07-04 19:29:53 -0700 | [diff] [blame] | 443 | int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); |
Troy Kisky | af0adf3 | 2009-07-04 19:29:59 -0700 | [diff] [blame^] | 444 | if ((dev->pcr & DAVINCI_MCBSP_PCR_FSXM) == 0) |
| 445 | return 0; /* return if codec is master */ |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 446 | |
| 447 | switch (cmd) { |
| 448 | case SNDRV_PCM_TRIGGER_START: |
| 449 | case SNDRV_PCM_TRIGGER_RESUME: |
| 450 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
Troy Kisky | f9af37c | 2009-07-04 19:29:53 -0700 | [diff] [blame] | 451 | davinci_mcbsp_start(dev, substream); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 452 | break; |
| 453 | case SNDRV_PCM_TRIGGER_STOP: |
| 454 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| 455 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
Troy Kisky | f9af37c | 2009-07-04 19:29:53 -0700 | [diff] [blame] | 456 | davinci_mcbsp_stop(dev, playback); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 457 | break; |
| 458 | default: |
| 459 | ret = -EINVAL; |
| 460 | } |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 461 | return ret; |
| 462 | } |
| 463 | |
Troy Kisky | af0adf3 | 2009-07-04 19:29:59 -0700 | [diff] [blame^] | 464 | static void davinci_i2s_shutdown(struct snd_pcm_substream *substream, |
| 465 | struct snd_soc_dai *dai) |
| 466 | { |
| 467 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 468 | struct davinci_mcbsp_dev *dev = rtd->dai->cpu_dai->private_data; |
| 469 | int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); |
| 470 | davinci_mcbsp_stop(dev, playback); |
| 471 | } |
| 472 | |
Mark Brown | bdb9287 | 2008-06-11 13:47:10 +0100 | [diff] [blame] | 473 | static int davinci_i2s_probe(struct platform_device *pdev, |
Liam Girdwood | 9cb132d | 2008-07-07 16:07:42 +0100 | [diff] [blame] | 474 | struct snd_soc_dai *dai) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 475 | { |
| 476 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 477 | struct snd_soc_card *card = socdev->card; |
David Brownell | a62114c | 2009-05-14 12:47:42 -0700 | [diff] [blame] | 478 | struct snd_soc_dai *cpu_dai = card->dai_link->cpu_dai; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 479 | struct davinci_mcbsp_dev *dev; |
| 480 | struct resource *mem, *ioarea; |
| 481 | struct evm_snd_platform_data *pdata; |
| 482 | int ret; |
| 483 | |
| 484 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 485 | if (!mem) { |
| 486 | dev_err(&pdev->dev, "no mem resource?\n"); |
| 487 | return -ENODEV; |
| 488 | } |
| 489 | |
| 490 | ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1, |
| 491 | pdev->name); |
| 492 | if (!ioarea) { |
| 493 | dev_err(&pdev->dev, "McBSP region already claimed\n"); |
| 494 | return -EBUSY; |
| 495 | } |
| 496 | |
| 497 | dev = kzalloc(sizeof(struct davinci_mcbsp_dev), GFP_KERNEL); |
| 498 | if (!dev) { |
| 499 | ret = -ENOMEM; |
| 500 | goto err_release_region; |
| 501 | } |
| 502 | |
| 503 | cpu_dai->private_data = dev; |
| 504 | |
David Brownell | a62114c | 2009-05-14 12:47:42 -0700 | [diff] [blame] | 505 | dev->clk = clk_get(&pdev->dev, NULL); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 506 | if (IS_ERR(dev->clk)) { |
| 507 | ret = -ENODEV; |
| 508 | goto err_free_mem; |
| 509 | } |
| 510 | clk_enable(dev->clk); |
| 511 | |
| 512 | dev->base = (void __iomem *)IO_ADDRESS(mem->start); |
| 513 | pdata = pdev->dev.platform_data; |
| 514 | |
| 515 | dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK] = &davinci_i2s_pcm_out; |
| 516 | dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->channel = pdata->tx_dma_ch; |
| 517 | dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->dma_addr = |
| 518 | (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DXR_REG); |
| 519 | |
| 520 | dev->dma_params[SNDRV_PCM_STREAM_CAPTURE] = &davinci_i2s_pcm_in; |
| 521 | dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->channel = pdata->rx_dma_ch; |
| 522 | dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->dma_addr = |
| 523 | (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DRR_REG); |
| 524 | |
| 525 | return 0; |
| 526 | |
| 527 | err_free_mem: |
| 528 | kfree(dev); |
| 529 | err_release_region: |
| 530 | release_mem_region(mem->start, (mem->end - mem->start) + 1); |
| 531 | |
| 532 | return ret; |
| 533 | } |
| 534 | |
Mark Brown | bdb9287 | 2008-06-11 13:47:10 +0100 | [diff] [blame] | 535 | static void davinci_i2s_remove(struct platform_device *pdev, |
Liam Girdwood | 9cb132d | 2008-07-07 16:07:42 +0100 | [diff] [blame] | 536 | struct snd_soc_dai *dai) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 537 | { |
| 538 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 539 | struct snd_soc_card *card = socdev->card; |
David Brownell | a62114c | 2009-05-14 12:47:42 -0700 | [diff] [blame] | 540 | struct snd_soc_dai *cpu_dai = card->dai_link->cpu_dai; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 541 | struct davinci_mcbsp_dev *dev = cpu_dai->private_data; |
| 542 | struct resource *mem; |
| 543 | |
| 544 | clk_disable(dev->clk); |
| 545 | clk_put(dev->clk); |
| 546 | dev->clk = NULL; |
| 547 | |
| 548 | kfree(dev); |
| 549 | |
| 550 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 551 | release_mem_region(mem->start, (mem->end - mem->start) + 1); |
| 552 | } |
| 553 | |
| 554 | #define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 |
| 555 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 556 | static struct snd_soc_dai_ops davinci_i2s_dai_ops = { |
| 557 | .startup = davinci_i2s_startup, |
Troy Kisky | af0adf3 | 2009-07-04 19:29:59 -0700 | [diff] [blame^] | 558 | .shutdown = davinci_i2s_shutdown, |
| 559 | .prepare = davinci_i2s_prepare, |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 560 | .trigger = davinci_i2s_trigger, |
| 561 | .hw_params = davinci_i2s_hw_params, |
| 562 | .set_fmt = davinci_i2s_set_dai_fmt, |
| 563 | }; |
| 564 | |
Liam Girdwood | 9cb132d | 2008-07-07 16:07:42 +0100 | [diff] [blame] | 565 | struct snd_soc_dai davinci_i2s_dai = { |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 566 | .name = "davinci-i2s", |
| 567 | .id = 0, |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 568 | .probe = davinci_i2s_probe, |
| 569 | .remove = davinci_i2s_remove, |
| 570 | .playback = { |
| 571 | .channels_min = 2, |
| 572 | .channels_max = 2, |
| 573 | .rates = DAVINCI_I2S_RATES, |
| 574 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, |
| 575 | .capture = { |
| 576 | .channels_min = 2, |
| 577 | .channels_max = 2, |
| 578 | .rates = DAVINCI_I2S_RATES, |
| 579 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 580 | .ops = &davinci_i2s_dai_ops, |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 581 | }; |
| 582 | EXPORT_SYMBOL_GPL(davinci_i2s_dai); |
| 583 | |
Takashi Iwai | c9b3a40 | 2008-12-10 07:47:22 +0100 | [diff] [blame] | 584 | static int __init davinci_i2s_init(void) |
Mark Brown | 3f4b783 | 2008-12-03 19:26:35 +0000 | [diff] [blame] | 585 | { |
| 586 | return snd_soc_register_dai(&davinci_i2s_dai); |
| 587 | } |
| 588 | module_init(davinci_i2s_init); |
| 589 | |
| 590 | static void __exit davinci_i2s_exit(void) |
| 591 | { |
| 592 | snd_soc_unregister_dai(&davinci_i2s_dai); |
| 593 | } |
| 594 | module_exit(davinci_i2s_exit); |
| 595 | |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 596 | MODULE_AUTHOR("Vladimir Barinov"); |
| 597 | MODULE_DESCRIPTION("TI DAVINCI I2S (McBSP) SoC Interface"); |
| 598 | MODULE_LICENSE("GPL"); |