aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolin Chen <b42378@freescale.com>2013-11-18 04:54:01 -0500
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:47:15 -0400
commit59fd8b765267377d879e5e77035e4a4878d10610 (patch)
treee30b2f670b1b250e18b7f186c7adc0fe9e189929
parent8de20057e460c15e7dd6193349d99a3416d85e09 (diff)
ENGR00288421-3 ASoC: fsl_ssi: Move i2s_mode from static to ssi_private
It's no good to use static variable because there might be several drivers calling the function and the value would be overwritten by all of them. Thus we move it into ssi_private. Acked-by: Wang Shengjiu <b02247@freescale.com> Signed-off-by: Nicolin Chen <b42378@freescale.com>
-rw-r--r--sound/soc/fsl/fsl_ssi.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 68d84f0af67e..174578ccf9b8 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -142,6 +142,7 @@ struct fsl_ssi_private {
142 bool new_binding; 142 bool new_binding;
143 bool ssi_on_imx; 143 bool ssi_on_imx;
144 bool use_dual_fifo; 144 bool use_dual_fifo;
145 u8 i2s_mode;
145 struct clk *coreclk; 146 struct clk *coreclk;
146 struct clk *clk; 147 struct clk *clk;
147 struct snd_dmaengine_dai_dma_data dma_params_tx; 148 struct snd_dmaengine_dai_dma_data dma_params_tx;
@@ -372,9 +373,10 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
372 * 373 *
373 * FIXME: Little-endian samples require a different shift dir 374 * FIXME: Little-endian samples require a different shift dir
374 */ 375 */
376 ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE;
375 write_ssi_mask(&ssi->scr, 377 write_ssi_mask(&ssi->scr,
376 CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN, 378 CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN,
377 CCSR_SSI_SCR_TFR_CLK_DIS | CCSR_SSI_SCR_I2S_MODE_SLAVE 379 CCSR_SSI_SCR_TFR_CLK_DIS | ssi_private->i2s_mode
378 | (synchronous ? CCSR_SSI_SCR_SYN : 0)); 380 | (synchronous ? CCSR_SSI_SCR_SYN : 0));
379 381
380 write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | 382 write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 |
@@ -462,7 +464,6 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
462 u32 wl = CCSR_SSI_SxCCR_WL(sample_size); 464 u32 wl = CCSR_SSI_SxCCR_WL(sample_size);
463 int enabled = read_ssi(&ssi->scr) & CCSR_SSI_SCR_SSIEN; 465 int enabled = read_ssi(&ssi->scr) & CCSR_SSI_SCR_SSIEN;
464 unsigned int channels = params_channels(hw_params); 466 unsigned int channels = params_channels(hw_params);
465 static u8 i2s_mode;
466 int ret; 467 int ret;
467 468
468 /* 469 /*
@@ -497,19 +498,8 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
497 else 498 else
498 write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl); 499 write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl);
499 500
500 /* Save i2s mode configuration so that we can restore it later */ 501 write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_NET | CCSR_SSI_SCR_I2S_MODE_MASK,
501 switch (read_ssi(&ssi->scr) & CCSR_SSI_SCR_I2S_MODE_MASK) { 502 channels == 1 ? 0 : ssi_private->i2s_mode);
502 case CCSR_SSI_SCR_I2S_MODE_SLAVE:
503 case CCSR_SSI_SCR_I2S_MODE_MASTER:
504 i2s_mode = read_ssi(&ssi->scr) & CCSR_SSI_SCR_I2S_MODE_MASK;
505 default:
506 break;
507 }
508
509 write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_NET,
510 channels == 1 ? 0 : CCSR_SSI_SCR_NET);
511 write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_I2S_MODE_MASK,
512 channels == 1 ? 0 : i2s_mode);
513 503
514 return 0; 504 return 0;
515} 505}
@@ -589,18 +579,18 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
589 /* Pre-set SSI I2S mode */ 579 /* Pre-set SSI I2S mode */
590 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 580 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
591 case SND_SOC_DAIFMT_CBS_CFS: 581 case SND_SOC_DAIFMT_CBS_CFS:
592 scr &= ~CCSR_SSI_SCR_I2S_MODE_MASK; 582 ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_MASTER;
593 scr |= CCSR_SSI_SCR_I2S_MODE_MASTER;
594 break; 583 break;
595 case SND_SOC_DAIFMT_CBM_CFM: 584 case SND_SOC_DAIFMT_CBM_CFM:
596 scr &= ~CCSR_SSI_SCR_I2S_MODE_MASK; 585 ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE;
597 scr |= CCSR_SSI_SCR_I2S_MODE_SLAVE;
598 break; 586 break;
599 default: 587 default:
600 dev_err(cpu_dai->dev, "unsupported SND_SOC_DAIFMT_MASTER: %d", 588 dev_err(cpu_dai->dev, "unsupported SND_SOC_DAIFMT_MASTER: %d",
601 fmt & SND_SOC_DAIFMT_MASTER_MASK); 589 fmt & SND_SOC_DAIFMT_MASTER_MASK);
602 return -EINVAL; 590 return -EINVAL;
603 } 591 }
592 scr &= ~CCSR_SSI_SCR_I2S_MODE_MASK;
593 scr |= ssi_private->i2s_mode;
604 594
605 /* Data on rising edge of bclk, frame low, 1clk before data */ 595 /* Data on rising edge of bclk, frame low, 1clk before data */
606 strcr |= CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TSCKP 596 strcr |= CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TSCKP