aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/adi/axi-i2s.c2
-rw-r--r--sound/soc/atmel/Kconfig2
-rw-r--r--sound/soc/atmel/atmel-pcm-dma.c12
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.c132
-rw-r--r--sound/soc/atmel/sam9g20_wm8731.c1
-rw-r--r--sound/soc/au1x/dbdma2.c6
-rw-r--r--sound/soc/au1x/dma.c6
-rw-r--r--sound/soc/codecs/88pm860x-codec.c4
-rw-r--r--sound/soc/codecs/ad193x.c4
-rw-r--r--sound/soc/codecs/ak4671.c2
-rw-r--r--sound/soc/codecs/alc5623.c8
-rw-r--r--sound/soc/codecs/alc5632.c12
-rw-r--r--sound/soc/codecs/arizona.c78
-rw-r--r--sound/soc/codecs/arizona.h5
-rw-r--r--sound/soc/codecs/bt-sco.c2
-rw-r--r--sound/soc/codecs/cs35l32.c4
-rw-r--r--sound/soc/codecs/cs42l52.c4
-rw-r--r--sound/soc/codecs/cs42l56.c4
-rw-r--r--sound/soc/codecs/cs42l73.c4
-rw-r--r--sound/soc/codecs/da732x.c4
-rw-r--r--sound/soc/codecs/pcm3008.c4
-rw-r--r--sound/soc/codecs/pcm512x-i2c.c4
-rw-r--r--sound/soc/codecs/pcm512x-spi.c4
-rw-r--r--sound/soc/codecs/pcm512x.c934
-rw-r--r--sound/soc/codecs/pcm512x.h109
-rw-r--r--sound/soc/codecs/rt286.c59
-rw-r--r--sound/soc/codecs/rt5631.c28
-rw-r--r--sound/soc/codecs/rt5640.c12
-rw-r--r--sound/soc/codecs/rt5645.c16
-rw-r--r--sound/soc/codecs/rt5651.c18
-rw-r--r--sound/soc/codecs/rt5670.c54
-rw-r--r--sound/soc/codecs/rt5677.c267
-rw-r--r--sound/soc/codecs/sgtl5000.c27
-rw-r--r--sound/soc/codecs/sn95031.c33
-rw-r--r--sound/soc/codecs/sta32x.h2
-rw-r--r--sound/soc/codecs/tlv320aic31xx.c9
-rw-r--r--sound/soc/codecs/tlv320aic3x.c4
-rw-r--r--sound/soc/codecs/tlv320dac33.c9
-rw-r--r--sound/soc/codecs/ts3a227e.c6
-rw-r--r--sound/soc/codecs/twl4030.c55
-rw-r--r--sound/soc/codecs/twl6040.c4
-rw-r--r--sound/soc/codecs/wm2000.c2
-rw-r--r--sound/soc/codecs/wm5100.c5
-rw-r--r--sound/soc/codecs/wm5102.c23
-rw-r--r--sound/soc/codecs/wm5110.c20
-rw-r--r--sound/soc/codecs/wm8350.c2
-rw-r--r--sound/soc/codecs/wm8400.c9
-rw-r--r--sound/soc/codecs/wm8731.c5
-rw-r--r--sound/soc/codecs/wm8750.c2
-rw-r--r--sound/soc/codecs/wm8770.c8
-rw-r--r--sound/soc/codecs/wm8900.c2
-rw-r--r--sound/soc/codecs/wm8903.c2
-rw-r--r--sound/soc/codecs/wm8904.c27
-rw-r--r--sound/soc/codecs/wm8955.c2
-rw-r--r--sound/soc/codecs/wm8958-dsp2.c2
-rw-r--r--sound/soc/codecs/wm8960.c2
-rw-r--r--sound/soc/codecs/wm8961.c4
-rw-r--r--sound/soc/codecs/wm8962.c6
-rw-r--r--sound/soc/codecs/wm8988.c2
-rw-r--r--sound/soc/codecs/wm8990.c9
-rw-r--r--sound/soc/codecs/wm8991.c9
-rw-r--r--sound/soc/codecs/wm8993.c2
-rw-r--r--sound/soc/codecs/wm8994.c23
-rw-r--r--sound/soc/codecs/wm8995.c14
-rw-r--r--sound/soc/codecs/wm8996.c8
-rw-r--r--sound/soc/codecs/wm8997.c11
-rw-r--r--sound/soc/codecs/wm9081.c2
-rw-r--r--sound/soc/codecs/wm9090.c2
-rw-r--r--sound/soc/codecs/wm9705.c16
-rw-r--r--sound/soc/codecs/wm9712.c12
-rw-r--r--sound/soc/codecs/wm9713.c14
-rw-r--r--sound/soc/codecs/wm_adsp.c6
-rw-r--r--sound/soc/codecs/wm_hubs.c10
-rw-r--r--sound/soc/davinci/Kconfig3
-rw-r--r--sound/soc/davinci/davinci-evm.c6
-rw-r--r--sound/soc/davinci/davinci-mcasp.c103
-rw-r--r--sound/soc/dwc/designware_i2s.c135
-rw-r--r--sound/soc/fsl/fsl_esai.h2
-rw-r--r--sound/soc/fsl/fsl_ssi.c4
-rw-r--r--sound/soc/fsl/imx-wm8962.c1
-rw-r--r--sound/soc/generic/simple-card.c7
-rw-r--r--sound/soc/intel/Kconfig8
-rw-r--r--sound/soc/intel/bytcr_dpcm_rt5640.c3
-rw-r--r--sound/soc/intel/cht_bsw_rt5672.c1
-rw-r--r--sound/soc/intel/sst-firmware.c16
-rw-r--r--sound/soc/intel/sst-haswell-ipc.c34
-rw-r--r--sound/soc/intel/sst/sst.h3
-rw-r--r--sound/soc/intel/sst/sst_acpi.c11
-rw-r--r--sound/soc/omap/omap-hdmi-audio.c1
-rw-r--r--sound/soc/omap/omap-mcbsp.c2
-rw-r--r--sound/soc/pxa/mioa701_wm9713.c2
-rw-r--r--sound/soc/pxa/spitz.c1
-rw-r--r--sound/soc/rockchip/rockchip_i2s.c9
-rw-r--r--sound/soc/rockchip/rockchip_i2s.h2
-rw-r--r--sound/soc/samsung/arndale_rt5631.c1
-rw-r--r--sound/soc/soc-ac97.c36
-rw-r--r--sound/soc/soc-compress.c9
-rw-r--r--sound/soc/soc-core.c77
-rw-r--r--sound/soc/soc-dapm.c125
-rw-r--r--sound/soc/soc-generic-dmaengine-pcm.c15
-rw-r--r--sound/soc/soc-pcm.c7
101 files changed, 2113 insertions, 728 deletions
diff --git a/sound/soc/adi/axi-i2s.c b/sound/soc/adi/axi-i2s.c
index 7752860f7230..4c23381727a1 100644
--- a/sound/soc/adi/axi-i2s.c
+++ b/sound/soc/adi/axi-i2s.c
@@ -240,6 +240,8 @@ static int axi_i2s_probe(struct platform_device *pdev)
240 if (ret) 240 if (ret)
241 goto err_clk_disable; 241 goto err_clk_disable;
242 242
243 return 0;
244
243err_clk_disable: 245err_clk_disable:
244 clk_disable_unprepare(i2s->clk); 246 clk_disable_unprepare(i2s->clk);
245 return ret; 247 return ret;
diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig
index fb3878312bf8..1579e994acf8 100644
--- a/sound/soc/atmel/Kconfig
+++ b/sound/soc/atmel/Kconfig
@@ -45,7 +45,7 @@ config SND_ATMEL_SOC_WM8904
45 45
46config SND_AT91_SOC_SAM9X5_WM8731 46config SND_AT91_SOC_SAM9X5_WM8731
47 tristate "SoC Audio support for WM8731-based at91sam9x5 board" 47 tristate "SoC Audio support for WM8731-based at91sam9x5 board"
48 depends on ATMEL_SSC && SND_ATMEL_SOC && SOC_AT91SAM9X5 48 depends on ARCH_AT91 && ATMEL_SSC && SND_ATMEL_SOC
49 select SND_ATMEL_SOC_SSC 49 select SND_ATMEL_SOC_SSC
50 select SND_ATMEL_SOC_DMA 50 select SND_ATMEL_SOC_DMA
51 select SND_SOC_WM8731 51 select SND_SOC_WM8731
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c
index 33fb3bb133df..b8e7bad05eb1 100644
--- a/sound/soc/atmel/atmel-pcm-dma.c
+++ b/sound/soc/atmel/atmel-pcm-dma.c
@@ -105,13 +105,11 @@ static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream,
105 return ret; 105 return ret;
106 } 106 }
107 107
108 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 108 slave_config->dst_addr = ssc->phybase + SSC_THR;
109 slave_config->dst_addr = ssc->phybase + SSC_THR; 109 slave_config->dst_maxburst = 1;
110 slave_config->dst_maxburst = 1; 110
111 } else { 111 slave_config->src_addr = ssc->phybase + SSC_RHR;
112 slave_config->src_addr = ssc->phybase + SSC_RHR; 112 slave_config->src_maxburst = 1;
113 slave_config->src_maxburst = 1;
114 }
115 113
116 prtd->dma_intr_handler = atmel_pcm_dma_irq; 114 prtd->dma_intr_handler = atmel_pcm_dma_irq;
117 115
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index 99ff35e2a25d..fb0b7e8b08ff 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -204,6 +204,13 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream,
204 pr_debug("atmel_ssc_startup: SSC_SR=0x%u\n", 204 pr_debug("atmel_ssc_startup: SSC_SR=0x%u\n",
205 ssc_readl(ssc_p->ssc->regs, SR)); 205 ssc_readl(ssc_p->ssc->regs, SR));
206 206
207 /* Enable PMC peripheral clock for this SSC */
208 pr_debug("atmel_ssc_dai: Starting clock\n");
209 clk_enable(ssc_p->ssc->clk);
210
211 /* Reset the SSC to keep it at a clean status */
212 ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST));
213
207 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 214 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
208 dir = 0; 215 dir = 0;
209 dir_mask = SSC_DIR_MASK_PLAYBACK; 216 dir_mask = SSC_DIR_MASK_PLAYBACK;
@@ -250,11 +257,6 @@ static void atmel_ssc_shutdown(struct snd_pcm_substream *substream,
250 dma_params = ssc_p->dma_params[dir]; 257 dma_params = ssc_p->dma_params[dir];
251 258
252 if (dma_params != NULL) { 259 if (dma_params != NULL) {
253 ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_disable);
254 pr_debug("atmel_ssc_shutdown: %s disabled SSC_SR=0x%08x\n",
255 (dir ? "receive" : "transmit"),
256 ssc_readl(ssc_p->ssc->regs, SR));
257
258 dma_params->ssc = NULL; 260 dma_params->ssc = NULL;
259 dma_params->substream = NULL; 261 dma_params->substream = NULL;
260 ssc_p->dma_params[dir] = NULL; 262 ssc_p->dma_params[dir] = NULL;
@@ -266,10 +268,6 @@ static void atmel_ssc_shutdown(struct snd_pcm_substream *substream,
266 ssc_p->dir_mask &= ~dir_mask; 268 ssc_p->dir_mask &= ~dir_mask;
267 if (!ssc_p->dir_mask) { 269 if (!ssc_p->dir_mask) {
268 if (ssc_p->initialized) { 270 if (ssc_p->initialized) {
269 /* Shutdown the SSC clock. */
270 pr_debug("atmel_ssc_dai: Stopping clock\n");
271 clk_disable(ssc_p->ssc->clk);
272
273 free_irq(ssc_p->ssc->irq, ssc_p); 271 free_irq(ssc_p->ssc->irq, ssc_p);
274 ssc_p->initialized = 0; 272 ssc_p->initialized = 0;
275 } 273 }
@@ -280,6 +278,10 @@ static void atmel_ssc_shutdown(struct snd_pcm_substream *substream,
280 ssc_p->cmr_div = ssc_p->tcmr_period = ssc_p->rcmr_period = 0; 278 ssc_p->cmr_div = ssc_p->tcmr_period = ssc_p->rcmr_period = 0;
281 } 279 }
282 spin_unlock_irq(&ssc_p->lock); 280 spin_unlock_irq(&ssc_p->lock);
281
282 /* Shutdown the SSC clock. */
283 pr_debug("atmel_ssc_dai: Stopping clock\n");
284 clk_disable(ssc_p->ssc->clk);
283} 285}
284 286
285 287
@@ -348,7 +350,6 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
348 struct atmel_pcm_dma_params *dma_params; 350 struct atmel_pcm_dma_params *dma_params;
349 int dir, channels, bits; 351 int dir, channels, bits;
350 u32 tfmr, rfmr, tcmr, rcmr; 352 u32 tfmr, rfmr, tcmr, rcmr;
351 int start_event;
352 int ret; 353 int ret;
353 int fslen, fslen_ext; 354 int fslen, fslen_ext;
354 355
@@ -451,25 +452,10 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
451 break; 452 break;
452 453
453 case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM: 454 case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM:
454 /* 455 /* I2S format, CODEC supplies BCLK and LRC clocks. */
455 * I2S format, CODEC supplies BCLK and LRC clocks.
456 *
457 * The SSC transmit clock is obtained from the BCLK signal on
458 * on the TK line, and the SSC receive clock is
459 * generated from the transmit clock.
460 *
461 * For single channel data, one sample is transferred
462 * on the falling edge of the LRC clock.
463 * For two channel data, one sample is
464 * transferred on both edges of the LRC clock.
465 */
466 start_event = ((channels == 1)
467 ? SSC_START_FALLING_RF
468 : SSC_START_EDGE_RF);
469
470 rcmr = SSC_BF(RCMR_PERIOD, 0) 456 rcmr = SSC_BF(RCMR_PERIOD, 0)
471 | SSC_BF(RCMR_STTDLY, START_DELAY) 457 | SSC_BF(RCMR_STTDLY, START_DELAY)
472 | SSC_BF(RCMR_START, start_event) 458 | SSC_BF(RCMR_START, SSC_START_FALLING_RF)
473 | SSC_BF(RCMR_CKI, SSC_CKI_RISING) 459 | SSC_BF(RCMR_CKI, SSC_CKI_RISING)
474 | SSC_BF(RCMR_CKO, SSC_CKO_NONE) 460 | SSC_BF(RCMR_CKO, SSC_CKO_NONE)
475 | SSC_BF(RCMR_CKS, ssc->clk_from_rk_pin ? 461 | SSC_BF(RCMR_CKS, ssc->clk_from_rk_pin ?
@@ -478,14 +464,14 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
478 rfmr = SSC_BF(RFMR_FSEDGE, SSC_FSEDGE_POSITIVE) 464 rfmr = SSC_BF(RFMR_FSEDGE, SSC_FSEDGE_POSITIVE)
479 | SSC_BF(RFMR_FSOS, SSC_FSOS_NONE) 465 | SSC_BF(RFMR_FSOS, SSC_FSOS_NONE)
480 | SSC_BF(RFMR_FSLEN, 0) 466 | SSC_BF(RFMR_FSLEN, 0)
481 | SSC_BF(RFMR_DATNB, 0) 467 | SSC_BF(RFMR_DATNB, (channels - 1))
482 | SSC_BIT(RFMR_MSBF) 468 | SSC_BIT(RFMR_MSBF)
483 | SSC_BF(RFMR_LOOP, 0) 469 | SSC_BF(RFMR_LOOP, 0)
484 | SSC_BF(RFMR_DATLEN, (bits - 1)); 470 | SSC_BF(RFMR_DATLEN, (bits - 1));
485 471
486 tcmr = SSC_BF(TCMR_PERIOD, 0) 472 tcmr = SSC_BF(TCMR_PERIOD, 0)
487 | SSC_BF(TCMR_STTDLY, START_DELAY) 473 | SSC_BF(TCMR_STTDLY, START_DELAY)
488 | SSC_BF(TCMR_START, start_event) 474 | SSC_BF(TCMR_START, SSC_START_FALLING_RF)
489 | SSC_BF(TCMR_CKI, SSC_CKI_FALLING) 475 | SSC_BF(TCMR_CKI, SSC_CKI_FALLING)
490 | SSC_BF(TCMR_CKO, SSC_CKO_NONE) 476 | SSC_BF(TCMR_CKO, SSC_CKO_NONE)
491 | SSC_BF(TCMR_CKS, ssc->clk_from_rk_pin ? 477 | SSC_BF(TCMR_CKS, ssc->clk_from_rk_pin ?
@@ -495,7 +481,55 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
495 | SSC_BF(TFMR_FSDEN, 0) 481 | SSC_BF(TFMR_FSDEN, 0)
496 | SSC_BF(TFMR_FSOS, SSC_FSOS_NONE) 482 | SSC_BF(TFMR_FSOS, SSC_FSOS_NONE)
497 | SSC_BF(TFMR_FSLEN, 0) 483 | SSC_BF(TFMR_FSLEN, 0)
498 | SSC_BF(TFMR_DATNB, 0) 484 | SSC_BF(TFMR_DATNB, (channels - 1))
485 | SSC_BIT(TFMR_MSBF)
486 | SSC_BF(TFMR_DATDEF, 0)
487 | SSC_BF(TFMR_DATLEN, (bits - 1));
488 break;
489
490 case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFS:
491 /* I2S format, CODEC supplies BCLK, SSC supplies LRCLK. */
492 if (bits > 16 && !ssc->pdata->has_fslen_ext) {
493 dev_err(dai->dev,
494 "sample size %d is too large for SSC device\n",
495 bits);
496 return -EINVAL;
497 }
498
499 fslen_ext = (bits - 1) / 16;
500 fslen = (bits - 1) % 16;
501
502 rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period)
503 | SSC_BF(RCMR_STTDLY, START_DELAY)
504 | SSC_BF(RCMR_START, SSC_START_FALLING_RF)
505 | SSC_BF(RCMR_CKI, SSC_CKI_RISING)
506 | SSC_BF(RCMR_CKO, SSC_CKO_NONE)
507 | SSC_BF(RCMR_CKS, ssc->clk_from_rk_pin ?
508 SSC_CKS_PIN : SSC_CKS_CLOCK);
509
510 rfmr = SSC_BF(RFMR_FSLEN_EXT, fslen_ext)
511 | SSC_BF(RFMR_FSEDGE, SSC_FSEDGE_POSITIVE)
512 | SSC_BF(RFMR_FSOS, SSC_FSOS_NEGATIVE)
513 | SSC_BF(RFMR_FSLEN, fslen)
514 | SSC_BF(RFMR_DATNB, (channels - 1))
515 | SSC_BIT(RFMR_MSBF)
516 | SSC_BF(RFMR_LOOP, 0)
517 | SSC_BF(RFMR_DATLEN, (bits - 1));
518
519 tcmr = SSC_BF(TCMR_PERIOD, ssc_p->tcmr_period)
520 | SSC_BF(TCMR_STTDLY, START_DELAY)
521 | SSC_BF(TCMR_START, SSC_START_FALLING_RF)
522 | SSC_BF(TCMR_CKI, SSC_CKI_FALLING)
523 | SSC_BF(TCMR_CKO, SSC_CKO_NONE)
524 | SSC_BF(TCMR_CKS, ssc->clk_from_rk_pin ?
525 SSC_CKS_CLOCK : SSC_CKS_PIN);
526
527 tfmr = SSC_BF(TFMR_FSLEN_EXT, fslen_ext)
528 | SSC_BF(TFMR_FSEDGE, SSC_FSEDGE_NEGATIVE)
529 | SSC_BF(TFMR_FSDEN, 0)
530 | SSC_BF(TFMR_FSOS, SSC_FSOS_NEGATIVE)
531 | SSC_BF(TFMR_FSLEN, fslen)
532 | SSC_BF(TFMR_DATNB, (channels - 1))
499 | SSC_BIT(TFMR_MSBF) 533 | SSC_BIT(TFMR_MSBF)
500 | SSC_BF(TFMR_DATDEF, 0) 534 | SSC_BF(TFMR_DATDEF, 0)
501 | SSC_BF(TFMR_DATLEN, (bits - 1)); 535 | SSC_BF(TFMR_DATLEN, (bits - 1));
@@ -512,7 +546,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
512 rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period) 546 rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period)
513 | SSC_BF(RCMR_STTDLY, 1) 547 | SSC_BF(RCMR_STTDLY, 1)
514 | SSC_BF(RCMR_START, SSC_START_RISING_RF) 548 | SSC_BF(RCMR_START, SSC_START_RISING_RF)
515 | SSC_BF(RCMR_CKI, SSC_CKI_RISING) 549 | SSC_BF(RCMR_CKI, SSC_CKI_FALLING)
516 | SSC_BF(RCMR_CKO, SSC_CKO_NONE) 550 | SSC_BF(RCMR_CKO, SSC_CKO_NONE)
517 | SSC_BF(RCMR_CKS, SSC_CKS_DIV); 551 | SSC_BF(RCMR_CKS, SSC_CKS_DIV);
518 552
@@ -527,7 +561,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
527 tcmr = SSC_BF(TCMR_PERIOD, ssc_p->tcmr_period) 561 tcmr = SSC_BF(TCMR_PERIOD, ssc_p->tcmr_period)
528 | SSC_BF(TCMR_STTDLY, 1) 562 | SSC_BF(TCMR_STTDLY, 1)
529 | SSC_BF(TCMR_START, SSC_START_RISING_RF) 563 | SSC_BF(TCMR_START, SSC_START_RISING_RF)
530 | SSC_BF(TCMR_CKI, SSC_CKI_RISING) 564 | SSC_BF(TCMR_CKI, SSC_CKI_FALLING)
531 | SSC_BF(TCMR_CKO, SSC_CKO_CONTINUOUS) 565 | SSC_BF(TCMR_CKO, SSC_CKO_CONTINUOUS)
532 | SSC_BF(TCMR_CKS, SSC_CKS_DIV); 566 | SSC_BF(TCMR_CKS, SSC_CKS_DIV);
533 567
@@ -545,10 +579,6 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
545 /* 579 /*
546 * DSP/PCM Mode A format, CODEC supplies BCLK and LRC clocks. 580 * DSP/PCM Mode A format, CODEC supplies BCLK and LRC clocks.
547 * 581 *
548 * The SSC transmit clock is obtained from the BCLK signal on
549 * on the TK line, and the SSC receive clock is
550 * generated from the transmit clock.
551 *
552 * Data is transferred on first BCLK after LRC pulse rising 582 * Data is transferred on first BCLK after LRC pulse rising
553 * edge.If stereo, the right channel data is contiguous with 583 * edge.If stereo, the right channel data is contiguous with
554 * the left channel data. 584 * the left channel data.
@@ -556,7 +586,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
556 rcmr = SSC_BF(RCMR_PERIOD, 0) 586 rcmr = SSC_BF(RCMR_PERIOD, 0)
557 | SSC_BF(RCMR_STTDLY, START_DELAY) 587 | SSC_BF(RCMR_STTDLY, START_DELAY)
558 | SSC_BF(RCMR_START, SSC_START_RISING_RF) 588 | SSC_BF(RCMR_START, SSC_START_RISING_RF)
559 | SSC_BF(RCMR_CKI, SSC_CKI_RISING) 589 | SSC_BF(RCMR_CKI, SSC_CKI_FALLING)
560 | SSC_BF(RCMR_CKO, SSC_CKO_NONE) 590 | SSC_BF(RCMR_CKO, SSC_CKO_NONE)
561 | SSC_BF(RCMR_CKS, ssc->clk_from_rk_pin ? 591 | SSC_BF(RCMR_CKS, ssc->clk_from_rk_pin ?
562 SSC_CKS_PIN : SSC_CKS_CLOCK); 592 SSC_CKS_PIN : SSC_CKS_CLOCK);
@@ -597,23 +627,17 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
597 rcmr, rfmr, tcmr, tfmr); 627 rcmr, rfmr, tcmr, tfmr);
598 628
599 if (!ssc_p->initialized) { 629 if (!ssc_p->initialized) {
600 630 if (!ssc_p->ssc->pdata->use_dma) {
601 /* Enable PMC peripheral clock for this SSC */ 631 ssc_writel(ssc_p->ssc->regs, PDC_RPR, 0);
602 pr_debug("atmel_ssc_dai: Starting clock\n"); 632 ssc_writel(ssc_p->ssc->regs, PDC_RCR, 0);
603 clk_enable(ssc_p->ssc->clk); 633 ssc_writel(ssc_p->ssc->regs, PDC_RNPR, 0);
604 634 ssc_writel(ssc_p->ssc->regs, PDC_RNCR, 0);
605 /* Reset the SSC and its PDC registers */ 635
606 ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); 636 ssc_writel(ssc_p->ssc->regs, PDC_TPR, 0);
607 637 ssc_writel(ssc_p->ssc->regs, PDC_TCR, 0);
608 ssc_writel(ssc_p->ssc->regs, PDC_RPR, 0); 638 ssc_writel(ssc_p->ssc->regs, PDC_TNPR, 0);
609 ssc_writel(ssc_p->ssc->regs, PDC_RCR, 0); 639 ssc_writel(ssc_p->ssc->regs, PDC_TNCR, 0);
610 ssc_writel(ssc_p->ssc->regs, PDC_RNPR, 0); 640 }
611 ssc_writel(ssc_p->ssc->regs, PDC_RNCR, 0);
612
613 ssc_writel(ssc_p->ssc->regs, PDC_TPR, 0);
614 ssc_writel(ssc_p->ssc->regs, PDC_TCR, 0);
615 ssc_writel(ssc_p->ssc->regs, PDC_TNPR, 0);
616 ssc_writel(ssc_p->ssc->regs, PDC_TNCR, 0);
617 641
618 ret = request_irq(ssc_p->ssc->irq, atmel_ssc_interrupt, 0, 642 ret = request_irq(ssc_p->ssc->irq, atmel_ssc_interrupt, 0,
619 ssc_p->name, ssc_p); 643 ssc_p->name, ssc_p);
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
index 98ca6341147b..f5ad214663f9 100644
--- a/sound/soc/atmel/sam9g20_wm8731.c
+++ b/sound/soc/atmel/sam9g20_wm8731.c
@@ -47,7 +47,6 @@
47#include <sound/soc.h> 47#include <sound/soc.h>
48 48
49#include <asm/mach-types.h> 49#include <asm/mach-types.h>
50#include <mach/hardware.h>
51 50
52#include "../codecs/wm8731.h" 51#include "../codecs/wm8731.h"
53#include "atmel-pcm.h" 52#include "atmel-pcm.h"
diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c
index b06b8d8128c6..dd94fea72d5d 100644
--- a/sound/soc/au1x/dbdma2.c
+++ b/sound/soc/au1x/dbdma2.c
@@ -315,11 +315,6 @@ static struct snd_pcm_ops au1xpsc_pcm_ops = {
315 .pointer = au1xpsc_pcm_pointer, 315 .pointer = au1xpsc_pcm_pointer,
316}; 316};
317 317
318static void au1xpsc_pcm_free_dma_buffers(struct snd_pcm *pcm)
319{
320 snd_pcm_lib_preallocate_free_for_all(pcm);
321}
322
323static int au1xpsc_pcm_new(struct snd_soc_pcm_runtime *rtd) 318static int au1xpsc_pcm_new(struct snd_soc_pcm_runtime *rtd)
324{ 319{
325 struct snd_card *card = rtd->card->snd_card; 320 struct snd_card *card = rtd->card->snd_card;
@@ -335,7 +330,6 @@ static int au1xpsc_pcm_new(struct snd_soc_pcm_runtime *rtd)
335static struct snd_soc_platform_driver au1xpsc_soc_platform = { 330static struct snd_soc_platform_driver au1xpsc_soc_platform = {
336 .ops = &au1xpsc_pcm_ops, 331 .ops = &au1xpsc_pcm_ops,
337 .pcm_new = au1xpsc_pcm_new, 332 .pcm_new = au1xpsc_pcm_new,
338 .pcm_free = au1xpsc_pcm_free_dma_buffers,
339}; 333};
340 334
341static int au1xpsc_pcm_drvprobe(struct platform_device *pdev) 335static int au1xpsc_pcm_drvprobe(struct platform_device *pdev)
diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c
index 6ffaaff469c7..24cc7f40d87a 100644
--- a/sound/soc/au1x/dma.c
+++ b/sound/soc/au1x/dma.c
@@ -287,11 +287,6 @@ static struct snd_pcm_ops alchemy_pcm_ops = {
287 .pointer = alchemy_pcm_pointer, 287 .pointer = alchemy_pcm_pointer,
288}; 288};
289 289
290static void alchemy_pcm_free_dma_buffers(struct snd_pcm *pcm)
291{
292 snd_pcm_lib_preallocate_free_for_all(pcm);
293}
294
295static int alchemy_pcm_new(struct snd_soc_pcm_runtime *rtd) 290static int alchemy_pcm_new(struct snd_soc_pcm_runtime *rtd)
296{ 291{
297 struct snd_pcm *pcm = rtd->pcm; 292 struct snd_pcm *pcm = rtd->pcm;
@@ -305,7 +300,6 @@ static int alchemy_pcm_new(struct snd_soc_pcm_runtime *rtd)
305static struct snd_soc_platform_driver alchemy_pcm_soc_platform = { 300static struct snd_soc_platform_driver alchemy_pcm_soc_platform = {
306 .ops = &alchemy_pcm_ops, 301 .ops = &alchemy_pcm_ops,
307 .pcm_new = alchemy_pcm_new, 302 .pcm_new = alchemy_pcm_new,
308 .pcm_free = alchemy_pcm_free_dma_buffers,
309}; 303};
310 304
311static int alchemy_pcm_drvprobe(struct platform_device *pdev) 305static int alchemy_pcm_drvprobe(struct platform_device *pdev)
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c
index a2bf27f4baab..a0f265327fdf 100644
--- a/sound/soc/codecs/88pm860x-codec.c
+++ b/sound/soc/codecs/88pm860x-codec.c
@@ -386,7 +386,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol,
386static int pm860x_rsync_event(struct snd_soc_dapm_widget *w, 386static int pm860x_rsync_event(struct snd_soc_dapm_widget *w,
387 struct snd_kcontrol *kcontrol, int event) 387 struct snd_kcontrol *kcontrol, int event)
388{ 388{
389 struct snd_soc_codec *codec = w->codec; 389 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
390 390
391 /* 391 /*
392 * In order to avoid current on the load, mute power-on and power-off 392 * In order to avoid current on the load, mute power-on and power-off
@@ -403,7 +403,7 @@ static int pm860x_rsync_event(struct snd_soc_dapm_widget *w,
403static int pm860x_dac_event(struct snd_soc_dapm_widget *w, 403static int pm860x_dac_event(struct snd_soc_dapm_widget *w,
404 struct snd_kcontrol *kcontrol, int event) 404 struct snd_kcontrol *kcontrol, int event)
405{ 405{
406 struct snd_soc_codec *codec = w->codec; 406 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
407 unsigned int dac = 0; 407 unsigned int dac = 0;
408 int data; 408 int data;
409 409
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c
index 387530b0b0fd..17c953595660 100644
--- a/sound/soc/codecs/ad193x.c
+++ b/sound/soc/codecs/ad193x.c
@@ -333,8 +333,8 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec)
333 regmap_write(ad193x->regmap, AD193X_DAC_CHNL_MUTE, 0x0); 333 regmap_write(ad193x->regmap, AD193X_DAC_CHNL_MUTE, 0x0);
334 /* de-emphasis: 48kHz, powedown dac */ 334 /* de-emphasis: 48kHz, powedown dac */
335 regmap_write(ad193x->regmap, AD193X_DAC_CTRL2, 0x1A); 335 regmap_write(ad193x->regmap, AD193X_DAC_CTRL2, 0x1A);
336 /* powerdown dac, dac in tdm mode */ 336 /* dac in tdm mode */
337 regmap_write(ad193x->regmap, AD193X_DAC_CTRL0, 0x41); 337 regmap_write(ad193x->regmap, AD193X_DAC_CTRL0, 0x40);
338 /* high-pass filter enable */ 338 /* high-pass filter enable */
339 regmap_write(ad193x->regmap, AD193X_ADC_CTRL0, 0x3); 339 regmap_write(ad193x->regmap, AD193X_ADC_CTRL0, 0x3);
340 /* sata delay=1, adc aux mode */ 340 /* sata delay=1, adc aux mode */
diff --git a/sound/soc/codecs/ak4671.c b/sound/soc/codecs/ak4671.c
index 686cacb0e835..632e89f793a7 100644
--- a/sound/soc/codecs/ak4671.c
+++ b/sound/soc/codecs/ak4671.c
@@ -163,7 +163,7 @@ static const struct snd_kcontrol_new ak4671_snd_controls[] = {
163static int ak4671_out2_event(struct snd_soc_dapm_widget *w, 163static int ak4671_out2_event(struct snd_soc_dapm_widget *w,
164 struct snd_kcontrol *kcontrol, int event) 164 struct snd_kcontrol *kcontrol, int event)
165{ 165{
166 struct snd_soc_codec *codec = w->codec; 166 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
167 167
168 switch (event) { 168 switch (event) {
169 case SND_SOC_DAPM_POST_PMU: 169 case SND_SOC_DAPM_POST_PMU:
diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c
index bdf8c5ac8ca4..0e357996864b 100644
--- a/sound/soc/codecs/alc5623.c
+++ b/sound/soc/codecs/alc5623.c
@@ -55,18 +55,20 @@ static inline int alc5623_reset(struct snd_soc_codec *codec)
55static int amp_mixer_event(struct snd_soc_dapm_widget *w, 55static int amp_mixer_event(struct snd_soc_dapm_widget *w,
56 struct snd_kcontrol *kcontrol, int event) 56 struct snd_kcontrol *kcontrol, int event)
57{ 57{
58 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
59
58 /* to power-on/off class-d amp generators/speaker */ 60 /* to power-on/off class-d amp generators/speaker */
59 /* need to write to 'index-46h' register : */ 61 /* need to write to 'index-46h' register : */
60 /* so write index num (here 0x46) to reg 0x6a */ 62 /* so write index num (here 0x46) to reg 0x6a */
61 /* and then 0xffff/0 to reg 0x6c */ 63 /* and then 0xffff/0 to reg 0x6c */
62 snd_soc_write(w->codec, ALC5623_HID_CTRL_INDEX, 0x46); 64 snd_soc_write(codec, ALC5623_HID_CTRL_INDEX, 0x46);
63 65
64 switch (event) { 66 switch (event) {
65 case SND_SOC_DAPM_PRE_PMU: 67 case SND_SOC_DAPM_PRE_PMU:
66 snd_soc_write(w->codec, ALC5623_HID_CTRL_DATA, 0xFFFF); 68 snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0xFFFF);
67 break; 69 break;
68 case SND_SOC_DAPM_POST_PMD: 70 case SND_SOC_DAPM_POST_PMD:
69 snd_soc_write(w->codec, ALC5623_HID_CTRL_DATA, 0); 71 snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0);
70 break; 72 break;
71 } 73 }
72 74
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c
index d1fdbc266631..db3283abbe18 100644
--- a/sound/soc/codecs/alc5632.c
+++ b/sound/soc/codecs/alc5632.c
@@ -116,18 +116,20 @@ static inline int alc5632_reset(struct regmap *map)
116static int amp_mixer_event(struct snd_soc_dapm_widget *w, 116static int amp_mixer_event(struct snd_soc_dapm_widget *w,
117 struct snd_kcontrol *kcontrol, int event) 117 struct snd_kcontrol *kcontrol, int event)
118{ 118{
119 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
120
119 /* to power-on/off class-d amp generators/speaker */ 121 /* to power-on/off class-d amp generators/speaker */
120 /* need to write to 'index-46h' register : */ 122 /* need to write to 'index-46h' register : */
121 /* so write index num (here 0x46) to reg 0x6a */ 123 /* so write index num (here 0x46) to reg 0x6a */
122 /* and then 0xffff/0 to reg 0x6c */ 124 /* and then 0xffff/0 to reg 0x6c */
123 snd_soc_write(w->codec, ALC5632_HID_CTRL_INDEX, 0x46); 125 snd_soc_write(codec, ALC5632_HID_CTRL_INDEX, 0x46);
124 126
125 switch (event) { 127 switch (event) {
126 case SND_SOC_DAPM_PRE_PMU: 128 case SND_SOC_DAPM_PRE_PMU:
127 snd_soc_write(w->codec, ALC5632_HID_CTRL_DATA, 0xFFFF); 129 snd_soc_write(codec, ALC5632_HID_CTRL_DATA, 0xFFFF);
128 break; 130 break;
129 case SND_SOC_DAPM_POST_PMD: 131 case SND_SOC_DAPM_POST_PMD:
130 snd_soc_write(w->codec, ALC5632_HID_CTRL_DATA, 0); 132 snd_soc_write(codec, ALC5632_HID_CTRL_DATA, 0);
131 break; 133 break;
132 } 134 }
133 135
@@ -1066,7 +1068,7 @@ static int alc5632_probe(struct snd_soc_codec *codec)
1066 return 0; 1068 return 0;
1067} 1069}
1068 1070
1069static struct snd_soc_codec_driver soc_codec_device_alc5632 = { 1071static const struct snd_soc_codec_driver soc_codec_device_alc5632 = {
1070 .probe = alc5632_probe, 1072 .probe = alc5632_probe,
1071 .resume = alc5632_resume, 1073 .resume = alc5632_resume,
1072 .set_bias_level = alc5632_set_bias_level, 1074 .set_bias_level = alc5632_set_bias_level,
@@ -1080,7 +1082,7 @@ static struct snd_soc_codec_driver soc_codec_device_alc5632 = {
1080 .num_dapm_routes = ARRAY_SIZE(alc5632_dapm_routes), 1082 .num_dapm_routes = ARRAY_SIZE(alc5632_dapm_routes),
1081}; 1083};
1082 1084
1083static struct regmap_config alc5632_regmap = { 1085static const struct regmap_config alc5632_regmap = {
1084 .reg_bits = 8, 1086 .reg_bits = 8,
1085 .val_bits = 16, 1087 .val_bits = 16,
1086 1088
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 9550d7433ad0..29202610dd0d 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -84,7 +84,7 @@ static int arizona_spk_ev(struct snd_soc_dapm_widget *w,
84 struct snd_kcontrol *kcontrol, 84 struct snd_kcontrol *kcontrol,
85 int event) 85 int event)
86{ 86{
87 struct snd_soc_codec *codec = w->codec; 87 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
88 struct arizona *arizona = dev_get_drvdata(codec->dev->parent); 88 struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
89 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); 89 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
90 bool manual_ena = false; 90 bool manual_ena = false;
@@ -692,7 +692,8 @@ static void arizona_in_set_vu(struct snd_soc_codec *codec, int ena)
692int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, 692int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
693 int event) 693 int event)
694{ 694{
695 struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); 695 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
696 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
696 unsigned int reg; 697 unsigned int reg;
697 698
698 if (w->shift % 2) 699 if (w->shift % 2)
@@ -705,25 +706,25 @@ int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
705 priv->in_pending++; 706 priv->in_pending++;
706 break; 707 break;
707 case SND_SOC_DAPM_POST_PMU: 708 case SND_SOC_DAPM_POST_PMU:
708 snd_soc_update_bits(w->codec, reg, ARIZONA_IN1L_MUTE, 0); 709 snd_soc_update_bits(codec, reg, ARIZONA_IN1L_MUTE, 0);
709 710
710 /* If this is the last input pending then allow VU */ 711 /* If this is the last input pending then allow VU */
711 priv->in_pending--; 712 priv->in_pending--;
712 if (priv->in_pending == 0) { 713 if (priv->in_pending == 0) {
713 msleep(1); 714 msleep(1);
714 arizona_in_set_vu(w->codec, 1); 715 arizona_in_set_vu(codec, 1);
715 } 716 }
716 break; 717 break;
717 case SND_SOC_DAPM_PRE_PMD: 718 case SND_SOC_DAPM_PRE_PMD:
718 snd_soc_update_bits(w->codec, reg, 719 snd_soc_update_bits(codec, reg,
719 ARIZONA_IN1L_MUTE | ARIZONA_IN_VU, 720 ARIZONA_IN1L_MUTE | ARIZONA_IN_VU,
720 ARIZONA_IN1L_MUTE | ARIZONA_IN_VU); 721 ARIZONA_IN1L_MUTE | ARIZONA_IN_VU);
721 break; 722 break;
722 case SND_SOC_DAPM_POST_PMD: 723 case SND_SOC_DAPM_POST_PMD:
723 /* Disable volume updates if no inputs are enabled */ 724 /* Disable volume updates if no inputs are enabled */
724 reg = snd_soc_read(w->codec, ARIZONA_INPUT_ENABLES); 725 reg = snd_soc_read(codec, ARIZONA_INPUT_ENABLES);
725 if (reg == 0) 726 if (reg == 0)
726 arizona_in_set_vu(w->codec, 0); 727 arizona_in_set_vu(codec, 0);
727 } 728 }
728 729
729 return 0; 730 return 0;
@@ -734,7 +735,25 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w,
734 struct snd_kcontrol *kcontrol, 735 struct snd_kcontrol *kcontrol,
735 int event) 736 int event)
736{ 737{
738 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
739 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
740
737 switch (event) { 741 switch (event) {
742 case SND_SOC_DAPM_PRE_PMU:
743 switch (w->shift) {
744 case ARIZONA_OUT1L_ENA_SHIFT:
745 case ARIZONA_OUT1R_ENA_SHIFT:
746 case ARIZONA_OUT2L_ENA_SHIFT:
747 case ARIZONA_OUT2R_ENA_SHIFT:
748 case ARIZONA_OUT3L_ENA_SHIFT:
749 case ARIZONA_OUT3R_ENA_SHIFT:
750 priv->out_up_pending++;
751 priv->out_up_delay += 17;
752 break;
753 default:
754 break;
755 }
756 break;
738 case SND_SOC_DAPM_POST_PMU: 757 case SND_SOC_DAPM_POST_PMU:
739 switch (w->shift) { 758 switch (w->shift) {
740 case ARIZONA_OUT1L_ENA_SHIFT: 759 case ARIZONA_OUT1L_ENA_SHIFT:
@@ -743,13 +762,50 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w,
743 case ARIZONA_OUT2R_ENA_SHIFT: 762 case ARIZONA_OUT2R_ENA_SHIFT:
744 case ARIZONA_OUT3L_ENA_SHIFT: 763 case ARIZONA_OUT3L_ENA_SHIFT:
745 case ARIZONA_OUT3R_ENA_SHIFT: 764 case ARIZONA_OUT3R_ENA_SHIFT:
746 msleep(17); 765 priv->out_up_pending--;
766 if (!priv->out_up_pending) {
767 msleep(priv->out_up_delay);
768 priv->out_up_delay = 0;
769 }
747 break; 770 break;
748 771
749 default: 772 default:
750 break; 773 break;
751 } 774 }
752 break; 775 break;
776 case SND_SOC_DAPM_PRE_PMD:
777 switch (w->shift) {
778 case ARIZONA_OUT1L_ENA_SHIFT:
779 case ARIZONA_OUT1R_ENA_SHIFT:
780 case ARIZONA_OUT2L_ENA_SHIFT:
781 case ARIZONA_OUT2R_ENA_SHIFT:
782 case ARIZONA_OUT3L_ENA_SHIFT:
783 case ARIZONA_OUT3R_ENA_SHIFT:
784 priv->out_down_pending++;
785 priv->out_down_delay++;
786 break;
787 default:
788 break;
789 }
790 break;
791 case SND_SOC_DAPM_POST_PMD:
792 switch (w->shift) {
793 case ARIZONA_OUT1L_ENA_SHIFT:
794 case ARIZONA_OUT1R_ENA_SHIFT:
795 case ARIZONA_OUT2L_ENA_SHIFT:
796 case ARIZONA_OUT2R_ENA_SHIFT:
797 case ARIZONA_OUT3L_ENA_SHIFT:
798 case ARIZONA_OUT3R_ENA_SHIFT:
799 priv->out_down_pending--;
800 if (!priv->out_down_pending) {
801 msleep(priv->out_down_delay);
802 priv->out_down_delay = 0;
803 }
804 break;
805 default:
806 break;
807 }
808 break;
753 } 809 }
754 810
755 return 0; 811 return 0;
@@ -760,7 +816,8 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w,
760 struct snd_kcontrol *kcontrol, 816 struct snd_kcontrol *kcontrol,
761 int event) 817 int event)
762{ 818{
763 struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); 819 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
820 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
764 struct arizona *arizona = priv->arizona; 821 struct arizona *arizona = priv->arizona;
765 unsigned int mask = 1 << w->shift; 822 unsigned int mask = 1 << w->shift;
766 unsigned int val; 823 unsigned int val;
@@ -772,6 +829,9 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w,
772 case SND_SOC_DAPM_PRE_PMD: 829 case SND_SOC_DAPM_PRE_PMD:
773 val = 0; 830 val = 0;
774 break; 831 break;
832 case SND_SOC_DAPM_PRE_PMU:
833 case SND_SOC_DAPM_POST_PMD:
834 return arizona_out_ev(w, kcontrol, event);
775 default: 835 default:
776 return -EINVAL; 836 return -EINVAL;
777 } 837 }
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 942cfb197b6d..11ff899b0272 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -77,6 +77,11 @@ struct arizona_priv {
77 int num_inputs; 77 int num_inputs;
78 unsigned int in_pending; 78 unsigned int in_pending;
79 79
80 unsigned int out_up_pending;
81 unsigned int out_up_delay;
82 unsigned int out_down_pending;
83 unsigned int out_down_delay;
84
80 unsigned int spk_ena:2; 85 unsigned int spk_ena:2;
81 unsigned int spk_ena_pending:1; 86 unsigned int spk_ena_pending:1;
82}; 87};
diff --git a/sound/soc/codecs/bt-sco.c b/sound/soc/codecs/bt-sco.c
index 5075bf0a7276..e7238b8904bc 100644
--- a/sound/soc/codecs/bt-sco.c
+++ b/sound/soc/codecs/bt-sco.c
@@ -86,5 +86,5 @@ static struct platform_driver bt_sco_driver = {
86module_platform_driver(bt_sco_driver); 86module_platform_driver(bt_sco_driver);
87 87
88MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); 88MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
89MODULE_DESCRIPTION("ASoC generic bluethooth sco link driver"); 89MODULE_DESCRIPTION("ASoC generic bluetooth sco link driver");
90MODULE_LICENSE("GPL"); 90MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/cs35l32.c b/sound/soc/codecs/cs35l32.c
index ec55c590afd0..f2b8aad21274 100644
--- a/sound/soc/codecs/cs35l32.c
+++ b/sound/soc/codecs/cs35l32.c
@@ -264,7 +264,7 @@ static int cs35l32_codec_set_sysclk(struct snd_soc_codec *codec,
264 CS35L32_MCLK_DIV2_MASK | CS35L32_MCLK_RATIO_MASK, val); 264 CS35L32_MCLK_DIV2_MASK | CS35L32_MCLK_RATIO_MASK, val);
265} 265}
266 266
267static struct snd_soc_codec_driver soc_codec_dev_cs35l32 = { 267static const struct snd_soc_codec_driver soc_codec_dev_cs35l32 = {
268 .set_sysclk = cs35l32_codec_set_sysclk, 268 .set_sysclk = cs35l32_codec_set_sysclk,
269 269
270 .dapm_widgets = cs35l32_dapm_widgets, 270 .dapm_widgets = cs35l32_dapm_widgets,
@@ -288,7 +288,7 @@ static const struct reg_default cs35l32_monitor_patch[] = {
288 { 0x00, 0x00 }, 288 { 0x00, 0x00 },
289}; 289};
290 290
291static struct regmap_config cs35l32_regmap = { 291static const struct regmap_config cs35l32_regmap = {
292 .reg_bits = 8, 292 .reg_bits = 8,
293 .val_bits = 8, 293 .val_bits = 8,
294 294
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 35fbef743fbe..1589e7a881d8 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -1103,7 +1103,7 @@ static int cs42l52_remove(struct snd_soc_codec *codec)
1103 return 0; 1103 return 0;
1104} 1104}
1105 1105
1106static struct snd_soc_codec_driver soc_codec_dev_cs42l52 = { 1106static const struct snd_soc_codec_driver soc_codec_dev_cs42l52 = {
1107 .probe = cs42l52_probe, 1107 .probe = cs42l52_probe,
1108 .remove = cs42l52_remove, 1108 .remove = cs42l52_remove,
1109 .set_bias_level = cs42l52_set_bias_level, 1109 .set_bias_level = cs42l52_set_bias_level,
@@ -1130,7 +1130,7 @@ static const struct reg_default cs42l52_threshold_patch[] = {
1130 1130
1131}; 1131};
1132 1132
1133static struct regmap_config cs42l52_regmap = { 1133static const struct regmap_config cs42l52_regmap = {
1134 .reg_bits = 8, 1134 .reg_bits = 8,
1135 .val_bits = 8, 1135 .val_bits = 8,
1136 1136
diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c
index 2ddc7ac10ad7..cbc654fe48c7 100644
--- a/sound/soc/codecs/cs42l56.c
+++ b/sound/soc/codecs/cs42l56.c
@@ -1164,7 +1164,7 @@ static int cs42l56_remove(struct snd_soc_codec *codec)
1164 return 0; 1164 return 0;
1165} 1165}
1166 1166
1167static struct snd_soc_codec_driver soc_codec_dev_cs42l56 = { 1167static const struct snd_soc_codec_driver soc_codec_dev_cs42l56 = {
1168 .probe = cs42l56_probe, 1168 .probe = cs42l56_probe,
1169 .remove = cs42l56_remove, 1169 .remove = cs42l56_remove,
1170 .set_bias_level = cs42l56_set_bias_level, 1170 .set_bias_level = cs42l56_set_bias_level,
@@ -1179,7 +1179,7 @@ static struct snd_soc_codec_driver soc_codec_dev_cs42l56 = {
1179 .num_controls = ARRAY_SIZE(cs42l56_snd_controls), 1179 .num_controls = ARRAY_SIZE(cs42l56_snd_controls),
1180}; 1180};
1181 1181
1182static struct regmap_config cs42l56_regmap = { 1182static const struct regmap_config cs42l56_regmap = {
1183 .reg_bits = 8, 1183 .reg_bits = 8,
1184 .val_bits = 8, 1184 .val_bits = 8,
1185 1185
diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c
index 7c55537c69cf..8ecedba79606 100644
--- a/sound/soc/codecs/cs42l73.c
+++ b/sound/soc/codecs/cs42l73.c
@@ -1347,7 +1347,7 @@ static int cs42l73_probe(struct snd_soc_codec *codec)
1347 return 0; 1347 return 0;
1348} 1348}
1349 1349
1350static struct snd_soc_codec_driver soc_codec_dev_cs42l73 = { 1350static const struct snd_soc_codec_driver soc_codec_dev_cs42l73 = {
1351 .probe = cs42l73_probe, 1351 .probe = cs42l73_probe,
1352 .set_bias_level = cs42l73_set_bias_level, 1352 .set_bias_level = cs42l73_set_bias_level,
1353 .suspend_bias_off = true, 1353 .suspend_bias_off = true,
@@ -1361,7 +1361,7 @@ static struct snd_soc_codec_driver soc_codec_dev_cs42l73 = {
1361 .num_controls = ARRAY_SIZE(cs42l73_snd_controls), 1361 .num_controls = ARRAY_SIZE(cs42l73_snd_controls),
1362}; 1362};
1363 1363
1364static struct regmap_config cs42l73_regmap = { 1364static const struct regmap_config cs42l73_regmap = {
1365 .reg_bits = 8, 1365 .reg_bits = 8,
1366 .val_bits = 8, 1366 .val_bits = 8,
1367 1367
diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c
index 61b2f9a2eef1..ffe96175a8a5 100644
--- a/sound/soc/codecs/da732x.c
+++ b/sound/soc/codecs/da732x.c
@@ -609,7 +609,7 @@ static const struct snd_kcontrol_new da732x_snd_controls[] = {
609static int da732x_adc_event(struct snd_soc_dapm_widget *w, 609static int da732x_adc_event(struct snd_soc_dapm_widget *w,
610 struct snd_kcontrol *kcontrol, int event) 610 struct snd_kcontrol *kcontrol, int event)
611{ 611{
612 struct snd_soc_codec *codec = w->codec; 612 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
613 613
614 switch (event) { 614 switch (event) {
615 case SND_SOC_DAPM_POST_PMU: 615 case SND_SOC_DAPM_POST_PMU:
@@ -663,7 +663,7 @@ static int da732x_adc_event(struct snd_soc_dapm_widget *w,
663static int da732x_out_pga_event(struct snd_soc_dapm_widget *w, 663static int da732x_out_pga_event(struct snd_soc_dapm_widget *w,
664 struct snd_kcontrol *kcontrol, int event) 664 struct snd_kcontrol *kcontrol, int event)
665{ 665{
666 struct snd_soc_codec *codec = w->codec; 666 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
667 667
668 switch (event) { 668 switch (event) {
669 case SND_SOC_DAPM_POST_PMU: 669 case SND_SOC_DAPM_POST_PMU:
diff --git a/sound/soc/codecs/pcm3008.c b/sound/soc/codecs/pcm3008.c
index 7e73fa4b3183..8fb445f33f6f 100644
--- a/sound/soc/codecs/pcm3008.c
+++ b/sound/soc/codecs/pcm3008.c
@@ -32,7 +32,7 @@ static int pcm3008_dac_ev(struct snd_soc_dapm_widget *w,
32 struct snd_kcontrol *kcontrol, 32 struct snd_kcontrol *kcontrol,
33 int event) 33 int event)
34{ 34{
35 struct snd_soc_codec *codec = w->codec; 35 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
36 struct pcm3008_setup_data *setup = codec->dev->platform_data; 36 struct pcm3008_setup_data *setup = codec->dev->platform_data;
37 37
38 gpio_set_value_cansleep(setup->pdda_pin, 38 gpio_set_value_cansleep(setup->pdda_pin,
@@ -45,7 +45,7 @@ static int pcm3008_adc_ev(struct snd_soc_dapm_widget *w,
45 struct snd_kcontrol *kcontrol, 45 struct snd_kcontrol *kcontrol,
46 int event) 46 int event)
47{ 47{
48 struct snd_soc_codec *codec = w->codec; 48 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
49 struct pcm3008_setup_data *setup = codec->dev->platform_data; 49 struct pcm3008_setup_data *setup = codec->dev->platform_data;
50 50
51 gpio_set_value_cansleep(setup->pdad_pin, 51 gpio_set_value_cansleep(setup->pdad_pin,
diff --git a/sound/soc/codecs/pcm512x-i2c.c b/sound/soc/codecs/pcm512x-i2c.c
index d0547fa275fc..dcdfac0ffeb1 100644
--- a/sound/soc/codecs/pcm512x-i2c.c
+++ b/sound/soc/codecs/pcm512x-i2c.c
@@ -46,6 +46,8 @@ static int pcm512x_i2c_remove(struct i2c_client *i2c)
46static const struct i2c_device_id pcm512x_i2c_id[] = { 46static const struct i2c_device_id pcm512x_i2c_id[] = {
47 { "pcm5121", }, 47 { "pcm5121", },
48 { "pcm5122", }, 48 { "pcm5122", },
49 { "pcm5141", },
50 { "pcm5142", },
49 { } 51 { }
50}; 52};
51MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id); 53MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
@@ -53,6 +55,8 @@ MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
53static const struct of_device_id pcm512x_of_match[] = { 55static const struct of_device_id pcm512x_of_match[] = {
54 { .compatible = "ti,pcm5121", }, 56 { .compatible = "ti,pcm5121", },
55 { .compatible = "ti,pcm5122", }, 57 { .compatible = "ti,pcm5122", },
58 { .compatible = "ti,pcm5141", },
59 { .compatible = "ti,pcm5142", },
56 { } 60 { }
57}; 61};
58MODULE_DEVICE_TABLE(of, pcm512x_of_match); 62MODULE_DEVICE_TABLE(of, pcm512x_of_match);
diff --git a/sound/soc/codecs/pcm512x-spi.c b/sound/soc/codecs/pcm512x-spi.c
index f297058c0038..7b64a9cef704 100644
--- a/sound/soc/codecs/pcm512x-spi.c
+++ b/sound/soc/codecs/pcm512x-spi.c
@@ -43,6 +43,8 @@ static int pcm512x_spi_remove(struct spi_device *spi)
43static const struct spi_device_id pcm512x_spi_id[] = { 43static const struct spi_device_id pcm512x_spi_id[] = {
44 { "pcm5121", }, 44 { "pcm5121", },
45 { "pcm5122", }, 45 { "pcm5122", },
46 { "pcm5141", },
47 { "pcm5142", },
46 { }, 48 { },
47}; 49};
48MODULE_DEVICE_TABLE(spi, pcm512x_spi_id); 50MODULE_DEVICE_TABLE(spi, pcm512x_spi_id);
@@ -50,6 +52,8 @@ MODULE_DEVICE_TABLE(spi, pcm512x_spi_id);
50static const struct of_device_id pcm512x_of_match[] = { 52static const struct of_device_id pcm512x_of_match[] = {
51 { .compatible = "ti,pcm5121", }, 53 { .compatible = "ti,pcm5121", },
52 { .compatible = "ti,pcm5122", }, 54 { .compatible = "ti,pcm5122", },
55 { .compatible = "ti,pcm5141", },
56 { .compatible = "ti,pcm5142", },
53 { } 57 { }
54}; 58};
55MODULE_DEVICE_TABLE(of, pcm512x_of_match); 59MODULE_DEVICE_TABLE(of, pcm512x_of_match);
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index e5f2fb884bf3..9974f201a08f 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -21,12 +21,19 @@
21#include <linux/pm_runtime.h> 21#include <linux/pm_runtime.h>
22#include <linux/regmap.h> 22#include <linux/regmap.h>
23#include <linux/regulator/consumer.h> 23#include <linux/regulator/consumer.h>
24#include <linux/gcd.h>
24#include <sound/soc.h> 25#include <sound/soc.h>
25#include <sound/soc-dapm.h> 26#include <sound/soc-dapm.h>
27#include <sound/pcm_params.h>
26#include <sound/tlv.h> 28#include <sound/tlv.h>
27 29
28#include "pcm512x.h" 30#include "pcm512x.h"
29 31
32#define DIV_ROUND_DOWN_ULL(ll, d) \
33 ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })
34#define DIV_ROUND_CLOSEST_ULL(ll, d) \
35 ({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; })
36
30#define PCM512x_NUM_SUPPLIES 3 37#define PCM512x_NUM_SUPPLIES 3
31static const char * const pcm512x_supply_names[PCM512x_NUM_SUPPLIES] = { 38static const char * const pcm512x_supply_names[PCM512x_NUM_SUPPLIES] = {
32 "AVDD", 39 "AVDD",
@@ -39,6 +46,14 @@ struct pcm512x_priv {
39 struct clk *sclk; 46 struct clk *sclk;
40 struct regulator_bulk_data supplies[PCM512x_NUM_SUPPLIES]; 47 struct regulator_bulk_data supplies[PCM512x_NUM_SUPPLIES];
41 struct notifier_block supply_nb[PCM512x_NUM_SUPPLIES]; 48 struct notifier_block supply_nb[PCM512x_NUM_SUPPLIES];
49 int fmt;
50 int pll_in;
51 int pll_out;
52 int pll_r;
53 int pll_j;
54 int pll_d;
55 int pll_p;
56 unsigned long real_pll;
42}; 57};
43 58
44/* 59/*
@@ -69,6 +84,7 @@ static const struct reg_default pcm512x_reg_defaults[] = {
69 { PCM512x_MUTE, 0x00 }, 84 { PCM512x_MUTE, 0x00 },
70 { PCM512x_DSP, 0x00 }, 85 { PCM512x_DSP, 0x00 },
71 { PCM512x_PLL_REF, 0x00 }, 86 { PCM512x_PLL_REF, 0x00 },
87 { PCM512x_DAC_REF, 0x00 },
72 { PCM512x_DAC_ROUTING, 0x11 }, 88 { PCM512x_DAC_ROUTING, 0x11 },
73 { PCM512x_DSP_PROGRAM, 0x01 }, 89 { PCM512x_DSP_PROGRAM, 0x01 },
74 { PCM512x_CLKDET, 0x00 }, 90 { PCM512x_CLKDET, 0x00 },
@@ -87,6 +103,25 @@ static const struct reg_default pcm512x_reg_defaults[] = {
87 { PCM512x_ANALOG_GAIN_BOOST, 0x00 }, 103 { PCM512x_ANALOG_GAIN_BOOST, 0x00 },
88 { PCM512x_VCOM_CTRL_1, 0x00 }, 104 { PCM512x_VCOM_CTRL_1, 0x00 },
89 { PCM512x_VCOM_CTRL_2, 0x01 }, 105 { PCM512x_VCOM_CTRL_2, 0x01 },
106 { PCM512x_BCLK_LRCLK_CFG, 0x00 },
107 { PCM512x_MASTER_MODE, 0x7c },
108 { PCM512x_GPIO_DACIN, 0x00 },
109 { PCM512x_GPIO_PLLIN, 0x00 },
110 { PCM512x_SYNCHRONIZE, 0x10 },
111 { PCM512x_PLL_COEFF_0, 0x00 },
112 { PCM512x_PLL_COEFF_1, 0x00 },
113 { PCM512x_PLL_COEFF_2, 0x00 },
114 { PCM512x_PLL_COEFF_3, 0x00 },
115 { PCM512x_PLL_COEFF_4, 0x00 },
116 { PCM512x_DSP_CLKDIV, 0x00 },
117 { PCM512x_DAC_CLKDIV, 0x00 },
118 { PCM512x_NCP_CLKDIV, 0x00 },
119 { PCM512x_OSR_CLKDIV, 0x00 },
120 { PCM512x_MASTER_CLKDIV_1, 0x00 },
121 { PCM512x_MASTER_CLKDIV_2, 0x00 },
122 { PCM512x_FS_SPEED_MODE, 0x00 },
123 { PCM512x_IDAC_1, 0x01 },
124 { PCM512x_IDAC_2, 0x00 },
90}; 125};
91 126
92static bool pcm512x_readable(struct device *dev, unsigned int reg) 127static bool pcm512x_readable(struct device *dev, unsigned int reg)
@@ -103,6 +138,10 @@ static bool pcm512x_readable(struct device *dev, unsigned int reg)
103 case PCM512x_DSP_GPIO_INPUT: 138 case PCM512x_DSP_GPIO_INPUT:
104 case PCM512x_MASTER_MODE: 139 case PCM512x_MASTER_MODE:
105 case PCM512x_PLL_REF: 140 case PCM512x_PLL_REF:
141 case PCM512x_DAC_REF:
142 case PCM512x_GPIO_DACIN:
143 case PCM512x_GPIO_PLLIN:
144 case PCM512x_SYNCHRONIZE:
106 case PCM512x_PLL_COEFF_0: 145 case PCM512x_PLL_COEFF_0:
107 case PCM512x_PLL_COEFF_1: 146 case PCM512x_PLL_COEFF_1:
108 case PCM512x_PLL_COEFF_2: 147 case PCM512x_PLL_COEFF_2:
@@ -143,6 +182,7 @@ static bool pcm512x_readable(struct device *dev, unsigned int reg)
143 case PCM512x_RATE_DET_2: 182 case PCM512x_RATE_DET_2:
144 case PCM512x_RATE_DET_3: 183 case PCM512x_RATE_DET_3:
145 case PCM512x_RATE_DET_4: 184 case PCM512x_RATE_DET_4:
185 case PCM512x_CLOCK_STATUS:
146 case PCM512x_ANALOG_MUTE_DET: 186 case PCM512x_ANALOG_MUTE_DET:
147 case PCM512x_GPIN: 187 case PCM512x_GPIN:
148 case PCM512x_DIGITAL_MUTE_DET: 188 case PCM512x_DIGITAL_MUTE_DET:
@@ -154,6 +194,8 @@ static bool pcm512x_readable(struct device *dev, unsigned int reg)
154 case PCM512x_VCOM_CTRL_1: 194 case PCM512x_VCOM_CTRL_1:
155 case PCM512x_VCOM_CTRL_2: 195 case PCM512x_VCOM_CTRL_2:
156 case PCM512x_CRAM_CTRL: 196 case PCM512x_CRAM_CTRL:
197 case PCM512x_FLEX_A:
198 case PCM512x_FLEX_B:
157 return true; 199 return true;
158 default: 200 default:
159 /* There are 256 raw register addresses */ 201 /* There are 256 raw register addresses */
@@ -170,6 +212,7 @@ static bool pcm512x_volatile(struct device *dev, unsigned int reg)
170 case PCM512x_RATE_DET_2: 212 case PCM512x_RATE_DET_2:
171 case PCM512x_RATE_DET_3: 213 case PCM512x_RATE_DET_3:
172 case PCM512x_RATE_DET_4: 214 case PCM512x_RATE_DET_4:
215 case PCM512x_CLOCK_STATUS:
173 case PCM512x_ANALOG_MUTE_DET: 216 case PCM512x_ANALOG_MUTE_DET:
174 case PCM512x_GPIN: 217 case PCM512x_GPIN:
175 case PCM512x_DIGITAL_MUTE_DET: 218 case PCM512x_DIGITAL_MUTE_DET:
@@ -188,8 +231,8 @@ static const DECLARE_TLV_DB_SCALE(boost_tlv, 0, 80, 0);
188static const char * const pcm512x_dsp_program_texts[] = { 231static const char * const pcm512x_dsp_program_texts[] = {
189 "FIR interpolation with de-emphasis", 232 "FIR interpolation with de-emphasis",
190 "Low latency IIR with de-emphasis", 233 "Low latency IIR with de-emphasis",
191 "Fixed process flow",
192 "High attenuation with de-emphasis", 234 "High attenuation with de-emphasis",
235 "Fixed process flow",
193 "Ringing-less low latency FIR", 236 "Ringing-less low latency FIR",
194}; 237};
195 238
@@ -277,7 +320,7 @@ SOC_ENUM("Auto Mute Time Right", pcm512x_autom_r),
277SOC_SINGLE("Auto Mute Mono Switch", PCM512x_DIGITAL_MUTE_3, 320SOC_SINGLE("Auto Mute Mono Switch", PCM512x_DIGITAL_MUTE_3,
278 PCM512x_ACTL_SHIFT, 1, 0), 321 PCM512x_ACTL_SHIFT, 1, 0),
279SOC_DOUBLE("Auto Mute Switch", PCM512x_DIGITAL_MUTE_3, PCM512x_AMLE_SHIFT, 322SOC_DOUBLE("Auto Mute Switch", PCM512x_DIGITAL_MUTE_3, PCM512x_AMLE_SHIFT,
280 PCM512x_AMLR_SHIFT, 1, 0), 323 PCM512x_AMRE_SHIFT, 1, 0),
281 324
282SOC_ENUM("Volume Ramp Down Rate", pcm512x_vndf), 325SOC_ENUM("Volume Ramp Down Rate", pcm512x_vndf),
283SOC_ENUM("Volume Ramp Down Step", pcm512x_vnds), 326SOC_ENUM("Volume Ramp Down Step", pcm512x_vnds),
@@ -303,6 +346,136 @@ static const struct snd_soc_dapm_route pcm512x_dapm_routes[] = {
303 { "OUTR", NULL, "DACR" }, 346 { "OUTR", NULL, "DACR" },
304}; 347};
305 348
349static const u32 pcm512x_dai_rates[] = {
350 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000,
351 88200, 96000, 176400, 192000, 384000,
352};
353
354static const struct snd_pcm_hw_constraint_list constraints_slave = {
355 .count = ARRAY_SIZE(pcm512x_dai_rates),
356 .list = pcm512x_dai_rates,
357};
358
359static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params,
360 struct snd_pcm_hw_rule *rule)
361{
362 struct snd_interval ranges[2];
363 int frame_size;
364
365 frame_size = snd_soc_params_to_frame_size(params);
366 if (frame_size < 0)
367 return frame_size;
368
369 switch (frame_size) {
370 case 32:
371 /* No hole when the frame size is 32. */
372 return 0;
373 case 48:
374 case 64:
375 /* There is only one hole in the range of supported
376 * rates, but it moves with the frame size.
377 */
378 memset(ranges, 0, sizeof(ranges));
379 ranges[0].min = 8000;
380 ranges[0].max = 25000000 / frame_size / 2;
381 ranges[1].min = DIV_ROUND_UP(16000000, frame_size);
382 ranges[1].max = 384000;
383 break;
384 default:
385 return -EINVAL;
386 }
387
388 return snd_interval_ranges(hw_param_interval(params, rule->var),
389 ARRAY_SIZE(ranges), ranges, 0);
390}
391
392static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream,
393 struct snd_soc_dai *dai)
394{
395 struct snd_soc_codec *codec = dai->codec;
396 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
397 struct device *dev = dai->dev;
398 struct snd_pcm_hw_constraint_ratnums *constraints_no_pll;
399 struct snd_ratnum *rats_no_pll;
400
401 if (IS_ERR(pcm512x->sclk)) {
402 dev_err(dev, "Need SCLK for master mode: %ld\n",
403 PTR_ERR(pcm512x->sclk));
404 return PTR_ERR(pcm512x->sclk);
405 }
406
407 if (pcm512x->pll_out)
408 return snd_pcm_hw_rule_add(substream->runtime, 0,
409 SNDRV_PCM_HW_PARAM_RATE,
410 pcm512x_hw_rule_rate,
411 NULL,
412 SNDRV_PCM_HW_PARAM_FRAME_BITS,
413 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
414
415 constraints_no_pll = devm_kzalloc(dev, sizeof(*constraints_no_pll),
416 GFP_KERNEL);
417 if (!constraints_no_pll)
418 return -ENOMEM;
419 constraints_no_pll->nrats = 1;
420 rats_no_pll = devm_kzalloc(dev, sizeof(*rats_no_pll), GFP_KERNEL);
421 if (!rats_no_pll)
422 return -ENOMEM;
423 constraints_no_pll->rats = rats_no_pll;
424 rats_no_pll->num = clk_get_rate(pcm512x->sclk) / 64;
425 rats_no_pll->den_min = 1;
426 rats_no_pll->den_max = 128;
427 rats_no_pll->den_step = 1;
428
429 return snd_pcm_hw_constraint_ratnums(substream->runtime, 0,
430 SNDRV_PCM_HW_PARAM_RATE,
431 constraints_no_pll);
432}
433
434static int pcm512x_dai_startup_slave(struct snd_pcm_substream *substream,
435 struct snd_soc_dai *dai)
436{
437 struct snd_soc_codec *codec = dai->codec;
438 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
439 struct device *dev = dai->dev;
440 struct regmap *regmap = pcm512x->regmap;
441
442 if (IS_ERR(pcm512x->sclk)) {
443 dev_info(dev, "No SCLK, using BCLK: %ld\n",
444 PTR_ERR(pcm512x->sclk));
445
446 /* Disable reporting of missing SCLK as an error */
447 regmap_update_bits(regmap, PCM512x_ERROR_DETECT,
448 PCM512x_IDCH, PCM512x_IDCH);
449
450 /* Switch PLL input to BCLK */
451 regmap_update_bits(regmap, PCM512x_PLL_REF,
452 PCM512x_SREF, PCM512x_SREF_BCK);
453 }
454
455 return snd_pcm_hw_constraint_list(substream->runtime, 0,
456 SNDRV_PCM_HW_PARAM_RATE,
457 &constraints_slave);
458}
459
460static int pcm512x_dai_startup(struct snd_pcm_substream *substream,
461 struct snd_soc_dai *dai)
462{
463 struct snd_soc_codec *codec = dai->codec;
464 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
465
466 switch (pcm512x->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
467 case SND_SOC_DAIFMT_CBM_CFM:
468 case SND_SOC_DAIFMT_CBM_CFS:
469 return pcm512x_dai_startup_master(substream, dai);
470
471 case SND_SOC_DAIFMT_CBS_CFS:
472 return pcm512x_dai_startup_slave(substream, dai);
473
474 default:
475 return -EINVAL;
476 }
477}
478
306static int pcm512x_set_bias_level(struct snd_soc_codec *codec, 479static int pcm512x_set_bias_level(struct snd_soc_codec *codec,
307 enum snd_soc_bias_level level) 480 enum snd_soc_bias_level level)
308{ 481{
@@ -340,17 +513,717 @@ static int pcm512x_set_bias_level(struct snd_soc_codec *codec,
340 return 0; 513 return 0;
341} 514}
342 515
516static unsigned long pcm512x_find_sck(struct snd_soc_dai *dai,
517 unsigned long bclk_rate)
518{
519 struct device *dev = dai->dev;
520 unsigned long sck_rate;
521 int pow2;
522
523 /* 64 MHz <= pll_rate <= 100 MHz, VREF mode */
524 /* 16 MHz <= sck_rate <= 25 MHz, VREF mode */
525
526 /* select sck_rate as a multiple of bclk_rate but still with
527 * as many factors of 2 as possible, as that makes it easier
528 * to find a fast DAC rate
529 */
530 pow2 = 1 << fls((25000000 - 16000000) / bclk_rate);
531 for (; pow2; pow2 >>= 1) {
532 sck_rate = rounddown(25000000, bclk_rate * pow2);
533 if (sck_rate >= 16000000)
534 break;
535 }
536 if (!pow2) {
537 dev_err(dev, "Impossible to generate a suitable SCK\n");
538 return 0;
539 }
540
541 dev_dbg(dev, "sck_rate %lu\n", sck_rate);
542 return sck_rate;
543}
544
545/* pll_rate = pllin_rate * R * J.D / P
546 * 1 <= R <= 16
547 * 1 <= J <= 63
548 * 0 <= D <= 9999
549 * 1 <= P <= 15
550 * 64 MHz <= pll_rate <= 100 MHz
551 * if D == 0
552 * 1 MHz <= pllin_rate / P <= 20 MHz
553 * else if D > 0
554 * 6.667 MHz <= pllin_rate / P <= 20 MHz
555 * 4 <= J <= 11
556 * R = 1
557 */
558static int pcm512x_find_pll_coeff(struct snd_soc_dai *dai,
559 unsigned long pllin_rate,
560 unsigned long pll_rate)
561{
562 struct device *dev = dai->dev;
563 struct snd_soc_codec *codec = dai->codec;
564 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
565 unsigned long common;
566 int R, J, D, P;
567 unsigned long K; /* 10000 * J.D */
568 unsigned long num;
569 unsigned long den;
570
571 common = gcd(pll_rate, pllin_rate);
572 dev_dbg(dev, "pll %lu pllin %lu common %lu\n",
573 pll_rate, pllin_rate, common);
574 num = pll_rate / common;
575 den = pllin_rate / common;
576
577 /* pllin_rate / P (or here, den) cannot be greater than 20 MHz */
578 if (pllin_rate / den > 20000000 && num < 8) {
579 num *= 20000000 / (pllin_rate / den);
580 den *= 20000000 / (pllin_rate / den);
581 }
582 dev_dbg(dev, "num / den = %lu / %lu\n", num, den);
583
584 P = den;
585 if (den <= 15 && num <= 16 * 63
586 && 1000000 <= pllin_rate / P && pllin_rate / P <= 20000000) {
587 /* Try the case with D = 0 */
588 D = 0;
589 /* factor 'num' into J and R, such that R <= 16 and J <= 63 */
590 for (R = 16; R; R--) {
591 if (num % R)
592 continue;
593 J = num / R;
594 if (J == 0 || J > 63)
595 continue;
596
597 dev_dbg(dev, "R * J / P = %d * %d / %d\n", R, J, P);
598 pcm512x->real_pll = pll_rate;
599 goto done;
600 }
601 /* no luck */
602 }
603
604 R = 1;
605
606 if (num > 0xffffffffUL / 10000)
607 goto fallback;
608
609 /* Try to find an exact pll_rate using the D > 0 case */
610 common = gcd(10000 * num, den);
611 num = 10000 * num / common;
612 den /= common;
613 dev_dbg(dev, "num %lu den %lu common %lu\n", num, den, common);
614
615 for (P = den; P <= 15; P++) {
616 if (pllin_rate / P < 6667000 || 200000000 < pllin_rate / P)
617 continue;
618 if (num * P % den)
619 continue;
620 K = num * P / den;
621 /* J == 12 is ok if D == 0 */
622 if (K < 40000 || K > 120000)
623 continue;
624
625 J = K / 10000;
626 D = K % 10000;
627 dev_dbg(dev, "J.D / P = %d.%04d / %d\n", J, D, P);
628 pcm512x->real_pll = pll_rate;
629 goto done;
630 }
631
632 /* Fall back to an approximate pll_rate */
633
634fallback:
635 /* find smallest possible P */
636 P = DIV_ROUND_UP(pllin_rate, 20000000);
637 if (!P)
638 P = 1;
639 else if (P > 15) {
640 dev_err(dev, "Need a slower clock as pll-input\n");
641 return -EINVAL;
642 }
643 if (pllin_rate / P < 6667000) {
644 dev_err(dev, "Need a faster clock as pll-input\n");
645 return -EINVAL;
646 }
647 K = DIV_ROUND_CLOSEST_ULL(10000ULL * pll_rate * P, pllin_rate);
648 if (K < 40000)
649 K = 40000;
650 /* J == 12 is ok if D == 0 */
651 if (K > 120000)
652 K = 120000;
653 J = K / 10000;
654 D = K % 10000;
655 dev_dbg(dev, "J.D / P ~ %d.%04d / %d\n", J, D, P);
656 pcm512x->real_pll = DIV_ROUND_DOWN_ULL((u64)K * pllin_rate, 10000 * P);
657
658done:
659 pcm512x->pll_r = R;
660 pcm512x->pll_j = J;
661 pcm512x->pll_d = D;
662 pcm512x->pll_p = P;
663 return 0;
664}
665
666static unsigned long pcm512x_pllin_dac_rate(struct snd_soc_dai *dai,
667 unsigned long osr_rate,
668 unsigned long pllin_rate)
669{
670 struct snd_soc_codec *codec = dai->codec;
671 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
672 unsigned long dac_rate;
673
674 if (!pcm512x->pll_out)
675 return 0; /* no PLL to bypass, force SCK as DAC input */
676
677 if (pllin_rate % osr_rate)
678 return 0; /* futile, quit early */
679
680 /* run DAC no faster than 6144000 Hz */
681 for (dac_rate = rounddown(6144000, osr_rate);
682 dac_rate;
683 dac_rate -= osr_rate) {
684
685 if (pllin_rate / dac_rate > 128)
686 return 0; /* DAC divider would be too big */
687
688 if (!(pllin_rate % dac_rate))
689 return dac_rate;
690
691 dac_rate -= osr_rate;
692 }
693
694 return 0;
695}
696
697static int pcm512x_set_dividers(struct snd_soc_dai *dai,
698 struct snd_pcm_hw_params *params)
699{
700 struct device *dev = dai->dev;
701 struct snd_soc_codec *codec = dai->codec;
702 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
703 unsigned long pllin_rate = 0;
704 unsigned long pll_rate;
705 unsigned long sck_rate;
706 unsigned long mck_rate;
707 unsigned long bclk_rate;
708 unsigned long sample_rate;
709 unsigned long osr_rate;
710 unsigned long dacsrc_rate;
711 int bclk_div;
712 int lrclk_div;
713 int dsp_div;
714 int dac_div;
715 unsigned long dac_rate;
716 int ncp_div;
717 int osr_div;
718 int ret;
719 int idac;
720 int fssp;
721 int gpio;
722
723 lrclk_div = snd_soc_params_to_frame_size(params);
724 if (lrclk_div == 0) {
725 dev_err(dev, "No LRCLK?\n");
726 return -EINVAL;
727 }
728
729 if (!pcm512x->pll_out) {
730 sck_rate = clk_get_rate(pcm512x->sclk);
731 bclk_div = params->rate_den * 64 / lrclk_div;
732 bclk_rate = DIV_ROUND_CLOSEST(sck_rate, bclk_div);
733
734 mck_rate = sck_rate;
735 } else {
736 ret = snd_soc_params_to_bclk(params);
737 if (ret < 0) {
738 dev_err(dev, "Failed to find suitable BCLK: %d\n", ret);
739 return ret;
740 }
741 if (ret == 0) {
742 dev_err(dev, "No BCLK?\n");
743 return -EINVAL;
744 }
745 bclk_rate = ret;
746
747 pllin_rate = clk_get_rate(pcm512x->sclk);
748
749 sck_rate = pcm512x_find_sck(dai, bclk_rate);
750 if (!sck_rate)
751 return -EINVAL;
752 pll_rate = 4 * sck_rate;
753
754 ret = pcm512x_find_pll_coeff(dai, pllin_rate, pll_rate);
755 if (ret != 0)
756 return ret;
757
758 ret = regmap_write(pcm512x->regmap,
759 PCM512x_PLL_COEFF_0, pcm512x->pll_p - 1);
760 if (ret != 0) {
761 dev_err(dev, "Failed to write PLL P: %d\n", ret);
762 return ret;
763 }
764
765 ret = regmap_write(pcm512x->regmap,
766 PCM512x_PLL_COEFF_1, pcm512x->pll_j);
767 if (ret != 0) {
768 dev_err(dev, "Failed to write PLL J: %d\n", ret);
769 return ret;
770 }
771
772 ret = regmap_write(pcm512x->regmap,
773 PCM512x_PLL_COEFF_2, pcm512x->pll_d >> 8);
774 if (ret != 0) {
775 dev_err(dev, "Failed to write PLL D msb: %d\n", ret);
776 return ret;
777 }
778
779 ret = regmap_write(pcm512x->regmap,
780 PCM512x_PLL_COEFF_3, pcm512x->pll_d & 0xff);
781 if (ret != 0) {
782 dev_err(dev, "Failed to write PLL D lsb: %d\n", ret);
783 return ret;
784 }
785
786 ret = regmap_write(pcm512x->regmap,
787 PCM512x_PLL_COEFF_4, pcm512x->pll_r - 1);
788 if (ret != 0) {
789 dev_err(dev, "Failed to write PLL R: %d\n", ret);
790 return ret;
791 }
792
793 mck_rate = pcm512x->real_pll;
794
795 bclk_div = DIV_ROUND_CLOSEST(sck_rate, bclk_rate);
796 }
797
798 if (bclk_div > 128) {
799 dev_err(dev, "Failed to find BCLK divider\n");
800 return -EINVAL;
801 }
802
803 /* the actual rate */
804 sample_rate = sck_rate / bclk_div / lrclk_div;
805 osr_rate = 16 * sample_rate;
806
807 /* run DSP no faster than 50 MHz */
808 dsp_div = mck_rate > 50000000 ? 2 : 1;
809
810 dac_rate = pcm512x_pllin_dac_rate(dai, osr_rate, pllin_rate);
811 if (dac_rate) {
812 /* the desired clock rate is "compatible" with the pll input
813 * clock, so use that clock as dac input instead of the pll
814 * output clock since the pll will introduce jitter and thus
815 * noise.
816 */
817 dev_dbg(dev, "using pll input as dac input\n");
818 ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF,
819 PCM512x_SDAC, PCM512x_SDAC_GPIO);
820 if (ret != 0) {
821 dev_err(codec->dev,
822 "Failed to set gpio as dacref: %d\n", ret);
823 return ret;
824 }
825
826 gpio = PCM512x_GREF_GPIO1 + pcm512x->pll_in - 1;
827 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_DACIN,
828 PCM512x_GREF, gpio);
829 if (ret != 0) {
830 dev_err(codec->dev,
831 "Failed to set gpio %d as dacin: %d\n",
832 pcm512x->pll_in, ret);
833 return ret;
834 }
835
836 dacsrc_rate = pllin_rate;
837 } else {
838 /* run DAC no faster than 6144000 Hz */
839 unsigned long dac_mul = 6144000 / osr_rate;
840 unsigned long sck_mul = sck_rate / osr_rate;
841
842 for (; dac_mul; dac_mul--) {
843 if (!(sck_mul % dac_mul))
844 break;
845 }
846 if (!dac_mul) {
847 dev_err(dev, "Failed to find DAC rate\n");
848 return -EINVAL;
849 }
850
851 dac_rate = dac_mul * osr_rate;
852 dev_dbg(dev, "dac_rate %lu sample_rate %lu\n",
853 dac_rate, sample_rate);
854
855 ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF,
856 PCM512x_SDAC, PCM512x_SDAC_SCK);
857 if (ret != 0) {
858 dev_err(codec->dev,
859 "Failed to set sck as dacref: %d\n", ret);
860 return ret;
861 }
862
863 dacsrc_rate = sck_rate;
864 }
865
866 dac_div = DIV_ROUND_CLOSEST(dacsrc_rate, dac_rate);
867 if (dac_div > 128) {
868 dev_err(dev, "Failed to find DAC divider\n");
869 return -EINVAL;
870 }
871
872 ncp_div = DIV_ROUND_CLOSEST(dacsrc_rate / dac_div, 1536000);
873 if (ncp_div > 128 || dacsrc_rate / dac_div / ncp_div > 2048000) {
874 /* run NCP no faster than 2048000 Hz, but why? */
875 ncp_div = DIV_ROUND_UP(dacsrc_rate / dac_div, 2048000);
876 if (ncp_div > 128) {
877 dev_err(dev, "Failed to find NCP divider\n");
878 return -EINVAL;
879 }
880 }
881
882 osr_div = DIV_ROUND_CLOSEST(dac_rate, osr_rate);
883 if (osr_div > 128) {
884 dev_err(dev, "Failed to find OSR divider\n");
885 return -EINVAL;
886 }
887
888 idac = mck_rate / (dsp_div * sample_rate);
889
890 ret = regmap_write(pcm512x->regmap, PCM512x_DSP_CLKDIV, dsp_div - 1);
891 if (ret != 0) {
892 dev_err(dev, "Failed to write DSP divider: %d\n", ret);
893 return ret;
894 }
895
896 ret = regmap_write(pcm512x->regmap, PCM512x_DAC_CLKDIV, dac_div - 1);
897 if (ret != 0) {
898 dev_err(dev, "Failed to write DAC divider: %d\n", ret);
899 return ret;
900 }
901
902 ret = regmap_write(pcm512x->regmap, PCM512x_NCP_CLKDIV, ncp_div - 1);
903 if (ret != 0) {
904 dev_err(dev, "Failed to write NCP divider: %d\n", ret);
905 return ret;
906 }
907
908 ret = regmap_write(pcm512x->regmap, PCM512x_OSR_CLKDIV, osr_div - 1);
909 if (ret != 0) {
910 dev_err(dev, "Failed to write OSR divider: %d\n", ret);
911 return ret;
912 }
913
914 ret = regmap_write(pcm512x->regmap,
915 PCM512x_MASTER_CLKDIV_1, bclk_div - 1);
916 if (ret != 0) {
917 dev_err(dev, "Failed to write BCLK divider: %d\n", ret);
918 return ret;
919 }
920
921 ret = regmap_write(pcm512x->regmap,
922 PCM512x_MASTER_CLKDIV_2, lrclk_div - 1);
923 if (ret != 0) {
924 dev_err(dev, "Failed to write LRCLK divider: %d\n", ret);
925 return ret;
926 }
927
928 ret = regmap_write(pcm512x->regmap, PCM512x_IDAC_1, idac >> 8);
929 if (ret != 0) {
930 dev_err(dev, "Failed to write IDAC msb divider: %d\n", ret);
931 return ret;
932 }
933
934 ret = regmap_write(pcm512x->regmap, PCM512x_IDAC_2, idac & 0xff);
935 if (ret != 0) {
936 dev_err(dev, "Failed to write IDAC lsb divider: %d\n", ret);
937 return ret;
938 }
939
940 if (sample_rate <= 48000)
941 fssp = PCM512x_FSSP_48KHZ;
942 else if (sample_rate <= 96000)
943 fssp = PCM512x_FSSP_96KHZ;
944 else if (sample_rate <= 192000)
945 fssp = PCM512x_FSSP_192KHZ;
946 else
947 fssp = PCM512x_FSSP_384KHZ;
948 ret = regmap_update_bits(pcm512x->regmap, PCM512x_FS_SPEED_MODE,
949 PCM512x_FSSP, fssp);
950 if (ret != 0) {
951 dev_err(codec->dev, "Failed to set fs speed: %d\n", ret);
952 return ret;
953 }
954
955 dev_dbg(codec->dev, "DSP divider %d\n", dsp_div);
956 dev_dbg(codec->dev, "DAC divider %d\n", dac_div);
957 dev_dbg(codec->dev, "NCP divider %d\n", ncp_div);
958 dev_dbg(codec->dev, "OSR divider %d\n", osr_div);
959 dev_dbg(codec->dev, "BCK divider %d\n", bclk_div);
960 dev_dbg(codec->dev, "LRCK divider %d\n", lrclk_div);
961 dev_dbg(codec->dev, "IDAC %d\n", idac);
962 dev_dbg(codec->dev, "1<<FSSP %d\n", 1 << fssp);
963
964 return 0;
965}
966
967static int pcm512x_hw_params(struct snd_pcm_substream *substream,
968 struct snd_pcm_hw_params *params,
969 struct snd_soc_dai *dai)
970{
971 struct snd_soc_codec *codec = dai->codec;
972 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
973 int alen;
974 int gpio;
975 int clock_output;
976 int master_mode;
977 int ret;
978
979 dev_dbg(codec->dev, "hw_params %u Hz, %u channels\n",
980 params_rate(params),
981 params_channels(params));
982
983 switch (snd_pcm_format_width(params_format(params))) {
984 case 16:
985 alen = PCM512x_ALEN_16;
986 break;
987 case 20:
988 alen = PCM512x_ALEN_20;
989 break;
990 case 24:
991 alen = PCM512x_ALEN_24;
992 break;
993 case 32:
994 alen = PCM512x_ALEN_32;
995 break;
996 default:
997 dev_err(codec->dev, "Bad frame size: %d\n",
998 snd_pcm_format_width(params_format(params)));
999 return -EINVAL;
1000 }
1001
1002 switch (pcm512x->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
1003 case SND_SOC_DAIFMT_CBS_CFS:
1004 ret = regmap_update_bits(pcm512x->regmap,
1005 PCM512x_BCLK_LRCLK_CFG,
1006 PCM512x_BCKP
1007 | PCM512x_BCKO | PCM512x_LRKO,
1008 0);
1009 if (ret != 0) {
1010 dev_err(codec->dev,
1011 "Failed to enable slave mode: %d\n", ret);
1012 return ret;
1013 }
1014
1015 ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT,
1016 PCM512x_DCAS, 0);
1017 if (ret != 0) {
1018 dev_err(codec->dev,
1019 "Failed to enable clock divider autoset: %d\n",
1020 ret);
1021 return ret;
1022 }
1023 return 0;
1024 case SND_SOC_DAIFMT_CBM_CFM:
1025 clock_output = PCM512x_BCKO | PCM512x_LRKO;
1026 master_mode = PCM512x_RLRK | PCM512x_RBCK;
1027 break;
1028 case SND_SOC_DAIFMT_CBM_CFS:
1029 clock_output = PCM512x_BCKO;
1030 master_mode = PCM512x_RBCK;
1031 break;
1032 default:
1033 return -EINVAL;
1034 }
1035
1036 ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1,
1037 PCM512x_ALEN, alen);
1038 if (ret != 0) {
1039 dev_err(codec->dev, "Failed to set frame size: %d\n", ret);
1040 return ret;
1041 }
1042
1043 if (pcm512x->pll_out) {
1044 ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_A, 0x11);
1045 if (ret != 0) {
1046 dev_err(codec->dev, "Failed to set FLEX_A: %d\n", ret);
1047 return ret;
1048 }
1049
1050 ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_B, 0xff);
1051 if (ret != 0) {
1052 dev_err(codec->dev, "Failed to set FLEX_B: %d\n", ret);
1053 return ret;
1054 }
1055
1056 ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT,
1057 PCM512x_IDFS | PCM512x_IDBK
1058 | PCM512x_IDSK | PCM512x_IDCH
1059 | PCM512x_IDCM | PCM512x_DCAS
1060 | PCM512x_IPLK,
1061 PCM512x_IDFS | PCM512x_IDBK
1062 | PCM512x_IDSK | PCM512x_IDCH
1063 | PCM512x_DCAS);
1064 if (ret != 0) {
1065 dev_err(codec->dev,
1066 "Failed to ignore auto-clock failures: %d\n",
1067 ret);
1068 return ret;
1069 }
1070 } else {
1071 ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT,
1072 PCM512x_IDFS | PCM512x_IDBK
1073 | PCM512x_IDSK | PCM512x_IDCH
1074 | PCM512x_IDCM | PCM512x_DCAS
1075 | PCM512x_IPLK,
1076 PCM512x_IDFS | PCM512x_IDBK
1077 | PCM512x_IDSK | PCM512x_IDCH
1078 | PCM512x_DCAS | PCM512x_IPLK);
1079 if (ret != 0) {
1080 dev_err(codec->dev,
1081 "Failed to ignore auto-clock failures: %d\n",
1082 ret);
1083 return ret;
1084 }
1085
1086 ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN,
1087 PCM512x_PLLE, 0);
1088 if (ret != 0) {
1089 dev_err(codec->dev, "Failed to disable pll: %d\n", ret);
1090 return ret;
1091 }
1092 }
1093
1094 ret = pcm512x_set_dividers(dai, params);
1095 if (ret != 0)
1096 return ret;
1097
1098 if (pcm512x->pll_out) {
1099 ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_REF,
1100 PCM512x_SREF, PCM512x_SREF_GPIO);
1101 if (ret != 0) {
1102 dev_err(codec->dev,
1103 "Failed to set gpio as pllref: %d\n", ret);
1104 return ret;
1105 }
1106
1107 gpio = PCM512x_GREF_GPIO1 + pcm512x->pll_in - 1;
1108 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_PLLIN,
1109 PCM512x_GREF, gpio);
1110 if (ret != 0) {
1111 dev_err(codec->dev,
1112 "Failed to set gpio %d as pllin: %d\n",
1113 pcm512x->pll_in, ret);
1114 return ret;
1115 }
1116
1117 ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN,
1118 PCM512x_PLLE, PCM512x_PLLE);
1119 if (ret != 0) {
1120 dev_err(codec->dev, "Failed to enable pll: %d\n", ret);
1121 return ret;
1122 }
1123 }
1124
1125 ret = regmap_update_bits(pcm512x->regmap, PCM512x_BCLK_LRCLK_CFG,
1126 PCM512x_BCKP | PCM512x_BCKO | PCM512x_LRKO,
1127 clock_output);
1128 if (ret != 0) {
1129 dev_err(codec->dev, "Failed to enable clock output: %d\n", ret);
1130 return ret;
1131 }
1132
1133 ret = regmap_update_bits(pcm512x->regmap, PCM512x_MASTER_MODE,
1134 PCM512x_RLRK | PCM512x_RBCK,
1135 master_mode);
1136 if (ret != 0) {
1137 dev_err(codec->dev, "Failed to enable master mode: %d\n", ret);
1138 return ret;
1139 }
1140
1141 if (pcm512x->pll_out) {
1142 gpio = PCM512x_G1OE << (pcm512x->pll_out - 1);
1143 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN,
1144 gpio, gpio);
1145 if (ret != 0) {
1146 dev_err(codec->dev, "Failed to enable gpio %d: %d\n",
1147 pcm512x->pll_out, ret);
1148 return ret;
1149 }
1150
1151 gpio = PCM512x_GPIO_OUTPUT_1 + pcm512x->pll_out - 1;
1152 ret = regmap_update_bits(pcm512x->regmap, gpio,
1153 PCM512x_GxSL, PCM512x_GxSL_PLLCK);
1154 if (ret != 0) {
1155 dev_err(codec->dev, "Failed to output pll on %d: %d\n",
1156 ret, pcm512x->pll_out);
1157 return ret;
1158 }
1159
1160 gpio = PCM512x_G1OE << (4 - 1);
1161 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN,
1162 gpio, gpio);
1163 if (ret != 0) {
1164 dev_err(codec->dev, "Failed to enable gpio %d: %d\n",
1165 4, ret);
1166 return ret;
1167 }
1168
1169 gpio = PCM512x_GPIO_OUTPUT_1 + 4 - 1;
1170 ret = regmap_update_bits(pcm512x->regmap, gpio,
1171 PCM512x_GxSL, PCM512x_GxSL_PLLLK);
1172 if (ret != 0) {
1173 dev_err(codec->dev,
1174 "Failed to output pll lock on %d: %d\n",
1175 ret, 4);
1176 return ret;
1177 }
1178 }
1179
1180 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE,
1181 PCM512x_RQSY, PCM512x_RQSY_HALT);
1182 if (ret != 0) {
1183 dev_err(codec->dev, "Failed to halt clocks: %d\n", ret);
1184 return ret;
1185 }
1186
1187 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE,
1188 PCM512x_RQSY, PCM512x_RQSY_RESUME);
1189 if (ret != 0) {
1190 dev_err(codec->dev, "Failed to resume clocks: %d\n", ret);
1191 return ret;
1192 }
1193
1194 return 0;
1195}
1196
1197static int pcm512x_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
1198{
1199 struct snd_soc_codec *codec = dai->codec;
1200 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
1201
1202 pcm512x->fmt = fmt;
1203
1204 return 0;
1205}
1206
1207static const struct snd_soc_dai_ops pcm512x_dai_ops = {
1208 .startup = pcm512x_dai_startup,
1209 .hw_params = pcm512x_hw_params,
1210 .set_fmt = pcm512x_set_fmt,
1211};
1212
343static struct snd_soc_dai_driver pcm512x_dai = { 1213static struct snd_soc_dai_driver pcm512x_dai = {
344 .name = "pcm512x-hifi", 1214 .name = "pcm512x-hifi",
345 .playback = { 1215 .playback = {
346 .stream_name = "Playback", 1216 .stream_name = "Playback",
347 .channels_min = 2, 1217 .channels_min = 2,
348 .channels_max = 2, 1218 .channels_max = 2,
349 .rates = SNDRV_PCM_RATE_8000_192000, 1219 .rates = SNDRV_PCM_RATE_CONTINUOUS,
1220 .rate_min = 8000,
1221 .rate_max = 384000,
350 .formats = SNDRV_PCM_FMTBIT_S16_LE | 1222 .formats = SNDRV_PCM_FMTBIT_S16_LE |
351 SNDRV_PCM_FMTBIT_S24_LE | 1223 SNDRV_PCM_FMTBIT_S24_LE |
352 SNDRV_PCM_FMTBIT_S32_LE 1224 SNDRV_PCM_FMTBIT_S32_LE
353 }, 1225 },
1226 .ops = &pcm512x_dai_ops,
354}; 1227};
355 1228
356static struct snd_soc_codec_driver pcm512x_codec_driver = { 1229static struct snd_soc_codec_driver pcm512x_codec_driver = {
@@ -448,21 +1321,9 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)
448 } 1321 }
449 1322
450 pcm512x->sclk = devm_clk_get(dev, NULL); 1323 pcm512x->sclk = devm_clk_get(dev, NULL);
451 if (IS_ERR(pcm512x->sclk)) { 1324 if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER)
452 if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER) 1325 return -EPROBE_DEFER;
453 return -EPROBE_DEFER; 1326 if (!IS_ERR(pcm512x->sclk)) {
454
455 dev_info(dev, "No SCLK, using BCLK: %ld\n",
456 PTR_ERR(pcm512x->sclk));
457
458 /* Disable reporting of missing SCLK as an error */
459 regmap_update_bits(regmap, PCM512x_ERROR_DETECT,
460 PCM512x_IDCH, PCM512x_IDCH);
461
462 /* Switch PLL input to BCLK */
463 regmap_update_bits(regmap, PCM512x_PLL_REF,
464 PCM512x_SREF, PCM512x_SREF);
465 } else {
466 ret = clk_prepare_enable(pcm512x->sclk); 1327 ret = clk_prepare_enable(pcm512x->sclk);
467 if (ret != 0) { 1328 if (ret != 0) {
468 dev_err(dev, "Failed to enable SCLK: %d\n", ret); 1329 dev_err(dev, "Failed to enable SCLK: %d\n", ret);
@@ -483,6 +1344,43 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)
483 pm_runtime_enable(dev); 1344 pm_runtime_enable(dev);
484 pm_runtime_idle(dev); 1345 pm_runtime_idle(dev);
485 1346
1347#ifdef CONFIG_OF
1348 if (dev->of_node) {
1349 const struct device_node *np = dev->of_node;
1350 u32 val;
1351
1352 if (of_property_read_u32(np, "pll-in", &val) >= 0) {
1353 if (val > 6) {
1354 dev_err(dev, "Invalid pll-in\n");
1355 ret = -EINVAL;
1356 goto err_clk;
1357 }
1358 pcm512x->pll_in = val;
1359 }
1360
1361 if (of_property_read_u32(np, "pll-out", &val) >= 0) {
1362 if (val > 6) {
1363 dev_err(dev, "Invalid pll-out\n");
1364 ret = -EINVAL;
1365 goto err_clk;
1366 }
1367 pcm512x->pll_out = val;
1368 }
1369
1370 if (!pcm512x->pll_in != !pcm512x->pll_out) {
1371 dev_err(dev,
1372 "Error: both pll-in and pll-out, or none\n");
1373 ret = -EINVAL;
1374 goto err_clk;
1375 }
1376 if (pcm512x->pll_in && pcm512x->pll_in == pcm512x->pll_out) {
1377 dev_err(dev, "Error: pll-in == pll-out\n");
1378 ret = -EINVAL;
1379 goto err_clk;
1380 }
1381 }
1382#endif
1383
486 ret = snd_soc_register_codec(dev, &pcm512x_codec_driver, 1384 ret = snd_soc_register_codec(dev, &pcm512x_codec_driver,
487 &pcm512x_dai, 1); 1385 &pcm512x_dai, 1);
488 if (ret != 0) { 1386 if (ret != 0) {
diff --git a/sound/soc/codecs/pcm512x.h b/sound/soc/codecs/pcm512x.h
index 6ee76aaca09a..b7c310207223 100644
--- a/sound/soc/codecs/pcm512x.h
+++ b/sound/soc/codecs/pcm512x.h
@@ -37,6 +37,10 @@
37#define PCM512x_DSP_GPIO_INPUT (PCM512x_PAGE_BASE(0) + 10) 37#define PCM512x_DSP_GPIO_INPUT (PCM512x_PAGE_BASE(0) + 10)
38#define PCM512x_MASTER_MODE (PCM512x_PAGE_BASE(0) + 12) 38#define PCM512x_MASTER_MODE (PCM512x_PAGE_BASE(0) + 12)
39#define PCM512x_PLL_REF (PCM512x_PAGE_BASE(0) + 13) 39#define PCM512x_PLL_REF (PCM512x_PAGE_BASE(0) + 13)
40#define PCM512x_DAC_REF (PCM512x_PAGE_BASE(0) + 14)
41#define PCM512x_GPIO_DACIN (PCM512x_PAGE_BASE(0) + 16)
42#define PCM512x_GPIO_PLLIN (PCM512x_PAGE_BASE(0) + 18)
43#define PCM512x_SYNCHRONIZE (PCM512x_PAGE_BASE(0) + 19)
40#define PCM512x_PLL_COEFF_0 (PCM512x_PAGE_BASE(0) + 20) 44#define PCM512x_PLL_COEFF_0 (PCM512x_PAGE_BASE(0) + 20)
41#define PCM512x_PLL_COEFF_1 (PCM512x_PAGE_BASE(0) + 21) 45#define PCM512x_PLL_COEFF_1 (PCM512x_PAGE_BASE(0) + 21)
42#define PCM512x_PLL_COEFF_2 (PCM512x_PAGE_BASE(0) + 22) 46#define PCM512x_PLL_COEFF_2 (PCM512x_PAGE_BASE(0) + 22)
@@ -77,6 +81,7 @@
77#define PCM512x_RATE_DET_2 (PCM512x_PAGE_BASE(0) + 92) 81#define PCM512x_RATE_DET_2 (PCM512x_PAGE_BASE(0) + 92)
78#define PCM512x_RATE_DET_3 (PCM512x_PAGE_BASE(0) + 93) 82#define PCM512x_RATE_DET_3 (PCM512x_PAGE_BASE(0) + 93)
79#define PCM512x_RATE_DET_4 (PCM512x_PAGE_BASE(0) + 94) 83#define PCM512x_RATE_DET_4 (PCM512x_PAGE_BASE(0) + 94)
84#define PCM512x_CLOCK_STATUS (PCM512x_PAGE_BASE(0) + 95)
80#define PCM512x_ANALOG_MUTE_DET (PCM512x_PAGE_BASE(0) + 108) 85#define PCM512x_ANALOG_MUTE_DET (PCM512x_PAGE_BASE(0) + 108)
81#define PCM512x_GPIN (PCM512x_PAGE_BASE(0) + 119) 86#define PCM512x_GPIN (PCM512x_PAGE_BASE(0) + 119)
82#define PCM512x_DIGITAL_MUTE_DET (PCM512x_PAGE_BASE(0) + 120) 87#define PCM512x_DIGITAL_MUTE_DET (PCM512x_PAGE_BASE(0) + 120)
@@ -91,7 +96,10 @@
91 96
92#define PCM512x_CRAM_CTRL (PCM512x_PAGE_BASE(44) + 1) 97#define PCM512x_CRAM_CTRL (PCM512x_PAGE_BASE(44) + 1)
93 98
94#define PCM512x_MAX_REGISTER (PCM512x_PAGE_BASE(44) + 1) 99#define PCM512x_FLEX_A (PCM512x_PAGE_BASE(253) + 63)
100#define PCM512x_FLEX_B (PCM512x_PAGE_BASE(253) + 64)
101
102#define PCM512x_MAX_REGISTER (PCM512x_PAGE_BASE(253) + 64)
95 103
96/* Page 0, Register 1 - reset */ 104/* Page 0, Register 1 - reset */
97#define PCM512x_RSTR (1 << 0) 105#define PCM512x_RSTR (1 << 0)
@@ -108,8 +116,8 @@
108#define PCM512x_RQML_SHIFT 4 116#define PCM512x_RQML_SHIFT 4
109 117
110/* Page 0, Register 4 - PLL */ 118/* Page 0, Register 4 - PLL */
111#define PCM512x_PLCE (1 << 0) 119#define PCM512x_PLLE (1 << 0)
112#define PCM512x_RLCE_SHIFT 0 120#define PCM512x_PLLE_SHIFT 0
113#define PCM512x_PLCK (1 << 4) 121#define PCM512x_PLCK (1 << 4)
114#define PCM512x_PLCK_SHIFT 4 122#define PCM512x_PLCK_SHIFT 4
115 123
@@ -119,8 +127,66 @@
119#define PCM512x_DEMP (1 << 4) 127#define PCM512x_DEMP (1 << 4)
120#define PCM512x_DEMP_SHIFT 4 128#define PCM512x_DEMP_SHIFT 4
121 129
130/* Page 0, Register 8 - GPIO output enable */
131#define PCM512x_G1OE (1 << 0)
132#define PCM512x_G2OE (1 << 1)
133#define PCM512x_G3OE (1 << 2)
134#define PCM512x_G4OE (1 << 3)
135#define PCM512x_G5OE (1 << 4)
136#define PCM512x_G6OE (1 << 5)
137
138/* Page 0, Register 9 - BCK, LRCLK configuration */
139#define PCM512x_LRKO (1 << 0)
140#define PCM512x_LRKO_SHIFT 0
141#define PCM512x_BCKO (1 << 4)
142#define PCM512x_BCKO_SHIFT 4
143#define PCM512x_BCKP (1 << 5)
144#define PCM512x_BCKP_SHIFT 5
145
146/* Page 0, Register 12 - Master mode BCK, LRCLK reset */
147#define PCM512x_RLRK (1 << 0)
148#define PCM512x_RLRK_SHIFT 0
149#define PCM512x_RBCK (1 << 1)
150#define PCM512x_RBCK_SHIFT 1
151
122/* Page 0, Register 13 - PLL reference */ 152/* Page 0, Register 13 - PLL reference */
123#define PCM512x_SREF (1 << 4) 153#define PCM512x_SREF (7 << 4)
154#define PCM512x_SREF_SHIFT 4
155#define PCM512x_SREF_SCK (0 << 4)
156#define PCM512x_SREF_BCK (1 << 4)
157#define PCM512x_SREF_GPIO (3 << 4)
158
159/* Page 0, Register 14 - DAC reference */
160#define PCM512x_SDAC (7 << 4)
161#define PCM512x_SDAC_SHIFT 4
162#define PCM512x_SDAC_MCK (0 << 4)
163#define PCM512x_SDAC_PLL (1 << 4)
164#define PCM512x_SDAC_SCK (3 << 4)
165#define PCM512x_SDAC_BCK (4 << 4)
166#define PCM512x_SDAC_GPIO (5 << 4)
167
168/* Page 0, Register 16, 18 - GPIO source for DAC, PLL */
169#define PCM512x_GREF (7 << 0)
170#define PCM512x_GREF_SHIFT 0
171#define PCM512x_GREF_GPIO1 (0 << 0)
172#define PCM512x_GREF_GPIO2 (1 << 0)
173#define PCM512x_GREF_GPIO3 (2 << 0)
174#define PCM512x_GREF_GPIO4 (3 << 0)
175#define PCM512x_GREF_GPIO5 (4 << 0)
176#define PCM512x_GREF_GPIO6 (5 << 0)
177
178/* Page 0, Register 19 - synchronize */
179#define PCM512x_RQSY (1 << 0)
180#define PCM512x_RQSY_RESUME (0 << 0)
181#define PCM512x_RQSY_HALT (1 << 0)
182
183/* Page 0, Register 34 - fs speed mode */
184#define PCM512x_FSSP (3 << 0)
185#define PCM512x_FSSP_SHIFT 0
186#define PCM512x_FSSP_48KHZ (0 << 0)
187#define PCM512x_FSSP_96KHZ (1 << 0)
188#define PCM512x_FSSP_192KHZ (2 << 0)
189#define PCM512x_FSSP_384KHZ (3 << 0)
124 190
125/* Page 0, Register 37 - Error detection */ 191/* Page 0, Register 37 - Error detection */
126#define PCM512x_IPLK (1 << 0) 192#define PCM512x_IPLK (1 << 0)
@@ -131,6 +197,20 @@
131#define PCM512x_IDBK (1 << 5) 197#define PCM512x_IDBK (1 << 5)
132#define PCM512x_IDFS (1 << 6) 198#define PCM512x_IDFS (1 << 6)
133 199
200/* Page 0, Register 40 - I2S configuration */
201#define PCM512x_ALEN (3 << 0)
202#define PCM512x_ALEN_SHIFT 0
203#define PCM512x_ALEN_16 (0 << 0)
204#define PCM512x_ALEN_20 (1 << 0)
205#define PCM512x_ALEN_24 (2 << 0)
206#define PCM512x_ALEN_32 (3 << 0)
207#define PCM512x_AFMT (3 << 4)
208#define PCM512x_AFMT_SHIFT 4
209#define PCM512x_AFMT_I2S (0 << 4)
210#define PCM512x_AFMT_DSP (1 << 4)
211#define PCM512x_AFMT_RTJ (2 << 4)
212#define PCM512x_AFMT_LTJ (3 << 4)
213
134/* Page 0, Register 42 - DAC routing */ 214/* Page 0, Register 42 - DAC routing */
135#define PCM512x_AUPR_SHIFT 0 215#define PCM512x_AUPR_SHIFT 0
136#define PCM512x_AUPL_SHIFT 4 216#define PCM512x_AUPL_SHIFT 4
@@ -152,7 +232,26 @@
152/* Page 0, Register 65 - Digital mute enables */ 232/* Page 0, Register 65 - Digital mute enables */
153#define PCM512x_ACTL_SHIFT 2 233#define PCM512x_ACTL_SHIFT 2
154#define PCM512x_AMLE_SHIFT 1 234#define PCM512x_AMLE_SHIFT 1
155#define PCM512x_AMLR_SHIFT 0 235#define PCM512x_AMRE_SHIFT 0
236
237/* Page 0, Register 80-85, GPIO output selection */
238#define PCM512x_GxSL (31 << 0)
239#define PCM512x_GxSL_SHIFT 0
240#define PCM512x_GxSL_OFF (0 << 0)
241#define PCM512x_GxSL_DSP (1 << 0)
242#define PCM512x_GxSL_REG (2 << 0)
243#define PCM512x_GxSL_AMUTB (3 << 0)
244#define PCM512x_GxSL_AMUTL (4 << 0)
245#define PCM512x_GxSL_AMUTR (5 << 0)
246#define PCM512x_GxSL_CLKI (6 << 0)
247#define PCM512x_GxSL_SDOUT (7 << 0)
248#define PCM512x_GxSL_ANMUL (8 << 0)
249#define PCM512x_GxSL_ANMUR (9 << 0)
250#define PCM512x_GxSL_PLLLK (10 << 0)
251#define PCM512x_GxSL_CPCLK (11 << 0)
252#define PCM512x_GxSL_UV0_7 (14 << 0)
253#define PCM512x_GxSL_UV0_3 (15 << 0)
254#define PCM512x_GxSL_PLLCK (16 << 0)
156 255
157/* Page 1, Register 2 - analog volume control */ 256/* Page 1, Register 2 - analog volume control */
158#define PCM512x_RAGN_SHIFT 0 257#define PCM512x_RAGN_SHIFT 0
diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index 2cd4fe463102..d0698891b69e 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -305,6 +305,8 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic)
305 *hp = false; 305 *hp = false;
306 *mic = false; 306 *mic = false;
307 307
308 if (!rt286->codec)
309 return -EINVAL;
308 if (rt286->pdata.cbj_en) { 310 if (rt286->pdata.cbj_en) {
309 regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); 311 regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf);
310 *hp = buf & 0x80000000; 312 *hp = buf & 0x80000000;
@@ -403,7 +405,8 @@ EXPORT_SYMBOL_GPL(rt286_mic_detect);
403static int is_mclk_mode(struct snd_soc_dapm_widget *source, 405static int is_mclk_mode(struct snd_soc_dapm_widget *source,
404 struct snd_soc_dapm_widget *sink) 406 struct snd_soc_dapm_widget *sink)
405{ 407{
406 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(source->codec); 408 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
409 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec);
407 410
408 if (rt286->clk_id == RT286_SCLK_S_MCLK) 411 if (rt286->clk_id == RT286_SCLK_S_MCLK)
409 return 1; 412 return 1;
@@ -417,6 +420,8 @@ static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0);
417static const struct snd_kcontrol_new rt286_snd_controls[] = { 420static const struct snd_kcontrol_new rt286_snd_controls[] = {
418 SOC_DOUBLE_R_TLV("DAC0 Playback Volume", RT286_DACL_GAIN, 421 SOC_DOUBLE_R_TLV("DAC0 Playback Volume", RT286_DACL_GAIN,
419 RT286_DACR_GAIN, 0, 0x7f, 0, out_vol_tlv), 422 RT286_DACR_GAIN, 0, 0x7f, 0, out_vol_tlv),
423 SOC_DOUBLE_R("ADC0 Capture Switch", RT286_ADCL_GAIN,
424 RT286_ADCR_GAIN, 7, 1, 1),
420 SOC_DOUBLE_R_TLV("ADC0 Capture Volume", RT286_ADCL_GAIN, 425 SOC_DOUBLE_R_TLV("ADC0 Capture Volume", RT286_ADCL_GAIN,
421 RT286_ADCR_GAIN, 0, 0x7f, 0, out_vol_tlv), 426 RT286_ADCR_GAIN, 0, 0x7f, 0, out_vol_tlv),
422 SOC_SINGLE_TLV("AMIC Volume", RT286_MIC_GAIN, 427 SOC_SINGLE_TLV("AMIC Volume", RT286_MIC_GAIN,
@@ -500,7 +505,7 @@ SOC_DAPM_ENUM("SPO source", rt286_spo_enum);
500static int rt286_spk_event(struct snd_soc_dapm_widget *w, 505static int rt286_spk_event(struct snd_soc_dapm_widget *w,
501 struct snd_kcontrol *kcontrol, int event) 506 struct snd_kcontrol *kcontrol, int event)
502{ 507{
503 struct snd_soc_codec *codec = w->codec; 508 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
504 509
505 switch (event) { 510 switch (event) {
506 case SND_SOC_DAPM_POST_PMU: 511 case SND_SOC_DAPM_POST_PMU:
@@ -522,7 +527,7 @@ static int rt286_spk_event(struct snd_soc_dapm_widget *w,
522static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, 527static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w,
523 struct snd_kcontrol *kcontrol, int event) 528 struct snd_kcontrol *kcontrol, int event)
524{ 529{
525 struct snd_soc_codec *codec = w->codec; 530 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
526 531
527 switch (event) { 532 switch (event) {
528 case SND_SOC_DAPM_POST_PMU: 533 case SND_SOC_DAPM_POST_PMU:
@@ -538,36 +543,10 @@ static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w,
538 return 0; 543 return 0;
539} 544}
540 545
541static int rt286_adc_event(struct snd_soc_dapm_widget *w,
542 struct snd_kcontrol *kcontrol, int event)
543{
544 struct snd_soc_codec *codec = w->codec;
545 unsigned int nid;
546
547 nid = (w->reg >> 20) & 0xff;
548
549 switch (event) {
550 case SND_SOC_DAPM_POST_PMU:
551 snd_soc_update_bits(codec,
552 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0),
553 0x7080, 0x7000);
554 break;
555 case SND_SOC_DAPM_PRE_PMD:
556 snd_soc_update_bits(codec,
557 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0),
558 0x7080, 0x7080);
559 break;
560 default:
561 return 0;
562 }
563
564 return 0;
565}
566
567static int rt286_vref_event(struct snd_soc_dapm_widget *w, 546static int rt286_vref_event(struct snd_soc_dapm_widget *w,
568 struct snd_kcontrol *kcontrol, int event) 547 struct snd_kcontrol *kcontrol, int event)
569{ 548{
570 struct snd_soc_codec *codec = w->codec; 549 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
571 550
572 switch (event) { 551 switch (event) {
573 case SND_SOC_DAPM_PRE_PMU: 552 case SND_SOC_DAPM_PRE_PMU:
@@ -585,7 +564,7 @@ static int rt286_vref_event(struct snd_soc_dapm_widget *w,
585static int rt286_ldo2_event(struct snd_soc_dapm_widget *w, 564static int rt286_ldo2_event(struct snd_soc_dapm_widget *w,
586 struct snd_kcontrol *kcontrol, int event) 565 struct snd_kcontrol *kcontrol, int event)
587{ 566{
588 struct snd_soc_codec *codec = w->codec; 567 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
589 568
590 switch (event) { 569 switch (event) {
591 case SND_SOC_DAPM_POST_PMU: 570 case SND_SOC_DAPM_POST_PMU:
@@ -604,7 +583,7 @@ static int rt286_ldo2_event(struct snd_soc_dapm_widget *w,
604static int rt286_mic1_event(struct snd_soc_dapm_widget *w, 583static int rt286_mic1_event(struct snd_soc_dapm_widget *w,
605 struct snd_kcontrol *kcontrol, int event) 584 struct snd_kcontrol *kcontrol, int event)
606{ 585{
607 struct snd_soc_codec *codec = w->codec; 586 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
608 587
609 switch (event) { 588 switch (event) {
610 case SND_SOC_DAPM_PRE_PMU: 589 case SND_SOC_DAPM_PRE_PMU:
@@ -667,12 +646,10 @@ static const struct snd_soc_dapm_widget rt286_dapm_widgets[] = {
667 SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, 0, 0), 646 SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, 0, 0),
668 647
669 /* ADC Mux */ 648 /* ADC Mux */
670 SND_SOC_DAPM_MUX_E("ADC 0 Mux", RT286_SET_POWER(RT286_ADC_IN1), 0, 1, 649 SND_SOC_DAPM_MUX("ADC 0 Mux", RT286_SET_POWER(RT286_ADC_IN1), 0, 1,
671 &rt286_adc0_mux, rt286_adc_event, SND_SOC_DAPM_PRE_PMD | 650 &rt286_adc0_mux),
672 SND_SOC_DAPM_POST_PMU), 651 SND_SOC_DAPM_MUX("ADC 1 Mux", RT286_SET_POWER(RT286_ADC_IN2), 0, 1,
673 SND_SOC_DAPM_MUX_E("ADC 1 Mux", RT286_SET_POWER(RT286_ADC_IN2), 0, 1, 652 &rt286_adc1_mux),
674 &rt286_adc1_mux, rt286_adc_event, SND_SOC_DAPM_PRE_PMD |
675 SND_SOC_DAPM_POST_PMU),
676 653
677 /* Audio Interface */ 654 /* Audio Interface */
678 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), 655 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
@@ -861,10 +838,8 @@ static int rt286_hw_params(struct snd_pcm_substream *substream,
861 RT286_I2S_CTRL1, 0x0018, d_len_code << 3); 838 RT286_I2S_CTRL1, 0x0018, d_len_code << 3);
862 dev_dbg(codec->dev, "format val = 0x%x\n", val); 839 dev_dbg(codec->dev, "format val = 0x%x\n", val);
863 840
864 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 841 snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x407f, val);
865 snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x407f, val); 842 snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x407f, val);
866 else
867 snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x407f, val);
868 843
869 return 0; 844 return 0;
870} 845}
diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c
index 6d7b7ca7d530..c61852742ee3 100644
--- a/sound/soc/codecs/rt5631.c
+++ b/sound/soc/codecs/rt5631.c
@@ -287,70 +287,78 @@ static const struct snd_kcontrol_new rt5631_snd_controls[] = {
287static int check_sysclk1_source(struct snd_soc_dapm_widget *source, 287static int check_sysclk1_source(struct snd_soc_dapm_widget *source,
288 struct snd_soc_dapm_widget *sink) 288 struct snd_soc_dapm_widget *sink)
289{ 289{
290 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
290 unsigned int reg; 291 unsigned int reg;
291 292
292 reg = snd_soc_read(source->codec, RT5631_GLOBAL_CLK_CTRL); 293 reg = snd_soc_read(codec, RT5631_GLOBAL_CLK_CTRL);
293 return reg & RT5631_SYSCLK_SOUR_SEL_PLL; 294 return reg & RT5631_SYSCLK_SOUR_SEL_PLL;
294} 295}
295 296
296static int check_dmic_used(struct snd_soc_dapm_widget *source, 297static int check_dmic_used(struct snd_soc_dapm_widget *source,
297 struct snd_soc_dapm_widget *sink) 298 struct snd_soc_dapm_widget *sink)
298{ 299{
299 struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(source->codec); 300 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
301 struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
300 return rt5631->dmic_used_flag; 302 return rt5631->dmic_used_flag;
301} 303}
302 304
303static int check_dacl_to_outmixl(struct snd_soc_dapm_widget *source, 305static int check_dacl_to_outmixl(struct snd_soc_dapm_widget *source,
304 struct snd_soc_dapm_widget *sink) 306 struct snd_soc_dapm_widget *sink)
305{ 307{
308 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
306 unsigned int reg; 309 unsigned int reg;
307 310
308 reg = snd_soc_read(source->codec, RT5631_OUTMIXER_L_CTRL); 311 reg = snd_soc_read(codec, RT5631_OUTMIXER_L_CTRL);
309 return !(reg & RT5631_M_DAC_L_TO_OUTMIXER_L); 312 return !(reg & RT5631_M_DAC_L_TO_OUTMIXER_L);
310} 313}
311 314
312static int check_dacr_to_outmixr(struct snd_soc_dapm_widget *source, 315static int check_dacr_to_outmixr(struct snd_soc_dapm_widget *source,
313 struct snd_soc_dapm_widget *sink) 316 struct snd_soc_dapm_widget *sink)
314{ 317{
318 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
315 unsigned int reg; 319 unsigned int reg;
316 320
317 reg = snd_soc_read(source->codec, RT5631_OUTMIXER_R_CTRL); 321 reg = snd_soc_read(codec, RT5631_OUTMIXER_R_CTRL);
318 return !(reg & RT5631_M_DAC_R_TO_OUTMIXER_R); 322 return !(reg & RT5631_M_DAC_R_TO_OUTMIXER_R);
319} 323}
320 324
321static int check_dacl_to_spkmixl(struct snd_soc_dapm_widget *source, 325static int check_dacl_to_spkmixl(struct snd_soc_dapm_widget *source,
322 struct snd_soc_dapm_widget *sink) 326 struct snd_soc_dapm_widget *sink)
323{ 327{
328 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
324 unsigned int reg; 329 unsigned int reg;
325 330
326 reg = snd_soc_read(source->codec, RT5631_SPK_MIXER_CTRL); 331 reg = snd_soc_read(codec, RT5631_SPK_MIXER_CTRL);
327 return !(reg & RT5631_M_DAC_L_TO_SPKMIXER_L); 332 return !(reg & RT5631_M_DAC_L_TO_SPKMIXER_L);
328} 333}
329 334
330static int check_dacr_to_spkmixr(struct snd_soc_dapm_widget *source, 335static int check_dacr_to_spkmixr(struct snd_soc_dapm_widget *source,
331 struct snd_soc_dapm_widget *sink) 336 struct snd_soc_dapm_widget *sink)
332{ 337{
338 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
333 unsigned int reg; 339 unsigned int reg;
334 340
335 reg = snd_soc_read(source->codec, RT5631_SPK_MIXER_CTRL); 341 reg = snd_soc_read(codec, RT5631_SPK_MIXER_CTRL);
336 return !(reg & RT5631_M_DAC_R_TO_SPKMIXER_R); 342 return !(reg & RT5631_M_DAC_R_TO_SPKMIXER_R);
337} 343}
338 344
339static int check_adcl_select(struct snd_soc_dapm_widget *source, 345static int check_adcl_select(struct snd_soc_dapm_widget *source,
340 struct snd_soc_dapm_widget *sink) 346 struct snd_soc_dapm_widget *sink)
341{ 347{
348 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
342 unsigned int reg; 349 unsigned int reg;
343 350
344 reg = snd_soc_read(source->codec, RT5631_ADC_REC_MIXER); 351 reg = snd_soc_read(codec, RT5631_ADC_REC_MIXER);
345 return !(reg & RT5631_M_MIC1_TO_RECMIXER_L); 352 return !(reg & RT5631_M_MIC1_TO_RECMIXER_L);
346} 353}
347 354
348static int check_adcr_select(struct snd_soc_dapm_widget *source, 355static int check_adcr_select(struct snd_soc_dapm_widget *source,
349 struct snd_soc_dapm_widget *sink) 356 struct snd_soc_dapm_widget *sink)
350{ 357{
358 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
351 unsigned int reg; 359 unsigned int reg;
352 360
353 reg = snd_soc_read(source->codec, RT5631_ADC_REC_MIXER); 361 reg = snd_soc_read(codec, RT5631_ADC_REC_MIXER);
354 return !(reg & RT5631_M_MIC2_TO_RECMIXER_R); 362 return !(reg & RT5631_M_MIC2_TO_RECMIXER_R);
355} 363}
356 364
@@ -556,7 +564,7 @@ static void depop_seq_mute_stage(struct snd_soc_codec *codec, int enable)
556static int hp_event(struct snd_soc_dapm_widget *w, 564static int hp_event(struct snd_soc_dapm_widget *w,
557 struct snd_kcontrol *kcontrol, int event) 565 struct snd_kcontrol *kcontrol, int event)
558{ 566{
559 struct snd_soc_codec *codec = w->codec; 567 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
560 struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); 568 struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
561 569
562 switch (event) { 570 switch (event) {
@@ -590,7 +598,7 @@ static int hp_event(struct snd_soc_dapm_widget *w,
590static int set_dmic_params(struct snd_soc_dapm_widget *w, 598static int set_dmic_params(struct snd_soc_dapm_widget *w,
591 struct snd_kcontrol *kcontrol, int event) 599 struct snd_kcontrol *kcontrol, int event)
592{ 600{
593 struct snd_soc_codec *codec = w->codec; 601 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
594 struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); 602 struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
595 603
596 switch (rt5631->rx_rate) { 604 switch (rt5631->rx_rate) {
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index c3f2decd643c..178e55d4d481 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -458,7 +458,7 @@ static const struct snd_kcontrol_new rt5640_specific_snd_controls[] = {
458static int set_dmic_clk(struct snd_soc_dapm_widget *w, 458static int set_dmic_clk(struct snd_soc_dapm_widget *w,
459 struct snd_kcontrol *kcontrol, int event) 459 struct snd_kcontrol *kcontrol, int event)
460{ 460{
461 struct snd_soc_codec *codec = w->codec; 461 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
462 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); 462 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
463 int idx = -EINVAL; 463 int idx = -EINVAL;
464 464
@@ -475,9 +475,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
475static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, 475static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
476 struct snd_soc_dapm_widget *sink) 476 struct snd_soc_dapm_widget *sink)
477{ 477{
478 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
478 unsigned int val; 479 unsigned int val;
479 480
480 val = snd_soc_read(source->codec, RT5640_GLB_CLK); 481 val = snd_soc_read(codec, RT5640_GLB_CLK);
481 val &= RT5640_SCLK_SRC_MASK; 482 val &= RT5640_SCLK_SRC_MASK;
482 if (val == RT5640_SCLK_SRC_PLL1) 483 if (val == RT5640_SCLK_SRC_PLL1)
483 return 1; 484 return 1;
@@ -963,7 +964,7 @@ static void rt5640_pmu_depop(struct snd_soc_codec *codec)
963static int rt5640_hp_event(struct snd_soc_dapm_widget *w, 964static int rt5640_hp_event(struct snd_soc_dapm_widget *w,
964 struct snd_kcontrol *kcontrol, int event) 965 struct snd_kcontrol *kcontrol, int event)
965{ 966{
966 struct snd_soc_codec *codec = w->codec; 967 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
967 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); 968 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
968 969
969 switch (event) { 970 switch (event) {
@@ -987,7 +988,7 @@ static int rt5640_hp_event(struct snd_soc_dapm_widget *w,
987static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w, 988static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w,
988 struct snd_kcontrol *kcontrol, int event) 989 struct snd_kcontrol *kcontrol, int event)
989{ 990{
990 struct snd_soc_codec *codec = w->codec; 991 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
991 992
992 switch (event) { 993 switch (event) {
993 case SND_SOC_DAPM_POST_PMU: 994 case SND_SOC_DAPM_POST_PMU:
@@ -1003,7 +1004,7 @@ static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w,
1003static int rt5640_hp_post_event(struct snd_soc_dapm_widget *w, 1004static int rt5640_hp_post_event(struct snd_soc_dapm_widget *w,
1004 struct snd_kcontrol *kcontrol, int event) 1005 struct snd_kcontrol *kcontrol, int event)
1005{ 1006{
1006 struct snd_soc_codec *codec = w->codec; 1007 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1007 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); 1008 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
1008 1009
1009 switch (event) { 1010 switch (event) {
@@ -2124,6 +2125,7 @@ MODULE_DEVICE_TABLE(of, rt5640_of_match);
2124static struct acpi_device_id rt5640_acpi_match[] = { 2125static struct acpi_device_id rt5640_acpi_match[] = {
2125 { "INT33CA", 0 }, 2126 { "INT33CA", 0 },
2126 { "10EC5640", 0 }, 2127 { "10EC5640", 0 },
2128 { "10EC5642", 0 },
2127 { }, 2129 { },
2128}; 2130};
2129MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match); 2131MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match);
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 27141e2df878..068dfd5c7640 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -527,7 +527,7 @@ static const struct snd_kcontrol_new rt5645_snd_controls[] = {
527static int set_dmic_clk(struct snd_soc_dapm_widget *w, 527static int set_dmic_clk(struct snd_soc_dapm_widget *w,
528 struct snd_kcontrol *kcontrol, int event) 528 struct snd_kcontrol *kcontrol, int event)
529{ 529{
530 struct snd_soc_codec *codec = w->codec; 530 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
531 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); 531 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
532 int idx = -EINVAL; 532 int idx = -EINVAL;
533 533
@@ -544,9 +544,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
544static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, 544static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
545 struct snd_soc_dapm_widget *sink) 545 struct snd_soc_dapm_widget *sink)
546{ 546{
547 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
547 unsigned int val; 548 unsigned int val;
548 549
549 val = snd_soc_read(source->codec, RT5645_GLB_CLK); 550 val = snd_soc_read(codec, RT5645_GLB_CLK);
550 val &= RT5645_SCLK_SRC_MASK; 551 val &= RT5645_SCLK_SRC_MASK;
551 if (val == RT5645_SCLK_SRC_PLL1) 552 if (val == RT5645_SCLK_SRC_PLL1)
552 return 1; 553 return 1;
@@ -557,6 +558,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
557static int is_using_asrc(struct snd_soc_dapm_widget *source, 558static int is_using_asrc(struct snd_soc_dapm_widget *source,
558 struct snd_soc_dapm_widget *sink) 559 struct snd_soc_dapm_widget *sink)
559{ 560{
561 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
560 unsigned int reg, shift, val; 562 unsigned int reg, shift, val;
561 563
562 switch (source->shift) { 564 switch (source->shift) {
@@ -588,7 +590,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source,
588 return 0; 590 return 0;
589 } 591 }
590 592
591 val = (snd_soc_read(source->codec, reg) >> shift) & 0xf; 593 val = (snd_soc_read(codec, reg) >> shift) & 0xf;
592 switch (val) { 594 switch (val) {
593 case 1: 595 case 1:
594 case 2: 596 case 2:
@@ -1144,7 +1146,7 @@ static void hp_amp_power(struct snd_soc_codec *codec, int on)
1144static int rt5645_hp_event(struct snd_soc_dapm_widget *w, 1146static int rt5645_hp_event(struct snd_soc_dapm_widget *w,
1145 struct snd_kcontrol *kcontrol, int event) 1147 struct snd_kcontrol *kcontrol, int event)
1146{ 1148{
1147 struct snd_soc_codec *codec = w->codec; 1149 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1148 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); 1150 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
1149 1151
1150 switch (event) { 1152 switch (event) {
@@ -1205,7 +1207,7 @@ static int rt5645_hp_event(struct snd_soc_dapm_widget *w,
1205static int rt5645_spk_event(struct snd_soc_dapm_widget *w, 1207static int rt5645_spk_event(struct snd_soc_dapm_widget *w,
1206 struct snd_kcontrol *kcontrol, int event) 1208 struct snd_kcontrol *kcontrol, int event)
1207{ 1209{
1208 struct snd_soc_codec *codec = w->codec; 1210 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1209 1211
1210 switch (event) { 1212 switch (event) {
1211 case SND_SOC_DAPM_POST_PMU: 1213 case SND_SOC_DAPM_POST_PMU:
@@ -1232,7 +1234,7 @@ static int rt5645_spk_event(struct snd_soc_dapm_widget *w,
1232static int rt5645_lout_event(struct snd_soc_dapm_widget *w, 1234static int rt5645_lout_event(struct snd_soc_dapm_widget *w,
1233 struct snd_kcontrol *kcontrol, int event) 1235 struct snd_kcontrol *kcontrol, int event)
1234{ 1236{
1235 struct snd_soc_codec *codec = w->codec; 1237 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1236 1238
1237 switch (event) { 1239 switch (event) {
1238 case SND_SOC_DAPM_POST_PMU: 1240 case SND_SOC_DAPM_POST_PMU:
@@ -1262,7 +1264,7 @@ static int rt5645_lout_event(struct snd_soc_dapm_widget *w,
1262static int rt5645_bst2_event(struct snd_soc_dapm_widget *w, 1264static int rt5645_bst2_event(struct snd_soc_dapm_widget *w,
1263 struct snd_kcontrol *kcontrol, int event) 1265 struct snd_kcontrol *kcontrol, int event)
1264{ 1266{
1265 struct snd_soc_codec *codec = w->codec; 1267 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1266 1268
1267 switch (event) { 1269 switch (event) {
1268 case SND_SOC_DAPM_POST_PMU: 1270 case SND_SOC_DAPM_POST_PMU:
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c
index bb0a3ab5416c..9f4c7be6d798 100644
--- a/sound/soc/codecs/rt5651.c
+++ b/sound/soc/codecs/rt5651.c
@@ -376,7 +376,7 @@ static const struct snd_kcontrol_new rt5651_snd_controls[] = {
376static int set_dmic_clk(struct snd_soc_dapm_widget *w, 376static int set_dmic_clk(struct snd_soc_dapm_widget *w,
377 struct snd_kcontrol *kcontrol, int event) 377 struct snd_kcontrol *kcontrol, int event)
378{ 378{
379 struct snd_soc_codec *codec = w->codec; 379 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
380 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); 380 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec);
381 int idx = -EINVAL; 381 int idx = -EINVAL;
382 382
@@ -394,9 +394,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
394static int is_sysclk_from_pll(struct snd_soc_dapm_widget *source, 394static int is_sysclk_from_pll(struct snd_soc_dapm_widget *source,
395 struct snd_soc_dapm_widget *sink) 395 struct snd_soc_dapm_widget *sink)
396{ 396{
397 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
397 unsigned int val; 398 unsigned int val;
398 399
399 val = snd_soc_read(source->codec, RT5651_GLB_CLK); 400 val = snd_soc_read(codec, RT5651_GLB_CLK);
400 val &= RT5651_SCLK_SRC_MASK; 401 val &= RT5651_SCLK_SRC_MASK;
401 if (val == RT5651_SCLK_SRC_PLL1) 402 if (val == RT5651_SCLK_SRC_PLL1)
402 return 1; 403 return 1;
@@ -731,7 +732,7 @@ static const struct snd_kcontrol_new rt5651_pdm_r_mux =
731static int rt5651_amp_power_event(struct snd_soc_dapm_widget *w, 732static int rt5651_amp_power_event(struct snd_soc_dapm_widget *w,
732 struct snd_kcontrol *kcontrol, int event) 733 struct snd_kcontrol *kcontrol, int event)
733{ 734{
734 struct snd_soc_codec *codec = w->codec; 735 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
735 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); 736 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec);
736 737
737 switch (event) { 738 switch (event) {
@@ -769,7 +770,7 @@ static int rt5651_amp_power_event(struct snd_soc_dapm_widget *w,
769static int rt5651_hp_event(struct snd_soc_dapm_widget *w, 770static int rt5651_hp_event(struct snd_soc_dapm_widget *w,
770 struct snd_kcontrol *kcontrol, int event) 771 struct snd_kcontrol *kcontrol, int event)
771{ 772{
772 struct snd_soc_codec *codec = w->codec; 773 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
773 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); 774 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec);
774 775
775 switch (event) { 776 switch (event) {
@@ -813,7 +814,8 @@ static int rt5651_hp_event(struct snd_soc_dapm_widget *w,
813static int rt5651_hp_post_event(struct snd_soc_dapm_widget *w, 814static int rt5651_hp_post_event(struct snd_soc_dapm_widget *w,
814 struct snd_kcontrol *kcontrol, int event) 815 struct snd_kcontrol *kcontrol, int event)
815{ 816{
816 struct snd_soc_codec *codec = w->codec; 817
818 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
817 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); 819 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec);
818 820
819 switch (event) { 821 switch (event) {
@@ -833,7 +835,7 @@ static int rt5651_hp_post_event(struct snd_soc_dapm_widget *w,
833static int rt5651_bst1_event(struct snd_soc_dapm_widget *w, 835static int rt5651_bst1_event(struct snd_soc_dapm_widget *w,
834 struct snd_kcontrol *kcontrol, int event) 836 struct snd_kcontrol *kcontrol, int event)
835{ 837{
836 struct snd_soc_codec *codec = w->codec; 838 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
837 839
838 switch (event) { 840 switch (event) {
839 case SND_SOC_DAPM_POST_PMU: 841 case SND_SOC_DAPM_POST_PMU:
@@ -856,7 +858,7 @@ static int rt5651_bst1_event(struct snd_soc_dapm_widget *w,
856static int rt5651_bst2_event(struct snd_soc_dapm_widget *w, 858static int rt5651_bst2_event(struct snd_soc_dapm_widget *w,
857 struct snd_kcontrol *kcontrol, int event) 859 struct snd_kcontrol *kcontrol, int event)
858{ 860{
859 struct snd_soc_codec *codec = w->codec; 861 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
860 862
861 switch (event) { 863 switch (event) {
862 case SND_SOC_DAPM_POST_PMU: 864 case SND_SOC_DAPM_POST_PMU:
@@ -879,7 +881,7 @@ static int rt5651_bst2_event(struct snd_soc_dapm_widget *w,
879static int rt5651_bst3_event(struct snd_soc_dapm_widget *w, 881static int rt5651_bst3_event(struct snd_soc_dapm_widget *w,
880 struct snd_kcontrol *kcontrol, int event) 882 struct snd_kcontrol *kcontrol, int event)
881{ 883{
882 struct snd_soc_codec *codec = w->codec; 884 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
883 885
884 switch (event) { 886 switch (event) {
885 case SND_SOC_DAPM_POST_PMU: 887 case SND_SOC_DAPM_POST_PMU:
diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
index 8a0833de1665..f5b054de481e 100644
--- a/sound/soc/codecs/rt5670.c
+++ b/sound/soc/codecs/rt5670.c
@@ -14,10 +14,12 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/pm.h> 16#include <linux/pm.h>
17#include <linux/pm_runtime.h>
17#include <linux/i2c.h> 18#include <linux/i2c.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
19#include <linux/acpi.h> 20#include <linux/acpi.h>
20#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
22#include <linux/dmi.h>
21#include <sound/core.h> 23#include <sound/core.h>
22#include <sound/pcm.h> 24#include <sound/pcm.h>
23#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
@@ -498,7 +500,7 @@ static const struct snd_kcontrol_new rt5670_snd_controls[] = {
498static int set_dmic_clk(struct snd_soc_dapm_widget *w, 500static int set_dmic_clk(struct snd_soc_dapm_widget *w,
499 struct snd_kcontrol *kcontrol, int event) 501 struct snd_kcontrol *kcontrol, int event)
500{ 502{
501 struct snd_soc_codec *codec = w->codec; 503 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
502 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); 504 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec);
503 int idx = -EINVAL; 505 int idx = -EINVAL;
504 506
@@ -515,9 +517,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
515static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, 517static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
516 struct snd_soc_dapm_widget *sink) 518 struct snd_soc_dapm_widget *sink)
517{ 519{
520 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
518 unsigned int val; 521 unsigned int val;
519 522
520 val = snd_soc_read(source->codec, RT5670_GLB_CLK); 523 val = snd_soc_read(codec, RT5670_GLB_CLK);
521 val &= RT5670_SCLK_SRC_MASK; 524 val &= RT5670_SCLK_SRC_MASK;
522 if (val == RT5670_SCLK_SRC_PLL1) 525 if (val == RT5670_SCLK_SRC_PLL1)
523 return 1; 526 return 1;
@@ -528,6 +531,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
528static int is_using_asrc(struct snd_soc_dapm_widget *source, 531static int is_using_asrc(struct snd_soc_dapm_widget *source,
529 struct snd_soc_dapm_widget *sink) 532 struct snd_soc_dapm_widget *sink)
530{ 533{
534 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
531 unsigned int reg, shift, val; 535 unsigned int reg, shift, val;
532 536
533 switch (source->shift) { 537 switch (source->shift) {
@@ -563,7 +567,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source,
563 return 0; 567 return 0;
564 } 568 }
565 569
566 val = (snd_soc_read(source->codec, reg) >> shift) & 0xf; 570 val = (snd_soc_read(codec, reg) >> shift) & 0xf;
567 switch (val) { 571 switch (val) {
568 case 1: 572 case 1:
569 case 2: 573 case 2:
@@ -1146,7 +1150,7 @@ static const struct snd_kcontrol_new rt5670_vad_adc_mux =
1146static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, 1150static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w,
1147 struct snd_kcontrol *kcontrol, int event) 1151 struct snd_kcontrol *kcontrol, int event)
1148{ 1152{
1149 struct snd_soc_codec *codec = w->codec; 1153 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1150 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); 1154 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec);
1151 1155
1152 switch (event) { 1156 switch (event) {
@@ -1182,7 +1186,7 @@ static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w,
1182static int rt5670_hp_event(struct snd_soc_dapm_widget *w, 1186static int rt5670_hp_event(struct snd_soc_dapm_widget *w,
1183 struct snd_kcontrol *kcontrol, int event) 1187 struct snd_kcontrol *kcontrol, int event)
1184{ 1188{
1185 struct snd_soc_codec *codec = w->codec; 1189 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1186 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); 1190 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec);
1187 1191
1188 switch (event) { 1192 switch (event) {
@@ -1232,7 +1236,7 @@ static int rt5670_hp_event(struct snd_soc_dapm_widget *w,
1232static int rt5670_bst1_event(struct snd_soc_dapm_widget *w, 1236static int rt5670_bst1_event(struct snd_soc_dapm_widget *w,
1233 struct snd_kcontrol *kcontrol, int event) 1237 struct snd_kcontrol *kcontrol, int event)
1234{ 1238{
1235 struct snd_soc_codec *codec = w->codec; 1239 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1236 1240
1237 switch (event) { 1241 switch (event) {
1238 case SND_SOC_DAPM_POST_PMU: 1242 case SND_SOC_DAPM_POST_PMU:
@@ -1255,7 +1259,7 @@ static int rt5670_bst1_event(struct snd_soc_dapm_widget *w,
1255static int rt5670_bst2_event(struct snd_soc_dapm_widget *w, 1259static int rt5670_bst2_event(struct snd_soc_dapm_widget *w,
1256 struct snd_kcontrol *kcontrol, int event) 1260 struct snd_kcontrol *kcontrol, int event)
1257{ 1261{
1258 struct snd_soc_codec *codec = w->codec; 1262 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1259 1263
1260 switch (event) { 1264 switch (event) {
1261 case SND_SOC_DAPM_POST_PMU: 1265 case SND_SOC_DAPM_POST_PMU:
@@ -2188,6 +2192,13 @@ static int rt5670_set_dai_sysclk(struct snd_soc_dai *dai,
2188 if (freq == rt5670->sysclk && clk_id == rt5670->sysclk_src) 2192 if (freq == rt5670->sysclk && clk_id == rt5670->sysclk_src)
2189 return 0; 2193 return 0;
2190 2194
2195 if (rt5670->pdata.jd_mode) {
2196 if (clk_id == RT5670_SCLK_S_PLL1)
2197 snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL1");
2198 else
2199 snd_soc_dapm_disable_pin(&codec->dapm, "PLL1");
2200 snd_soc_dapm_sync(&codec->dapm);
2201 }
2191 switch (clk_id) { 2202 switch (clk_id) {
2192 case RT5670_SCLK_S_MCLK: 2203 case RT5670_SCLK_S_MCLK:
2193 reg_val |= RT5670_SCLK_SRC_MCLK; 2204 reg_val |= RT5670_SCLK_SRC_MCLK;
@@ -2549,6 +2560,17 @@ static struct acpi_device_id rt5670_acpi_match[] = {
2549MODULE_DEVICE_TABLE(acpi, rt5670_acpi_match); 2560MODULE_DEVICE_TABLE(acpi, rt5670_acpi_match);
2550#endif 2561#endif
2551 2562
2563static const struct dmi_system_id dmi_platform_intel_braswell[] = {
2564 {
2565 .ident = "Intel Braswell",
2566 .matches = {
2567 DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
2568 DMI_MATCH(DMI_BOARD_NAME, "Braswell CRB"),
2569 },
2570 },
2571 {}
2572};
2573
2552static int rt5670_i2c_probe(struct i2c_client *i2c, 2574static int rt5670_i2c_probe(struct i2c_client *i2c,
2553 const struct i2c_device_id *id) 2575 const struct i2c_device_id *id)
2554{ 2576{
@@ -2568,6 +2590,12 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
2568 if (pdata) 2590 if (pdata)
2569 rt5670->pdata = *pdata; 2591 rt5670->pdata = *pdata;
2570 2592
2593 if (dmi_check_system(dmi_platform_intel_braswell)) {
2594 rt5670->pdata.dmic_en = true;
2595 rt5670->pdata.dmic1_data_pin = RT5670_DMIC_DATA_IN2P;
2596 rt5670->pdata.jd_mode = 1;
2597 }
2598
2571 rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap); 2599 rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap);
2572 if (IS_ERR(rt5670->regmap)) { 2600 if (IS_ERR(rt5670->regmap)) {
2573 ret = PTR_ERR(rt5670->regmap); 2601 ret = PTR_ERR(rt5670->regmap);
@@ -2609,6 +2637,10 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
2609 } 2637 }
2610 2638
2611 if (rt5670->pdata.jd_mode) { 2639 if (rt5670->pdata.jd_mode) {
2640 regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK,
2641 RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_RCCLK);
2642 rt5670->sysclk = 0;
2643 rt5670->sysclk_src = RT5670_SCLK_S_RCCLK;
2612 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, 2644 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1,
2613 RT5670_PWR_MB, RT5670_PWR_MB); 2645 RT5670_PWR_MB, RT5670_PWR_MB);
2614 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG2, 2646 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG2,
@@ -2716,18 +2748,26 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
2716 2748
2717 } 2749 }
2718 2750
2751 pm_runtime_enable(&i2c->dev);
2752 pm_request_idle(&i2c->dev);
2753
2719 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5670, 2754 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5670,
2720 rt5670_dai, ARRAY_SIZE(rt5670_dai)); 2755 rt5670_dai, ARRAY_SIZE(rt5670_dai));
2721 if (ret < 0) 2756 if (ret < 0)
2722 goto err; 2757 goto err;
2723 2758
2759 pm_runtime_put(&i2c->dev);
2760
2724 return 0; 2761 return 0;
2725err: 2762err:
2763 pm_runtime_disable(&i2c->dev);
2764
2726 return ret; 2765 return ret;
2727} 2766}
2728 2767
2729static int rt5670_i2c_remove(struct i2c_client *i2c) 2768static int rt5670_i2c_remove(struct i2c_client *i2c)
2730{ 2769{
2770 pm_runtime_disable(&i2c->dev);
2731 snd_soc_unregister_codec(&i2c->dev); 2771 snd_soc_unregister_codec(&i2c->dev);
2732 2772
2733 return 0; 2773 return 0;
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 81fe1464d268..26fc538f03b1 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -784,8 +784,8 @@ static unsigned int bst_tlv[] = {
784static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol, 784static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
785 struct snd_ctl_elem_value *ucontrol) 785 struct snd_ctl_elem_value *ucontrol)
786{ 786{
787 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 787 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
788 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 788 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
789 789
790 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en; 790 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en;
791 791
@@ -795,8 +795,9 @@ static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
795static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol, 795static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol,
796 struct snd_ctl_elem_value *ucontrol) 796 struct snd_ctl_elem_value *ucontrol)
797{ 797{
798 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 798 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
799 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 799 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
800 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
800 801
801 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0]; 802 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0];
802 803
@@ -895,7 +896,7 @@ static const struct snd_kcontrol_new rt5677_snd_controls[] = {
895static int set_dmic_clk(struct snd_soc_dapm_widget *w, 896static int set_dmic_clk(struct snd_soc_dapm_widget *w,
896 struct snd_kcontrol *kcontrol, int event) 897 struct snd_kcontrol *kcontrol, int event)
897{ 898{
898 struct snd_soc_codec *codec = w->codec; 899 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
899 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 900 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
900 int idx = rl6231_calc_dmic_clk(rt5677->sysclk); 901 int idx = rl6231_calc_dmic_clk(rt5677->sysclk);
901 902
@@ -910,7 +911,8 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
910static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, 911static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
911 struct snd_soc_dapm_widget *sink) 912 struct snd_soc_dapm_widget *sink)
912{ 913{
913 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(source->codec); 914 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
915 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
914 unsigned int val; 916 unsigned int val;
915 917
916 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val); 918 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val);
@@ -921,6 +923,101 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
921 return 0; 923 return 0;
922} 924}
923 925
926static int is_using_asrc(struct snd_soc_dapm_widget *source,
927 struct snd_soc_dapm_widget *sink)
928{
929 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
930 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
931 unsigned int reg, shift, val;
932
933 if (source->reg == RT5677_ASRC_1) {
934 switch (source->shift) {
935 case 12:
936 reg = RT5677_ASRC_4;
937 shift = 0;
938 break;
939 case 13:
940 reg = RT5677_ASRC_4;
941 shift = 4;
942 break;
943 case 14:
944 reg = RT5677_ASRC_4;
945 shift = 8;
946 break;
947 case 15:
948 reg = RT5677_ASRC_4;
949 shift = 12;
950 break;
951 default:
952 return 0;
953 }
954 } else {
955 switch (source->shift) {
956 case 0:
957 reg = RT5677_ASRC_6;
958 shift = 8;
959 break;
960 case 1:
961 reg = RT5677_ASRC_6;
962 shift = 12;
963 break;
964 case 2:
965 reg = RT5677_ASRC_5;
966 shift = 0;
967 break;
968 case 3:
969 reg = RT5677_ASRC_5;
970 shift = 4;
971 break;
972 case 4:
973 reg = RT5677_ASRC_5;
974 shift = 8;
975 break;
976 case 5:
977 reg = RT5677_ASRC_5;
978 shift = 12;
979 break;
980 case 12:
981 reg = RT5677_ASRC_3;
982 shift = 0;
983 break;
984 case 13:
985 reg = RT5677_ASRC_3;
986 shift = 4;
987 break;
988 case 14:
989 reg = RT5677_ASRC_3;
990 shift = 12;
991 break;
992 default:
993 return 0;
994 }
995 }
996
997 regmap_read(rt5677->regmap, reg, &val);
998 val = (val >> shift) & 0xf;
999
1000 switch (val) {
1001 case 1 ... 6:
1002 return 1;
1003 default:
1004 return 0;
1005 }
1006
1007}
1008
1009static int can_use_asrc(struct snd_soc_dapm_widget *source,
1010 struct snd_soc_dapm_widget *sink)
1011{
1012 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
1013 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
1014
1015 if (rt5677->sysclk > rt5677->lrck[RT5677_AIF1] * 384)
1016 return 1;
1017
1018 return 0;
1019}
1020
924/* Digital Mixer */ 1021/* Digital Mixer */
925static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = { 1022static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = {
926 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER, 1023 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
@@ -2030,7 +2127,7 @@ static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux =
2030static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, 2127static int rt5677_bst1_event(struct snd_soc_dapm_widget *w,
2031 struct snd_kcontrol *kcontrol, int event) 2128 struct snd_kcontrol *kcontrol, int event)
2032{ 2129{
2033 struct snd_soc_codec *codec = w->codec; 2130 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2034 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2131 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2035 2132
2036 switch (event) { 2133 switch (event) {
@@ -2054,7 +2151,7 @@ static int rt5677_bst1_event(struct snd_soc_dapm_widget *w,
2054static int rt5677_bst2_event(struct snd_soc_dapm_widget *w, 2151static int rt5677_bst2_event(struct snd_soc_dapm_widget *w,
2055 struct snd_kcontrol *kcontrol, int event) 2152 struct snd_kcontrol *kcontrol, int event)
2056{ 2153{
2057 struct snd_soc_codec *codec = w->codec; 2154 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2058 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2155 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2059 2156
2060 switch (event) { 2157 switch (event) {
@@ -2078,14 +2175,18 @@ static int rt5677_bst2_event(struct snd_soc_dapm_widget *w,
2078static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w, 2175static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w,
2079 struct snd_kcontrol *kcontrol, int event) 2176 struct snd_kcontrol *kcontrol, int event)
2080{ 2177{
2081 struct snd_soc_codec *codec = w->codec; 2178 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2082 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2179 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2083 2180
2084 switch (event) { 2181 switch (event) {
2085 case SND_SOC_DAPM_POST_PMU: 2182 case SND_SOC_DAPM_PRE_PMU:
2086 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2); 2183 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2);
2184 break;
2185
2186 case SND_SOC_DAPM_POST_PMU:
2087 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0); 2187 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0);
2088 break; 2188 break;
2189
2089 default: 2190 default:
2090 return 0; 2191 return 0;
2091 } 2192 }
@@ -2096,14 +2197,18 @@ static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w,
2096static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w, 2197static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w,
2097 struct snd_kcontrol *kcontrol, int event) 2198 struct snd_kcontrol *kcontrol, int event)
2098{ 2199{
2099 struct snd_soc_codec *codec = w->codec; 2200 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2100 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2201 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2101 2202
2102 switch (event) { 2203 switch (event) {
2103 case SND_SOC_DAPM_POST_PMU: 2204 case SND_SOC_DAPM_PRE_PMU:
2104 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2); 2205 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2);
2206 break;
2207
2208 case SND_SOC_DAPM_POST_PMU:
2105 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0); 2209 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0);
2106 break; 2210 break;
2211
2107 default: 2212 default:
2108 return 0; 2213 return 0;
2109 } 2214 }
@@ -2114,7 +2219,7 @@ static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w,
2114static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w, 2219static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w,
2115 struct snd_kcontrol *kcontrol, int event) 2220 struct snd_kcontrol *kcontrol, int event)
2116{ 2221{
2117 struct snd_soc_codec *codec = w->codec; 2222 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2118 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2223 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2119 2224
2120 switch (event) { 2225 switch (event) {
@@ -2141,7 +2246,7 @@ static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w,
2141static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w, 2246static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w,
2142 struct snd_kcontrol *kcontrol, int event) 2247 struct snd_kcontrol *kcontrol, int event)
2143{ 2248{
2144 struct snd_soc_codec *codec = w->codec; 2249 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2145 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2250 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2146 unsigned int value; 2251 unsigned int value;
2147 2252
@@ -2164,7 +2269,7 @@ static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w,
2164static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w, 2269static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w,
2165 struct snd_kcontrol *kcontrol, int event) 2270 struct snd_kcontrol *kcontrol, int event)
2166{ 2271{
2167 struct snd_soc_codec *codec = w->codec; 2272 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2168 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2273 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2169 unsigned int value; 2274 unsigned int value;
2170 2275
@@ -2187,7 +2292,7 @@ static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w,
2187static int rt5677_vref_event(struct snd_soc_dapm_widget *w, 2292static int rt5677_vref_event(struct snd_soc_dapm_widget *w,
2188 struct snd_kcontrol *kcontrol, int event) 2293 struct snd_kcontrol *kcontrol, int event)
2189{ 2294{
2190 struct snd_soc_codec *codec = w->codec; 2295 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2191 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2296 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2192 2297
2193 switch (event) { 2298 switch (event) {
@@ -2211,9 +2316,50 @@ static int rt5677_vref_event(struct snd_soc_dapm_widget *w,
2211 2316
2212static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = { 2317static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2213 SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT, 2318 SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT,
2214 0, rt5677_set_pll1_event, SND_SOC_DAPM_POST_PMU), 2319 0, rt5677_set_pll1_event, SND_SOC_DAPM_PRE_PMU |
2320 SND_SOC_DAPM_POST_PMU),
2215 SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT, 2321 SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT,
2216 0, rt5677_set_pll2_event, SND_SOC_DAPM_POST_PMU), 2322 0, rt5677_set_pll2_event, SND_SOC_DAPM_PRE_PMU |
2323 SND_SOC_DAPM_POST_PMU),
2324
2325 /* ASRC */
2326 SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5677_ASRC_1, 0, 0, NULL, 0),
2327 SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5677_ASRC_1, 1, 0, NULL, 0),
2328 SND_SOC_DAPM_SUPPLY_S("I2S3 ASRC", 1, RT5677_ASRC_1, 2, 0, NULL, 0),
2329 SND_SOC_DAPM_SUPPLY_S("I2S4 ASRC", 1, RT5677_ASRC_1, 3, 0, NULL, 0),
2330 SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5677_ASRC_2, 14, 0, NULL, 0),
2331 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 L ASRC", 1, RT5677_ASRC_2, 13, 0, NULL,
2332 0),
2333 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 R ASRC", 1, RT5677_ASRC_2, 12, 0, NULL,
2334 0),
2335 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 L ASRC", 1, RT5677_ASRC_1, 15, 0, NULL,
2336 0),
2337 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 R ASRC", 1, RT5677_ASRC_1, 14, 0, NULL,
2338 0),
2339 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 L ASRC", 1, RT5677_ASRC_1, 13, 0, NULL,
2340 0),
2341 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 R ASRC", 1, RT5677_ASRC_1, 12, 0, NULL,
2342 0),
2343 SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5677_ASRC_2, 11, 0, NULL,
2344 0),
2345 SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5677_ASRC_2, 10, 0, NULL,
2346 0),
2347 SND_SOC_DAPM_SUPPLY_S("DMIC STO3 ASRC", 1, RT5677_ASRC_2, 9, 0, NULL,
2348 0),
2349 SND_SOC_DAPM_SUPPLY_S("DMIC STO4 ASRC", 1, RT5677_ASRC_2, 8, 0, NULL,
2350 0),
2351 SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5677_ASRC_2, 7, 0, NULL,
2352 0),
2353 SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5677_ASRC_2, 6, 0, NULL,
2354 0),
2355 SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5677_ASRC_2, 5, 0, NULL, 0),
2356 SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5677_ASRC_2, 4, 0, NULL, 0),
2357 SND_SOC_DAPM_SUPPLY_S("ADC STO3 ASRC", 1, RT5677_ASRC_2, 3, 0, NULL, 0),
2358 SND_SOC_DAPM_SUPPLY_S("ADC STO4 ASRC", 1, RT5677_ASRC_2, 2, 0, NULL, 0),
2359 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5677_ASRC_2, 1, 0, NULL,
2360 0),
2361 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5677_ASRC_2, 0, 0, NULL,
2362 0),
2217 2363
2218 /* Input Side */ 2364 /* Input Side */
2219 /* micbias */ 2365 /* micbias */
@@ -2645,10 +2791,18 @@ static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2645 /* DAC Mixer */ 2791 /* DAC Mixer */
2646 SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2, 2792 SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2,
2647 RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0), 2793 RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0),
2648 SND_SOC_DAPM_SUPPLY("dac mono left filter", RT5677_PWR_DIG2, 2794 SND_SOC_DAPM_SUPPLY("dac mono2 left filter", RT5677_PWR_DIG2,
2649 RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0), 2795 RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0),
2650 SND_SOC_DAPM_SUPPLY("dac mono right filter", RT5677_PWR_DIG2, 2796 SND_SOC_DAPM_SUPPLY("dac mono2 right filter", RT5677_PWR_DIG2,
2651 RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0), 2797 RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0),
2798 SND_SOC_DAPM_SUPPLY("dac mono3 left filter", RT5677_PWR_DIG2,
2799 RT5677_PWR_DAC_M3F_L_BIT, 0, NULL, 0),
2800 SND_SOC_DAPM_SUPPLY("dac mono3 right filter", RT5677_PWR_DIG2,
2801 RT5677_PWR_DAC_M3F_R_BIT, 0, NULL, 0),
2802 SND_SOC_DAPM_SUPPLY("dac mono4 left filter", RT5677_PWR_DIG2,
2803 RT5677_PWR_DAC_M4F_L_BIT, 0, NULL, 0),
2804 SND_SOC_DAPM_SUPPLY("dac mono4 right filter", RT5677_PWR_DIG2,
2805 RT5677_PWR_DAC_M4F_R_BIT, 0, NULL, 0),
2652 2806
2653 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, 2807 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
2654 rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)), 2808 rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)),
@@ -2721,6 +2875,31 @@ static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2721}; 2875};
2722 2876
2723static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { 2877static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2878 { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", can_use_asrc },
2879 { "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", can_use_asrc },
2880 { "Stereo3 DMIC Mux", NULL, "DMIC STO3 ASRC", can_use_asrc },
2881 { "Stereo4 DMIC Mux", NULL, "DMIC STO4 ASRC", can_use_asrc },
2882 { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc },
2883 { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc },
2884 { "I2S1", NULL, "I2S1 ASRC", can_use_asrc},
2885 { "I2S2", NULL, "I2S2 ASRC", can_use_asrc},
2886 { "I2S3", NULL, "I2S3 ASRC", can_use_asrc},
2887 { "I2S4", NULL, "I2S4 ASRC", can_use_asrc},
2888
2889 { "dac stereo1 filter", NULL, "DAC STO ASRC", is_using_asrc },
2890 { "dac mono2 left filter", NULL, "DAC MONO2 L ASRC", is_using_asrc },
2891 { "dac mono2 right filter", NULL, "DAC MONO2 R ASRC", is_using_asrc },
2892 { "dac mono3 left filter", NULL, "DAC MONO3 L ASRC", is_using_asrc },
2893 { "dac mono3 right filter", NULL, "DAC MONO3 R ASRC", is_using_asrc },
2894 { "dac mono4 left filter", NULL, "DAC MONO4 L ASRC", is_using_asrc },
2895 { "dac mono4 right filter", NULL, "DAC MONO4 R ASRC", is_using_asrc },
2896 { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc },
2897 { "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc },
2898 { "adc stereo3 filter", NULL, "ADC STO3 ASRC", is_using_asrc },
2899 { "adc stereo4 filter", NULL, "ADC STO4 ASRC", is_using_asrc },
2900 { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc },
2901 { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc },
2902
2724 { "DMIC1", NULL, "DMIC L1" }, 2903 { "DMIC1", NULL, "DMIC L1" },
2725 { "DMIC1", NULL, "DMIC R1" }, 2904 { "DMIC1", NULL, "DMIC R1" },
2726 { "DMIC2", NULL, "DMIC L2" }, 2905 { "DMIC2", NULL, "DMIC L2" },
@@ -2851,8 +3030,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2851 3030
2852 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" }, 3031 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" },
2853 { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" }, 3032 { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" },
2854 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
2855
2856 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" }, 3033 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" },
2857 { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" }, 3034 { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" },
2858 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll }, 3035 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
@@ -2873,8 +3050,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2873 3050
2874 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" }, 3051 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" },
2875 { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" }, 3052 { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" },
2876 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
2877
2878 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" }, 3053 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" },
2879 { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" }, 3054 { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" },
2880 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll }, 3055 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
@@ -2889,8 +3064,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2889 3064
2890 { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" }, 3065 { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" },
2891 { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" }, 3066 { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" },
2892 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
2893
2894 { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" }, 3067 { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" },
2895 { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" }, 3068 { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" },
2896 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll }, 3069 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
@@ -2905,8 +3078,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2905 3078
2906 { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" }, 3079 { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" },
2907 { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" }, 3080 { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" },
2908 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
2909
2910 { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" }, 3081 { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" },
2911 { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" }, 3082 { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" },
2912 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll }, 3083 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
@@ -3455,10 +3626,8 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3455 3626
3456 { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" }, 3627 { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" },
3457 { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" }, 3628 { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" },
3458 { "DAC1 MIXL", NULL, "dac stereo1 filter" },
3459 { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" }, 3629 { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" },
3460 { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" }, 3630 { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" },
3461 { "DAC1 MIXR", NULL, "dac stereo1 filter" },
3462 3631
3463 { "DAC1 FS", NULL, "DAC1 MIXL" }, 3632 { "DAC1 FS", NULL, "DAC1 MIXL" },
3464 { "DAC1 FS", NULL, "DAC1 MIXR" }, 3633 { "DAC1 FS", NULL, "DAC1 MIXR" },
@@ -3525,35 +3694,46 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3525 { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, 3694 { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3526 { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" }, 3695 { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" },
3527 { "Stereo DAC MIXR", NULL, "dac stereo1 filter" }, 3696 { "Stereo DAC MIXR", NULL, "dac stereo1 filter" },
3697 { "dac stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
3528 3698
3529 { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" }, 3699 { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" },
3530 { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" }, 3700 { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3531 { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" }, 3701 { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3532 { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" }, 3702 { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" },
3533 { "Mono DAC MIXL", NULL, "dac mono left filter" }, 3703 { "Mono DAC MIXL", NULL, "dac mono2 left filter" },
3704 { "dac mono2 left filter", NULL, "PLL1", is_sys_clk_from_pll },
3534 { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" }, 3705 { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" },
3535 { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" }, 3706 { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3536 { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, 3707 { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3537 { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" }, 3708 { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" },
3538 { "Mono DAC MIXR", NULL, "dac mono right filter" }, 3709 { "Mono DAC MIXR", NULL, "dac mono2 right filter" },
3710 { "dac mono2 right filter", NULL, "PLL1", is_sys_clk_from_pll },
3539 3711
3540 { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, 3712 { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3541 { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, 3713 { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3542 { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" }, 3714 { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" },
3543 { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" }, 3715 { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" },
3716 { "DD1 MIXL", NULL, "dac mono3 left filter" },
3717 { "dac mono3 left filter", NULL, "PLL1", is_sys_clk_from_pll },
3544 { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, 3718 { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3545 { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, 3719 { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3546 { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" }, 3720 { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" },
3547 { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" }, 3721 { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" },
3722 { "DD1 MIXR", NULL, "dac mono3 right filter" },
3723 { "dac mono3 right filter", NULL, "PLL1", is_sys_clk_from_pll },
3548 3724
3549 { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, 3725 { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3550 { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, 3726 { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3551 { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" }, 3727 { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" },
3552 { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" }, 3728 { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" },
3729 { "DD2 MIXL", NULL, "dac mono4 left filter" },
3730 { "dac mono4 left filter", NULL, "PLL1", is_sys_clk_from_pll },
3553 { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, 3731 { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3554 { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, 3732 { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3555 { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" }, 3733 { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" },
3556 { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" }, 3734 { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" },
3735 { "DD2 MIXR", NULL, "dac mono4 right filter" },
3736 { "dac mono4 right filter", NULL, "PLL1", is_sys_clk_from_pll },
3557 3737
3558 { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" }, 3738 { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" },
3559 { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" }, 3739 { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" },
@@ -3575,11 +3755,8 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3575 { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" }, 3755 { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" },
3576 3756
3577 { "DAC 1", NULL, "DAC12 SRC Mux" }, 3757 { "DAC 1", NULL, "DAC12 SRC Mux" },
3578 { "DAC 1", NULL, "PLL1", is_sys_clk_from_pll },
3579 { "DAC 2", NULL, "DAC12 SRC Mux" }, 3758 { "DAC 2", NULL, "DAC12 SRC Mux" },
3580 { "DAC 2", NULL, "PLL1", is_sys_clk_from_pll },
3581 { "DAC 3", NULL, "DAC3 SRC Mux" }, 3759 { "DAC 3", NULL, "DAC3 SRC Mux" },
3582 { "DAC 3", NULL, "PLL1", is_sys_clk_from_pll },
3583 3760
3584 { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" }, 3761 { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
3585 { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" }, 3762 { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
@@ -3926,7 +4103,8 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
3926 unsigned int rx_mask, int slots, int slot_width) 4103 unsigned int rx_mask, int slots, int slot_width)
3927{ 4104{
3928 struct snd_soc_codec *codec = dai->codec; 4105 struct snd_soc_codec *codec = dai->codec;
3929 unsigned int val = 0; 4106 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4107 unsigned int val = 0, slot_width_25 = 0;
3930 4108
3931 if (rx_mask || tx_mask) 4109 if (rx_mask || tx_mask)
3932 val |= (1 << 12); 4110 val |= (1 << 12);
@@ -3950,6 +4128,8 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
3950 case 20: 4128 case 20:
3951 val |= (1 << 8); 4129 val |= (1 << 8);
3952 break; 4130 break;
4131 case 25:
4132 slot_width_25 = 0x8080;
3953 case 24: 4133 case 24:
3954 val |= (2 << 8); 4134 val |= (2 << 8);
3955 break; 4135 break;
@@ -3963,10 +4143,16 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
3963 4143
3964 switch (dai->id) { 4144 switch (dai->id) {
3965 case RT5677_AIF1: 4145 case RT5677_AIF1:
3966 snd_soc_update_bits(codec, RT5677_TDM1_CTRL1, 0x1f00, val); 4146 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 0x1f00,
4147 val);
4148 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x8000,
4149 slot_width_25);
3967 break; 4150 break;
3968 case RT5677_AIF2: 4151 case RT5677_AIF2:
3969 snd_soc_update_bits(codec, RT5677_TDM2_CTRL1, 0x1f00, val); 4152 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 0x1f00,
4153 val);
4154 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x80,
4155 slot_width_25);
3970 break; 4156 break;
3971 default: 4157 default:
3972 break; 4158 break;
@@ -4751,6 +4937,11 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
4751 RT5677_GPIO5_DIR_OUT); 4937 RT5677_GPIO5_DIR_OUT);
4752 } 4938 }
4753 4939
4940 if (rt5677->pdata.micbias1_vdd_3v3)
4941 regmap_update_bits(rt5677->regmap, RT5677_MICBIAS,
4942 RT5677_MICBIAS1_CTRL_VDD_MASK,
4943 RT5677_MICBIAS1_CTRL_VDD_3_3V);
4944
4754 rt5677_init_gpio(i2c); 4945 rt5677_init_gpio(i2c);
4755 rt5677_init_irq(i2c); 4946 rt5677_init_irq(i2c);
4756 4947
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 29cf7ce610f4..e182e6569bbd 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -155,18 +155,19 @@ struct sgtl5000_priv {
155static int mic_bias_event(struct snd_soc_dapm_widget *w, 155static int mic_bias_event(struct snd_soc_dapm_widget *w,
156 struct snd_kcontrol *kcontrol, int event) 156 struct snd_kcontrol *kcontrol, int event)
157{ 157{
158 struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(w->codec); 158 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
159 struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
159 160
160 switch (event) { 161 switch (event) {
161 case SND_SOC_DAPM_POST_PMU: 162 case SND_SOC_DAPM_POST_PMU:
162 /* change mic bias resistor */ 163 /* change mic bias resistor */
163 snd_soc_update_bits(w->codec, SGTL5000_CHIP_MIC_CTRL, 164 snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL,
164 SGTL5000_BIAS_R_MASK, 165 SGTL5000_BIAS_R_MASK,
165 sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); 166 sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT);
166 break; 167 break;
167 168
168 case SND_SOC_DAPM_PRE_PMD: 169 case SND_SOC_DAPM_PRE_PMD:
169 snd_soc_update_bits(w->codec, SGTL5000_CHIP_MIC_CTRL, 170 snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL,
170 SGTL5000_BIAS_R_MASK, 0); 171 SGTL5000_BIAS_R_MASK, 0);
171 break; 172 break;
172 } 173 }
@@ -181,11 +182,12 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w,
181static int power_vag_event(struct snd_soc_dapm_widget *w, 182static int power_vag_event(struct snd_soc_dapm_widget *w,
182 struct snd_kcontrol *kcontrol, int event) 183 struct snd_kcontrol *kcontrol, int event)
183{ 184{
185 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
184 const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP; 186 const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP;
185 187
186 switch (event) { 188 switch (event) {
187 case SND_SOC_DAPM_POST_PMU: 189 case SND_SOC_DAPM_POST_PMU:
188 snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, 190 snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
189 SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); 191 SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
190 break; 192 break;
191 193
@@ -195,9 +197,9 @@ static int power_vag_event(struct snd_soc_dapm_widget *w,
195 * operational to prevent inadvertently starving the 197 * operational to prevent inadvertently starving the
196 * other one of them. 198 * other one of them.
197 */ 199 */
198 if ((snd_soc_read(w->codec, SGTL5000_CHIP_ANA_POWER) & 200 if ((snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER) &
199 mask) != mask) { 201 mask) != mask) {
200 snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, 202 snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
201 SGTL5000_VAG_POWERUP, 0); 203 SGTL5000_VAG_POWERUP, 0);
202 msleep(400); 204 msleep(400);
203 } 205 }
@@ -483,21 +485,21 @@ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
483 /* setting i2s data format */ 485 /* setting i2s data format */
484 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 486 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
485 case SND_SOC_DAIFMT_DSP_A: 487 case SND_SOC_DAIFMT_DSP_A:
486 i2sctl |= SGTL5000_I2S_MODE_PCM; 488 i2sctl |= SGTL5000_I2S_MODE_PCM << SGTL5000_I2S_MODE_SHIFT;
487 break; 489 break;
488 case SND_SOC_DAIFMT_DSP_B: 490 case SND_SOC_DAIFMT_DSP_B:
489 i2sctl |= SGTL5000_I2S_MODE_PCM; 491 i2sctl |= SGTL5000_I2S_MODE_PCM << SGTL5000_I2S_MODE_SHIFT;
490 i2sctl |= SGTL5000_I2S_LRALIGN; 492 i2sctl |= SGTL5000_I2S_LRALIGN;
491 break; 493 break;
492 case SND_SOC_DAIFMT_I2S: 494 case SND_SOC_DAIFMT_I2S:
493 i2sctl |= SGTL5000_I2S_MODE_I2S_LJ; 495 i2sctl |= SGTL5000_I2S_MODE_I2S_LJ << SGTL5000_I2S_MODE_SHIFT;
494 break; 496 break;
495 case SND_SOC_DAIFMT_RIGHT_J: 497 case SND_SOC_DAIFMT_RIGHT_J:
496 i2sctl |= SGTL5000_I2S_MODE_RJ; 498 i2sctl |= SGTL5000_I2S_MODE_RJ << SGTL5000_I2S_MODE_SHIFT;
497 i2sctl |= SGTL5000_I2S_LRPOL; 499 i2sctl |= SGTL5000_I2S_LRPOL;
498 break; 500 break;
499 case SND_SOC_DAIFMT_LEFT_J: 501 case SND_SOC_DAIFMT_LEFT_J:
500 i2sctl |= SGTL5000_I2S_MODE_I2S_LJ; 502 i2sctl |= SGTL5000_I2S_MODE_I2S_LJ << SGTL5000_I2S_MODE_SHIFT;
501 i2sctl |= SGTL5000_I2S_LRALIGN; 503 i2sctl |= SGTL5000_I2S_LRALIGN;
502 break; 504 break;
503 default: 505 default:
@@ -1462,6 +1464,9 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1462 if (ret) 1464 if (ret)
1463 return ret; 1465 return ret;
1464 1466
1467 /* Need 8 clocks before I2C accesses */
1468 udelay(1);
1469
1465 /* read chip information */ 1470 /* read chip information */
1466 ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, &reg); 1471 ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, &reg);
1467 if (ret) 1472 if (ret)
diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c
index 1f451a1946eb..47b257e41809 100644
--- a/sound/soc/codecs/sn95031.c
+++ b/sound/soc/codecs/sn95031.c
@@ -233,16 +233,18 @@ static int sn95031_set_vaud_bias(struct snd_soc_codec *codec,
233static int sn95031_vhs_event(struct snd_soc_dapm_widget *w, 233static int sn95031_vhs_event(struct snd_soc_dapm_widget *w,
234 struct snd_kcontrol *kcontrol, int event) 234 struct snd_kcontrol *kcontrol, int event)
235{ 235{
236 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
237
236 if (SND_SOC_DAPM_EVENT_ON(event)) { 238 if (SND_SOC_DAPM_EVENT_ON(event)) {
237 pr_debug("VHS SND_SOC_DAPM_EVENT_ON doing rail startup now\n"); 239 pr_debug("VHS SND_SOC_DAPM_EVENT_ON doing rail startup now\n");
238 /* power up the rail */ 240 /* power up the rail */
239 snd_soc_write(w->codec, SN95031_VHSP, 0x3D); 241 snd_soc_write(codec, SN95031_VHSP, 0x3D);
240 snd_soc_write(w->codec, SN95031_VHSN, 0x3F); 242 snd_soc_write(codec, SN95031_VHSN, 0x3F);
241 msleep(1); 243 msleep(1);
242 } else if (SND_SOC_DAPM_EVENT_OFF(event)) { 244 } else if (SND_SOC_DAPM_EVENT_OFF(event)) {
243 pr_debug("VHS SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n"); 245 pr_debug("VHS SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n");
244 snd_soc_write(w->codec, SN95031_VHSP, 0xC4); 246 snd_soc_write(codec, SN95031_VHSP, 0xC4);
245 snd_soc_write(w->codec, SN95031_VHSN, 0x04); 247 snd_soc_write(codec, SN95031_VHSN, 0x04);
246 } 248 }
247 return 0; 249 return 0;
248} 250}
@@ -250,14 +252,16 @@ static int sn95031_vhs_event(struct snd_soc_dapm_widget *w,
250static int sn95031_vihf_event(struct snd_soc_dapm_widget *w, 252static int sn95031_vihf_event(struct snd_soc_dapm_widget *w,
251 struct snd_kcontrol *kcontrol, int event) 253 struct snd_kcontrol *kcontrol, int event)
252{ 254{
255 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
256
253 if (SND_SOC_DAPM_EVENT_ON(event)) { 257 if (SND_SOC_DAPM_EVENT_ON(event)) {
254 pr_debug("VIHF SND_SOC_DAPM_EVENT_ON doing rail startup now\n"); 258 pr_debug("VIHF SND_SOC_DAPM_EVENT_ON doing rail startup now\n");
255 /* power up the rail */ 259 /* power up the rail */
256 snd_soc_write(w->codec, SN95031_VIHF, 0x27); 260 snd_soc_write(codec, SN95031_VIHF, 0x27);
257 msleep(1); 261 msleep(1);
258 } else if (SND_SOC_DAPM_EVENT_OFF(event)) { 262 } else if (SND_SOC_DAPM_EVENT_OFF(event)) {
259 pr_debug("VIHF SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n"); 263 pr_debug("VIHF SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n");
260 snd_soc_write(w->codec, SN95031_VIHF, 0x24); 264 snd_soc_write(codec, SN95031_VIHF, 0x24);
261 } 265 }
262 return 0; 266 return 0;
263} 267}
@@ -265,6 +269,7 @@ static int sn95031_vihf_event(struct snd_soc_dapm_widget *w,
265static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w, 269static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w,
266 struct snd_kcontrol *k, int event) 270 struct snd_kcontrol *k, int event)
267{ 271{
272 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
268 unsigned int ldo = 0, clk_dir = 0, data_dir = 0; 273 unsigned int ldo = 0, clk_dir = 0, data_dir = 0;
269 274
270 if (SND_SOC_DAPM_EVENT_ON(event)) { 275 if (SND_SOC_DAPM_EVENT_ON(event)) {
@@ -273,15 +278,16 @@ static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w,
273 data_dir = BIT(7); 278 data_dir = BIT(7);
274 } 279 }
275 /* program DMIC LDO, clock and set clock */ 280 /* program DMIC LDO, clock and set clock */
276 snd_soc_update_bits(w->codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); 281 snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo);
277 snd_soc_update_bits(w->codec, SN95031_DMICBUF0123, BIT(0), clk_dir); 282 snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(0), clk_dir);
278 snd_soc_update_bits(w->codec, SN95031_DMICBUF0123, BIT(7), data_dir); 283 snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(7), data_dir);
279 return 0; 284 return 0;
280} 285}
281 286
282static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w, 287static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w,
283 struct snd_kcontrol *k, int event) 288 struct snd_kcontrol *k, int event)
284{ 289{
290 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
285 unsigned int ldo = 0, clk_dir = 0, data_dir = 0; 291 unsigned int ldo = 0, clk_dir = 0, data_dir = 0;
286 292
287 if (SND_SOC_DAPM_EVENT_ON(event)) { 293 if (SND_SOC_DAPM_EVENT_ON(event)) {
@@ -290,22 +296,23 @@ static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w,
290 data_dir = BIT(1); 296 data_dir = BIT(1);
291 } 297 }
292 /* program DMIC LDO, clock and set clock */ 298 /* program DMIC LDO, clock and set clock */
293 snd_soc_update_bits(w->codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); 299 snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo);
294 snd_soc_update_bits(w->codec, SN95031_DMICBUF0123, BIT(2), clk_dir); 300 snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(2), clk_dir);
295 snd_soc_update_bits(w->codec, SN95031_DMICBUF45, BIT(1), data_dir); 301 snd_soc_update_bits(codec, SN95031_DMICBUF45, BIT(1), data_dir);
296 return 0; 302 return 0;
297} 303}
298 304
299static int sn95031_dmic56_event(struct snd_soc_dapm_widget *w, 305static int sn95031_dmic56_event(struct snd_soc_dapm_widget *w,
300 struct snd_kcontrol *k, int event) 306 struct snd_kcontrol *k, int event)
301{ 307{
308 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
302 unsigned int ldo = 0; 309 unsigned int ldo = 0;
303 310
304 if (SND_SOC_DAPM_EVENT_ON(event)) 311 if (SND_SOC_DAPM_EVENT_ON(event))
305 ldo = BIT(7)|BIT(6); 312 ldo = BIT(7)|BIT(6);
306 313
307 /* program DMIC LDO */ 314 /* program DMIC LDO */
308 snd_soc_update_bits(w->codec, SN95031_MICBIAS, BIT(7)|BIT(6), ldo); 315 snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(7)|BIT(6), ldo);
309 return 0; 316 return 0;
310} 317}
311 318
diff --git a/sound/soc/codecs/sta32x.h b/sound/soc/codecs/sta32x.h
index d8e32a6262ee..d3191c983d71 100644
--- a/sound/soc/codecs/sta32x.h
+++ b/sound/soc/codecs/sta32x.h
@@ -131,7 +131,7 @@
131#define STA32X_CONFF_OCFG_MASK 0x03 131#define STA32X_CONFF_OCFG_MASK 0x03
132#define STA32X_CONFF_OCFG_SHIFT 0 132#define STA32X_CONFF_OCFG_SHIFT 0
133#define STA32X_CONFF_IDE 0x04 133#define STA32X_CONFF_IDE 0x04
134#define STA32X_CONFF_IDE_SHIFT 3 134#define STA32X_CONFF_IDE_SHIFT 2
135#define STA32X_CONFF_BCLE 0x08 135#define STA32X_CONFF_BCLE 0x08
136#define STA32X_CONFF_ECLE 0x20 136#define STA32X_CONFF_ECLE 0x20
137#define STA32X_CONFF_PWDN 0x40 137#define STA32X_CONFF_PWDN 0x40
diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c
index dc3223d6eca1..c86dd9aae157 100644
--- a/sound/soc/codecs/tlv320aic31xx.c
+++ b/sound/soc/codecs/tlv320aic31xx.c
@@ -349,7 +349,8 @@ static int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg,
349static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, 349static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w,
350 struct snd_kcontrol *kcontrol, int event) 350 struct snd_kcontrol *kcontrol, int event)
351{ 351{
352 struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(w->codec); 352 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
353 struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
353 unsigned int reg = AIC31XX_DACFLAG1; 354 unsigned int reg = AIC31XX_DACFLAG1;
354 unsigned int mask; 355 unsigned int mask;
355 356
@@ -377,7 +378,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w,
377 reg = AIC31XX_ADCFLAG; 378 reg = AIC31XX_ADCFLAG;
378 break; 379 break;
379 default: 380 default:
380 dev_err(w->codec->dev, "Unknown widget '%s' calling %s\n", 381 dev_err(codec->dev, "Unknown widget '%s' calling %s\n",
381 w->name, __func__); 382 w->name, __func__);
382 return -EINVAL; 383 return -EINVAL;
383 } 384 }
@@ -388,7 +389,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w,
388 case SND_SOC_DAPM_POST_PMD: 389 case SND_SOC_DAPM_POST_PMD:
389 return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100); 390 return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100);
390 default: 391 default:
391 dev_dbg(w->codec->dev, 392 dev_dbg(codec->dev,
392 "Unhandled dapm widget event %d from %s\n", 393 "Unhandled dapm widget event %d from %s\n",
393 event, w->name); 394 event, w->name);
394 } 395 }
@@ -433,7 +434,7 @@ static const struct snd_kcontrol_new aic31xx_dapm_spr_switch =
433static int mic_bias_event(struct snd_soc_dapm_widget *w, 434static int mic_bias_event(struct snd_soc_dapm_widget *w,
434 struct snd_kcontrol *kcontrol, int event) 435 struct snd_kcontrol *kcontrol, int event)
435{ 436{
436 struct snd_soc_codec *codec = w->codec; 437 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
437 struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); 438 struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
438 439
439 switch (event) { 440 switch (event) {
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index b7ebce054b4e..07603d142923 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -197,7 +197,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol,
197static int mic_bias_event(struct snd_soc_dapm_widget *w, 197static int mic_bias_event(struct snd_soc_dapm_widget *w,
198 struct snd_kcontrol *kcontrol, int event) 198 struct snd_kcontrol *kcontrol, int event)
199{ 199{
200 struct snd_soc_codec *codec = w->codec; 200 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
201 struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); 201 struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
202 202
203 switch (event) { 203 switch (event) {
@@ -1046,7 +1046,7 @@ static int aic3x_prepare(struct snd_pcm_substream *substream,
1046 delay += aic3x->tdm_delay; 1046 delay += aic3x->tdm_delay;
1047 1047
1048 /* Configure data delay */ 1048 /* Configure data delay */
1049 snd_soc_write(codec, AIC3X_ASD_INTF_CTRLC, aic3x->tdm_delay); 1049 snd_soc_write(codec, AIC3X_ASD_INTF_CTRLC, delay);
1050 1050
1051 return 0; 1051 return 0;
1052} 1052}
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index 0fe2ced5b09f..4e3e607dec13 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -423,17 +423,18 @@ exit:
423static int dac33_playback_event(struct snd_soc_dapm_widget *w, 423static int dac33_playback_event(struct snd_soc_dapm_widget *w,
424 struct snd_kcontrol *kcontrol, int event) 424 struct snd_kcontrol *kcontrol, int event)
425{ 425{
426 struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(w->codec); 426 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
427 struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec);
427 428
428 switch (event) { 429 switch (event) {
429 case SND_SOC_DAPM_PRE_PMU: 430 case SND_SOC_DAPM_PRE_PMU:
430 if (likely(dac33->substream)) { 431 if (likely(dac33->substream)) {
431 dac33_calculate_times(dac33->substream, w->codec); 432 dac33_calculate_times(dac33->substream, codec);
432 dac33_prepare_chip(dac33->substream, w->codec); 433 dac33_prepare_chip(dac33->substream, codec);
433 } 434 }
434 break; 435 break;
435 case SND_SOC_DAPM_POST_PMD: 436 case SND_SOC_DAPM_POST_PMD:
436 dac33_disable_digital(w->codec); 437 dac33_disable_digital(codec);
437 break; 438 break;
438 } 439 }
439 return 0; 440 return 0;
diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c
index 1d1205702d23..9f2dced046de 100644
--- a/sound/soc/codecs/ts3a227e.c
+++ b/sound/soc/codecs/ts3a227e.c
@@ -254,6 +254,7 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
254 struct ts3a227e *ts3a227e; 254 struct ts3a227e *ts3a227e;
255 struct device *dev = &i2c->dev; 255 struct device *dev = &i2c->dev;
256 int ret; 256 int ret;
257 unsigned int acc_reg;
257 258
258 ts3a227e = devm_kzalloc(&i2c->dev, sizeof(*ts3a227e), GFP_KERNEL); 259 ts3a227e = devm_kzalloc(&i2c->dev, sizeof(*ts3a227e), GFP_KERNEL);
259 if (ts3a227e == NULL) 260 if (ts3a227e == NULL)
@@ -283,6 +284,11 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
283 INTB_DISABLE | ADC_COMPLETE_INT_DISABLE, 284 INTB_DISABLE | ADC_COMPLETE_INT_DISABLE,
284 ADC_COMPLETE_INT_DISABLE); 285 ADC_COMPLETE_INT_DISABLE);
285 286
287 /* Read jack status because chip might not trigger interrupt at boot. */
288 regmap_read(ts3a227e->regmap, TS3A227E_REG_ACCESSORY_STATUS, &acc_reg);
289 ts3a227e_new_jack_state(ts3a227e, acc_reg);
290 ts3a227e_jack_report(ts3a227e);
291
286 return 0; 292 return 0;
287} 293}
288 294
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 44af3188afb9..d04693e9cf9f 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -567,12 +567,13 @@ static const struct snd_kcontrol_new twl4030_dapm_dbypassv_control =
567static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \ 567static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \
568 struct snd_kcontrol *kcontrol, int event) \ 568 struct snd_kcontrol *kcontrol, int event) \
569{ \ 569{ \
570 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); \ 570 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); \
571 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); \
571 \ 572 \
572 switch (event) { \ 573 switch (event) { \
573 case SND_SOC_DAPM_POST_PMU: \ 574 case SND_SOC_DAPM_POST_PMU: \
574 twl4030->pin_name##_enabled = 1; \ 575 twl4030->pin_name##_enabled = 1; \
575 twl4030_write(w->codec, reg, twl4030_read(w->codec, reg)); \ 576 twl4030_write(codec, reg, twl4030_read(codec, reg)); \
576 break; \ 577 break; \
577 case SND_SOC_DAPM_POST_PMD: \ 578 case SND_SOC_DAPM_POST_PMD: \
578 twl4030->pin_name##_enabled = 0; \ 579 twl4030->pin_name##_enabled = 0; \
@@ -621,12 +622,14 @@ static void handsfree_ramp(struct snd_soc_codec *codec, int reg, int ramp)
621static int handsfreelpga_event(struct snd_soc_dapm_widget *w, 622static int handsfreelpga_event(struct snd_soc_dapm_widget *w,
622 struct snd_kcontrol *kcontrol, int event) 623 struct snd_kcontrol *kcontrol, int event)
623{ 624{
625 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
626
624 switch (event) { 627 switch (event) {
625 case SND_SOC_DAPM_POST_PMU: 628 case SND_SOC_DAPM_POST_PMU:
626 handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 1); 629 handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 1);
627 break; 630 break;
628 case SND_SOC_DAPM_POST_PMD: 631 case SND_SOC_DAPM_POST_PMD:
629 handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 0); 632 handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 0);
630 break; 633 break;
631 } 634 }
632 return 0; 635 return 0;
@@ -635,12 +638,14 @@ static int handsfreelpga_event(struct snd_soc_dapm_widget *w,
635static int handsfreerpga_event(struct snd_soc_dapm_widget *w, 638static int handsfreerpga_event(struct snd_soc_dapm_widget *w,
636 struct snd_kcontrol *kcontrol, int event) 639 struct snd_kcontrol *kcontrol, int event)
637{ 640{
641 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
642
638 switch (event) { 643 switch (event) {
639 case SND_SOC_DAPM_POST_PMU: 644 case SND_SOC_DAPM_POST_PMU:
640 handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 1); 645 handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 1);
641 break; 646 break;
642 case SND_SOC_DAPM_POST_PMD: 647 case SND_SOC_DAPM_POST_PMD:
643 handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 0); 648 handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 0);
644 break; 649 break;
645 } 650 }
646 return 0; 651 return 0;
@@ -649,19 +654,23 @@ static int handsfreerpga_event(struct snd_soc_dapm_widget *w,
649static int vibramux_event(struct snd_soc_dapm_widget *w, 654static int vibramux_event(struct snd_soc_dapm_widget *w,
650 struct snd_kcontrol *kcontrol, int event) 655 struct snd_kcontrol *kcontrol, int event)
651{ 656{
652 twl4030_write(w->codec, TWL4030_REG_VIBRA_SET, 0xff); 657 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
658
659 twl4030_write(codec, TWL4030_REG_VIBRA_SET, 0xff);
653 return 0; 660 return 0;
654} 661}
655 662
656static int apll_event(struct snd_soc_dapm_widget *w, 663static int apll_event(struct snd_soc_dapm_widget *w,
657 struct snd_kcontrol *kcontrol, int event) 664 struct snd_kcontrol *kcontrol, int event)
658{ 665{
666 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
667
659 switch (event) { 668 switch (event) {
660 case SND_SOC_DAPM_PRE_PMU: 669 case SND_SOC_DAPM_PRE_PMU:
661 twl4030_apll_enable(w->codec, 1); 670 twl4030_apll_enable(codec, 1);
662 break; 671 break;
663 case SND_SOC_DAPM_POST_PMD: 672 case SND_SOC_DAPM_POST_PMD:
664 twl4030_apll_enable(w->codec, 0); 673 twl4030_apll_enable(codec, 0);
665 break; 674 break;
666 } 675 }
667 return 0; 676 return 0;
@@ -670,23 +679,24 @@ static int apll_event(struct snd_soc_dapm_widget *w,
670static int aif_event(struct snd_soc_dapm_widget *w, 679static int aif_event(struct snd_soc_dapm_widget *w,
671 struct snd_kcontrol *kcontrol, int event) 680 struct snd_kcontrol *kcontrol, int event)
672{ 681{
682 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
673 u8 audio_if; 683 u8 audio_if;
674 684
675 audio_if = twl4030_read(w->codec, TWL4030_REG_AUDIO_IF); 685 audio_if = twl4030_read(codec, TWL4030_REG_AUDIO_IF);
676 switch (event) { 686 switch (event) {
677 case SND_SOC_DAPM_PRE_PMU: 687 case SND_SOC_DAPM_PRE_PMU:
678 /* Enable AIF */ 688 /* Enable AIF */
679 /* enable the PLL before we use it to clock the DAI */ 689 /* enable the PLL before we use it to clock the DAI */
680 twl4030_apll_enable(w->codec, 1); 690 twl4030_apll_enable(codec, 1);
681 691
682 twl4030_write(w->codec, TWL4030_REG_AUDIO_IF, 692 twl4030_write(codec, TWL4030_REG_AUDIO_IF,
683 audio_if | TWL4030_AIF_EN); 693 audio_if | TWL4030_AIF_EN);
684 break; 694 break;
685 case SND_SOC_DAPM_POST_PMD: 695 case SND_SOC_DAPM_POST_PMD:
686 /* disable the DAI before we stop it's source PLL */ 696 /* disable the DAI before we stop it's source PLL */
687 twl4030_write(w->codec, TWL4030_REG_AUDIO_IF, 697 twl4030_write(codec, TWL4030_REG_AUDIO_IF,
688 audio_if & ~TWL4030_AIF_EN); 698 audio_if & ~TWL4030_AIF_EN);
689 twl4030_apll_enable(w->codec, 0); 699 twl4030_apll_enable(codec, 0);
690 break; 700 break;
691 } 701 }
692 return 0; 702 return 0;
@@ -758,20 +768,21 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp)
758static int headsetlpga_event(struct snd_soc_dapm_widget *w, 768static int headsetlpga_event(struct snd_soc_dapm_widget *w,
759 struct snd_kcontrol *kcontrol, int event) 769 struct snd_kcontrol *kcontrol, int event)
760{ 770{
761 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 771 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
772 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
762 773
763 switch (event) { 774 switch (event) {
764 case SND_SOC_DAPM_POST_PMU: 775 case SND_SOC_DAPM_POST_PMU:
765 /* Do the ramp-up only once */ 776 /* Do the ramp-up only once */
766 if (!twl4030->hsr_enabled) 777 if (!twl4030->hsr_enabled)
767 headset_ramp(w->codec, 1); 778 headset_ramp(codec, 1);
768 779
769 twl4030->hsl_enabled = 1; 780 twl4030->hsl_enabled = 1;
770 break; 781 break;
771 case SND_SOC_DAPM_POST_PMD: 782 case SND_SOC_DAPM_POST_PMD:
772 /* Do the ramp-down only if both headsetL/R is disabled */ 783 /* Do the ramp-down only if both headsetL/R is disabled */
773 if (!twl4030->hsr_enabled) 784 if (!twl4030->hsr_enabled)
774 headset_ramp(w->codec, 0); 785 headset_ramp(codec, 0);
775 786
776 twl4030->hsl_enabled = 0; 787 twl4030->hsl_enabled = 0;
777 break; 788 break;
@@ -782,20 +793,21 @@ static int headsetlpga_event(struct snd_soc_dapm_widget *w,
782static int headsetrpga_event(struct snd_soc_dapm_widget *w, 793static int headsetrpga_event(struct snd_soc_dapm_widget *w,
783 struct snd_kcontrol *kcontrol, int event) 794 struct snd_kcontrol *kcontrol, int event)
784{ 795{
785 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 796 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
797 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
786 798
787 switch (event) { 799 switch (event) {
788 case SND_SOC_DAPM_POST_PMU: 800 case SND_SOC_DAPM_POST_PMU:
789 /* Do the ramp-up only once */ 801 /* Do the ramp-up only once */
790 if (!twl4030->hsl_enabled) 802 if (!twl4030->hsl_enabled)
791 headset_ramp(w->codec, 1); 803 headset_ramp(codec, 1);
792 804
793 twl4030->hsr_enabled = 1; 805 twl4030->hsr_enabled = 1;
794 break; 806 break;
795 case SND_SOC_DAPM_POST_PMD: 807 case SND_SOC_DAPM_POST_PMD:
796 /* Do the ramp-down only if both headsetL/R is disabled */ 808 /* Do the ramp-down only if both headsetL/R is disabled */
797 if (!twl4030->hsl_enabled) 809 if (!twl4030->hsl_enabled)
798 headset_ramp(w->codec, 0); 810 headset_ramp(codec, 0);
799 811
800 twl4030->hsr_enabled = 0; 812 twl4030->hsr_enabled = 0;
801 break; 813 break;
@@ -806,7 +818,8 @@ static int headsetrpga_event(struct snd_soc_dapm_widget *w,
806static int digimic_event(struct snd_soc_dapm_widget *w, 818static int digimic_event(struct snd_soc_dapm_widget *w,
807 struct snd_kcontrol *kcontrol, int event) 819 struct snd_kcontrol *kcontrol, int event)
808{ 820{
809 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 821 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
822 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
810 struct twl4030_codec_data *pdata = twl4030->pdata; 823 struct twl4030_codec_data *pdata = twl4030->pdata;
811 824
812 if (pdata && pdata->digimic_delay) 825 if (pdata && pdata->digimic_delay)
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index 90f47f988b3f..aeec27b6f1af 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -234,7 +234,7 @@ static int headset_power_mode(struct snd_soc_codec *codec, int high_perf)
234static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w, 234static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w,
235 struct snd_kcontrol *kcontrol, int event) 235 struct snd_kcontrol *kcontrol, int event)
236{ 236{
237 struct snd_soc_codec *codec = w->codec; 237 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
238 u8 hslctl, hsrctl; 238 u8 hslctl, hsrctl;
239 239
240 /* 240 /*
@@ -261,7 +261,7 @@ static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w,
261static int twl6040_ep_drv_event(struct snd_soc_dapm_widget *w, 261static int twl6040_ep_drv_event(struct snd_soc_dapm_widget *w,
262 struct snd_kcontrol *kcontrol, int event) 262 struct snd_kcontrol *kcontrol, int event)
263{ 263{
264 struct snd_soc_codec *codec = w->codec; 264 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
265 struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); 265 struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
266 int ret = 0; 266 int ret = 0;
267 267
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index 34ef65c52a7d..8d9de49a5052 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -683,7 +683,7 @@ static const struct snd_kcontrol_new wm2000_controls[] = {
683static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w, 683static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w,
684 struct snd_kcontrol *kcontrol, int event) 684 struct snd_kcontrol *kcontrol, int event)
685{ 685{
686 struct snd_soc_codec *codec = w->codec; 686 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
687 struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); 687 struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev);
688 int ret; 688 int ret;
689 689
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c
index b80970dc2d2f..ea09db585aa1 100644
--- a/sound/soc/codecs/wm5100.c
+++ b/sound/soc/codecs/wm5100.c
@@ -775,7 +775,8 @@ static int wm5100_out_ev(struct snd_soc_dapm_widget *w,
775 struct snd_kcontrol *kcontrol, 775 struct snd_kcontrol *kcontrol,
776 int event) 776 int event)
777{ 777{
778 struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(w->codec); 778 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
779 struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec);
779 780
780 switch (w->reg) { 781 switch (w->reg) {
781 case WM5100_CHANNEL_ENABLES_1: 782 case WM5100_CHANNEL_ENABLES_1:
@@ -839,7 +840,7 @@ static int wm5100_post_ev(struct snd_soc_dapm_widget *w,
839 struct snd_kcontrol *kcontrol, 840 struct snd_kcontrol *kcontrol,
840 int event) 841 int event)
841{ 842{
842 struct snd_soc_codec *codec = w->codec; 843 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
843 struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); 844 struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec);
844 int ret; 845 int ret;
845 846
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index f439ae052128..6d0fe0ac95a3 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/mfd/arizona/core.h> 29#include <linux/mfd/arizona/core.h>
30#include <linux/mfd/arizona/registers.h> 30#include <linux/mfd/arizona/registers.h>
31#include <asm/unaligned.h>
31 32
32#include "arizona.h" 33#include "arizona.h"
33#include "wm5102.h" 34#include "wm5102.h"
@@ -580,7 +581,7 @@ static const struct reg_default wm5102_sysclk_revb_patch[] = {
580static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w, 581static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w,
581 struct snd_kcontrol *kcontrol, int event) 582 struct snd_kcontrol *kcontrol, int event)
582{ 583{
583 struct snd_soc_codec *codec = w->codec; 584 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
584 struct arizona *arizona = dev_get_drvdata(codec->dev->parent); 585 struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
585 struct regmap *regmap = arizona->regmap; 586 struct regmap *regmap = arizona->regmap;
586 const struct reg_default *patch = NULL; 587 const struct reg_default *patch = NULL;
@@ -617,11 +618,10 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
617{ 618{
618 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 619 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
619 struct arizona *arizona = dev_get_drvdata(codec->dev->parent); 620 struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
620 uint16_t data;
621 621
622 mutex_lock(&arizona->dac_comp_lock); 622 mutex_lock(&arizona->dac_comp_lock);
623 data = cpu_to_be16(arizona->dac_comp_coeff); 623 put_unaligned_be16(arizona->dac_comp_coeff,
624 memcpy(ucontrol->value.bytes.data, &data, sizeof(data)); 624 ucontrol->value.bytes.data);
625 mutex_unlock(&arizona->dac_comp_lock); 625 mutex_unlock(&arizona->dac_comp_lock);
626 626
627 return 0; 627 return 0;
@@ -1272,19 +1272,24 @@ SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
1272 1272
1273SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, 1273SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
1274 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, 1274 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
1275 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 1275 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
1276 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
1276SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, 1277SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
1277 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, 1278 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
1278 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 1279 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
1280 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
1279SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, 1281SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1,
1280 ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 1282 ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
1281 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 1283 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
1284 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
1282SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1, 1285SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1,
1283 ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 1286 ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
1284 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 1287 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
1288 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
1285SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, 1289SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1,
1286 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 1290 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
1287 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 1291 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
1292 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
1288SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, 1293SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1,
1289 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 1294 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
1290 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 1295 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index 4456b38a3ef5..fbaeddb3e903 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -134,7 +134,7 @@ static const struct reg_default wm5110_sysclk_revd_patch[] = {
134static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w, 134static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w,
135 struct snd_kcontrol *kcontrol, int event) 135 struct snd_kcontrol *kcontrol, int event)
136{ 136{
137 struct snd_soc_codec *codec = w->codec; 137 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
138 struct arizona *arizona = dev_get_drvdata(codec->dev->parent); 138 struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
139 struct regmap *regmap = arizona->regmap; 139 struct regmap *regmap = arizona->regmap;
140 const struct reg_default *patch = NULL; 140 const struct reg_default *patch = NULL;
@@ -905,22 +905,28 @@ SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
905 905
906SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, 906SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
907 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, 907 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
908 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 908 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
909 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
909SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, 910SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
910 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, 911 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
911 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 912 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
913 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
912SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, 914SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1,
913 ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 915 ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
914 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 916 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
917 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
915SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1, 918SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1,
916 ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 919 ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
917 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 920 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
921 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
918SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, 922SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1,
919 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 923 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
920 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 924 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
925 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
921SND_SOC_DAPM_PGA_E("OUT3R", ARIZONA_OUTPUT_ENABLES_1, 926SND_SOC_DAPM_PGA_E("OUT3R", ARIZONA_OUTPUT_ENABLES_1,
922 ARIZONA_OUT3R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 927 ARIZONA_OUT3R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
923 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 928 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
929 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
924SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, 930SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1,
925 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 931 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
926 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 932 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
index 574579b98872..c81a9eab3e3e 100644
--- a/sound/soc/codecs/wm8350.c
+++ b/sound/soc/codecs/wm8350.c
@@ -259,7 +259,7 @@ static void wm8350_pga_work(struct work_struct *work)
259static int pga_event(struct snd_soc_dapm_widget *w, 259static int pga_event(struct snd_soc_dapm_widget *w,
260 struct snd_kcontrol *kcontrol, int event) 260 struct snd_kcontrol *kcontrol, int event)
261{ 261{
262 struct snd_soc_codec *codec = w->codec; 262 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
263 struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec); 263 struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec);
264 struct wm8350_output *out; 264 struct wm8350_output *out;
265 265
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c
index 8ee446987aa9..b0d84e552fca 100644
--- a/sound/soc/codecs/wm8400.c
+++ b/sound/soc/codecs/wm8400.c
@@ -324,6 +324,7 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME,
324static int outmixer_event (struct snd_soc_dapm_widget *w, 324static int outmixer_event (struct snd_soc_dapm_widget *w,
325 struct snd_kcontrol * kcontrol, int event) 325 struct snd_kcontrol * kcontrol, int event)
326{ 326{
327 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
327 struct soc_mixer_control *mc = 328 struct soc_mixer_control *mc =
328 (struct soc_mixer_control *)kcontrol->private_value; 329 (struct soc_mixer_control *)kcontrol->private_value;
329 u32 reg_shift = mc->shift; 330 u32 reg_shift = mc->shift;
@@ -332,7 +333,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w,
332 333
333 switch (reg_shift) { 334 switch (reg_shift) {
334 case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) : 335 case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) :
335 reg = snd_soc_read(w->codec, WM8400_OUTPUT_MIXER1); 336 reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER1);
336 if (reg & WM8400_LDLO) { 337 if (reg & WM8400_LDLO) {
337 printk(KERN_WARNING 338 printk(KERN_WARNING
338 "Cannot set as Output Mixer 1 LDLO Set\n"); 339 "Cannot set as Output Mixer 1 LDLO Set\n");
@@ -340,7 +341,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w,
340 } 341 }
341 break; 342 break;
342 case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8): 343 case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8):
343 reg = snd_soc_read(w->codec, WM8400_OUTPUT_MIXER2); 344 reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER2);
344 if (reg & WM8400_RDRO) { 345 if (reg & WM8400_RDRO) {
345 printk(KERN_WARNING 346 printk(KERN_WARNING
346 "Cannot set as Output Mixer 2 RDRO Set\n"); 347 "Cannot set as Output Mixer 2 RDRO Set\n");
@@ -348,7 +349,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w,
348 } 349 }
349 break; 350 break;
350 case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8): 351 case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8):
351 reg = snd_soc_read(w->codec, WM8400_SPEAKER_MIXER); 352 reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER);
352 if (reg & WM8400_LDSPK) { 353 if (reg & WM8400_LDSPK) {
353 printk(KERN_WARNING 354 printk(KERN_WARNING
354 "Cannot set as Speaker Mixer LDSPK Set\n"); 355 "Cannot set as Speaker Mixer LDSPK Set\n");
@@ -356,7 +357,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w,
356 } 357 }
357 break; 358 break;
358 case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8): 359 case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8):
359 reg = snd_soc_read(w->codec, WM8400_SPEAKER_MIXER); 360 reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER);
360 if (reg & WM8400_RDSPK) { 361 if (reg & WM8400_RDSPK) {
361 printk(KERN_WARNING 362 printk(KERN_WARNING
362 "Cannot set as Speaker Mixer RDSPK Set\n"); 363 "Cannot set as Speaker Mixer RDSPK Set\n");
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index b9211b42f6e9..098c143f44d6 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -217,7 +217,8 @@ SND_SOC_DAPM_INPUT("LLINEIN"),
217static int wm8731_check_osc(struct snd_soc_dapm_widget *source, 217static int wm8731_check_osc(struct snd_soc_dapm_widget *source,
218 struct snd_soc_dapm_widget *sink) 218 struct snd_soc_dapm_widget *sink)
219{ 219{
220 struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(source->codec); 220 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
221 struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
221 222
222 return wm8731->sysclk_type == WM8731_SYSCLK_XTAL; 223 return wm8731->sysclk_type == WM8731_SYSCLK_XTAL;
223} 224}
@@ -717,6 +718,8 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
717 if (wm8731 == NULL) 718 if (wm8731 == NULL)
718 return -ENOMEM; 719 return -ENOMEM;
719 720
721 mutex_init(&wm8731->lock);
722
720 wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap); 723 wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap);
721 if (IS_ERR(wm8731->regmap)) { 724 if (IS_ERR(wm8731->regmap)) {
722 ret = PTR_ERR(wm8731->regmap); 725 ret = PTR_ERR(wm8731->regmap);
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index f6847fdd6ddd..eb0a1644ba11 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -323,7 +323,7 @@ static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
323 SND_SOC_DAPM_OUTPUT("ROUT2"), 323 SND_SOC_DAPM_OUTPUT("ROUT2"),
324 SND_SOC_DAPM_OUTPUT("MONO1"), 324 SND_SOC_DAPM_OUTPUT("MONO1"),
325 SND_SOC_DAPM_OUTPUT("OUT3"), 325 SND_SOC_DAPM_OUTPUT("OUT3"),
326 SND_SOC_DAPM_OUTPUT("VREF"), 326 SND_SOC_DAPM_VMID("VREF"),
327 327
328 SND_SOC_DAPM_INPUT("LINPUT1"), 328 SND_SOC_DAPM_INPUT("LINPUT1"),
329 SND_SOC_DAPM_INPUT("LINPUT2"), 329 SND_SOC_DAPM_INPUT("LINPUT2"),
diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c
index 180e7a098726..53e977da2f86 100644
--- a/sound/soc/codecs/wm8770.c
+++ b/sound/soc/codecs/wm8770.c
@@ -308,9 +308,7 @@ static const struct snd_soc_dapm_route wm8770_intercon[] = {
308static int vout12supply_event(struct snd_soc_dapm_widget *w, 308static int vout12supply_event(struct snd_soc_dapm_widget *w,
309 struct snd_kcontrol *kcontrol, int event) 309 struct snd_kcontrol *kcontrol, int event)
310{ 310{
311 struct snd_soc_codec *codec; 311 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
312
313 codec = w->codec;
314 312
315 switch (event) { 313 switch (event) {
316 case SND_SOC_DAPM_PRE_PMU: 314 case SND_SOC_DAPM_PRE_PMU:
@@ -327,9 +325,7 @@ static int vout12supply_event(struct snd_soc_dapm_widget *w,
327static int vout34supply_event(struct snd_soc_dapm_widget *w, 325static int vout34supply_event(struct snd_soc_dapm_widget *w,
328 struct snd_kcontrol *kcontrol, int event) 326 struct snd_kcontrol *kcontrol, int event)
329{ 327{
330 struct snd_soc_codec *codec; 328 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
331
332 codec = w->codec;
333 329
334 switch (event) { 330 switch (event) {
335 case SND_SOC_DAPM_PRE_PMU: 331 case SND_SOC_DAPM_PRE_PMU:
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c
index 3a0d4b7d692f..2eb986c19b88 100644
--- a/sound/soc/codecs/wm8900.c
+++ b/sound/soc/codecs/wm8900.c
@@ -224,7 +224,7 @@ static void wm8900_reset(struct snd_soc_codec *codec)
224static int wm8900_hp_event(struct snd_soc_dapm_widget *w, 224static int wm8900_hp_event(struct snd_soc_dapm_widget *w,
225 struct snd_kcontrol *kcontrol, int event) 225 struct snd_kcontrol *kcontrol, int event)
226{ 226{
227 struct snd_soc_codec *codec = w->codec; 227 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
228 u16 hpctl1 = snd_soc_read(codec, WM8900_REG_HPCTL1); 228 u16 hpctl1 = snd_soc_read(codec, WM8900_REG_HPCTL1);
229 229
230 switch (event) { 230 switch (event) {
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index cc6b0ef98a34..dde462c082be 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -260,7 +260,7 @@ static int wm8903_cp_event(struct snd_soc_dapm_widget *w,
260static int wm8903_dcs_event(struct snd_soc_dapm_widget *w, 260static int wm8903_dcs_event(struct snd_soc_dapm_widget *w,
261 struct snd_kcontrol *kcontrol, int event) 261 struct snd_kcontrol *kcontrol, int event)
262{ 262{
263 struct snd_soc_codec *codec = w->codec; 263 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
264 struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); 264 struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec);
265 265
266 switch (event) { 266 switch (event) {
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 4d2d2b1380d5..c5eaa0198ef0 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -673,7 +673,7 @@ static int cp_event(struct snd_soc_dapm_widget *w,
673static int sysclk_event(struct snd_soc_dapm_widget *w, 673static int sysclk_event(struct snd_soc_dapm_widget *w,
674 struct snd_kcontrol *kcontrol, int event) 674 struct snd_kcontrol *kcontrol, int event)
675{ 675{
676 struct snd_soc_codec *codec = w->codec; 676 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
677 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); 677 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
678 678
679 switch (event) { 679 switch (event) {
@@ -711,7 +711,7 @@ static int sysclk_event(struct snd_soc_dapm_widget *w,
711static int out_pga_event(struct snd_soc_dapm_widget *w, 711static int out_pga_event(struct snd_soc_dapm_widget *w,
712 struct snd_kcontrol *kcontrol, int event) 712 struct snd_kcontrol *kcontrol, int event)
713{ 713{
714 struct snd_soc_codec *codec = w->codec; 714 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
715 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); 715 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
716 int reg, val; 716 int reg, val;
717 int dcs_mask; 717 int dcs_mask;
@@ -1076,10 +1076,13 @@ static const struct snd_soc_dapm_route adc_intercon[] = {
1076 { "Right Capture PGA", NULL, "Right Capture Mux" }, 1076 { "Right Capture PGA", NULL, "Right Capture Mux" },
1077 { "Right Capture PGA", NULL, "Right Capture Inverting Mux" }, 1077 { "Right Capture PGA", NULL, "Right Capture Inverting Mux" },
1078 1078
1079 { "AIFOUTL", "Left", "ADCL" }, 1079 { "AIFOUTL Mux", "Left", "ADCL" },
1080 { "AIFOUTL", "Right", "ADCR" }, 1080 { "AIFOUTL Mux", "Right", "ADCR" },
1081 { "AIFOUTR", "Left", "ADCL" }, 1081 { "AIFOUTR Mux", "Left", "ADCL" },
1082 { "AIFOUTR", "Right", "ADCR" }, 1082 { "AIFOUTR Mux", "Right", "ADCR" },
1083
1084 { "AIFOUTL", NULL, "AIFOUTL Mux" },
1085 { "AIFOUTR", NULL, "AIFOUTR Mux" },
1083 1086
1084 { "ADCL", NULL, "CLK_DSP" }, 1087 { "ADCL", NULL, "CLK_DSP" },
1085 { "ADCL", NULL, "Left Capture PGA" }, 1088 { "ADCL", NULL, "Left Capture PGA" },
@@ -1089,12 +1092,16 @@ static const struct snd_soc_dapm_route adc_intercon[] = {
1089}; 1092};
1090 1093
1091static const struct snd_soc_dapm_route dac_intercon[] = { 1094static const struct snd_soc_dapm_route dac_intercon[] = {
1092 { "DACL", "Right", "AIFINR" }, 1095 { "DACL Mux", "Left", "AIFINL" },
1093 { "DACL", "Left", "AIFINL" }, 1096 { "DACL Mux", "Right", "AIFINR" },
1097
1098 { "DACR Mux", "Left", "AIFINL" },
1099 { "DACR Mux", "Right", "AIFINR" },
1100
1101 { "DACL", NULL, "DACL Mux" },
1094 { "DACL", NULL, "CLK_DSP" }, 1102 { "DACL", NULL, "CLK_DSP" },
1095 1103
1096 { "DACR", "Right", "AIFINR" }, 1104 { "DACR", NULL, "DACR Mux" },
1097 { "DACR", "Left", "AIFINL" },
1098 { "DACR", NULL, "CLK_DSP" }, 1105 { "DACR", NULL, "CLK_DSP" },
1099 1106
1100 { "Charge pump", NULL, "SYSCLK" }, 1107 { "Charge pump", NULL, "SYSCLK" },
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c
index 1173f7fef5a7..1ab2d462afad 100644
--- a/sound/soc/codecs/wm8955.c
+++ b/sound/soc/codecs/wm8955.c
@@ -333,7 +333,7 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec)
333static int wm8955_sysclk(struct snd_soc_dapm_widget *w, 333static int wm8955_sysclk(struct snd_soc_dapm_widget *w,
334 struct snd_kcontrol *kcontrol, int event) 334 struct snd_kcontrol *kcontrol, int event)
335{ 335{
336 struct snd_soc_codec *codec = w->codec; 336 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
337 int ret = 0; 337 int ret = 0;
338 338
339 /* Always disable the clocks - if we're doing reconfiguration this 339 /* Always disable the clocks - if we're doing reconfiguration this
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
index 3cbc82b33292..c799cca5abeb 100644
--- a/sound/soc/codecs/wm8958-dsp2.c
+++ b/sound/soc/codecs/wm8958-dsp2.c
@@ -418,7 +418,7 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start)
418int wm8958_aif_ev(struct snd_soc_dapm_widget *w, 418int wm8958_aif_ev(struct snd_soc_dapm_widget *w,
419 struct snd_kcontrol *kcontrol, int event) 419 struct snd_kcontrol *kcontrol, int event)
420{ 420{
421 struct snd_soc_codec *codec = w->codec; 421 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
422 int i; 422 int i;
423 423
424 switch (event) { 424 switch (event) {
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index 031a1ae71d94..a96eb497a379 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -556,7 +556,7 @@ static struct {
556 { 22050, 2 }, 556 { 22050, 2 },
557 { 24000, 2 }, 557 { 24000, 2 },
558 { 16000, 3 }, 558 { 16000, 3 },
559 { 11250, 4 }, 559 { 11025, 4 },
560 { 12000, 4 }, 560 { 12000, 4 },
561 { 8000, 5 }, 561 { 8000, 5 },
562}; 562};
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c
index eeffd05384b4..95e2c1bfc809 100644
--- a/sound/soc/codecs/wm8961.c
+++ b/sound/soc/codecs/wm8961.c
@@ -194,7 +194,7 @@ static bool wm8961_readable(struct device *dev, unsigned int reg)
194static int wm8961_hp_event(struct snd_soc_dapm_widget *w, 194static int wm8961_hp_event(struct snd_soc_dapm_widget *w,
195 struct snd_kcontrol *kcontrol, int event) 195 struct snd_kcontrol *kcontrol, int event)
196{ 196{
197 struct snd_soc_codec *codec = w->codec; 197 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
198 u16 hp_reg = snd_soc_read(codec, WM8961_ANALOGUE_HP_0); 198 u16 hp_reg = snd_soc_read(codec, WM8961_ANALOGUE_HP_0);
199 u16 cp_reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_1); 199 u16 cp_reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_1);
200 u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); 200 u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2);
@@ -286,7 +286,7 @@ static int wm8961_hp_event(struct snd_soc_dapm_widget *w,
286static int wm8961_spk_event(struct snd_soc_dapm_widget *w, 286static int wm8961_spk_event(struct snd_soc_dapm_widget *w,
287 struct snd_kcontrol *kcontrol, int event) 287 struct snd_kcontrol *kcontrol, int event)
288{ 288{
289 struct snd_soc_codec *codec = w->codec; 289 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
290 u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); 290 u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2);
291 u16 spk_reg = snd_soc_read(codec, WM8961_CLASS_D_CONTROL_1); 291 u16 spk_reg = snd_soc_read(codec, WM8961_CLASS_D_CONTROL_1);
292 292
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index d32d554f5b34..118b0034ba23 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -1866,7 +1866,7 @@ static int cp_event(struct snd_soc_dapm_widget *w,
1866static int hp_event(struct snd_soc_dapm_widget *w, 1866static int hp_event(struct snd_soc_dapm_widget *w,
1867 struct snd_kcontrol *kcontrol, int event) 1867 struct snd_kcontrol *kcontrol, int event)
1868{ 1868{
1869 struct snd_soc_codec *codec = w->codec; 1869 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1870 int timeout; 1870 int timeout;
1871 int reg; 1871 int reg;
1872 int expected = (WM8962_DCS_STARTUP_DONE_HP1L | 1872 int expected = (WM8962_DCS_STARTUP_DONE_HP1L |
@@ -1960,7 +1960,7 @@ static int hp_event(struct snd_soc_dapm_widget *w,
1960static int out_pga_event(struct snd_soc_dapm_widget *w, 1960static int out_pga_event(struct snd_soc_dapm_widget *w,
1961 struct snd_kcontrol *kcontrol, int event) 1961 struct snd_kcontrol *kcontrol, int event)
1962{ 1962{
1963 struct snd_soc_codec *codec = w->codec; 1963 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1964 int reg; 1964 int reg;
1965 1965
1966 switch (w->shift) { 1966 switch (w->shift) {
@@ -1993,7 +1993,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w,
1993static int dsp2_event(struct snd_soc_dapm_widget *w, 1993static int dsp2_event(struct snd_soc_dapm_widget *w,
1994 struct snd_kcontrol *kcontrol, int event) 1994 struct snd_kcontrol *kcontrol, int event)
1995{ 1995{
1996 struct snd_soc_codec *codec = w->codec; 1996 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1997 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); 1997 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
1998 1998
1999 switch (event) { 1999 switch (event) {
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c
index e418199155a8..baff2cc222a6 100644
--- a/sound/soc/codecs/wm8988.c
+++ b/sound/soc/codecs/wm8988.c
@@ -244,7 +244,7 @@ SOC_DOUBLE_R_TLV("Output 2 Playback Volume", WM8988_LOUT2V, WM8988_ROUT2V,
244static int wm8988_lrc_control(struct snd_soc_dapm_widget *w, 244static int wm8988_lrc_control(struct snd_soc_dapm_widget *w,
245 struct snd_kcontrol *kcontrol, int event) 245 struct snd_kcontrol *kcontrol, int event)
246{ 246{
247 struct snd_soc_codec *codec = w->codec; 247 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
248 u16 adctl2 = snd_soc_read(codec, WM8988_ADCTL2); 248 u16 adctl2 = snd_soc_read(codec, WM8988_ADCTL2);
249 249
250 /* Use the DAC to gate LRC if active, otherwise use ADC */ 250 /* Use the DAC to gate LRC if active, otherwise use ADC */
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c
index 8a584229310a..c93bffcb3cfb 100644
--- a/sound/soc/codecs/wm8990.c
+++ b/sound/soc/codecs/wm8990.c
@@ -374,13 +374,14 @@ SOC_SINGLE("RIN34 Mute Switch", WM8990_RIGHT_LINE_INPUT_3_4_VOLUME,
374static int outmixer_event(struct snd_soc_dapm_widget *w, 374static int outmixer_event(struct snd_soc_dapm_widget *w,
375 struct snd_kcontrol *kcontrol, int event) 375 struct snd_kcontrol *kcontrol, int event)
376{ 376{
377 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
377 u32 reg_shift = kcontrol->private_value & 0xfff; 378 u32 reg_shift = kcontrol->private_value & 0xfff;
378 int ret = 0; 379 int ret = 0;
379 u16 reg; 380 u16 reg;
380 381
381 switch (reg_shift) { 382 switch (reg_shift) {
382 case WM8990_SPEAKER_MIXER | (WM8990_LDSPK_BIT << 8) : 383 case WM8990_SPEAKER_MIXER | (WM8990_LDSPK_BIT << 8) :
383 reg = snd_soc_read(w->codec, WM8990_OUTPUT_MIXER1); 384 reg = snd_soc_read(codec, WM8990_OUTPUT_MIXER1);
384 if (reg & WM8990_LDLO) { 385 if (reg & WM8990_LDLO) {
385 printk(KERN_WARNING 386 printk(KERN_WARNING
386 "Cannot set as Output Mixer 1 LDLO Set\n"); 387 "Cannot set as Output Mixer 1 LDLO Set\n");
@@ -388,7 +389,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
388 } 389 }
389 break; 390 break;
390 case WM8990_SPEAKER_MIXER | (WM8990_RDSPK_BIT << 8): 391 case WM8990_SPEAKER_MIXER | (WM8990_RDSPK_BIT << 8):
391 reg = snd_soc_read(w->codec, WM8990_OUTPUT_MIXER2); 392 reg = snd_soc_read(codec, WM8990_OUTPUT_MIXER2);
392 if (reg & WM8990_RDRO) { 393 if (reg & WM8990_RDRO) {
393 printk(KERN_WARNING 394 printk(KERN_WARNING
394 "Cannot set as Output Mixer 2 RDRO Set\n"); 395 "Cannot set as Output Mixer 2 RDRO Set\n");
@@ -396,7 +397,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
396 } 397 }
397 break; 398 break;
398 case WM8990_OUTPUT_MIXER1 | (WM8990_LDLO_BIT << 8): 399 case WM8990_OUTPUT_MIXER1 | (WM8990_LDLO_BIT << 8):
399 reg = snd_soc_read(w->codec, WM8990_SPEAKER_MIXER); 400 reg = snd_soc_read(codec, WM8990_SPEAKER_MIXER);
400 if (reg & WM8990_LDSPK) { 401 if (reg & WM8990_LDSPK) {
401 printk(KERN_WARNING 402 printk(KERN_WARNING
402 "Cannot set as Speaker Mixer LDSPK Set\n"); 403 "Cannot set as Speaker Mixer LDSPK Set\n");
@@ -404,7 +405,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
404 } 405 }
405 break; 406 break;
406 case WM8990_OUTPUT_MIXER2 | (WM8990_RDRO_BIT << 8): 407 case WM8990_OUTPUT_MIXER2 | (WM8990_RDRO_BIT << 8):
407 reg = snd_soc_read(w->codec, WM8990_SPEAKER_MIXER); 408 reg = snd_soc_read(codec, WM8990_SPEAKER_MIXER);
408 if (reg & WM8990_RDSPK) { 409 if (reg & WM8990_RDSPK) {
409 printk(KERN_WARNING 410 printk(KERN_WARNING
410 "Cannot set as Speaker Mixer RDSPK Set\n"); 411 "Cannot set as Speaker Mixer RDSPK Set\n");
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index b0ac2c3e31b9..49df0dc607e6 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -382,13 +382,14 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {
382static int outmixer_event(struct snd_soc_dapm_widget *w, 382static int outmixer_event(struct snd_soc_dapm_widget *w,
383 struct snd_kcontrol *kcontrol, int event) 383 struct snd_kcontrol *kcontrol, int event)
384{ 384{
385 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
385 u32 reg_shift = kcontrol->private_value & 0xfff; 386 u32 reg_shift = kcontrol->private_value & 0xfff;
386 int ret = 0; 387 int ret = 0;
387 u16 reg; 388 u16 reg;
388 389
389 switch (reg_shift) { 390 switch (reg_shift) {
390 case WM8991_SPEAKER_MIXER | (WM8991_LDSPK_BIT << 8): 391 case WM8991_SPEAKER_MIXER | (WM8991_LDSPK_BIT << 8):
391 reg = snd_soc_read(w->codec, WM8991_OUTPUT_MIXER1); 392 reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER1);
392 if (reg & WM8991_LDLO) { 393 if (reg & WM8991_LDLO) {
393 printk(KERN_WARNING 394 printk(KERN_WARNING
394 "Cannot set as Output Mixer 1 LDLO Set\n"); 395 "Cannot set as Output Mixer 1 LDLO Set\n");
@@ -397,7 +398,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
397 break; 398 break;
398 399
399 case WM8991_SPEAKER_MIXER | (WM8991_RDSPK_BIT << 8): 400 case WM8991_SPEAKER_MIXER | (WM8991_RDSPK_BIT << 8):
400 reg = snd_soc_read(w->codec, WM8991_OUTPUT_MIXER2); 401 reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER2);
401 if (reg & WM8991_RDRO) { 402 if (reg & WM8991_RDRO) {
402 printk(KERN_WARNING 403 printk(KERN_WARNING
403 "Cannot set as Output Mixer 2 RDRO Set\n"); 404 "Cannot set as Output Mixer 2 RDRO Set\n");
@@ -406,7 +407,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
406 break; 407 break;
407 408
408 case WM8991_OUTPUT_MIXER1 | (WM8991_LDLO_BIT << 8): 409 case WM8991_OUTPUT_MIXER1 | (WM8991_LDLO_BIT << 8):
409 reg = snd_soc_read(w->codec, WM8991_SPEAKER_MIXER); 410 reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER);
410 if (reg & WM8991_LDSPK) { 411 if (reg & WM8991_LDSPK) {
411 printk(KERN_WARNING 412 printk(KERN_WARNING
412 "Cannot set as Speaker Mixer LDSPK Set\n"); 413 "Cannot set as Speaker Mixer LDSPK Set\n");
@@ -415,7 +416,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
415 break; 416 break;
416 417
417 case WM8991_OUTPUT_MIXER2 | (WM8991_RDRO_BIT << 8): 418 case WM8991_OUTPUT_MIXER2 | (WM8991_RDRO_BIT << 8):
418 reg = snd_soc_read(w->codec, WM8991_SPEAKER_MIXER); 419 reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER);
419 if (reg & WM8991_RDSPK) { 420 if (reg & WM8991_RDSPK) {
420 printk(KERN_WARNING 421 printk(KERN_WARNING
421 "Cannot set as Speaker Mixer RDSPK Set\n"); 422 "Cannot set as Speaker Mixer RDSPK Set\n");
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c
index 53c6fe359496..2e70a270eb28 100644
--- a/sound/soc/codecs/wm8993.c
+++ b/sound/soc/codecs/wm8993.c
@@ -810,7 +810,7 @@ SOC_SINGLE_TLV("EQ5 Volume", WM8993_EQ6, 0, 24, 0, eq_tlv),
810static int clk_sys_event(struct snd_soc_dapm_widget *w, 810static int clk_sys_event(struct snd_soc_dapm_widget *w,
811 struct snd_kcontrol *kcontrol, int event) 811 struct snd_kcontrol *kcontrol, int event)
812{ 812{
813 struct snd_soc_codec *codec = w->codec; 813 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
814 814
815 switch (event) { 815 switch (event) {
816 case SND_SOC_DAPM_PRE_PMU: 816 case SND_SOC_DAPM_PRE_PMU:
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 1b97de2e4e67..4fbc7689339a 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -249,7 +249,8 @@ static int configure_clock(struct snd_soc_codec *codec)
249static int check_clk_sys(struct snd_soc_dapm_widget *source, 249static int check_clk_sys(struct snd_soc_dapm_widget *source,
250 struct snd_soc_dapm_widget *sink) 250 struct snd_soc_dapm_widget *sink)
251{ 251{
252 int reg = snd_soc_read(source->codec, WM8994_CLOCKING_1); 252 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
253 int reg = snd_soc_read(codec, WM8994_CLOCKING_1);
253 const char *clk; 254 const char *clk;
254 255
255 /* Check what we're currently using for CLK_SYS */ 256 /* Check what we're currently using for CLK_SYS */
@@ -806,7 +807,7 @@ static void active_dereference(struct snd_soc_codec *codec)
806static int clk_sys_event(struct snd_soc_dapm_widget *w, 807static int clk_sys_event(struct snd_soc_dapm_widget *w,
807 struct snd_kcontrol *kcontrol, int event) 808 struct snd_kcontrol *kcontrol, int event)
808{ 809{
809 struct snd_soc_codec *codec = w->codec; 810 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
810 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 811 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
811 812
812 switch (event) { 813 switch (event) {
@@ -981,7 +982,7 @@ static void vmid_dereference(struct snd_soc_codec *codec)
981static int vmid_event(struct snd_soc_dapm_widget *w, 982static int vmid_event(struct snd_soc_dapm_widget *w,
982 struct snd_kcontrol *kcontrol, int event) 983 struct snd_kcontrol *kcontrol, int event)
983{ 984{
984 struct snd_soc_codec *codec = w->codec; 985 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
985 986
986 switch (event) { 987 switch (event) {
987 case SND_SOC_DAPM_PRE_PMU: 988 case SND_SOC_DAPM_PRE_PMU:
@@ -1037,7 +1038,7 @@ static bool wm8994_check_class_w_digital(struct snd_soc_codec *codec)
1037static int aif1clk_ev(struct snd_soc_dapm_widget *w, 1038static int aif1clk_ev(struct snd_soc_dapm_widget *w,
1038 struct snd_kcontrol *kcontrol, int event) 1039 struct snd_kcontrol *kcontrol, int event)
1039{ 1040{
1040 struct snd_soc_codec *codec = w->codec; 1041 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1041 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 1042 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1042 struct wm8994 *control = wm8994->wm8994; 1043 struct wm8994 *control = wm8994->wm8994;
1043 int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA; 1044 int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA;
@@ -1135,7 +1136,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
1135static int aif2clk_ev(struct snd_soc_dapm_widget *w, 1136static int aif2clk_ev(struct snd_soc_dapm_widget *w,
1136 struct snd_kcontrol *kcontrol, int event) 1137 struct snd_kcontrol *kcontrol, int event)
1137{ 1138{
1138 struct snd_soc_codec *codec = w->codec; 1139 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1139 int i; 1140 int i;
1140 int dac; 1141 int dac;
1141 int adc; 1142 int adc;
@@ -1220,7 +1221,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
1220static int aif1clk_late_ev(struct snd_soc_dapm_widget *w, 1221static int aif1clk_late_ev(struct snd_soc_dapm_widget *w,
1221 struct snd_kcontrol *kcontrol, int event) 1222 struct snd_kcontrol *kcontrol, int event)
1222{ 1223{
1223 struct snd_soc_codec *codec = w->codec; 1224 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1224 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 1225 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1225 1226
1226 switch (event) { 1227 switch (event) {
@@ -1238,7 +1239,7 @@ static int aif1clk_late_ev(struct snd_soc_dapm_widget *w,
1238static int aif2clk_late_ev(struct snd_soc_dapm_widget *w, 1239static int aif2clk_late_ev(struct snd_soc_dapm_widget *w,
1239 struct snd_kcontrol *kcontrol, int event) 1240 struct snd_kcontrol *kcontrol, int event)
1240{ 1241{
1241 struct snd_soc_codec *codec = w->codec; 1242 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1242 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 1243 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1243 1244
1244 switch (event) { 1245 switch (event) {
@@ -1256,7 +1257,7 @@ static int aif2clk_late_ev(struct snd_soc_dapm_widget *w,
1256static int late_enable_ev(struct snd_soc_dapm_widget *w, 1257static int late_enable_ev(struct snd_soc_dapm_widget *w,
1257 struct snd_kcontrol *kcontrol, int event) 1258 struct snd_kcontrol *kcontrol, int event)
1258{ 1259{
1259 struct snd_soc_codec *codec = w->codec; 1260 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1260 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 1261 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1261 1262
1262 switch (event) { 1263 switch (event) {
@@ -1289,7 +1290,7 @@ static int late_enable_ev(struct snd_soc_dapm_widget *w,
1289static int late_disable_ev(struct snd_soc_dapm_widget *w, 1290static int late_disable_ev(struct snd_soc_dapm_widget *w,
1290 struct snd_kcontrol *kcontrol, int event) 1291 struct snd_kcontrol *kcontrol, int event)
1291{ 1292{
1292 struct snd_soc_codec *codec = w->codec; 1293 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1293 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 1294 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1294 1295
1295 switch (event) { 1296 switch (event) {
@@ -1331,7 +1332,7 @@ static int micbias_ev(struct snd_soc_dapm_widget *w,
1331static int dac_ev(struct snd_soc_dapm_widget *w, 1332static int dac_ev(struct snd_soc_dapm_widget *w,
1332 struct snd_kcontrol *kcontrol, int event) 1333 struct snd_kcontrol *kcontrol, int event)
1333{ 1334{
1334 struct snd_soc_codec *codec = w->codec; 1335 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1335 unsigned int mask = 1 << w->shift; 1336 unsigned int mask = 1 << w->shift;
1336 1337
1337 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, 1338 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
@@ -1372,7 +1373,7 @@ SOC_DAPM_SINGLE("DAC1 Switch", WM8994_SPEAKER_MIXER, 0, 1, 0),
1372static int post_ev(struct snd_soc_dapm_widget *w, 1373static int post_ev(struct snd_soc_dapm_widget *w,
1373 struct snd_kcontrol *kcontrol, int event) 1374 struct snd_kcontrol *kcontrol, int event)
1374{ 1375{
1375 struct snd_soc_codec *codec = w->codec; 1376 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1376 dev_dbg(codec->dev, "SRC status: %x\n", 1377 dev_dbg(codec->dev, "SRC status: %x\n",
1377 snd_soc_read(codec, 1378 snd_soc_read(codec,
1378 WM8994_RATE_STATUS)); 1379 WM8994_RATE_STATUS));
diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c
index c280f0a3a424..79e1aead5131 100644
--- a/sound/soc/codecs/wm8995.c
+++ b/sound/soc/codecs/wm8995.c
@@ -534,10 +534,11 @@ static void wm8995_update_class_w(struct snd_soc_codec *codec)
534static int check_clk_sys(struct snd_soc_dapm_widget *source, 534static int check_clk_sys(struct snd_soc_dapm_widget *source,
535 struct snd_soc_dapm_widget *sink) 535 struct snd_soc_dapm_widget *sink)
536{ 536{
537 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
537 unsigned int reg; 538 unsigned int reg;
538 const char *clk; 539 const char *clk;
539 540
540 reg = snd_soc_read(source->codec, WM8995_CLOCKING_1); 541 reg = snd_soc_read(codec, WM8995_CLOCKING_1);
541 /* Check what we're currently using for CLK_SYS */ 542 /* Check what we're currently using for CLK_SYS */
542 if (reg & WM8995_SYSCLK_SRC) 543 if (reg & WM8995_SYSCLK_SRC)
543 clk = "AIF2CLK"; 544 clk = "AIF2CLK";
@@ -560,9 +561,7 @@ static int wm8995_put_class_w(struct snd_kcontrol *kcontrol,
560static int hp_supply_event(struct snd_soc_dapm_widget *w, 561static int hp_supply_event(struct snd_soc_dapm_widget *w,
561 struct snd_kcontrol *kcontrol, int event) 562 struct snd_kcontrol *kcontrol, int event)
562{ 563{
563 struct snd_soc_codec *codec; 564 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
564
565 codec = w->codec;
566 565
567 switch (event) { 566 switch (event) {
568 case SND_SOC_DAPM_PRE_PMU: 567 case SND_SOC_DAPM_PRE_PMU:
@@ -611,10 +610,9 @@ static void dc_servo_cmd(struct snd_soc_codec *codec,
611static int hp_event(struct snd_soc_dapm_widget *w, 610static int hp_event(struct snd_soc_dapm_widget *w,
612 struct snd_kcontrol *kcontrol, int event) 611 struct snd_kcontrol *kcontrol, int event)
613{ 612{
614 struct snd_soc_codec *codec; 613 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
615 unsigned int reg; 614 unsigned int reg;
616 615
617 codec = w->codec;
618 reg = snd_soc_read(codec, WM8995_ANALOGUE_HP_1); 616 reg = snd_soc_read(codec, WM8995_ANALOGUE_HP_1);
619 617
620 switch (event) { 618 switch (event) {
@@ -761,9 +759,7 @@ static int configure_clock(struct snd_soc_codec *codec)
761static int clk_sys_event(struct snd_soc_dapm_widget *w, 759static int clk_sys_event(struct snd_soc_dapm_widget *w,
762 struct snd_kcontrol *kcontrol, int event) 760 struct snd_kcontrol *kcontrol, int event)
763{ 761{
764 struct snd_soc_codec *codec; 762 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
765
766 codec = w->codec;
767 763
768 switch (event) { 764 switch (event) {
769 case SND_SOC_DAPM_PRE_PMU: 765 case SND_SOC_DAPM_PRE_PMU:
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c
index b1dcc11c1b23..dc92d5e4e942 100644
--- a/sound/soc/codecs/wm8996.c
+++ b/sound/soc/codecs/wm8996.c
@@ -599,7 +599,7 @@ static void wm8996_bg_disable(struct snd_soc_codec *codec)
599static int bg_event(struct snd_soc_dapm_widget *w, 599static int bg_event(struct snd_soc_dapm_widget *w,
600 struct snd_kcontrol *kcontrol, int event) 600 struct snd_kcontrol *kcontrol, int event)
601{ 601{
602 struct snd_soc_codec *codec = w->codec; 602 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
603 int ret = 0; 603 int ret = 0;
604 604
605 switch (event) { 605 switch (event) {
@@ -634,7 +634,8 @@ static int cp_event(struct snd_soc_dapm_widget *w,
634static int rmv_short_event(struct snd_soc_dapm_widget *w, 634static int rmv_short_event(struct snd_soc_dapm_widget *w,
635 struct snd_kcontrol *kcontrol, int event) 635 struct snd_kcontrol *kcontrol, int event)
636{ 636{
637 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(w->codec); 637 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
638 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec);
638 639
639 /* Record which outputs we enabled */ 640 /* Record which outputs we enabled */
640 switch (event) { 641 switch (event) {
@@ -758,7 +759,8 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm,
758static int dcs_start(struct snd_soc_dapm_widget *w, 759static int dcs_start(struct snd_soc_dapm_widget *w,
759 struct snd_kcontrol *kcontrol, int event) 760 struct snd_kcontrol *kcontrol, int event)
760{ 761{
761 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(w->codec); 762 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
763 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec);
762 764
763 switch (event) { 765 switch (event) {
764 case SND_SOC_DAPM_POST_PMU: 766 case SND_SOC_DAPM_POST_PMU:
diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c
index 7e8bfe27566b..a4d11770630c 100644
--- a/sound/soc/codecs/wm8997.c
+++ b/sound/soc/codecs/wm8997.c
@@ -84,7 +84,7 @@ static const struct reg_default wm8997_sysclk_reva_patch[] = {
84static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w, 84static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w,
85 struct snd_kcontrol *kcontrol, int event) 85 struct snd_kcontrol *kcontrol, int event)
86{ 86{
87 struct snd_soc_codec *codec = w->codec; 87 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
88 struct arizona *arizona = dev_get_drvdata(codec->dev->parent); 88 struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
89 struct regmap *regmap = arizona->regmap; 89 struct regmap *regmap = arizona->regmap;
90 const struct reg_default *patch = NULL; 90 const struct reg_default *patch = NULL;
@@ -610,13 +610,16 @@ SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
610 610
611SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, 611SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
612 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, 612 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
613 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 613 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
614 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
614SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, 615SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
615 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, 616 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
616 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 617 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
618 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
617SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, 619SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1,
618 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 620 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
619 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 621 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
622 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
620SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, 623SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1,
621 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 624 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
622 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 625 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c
index b1d946facd57..13a3f335ea5b 100644
--- a/sound/soc/codecs/wm9081.c
+++ b/sound/soc/codecs/wm9081.c
@@ -734,7 +734,7 @@ static int configure_clock(struct snd_soc_codec *codec)
734static int clk_sys_event(struct snd_soc_dapm_widget *w, 734static int clk_sys_event(struct snd_soc_dapm_widget *w,
735 struct snd_kcontrol *kcontrol, int event) 735 struct snd_kcontrol *kcontrol, int event)
736{ 736{
737 struct snd_soc_codec *codec = w->codec; 737 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
738 struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); 738 struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec);
739 739
740 /* This should be done on init() for bypass paths */ 740 /* This should be done on init() for bypass paths */
diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c
index 6ffe8dc4f3fa..60d243c904f5 100644
--- a/sound/soc/codecs/wm9090.c
+++ b/sound/soc/codecs/wm9090.c
@@ -254,7 +254,7 @@ SOC_SINGLE_TLV("MIXOUTR IN2B Volume", WM9090_OUTPUT_MIXER4, 0, 3, 1,
254static int hp_ev(struct snd_soc_dapm_widget *w, 254static int hp_ev(struct snd_soc_dapm_widget *w,
255 struct snd_kcontrol *kcontrol, int event) 255 struct snd_kcontrol *kcontrol, int event)
256{ 256{
257 struct snd_soc_codec *codec = w->codec; 257 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
258 unsigned int reg = snd_soc_read(codec, WM9090_ANALOGUE_HP_0); 258 unsigned int reg = snd_soc_read(codec, WM9090_ANALOGUE_HP_0);
259 259
260 switch (event) { 260 switch (event) {
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index 3eddb18fefd1..5cc457ef8894 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -344,23 +344,27 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec)
344 struct snd_ac97 *ac97; 344 struct snd_ac97 *ac97;
345 int ret = 0; 345 int ret = 0;
346 346
347 ac97 = snd_soc_new_ac97_codec(codec); 347 ac97 = snd_soc_alloc_ac97_codec(codec);
348 if (IS_ERR(ac97)) { 348 if (IS_ERR(ac97)) {
349 ret = PTR_ERR(ac97); 349 ret = PTR_ERR(ac97);
350 dev_err(codec->dev, "Failed to register AC97 codec\n"); 350 dev_err(codec->dev, "Failed to register AC97 codec\n");
351 return ret; 351 return ret;
352 } 352 }
353 353
354 snd_soc_codec_set_drvdata(codec, ac97);
355
356 ret = wm9705_reset(codec); 354 ret = wm9705_reset(codec);
357 if (ret) 355 if (ret)
358 goto reset_err; 356 goto err_put_device;
357
358 ret = device_add(&ac97->dev);
359 if (ret)
360 goto err_put_device;
361
362 snd_soc_codec_set_drvdata(codec, ac97);
359 363
360 return 0; 364 return 0;
361 365
362reset_err: 366err_put_device:
363 snd_soc_free_ac97_codec(ac97); 367 put_device(&ac97->dev);
364 return ret; 368 return ret;
365} 369}
366 370
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index e04643d2bb24..9517571e820d 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -666,7 +666,7 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
666 struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); 666 struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
667 int ret = 0; 667 int ret = 0;
668 668
669 wm9712->ac97 = snd_soc_new_ac97_codec(codec); 669 wm9712->ac97 = snd_soc_alloc_ac97_codec(codec);
670 if (IS_ERR(wm9712->ac97)) { 670 if (IS_ERR(wm9712->ac97)) {
671 ret = PTR_ERR(wm9712->ac97); 671 ret = PTR_ERR(wm9712->ac97);
672 dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); 672 dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret);
@@ -675,15 +675,19 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
675 675
676 ret = wm9712_reset(codec, 0); 676 ret = wm9712_reset(codec, 0);
677 if (ret < 0) 677 if (ret < 0)
678 goto reset_err; 678 goto err_put_device;
679
680 ret = device_add(&wm9712->ac97->dev);
681 if (ret)
682 goto err_put_device;
679 683
680 /* set alc mux to none */ 684 /* set alc mux to none */
681 ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); 685 ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000);
682 686
683 return 0; 687 return 0;
684 688
685reset_err: 689err_put_device:
686 snd_soc_free_ac97_codec(wm9712->ac97); 690 put_device(&wm9712->ac97->dev);
687 return ret; 691 return ret;
688} 692}
689 693
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
index 71b9d5b0734d..68222917b396 100644
--- a/sound/soc/codecs/wm9713.c
+++ b/sound/soc/codecs/wm9713.c
@@ -217,7 +217,7 @@ SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1),
217static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w, 217static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w,
218 struct snd_kcontrol *kcontrol, int event) 218 struct snd_kcontrol *kcontrol, int event)
219{ 219{
220 struct snd_soc_codec *codec = w->codec; 220 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
221 u16 status, rate; 221 u16 status, rate;
222 222
223 if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD)) 223 if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD))
@@ -1225,7 +1225,7 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
1225 struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); 1225 struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
1226 int ret = 0, reg; 1226 int ret = 0, reg;
1227 1227
1228 wm9713->ac97 = snd_soc_new_ac97_codec(codec); 1228 wm9713->ac97 = snd_soc_alloc_ac97_codec(codec);
1229 if (IS_ERR(wm9713->ac97)) 1229 if (IS_ERR(wm9713->ac97))
1230 return PTR_ERR(wm9713->ac97); 1230 return PTR_ERR(wm9713->ac97);
1231 1231
@@ -1234,7 +1234,11 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
1234 wm9713_reset(codec, 0); 1234 wm9713_reset(codec, 0);
1235 ret = wm9713_reset(codec, 1); 1235 ret = wm9713_reset(codec, 1);
1236 if (ret < 0) 1236 if (ret < 0)
1237 goto reset_err; 1237 goto err_put_device;
1238
1239 ret = device_add(&wm9713->ac97->dev);
1240 if (ret)
1241 goto err_put_device;
1238 1242
1239 /* unmute the adc - move to kcontrol */ 1243 /* unmute the adc - move to kcontrol */
1240 reg = ac97_read(codec, AC97_CD) & 0x7fff; 1244 reg = ac97_read(codec, AC97_CD) & 0x7fff;
@@ -1242,8 +1246,8 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
1242 1246
1243 return 0; 1247 return 0;
1244 1248
1245reset_err: 1249err_put_device:
1246 snd_soc_free_ac97_codec(wm9713->ac97); 1250 put_device(&wm9713->ac97->dev);
1247 return ret; 1251 return ret;
1248} 1252}
1249 1253
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 720d6e852986..ff67b334065b 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -1373,7 +1373,7 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w,
1373 struct snd_kcontrol *kcontrol, 1373 struct snd_kcontrol *kcontrol,
1374 int event) 1374 int event)
1375{ 1375{
1376 struct snd_soc_codec *codec = w->codec; 1376 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1377 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); 1377 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
1378 struct wm_adsp *dsp = &dsps[w->shift]; 1378 struct wm_adsp *dsp = &dsps[w->shift];
1379 struct wm_adsp_alg_region *alg_region; 1379 struct wm_adsp_alg_region *alg_region;
@@ -1605,7 +1605,7 @@ err:
1605int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, 1605int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,
1606 struct snd_kcontrol *kcontrol, int event) 1606 struct snd_kcontrol *kcontrol, int event)
1607{ 1607{
1608 struct snd_soc_codec *codec = w->codec; 1608 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1609 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); 1609 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
1610 struct wm_adsp *dsp = &dsps[w->shift]; 1610 struct wm_adsp *dsp = &dsps[w->shift];
1611 1611
@@ -1626,7 +1626,7 @@ EXPORT_SYMBOL_GPL(wm_adsp2_early_event);
1626int wm_adsp2_event(struct snd_soc_dapm_widget *w, 1626int wm_adsp2_event(struct snd_soc_dapm_widget *w,
1627 struct snd_kcontrol *kcontrol, int event) 1627 struct snd_kcontrol *kcontrol, int event)
1628{ 1628{
1629 struct snd_soc_codec *codec = w->codec; 1629 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1630 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); 1630 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
1631 struct wm_adsp *dsp = &dsps[w->shift]; 1631 struct wm_adsp *dsp = &dsps[w->shift];
1632 struct wm_adsp_alg_region *alg_region; 1632 struct wm_adsp_alg_region *alg_region;
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index 374537d5e179..8366e19657a7 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -500,7 +500,7 @@ SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1,
500static int hp_supply_event(struct snd_soc_dapm_widget *w, 500static int hp_supply_event(struct snd_soc_dapm_widget *w,
501 struct snd_kcontrol *kcontrol, int event) 501 struct snd_kcontrol *kcontrol, int event)
502{ 502{
503 struct snd_soc_codec *codec = w->codec; 503 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
504 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); 504 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
505 505
506 switch (event) { 506 switch (event) {
@@ -542,7 +542,7 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w,
542static int hp_event(struct snd_soc_dapm_widget *w, 542static int hp_event(struct snd_soc_dapm_widget *w,
543 struct snd_kcontrol *kcontrol, int event) 543 struct snd_kcontrol *kcontrol, int event)
544{ 544{
545 struct snd_soc_codec *codec = w->codec; 545 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
546 unsigned int reg = snd_soc_read(codec, WM8993_ANALOGUE_HP_0); 546 unsigned int reg = snd_soc_read(codec, WM8993_ANALOGUE_HP_0);
547 547
548 switch (event) { 548 switch (event) {
@@ -594,7 +594,7 @@ static int hp_event(struct snd_soc_dapm_widget *w,
594static int earpiece_event(struct snd_soc_dapm_widget *w, 594static int earpiece_event(struct snd_soc_dapm_widget *w,
595 struct snd_kcontrol *control, int event) 595 struct snd_kcontrol *control, int event)
596{ 596{
597 struct snd_soc_codec *codec = w->codec; 597 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
598 u16 reg = snd_soc_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA; 598 u16 reg = snd_soc_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA;
599 599
600 switch (event) { 600 switch (event) {
@@ -619,7 +619,7 @@ static int earpiece_event(struct snd_soc_dapm_widget *w,
619static int lineout_event(struct snd_soc_dapm_widget *w, 619static int lineout_event(struct snd_soc_dapm_widget *w,
620 struct snd_kcontrol *control, int event) 620 struct snd_kcontrol *control, int event)
621{ 621{
622 struct snd_soc_codec *codec = w->codec; 622 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
623 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); 623 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
624 bool *flag; 624 bool *flag;
625 625
@@ -649,7 +649,7 @@ static int lineout_event(struct snd_soc_dapm_widget *w,
649static int micbias_event(struct snd_soc_dapm_widget *w, 649static int micbias_event(struct snd_soc_dapm_widget *w,
650 struct snd_kcontrol *kcontrol, int event) 650 struct snd_kcontrol *kcontrol, int event)
651{ 651{
652 struct snd_soc_codec *codec = w->codec; 652 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
653 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); 653 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
654 654
655 switch (w->shift) { 655 switch (w->shift) {
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig
index 8e948c63f3d9..2b81ca418d2a 100644
--- a/sound/soc/davinci/Kconfig
+++ b/sound/soc/davinci/Kconfig
@@ -58,13 +58,12 @@ choice
58 depends on MACH_DAVINCI_DM365_EVM 58 depends on MACH_DAVINCI_DM365_EVM
59 59
60config SND_DM365_AIC3X_CODEC 60config SND_DM365_AIC3X_CODEC
61 bool "Audio Codec - AIC3101" 61 tristate "Audio Codec - AIC3101"
62 help 62 help
63 Say Y if you want to add support for AIC3101 audio codec 63 Say Y if you want to add support for AIC3101 audio codec
64 64
65config SND_DM365_VOICE_CODEC 65config SND_DM365_VOICE_CODEC
66 tristate "Voice Codec - CQ93VC" 66 tristate "Voice Codec - CQ93VC"
67 depends on SND_DAVINCI_SOC
68 select MFD_DAVINCI_VOICECODEC 67 select MFD_DAVINCI_VOICECODEC
69 select SND_DAVINCI_SOC_VCIF 68 select SND_DAVINCI_SOC_VCIF
70 select SND_SOC_CQ0093VC 69 select SND_SOC_CQ0093VC
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 158cb3d1db70..b6bb5947a8a8 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -14,7 +14,6 @@
14#include <linux/timer.h> 14#include <linux/timer.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/platform_data/edma.h>
18#include <linux/i2c.h> 17#include <linux/i2c.h>
19#include <linux/of_platform.h> 18#include <linux/of_platform.h>
20#include <linux/clk.h> 19#include <linux/clk.h>
@@ -25,11 +24,6 @@
25#include <asm/dma.h> 24#include <asm/dma.h>
26#include <asm/mach-types.h> 25#include <asm/mach-types.h>
27 26
28#include <linux/edma.h>
29
30#include "davinci-pcm.h"
31#include "davinci-i2s.h"
32
33struct snd_soc_card_drvdata_davinci { 27struct snd_soc_card_drvdata_davinci {
34 struct clk *mclk; 28 struct clk *mclk;
35 unsigned sysclk; 29 unsigned sysclk;
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 30b94d4f9c5d..de3b155a5011 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -364,6 +364,20 @@ static irqreturn_t davinci_mcasp_rx_irq_handler(int irq, void *data)
364 return IRQ_RETVAL(handled_mask); 364 return IRQ_RETVAL(handled_mask);
365} 365}
366 366
367static irqreturn_t davinci_mcasp_common_irq_handler(int irq, void *data)
368{
369 struct davinci_mcasp *mcasp = (struct davinci_mcasp *)data;
370 irqreturn_t ret = IRQ_NONE;
371
372 if (mcasp->substreams[SNDRV_PCM_STREAM_PLAYBACK])
373 ret = davinci_mcasp_tx_irq_handler(irq, data);
374
375 if (mcasp->substreams[SNDRV_PCM_STREAM_CAPTURE])
376 ret |= davinci_mcasp_rx_irq_handler(irq, data);
377
378 return ret;
379}
380
367static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, 381static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
368 unsigned int fmt) 382 unsigned int fmt)
369{ 383{
@@ -1313,16 +1327,19 @@ static struct davinci_mcasp_pdata *davinci_mcasp_set_pdata_from_of(
1313 1327
1314 pdata->tx_dma_channel = dma_spec.args[0]; 1328 pdata->tx_dma_channel = dma_spec.args[0];
1315 1329
1316 ret = of_property_match_string(np, "dma-names", "rx"); 1330 /* RX is not valid in DIT mode */
1317 if (ret < 0) 1331 if (pdata->op_mode != DAVINCI_MCASP_DIT_MODE) {
1318 goto nodata; 1332 ret = of_property_match_string(np, "dma-names", "rx");
1333 if (ret < 0)
1334 goto nodata;
1319 1335
1320 ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret, 1336 ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret,
1321 &dma_spec); 1337 &dma_spec);
1322 if (ret < 0) 1338 if (ret < 0)
1323 goto nodata; 1339 goto nodata;
1324 1340
1325 pdata->rx_dma_channel = dma_spec.args[0]; 1341 pdata->rx_dma_channel = dma_spec.args[0];
1342 }
1326 1343
1327 ret = of_property_read_u32(np, "tx-num-evt", &val); 1344 ret = of_property_read_u32(np, "tx-num-evt", &val);
1328 if (ret >= 0) 1345 if (ret >= 0)
@@ -1441,6 +1458,23 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1441 1458
1442 mcasp->dev = &pdev->dev; 1459 mcasp->dev = &pdev->dev;
1443 1460
1461 irq = platform_get_irq_byname(pdev, "common");
1462 if (irq >= 0) {
1463 irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_common\n",
1464 dev_name(&pdev->dev));
1465 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
1466 davinci_mcasp_common_irq_handler,
1467 IRQF_ONESHOT | IRQF_SHARED,
1468 irq_name, mcasp);
1469 if (ret) {
1470 dev_err(&pdev->dev, "common IRQ request failed\n");
1471 goto err;
1472 }
1473
1474 mcasp->irq_request[SNDRV_PCM_STREAM_PLAYBACK] = XUNDRN;
1475 mcasp->irq_request[SNDRV_PCM_STREAM_CAPTURE] = ROVRN;
1476 }
1477
1444 irq = platform_get_irq_byname(pdev, "rx"); 1478 irq = platform_get_irq_byname(pdev, "rx");
1445 if (irq >= 0) { 1479 if (irq >= 0) {
1446 irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_rx\n", 1480 irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_rx\n",
@@ -1501,19 +1535,34 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1501 else 1535 else
1502 dma_data->filter_data = &dma_params->channel; 1536 dma_data->filter_data = &dma_params->channel;
1503 1537
1504 dma_params = &mcasp->dma_params[SNDRV_PCM_STREAM_CAPTURE]; 1538 /* RX is not valid in DIT mode */
1505 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE]; 1539 if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) {
1506 dma_params->asp_chan_q = pdata->asp_chan_q; 1540 dma_params = &mcasp->dma_params[SNDRV_PCM_STREAM_CAPTURE];
1507 dma_params->ram_chan_q = pdata->ram_chan_q; 1541 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE];
1508 dma_params->sram_pool = pdata->sram_pool; 1542 dma_params->asp_chan_q = pdata->asp_chan_q;
1509 dma_params->sram_size = pdata->sram_size_capture; 1543 dma_params->ram_chan_q = pdata->ram_chan_q;
1510 if (dat) 1544 dma_params->sram_pool = pdata->sram_pool;
1511 dma_params->dma_addr = dat->start; 1545 dma_params->sram_size = pdata->sram_size_capture;
1512 else 1546 if (dat)
1513 dma_params->dma_addr = mem->start + pdata->rx_dma_offset; 1547 dma_params->dma_addr = dat->start;
1514 1548 else
1515 /* Unconditional dmaengine stuff */ 1549 dma_params->dma_addr = mem->start + pdata->rx_dma_offset;
1516 dma_data->addr = dma_params->dma_addr; 1550
1551 /* Unconditional dmaengine stuff */
1552 dma_data->addr = dma_params->dma_addr;
1553
1554 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
1555 if (res)
1556 dma_params->channel = res->start;
1557 else
1558 dma_params->channel = pdata->rx_dma_channel;
1559
1560 /* dmaengine filter data for DT and non-DT boot */
1561 if (pdev->dev.of_node)
1562 dma_data->filter_data = "rx";
1563 else
1564 dma_data->filter_data = &dma_params->channel;
1565 }
1517 1566
1518 if (mcasp->version < MCASP_VERSION_3) { 1567 if (mcasp->version < MCASP_VERSION_3) {
1519 mcasp->fifo_base = DAVINCI_MCASP_V2_AFIFO_BASE; 1568 mcasp->fifo_base = DAVINCI_MCASP_V2_AFIFO_BASE;
@@ -1523,18 +1572,6 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1523 mcasp->fifo_base = DAVINCI_MCASP_V3_AFIFO_BASE; 1572 mcasp->fifo_base = DAVINCI_MCASP_V3_AFIFO_BASE;
1524 } 1573 }
1525 1574
1526 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
1527 if (res)
1528 dma_params->channel = res->start;
1529 else
1530 dma_params->channel = pdata->rx_dma_channel;
1531
1532 /* dmaengine filter data for DT and non-DT boot */
1533 if (pdev->dev.of_node)
1534 dma_data->filter_data = "rx";
1535 else
1536 dma_data->filter_data = &dma_params->channel;
1537
1538 dev_set_drvdata(&pdev->dev, mcasp); 1575 dev_set_drvdata(&pdev->dev, mcasp);
1539 1576
1540 mcasp_reparent_fck(pdev); 1577 mcasp_reparent_fck(pdev);
diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
index b93168d4f648..06d3a34ac90a 100644
--- a/sound/soc/dwc/designware_i2s.c
+++ b/sound/soc/dwc/designware_i2s.c
@@ -209,16 +209,9 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
209 209
210 switch (config->chan_nr) { 210 switch (config->chan_nr) {
211 case EIGHT_CHANNEL_SUPPORT: 211 case EIGHT_CHANNEL_SUPPORT:
212 ch_reg = 3;
213 break;
214 case SIX_CHANNEL_SUPPORT: 212 case SIX_CHANNEL_SUPPORT:
215 ch_reg = 2;
216 break;
217 case FOUR_CHANNEL_SUPPORT: 213 case FOUR_CHANNEL_SUPPORT:
218 ch_reg = 1;
219 break;
220 case TWO_CHANNEL_SUPPORT: 214 case TWO_CHANNEL_SUPPORT:
221 ch_reg = 0;
222 break; 215 break;
223 default: 216 default:
224 dev_err(dev->dev, "channel not supported\n"); 217 dev_err(dev->dev, "channel not supported\n");
@@ -227,18 +220,22 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
227 220
228 i2s_disable_channels(dev, substream->stream); 221 i2s_disable_channels(dev, substream->stream);
229 222
230 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 223 for (ch_reg = 0; ch_reg < (config->chan_nr / 2); ch_reg++) {
231 i2s_write_reg(dev->i2s_base, TCR(ch_reg), xfer_resolution); 224 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
232 i2s_write_reg(dev->i2s_base, TFCR(ch_reg), 0x02); 225 i2s_write_reg(dev->i2s_base, TCR(ch_reg),
233 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg)); 226 xfer_resolution);
234 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x30); 227 i2s_write_reg(dev->i2s_base, TFCR(ch_reg), 0x02);
235 i2s_write_reg(dev->i2s_base, TER(ch_reg), 1); 228 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg));
236 } else { 229 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x30);
237 i2s_write_reg(dev->i2s_base, RCR(ch_reg), xfer_resolution); 230 i2s_write_reg(dev->i2s_base, TER(ch_reg), 1);
238 i2s_write_reg(dev->i2s_base, RFCR(ch_reg), 0x07); 231 } else {
239 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg)); 232 i2s_write_reg(dev->i2s_base, RCR(ch_reg),
240 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x03); 233 xfer_resolution);
241 i2s_write_reg(dev->i2s_base, RER(ch_reg), 1); 234 i2s_write_reg(dev->i2s_base, RFCR(ch_reg), 0x07);
235 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg));
236 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x03);
237 i2s_write_reg(dev->i2s_base, RER(ch_reg), 1);
238 }
242 } 239 }
243 240
244 i2s_write_reg(dev->i2s_base, CCR, ccr); 241 i2s_write_reg(dev->i2s_base, CCR, ccr);
@@ -263,6 +260,19 @@ static void dw_i2s_shutdown(struct snd_pcm_substream *substream,
263 snd_soc_dai_set_dma_data(dai, substream, NULL); 260 snd_soc_dai_set_dma_data(dai, substream, NULL);
264} 261}
265 262
263static int dw_i2s_prepare(struct snd_pcm_substream *substream,
264 struct snd_soc_dai *dai)
265{
266 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
267
268 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
269 i2s_write_reg(dev->i2s_base, TXFFR, 1);
270 else
271 i2s_write_reg(dev->i2s_base, RXFFR, 1);
272
273 return 0;
274}
275
266static int dw_i2s_trigger(struct snd_pcm_substream *substream, 276static int dw_i2s_trigger(struct snd_pcm_substream *substream,
267 int cmd, struct snd_soc_dai *dai) 277 int cmd, struct snd_soc_dai *dai)
268{ 278{
@@ -294,6 +304,7 @@ static struct snd_soc_dai_ops dw_i2s_dai_ops = {
294 .startup = dw_i2s_startup, 304 .startup = dw_i2s_startup,
295 .shutdown = dw_i2s_shutdown, 305 .shutdown = dw_i2s_shutdown,
296 .hw_params = dw_i2s_hw_params, 306 .hw_params = dw_i2s_hw_params,
307 .prepare = dw_i2s_prepare,
297 .trigger = dw_i2s_trigger, 308 .trigger = dw_i2s_trigger,
298}; 309};
299 310
@@ -324,13 +335,47 @@ static int dw_i2s_resume(struct snd_soc_dai *dai)
324#define dw_i2s_resume NULL 335#define dw_i2s_resume NULL
325#endif 336#endif
326 337
338static void dw_configure_dai_by_pd(struct dw_i2s_dev *dev,
339 struct snd_soc_dai_driver *dw_i2s_dai,
340 struct resource *res,
341 const struct i2s_platform_data *pdata)
342{
343 /* Set DMA slaves info */
344
345 dev->play_dma_data.data = pdata->play_dma_data;
346 dev->capture_dma_data.data = pdata->capture_dma_data;
347 dev->play_dma_data.addr = res->start + I2S_TXDMA;
348 dev->capture_dma_data.addr = res->start + I2S_RXDMA;
349 dev->play_dma_data.max_burst = 16;
350 dev->capture_dma_data.max_burst = 16;
351 dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
352 dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
353 dev->play_dma_data.filter = pdata->filter;
354 dev->capture_dma_data.filter = pdata->filter;
355
356 if (pdata->cap & DWC_I2S_PLAY) {
357 dev_dbg(dev->dev, " designware: play supported\n");
358 dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM;
359 dw_i2s_dai->playback.channels_max = pdata->channel;
360 dw_i2s_dai->playback.formats = pdata->snd_fmts;
361 dw_i2s_dai->playback.rates = pdata->snd_rates;
362 }
363
364 if (pdata->cap & DWC_I2S_RECORD) {
365 dev_dbg(dev->dev, "designware: record supported\n");
366 dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM;
367 dw_i2s_dai->capture.channels_max = pdata->channel;
368 dw_i2s_dai->capture.formats = pdata->snd_fmts;
369 dw_i2s_dai->capture.rates = pdata->snd_rates;
370 }
371}
372
327static int dw_i2s_probe(struct platform_device *pdev) 373static int dw_i2s_probe(struct platform_device *pdev)
328{ 374{
329 const struct i2s_platform_data *pdata = pdev->dev.platform_data; 375 const struct i2s_platform_data *pdata = pdev->dev.platform_data;
330 struct dw_i2s_dev *dev; 376 struct dw_i2s_dev *dev;
331 struct resource *res; 377 struct resource *res;
332 int ret; 378 int ret;
333 unsigned int cap;
334 struct snd_soc_dai_driver *dw_i2s_dai; 379 struct snd_soc_dai_driver *dw_i2s_dai;
335 380
336 if (!pdata) { 381 if (!pdata) {
@@ -345,44 +390,23 @@ static int dw_i2s_probe(struct platform_device *pdev)
345 } 390 }
346 391
347 dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL); 392 dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL);
348 if (!dw_i2s_dai) { 393 if (!dw_i2s_dai)
349 dev_err(&pdev->dev, "mem allocation failed for dai driver\n");
350 return -ENOMEM; 394 return -ENOMEM;
351 }
352 395
353 dw_i2s_dai->ops = &dw_i2s_dai_ops; 396 dw_i2s_dai->ops = &dw_i2s_dai_ops;
354 dw_i2s_dai->suspend = dw_i2s_suspend; 397 dw_i2s_dai->suspend = dw_i2s_suspend;
355 dw_i2s_dai->resume = dw_i2s_resume; 398 dw_i2s_dai->resume = dw_i2s_resume;
356 399
357 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 400 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
358 if (!res) {
359 dev_err(&pdev->dev, "no i2s resource defined\n");
360 return -ENODEV;
361 }
362
363 dev->i2s_base = devm_ioremap_resource(&pdev->dev, res); 401 dev->i2s_base = devm_ioremap_resource(&pdev->dev, res);
364 if (IS_ERR(dev->i2s_base)) { 402 if (IS_ERR(dev->i2s_base))
365 dev_err(&pdev->dev, "ioremap fail for i2s_region\n");
366 return PTR_ERR(dev->i2s_base); 403 return PTR_ERR(dev->i2s_base);
367 }
368
369 cap = pdata->cap;
370 dev->capability = cap;
371 dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
372 404
373 /* Set DMA slaves info */ 405 dev->dev = &pdev->dev;
374 406 dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata);
375 dev->play_dma_data.data = pdata->play_dma_data;
376 dev->capture_dma_data.data = pdata->capture_dma_data;
377 dev->play_dma_data.addr = res->start + I2S_TXDMA;
378 dev->capture_dma_data.addr = res->start + I2S_RXDMA;
379 dev->play_dma_data.max_burst = 16;
380 dev->capture_dma_data.max_burst = 16;
381 dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
382 dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
383 dev->play_dma_data.filter = pdata->filter;
384 dev->capture_dma_data.filter = pdata->filter;
385 407
408 dev->capability = pdata->cap;
409 dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
386 dev->clk = clk_get(&pdev->dev, NULL); 410 dev->clk = clk_get(&pdev->dev, NULL);
387 if (IS_ERR(dev->clk)) 411 if (IS_ERR(dev->clk))
388 return PTR_ERR(dev->clk); 412 return PTR_ERR(dev->clk);
@@ -391,23 +415,6 @@ static int dw_i2s_probe(struct platform_device *pdev)
391 if (ret < 0) 415 if (ret < 0)
392 goto err_clk_put; 416 goto err_clk_put;
393 417
394 if (cap & DWC_I2S_PLAY) {
395 dev_dbg(&pdev->dev, " designware: play supported\n");
396 dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM;
397 dw_i2s_dai->playback.channels_max = pdata->channel;
398 dw_i2s_dai->playback.formats = pdata->snd_fmts;
399 dw_i2s_dai->playback.rates = pdata->snd_rates;
400 }
401
402 if (cap & DWC_I2S_RECORD) {
403 dev_dbg(&pdev->dev, "designware: record supported\n");
404 dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM;
405 dw_i2s_dai->capture.channels_max = pdata->channel;
406 dw_i2s_dai->capture.formats = pdata->snd_fmts;
407 dw_i2s_dai->capture.rates = pdata->snd_rates;
408 }
409
410 dev->dev = &pdev->dev;
411 dev_set_drvdata(&pdev->dev, dev); 418 dev_set_drvdata(&pdev->dev, dev);
412 ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component, 419 ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component,
413 dw_i2s_dai, 1); 420 dw_i2s_dai, 1);
diff --git a/sound/soc/fsl/fsl_esai.h b/sound/soc/fsl/fsl_esai.h
index 91a550f4a10d..5e793bbb6b02 100644
--- a/sound/soc/fsl/fsl_esai.h
+++ b/sound/soc/fsl/fsl_esai.h
@@ -302,7 +302,7 @@
302#define ESAI_xCCR_xFP_MASK (((1 << ESAI_xCCR_xFP_WIDTH) - 1) << ESAI_xCCR_xFP_SHIFT) 302#define ESAI_xCCR_xFP_MASK (((1 << ESAI_xCCR_xFP_WIDTH) - 1) << ESAI_xCCR_xFP_SHIFT)
303#define ESAI_xCCR_xFP(v) ((((v) - 1) << ESAI_xCCR_xFP_SHIFT) & ESAI_xCCR_xFP_MASK) 303#define ESAI_xCCR_xFP(v) ((((v) - 1) << ESAI_xCCR_xFP_SHIFT) & ESAI_xCCR_xFP_MASK)
304#define ESAI_xCCR_xDC_SHIFT 9 304#define ESAI_xCCR_xDC_SHIFT 9
305#define ESAI_xCCR_xDC_WIDTH 4 305#define ESAI_xCCR_xDC_WIDTH 5
306#define ESAI_xCCR_xDC_MASK (((1 << ESAI_xCCR_xDC_WIDTH) - 1) << ESAI_xCCR_xDC_SHIFT) 306#define ESAI_xCCR_xDC_MASK (((1 << ESAI_xCCR_xDC_WIDTH) - 1) << ESAI_xCCR_xDC_SHIFT)
307#define ESAI_xCCR_xDC(v) ((((v) - 1) << ESAI_xCCR_xDC_SHIFT) & ESAI_xCCR_xDC_MASK) 307#define ESAI_xCCR_xDC(v) ((((v) - 1) << ESAI_xCCR_xDC_SHIFT) & ESAI_xCCR_xDC_MASK)
308#define ESAI_xCCR_xPSR_SHIFT 8 308#define ESAI_xCCR_xPSR_SHIFT 8
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index a65f17d57ffb..059496ed9ad7 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1362,9 +1362,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)
1362 } 1362 }
1363 1363
1364 ssi_private->irq = platform_get_irq(pdev, 0); 1364 ssi_private->irq = platform_get_irq(pdev, 0);
1365 if (!ssi_private->irq) { 1365 if (ssi_private->irq < 0) {
1366 dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); 1366 dev_err(&pdev->dev, "no irq for node %s\n", np->full_name);
1367 return -ENXIO; 1367 return ssi_private->irq;
1368 } 1368 }
1369 1369
1370 /* Are the RX and the TX clocks locked? */ 1370 /* Are the RX and the TX clocks locked? */
diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c
index 4caacb05a623..cd146d4fa805 100644
--- a/sound/soc/fsl/imx-wm8962.c
+++ b/sound/soc/fsl/imx-wm8962.c
@@ -257,6 +257,7 @@ static int imx_wm8962_probe(struct platform_device *pdev)
257 if (ret) 257 if (ret)
258 goto clk_fail; 258 goto clk_fail;
259 data->card.num_links = 1; 259 data->card.num_links = 1;
260 data->card.owner = THIS_MODULE;
260 data->card.dai_link = &data->dai; 261 data->card.dai_link = &data->dai;
261 data->card.dapm_widgets = imx_wm8962_dapm_widgets; 262 data->card.dapm_widgets = imx_wm8962_dapm_widgets;
262 data->card.num_dapm_widgets = ARRAY_SIZE(imx_wm8962_dapm_widgets); 263 data->card.num_dapm_widgets = ARRAY_SIZE(imx_wm8962_dapm_widgets);
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index fb9240fdc9b7..7fe3009b1c43 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -452,9 +452,8 @@ static int asoc_simple_card_parse_of(struct device_node *node,
452} 452}
453 453
454/* Decrease the reference count of the device nodes */ 454/* Decrease the reference count of the device nodes */
455static int asoc_simple_card_unref(struct platform_device *pdev) 455static int asoc_simple_card_unref(struct snd_soc_card *card)
456{ 456{
457 struct snd_soc_card *card = platform_get_drvdata(pdev);
458 struct snd_soc_dai_link *dai_link; 457 struct snd_soc_dai_link *dai_link;
459 int num_links; 458 int num_links;
460 459
@@ -556,7 +555,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
556 return ret; 555 return ret;
557 556
558err: 557err:
559 asoc_simple_card_unref(pdev); 558 asoc_simple_card_unref(&priv->snd_card);
560 return ret; 559 return ret;
561} 560}
562 561
@@ -572,7 +571,7 @@ static int asoc_simple_card_remove(struct platform_device *pdev)
572 snd_soc_jack_free_gpios(&simple_card_mic_jack, 1, 571 snd_soc_jack_free_gpios(&simple_card_mic_jack, 1,
573 &simple_card_mic_jack_gpio); 572 &simple_card_mic_jack_gpio);
574 573
575 return asoc_simple_card_unref(pdev); 574 return asoc_simple_card_unref(card);
576} 575}
577 576
578static const struct of_device_id asoc_simple_of_match[] = { 577static const struct of_device_id asoc_simple_of_match[] = {
diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index e989ecf046c9..c0813f546d1f 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -46,7 +46,7 @@ config SND_SOC_INTEL_BAYTRAIL
46 46
47config SND_SOC_INTEL_HASWELL_MACH 47config SND_SOC_INTEL_HASWELL_MACH
48 tristate "ASoC Audio DSP support for Intel Haswell Lynxpoint" 48 tristate "ASoC Audio DSP support for Intel Haswell Lynxpoint"
49 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C && \\ 49 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C && \
50 I2C_DESIGNWARE_PLATFORM 50 I2C_DESIGNWARE_PLATFORM
51 select SND_SOC_INTEL_HASWELL 51 select SND_SOC_INTEL_HASWELL
52 select SND_SOC_RT5640 52 select SND_SOC_RT5640
@@ -76,7 +76,7 @@ config SND_SOC_INTEL_BYT_MAX98090_MACH
76 76
77config SND_SOC_INTEL_BROADWELL_MACH 77config SND_SOC_INTEL_BROADWELL_MACH
78 tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint" 78 tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint"
79 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && DW_DMAC && \\ 79 depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && DW_DMAC && \
80 I2C_DESIGNWARE_PLATFORM 80 I2C_DESIGNWARE_PLATFORM
81 select SND_SOC_INTEL_HASWELL 81 select SND_SOC_INTEL_HASWELL
82 select SND_COMPRESS_OFFLOAD 82 select SND_COMPRESS_OFFLOAD
@@ -89,7 +89,7 @@ config SND_SOC_INTEL_BROADWELL_MACH
89 89
90config SND_SOC_INTEL_BYTCR_RT5640_MACH 90config SND_SOC_INTEL_BYTCR_RT5640_MACH
91 tristate "ASoC Audio DSP Support for MID BYT Platform" 91 tristate "ASoC Audio DSP Support for MID BYT Platform"
92 depends on X86 92 depends on X86 && I2C
93 select SND_SOC_RT5640 93 select SND_SOC_RT5640
94 select SND_SST_MFLD_PLATFORM 94 select SND_SST_MFLD_PLATFORM
95 select SND_SST_IPC_ACPI 95 select SND_SST_IPC_ACPI
@@ -101,7 +101,7 @@ config SND_SOC_INTEL_BYTCR_RT5640_MACH
101 101
102config SND_SOC_INTEL_CHT_BSW_RT5672_MACH 102config SND_SOC_INTEL_CHT_BSW_RT5672_MACH
103 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5672 codec" 103 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5672 codec"
104 depends on X86_INTEL_LPSS 104 depends on X86_INTEL_LPSS && I2C
105 select SND_SOC_RT5670 105 select SND_SOC_RT5670
106 select SND_SST_MFLD_PLATFORM 106 select SND_SST_MFLD_PLATFORM
107 select SND_SST_IPC_ACPI 107 select SND_SST_IPC_ACPI
diff --git a/sound/soc/intel/bytcr_dpcm_rt5640.c b/sound/soc/intel/bytcr_dpcm_rt5640.c
index f5d0fc1ab10c..59308629043e 100644
--- a/sound/soc/intel/bytcr_dpcm_rt5640.c
+++ b/sound/soc/intel/bytcr_dpcm_rt5640.c
@@ -215,7 +215,6 @@ static int snd_byt_mc_probe(struct platform_device *pdev)
215 215
216static struct platform_driver snd_byt_mc_driver = { 216static struct platform_driver snd_byt_mc_driver = {
217 .driver = { 217 .driver = {
218 .owner = THIS_MODULE,
219 .name = "bytt100_rt5640", 218 .name = "bytt100_rt5640",
220 .pm = &snd_soc_pm_ops, 219 .pm = &snd_soc_pm_ops,
221 }, 220 },
@@ -227,4 +226,4 @@ module_platform_driver(snd_byt_mc_driver);
227MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver"); 226MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver");
228MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>"); 227MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>");
229MODULE_LICENSE("GPL v2"); 228MODULE_LICENSE("GPL v2");
230MODULE_ALIAS("platform:bytrt5640-audio"); 229MODULE_ALIAS("platform:bytt100_rt5640");
diff --git a/sound/soc/intel/cht_bsw_rt5672.c b/sound/soc/intel/cht_bsw_rt5672.c
index 9b8b561171b7..a406c6104897 100644
--- a/sound/soc/intel/cht_bsw_rt5672.c
+++ b/sound/soc/intel/cht_bsw_rt5672.c
@@ -270,7 +270,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
270 270
271static struct platform_driver snd_cht_mc_driver = { 271static struct platform_driver snd_cht_mc_driver = {
272 .driver = { 272 .driver = {
273 .owner = THIS_MODULE,
274 .name = "cht-bsw-rt5672", 273 .name = "cht-bsw-rt5672",
275 .pm = &snd_soc_pm_ops, 274 .pm = &snd_soc_pm_ops,
276 }, 275 },
diff --git a/sound/soc/intel/sst-firmware.c b/sound/soc/intel/sst-firmware.c
index 4a5bde9c686b..a2ae2c5f2e9f 100644
--- a/sound/soc/intel/sst-firmware.c
+++ b/sound/soc/intel/sst-firmware.c
@@ -497,6 +497,7 @@ struct sst_module *sst_module_new(struct sst_fw *sst_fw,
497 sst_module->sst_fw = sst_fw; 497 sst_module->sst_fw = sst_fw;
498 sst_module->scratch_size = template->scratch_size; 498 sst_module->scratch_size = template->scratch_size;
499 sst_module->persistent_size = template->persistent_size; 499 sst_module->persistent_size = template->persistent_size;
500 sst_module->entry = template->entry;
500 501
501 INIT_LIST_HEAD(&sst_module->block_list); 502 INIT_LIST_HEAD(&sst_module->block_list);
502 INIT_LIST_HEAD(&sst_module->runtime_list); 503 INIT_LIST_HEAD(&sst_module->runtime_list);
@@ -706,6 +707,7 @@ static int block_alloc_fixed(struct sst_dsp *dsp, struct sst_block_allocator *ba
706 struct list_head *block_list) 707 struct list_head *block_list)
707{ 708{
708 struct sst_mem_block *block, *tmp; 709 struct sst_mem_block *block, *tmp;
710 struct sst_block_allocator ba_tmp = *ba;
709 u32 end = ba->offset + ba->size, block_end; 711 u32 end = ba->offset + ba->size, block_end;
710 int err; 712 int err;
711 713
@@ -730,9 +732,9 @@ static int block_alloc_fixed(struct sst_dsp *dsp, struct sst_block_allocator *ba
730 if (ba->offset >= block->offset && ba->offset < block_end) { 732 if (ba->offset >= block->offset && ba->offset < block_end) {
731 733
732 /* align ba to block boundary */ 734 /* align ba to block boundary */
733 ba->size -= block_end - ba->offset; 735 ba_tmp.size -= block_end - ba->offset;
734 ba->offset = block_end; 736 ba_tmp.offset = block_end;
735 err = block_alloc_contiguous(dsp, ba, block_list); 737 err = block_alloc_contiguous(dsp, &ba_tmp, block_list);
736 if (err < 0) 738 if (err < 0)
737 return -ENOMEM; 739 return -ENOMEM;
738 740
@@ -763,10 +765,14 @@ static int block_alloc_fixed(struct sst_dsp *dsp, struct sst_block_allocator *ba
763 /* does block span more than 1 section */ 765 /* does block span more than 1 section */
764 if (ba->offset >= block->offset && ba->offset < block_end) { 766 if (ba->offset >= block->offset && ba->offset < block_end) {
765 767
768 /* add block */
769 list_move(&block->list, &dsp->used_block_list);
770 list_add(&block->module_list, block_list);
766 /* align ba to block boundary */ 771 /* align ba to block boundary */
767 ba->offset = block->offset; 772 ba_tmp.size -= block_end - ba->offset;
773 ba_tmp.offset = block_end;
768 774
769 err = block_alloc_contiguous(dsp, ba, block_list); 775 err = block_alloc_contiguous(dsp, &ba_tmp, block_list);
770 if (err < 0) 776 if (err < 0)
771 return -ENOMEM; 777 return -ENOMEM;
772 778
diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c
index 3f8c48231364..8156cc1accb7 100644
--- a/sound/soc/intel/sst-haswell-ipc.c
+++ b/sound/soc/intel/sst-haswell-ipc.c
@@ -651,11 +651,11 @@ static void hsw_notification_work(struct work_struct *work)
651 } 651 }
652 652
653 /* tell DSP that notification has been handled */ 653 /* tell DSP that notification has been handled */
654 sst_dsp_shim_update_bits_unlocked(hsw->dsp, SST_IPCD, 654 sst_dsp_shim_update_bits(hsw->dsp, SST_IPCD,
655 SST_IPCD_BUSY | SST_IPCD_DONE, SST_IPCD_DONE); 655 SST_IPCD_BUSY | SST_IPCD_DONE, SST_IPCD_DONE);
656 656
657 /* unmask busy interrupt */ 657 /* unmask busy interrupt */
658 sst_dsp_shim_update_bits_unlocked(hsw->dsp, SST_IMRX, SST_IMRX_BUSY, 0); 658 sst_dsp_shim_update_bits(hsw->dsp, SST_IMRX, SST_IMRX_BUSY, 0);
659} 659}
660 660
661static struct ipc_message *reply_find_msg(struct sst_hsw *hsw, u32 header) 661static struct ipc_message *reply_find_msg(struct sst_hsw *hsw, u32 header)
@@ -1228,6 +1228,11 @@ int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1228 struct sst_dsp *sst = hsw->dsp; 1228 struct sst_dsp *sst = hsw->dsp;
1229 unsigned long flags; 1229 unsigned long flags;
1230 1230
1231 if (!stream) {
1232 dev_warn(hsw->dev, "warning: stream is NULL, no stream to free, ignore it.\n");
1233 return 0;
1234 }
1235
1231 /* dont free DSP streams that are not commited */ 1236 /* dont free DSP streams that are not commited */
1232 if (!stream->commited) 1237 if (!stream->commited)
1233 goto out; 1238 goto out;
@@ -1415,6 +1420,16 @@ int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1415 u32 header; 1420 u32 header;
1416 int ret; 1421 int ret;
1417 1422
1423 if (!stream) {
1424 dev_warn(hsw->dev, "warning: stream is NULL, no stream to commit, ignore it.\n");
1425 return 0;
1426 }
1427
1428 if (stream->commited) {
1429 dev_warn(hsw->dev, "warning: stream is already committed, ignore it.\n");
1430 return 0;
1431 }
1432
1418 trace_ipc_request("stream alloc", stream->host_id); 1433 trace_ipc_request("stream alloc", stream->host_id);
1419 1434
1420 header = IPC_GLB_TYPE(IPC_GLB_ALLOCATE_STREAM); 1435 header = IPC_GLB_TYPE(IPC_GLB_ALLOCATE_STREAM);
@@ -1519,6 +1534,11 @@ int sst_hsw_stream_pause(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
1519{ 1534{
1520 int ret; 1535 int ret;
1521 1536
1537 if (!stream) {
1538 dev_warn(hsw->dev, "warning: stream is NULL, no stream to pause, ignore it.\n");
1539 return 0;
1540 }
1541
1522 trace_ipc_request("stream pause", stream->reply.stream_hw_id); 1542 trace_ipc_request("stream pause", stream->reply.stream_hw_id);
1523 1543
1524 ret = sst_hsw_stream_operations(hsw, IPC_STR_PAUSE, 1544 ret = sst_hsw_stream_operations(hsw, IPC_STR_PAUSE,
@@ -1535,6 +1555,11 @@ int sst_hsw_stream_resume(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
1535{ 1555{
1536 int ret; 1556 int ret;
1537 1557
1558 if (!stream) {
1559 dev_warn(hsw->dev, "warning: stream is NULL, no stream to resume, ignore it.\n");
1560 return 0;
1561 }
1562
1538 trace_ipc_request("stream resume", stream->reply.stream_hw_id); 1563 trace_ipc_request("stream resume", stream->reply.stream_hw_id);
1539 1564
1540 ret = sst_hsw_stream_operations(hsw, IPC_STR_RESUME, 1565 ret = sst_hsw_stream_operations(hsw, IPC_STR_RESUME,
@@ -1550,6 +1575,11 @@ int sst_hsw_stream_reset(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1550{ 1575{
1551 int ret, tries = 10; 1576 int ret, tries = 10;
1552 1577
1578 if (!stream) {
1579 dev_warn(hsw->dev, "warning: stream is NULL, no stream to reset, ignore it.\n");
1580 return 0;
1581 }
1582
1553 /* dont reset streams that are not commited */ 1583 /* dont reset streams that are not commited */
1554 if (!stream->commited) 1584 if (!stream->commited)
1555 return 0; 1585 return 0;
diff --git a/sound/soc/intel/sst/sst.h b/sound/soc/intel/sst/sst.h
index 7f4bbfcbc6f5..562bc483d6b7 100644
--- a/sound/soc/intel/sst/sst.h
+++ b/sound/soc/intel/sst/sst.h
@@ -58,6 +58,7 @@ enum sst_algo_ops {
58#define SST_BLOCK_TIMEOUT 1000 58#define SST_BLOCK_TIMEOUT 1000
59 59
60#define FW_SIGNATURE_SIZE 4 60#define FW_SIGNATURE_SIZE 4
61#define FW_NAME_SIZE 32
61 62
62/* stream states */ 63/* stream states */
63enum sst_stream_states { 64enum sst_stream_states {
@@ -426,7 +427,7 @@ struct intel_sst_drv {
426 * Holder for firmware name. Due to async call it needs to be 427 * Holder for firmware name. Due to async call it needs to be
427 * persistent till worker thread gets called 428 * persistent till worker thread gets called
428 */ 429 */
429 char firmware_name[20]; 430 char firmware_name[FW_NAME_SIZE];
430}; 431};
431 432
432/* misc definitions */ 433/* misc definitions */
diff --git a/sound/soc/intel/sst/sst_acpi.c b/sound/soc/intel/sst/sst_acpi.c
index 3abc29e8a928..e541d0e69ea2 100644
--- a/sound/soc/intel/sst/sst_acpi.c
+++ b/sound/soc/intel/sst/sst_acpi.c
@@ -47,7 +47,7 @@ struct sst_machines {
47 char board[32]; 47 char board[32];
48 char machine[32]; 48 char machine[32];
49 void (*machine_quirk)(void); 49 void (*machine_quirk)(void);
50 char firmware[32]; 50 char firmware[FW_NAME_SIZE];
51 struct sst_platform_info *pdata; 51 struct sst_platform_info *pdata;
52 52
53}; 53};
@@ -245,7 +245,7 @@ static struct sst_machines *sst_acpi_find_machine(
245 return NULL; 245 return NULL;
246} 246}
247 247
248int sst_acpi_probe(struct platform_device *pdev) 248static int sst_acpi_probe(struct platform_device *pdev)
249{ 249{
250 struct device *dev = &pdev->dev; 250 struct device *dev = &pdev->dev;
251 int ret = 0; 251 int ret = 0;
@@ -332,7 +332,7 @@ do_sst_cleanup:
332* This function is called by OS when a device is unloaded 332* This function is called by OS when a device is unloaded
333* This frees the interrupt etc 333* This frees the interrupt etc
334*/ 334*/
335int sst_acpi_remove(struct platform_device *pdev) 335static int sst_acpi_remove(struct platform_device *pdev)
336{ 336{
337 struct intel_sst_drv *ctx; 337 struct intel_sst_drv *ctx;
338 338
@@ -343,14 +343,14 @@ int sst_acpi_remove(struct platform_device *pdev)
343} 343}
344 344
345static struct sst_machines sst_acpi_bytcr[] = { 345static struct sst_machines sst_acpi_bytcr[] = {
346 {"10EC5640", "T100", "bytt100_rt5640", NULL, "fw_sst_0f28.bin", 346 {"10EC5640", "T100", "bytt100_rt5640", NULL, "intel/fw_sst_0f28.bin",
347 &byt_rvp_platform_data }, 347 &byt_rvp_platform_data },
348 {}, 348 {},
349}; 349};
350 350
351/* Cherryview-based platforms: CherryTrail and Braswell */ 351/* Cherryview-based platforms: CherryTrail and Braswell */
352static struct sst_machines sst_acpi_chv[] = { 352static struct sst_machines sst_acpi_chv[] = {
353 {"10EC5670", "cht-bsw", "cht-bsw-rt5672", NULL, "fw_sst_22a8.bin", 353 {"10EC5670", "cht-bsw", "cht-bsw-rt5672", NULL, "intel/fw_sst_22a8.bin",
354 &chv_platform_data }, 354 &chv_platform_data },
355 {}, 355 {},
356}; 356};
@@ -366,7 +366,6 @@ MODULE_DEVICE_TABLE(acpi, sst_acpi_ids);
366static struct platform_driver sst_acpi_driver = { 366static struct platform_driver sst_acpi_driver = {
367 .driver = { 367 .driver = {
368 .name = "intel_sst_acpi", 368 .name = "intel_sst_acpi",
369 .owner = THIS_MODULE,
370 .acpi_match_table = ACPI_PTR(sst_acpi_ids), 369 .acpi_match_table = ACPI_PTR(sst_acpi_ids),
371 .pm = &intel_sst_pm, 370 .pm = &intel_sst_pm,
372 }, 371 },
diff --git a/sound/soc/omap/omap-hdmi-audio.c b/sound/soc/omap/omap-hdmi-audio.c
index 3f9ac7dbdc80..ccfb41c22e53 100644
--- a/sound/soc/omap/omap-hdmi-audio.c
+++ b/sound/soc/omap/omap-hdmi-audio.c
@@ -393,7 +393,6 @@ static int omap_hdmi_audio_remove(struct platform_device *pdev)
393static struct platform_driver hdmi_audio_driver = { 393static struct platform_driver hdmi_audio_driver = {
394 .driver = { 394 .driver = {
395 .name = DRV_NAME, 395 .name = DRV_NAME,
396 .owner = THIS_MODULE,
397 }, 396 },
398 .probe = omap_hdmi_audio_probe, 397 .probe = omap_hdmi_audio_probe,
399 .remove = omap_hdmi_audio_remove, 398 .remove = omap_hdmi_audio_remove,
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 8b79cafab1e2..c7eb9dd67f60 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -434,7 +434,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
434 case SND_SOC_DAIFMT_CBM_CFS: 434 case SND_SOC_DAIFMT_CBM_CFS:
435 /* McBSP slave. FS clock as output */ 435 /* McBSP slave. FS clock as output */
436 regs->srgr2 |= FSGM; 436 regs->srgr2 |= FSGM;
437 regs->pcr0 |= FSXM; 437 regs->pcr0 |= FSXM | FSRM;
438 break; 438 break;
439 case SND_SOC_DAIFMT_CBM_CFM: 439 case SND_SOC_DAIFMT_CBM_CFM:
440 /* McBSP slave */ 440 /* McBSP slave */
diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c
index 396dbd51a64f..a9615a574546 100644
--- a/sound/soc/pxa/mioa701_wm9713.c
+++ b/sound/soc/pxa/mioa701_wm9713.c
@@ -81,7 +81,7 @@ static int rear_amp_power(struct snd_soc_codec *codec, int power)
81static int rear_amp_event(struct snd_soc_dapm_widget *widget, 81static int rear_amp_event(struct snd_soc_dapm_widget *widget,
82 struct snd_kcontrol *kctl, int event) 82 struct snd_kcontrol *kctl, int event)
83{ 83{
84 struct snd_soc_codec *codec = widget->codec; 84 struct snd_soc_codec *codec = widget->dapm->card->rtd[0].codec;
85 85
86 return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event)); 86 return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event));
87} 87}
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index d7d5fb20ea6f..a6d680acd907 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -352,7 +352,6 @@ static int spitz_remove(struct platform_device *pdev)
352static struct platform_driver spitz_driver = { 352static struct platform_driver spitz_driver = {
353 .driver = { 353 .driver = {
354 .name = "spitz-audio", 354 .name = "spitz-audio",
355 .owner = THIS_MODULE,
356 .pm = &snd_soc_pm_ops, 355 .pm = &snd_soc_pm_ops,
357 }, 356 },
358 .probe = spitz_probe, 357 .probe = spitz_probe,
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index 26ec5117b35c..acb5be53bfb4 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -247,6 +247,10 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
247 247
248 regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val); 248 regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val);
249 regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val); 249 regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val);
250 regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK,
251 I2S_DMACR_TDL(16));
252 regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK,
253 I2S_DMACR_RDL(16));
250 254
251 return 0; 255 return 0;
252} 256}
@@ -335,6 +339,7 @@ static struct snd_soc_dai_driver rockchip_i2s_dai = {
335 SNDRV_PCM_FMTBIT_S24_LE), 339 SNDRV_PCM_FMTBIT_S24_LE),
336 }, 340 },
337 .ops = &rockchip_i2s_dai_ops, 341 .ops = &rockchip_i2s_dai_ops,
342 .symmetric_rates = 1,
338}; 343};
339 344
340static const struct snd_soc_component_driver rockchip_i2s_component = { 345static const struct snd_soc_component_driver rockchip_i2s_component = {
@@ -454,11 +459,11 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
454 459
455 i2s->playback_dma_data.addr = res->start + I2S_TXDR; 460 i2s->playback_dma_data.addr = res->start + I2S_TXDR;
456 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 461 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
457 i2s->playback_dma_data.maxburst = 16; 462 i2s->playback_dma_data.maxburst = 4;
458 463
459 i2s->capture_dma_data.addr = res->start + I2S_RXDR; 464 i2s->capture_dma_data.addr = res->start + I2S_RXDR;
460 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 465 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
461 i2s->capture_dma_data.maxburst = 16; 466 i2s->capture_dma_data.maxburst = 4;
462 467
463 i2s->dev = &pdev->dev; 468 i2s->dev = &pdev->dev;
464 dev_set_drvdata(&pdev->dev, i2s); 469 dev_set_drvdata(&pdev->dev, i2s);
diff --git a/sound/soc/rockchip/rockchip_i2s.h b/sound/soc/rockchip/rockchip_i2s.h
index 89a5d8bc6ee7..93f456f518a9 100644
--- a/sound/soc/rockchip/rockchip_i2s.h
+++ b/sound/soc/rockchip/rockchip_i2s.h
@@ -127,7 +127,7 @@
127#define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT) 127#define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT)
128#define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT) 128#define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT)
129#define I2S_DMACR_TDL_SHIFT 0 129#define I2S_DMACR_TDL_SHIFT 0
130#define I2S_DMACR_TDL(x) ((x - 1) << I2S_DMACR_TDL_SHIFT) 130#define I2S_DMACR_TDL(x) ((x) << I2S_DMACR_TDL_SHIFT)
131#define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT) 131#define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT)
132 132
133/* 133/*
diff --git a/sound/soc/samsung/arndale_rt5631.c b/sound/soc/samsung/arndale_rt5631.c
index 1e2b61ca8db2..8bf2e2c4bafb 100644
--- a/sound/soc/samsung/arndale_rt5631.c
+++ b/sound/soc/samsung/arndale_rt5631.c
@@ -135,7 +135,6 @@ MODULE_DEVICE_TABLE(of, samsung_arndale_rt5631_of_match);
135static struct platform_driver arndale_audio_driver = { 135static struct platform_driver arndale_audio_driver = {
136 .driver = { 136 .driver = {
137 .name = "arndale-audio", 137 .name = "arndale-audio",
138 .owner = THIS_MODULE,
139 .pm = &snd_soc_pm_ops, 138 .pm = &snd_soc_pm_ops,
140 .of_match_table = of_match_ptr(samsung_arndale_rt5631_of_match), 139 .of_match_table = of_match_ptr(samsung_arndale_rt5631_of_match),
141 }, 140 },
diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c
index 2e10e9a38376..08d7259bbaab 100644
--- a/sound/soc/soc-ac97.c
+++ b/sound/soc/soc-ac97.c
@@ -48,15 +48,18 @@ static void soc_ac97_device_release(struct device *dev)
48} 48}
49 49
50/** 50/**
51 * snd_soc_new_ac97_codec - initailise AC97 device 51 * snd_soc_alloc_ac97_codec() - Allocate new a AC'97 device
52 * @codec: audio codec 52 * @codec: The CODEC for which to create the AC'97 device
53 * 53 *
54 * Initialises AC97 codec resources for use by ad-hoc devices only. 54 * Allocated a new snd_ac97 device and intializes it, but does not yet register
55 * it. The caller is responsible to either call device_add(&ac97->dev) to
56 * register the device, or to call put_device(&ac97->dev) to free the device.
57 *
58 * Returns: A snd_ac97 device or a PTR_ERR in case of an error.
55 */ 59 */
56struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec) 60struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec)
57{ 61{
58 struct snd_ac97 *ac97; 62 struct snd_ac97 *ac97;
59 int ret;
60 63
61 ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); 64 ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
62 if (ac97 == NULL) 65 if (ac97 == NULL)
@@ -73,7 +76,28 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec)
73 codec->component.card->snd_card->number, 0, 76 codec->component.card->snd_card->number, 0,
74 codec->component.name); 77 codec->component.name);
75 78
76 ret = device_register(&ac97->dev); 79 device_initialize(&ac97->dev);
80
81 return ac97;
82}
83EXPORT_SYMBOL(snd_soc_alloc_ac97_codec);
84
85/**
86 * snd_soc_new_ac97_codec - initailise AC97 device
87 * @codec: audio codec
88 *
89 * Initialises AC97 codec resources for use by ad-hoc devices only.
90 */
91struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec)
92{
93 struct snd_ac97 *ac97;
94 int ret;
95
96 ac97 = snd_soc_alloc_ac97_codec(codec);
97 if (IS_ERR(ac97))
98 return ac97;
99
100 ret = device_add(&ac97->dev);
77 if (ret) { 101 if (ret) {
78 put_device(&ac97->dev); 102 put_device(&ac97->dev);
79 return ERR_PTR(ret); 103 return ERR_PTR(ret);
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 590a82f01d0b..025c38fbe3c0 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -659,7 +659,8 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
659 rtd->dai_link->stream_name); 659 rtd->dai_link->stream_name);
660 660
661 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, 661 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
662 1, 0, &be_pcm); 662 rtd->dai_link->dpcm_playback,
663 rtd->dai_link->dpcm_capture, &be_pcm);
663 if (ret < 0) { 664 if (ret < 0) {
664 dev_err(rtd->card->dev, "ASoC: can't create compressed for %s\n", 665 dev_err(rtd->card->dev, "ASoC: can't create compressed for %s\n",
665 rtd->dai_link->name); 666 rtd->dai_link->name);
@@ -668,8 +669,10 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
668 669
669 rtd->pcm = be_pcm; 670 rtd->pcm = be_pcm;
670 rtd->fe_compr = 1; 671 rtd->fe_compr = 1;
671 be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd; 672 if (rtd->dai_link->dpcm_playback)
672 be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd; 673 be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
674 else if (rtd->dai_link->dpcm_capture)
675 be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
673 memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops)); 676 memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops));
674 } else 677 } else
675 memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); 678 memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d342ee2ce28b..678823d2e14a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -191,6 +191,39 @@ static ssize_t pmdown_time_set(struct device *dev,
191 191
192static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set); 192static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set);
193 193
194static struct attribute *soc_dev_attrs[] = {
195 &dev_attr_codec_reg.attr,
196 &dev_attr_pmdown_time.attr,
197 NULL
198};
199
200static umode_t soc_dev_attr_is_visible(struct kobject *kobj,
201 struct attribute *attr, int idx)
202{
203 struct device *dev = kobj_to_dev(kobj);
204 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
205
206 if (attr == &dev_attr_pmdown_time.attr)
207 return attr->mode; /* always visible */
208 return rtd->codec ? attr->mode : 0; /* enabled only with codec */
209}
210
211static const struct attribute_group soc_dapm_dev_group = {
212 .attrs = soc_dapm_dev_attrs,
213 .is_visible = soc_dev_attr_is_visible,
214};
215
216static const struct attribute_group soc_dev_roup = {
217 .attrs = soc_dev_attrs,
218 .is_visible = soc_dev_attr_is_visible,
219};
220
221static const struct attribute_group *soc_dev_attr_groups[] = {
222 &soc_dapm_dev_group,
223 &soc_dev_roup,
224 NULL
225};
226
194#ifdef CONFIG_DEBUG_FS 227#ifdef CONFIG_DEBUG_FS
195static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf, 228static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf,
196 size_t count, loff_t *ppos) 229 size_t count, loff_t *ppos)
@@ -949,8 +982,6 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order)
949 982
950 /* unregister the rtd device */ 983 /* unregister the rtd device */
951 if (rtd->dev_registered) { 984 if (rtd->dev_registered) {
952 device_remove_file(rtd->dev, &dev_attr_pmdown_time);
953 device_remove_file(rtd->dev, &dev_attr_codec_reg);
954 device_unregister(rtd->dev); 985 device_unregister(rtd->dev);
955 rtd->dev_registered = 0; 986 rtd->dev_registered = 0;
956 } 987 }
@@ -1120,6 +1151,7 @@ static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd,
1120 device_initialize(rtd->dev); 1151 device_initialize(rtd->dev);
1121 rtd->dev->parent = rtd->card->dev; 1152 rtd->dev->parent = rtd->card->dev;
1122 rtd->dev->release = rtd_release; 1153 rtd->dev->release = rtd_release;
1154 rtd->dev->groups = soc_dev_attr_groups;
1123 dev_set_name(rtd->dev, "%s", name); 1155 dev_set_name(rtd->dev, "%s", name);
1124 dev_set_drvdata(rtd->dev, rtd); 1156 dev_set_drvdata(rtd->dev, rtd);
1125 mutex_init(&rtd->pcm_mutex); 1157 mutex_init(&rtd->pcm_mutex);
@@ -1136,23 +1168,6 @@ static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd,
1136 return ret; 1168 return ret;
1137 } 1169 }
1138 rtd->dev_registered = 1; 1170 rtd->dev_registered = 1;
1139
1140 if (rtd->codec) {
1141 /* add DAPM sysfs entries for this codec */
1142 ret = snd_soc_dapm_sys_add(rtd->dev);
1143 if (ret < 0)
1144 dev_err(rtd->dev,
1145 "ASoC: failed to add codec dapm sysfs entries: %d\n",
1146 ret);
1147
1148 /* add codec sysfs entries */
1149 ret = device_create_file(rtd->dev, &dev_attr_codec_reg);
1150 if (ret < 0)
1151 dev_err(rtd->dev,
1152 "ASoC: failed to add codec sysfs files: %d\n",
1153 ret);
1154 }
1155
1156 return 0; 1171 return 0;
1157} 1172}
1158 1173
@@ -1308,11 +1323,6 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1308 } 1323 }
1309#endif 1324#endif
1310 1325
1311 ret = device_create_file(rtd->dev, &dev_attr_pmdown_time);
1312 if (ret < 0)
1313 dev_warn(rtd->dev, "ASoC: failed to add pmdown_time sysfs: %d\n",
1314 ret);
1315
1316 if (cpu_dai->driver->compress_dai) { 1326 if (cpu_dai->driver->compress_dai) {
1317 /*create compress_device"*/ 1327 /*create compress_device"*/
1318 ret = soc_new_compress(rtd, num); 1328 ret = soc_new_compress(rtd, num);
@@ -1640,9 +1650,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1640 } 1650 }
1641 } 1651 }
1642 1652
1643 if (card->fully_routed)
1644 snd_soc_dapm_auto_nc_pins(card);
1645
1646 snd_soc_dapm_new_widgets(card); 1653 snd_soc_dapm_new_widgets(card);
1647 1654
1648 ret = snd_card_register(card->snd_card); 1655 ret = snd_card_register(card->snd_card);
@@ -2400,8 +2407,8 @@ int snd_soc_unregister_card(struct snd_soc_card *card)
2400 card->instantiated = false; 2407 card->instantiated = false;
2401 snd_soc_dapm_shutdown(card); 2408 snd_soc_dapm_shutdown(card);
2402 soc_cleanup_card_resources(card); 2409 soc_cleanup_card_resources(card);
2410 dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
2403 } 2411 }
2404 dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
2405 2412
2406 return 0; 2413 return 0;
2407} 2414}
@@ -3244,7 +3251,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3244 const char *propname) 3251 const char *propname)
3245{ 3252{
3246 struct device_node *np = card->dev->of_node; 3253 struct device_node *np = card->dev->of_node;
3247 int num_routes, old_routes; 3254 int num_routes;
3248 struct snd_soc_dapm_route *routes; 3255 struct snd_soc_dapm_route *routes;
3249 int i, ret; 3256 int i, ret;
3250 3257
@@ -3262,9 +3269,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3262 return -EINVAL; 3269 return -EINVAL;
3263 } 3270 }
3264 3271
3265 old_routes = card->num_dapm_routes; 3272 routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
3266 routes = devm_kzalloc(card->dev,
3267 (old_routes + num_routes) * sizeof(*routes),
3268 GFP_KERNEL); 3273 GFP_KERNEL);
3269 if (!routes) { 3274 if (!routes) {
3270 dev_err(card->dev, 3275 dev_err(card->dev,
@@ -3272,11 +3277,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3272 return -EINVAL; 3277 return -EINVAL;
3273 } 3278 }
3274 3279
3275 memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes));
3276
3277 for (i = 0; i < num_routes; i++) { 3280 for (i = 0; i < num_routes; i++) {
3278 ret = of_property_read_string_index(np, propname, 3281 ret = of_property_read_string_index(np, propname,
3279 2 * i, &routes[old_routes + i].sink); 3282 2 * i, &routes[i].sink);
3280 if (ret) { 3283 if (ret) {
3281 dev_err(card->dev, 3284 dev_err(card->dev,
3282 "ASoC: Property '%s' index %d could not be read: %d\n", 3285 "ASoC: Property '%s' index %d could not be read: %d\n",
@@ -3284,7 +3287,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3284 return -EINVAL; 3287 return -EINVAL;
3285 } 3288 }
3286 ret = of_property_read_string_index(np, propname, 3289 ret = of_property_read_string_index(np, propname,
3287 (2 * i) + 1, &routes[old_routes + i].source); 3290 (2 * i) + 1, &routes[i].source);
3288 if (ret) { 3291 if (ret) {
3289 dev_err(card->dev, 3292 dev_err(card->dev,
3290 "ASoC: Property '%s' index %d could not be read: %d\n", 3293 "ASoC: Property '%s' index %d could not be read: %d\n",
@@ -3293,7 +3296,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3293 } 3296 }
3294 } 3297 }
3295 3298
3296 card->num_dapm_routes += num_routes; 3299 card->num_dapm_routes = num_routes;
3297 card->dapm_routes = routes; 3300 card->dapm_routes = routes;
3298 3301
3299 return 0; 3302 return 0;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index c5136bb1f982..b6f88202b8c9 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -517,8 +517,8 @@ static int soc_dapm_update_bits(struct snd_soc_dapm_context *dapm,
517{ 517{
518 if (!dapm->component) 518 if (!dapm->component)
519 return -EIO; 519 return -EIO;
520 return snd_soc_component_update_bits_async(dapm->component, reg, 520 return snd_soc_component_update_bits(dapm->component, reg,
521 mask, value); 521 mask, value);
522} 522}
523 523
524static int soc_dapm_test_bits(struct snd_soc_dapm_context *dapm, 524static int soc_dapm_test_bits(struct snd_soc_dapm_context *dapm,
@@ -2127,15 +2127,10 @@ static ssize_t dapm_widget_show(struct device *dev,
2127 2127
2128static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); 2128static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
2129 2129
2130int snd_soc_dapm_sys_add(struct device *dev) 2130struct attribute *soc_dapm_dev_attrs[] = {
2131{ 2131 &dev_attr_dapm_widget.attr,
2132 return device_create_file(dev, &dev_attr_dapm_widget); 2132 NULL
2133} 2133};
2134
2135static void snd_soc_dapm_sys_remove(struct device *dev)
2136{
2137 device_remove_file(dev, &dev_attr_dapm_widget);
2138}
2139 2134
2140static void dapm_free_path(struct snd_soc_dapm_path *path) 2135static void dapm_free_path(struct snd_soc_dapm_path *path)
2141{ 2136{
@@ -2279,6 +2274,9 @@ static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w)
2279 2274
2280 switch (w->id) { 2275 switch (w->id) {
2281 case snd_soc_dapm_input: 2276 case snd_soc_dapm_input:
2277 /* On a fully routed card a input is never a source */
2278 if (w->dapm->card->fully_routed)
2279 break;
2282 w->is_source = 1; 2280 w->is_source = 1;
2283 list_for_each_entry(p, &w->sources, list_sink) { 2281 list_for_each_entry(p, &w->sources, list_sink) {
2284 if (p->source->id == snd_soc_dapm_micbias || 2282 if (p->source->id == snd_soc_dapm_micbias ||
@@ -2291,6 +2289,9 @@ static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w)
2291 } 2289 }
2292 break; 2290 break;
2293 case snd_soc_dapm_output: 2291 case snd_soc_dapm_output:
2292 /* On a fully routed card a output is never a sink */
2293 if (w->dapm->card->fully_routed)
2294 break;
2294 w->is_sink = 1; 2295 w->is_sink = 1;
2295 list_for_each_entry(p, &w->sinks, list_source) { 2296 list_for_each_entry(p, &w->sinks, list_source) {
2296 if (p->sink->id == snd_soc_dapm_spk || 2297 if (p->sink->id == snd_soc_dapm_spk ||
@@ -3085,16 +3086,24 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
3085 3086
3086 switch (w->id) { 3087 switch (w->id) {
3087 case snd_soc_dapm_mic: 3088 case snd_soc_dapm_mic:
3088 case snd_soc_dapm_input:
3089 w->is_source = 1; 3089 w->is_source = 1;
3090 w->power_check = dapm_generic_check_power; 3090 w->power_check = dapm_generic_check_power;
3091 break; 3091 break;
3092 case snd_soc_dapm_input:
3093 if (!dapm->card->fully_routed)
3094 w->is_source = 1;
3095 w->power_check = dapm_generic_check_power;
3096 break;
3092 case snd_soc_dapm_spk: 3097 case snd_soc_dapm_spk:
3093 case snd_soc_dapm_hp: 3098 case snd_soc_dapm_hp:
3094 case snd_soc_dapm_output:
3095 w->is_sink = 1; 3099 w->is_sink = 1;
3096 w->power_check = dapm_generic_check_power; 3100 w->power_check = dapm_generic_check_power;
3097 break; 3101 break;
3102 case snd_soc_dapm_output:
3103 if (!dapm->card->fully_routed)
3104 w->is_sink = 1;
3105 w->power_check = dapm_generic_check_power;
3106 break;
3098 case snd_soc_dapm_vmid: 3107 case snd_soc_dapm_vmid:
3099 case snd_soc_dapm_siggen: 3108 case snd_soc_dapm_siggen:
3100 w->is_source = 1; 3109 w->is_source = 1;
@@ -3130,8 +3139,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
3130 } 3139 }
3131 3140
3132 w->dapm = dapm; 3141 w->dapm = dapm;
3133 if (dapm->component)
3134 w->codec = dapm->component->codec;
3135 INIT_LIST_HEAD(&w->sources); 3142 INIT_LIST_HEAD(&w->sources);
3136 INIT_LIST_HEAD(&w->sinks); 3143 INIT_LIST_HEAD(&w->sinks);
3137 INIT_LIST_HEAD(&w->list); 3144 INIT_LIST_HEAD(&w->list);
@@ -3809,93 +3816,6 @@ int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
3809EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend); 3816EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);
3810 3817
3811/** 3818/**
3812 * dapm_is_external_path() - Checks if a path is a external path
3813 * @card: The card the path belongs to
3814 * @path: The path to check
3815 *
3816 * Returns true if the path is either between two different DAPM contexts or
3817 * between two external pins of the same DAPM context. Otherwise returns
3818 * false.
3819 */
3820static bool dapm_is_external_path(struct snd_soc_card *card,
3821 struct snd_soc_dapm_path *path)
3822{
3823 dev_dbg(card->dev,
3824 "... Path %s(id:%d dapm:%p) - %s(id:%d dapm:%p)\n",
3825 path->source->name, path->source->id, path->source->dapm,
3826 path->sink->name, path->sink->id, path->sink->dapm);
3827
3828 /* Connection between two different DAPM contexts */
3829 if (path->source->dapm != path->sink->dapm)
3830 return true;
3831
3832 /* Loopback connection from external pin to external pin */
3833 if (path->sink->id == snd_soc_dapm_input) {
3834 switch (path->source->id) {
3835 case snd_soc_dapm_output:
3836 case snd_soc_dapm_micbias:
3837 return true;
3838 default:
3839 break;
3840 }
3841 }
3842
3843 return false;
3844}
3845
3846static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card,
3847 struct snd_soc_dapm_widget *w)
3848{
3849 struct snd_soc_dapm_path *p;
3850
3851 list_for_each_entry(p, &w->sources, list_sink) {
3852 if (dapm_is_external_path(card, p))
3853 return true;
3854 }
3855
3856 list_for_each_entry(p, &w->sinks, list_source) {
3857 if (dapm_is_external_path(card, p))
3858 return true;
3859 }
3860
3861 return false;
3862}
3863
3864/**
3865 * snd_soc_dapm_auto_nc_pins - call snd_soc_dapm_nc_pin for unused pins
3866 * @card: The card whose pins should be processed
3867 *
3868 * Automatically call snd_soc_dapm_nc_pin() for any external pins in the card
3869 * which are unused. Pins are used if they are connected externally to a
3870 * component, whether that be to some other device, or a loop-back connection to
3871 * the component itself.
3872 */
3873void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card)
3874{
3875 struct snd_soc_dapm_widget *w;
3876
3877 dev_dbg(card->dev, "ASoC: Auto NC: DAPMs: card:%p\n", &card->dapm);
3878
3879 list_for_each_entry(w, &card->widgets, list) {
3880 switch (w->id) {
3881 case snd_soc_dapm_input:
3882 case snd_soc_dapm_output:
3883 case snd_soc_dapm_micbias:
3884 dev_dbg(card->dev, "ASoC: Auto NC: Checking widget %s\n",
3885 w->name);
3886 if (!snd_soc_dapm_widget_in_card_paths(card, w)) {
3887 dev_dbg(card->dev,
3888 "... Not in map; disabling\n");
3889 snd_soc_dapm_nc_pin(w->dapm, w->name);
3890 }
3891 break;
3892 default:
3893 break;
3894 }
3895 }
3896}
3897
3898/**
3899 * snd_soc_dapm_free - free dapm resources 3819 * snd_soc_dapm_free - free dapm resources
3900 * @dapm: DAPM context 3820 * @dapm: DAPM context
3901 * 3821 *
@@ -3903,7 +3823,6 @@ void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card)
3903 */ 3823 */
3904void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm) 3824void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm)
3905{ 3825{
3906 snd_soc_dapm_sys_remove(dapm->dev);
3907 dapm_debugfs_cleanup(dapm); 3826 dapm_debugfs_cleanup(dapm);
3908 dapm_free_widgets(dapm); 3827 dapm_free_widgets(dapm);
3909 list_del(&dapm->list); 3828 list_del(&dapm->list);
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index b329b84bc5af..4864392bfcba 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -200,11 +200,6 @@ static int dmaengine_pcm_open(struct snd_pcm_substream *substream)
200 return snd_dmaengine_pcm_open(substream, chan); 200 return snd_dmaengine_pcm_open(substream, chan);
201} 201}
202 202
203static void dmaengine_pcm_free(struct snd_pcm *pcm)
204{
205 snd_pcm_lib_preallocate_free_for_all(pcm);
206}
207
208static struct dma_chan *dmaengine_pcm_compat_request_channel( 203static struct dma_chan *dmaengine_pcm_compat_request_channel(
209 struct snd_soc_pcm_runtime *rtd, 204 struct snd_soc_pcm_runtime *rtd,
210 struct snd_pcm_substream *substream) 205 struct snd_pcm_substream *substream)
@@ -283,8 +278,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
283 if (!pcm->chan[i]) { 278 if (!pcm->chan[i]) {
284 dev_err(rtd->platform->dev, 279 dev_err(rtd->platform->dev,
285 "Missing dma channel for stream: %d\n", i); 280 "Missing dma channel for stream: %d\n", i);
286 ret = -EINVAL; 281 return -EINVAL;
287 goto err_free;
288 } 282 }
289 283
290 ret = snd_pcm_lib_preallocate_pages(substream, 284 ret = snd_pcm_lib_preallocate_pages(substream,
@@ -293,7 +287,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
293 prealloc_buffer_size, 287 prealloc_buffer_size,
294 max_buffer_size); 288 max_buffer_size);
295 if (ret) 289 if (ret)
296 goto err_free; 290 return ret;
297 291
298 /* 292 /*
299 * This will only return false if we know for sure that at least 293 * This will only return false if we know for sure that at least
@@ -307,10 +301,6 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
307 } 301 }
308 302
309 return 0; 303 return 0;
310
311err_free:
312 dmaengine_pcm_free(rtd->pcm);
313 return ret;
314} 304}
315 305
316static snd_pcm_uframes_t dmaengine_pcm_pointer( 306static snd_pcm_uframes_t dmaengine_pcm_pointer(
@@ -341,7 +331,6 @@ static const struct snd_soc_platform_driver dmaengine_pcm_platform = {
341 }, 331 },
342 .ops = &dmaengine_pcm_ops, 332 .ops = &dmaengine_pcm_ops,
343 .pcm_new = dmaengine_pcm_new, 333 .pcm_new = dmaengine_pcm_new,
344 .pcm_free = dmaengine_pcm_free,
345}; 334};
346 335
347static const char * const dmaengine_pcm_dma_channel_names[] = { 336static const char * const dmaengine_pcm_dma_channel_names[] = {
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index eb87d96e2cf0..0ae0e2a9eed7 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -746,7 +746,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
746 codec_dai); 746 codec_dai);
747 if (ret < 0) { 747 if (ret < 0) {
748 dev_err(codec_dai->dev, 748 dev_err(codec_dai->dev,
749 "ASoC: DAI prepare error: %d\n", ret); 749 "ASoC: codec DAI prepare error: %d\n",
750 ret);
750 goto out; 751 goto out;
751 } 752 }
752 } 753 }
@@ -755,8 +756,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
755 if (cpu_dai->driver->ops && cpu_dai->driver->ops->prepare) { 756 if (cpu_dai->driver->ops && cpu_dai->driver->ops->prepare) {
756 ret = cpu_dai->driver->ops->prepare(substream, cpu_dai); 757 ret = cpu_dai->driver->ops->prepare(substream, cpu_dai);
757 if (ret < 0) { 758 if (ret < 0) {
758 dev_err(cpu_dai->dev, "ASoC: DAI prepare error: %d\n", 759 dev_err(cpu_dai->dev,
759 ret); 760 "ASoC: cpu DAI prepare error: %d\n", ret);
760 goto out; 761 goto out;
761 } 762 }
762 } 763 }