| .. | .. |
|---|
| 203 | 203 | }; |
|---|
| 204 | 204 | |
|---|
| 205 | 205 | /** |
|---|
| 206 | | - * fsl_ssi: per-SSI private data |
|---|
| 207 | | - * |
|---|
| 206 | + * struct fsl_ssi - per-SSI private data |
|---|
| 208 | 207 | * @regs: Pointer to the regmap registers |
|---|
| 209 | 208 | * @irq: IRQ of this SSI |
|---|
| 210 | 209 | * @cpu_dai_drv: CPU DAI driver for this device |
|---|
| 211 | | - * |
|---|
| 212 | 210 | * @dai_fmt: DAI configuration this device is currently used with |
|---|
| 213 | 211 | * @streams: Mask of current active streams: BIT(TX) and BIT(RX) |
|---|
| 214 | 212 | * @i2s_net: I2S and Network mode configurations of SCR register |
|---|
| .. | .. |
|---|
| 221 | 219 | * @slot_width: Width of each DAI slot |
|---|
| 222 | 220 | * @slots: Number of slots |
|---|
| 223 | 221 | * @regvals: Specific RX/TX register settings |
|---|
| 224 | | - * |
|---|
| 225 | 222 | * @clk: Clock source to access register |
|---|
| 226 | 223 | * @baudclk: Clock source to generate bit and frame-sync clocks |
|---|
| 227 | 224 | * @baudclk_streams: Active streams that are using baudclk |
|---|
| 228 | | - * |
|---|
| 229 | 225 | * @regcache_sfcsr: Cache sfcsr register value during suspend and resume |
|---|
| 230 | 226 | * @regcache_sacnt: Cache sacnt register value during suspend and resume |
|---|
| 231 | | - * |
|---|
| 232 | 227 | * @dma_params_tx: DMA transmit parameters |
|---|
| 233 | 228 | * @dma_params_rx: DMA receive parameters |
|---|
| 234 | 229 | * @ssi_phys: physical address of the SSI registers |
|---|
| 235 | | - * |
|---|
| 236 | 230 | * @fiq_params: FIQ stream filtering parameters |
|---|
| 237 | | - * |
|---|
| 238 | 231 | * @card_pdev: Platform_device pointer to register a sound card for PowerPC or |
|---|
| 239 | 232 | * to register a CODEC platform device for AC97 |
|---|
| 240 | 233 | * @card_name: Platform_device name to register a sound card for PowerPC or |
|---|
| 241 | 234 | * to register a CODEC platform device for AC97 |
|---|
| 242 | 235 | * @card_idx: The index of SSI to register a sound card for PowerPC or |
|---|
| 243 | 236 | * to register a CODEC platform device for AC97 |
|---|
| 244 | | - * |
|---|
| 245 | 237 | * @dbg_stats: Debugging statistics |
|---|
| 246 | | - * |
|---|
| 247 | 238 | * @soc: SoC specific data |
|---|
| 248 | 239 | * @dev: Pointer to &pdev->dev |
|---|
| 249 | | - * |
|---|
| 250 | 240 | * @fifo_watermark: The FIFO watermark setting. Notifies DMA when there are |
|---|
| 251 | 241 | * @fifo_watermark or fewer words in TX fifo or |
|---|
| 252 | 242 | * @fifo_watermark or more empty words in RX fifo. |
|---|
| 253 | 243 | * @dma_maxburst: Max number of words to transfer in one go. So far, |
|---|
| 254 | 244 | * this is always the same as fifo_watermark. |
|---|
| 255 | | - * |
|---|
| 256 | 245 | * @ac97_reg_lock: Mutex lock to serialize AC97 register access operations |
|---|
| 257 | 246 | */ |
|---|
| 258 | 247 | struct fsl_ssi { |
|---|
| .. | .. |
|---|
| 374 | 363 | } |
|---|
| 375 | 364 | |
|---|
| 376 | 365 | /** |
|---|
| 377 | | - * Interrupt handler to gather states |
|---|
| 366 | + * fsl_ssi_irq - Interrupt handler to gather states |
|---|
| 367 | + * @irq: irq number |
|---|
| 368 | + * @dev_id: context |
|---|
| 378 | 369 | */ |
|---|
| 379 | 370 | static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) |
|---|
| 380 | 371 | { |
|---|
| .. | .. |
|---|
| 395 | 386 | } |
|---|
| 396 | 387 | |
|---|
| 397 | 388 | /** |
|---|
| 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 |
|---|
| 399 | 393 | * |
|---|
| 400 | 394 | * Notes: |
|---|
| 401 | 395 | * 1) For offline_config SoCs, enable all necessary bits of both streams |
|---|
| .. | .. |
|---|
| 474 | 468 | ssi->streams |= BIT(dir); |
|---|
| 475 | 469 | } |
|---|
| 476 | 470 | |
|---|
| 477 | | -/** |
|---|
| 471 | +/* |
|---|
| 478 | 472 | * Exclude bits that are used by the opposite stream |
|---|
| 479 | 473 | * |
|---|
| 480 | 474 | * When both streams are active, disabling some bits for the current stream |
|---|
| .. | .. |
|---|
| 495 | 489 | ((vals) & _ssi_xor_shared_bits(vals, avals, aactive)) |
|---|
| 496 | 490 | |
|---|
| 497 | 491 | /** |
|---|
| 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 |
|---|
| 499 | 496 | * |
|---|
| 500 | 497 | * Notes: |
|---|
| 501 | 498 | * 1) For offline_config SoCs, to avoid online reconfigurations, disable all |
|---|
| .. | .. |
|---|
| 577 | 574 | } |
|---|
| 578 | 575 | |
|---|
| 579 | 576 | /** |
|---|
| 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 |
|---|
| 581 | 580 | */ |
|---|
| 582 | 581 | static void fsl_ssi_setup_regvals(struct fsl_ssi *ssi) |
|---|
| 583 | 582 | { |
|---|
| .. | .. |
|---|
| 630 | 629 | static int fsl_ssi_startup(struct snd_pcm_substream *substream, |
|---|
| 631 | 630 | struct snd_soc_dai *dai) |
|---|
| 632 | 631 | { |
|---|
| 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)); |
|---|
| 635 | 634 | int ret; |
|---|
| 636 | 635 | |
|---|
| 637 | 636 | ret = clk_prepare_enable(ssi->clk); |
|---|
| .. | .. |
|---|
| 654 | 653 | static void fsl_ssi_shutdown(struct snd_pcm_substream *substream, |
|---|
| 655 | 654 | struct snd_soc_dai *dai) |
|---|
| 656 | 655 | { |
|---|
| 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)); |
|---|
| 659 | 658 | |
|---|
| 660 | 659 | clk_disable_unprepare(ssi->clk); |
|---|
| 661 | 660 | } |
|---|
| 662 | 661 | |
|---|
| 663 | 662 | /** |
|---|
| 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 |
|---|
| 665 | 667 | * |
|---|
| 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 |
|---|
| 667 | 669 | * |
|---|
| 668 | 670 | * Quick instruction for parameters: |
|---|
| 669 | 671 | * freq: Output BCLK frequency = samplerate * slots * slot_width |
|---|
| .. | .. |
|---|
| 782 | 784 | } |
|---|
| 783 | 785 | |
|---|
| 784 | 786 | /** |
|---|
| 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 |
|---|
| 786 | 791 | * |
|---|
| 787 | 792 | * Notes: |
|---|
| 788 | 793 | * 1) SxCCR.WL bits are critical bits that require SSI to be temporarily |
|---|
| .. | .. |
|---|
| 858 | 863 | static int fsl_ssi_hw_free(struct snd_pcm_substream *substream, |
|---|
| 859 | 864 | struct snd_soc_dai *dai) |
|---|
| 860 | 865 | { |
|---|
| 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)); |
|---|
| 863 | 868 | |
|---|
| 864 | 869 | if (fsl_ssi_is_i2s_master(ssi) && |
|---|
| 865 | 870 | ssi->baudclk_streams & BIT(substream->stream)) { |
|---|
| .. | .. |
|---|
| 894 | 899 | "missing baudclk for master mode\n"); |
|---|
| 895 | 900 | return -EINVAL; |
|---|
| 896 | 901 | } |
|---|
| 897 | | - /* fall through */ |
|---|
| 902 | + fallthrough; |
|---|
| 898 | 903 | case SND_SOC_DAIFMT_CBM_CFS: |
|---|
| 899 | 904 | ssi->i2s_net |= SSI_SCR_I2S_MODE_MASTER; |
|---|
| 900 | 905 | break; |
|---|
| .. | .. |
|---|
| 999 | 1004 | } |
|---|
| 1000 | 1005 | |
|---|
| 1001 | 1006 | /** |
|---|
| 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 |
|---|
| 1003 | 1010 | */ |
|---|
| 1004 | 1011 | static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
|---|
| 1005 | 1012 | { |
|---|
| .. | .. |
|---|
| 1013 | 1020 | } |
|---|
| 1014 | 1021 | |
|---|
| 1015 | 1022 | /** |
|---|
| 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 |
|---|
| 1017 | 1029 | */ |
|---|
| 1018 | 1030 | static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask, |
|---|
| 1019 | 1031 | u32 rx_mask, int slots, int slot_width) |
|---|
| .. | .. |
|---|
| 1057 | 1069 | } |
|---|
| 1058 | 1070 | |
|---|
| 1059 | 1071 | /** |
|---|
| 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 |
|---|
| 1061 | 1076 | * |
|---|
| 1062 | 1077 | * The DMA channel is in external master start and pause mode, which |
|---|
| 1063 | 1078 | * means the SSI completely controls the flow of data. |
|---|
| .. | .. |
|---|
| 1065 | 1080 | static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, |
|---|
| 1066 | 1081 | struct snd_soc_dai *dai) |
|---|
| 1067 | 1082 | { |
|---|
| 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)); |
|---|
| 1070 | 1085 | bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
|---|
| 1071 | 1086 | |
|---|
| 1072 | 1087 | switch (cmd) { |
|---|
| .. | .. |
|---|
| 1143 | 1158 | }; |
|---|
| 1144 | 1159 | |
|---|
| 1145 | 1160 | static struct snd_soc_dai_driver fsl_ssi_ac97_dai = { |
|---|
| 1146 | | - .bus_control = true, |
|---|
| 1147 | 1161 | .symmetric_channels = 1, |
|---|
| 1148 | 1162 | .probe = fsl_ssi_dai_probe, |
|---|
| 1149 | 1163 | .playback = { |
|---|
| .. | .. |
|---|
| 1242 | 1256 | }; |
|---|
| 1243 | 1257 | |
|---|
| 1244 | 1258 | /** |
|---|
| 1245 | | - * Initialize SSI registers |
|---|
| 1259 | + * fsl_ssi_hw_init - Initialize SSI registers |
|---|
| 1260 | + * @ssi: SSI context |
|---|
| 1246 | 1261 | */ |
|---|
| 1247 | 1262 | static int fsl_ssi_hw_init(struct fsl_ssi *ssi) |
|---|
| 1248 | 1263 | { |
|---|
| .. | .. |
|---|
| 1271 | 1286 | } |
|---|
| 1272 | 1287 | |
|---|
| 1273 | 1288 | /** |
|---|
| 1274 | | - * Clear SSI registers |
|---|
| 1289 | + * fsl_ssi_hw_clean - Clear SSI registers |
|---|
| 1290 | + * @ssi: SSI context |
|---|
| 1275 | 1291 | */ |
|---|
| 1276 | 1292 | static void fsl_ssi_hw_clean(struct fsl_ssi *ssi) |
|---|
| 1277 | 1293 | { |
|---|
| .. | .. |
|---|
| 1288 | 1304 | regmap_update_bits(ssi->regs, REG_SSI_SCR, SSI_SCR_SSIEN, 0); |
|---|
| 1289 | 1305 | } |
|---|
| 1290 | 1306 | } |
|---|
| 1291 | | -/** |
|---|
| 1307 | + |
|---|
| 1308 | +/* |
|---|
| 1292 | 1309 | * Make every character in a string lower-case |
|---|
| 1293 | 1310 | */ |
|---|
| 1294 | 1311 | static void make_lowercase(char *s) |
|---|
| .. | .. |
|---|
| 1517 | 1534 | } |
|---|
| 1518 | 1535 | |
|---|
| 1519 | 1536 | 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) |
|---|
| 1522 | 1538 | return ssi->irq; |
|---|
| 1523 | | - } |
|---|
| 1524 | 1539 | |
|---|
| 1525 | 1540 | /* Set software limitations for synchronous mode except AC97 */ |
|---|
| 1526 | 1541 | if (ssi->synchronous && !fsl_ssi_is_ac97(ssi)) { |
|---|
| .. | .. |
|---|
| 1589 | 1604 | } |
|---|
| 1590 | 1605 | } |
|---|
| 1591 | 1606 | |
|---|
| 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); |
|---|
| 1595 | 1608 | |
|---|
| 1596 | 1609 | /* Initially configures SSI registers */ |
|---|
| 1597 | 1610 | fsl_ssi_hw_init(ssi); |
|---|