summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolin Chen <nicoleotsuka@gmail.com>2017-12-17 21:52:10 -0500
committerMark Brown <broonie@kernel.org>2017-12-19 04:25:07 -0500
commit52eee84e815e0fbaf9ada848ab5646314a529b61 (patch)
treefc5737ae24c9127542f7fc9c0d39a3b536558874
parent8bc84a3344ca27836cff29bfbb42365753c9c557 (diff)
ASoC: fsl_ssi: Define ternary macros to simplify code
Some regmap code looks redudant. So simplify it. Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com> Tested-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Reviewed-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Acked-by: Timur Tabi <timur@tabi.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/fsl/fsl_ssi.c27
-rw-r--r--sound/soc/fsl/fsl_ssi.h4
2 files changed, 15 insertions, 16 deletions
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 2b3915c45199..aecd00f7929d 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -408,13 +408,10 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable)
408 */ 408 */
409static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) 409static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
410{ 410{
411 if (is_rx) { 411 bool tx = !is_rx;
412 regmap_update_bits(ssi->regs, REG_SSI_SOR, 412
413 SSI_SOR_RX_CLR, SSI_SOR_RX_CLR); 413 regmap_update_bits(ssi->regs, REG_SSI_SOR,
414 } else { 414 SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx));
415 regmap_update_bits(ssi->regs, REG_SSI_SOR,
416 SSI_SOR_TX_CLR, SSI_SOR_TX_CLR);
417 }
418} 415}
419 416
420/** 417/**
@@ -681,6 +678,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
681 struct snd_soc_dai *dai, 678 struct snd_soc_dai *dai,
682 struct snd_pcm_hw_params *hw_params) 679 struct snd_pcm_hw_params *hw_params)
683{ 680{
681 bool tx2, tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
684 struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai); 682 struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai);
685 struct regmap *regs = ssi->regs; 683 struct regmap *regs = ssi->regs;
686 int synchronous = ssi->cpu_dai_drv.symmetric_rates, ret; 684 int synchronous = ssi->cpu_dai_drv.symmetric_rates, ret;
@@ -768,10 +766,9 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
768 (psr ? SSI_SxCCR_PSR : 0); 766 (psr ? SSI_SxCCR_PSR : 0);
769 mask = SSI_SxCCR_PM_MASK | SSI_SxCCR_DIV2 | SSI_SxCCR_PSR; 767 mask = SSI_SxCCR_PM_MASK | SSI_SxCCR_DIV2 | SSI_SxCCR_PSR;
770 768
771 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || synchronous) 769 /* STCCR is used for RX in synchronous mode */
772 regmap_update_bits(regs, REG_SSI_STCCR, mask, stccr); 770 tx2 = tx || synchronous;
773 else 771 regmap_update_bits(regs, REG_SSI_SxCCR(tx2), mask, stccr);
774 regmap_update_bits(regs, REG_SSI_SRCCR, mask, stccr);
775 772
776 if (!baudclk_is_used) { 773 if (!baudclk_is_used) {
777 ret = clk_set_rate(ssi->baudclk, baudrate); 774 ret = clk_set_rate(ssi->baudclk, baudrate);
@@ -799,6 +796,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
799 struct snd_pcm_hw_params *hw_params, 796 struct snd_pcm_hw_params *hw_params,
800 struct snd_soc_dai *dai) 797 struct snd_soc_dai *dai)
801{ 798{
799 bool tx2, tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
802 struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai); 800 struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai);
803 struct regmap *regs = ssi->regs; 801 struct regmap *regs = ssi->regs;
804 unsigned int channels = params_channels(hw_params); 802 unsigned int channels = params_channels(hw_params);
@@ -849,11 +847,8 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
849 } 847 }
850 848
851 /* In synchronous mode, the SSI uses STCCR for capture */ 849 /* In synchronous mode, the SSI uses STCCR for capture */
852 if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) || 850 tx2 = tx || ssi->cpu_dai_drv.symmetric_rates;
853 ssi->cpu_dai_drv.symmetric_rates) 851 regmap_update_bits(regs, REG_SSI_SxCCR(tx2), SSI_SxCCR_WL_MASK, wl);
854 regmap_update_bits(regs, REG_SSI_STCCR, SSI_SxCCR_WL_MASK, wl);
855 else
856 regmap_update_bits(regs, REG_SSI_SRCCR, SSI_SxCCR_WL_MASK, wl);
857 852
858 return 0; 853 return 0;
859} 854}
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h
index b61008779e3c..de2fdc5db726 100644
--- a/sound/soc/fsl/fsl_ssi.h
+++ b/sound/soc/fsl/fsl_ssi.h
@@ -35,10 +35,12 @@
35#define REG_SSI_STCR 0x1c 35#define REG_SSI_STCR 0x1c
36/* SSI Receive Configuration Register */ 36/* SSI Receive Configuration Register */
37#define REG_SSI_SRCR 0x20 37#define REG_SSI_SRCR 0x20
38#define REG_SSI_SxCR(tx) ((tx) ? REG_SSI_STCR : REG_SSI_SRCR)
38/* SSI Transmit Clock Control Register */ 39/* SSI Transmit Clock Control Register */
39#define REG_SSI_STCCR 0x24 40#define REG_SSI_STCCR 0x24
40/* SSI Receive Clock Control Register */ 41/* SSI Receive Clock Control Register */
41#define REG_SSI_SRCCR 0x28 42#define REG_SSI_SRCCR 0x28
43#define REG_SSI_SxCCR(tx) ((tx) ? REG_SSI_STCCR : REG_SSI_SRCCR)
42/* SSI FIFO Control/Status Register */ 44/* SSI FIFO Control/Status Register */
43#define REG_SSI_SFCSR 0x2c 45#define REG_SSI_SFCSR 0x2c
44/* 46/*
@@ -67,6 +69,7 @@
67#define REG_SSI_STMSK 0x48 69#define REG_SSI_STMSK 0x48
68/* SSI Receive Time Slot Mask Register */ 70/* SSI Receive Time Slot Mask Register */
69#define REG_SSI_SRMSK 0x4c 71#define REG_SSI_SRMSK 0x4c
72#define REG_SSI_SxMSK(tx) ((tx) ? REG_SSI_STMSK : REG_SSI_SRMSK)
70/* 73/*
71 * SSI AC97 Channel Status Register 74 * SSI AC97 Channel Status Register
72 * 75 *
@@ -249,6 +252,7 @@
249#define SSI_SOR_CLKOFF 0x00000040 252#define SSI_SOR_CLKOFF 0x00000040
250#define SSI_SOR_RX_CLR 0x00000020 253#define SSI_SOR_RX_CLR 0x00000020
251#define SSI_SOR_TX_CLR 0x00000010 254#define SSI_SOR_TX_CLR 0x00000010
255#define SSI_SOR_xX_CLR(tx) ((tx) ? SSI_SOR_TX_CLR : SSI_SOR_RX_CLR)
252#define SSI_SOR_INIT 0x00000008 256#define SSI_SOR_INIT 0x00000008
253#define SSI_SOR_WAIT_SHIFT 1 257#define SSI_SOR_WAIT_SHIFT 1
254#define SSI_SOR_WAIT_MASK 0x00000006 258#define SSI_SOR_WAIT_MASK 0x00000006