aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/Makefile5
-rw-r--r--sound/soc/atmel/Kconfig13
-rw-r--r--sound/soc/atmel/Makefile4
-rw-r--r--sound/soc/atmel/atmel-pcm-dma.c240
-rw-r--r--sound/soc/atmel/atmel-pcm-pdc.c401
-rw-r--r--sound/soc/atmel/atmel-pcm.c401
-rw-r--r--sound/soc/atmel/atmel-pcm.h34
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.c168
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.h3
-rw-r--r--sound/soc/atmel/sam9g20_wm8731.c116
-rw-r--r--sound/soc/codecs/Kconfig7
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/ab8500-codec.c2
-rw-r--r--sound/soc/codecs/ak4104.c65
-rw-r--r--sound/soc/codecs/ak4535.c7
-rw-r--r--sound/soc/codecs/ak4642.c23
-rw-r--r--sound/soc/codecs/arizona.c57
-rw-r--r--sound/soc/codecs/arizona.h71
-rw-r--r--sound/soc/codecs/cs4271.c32
-rw-r--r--sound/soc/codecs/cs42l52.c5
-rw-r--r--sound/soc/codecs/da7210.c24
-rw-r--r--sound/soc/codecs/da9055.c65
-rw-r--r--sound/soc/codecs/twl6040.c8
-rw-r--r--sound/soc/codecs/wm2200.c637
-rw-r--r--sound/soc/codecs/wm5102.c690
-rw-r--r--sound/soc/codecs/wm5110.c69
-rw-r--r--sound/soc/codecs/wm8978.c2
-rw-r--r--sound/soc/codecs/wm8994.c20
-rw-r--r--sound/soc/codecs/wm8994.h1
-rw-r--r--sound/soc/codecs/wm_adsp.c699
-rw-r--r--sound/soc/codecs/wm_adsp.h59
-rw-r--r--sound/soc/codecs/wmfw.h128
-rw-r--r--sound/soc/fsl/Kconfig4
-rw-r--r--sound/soc/fsl/Makefile10
-rw-r--r--sound/soc/kirkwood/kirkwood-dma.c3
-rw-r--r--sound/soc/kirkwood/kirkwood-i2s.c74
-rw-r--r--sound/soc/mxs/mxs-saif.c19
-rw-r--r--sound/soc/omap/ams-delta.c63
-rw-r--r--sound/soc/omap/mcbsp.c4
-rw-r--r--sound/soc/omap/mcbsp.h6
-rw-r--r--sound/soc/omap/omap-abe-twl6040.c6
-rw-r--r--sound/soc/omap/omap-dmic.c4
-rw-r--r--sound/soc/omap/omap-mcbsp.c5
-rw-r--r--sound/soc/omap/omap-mcpdm.c9
-rw-r--r--sound/soc/omap/zoom2.c12
-rw-r--r--sound/soc/pxa/mmp-pcm.c2
-rw-r--r--sound/soc/samsung/Kconfig2
-rw-r--r--sound/soc/samsung/bells.c2
-rw-r--r--sound/soc/sh/fsi.c15
-rw-r--r--sound/soc/soc-core.c5
-rw-r--r--sound/soc/soc-dapm.c2
-rw-r--r--sound/soc/soc-jack.c7
-rw-r--r--sound/soc/ux500/mop500.c17
-rw-r--r--sound/soc/ux500/ux500_msp_i2s.c8
54 files changed, 3473 insertions, 864 deletions
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index bcbf1d00aa85..99f32f7c0692 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -1,8 +1,9 @@
1snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o 1snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o
2snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o 2snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o
3 3
4snd-soc-dmaengine-pcm-objs := soc-dmaengine-pcm.o 4ifneq ($(CONFIG_SND_SOC_DMAENGINE_PCM),)
5obj-$(CONFIG_SND_SOC_DMAENGINE_PCM) += snd-soc-dmaengine-pcm.o 5snd-soc-core-objs += soc-dmaengine-pcm.o
6endif
6 7
7obj-$(CONFIG_SND_SOC) += snd-soc-core.o 8obj-$(CONFIG_SND_SOC) += snd-soc-core.o
8obj-$(CONFIG_SND_SOC) += codecs/ 9obj-$(CONFIG_SND_SOC) += codecs/
diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig
index 72b09cfd3dc3..d1b691bf8e2d 100644
--- a/sound/soc/atmel/Kconfig
+++ b/sound/soc/atmel/Kconfig
@@ -6,6 +6,14 @@ config SND_ATMEL_SOC
6 the ATMEL SSC interface. You will also need 6 the ATMEL SSC interface. You will also need
7 to select the audio interfaces to support below. 7 to select the audio interfaces to support below.
8 8
9config SND_ATMEL_SOC_PDC
10 tristate
11 depends on SND_ATMEL_SOC
12
13config SND_ATMEL_SOC_DMA
14 tristate
15 depends on SND_ATMEL_SOC
16
9config SND_ATMEL_SOC_SSC 17config SND_ATMEL_SOC_SSC
10 tristate 18 tristate
11 depends on SND_ATMEL_SOC 19 depends on SND_ATMEL_SOC
@@ -16,8 +24,8 @@ config SND_ATMEL_SOC_SSC
16 24
17config SND_AT91_SOC_SAM9G20_WM8731 25config SND_AT91_SOC_SAM9G20_WM8731
18 tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board" 26 tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board"
19 depends on ATMEL_SSC && ARCH_AT91SAM9G20 && SND_ATMEL_SOC && \ 27 depends on ATMEL_SSC && SND_ATMEL_SOC && AT91_PROGRAMMABLE_CLOCKS
20 AT91_PROGRAMMABLE_CLOCKS 28 select SND_ATMEL_SOC_PDC
21 select SND_ATMEL_SOC_SSC 29 select SND_ATMEL_SOC_SSC
22 select SND_SOC_WM8731 30 select SND_SOC_WM8731
23 help 31 help
@@ -27,6 +35,7 @@ config SND_AT91_SOC_SAM9G20_WM8731
27config SND_AT91_SOC_AFEB9260 35config SND_AT91_SOC_AFEB9260
28 tristate "SoC Audio support for AFEB9260 board" 36 tristate "SoC Audio support for AFEB9260 board"
29 depends on ATMEL_SSC && ARCH_AT91 && MACH_AFEB9260 && SND_ATMEL_SOC 37 depends on ATMEL_SSC && ARCH_AT91 && MACH_AFEB9260 && SND_ATMEL_SOC
38 select SND_ATMEL_SOC_PDC
30 select SND_ATMEL_SOC_SSC 39 select SND_ATMEL_SOC_SSC
31 select SND_SOC_TLV320AIC23 40 select SND_SOC_TLV320AIC23
32 help 41 help
diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile
index a5c0bf19da78..41967ccb6f41 100644
--- a/sound/soc/atmel/Makefile
+++ b/sound/soc/atmel/Makefile
@@ -1,8 +1,12 @@
1# AT91 Platform Support 1# AT91 Platform Support
2snd-soc-atmel-pcm-objs := atmel-pcm.o 2snd-soc-atmel-pcm-objs := atmel-pcm.o
3snd-soc-atmel-pcm-pdc-objs := atmel-pcm-pdc.o
4snd-soc-atmel-pcm-dma-objs := atmel-pcm-dma.o
3snd-soc-atmel_ssc_dai-objs := atmel_ssc_dai.o 5snd-soc-atmel_ssc_dai-objs := atmel_ssc_dai.o
4 6
5obj-$(CONFIG_SND_ATMEL_SOC) += snd-soc-atmel-pcm.o 7obj-$(CONFIG_SND_ATMEL_SOC) += snd-soc-atmel-pcm.o
8obj-$(CONFIG_SND_ATMEL_SOC_PDC) += snd-soc-atmel-pcm-pdc.o
9obj-$(CONFIG_SND_ATMEL_SOC_DMA) += snd-soc-atmel-pcm-dma.o
6obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o 10obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o
7 11
8# AT91 Machine Support 12# AT91 Machine Support
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c
new file mode 100644
index 000000000000..30184a4a147a
--- /dev/null
+++ b/sound/soc/atmel/atmel-pcm-dma.c
@@ -0,0 +1,240 @@
1/*
2 * atmel-pcm-dma.c -- ALSA PCM DMA support for the Atmel SoC.
3 *
4 * Copyright (C) 2012 Atmel
5 *
6 * Author: Bo Shen <voice.shen@atmel.com>
7 *
8 * Based on atmel-pcm by:
9 * Sedji Gaouaou <sedji.gaouaou@atmel.com>
10 * Copyright 2008 Atmel
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/platform_device.h>
30#include <linux/slab.h>
31#include <linux/dma-mapping.h>
32#include <linux/dmaengine.h>
33#include <linux/atmel-ssc.h>
34#include <linux/platform_data/dma-atmel.h>
35
36#include <sound/core.h>
37#include <sound/pcm.h>
38#include <sound/pcm_params.h>
39#include <sound/soc.h>
40#include <sound/dmaengine_pcm.h>
41
42#include "atmel-pcm.h"
43
44/*--------------------------------------------------------------------------*\
45 * Hardware definition
46\*--------------------------------------------------------------------------*/
47static const struct snd_pcm_hardware atmel_pcm_dma_hardware = {
48 .info = SNDRV_PCM_INFO_MMAP |
49 SNDRV_PCM_INFO_MMAP_VALID |
50 SNDRV_PCM_INFO_INTERLEAVED |
51 SNDRV_PCM_INFO_RESUME |
52 SNDRV_PCM_INFO_PAUSE,
53 .formats = SNDRV_PCM_FMTBIT_S16_LE,
54 .period_bytes_min = 256, /* lighting DMA overhead */
55 .period_bytes_max = 2 * 0xffff, /* if 2 bytes format */
56 .periods_min = 8,
57 .periods_max = 1024, /* no limit */
58 .buffer_bytes_max = ATMEL_SSC_DMABUF_SIZE,
59};
60
61/**
62 * atmel_pcm_dma_irq: SSC interrupt handler for DMAENGINE enabled SSC
63 *
64 * We use DMAENGINE to send/receive data to/from SSC so this ISR is only to
65 * check if any overrun occured.
66 */
67static void atmel_pcm_dma_irq(u32 ssc_sr,
68 struct snd_pcm_substream *substream)
69{
70 struct atmel_pcm_dma_params *prtd;
71
72 prtd = snd_dmaengine_pcm_get_data(substream);
73
74 if (ssc_sr & prtd->mask->ssc_error) {
75 if (snd_pcm_running(substream))
76 pr_warn("atmel-pcm: buffer %s on %s (SSC_SR=%#x)\n",
77 substream->stream == SNDRV_PCM_STREAM_PLAYBACK
78 ? "underrun" : "overrun", prtd->name,
79 ssc_sr);
80
81 /* stop RX and capture: will be enabled again at restart */
82 ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_disable);
83 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
84
85 /* now drain RHR and read status to remove xrun condition */
86 ssc_readx(prtd->ssc->regs, SSC_RHR);
87 ssc_readx(prtd->ssc->regs, SSC_SR);
88 }
89}
90
91/*--------------------------------------------------------------------------*\
92 * DMAENGINE operations
93\*--------------------------------------------------------------------------*/
94static bool filter(struct dma_chan *chan, void *slave)
95{
96 struct at_dma_slave *sl = slave;
97
98 if (sl->dma_dev == chan->device->dev) {
99 chan->private = sl;
100 return true;
101 } else {
102 return false;
103 }
104}
105
106static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream,
107 struct snd_pcm_hw_params *params)
108{
109 struct atmel_pcm_dma_params *prtd;
110 struct ssc_device *ssc;
111 struct dma_chan *dma_chan;
112 struct dma_slave_config slave_config;
113 int ret;
114
115 prtd = snd_dmaengine_pcm_get_data(substream);
116 ssc = prtd->ssc;
117
118 ret = snd_hwparams_to_dma_slave_config(substream, params,
119 &slave_config);
120 if (ret) {
121 pr_err("atmel-pcm: hwparams to dma slave configure failed\n");
122 return ret;
123 }
124
125 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
126 slave_config.dst_addr = (dma_addr_t)ssc->phybase + SSC_THR;
127 slave_config.dst_maxburst = 1;
128 } else {
129 slave_config.src_addr = (dma_addr_t)ssc->phybase + SSC_RHR;
130 slave_config.src_maxburst = 1;
131 }
132
133 slave_config.device_fc = false;
134
135 dma_chan = snd_dmaengine_pcm_get_chan(substream);
136 if (dmaengine_slave_config(dma_chan, &slave_config)) {
137 pr_err("atmel-pcm: failed to configure dma channel\n");
138 ret = -EBUSY;
139 return ret;
140 }
141
142 return 0;
143}
144
145static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
146 struct snd_pcm_hw_params *params)
147{
148 struct snd_soc_pcm_runtime *rtd = substream->private_data;
149 struct atmel_pcm_dma_params *prtd;
150 struct ssc_device *ssc;
151 struct at_dma_slave *sdata = NULL;
152 int ret;
153
154 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
155
156 prtd = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
157 ssc = prtd->ssc;
158 if (ssc->pdev)
159 sdata = ssc->pdev->dev.platform_data;
160
161 ret = snd_dmaengine_pcm_open(substream, filter, sdata);
162 if (ret) {
163 pr_err("atmel-pcm: dmaengine pcm open failed\n");
164 return -EINVAL;
165 }
166
167 snd_dmaengine_pcm_set_data(substream, prtd);
168
169 ret = atmel_pcm_configure_dma(substream, params);
170 if (ret) {
171 pr_err("atmel-pcm: failed to configure dmai\n");
172 goto err;
173 }
174
175 prtd->dma_intr_handler = atmel_pcm_dma_irq;
176
177 return 0;
178err:
179 snd_dmaengine_pcm_close(substream);
180 return ret;
181}
182
183static int atmel_pcm_dma_prepare(struct snd_pcm_substream *substream)
184{
185 struct atmel_pcm_dma_params *prtd;
186
187 prtd = snd_dmaengine_pcm_get_data(substream);
188
189 ssc_writex(prtd->ssc->regs, SSC_IER, prtd->mask->ssc_error);
190 ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_enable);
191
192 return 0;
193}
194
195static int atmel_pcm_open(struct snd_pcm_substream *substream)
196{
197 snd_soc_set_runtime_hwparams(substream, &atmel_pcm_dma_hardware);
198
199 return 0;
200}
201
202static int atmel_pcm_close(struct snd_pcm_substream *substream)
203{
204 snd_dmaengine_pcm_close(substream);
205
206 return 0;
207}
208
209static struct snd_pcm_ops atmel_pcm_ops = {
210 .open = atmel_pcm_open,
211 .close = atmel_pcm_close,
212 .ioctl = snd_pcm_lib_ioctl,
213 .hw_params = atmel_pcm_hw_params,
214 .prepare = atmel_pcm_dma_prepare,
215 .trigger = snd_dmaengine_pcm_trigger,
216 .pointer = snd_dmaengine_pcm_pointer_no_residue,
217 .mmap = atmel_pcm_mmap,
218};
219
220static struct snd_soc_platform_driver atmel_soc_platform = {
221 .ops = &atmel_pcm_ops,
222 .pcm_new = atmel_pcm_new,
223 .pcm_free = atmel_pcm_free,
224};
225
226int atmel_pcm_dma_platform_register(struct device *dev)
227{
228 return snd_soc_register_platform(dev, &atmel_soc_platform);
229}
230EXPORT_SYMBOL(atmel_pcm_dma_platform_register);
231
232void atmel_pcm_dma_platform_unregister(struct device *dev)
233{
234 snd_soc_unregister_platform(dev);
235}
236EXPORT_SYMBOL(atmel_pcm_dma_platform_unregister);
237
238MODULE_AUTHOR("Bo Shen <voice.shen@atmel.com>");
239MODULE_DESCRIPTION("Atmel DMA based PCM module");
240MODULE_LICENSE("GPL");
diff --git a/sound/soc/atmel/atmel-pcm-pdc.c b/sound/soc/atmel/atmel-pcm-pdc.c
new file mode 100644
index 000000000000..6a293c713a38
--- /dev/null
+++ b/sound/soc/atmel/atmel-pcm-pdc.c
@@ -0,0 +1,401 @@
1/*
2 * atmel-pcm.c -- ALSA PCM interface for the Atmel atmel SoC.
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2008 Atmel
6 *
7 * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
8 *
9 * Based on at91-pcm. by:
10 * Frank Mandarino <fmandarino@endrelia.com>
11 * Copyright 2006 Endrelia Technologies Inc.
12 *
13 * Based on pxa2xx-pcm.c by:
14 *
15 * Author: Nicolas Pitre
16 * Created: Nov 30, 2004
17 * Copyright: (C) 2004 MontaVista Software, Inc.
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 */
33
34#include <linux/module.h>
35#include <linux/init.h>
36#include <linux/platform_device.h>
37#include <linux/slab.h>
38#include <linux/dma-mapping.h>
39#include <linux/atmel_pdc.h>
40#include <linux/atmel-ssc.h>
41
42#include <sound/core.h>
43#include <sound/pcm.h>
44#include <sound/pcm_params.h>
45#include <sound/soc.h>
46
47#include "atmel-pcm.h"
48
49
50/*--------------------------------------------------------------------------*\
51 * Hardware definition
52\*--------------------------------------------------------------------------*/
53/* TODO: These values were taken from the AT91 platform driver, check
54 * them against real values for AT32
55 */
56static const struct snd_pcm_hardware atmel_pcm_hardware = {
57 .info = SNDRV_PCM_INFO_MMAP |
58 SNDRV_PCM_INFO_MMAP_VALID |
59 SNDRV_PCM_INFO_INTERLEAVED |
60 SNDRV_PCM_INFO_PAUSE,
61 .formats = SNDRV_PCM_FMTBIT_S16_LE,
62 .period_bytes_min = 32,
63 .period_bytes_max = 8192,
64 .periods_min = 2,
65 .periods_max = 1024,
66 .buffer_bytes_max = ATMEL_SSC_DMABUF_SIZE,
67};
68
69
70/*--------------------------------------------------------------------------*\
71 * Data types
72\*--------------------------------------------------------------------------*/
73struct atmel_runtime_data {
74 struct atmel_pcm_dma_params *params;
75 dma_addr_t dma_buffer; /* physical address of dma buffer */
76 dma_addr_t dma_buffer_end; /* first address beyond DMA buffer */
77 size_t period_size;
78
79 dma_addr_t period_ptr; /* physical address of next period */
80
81 /* PDC register save */
82 u32 pdc_xpr_save;
83 u32 pdc_xcr_save;
84 u32 pdc_xnpr_save;
85 u32 pdc_xncr_save;
86};
87
88/*--------------------------------------------------------------------------*\
89 * ISR
90\*--------------------------------------------------------------------------*/
91static void atmel_pcm_dma_irq(u32 ssc_sr,
92 struct snd_pcm_substream *substream)
93{
94 struct atmel_runtime_data *prtd = substream->runtime->private_data;
95 struct atmel_pcm_dma_params *params = prtd->params;
96 static int count;
97
98 count++;
99
100 if (ssc_sr & params->mask->ssc_endbuf) {
101 pr_warn("atmel-pcm: buffer %s on %s (SSC_SR=%#x, count=%d)\n",
102 substream->stream == SNDRV_PCM_STREAM_PLAYBACK
103 ? "underrun" : "overrun",
104 params->name, ssc_sr, count);
105
106 /* re-start the PDC */
107 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
108 params->mask->pdc_disable);
109 prtd->period_ptr += prtd->period_size;
110 if (prtd->period_ptr >= prtd->dma_buffer_end)
111 prtd->period_ptr = prtd->dma_buffer;
112
113 ssc_writex(params->ssc->regs, params->pdc->xpr,
114 prtd->period_ptr);
115 ssc_writex(params->ssc->regs, params->pdc->xcr,
116 prtd->period_size / params->pdc_xfer_size);
117 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
118 params->mask->pdc_enable);
119 }
120
121 if (ssc_sr & params->mask->ssc_endx) {
122 /* Load the PDC next pointer and counter registers */
123 prtd->period_ptr += prtd->period_size;
124 if (prtd->period_ptr >= prtd->dma_buffer_end)
125 prtd->period_ptr = prtd->dma_buffer;
126
127 ssc_writex(params->ssc->regs, params->pdc->xnpr,
128 prtd->period_ptr);
129 ssc_writex(params->ssc->regs, params->pdc->xncr,
130 prtd->period_size / params->pdc_xfer_size);
131 }
132
133 snd_pcm_period_elapsed(substream);
134}
135
136
137/*--------------------------------------------------------------------------*\
138 * PCM operations
139\*--------------------------------------------------------------------------*/
140static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
141 struct snd_pcm_hw_params *params)
142{
143 struct snd_pcm_runtime *runtime = substream->runtime;
144 struct atmel_runtime_data *prtd = runtime->private_data;
145 struct snd_soc_pcm_runtime *rtd = substream->private_data;
146
147 /* this may get called several times by oss emulation
148 * with different params */
149
150 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
151 runtime->dma_bytes = params_buffer_bytes(params);
152
153 prtd->params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
154 prtd->params->dma_intr_handler = atmel_pcm_dma_irq;
155
156 prtd->dma_buffer = runtime->dma_addr;
157 prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes;
158 prtd->period_size = params_period_bytes(params);
159
160 pr_debug("atmel-pcm: "
161 "hw_params: DMA for %s initialized "
162 "(dma_bytes=%u, period_size=%u)\n",
163 prtd->params->name,
164 runtime->dma_bytes,
165 prtd->period_size);
166 return 0;
167}
168
169static int atmel_pcm_hw_free(struct snd_pcm_substream *substream)
170{
171 struct atmel_runtime_data *prtd = substream->runtime->private_data;
172 struct atmel_pcm_dma_params *params = prtd->params;
173
174 if (params != NULL) {
175 ssc_writex(params->ssc->regs, SSC_PDC_PTCR,
176 params->mask->pdc_disable);
177 prtd->params->dma_intr_handler = NULL;
178 }
179
180 return 0;
181}
182
183static int atmel_pcm_prepare(struct snd_pcm_substream *substream)
184{
185 struct atmel_runtime_data *prtd = substream->runtime->private_data;
186 struct atmel_pcm_dma_params *params = prtd->params;
187
188 ssc_writex(params->ssc->regs, SSC_IDR,
189 params->mask->ssc_endx | params->mask->ssc_endbuf);
190 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
191 params->mask->pdc_disable);
192 return 0;
193}
194
195static int atmel_pcm_trigger(struct snd_pcm_substream *substream,
196 int cmd)
197{
198 struct snd_pcm_runtime *rtd = substream->runtime;
199 struct atmel_runtime_data *prtd = rtd->private_data;
200 struct atmel_pcm_dma_params *params = prtd->params;
201 int ret = 0;
202
203 pr_debug("atmel-pcm:buffer_size = %ld,"
204 "dma_area = %p, dma_bytes = %u\n",
205 rtd->buffer_size, rtd->dma_area, rtd->dma_bytes);
206
207 switch (cmd) {
208 case SNDRV_PCM_TRIGGER_START:
209 prtd->period_ptr = prtd->dma_buffer;
210
211 ssc_writex(params->ssc->regs, params->pdc->xpr,
212 prtd->period_ptr);
213 ssc_writex(params->ssc->regs, params->pdc->xcr,
214 prtd->period_size / params->pdc_xfer_size);
215
216 prtd->period_ptr += prtd->period_size;
217 ssc_writex(params->ssc->regs, params->pdc->xnpr,
218 prtd->period_ptr);
219 ssc_writex(params->ssc->regs, params->pdc->xncr,
220 prtd->period_size / params->pdc_xfer_size);
221
222 pr_debug("atmel-pcm: trigger: "
223 "period_ptr=%lx, xpr=%u, "
224 "xcr=%u, xnpr=%u, xncr=%u\n",
225 (unsigned long)prtd->period_ptr,
226 ssc_readx(params->ssc->regs, params->pdc->xpr),
227 ssc_readx(params->ssc->regs, params->pdc->xcr),
228 ssc_readx(params->ssc->regs, params->pdc->xnpr),
229 ssc_readx(params->ssc->regs, params->pdc->xncr));
230
231 ssc_writex(params->ssc->regs, SSC_IER,
232 params->mask->ssc_endx | params->mask->ssc_endbuf);
233 ssc_writex(params->ssc->regs, SSC_PDC_PTCR,
234 params->mask->pdc_enable);
235
236 pr_debug("sr=%u imr=%u\n",
237 ssc_readx(params->ssc->regs, SSC_SR),
238 ssc_readx(params->ssc->regs, SSC_IER));
239 break; /* SNDRV_PCM_TRIGGER_START */
240
241 case SNDRV_PCM_TRIGGER_STOP:
242 case SNDRV_PCM_TRIGGER_SUSPEND:
243 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
244 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
245 params->mask->pdc_disable);
246 break;
247
248 case SNDRV_PCM_TRIGGER_RESUME:
249 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
250 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
251 params->mask->pdc_enable);
252 break;
253
254 default:
255 ret = -EINVAL;
256 }
257
258 return ret;
259}
260
261static snd_pcm_uframes_t atmel_pcm_pointer(
262 struct snd_pcm_substream *substream)
263{
264 struct snd_pcm_runtime *runtime = substream->runtime;
265 struct atmel_runtime_data *prtd = runtime->private_data;
266 struct atmel_pcm_dma_params *params = prtd->params;
267 dma_addr_t ptr;
268 snd_pcm_uframes_t x;
269
270 ptr = (dma_addr_t) ssc_readx(params->ssc->regs, params->pdc->xpr);
271 x = bytes_to_frames(runtime, ptr - prtd->dma_buffer);
272
273 if (x == runtime->buffer_size)
274 x = 0;
275
276 return x;
277}
278
279static int atmel_pcm_open(struct snd_pcm_substream *substream)
280{
281 struct snd_pcm_runtime *runtime = substream->runtime;
282 struct atmel_runtime_data *prtd;
283 int ret = 0;
284
285 snd_soc_set_runtime_hwparams(substream, &atmel_pcm_hardware);
286
287 /* ensure that buffer size is a multiple of period size */
288 ret = snd_pcm_hw_constraint_integer(runtime,
289 SNDRV_PCM_HW_PARAM_PERIODS);
290 if (ret < 0)
291 goto out;
292
293 prtd = kzalloc(sizeof(struct atmel_runtime_data), GFP_KERNEL);
294 if (prtd == NULL) {
295 ret = -ENOMEM;
296 goto out;
297 }
298 runtime->private_data = prtd;
299
300 out:
301 return ret;
302}
303
304static int atmel_pcm_close(struct snd_pcm_substream *substream)
305{
306 struct atmel_runtime_data *prtd = substream->runtime->private_data;
307
308 kfree(prtd);
309 return 0;
310}
311
312static struct snd_pcm_ops atmel_pcm_ops = {
313 .open = atmel_pcm_open,
314 .close = atmel_pcm_close,
315 .ioctl = snd_pcm_lib_ioctl,
316 .hw_params = atmel_pcm_hw_params,
317 .hw_free = atmel_pcm_hw_free,
318 .prepare = atmel_pcm_prepare,
319 .trigger = atmel_pcm_trigger,
320 .pointer = atmel_pcm_pointer,
321 .mmap = atmel_pcm_mmap,
322};
323
324
325/*--------------------------------------------------------------------------*\
326 * ASoC platform driver
327\*--------------------------------------------------------------------------*/
328#ifdef CONFIG_PM
329static int atmel_pcm_suspend(struct snd_soc_dai *dai)
330{
331 struct snd_pcm_runtime *runtime = dai->runtime;
332 struct atmel_runtime_data *prtd;
333 struct atmel_pcm_dma_params *params;
334
335 if (!runtime)
336 return 0;
337
338 prtd = runtime->private_data;
339 params = prtd->params;
340
341 /* disable the PDC and save the PDC registers */
342
343 ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_disable);
344
345 prtd->pdc_xpr_save = ssc_readx(params->ssc->regs, params->pdc->xpr);
346 prtd->pdc_xcr_save = ssc_readx(params->ssc->regs, params->pdc->xcr);
347 prtd->pdc_xnpr_save = ssc_readx(params->ssc->regs, params->pdc->xnpr);
348 prtd->pdc_xncr_save = ssc_readx(params->ssc->regs, params->pdc->xncr);
349
350 return 0;
351}
352
353static int atmel_pcm_resume(struct snd_soc_dai *dai)
354{
355 struct snd_pcm_runtime *runtime = dai->runtime;
356 struct atmel_runtime_data *prtd;
357 struct atmel_pcm_dma_params *params;
358
359 if (!runtime)
360 return 0;
361
362 prtd = runtime->private_data;
363 params = prtd->params;
364
365 /* restore the PDC registers and enable the PDC */
366 ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->pdc_xpr_save);
367 ssc_writex(params->ssc->regs, params->pdc->xcr, prtd->pdc_xcr_save);
368 ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->pdc_xnpr_save);
369 ssc_writex(params->ssc->regs, params->pdc->xncr, prtd->pdc_xncr_save);
370
371 ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_enable);
372 return 0;
373}
374#else
375#define atmel_pcm_suspend NULL
376#define atmel_pcm_resume NULL
377#endif
378
379static struct snd_soc_platform_driver atmel_soc_platform = {
380 .ops = &atmel_pcm_ops,
381 .pcm_new = atmel_pcm_new,
382 .pcm_free = atmel_pcm_free,
383 .suspend = atmel_pcm_suspend,
384 .resume = atmel_pcm_resume,
385};
386
387int atmel_pcm_pdc_platform_register(struct device *dev)
388{
389 return snd_soc_register_platform(dev, &atmel_soc_platform);
390}
391EXPORT_SYMBOL(atmel_pcm_pdc_platform_register);
392
393void atmel_pcm_pdc_platform_unregister(struct device *dev)
394{
395 snd_soc_unregister_platform(dev);
396}
397EXPORT_SYMBOL(atmel_pcm_pdc_platform_unregister);
398
399MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>");
400MODULE_DESCRIPTION("Atmel PCM module");
401MODULE_LICENSE("GPL");
diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c
index 9b84f985770e..e99f1811300a 100644
--- a/sound/soc/atmel/atmel-pcm.c
+++ b/sound/soc/atmel/atmel-pcm.c
@@ -32,80 +32,25 @@
32 */ 32 */
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h>
36#include <linux/platform_device.h>
37#include <linux/slab.h>
38#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
39#include <linux/atmel_pdc.h>
40#include <linux/atmel-ssc.h>
41
42#include <sound/core.h>
43#include <sound/pcm.h> 36#include <sound/pcm.h>
44#include <sound/pcm_params.h>
45#include <sound/soc.h> 37#include <sound/soc.h>
46
47#include "atmel-pcm.h" 38#include "atmel-pcm.h"
48 39
49
50/*--------------------------------------------------------------------------*\
51 * Hardware definition
52\*--------------------------------------------------------------------------*/
53/* TODO: These values were taken from the AT91 platform driver, check
54 * them against real values for AT32
55 */
56static const struct snd_pcm_hardware atmel_pcm_hardware = {
57 .info = SNDRV_PCM_INFO_MMAP |
58 SNDRV_PCM_INFO_MMAP_VALID |
59 SNDRV_PCM_INFO_INTERLEAVED |
60 SNDRV_PCM_INFO_PAUSE,
61 .formats = SNDRV_PCM_FMTBIT_S16_LE,
62 .period_bytes_min = 32,
63 .period_bytes_max = 8192,
64 .periods_min = 2,
65 .periods_max = 1024,
66 .buffer_bytes_max = 32 * 1024,
67};
68
69
70/*--------------------------------------------------------------------------*\
71 * Data types
72\*--------------------------------------------------------------------------*/
73struct atmel_runtime_data {
74 struct atmel_pcm_dma_params *params;
75 dma_addr_t dma_buffer; /* physical address of dma buffer */
76 dma_addr_t dma_buffer_end; /* first address beyond DMA buffer */
77 size_t period_size;
78
79 dma_addr_t period_ptr; /* physical address of next period */
80
81 /* PDC register save */
82 u32 pdc_xpr_save;
83 u32 pdc_xcr_save;
84 u32 pdc_xnpr_save;
85 u32 pdc_xncr_save;
86};
87
88
89/*--------------------------------------------------------------------------*\
90 * Helper functions
91\*--------------------------------------------------------------------------*/
92static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, 40static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
93 int stream) 41 int stream)
94{ 42{
95 struct snd_pcm_substream *substream = pcm->streams[stream].substream; 43 struct snd_pcm_substream *substream = pcm->streams[stream].substream;
96 struct snd_dma_buffer *buf = &substream->dma_buffer; 44 struct snd_dma_buffer *buf = &substream->dma_buffer;
97 size_t size = atmel_pcm_hardware.buffer_bytes_max; 45 size_t size = ATMEL_SSC_DMABUF_SIZE;
98 46
99 buf->dev.type = SNDRV_DMA_TYPE_DEV; 47 buf->dev.type = SNDRV_DMA_TYPE_DEV;
100 buf->dev.dev = pcm->card->dev; 48 buf->dev.dev = pcm->card->dev;
101 buf->private_data = NULL; 49 buf->private_data = NULL;
102 buf->area = dma_alloc_coherent(pcm->card->dev, size, 50 buf->area = dma_alloc_coherent(pcm->card->dev, size,
103 &buf->addr, GFP_KERNEL); 51 &buf->addr, GFP_KERNEL);
104 pr_debug("atmel-pcm:" 52 pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%d\n",
105 "preallocate_dma_buffer: area=%p, addr=%p, size=%d\n", 53 (void *)buf->area, (void *)buf->addr, size);
106 (void *) buf->area,
107 (void *) buf->addr,
108 size);
109 54
110 if (!buf->area) 55 if (!buf->area)
111 return -ENOMEM; 56 return -ENOMEM;
@@ -113,258 +58,19 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
113 buf->bytes = size; 58 buf->bytes = size;
114 return 0; 59 return 0;
115} 60}
116/*--------------------------------------------------------------------------*\
117 * ISR
118\*--------------------------------------------------------------------------*/
119static void atmel_pcm_dma_irq(u32 ssc_sr,
120 struct snd_pcm_substream *substream)
121{
122 struct atmel_runtime_data *prtd = substream->runtime->private_data;
123 struct atmel_pcm_dma_params *params = prtd->params;
124 static int count;
125
126 count++;
127
128 if (ssc_sr & params->mask->ssc_endbuf) {
129 pr_warning("atmel-pcm: buffer %s on %s"
130 " (SSC_SR=%#x, count=%d)\n",
131 substream->stream == SNDRV_PCM_STREAM_PLAYBACK
132 ? "underrun" : "overrun",
133 params->name, ssc_sr, count);
134
135 /* re-start the PDC */
136 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
137 params->mask->pdc_disable);
138 prtd->period_ptr += prtd->period_size;
139 if (prtd->period_ptr >= prtd->dma_buffer_end)
140 prtd->period_ptr = prtd->dma_buffer;
141
142 ssc_writex(params->ssc->regs, params->pdc->xpr,
143 prtd->period_ptr);
144 ssc_writex(params->ssc->regs, params->pdc->xcr,
145 prtd->period_size / params->pdc_xfer_size);
146 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
147 params->mask->pdc_enable);
148 }
149
150 if (ssc_sr & params->mask->ssc_endx) {
151 /* Load the PDC next pointer and counter registers */
152 prtd->period_ptr += prtd->period_size;
153 if (prtd->period_ptr >= prtd->dma_buffer_end)
154 prtd->period_ptr = prtd->dma_buffer;
155
156 ssc_writex(params->ssc->regs, params->pdc->xnpr,
157 prtd->period_ptr);
158 ssc_writex(params->ssc->regs, params->pdc->xncr,
159 prtd->period_size / params->pdc_xfer_size);
160 }
161
162 snd_pcm_period_elapsed(substream);
163}
164
165
166/*--------------------------------------------------------------------------*\
167 * PCM operations
168\*--------------------------------------------------------------------------*/
169static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
170 struct snd_pcm_hw_params *params)
171{
172 struct snd_pcm_runtime *runtime = substream->runtime;
173 struct atmel_runtime_data *prtd = runtime->private_data;
174 struct snd_soc_pcm_runtime *rtd = substream->private_data;
175
176 /* this may get called several times by oss emulation
177 * with different params */
178
179 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
180 runtime->dma_bytes = params_buffer_bytes(params);
181
182 prtd->params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
183 prtd->params->dma_intr_handler = atmel_pcm_dma_irq;
184
185 prtd->dma_buffer = runtime->dma_addr;
186 prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes;
187 prtd->period_size = params_period_bytes(params);
188
189 pr_debug("atmel-pcm: "
190 "hw_params: DMA for %s initialized "
191 "(dma_bytes=%u, period_size=%u)\n",
192 prtd->params->name,
193 runtime->dma_bytes,
194 prtd->period_size);
195 return 0;
196}
197
198static int atmel_pcm_hw_free(struct snd_pcm_substream *substream)
199{
200 struct atmel_runtime_data *prtd = substream->runtime->private_data;
201 struct atmel_pcm_dma_params *params = prtd->params;
202
203 if (params != NULL) {
204 ssc_writex(params->ssc->regs, SSC_PDC_PTCR,
205 params->mask->pdc_disable);
206 prtd->params->dma_intr_handler = NULL;
207 }
208
209 return 0;
210}
211
212static int atmel_pcm_prepare(struct snd_pcm_substream *substream)
213{
214 struct atmel_runtime_data *prtd = substream->runtime->private_data;
215 struct atmel_pcm_dma_params *params = prtd->params;
216
217 ssc_writex(params->ssc->regs, SSC_IDR,
218 params->mask->ssc_endx | params->mask->ssc_endbuf);
219 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
220 params->mask->pdc_disable);
221 return 0;
222}
223
224static int atmel_pcm_trigger(struct snd_pcm_substream *substream,
225 int cmd)
226{
227 struct snd_pcm_runtime *rtd = substream->runtime;
228 struct atmel_runtime_data *prtd = rtd->private_data;
229 struct atmel_pcm_dma_params *params = prtd->params;
230 int ret = 0;
231
232 pr_debug("atmel-pcm:buffer_size = %ld,"
233 "dma_area = %p, dma_bytes = %u\n",
234 rtd->buffer_size, rtd->dma_area, rtd->dma_bytes);
235
236 switch (cmd) {
237 case SNDRV_PCM_TRIGGER_START:
238 prtd->period_ptr = prtd->dma_buffer;
239
240 ssc_writex(params->ssc->regs, params->pdc->xpr,
241 prtd->period_ptr);
242 ssc_writex(params->ssc->regs, params->pdc->xcr,
243 prtd->period_size / params->pdc_xfer_size);
244
245 prtd->period_ptr += prtd->period_size;
246 ssc_writex(params->ssc->regs, params->pdc->xnpr,
247 prtd->period_ptr);
248 ssc_writex(params->ssc->regs, params->pdc->xncr,
249 prtd->period_size / params->pdc_xfer_size);
250
251 pr_debug("atmel-pcm: trigger: "
252 "period_ptr=%lx, xpr=%u, "
253 "xcr=%u, xnpr=%u, xncr=%u\n",
254 (unsigned long)prtd->period_ptr,
255 ssc_readx(params->ssc->regs, params->pdc->xpr),
256 ssc_readx(params->ssc->regs, params->pdc->xcr),
257 ssc_readx(params->ssc->regs, params->pdc->xnpr),
258 ssc_readx(params->ssc->regs, params->pdc->xncr));
259
260 ssc_writex(params->ssc->regs, SSC_IER,
261 params->mask->ssc_endx | params->mask->ssc_endbuf);
262 ssc_writex(params->ssc->regs, SSC_PDC_PTCR,
263 params->mask->pdc_enable);
264
265 pr_debug("sr=%u imr=%u\n",
266 ssc_readx(params->ssc->regs, SSC_SR),
267 ssc_readx(params->ssc->regs, SSC_IER));
268 break; /* SNDRV_PCM_TRIGGER_START */
269
270 case SNDRV_PCM_TRIGGER_STOP:
271 case SNDRV_PCM_TRIGGER_SUSPEND:
272 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
273 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
274 params->mask->pdc_disable);
275 break;
276
277 case SNDRV_PCM_TRIGGER_RESUME:
278 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
279 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
280 params->mask->pdc_enable);
281 break;
282
283 default:
284 ret = -EINVAL;
285 }
286 61
287 return ret; 62int atmel_pcm_mmap(struct snd_pcm_substream *substream,
288}
289
290static snd_pcm_uframes_t atmel_pcm_pointer(
291 struct snd_pcm_substream *substream)
292{
293 struct snd_pcm_runtime *runtime = substream->runtime;
294 struct atmel_runtime_data *prtd = runtime->private_data;
295 struct atmel_pcm_dma_params *params = prtd->params;
296 dma_addr_t ptr;
297 snd_pcm_uframes_t x;
298
299 ptr = (dma_addr_t) ssc_readx(params->ssc->regs, params->pdc->xpr);
300 x = bytes_to_frames(runtime, ptr - prtd->dma_buffer);
301
302 if (x == runtime->buffer_size)
303 x = 0;
304
305 return x;
306}
307
308static int atmel_pcm_open(struct snd_pcm_substream *substream)
309{
310 struct snd_pcm_runtime *runtime = substream->runtime;
311 struct atmel_runtime_data *prtd;
312 int ret = 0;
313
314 snd_soc_set_runtime_hwparams(substream, &atmel_pcm_hardware);
315
316 /* ensure that buffer size is a multiple of period size */
317 ret = snd_pcm_hw_constraint_integer(runtime,
318 SNDRV_PCM_HW_PARAM_PERIODS);
319 if (ret < 0)
320 goto out;
321
322 prtd = kzalloc(sizeof(struct atmel_runtime_data), GFP_KERNEL);
323 if (prtd == NULL) {
324 ret = -ENOMEM;
325 goto out;
326 }
327 runtime->private_data = prtd;
328
329 out:
330 return ret;
331}
332
333static int atmel_pcm_close(struct snd_pcm_substream *substream)
334{
335 struct atmel_runtime_data *prtd = substream->runtime->private_data;
336
337 kfree(prtd);
338 return 0;
339}
340
341static int atmel_pcm_mmap(struct snd_pcm_substream *substream,
342 struct vm_area_struct *vma) 63 struct vm_area_struct *vma)
343{ 64{
344 return remap_pfn_range(vma, vma->vm_start, 65 return remap_pfn_range(vma, vma->vm_start,
345 substream->dma_buffer.addr >> PAGE_SHIFT, 66 substream->dma_buffer.addr >> PAGE_SHIFT,
346 vma->vm_end - vma->vm_start, vma->vm_page_prot); 67 vma->vm_end - vma->vm_start, vma->vm_page_prot);
347} 68}
69EXPORT_SYMBOL_GPL(atmel_pcm_mmap);
348 70
349static struct snd_pcm_ops atmel_pcm_ops = {
350 .open = atmel_pcm_open,
351 .close = atmel_pcm_close,
352 .ioctl = snd_pcm_lib_ioctl,
353 .hw_params = atmel_pcm_hw_params,
354 .hw_free = atmel_pcm_hw_free,
355 .prepare = atmel_pcm_prepare,
356 .trigger = atmel_pcm_trigger,
357 .pointer = atmel_pcm_pointer,
358 .mmap = atmel_pcm_mmap,
359};
360
361
362/*--------------------------------------------------------------------------*\
363 * ASoC platform driver
364\*--------------------------------------------------------------------------*/
365static u64 atmel_pcm_dmamask = DMA_BIT_MASK(32); 71static u64 atmel_pcm_dmamask = DMA_BIT_MASK(32);
366 72
367static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd) 73int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
368{ 74{
369 struct snd_card *card = rtd->card->snd_card; 75 struct snd_card *card = rtd->card->snd_card;
370 struct snd_pcm *pcm = rtd->pcm; 76 struct snd_pcm *pcm = rtd->pcm;
@@ -376,6 +82,7 @@ static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
376 card->dev->coherent_dma_mask = DMA_BIT_MASK(32); 82 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
377 83
378 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 84 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
85 pr_debug("atmel-pcm: allocating PCM playback DMA buffer\n");
379 ret = atmel_pcm_preallocate_dma_buffer(pcm, 86 ret = atmel_pcm_preallocate_dma_buffer(pcm,
380 SNDRV_PCM_STREAM_PLAYBACK); 87 SNDRV_PCM_STREAM_PLAYBACK);
381 if (ret) 88 if (ret)
@@ -383,8 +90,7 @@ static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
383 } 90 }
384 91
385 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { 92 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
386 pr_debug("atmel-pcm:" 93 pr_debug("atmel-pcm: allocating PCM capture DMA buffer\n");
387 "Allocating PCM capture DMA buffer\n");
388 ret = atmel_pcm_preallocate_dma_buffer(pcm, 94 ret = atmel_pcm_preallocate_dma_buffer(pcm,
389 SNDRV_PCM_STREAM_CAPTURE); 95 SNDRV_PCM_STREAM_CAPTURE);
390 if (ret) 96 if (ret)
@@ -393,8 +99,9 @@ static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
393 out: 99 out:
394 return ret; 100 return ret;
395} 101}
102EXPORT_SYMBOL_GPL(atmel_pcm_new);
396 103
397static void atmel_pcm_free_dma_buffers(struct snd_pcm *pcm) 104void atmel_pcm_free(struct snd_pcm *pcm)
398{ 105{
399 struct snd_pcm_substream *substream; 106 struct snd_pcm_substream *substream;
400 struct snd_dma_buffer *buf; 107 struct snd_dma_buffer *buf;
@@ -413,89 +120,5 @@ static void atmel_pcm_free_dma_buffers(struct snd_pcm *pcm)
413 buf->area = NULL; 120 buf->area = NULL;
414 } 121 }
415} 122}
123EXPORT_SYMBOL_GPL(atmel_pcm_free);
416 124
417#ifdef CONFIG_PM
418static int atmel_pcm_suspend(struct snd_soc_dai *dai)
419{
420 struct snd_pcm_runtime *runtime = dai->runtime;
421 struct atmel_runtime_data *prtd;
422 struct atmel_pcm_dma_params *params;
423
424 if (!runtime)
425 return 0;
426
427 prtd = runtime->private_data;
428 params = prtd->params;
429
430 /* disable the PDC and save the PDC registers */
431
432 ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_disable);
433
434 prtd->pdc_xpr_save = ssc_readx(params->ssc->regs, params->pdc->xpr);
435 prtd->pdc_xcr_save = ssc_readx(params->ssc->regs, params->pdc->xcr);
436 prtd->pdc_xnpr_save = ssc_readx(params->ssc->regs, params->pdc->xnpr);
437 prtd->pdc_xncr_save = ssc_readx(params->ssc->regs, params->pdc->xncr);
438
439 return 0;
440}
441
442static int atmel_pcm_resume(struct snd_soc_dai *dai)
443{
444 struct snd_pcm_runtime *runtime = dai->runtime;
445 struct atmel_runtime_data *prtd;
446 struct atmel_pcm_dma_params *params;
447
448 if (!runtime)
449 return 0;
450
451 prtd = runtime->private_data;
452 params = prtd->params;
453
454 /* restore the PDC registers and enable the PDC */
455 ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->pdc_xpr_save);
456 ssc_writex(params->ssc->regs, params->pdc->xcr, prtd->pdc_xcr_save);
457 ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->pdc_xnpr_save);
458 ssc_writex(params->ssc->regs, params->pdc->xncr, prtd->pdc_xncr_save);
459
460 ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_enable);
461 return 0;
462}
463#else
464#define atmel_pcm_suspend NULL
465#define atmel_pcm_resume NULL
466#endif
467
468static struct snd_soc_platform_driver atmel_soc_platform = {
469 .ops = &atmel_pcm_ops,
470 .pcm_new = atmel_pcm_new,
471 .pcm_free = atmel_pcm_free_dma_buffers,
472 .suspend = atmel_pcm_suspend,
473 .resume = atmel_pcm_resume,
474};
475
476static int __devinit atmel_soc_platform_probe(struct platform_device *pdev)
477{
478 return snd_soc_register_platform(&pdev->dev, &atmel_soc_platform);
479}
480
481static int __devexit atmel_soc_platform_remove(struct platform_device *pdev)
482{
483 snd_soc_unregister_platform(&pdev->dev);
484 return 0;
485}
486
487static struct platform_driver atmel_pcm_driver = {
488 .driver = {
489 .name = "atmel-pcm-audio",
490 .owner = THIS_MODULE,
491 },
492
493 .probe = atmel_soc_platform_probe,
494 .remove = __devexit_p(atmel_soc_platform_remove),
495};
496
497module_platform_driver(atmel_pcm_driver);
498
499MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>");
500MODULE_DESCRIPTION("Atmel PCM module");
501MODULE_LICENSE("GPL");
diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h
index 5e0a95e64329..bb45d20e7250 100644
--- a/sound/soc/atmel/atmel-pcm.h
+++ b/sound/soc/atmel/atmel-pcm.h
@@ -36,6 +36,8 @@
36 36
37#include <linux/atmel-ssc.h> 37#include <linux/atmel-ssc.h>
38 38
39#define ATMEL_SSC_DMABUF_SIZE (64 * 1024)
40
39/* 41/*
40 * Registers and status bits that are required by the PCM driver. 42 * Registers and status bits that are required by the PCM driver.
41 */ 43 */
@@ -50,6 +52,7 @@ struct atmel_pdc_regs {
50struct atmel_ssc_mask { 52struct atmel_ssc_mask {
51 u32 ssc_enable; /* SSC recv/trans enable */ 53 u32 ssc_enable; /* SSC recv/trans enable */
52 u32 ssc_disable; /* SSC recv/trans disable */ 54 u32 ssc_disable; /* SSC recv/trans disable */
55 u32 ssc_error; /* SSC error conditions */
53 u32 ssc_endx; /* SSC ENDTX or ENDRX */ 56 u32 ssc_endx; /* SSC ENDTX or ENDRX */
54 u32 ssc_endbuf; /* SSC TXBUFE or RXBUFF */ 57 u32 ssc_endbuf; /* SSC TXBUFE or RXBUFF */
55 u32 pdc_enable; /* PDC recv/trans enable */ 58 u32 pdc_enable; /* PDC recv/trans enable */
@@ -80,4 +83,35 @@ struct atmel_pcm_dma_params {
80#define ssc_readx(base, reg) (__raw_readl((base) + (reg))) 83#define ssc_readx(base, reg) (__raw_readl((base) + (reg)))
81#define ssc_writex(base, reg, value) __raw_writel((value), (base) + (reg)) 84#define ssc_writex(base, reg, value) __raw_writel((value), (base) + (reg))
82 85
86int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd);
87void atmel_pcm_free(struct snd_pcm *pcm);
88int atmel_pcm_mmap(struct snd_pcm_substream *substream,
89 struct vm_area_struct *vma);
90
91#ifdef CONFIG_SND_ATMEL_SOC_PDC
92int atmel_pcm_pdc_platform_register(struct device *dev);
93void atmel_pcm_pdc_platform_unregister(struct device *dev);
94#else
95static inline int atmel_pcm_pdc_platform_register(struct device *dev)
96{
97 return 0;
98}
99static inline void atmel_pcm_pdc_platform_unregister(struct device *dev)
100{
101}
102#endif
103
104#ifdef CONFIG_SND_ATMEL_SOC_DMA
105int atmel_pcm_dma_platform_register(struct device *dev);
106void atmel_pcm_dma_platform_unregister(struct device *dev);
107#else
108static inline int atmel_pcm_dma_platform_register(struct device *dev)
109{
110 return 0;
111}
112static inline void atmel_pcm_dma_platform_unregister(struct device *dev)
113{
114}
115#endif
116
83#endif /* _ATMEL_PCM_H */ 117#endif /* _ATMEL_PCM_H */
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index 354341ec0f42..1c7663422054 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -48,11 +48,7 @@
48#include "atmel_ssc_dai.h" 48#include "atmel_ssc_dai.h"
49 49
50 50
51#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9G20)
52#define NUM_SSC_DEVICES 1
53#else
54#define NUM_SSC_DEVICES 3 51#define NUM_SSC_DEVICES 3
55#endif
56 52
57/* 53/*
58 * SSC PDC registers required by the PCM DMA engine. 54 * SSC PDC registers required by the PCM DMA engine.
@@ -107,7 +103,6 @@ static struct atmel_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = {
107 .pdc = &pdc_rx_reg, 103 .pdc = &pdc_rx_reg,
108 .mask = &ssc_rx_mask, 104 .mask = &ssc_rx_mask,
109 } }, 105 } },
110#if NUM_SSC_DEVICES == 3
111 {{ 106 {{
112 .name = "SSC1 PCM out", 107 .name = "SSC1 PCM out",
113 .pdc = &pdc_tx_reg, 108 .pdc = &pdc_tx_reg,
@@ -128,7 +123,6 @@ static struct atmel_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = {
128 .pdc = &pdc_rx_reg, 123 .pdc = &pdc_rx_reg,
129 .mask = &ssc_rx_mask, 124 .mask = &ssc_rx_mask,
130 } }, 125 } },
131#endif
132}; 126};
133 127
134 128
@@ -139,7 +133,6 @@ static struct atmel_ssc_info ssc_info[NUM_SSC_DEVICES] = {
139 .dir_mask = SSC_DIR_MASK_UNUSED, 133 .dir_mask = SSC_DIR_MASK_UNUSED,
140 .initialized = 0, 134 .initialized = 0,
141 }, 135 },
142#if NUM_SSC_DEVICES == 3
143 { 136 {
144 .name = "ssc1", 137 .name = "ssc1",
145 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[1].lock), 138 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[1].lock),
@@ -152,7 +145,6 @@ static struct atmel_ssc_info ssc_info[NUM_SSC_DEVICES] = {
152 .dir_mask = SSC_DIR_MASK_UNUSED, 145 .dir_mask = SSC_DIR_MASK_UNUSED,
153 .initialized = 0, 146 .initialized = 0,
154 }, 147 },
155#endif
156}; 148};
157 149
158 150
@@ -690,27 +682,9 @@ static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai)
690static int atmel_ssc_probe(struct snd_soc_dai *dai) 682static int atmel_ssc_probe(struct snd_soc_dai *dai)
691{ 683{
692 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; 684 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id];
693 int ret = 0;
694 685
695 snd_soc_dai_set_drvdata(dai, ssc_p); 686 snd_soc_dai_set_drvdata(dai, ssc_p);
696 687
697 /*
698 * Request SSC device
699 */
700 ssc_p->ssc = ssc_request(dai->id);
701 if (IS_ERR(ssc_p->ssc)) {
702 printk(KERN_ERR "ASoC: Failed to request SSC %d\n", dai->id);
703 ret = PTR_ERR(ssc_p->ssc);
704 }
705
706 return ret;
707}
708
709static int atmel_ssc_remove(struct snd_soc_dai *dai)
710{
711 struct atmel_ssc_info *ssc_p = snd_soc_dai_get_drvdata(dai);
712
713 ssc_free(ssc_p->ssc);
714 return 0; 688 return 0;
715} 689}
716 690
@@ -728,30 +702,8 @@ static const struct snd_soc_dai_ops atmel_ssc_dai_ops = {
728 .set_clkdiv = atmel_ssc_set_dai_clkdiv, 702 .set_clkdiv = atmel_ssc_set_dai_clkdiv,
729}; 703};
730 704
731static struct snd_soc_dai_driver atmel_ssc_dai[NUM_SSC_DEVICES] = { 705static struct snd_soc_dai_driver atmel_ssc_dai = {
732 {
733 .name = "atmel-ssc-dai.0",
734 .probe = atmel_ssc_probe,
735 .remove = atmel_ssc_remove,
736 .suspend = atmel_ssc_suspend,
737 .resume = atmel_ssc_resume,
738 .playback = {
739 .channels_min = 1,
740 .channels_max = 2,
741 .rates = ATMEL_SSC_RATES,
742 .formats = ATMEL_SSC_FORMATS,},
743 .capture = {
744 .channels_min = 1,
745 .channels_max = 2,
746 .rates = ATMEL_SSC_RATES,
747 .formats = ATMEL_SSC_FORMATS,},
748 .ops = &atmel_ssc_dai_ops,
749 },
750#if NUM_SSC_DEVICES == 3
751 {
752 .name = "atmel-ssc-dai.1",
753 .probe = atmel_ssc_probe, 706 .probe = atmel_ssc_probe,
754 .remove = atmel_ssc_remove,
755 .suspend = atmel_ssc_suspend, 707 .suspend = atmel_ssc_suspend,
756 .resume = atmel_ssc_resume, 708 .resume = atmel_ssc_resume,
757 .playback = { 709 .playback = {
@@ -765,50 +717,50 @@ static struct snd_soc_dai_driver atmel_ssc_dai[NUM_SSC_DEVICES] = {
765 .rates = ATMEL_SSC_RATES, 717 .rates = ATMEL_SSC_RATES,
766 .formats = ATMEL_SSC_FORMATS,}, 718 .formats = ATMEL_SSC_FORMATS,},
767 .ops = &atmel_ssc_dai_ops, 719 .ops = &atmel_ssc_dai_ops,
768 },
769 {
770 .name = "atmel-ssc-dai.2",
771 .probe = atmel_ssc_probe,
772 .remove = atmel_ssc_remove,
773 .suspend = atmel_ssc_suspend,
774 .resume = atmel_ssc_resume,
775 .playback = {
776 .channels_min = 1,
777 .channels_max = 2,
778 .rates = ATMEL_SSC_RATES,
779 .formats = ATMEL_SSC_FORMATS,},
780 .capture = {
781 .channels_min = 1,
782 .channels_max = 2,
783 .rates = ATMEL_SSC_RATES,
784 .formats = ATMEL_SSC_FORMATS,},
785 .ops = &atmel_ssc_dai_ops,
786 },
787#endif
788}; 720};
789 721
790static __devinit int asoc_ssc_probe(struct platform_device *pdev) 722static int asoc_ssc_init(struct device *dev)
791{ 723{
792 BUG_ON(pdev->id < 0); 724 struct platform_device *pdev = to_platform_device(dev);
793 BUG_ON(pdev->id >= ARRAY_SIZE(atmel_ssc_dai)); 725 struct ssc_device *ssc = platform_get_drvdata(pdev);
794 return snd_soc_register_dai(&pdev->dev, &atmel_ssc_dai[pdev->id]); 726 int ret;
795} 727
728 ret = snd_soc_register_dai(dev, &atmel_ssc_dai);
729 if (ret) {
730 dev_err(dev, "Could not register DAI: %d\n", ret);
731 goto err;
732 }
733
734 if (ssc->pdata->use_dma)
735 ret = atmel_pcm_dma_platform_register(dev);
736 else
737 ret = atmel_pcm_pdc_platform_register(dev);
738
739 if (ret) {
740 dev_err(dev, "Could not register PCM: %d\n", ret);
741 goto err_unregister_dai;
742 };
796 743
797static int __devexit asoc_ssc_remove(struct platform_device *pdev)
798{
799 snd_soc_unregister_dai(&pdev->dev);
800 return 0; 744 return 0;
745
746err_unregister_dai:
747 snd_soc_unregister_dai(dev);
748err:
749 return ret;
801} 750}
802 751
803static struct platform_driver asoc_ssc_driver = { 752static void asoc_ssc_exit(struct device *dev)
804 .driver = { 753{
805 .name = "atmel-ssc-dai", 754 struct platform_device *pdev = to_platform_device(dev);
806 .owner = THIS_MODULE, 755 struct ssc_device *ssc = platform_get_drvdata(pdev);
807 },
808 756
809 .probe = asoc_ssc_probe, 757 if (ssc->pdata->use_dma)
810 .remove = __devexit_p(asoc_ssc_remove), 758 atmel_pcm_dma_platform_unregister(dev);
811}; 759 else
760 atmel_pcm_pdc_platform_unregister(dev);
761
762 snd_soc_unregister_dai(dev);
763}
812 764
813/** 765/**
814 * atmel_ssc_set_audio - Allocate the specified SSC for audio use. 766 * atmel_ssc_set_audio - Allocate the specified SSC for audio use.
@@ -816,50 +768,32 @@ static struct platform_driver asoc_ssc_driver = {
816int atmel_ssc_set_audio(int ssc_id) 768int atmel_ssc_set_audio(int ssc_id)
817{ 769{
818 struct ssc_device *ssc; 770 struct ssc_device *ssc;
819 static struct platform_device *dma_pdev;
820 struct platform_device *ssc_pdev;
821 int ret; 771 int ret;
822 772
823 if (ssc_id < 0 || ssc_id >= ARRAY_SIZE(atmel_ssc_dai))
824 return -EINVAL;
825
826 /* Allocate a dummy device for DMA if we don't have one already */
827 if (!dma_pdev) {
828 dma_pdev = platform_device_alloc("atmel-pcm-audio", -1);
829 if (!dma_pdev)
830 return -ENOMEM;
831
832 ret = platform_device_add(dma_pdev);
833 if (ret < 0) {
834 platform_device_put(dma_pdev);
835 dma_pdev = NULL;
836 return ret;
837 }
838 }
839
840 ssc_pdev = platform_device_alloc("atmel-ssc-dai", ssc_id);
841 if (!ssc_pdev)
842 return -ENOMEM;
843
844 /* If we can grab the SSC briefly to parent the DAI device off it */ 773 /* If we can grab the SSC briefly to parent the DAI device off it */
845 ssc = ssc_request(ssc_id); 774 ssc = ssc_request(ssc_id);
846 if (IS_ERR(ssc)) 775 if (IS_ERR(ssc)) {
847 pr_warn("Unable to parent ASoC SSC DAI on SSC: %ld\n", 776 pr_err("Unable to parent ASoC SSC DAI on SSC: %ld\n",
848 PTR_ERR(ssc)); 777 PTR_ERR(ssc));
849 else { 778 return PTR_ERR(ssc);
850 ssc_pdev->dev.parent = &(ssc->pdev->dev); 779 } else {
851 ssc_free(ssc); 780 ssc_info[ssc_id].ssc = ssc;
852 } 781 }
853 782
854 ret = platform_device_add(ssc_pdev); 783 ret = asoc_ssc_init(&ssc->pdev->dev);
855 if (ret < 0)
856 platform_device_put(ssc_pdev);
857 784
858 return ret; 785 return ret;
859} 786}
860EXPORT_SYMBOL_GPL(atmel_ssc_set_audio); 787EXPORT_SYMBOL_GPL(atmel_ssc_set_audio);
861 788
862module_platform_driver(asoc_ssc_driver); 789void atmel_ssc_put_audio(int ssc_id)
790{
791 struct ssc_device *ssc = ssc_info[ssc_id].ssc;
792
793 ssc_free(ssc);
794 asoc_ssc_exit(&ssc->pdev->dev);
795}
796EXPORT_SYMBOL_GPL(atmel_ssc_put_audio);
863 797
864/* Module information */ 798/* Module information */
865MODULE_AUTHOR("Sedji Gaouaou, sedji.gaouaou@atmel.com, www.atmel.com"); 799MODULE_AUTHOR("Sedji Gaouaou, sedji.gaouaou@atmel.com, www.atmel.com");
diff --git a/sound/soc/atmel/atmel_ssc_dai.h b/sound/soc/atmel/atmel_ssc_dai.h
index 5d4f0f9b4d9a..b1f08d511495 100644
--- a/sound/soc/atmel/atmel_ssc_dai.h
+++ b/sound/soc/atmel/atmel_ssc_dai.h
@@ -117,6 +117,7 @@ struct atmel_ssc_info {
117 struct atmel_ssc_state ssc_state; 117 struct atmel_ssc_state ssc_state;
118}; 118};
119 119
120int atmel_ssc_set_audio(int ssc); 120int atmel_ssc_set_audio(int ssc_id);
121void atmel_ssc_put_audio(int ssc_id);
121 122
122#endif /* _AT91_SSC_DAI_H */ 123#endif /* _AT91_SSC_DAI_H */
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
index c88351488f45..0744610e53dd 100644
--- a/sound/soc/atmel/sam9g20_wm8731.c
+++ b/sound/soc/atmel/sam9g20_wm8731.c
@@ -38,6 +38,8 @@
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/i2c.h> 39#include <linux/i2c.h>
40 40
41#include <linux/pinctrl/consumer.h>
42
41#include <linux/atmel-ssc.h> 43#include <linux/atmel-ssc.h>
42 44
43#include <sound/core.h> 45#include <sound/core.h>
@@ -179,10 +181,10 @@ static int at91sam9g20ek_wm8731_init(struct snd_soc_pcm_runtime *rtd)
179static struct snd_soc_dai_link at91sam9g20ek_dai = { 181static struct snd_soc_dai_link at91sam9g20ek_dai = {
180 .name = "WM8731", 182 .name = "WM8731",
181 .stream_name = "WM8731 PCM", 183 .stream_name = "WM8731 PCM",
182 .cpu_dai_name = "atmel-ssc-dai.0", 184 .cpu_dai_name = "at91rm9200_ssc.0",
183 .codec_dai_name = "wm8731-hifi", 185 .codec_dai_name = "wm8731-hifi",
184 .init = at91sam9g20ek_wm8731_init, 186 .init = at91sam9g20ek_wm8731_init,
185 .platform_name = "atmel-pcm-audio", 187 .platform_name = "at91rm9200_ssc.0",
186 .codec_name = "wm8731.0-001b", 188 .codec_name = "wm8731.0-001b",
187 .ops = &at91sam9g20ek_ops, 189 .ops = &at91sam9g20ek_ops,
188}; 190};
@@ -195,20 +197,31 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = {
195 .set_bias_level = at91sam9g20ek_set_bias_level, 197 .set_bias_level = at91sam9g20ek_set_bias_level,
196}; 198};
197 199
198static struct platform_device *at91sam9g20ek_snd_device; 200static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev)
199
200static int __init at91sam9g20ek_init(void)
201{ 201{
202 struct device_node *np = pdev->dev.of_node;
203 struct device_node *codec_np, *cpu_np;
202 struct clk *pllb; 204 struct clk *pllb;
205 struct snd_soc_card *card = &snd_soc_at91sam9g20ek;
206 struct pinctrl *pinctrl;
203 int ret; 207 int ret;
204 208
205 if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) 209 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
206 return -ENODEV; 210 if (IS_ERR(pinctrl)) {
211 dev_err(&pdev->dev, "Failed to request pinctrl for mck\n");
212 return PTR_ERR(pinctrl);
213 }
214
215 if (!np) {
216 if (!(machine_is_at91sam9g20ek() ||
217 machine_is_at91sam9g20ek_2mmc()))
218 return -ENODEV;
219 }
207 220
208 ret = atmel_ssc_set_audio(0); 221 ret = atmel_ssc_set_audio(0);
209 if (ret != 0) { 222 if (ret) {
210 pr_err("Failed to set SSC 0 for audio: %d\n", ret); 223 dev_err(&pdev->dev, "ssc channel is not valid\n");
211 return ret; 224 return -EINVAL;
212 } 225 }
213 226
214 /* 227 /*
@@ -236,45 +249,92 @@ static int __init at91sam9g20ek_init(void)
236 249
237 clk_set_rate(mclk, MCLK_RATE); 250 clk_set_rate(mclk, MCLK_RATE);
238 251
239 at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); 252 card->dev = &pdev->dev;
240 if (!at91sam9g20ek_snd_device) { 253
241 printk(KERN_ERR "ASoC: Platform device allocation failed\n"); 254 /* Parse device node info */
242 ret = -ENOMEM; 255 if (np) {
243 goto err_mclk; 256 ret = snd_soc_of_parse_card_name(card, "atmel,model");
257 if (ret)
258 goto err;
259
260 ret = snd_soc_of_parse_audio_routing(card,
261 "atmel,audio-routing");
262 if (ret)
263 goto err;
264
265 /* Parse codec info */
266 at91sam9g20ek_dai.codec_name = NULL;
267 codec_np = of_parse_phandle(np, "atmel,audio-codec", 0);
268 if (!codec_np) {
269 dev_err(&pdev->dev, "codec info missing\n");
270 return -EINVAL;
271 }
272 at91sam9g20ek_dai.codec_of_node = codec_np;
273
274 /* Parse dai and platform info */
275 at91sam9g20ek_dai.cpu_dai_name = NULL;
276 at91sam9g20ek_dai.platform_name = NULL;
277 cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0);
278 if (!cpu_np) {
279 dev_err(&pdev->dev, "dai and pcm info missing\n");
280 return -EINVAL;
281 }
282 at91sam9g20ek_dai.cpu_of_node = cpu_np;
283 at91sam9g20ek_dai.platform_of_node = cpu_np;
284
285 of_node_put(codec_np);
286 of_node_put(cpu_np);
244 } 287 }
245 288
246 platform_set_drvdata(at91sam9g20ek_snd_device, 289 ret = snd_soc_register_card(card);
247 &snd_soc_at91sam9g20ek);
248
249 ret = platform_device_add(at91sam9g20ek_snd_device);
250 if (ret) { 290 if (ret) {
251 printk(KERN_ERR "ASoC: Platform device allocation failed\n"); 291 printk(KERN_ERR "ASoC: snd_soc_register_card() failed\n");
252 goto err_device_add;
253 } 292 }
254 293
255 return ret; 294 return ret;
256 295
257err_device_add:
258 platform_device_put(at91sam9g20ek_snd_device);
259err_mclk: 296err_mclk:
260 clk_put(mclk); 297 clk_put(mclk);
261 mclk = NULL; 298 mclk = NULL;
262err: 299err:
300 atmel_ssc_put_audio(0);
263 return ret; 301 return ret;
264} 302}
265 303
266static void __exit at91sam9g20ek_exit(void) 304static int __devexit at91sam9g20ek_audio_remove(struct platform_device *pdev)
267{ 305{
268 platform_device_unregister(at91sam9g20ek_snd_device); 306 struct snd_soc_card *card = platform_get_drvdata(pdev);
269 at91sam9g20ek_snd_device = NULL; 307
308 atmel_ssc_put_audio(0);
309 snd_soc_unregister_card(card);
270 clk_put(mclk); 310 clk_put(mclk);
271 mclk = NULL; 311 mclk = NULL;
312
313 return 0;
272} 314}
273 315
274module_init(at91sam9g20ek_init); 316#ifdef CONFIG_OF
275module_exit(at91sam9g20ek_exit); 317static const struct of_device_id at91sam9g20ek_wm8731_dt_ids[] = {
318 { .compatible = "atmel,at91sam9g20ek-wm8731-audio", },
319 { }
320};
321MODULE_DEVICE_TABLE(of, at91sam9g20ek_wm8731_dt_ids);
322#endif
323
324static struct platform_driver at91sam9g20ek_audio_driver = {
325 .driver = {
326 .name = "at91sam9g20ek-audio",
327 .owner = THIS_MODULE,
328 .of_match_table = of_match_ptr(at91sam9g20ek_wm8731_dt_ids),
329 },
330 .probe = at91sam9g20ek_audio_probe,
331 .remove = __devexit_p(at91sam9g20ek_audio_remove),
332};
333
334module_platform_driver(at91sam9g20ek_audio_driver);
276 335
277/* Module information */ 336/* Module information */
278MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>"); 337MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>");
279MODULE_DESCRIPTION("ALSA SoC AT91SAM9G20EK_WM8731"); 338MODULE_DESCRIPTION("ALSA SoC AT91SAM9G20EK_WM8731");
339MODULE_ALIAS("platform:at91sam9g20ek-audio");
280MODULE_LICENSE("GPL"); 340MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index b92759a39361..80799639814e 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -146,6 +146,13 @@ config SND_SOC_WM_HUBS
146 default y if SND_SOC_WM8993=y || SND_SOC_WM8994=y 146 default y if SND_SOC_WM8993=y || SND_SOC_WM8994=y
147 default m if SND_SOC_WM8993=m || SND_SOC_WM8994=m 147 default m if SND_SOC_WM8993=m || SND_SOC_WM8994=m
148 148
149config SND_SOC_WM_ADSP
150 tristate
151 default y if SND_SOC_WM5102=y
152 default y if SND_SOC_WM2200=y
153 default m if SND_SOC_WM5102=m
154 default m if SND_SOC_WM2200=m
155
149config SND_SOC_AB8500_CODEC 156config SND_SOC_AB8500_CODEC
150 tristate 157 tristate
151 158
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 9bd4d95aab4f..61633d5ff3da 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -62,6 +62,7 @@ snd-soc-twl6040-objs := twl6040.o
62snd-soc-uda134x-objs := uda134x.o 62snd-soc-uda134x-objs := uda134x.o
63snd-soc-uda1380-objs := uda1380.o 63snd-soc-uda1380-objs := uda1380.o
64snd-soc-wl1273-objs := wl1273.o 64snd-soc-wl1273-objs := wl1273.o
65snd-soc-wm-adsp-objs := wm_adsp.o
65snd-soc-wm0010-objs := wm0010.o 66snd-soc-wm0010-objs := wm0010.o
66snd-soc-wm1250-ev1-objs := wm1250-ev1.o 67snd-soc-wm1250-ev1-objs := wm1250-ev1.o
67snd-soc-wm2000-objs := wm2000.o 68snd-soc-wm2000-objs := wm2000.o
@@ -229,6 +230,7 @@ obj-$(CONFIG_SND_SOC_WM9090) += snd-soc-wm9090.o
229obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o 230obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o
230obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o 231obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o
231obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o 232obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o
233obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o
232obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o 234obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o
233 235
234# Amp 236# Amp
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c
index af547490b4f7..4d96090db662 100644
--- a/sound/soc/codecs/ab8500-codec.c
+++ b/sound/soc/codecs/ab8500-codec.c
@@ -2356,7 +2356,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
2356 return 0; 2356 return 0;
2357} 2357}
2358 2358
2359struct snd_soc_dai_driver ab8500_codec_dai[] = { 2359static struct snd_soc_dai_driver ab8500_codec_dai[] = {
2360 { 2360 {
2361 .name = "ab8500-codec-dai.0", 2361 .name = "ab8500-codec-dai.0",
2362 .id = 0, 2362 .id = 0,
diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c
index 31d4483245d0..4b11b82b2273 100644
--- a/sound/soc/codecs/ak4104.c
+++ b/sound/soc/codecs/ak4104.c
@@ -15,6 +15,8 @@
15#include <sound/soc.h> 15#include <sound/soc.h>
16#include <sound/initval.h> 16#include <sound/initval.h>
17#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
18#include <linux/of_device.h>
19#include <linux/of_gpio.h>
18#include <sound/asoundef.h> 20#include <sound/asoundef.h>
19 21
20/* AK4104 registers addresses */ 22/* AK4104 registers addresses */
@@ -98,14 +100,32 @@ static int ak4104_hw_params(struct snd_pcm_substream *substream,
98 val = 0; 100 val = 0;
99 101
100 switch (params_rate(params)) { 102 switch (params_rate(params)) {
103 case 22050:
104 val |= IEC958_AES3_CON_FS_22050;
105 break;
106 case 24000:
107 val |= IEC958_AES3_CON_FS_24000;
108 break;
109 case 32000:
110 val |= IEC958_AES3_CON_FS_32000;
111 break;
101 case 44100: 112 case 44100:
102 val |= IEC958_AES3_CON_FS_44100; 113 val |= IEC958_AES3_CON_FS_44100;
103 break; 114 break;
104 case 48000: 115 case 48000:
105 val |= IEC958_AES3_CON_FS_48000; 116 val |= IEC958_AES3_CON_FS_48000;
106 break; 117 break;
107 case 32000: 118 case 88200:
108 val |= IEC958_AES3_CON_FS_32000; 119 val |= IEC958_AES3_CON_FS_88200;
120 break;
121 case 96000:
122 val |= IEC958_AES3_CON_FS_96000;
123 break;
124 case 176400:
125 val |= IEC958_AES3_CON_FS_176400;
126 break;
127 case 192000:
128 val |= IEC958_AES3_CON_FS_192000;
109 break; 129 break;
110 default: 130 default:
111 dev_err(codec->dev, "unsupported sampling rate\n"); 131 dev_err(codec->dev, "unsupported sampling rate\n");
@@ -186,6 +206,7 @@ static const struct regmap_config ak4104_regmap = {
186 206
187static int ak4104_spi_probe(struct spi_device *spi) 207static int ak4104_spi_probe(struct spi_device *spi)
188{ 208{
209 struct device_node *np = spi->dev.of_node;
189 struct ak4104_private *ak4104; 210 struct ak4104_private *ak4104;
190 unsigned int val; 211 unsigned int val;
191 int ret; 212 int ret;
@@ -201,49 +222,59 @@ static int ak4104_spi_probe(struct spi_device *spi)
201 if (ak4104 == NULL) 222 if (ak4104 == NULL)
202 return -ENOMEM; 223 return -ENOMEM;
203 224
204 ak4104->regmap = regmap_init_spi(spi, &ak4104_regmap); 225 ak4104->regmap = devm_regmap_init_spi(spi, &ak4104_regmap);
205 if (IS_ERR(ak4104->regmap)) { 226 if (IS_ERR(ak4104->regmap)) {
206 ret = PTR_ERR(ak4104->regmap); 227 ret = PTR_ERR(ak4104->regmap);
207 return ret; 228 return ret;
208 } 229 }
209 230
231 if (np) {
232 enum of_gpio_flags flags;
233 int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags);
234
235 if (gpio_is_valid(gpio)) {
236 ret = devm_gpio_request_one(&spi->dev, gpio,
237 flags & OF_GPIO_ACTIVE_LOW ?
238 GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH,
239 "ak4104 reset");
240 if (ret < 0)
241 return ret;
242 }
243 }
244
210 /* read the 'reserved' register - according to the datasheet, it 245 /* read the 'reserved' register - according to the datasheet, it
211 * should contain 0x5b. Not a good way to verify the presence of 246 * should contain 0x5b. Not a good way to verify the presence of
212 * the device, but there is no hardware ID register. */ 247 * the device, but there is no hardware ID register. */
213 ret = regmap_read(ak4104->regmap, AK4104_REG_RESERVED, &val); 248 ret = regmap_read(ak4104->regmap, AK4104_REG_RESERVED, &val);
214 if (ret != 0) 249 if (ret != 0)
215 goto err; 250 return ret;
216 if (val != AK4104_RESERVED_VAL) { 251 if (val != AK4104_RESERVED_VAL)
217 ret = -ENODEV; 252 return -ENODEV;
218 goto err;
219 }
220 253
221 spi_set_drvdata(spi, ak4104); 254 spi_set_drvdata(spi, ak4104);
222 255
223 ret = snd_soc_register_codec(&spi->dev, 256 ret = snd_soc_register_codec(&spi->dev,
224 &soc_codec_device_ak4104, &ak4104_dai, 1); 257 &soc_codec_device_ak4104, &ak4104_dai, 1);
225 if (ret != 0)
226 goto err;
227
228 return 0;
229
230err:
231 regmap_exit(ak4104->regmap);
232 return ret; 258 return ret;
233} 259}
234 260
235static int __devexit ak4104_spi_remove(struct spi_device *spi) 261static int __devexit ak4104_spi_remove(struct spi_device *spi)
236{ 262{
237 struct ak4104_private *ak4101 = spi_get_drvdata(spi);
238 regmap_exit(ak4101->regmap);
239 snd_soc_unregister_codec(&spi->dev); 263 snd_soc_unregister_codec(&spi->dev);
240 return 0; 264 return 0;
241} 265}
242 266
267static const struct of_device_id ak4104_of_match[] = {
268 { .compatible = "asahi-kasei,ak4104", },
269 { }
270};
271MODULE_DEVICE_TABLE(of, ak4104_of_match);
272
243static struct spi_driver ak4104_spi_driver = { 273static struct spi_driver ak4104_spi_driver = {
244 .driver = { 274 .driver = {
245 .name = DRV_NAME, 275 .name = DRV_NAME,
246 .owner = THIS_MODULE, 276 .owner = THIS_MODULE,
277 .of_match_table = ak4104_of_match,
247 }, 278 },
248 .probe = ak4104_spi_probe, 279 .probe = ak4104_spi_probe,
249 .remove = __devexit_p(ak4104_spi_remove), 280 .remove = __devexit_p(ak4104_spi_remove),
diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c
index 618fdc30f73e..fc5581063b2d 100644
--- a/sound/soc/codecs/ak4535.c
+++ b/sound/soc/codecs/ak4535.c
@@ -447,7 +447,7 @@ static __devinit int ak4535_i2c_probe(struct i2c_client *i2c,
447 if (ak4535 == NULL) 447 if (ak4535 == NULL)
448 return -ENOMEM; 448 return -ENOMEM;
449 449
450 ak4535->regmap = regmap_init_i2c(i2c, &ak4535_regmap); 450 ak4535->regmap = devm_regmap_init_i2c(i2c, &ak4535_regmap);
451 if (IS_ERR(ak4535->regmap)) { 451 if (IS_ERR(ak4535->regmap)) {
452 ret = PTR_ERR(ak4535->regmap); 452 ret = PTR_ERR(ak4535->regmap);
453 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret); 453 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret);
@@ -458,18 +458,13 @@ static __devinit int ak4535_i2c_probe(struct i2c_client *i2c,
458 458
459 ret = snd_soc_register_codec(&i2c->dev, 459 ret = snd_soc_register_codec(&i2c->dev,
460 &soc_codec_dev_ak4535, &ak4535_dai, 1); 460 &soc_codec_dev_ak4535, &ak4535_dai, 1);
461 if (ret != 0)
462 regmap_exit(ak4535->regmap);
463 461
464 return ret; 462 return ret;
465} 463}
466 464
467static __devexit int ak4535_i2c_remove(struct i2c_client *client) 465static __devexit int ak4535_i2c_remove(struct i2c_client *client)
468{ 466{
469 struct ak4535_priv *ak4535 = i2c_get_clientdata(client);
470
471 snd_soc_unregister_codec(&client->dev); 467 snd_soc_unregister_codec(&client->dev);
472 regmap_exit(ak4535->regmap);
473 return 0; 468 return 0;
474} 469}
475 470
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index b3e24f289421..546466abb77f 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -194,12 +194,6 @@ static const struct snd_soc_dapm_route ak4642_intercon[] = {
194 {"LINEOUT Mixer", "DACL", "DAC"}, 194 {"LINEOUT Mixer", "DACL", "DAC"},
195}; 195};
196 196
197/* codec private data */
198struct ak4642_priv {
199 unsigned int sysclk;
200 enum snd_soc_control_type control_type;
201};
202
203/* 197/*
204 * ak4642 register cache 198 * ak4642 register cache
205 */ 199 */
@@ -468,10 +462,9 @@ static int ak4642_resume(struct snd_soc_codec *codec)
468 462
469static int ak4642_probe(struct snd_soc_codec *codec) 463static int ak4642_probe(struct snd_soc_codec *codec)
470{ 464{
471 struct ak4642_priv *ak4642 = snd_soc_codec_get_drvdata(codec);
472 int ret; 465 int ret;
473 466
474 ret = snd_soc_codec_set_cache_io(codec, 8, 8, ak4642->control_type); 467 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
475 if (ret < 0) { 468 if (ret < 0) {
476 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 469 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
477 return ret; 470 return ret;
@@ -523,21 +516,9 @@ static struct snd_soc_codec_driver soc_codec_dev_ak4648 = {
523static __devinit int ak4642_i2c_probe(struct i2c_client *i2c, 516static __devinit int ak4642_i2c_probe(struct i2c_client *i2c,
524 const struct i2c_device_id *id) 517 const struct i2c_device_id *id)
525{ 518{
526 struct ak4642_priv *ak4642; 519 return snd_soc_register_codec(&i2c->dev,
527 int ret;
528
529 ak4642 = devm_kzalloc(&i2c->dev, sizeof(struct ak4642_priv),
530 GFP_KERNEL);
531 if (!ak4642)
532 return -ENOMEM;
533
534 i2c_set_clientdata(i2c, ak4642);
535 ak4642->control_type = SND_SOC_I2C;
536
537 ret = snd_soc_register_codec(&i2c->dev,
538 (struct snd_soc_codec_driver *)id->driver_data, 520 (struct snd_soc_codec_driver *)id->driver_data,
539 &ak4642_dai, 1); 521 &ak4642_dai, 1);
540 return ret;
541} 522}
542 523
543static __devexit int ak4642_i2c_remove(struct i2c_client *client) 524static __devexit int ak4642_i2c_remove(struct i2c_client *client)
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index c03b65af3059..adf397b9d0e6 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -226,6 +226,31 @@ EXPORT_SYMBOL_GPL(arizona_mixer_values);
226const DECLARE_TLV_DB_SCALE(arizona_mixer_tlv, -3200, 100, 0); 226const DECLARE_TLV_DB_SCALE(arizona_mixer_tlv, -3200, 100, 0);
227EXPORT_SYMBOL_GPL(arizona_mixer_tlv); 227EXPORT_SYMBOL_GPL(arizona_mixer_tlv);
228 228
229static const char *arizona_vol_ramp_text[] = {
230 "0ms/6dB", "0.5ms/6dB", "1ms/6dB", "2ms/6dB", "4ms/6dB", "8ms/6dB",
231 "15ms/6dB", "30ms/6dB",
232};
233
234const struct soc_enum arizona_in_vd_ramp =
235 SOC_ENUM_SINGLE(ARIZONA_INPUT_VOLUME_RAMP,
236 ARIZONA_IN_VD_RAMP_SHIFT, 7, arizona_vol_ramp_text);
237EXPORT_SYMBOL_GPL(arizona_in_vd_ramp);
238
239const struct soc_enum arizona_in_vi_ramp =
240 SOC_ENUM_SINGLE(ARIZONA_INPUT_VOLUME_RAMP,
241 ARIZONA_IN_VI_RAMP_SHIFT, 7, arizona_vol_ramp_text);
242EXPORT_SYMBOL_GPL(arizona_in_vi_ramp);
243
244const struct soc_enum arizona_out_vd_ramp =
245 SOC_ENUM_SINGLE(ARIZONA_OUTPUT_VOLUME_RAMP,
246 ARIZONA_OUT_VD_RAMP_SHIFT, 7, arizona_vol_ramp_text);
247EXPORT_SYMBOL_GPL(arizona_out_vd_ramp);
248
249const struct soc_enum arizona_out_vi_ramp =
250 SOC_ENUM_SINGLE(ARIZONA_OUTPUT_VOLUME_RAMP,
251 ARIZONA_OUT_VI_RAMP_SHIFT, 7, arizona_vol_ramp_text);
252EXPORT_SYMBOL_GPL(arizona_out_vi_ramp);
253
229static const char *arizona_lhpf_mode_text[] = { 254static const char *arizona_lhpf_mode_text[] = {
230 "Low-pass", "High-pass" 255 "Low-pass", "High-pass"
231}; 256};
@@ -268,7 +293,7 @@ EXPORT_SYMBOL_GPL(arizona_out_ev);
268static unsigned int arizona_sysclk_48k_rates[] = { 293static unsigned int arizona_sysclk_48k_rates[] = {
269 6144000, 294 6144000,
270 12288000, 295 12288000,
271 22579200, 296 24576000,
272 49152000, 297 49152000,
273 73728000, 298 73728000,
274 98304000, 299 98304000,
@@ -278,7 +303,7 @@ static unsigned int arizona_sysclk_48k_rates[] = {
278static unsigned int arizona_sysclk_44k1_rates[] = { 303static unsigned int arizona_sysclk_44k1_rates[] = {
279 5644800, 304 5644800,
280 11289600, 305 11289600,
281 24576000, 306 22579200,
282 45158400, 307 45158400,
283 67737600, 308 67737600,
284 90316800, 309 90316800,
@@ -380,6 +405,18 @@ int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id,
380 case 49152000: 405 case 49152000:
381 val |= 3 << ARIZONA_SYSCLK_FREQ_SHIFT; 406 val |= 3 << ARIZONA_SYSCLK_FREQ_SHIFT;
382 break; 407 break;
408 case 67737600:
409 case 73728000:
410 val |= 4 << ARIZONA_SYSCLK_FREQ_SHIFT;
411 break;
412 case 90316800:
413 case 98304000:
414 val |= 5 << ARIZONA_SYSCLK_FREQ_SHIFT;
415 break;
416 case 135475200:
417 case 147456000:
418 val |= 6 << ARIZONA_SYSCLK_FREQ_SHIFT;
419 break;
383 default: 420 default:
384 return -EINVAL; 421 return -EINVAL;
385 } 422 }
@@ -737,6 +774,9 @@ static int arizona_dai_set_sysclk(struct snd_soc_dai *dai,
737 return -EBUSY; 774 return -EBUSY;
738 } 775 }
739 776
777 dev_dbg(codec->dev, "Setting AIF%d to %s\n", dai->id + 1,
778 arizona_dai_clk_str(clk_id));
779
740 memset(&routes, 0, sizeof(routes)); 780 memset(&routes, 0, sizeof(routes));
741 routes[0].sink = dai->driver->capture.stream_name; 781 routes[0].sink = dai->driver->capture.stream_name;
742 routes[1].sink = dai->driver->playback.stream_name; 782 routes[1].sink = dai->driver->playback.stream_name;
@@ -749,6 +789,8 @@ static int arizona_dai_set_sysclk(struct snd_soc_dai *dai,
749 routes[1].source = arizona_dai_clk_str(clk_id); 789 routes[1].source = arizona_dai_clk_str(clk_id);
750 snd_soc_dapm_add_routes(&codec->dapm, routes, ARRAY_SIZE(routes)); 790 snd_soc_dapm_add_routes(&codec->dapm, routes, ARRAY_SIZE(routes));
751 791
792 dai_priv->clk = clk_id;
793
752 return snd_soc_dapm_sync(&codec->dapm); 794 return snd_soc_dapm_sync(&codec->dapm);
753} 795}
754 796
@@ -925,6 +967,9 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
925 bool ena; 967 bool ena;
926 int ret; 968 int ret;
927 969
970 if (fll->fref == Fref && fll->fout == Fout)
971 return 0;
972
928 ret = regmap_read(arizona->regmap, fll->base + 1, &reg); 973 ret = regmap_read(arizona->regmap, fll->base + 1, &reg);
929 if (ret != 0) { 974 if (ret != 0) {
930 arizona_fll_err(fll, "Failed to read current state: %d\n", 975 arizona_fll_err(fll, "Failed to read current state: %d\n",
@@ -970,6 +1015,9 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
970 if (ena) 1015 if (ena)
971 pm_runtime_put_autosuspend(arizona->dev); 1016 pm_runtime_put_autosuspend(arizona->dev);
972 1017
1018 fll->fref = Fref;
1019 fll->fout = Fout;
1020
973 return 0; 1021 return 0;
974 } 1022 }
975 1023
@@ -998,10 +1046,13 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
998 ARIZONA_FLL1_SYNC_ENA); 1046 ARIZONA_FLL1_SYNC_ENA);
999 1047
1000 ret = wait_for_completion_timeout(&fll->ok, 1048 ret = wait_for_completion_timeout(&fll->ok,
1001 msecs_to_jiffies(25)); 1049 msecs_to_jiffies(250));
1002 if (ret == 0) 1050 if (ret == 0)
1003 arizona_fll_warn(fll, "Timed out waiting for lock\n"); 1051 arizona_fll_warn(fll, "Timed out waiting for lock\n");
1004 1052
1053 fll->fref = Fref;
1054 fll->fout = Fout;
1055
1005 return 0; 1056 return 0;
1006} 1057}
1007EXPORT_SYMBOL_GPL(arizona_set_fll); 1058EXPORT_SYMBOL_GPL(arizona_set_fll);
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 36ec64946120..41dae1ed3b71 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -17,6 +17,8 @@
17 17
18#include <sound/soc.h> 18#include <sound/soc.h>
19 19
20#include "wm_adsp.h"
21
20#define ARIZONA_CLK_SYSCLK 1 22#define ARIZONA_CLK_SYSCLK 1
21#define ARIZONA_CLK_ASYNCCLK 2 23#define ARIZONA_CLK_ASYNCCLK 2
22#define ARIZONA_CLK_OPCLK 3 24#define ARIZONA_CLK_OPCLK 3
@@ -46,15 +48,18 @@
46#define ARIZONA_MIXER_VOL_SHIFT 1 48#define ARIZONA_MIXER_VOL_SHIFT 1
47#define ARIZONA_MIXER_VOL_WIDTH 7 49#define ARIZONA_MIXER_VOL_WIDTH 7
48 50
49#define ARIZONA_MAX_DAI 3 51#define ARIZONA_MAX_DAI 4
52#define ARIZONA_MAX_ADSP 4
50 53
51struct arizona; 54struct arizona;
55struct wm_adsp;
52 56
53struct arizona_dai_priv { 57struct arizona_dai_priv {
54 int clk; 58 int clk;
55}; 59};
56 60
57struct arizona_priv { 61struct arizona_priv {
62 struct wm_adsp adsp[ARIZONA_MAX_ADSP];
58 struct arizona *arizona; 63 struct arizona *arizona;
59 int sysclk; 64 int sysclk;
60 int asyncclk; 65 int asyncclk;
@@ -89,19 +94,30 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
89 const struct snd_kcontrol_new name##_mux = \ 94 const struct snd_kcontrol_new name##_mux = \
90 SOC_DAPM_VALUE_ENUM("Route", name##_enum) 95 SOC_DAPM_VALUE_ENUM("Route", name##_enum)
91 96
97#define ARIZONA_MUX_ENUMS(name, base_reg) \
98 static ARIZONA_MUX_ENUM_DECL(name##_enum, base_reg); \
99 static ARIZONA_MUX_CTL_DECL(name)
100
92#define ARIZONA_MIXER_ENUMS(name, base_reg) \ 101#define ARIZONA_MIXER_ENUMS(name, base_reg) \
93 static ARIZONA_MUX_ENUM_DECL(name##_in1_enum, base_reg); \ 102 ARIZONA_MUX_ENUMS(name##_in1, base_reg); \
94 static ARIZONA_MUX_ENUM_DECL(name##_in2_enum, base_reg + 2); \ 103 ARIZONA_MUX_ENUMS(name##_in2, base_reg + 2); \
95 static ARIZONA_MUX_ENUM_DECL(name##_in3_enum, base_reg + 4); \ 104 ARIZONA_MUX_ENUMS(name##_in3, base_reg + 4); \
96 static ARIZONA_MUX_ENUM_DECL(name##_in4_enum, base_reg + 6); \ 105 ARIZONA_MUX_ENUMS(name##_in4, base_reg + 6)
97 static ARIZONA_MUX_CTL_DECL(name##_in1); \ 106
98 static ARIZONA_MUX_CTL_DECL(name##_in2); \ 107#define ARIZONA_DSP_AUX_ENUMS(name, base_reg) \
99 static ARIZONA_MUX_CTL_DECL(name##_in3); \ 108 ARIZONA_MUX_ENUMS(name##_aux1, base_reg); \
100 static ARIZONA_MUX_CTL_DECL(name##_in4) 109 ARIZONA_MUX_ENUMS(name##_aux2, base_reg + 8); \
110 ARIZONA_MUX_ENUMS(name##_aux3, base_reg + 16); \
111 ARIZONA_MUX_ENUMS(name##_aux4, base_reg + 24); \
112 ARIZONA_MUX_ENUMS(name##_aux5, base_reg + 32); \
113 ARIZONA_MUX_ENUMS(name##_aux6, base_reg + 40)
101 114
102#define ARIZONA_MUX(name, ctrl) \ 115#define ARIZONA_MUX(name, ctrl) \
103 SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) 116 SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl)
104 117
118#define ARIZONA_MUX_WIDGETS(name, name_str) \
119 ARIZONA_MUX(name_str " Input", &name##_mux)
120
105#define ARIZONA_MIXER_WIDGETS(name, name_str) \ 121#define ARIZONA_MIXER_WIDGETS(name, name_str) \
106 ARIZONA_MUX(name_str " Input 1", &name##_in1_mux), \ 122 ARIZONA_MUX(name_str " Input 1", &name##_in1_mux), \
107 ARIZONA_MUX(name_str " Input 2", &name##_in2_mux), \ 123 ARIZONA_MUX(name_str " Input 2", &name##_in2_mux), \
@@ -109,6 +125,19 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
109 ARIZONA_MUX(name_str " Input 4", &name##_in4_mux), \ 125 ARIZONA_MUX(name_str " Input 4", &name##_in4_mux), \
110 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0) 126 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0)
111 127
128#define ARIZONA_DSP_WIDGETS(name, name_str) \
129 ARIZONA_MIXER_WIDGETS(name##L, name_str "L"), \
130 ARIZONA_MIXER_WIDGETS(name##R, name_str "R"), \
131 ARIZONA_MUX(name_str " Aux 1", &name##_aux1_mux), \
132 ARIZONA_MUX(name_str " Aux 2", &name##_aux2_mux), \
133 ARIZONA_MUX(name_str " Aux 3", &name##_aux3_mux), \
134 ARIZONA_MUX(name_str " Aux 4", &name##_aux4_mux), \
135 ARIZONA_MUX(name_str " Aux 5", &name##_aux5_mux), \
136 ARIZONA_MUX(name_str " Aux 6", &name##_aux6_mux)
137
138#define ARIZONA_MUX_ROUTES(name) \
139 ARIZONA_MIXER_INPUT_ROUTES(name " Input")
140
112#define ARIZONA_MIXER_ROUTES(widget, name) \ 141#define ARIZONA_MIXER_ROUTES(widget, name) \
113 { widget, NULL, name " Mixer" }, \ 142 { widget, NULL, name " Mixer" }, \
114 { name " Mixer", NULL, name " Input 1" }, \ 143 { name " Mixer", NULL, name " Input 1" }, \
@@ -120,6 +149,28 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
120 ARIZONA_MIXER_INPUT_ROUTES(name " Input 3"), \ 149 ARIZONA_MIXER_INPUT_ROUTES(name " Input 3"), \
121 ARIZONA_MIXER_INPUT_ROUTES(name " Input 4") 150 ARIZONA_MIXER_INPUT_ROUTES(name " Input 4")
122 151
152#define ARIZONA_DSP_ROUTES(name) \
153 { name, NULL, name " Aux 1" }, \
154 { name, NULL, name " Aux 2" }, \
155 { name, NULL, name " Aux 3" }, \
156 { name, NULL, name " Aux 4" }, \
157 { name, NULL, name " Aux 5" }, \
158 { name, NULL, name " Aux 6" }, \
159 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 1"), \
160 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 2"), \
161 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 3"), \
162 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 4"), \
163 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 5"), \
164 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 6"), \
165 ARIZONA_MIXER_ROUTES(name, name "L"), \
166 ARIZONA_MIXER_ROUTES(name, name "R")
167
168extern const struct soc_enum arizona_in_vi_ramp;
169extern const struct soc_enum arizona_in_vd_ramp;
170
171extern const struct soc_enum arizona_out_vi_ramp;
172extern const struct soc_enum arizona_out_vd_ramp;
173
123extern const struct soc_enum arizona_lhpf1_mode; 174extern const struct soc_enum arizona_lhpf1_mode;
124extern const struct soc_enum arizona_lhpf2_mode; 175extern const struct soc_enum arizona_lhpf2_mode;
125extern const struct soc_enum arizona_lhpf3_mode; 176extern const struct soc_enum arizona_lhpf3_mode;
@@ -146,6 +197,8 @@ struct arizona_fll {
146 unsigned int vco_mult; 197 unsigned int vco_mult;
147 struct completion lock; 198 struct completion lock;
148 struct completion ok; 199 struct completion ok;
200 unsigned int fref;
201 unsigned int fout;
149 202
150 char lock_name[ARIZONA_FLL_NAME_LEN]; 203 char lock_name[ARIZONA_FLL_NAME_LEN];
151 char clock_ok_name[ARIZONA_FLL_NAME_LEN]; 204 char clock_ok_name[ARIZONA_FLL_NAME_LEN];
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index f994af34f552..6ad3878db8fc 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -474,18 +474,28 @@ static int cs4271_probe(struct snd_soc_codec *codec)
474 struct cs4271_platform_data *cs4271plat = codec->dev->platform_data; 474 struct cs4271_platform_data *cs4271plat = codec->dev->platform_data;
475 int ret; 475 int ret;
476 int gpio_nreset = -EINVAL; 476 int gpio_nreset = -EINVAL;
477 int amutec_eq_bmutec = 0;
477 478
478#ifdef CONFIG_OF 479#ifdef CONFIG_OF
479 if (of_match_device(cs4271_dt_ids, codec->dev)) 480 if (of_match_device(cs4271_dt_ids, codec->dev)) {
480 gpio_nreset = of_get_named_gpio(codec->dev->of_node, 481 gpio_nreset = of_get_named_gpio(codec->dev->of_node,
481 "reset-gpio", 0); 482 "reset-gpio", 0);
483
484 if (!of_get_property(codec->dev->of_node,
485 "cirrus,amutec-eq-bmutec", NULL))
486 amutec_eq_bmutec = 1;
487 }
482#endif 488#endif
483 489
484 if (cs4271plat && gpio_is_valid(cs4271plat->gpio_nreset)) 490 if (cs4271plat) {
485 gpio_nreset = cs4271plat->gpio_nreset; 491 if (gpio_is_valid(cs4271plat->gpio_nreset))
492 gpio_nreset = cs4271plat->gpio_nreset;
493
494 amutec_eq_bmutec = cs4271plat->amutec_eq_bmutec;
495 }
486 496
487 if (gpio_nreset >= 0) 497 if (gpio_nreset >= 0)
488 if (gpio_request(gpio_nreset, "CS4271 Reset")) 498 if (devm_gpio_request(codec->dev, gpio_nreset, "CS4271 Reset"))
489 gpio_nreset = -EINVAL; 499 gpio_nreset = -EINVAL;
490 if (gpio_nreset >= 0) { 500 if (gpio_nreset >= 0) {
491 /* Reset codec */ 501 /* Reset codec */
@@ -528,6 +538,11 @@ static int cs4271_probe(struct snd_soc_codec *codec)
528 /* Power-up sequence requires 85 uS */ 538 /* Power-up sequence requires 85 uS */
529 udelay(85); 539 udelay(85);
530 540
541 if (amutec_eq_bmutec)
542 snd_soc_update_bits(codec, CS4271_MODE2,
543 CS4271_MODE2_MUTECAEQUB,
544 CS4271_MODE2_MUTECAEQUB);
545
531 return snd_soc_add_codec_controls(codec, cs4271_snd_controls, 546 return snd_soc_add_codec_controls(codec, cs4271_snd_controls,
532 ARRAY_SIZE(cs4271_snd_controls)); 547 ARRAY_SIZE(cs4271_snd_controls));
533} 548}
@@ -535,15 +550,10 @@ static int cs4271_probe(struct snd_soc_codec *codec)
535static int cs4271_remove(struct snd_soc_codec *codec) 550static int cs4271_remove(struct snd_soc_codec *codec)
536{ 551{
537 struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); 552 struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
538 int gpio_nreset;
539
540 gpio_nreset = cs4271->gpio_nreset;
541 553
542 if (gpio_is_valid(gpio_nreset)) { 554 if (gpio_is_valid(cs4271->gpio_nreset))
543 /* Set codec to the reset state */ 555 /* Set codec to the reset state */
544 gpio_set_value(gpio_nreset, 0); 556 gpio_set_value(cs4271->gpio_nreset, 0);
545 gpio_free(gpio_nreset);
546 }
547 557
548 return 0; 558 return 0;
549}; 559};
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 61599298fb26..97a81051e88d 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -763,7 +763,7 @@ static int cs42l52_set_sysclk(struct snd_soc_dai *codec_dai,
763 if ((freq >= CS42L52_MIN_CLK) && (freq <= CS42L52_MAX_CLK)) { 763 if ((freq >= CS42L52_MIN_CLK) && (freq <= CS42L52_MAX_CLK)) {
764 cs42l52->sysclk = freq; 764 cs42l52->sysclk = freq;
765 } else { 765 } else {
766 dev_err(codec->dev, "Invalid freq paramter\n"); 766 dev_err(codec->dev, "Invalid freq parameter\n");
767 return -EINVAL; 767 return -EINVAL;
768 } 768 }
769 return 0; 769 return 0;
@@ -773,7 +773,6 @@ static int cs42l52_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
773{ 773{
774 struct snd_soc_codec *codec = codec_dai->codec; 774 struct snd_soc_codec *codec = codec_dai->codec;
775 struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); 775 struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec);
776 int ret = 0;
777 u8 iface = 0; 776 u8 iface = 0;
778 777
779 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 778 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -822,7 +821,7 @@ static int cs42l52_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
822 case SND_SOC_DAIFMT_NB_IF: 821 case SND_SOC_DAIFMT_NB_IF:
823 break; 822 break;
824 default: 823 default:
825 ret = -EINVAL; 824 return -EINVAL;
826 } 825 }
827 cs42l52->config.format = iface; 826 cs42l52->config.format = iface;
828 snd_soc_write(codec, CS42L52_IFACE_CTL1, cs42l52->config.format); 827 snd_soc_write(codec, CS42L52_IFACE_CTL1, cs42l52->config.format);
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
index af5db7080519..843c1eb72faf 100644
--- a/sound/soc/codecs/da7210.c
+++ b/sound/soc/codecs/da7210.c
@@ -1231,7 +1231,7 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
1231 1231
1232 i2c_set_clientdata(i2c, da7210); 1232 i2c_set_clientdata(i2c, da7210);
1233 1233
1234 da7210->regmap = regmap_init_i2c(i2c, &da7210_regmap_config_i2c); 1234 da7210->regmap = devm_regmap_init_i2c(i2c, &da7210_regmap_config_i2c);
1235 if (IS_ERR(da7210->regmap)) { 1235 if (IS_ERR(da7210->regmap)) {
1236 ret = PTR_ERR(da7210->regmap); 1236 ret = PTR_ERR(da7210->regmap);
1237 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); 1237 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret);
@@ -1245,24 +1245,15 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
1245 1245
1246 ret = snd_soc_register_codec(&i2c->dev, 1246 ret = snd_soc_register_codec(&i2c->dev,
1247 &soc_codec_dev_da7210, &da7210_dai, 1); 1247 &soc_codec_dev_da7210, &da7210_dai, 1);
1248 if (ret < 0) { 1248 if (ret < 0)
1249 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); 1249 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
1250 goto err_regmap;
1251 }
1252 return ret;
1253
1254err_regmap:
1255 regmap_exit(da7210->regmap);
1256 1250
1257 return ret; 1251 return ret;
1258} 1252}
1259 1253
1260static int __devexit da7210_i2c_remove(struct i2c_client *client) 1254static int __devexit da7210_i2c_remove(struct i2c_client *client)
1261{ 1255{
1262 struct da7210_priv *da7210 = i2c_get_clientdata(client);
1263
1264 snd_soc_unregister_codec(&client->dev); 1256 snd_soc_unregister_codec(&client->dev);
1265 regmap_exit(da7210->regmap);
1266 return 0; 1257 return 0;
1267} 1258}
1268 1259
@@ -1346,24 +1337,15 @@ static int __devinit da7210_spi_probe(struct spi_device *spi)
1346 if (ret != 0) 1337 if (ret != 0)
1347 dev_warn(&spi->dev, "Failed to apply regmap patch: %d\n", ret); 1338 dev_warn(&spi->dev, "Failed to apply regmap patch: %d\n", ret);
1348 1339
1349 ret = snd_soc_register_codec(&spi->dev, 1340 ret = snd_soc_register_codec(&spi->dev,
1350 &soc_codec_dev_da7210, &da7210_dai, 1); 1341 &soc_codec_dev_da7210, &da7210_dai, 1);
1351 if (ret < 0)
1352 goto err_regmap;
1353
1354 return ret;
1355
1356err_regmap:
1357 regmap_exit(da7210->regmap);
1358 1342
1359 return ret; 1343 return ret;
1360} 1344}
1361 1345
1362static int __devexit da7210_spi_remove(struct spi_device *spi) 1346static int __devexit da7210_spi_remove(struct spi_device *spi)
1363{ 1347{
1364 struct da7210_priv *da7210 = spi_get_drvdata(spi);
1365 snd_soc_unregister_codec(&spi->dev); 1348 snd_soc_unregister_codec(&spi->dev);
1366 regmap_exit(da7210->regmap);
1367 return 0; 1349 return 0;
1368} 1350}
1369 1351
diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c
index 185d8dd36399..d3a6de2e757b 100644
--- a/sound/soc/codecs/da9055.c
+++ b/sound/soc/codecs/da9055.c
@@ -173,11 +173,18 @@
173#define DA9055_AIF_FORMAT_I2S_MODE (0 << 0) 173#define DA9055_AIF_FORMAT_I2S_MODE (0 << 0)
174#define DA9055_AIF_FORMAT_LEFT_J (1 << 0) 174#define DA9055_AIF_FORMAT_LEFT_J (1 << 0)
175#define DA9055_AIF_FORMAT_RIGHT_J (2 << 0) 175#define DA9055_AIF_FORMAT_RIGHT_J (2 << 0)
176#define DA9055_AIF_FORMAT_DSP (3 << 0)
176#define DA9055_AIF_WORD_S16_LE (0 << 2) 177#define DA9055_AIF_WORD_S16_LE (0 << 2)
177#define DA9055_AIF_WORD_S20_3LE (1 << 2) 178#define DA9055_AIF_WORD_S20_3LE (1 << 2)
178#define DA9055_AIF_WORD_S24_LE (2 << 2) 179#define DA9055_AIF_WORD_S24_LE (2 << 2)
179#define DA9055_AIF_WORD_S32_LE (3 << 2) 180#define DA9055_AIF_WORD_S32_LE (3 << 2)
180 181
182/* MIC_L_CTRL bit fields */
183#define DA9055_MIC_L_MUTE_EN (1 << 6)
184
185/* MIC_R_CTRL bit fields */
186#define DA9055_MIC_R_MUTE_EN (1 << 6)
187
181/* MIXIN_L_CTRL bit fields */ 188/* MIXIN_L_CTRL bit fields */
182#define DA9055_MIXIN_L_MIX_EN (1 << 3) 189#define DA9055_MIXIN_L_MIX_EN (1 << 3)
183 190
@@ -476,7 +483,7 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol,
476 struct snd_ctl_elem_value *ucontrol) 483 struct snd_ctl_elem_value *ucontrol)
477{ 484{
478 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 485 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
479 u8 reg_val, adc_left, adc_right; 486 u8 reg_val, adc_left, adc_right, mic_left, mic_right;
480 int avg_left_data, avg_right_data, offset_l, offset_r; 487 int avg_left_data, avg_right_data, offset_l, offset_r;
481 488
482 if (ucontrol->value.integer.value[0]) { 489 if (ucontrol->value.integer.value[0]) {
@@ -485,6 +492,16 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol,
485 * offsets must be done first 492 * offsets must be done first
486 */ 493 */
487 494
495 /* Save current values from Mic control registers */
496 mic_left = snd_soc_read(codec, DA9055_MIC_L_CTRL);
497 mic_right = snd_soc_read(codec, DA9055_MIC_R_CTRL);
498
499 /* Mute Mic PGA Left and Right */
500 snd_soc_update_bits(codec, DA9055_MIC_L_CTRL,
501 DA9055_MIC_L_MUTE_EN, DA9055_MIC_L_MUTE_EN);
502 snd_soc_update_bits(codec, DA9055_MIC_R_CTRL,
503 DA9055_MIC_R_MUTE_EN, DA9055_MIC_R_MUTE_EN);
504
488 /* Save current values from ADC control registers */ 505 /* Save current values from ADC control registers */
489 adc_left = snd_soc_read(codec, DA9055_ADC_L_CTRL); 506 adc_left = snd_soc_read(codec, DA9055_ADC_L_CTRL);
490 adc_right = snd_soc_read(codec, DA9055_ADC_R_CTRL); 507 adc_right = snd_soc_read(codec, DA9055_ADC_R_CTRL);
@@ -520,6 +537,10 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol,
520 /* Restore original values of ADC control registers */ 537 /* Restore original values of ADC control registers */
521 snd_soc_write(codec, DA9055_ADC_L_CTRL, adc_left); 538 snd_soc_write(codec, DA9055_ADC_L_CTRL, adc_left);
522 snd_soc_write(codec, DA9055_ADC_R_CTRL, adc_right); 539 snd_soc_write(codec, DA9055_ADC_R_CTRL, adc_right);
540
541 /* Restore original values of Mic control registers */
542 snd_soc_write(codec, DA9055_MIC_L_CTRL, mic_left);
543 snd_soc_write(codec, DA9055_MIC_R_CTRL, mic_right);
523 } 544 }
524 545
525 return snd_soc_put_volsw(kcontrol, ucontrol); 546 return snd_soc_put_volsw(kcontrol, ucontrol);
@@ -732,6 +753,17 @@ static const struct snd_kcontrol_new da9055_dapm_mixoutr_controls[] = {
732 6, 1, 0), 753 6, 1, 0),
733}; 754};
734 755
756/* Headphone Output Enable */
757static const struct snd_kcontrol_new da9055_dapm_hp_l_control =
758SOC_DAPM_SINGLE("Switch", DA9055_HP_L_CTRL, 3, 1, 0);
759
760static const struct snd_kcontrol_new da9055_dapm_hp_r_control =
761SOC_DAPM_SINGLE("Switch", DA9055_HP_R_CTRL, 3, 1, 0);
762
763/* Lineout Output Enable */
764static const struct snd_kcontrol_new da9055_dapm_lineout_control =
765SOC_DAPM_SINGLE("Switch", DA9055_LINE_CTRL, 3, 1, 0);
766
735/* DAPM widgets */ 767/* DAPM widgets */
736static const struct snd_soc_dapm_widget da9055_dapm_widgets[] = { 768static const struct snd_soc_dapm_widget da9055_dapm_widgets[] = {
737 /* Input Side */ 769 /* Input Side */
@@ -796,6 +828,14 @@ static const struct snd_soc_dapm_widget da9055_dapm_widgets[] = {
796 &da9055_dapm_mixoutr_controls[0], 828 &da9055_dapm_mixoutr_controls[0],
797 ARRAY_SIZE(da9055_dapm_mixoutr_controls)), 829 ARRAY_SIZE(da9055_dapm_mixoutr_controls)),
798 830
831 /* Output Enable Switches */
832 SND_SOC_DAPM_SWITCH("Headphone Left Enable", SND_SOC_NOPM, 0, 0,
833 &da9055_dapm_hp_l_control),
834 SND_SOC_DAPM_SWITCH("Headphone Right Enable", SND_SOC_NOPM, 0, 0,
835 &da9055_dapm_hp_r_control),
836 SND_SOC_DAPM_SWITCH("Lineout Enable", SND_SOC_NOPM, 0, 0,
837 &da9055_dapm_lineout_control),
838
799 /* Output PGAs */ 839 /* Output PGAs */
800 SND_SOC_DAPM_PGA("MIXOUT Left", DA9055_MIXOUT_L_CTRL, 7, 0, NULL, 0), 840 SND_SOC_DAPM_PGA("MIXOUT Left", DA9055_MIXOUT_L_CTRL, 7, 0, NULL, 0),
801 SND_SOC_DAPM_PGA("MIXOUT Right", DA9055_MIXOUT_R_CTRL, 7, 0, NULL, 0), 841 SND_SOC_DAPM_PGA("MIXOUT Right", DA9055_MIXOUT_R_CTRL, 7, 0, NULL, 0),
@@ -881,17 +921,20 @@ static const struct snd_soc_dapm_route da9055_audio_map[] = {
881 {"Out Mixer Right", "DAC Right Switch", "DAC Right"}, 921 {"Out Mixer Right", "DAC Right Switch", "DAC Right"},
882 922
883 {"MIXOUT Left", NULL, "Out Mixer Left"}, 923 {"MIXOUT Left", NULL, "Out Mixer Left"},
884 {"Headphone Left", NULL, "MIXOUT Left"}, 924 {"Headphone Left Enable", "Switch", "MIXOUT Left"},
925 {"Headphone Left", NULL, "Headphone Left Enable"},
885 {"Headphone Left", NULL, "Charge Pump"}, 926 {"Headphone Left", NULL, "Charge Pump"},
886 {"HPL", NULL, "Headphone Left"}, 927 {"HPL", NULL, "Headphone Left"},
887 928
888 {"MIXOUT Right", NULL, "Out Mixer Right"}, 929 {"MIXOUT Right", NULL, "Out Mixer Right"},
889 {"Headphone Right", NULL, "MIXOUT Right"}, 930 {"Headphone Right Enable", "Switch", "MIXOUT Right"},
931 {"Headphone Right", NULL, "Headphone Right Enable"},
890 {"Headphone Right", NULL, "Charge Pump"}, 932 {"Headphone Right", NULL, "Charge Pump"},
891 {"HPR", NULL, "Headphone Right"}, 933 {"HPR", NULL, "Headphone Right"},
892 934
893 {"MIXOUT Right", NULL, "Out Mixer Right"}, 935 {"MIXOUT Right", NULL, "Out Mixer Right"},
894 {"Lineout", NULL, "MIXOUT Right"}, 936 {"Lineout Enable", "Switch", "MIXOUT Right"},
937 {"Lineout", NULL, "Lineout Enable"},
895 {"LINE", NULL, "Lineout"}, 938 {"LINE", NULL, "Lineout"},
896}; 939};
897 940
@@ -1155,6 +1198,9 @@ static int da9055_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
1155 case SND_SOC_DAIFMT_RIGHT_J: 1198 case SND_SOC_DAIFMT_RIGHT_J:
1156 aif_ctrl = DA9055_AIF_FORMAT_RIGHT_J; 1199 aif_ctrl = DA9055_AIF_FORMAT_RIGHT_J;
1157 break; 1200 break;
1201 case SND_SOC_DAIFMT_DSP_A:
1202 aif_ctrl = DA9055_AIF_FORMAT_DSP;
1203 break;
1158 default: 1204 default:
1159 return -EINVAL; 1205 return -EINVAL;
1160 } 1206 }
@@ -1370,8 +1416,7 @@ static int da9055_probe(struct snd_soc_codec *codec)
1370 DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); 1416 DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
1371 1417
1372 /* 1418 /*
1373 * There are two separate control bits for input and output mixers as 1419 * There are two separate control bits for input and output mixers.
1374 * well as headphone and line outs.
1375 * One to enable corresponding amplifier and other to enable its 1420 * One to enable corresponding amplifier and other to enable its
1376 * output. As amplifier bits are related to power control, they are 1421 * output. As amplifier bits are related to power control, they are
1377 * being managed by DAPM while other (non power related) bits are 1422 * being managed by DAPM while other (non power related) bits are
@@ -1387,14 +1432,6 @@ static int da9055_probe(struct snd_soc_codec *codec)
1387 snd_soc_update_bits(codec, DA9055_MIXOUT_R_CTRL, 1432 snd_soc_update_bits(codec, DA9055_MIXOUT_R_CTRL,
1388 DA9055_MIXOUT_R_MIX_EN, DA9055_MIXOUT_R_MIX_EN); 1433 DA9055_MIXOUT_R_MIX_EN, DA9055_MIXOUT_R_MIX_EN);
1389 1434
1390 snd_soc_update_bits(codec, DA9055_HP_L_CTRL,
1391 DA9055_HP_L_AMP_OE, DA9055_HP_L_AMP_OE);
1392 snd_soc_update_bits(codec, DA9055_HP_R_CTRL,
1393 DA9055_HP_R_AMP_OE, DA9055_HP_R_AMP_OE);
1394
1395 snd_soc_update_bits(codec, DA9055_LINE_CTRL,
1396 DA9055_LINE_AMP_OE, DA9055_LINE_AMP_OE);
1397
1398 /* Set this as per your system configuration */ 1435 /* Set this as per your system configuration */
1399 snd_soc_write(codec, DA9055_PLL_CTRL, DA9055_PLL_INDIV_10_20_MHZ); 1436 snd_soc_write(codec, DA9055_PLL_CTRL, DA9055_PLL_INDIV_10_20_MHZ);
1400 1437
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index e8f97af75928..00b85cc1b9a3 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -820,10 +820,10 @@ static const struct snd_soc_dapm_route intercon[] = {
820 {"VIBRA DAC", NULL, "Vibra Playback"}, 820 {"VIBRA DAC", NULL, "Vibra Playback"},
821 821
822 /* ADC -> Stream mapping */ 822 /* ADC -> Stream mapping */
823 {"ADC Left", NULL, "Legacy Capture"}, 823 {"Legacy Capture" , NULL, "ADC Left"},
824 {"ADC Left", NULL, "Capture"}, 824 {"Capture", NULL, "ADC Left"},
825 {"ADC Right", NULL, "Legacy Capture"}, 825 {"Legacy Capture", NULL, "ADC Right"},
826 {"ADC Right", NULL, "Capture"}, 826 {"Capture" , NULL, "ADC Right"},
827 827
828 /* Capture path */ 828 /* Capture path */
829 {"Analog Left Capture Route", "Headset Mic", "HSMIC"}, 829 {"Analog Left Capture Route", "Headset Mic", "HSMIC"},
diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
index efa93dbb0191..06d4e612a164 100644
--- a/sound/soc/codecs/wm2200.c
+++ b/sound/soc/codecs/wm2200.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/pm.h> 17#include <linux/pm.h>
18#include <linux/firmware.h>
18#include <linux/gcd.h> 19#include <linux/gcd.h>
19#include <linux/gpio.h> 20#include <linux/gpio.h>
20#include <linux/i2c.h> 21#include <linux/i2c.h>
@@ -32,6 +33,39 @@
32#include <sound/wm2200.h> 33#include <sound/wm2200.h>
33 34
34#include "wm2200.h" 35#include "wm2200.h"
36#include "wmfw.h"
37
38#define WM2200_DSP_CONTROL_1 0x00
39#define WM2200_DSP_CONTROL_2 0x02
40#define WM2200_DSP_CONTROL_3 0x03
41#define WM2200_DSP_CONTROL_4 0x04
42#define WM2200_DSP_CONTROL_5 0x06
43#define WM2200_DSP_CONTROL_6 0x07
44#define WM2200_DSP_CONTROL_7 0x08
45#define WM2200_DSP_CONTROL_8 0x09
46#define WM2200_DSP_CONTROL_9 0x0A
47#define WM2200_DSP_CONTROL_10 0x0B
48#define WM2200_DSP_CONTROL_11 0x0C
49#define WM2200_DSP_CONTROL_12 0x0D
50#define WM2200_DSP_CONTROL_13 0x0F
51#define WM2200_DSP_CONTROL_14 0x10
52#define WM2200_DSP_CONTROL_15 0x11
53#define WM2200_DSP_CONTROL_16 0x12
54#define WM2200_DSP_CONTROL_17 0x13
55#define WM2200_DSP_CONTROL_18 0x14
56#define WM2200_DSP_CONTROL_19 0x16
57#define WM2200_DSP_CONTROL_20 0x17
58#define WM2200_DSP_CONTROL_21 0x18
59#define WM2200_DSP_CONTROL_22 0x1A
60#define WM2200_DSP_CONTROL_23 0x1B
61#define WM2200_DSP_CONTROL_24 0x1C
62#define WM2200_DSP_CONTROL_25 0x1E
63#define WM2200_DSP_CONTROL_26 0x20
64#define WM2200_DSP_CONTROL_27 0x21
65#define WM2200_DSP_CONTROL_28 0x22
66#define WM2200_DSP_CONTROL_29 0x23
67#define WM2200_DSP_CONTROL_30 0x24
68#define WM2200_DSP_CONTROL_31 0x26
35 69
36/* The code assumes DCVDD is generated internally */ 70/* The code assumes DCVDD is generated internally */
37#define WM2200_NUM_CORE_SUPPLIES 2 71#define WM2200_NUM_CORE_SUPPLIES 2
@@ -64,6 +98,66 @@ struct wm2200_priv {
64 int sysclk; 98 int sysclk;
65}; 99};
66 100
101#define WM2200_DSP_RANGE_BASE (WM2200_MAX_REGISTER + 1)
102#define WM2200_DSP_SPACING 12288
103
104#define WM2200_DSP1_DM_BASE (WM2200_DSP_RANGE_BASE + (0 * WM2200_DSP_SPACING))
105#define WM2200_DSP1_PM_BASE (WM2200_DSP_RANGE_BASE + (1 * WM2200_DSP_SPACING))
106#define WM2200_DSP1_ZM_BASE (WM2200_DSP_RANGE_BASE + (2 * WM2200_DSP_SPACING))
107#define WM2200_DSP2_DM_BASE (WM2200_DSP_RANGE_BASE + (3 * WM2200_DSP_SPACING))
108#define WM2200_DSP2_PM_BASE (WM2200_DSP_RANGE_BASE + (4 * WM2200_DSP_SPACING))
109#define WM2200_DSP2_ZM_BASE (WM2200_DSP_RANGE_BASE + (5 * WM2200_DSP_SPACING))
110
111static const struct regmap_range_cfg wm2200_ranges[] = {
112 /* DSP1 DM */
113 { .range_min = WM2200_DSP1_DM_BASE,
114 .range_max = WM2200_DSP1_DM_BASE + 12287,
115 .selector_reg = WM2200_DSP1_CONTROL_3,
116 .selector_mask = WM2200_DSP1_PAGE_BASE_DM_0_MASK,
117 .selector_shift = WM2200_DSP1_PAGE_BASE_DM_0_SHIFT,
118 .window_start = WM2200_DSP1_DM_0, .window_len = 2048, },
119
120 /* DSP1 PM */
121 { .range_min = WM2200_DSP1_PM_BASE,
122 .range_max = WM2200_DSP1_PM_BASE + 12287,
123 .selector_reg = WM2200_DSP1_CONTROL_2,
124 .selector_mask = WM2200_DSP1_PAGE_BASE_PM_0_MASK,
125 .selector_shift = WM2200_DSP1_PAGE_BASE_PM_0_SHIFT,
126 .window_start = WM2200_DSP1_PM_0, .window_len = 768, },
127
128 /* DSP1 ZM */
129 { .range_min = WM2200_DSP1_ZM_BASE,
130 .range_max = WM2200_DSP1_ZM_BASE + 2047,
131 .selector_reg = WM2200_DSP1_CONTROL_4,
132 .selector_mask = WM2200_DSP1_PAGE_BASE_ZM_0_MASK,
133 .selector_shift = WM2200_DSP1_PAGE_BASE_ZM_0_SHIFT,
134 .window_start = WM2200_DSP1_ZM_0, .window_len = 1024, },
135
136 /* DSP2 DM */
137 { .range_min = WM2200_DSP2_DM_BASE,
138 .range_max = WM2200_DSP2_DM_BASE + 4095,
139 .selector_reg = WM2200_DSP2_CONTROL_3,
140 .selector_mask = WM2200_DSP2_PAGE_BASE_DM_0_MASK,
141 .selector_shift = WM2200_DSP2_PAGE_BASE_DM_0_SHIFT,
142 .window_start = WM2200_DSP2_DM_0, .window_len = 2048, },
143
144 /* DSP2 PM */
145 { .range_min = WM2200_DSP2_PM_BASE,
146 .range_max = WM2200_DSP2_PM_BASE + 11287,
147 .selector_reg = WM2200_DSP2_CONTROL_2,
148 .selector_mask = WM2200_DSP2_PAGE_BASE_PM_0_MASK,
149 .selector_shift = WM2200_DSP2_PAGE_BASE_PM_0_SHIFT,
150 .window_start = WM2200_DSP2_PM_0, .window_len = 768, },
151
152 /* DSP2 ZM */
153 { .range_min = WM2200_DSP2_ZM_BASE,
154 .range_max = WM2200_DSP2_ZM_BASE + 2047,
155 .selector_reg = WM2200_DSP2_CONTROL_4,
156 .selector_mask = WM2200_DSP2_PAGE_BASE_ZM_0_MASK,
157 .selector_shift = WM2200_DSP2_PAGE_BASE_ZM_0_SHIFT,
158 .window_start = WM2200_DSP2_ZM_0, .window_len = 1024, },
159};
160
67static struct reg_default wm2200_reg_defaults[] = { 161static struct reg_default wm2200_reg_defaults[] = {
68 { 0x000B, 0x0000 }, /* R11 - Tone Generator 1 */ 162 { 0x000B, 0x0000 }, /* R11 - Tone Generator 1 */
69 { 0x0102, 0x0000 }, /* R258 - Clocking 3 */ 163 { 0x0102, 0x0000 }, /* R258 - Clocking 3 */
@@ -407,6 +501,16 @@ static struct reg_default wm2200_reg_defaults[] = {
407 501
408static bool wm2200_volatile_register(struct device *dev, unsigned int reg) 502static bool wm2200_volatile_register(struct device *dev, unsigned int reg)
409{ 503{
504 int i;
505
506 for (i = 0; i < ARRAY_SIZE(wm2200_ranges); i++)
507 if ((reg >= wm2200_ranges[i].window_start &&
508 reg <= wm2200_ranges[i].window_start +
509 wm2200_ranges[i].window_len) ||
510 (reg >= wm2200_ranges[i].range_min &&
511 reg <= wm2200_ranges[i].range_max))
512 return true;
513
410 switch (reg) { 514 switch (reg) {
411 case WM2200_SOFTWARE_RESET: 515 case WM2200_SOFTWARE_RESET:
412 case WM2200_DEVICE_REVISION: 516 case WM2200_DEVICE_REVISION:
@@ -423,6 +527,16 @@ static bool wm2200_volatile_register(struct device *dev, unsigned int reg)
423 527
424static bool wm2200_readable_register(struct device *dev, unsigned int reg) 528static bool wm2200_readable_register(struct device *dev, unsigned int reg)
425{ 529{
530 int i;
531
532 for (i = 0; i < ARRAY_SIZE(wm2200_ranges); i++)
533 if ((reg >= wm2200_ranges[i].window_start &&
534 reg <= wm2200_ranges[i].window_start +
535 wm2200_ranges[i].window_len) ||
536 (reg >= wm2200_ranges[i].range_min &&
537 reg <= wm2200_ranges[i].range_max))
538 return true;
539
426 switch (reg) { 540 switch (reg) {
427 case WM2200_SOFTWARE_RESET: 541 case WM2200_SOFTWARE_RESET:
428 case WM2200_DEVICE_REVISION: 542 case WM2200_DEVICE_REVISION:
@@ -873,6 +987,400 @@ static int wm2200_reset(struct wm2200_priv *wm2200)
873 } 987 }
874} 988}
875 989
990static int wm2200_dsp_load(struct snd_soc_codec *codec, int base)
991{
992 const struct firmware *firmware;
993 struct regmap *regmap = codec->control_data;
994 unsigned int pos = 0;
995 const struct wmfw_header *header;
996 const struct wmfw_adsp1_sizes *adsp1_sizes;
997 const struct wmfw_footer *footer;
998 const struct wmfw_region *region;
999 const char *file, *region_name;
1000 char *text;
1001 unsigned int dm, pm, zm, reg;
1002 int regions = 0;
1003 int ret, offset, type;
1004
1005 switch (base) {
1006 case WM2200_DSP1_CONTROL_1:
1007 file = "wm2200-dsp1.wmfw";
1008 dm = WM2200_DSP1_DM_BASE;
1009 pm = WM2200_DSP1_PM_BASE;
1010 zm = WM2200_DSP1_ZM_BASE;
1011 break;
1012 case WM2200_DSP2_CONTROL_1:
1013 file = "wm2200-dsp2.wmfw";
1014 dm = WM2200_DSP2_DM_BASE;
1015 pm = WM2200_DSP2_PM_BASE;
1016 zm = WM2200_DSP2_ZM_BASE;
1017 break;
1018 default:
1019 dev_err(codec->dev, "BASE %x\n", base);
1020 BUG_ON(1);
1021 return -EINVAL;
1022 }
1023
1024 ret = request_firmware(&firmware, file, codec->dev);
1025 if (ret != 0) {
1026 dev_err(codec->dev, "Failed to request '%s'\n", file);
1027 return ret;
1028 }
1029
1030 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
1031 if (pos >= firmware->size) {
1032 dev_err(codec->dev, "%s: file too short, %d bytes\n",
1033 file, firmware->size);
1034 return -EINVAL;
1035 }
1036
1037 header = (void*)&firmware->data[0];
1038
1039 if (memcmp(&header->magic[0], "WMFW", 4) != 0) {
1040 dev_err(codec->dev, "%s: invalid magic\n", file);
1041 return -EINVAL;
1042 }
1043
1044 if (header->ver != 0) {
1045 dev_err(codec->dev, "%s: unknown file format %d\n",
1046 file, header->ver);
1047 return -EINVAL;
1048 }
1049
1050 if (le32_to_cpu(header->len) != sizeof(*header) +
1051 sizeof(*adsp1_sizes) + sizeof(*footer)) {
1052 dev_err(codec->dev, "%s: unexpected header length %d\n",
1053 file, le32_to_cpu(header->len));
1054 return -EINVAL;
1055 }
1056
1057 if (header->core != WMFW_ADSP1) {
1058 dev_err(codec->dev, "%s: invalid core %d\n",
1059 file, header->core);
1060 return -EINVAL;
1061 }
1062
1063 adsp1_sizes = (void *)&(header[1]);
1064 footer = (void *)&(adsp1_sizes[1]);
1065
1066 dev_dbg(codec->dev, "%s: %d DM, %d PM, %d ZM\n",
1067 file, le32_to_cpu(adsp1_sizes->dm),
1068 le32_to_cpu(adsp1_sizes->pm), le32_to_cpu(adsp1_sizes->zm));
1069
1070 dev_dbg(codec->dev, "%s: timestamp %llu\n", file,
1071 le64_to_cpu(footer->timestamp));
1072
1073 while (pos < firmware->size &&
1074 pos - firmware->size > sizeof(*region)) {
1075 region = (void *)&(firmware->data[pos]);
1076 region_name = "Unknown";
1077 reg = 0;
1078 text = NULL;
1079 offset = le32_to_cpu(region->offset) & 0xffffff;
1080 type = be32_to_cpu(region->type) & 0xff;
1081
1082 switch (type) {
1083 case WMFW_NAME_TEXT:
1084 region_name = "Firmware name";
1085 text = kzalloc(le32_to_cpu(region->len) + 1,
1086 GFP_KERNEL);
1087 break;
1088 case WMFW_INFO_TEXT:
1089 region_name = "Information";
1090 text = kzalloc(le32_to_cpu(region->len) + 1,
1091 GFP_KERNEL);
1092 break;
1093 case WMFW_ABSOLUTE:
1094 region_name = "Absolute";
1095 reg = offset;
1096 break;
1097 case WMFW_ADSP1_PM:
1098 region_name = "PM";
1099 reg = pm + (offset * 3);
1100 break;
1101 case WMFW_ADSP1_DM:
1102 region_name = "DM";
1103 reg = dm + (offset * 2);
1104 break;
1105 case WMFW_ADSP1_ZM:
1106 region_name = "ZM";
1107 reg = zm + (offset * 2);
1108 break;
1109 default:
1110 dev_warn(codec->dev,
1111 "%s.%d: Unknown region type %x at %d(%x)\n",
1112 file, regions, type, pos, pos);
1113 break;
1114 }
1115
1116 dev_dbg(codec->dev, "%s.%d: %d bytes at %d in %s\n", file,
1117 regions, le32_to_cpu(region->len), offset,
1118 region_name);
1119
1120 if (text) {
1121 memcpy(text, region->data, le32_to_cpu(region->len));
1122 dev_info(codec->dev, "%s: %s\n", file, text);
1123 kfree(text);
1124 }
1125
1126 if (reg) {
1127 ret = regmap_raw_write(regmap, reg, region->data,
1128 le32_to_cpu(region->len));
1129 if (ret != 0) {
1130 dev_err(codec->dev,
1131 "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
1132 file, regions,
1133 le32_to_cpu(region->len), offset,
1134 region_name, ret);
1135 goto out;
1136 }
1137 }
1138
1139 pos += le32_to_cpu(region->len) + sizeof(*region);
1140 regions++;
1141 }
1142
1143 if (pos > firmware->size)
1144 dev_warn(codec->dev, "%s.%d: %d bytes at end of file\n",
1145 file, regions, pos - firmware->size);
1146
1147out:
1148 release_firmware(firmware);
1149
1150 return ret;
1151}
1152
1153static int wm2200_setup_algs(struct snd_soc_codec *codec, int base)
1154{
1155 struct regmap *regmap = codec->control_data;
1156 struct wmfw_adsp1_id_hdr id;
1157 struct wmfw_adsp1_alg_hdr *alg;
1158 size_t algs;
1159 int zm, dm, pm, ret, i;
1160 __be32 val;
1161
1162 switch (base) {
1163 case WM2200_DSP1_CONTROL_1:
1164 dm = WM2200_DSP1_DM_BASE;
1165 pm = WM2200_DSP1_PM_BASE;
1166 zm = WM2200_DSP1_ZM_BASE;
1167 break;
1168 case WM2200_DSP2_CONTROL_1:
1169 dm = WM2200_DSP2_DM_BASE;
1170 pm = WM2200_DSP2_PM_BASE;
1171 zm = WM2200_DSP2_ZM_BASE;
1172 break;
1173 default:
1174 dev_err(codec->dev, "BASE %x\n", base);
1175 BUG_ON(1);
1176 return -EINVAL;
1177 }
1178
1179 ret = regmap_raw_read(regmap, dm, &id, sizeof(id));
1180 if (ret != 0) {
1181 dev_err(codec->dev, "Failed to read algorithm info: %d\n",
1182 ret);
1183 return ret;
1184 }
1185
1186 algs = be32_to_cpu(id.algs);
1187 dev_info(codec->dev, "Firmware: %x v%d.%d.%d, %d algorithms\n",
1188 be32_to_cpu(id.fw.id),
1189 (be32_to_cpu(id.fw.ver) & 0xff000) >> 16,
1190 (be32_to_cpu(id.fw.ver) & 0xff00) >> 8,
1191 be32_to_cpu(id.fw.ver) & 0xff,
1192 algs);
1193
1194 /* Read the terminator first to validate the length */
1195 ret = regmap_raw_read(regmap, dm +
1196 (sizeof(id) + (algs * sizeof(*alg))) / 2,
1197 &val, sizeof(val));
1198 if (ret != 0) {
1199 dev_err(codec->dev, "Failed to read algorithm list end: %d\n",
1200 ret);
1201 return ret;
1202 }
1203
1204 if (be32_to_cpu(val) != 0xbedead)
1205 dev_warn(codec->dev, "Algorithm list end %x 0x%x != 0xbeadead\n",
1206 (sizeof(id) + (algs * sizeof(*alg))) / 2,
1207 be32_to_cpu(val));
1208
1209 alg = kzalloc(sizeof(*alg) * algs, GFP_KERNEL);
1210 if (!alg)
1211 return -ENOMEM;
1212
1213 ret = regmap_raw_read(regmap, dm + (sizeof(id) / 2),
1214 alg, algs * sizeof(*alg));
1215 if (ret != 0) {
1216 dev_err(codec->dev, "Failed to read algorithm list: %d\n",
1217 ret);
1218 goto out;
1219 }
1220
1221 for (i = 0; i < algs; i++) {
1222 dev_info(codec->dev, "%d: ID %x v%d.%d.%d\n",
1223 i, be32_to_cpu(alg[i].alg.id),
1224 (be32_to_cpu(alg[i].alg.ver) & 0xff000) >> 16,
1225 (be32_to_cpu(alg[i].alg.ver) & 0xff00) >> 8,
1226 be32_to_cpu(alg[i].alg.ver) & 0xff);
1227 }
1228
1229out:
1230 kfree(alg);
1231 return ret;
1232}
1233
1234static int wm2200_load_coeff(struct snd_soc_codec *codec, int base)
1235{
1236 struct regmap *regmap = codec->control_data;
1237 struct wmfw_coeff_hdr *hdr;
1238 struct wmfw_coeff_item *blk;
1239 const struct firmware *firmware;
1240 const char *file, *region_name;
1241 int ret, dm, pm, zm, pos, blocks, type, offset, reg;
1242
1243 switch (base) {
1244 case WM2200_DSP1_CONTROL_1:
1245 file = "wm2200-dsp1.bin";
1246 dm = WM2200_DSP1_DM_BASE;
1247 pm = WM2200_DSP1_PM_BASE;
1248 zm = WM2200_DSP1_ZM_BASE;
1249 break;
1250 case WM2200_DSP2_CONTROL_1:
1251 file = "wm2200-dsp2.bin";
1252 dm = WM2200_DSP2_DM_BASE;
1253 pm = WM2200_DSP2_PM_BASE;
1254 zm = WM2200_DSP2_ZM_BASE;
1255 break;
1256 default:
1257 dev_err(codec->dev, "BASE %x\n", base);
1258 BUG_ON(1);
1259 return -EINVAL;
1260 }
1261
1262 ret = request_firmware(&firmware, file, codec->dev);
1263 if (ret != 0) {
1264 dev_err(codec->dev, "Failed to request '%s'\n", file);
1265 return ret;
1266 }
1267
1268 if (sizeof(*hdr) >= firmware->size) {
1269 dev_err(codec->dev, "%s: file too short, %d bytes\n",
1270 file, firmware->size);
1271 return -EINVAL;
1272 }
1273
1274 hdr = (void*)&firmware->data[0];
1275 if (memcmp(hdr->magic, "WMDR", 4) != 0) {
1276 dev_err(codec->dev, "%s: invalid magic\n", file);
1277 return -EINVAL;
1278 }
1279
1280 dev_dbg(codec->dev, "%s: v%d.%d.%d\n", file,
1281 (le32_to_cpu(hdr->ver) >> 16) & 0xff,
1282 (le32_to_cpu(hdr->ver) >> 8) & 0xff,
1283 le32_to_cpu(hdr->ver) & 0xff);
1284
1285 pos = le32_to_cpu(hdr->len);
1286
1287 blocks = 0;
1288 while (pos < firmware->size &&
1289 pos - firmware->size > sizeof(*blk)) {
1290 blk = (void*)(&firmware->data[pos]);
1291
1292 type = be32_to_cpu(blk->type) & 0xff;
1293 offset = le32_to_cpu(blk->offset) & 0xffffff;
1294
1295 dev_dbg(codec->dev, "%s.%d: %x v%d.%d.%d\n",
1296 file, blocks, le32_to_cpu(blk->id),
1297 (le32_to_cpu(blk->ver) >> 16) & 0xff,
1298 (le32_to_cpu(blk->ver) >> 8) & 0xff,
1299 le32_to_cpu(blk->ver) & 0xff);
1300 dev_dbg(codec->dev, "%s.%d: %d bytes at 0x%x in %x\n",
1301 file, blocks, le32_to_cpu(blk->len), offset, type);
1302
1303 reg = 0;
1304 region_name = "Unknown";
1305 switch (type) {
1306 case WMFW_NAME_TEXT:
1307 case WMFW_INFO_TEXT:
1308 break;
1309 case WMFW_ABSOLUTE:
1310 region_name = "register";
1311 reg = offset;
1312 break;
1313 default:
1314 dev_err(codec->dev, "Unknown region type %x\n", type);
1315 break;
1316 }
1317
1318 if (reg) {
1319 ret = regmap_raw_write(regmap, reg, blk->data,
1320 le32_to_cpu(blk->len));
1321 if (ret != 0) {
1322 dev_err(codec->dev,
1323 "%s.%d: Failed to write to %x in %s\n",
1324 file, blocks, reg, region_name);
1325 }
1326 }
1327
1328 pos += le32_to_cpu(blk->len) + sizeof(*blk);
1329 blocks++;
1330 }
1331
1332 if (pos > firmware->size)
1333 dev_warn(codec->dev, "%s.%d: %d bytes at end of file\n",
1334 file, blocks, pos - firmware->size);
1335
1336 return 0;
1337}
1338
1339static int wm2200_dsp_ev(struct snd_soc_dapm_widget *w,
1340 struct snd_kcontrol *kcontrol,
1341 int event)
1342{
1343 struct snd_soc_codec *codec = w->codec;
1344 int base = w->reg - WM2200_DSP_CONTROL_30;
1345 int ret;
1346
1347 switch (event) {
1348 case SND_SOC_DAPM_POST_PMU:
1349 ret = wm2200_dsp_load(codec, base);
1350 if (ret != 0)
1351 return ret;
1352
1353 ret = wm2200_setup_algs(codec, base);
1354 if (ret != 0)
1355 return ret;
1356
1357 ret = wm2200_load_coeff(codec, base);
1358 if (ret != 0)
1359 return ret;
1360
1361 /* Start the core running */
1362 snd_soc_update_bits(codec, w->reg,
1363 WM2200_DSP1_CORE_ENA | WM2200_DSP1_START,
1364 WM2200_DSP1_CORE_ENA | WM2200_DSP1_START);
1365 break;
1366
1367 case SND_SOC_DAPM_PRE_PMD:
1368 /* Halt the core */
1369 snd_soc_update_bits(codec, w->reg,
1370 WM2200_DSP1_CORE_ENA | WM2200_DSP1_START,
1371 0);
1372
1373 snd_soc_update_bits(codec, base + WM2200_DSP_CONTROL_19,
1374 WM2200_DSP1_WDMA_BUFFER_LENGTH_MASK, 0);
1375 break;
1376
1377 default:
1378 break;
1379 }
1380
1381 return 0;
1382}
1383
876static DECLARE_TLV_DB_SCALE(in_tlv, -6300, 100, 0); 1384static DECLARE_TLV_DB_SCALE(in_tlv, -6300, 100, 0);
877static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0); 1385static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
878static DECLARE_TLV_DB_SCALE(out_tlv, -6400, 100, 0); 1386static DECLARE_TLV_DB_SCALE(out_tlv, -6400, 100, 0);
@@ -880,7 +1388,7 @@ static DECLARE_TLV_DB_SCALE(out_tlv, -6400, 100, 0);
880static const char *wm2200_mixer_texts[] = { 1388static const char *wm2200_mixer_texts[] = {
881 "None", 1389 "None",
882 "Tone Generator", 1390 "Tone Generator",
883 "AEC loopback", 1391 "AEC Loopback",
884 "IN1L", 1392 "IN1L",
885 "IN1R", 1393 "IN1R",
886 "IN2L", 1394 "IN2L",
@@ -976,6 +1484,20 @@ static int wm2200_mixer_values[] = {
976 static WM2200_MUX_CTL_DECL(name##_in3); \ 1484 static WM2200_MUX_CTL_DECL(name##_in3); \
977 static WM2200_MUX_CTL_DECL(name##_in4) 1485 static WM2200_MUX_CTL_DECL(name##_in4)
978 1486
1487#define WM2200_DSP_ENUMS(name, base_reg) \
1488 static WM2200_MUX_ENUM_DECL(name##_aux1_enum, base_reg); \
1489 static WM2200_MUX_ENUM_DECL(name##_aux2_enum, base_reg + 1); \
1490 static WM2200_MUX_ENUM_DECL(name##_aux3_enum, base_reg + 2); \
1491 static WM2200_MUX_ENUM_DECL(name##_aux4_enum, base_reg + 3); \
1492 static WM2200_MUX_ENUM_DECL(name##_aux5_enum, base_reg + 4); \
1493 static WM2200_MUX_ENUM_DECL(name##_aux6_enum, base_reg + 5); \
1494 static WM2200_MUX_CTL_DECL(name##_aux1); \
1495 static WM2200_MUX_CTL_DECL(name##_aux2); \
1496 static WM2200_MUX_CTL_DECL(name##_aux3); \
1497 static WM2200_MUX_CTL_DECL(name##_aux4); \
1498 static WM2200_MUX_CTL_DECL(name##_aux5); \
1499 static WM2200_MUX_CTL_DECL(name##_aux6);
1500
979static const struct snd_kcontrol_new wm2200_snd_controls[] = { 1501static const struct snd_kcontrol_new wm2200_snd_controls[] = {
980SOC_SINGLE("IN1 High Performance Switch", WM2200_IN1L_CONTROL, 1502SOC_SINGLE("IN1 High Performance Switch", WM2200_IN1L_CONTROL,
981 WM2200_IN1_OSR_SHIFT, 1, 0), 1503 WM2200_IN1_OSR_SHIFT, 1, 0),
@@ -1028,7 +1550,7 @@ SOC_DOUBLE_R_TLV("OUT2 Digital Volume", WM2200_DAC_DIGITAL_VOLUME_2L,
1028 WM2200_DAC_DIGITAL_VOLUME_2R, WM2200_OUT2L_VOL_SHIFT, 0x9f, 0, 1550 WM2200_DAC_DIGITAL_VOLUME_2R, WM2200_OUT2L_VOL_SHIFT, 0x9f, 0,
1029 digital_tlv), 1551 digital_tlv),
1030SOC_DOUBLE("OUT2 Switch", WM2200_PDM_1, WM2200_SPK1L_MUTE_SHIFT, 1552SOC_DOUBLE("OUT2 Switch", WM2200_PDM_1, WM2200_SPK1L_MUTE_SHIFT,
1031 WM2200_SPK1R_MUTE_SHIFT, 1, 0), 1553 WM2200_SPK1R_MUTE_SHIFT, 1, 1),
1032}; 1554};
1033 1555
1034WM2200_MIXER_ENUMS(OUT1L, WM2200_OUT1LMIX_INPUT_1_SOURCE); 1556WM2200_MIXER_ENUMS(OUT1L, WM2200_OUT1LMIX_INPUT_1_SOURCE);
@@ -1051,6 +1573,9 @@ WM2200_MIXER_ENUMS(DSP1R, WM2200_DSP1RMIX_INPUT_1_SOURCE);
1051WM2200_MIXER_ENUMS(DSP2L, WM2200_DSP2LMIX_INPUT_1_SOURCE); 1573WM2200_MIXER_ENUMS(DSP2L, WM2200_DSP2LMIX_INPUT_1_SOURCE);
1052WM2200_MIXER_ENUMS(DSP2R, WM2200_DSP2RMIX_INPUT_1_SOURCE); 1574WM2200_MIXER_ENUMS(DSP2R, WM2200_DSP2RMIX_INPUT_1_SOURCE);
1053 1575
1576WM2200_DSP_ENUMS(DSP1, WM2200_DSP1AUX1MIX_INPUT_1_SOURCE);
1577WM2200_DSP_ENUMS(DSP2, WM2200_DSP2AUX1MIX_INPUT_1_SOURCE);
1578
1054WM2200_MIXER_ENUMS(LHPF1, WM2200_LHPF1MIX_INPUT_1_SOURCE); 1579WM2200_MIXER_ENUMS(LHPF1, WM2200_LHPF1MIX_INPUT_1_SOURCE);
1055WM2200_MIXER_ENUMS(LHPF2, WM2200_LHPF2MIX_INPUT_1_SOURCE); 1580WM2200_MIXER_ENUMS(LHPF2, WM2200_LHPF2MIX_INPUT_1_SOURCE);
1056 1581
@@ -1064,8 +1589,19 @@ WM2200_MIXER_ENUMS(LHPF2, WM2200_LHPF2MIX_INPUT_1_SOURCE);
1064 WM2200_MUX(name_str " Input 4", &name##_in4_mux), \ 1589 WM2200_MUX(name_str " Input 4", &name##_in4_mux), \
1065 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0) 1590 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0)
1066 1591
1592#define WM2200_DSP_WIDGETS(name, name_str) \
1593 WM2200_MIXER_WIDGETS(name##L, name_str "L"), \
1594 WM2200_MIXER_WIDGETS(name##R, name_str "R"), \
1595 WM2200_MUX(name_str " Aux 1", &name##_aux1_mux), \
1596 WM2200_MUX(name_str " Aux 2", &name##_aux2_mux), \
1597 WM2200_MUX(name_str " Aux 3", &name##_aux3_mux), \
1598 WM2200_MUX(name_str " Aux 4", &name##_aux4_mux), \
1599 WM2200_MUX(name_str " Aux 5", &name##_aux5_mux), \
1600 WM2200_MUX(name_str " Aux 6", &name##_aux6_mux)
1601
1067#define WM2200_MIXER_INPUT_ROUTES(name) \ 1602#define WM2200_MIXER_INPUT_ROUTES(name) \
1068 { name, "Tone Generator", "Tone Generator" }, \ 1603 { name, "Tone Generator", "Tone Generator" }, \
1604 { name, "AEC Loopback", "AEC Loopback" }, \
1069 { name, "IN1L", "IN1L PGA" }, \ 1605 { name, "IN1L", "IN1L PGA" }, \
1070 { name, "IN1R", "IN1R PGA" }, \ 1606 { name, "IN1R", "IN1R PGA" }, \
1071 { name, "IN2L", "IN2L PGA" }, \ 1607 { name, "IN2L", "IN2L PGA" }, \
@@ -1106,6 +1642,33 @@ WM2200_MIXER_ENUMS(LHPF2, WM2200_LHPF2MIX_INPUT_1_SOURCE);
1106 WM2200_MIXER_INPUT_ROUTES(name " Input 3"), \ 1642 WM2200_MIXER_INPUT_ROUTES(name " Input 3"), \
1107 WM2200_MIXER_INPUT_ROUTES(name " Input 4") 1643 WM2200_MIXER_INPUT_ROUTES(name " Input 4")
1108 1644
1645#define WM2200_DSP_AUX_ROUTES(name) \
1646 { name, NULL, name " Aux 1" }, \
1647 { name, NULL, name " Aux 2" }, \
1648 { name, NULL, name " Aux 3" }, \
1649 { name, NULL, name " Aux 4" }, \
1650 { name, NULL, name " Aux 5" }, \
1651 { name, NULL, name " Aux 6" }, \
1652 WM2200_MIXER_INPUT_ROUTES(name " Aux 1"), \
1653 WM2200_MIXER_INPUT_ROUTES(name " Aux 2"), \
1654 WM2200_MIXER_INPUT_ROUTES(name " Aux 3"), \
1655 WM2200_MIXER_INPUT_ROUTES(name " Aux 4"), \
1656 WM2200_MIXER_INPUT_ROUTES(name " Aux 5"), \
1657 WM2200_MIXER_INPUT_ROUTES(name " Aux 6")
1658
1659static const char *wm2200_aec_loopback_texts[] = {
1660 "OUT1L", "OUT1R", "OUT2L", "OUT2R",
1661};
1662
1663static const struct soc_enum wm2200_aec_loopback =
1664 SOC_ENUM_SINGLE(WM2200_DAC_AEC_CONTROL_1,
1665 WM2200_AEC_LOOPBACK_SRC_SHIFT,
1666 ARRAY_SIZE(wm2200_aec_loopback_texts),
1667 wm2200_aec_loopback_texts);
1668
1669static const struct snd_kcontrol_new wm2200_aec_loopback_mux =
1670 SOC_DAPM_ENUM("AEC Loopback", wm2200_aec_loopback);
1671
1109static const struct snd_soc_dapm_widget wm2200_dapm_widgets[] = { 1672static const struct snd_soc_dapm_widget wm2200_dapm_widgets[] = {
1110SND_SOC_DAPM_SUPPLY("SYSCLK", WM2200_CLOCKING_3, WM2200_SYSCLK_ENA_SHIFT, 0, 1673SND_SOC_DAPM_SUPPLY("SYSCLK", WM2200_CLOCKING_3, WM2200_SYSCLK_ENA_SHIFT, 0,
1111 NULL, 0), 1674 NULL, 0),
@@ -1165,8 +1728,12 @@ SND_SOC_DAPM_PGA("LHPF1", WM2200_HPLPF1_1, WM2200_LHPF1_ENA_SHIFT, 0,
1165SND_SOC_DAPM_PGA("LHPF2", WM2200_HPLPF2_1, WM2200_LHPF2_ENA_SHIFT, 0, 1728SND_SOC_DAPM_PGA("LHPF2", WM2200_HPLPF2_1, WM2200_LHPF2_ENA_SHIFT, 0,
1166 NULL, 0), 1729 NULL, 0),
1167 1730
1168SND_SOC_DAPM_PGA_E("DSP1", SND_SOC_NOPM, 0, 0, NULL, 0, NULL, 0), 1731SND_SOC_DAPM_PGA_E("DSP1", WM2200_DSP1_CONTROL_30, WM2200_DSP1_SYS_ENA_SHIFT,
1169SND_SOC_DAPM_PGA_E("DSP2", SND_SOC_NOPM, 1, 0, NULL, 0, NULL, 0), 1732 0, NULL, 0, wm2200_dsp_ev,
1733 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
1734SND_SOC_DAPM_PGA_E("DSP2", WM2200_DSP2_CONTROL_30, WM2200_DSP2_SYS_ENA_SHIFT,
1735 0, NULL, 0, wm2200_dsp_ev,
1736 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
1170 1737
1171SND_SOC_DAPM_AIF_OUT("AIF1TX1", "Capture", 0, 1738SND_SOC_DAPM_AIF_OUT("AIF1TX1", "Capture", 0,
1172 WM2200_AUDIO_IF_1_22, WM2200_AIF1TX1_ENA_SHIFT, 0), 1739 WM2200_AUDIO_IF_1_22, WM2200_AIF1TX1_ENA_SHIFT, 0),
@@ -1181,6 +1748,9 @@ SND_SOC_DAPM_AIF_OUT("AIF1TX5", "Capture", 4,
1181SND_SOC_DAPM_AIF_OUT("AIF1TX6", "Capture", 5, 1748SND_SOC_DAPM_AIF_OUT("AIF1TX6", "Capture", 5,
1182 WM2200_AUDIO_IF_1_22, WM2200_AIF1TX6_ENA_SHIFT, 0), 1749 WM2200_AUDIO_IF_1_22, WM2200_AIF1TX6_ENA_SHIFT, 0),
1183 1750
1751SND_SOC_DAPM_MUX("AEC Loopback", WM2200_DAC_AEC_CONTROL_1,
1752 WM2200_AEC_LOOPBACK_ENA_SHIFT, 0, &wm2200_aec_loopback_mux),
1753
1184SND_SOC_DAPM_PGA_S("OUT1L", 0, WM2200_OUTPUT_ENABLES, 1754SND_SOC_DAPM_PGA_S("OUT1L", 0, WM2200_OUTPUT_ENABLES,
1185 WM2200_OUT1L_ENA_SHIFT, 0, NULL, 0), 1755 WM2200_OUT1L_ENA_SHIFT, 0, NULL, 0),
1186SND_SOC_DAPM_PGA_S("OUT1R", 0, WM2200_OUTPUT_ENABLES, 1756SND_SOC_DAPM_PGA_S("OUT1R", 0, WM2200_OUTPUT_ENABLES,
@@ -1231,10 +1801,8 @@ WM2200_MIXER_WIDGETS(EQR, "EQR"),
1231WM2200_MIXER_WIDGETS(LHPF1, "LHPF1"), 1801WM2200_MIXER_WIDGETS(LHPF1, "LHPF1"),
1232WM2200_MIXER_WIDGETS(LHPF2, "LHPF2"), 1802WM2200_MIXER_WIDGETS(LHPF2, "LHPF2"),
1233 1803
1234WM2200_MIXER_WIDGETS(DSP1L, "DSP1L"), 1804WM2200_DSP_WIDGETS(DSP1, "DSP1"),
1235WM2200_MIXER_WIDGETS(DSP1R, "DSP1R"), 1805WM2200_DSP_WIDGETS(DSP2, "DSP2"),
1236WM2200_MIXER_WIDGETS(DSP2L, "DSP2L"),
1237WM2200_MIXER_WIDGETS(DSP2R, "DSP2R"),
1238 1806
1239WM2200_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"), 1807WM2200_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
1240WM2200_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"), 1808WM2200_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
@@ -1326,11 +1894,19 @@ static const struct snd_soc_dapm_route wm2200_dapm_routes[] = {
1326 { "SPK", NULL, "OUT2L" }, 1894 { "SPK", NULL, "OUT2L" },
1327 { "SPK", NULL, "OUT2R" }, 1895 { "SPK", NULL, "OUT2R" },
1328 1896
1897 { "AEC Loopback", "OUT1L", "OUT1L" },
1898 { "AEC Loopback", "OUT1R", "OUT1R" },
1899 { "AEC Loopback", "OUT2L", "OUT2L" },
1900 { "AEC Loopback", "OUT2R", "OUT2R" },
1901
1329 WM2200_MIXER_ROUTES("DSP1", "DSP1L"), 1902 WM2200_MIXER_ROUTES("DSP1", "DSP1L"),
1330 WM2200_MIXER_ROUTES("DSP1", "DSP1R"), 1903 WM2200_MIXER_ROUTES("DSP1", "DSP1R"),
1331 WM2200_MIXER_ROUTES("DSP2", "DSP2L"), 1904 WM2200_MIXER_ROUTES("DSP2", "DSP2L"),
1332 WM2200_MIXER_ROUTES("DSP2", "DSP2R"), 1905 WM2200_MIXER_ROUTES("DSP2", "DSP2R"),
1333 1906
1907 WM2200_DSP_AUX_ROUTES("DSP1"),
1908 WM2200_DSP_AUX_ROUTES("DSP2"),
1909
1334 WM2200_MIXER_ROUTES("OUT1L", "OUT1L"), 1910 WM2200_MIXER_ROUTES("OUT1L", "OUT1L"),
1335 WM2200_MIXER_ROUTES("OUT1R", "OUT1R"), 1911 WM2200_MIXER_ROUTES("OUT1R", "OUT1R"),
1336 WM2200_MIXER_ROUTES("OUT2L", "OUT2L"), 1912 WM2200_MIXER_ROUTES("OUT2L", "OUT2L"),
@@ -1968,12 +2544,15 @@ static const struct regmap_config wm2200_regmap = {
1968 .reg_bits = 16, 2544 .reg_bits = 16,
1969 .val_bits = 16, 2545 .val_bits = 16,
1970 2546
1971 .max_register = WM2200_MAX_REGISTER, 2547 .max_register = WM2200_MAX_REGISTER + (ARRAY_SIZE(wm2200_ranges) *
2548 WM2200_DSP_SPACING),
1972 .reg_defaults = wm2200_reg_defaults, 2549 .reg_defaults = wm2200_reg_defaults,
1973 .num_reg_defaults = ARRAY_SIZE(wm2200_reg_defaults), 2550 .num_reg_defaults = ARRAY_SIZE(wm2200_reg_defaults),
1974 .volatile_reg = wm2200_volatile_register, 2551 .volatile_reg = wm2200_volatile_register,
1975 .readable_reg = wm2200_readable_register, 2552 .readable_reg = wm2200_readable_register,
1976 .cache_type = REGCACHE_RBTREE, 2553 .cache_type = REGCACHE_RBTREE,
2554 .ranges = wm2200_ranges,
2555 .num_ranges = ARRAY_SIZE(wm2200_ranges),
1977}; 2556};
1978 2557
1979static const unsigned int wm2200_dig_vu[] = { 2558static const unsigned int wm2200_dig_vu[] = {
@@ -2011,7 +2590,7 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2011 wm2200->dev = &i2c->dev; 2590 wm2200->dev = &i2c->dev;
2012 init_completion(&wm2200->fll_lock); 2591 init_completion(&wm2200->fll_lock);
2013 2592
2014 wm2200->regmap = regmap_init_i2c(i2c, &wm2200_regmap); 2593 wm2200->regmap = devm_regmap_init_i2c(i2c, &wm2200_regmap);
2015 if (IS_ERR(wm2200->regmap)) { 2594 if (IS_ERR(wm2200->regmap)) {
2016 ret = PTR_ERR(wm2200->regmap); 2595 ret = PTR_ERR(wm2200->regmap);
2017 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 2596 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
@@ -2027,8 +2606,9 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2027 for (i = 0; i < ARRAY_SIZE(wm2200->core_supplies); i++) 2606 for (i = 0; i < ARRAY_SIZE(wm2200->core_supplies); i++)
2028 wm2200->core_supplies[i].supply = wm2200_core_supply_names[i]; 2607 wm2200->core_supplies[i].supply = wm2200_core_supply_names[i];
2029 2608
2030 ret = regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm2200->core_supplies), 2609 ret = devm_regulator_bulk_get(&i2c->dev,
2031 wm2200->core_supplies); 2610 ARRAY_SIZE(wm2200->core_supplies),
2611 wm2200->core_supplies);
2032 if (ret != 0) { 2612 if (ret != 0) {
2033 dev_err(&i2c->dev, "Failed to request core supplies: %d\n", 2613 dev_err(&i2c->dev, "Failed to request core supplies: %d\n",
2034 ret); 2614 ret);
@@ -2044,8 +2624,9 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2044 } 2624 }
2045 2625
2046 if (wm2200->pdata.ldo_ena) { 2626 if (wm2200->pdata.ldo_ena) {
2047 ret = gpio_request_one(wm2200->pdata.ldo_ena, 2627 ret = devm_gpio_request_one(&i2c->dev, wm2200->pdata.ldo_ena,
2048 GPIOF_OUT_INIT_HIGH, "WM2200 LDOENA"); 2628 GPIOF_OUT_INIT_HIGH,
2629 "WM2200 LDOENA");
2049 if (ret < 0) { 2630 if (ret < 0) {
2050 dev_err(&i2c->dev, "Failed to request LDOENA %d: %d\n", 2631 dev_err(&i2c->dev, "Failed to request LDOENA %d: %d\n",
2051 wm2200->pdata.ldo_ena, ret); 2632 wm2200->pdata.ldo_ena, ret);
@@ -2055,8 +2636,9 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2055 } 2636 }
2056 2637
2057 if (wm2200->pdata.reset) { 2638 if (wm2200->pdata.reset) {
2058 ret = gpio_request_one(wm2200->pdata.reset, 2639 ret = devm_gpio_request_one(&i2c->dev, wm2200->pdata.reset,
2059 GPIOF_OUT_INIT_HIGH, "WM2200 /RESET"); 2640 GPIOF_OUT_INIT_HIGH,
2641 "WM2200 /RESET");
2060 if (ret < 0) { 2642 if (ret < 0) {
2061 dev_err(&i2c->dev, "Failed to request /RESET %d: %d\n", 2643 dev_err(&i2c->dev, "Failed to request /RESET %d: %d\n",
2062 wm2200->pdata.reset, ret); 2644 wm2200->pdata.reset, ret);
@@ -2091,6 +2673,7 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2091 2673
2092 switch (wm2200->rev) { 2674 switch (wm2200->rev) {
2093 case 0: 2675 case 0:
2676 case 1:
2094 ret = regmap_register_patch(wm2200->regmap, wm2200_reva_patch, 2677 ret = regmap_register_patch(wm2200->regmap, wm2200_reva_patch,
2095 ARRAY_SIZE(wm2200_reva_patch)); 2678 ARRAY_SIZE(wm2200_reva_patch));
2096 if (ret != 0) { 2679 if (ret != 0) {
@@ -2165,23 +2748,16 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2165err_pm_runtime: 2748err_pm_runtime:
2166 pm_runtime_disable(&i2c->dev); 2749 pm_runtime_disable(&i2c->dev);
2167err_reset: 2750err_reset:
2168 if (wm2200->pdata.reset) { 2751 if (wm2200->pdata.reset)
2169 gpio_set_value_cansleep(wm2200->pdata.reset, 0); 2752 gpio_set_value_cansleep(wm2200->pdata.reset, 0);
2170 gpio_free(wm2200->pdata.reset);
2171 }
2172err_ldo: 2753err_ldo:
2173 if (wm2200->pdata.ldo_ena) { 2754 if (wm2200->pdata.ldo_ena)
2174 gpio_set_value_cansleep(wm2200->pdata.ldo_ena, 0); 2755 gpio_set_value_cansleep(wm2200->pdata.ldo_ena, 0);
2175 gpio_free(wm2200->pdata.ldo_ena);
2176 }
2177err_enable: 2756err_enable:
2178 regulator_bulk_disable(ARRAY_SIZE(wm2200->core_supplies), 2757 regulator_bulk_disable(ARRAY_SIZE(wm2200->core_supplies),
2179 wm2200->core_supplies); 2758 wm2200->core_supplies);
2180err_core: 2759err_core:
2181 regulator_bulk_free(ARRAY_SIZE(wm2200->core_supplies),
2182 wm2200->core_supplies);
2183err_regmap: 2760err_regmap:
2184 regmap_exit(wm2200->regmap);
2185err: 2761err:
2186 return ret; 2762 return ret;
2187} 2763}
@@ -2193,17 +2769,10 @@ static __devexit int wm2200_i2c_remove(struct i2c_client *i2c)
2193 snd_soc_unregister_codec(&i2c->dev); 2769 snd_soc_unregister_codec(&i2c->dev);
2194 if (i2c->irq) 2770 if (i2c->irq)
2195 free_irq(i2c->irq, wm2200); 2771 free_irq(i2c->irq, wm2200);
2196 if (wm2200->pdata.reset) { 2772 if (wm2200->pdata.reset)
2197 gpio_set_value_cansleep(wm2200->pdata.reset, 0); 2773 gpio_set_value_cansleep(wm2200->pdata.reset, 0);
2198 gpio_free(wm2200->pdata.reset); 2774 if (wm2200->pdata.ldo_ena)
2199 }
2200 if (wm2200->pdata.ldo_ena) {
2201 gpio_set_value_cansleep(wm2200->pdata.ldo_ena, 0); 2775 gpio_set_value_cansleep(wm2200->pdata.ldo_ena, 0);
2202 gpio_free(wm2200->pdata.ldo_ena);
2203 }
2204 regulator_bulk_free(ARRAY_SIZE(wm2200->core_supplies),
2205 wm2200->core_supplies);
2206 regmap_exit(wm2200->regmap);
2207 2776
2208 return 0; 2777 return 0;
2209} 2778}
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index 1722b586bdba..27f7e38e7eca 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -31,6 +31,7 @@
31 31
32#include "arizona.h" 32#include "arizona.h"
33#include "wm5102.h" 33#include "wm5102.h"
34#include "wm_adsp.h"
34 35
35struct wm5102_priv { 36struct wm5102_priv {
36 struct arizona_priv core; 37 struct arizona_priv core;
@@ -42,6 +43,563 @@ static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
42static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0); 43static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
43static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0); 44static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0);
44 45
46static const struct wm_adsp_region wm5102_dsp1_regions[] = {
47 { .type = WMFW_ADSP2_PM, .base = 0x100000 },
48 { .type = WMFW_ADSP2_ZM, .base = 0x180000 },
49 { .type = WMFW_ADSP2_XM, .base = 0x190000 },
50 { .type = WMFW_ADSP2_YM, .base = 0x1a8000 },
51};
52
53static const struct reg_default wm5102_sysclk_reva_patch[] = {
54 { 0x3000, 0x2225 },
55 { 0x3001, 0x3a03 },
56 { 0x3002, 0x0225 },
57 { 0x3003, 0x0801 },
58 { 0x3004, 0x6249 },
59 { 0x3005, 0x0c04 },
60 { 0x3006, 0x0225 },
61 { 0x3007, 0x5901 },
62 { 0x3008, 0xe249 },
63 { 0x3009, 0x030d },
64 { 0x300a, 0x0249 },
65 { 0x300b, 0x2c01 },
66 { 0x300c, 0xe249 },
67 { 0x300d, 0x4342 },
68 { 0x300e, 0xe249 },
69 { 0x300f, 0x73c0 },
70 { 0x3010, 0x4249 },
71 { 0x3011, 0x0c00 },
72 { 0x3012, 0x0225 },
73 { 0x3013, 0x1f01 },
74 { 0x3014, 0x0225 },
75 { 0x3015, 0x1e01 },
76 { 0x3016, 0x0225 },
77 { 0x3017, 0xfa00 },
78 { 0x3018, 0x0000 },
79 { 0x3019, 0xf000 },
80 { 0x301a, 0x0000 },
81 { 0x301b, 0xf000 },
82 { 0x301c, 0x0000 },
83 { 0x301d, 0xf000 },
84 { 0x301e, 0x0000 },
85 { 0x301f, 0xf000 },
86 { 0x3020, 0x0000 },
87 { 0x3021, 0xf000 },
88 { 0x3022, 0x0000 },
89 { 0x3023, 0xf000 },
90 { 0x3024, 0x0000 },
91 { 0x3025, 0xf000 },
92 { 0x3026, 0x0000 },
93 { 0x3027, 0xf000 },
94 { 0x3028, 0x0000 },
95 { 0x3029, 0xf000 },
96 { 0x302a, 0x0000 },
97 { 0x302b, 0xf000 },
98 { 0x302c, 0x0000 },
99 { 0x302d, 0xf000 },
100 { 0x302e, 0x0000 },
101 { 0x302f, 0xf000 },
102 { 0x3030, 0x0225 },
103 { 0x3031, 0x1a01 },
104 { 0x3032, 0x0225 },
105 { 0x3033, 0x1e00 },
106 { 0x3034, 0x0225 },
107 { 0x3035, 0x1f00 },
108 { 0x3036, 0x6225 },
109 { 0x3037, 0xf800 },
110 { 0x3038, 0x0000 },
111 { 0x3039, 0xf000 },
112 { 0x303a, 0x0000 },
113 { 0x303b, 0xf000 },
114 { 0x303c, 0x0000 },
115 { 0x303d, 0xf000 },
116 { 0x303e, 0x0000 },
117 { 0x303f, 0xf000 },
118 { 0x3040, 0x2226 },
119 { 0x3041, 0x3a03 },
120 { 0x3042, 0x0226 },
121 { 0x3043, 0x0801 },
122 { 0x3044, 0x6249 },
123 { 0x3045, 0x0c06 },
124 { 0x3046, 0x0226 },
125 { 0x3047, 0x5901 },
126 { 0x3048, 0xe249 },
127 { 0x3049, 0x030d },
128 { 0x304a, 0x0249 },
129 { 0x304b, 0x2c01 },
130 { 0x304c, 0xe249 },
131 { 0x304d, 0x4342 },
132 { 0x304e, 0xe249 },
133 { 0x304f, 0x73c0 },
134 { 0x3050, 0x4249 },
135 { 0x3051, 0x0c00 },
136 { 0x3052, 0x0226 },
137 { 0x3053, 0x1f01 },
138 { 0x3054, 0x0226 },
139 { 0x3055, 0x1e01 },
140 { 0x3056, 0x0226 },
141 { 0x3057, 0xfa00 },
142 { 0x3058, 0x0000 },
143 { 0x3059, 0xf000 },
144 { 0x305a, 0x0000 },
145 { 0x305b, 0xf000 },
146 { 0x305c, 0x0000 },
147 { 0x305d, 0xf000 },
148 { 0x305e, 0x0000 },
149 { 0x305f, 0xf000 },
150 { 0x3060, 0x0000 },
151 { 0x3061, 0xf000 },
152 { 0x3062, 0x0000 },
153 { 0x3063, 0xf000 },
154 { 0x3064, 0x0000 },
155 { 0x3065, 0xf000 },
156 { 0x3066, 0x0000 },
157 { 0x3067, 0xf000 },
158 { 0x3068, 0x0000 },
159 { 0x3069, 0xf000 },
160 { 0x306a, 0x0000 },
161 { 0x306b, 0xf000 },
162 { 0x306c, 0x0000 },
163 { 0x306d, 0xf000 },
164 { 0x306e, 0x0000 },
165 { 0x306f, 0xf000 },
166 { 0x3070, 0x0226 },
167 { 0x3071, 0x1a01 },
168 { 0x3072, 0x0226 },
169 { 0x3073, 0x1e00 },
170 { 0x3074, 0x0226 },
171 { 0x3075, 0x1f00 },
172 { 0x3076, 0x6226 },
173 { 0x3077, 0xf800 },
174 { 0x3078, 0x0000 },
175 { 0x3079, 0xf000 },
176 { 0x307a, 0x0000 },
177 { 0x307b, 0xf000 },
178 { 0x307c, 0x0000 },
179 { 0x307d, 0xf000 },
180 { 0x307e, 0x0000 },
181 { 0x307f, 0xf000 },
182 { 0x3080, 0x2227 },
183 { 0x3081, 0x3a03 },
184 { 0x3082, 0x0227 },
185 { 0x3083, 0x0801 },
186 { 0x3084, 0x6255 },
187 { 0x3085, 0x0c04 },
188 { 0x3086, 0x0227 },
189 { 0x3087, 0x5901 },
190 { 0x3088, 0xe255 },
191 { 0x3089, 0x030d },
192 { 0x308a, 0x0255 },
193 { 0x308b, 0x2c01 },
194 { 0x308c, 0xe255 },
195 { 0x308d, 0x4342 },
196 { 0x308e, 0xe255 },
197 { 0x308f, 0x73c0 },
198 { 0x3090, 0x4255 },
199 { 0x3091, 0x0c00 },
200 { 0x3092, 0x0227 },
201 { 0x3093, 0x1f01 },
202 { 0x3094, 0x0227 },
203 { 0x3095, 0x1e01 },
204 { 0x3096, 0x0227 },
205 { 0x3097, 0xfa00 },
206 { 0x3098, 0x0000 },
207 { 0x3099, 0xf000 },
208 { 0x309a, 0x0000 },
209 { 0x309b, 0xf000 },
210 { 0x309c, 0x0000 },
211 { 0x309d, 0xf000 },
212 { 0x309e, 0x0000 },
213 { 0x309f, 0xf000 },
214 { 0x30a0, 0x0000 },
215 { 0x30a1, 0xf000 },
216 { 0x30a2, 0x0000 },
217 { 0x30a3, 0xf000 },
218 { 0x30a4, 0x0000 },
219 { 0x30a5, 0xf000 },
220 { 0x30a6, 0x0000 },
221 { 0x30a7, 0xf000 },
222 { 0x30a8, 0x0000 },
223 { 0x30a9, 0xf000 },
224 { 0x30aa, 0x0000 },
225 { 0x30ab, 0xf000 },
226 { 0x30ac, 0x0000 },
227 { 0x30ad, 0xf000 },
228 { 0x30ae, 0x0000 },
229 { 0x30af, 0xf000 },
230 { 0x30b0, 0x0227 },
231 { 0x30b1, 0x1a01 },
232 { 0x30b2, 0x0227 },
233 { 0x30b3, 0x1e00 },
234 { 0x30b4, 0x0227 },
235 { 0x30b5, 0x1f00 },
236 { 0x30b6, 0x6227 },
237 { 0x30b7, 0xf800 },
238 { 0x30b8, 0x0000 },
239 { 0x30b9, 0xf000 },
240 { 0x30ba, 0x0000 },
241 { 0x30bb, 0xf000 },
242 { 0x30bc, 0x0000 },
243 { 0x30bd, 0xf000 },
244 { 0x30be, 0x0000 },
245 { 0x30bf, 0xf000 },
246 { 0x30c0, 0x2228 },
247 { 0x30c1, 0x3a03 },
248 { 0x30c2, 0x0228 },
249 { 0x30c3, 0x0801 },
250 { 0x30c4, 0x6255 },
251 { 0x30c5, 0x0c06 },
252 { 0x30c6, 0x0228 },
253 { 0x30c7, 0x5901 },
254 { 0x30c8, 0xe255 },
255 { 0x30c9, 0x030d },
256 { 0x30ca, 0x0255 },
257 { 0x30cb, 0x2c01 },
258 { 0x30cc, 0xe255 },
259 { 0x30cd, 0x4342 },
260 { 0x30ce, 0xe255 },
261 { 0x30cf, 0x73c0 },
262 { 0x30d0, 0x4255 },
263 { 0x30d1, 0x0c00 },
264 { 0x30d2, 0x0228 },
265 { 0x30d3, 0x1f01 },
266 { 0x30d4, 0x0228 },
267 { 0x30d5, 0x1e01 },
268 { 0x30d6, 0x0228 },
269 { 0x30d7, 0xfa00 },
270 { 0x30d8, 0x0000 },
271 { 0x30d9, 0xf000 },
272 { 0x30da, 0x0000 },
273 { 0x30db, 0xf000 },
274 { 0x30dc, 0x0000 },
275 { 0x30dd, 0xf000 },
276 { 0x30de, 0x0000 },
277 { 0x30df, 0xf000 },
278 { 0x30e0, 0x0000 },
279 { 0x30e1, 0xf000 },
280 { 0x30e2, 0x0000 },
281 { 0x30e3, 0xf000 },
282 { 0x30e4, 0x0000 },
283 { 0x30e5, 0xf000 },
284 { 0x30e6, 0x0000 },
285 { 0x30e7, 0xf000 },
286 { 0x30e8, 0x0000 },
287 { 0x30e9, 0xf000 },
288 { 0x30ea, 0x0000 },
289 { 0x30eb, 0xf000 },
290 { 0x30ec, 0x0000 },
291 { 0x30ed, 0xf000 },
292 { 0x30ee, 0x0000 },
293 { 0x30ef, 0xf000 },
294 { 0x30f0, 0x0228 },
295 { 0x30f1, 0x1a01 },
296 { 0x30f2, 0x0228 },
297 { 0x30f3, 0x1e00 },
298 { 0x30f4, 0x0228 },
299 { 0x30f5, 0x1f00 },
300 { 0x30f6, 0x6228 },
301 { 0x30f7, 0xf800 },
302 { 0x30f8, 0x0000 },
303 { 0x30f9, 0xf000 },
304 { 0x30fa, 0x0000 },
305 { 0x30fb, 0xf000 },
306 { 0x30fc, 0x0000 },
307 { 0x30fd, 0xf000 },
308 { 0x30fe, 0x0000 },
309 { 0x30ff, 0xf000 },
310 { 0x3100, 0x222b },
311 { 0x3101, 0x3a03 },
312 { 0x3102, 0x222b },
313 { 0x3103, 0x5803 },
314 { 0x3104, 0xe26f },
315 { 0x3105, 0x030d },
316 { 0x3106, 0x626f },
317 { 0x3107, 0x2c01 },
318 { 0x3108, 0xe26f },
319 { 0x3109, 0x4342 },
320 { 0x310a, 0xe26f },
321 { 0x310b, 0x73c0 },
322 { 0x310c, 0x026f },
323 { 0x310d, 0x0c00 },
324 { 0x310e, 0x022b },
325 { 0x310f, 0x1f01 },
326 { 0x3110, 0x022b },
327 { 0x3111, 0x1e01 },
328 { 0x3112, 0x022b },
329 { 0x3113, 0xfa00 },
330 { 0x3114, 0x0000 },
331 { 0x3115, 0xf000 },
332 { 0x3116, 0x0000 },
333 { 0x3117, 0xf000 },
334 { 0x3118, 0x0000 },
335 { 0x3119, 0xf000 },
336 { 0x311a, 0x0000 },
337 { 0x311b, 0xf000 },
338 { 0x311c, 0x0000 },
339 { 0x311d, 0xf000 },
340 { 0x311e, 0x0000 },
341 { 0x311f, 0xf000 },
342 { 0x3120, 0x022b },
343 { 0x3121, 0x0a01 },
344 { 0x3122, 0x022b },
345 { 0x3123, 0x1e00 },
346 { 0x3124, 0x022b },
347 { 0x3125, 0x1f00 },
348 { 0x3126, 0x622b },
349 { 0x3127, 0xf800 },
350 { 0x3128, 0x0000 },
351 { 0x3129, 0xf000 },
352 { 0x312a, 0x0000 },
353 { 0x312b, 0xf000 },
354 { 0x312c, 0x0000 },
355 { 0x312d, 0xf000 },
356 { 0x312e, 0x0000 },
357 { 0x312f, 0xf000 },
358 { 0x3130, 0x0000 },
359 { 0x3131, 0xf000 },
360 { 0x3132, 0x0000 },
361 { 0x3133, 0xf000 },
362 { 0x3134, 0x0000 },
363 { 0x3135, 0xf000 },
364 { 0x3136, 0x0000 },
365 { 0x3137, 0xf000 },
366 { 0x3138, 0x0000 },
367 { 0x3139, 0xf000 },
368 { 0x313a, 0x0000 },
369 { 0x313b, 0xf000 },
370 { 0x313c, 0x0000 },
371 { 0x313d, 0xf000 },
372 { 0x313e, 0x0000 },
373 { 0x313f, 0xf000 },
374 { 0x3140, 0x0000 },
375 { 0x3141, 0xf000 },
376 { 0x3142, 0x0000 },
377 { 0x3143, 0xf000 },
378 { 0x3144, 0x0000 },
379 { 0x3145, 0xf000 },
380 { 0x3146, 0x0000 },
381 { 0x3147, 0xf000 },
382 { 0x3148, 0x0000 },
383 { 0x3149, 0xf000 },
384 { 0x314a, 0x0000 },
385 { 0x314b, 0xf000 },
386 { 0x314c, 0x0000 },
387 { 0x314d, 0xf000 },
388 { 0x314e, 0x0000 },
389 { 0x314f, 0xf000 },
390 { 0x3150, 0x0000 },
391 { 0x3151, 0xf000 },
392 { 0x3152, 0x0000 },
393 { 0x3153, 0xf000 },
394 { 0x3154, 0x0000 },
395 { 0x3155, 0xf000 },
396 { 0x3156, 0x0000 },
397 { 0x3157, 0xf000 },
398 { 0x3158, 0x0000 },
399 { 0x3159, 0xf000 },
400 { 0x315a, 0x0000 },
401 { 0x315b, 0xf000 },
402 { 0x315c, 0x0000 },
403 { 0x315d, 0xf000 },
404 { 0x315e, 0x0000 },
405 { 0x315f, 0xf000 },
406 { 0x3160, 0x0000 },
407 { 0x3161, 0xf000 },
408 { 0x3162, 0x0000 },
409 { 0x3163, 0xf000 },
410 { 0x3164, 0x0000 },
411 { 0x3165, 0xf000 },
412 { 0x3166, 0x0000 },
413 { 0x3167, 0xf000 },
414 { 0x3168, 0x0000 },
415 { 0x3169, 0xf000 },
416 { 0x316a, 0x0000 },
417 { 0x316b, 0xf000 },
418 { 0x316c, 0x0000 },
419 { 0x316d, 0xf000 },
420 { 0x316e, 0x0000 },
421 { 0x316f, 0xf000 },
422 { 0x3170, 0x0000 },
423 { 0x3171, 0xf000 },
424 { 0x3172, 0x0000 },
425 { 0x3173, 0xf000 },
426 { 0x3174, 0x0000 },
427 { 0x3175, 0xf000 },
428 { 0x3176, 0x0000 },
429 { 0x3177, 0xf000 },
430 { 0x3178, 0x0000 },
431 { 0x3179, 0xf000 },
432 { 0x317a, 0x0000 },
433 { 0x317b, 0xf000 },
434 { 0x317c, 0x0000 },
435 { 0x317d, 0xf000 },
436 { 0x317e, 0x0000 },
437 { 0x317f, 0xf000 },
438 { 0x3180, 0x2001 },
439 { 0x3181, 0xf101 },
440 { 0x3182, 0x0000 },
441 { 0x3183, 0xf000 },
442 { 0x3184, 0x0000 },
443 { 0x3185, 0xf000 },
444 { 0x3186, 0x0000 },
445 { 0x3187, 0xf000 },
446 { 0x3188, 0x0000 },
447 { 0x3189, 0xf000 },
448 { 0x318a, 0x0000 },
449 { 0x318b, 0xf000 },
450 { 0x318c, 0x0000 },
451 { 0x318d, 0xf000 },
452 { 0x318e, 0x0000 },
453 { 0x318f, 0xf000 },
454 { 0x3190, 0x0000 },
455 { 0x3191, 0xf000 },
456 { 0x3192, 0x0000 },
457 { 0x3193, 0xf000 },
458 { 0x3194, 0x0000 },
459 { 0x3195, 0xf000 },
460 { 0x3196, 0x0000 },
461 { 0x3197, 0xf000 },
462 { 0x3198, 0x0000 },
463 { 0x3199, 0xf000 },
464 { 0x319a, 0x0000 },
465 { 0x319b, 0xf000 },
466 { 0x319c, 0x0000 },
467 { 0x319d, 0xf000 },
468 { 0x319e, 0x0000 },
469 { 0x319f, 0xf000 },
470 { 0x31a0, 0x0000 },
471 { 0x31a1, 0xf000 },
472 { 0x31a2, 0x0000 },
473 { 0x31a3, 0xf000 },
474 { 0x31a4, 0x0000 },
475 { 0x31a5, 0xf000 },
476 { 0x31a6, 0x0000 },
477 { 0x31a7, 0xf000 },
478 { 0x31a8, 0x0000 },
479 { 0x31a9, 0xf000 },
480 { 0x31aa, 0x0000 },
481 { 0x31ab, 0xf000 },
482 { 0x31ac, 0x0000 },
483 { 0x31ad, 0xf000 },
484 { 0x31ae, 0x0000 },
485 { 0x31af, 0xf000 },
486 { 0x31b0, 0x0000 },
487 { 0x31b1, 0xf000 },
488 { 0x31b2, 0x0000 },
489 { 0x31b3, 0xf000 },
490 { 0x31b4, 0x0000 },
491 { 0x31b5, 0xf000 },
492 { 0x31b6, 0x0000 },
493 { 0x31b7, 0xf000 },
494 { 0x31b8, 0x0000 },
495 { 0x31b9, 0xf000 },
496 { 0x31ba, 0x0000 },
497 { 0x31bb, 0xf000 },
498 { 0x31bc, 0x0000 },
499 { 0x31bd, 0xf000 },
500 { 0x31be, 0x0000 },
501 { 0x31bf, 0xf000 },
502 { 0x31c0, 0x0000 },
503 { 0x31c1, 0xf000 },
504 { 0x31c2, 0x0000 },
505 { 0x31c3, 0xf000 },
506 { 0x31c4, 0x0000 },
507 { 0x31c5, 0xf000 },
508 { 0x31c6, 0x0000 },
509 { 0x31c7, 0xf000 },
510 { 0x31c8, 0x0000 },
511 { 0x31c9, 0xf000 },
512 { 0x31ca, 0x0000 },
513 { 0x31cb, 0xf000 },
514 { 0x31cc, 0x0000 },
515 { 0x31cd, 0xf000 },
516 { 0x31ce, 0x0000 },
517 { 0x31cf, 0xf000 },
518 { 0x31d0, 0x0000 },
519 { 0x31d1, 0xf000 },
520 { 0x31d2, 0x0000 },
521 { 0x31d3, 0xf000 },
522 { 0x31d4, 0x0000 },
523 { 0x31d5, 0xf000 },
524 { 0x31d6, 0x0000 },
525 { 0x31d7, 0xf000 },
526 { 0x31d8, 0x0000 },
527 { 0x31d9, 0xf000 },
528 { 0x31da, 0x0000 },
529 { 0x31db, 0xf000 },
530 { 0x31dc, 0x0000 },
531 { 0x31dd, 0xf000 },
532 { 0x31de, 0x0000 },
533 { 0x31df, 0xf000 },
534 { 0x31e0, 0x0000 },
535 { 0x31e1, 0xf000 },
536 { 0x31e2, 0x0000 },
537 { 0x31e3, 0xf000 },
538 { 0x31e4, 0x0000 },
539 { 0x31e5, 0xf000 },
540 { 0x31e6, 0x0000 },
541 { 0x31e7, 0xf000 },
542 { 0x31e8, 0x0000 },
543 { 0x31e9, 0xf000 },
544 { 0x31ea, 0x0000 },
545 { 0x31eb, 0xf000 },
546 { 0x31ec, 0x0000 },
547 { 0x31ed, 0xf000 },
548 { 0x31ee, 0x0000 },
549 { 0x31ef, 0xf000 },
550 { 0x31f0, 0x0000 },
551 { 0x31f1, 0xf000 },
552 { 0x31f2, 0x0000 },
553 { 0x31f3, 0xf000 },
554 { 0x31f4, 0x0000 },
555 { 0x31f5, 0xf000 },
556 { 0x31f6, 0x0000 },
557 { 0x31f7, 0xf000 },
558 { 0x31f8, 0x0000 },
559 { 0x31f9, 0xf000 },
560 { 0x31fa, 0x0000 },
561 { 0x31fb, 0xf000 },
562 { 0x31fc, 0x0000 },
563 { 0x31fd, 0xf000 },
564 { 0x31fe, 0x0000 },
565 { 0x31ff, 0xf000 },
566 { 0x024d, 0xff50 },
567 { 0x0252, 0xff50 },
568 { 0x0259, 0x0112 },
569 { 0x025e, 0x0112 },
570};
571
572static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w,
573 struct snd_kcontrol *kcontrol, int event)
574{
575 struct snd_soc_codec *codec = w->codec;
576 struct arizona *arizona = dev_get_drvdata(codec->dev);
577 struct regmap *regmap = codec->control_data;
578 const struct reg_default *patch = NULL;
579 int i, patch_size;
580
581 switch (arizona->rev) {
582 case 0:
583 patch = wm5102_sysclk_reva_patch;
584 patch_size = ARRAY_SIZE(wm5102_sysclk_reva_patch);
585 break;
586 }
587
588 switch (event) {
589 case SND_SOC_DAPM_POST_PMU:
590 if (patch)
591 for (i = 0; i < patch_size; i++)
592 regmap_write(regmap, patch[i].reg,
593 patch[i].def);
594 break;
595
596 default:
597 break;
598 }
599
600 return 0;
601}
602
45static const struct snd_kcontrol_new wm5102_snd_controls[] = { 603static const struct snd_kcontrol_new wm5102_snd_controls[] = {
46SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL, 604SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL,
47 ARIZONA_IN1_OSR_SHIFT, 1, 0), 605 ARIZONA_IN1_OSR_SHIFT, 1, 0),
@@ -77,11 +635,23 @@ SOC_DOUBLE_R_TLV("IN3 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_3L,
77 ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_DIG_VOL_SHIFT, 635 ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_DIG_VOL_SHIFT,
78 0xbf, 0, digital_tlv), 636 0xbf, 0, digital_tlv),
79 637
638SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp),
639SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp),
640
80ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE), 641ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
81ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), 642ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
82ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), 643ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
83ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), 644ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
84 645
646SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21,
647 ARIZONA_EQ1_ENA_MASK),
648SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21,
649 ARIZONA_EQ2_ENA_MASK),
650SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21,
651 ARIZONA_EQ3_ENA_MASK),
652SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21,
653 ARIZONA_EQ4_ENA_MASK),
654
85SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, 655SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
86 24, 0, eq_tlv), 656 24, 0, eq_tlv),
87SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, 657SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
@@ -137,6 +707,14 @@ ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
137ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE), 707ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
138ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE), 708ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
139 709
710SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1),
711SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1),
712SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1),
713SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1),
714
715ARIZONA_MIXER_CONTROLS("DSP1L", ARIZONA_DSP1LMIX_INPUT_1_SOURCE),
716ARIZONA_MIXER_CONTROLS("DSP1R", ARIZONA_DSP1RMIX_INPUT_1_SOURCE),
717
140SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode), 718SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
141SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), 719SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
142SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), 720SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
@@ -158,14 +736,6 @@ ARIZONA_MIXER_CONTROLS("SPKOUTR", ARIZONA_OUT4RMIX_INPUT_1_SOURCE),
158ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE), 736ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE),
159ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE), 737ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE),
160 738
161SOC_SINGLE("HPOUT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_1L,
162 ARIZONA_OUT1_OSR_SHIFT, 1, 0),
163SOC_SINGLE("OUT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_2L,
164 ARIZONA_OUT2_OSR_SHIFT, 1, 0),
165SOC_SINGLE("EPOUT High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_3L,
166 ARIZONA_OUT3_OSR_SHIFT, 1, 0),
167SOC_SINGLE("Speaker High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_4L,
168 ARIZONA_OUT4_OSR_SHIFT, 1, 0),
169SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L, 739SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L,
170 ARIZONA_OUT5_OSR_SHIFT, 1, 0), 740 ARIZONA_OUT5_OSR_SHIFT, 1, 0),
171 741
@@ -195,16 +765,8 @@ SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L,
195 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT, 765 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT,
196 0xbf, 0, digital_tlv), 766 0xbf, 0, digital_tlv),
197 767
198SOC_DOUBLE_R_RANGE_TLV("HPOUT1 Volume", ARIZONA_OUTPUT_PATH_CONFIG_1L, 768SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp),
199 ARIZONA_OUTPUT_PATH_CONFIG_1R, 769SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp),
200 ARIZONA_OUT1L_PGA_VOL_SHIFT,
201 0x34, 0x40, 0, ana_tlv),
202SOC_DOUBLE_R_RANGE_TLV("OUT2 Volume", ARIZONA_OUTPUT_PATH_CONFIG_2L,
203 ARIZONA_OUTPUT_PATH_CONFIG_2R,
204 ARIZONA_OUT2L_PGA_VOL_SHIFT,
205 0x34, 0x40, 0, ana_tlv),
206SOC_SINGLE_RANGE_TLV("EPOUT Volume", ARIZONA_OUTPUT_PATH_CONFIG_3L,
207 ARIZONA_OUT3L_PGA_VOL_SHIFT, 0x34, 0x40, 0, ana_tlv),
208 770
209SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT, 771SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
210 ARIZONA_SPK1R_MUTE_SHIFT, 1, 1), 772 ARIZONA_SPK1R_MUTE_SHIFT, 1, 1),
@@ -269,11 +831,15 @@ ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
269ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); 831ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
270ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); 832ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
271 833
272ARIZONA_MIXER_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE); 834ARIZONA_MUX_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
273ARIZONA_MIXER_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE); 835ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
274ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); 836ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
275ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); 837ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
838
839ARIZONA_MIXER_ENUMS(DSP1L, ARIZONA_DSP1LMIX_INPUT_1_SOURCE);
840ARIZONA_MIXER_ENUMS(DSP1R, ARIZONA_DSP1RMIX_INPUT_1_SOURCE);
276 841
842ARIZONA_DSP_AUX_ENUMS(DSP1, ARIZONA_DSP1AUX1MIX_INPUT_1_SOURCE);
277 843
278static const char *wm5102_aec_loopback_texts[] = { 844static const char *wm5102_aec_loopback_texts[] = {
279 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "EPOUT", 845 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "EPOUT",
@@ -297,7 +863,7 @@ static const struct snd_kcontrol_new wm5102_aec_loopback_mux =
297 863
298static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = { 864static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = {
299SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT, 865SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
300 0, NULL, 0), 866 0, wm5102_sysclk_ev, SND_SOC_DAPM_POST_PMU),
301SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1, 867SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
302 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), 868 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
303SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK, 869SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
@@ -314,6 +880,7 @@ SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0),
314 880
315SND_SOC_DAPM_SIGGEN("TONE"), 881SND_SOC_DAPM_SIGGEN("TONE"),
316SND_SOC_DAPM_SIGGEN("NOISE"), 882SND_SOC_DAPM_SIGGEN("NOISE"),
883SND_SOC_DAPM_SIGGEN("HAPTICS"),
317 884
318SND_SOC_DAPM_INPUT("IN1L"), 885SND_SOC_DAPM_INPUT("IN1L"),
319SND_SOC_DAPM_INPUT("IN1R"), 886SND_SOC_DAPM_INPUT("IN1R"),
@@ -344,9 +911,9 @@ SND_SOC_DAPM_PGA_E("IN3R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3R_ENA_SHIFT,
344SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1, 911SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
345 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), 912 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
346SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2, 913SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
347 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), 914 ARIZONA_MICB2_ENA_SHIFT, 0, NULL, 0),
348SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3, 915SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
349 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), 916 ARIZONA_MICB3_ENA_SHIFT, 0, NULL, 0),
350 917
351SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR, 918SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
352 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0), 919 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
@@ -446,6 +1013,8 @@ SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
446SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, 1013SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
447 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0), 1014 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0),
448 1015
1016ARIZONA_DSP_WIDGETS(DSP1, "DSP1"),
1017
449SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, 1018SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
450 ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux), 1019 ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux),
451 1020
@@ -521,10 +1090,12 @@ ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
521ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), 1090ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
522ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), 1091ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
523 1092
524ARIZONA_MIXER_WIDGETS(ASRC1L, "ASRC1L"), 1093ARIZONA_MUX_WIDGETS(ASRC1L, "ASRC1L"),
525ARIZONA_MIXER_WIDGETS(ASRC1R, "ASRC1R"), 1094ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"),
526ARIZONA_MIXER_WIDGETS(ASRC2L, "ASRC2L"), 1095ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"),
527ARIZONA_MIXER_WIDGETS(ASRC2R, "ASRC2R"), 1096ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"),
1097
1098WM_ADSP2("DSP1", 0),
528 1099
529SND_SOC_DAPM_OUTPUT("HPOUT1L"), 1100SND_SOC_DAPM_OUTPUT("HPOUT1L"),
530SND_SOC_DAPM_OUTPUT("HPOUT1R"), 1101SND_SOC_DAPM_OUTPUT("HPOUT1R"),
@@ -544,6 +1115,7 @@ SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
544 { name, "Noise Generator", "Noise Generator" }, \ 1115 { name, "Noise Generator", "Noise Generator" }, \
545 { name, "Tone Generator 1", "Tone Generator 1" }, \ 1116 { name, "Tone Generator 1", "Tone Generator 1" }, \
546 { name, "Tone Generator 2", "Tone Generator 2" }, \ 1117 { name, "Tone Generator 2", "Tone Generator 2" }, \
1118 { name, "Haptics", "HAPTICS" }, \
547 { name, "AEC", "AEC Loopback" }, \ 1119 { name, "AEC", "AEC Loopback" }, \
548 { name, "IN1L", "IN1L PGA" }, \ 1120 { name, "IN1L", "IN1L PGA" }, \
549 { name, "IN1R", "IN1R PGA" }, \ 1121 { name, "IN1R", "IN1R PGA" }, \
@@ -577,7 +1149,13 @@ SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
577 { name, "ASRC1L", "ASRC1L" }, \ 1149 { name, "ASRC1L", "ASRC1L" }, \
578 { name, "ASRC1R", "ASRC1R" }, \ 1150 { name, "ASRC1R", "ASRC1R" }, \
579 { name, "ASRC2L", "ASRC2L" }, \ 1151 { name, "ASRC2L", "ASRC2L" }, \
580 { name, "ASRC2R", "ASRC2R" } 1152 { name, "ASRC2R", "ASRC2R" }, \
1153 { name, "DSP1.1", "DSP1" }, \
1154 { name, "DSP1.2", "DSP1" }, \
1155 { name, "DSP1.3", "DSP1" }, \
1156 { name, "DSP1.4", "DSP1" }, \
1157 { name, "DSP1.5", "DSP1" }, \
1158 { name, "DSP1.6", "DSP1" }
581 1159
582static const struct snd_soc_dapm_route wm5102_dapm_routes[] = { 1160static const struct snd_soc_dapm_route wm5102_dapm_routes[] = {
583 { "AIF2 Capture", NULL, "DBVDD2" }, 1161 { "AIF2 Capture", NULL, "DBVDD2" },
@@ -663,6 +1241,11 @@ static const struct snd_soc_dapm_route wm5102_dapm_routes[] = {
663 { "IN3L PGA", NULL, "IN3L" }, 1241 { "IN3L PGA", NULL, "IN3L" },
664 { "IN3R PGA", NULL, "IN3R" }, 1242 { "IN3R PGA", NULL, "IN3R" },
665 1243
1244 { "ASRC1L", NULL, "ASRC1L Input" },
1245 { "ASRC1R", NULL, "ASRC1R Input" },
1246 { "ASRC2L", NULL, "ASRC2L Input" },
1247 { "ASRC2R", NULL, "ASRC2R Input" },
1248
666 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"), 1249 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
667 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"), 1250 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
668 ARIZONA_MIXER_ROUTES("OUT2L", "HPOUT2L"), 1251 ARIZONA_MIXER_ROUTES("OUT2L", "HPOUT2L"),
@@ -705,10 +1288,12 @@ static const struct snd_soc_dapm_route wm5102_dapm_routes[] = {
705 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"), 1288 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
706 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"), 1289 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
707 1290
708 ARIZONA_MIXER_ROUTES("ASRC1L", "ASRC1L"), 1291 ARIZONA_MUX_ROUTES("ASRC1L"),
709 ARIZONA_MIXER_ROUTES("ASRC1R", "ASRC1R"), 1292 ARIZONA_MUX_ROUTES("ASRC1R"),
710 ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"), 1293 ARIZONA_MUX_ROUTES("ASRC2L"),
711 ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"), 1294 ARIZONA_MUX_ROUTES("ASRC2R"),
1295
1296 ARIZONA_DSP_ROUTES("DSP1"),
712 1297
713 { "AEC Loopback", "HPOUT1L", "OUT1L" }, 1298 { "AEC Loopback", "HPOUT1L", "OUT1L" },
714 { "AEC Loopback", "HPOUT1R", "OUT1R" }, 1299 { "AEC Loopback", "HPOUT1R", "OUT1R" },
@@ -827,9 +1412,28 @@ static struct snd_soc_dai_driver wm5102_dai[] = {
827static int wm5102_codec_probe(struct snd_soc_codec *codec) 1412static int wm5102_codec_probe(struct snd_soc_codec *codec)
828{ 1413{
829 struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); 1414 struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
1415 int ret;
830 1416
831 codec->control_data = priv->core.arizona->regmap; 1417 codec->control_data = priv->core.arizona->regmap;
832 return snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP); 1418
1419 ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
1420 if (ret != 0)
1421 return ret;
1422
1423 snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS");
1424
1425 priv->core.arizona->dapm = &codec->dapm;
1426
1427 return 0;
1428}
1429
1430static int wm5102_codec_remove(struct snd_soc_codec *codec)
1431{
1432 struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
1433
1434 priv->core.arizona->dapm = NULL;
1435
1436 return 0;
833} 1437}
834 1438
835#define WM5102_DIG_VU 0x0200 1439#define WM5102_DIG_VU 0x0200
@@ -856,6 +1460,7 @@ static unsigned int wm5102_digital_vu[] = {
856 1460
857static struct snd_soc_codec_driver soc_codec_dev_wm5102 = { 1461static struct snd_soc_codec_driver soc_codec_dev_wm5102 = {
858 .probe = wm5102_codec_probe, 1462 .probe = wm5102_codec_probe,
1463 .remove = wm5102_codec_remove,
859 1464
860 .idle_bias_off = true, 1465 .idle_bias_off = true,
861 1466
@@ -874,7 +1479,7 @@ static int __devinit wm5102_probe(struct platform_device *pdev)
874{ 1479{
875 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 1480 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
876 struct wm5102_priv *wm5102; 1481 struct wm5102_priv *wm5102;
877 int i; 1482 int i, ret;
878 1483
879 wm5102 = devm_kzalloc(&pdev->dev, sizeof(struct wm5102_priv), 1484 wm5102 = devm_kzalloc(&pdev->dev, sizeof(struct wm5102_priv),
880 GFP_KERNEL); 1485 GFP_KERNEL);
@@ -884,6 +1489,19 @@ static int __devinit wm5102_probe(struct platform_device *pdev)
884 1489
885 wm5102->core.arizona = arizona; 1490 wm5102->core.arizona = arizona;
886 1491
1492 wm5102->core.adsp[0].part = "wm5102";
1493 wm5102->core.adsp[0].num = 1;
1494 wm5102->core.adsp[0].type = WMFW_ADSP2;
1495 wm5102->core.adsp[0].base = ARIZONA_DSP1_CONTROL_1;
1496 wm5102->core.adsp[0].dev = arizona->dev;
1497 wm5102->core.adsp[0].regmap = arizona->regmap;
1498 wm5102->core.adsp[0].mem = wm5102_dsp1_regions;
1499 wm5102->core.adsp[0].num_mems = ARRAY_SIZE(wm5102_dsp1_regions);
1500
1501 ret = wm_adsp2_init(&wm5102->core.adsp[0], true);
1502 if (ret != 0)
1503 return ret;
1504
887 for (i = 0; i < ARRAY_SIZE(wm5102->fll); i++) 1505 for (i = 0; i < ARRAY_SIZE(wm5102->fll); i++)
888 wm5102->fll[i].vco_mult = 1; 1506 wm5102->fll[i].vco_mult = 1;
889 1507
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index 9211e4192f71..c57dc7468300 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -84,11 +84,23 @@ SOC_DOUBLE_R_TLV("IN4 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_4L,
84 ARIZONA_ADC_DIGITAL_VOLUME_4R, ARIZONA_IN4L_DIG_VOL_SHIFT, 84 ARIZONA_ADC_DIGITAL_VOLUME_4R, ARIZONA_IN4L_DIG_VOL_SHIFT,
85 0xbf, 0, digital_tlv), 85 0xbf, 0, digital_tlv),
86 86
87SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp),
88SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp),
89
87ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE), 90ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
88ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), 91ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
89ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), 92ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
90ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), 93ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
91 94
95SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21,
96 ARIZONA_EQ1_ENA_MASK),
97SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21,
98 ARIZONA_EQ2_ENA_MASK),
99SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21,
100 ARIZONA_EQ3_ENA_MASK),
101SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21,
102 ARIZONA_EQ4_ENA_MASK),
103
92SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, 104SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
93 24, 0, eq_tlv), 105 24, 0, eq_tlv),
94SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, 106SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
@@ -148,6 +160,11 @@ ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
148ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE), 160ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
149ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE), 161ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
150 162
163SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1),
164SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1),
165SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1),
166SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1),
167
151SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode), 168SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
152SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), 169SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
153SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), 170SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
@@ -243,6 +260,9 @@ SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
243SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT, 260SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT,
244 ARIZONA_SPK2R_MUTE_SHIFT, 1, 1), 261 ARIZONA_SPK2R_MUTE_SHIFT, 1, 1),
245 262
263SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp),
264SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp),
265
246ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE), 266ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
247ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE), 267ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
248ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE), 268ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
@@ -308,10 +328,10 @@ ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
308ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); 328ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
309ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); 329ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
310 330
311ARIZONA_MIXER_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE); 331ARIZONA_MUX_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
312ARIZONA_MIXER_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE); 332ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
313ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); 333ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
314ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); 334ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
315 335
316static const char *wm5110_aec_loopback_texts[] = { 336static const char *wm5110_aec_loopback_texts[] = {
317 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "HPOUT3L", "HPOUT3R", 337 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "HPOUT3L", "HPOUT3R",
@@ -352,6 +372,7 @@ SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0),
352 372
353SND_SOC_DAPM_SIGGEN("TONE"), 373SND_SOC_DAPM_SIGGEN("TONE"),
354SND_SOC_DAPM_SIGGEN("NOISE"), 374SND_SOC_DAPM_SIGGEN("NOISE"),
375SND_SOC_DAPM_SIGGEN("HAPTICS"),
355 376
356SND_SOC_DAPM_INPUT("IN1L"), 377SND_SOC_DAPM_INPUT("IN1L"),
357SND_SOC_DAPM_INPUT("IN1R"), 378SND_SOC_DAPM_INPUT("IN1R"),
@@ -585,10 +606,10 @@ ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
585ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), 606ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
586ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), 607ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
587 608
588ARIZONA_MIXER_WIDGETS(ASRC1L, "ASRC1L"), 609ARIZONA_MUX_WIDGETS(ASRC1L, "ASRC1L"),
589ARIZONA_MIXER_WIDGETS(ASRC1R, "ASRC1R"), 610ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"),
590ARIZONA_MIXER_WIDGETS(ASRC2L, "ASRC2L"), 611ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"),
591ARIZONA_MIXER_WIDGETS(ASRC2R, "ASRC2R"), 612ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"),
592 613
593SND_SOC_DAPM_OUTPUT("HPOUT1L"), 614SND_SOC_DAPM_OUTPUT("HPOUT1L"),
594SND_SOC_DAPM_OUTPUT("HPOUT1R"), 615SND_SOC_DAPM_OUTPUT("HPOUT1R"),
@@ -610,6 +631,7 @@ SND_SOC_DAPM_OUTPUT("SPKDAT2R"),
610 { name, "Noise Generator", "Noise Generator" }, \ 631 { name, "Noise Generator", "Noise Generator" }, \
611 { name, "Tone Generator 1", "Tone Generator 1" }, \ 632 { name, "Tone Generator 1", "Tone Generator 1" }, \
612 { name, "Tone Generator 2", "Tone Generator 2" }, \ 633 { name, "Tone Generator 2", "Tone Generator 2" }, \
634 { name, "Haptics", "HAPTICS" }, \
613 { name, "AEC", "AEC Loopback" }, \ 635 { name, "AEC", "AEC Loopback" }, \
614 { name, "IN1L", "IN1L PGA" }, \ 636 { name, "IN1L", "IN1L PGA" }, \
615 { name, "IN1R", "IN1R PGA" }, \ 637 { name, "IN1R", "IN1R PGA" }, \
@@ -786,10 +808,10 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = {
786 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"), 808 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
787 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"), 809 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
788 810
789 ARIZONA_MIXER_ROUTES("ASRC1L", "ASRC1L"), 811 ARIZONA_MUX_ROUTES("ASRC1L"),
790 ARIZONA_MIXER_ROUTES("ASRC1R", "ASRC1R"), 812 ARIZONA_MUX_ROUTES("ASRC1R"),
791 ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"), 813 ARIZONA_MUX_ROUTES("ASRC2L"),
792 ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"), 814 ARIZONA_MUX_ROUTES("ASRC2R"),
793 815
794 { "HPOUT1L", NULL, "OUT1L" }, 816 { "HPOUT1L", NULL, "OUT1L" },
795 { "HPOUT1R", NULL, "OUT1R" }, 817 { "HPOUT1R", NULL, "OUT1R" },
@@ -902,9 +924,29 @@ static struct snd_soc_dai_driver wm5110_dai[] = {
902static int wm5110_codec_probe(struct snd_soc_codec *codec) 924static int wm5110_codec_probe(struct snd_soc_codec *codec)
903{ 925{
904 struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec); 926 struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
927 int ret;
905 928
906 codec->control_data = priv->core.arizona->regmap; 929 codec->control_data = priv->core.arizona->regmap;
907 return snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP); 930 priv->core.arizona->dapm = &codec->dapm;
931
932 ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
933 if (ret != 0)
934 return ret;
935
936 snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS");
937
938 priv->core.arizona->dapm = &codec->dapm;
939
940 return 0;
941}
942
943static int wm5110_codec_remove(struct snd_soc_codec *codec)
944{
945 struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
946
947 priv->core.arizona->dapm = NULL;
948
949 return 0;
908} 950}
909 951
910#define WM5110_DIG_VU 0x0200 952#define WM5110_DIG_VU 0x0200
@@ -935,6 +977,7 @@ static unsigned int wm5110_digital_vu[] = {
935 977
936static struct snd_soc_codec_driver soc_codec_dev_wm5110 = { 978static struct snd_soc_codec_driver soc_codec_dev_wm5110 = {
937 .probe = wm5110_codec_probe, 979 .probe = wm5110_codec_probe,
980 .remove = wm5110_codec_remove,
938 981
939 .idle_bias_off = true, 982 .idle_bias_off = true,
940 983
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index 5421fd9fbcb5..4c0a8e496131 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -782,7 +782,7 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream,
782 wm8978->mclk_idx = -1; 782 wm8978->mclk_idx = -1;
783 f_sel = wm8978->f_mclk; 783 f_sel = wm8978->f_mclk;
784 } else { 784 } else {
785 if (!wm8978->f_pllout) { 785 if (!wm8978->f_opclk) {
786 /* We only enter here, if OPCLK is not used */ 786 /* We only enter here, if OPCLK is not used */
787 int ret = wm8978_configure_pll(codec); 787 int ret = wm8978_configure_pll(codec);
788 if (ret < 0) 788 if (ret < 0)
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 2b2dadc54dac..b2b2b37131bd 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -1045,6 +1045,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
1045 struct snd_kcontrol *kcontrol, int event) 1045 struct snd_kcontrol *kcontrol, int event)
1046{ 1046{
1047 struct snd_soc_codec *codec = w->codec; 1047 struct snd_soc_codec *codec = w->codec;
1048 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1048 struct wm8994 *control = codec->control_data; 1049 struct wm8994 *control = codec->control_data;
1049 int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA; 1050 int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA;
1050 int i; 1051 int i;
@@ -1063,6 +1064,10 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
1063 1064
1064 switch (event) { 1065 switch (event) {
1065 case SND_SOC_DAPM_PRE_PMU: 1066 case SND_SOC_DAPM_PRE_PMU:
1067 /* Don't enable timeslot 2 if not in use */
1068 if (wm8994->channels[0] <= 2)
1069 mask &= ~(WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA);
1070
1066 val = snd_soc_read(codec, WM8994_AIF1_CONTROL_1); 1071 val = snd_soc_read(codec, WM8994_AIF1_CONTROL_1);
1067 if ((val & WM8994_AIF1ADCL_SRC) && 1072 if ((val & WM8994_AIF1ADCL_SRC) &&
1068 (val & WM8994_AIF1ADCR_SRC)) 1073 (val & WM8994_AIF1ADCR_SRC))
@@ -2687,7 +2692,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
2687 return -EINVAL; 2692 return -EINVAL;
2688 } 2693 }
2689 2694
2690 bclk_rate = params_rate(params) * 4; 2695 bclk_rate = params_rate(params);
2691 switch (params_format(params)) { 2696 switch (params_format(params)) {
2692 case SNDRV_PCM_FORMAT_S16_LE: 2697 case SNDRV_PCM_FORMAT_S16_LE:
2693 bclk_rate *= 16; 2698 bclk_rate *= 16;
@@ -2708,6 +2713,17 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
2708 return -EINVAL; 2713 return -EINVAL;
2709 } 2714 }
2710 2715
2716 wm8994->channels[id] = params_channels(params);
2717 switch (params_channels(params)) {
2718 case 1:
2719 case 2:
2720 bclk_rate *= 2;
2721 break;
2722 default:
2723 bclk_rate *= 4;
2724 break;
2725 }
2726
2711 /* Try to find an appropriate sample rate; look for an exact match. */ 2727 /* Try to find an appropriate sample rate; look for an exact match. */
2712 for (i = 0; i < ARRAY_SIZE(srs); i++) 2728 for (i = 0; i < ARRAY_SIZE(srs); i++)
2713 if (srs[i].rate == params_rate(params)) 2729 if (srs[i].rate == params_rate(params))
@@ -3706,7 +3722,7 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
3706 } while (count--); 3722 } while (count--);
3707 3723
3708 if (count == 0) 3724 if (count == 0)
3709 dev_warn(codec->dev, "No impedence range reported for jack\n"); 3725 dev_warn(codec->dev, "No impedance range reported for jack\n");
3710 3726
3711#ifndef CONFIG_SND_SOC_WM8994_MODULE 3727#ifndef CONFIG_SND_SOC_WM8994_MODULE
3712 trace_snd_soc_jack_irq(dev_name(codec->dev)); 3728 trace_snd_soc_jack_irq(dev_name(codec->dev));
diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h
index f142ec198db3..ccbce5791e95 100644
--- a/sound/soc/codecs/wm8994.h
+++ b/sound/soc/codecs/wm8994.h
@@ -77,6 +77,7 @@ struct wm8994_priv {
77 int sysclk_rate[2]; 77 int sysclk_rate[2];
78 int mclk[2]; 78 int mclk[2];
79 int aifclk[2]; 79 int aifclk[2];
80 int channels[2];
80 struct wm8994_fll_config fll[2], fll_suspend[2]; 81 struct wm8994_fll_config fll[2], fll_suspend[2];
81 struct completion fll_locked[2]; 82 struct completion fll_locked[2];
82 bool fll_locked_irq; 83 bool fll_locked_irq;
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
new file mode 100644
index 000000000000..ffc89fab96fb
--- /dev/null
+++ b/sound/soc/codecs/wm_adsp.c
@@ -0,0 +1,699 @@
1/*
2 * wm_adsp.c -- Wolfson ADSP support
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/firmware.h>
18#include <linux/pm.h>
19#include <linux/pm_runtime.h>
20#include <linux/regmap.h>
21#include <linux/regulator/consumer.h>
22#include <linux/slab.h>
23#include <sound/core.h>
24#include <sound/pcm.h>
25#include <sound/pcm_params.h>
26#include <sound/soc.h>
27#include <sound/jack.h>
28#include <sound/initval.h>
29#include <sound/tlv.h>
30
31#include <linux/mfd/arizona/registers.h>
32
33#include "wm_adsp.h"
34
35#define adsp_crit(_dsp, fmt, ...) \
36 dev_crit(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
37#define adsp_err(_dsp, fmt, ...) \
38 dev_err(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
39#define adsp_warn(_dsp, fmt, ...) \
40 dev_warn(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
41#define adsp_info(_dsp, fmt, ...) \
42 dev_info(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
43#define adsp_dbg(_dsp, fmt, ...) \
44 dev_dbg(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
45
46#define ADSP1_CONTROL_1 0x00
47#define ADSP1_CONTROL_2 0x02
48#define ADSP1_CONTROL_3 0x03
49#define ADSP1_CONTROL_4 0x04
50#define ADSP1_CONTROL_5 0x06
51#define ADSP1_CONTROL_6 0x07
52#define ADSP1_CONTROL_7 0x08
53#define ADSP1_CONTROL_8 0x09
54#define ADSP1_CONTROL_9 0x0A
55#define ADSP1_CONTROL_10 0x0B
56#define ADSP1_CONTROL_11 0x0C
57#define ADSP1_CONTROL_12 0x0D
58#define ADSP1_CONTROL_13 0x0F
59#define ADSP1_CONTROL_14 0x10
60#define ADSP1_CONTROL_15 0x11
61#define ADSP1_CONTROL_16 0x12
62#define ADSP1_CONTROL_17 0x13
63#define ADSP1_CONTROL_18 0x14
64#define ADSP1_CONTROL_19 0x16
65#define ADSP1_CONTROL_20 0x17
66#define ADSP1_CONTROL_21 0x18
67#define ADSP1_CONTROL_22 0x1A
68#define ADSP1_CONTROL_23 0x1B
69#define ADSP1_CONTROL_24 0x1C
70#define ADSP1_CONTROL_25 0x1E
71#define ADSP1_CONTROL_26 0x20
72#define ADSP1_CONTROL_27 0x21
73#define ADSP1_CONTROL_28 0x22
74#define ADSP1_CONTROL_29 0x23
75#define ADSP1_CONTROL_30 0x24
76#define ADSP1_CONTROL_31 0x26
77
78/*
79 * ADSP1 Control 19
80 */
81#define ADSP1_WDMA_BUFFER_LENGTH_MASK 0x00FF /* DSP1_WDMA_BUFFER_LENGTH - [7:0] */
82#define ADSP1_WDMA_BUFFER_LENGTH_SHIFT 0 /* DSP1_WDMA_BUFFER_LENGTH - [7:0] */
83#define ADSP1_WDMA_BUFFER_LENGTH_WIDTH 8 /* DSP1_WDMA_BUFFER_LENGTH - [7:0] */
84
85
86/*
87 * ADSP1 Control 30
88 */
89#define ADSP1_DBG_CLK_ENA 0x0008 /* DSP1_DBG_CLK_ENA */
90#define ADSP1_DBG_CLK_ENA_MASK 0x0008 /* DSP1_DBG_CLK_ENA */
91#define ADSP1_DBG_CLK_ENA_SHIFT 3 /* DSP1_DBG_CLK_ENA */
92#define ADSP1_DBG_CLK_ENA_WIDTH 1 /* DSP1_DBG_CLK_ENA */
93#define ADSP1_SYS_ENA 0x0004 /* DSP1_SYS_ENA */
94#define ADSP1_SYS_ENA_MASK 0x0004 /* DSP1_SYS_ENA */
95#define ADSP1_SYS_ENA_SHIFT 2 /* DSP1_SYS_ENA */
96#define ADSP1_SYS_ENA_WIDTH 1 /* DSP1_SYS_ENA */
97#define ADSP1_CORE_ENA 0x0002 /* DSP1_CORE_ENA */
98#define ADSP1_CORE_ENA_MASK 0x0002 /* DSP1_CORE_ENA */
99#define ADSP1_CORE_ENA_SHIFT 1 /* DSP1_CORE_ENA */
100#define ADSP1_CORE_ENA_WIDTH 1 /* DSP1_CORE_ENA */
101#define ADSP1_START 0x0001 /* DSP1_START */
102#define ADSP1_START_MASK 0x0001 /* DSP1_START */
103#define ADSP1_START_SHIFT 0 /* DSP1_START */
104#define ADSP1_START_WIDTH 1 /* DSP1_START */
105
106#define ADSP2_CONTROL 0
107#define ADSP2_CLOCKING 1
108#define ADSP2_STATUS1 4
109
110/*
111 * ADSP2 Control
112 */
113
114#define ADSP2_MEM_ENA 0x0010 /* DSP1_MEM_ENA */
115#define ADSP2_MEM_ENA_MASK 0x0010 /* DSP1_MEM_ENA */
116#define ADSP2_MEM_ENA_SHIFT 4 /* DSP1_MEM_ENA */
117#define ADSP2_MEM_ENA_WIDTH 1 /* DSP1_MEM_ENA */
118#define ADSP2_SYS_ENA 0x0004 /* DSP1_SYS_ENA */
119#define ADSP2_SYS_ENA_MASK 0x0004 /* DSP1_SYS_ENA */
120#define ADSP2_SYS_ENA_SHIFT 2 /* DSP1_SYS_ENA */
121#define ADSP2_SYS_ENA_WIDTH 1 /* DSP1_SYS_ENA */
122#define ADSP2_CORE_ENA 0x0002 /* DSP1_CORE_ENA */
123#define ADSP2_CORE_ENA_MASK 0x0002 /* DSP1_CORE_ENA */
124#define ADSP2_CORE_ENA_SHIFT 1 /* DSP1_CORE_ENA */
125#define ADSP2_CORE_ENA_WIDTH 1 /* DSP1_CORE_ENA */
126#define ADSP2_START 0x0001 /* DSP1_START */
127#define ADSP2_START_MASK 0x0001 /* DSP1_START */
128#define ADSP2_START_SHIFT 0 /* DSP1_START */
129#define ADSP2_START_WIDTH 1 /* DSP1_START */
130
131/*
132 * ADSP2 clocking
133 */
134#define ADSP2_CLK_SEL_MASK 0x0007 /* CLK_SEL_ENA */
135#define ADSP2_CLK_SEL_SHIFT 0 /* CLK_SEL_ENA */
136#define ADSP2_CLK_SEL_WIDTH 3 /* CLK_SEL_ENA */
137
138/*
139 * ADSP2 Status 1
140 */
141#define ADSP2_RAM_RDY 0x0001
142#define ADSP2_RAM_RDY_MASK 0x0001
143#define ADSP2_RAM_RDY_SHIFT 0
144#define ADSP2_RAM_RDY_WIDTH 1
145
146
147static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp,
148 int type)
149{
150 int i;
151
152 for (i = 0; i < dsp->num_mems; i++)
153 if (dsp->mem[i].type == type)
154 return &dsp->mem[i];
155
156 return NULL;
157}
158
159static int wm_adsp_load(struct wm_adsp *dsp)
160{
161 const struct firmware *firmware;
162 struct regmap *regmap = dsp->regmap;
163 unsigned int pos = 0;
164 const struct wmfw_header *header;
165 const struct wmfw_adsp1_sizes *adsp1_sizes;
166 const struct wmfw_adsp2_sizes *adsp2_sizes;
167 const struct wmfw_footer *footer;
168 const struct wmfw_region *region;
169 const struct wm_adsp_region *mem;
170 const char *region_name;
171 char *file, *text;
172 unsigned int reg;
173 int regions = 0;
174 int ret, offset, type, sizes;
175
176 file = kzalloc(PAGE_SIZE, GFP_KERNEL);
177 if (file == NULL)
178 return -ENOMEM;
179
180 snprintf(file, PAGE_SIZE, "%s-dsp%d.wmfw", dsp->part, dsp->num);
181 file[PAGE_SIZE - 1] = '\0';
182
183 ret = request_firmware(&firmware, file, dsp->dev);
184 if (ret != 0) {
185 adsp_err(dsp, "Failed to request '%s'\n", file);
186 goto out;
187 }
188 ret = -EINVAL;
189
190 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
191 if (pos >= firmware->size) {
192 adsp_err(dsp, "%s: file too short, %zu bytes\n",
193 file, firmware->size);
194 goto out_fw;
195 }
196
197 header = (void*)&firmware->data[0];
198
199 if (memcmp(&header->magic[0], "WMFW", 4) != 0) {
200 adsp_err(dsp, "%s: invalid magic\n", file);
201 goto out_fw;
202 }
203
204 if (header->ver != 0) {
205 adsp_err(dsp, "%s: unknown file format %d\n",
206 file, header->ver);
207 goto out_fw;
208 }
209
210 if (header->core != dsp->type) {
211 adsp_err(dsp, "%s: invalid core %d != %d\n",
212 file, header->core, dsp->type);
213 goto out_fw;
214 }
215
216 switch (dsp->type) {
217 case WMFW_ADSP1:
218 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
219 adsp1_sizes = (void *)&(header[1]);
220 footer = (void *)&(adsp1_sizes[1]);
221 sizes = sizeof(*adsp1_sizes);
222
223 adsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n",
224 file, le32_to_cpu(adsp1_sizes->dm),
225 le32_to_cpu(adsp1_sizes->pm),
226 le32_to_cpu(adsp1_sizes->zm));
227 break;
228
229 case WMFW_ADSP2:
230 pos = sizeof(*header) + sizeof(*adsp2_sizes) + sizeof(*footer);
231 adsp2_sizes = (void *)&(header[1]);
232 footer = (void *)&(adsp2_sizes[1]);
233 sizes = sizeof(*adsp2_sizes);
234
235 adsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n",
236 file, le32_to_cpu(adsp2_sizes->xm),
237 le32_to_cpu(adsp2_sizes->ym),
238 le32_to_cpu(adsp2_sizes->pm),
239 le32_to_cpu(adsp2_sizes->zm));
240 break;
241
242 default:
243 BUG_ON(NULL == "Unknown DSP type");
244 goto out_fw;
245 }
246
247 if (le32_to_cpu(header->len) != sizeof(*header) +
248 sizes + sizeof(*footer)) {
249 adsp_err(dsp, "%s: unexpected header length %d\n",
250 file, le32_to_cpu(header->len));
251 goto out_fw;
252 }
253
254 adsp_dbg(dsp, "%s: timestamp %llu\n", file,
255 le64_to_cpu(footer->timestamp));
256
257 while (pos < firmware->size &&
258 pos - firmware->size > sizeof(*region)) {
259 region = (void *)&(firmware->data[pos]);
260 region_name = "Unknown";
261 reg = 0;
262 text = NULL;
263 offset = le32_to_cpu(region->offset) & 0xffffff;
264 type = be32_to_cpu(region->type) & 0xff;
265 mem = wm_adsp_find_region(dsp, type);
266
267 switch (type) {
268 case WMFW_NAME_TEXT:
269 region_name = "Firmware name";
270 text = kzalloc(le32_to_cpu(region->len) + 1,
271 GFP_KERNEL);
272 break;
273 case WMFW_INFO_TEXT:
274 region_name = "Information";
275 text = kzalloc(le32_to_cpu(region->len) + 1,
276 GFP_KERNEL);
277 break;
278 case WMFW_ABSOLUTE:
279 region_name = "Absolute";
280 reg = offset;
281 break;
282 case WMFW_ADSP1_PM:
283 BUG_ON(!mem);
284 region_name = "PM";
285 reg = mem->base + (offset * 3);
286 break;
287 case WMFW_ADSP1_DM:
288 BUG_ON(!mem);
289 region_name = "DM";
290 reg = mem->base + (offset * 2);
291 break;
292 case WMFW_ADSP2_XM:
293 BUG_ON(!mem);
294 region_name = "XM";
295 reg = mem->base + (offset * 2);
296 break;
297 case WMFW_ADSP2_YM:
298 BUG_ON(!mem);
299 region_name = "YM";
300 reg = mem->base + (offset * 2);
301 break;
302 case WMFW_ADSP1_ZM:
303 BUG_ON(!mem);
304 region_name = "ZM";
305 reg = mem->base + (offset * 2);
306 break;
307 default:
308 adsp_warn(dsp,
309 "%s.%d: Unknown region type %x at %d(%x)\n",
310 file, regions, type, pos, pos);
311 break;
312 }
313
314 adsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file,
315 regions, le32_to_cpu(region->len), offset,
316 region_name);
317
318 if (text) {
319 memcpy(text, region->data, le32_to_cpu(region->len));
320 adsp_info(dsp, "%s: %s\n", file, text);
321 kfree(text);
322 }
323
324 if (reg) {
325 ret = regmap_raw_write(regmap, reg, region->data,
326 le32_to_cpu(region->len));
327 if (ret != 0) {
328 adsp_err(dsp,
329 "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
330 file, regions,
331 le32_to_cpu(region->len), offset,
332 region_name, ret);
333 goto out_fw;
334 }
335 }
336
337 pos += le32_to_cpu(region->len) + sizeof(*region);
338 regions++;
339 }
340
341 if (pos > firmware->size)
342 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
343 file, regions, pos - firmware->size);
344
345out_fw:
346 release_firmware(firmware);
347out:
348 kfree(file);
349
350 return ret;
351}
352
353static int wm_adsp_load_coeff(struct wm_adsp *dsp)
354{
355 struct regmap *regmap = dsp->regmap;
356 struct wmfw_coeff_hdr *hdr;
357 struct wmfw_coeff_item *blk;
358 const struct firmware *firmware;
359 const char *region_name;
360 int ret, pos, blocks, type, offset, reg;
361 char *file;
362
363 file = kzalloc(PAGE_SIZE, GFP_KERNEL);
364 if (file == NULL)
365 return -ENOMEM;
366
367 snprintf(file, PAGE_SIZE, "%s-dsp%d.bin", dsp->part, dsp->num);
368 file[PAGE_SIZE - 1] = '\0';
369
370 ret = request_firmware(&firmware, file, dsp->dev);
371 if (ret != 0) {
372 adsp_warn(dsp, "Failed to request '%s'\n", file);
373 ret = 0;
374 goto out;
375 }
376 ret = -EINVAL;
377
378 if (sizeof(*hdr) >= firmware->size) {
379 adsp_err(dsp, "%s: file too short, %zu bytes\n",
380 file, firmware->size);
381 goto out_fw;
382 }
383
384 hdr = (void*)&firmware->data[0];
385 if (memcmp(hdr->magic, "WMDR", 4) != 0) {
386 adsp_err(dsp, "%s: invalid magic\n", file);
387 return -EINVAL;
388 }
389
390 adsp_dbg(dsp, "%s: v%d.%d.%d\n", file,
391 (le32_to_cpu(hdr->ver) >> 16) & 0xff,
392 (le32_to_cpu(hdr->ver) >> 8) & 0xff,
393 le32_to_cpu(hdr->ver) & 0xff);
394
395 pos = le32_to_cpu(hdr->len);
396
397 blocks = 0;
398 while (pos < firmware->size &&
399 pos - firmware->size > sizeof(*blk)) {
400 blk = (void*)(&firmware->data[pos]);
401
402 type = be32_to_cpu(blk->type) & 0xff;
403 offset = le32_to_cpu(blk->offset) & 0xffffff;
404
405 adsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n",
406 file, blocks, le32_to_cpu(blk->id),
407 (le32_to_cpu(blk->ver) >> 16) & 0xff,
408 (le32_to_cpu(blk->ver) >> 8) & 0xff,
409 le32_to_cpu(blk->ver) & 0xff);
410 adsp_dbg(dsp, "%s.%d: %d bytes at 0x%x in %x\n",
411 file, blocks, le32_to_cpu(blk->len), offset, type);
412
413 reg = 0;
414 region_name = "Unknown";
415 switch (type) {
416 case WMFW_NAME_TEXT:
417 case WMFW_INFO_TEXT:
418 break;
419 case WMFW_ABSOLUTE:
420 region_name = "register";
421 reg = offset;
422 break;
423 default:
424 adsp_err(dsp, "Unknown region type %x\n", type);
425 break;
426 }
427
428 if (reg) {
429 ret = regmap_raw_write(regmap, reg, blk->data,
430 le32_to_cpu(blk->len));
431 if (ret != 0) {
432 adsp_err(dsp,
433 "%s.%d: Failed to write to %x in %s\n",
434 file, blocks, reg, region_name);
435 }
436 }
437
438 pos += le32_to_cpu(blk->len) + sizeof(*blk);
439 blocks++;
440 }
441
442 if (pos > firmware->size)
443 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
444 file, blocks, pos - firmware->size);
445
446out_fw:
447 release_firmware(firmware);
448out:
449 kfree(file);
450 return 0;
451}
452
453int wm_adsp1_event(struct snd_soc_dapm_widget *w,
454 struct snd_kcontrol *kcontrol,
455 int event)
456{
457 struct snd_soc_codec *codec = w->codec;
458 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
459 struct wm_adsp *dsp = &dsps[w->shift];
460 int ret;
461
462 switch (event) {
463 case SND_SOC_DAPM_POST_PMU:
464 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
465 ADSP1_SYS_ENA, ADSP1_SYS_ENA);
466
467 ret = wm_adsp_load(dsp);
468 if (ret != 0)
469 goto err;
470
471 ret = wm_adsp_load_coeff(dsp);
472 if (ret != 0)
473 goto err;
474
475 /* Start the core running */
476 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
477 ADSP1_CORE_ENA | ADSP1_START,
478 ADSP1_CORE_ENA | ADSP1_START);
479 break;
480
481 case SND_SOC_DAPM_PRE_PMD:
482 /* Halt the core */
483 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
484 ADSP1_CORE_ENA | ADSP1_START, 0);
485
486 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19,
487 ADSP1_WDMA_BUFFER_LENGTH_MASK, 0);
488
489 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
490 ADSP1_SYS_ENA, 0);
491 break;
492
493 default:
494 break;
495 }
496
497 return 0;
498
499err:
500 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
501 ADSP1_SYS_ENA, 0);
502 return ret;
503}
504EXPORT_SYMBOL_GPL(wm_adsp1_event);
505
506static int wm_adsp2_ena(struct wm_adsp *dsp)
507{
508 unsigned int val;
509 int ret, count;
510
511 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL,
512 ADSP2_SYS_ENA, ADSP2_SYS_ENA);
513 if (ret != 0)
514 return ret;
515
516 /* Wait for the RAM to start, should be near instantaneous */
517 count = 0;
518 do {
519 ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1,
520 &val);
521 if (ret != 0)
522 return ret;
523 } while (!(val & ADSP2_RAM_RDY) && ++count < 10);
524
525 if (!(val & ADSP2_RAM_RDY)) {
526 adsp_err(dsp, "Failed to start DSP RAM\n");
527 return -EBUSY;
528 }
529
530 adsp_dbg(dsp, "RAM ready after %d polls\n", count);
531 adsp_info(dsp, "RAM ready after %d polls\n", count);
532
533 return 0;
534}
535
536int wm_adsp2_event(struct snd_soc_dapm_widget *w,
537 struct snd_kcontrol *kcontrol, int event)
538{
539 struct snd_soc_codec *codec = w->codec;
540 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
541 struct wm_adsp *dsp = &dsps[w->shift];
542 unsigned int val;
543 int ret;
544
545 switch (event) {
546 case SND_SOC_DAPM_POST_PMU:
547 /*
548 * For simplicity set the DSP clock rate to be the
549 * SYSCLK rate rather than making it configurable.
550 */
551 ret = regmap_read(dsp->regmap, ARIZONA_SYSTEM_CLOCK_1, &val);
552 if (ret != 0) {
553 adsp_err(dsp, "Failed to read SYSCLK state: %d\n",
554 ret);
555 return ret;
556 }
557 val = (val & ARIZONA_SYSCLK_FREQ_MASK)
558 >> ARIZONA_SYSCLK_FREQ_SHIFT;
559
560 ret = regmap_update_bits(dsp->regmap,
561 dsp->base + ADSP2_CLOCKING,
562 ADSP2_CLK_SEL_MASK, val);
563 if (ret != 0) {
564 adsp_err(dsp, "Failed to set clock rate: %d\n",
565 ret);
566 return ret;
567 }
568
569 if (dsp->dvfs) {
570 ret = regmap_read(dsp->regmap,
571 dsp->base + ADSP2_CLOCKING, &val);
572 if (ret != 0) {
573 dev_err(dsp->dev,
574 "Failed to read clocking: %d\n", ret);
575 return ret;
576 }
577
578 if ((val & ADSP2_CLK_SEL_MASK) >= 3) {
579 ret = regulator_enable(dsp->dvfs);
580 if (ret != 0) {
581 dev_err(dsp->dev,
582 "Failed to enable supply: %d\n",
583 ret);
584 return ret;
585 }
586
587 ret = regulator_set_voltage(dsp->dvfs,
588 1800000,
589 1800000);
590 if (ret != 0) {
591 dev_err(dsp->dev,
592 "Failed to raise supply: %d\n",
593 ret);
594 return ret;
595 }
596 }
597 }
598
599 ret = wm_adsp2_ena(dsp);
600 if (ret != 0)
601 return ret;
602
603 ret = wm_adsp_load(dsp);
604 if (ret != 0)
605 goto err;
606
607 ret = wm_adsp_load_coeff(dsp);
608 if (ret != 0)
609 goto err;
610
611 ret = regmap_update_bits(dsp->regmap,
612 dsp->base + ADSP2_CONTROL,
613 ADSP2_CORE_ENA | ADSP2_START,
614 ADSP2_CORE_ENA | ADSP2_START);
615 if (ret != 0)
616 goto err;
617 break;
618
619 case SND_SOC_DAPM_PRE_PMD:
620 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL,
621 ADSP2_SYS_ENA | ADSP2_CORE_ENA |
622 ADSP2_START, 0);
623
624 if (dsp->dvfs) {
625 ret = regulator_set_voltage(dsp->dvfs, 1200000,
626 1800000);
627 if (ret != 0)
628 dev_warn(dsp->dev,
629 "Failed to lower supply: %d\n",
630 ret);
631
632 ret = regulator_disable(dsp->dvfs);
633 if (ret != 0)
634 dev_err(dsp->dev,
635 "Failed to enable supply: %d\n",
636 ret);
637 }
638 break;
639
640 default:
641 break;
642 }
643
644 return 0;
645err:
646 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL,
647 ADSP2_SYS_ENA | ADSP2_CORE_ENA | ADSP2_START, 0);
648 return ret;
649}
650EXPORT_SYMBOL_GPL(wm_adsp2_event);
651
652int wm_adsp2_init(struct wm_adsp *adsp, bool dvfs)
653{
654 int ret;
655
656 /*
657 * Disable the DSP memory by default when in reset for a small
658 * power saving.
659 */
660 ret = regmap_update_bits(adsp->regmap, adsp->base + ADSP2_CONTROL,
661 ADSP2_MEM_ENA, 0);
662 if (ret != 0) {
663 adsp_err(adsp, "Failed to clear memory retention: %d\n", ret);
664 return ret;
665 }
666
667 if (dvfs) {
668 adsp->dvfs = devm_regulator_get(adsp->dev, "DCVDD");
669 if (IS_ERR(adsp->dvfs)) {
670 ret = PTR_ERR(adsp->dvfs);
671 dev_err(adsp->dev, "Failed to get DCVDD: %d\n", ret);
672 return ret;
673 }
674
675 ret = regulator_enable(adsp->dvfs);
676 if (ret != 0) {
677 dev_err(adsp->dev, "Failed to enable DCVDD: %d\n",
678 ret);
679 return ret;
680 }
681
682 ret = regulator_set_voltage(adsp->dvfs, 1200000, 1800000);
683 if (ret != 0) {
684 dev_err(adsp->dev, "Failed to initialise DVFS: %d\n",
685 ret);
686 return ret;
687 }
688
689 ret = regulator_disable(adsp->dvfs);
690 if (ret != 0) {
691 dev_err(adsp->dev, "Failed to disable DCVDD: %d\n",
692 ret);
693 return ret;
694 }
695 }
696
697 return 0;
698}
699EXPORT_SYMBOL_GPL(wm_adsp2_init);
diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h
new file mode 100644
index 000000000000..ffd29a4609e2
--- /dev/null
+++ b/sound/soc/codecs/wm_adsp.h
@@ -0,0 +1,59 @@
1/*
2 * wm_adsp.h -- Wolfson ADSP support
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __WM_ADSP_H
14#define __WM_ADSP_H
15
16#include <sound/soc.h>
17#include <sound/soc-dapm.h>
18
19#include "wmfw.h"
20
21struct regulator;
22
23struct wm_adsp_region {
24 int type;
25 unsigned int base;
26};
27
28struct wm_adsp {
29 const char *part;
30 int num;
31 int type;
32 struct device *dev;
33 struct regmap *regmap;
34
35 int base;
36
37 const struct wm_adsp_region *mem;
38 int num_mems;
39
40 struct regulator *dvfs;
41};
42
43#define WM_ADSP1(wname, num) \
44 { .id = snd_soc_dapm_pga, .name = wname, .reg = SND_SOC_NOPM, \
45 .shift = num, .event = wm_adsp1_event, \
46 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD }
47
48#define WM_ADSP2(wname, num) \
49{ .id = snd_soc_dapm_pga, .name = wname, .reg = SND_SOC_NOPM, \
50 .shift = num, .event = wm_adsp2_event, \
51 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD }
52
53int wm_adsp2_init(struct wm_adsp *adsp, bool dvfs);
54int wm_adsp1_event(struct snd_soc_dapm_widget *w,
55 struct snd_kcontrol *kcontrol, int event);
56int wm_adsp2_event(struct snd_soc_dapm_widget *w,
57 struct snd_kcontrol *kcontrol, int event);
58
59#endif
diff --git a/sound/soc/codecs/wmfw.h b/sound/soc/codecs/wmfw.h
new file mode 100644
index 000000000000..5632ded67fdd
--- /dev/null
+++ b/sound/soc/codecs/wmfw.h
@@ -0,0 +1,128 @@
1/*
2 * wmfw.h - Wolfson firmware format information
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __WMFW_H
14#define __WMFW_H
15
16#include <linux/types.h>
17
18struct wmfw_header {
19 char magic[4];
20 __le32 len;
21 __le16 rev;
22 u8 core;
23 u8 ver;
24} __packed;
25
26struct wmfw_footer {
27 __le64 timestamp;
28 __le32 checksum;
29} __packed;
30
31struct wmfw_adsp1_sizes {
32 __le32 dm;
33 __le32 pm;
34 __le32 zm;
35} __packed;
36
37struct wmfw_adsp2_sizes {
38 __le32 xm;
39 __le32 ym;
40 __le32 pm;
41 __le32 zm;
42} __packed;
43
44struct wmfw_region {
45 union {
46 __be32 type;
47 __le32 offset;
48 };
49 __le32 len;
50 u8 data[];
51} __packed;
52
53struct wmfw_id_hdr {
54 __be32 core_id;
55 __be32 core_rev;
56 __be32 id;
57 __be32 ver;
58} __packed;
59
60struct wmfw_adsp1_id_hdr {
61 struct wmfw_id_hdr fw;
62 __be32 zm;
63 __be32 dm;
64 __be32 algs;
65} __packed;
66
67struct wmfw_adsp2_id_hdr {
68 struct wmfw_id_hdr fw;
69 __be32 zm;
70 __be32 xm;
71 __be32 ym;
72 __be32 algs;
73} __packed;
74
75struct wmfw_alg_hdr {
76 __be32 id;
77 __be32 ver;
78} __packed;
79
80struct wmfw_adsp1_alg_hdr {
81 struct wmfw_alg_hdr alg;
82 __be32 zm;
83 __be32 dm;
84} __packed;
85
86struct wmfw_adsp2_alg_hdr {
87 struct wmfw_alg_hdr alg;
88 __be32 zm;
89 __be32 xm;
90 __be32 ym;
91} __packed;
92
93struct wmfw_coeff_hdr {
94 u8 magic[4];
95 __le32 len;
96 __le32 ver;
97 u8 data[];
98} __packed;
99
100struct wmfw_coeff_item {
101 union {
102 __be32 type;
103 __le32 offset;
104 };
105 __le32 id;
106 __le32 ver;
107 __le32 sr;
108 __le32 len;
109 u8 data[];
110} __packed;
111
112#define WMFW_ADSP1 1
113#define WMFW_ADSP2 2
114
115#define WMFW_ABSOLUTE 0xf0
116#define WMFW_NAME_TEXT 0xfe
117#define WMFW_INFO_TEXT 0xff
118
119#define WMFW_ADSP1_PM 2
120#define WMFW_ADSP1_DM 3
121#define WMFW_ADSP1_ZM 4
122
123#define WMFW_ADSP2_PM 2
124#define WMFW_ADSP2_ZM 4
125#define WMFW_ADSP2_XM 5
126#define WMFW_ADSP2_YM 6
127
128#endif
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 4563b28bd625..aa73efa64cb4 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -98,12 +98,12 @@ config SND_SOC_IMX_PCM
98 tristate 98 tristate
99 99
100config SND_SOC_IMX_PCM_FIQ 100config SND_SOC_IMX_PCM_FIQ
101 tristate 101 bool
102 select FIQ 102 select FIQ
103 select SND_SOC_IMX_PCM 103 select SND_SOC_IMX_PCM
104 104
105config SND_SOC_IMX_PCM_DMA 105config SND_SOC_IMX_PCM_DMA
106 tristate 106 bool
107 select SND_SOC_DMAENGINE_PCM 107 select SND_SOC_DMAENGINE_PCM
108 select SND_SOC_IMX_PCM 108 select SND_SOC_IMX_PCM
109 109
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index 5f3cf3f52ea0..c3deee897b5a 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -26,14 +26,18 @@ obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o
26# i.MX Platform Support 26# i.MX Platform Support
27snd-soc-imx-ssi-objs := imx-ssi.o 27snd-soc-imx-ssi-objs := imx-ssi.o
28snd-soc-imx-audmux-objs := imx-audmux.o 28snd-soc-imx-audmux-objs := imx-audmux.o
29snd-soc-imx-pcm-objs := imx-pcm.o
30ifneq ($(CONFIG_SND_SOC_IMX_PCM_FIQ),)
31 snd-soc-imx-pcm-objs += imx-pcm-fiq.o
32endif
33ifneq ($(CONFIG_SND_SOC_IMX_PCM_DMA),)
34 snd-soc-imx-pcm-objs += imx-pcm-dma.o
35endif
29 36
30obj-$(CONFIG_SND_SOC_IMX_SSI) += snd-soc-imx-ssi.o 37obj-$(CONFIG_SND_SOC_IMX_SSI) += snd-soc-imx-ssi.o
31obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o 38obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o
32 39
33obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o 40obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o
34snd-soc-imx-pcm-y := imx-pcm.o
35snd-soc-imx-pcm-$(CONFIG_SND_SOC_IMX_PCM_FIQ) += imx-pcm-fiq.o
36snd-soc-imx-pcm-$(CONFIG_SND_SOC_IMX_PCM_DMA) += imx-pcm-dma.o
37 41
38# i.MX Machine Support 42# i.MX Machine Support
39snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o 43snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c
index b9f16598324c..2ba08148655f 100644
--- a/sound/soc/kirkwood/kirkwood-dma.c
+++ b/sound/soc/kirkwood/kirkwood-dma.c
@@ -71,7 +71,6 @@ static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
71 printk(KERN_WARNING "%s: got err interrupt 0x%lx\n", 71 printk(KERN_WARNING "%s: got err interrupt 0x%lx\n",
72 __func__, cause); 72 __func__, cause);
73 writel(cause, priv->io + KIRKWOOD_ERR_CAUSE); 73 writel(cause, priv->io + KIRKWOOD_ERR_CAUSE);
74 return IRQ_HANDLED;
75 } 74 }
76 75
77 /* we've enabled only bytes interrupts ... */ 76 /* we've enabled only bytes interrupts ... */
@@ -178,7 +177,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
178 } 177 }
179 178
180 dram = mv_mbus_dram_info(); 179 dram = mv_mbus_dram_info();
181 addr = virt_to_phys(substream->dma_buffer.area); 180 addr = substream->dma_buffer.addr;
182 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 181 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
183 prdata->play_stream = substream; 182 prdata->play_stream = substream;
184 kirkwood_dma_conf_mbus_windows(priv->io, 183 kirkwood_dma_conf_mbus_windows(priv->io,
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 542538d10ab7..1d5db484d2df 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -95,7 +95,7 @@ static inline void kirkwood_set_dco(void __iomem *io, unsigned long rate)
95 do { 95 do {
96 cpu_relax(); 96 cpu_relax();
97 value = readl(io + KIRKWOOD_DCO_SPCR_STATUS); 97 value = readl(io + KIRKWOOD_DCO_SPCR_STATUS);
98 value &= KIRKWOOD_DCO_SPCR_STATUS; 98 value &= KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK;
99 } while (value == 0); 99 } while (value == 0);
100} 100}
101 101
@@ -180,67 +180,72 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
180 int cmd, struct snd_soc_dai *dai) 180 int cmd, struct snd_soc_dai *dai)
181{ 181{
182 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); 182 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
183 unsigned long value; 183 uint32_t ctl, value;
184 184
185 /* 185 ctl = readl(priv->io + KIRKWOOD_PLAYCTL);
186 * specs says KIRKWOOD_PLAYCTL must be read 2 times before 186 if (ctl & KIRKWOOD_PLAYCTL_PAUSE) {
187 * changing it. So read 1 time here and 1 later. 187 unsigned timeout = 5000;
188 */ 188 /*
189 value = readl(priv->io + KIRKWOOD_PLAYCTL); 189 * The Armada510 spec says that if we enter pause mode, the
190 * busy bit must be read back as clear _twice_. Make sure
191 * we respect that otherwise we get DMA underruns.
192 */
193 do {
194 value = ctl;
195 ctl = readl(priv->io + KIRKWOOD_PLAYCTL);
196 if (!((ctl | value) & KIRKWOOD_PLAYCTL_PLAY_BUSY))
197 break;
198 udelay(1);
199 } while (timeout--);
200
201 if ((ctl | value) & KIRKWOOD_PLAYCTL_PLAY_BUSY)
202 dev_notice(dai->dev, "timed out waiting for busy to deassert: %08x\n",
203 ctl);
204 }
190 205
191 switch (cmd) { 206 switch (cmd) {
192 case SNDRV_PCM_TRIGGER_START: 207 case SNDRV_PCM_TRIGGER_START:
193 /* stop audio, enable interrupts */
194 value = readl(priv->io + KIRKWOOD_PLAYCTL);
195 value |= KIRKWOOD_PLAYCTL_PAUSE;
196 writel(value, priv->io + KIRKWOOD_PLAYCTL);
197
198 value = readl(priv->io + KIRKWOOD_INT_MASK); 208 value = readl(priv->io + KIRKWOOD_INT_MASK);
199 value |= KIRKWOOD_INT_CAUSE_PLAY_BYTES; 209 value |= KIRKWOOD_INT_CAUSE_PLAY_BYTES;
200 writel(value, priv->io + KIRKWOOD_INT_MASK); 210 writel(value, priv->io + KIRKWOOD_INT_MASK);
201 211
202 /* configure audio & enable i2s playback */ 212 /* configure audio & enable i2s playback */
203 value = readl(priv->io + KIRKWOOD_PLAYCTL); 213 ctl &= ~KIRKWOOD_PLAYCTL_BURST_MASK;
204 value &= ~KIRKWOOD_PLAYCTL_BURST_MASK; 214 ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE
205 value &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE
206 | KIRKWOOD_PLAYCTL_SPDIF_EN); 215 | KIRKWOOD_PLAYCTL_SPDIF_EN);
207 216
208 if (priv->burst == 32) 217 if (priv->burst == 32)
209 value |= KIRKWOOD_PLAYCTL_BURST_32; 218 ctl |= KIRKWOOD_PLAYCTL_BURST_32;
210 else 219 else
211 value |= KIRKWOOD_PLAYCTL_BURST_128; 220 ctl |= KIRKWOOD_PLAYCTL_BURST_128;
212 value |= KIRKWOOD_PLAYCTL_I2S_EN; 221 ctl |= KIRKWOOD_PLAYCTL_I2S_EN;
213 writel(value, priv->io + KIRKWOOD_PLAYCTL); 222 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
214 break; 223 break;
215 224
216 case SNDRV_PCM_TRIGGER_STOP: 225 case SNDRV_PCM_TRIGGER_STOP:
217 /* stop audio, disable interrupts */ 226 /* stop audio, disable interrupts */
218 value = readl(priv->io + KIRKWOOD_PLAYCTL); 227 ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE;
219 value |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; 228 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
220 writel(value, priv->io + KIRKWOOD_PLAYCTL);
221 229
222 value = readl(priv->io + KIRKWOOD_INT_MASK); 230 value = readl(priv->io + KIRKWOOD_INT_MASK);
223 value &= ~KIRKWOOD_INT_CAUSE_PLAY_BYTES; 231 value &= ~KIRKWOOD_INT_CAUSE_PLAY_BYTES;
224 writel(value, priv->io + KIRKWOOD_INT_MASK); 232 writel(value, priv->io + KIRKWOOD_INT_MASK);
225 233
226 /* disable all playbacks */ 234 /* disable all playbacks */
227 value = readl(priv->io + KIRKWOOD_PLAYCTL); 235 ctl &= ~(KIRKWOOD_PLAYCTL_I2S_EN | KIRKWOOD_PLAYCTL_SPDIF_EN);
228 value &= ~(KIRKWOOD_PLAYCTL_I2S_EN | KIRKWOOD_PLAYCTL_SPDIF_EN); 236 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
229 writel(value, priv->io + KIRKWOOD_PLAYCTL);
230 break; 237 break;
231 238
232 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 239 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
233 case SNDRV_PCM_TRIGGER_SUSPEND: 240 case SNDRV_PCM_TRIGGER_SUSPEND:
234 value = readl(priv->io + KIRKWOOD_PLAYCTL); 241 ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE;
235 value |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; 242 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
236 writel(value, priv->io + KIRKWOOD_PLAYCTL);
237 break; 243 break;
238 244
239 case SNDRV_PCM_TRIGGER_RESUME: 245 case SNDRV_PCM_TRIGGER_RESUME:
240 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 246 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
241 value = readl(priv->io + KIRKWOOD_PLAYCTL); 247 ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE);
242 value &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE); 248 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
243 writel(value, priv->io + KIRKWOOD_PLAYCTL);
244 break; 249 break;
245 250
246 default: 251 default:
@@ -260,11 +265,6 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream,
260 265
261 switch (cmd) { 266 switch (cmd) {
262 case SNDRV_PCM_TRIGGER_START: 267 case SNDRV_PCM_TRIGGER_START:
263 /* stop audio, enable interrupts */
264 value = readl(priv->io + KIRKWOOD_RECCTL);
265 value |= KIRKWOOD_RECCTL_PAUSE;
266 writel(value, priv->io + KIRKWOOD_RECCTL);
267
268 value = readl(priv->io + KIRKWOOD_INT_MASK); 268 value = readl(priv->io + KIRKWOOD_INT_MASK);
269 value |= KIRKWOOD_INT_CAUSE_REC_BYTES; 269 value |= KIRKWOOD_INT_CAUSE_REC_BYTES;
270 writel(value, priv->io + KIRKWOOD_INT_MASK); 270 writel(value, priv->io + KIRKWOOD_INT_MASK);
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index aa037b292f3d..b304e375568a 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -229,6 +229,7 @@ int mxs_saif_put_mclk(unsigned int saif_id)
229 saif->mclk_in_use = 0; 229 saif->mclk_in_use = 0;
230 return 0; 230 return 0;
231} 231}
232EXPORT_SYMBOL_GPL(mxs_saif_put_mclk);
232 233
233/* 234/*
234 * Get MCLK and set clock rate, then enable it 235 * Get MCLK and set clock rate, then enable it
@@ -282,6 +283,7 @@ int mxs_saif_get_mclk(unsigned int saif_id, unsigned int mclk,
282 283
283 return 0; 284 return 0;
284} 285}
286EXPORT_SYMBOL_GPL(mxs_saif_get_mclk);
285 287
286/* 288/*
287 * SAIF DAI format configuration. 289 * SAIF DAI format configuration.
@@ -523,16 +525,24 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
523 525
524 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 526 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
525 /* 527 /*
526 * write a data to saif data register to trigger 528 * write data to saif data register to trigger
527 * the transfer 529 * the transfer.
530 * For 24-bit format the 32-bit FIFO register stores
531 * only one channel, so we need to write twice.
532 * This is also safe for the other non 24-bit formats.
528 */ 533 */
529 __raw_writel(0, saif->base + SAIF_DATA); 534 __raw_writel(0, saif->base + SAIF_DATA);
535 __raw_writel(0, saif->base + SAIF_DATA);
530 } else { 536 } else {
531 /* 537 /*
532 * read a data from saif data register to trigger 538 * read data from saif data register to trigger
533 * the receive 539 * the receive.
540 * For 24-bit format the 32-bit FIFO register stores
541 * only one channel, so we need to read twice.
542 * This is also safe for the other non 24-bit formats.
534 */ 543 */
535 __raw_readl(saif->base + SAIF_DATA); 544 __raw_readl(saif->base + SAIF_DATA);
545 __raw_readl(saif->base + SAIF_DATA);
536 } 546 }
537 547
538 master_saif->ongoing = 1; 548 master_saif->ongoing = 1;
@@ -812,3 +822,4 @@ module_platform_driver(mxs_saif_driver);
812MODULE_AUTHOR("Freescale Semiconductor, Inc."); 822MODULE_AUTHOR("Freescale Semiconductor, Inc.");
813MODULE_DESCRIPTION("MXS ASoC SAIF driver"); 823MODULE_DESCRIPTION("MXS ASoC SAIF driver");
814MODULE_LICENSE("GPL"); 824MODULE_LICENSE("GPL");
825MODULE_ALIAS("platform:mxs-saif");
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index dc0ee7626626..d8e96b2cd03e 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -575,56 +575,53 @@ static struct snd_soc_card ams_delta_audio_card = {
575}; 575};
576 576
577/* Module init/exit */ 577/* Module init/exit */
578static struct platform_device *ams_delta_audio_platform_device; 578static __devinit int ams_delta_probe(struct platform_device *pdev)
579static struct platform_device *cx20442_platform_device;
580
581static int __init ams_delta_module_init(void)
582{ 579{
580 struct snd_soc_card *card = &ams_delta_audio_card;
583 int ret; 581 int ret;
584 582
585 if (!(machine_is_ams_delta())) 583 card->dev = &pdev->dev;
586 return -ENODEV;
587
588 ams_delta_audio_platform_device =
589 platform_device_alloc("soc-audio", -1);
590 if (!ams_delta_audio_platform_device)
591 return -ENOMEM;
592 584
593 platform_set_drvdata(ams_delta_audio_platform_device, 585 ret = snd_soc_register_card(card);
594 &ams_delta_audio_card); 586 if (ret) {
595 587 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
596 ret = platform_device_add(ams_delta_audio_platform_device); 588 card->dev = NULL;
597 if (ret) 589 return ret;
598 goto err; 590 }
599
600 /*
601 * Codec platform device could be registered from elsewhere (board?),
602 * but I do it here as it makes sense only if used with the card.
603 */
604 cx20442_platform_device =
605 platform_device_register_simple("cx20442-codec", -1, NULL, 0);
606 return 0; 591 return 0;
607err:
608 platform_device_put(ams_delta_audio_platform_device);
609 return ret;
610} 592}
611late_initcall(ams_delta_module_init);
612 593
613static void __exit ams_delta_module_exit(void) 594static int __devexit ams_delta_remove(struct platform_device *pdev)
614{ 595{
596 struct snd_soc_card *card = platform_get_drvdata(pdev);
597
615 if (tty_unregister_ldisc(N_V253) != 0) 598 if (tty_unregister_ldisc(N_V253) != 0)
616 dev_warn(&ams_delta_audio_platform_device->dev, 599 dev_warn(&pdev->dev,
617 "failed to unregister V253 line discipline\n"); 600 "failed to unregister V253 line discipline\n");
618 601
619 snd_soc_jack_free_gpios(&ams_delta_hook_switch, 602 snd_soc_jack_free_gpios(&ams_delta_hook_switch,
620 ARRAY_SIZE(ams_delta_hook_switch_gpios), 603 ARRAY_SIZE(ams_delta_hook_switch_gpios),
621 ams_delta_hook_switch_gpios); 604 ams_delta_hook_switch_gpios);
622 605
623 platform_device_unregister(cx20442_platform_device); 606 snd_soc_unregister_card(card);
624 platform_device_unregister(ams_delta_audio_platform_device); 607 card->dev = NULL;
608 return 0;
625} 609}
626module_exit(ams_delta_module_exit); 610
611#define DRV_NAME "ams-delta-audio"
612
613static struct platform_driver ams_delta_driver = {
614 .driver = {
615 .name = DRV_NAME,
616 .owner = THIS_MODULE,
617 },
618 .probe = ams_delta_probe,
619 .remove = __devexit_p(ams_delta_remove),
620};
621
622module_platform_driver(ams_delta_driver);
627 623
628MODULE_AUTHOR("Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>"); 624MODULE_AUTHOR("Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>");
629MODULE_DESCRIPTION("ALSA SoC driver for Amstrad E3 (Delta) videophone"); 625MODULE_DESCRIPTION("ALSA SoC driver for Amstrad E3 (Delta) videophone");
630MODULE_LICENSE("GPL"); 626MODULE_LICENSE("GPL");
627MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index afb8d4f1bedf..a9a243860428 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -28,8 +28,6 @@
28 28
29#include <linux/platform_data/asoc-ti-mcbsp.h> 29#include <linux/platform_data/asoc-ti-mcbsp.h>
30 30
31#include <plat/cpu.h>
32
33#include "mcbsp.h" 31#include "mcbsp.h"
34 32
35static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) 33static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
@@ -612,7 +610,7 @@ void omap_mcbsp_free(struct omap_mcbsp *mcbsp)
612 * system will refuse to enter idle if the CLKS pin source is not reset 610 * system will refuse to enter idle if the CLKS pin source is not reset
613 * back to internal source. 611 * back to internal source.
614 */ 612 */
615 if (!cpu_class_is_omap1()) 613 if (!mcbsp_omap1())
616 omap2_mcbsp_set_clks_src(mcbsp, MCBSP_CLKS_PRCM_SRC); 614 omap2_mcbsp_set_clks_src(mcbsp, MCBSP_CLKS_PRCM_SRC);
617 615
618 spin_lock(&mcbsp->lock); 616 spin_lock(&mcbsp->lock);
diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h
index 49a67259ce5a..a89791c239a5 100644
--- a/sound/soc/omap/mcbsp.h
+++ b/sound/soc/omap/mcbsp.h
@@ -26,6 +26,12 @@
26 26
27#include "omap-pcm.h" 27#include "omap-pcm.h"
28 28
29#ifdef CONFIG_ARCH_OMAP1
30#define mcbsp_omap1() 1
31#else
32#define mcbsp_omap1() 0
33#endif
34
29/* McBSP register numbers. Register address offset = num * reg_step */ 35/* McBSP register numbers. Register address offset = num * reg_step */
30enum { 36enum {
31 /* Common registers */ 37 /* Common registers */
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index 4a73ef3ae12f..1d6ea8609d28 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -216,7 +216,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
216 twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk"); 216 twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk");
217 twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk"); 217 twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk");
218 twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out"); 218 twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out");
219 twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vinrator"); 219 twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vibrator");
220 twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic"); 220 twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic");
221 twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic"); 221 twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic");
222 twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic"); 222 twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic");
@@ -331,8 +331,8 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
331 num_links = 1; 331 num_links = 1;
332 } 332 }
333 333
334 of_property_read_u32(node, "ti,jack-detection", 334 priv->jack_detection = of_property_read_bool(node,
335 &priv->jack_detection); 335 "ti,jack-detection");
336 of_property_read_u32(node, "ti,mclk-freq", 336 of_property_read_u32(node, "ti,mclk-freq",
337 &priv->mclk_freq); 337 &priv->mclk_freq);
338 if (!priv->mclk_freq) { 338 if (!priv->mclk_freq) {
diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
index 68f2cd1a9206..5a6aeaf552a8 100644
--- a/sound/soc/omap/omap-dmic.c
+++ b/sound/soc/omap/omap-dmic.c
@@ -464,9 +464,9 @@ static __devinit int asoc_dmic_probe(struct platform_device *pdev)
464 464
465 mutex_init(&dmic->mutex); 465 mutex_init(&dmic->mutex);
466 466
467 dmic->fclk = clk_get(dmic->dev, "dmic_fck"); 467 dmic->fclk = clk_get(dmic->dev, "fck");
468 if (IS_ERR(dmic->fclk)) { 468 if (IS_ERR(dmic->fclk)) {
469 dev_err(dmic->dev, "cant get dmic_fck\n"); 469 dev_err(dmic->dev, "cant get fck\n");
470 return -ENODEV; 470 return -ENODEV;
471 } 471 }
472 472
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index a6ee15747859..09167609c93e 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -34,7 +34,6 @@
34#include <sound/initval.h> 34#include <sound/initval.h>
35#include <sound/soc.h> 35#include <sound/soc.h>
36 36
37#include <plat/cpu.h>
38#include <linux/platform_data/asoc-ti-mcbsp.h> 37#include <linux/platform_data/asoc-ti-mcbsp.h>
39#include "mcbsp.h" 38#include "mcbsp.h"
40#include "omap-mcbsp.h" 39#include "omap-mcbsp.h"
@@ -512,7 +511,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
512 regs->srgr2 |= CLKSM; 511 regs->srgr2 |= CLKSM;
513 break; 512 break;
514 case OMAP_MCBSP_SYSCLK_CLKS_FCLK: 513 case OMAP_MCBSP_SYSCLK_CLKS_FCLK:
515 if (cpu_class_is_omap1()) { 514 if (mcbsp_omap1()) {
516 err = -EINVAL; 515 err = -EINVAL;
517 break; 516 break;
518 } 517 }
@@ -520,7 +519,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
520 MCBSP_CLKS_PRCM_SRC); 519 MCBSP_CLKS_PRCM_SRC);
521 break; 520 break;
522 case OMAP_MCBSP_SYSCLK_CLKS_EXT: 521 case OMAP_MCBSP_SYSCLK_CLKS_EXT:
523 if (cpu_class_is_omap1()) { 522 if (mcbsp_omap1()) {
524 err = 0; 523 err = 0;
525 break; 524 break;
526 } 525 }
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index c02b001ee4b5..56965bb3275c 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -40,7 +40,6 @@
40#include <sound/pcm_params.h> 40#include <sound/pcm_params.h>
41#include <sound/soc.h> 41#include <sound/soc.h>
42 42
43#include <plat/omap_hwmod.h>
44#include "omap-mcpdm.h" 43#include "omap-mcpdm.h"
45#include "omap-pcm.h" 44#include "omap-pcm.h"
46 45
@@ -260,13 +259,9 @@ static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream,
260 mutex_lock(&mcpdm->mutex); 259 mutex_lock(&mcpdm->mutex);
261 260
262 if (!dai->active) { 261 if (!dai->active) {
263 /* Enable watch dog for ES above ES 1.0 to avoid saturation */ 262 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL);
264 if (omap_rev() != OMAP4430_REV_ES1_0) {
265 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL);
266 263
267 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 264 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl | MCPDM_WD_EN);
268 ctrl | MCPDM_WD_EN);
269 }
270 omap_mcpdm_open_streams(mcpdm); 265 omap_mcpdm_open_streams(mcpdm);
271 } 266 }
272 mutex_unlock(&mcpdm->mutex); 267 mutex_unlock(&mcpdm->mutex);
diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c
index 677b567935f8..771bff27ac3e 100644
--- a/sound/soc/omap/zoom2.c
+++ b/sound/soc/omap/zoom2.c
@@ -21,15 +21,14 @@
21 21
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/gpio.h>
24#include <sound/core.h> 25#include <sound/core.h>
25#include <sound/pcm.h> 26#include <sound/pcm.h>
26#include <sound/soc.h> 27#include <sound/soc.h>
27 28
28#include <asm/mach-types.h> 29#include <asm/mach-types.h>
29#include <mach/hardware.h>
30#include <mach/gpio.h>
31#include <mach/board-zoom.h>
32#include <linux/platform_data/asoc-ti-mcbsp.h> 30#include <linux/platform_data/asoc-ti-mcbsp.h>
31#include <linux/platform_data/gpio-omap.h>
33 32
34/* Register descriptions for twl4030 codec part */ 33/* Register descriptions for twl4030 codec part */
35#include <linux/mfd/twl4030-audio.h> 34#include <linux/mfd/twl4030-audio.h>
@@ -38,8 +37,6 @@
38#include "omap-mcbsp.h" 37#include "omap-mcbsp.h"
39#include "omap-pcm.h" 38#include "omap-pcm.h"
40 39
41#define ZOOM2_HEADSET_MUX_GPIO (OMAP_MAX_GPIO_LINES + 15)
42
43static int zoom2_hw_params(struct snd_pcm_substream *substream, 40static int zoom2_hw_params(struct snd_pcm_substream *substream,
44 struct snd_pcm_hw_params *params) 41 struct snd_pcm_hw_params *params)
45{ 42{
@@ -188,9 +185,6 @@ static int __init zoom2_soc_init(void)
188 if (ret) 185 if (ret)
189 goto err1; 186 goto err1;
190 187
191 BUG_ON(gpio_request(ZOOM2_HEADSET_MUX_GPIO, "hs_mux") < 0);
192 gpio_direction_output(ZOOM2_HEADSET_MUX_GPIO, 0);
193
194 return 0; 188 return 0;
195 189
196err1: 190err1:
@@ -203,8 +197,6 @@ module_init(zoom2_soc_init);
203 197
204static void __exit zoom2_soc_exit(void) 198static void __exit zoom2_soc_exit(void)
205{ 199{
206 gpio_free(ZOOM2_HEADSET_MUX_GPIO);
207
208 platform_device_unregister(zoom2_snd_device); 200 platform_device_unregister(zoom2_snd_device);
209} 201}
210module_exit(zoom2_soc_exit); 202module_exit(zoom2_soc_exit);
diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c
index 73ac5463c9e4..e834faf859fd 100644
--- a/sound/soc/pxa/mmp-pcm.c
+++ b/sound/soc/pxa/mmp-pcm.c
@@ -15,13 +15,13 @@
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/dmaengine.h> 17#include <linux/dmaengine.h>
18#include <linux/platform_data/dma-mmp_tdma.h>
18#include <linux/platform_data/mmp_audio.h> 19#include <linux/platform_data/mmp_audio.h>
19#include <sound/pxa2xx-lib.h> 20#include <sound/pxa2xx-lib.h>
20#include <sound/core.h> 21#include <sound/core.h>
21#include <sound/pcm.h> 22#include <sound/pcm.h>
22#include <sound/pcm_params.h> 23#include <sound/pcm_params.h>
23#include <sound/soc.h> 24#include <sound/soc.h>
24#include <mach/sram.h>
25#include <sound/dmaengine_pcm.h> 25#include <sound/dmaengine_pcm.h>
26 26
27struct mmp_dma_data { 27struct mmp_dma_data {
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index e7b83179aca2..3c7c3a59ed39 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -207,6 +207,8 @@ config SND_SOC_BELLS
207 select SND_SOC_WM5102 207 select SND_SOC_WM5102
208 select SND_SOC_WM5110 208 select SND_SOC_WM5110
209 select SND_SOC_WM9081 209 select SND_SOC_WM9081
210 select SND_SOC_WM0010
211 select SND_SOC_WM1250_EV1
210 212
211config SND_SOC_LOWLAND 213config SND_SOC_LOWLAND
212 tristate "Audio support for Wolfson Lowland" 214 tristate "Audio support for Wolfson Lowland"
diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c
index 5dc10dfc0d42..a2ca1567b9e4 100644
--- a/sound/soc/samsung/bells.c
+++ b/sound/soc/samsung/bells.c
@@ -247,7 +247,7 @@ static struct snd_soc_dai_link bells_dai_wm5110[] = {
247 { 247 {
248 .name = "Sub", 248 .name = "Sub",
249 .stream_name = "Sub", 249 .stream_name = "Sub",
250 .cpu_dai_name = "wm5102-aif3", 250 .cpu_dai_name = "wm5110-aif3",
251 .codec_dai_name = "wm9081-hifi", 251 .codec_dai_name = "wm9081-hifi",
252 .codec_name = "wm9081.1-006c", 252 .codec_name = "wm9081.1-006c",
253 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 253 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 5328ae5539f1..9d7f30774a44 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -20,6 +20,7 @@
20#include <linux/sh_dma.h> 20#include <linux/sh_dma.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/workqueue.h>
23#include <sound/soc.h> 24#include <sound/soc.h>
24#include <sound/sh_fsi.h> 25#include <sound/sh_fsi.h>
25 26
@@ -223,7 +224,7 @@ struct fsi_stream {
223 */ 224 */
224 struct dma_chan *chan; 225 struct dma_chan *chan;
225 struct sh_dmae_slave slave; /* see fsi_handler_init() */ 226 struct sh_dmae_slave slave; /* see fsi_handler_init() */
226 struct tasklet_struct tasklet; 227 struct work_struct work;
227 dma_addr_t dma; 228 dma_addr_t dma;
228}; 229};
229 230
@@ -1085,9 +1086,9 @@ static void fsi_dma_complete(void *data)
1085 snd_pcm_period_elapsed(io->substream); 1086 snd_pcm_period_elapsed(io->substream);
1086} 1087}
1087 1088
1088static void fsi_dma_do_tasklet(unsigned long data) 1089static void fsi_dma_do_work(struct work_struct *work)
1089{ 1090{
1090 struct fsi_stream *io = (struct fsi_stream *)data; 1091 struct fsi_stream *io = container_of(work, struct fsi_stream, work);
1091 struct fsi_priv *fsi = fsi_stream_to_priv(io); 1092 struct fsi_priv *fsi = fsi_stream_to_priv(io);
1092 struct snd_soc_dai *dai; 1093 struct snd_soc_dai *dai;
1093 struct dma_async_tx_descriptor *desc; 1094 struct dma_async_tx_descriptor *desc;
@@ -1129,7 +1130,7 @@ static void fsi_dma_do_tasklet(unsigned long data)
1129 * FIXME 1130 * FIXME
1130 * 1131 *
1131 * In DMAEngine case, codec and FSI cannot be started simultaneously 1132 * In DMAEngine case, codec and FSI cannot be started simultaneously
1132 * since FSI is using tasklet. 1133 * since FSI is using the scheduler work queue.
1133 * Therefore, in capture case, probably FSI FIFO will have got 1134 * Therefore, in capture case, probably FSI FIFO will have got
1134 * overflow error in this point. 1135 * overflow error in this point.
1135 * in that case, DMA cannot start transfer until error was cleared. 1136 * in that case, DMA cannot start transfer until error was cleared.
@@ -1153,7 +1154,7 @@ static bool fsi_dma_filter(struct dma_chan *chan, void *param)
1153 1154
1154static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) 1155static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io)
1155{ 1156{
1156 tasklet_schedule(&io->tasklet); 1157 schedule_work(&io->work);
1157 1158
1158 return 0; 1159 return 0;
1159} 1160}
@@ -1195,14 +1196,14 @@ static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct dev
1195 return fsi_stream_probe(fsi, dev); 1196 return fsi_stream_probe(fsi, dev);
1196 } 1197 }
1197 1198
1198 tasklet_init(&io->tasklet, fsi_dma_do_tasklet, (unsigned long)io); 1199 INIT_WORK(&io->work, fsi_dma_do_work);
1199 1200
1200 return 0; 1201 return 0;
1201} 1202}
1202 1203
1203static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io) 1204static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io)
1204{ 1205{
1205 tasklet_kill(&io->tasklet); 1206 cancel_work_sync(&io->work);
1206 1207
1207 fsi_stream_stop(fsi, io); 1208 fsi_stream_stop(fsi, io);
1208 1209
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d1198627fc40..10d21be383f6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2786,8 +2786,9 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
2786 val = (ucontrol->value.integer.value[0] + min) & mask; 2786 val = (ucontrol->value.integer.value[0] + min) & mask;
2787 val = val << shift; 2787 val = val << shift;
2788 2788
2789 if (snd_soc_update_bits_locked(codec, reg, val_mask, val)) 2789 err = snd_soc_update_bits_locked(codec, reg, val_mask, val);
2790 return err; 2790 if (err < 0)
2791 return err;
2791 2792
2792 if (snd_soc_volsw_is_stereo(mc)) { 2793 if (snd_soc_volsw_is_stereo(mc)) {
2793 val_mask = mask << rshift; 2794 val_mask = mask << rshift;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d0a4be38dc0f..6e35bcae02df 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3745,7 +3745,7 @@ void snd_soc_dapm_shutdown(struct snd_soc_card *card)
3745{ 3745{
3746 struct snd_soc_codec *codec; 3746 struct snd_soc_codec *codec;
3747 3747
3748 list_for_each_entry(codec, &card->codec_dev_list, list) { 3748 list_for_each_entry(codec, &card->codec_dev_list, card_list) {
3749 soc_dapm_shutdown_codec(&codec->dapm); 3749 soc_dapm_shutdown_codec(&codec->dapm);
3750 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) 3750 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY)
3751 snd_soc_dapm_set_bias_level(&codec->dapm, 3751 snd_soc_dapm_set_bias_level(&codec->dapm,
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index fa0fd8ddae90..1ab5fe04bfcc 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -22,7 +22,7 @@
22 22
23/** 23/**
24 * snd_soc_jack_new - Create a new jack 24 * snd_soc_jack_new - Create a new jack
25 * @card: ASoC card 25 * @codec: ASoC codec
26 * @id: an identifying string for this jack 26 * @id: an identifying string for this jack
27 * @type: a bitmask of enum snd_jack_type values that can be detected by 27 * @type: a bitmask of enum snd_jack_type values that can be detected by
28 * this jack 28 * this jack
@@ -133,12 +133,13 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_add_zones);
133 133
134/** 134/**
135 * snd_soc_jack_get_type - Based on the mic bias value, this function returns 135 * snd_soc_jack_get_type - Based on the mic bias value, this function returns
136 * the type of jack from the zones delcared in the jack type 136 * the type of jack from the zones declared in the jack type
137 * 137 *
138 * @jack: ASoC jack
138 * @micbias_voltage: mic bias voltage at adc channel when jack is plugged in 139 * @micbias_voltage: mic bias voltage at adc channel when jack is plugged in
139 * 140 *
140 * Based on the mic bias value passed, this function helps identify 141 * Based on the mic bias value passed, this function helps identify
141 * the type of jack from the already delcared jack zones 142 * the type of jack from the already declared jack zones
142 */ 143 */
143int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage) 144int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage)
144{ 145{
diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c
index 356611d9654d..54f7e25b6f7d 100644
--- a/sound/soc/ux500/mop500.c
+++ b/sound/soc/ux500/mop500.c
@@ -57,6 +57,20 @@ static struct snd_soc_card mop500_card = {
57 .num_links = ARRAY_SIZE(mop500_dai_links), 57 .num_links = ARRAY_SIZE(mop500_dai_links),
58}; 58};
59 59
60static void mop500_of_node_put(void)
61{
62 int i;
63
64 for (i = 0; i < 2; i++) {
65 if (mop500_dai_links[i].cpu_of_node)
66 of_node_put((struct device_node *)
67 mop500_dai_links[i].cpu_of_node);
68 if (mop500_dai_links[i].codec_of_node)
69 of_node_put((struct device_node *)
70 mop500_dai_links[i].codec_of_node);
71 }
72}
73
60static int __devinit mop500_of_probe(struct platform_device *pdev, 74static int __devinit mop500_of_probe(struct platform_device *pdev,
61 struct device_node *np) 75 struct device_node *np)
62{ 76{
@@ -69,6 +83,7 @@ static int __devinit mop500_of_probe(struct platform_device *pdev,
69 83
70 if (!(msp_np[0] && msp_np[1] && codec_np)) { 84 if (!(msp_np[0] && msp_np[1] && codec_np)) {
71 dev_err(&pdev->dev, "Phandle missing or invalid\n"); 85 dev_err(&pdev->dev, "Phandle missing or invalid\n");
86 mop500_of_node_put();
72 return -EINVAL; 87 return -EINVAL;
73 } 88 }
74 89
@@ -83,6 +98,7 @@ static int __devinit mop500_of_probe(struct platform_device *pdev,
83 98
84 return 0; 99 return 0;
85} 100}
101
86static int __devinit mop500_probe(struct platform_device *pdev) 102static int __devinit mop500_probe(struct platform_device *pdev)
87{ 103{
88 struct device_node *np = pdev->dev.of_node; 104 struct device_node *np = pdev->dev.of_node;
@@ -128,6 +144,7 @@ static int __devexit mop500_remove(struct platform_device *pdev)
128 144
129 snd_soc_unregister_card(mop500_card); 145 snd_soc_unregister_card(mop500_card);
130 mop500_ab8500_remove(mop500_card); 146 mop500_ab8500_remove(mop500_card);
147 mop500_of_node_put();
131 148
132 return 0; 149 return 0;
133} 150}
diff --git a/sound/soc/ux500/ux500_msp_i2s.c b/sound/soc/ux500/ux500_msp_i2s.c
index b7c996e77570..a26c6bf0a29b 100644
--- a/sound/soc/ux500/ux500_msp_i2s.c
+++ b/sound/soc/ux500/ux500_msp_i2s.c
@@ -18,6 +18,7 @@
18#include <linux/pinctrl/consumer.h> 18#include <linux/pinctrl/consumer.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/io.h>
21#include <linux/of.h> 22#include <linux/of.h>
22 23
23#include <mach/hardware.h> 24#include <mach/hardware.h>
@@ -697,14 +698,11 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev,
697 platform_data = devm_kzalloc(&pdev->dev, 698 platform_data = devm_kzalloc(&pdev->dev,
698 sizeof(struct msp_i2s_platform_data), GFP_KERNEL); 699 sizeof(struct msp_i2s_platform_data), GFP_KERNEL);
699 if (!platform_data) 700 if (!platform_data)
700 ret = -ENOMEM; 701 return -ENOMEM;
701 } 702 }
702 } else 703 } else
703 if (!platform_data) 704 if (!platform_data)
704 ret = -EINVAL; 705 return -EINVAL;
705
706 if (ret)
707 goto err_res;
708 706
709 dev_dbg(&pdev->dev, "%s: Enter (name: %s, id: %d).\n", __func__, 707 dev_dbg(&pdev->dev, "%s: Enter (name: %s, id: %d).\n", __func__,
710 pdev->name, platform_data->id); 708 pdev->name, platform_data->id);