Lines Matching +full:spba +full:- +full:bus

1 // SPDX-License-Identifier: GPL-2.0
27 #include "imx-pcm.h"
99 * struct fsl_spdif_priv - Freescale SPDIF private data
117 * @spbaclk: SPBA clock (optional, depending on SoC design)
218 return (clk == STC_TXCLK_SPDIF_ROOT) && !spdif->soc->shared_root_clock; in fsl_spdif_can_set_clk_rate()
224 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_dpll_lock()
225 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_dpll_lock()
231 dev_dbg(&pdev->dev, "isr: Rx dpll %s \n", in spdif_irq_dpll_lock()
234 spdif_priv->dpll_locked = locked ? true : false; in spdif_irq_dpll_lock()
236 if (spdif_priv->snd_card && spdif_priv->rxrate_kcontrol) { in spdif_irq_dpll_lock()
237 snd_ctl_notify(spdif_priv->snd_card, in spdif_irq_dpll_lock()
239 &spdif_priv->rxrate_kcontrol->id); in spdif_irq_dpll_lock()
246 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_sym_error()
247 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_sym_error()
249 dev_dbg(&pdev->dev, "isr: receiver found illegal symbol\n"); in spdif_irq_sym_error()
252 if (!spdif_priv->dpll_locked) in spdif_irq_sym_error()
259 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_irq_uqrx_full()
260 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_uqrx_full()
261 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_uqrx_full()
266 pos = &ctrl->upos; in spdif_irq_uqrx_full()
271 pos = &ctrl->qpos; in spdif_irq_uqrx_full()
276 dev_err(&pdev->dev, "unsupported channel name\n"); in spdif_irq_uqrx_full()
280 dev_dbg(&pdev->dev, "isr: %c Channel receive register full\n", name); in spdif_irq_uqrx_full()
285 dev_err(&pdev->dev, "User bit receive buffer overflow\n"); in spdif_irq_uqrx_full()
290 ctrl->subcode[*pos++] = val >> 16; in spdif_irq_uqrx_full()
291 ctrl->subcode[*pos++] = val >> 8; in spdif_irq_uqrx_full()
292 ctrl->subcode[*pos++] = val; in spdif_irq_uqrx_full()
298 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_irq_uq_sync()
299 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_uq_sync()
301 dev_dbg(&pdev->dev, "isr: U/Q Channel sync found\n"); in spdif_irq_uq_sync()
304 if (ctrl->qpos == 0) in spdif_irq_uq_sync()
308 ctrl->ready_buf = (ctrl->qpos - 1) / SPDIF_QSUB_SIZE + 1; in spdif_irq_uq_sync()
314 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_irq_uq_err()
315 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_uq_err()
316 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_uq_err()
319 dev_dbg(&pdev->dev, "isr: U/Q Channel framing error\n"); in spdif_irq_uq_err()
326 ctrl->ready_buf = 0; in spdif_irq_uq_err()
327 ctrl->upos = 0; in spdif_irq_uq_err()
328 ctrl->qpos = 0; in spdif_irq_uq_err()
334 struct regmap *regmap = spdif_priv->regmap; in spdif_intr_status_clear()
348 struct platform_device *pdev = spdif_priv->pdev; in spdif_isr()
357 dev_dbg(&pdev->dev, "isr: Tx FIFO under/overrun\n"); in spdif_isr()
360 dev_dbg(&pdev->dev, "isr: Tx FIFO resync\n"); in spdif_isr()
363 dev_dbg(&pdev->dev, "isr: cstatus new\n"); in spdif_isr()
366 dev_dbg(&pdev->dev, "isr: validity flag no good\n"); in spdif_isr()
372 dev_dbg(&pdev->dev, "isr: receiver found parity bit error\n"); in spdif_isr()
378 dev_dbg(&pdev->dev, "isr: U Channel receive register overrun\n"); in spdif_isr()
384 dev_dbg(&pdev->dev, "isr: Q Channel receive register overrun\n"); in spdif_isr()
393 dev_dbg(&pdev->dev, "isr: Rx FIFO under/overrun\n"); in spdif_isr()
396 dev_dbg(&pdev->dev, "isr: Rx FIFO resync\n"); in spdif_isr()
403 dev_dbg(&pdev->dev, "isr: Tx FIFO empty\n"); in spdif_isr()
407 dev_dbg(&pdev->dev, "isr: Rx FIFO full\n"); in spdif_isr()
414 struct regmap *regmap = spdif_priv->regmap; in spdif_softreset()
427 } while ((val & SCR_SOFT_RESET) && cycle--); in spdif_softreset()
436 return -EBUSY; in spdif_softreset()
442 ctrl->ch_status[3] &= ~mask; in spdif_set_cstatus()
443 ctrl->ch_status[3] |= cstatus & mask; in spdif_set_cstatus()
448 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_write_channel_status()
449 struct regmap *regmap = spdif_priv->regmap; in spdif_write_channel_status()
450 struct platform_device *pdev = spdif_priv->pdev; in spdif_write_channel_status()
453 ch_status = (bitrev8(ctrl->ch_status[0]) << 16) | in spdif_write_channel_status()
454 (bitrev8(ctrl->ch_status[1]) << 8) | in spdif_write_channel_status()
455 bitrev8(ctrl->ch_status[2]); in spdif_write_channel_status()
458 dev_dbg(&pdev->dev, "STCSCH: 0x%06x\n", ch_status); in spdif_write_channel_status()
460 ch_status = bitrev8(ctrl->ch_status[3]) << 16; in spdif_write_channel_status()
463 dev_dbg(&pdev->dev, "STCSCL: 0x%06x\n", ch_status); in spdif_write_channel_status()
465 if (spdif_priv->soc->cchannel_192b) { in spdif_write_channel_status()
466 ch_status = (bitrev8(ctrl->ch_status[0]) << 24) | in spdif_write_channel_status()
467 (bitrev8(ctrl->ch_status[1]) << 16) | in spdif_write_channel_status()
468 (bitrev8(ctrl->ch_status[2]) << 8) | in spdif_write_channel_status()
469 bitrev8(ctrl->ch_status[3]); in spdif_write_channel_status()
487 struct regmap *regmap = spdif_priv->regmap; in spdif_set_rx_clksrc()
488 u8 clksrc = spdif_priv->rxclk_src; in spdif_set_rx_clksrc()
491 return -EINVAL; in spdif_set_rx_clksrc()
507 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_set_sample_rate()
508 struct regmap *regmap = spdif_priv->regmap; in spdif_set_sample_rate()
509 struct platform_device *pdev = spdif_priv->pdev; in spdif_set_sample_rate()
546 dev_err(&pdev->dev, "unsupported sample rate %d\n", sample_rate); in spdif_set_sample_rate()
547 return -EINVAL; in spdif_set_sample_rate()
554 clk = spdif_priv->txclk_src[rate]; in spdif_set_sample_rate()
556 dev_err(&pdev->dev, "tx clock source is out of range\n"); in spdif_set_sample_rate()
557 return -EINVAL; in spdif_set_sample_rate()
560 txclk_df = spdif_priv->txclk_df[rate]; in spdif_set_sample_rate()
562 dev_err(&pdev->dev, "the txclk_df can't be zero\n"); in spdif_set_sample_rate()
563 return -EINVAL; in spdif_set_sample_rate()
566 sysclk_df = spdif_priv->sysclk_df[rate]; in spdif_set_sample_rate()
572 ret = clk_set_rate(spdif_priv->txclk[clk], in spdif_set_sample_rate()
575 dev_err(&pdev->dev, "failed to set tx clock rate\n"); in spdif_set_sample_rate()
580 dev_dbg(&pdev->dev, "expected clock rate = %d\n", in spdif_set_sample_rate()
582 dev_dbg(&pdev->dev, "actual clock rate = %ld\n", in spdif_set_sample_rate()
583 clk_get_rate(spdif_priv->txclk[clk])); in spdif_set_sample_rate()
595 dev_dbg(&pdev->dev, "set sample rate to %dHz for %dHz playback\n", in spdif_set_sample_rate()
596 spdif_priv->txrate[rate], sample_rate); in spdif_set_sample_rate()
606 struct platform_device *pdev = spdif_priv->pdev; in fsl_spdif_startup()
607 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_startup()
615 dev_err(&pdev->dev, "failed to soft reset\n"); in fsl_spdif_startup()
623 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in fsl_spdif_startup()
648 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_shutdown()
651 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in fsl_spdif_shutdown()
675 struct platform_device *pdev = spdif_priv->pdev; in spdif_reparent_rootclk()
684 clk = spdif_priv->txclk[STC_TXCLK_SPDIF_ROOT]; in spdif_reparent_rootclk()
688 fsl_asoc_reparent_pll_clocks(&pdev->dev, clk, spdif_priv->pll8k_clk, in spdif_reparent_rootclk()
689 spdif_priv->pll11k_clk, sample_rate); in spdif_reparent_rootclk()
702 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_hw_params()
703 struct platform_device *pdev = spdif_priv->pdev; in fsl_spdif_hw_params()
707 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in fsl_spdif_hw_params()
710 dev_err(&pdev->dev, "%s: reparent root clk failed: %d\n", in fsl_spdif_hw_params()
717 dev_err(&pdev->dev, "%s: set sample rate failed: %d\n", in fsl_spdif_hw_params()
737 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_trigger()
738 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in fsl_spdif_trigger()
756 return -EINVAL; in fsl_spdif_trigger()
783 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in fsl_spdif_info()
784 uinfo->count = 1; in fsl_spdif_info()
794 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_pb_get()
796 uvalue->value.iec958.status[0] = ctrl->ch_status[0]; in fsl_spdif_pb_get()
797 uvalue->value.iec958.status[1] = ctrl->ch_status[1]; in fsl_spdif_pb_get()
798 uvalue->value.iec958.status[2] = ctrl->ch_status[2]; in fsl_spdif_pb_get()
799 uvalue->value.iec958.status[3] = ctrl->ch_status[3]; in fsl_spdif_pb_get()
809 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_pb_put()
811 ctrl->ch_status[0] = uvalue->value.iec958.status[0]; in fsl_spdif_pb_put()
812 ctrl->ch_status[1] = uvalue->value.iec958.status[1]; in fsl_spdif_pb_put()
813 ctrl->ch_status[2] = uvalue->value.iec958.status[2]; in fsl_spdif_pb_put()
814 ctrl->ch_status[3] = uvalue->value.iec958.status[3]; in fsl_spdif_pb_put()
827 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_capture_get()
832 return -EAGAIN; in fsl_spdif_capture_get()
835 ucontrol->value.iec958.status[0] = (cstatus >> 16) & 0xFF; in fsl_spdif_capture_get()
836 ucontrol->value.iec958.status[1] = (cstatus >> 8) & 0xFF; in fsl_spdif_capture_get()
837 ucontrol->value.iec958.status[2] = cstatus & 0xFF; in fsl_spdif_capture_get()
840 ucontrol->value.iec958.status[3] = (cstatus >> 16) & 0xFF; in fsl_spdif_capture_get()
841 ucontrol->value.iec958.status[4] = (cstatus >> 8) & 0xFF; in fsl_spdif_capture_get()
842 ucontrol->value.iec958.status[5] = cstatus & 0xFF; in fsl_spdif_capture_get()
859 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_subcode_get()
861 int ret = -EAGAIN; in fsl_spdif_subcode_get()
863 spin_lock_irqsave(&ctrl->ctl_lock, flags); in fsl_spdif_subcode_get()
864 if (ctrl->ready_buf) { in fsl_spdif_subcode_get()
865 int idx = (ctrl->ready_buf - 1) * SPDIF_UBITS_SIZE; in fsl_spdif_subcode_get()
866 memcpy(&ucontrol->value.iec958.subcode[0], in fsl_spdif_subcode_get()
867 &ctrl->subcode[idx], SPDIF_UBITS_SIZE); in fsl_spdif_subcode_get()
870 spin_unlock_irqrestore(&ctrl->ctl_lock, flags); in fsl_spdif_subcode_get()
875 /* Q-subcode information. The byte size is SPDIF_UBITS_SIZE/8 */
879 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in fsl_spdif_qinfo()
880 uinfo->count = SPDIF_QSUB_SIZE; in fsl_spdif_qinfo()
891 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_qget()
893 int ret = -EAGAIN; in fsl_spdif_qget()
895 spin_lock_irqsave(&ctrl->ctl_lock, flags); in fsl_spdif_qget()
896 if (ctrl->ready_buf) { in fsl_spdif_qget()
897 int idx = (ctrl->ready_buf - 1) * SPDIF_QSUB_SIZE; in fsl_spdif_qget()
898 memcpy(&ucontrol->value.bytes.data[0], in fsl_spdif_qget()
899 &ctrl->qsub[idx], SPDIF_QSUB_SIZE); in fsl_spdif_qget()
902 spin_unlock_irqrestore(&ctrl->ctl_lock, flags); in fsl_spdif_qget()
913 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_rx_vbit_get()
917 ucontrol->value.integer.value[0] = (val & INT_VAL_NOGOOD) != 0; in fsl_spdif_rx_vbit_get()
928 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_tx_vbit_get()
933 val = 1 - val; in fsl_spdif_tx_vbit_get()
934 ucontrol->value.integer.value[0] = val; in fsl_spdif_tx_vbit_get()
944 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_tx_vbit_put()
945 u32 val = (1 - ucontrol->value.integer.value[0]) << SCR_VAL_OFFSET; in fsl_spdif_tx_vbit_put()
957 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_rx_rcm_get()
962 ucontrol->value.integer.value[0] = val; in fsl_spdif_rx_rcm_get()
972 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_rx_rcm_put()
973 u32 val = (ucontrol->value.integer.value[0] ? SCR_RAW_CAPTURE_MODE : 0); in fsl_spdif_rx_rcm_put()
976 cpu_dai->driver->capture.formats |= SNDRV_PCM_FMTBIT_S32_LE; in fsl_spdif_rx_rcm_put()
978 cpu_dai->driver->capture.formats &= ~SNDRV_PCM_FMTBIT_S32_LE; in fsl_spdif_rx_rcm_put()
991 ucontrol->value.integer.value[0] = priv->bypass ? 1 : 0; in fsl_spdif_bypass_get()
1001 struct snd_soc_card *card = dai->component->card; in fsl_spdif_bypass_put()
1002 bool set = (ucontrol->value.integer.value[0] != 0); in fsl_spdif_bypass_put()
1003 struct regmap *regmap = priv->regmap; in fsl_spdif_bypass_put()
1008 rtd = snd_soc_get_pcm_runtime(card, card->dai_link); in fsl_spdif_bypass_put()
1010 if (priv->bypass == set) in fsl_spdif_bypass_put()
1014 dev_err(dai->dev, "Cannot change BYPASS mode while stream is running.\n"); in fsl_spdif_bypass_put()
1015 return -EBUSY; in fsl_spdif_bypass_put()
1018 pm_runtime_get_sync(dai->dev); in fsl_spdif_bypass_put()
1040 rtd->pcm->streams[stream].substream_count = (set ? 0 : 1); in fsl_spdif_bypass_put()
1042 priv->bypass = set; in fsl_spdif_bypass_put()
1043 pm_runtime_put_sync(dai->dev); in fsl_spdif_bypass_put()
1052 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in fsl_spdif_rxrate_info()
1053 uinfo->count = 1; in fsl_spdif_rxrate_info()
1054 uinfo->value.integer.min = 16000; in fsl_spdif_rxrate_info()
1055 uinfo->value.integer.max = 192000; in fsl_spdif_rxrate_info()
1068 struct regmap *regmap = spdif_priv->regmap; in spdif_get_rxclk_rate()
1069 struct platform_device *pdev = spdif_priv->pdev; in spdif_get_rxclk_rate()
1079 /* Get bus clock from system */ in spdif_get_rxclk_rate()
1081 busclk_freq = clk_get_rate(spdif_priv->sysclk); in spdif_get_rxclk_rate()
1088 dev_dbg(&pdev->dev, "FreqMeas: %d\n", freqmeas); in spdif_get_rxclk_rate()
1089 dev_dbg(&pdev->dev, "BusclkFreq: %lld\n", busclk_freq); in spdif_get_rxclk_rate()
1090 dev_dbg(&pdev->dev, "RxRate: %lld\n", tmpval64); in spdif_get_rxclk_rate()
1107 if (spdif_priv->dpll_locked) in fsl_spdif_rxrate_get()
1110 ucontrol->value.integer.value[0] = rate; in fsl_spdif_rxrate_get()
1118 * 0 Non-CD data
1125 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_usync_get()
1129 ucontrol->value.integer.value[0] = (val & SRCD_CD_USER) != 0; in fsl_spdif_usync_get()
1137 * 0 Non-CD data
1144 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_usync_put()
1145 u32 val = ucontrol->value.integer.value[0] << SRCD_CD_USER_OFFSET; in fsl_spdif_usync_put()
1184 .name = "IEC958 Q-subcode Capture Default",
1193 .name = "IEC958 RX V-Bit Errors",
1201 .name = "IEC958 TX V-Bit",
1257 snd_soc_dai_init_dma_data(dai, &spdif_private->dma_params_tx, in fsl_spdif_dai_probe()
1258 &spdif_private->dma_params_rx); in fsl_spdif_dai_probe()
1262 if (spdif_private->soc->raw_capture_mode) in fsl_spdif_dai_probe()
1266 spdif_private->snd_card = dai->component->card->snd_card; in fsl_spdif_dai_probe()
1267 spdif_private->rxrate_kcontrol = snd_soc_card_get_kcontrol(dai->component->card, in fsl_spdif_dai_probe()
1269 if (!spdif_private->rxrate_kcontrol) in fsl_spdif_dai_probe()
1270 dev_err(&spdif_private->pdev->dev, "failed to get %s kcontrol\n", in fsl_spdif_dai_probe()
1274 regmap_update_bits(spdif_private->regmap, REG_SPDIF_SCR, in fsl_spdif_dai_probe()
1283 .stream_name = "CPU-Playback",
1290 .stream_name = "CPU-Capture",
1300 .name = "fsl-spdif",
1427 bool is_sysclk = clk_is_match(clk, spdif_priv->sysclk); in fsl_spdif_txclk_caldiv()
1451 spdif_priv->txclk_df[index] = txclk_df; in fsl_spdif_txclk_caldiv()
1452 spdif_priv->sysclk_df[index] = sysclk_df; in fsl_spdif_txclk_caldiv()
1453 spdif_priv->txrate[index] = arate; in fsl_spdif_txclk_caldiv()
1457 sub = (u64)(arate - rate[index]) * 100000; in fsl_spdif_txclk_caldiv()
1462 spdif_priv->txclk_df[index] = txclk_df; in fsl_spdif_txclk_caldiv()
1463 spdif_priv->sysclk_df[index] = sysclk_df; in fsl_spdif_txclk_caldiv()
1464 spdif_priv->txrate[index] = arate; in fsl_spdif_txclk_caldiv()
1467 sub = (u64)(rate[index] - arate) * 100000; in fsl_spdif_txclk_caldiv()
1472 spdif_priv->txclk_df[index] = txclk_df; in fsl_spdif_txclk_caldiv()
1473 spdif_priv->sysclk_df[index] = sysclk_df; in fsl_spdif_txclk_caldiv()
1474 spdif_priv->txrate[index] = arate; in fsl_spdif_txclk_caldiv()
1488 struct platform_device *pdev = spdif_priv->pdev; in fsl_spdif_probe_txclk()
1489 struct device *dev = &pdev->dev; in fsl_spdif_probe_txclk()
1495 clk = spdif_priv->txclk[i]; in fsl_spdif_probe_txclk()
1509 spdif_priv->txclk_src[index] = i; in fsl_spdif_probe_txclk()
1517 spdif_priv->txclk_src[index], rate[index]); in fsl_spdif_probe_txclk()
1519 spdif_priv->txclk_df[index], rate[index]); in fsl_spdif_probe_txclk()
1520 if (clk_is_match(spdif_priv->txclk[spdif_priv->txclk_src[index]], spdif_priv->sysclk)) in fsl_spdif_probe_txclk()
1522 spdif_priv->sysclk_df[index], rate[index]); in fsl_spdif_probe_txclk()
1524 rate[index], spdif_priv->txrate[index]); in fsl_spdif_probe_txclk()
1538 spdif_priv = devm_kzalloc(&pdev->dev, sizeof(*spdif_priv), GFP_KERNEL); in fsl_spdif_probe()
1540 return -ENOMEM; in fsl_spdif_probe()
1542 spdif_priv->pdev = pdev; in fsl_spdif_probe()
1544 spdif_priv->soc = of_device_get_match_data(&pdev->dev); in fsl_spdif_probe()
1547 memcpy(&spdif_priv->cpu_dai_drv, &fsl_spdif_dai, sizeof(fsl_spdif_dai)); in fsl_spdif_probe()
1548 spdif_priv->cpu_dai_drv.name = dev_name(&pdev->dev); in fsl_spdif_probe()
1549 spdif_priv->cpu_dai_drv.playback.formats = in fsl_spdif_probe()
1550 spdif_priv->soc->tx_formats; in fsl_spdif_probe()
1557 spdif_priv->regmap = devm_regmap_init_mmio(&pdev->dev, regs, &fsl_spdif_regmap_config); in fsl_spdif_probe()
1558 if (IS_ERR(spdif_priv->regmap)) { in fsl_spdif_probe()
1559 dev_err(&pdev->dev, "regmap init failed\n"); in fsl_spdif_probe()
1560 return PTR_ERR(spdif_priv->regmap); in fsl_spdif_probe()
1563 for (i = 0; i < spdif_priv->soc->interrupts; i++) { in fsl_spdif_probe()
1568 ret = devm_request_irq(&pdev->dev, irq, spdif_isr, 0, in fsl_spdif_probe()
1569 dev_name(&pdev->dev), spdif_priv); in fsl_spdif_probe()
1571 dev_err(&pdev->dev, "could not claim irq %u\n", irq); in fsl_spdif_probe()
1578 spdif_priv->txclk[i] = devm_clk_get(&pdev->dev, tmp); in fsl_spdif_probe()
1579 if (IS_ERR(spdif_priv->txclk[i])) { in fsl_spdif_probe()
1580 dev_err(&pdev->dev, "no rxtx%d clock in devicetree\n", i); in fsl_spdif_probe()
1581 return PTR_ERR(spdif_priv->txclk[i]); in fsl_spdif_probe()
1586 spdif_priv->sysclk = spdif_priv->txclk[5]; in fsl_spdif_probe()
1587 if (IS_ERR(spdif_priv->sysclk)) { in fsl_spdif_probe()
1588 dev_err(&pdev->dev, "no sys clock (rxtx5) in devicetree\n"); in fsl_spdif_probe()
1589 return PTR_ERR(spdif_priv->sysclk); in fsl_spdif_probe()
1593 spdif_priv->coreclk = devm_clk_get(&pdev->dev, "core"); in fsl_spdif_probe()
1594 if (IS_ERR(spdif_priv->coreclk)) { in fsl_spdif_probe()
1595 dev_err(&pdev->dev, "no core clock in devicetree\n"); in fsl_spdif_probe()
1596 return PTR_ERR(spdif_priv->coreclk); in fsl_spdif_probe()
1599 spdif_priv->spbaclk = devm_clk_get(&pdev->dev, "spba"); in fsl_spdif_probe()
1600 if (IS_ERR(spdif_priv->spbaclk)) in fsl_spdif_probe()
1601 dev_warn(&pdev->dev, "no spba clock in devicetree\n"); in fsl_spdif_probe()
1604 spdif_priv->rxclk = spdif_priv->txclk[1]; in fsl_spdif_probe()
1605 if (IS_ERR(spdif_priv->rxclk)) { in fsl_spdif_probe()
1606 dev_err(&pdev->dev, "no rxtx1 clock in devicetree\n"); in fsl_spdif_probe()
1607 return PTR_ERR(spdif_priv->rxclk); in fsl_spdif_probe()
1609 spdif_priv->rxclk_src = DEFAULT_RXCLK_SRC; in fsl_spdif_probe()
1611 fsl_asoc_get_pll_clocks(&pdev->dev, &spdif_priv->pll8k_clk, in fsl_spdif_probe()
1612 &spdif_priv->pll11k_clk); in fsl_spdif_probe()
1615 ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_probe()
1616 spin_lock_init(&ctrl->ctl_lock); in fsl_spdif_probe()
1619 ctrl->ch_status[0] = IEC958_AES0_CON_NOT_COPYRIGHT | in fsl_spdif_probe()
1621 ctrl->ch_status[1] = IEC958_AES1_CON_DIGDIGCONV_ID; in fsl_spdif_probe()
1622 ctrl->ch_status[2] = 0x00; in fsl_spdif_probe()
1623 ctrl->ch_status[3] = IEC958_AES3_CON_FS_44100 | in fsl_spdif_probe()
1626 spdif_priv->dpll_locked = false; in fsl_spdif_probe()
1628 spdif_priv->dma_params_tx.maxburst = spdif_priv->soc->tx_burst; in fsl_spdif_probe()
1629 spdif_priv->dma_params_rx.maxburst = spdif_priv->soc->rx_burst; in fsl_spdif_probe()
1630 spdif_priv->dma_params_tx.addr = res->start + REG_SPDIF_STL; in fsl_spdif_probe()
1631 spdif_priv->dma_params_rx.addr = res->start + REG_SPDIF_SRL; in fsl_spdif_probe()
1634 dev_set_drvdata(&pdev->dev, spdif_priv); in fsl_spdif_probe()
1635 pm_runtime_enable(&pdev->dev); in fsl_spdif_probe()
1636 regcache_cache_only(spdif_priv->regmap, true); in fsl_spdif_probe()
1644 dev_err_probe(&pdev->dev, ret, "imx_pcm_dma_init failed\n"); in fsl_spdif_probe()
1648 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_spdif_component, in fsl_spdif_probe()
1649 &spdif_priv->cpu_dai_drv, 1); in fsl_spdif_probe()
1651 dev_err(&pdev->dev, "failed to register DAI: %d\n", ret); in fsl_spdif_probe()
1658 pm_runtime_disable(&pdev->dev); in fsl_spdif_probe()
1664 pm_runtime_disable(&pdev->dev); in fsl_spdif_remove()
1676 regmap_update_bits(spdif_priv->regmap, REG_SPDIF_SIE, 0xffffff, 0); in fsl_spdif_runtime_suspend()
1678 regmap_read(spdif_priv->regmap, REG_SPDIF_SRPC, in fsl_spdif_runtime_suspend()
1679 &spdif_priv->regcache_srpc); in fsl_spdif_runtime_suspend()
1680 regcache_cache_only(spdif_priv->regmap, true); in fsl_spdif_runtime_suspend()
1683 clk_disable_unprepare(spdif_priv->txclk[i]); in fsl_spdif_runtime_suspend()
1685 if (!IS_ERR(spdif_priv->spbaclk)) in fsl_spdif_runtime_suspend()
1686 clk_disable_unprepare(spdif_priv->spbaclk); in fsl_spdif_runtime_suspend()
1687 clk_disable_unprepare(spdif_priv->coreclk); in fsl_spdif_runtime_suspend()
1698 ret = clk_prepare_enable(spdif_priv->coreclk); in fsl_spdif_runtime_resume()
1704 if (!IS_ERR(spdif_priv->spbaclk)) { in fsl_spdif_runtime_resume()
1705 ret = clk_prepare_enable(spdif_priv->spbaclk); in fsl_spdif_runtime_resume()
1707 dev_err(dev, "failed to enable spba clock\n"); in fsl_spdif_runtime_resume()
1713 ret = clk_prepare_enable(spdif_priv->txclk[i]); in fsl_spdif_runtime_resume()
1718 regcache_cache_only(spdif_priv->regmap, false); in fsl_spdif_runtime_resume()
1719 regcache_mark_dirty(spdif_priv->regmap); in fsl_spdif_runtime_resume()
1721 regmap_update_bits(spdif_priv->regmap, REG_SPDIF_SRPC, in fsl_spdif_runtime_resume()
1723 spdif_priv->regcache_srpc); in fsl_spdif_runtime_resume()
1725 ret = regcache_sync(spdif_priv->regmap); in fsl_spdif_runtime_resume()
1732 for (i--; i >= 0; i--) in fsl_spdif_runtime_resume()
1733 clk_disable_unprepare(spdif_priv->txclk[i]); in fsl_spdif_runtime_resume()
1734 if (!IS_ERR(spdif_priv->spbaclk)) in fsl_spdif_runtime_resume()
1735 clk_disable_unprepare(spdif_priv->spbaclk); in fsl_spdif_runtime_resume()
1737 clk_disable_unprepare(spdif_priv->coreclk); in fsl_spdif_runtime_resume()
1751 { .compatible = "fsl,imx35-spdif", .data = &fsl_spdif_imx35, },
1752 { .compatible = "fsl,vf610-spdif", .data = &fsl_spdif_vf610, },
1753 { .compatible = "fsl,imx6sx-spdif", .data = &fsl_spdif_imx6sx, },
1754 { .compatible = "fsl,imx8qm-spdif", .data = &fsl_spdif_imx8qm, },
1755 { .compatible = "fsl,imx8mm-spdif", .data = &fsl_spdif_imx8mm, },
1756 { .compatible = "fsl,imx8ulp-spdif", .data = &fsl_spdif_imx8ulp, },
1763 .name = "fsl-spdif-dai",
1776 MODULE_ALIAS("platform:fsl-spdif-dai");