aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Pargmann <mpa@pengutronix.de>2014-03-15 08:44:09 -0400
committerMark Brown <broonie@linaro.org>2014-04-14 12:26:46 -0400
commit2b0db996ba2d9b833c2bd2d73cbf301abe11c60e (patch)
tree158fb6ae2fb796c57bd87eebdff1be38fab3ca9f
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
ASoC: fsl-ssi: Remove fsl_ssi_setup
fsl_ssi_set_dai_fmt() manages most of the register setup routines now. fsl_ssi_setup() makes the same as fsl_ssi_set_dai_fmt() but it relies on DT properties. In most cases the settings of fsl_ssi_setup() are already overwritten by fsl_ssi_set_dai_fmt() when it is called by the soc-core when a sound card is added. As these settings depend on the combination of codec and cpu DAI, this should really be done by sound cards. This patch removes fsl_ssi_setup() and adds the missing register setups to fsl_ssi_set_dai_fmt(). It also removes all calls to fsl_ssi_setup(). Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/fsl/fsl_ssi.c143
1 files changed, 39 insertions, 104 deletions
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 5428a1fda260..144934eb9463 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -642,96 +642,6 @@ static void fsl_ssi_setup_ac97(struct fsl_ssi_private *ssi_private)
642 write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor); 642 write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor);
643} 643}
644 644
645static int fsl_ssi_setup(struct fsl_ssi_private *ssi_private)
646{
647 struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
648 u8 wm;
649 int synchronous = ssi_private->cpu_dai_drv.symmetric_rates;
650
651 fsl_ssi_setup_reg_vals(ssi_private);
652
653 if (ssi_private->imx_ac97)
654 ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL | CCSR_SSI_SCR_NET;
655 else
656 ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE;
657
658 /*
659 * Section 16.5 of the MPC8610 reference manual says that the SSI needs
660 * to be disabled before updating the registers we set here.
661 */
662 write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0);
663
664 /*
665 * Program the SSI into I2S Slave Non-Network Synchronous mode. Also
666 * enable the transmit and receive FIFO.
667 *
668 * FIXME: Little-endian samples require a different shift dir
669 */
670 write_ssi_mask(&ssi->scr,
671 CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN,
672 CCSR_SSI_SCR_TFR_CLK_DIS |
673 ssi_private->i2s_mode |
674 (synchronous ? CCSR_SSI_SCR_SYN : 0));
675
676 write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFSI |
677 CCSR_SSI_STCR_TEFS | CCSR_SSI_STCR_TSCKP, &ssi->stcr);
678
679 write_ssi(CCSR_SSI_SRCR_RXBIT0 | CCSR_SSI_SRCR_RFSI |
680 CCSR_SSI_SRCR_REFS | CCSR_SSI_SRCR_RSCKP, &ssi->srcr);
681
682 /*
683 * The DC and PM bits are only used if the SSI is the clock master.
684 */
685
686 /*
687 * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't
688 * use FIFO 1. We program the transmit water to signal a DMA transfer
689 * if there are only two (or fewer) elements left in the FIFO. Two
690 * elements equals one frame (left channel, right channel). This value,
691 * however, depends on the depth of the transmit buffer.
692 *
693 * We set the watermark on the same level as the DMA burstsize. For
694 * fiq it is probably better to use the biggest possible watermark
695 * size.
696 */
697 if (ssi_private->use_dma)
698 wm = ssi_private->fifo_depth - 2;
699 else
700 wm = ssi_private->fifo_depth;
701
702 write_ssi(CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) |
703 CCSR_SSI_SFCSR_TFWM1(wm) | CCSR_SSI_SFCSR_RFWM1(wm),
704 &ssi->sfcsr);
705
706 /*
707 * For ac97 interrupts are enabled with the startup of the substream
708 * because it is also running without an active substream. Normally SSI
709 * is only enabled when there is a substream.
710 */
711 if (ssi_private->imx_ac97)
712 fsl_ssi_setup_ac97(ssi_private);
713
714 /*
715 * Set a default slot number so that there is no need for those common
716 * cases like I2S mode to call the extra set_tdm_slot() any more.
717 */
718 if (!ssi_private->imx_ac97) {
719 write_ssi_mask(&ssi->stccr, CCSR_SSI_SxCCR_DC_MASK,
720 CCSR_SSI_SxCCR_DC(2));
721 write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_DC_MASK,
722 CCSR_SSI_SxCCR_DC(2));
723 }
724
725 if (ssi_private->use_dual_fifo) {
726 write_ssi_mask(&ssi->srcr, 0, CCSR_SSI_SRCR_RFEN1);
727 write_ssi_mask(&ssi->stcr, 0, CCSR_SSI_STCR_TFEN1);
728 write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_TCH_EN);
729 }
730
731 return 0;
732}
733
734
735/** 645/**
736 * fsl_ssi_startup: create a new substream 646 * fsl_ssi_startup: create a new substream
737 * 647 *
@@ -748,12 +658,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
748 snd_soc_dai_get_drvdata(rtd->cpu_dai); 658 snd_soc_dai_get_drvdata(rtd->cpu_dai);
749 unsigned long flags; 659 unsigned long flags;
750 660
751 /* First, we only do fsl_ssi_setup() when SSI is going to be active.
752 * Second, fsl_ssi_setup was already called by ac97_init earlier if
753 * the driver is in ac97 mode.
754 */
755 if (!dai->active && !ssi_private->imx_ac97) { 661 if (!dai->active && !ssi_private->imx_ac97) {
756 fsl_ssi_setup(ssi_private);
757 spin_lock_irqsave(&ssi_private->baudclk_lock, flags); 662 spin_lock_irqsave(&ssi_private->baudclk_lock, flags);
758 ssi_private->baudclk_locked = false; 663 ssi_private->baudclk_locked = false;
759 spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); 664 spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags);
@@ -835,6 +740,9 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
835 struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); 740 struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
836 struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 741 struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
837 u32 strcr = 0, stcr, srcr, scr, mask; 742 u32 strcr = 0, stcr, srcr, scr, mask;
743 u8 wm;
744
745 fsl_ssi_setup_reg_vals(ssi_private);
838 746
839 scr = read_ssi(&ssi->scr) & ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK); 747 scr = read_ssi(&ssi->scr) & ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK);
840 scr |= CCSR_SSI_SCR_NET; 748 scr |= CCSR_SSI_SCR_NET;
@@ -857,7 +765,6 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
857 default: 765 default:
858 return -EINVAL; 766 return -EINVAL;
859 } 767 }
860 scr |= ssi_private->i2s_mode;
861 768
862 /* Data on rising edge of bclk, frame low, 1clk before data */ 769 /* Data on rising edge of bclk, frame low, 1clk before data */
863 strcr |= CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TSCKP | 770 strcr |= CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TSCKP |
@@ -877,9 +784,13 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
877 strcr |= CCSR_SSI_STCR_TFSL | CCSR_SSI_STCR_TSCKP | 784 strcr |= CCSR_SSI_STCR_TFSL | CCSR_SSI_STCR_TSCKP |
878 CCSR_SSI_STCR_TXBIT0; 785 CCSR_SSI_STCR_TXBIT0;
879 break; 786 break;
787 case SND_SOC_DAIFMT_AC97:
788 ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL;
789 break;
880 default: 790 default:
881 return -EINVAL; 791 return -EINVAL;
882 } 792 }
793 scr |= ssi_private->i2s_mode;
883 794
884 /* DAI clock inversion */ 795 /* DAI clock inversion */
885 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 796 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -929,6 +840,38 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
929 write_ssi(srcr, &ssi->srcr); 840 write_ssi(srcr, &ssi->srcr);
930 write_ssi(scr, &ssi->scr); 841 write_ssi(scr, &ssi->scr);
931 842
843 /*
844 * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't
845 * use FIFO 1. We program the transmit water to signal a DMA transfer
846 * if there are only two (or fewer) elements left in the FIFO. Two
847 * elements equals one frame (left channel, right channel). This value,
848 * however, depends on the depth of the transmit buffer.
849 *
850 * We set the watermark on the same level as the DMA burstsize. For
851 * fiq it is probably better to use the biggest possible watermark
852 * size.
853 */
854 if (ssi_private->use_dma)
855 wm = ssi_private->fifo_depth - 2;
856 else
857 wm = ssi_private->fifo_depth;
858
859 write_ssi(CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) |
860 CCSR_SSI_SFCSR_TFWM1(wm) | CCSR_SSI_SFCSR_RFWM1(wm),
861 &ssi->sfcsr);
862
863 if (ssi_private->use_dual_fifo) {
864 write_ssi_mask(&ssi->srcr, CCSR_SSI_SRCR_RFEN1,
865 CCSR_SSI_SRCR_RFEN1);
866 write_ssi_mask(&ssi->stcr, CCSR_SSI_STCR_TFEN1,
867 CCSR_SSI_STCR_TFEN1);
868 write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TCH_EN,
869 CCSR_SSI_SCR_TCH_EN);
870 }
871
872 if (fmt & SND_SOC_DAIFMT_AC97)
873 fsl_ssi_setup_ac97(ssi_private);
874
932 return 0; 875 return 0;
933} 876}
934 877
@@ -1184,11 +1127,6 @@ static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
1184 1127
1185static struct fsl_ssi_private *fsl_ac97_data; 1128static struct fsl_ssi_private *fsl_ac97_data;
1186 1129
1187static void fsl_ssi_ac97_init(void)
1188{
1189 fsl_ssi_setup(fsl_ac97_data);
1190}
1191
1192static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, 1130static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
1193 unsigned short val) 1131 unsigned short val)
1194{ 1132{
@@ -1547,9 +1485,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)
1547 } 1485 }
1548 1486
1549done: 1487done:
1550 if (ssi_private->imx_ac97)
1551 fsl_ssi_ac97_init();
1552
1553 return 0; 1488 return 0;
1554 1489
1555error_dai: 1490error_dai: