aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Pargmann <mpa@pengutronix.de>2014-04-28 06:54:48 -0400
committerMark Brown <broonie@linaro.org>2014-05-20 18:02:46 -0400
commit171d683d2ac4ab6f220cc99de08ef9ec2c039966 (patch)
treee6202c3334c5b58e26d8d79b2d836bff9e733a73
parent4d9b7926f2ce271e0670cf0e7131a0e2a686690a (diff)
ASoC: fsl-ssi: Remove unnecessary variables from ssi_private
There are some variables defined in struct fsl_ssi_private that describe states that are also described by other variables. This patch adds some helper functions that return exactly the same information based on available variables. This helps to clean up struct fsl_ssi_private and remove them from the probe function. It also removes some not really used variables (new_binding, name). Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Tested-By: Michael Grzeschik <mgr@pengutronix.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/fsl/fsl_ssi.c117
1 files changed, 64 insertions, 53 deletions
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index af1b82f09046..794f25fb8114 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -143,7 +143,6 @@ struct fsl_ssi_rxtx_reg_val {
143 * @cpu_dai: the CPU DAI for this device 143 * @cpu_dai: the CPU DAI for this device
144 * @dev_attr: the sysfs device attribute structure 144 * @dev_attr: the sysfs device attribute structure
145 * @stats: SSI statistics 145 * @stats: SSI statistics
146 * @name: name for this device
147 */ 146 */
148struct fsl_ssi_private { 147struct fsl_ssi_private {
149 struct ccsr_ssi __iomem *ssi; 148 struct ccsr_ssi __iomem *ssi;
@@ -152,14 +151,11 @@ struct fsl_ssi_private {
152 unsigned int fifo_depth; 151 unsigned int fifo_depth;
153 struct snd_soc_dai_driver cpu_dai_drv; 152 struct snd_soc_dai_driver cpu_dai_drv;
154 struct platform_device *pdev; 153 struct platform_device *pdev;
154 unsigned int dai_fmt;
155 155
156 enum fsl_ssi_type hw_type; 156 enum fsl_ssi_type hw_type;
157 bool new_binding;
158 bool ssi_on_imx;
159 bool imx_ac97;
160 bool use_dma; 157 bool use_dma;
161 bool baudclk_locked; 158 bool baudclk_locked;
162 bool offline_config;
163 bool use_dual_fifo; 159 bool use_dual_fifo;
164 u8 i2s_mode; 160 u8 i2s_mode;
165 spinlock_t baudclk_lock; 161 spinlock_t baudclk_lock;
@@ -172,8 +168,6 @@ struct fsl_ssi_private {
172 struct fsl_ssi_rxtx_reg_val rxtx_reg_val; 168 struct fsl_ssi_rxtx_reg_val rxtx_reg_val;
173 169
174 struct fsl_ssi_dbg dbg_stats; 170 struct fsl_ssi_dbg dbg_stats;
175
176 char name[1];
177}; 171};
178 172
179static const struct of_device_id fsl_ssi_ids[] = { 173static const struct of_device_id fsl_ssi_ids[] = {
@@ -185,6 +179,54 @@ static const struct of_device_id fsl_ssi_ids[] = {
185}; 179};
186MODULE_DEVICE_TABLE(of, fsl_ssi_ids); 180MODULE_DEVICE_TABLE(of, fsl_ssi_ids);
187 181
182static bool fsl_ssi_is_ac97(struct fsl_ssi_private *ssi_private)
183{
184 return !!(ssi_private->dai_fmt & SND_SOC_DAIFMT_AC97);
185}
186
187static bool fsl_ssi_on_imx(struct fsl_ssi_private *ssi_private)
188{
189 switch (ssi_private->hw_type) {
190 case FSL_SSI_MX21:
191 case FSL_SSI_MX35:
192 case FSL_SSI_MX51:
193 return true;
194 case FSL_SSI_MCP8610:
195 return false;
196 }
197
198 return false;
199}
200
201/*
202 * imx51 and later SoCs have a slightly different IP that allows the
203 * SSI configuration while the SSI unit is running.
204 *
205 * More important, it is necessary on those SoCs to configure the
206 * sperate TX/RX DMA bits just before starting the stream
207 * (fsl_ssi_trigger). The SDMA unit has to be configured before fsl_ssi
208 * sends any DMA requests to the SDMA unit, otherwise it is not defined
209 * how the SDMA unit handles the DMA request.
210 *
211 * SDMA units are present on devices starting at imx35 but the imx35
212 * reference manual states that the DMA bits should not be changed
213 * while the SSI unit is running (SSIEN). So we support the necessary
214 * online configuration of fsl-ssi starting at imx51.
215 */
216static bool fsl_ssi_offline_config(struct fsl_ssi_private *ssi_private)
217{
218 switch (ssi_private->hw_type) {
219 case FSL_SSI_MCP8610:
220 case FSL_SSI_MX21:
221 case FSL_SSI_MX35:
222 return true;
223 case FSL_SSI_MX51:
224 return false;
225 }
226
227 return true;
228}
229
188/** 230/**
189 * fsl_ssi_isr: SSI interrupt handler 231 * fsl_ssi_isr: SSI interrupt handler
190 * 232 *
@@ -317,7 +359,7 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,
317 * reconfiguration, so we have to enable all necessary flags at once 359 * reconfiguration, so we have to enable all necessary flags at once
318 * even if we do not use them later (capture and playback configuration) 360 * even if we do not use them later (capture and playback configuration)
319 */ 361 */
320 if (ssi_private->offline_config) { 362 if (fsl_ssi_offline_config(ssi_private)) {
321 if ((enable && !nr_active_streams) || 363 if ((enable && !nr_active_streams) ||
322 (!enable && !keep_active)) 364 (!enable && !keep_active))
323 fsl_ssi_rxtx_config(ssi_private, enable); 365 fsl_ssi_rxtx_config(ssi_private, enable);
@@ -393,7 +435,7 @@ static void fsl_ssi_setup_reg_vals(struct fsl_ssi_private *ssi_private)
393 reg->tx.stcr = CCSR_SSI_STCR_TFEN0; 435 reg->tx.stcr = CCSR_SSI_STCR_TFEN0;
394 reg->tx.scr = 0; 436 reg->tx.scr = 0;
395 437
396 if (!ssi_private->imx_ac97) { 438 if (!fsl_ssi_is_ac97(ssi_private)) {
397 reg->rx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE; 439 reg->rx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE;
398 reg->rx.sier |= CCSR_SSI_SIER_RFF0_EN; 440 reg->rx.sier |= CCSR_SSI_SIER_RFF0_EN;
399 reg->tx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE; 441 reg->tx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE;
@@ -458,7 +500,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
458 snd_soc_dai_get_drvdata(rtd->cpu_dai); 500 snd_soc_dai_get_drvdata(rtd->cpu_dai);
459 unsigned long flags; 501 unsigned long flags;
460 502
461 if (!dai->active && !ssi_private->imx_ac97) { 503 if (!dai->active && !fsl_ssi_is_ac97(ssi_private)) {
462 spin_lock_irqsave(&ssi_private->baudclk_lock, flags); 504 spin_lock_irqsave(&ssi_private->baudclk_lock, flags);
463 ssi_private->baudclk_locked = false; 505 ssi_private->baudclk_locked = false;
464 spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); 506 spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags);
@@ -524,7 +566,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
524 else 566 else
525 write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl); 567 write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl);
526 568
527 if (!ssi_private->imx_ac97) 569 if (!fsl_ssi_is_ac97(ssi_private))
528 write_ssi_mask(&ssi->scr, 570 write_ssi_mask(&ssi->scr,
529 CCSR_SSI_SCR_NET | CCSR_SSI_SCR_I2S_MODE_MASK, 571 CCSR_SSI_SCR_NET | CCSR_SSI_SCR_I2S_MODE_MASK,
530 channels == 1 ? 0 : ssi_private->i2s_mode); 572 channels == 1 ? 0 : ssi_private->i2s_mode);
@@ -542,6 +584,8 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
542 u32 strcr = 0, stcr, srcr, scr, mask; 584 u32 strcr = 0, stcr, srcr, scr, mask;
543 u8 wm; 585 u8 wm;
544 586
587 ssi_private->dai_fmt = fmt;
588
545 fsl_ssi_setup_reg_vals(ssi_private); 589 fsl_ssi_setup_reg_vals(ssi_private);
546 590
547 scr = read_ssi(&ssi->scr) & ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK); 591 scr = read_ssi(&ssi->scr) & ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK);
@@ -840,7 +884,7 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
840 else 884 else
841 fsl_ssi_rx_config(ssi_private, false); 885 fsl_ssi_rx_config(ssi_private, false);
842 886
843 if (!ssi_private->imx_ac97 && (read_ssi(&ssi->scr) & 887 if (!fsl_ssi_is_ac97(ssi_private) && (read_ssi(&ssi->scr) &
844 (CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE)) == 0) { 888 (CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE)) == 0) {
845 spin_lock_irqsave(&ssi_private->baudclk_lock, flags); 889 spin_lock_irqsave(&ssi_private->baudclk_lock, flags);
846 ssi_private->baudclk_locked = false; 890 ssi_private->baudclk_locked = false;
@@ -852,7 +896,7 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
852 return -EINVAL; 896 return -EINVAL;
853 } 897 }
854 898
855 if (ssi_private->imx_ac97) { 899 if (fsl_ssi_is_ac97(ssi_private)) {
856 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 900 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
857 write_ssi(CCSR_SSI_SOR_TX_CLR, &ssi->sor); 901 write_ssi(CCSR_SSI_SOR_TX_CLR, &ssi->sor);
858 else 902 else
@@ -866,7 +910,7 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai)
866{ 910{
867 struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(dai); 911 struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(dai);
868 912
869 if (ssi_private->ssi_on_imx && ssi_private->use_dma) { 913 if (fsl_ssi_on_imx(ssi_private) && ssi_private->use_dma) {
870 dai->playback_dma_data = &ssi_private->dma_params_tx; 914 dai->playback_dma_data = &ssi_private->dma_params_tx;
871 dai->capture_dma_data = &ssi_private->dma_params_rx; 915 dai->capture_dma_data = &ssi_private->dma_params_rx;
872 } 916 }
@@ -1135,7 +1179,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)
1135 sizeof(fsl_ssi_ac97_dai)); 1179 sizeof(fsl_ssi_ac97_dai));
1136 1180
1137 fsl_ac97_data = ssi_private; 1181 fsl_ac97_data = ssi_private;
1138 ssi_private->imx_ac97 = true;
1139 1182
1140 snd_soc_set_ac97_ops_of_reset(&fsl_ssi_ac97_ops, pdev); 1183 snd_soc_set_ac97_ops_of_reset(&fsl_ssi_ac97_ops, pdev);
1141 } else { 1184 } else {
@@ -1184,36 +1227,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
1184 1227
1185 dev_set_drvdata(&pdev->dev, ssi_private); 1228 dev_set_drvdata(&pdev->dev, ssi_private);
1186 1229
1187 /* 1230 if (fsl_ssi_on_imx(ssi_private)) {
1188 * imx51 and later SoCs have a slightly different IP that allows the
1189 * SSI configuration while the SSI unit is running.
1190 *
1191 * More important, it is necessary on those SoCs to configure the
1192 * sperate TX/RX DMA bits just before starting the stream
1193 * (fsl_ssi_trigger). The SDMA unit has to be configured before fsl_ssi
1194 * sends any DMA requests to the SDMA unit, otherwise it is not defined
1195 * how the SDMA unit handles the DMA request.
1196 *
1197 * SDMA units are present on devices starting at imx35 but the imx35
1198 * reference manual states that the DMA bits should not be changed
1199 * while the SSI unit is running (SSIEN). So we support the necessary
1200 * online configuration of fsl-ssi starting at imx51.
1201 */
1202 switch (hw_type) {
1203 case FSL_SSI_MCP8610:
1204 case FSL_SSI_MX21:
1205 case FSL_SSI_MX35:
1206 ssi_private->offline_config = true;
1207 break;
1208 case FSL_SSI_MX51:
1209 ssi_private->offline_config = false;
1210 break;
1211 }
1212
1213 if (hw_type == FSL_SSI_MX21 || hw_type == FSL_SSI_MX51 ||
1214 hw_type == FSL_SSI_MX35) {
1215 ssi_private->ssi_on_imx = true;
1216
1217 ret = fsl_ssi_imx_probe(pdev, ssi_private, ssi_private->ssi); 1231 ret = fsl_ssi_imx_probe(pdev, ssi_private, ssi_private->ssi);
1218 if (ret) 1232 if (ret)
1219 goto error_irqmap; 1233 goto error_irqmap;
@@ -1228,7 +1242,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
1228 1242
1229 if (ssi_private->use_dma) { 1243 if (ssi_private->use_dma) {
1230 ret = devm_request_irq(&pdev->dev, ssi_private->irq, 1244 ret = devm_request_irq(&pdev->dev, ssi_private->irq,
1231 fsl_ssi_isr, 0, ssi_private->name, 1245 fsl_ssi_isr, 0, dev_name(&pdev->dev),
1232 ssi_private); 1246 ssi_private);
1233 if (ret < 0) { 1247 if (ret < 0) {
1234 dev_err(&pdev->dev, "could not claim irq %u\n", 1248 dev_err(&pdev->dev, "could not claim irq %u\n",
@@ -1246,10 +1260,8 @@ static int fsl_ssi_probe(struct platform_device *pdev)
1246 * that the machine driver uses new binding which does not require 1260 * that the machine driver uses new binding which does not require
1247 * SSI driver to trigger machine driver's probe. 1261 * SSI driver to trigger machine driver's probe.
1248 */ 1262 */
1249 if (!of_get_property(np, "codec-handle", NULL)) { 1263 if (!of_get_property(np, "codec-handle", NULL))
1250 ssi_private->new_binding = true;
1251 goto done; 1264 goto done;
1252 }
1253 1265
1254 /* Trigger the machine driver's probe function. The platform driver 1266 /* Trigger the machine driver's probe function. The platform driver
1255 * name of the machine driver is taken from /compatible property of the 1267 * name of the machine driver is taken from /compatible property of the
@@ -1282,9 +1294,8 @@ error_irq:
1282 snd_soc_unregister_component(&pdev->dev); 1294 snd_soc_unregister_component(&pdev->dev);
1283 1295
1284error_asoc_register: 1296error_asoc_register:
1285 if (ssi_private->ssi_on_imx) { 1297 if (fsl_ssi_on_imx(ssi_private))
1286 fsl_ssi_imx_clean(pdev, ssi_private); 1298 fsl_ssi_imx_clean(pdev, ssi_private);
1287 }
1288 1299
1289error_irqmap: 1300error_irqmap:
1290 if (ssi_private->use_dma) 1301 if (ssi_private->use_dma)
@@ -1299,11 +1310,11 @@ static int fsl_ssi_remove(struct platform_device *pdev)
1299 1310
1300 fsl_ssi_debugfs_remove(&ssi_private->dbg_stats); 1311 fsl_ssi_debugfs_remove(&ssi_private->dbg_stats);
1301 1312
1302 if (!ssi_private->new_binding) 1313 if (ssi_private->pdev)
1303 platform_device_unregister(ssi_private->pdev); 1314 platform_device_unregister(ssi_private->pdev);
1304 snd_soc_unregister_component(&pdev->dev); 1315 snd_soc_unregister_component(&pdev->dev);
1305 1316
1306 if (ssi_private->ssi_on_imx) 1317 if (fsl_ssi_on_imx(ssi_private))
1307 fsl_ssi_imx_clean(pdev, ssi_private); 1318 fsl_ssi_imx_clean(pdev, ssi_private);
1308 1319
1309 if (ssi_private->use_dma) 1320 if (ssi_private->use_dma)