forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/fsl/fsl_ssi.c
....@@ -203,12 +203,10 @@
203203 };
204204
205205 /**
206
- * fsl_ssi: per-SSI private data
207
- *
206
+ * struct fsl_ssi - per-SSI private data
208207 * @regs: Pointer to the regmap registers
209208 * @irq: IRQ of this SSI
210209 * @cpu_dai_drv: CPU DAI driver for this device
211
- *
212210 * @dai_fmt: DAI configuration this device is currently used with
213211 * @streams: Mask of current active streams: BIT(TX) and BIT(RX)
214212 * @i2s_net: I2S and Network mode configurations of SCR register
....@@ -221,38 +219,29 @@
221219 * @slot_width: Width of each DAI slot
222220 * @slots: Number of slots
223221 * @regvals: Specific RX/TX register settings
224
- *
225222 * @clk: Clock source to access register
226223 * @baudclk: Clock source to generate bit and frame-sync clocks
227224 * @baudclk_streams: Active streams that are using baudclk
228
- *
229225 * @regcache_sfcsr: Cache sfcsr register value during suspend and resume
230226 * @regcache_sacnt: Cache sacnt register value during suspend and resume
231
- *
232227 * @dma_params_tx: DMA transmit parameters
233228 * @dma_params_rx: DMA receive parameters
234229 * @ssi_phys: physical address of the SSI registers
235
- *
236230 * @fiq_params: FIQ stream filtering parameters
237
- *
238231 * @card_pdev: Platform_device pointer to register a sound card for PowerPC or
239232 * to register a CODEC platform device for AC97
240233 * @card_name: Platform_device name to register a sound card for PowerPC or
241234 * to register a CODEC platform device for AC97
242235 * @card_idx: The index of SSI to register a sound card for PowerPC or
243236 * to register a CODEC platform device for AC97
244
- *
245237 * @dbg_stats: Debugging statistics
246
- *
247238 * @soc: SoC specific data
248239 * @dev: Pointer to &pdev->dev
249
- *
250240 * @fifo_watermark: The FIFO watermark setting. Notifies DMA when there are
251241 * @fifo_watermark or fewer words in TX fifo or
252242 * @fifo_watermark or more empty words in RX fifo.
253243 * @dma_maxburst: Max number of words to transfer in one go. So far,
254244 * this is always the same as fifo_watermark.
255
- *
256245 * @ac97_reg_lock: Mutex lock to serialize AC97 register access operations
257246 */
258247 struct fsl_ssi {
....@@ -374,7 +363,9 @@
374363 }
375364
376365 /**
377
- * Interrupt handler to gather states
366
+ * fsl_ssi_irq - Interrupt handler to gather states
367
+ * @irq: irq number
368
+ * @dev_id: context
378369 */
379370 static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
380371 {
....@@ -395,7 +386,10 @@
395386 }
396387
397388 /**
398
- * Set SCR, SIER, STCR and SRCR registers with cached values in regvals
389
+ * fsl_ssi_config_enable - Set SCR, SIER, STCR and SRCR registers with
390
+ * cached values in regvals
391
+ * @ssi: SSI context
392
+ * @tx: direction
399393 *
400394 * Notes:
401395 * 1) For offline_config SoCs, enable all necessary bits of both streams
....@@ -474,7 +468,7 @@
474468 ssi->streams |= BIT(dir);
475469 }
476470
477
-/**
471
+/*
478472 * Exclude bits that are used by the opposite stream
479473 *
480474 * When both streams are active, disabling some bits for the current stream
....@@ -495,7 +489,10 @@
495489 ((vals) & _ssi_xor_shared_bits(vals, avals, aactive))
496490
497491 /**
498
- * Unset SCR, SIER, STCR and SRCR registers with cached values in regvals
492
+ * fsl_ssi_config_disable - Unset SCR, SIER, STCR and SRCR registers
493
+ * with cached values in regvals
494
+ * @ssi: SSI context
495
+ * @tx: direction
499496 *
500497 * Notes:
501498 * 1) For offline_config SoCs, to avoid online reconfigurations, disable all
....@@ -577,7 +574,9 @@
577574 }
578575
579576 /**
580
- * Cache critical bits of SIER, SRCR, STCR and SCR to later set them safely
577
+ * fsl_ssi_setup_regvals - Cache critical bits of SIER, SRCR, STCR and
578
+ * SCR to later set them safely
579
+ * @ssi: SSI context
581580 */
582581 static void fsl_ssi_setup_regvals(struct fsl_ssi *ssi)
583582 {
....@@ -630,8 +629,8 @@
630629 static int fsl_ssi_startup(struct snd_pcm_substream *substream,
631630 struct snd_soc_dai *dai)
632631 {
633
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
634
- struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);
632
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
633
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
635634 int ret;
636635
637636 ret = clk_prepare_enable(ssi->clk);
....@@ -654,16 +653,19 @@
654653 static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
655654 struct snd_soc_dai *dai)
656655 {
657
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
658
- struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);
656
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
657
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
659658
660659 clk_disable_unprepare(ssi->clk);
661660 }
662661
663662 /**
664
- * Configure Digital Audio Interface bit clock
663
+ * fsl_ssi_set_bclk - Configure Digital Audio Interface bit clock
664
+ * @substream: ASoC substream
665
+ * @dai: pointer to DAI
666
+ * @hw_params: pointers to hw_params
665667 *
666
- * Note: This function can be only called when using SSI as DAI master
668
+ * Notes: This function can be only called when using SSI as DAI master
667669 *
668670 * Quick instruction for parameters:
669671 * freq: Output BCLK frequency = samplerate * slots * slot_width
....@@ -782,7 +784,10 @@
782784 }
783785
784786 /**
785
- * Configure SSI based on PCM hardware parameters
787
+ * fsl_ssi_hw_params - Configure SSI based on PCM hardware parameters
788
+ * @substream: ASoC substream
789
+ * @hw_params: pointers to hw_params
790
+ * @dai: pointer to DAI
786791 *
787792 * Notes:
788793 * 1) SxCCR.WL bits are critical bits that require SSI to be temporarily
....@@ -858,8 +863,8 @@
858863 static int fsl_ssi_hw_free(struct snd_pcm_substream *substream,
859864 struct snd_soc_dai *dai)
860865 {
861
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
862
- struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);
866
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
867
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
863868
864869 if (fsl_ssi_is_i2s_master(ssi) &&
865870 ssi->baudclk_streams & BIT(substream->stream)) {
....@@ -894,7 +899,7 @@
894899 "missing baudclk for master mode\n");
895900 return -EINVAL;
896901 }
897
- /* fall through */
902
+ fallthrough;
898903 case SND_SOC_DAIFMT_CBM_CFS:
899904 ssi->i2s_net |= SSI_SCR_I2S_MODE_MASTER;
900905 break;
....@@ -999,7 +1004,9 @@
9991004 }
10001005
10011006 /**
1002
- * Configure Digital Audio Interface (DAI) Format
1007
+ * fsl_ssi_set_dai_fmt - Configure Digital Audio Interface (DAI) Format
1008
+ * @dai: pointer to DAI
1009
+ * @fmt: format mask
10031010 */
10041011 static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
10051012 {
....@@ -1013,7 +1020,12 @@
10131020 }
10141021
10151022 /**
1016
- * Set TDM slot number and slot width
1023
+ * fsl_ssi_set_dai_tdm_slot - Set TDM slot number and slot width
1024
+ * @dai: pointer to DAI
1025
+ * @tx_mask: mask for TX
1026
+ * @rx_mask: mask for RX
1027
+ * @slots: number of slots
1028
+ * @slot_width: number of bits per slot
10171029 */
10181030 static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask,
10191031 u32 rx_mask, int slots, int slot_width)
....@@ -1057,7 +1069,10 @@
10571069 }
10581070
10591071 /**
1060
- * Start or stop SSI and corresponding DMA transaction.
1072
+ * fsl_ssi_trigger - Start or stop SSI and corresponding DMA transaction.
1073
+ * @substream: ASoC substream
1074
+ * @cmd: trigger command
1075
+ * @dai: pointer to DAI
10611076 *
10621077 * The DMA channel is in external master start and pause mode, which
10631078 * means the SSI completely controls the flow of data.
....@@ -1065,8 +1080,8 @@
10651080 static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
10661081 struct snd_soc_dai *dai)
10671082 {
1068
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
1069
- struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);
1083
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1084
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
10701085 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
10711086
10721087 switch (cmd) {
....@@ -1143,7 +1158,6 @@
11431158 };
11441159
11451160 static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
1146
- .bus_control = true,
11471161 .symmetric_channels = 1,
11481162 .probe = fsl_ssi_dai_probe,
11491163 .playback = {
....@@ -1242,7 +1256,8 @@
12421256 };
12431257
12441258 /**
1245
- * Initialize SSI registers
1259
+ * fsl_ssi_hw_init - Initialize SSI registers
1260
+ * @ssi: SSI context
12461261 */
12471262 static int fsl_ssi_hw_init(struct fsl_ssi *ssi)
12481263 {
....@@ -1271,7 +1286,8 @@
12711286 }
12721287
12731288 /**
1274
- * Clear SSI registers
1289
+ * fsl_ssi_hw_clean - Clear SSI registers
1290
+ * @ssi: SSI context
12751291 */
12761292 static void fsl_ssi_hw_clean(struct fsl_ssi *ssi)
12771293 {
....@@ -1288,7 +1304,8 @@
12881304 regmap_update_bits(ssi->regs, REG_SSI_SCR, SSI_SCR_SSIEN, 0);
12891305 }
12901306 }
1291
-/**
1307
+
1308
+/*
12921309 * Make every character in a string lower-case
12931310 */
12941311 static void make_lowercase(char *s)
....@@ -1517,10 +1534,8 @@
15171534 }
15181535
15191536 ssi->irq = platform_get_irq(pdev, 0);
1520
- if (ssi->irq < 0) {
1521
- dev_err(dev, "no irq for node %s\n", pdev->name);
1537
+ if (ssi->irq < 0)
15221538 return ssi->irq;
1523
- }
15241539
15251540 /* Set software limitations for synchronous mode except AC97 */
15261541 if (ssi->synchronous && !fsl_ssi_is_ac97(ssi)) {
....@@ -1589,9 +1604,7 @@
15891604 }
15901605 }
15911606
1592
- ret = fsl_ssi_debugfs_create(&ssi->dbg_stats, dev);
1593
- if (ret)
1594
- goto error_asoc_register;
1607
+ fsl_ssi_debugfs_create(&ssi->dbg_stats, dev);
15951608
15961609 /* Initially configures SSI registers */
15971610 fsl_ssi_hw_init(ssi);