Lines Matching refs:sai
58 #define STM_SAI_HAS_EXT_SYNC(x) (!STM_SAI_IS_F4(sai->pdata))
188 static int stm32_sai_sub_reg_up(struct stm32_sai_sub_data *sai, in stm32_sai_sub_reg_up() argument
194 ret = clk_enable(sai->pdata->pclk); in stm32_sai_sub_reg_up()
198 ret = regmap_update_bits(sai->regmap, reg, mask, val); in stm32_sai_sub_reg_up()
200 clk_disable(sai->pdata->pclk); in stm32_sai_sub_reg_up()
205 static int stm32_sai_sub_reg_wr(struct stm32_sai_sub_data *sai, in stm32_sai_sub_reg_wr() argument
211 ret = clk_enable(sai->pdata->pclk); in stm32_sai_sub_reg_wr()
215 ret = regmap_write_bits(sai->regmap, reg, mask, val); in stm32_sai_sub_reg_wr()
217 clk_disable(sai->pdata->pclk); in stm32_sai_sub_reg_wr()
222 static int stm32_sai_sub_reg_rd(struct stm32_sai_sub_data *sai, in stm32_sai_sub_reg_rd() argument
227 ret = clk_enable(sai->pdata->pclk); in stm32_sai_sub_reg_rd()
231 ret = regmap_read(sai->regmap, reg, val); in stm32_sai_sub_reg_rd()
233 clk_disable(sai->pdata->pclk); in stm32_sai_sub_reg_rd()
274 struct stm32_sai_sub_data *sai = snd_kcontrol_chip(kcontrol); in snd_pcm_iec958_get() local
276 mutex_lock(&sai->ctrl_lock); in snd_pcm_iec958_get()
277 memcpy(uctl->value.iec958.status, sai->iec958.status, 4); in snd_pcm_iec958_get()
278 mutex_unlock(&sai->ctrl_lock); in snd_pcm_iec958_get()
286 struct stm32_sai_sub_data *sai = snd_kcontrol_chip(kcontrol); in snd_pcm_iec958_put() local
288 mutex_lock(&sai->ctrl_lock); in snd_pcm_iec958_put()
289 memcpy(sai->iec958.status, uctl->value.iec958.status, 4); in snd_pcm_iec958_put()
290 mutex_unlock(&sai->ctrl_lock); in snd_pcm_iec958_put()
314 static int stm32_sai_get_clk_div(struct stm32_sai_sub_data *sai, in stm32_sai_get_clk_div() argument
318 int version = sai->pdata->conf.version; in stm32_sai_get_clk_div()
323 dev_err(&sai->pdev->dev, "Divider %d out of range\n", div); in stm32_sai_get_clk_div()
326 dev_dbg(&sai->pdev->dev, "SAI divider %d\n", div); in stm32_sai_get_clk_div()
329 dev_dbg(&sai->pdev->dev, in stm32_sai_get_clk_div()
336 static int stm32_sai_set_clk_div(struct stm32_sai_sub_data *sai, in stm32_sai_set_clk_div() argument
339 int version = sai->pdata->conf.version; in stm32_sai_set_clk_div()
343 dev_err(&sai->pdev->dev, "Divider %d out of range\n", div); in stm32_sai_set_clk_div()
349 ret = stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, mask, cr1); in stm32_sai_set_clk_div()
351 dev_err(&sai->pdev->dev, "Failed to update CR1 register\n"); in stm32_sai_set_clk_div()
356 static int stm32_sai_set_parent_clock(struct stm32_sai_sub_data *sai, in stm32_sai_set_parent_clock() argument
359 struct platform_device *pdev = sai->pdev; in stm32_sai_set_parent_clock()
360 struct clk *parent_clk = sai->pdata->clk_x8k; in stm32_sai_set_parent_clock()
364 parent_clk = sai->pdata->clk_x11k; in stm32_sai_set_parent_clock()
366 ret = clk_set_parent(sai->sai_ck, parent_clk); in stm32_sai_set_parent_clock()
379 struct stm32_sai_sub_data *sai = mclk->sai_data; in stm32_sai_mclk_round_rate() local
382 div = stm32_sai_get_clk_div(sai, *prate, rate); in stm32_sai_mclk_round_rate()
403 struct stm32_sai_sub_data *sai = mclk->sai_data; in stm32_sai_mclk_set_rate() local
406 div = stm32_sai_get_clk_div(sai, parent_rate, rate); in stm32_sai_mclk_set_rate()
410 ret = stm32_sai_set_clk_div(sai, div); in stm32_sai_mclk_set_rate()
422 struct stm32_sai_sub_data *sai = mclk->sai_data; in stm32_sai_mclk_enable() local
424 dev_dbg(&sai->pdev->dev, "Enable master clock\n"); in stm32_sai_mclk_enable()
426 return stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, in stm32_sai_mclk_enable()
433 struct stm32_sai_sub_data *sai = mclk->sai_data; in stm32_sai_mclk_disable() local
435 dev_dbg(&sai->pdev->dev, "Disable master clock\n"); in stm32_sai_mclk_disable()
437 stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, SAI_XCR1_MCKEN, 0); in stm32_sai_mclk_disable()
448 static int stm32_sai_add_mclk_provider(struct stm32_sai_sub_data *sai) in stm32_sai_add_mclk_provider() argument
452 struct device *dev = &sai->pdev->dev; in stm32_sai_add_mclk_provider()
453 const char *pname = __clk_get_name(sai->sai_ck); in stm32_sai_add_mclk_provider()
475 STM_SAI_IS_SUB_A(sai) ? strcat(p, "a_mclk") : strcat(p, "b_mclk"); in stm32_sai_add_mclk_provider()
478 mclk->sai_data = sai; in stm32_sai_add_mclk_provider()
482 ret = devm_clk_hw_register(&sai->pdev->dev, hw); in stm32_sai_add_mclk_provider()
487 sai->sai_mclk = hw->clk; in stm32_sai_add_mclk_provider()
495 struct stm32_sai_sub_data *sai = (struct stm32_sai_sub_data *)devid; in stm32_sai_isr() local
496 struct platform_device *pdev = sai->pdev; in stm32_sai_isr()
500 stm32_sai_sub_reg_rd(sai, STM_SAI_IMR_REGX, &imr); in stm32_sai_isr()
501 stm32_sai_sub_reg_rd(sai, STM_SAI_SR_REGX, &sr); in stm32_sai_isr()
507 stm32_sai_sub_reg_wr(sai, STM_SAI_CLRFR_REGX, SAI_XCLRFR_MASK, in stm32_sai_isr()
510 if (!sai->substream) { in stm32_sai_isr()
517 STM_SAI_IS_PLAYBACK(sai) ? "underrun" : "overrun"); in stm32_sai_isr()
542 spin_lock(&sai->irq_lock); in stm32_sai_isr()
543 if (status != SNDRV_PCM_STATE_RUNNING && sai->substream) in stm32_sai_isr()
544 snd_pcm_stop_xrun(sai->substream); in stm32_sai_isr()
545 spin_unlock(&sai->irq_lock); in stm32_sai_isr()
553 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_set_sysclk() local
556 if (dir == SND_SOC_CLOCK_OUT && sai->sai_mclk) { in stm32_sai_set_sysclk()
557 ret = stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, in stm32_sai_set_sysclk()
566 if (sai->mclk_rate) { in stm32_sai_set_sysclk()
567 clk_rate_exclusive_put(sai->sai_mclk); in stm32_sai_set_sysclk()
568 sai->mclk_rate = 0; in stm32_sai_set_sysclk()
574 ret = stm32_sai_set_parent_clock(sai, freq); in stm32_sai_set_sysclk()
578 ret = clk_set_rate_exclusive(sai->sai_mclk, freq); in stm32_sai_set_sysclk()
588 sai->mclk_rate = freq; in stm32_sai_set_sysclk()
597 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_set_dai_tdm_slot() local
600 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { in stm32_sai_set_dai_tdm_slot()
625 if (STM_SAI_IS_PLAYBACK(sai)) { in stm32_sai_set_dai_tdm_slot()
626 sai->slot_mask = tx_mask; in stm32_sai_set_dai_tdm_slot()
630 if (STM_SAI_IS_CAPTURE(sai)) { in stm32_sai_set_dai_tdm_slot()
631 sai->slot_mask = rx_mask; in stm32_sai_set_dai_tdm_slot()
637 stm32_sai_sub_reg_up(sai, STM_SAI_SLOTR_REGX, slotr_mask, slotr); in stm32_sai_set_dai_tdm_slot()
639 sai->slot_width = slot_width; in stm32_sai_set_dai_tdm_slot()
640 sai->slots = slots; in stm32_sai_set_dai_tdm_slot()
647 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_set_dai_fmt() local
659 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { in stm32_sai_set_dai_fmt()
719 stm32_sai_sub_reg_up(sai, STM_SAI_FRCR_REGX, frcr_mask, frcr); in stm32_sai_set_dai_fmt()
726 sai->master = false; in stm32_sai_set_dai_fmt()
729 sai->master = true; in stm32_sai_set_dai_fmt()
738 if (sai->sync) { in stm32_sai_set_dai_fmt()
741 sai->master = false; in stm32_sai_set_dai_fmt()
747 ret = stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, cr1_mask, cr1); in stm32_sai_set_dai_fmt()
753 sai->fmt = fmt; in stm32_sai_set_dai_fmt()
761 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_startup() local
765 spin_lock_irqsave(&sai->irq_lock, flags); in stm32_sai_startup()
766 sai->substream = substream; in stm32_sai_startup()
767 spin_unlock_irqrestore(&sai->irq_lock, flags); in stm32_sai_startup()
769 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { in stm32_sai_startup()
777 ret = clk_prepare_enable(sai->sai_ck); in stm32_sai_startup()
784 stm32_sai_sub_reg_wr(sai, STM_SAI_CLRFR_REGX, in stm32_sai_startup()
788 if (STM_SAI_IS_CAPTURE(sai)) { in stm32_sai_startup()
789 stm32_sai_sub_reg_rd(sai, STM_SAI_CR2_REGX, &cr2); in stm32_sai_startup()
794 if (sai->master) in stm32_sai_startup()
799 stm32_sai_sub_reg_up(sai, STM_SAI_IMR_REGX, in stm32_sai_startup()
809 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_set_config() local
817 stm32_sai_sub_reg_wr(sai, STM_SAI_CR2_REGX, in stm32_sai_set_config()
823 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { in stm32_sai_set_config()
824 sai->spdif_frm_cnt = 0; in stm32_sai_set_config()
846 if ((sai->slots == 2) && (params_channels(params) == 1)) in stm32_sai_set_config()
849 ret = stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, cr1_mask, cr1); in stm32_sai_set_config()
860 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_set_slots() local
863 stm32_sai_sub_reg_rd(sai, STM_SAI_SLOTR_REGX, &slotr); in stm32_sai_set_slots()
871 sai->slot_width = sai->data_size; in stm32_sai_set_slots()
873 if (sai->slot_width < sai->data_size) { in stm32_sai_set_slots()
876 sai->data_size); in stm32_sai_set_slots()
881 if (!sai->slots) in stm32_sai_set_slots()
882 sai->slots = 2; in stm32_sai_set_slots()
885 stm32_sai_sub_reg_up(sai, STM_SAI_SLOTR_REGX, in stm32_sai_set_slots()
887 SAI_XSLOTR_NBSLOT_SET((sai->slots - 1))); in stm32_sai_set_slots()
891 sai->slot_mask = (1 << sai->slots) - 1; in stm32_sai_set_slots()
892 stm32_sai_sub_reg_up(sai, in stm32_sai_set_slots()
894 SAI_XSLOTR_SLOTEN_SET(sai->slot_mask)); in stm32_sai_set_slots()
898 sai->slots, sai->slot_width); in stm32_sai_set_slots()
905 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_set_frame() local
909 format = sai->fmt & SND_SOC_DAIFMT_FORMAT_MASK; in stm32_sai_set_frame()
910 sai->fs_length = sai->slot_width * sai->slots; in stm32_sai_set_frame()
912 fs_active = sai->fs_length / 2; in stm32_sai_set_frame()
917 frcr = SAI_XFRCR_FRL_SET((sai->fs_length - 1)); in stm32_sai_set_frame()
922 sai->fs_length, fs_active); in stm32_sai_set_frame()
924 stm32_sai_sub_reg_up(sai, STM_SAI_FRCR_REGX, frcr_mask, frcr); in stm32_sai_set_frame()
926 if ((sai->fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_LSB) { in stm32_sai_set_frame()
927 offset = sai->slot_width - sai->data_size; in stm32_sai_set_frame()
929 stm32_sai_sub_reg_up(sai, STM_SAI_SLOTR_REGX, in stm32_sai_set_frame()
935 static void stm32_sai_init_iec958_status(struct stm32_sai_sub_data *sai) in stm32_sai_init_iec958_status() argument
937 unsigned char *cs = sai->iec958.status; in stm32_sai_init_iec958_status()
945 static void stm32_sai_set_iec958_status(struct stm32_sai_sub_data *sai, in stm32_sai_set_iec958_status() argument
952 mutex_lock(&sai->ctrl_lock); in stm32_sai_set_iec958_status()
955 sai->iec958.status[3] = IEC958_AES3_CON_FS_22050; in stm32_sai_set_iec958_status()
958 sai->iec958.status[3] = IEC958_AES3_CON_FS_44100; in stm32_sai_set_iec958_status()
961 sai->iec958.status[3] = IEC958_AES3_CON_FS_88200; in stm32_sai_set_iec958_status()
964 sai->iec958.status[3] = IEC958_AES3_CON_FS_176400; in stm32_sai_set_iec958_status()
967 sai->iec958.status[3] = IEC958_AES3_CON_FS_24000; in stm32_sai_set_iec958_status()
970 sai->iec958.status[3] = IEC958_AES3_CON_FS_48000; in stm32_sai_set_iec958_status()
973 sai->iec958.status[3] = IEC958_AES3_CON_FS_96000; in stm32_sai_set_iec958_status()
976 sai->iec958.status[3] = IEC958_AES3_CON_FS_192000; in stm32_sai_set_iec958_status()
979 sai->iec958.status[3] = IEC958_AES3_CON_FS_32000; in stm32_sai_set_iec958_status()
982 sai->iec958.status[3] = IEC958_AES3_CON_FS_NOTID; in stm32_sai_set_iec958_status()
985 mutex_unlock(&sai->ctrl_lock); in stm32_sai_set_iec958_status()
991 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_configure_clock() local
997 if (!sai->sai_mclk) { in stm32_sai_configure_clock()
998 ret = stm32_sai_set_parent_clock(sai, rate); in stm32_sai_configure_clock()
1002 sai_clk_rate = clk_get_rate(sai->sai_ck); in stm32_sai_configure_clock()
1004 if (STM_SAI_IS_F4(sai->pdata)) { in stm32_sai_configure_clock()
1012 if (!sai->mclk_rate) in stm32_sai_configure_clock()
1015 if (2 * sai_clk_rate >= 3 * sai->mclk_rate) { in stm32_sai_configure_clock()
1016 div = stm32_sai_get_clk_div(sai, sai_clk_rate, in stm32_sai_configure_clock()
1017 2 * sai->mclk_rate); in stm32_sai_configure_clock()
1031 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { in stm32_sai_configure_clock()
1032 div = stm32_sai_get_clk_div(sai, sai_clk_rate, in stm32_sai_configure_clock()
1037 if (sai->mclk_rate) { in stm32_sai_configure_clock()
1038 mclk_ratio = sai->mclk_rate / rate; in stm32_sai_configure_clock()
1048 stm32_sai_sub_reg_up(sai, in stm32_sai_configure_clock()
1052 div = stm32_sai_get_clk_div(sai, sai_clk_rate, in stm32_sai_configure_clock()
1053 sai->mclk_rate); in stm32_sai_configure_clock()
1058 den = sai->fs_length * params_rate(params); in stm32_sai_configure_clock()
1059 div = stm32_sai_get_clk_div(sai, sai_clk_rate, in stm32_sai_configure_clock()
1067 return stm32_sai_set_clk_div(sai, div); in stm32_sai_configure_clock()
1074 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_hw_params() local
1077 sai->data_size = params_width(params); in stm32_sai_hw_params()
1079 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { in stm32_sai_hw_params()
1082 stm32_sai_set_iec958_status(sai, substream->runtime); in stm32_sai_hw_params()
1094 if (sai->master) in stm32_sai_hw_params()
1103 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_trigger() local
1112 stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, in stm32_sai_trigger()
1116 ret = stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, in stm32_sai_trigger()
1126 stm32_sai_sub_reg_up(sai, STM_SAI_IMR_REGX, in stm32_sai_trigger()
1129 stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, in stm32_sai_trigger()
1133 ret = stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, in stm32_sai_trigger()
1139 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) in stm32_sai_trigger()
1140 sai->spdif_frm_cnt = 0; in stm32_sai_trigger()
1152 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); in stm32_sai_shutdown() local
1155 stm32_sai_sub_reg_up(sai, STM_SAI_IMR_REGX, SAI_XIMR_MASK, 0); in stm32_sai_shutdown()
1157 clk_disable_unprepare(sai->sai_ck); in stm32_sai_shutdown()
1159 spin_lock_irqsave(&sai->irq_lock, flags); in stm32_sai_shutdown()
1160 sai->substream = NULL; in stm32_sai_shutdown()
1161 spin_unlock_irqrestore(&sai->irq_lock, flags); in stm32_sai_shutdown()
1167 struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev); in stm32_sai_pcm_new() local
1170 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { in stm32_sai_pcm_new()
1171 dev_dbg(&sai->pdev->dev, "%s: register iec controls", __func__); in stm32_sai_pcm_new()
1173 return snd_ctl_add(rtd->pcm->card, snd_ctl_new1(&knew, sai)); in stm32_sai_pcm_new()
1181 struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev); in stm32_sai_dai_probe() local
1184 sai->cpu_dai = cpu_dai; in stm32_sai_dai_probe()
1186 sai->dma_params.addr = (dma_addr_t)(sai->phys_addr + STM_SAI_DR_REGX); in stm32_sai_dai_probe()
1192 sai->dma_params.maxburst = 4; in stm32_sai_dai_probe()
1193 if (sai->pdata->conf.fifo_size < 8) in stm32_sai_dai_probe()
1194 sai->dma_params.maxburst = 1; in stm32_sai_dai_probe()
1196 sai->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_UNDEFINED; in stm32_sai_dai_probe()
1198 if (STM_SAI_IS_PLAYBACK(sai)) in stm32_sai_dai_probe()
1199 snd_soc_dai_init_dma_data(cpu_dai, &sai->dma_params, NULL); in stm32_sai_dai_probe()
1201 snd_soc_dai_init_dma_data(cpu_dai, NULL, &sai->dma_params); in stm32_sai_dai_probe()
1204 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) in stm32_sai_dai_probe()
1208 if (STM_SAI_IS_CAPTURE(sai)) in stm32_sai_dai_probe()
1212 if (sai->sync == SAI_SYNC_EXTERNAL) { in stm32_sai_dai_probe()
1214 ret = sai->pdata->set_sync(sai->pdata, sai->np_sync_provider, in stm32_sai_dai_probe()
1215 sai->synco, sai->synci); in stm32_sai_dai_probe()
1221 cr1 |= SAI_XCR1_SYNCEN_SET(sai->sync); in stm32_sai_dai_probe()
1223 return stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX, cr1_mask, cr1); in stm32_sai_dai_probe()
1243 struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev); in stm32_sai_pcm_process_spdif() local
1247 unsigned int frm_cnt = sai->spdif_frm_cnt; in stm32_sai_pcm_process_spdif()
1257 if (sai->iec958.status[byte] & mask) in stm32_sai_pcm_process_spdif()
1267 sai->spdif_frm_cnt = frm_cnt; in stm32_sai_pcm_process_spdif()
1353 struct stm32_sai_sub_data *sai) in stm32_sai_sub_parse_of() argument
1368 sai->phys_addr = res->start; in stm32_sai_sub_parse_of()
1370 sai->regmap_config = &stm32_sai_sub_regmap_config_f4; in stm32_sai_sub_parse_of()
1372 if (STM_SAI_HAS_PDM(sai) && STM_SAI_IS_SUB_A(sai)) in stm32_sai_sub_parse_of()
1373 sai->regmap_config = &stm32_sai_sub_regmap_config_h7; in stm32_sai_sub_parse_of()
1380 sai->regmap = devm_regmap_init_mmio(&pdev->dev, base, in stm32_sai_sub_parse_of()
1381 sai->regmap_config); in stm32_sai_sub_parse_of()
1382 if (IS_ERR(sai->regmap)) in stm32_sai_sub_parse_of()
1383 return dev_err_probe(&pdev->dev, PTR_ERR(sai->regmap), in stm32_sai_sub_parse_of()
1388 sai->dir = SNDRV_PCM_STREAM_PLAYBACK; in stm32_sai_sub_parse_of()
1390 sai->dir = SNDRV_PCM_STREAM_CAPTURE; in stm32_sai_sub_parse_of()
1397 sai->spdif = false; in stm32_sai_sub_parse_of()
1399 if (!STM_SAI_HAS_SPDIF(sai) || in stm32_sai_sub_parse_of()
1400 sai->dir == SNDRV_PCM_STREAM_CAPTURE) { in stm32_sai_sub_parse_of()
1404 stm32_sai_init_iec958_status(sai); in stm32_sai_sub_parse_of()
1405 sai->spdif = true; in stm32_sai_sub_parse_of()
1406 sai->master = true; in stm32_sai_sub_parse_of()
1417 sai->sync = SAI_SYNC_NONE; in stm32_sai_sub_parse_of()
1425 sai->np_sync_provider = of_get_parent(args.np); in stm32_sai_sub_parse_of()
1426 if (!sai->np_sync_provider) { in stm32_sai_sub_parse_of()
1433 sai->sync = SAI_SYNC_INTERNAL; in stm32_sai_sub_parse_of()
1434 if (sai->np_sync_provider != sai->pdata->pdev->dev.of_node) { in stm32_sai_sub_parse_of()
1435 if (!STM_SAI_HAS_EXT_SYNC(sai)) { in stm32_sai_sub_parse_of()
1441 sai->sync = SAI_SYNC_EXTERNAL; in stm32_sai_sub_parse_of()
1443 sai->synci = args.args[0]; in stm32_sai_sub_parse_of()
1444 if (sai->synci < 1 || in stm32_sai_sub_parse_of()
1445 (sai->synci > (SAI_GCR_SYNCIN_MAX + 1))) { in stm32_sai_sub_parse_of()
1453 sai->synco = STM_SAI_SYNC_OUT_A; in stm32_sai_sub_parse_of()
1457 sai->synco = STM_SAI_SYNC_OUT_B; in stm32_sai_sub_parse_of()
1459 if (!sai->synco) { in stm32_sai_sub_parse_of()
1471 sai->sai_ck = devm_clk_get(&pdev->dev, "sai_ck"); in stm32_sai_sub_parse_of()
1472 if (IS_ERR(sai->sai_ck)) in stm32_sai_sub_parse_of()
1473 return dev_err_probe(&pdev->dev, PTR_ERR(sai->sai_ck), in stm32_sai_sub_parse_of()
1476 ret = clk_prepare(sai->pdata->pclk); in stm32_sai_sub_parse_of()
1480 if (STM_SAI_IS_F4(sai->pdata)) in stm32_sai_sub_parse_of()
1485 ret = stm32_sai_add_mclk_provider(sai); in stm32_sai_sub_parse_of()
1489 sai->sai_mclk = devm_clk_get(&pdev->dev, "MCLK"); in stm32_sai_sub_parse_of()
1490 if (IS_ERR(sai->sai_mclk)) { in stm32_sai_sub_parse_of()
1491 if (PTR_ERR(sai->sai_mclk) != -ENOENT) in stm32_sai_sub_parse_of()
1492 return PTR_ERR(sai->sai_mclk); in stm32_sai_sub_parse_of()
1493 sai->sai_mclk = NULL; in stm32_sai_sub_parse_of()
1502 struct stm32_sai_sub_data *sai; in stm32_sai_sub_probe() local
1507 sai = devm_kzalloc(&pdev->dev, sizeof(*sai), GFP_KERNEL); in stm32_sai_sub_probe()
1508 if (!sai) in stm32_sai_sub_probe()
1514 sai->id = (uintptr_t)of_id->data; in stm32_sai_sub_probe()
1516 sai->pdev = pdev; in stm32_sai_sub_probe()
1517 mutex_init(&sai->ctrl_lock); in stm32_sai_sub_probe()
1518 spin_lock_init(&sai->irq_lock); in stm32_sai_sub_probe()
1519 platform_set_drvdata(pdev, sai); in stm32_sai_sub_probe()
1521 sai->pdata = dev_get_drvdata(pdev->dev.parent); in stm32_sai_sub_probe()
1522 if (!sai->pdata) { in stm32_sai_sub_probe()
1527 ret = stm32_sai_sub_parse_of(pdev, sai); in stm32_sai_sub_probe()
1531 if (STM_SAI_IS_PLAYBACK(sai)) in stm32_sai_sub_probe()
1532 sai->cpu_dai_drv = stm32_sai_playback_dai; in stm32_sai_sub_probe()
1534 sai->cpu_dai_drv = stm32_sai_capture_dai; in stm32_sai_sub_probe()
1535 sai->cpu_dai_drv.name = dev_name(&pdev->dev); in stm32_sai_sub_probe()
1537 ret = devm_request_irq(&pdev->dev, sai->pdata->irq, stm32_sai_isr, in stm32_sai_sub_probe()
1538 IRQF_SHARED, dev_name(&pdev->dev), sai); in stm32_sai_sub_probe()
1544 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) in stm32_sai_sub_probe()
1552 &sai->cpu_dai_drv, 1); in stm32_sai_sub_probe()
1565 struct stm32_sai_sub_data *sai = dev_get_drvdata(&pdev->dev); in stm32_sai_sub_remove() local
1567 clk_unprepare(sai->pdata->pclk); in stm32_sai_sub_remove()
1578 struct stm32_sai_sub_data *sai = dev_get_drvdata(dev); in stm32_sai_sub_suspend() local
1581 ret = clk_enable(sai->pdata->pclk); in stm32_sai_sub_suspend()
1585 regcache_cache_only(sai->regmap, true); in stm32_sai_sub_suspend()
1586 regcache_mark_dirty(sai->regmap); in stm32_sai_sub_suspend()
1588 clk_disable(sai->pdata->pclk); in stm32_sai_sub_suspend()
1595 struct stm32_sai_sub_data *sai = dev_get_drvdata(dev); in stm32_sai_sub_resume() local
1598 ret = clk_enable(sai->pdata->pclk); in stm32_sai_sub_resume()
1602 regcache_cache_only(sai->regmap, false); in stm32_sai_sub_resume()
1603 ret = regcache_sync(sai->regmap); in stm32_sai_sub_resume()
1605 clk_disable(sai->pdata->pclk); in stm32_sai_sub_resume()