Lines Matching full:easrc

50 	struct fsl_asrc *easrc = snd_soc_component_get_drvdata(comp);  in fsl_easrc_iec958_put_bits()  local
51 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_iec958_put_bits()
65 struct fsl_asrc *easrc = snd_soc_component_get_drvdata(comp); in fsl_easrc_iec958_get_bits() local
66 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_iec958_get_bits()
174 struct fsl_asrc *easrc = ctx->asrc; in fsl_easrc_set_rs_ratio() local
175 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_set_rs_ratio()
205 dev_err(&easrc->pdev->dev, "ratio exceed range\n"); in fsl_easrc_set_rs_ratio()
209 regmap_write(easrc->regmap, REG_EASRC_RRL(ctx->index), in fsl_easrc_set_rs_ratio()
211 regmap_write(easrc->regmap, REG_EASRC_RRH(ctx->index), in fsl_easrc_set_rs_ratio()
239 static int fsl_easrc_coeff_mem_ptr_reset(struct fsl_asrc *easrc, in fsl_easrc_coeff_mem_ptr_reset() argument
245 if (!easrc) in fsl_easrc_coeff_mem_ptr_reset()
248 dev = &easrc->pdev->dev; in fsl_easrc_coeff_mem_ptr_reset()
278 regmap_update_bits(easrc->regmap, reg, mask, 0); in fsl_easrc_coeff_mem_ptr_reset()
279 regmap_update_bits(easrc->regmap, reg, mask, val); in fsl_easrc_coeff_mem_ptr_reset()
280 regmap_update_bits(easrc->regmap, reg, mask, 0); in fsl_easrc_coeff_mem_ptr_reset()
299 static int fsl_easrc_resampler_config(struct fsl_asrc *easrc) in fsl_easrc_resampler_config() argument
301 struct device *dev = &easrc->pdev->dev; in fsl_easrc_resampler_config()
302 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_resampler_config()
342 regmap_write(easrc->regmap, REG_EASRC_RCTCL, EASRC_RCTCL_RS_CL(r[0])); in fsl_easrc_resampler_config()
343 regmap_write(easrc->regmap, REG_EASRC_RCTCH, EASRC_RCTCH_RS_CH(r[1])); in fsl_easrc_resampler_config()
352 regmap_update_bits(easrc->regmap, REG_EASRC_CRCC, in fsl_easrc_resampler_config()
357 ret = fsl_easrc_coeff_mem_ptr_reset(easrc, 0, EASRC_RS_COEFF_MEM); in fsl_easrc_resampler_config()
373 regmap_write(easrc->regmap, REG_EASRC_CRCM, in fsl_easrc_resampler_config()
375 regmap_write(easrc->regmap, REG_EASRC_CRCM, in fsl_easrc_resampler_config()
389 * @easrc: Structure pointer of fsl_asrc
395 static int fsl_easrc_normalize_filter(struct fsl_asrc *easrc, in fsl_easrc_normalize_filter() argument
400 struct device *dev = &easrc->pdev->dev; in fsl_easrc_normalize_filter()
428 static int fsl_easrc_write_pf_coeff_mem(struct fsl_asrc *easrc, int ctx_id, in fsl_easrc_write_pf_coeff_mem() argument
431 struct device *dev = &easrc->pdev->dev; in fsl_easrc_write_pf_coeff_mem()
450 ret = fsl_easrc_coeff_mem_ptr_reset(easrc, ctx_id, EASRC_PF_COEFF_MEM); in fsl_easrc_write_pf_coeff_mem()
455 ret = fsl_easrc_normalize_filter(easrc, &coef[i], &tmp, shift); in fsl_easrc_write_pf_coeff_mem()
460 regmap_write(easrc->regmap, REG_EASRC_PCF(ctx_id), in fsl_easrc_write_pf_coeff_mem()
462 regmap_write(easrc->regmap, REG_EASRC_PCF(ctx_id), in fsl_easrc_write_pf_coeff_mem()
469 static int fsl_easrc_prefilter_config(struct fsl_asrc *easrc, in fsl_easrc_prefilter_config() argument
483 if (!easrc) in fsl_easrc_prefilter_config()
486 dev = &easrc->pdev->dev; in fsl_easrc_prefilter_config()
493 easrc_priv = easrc->private; in fsl_easrc_prefilter_config()
495 ctx = easrc->pair[ctx_id]; in fsl_easrc_prefilter_config()
509 regmap_write(easrc->regmap, REG_EASRC_CCE1(ctx_id), 0); in fsl_easrc_prefilter_config()
510 regmap_write(easrc->regmap, REG_EASRC_CCE2(ctx_id), 0); in fsl_easrc_prefilter_config()
553 regmap_update_bits(easrc->regmap, in fsl_easrc_prefilter_config()
636 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx_id), in fsl_easrc_prefilter_config()
647 regmap_update_bits(easrc->regmap, REG_EASRC_CCE2(ctx_id), in fsl_easrc_prefilter_config()
652 regmap_update_bits(easrc->regmap, REG_EASRC_CCE1(ctx_id), in fsl_easrc_prefilter_config()
656 ret = fsl_easrc_write_pf_coeff_mem(easrc, ctx_id, in fsl_easrc_prefilter_config()
671 regmap_update_bits(easrc->regmap, REG_EASRC_CCE1(ctx_id), in fsl_easrc_prefilter_config()
678 regmap_update_bits(easrc->regmap, REG_EASRC_CCE1(ctx_id), in fsl_easrc_prefilter_config()
682 regmap_update_bits(easrc->regmap, REG_EASRC_CCE1(ctx_id), in fsl_easrc_prefilter_config()
687 regmap_update_bits(easrc->regmap, REG_EASRC_CCE2(ctx_id), in fsl_easrc_prefilter_config()
692 regmap_update_bits(easrc->regmap, REG_EASRC_CCE1(ctx_id), in fsl_easrc_prefilter_config()
696 ret = fsl_easrc_write_pf_coeff_mem(easrc, ctx_id, in fsl_easrc_prefilter_config()
750 struct fsl_asrc *easrc = ctx->asrc; in fsl_easrc_config_one_slot() local
782 regmap_update_bits(easrc->regmap, reg0, in fsl_easrc_config_one_slot()
786 regmap_update_bits(easrc->regmap, reg0, in fsl_easrc_config_one_slot()
790 regmap_update_bits(easrc->regmap, reg0, in fsl_easrc_config_one_slot()
794 regmap_update_bits(easrc->regmap, reg0, in fsl_easrc_config_one_slot()
807 regmap_update_bits(easrc->regmap, reg2, in fsl_easrc_config_one_slot()
816 regmap_update_bits(easrc->regmap, reg2, in fsl_easrc_config_one_slot()
824 regmap_update_bits(easrc->regmap, reg1, in fsl_easrc_config_one_slot()
830 regmap_update_bits(easrc->regmap, reg3, in fsl_easrc_config_one_slot()
839 regmap_update_bits(easrc->regmap, reg3, in fsl_easrc_config_one_slot()
844 regmap_update_bits(easrc->regmap, reg0, in fsl_easrc_config_one_slot()
861 static int fsl_easrc_config_slot(struct fsl_asrc *easrc, unsigned int ctx_id) in fsl_easrc_config_slot() argument
863 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_config_slot()
864 struct fsl_asrc_pair *ctx = easrc->pair[ctx_id]; in fsl_easrc_config_slot()
912 dev_err(&easrc->pdev->dev, "no avail slot.\n"); in fsl_easrc_config_slot()
924 static int fsl_easrc_release_slot(struct fsl_asrc *easrc, unsigned int ctx_id) in fsl_easrc_release_slot() argument
926 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_release_slot()
927 struct fsl_asrc_pair *ctx = easrc->pair[ctx_id]; in fsl_easrc_release_slot()
937 regmap_write(easrc->regmap, REG_EASRC_DPCS0R0(i), 0); in fsl_easrc_release_slot()
938 regmap_write(easrc->regmap, REG_EASRC_DPCS0R1(i), 0); in fsl_easrc_release_slot()
939 regmap_write(easrc->regmap, REG_EASRC_DPCS0R2(i), 0); in fsl_easrc_release_slot()
940 regmap_write(easrc->regmap, REG_EASRC_DPCS0R3(i), 0); in fsl_easrc_release_slot()
949 regmap_write(easrc->regmap, REG_EASRC_DPCS1R0(i), 0); in fsl_easrc_release_slot()
950 regmap_write(easrc->regmap, REG_EASRC_DPCS1R1(i), 0); in fsl_easrc_release_slot()
951 regmap_write(easrc->regmap, REG_EASRC_DPCS1R2(i), 0); in fsl_easrc_release_slot()
952 regmap_write(easrc->regmap, REG_EASRC_DPCS1R3(i), 0); in fsl_easrc_release_slot()
964 static int fsl_easrc_config_context(struct fsl_asrc *easrc, unsigned int ctx_id) in fsl_easrc_config_context() argument
972 if (!easrc) in fsl_easrc_config_context()
975 dev = &easrc->pdev->dev; in fsl_easrc_config_context()
982 ctx = easrc->pair[ctx_id]; in fsl_easrc_config_context()
993 ret = fsl_easrc_prefilter_config(easrc, ctx->index); in fsl_easrc_config_context()
997 spin_lock_irqsave(&easrc->lock, lock_flags); in fsl_easrc_config_context()
998 ret = fsl_easrc_config_slot(easrc, ctx->index); in fsl_easrc_config_context()
999 spin_unlock_irqrestore(&easrc->lock, lock_flags); in fsl_easrc_config_context()
1010 regmap_update_bits(easrc->regmap, REG_EASRC_CCE1(ctx_id), in fsl_easrc_config_context()
1014 regmap_update_bits(easrc->regmap, REG_EASRC_CCE1(ctx_id), in fsl_easrc_config_context()
1022 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx_id), in fsl_easrc_config_context()
1031 regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx_id), in fsl_easrc_config_context()
1036 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx_id), in fsl_easrc_config_context()
1046 struct fsl_asrc *easrc = ctx->asrc; in fsl_easrc_process_format() local
1047 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_process_format()
1129 struct fsl_asrc *easrc = ctx->asrc; in fsl_easrc_set_ctx_format() local
1142 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), in fsl_easrc_set_ctx_format()
1145 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), in fsl_easrc_set_ctx_format()
1148 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), in fsl_easrc_set_ctx_format()
1151 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), in fsl_easrc_set_ctx_format()
1156 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), in fsl_easrc_set_ctx_format()
1167 regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx->index), in fsl_easrc_set_ctx_format()
1170 regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx->index), in fsl_easrc_set_ctx_format()
1173 regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx->index), in fsl_easrc_set_ctx_format()
1176 regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx->index), in fsl_easrc_set_ctx_format()
1181 regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx->index), in fsl_easrc_set_ctx_format()
1185 regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx->index), in fsl_easrc_set_ctx_format()
1201 struct fsl_asrc *easrc; in fsl_easrc_set_ctx_organziation() local
1206 easrc = ctx->asrc; in fsl_easrc_set_ctx_organziation()
1210 regmap_update_bits(easrc->regmap, REG_EASRC_CIA(ctx->index), in fsl_easrc_set_ctx_organziation()
1213 regmap_update_bits(easrc->regmap, REG_EASRC_CIA(ctx->index), in fsl_easrc_set_ctx_organziation()
1216 regmap_update_bits(easrc->regmap, REG_EASRC_CIA(ctx->index), in fsl_easrc_set_ctx_organziation()
1221 regmap_update_bits(easrc->regmap, REG_EASRC_COA(ctx->index), in fsl_easrc_set_ctx_organziation()
1224 regmap_update_bits(easrc->regmap, REG_EASRC_COA(ctx->index), in fsl_easrc_set_ctx_organziation()
1227 regmap_update_bits(easrc->regmap, REG_EASRC_COA(ctx->index), in fsl_easrc_set_ctx_organziation()
1243 struct fsl_asrc *easrc = ctx->asrc; in fsl_easrc_request_context() local
1249 dev = &easrc->pdev->dev; in fsl_easrc_request_context()
1251 spin_lock_irqsave(&easrc->lock, lock_flags); in fsl_easrc_request_context()
1254 if (easrc->pair[i]) in fsl_easrc_request_context()
1264 } else if (channels > easrc->channel_avail) { in fsl_easrc_request_context()
1271 easrc->pair[index] = ctx; in fsl_easrc_request_context()
1272 easrc->channel_avail -= channels; in fsl_easrc_request_context()
1275 spin_unlock_irqrestore(&easrc->lock, lock_flags); in fsl_easrc_request_context()
1288 struct fsl_asrc *easrc; in fsl_easrc_release_context() local
1293 easrc = ctx->asrc; in fsl_easrc_release_context()
1295 spin_lock_irqsave(&easrc->lock, lock_flags); in fsl_easrc_release_context()
1297 fsl_easrc_release_slot(easrc, ctx->index); in fsl_easrc_release_context()
1299 easrc->channel_avail += ctx->channels; in fsl_easrc_release_context()
1300 easrc->pair[ctx->index] = NULL; in fsl_easrc_release_context()
1302 spin_unlock_irqrestore(&easrc->lock, lock_flags); in fsl_easrc_release_context()
1312 struct fsl_asrc *easrc = ctx->asrc; in fsl_easrc_start_context() local
1314 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), in fsl_easrc_start_context()
1316 regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx->index), in fsl_easrc_start_context()
1318 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), in fsl_easrc_start_context()
1330 struct fsl_asrc *easrc = ctx->asrc; in fsl_easrc_stop_context() local
1335 regmap_read(easrc->regmap, REG_EASRC_CC(ctx->index), &val); in fsl_easrc_stop_context()
1338 regmap_update_bits(easrc->regmap, in fsl_easrc_stop_context()
1342 regmap_read(easrc->regmap, REG_EASRC_SFS(ctx->index), &val); in fsl_easrc_stop_context()
1348 regmap_read(easrc->regmap, REG_EASRC_RDFIFO(ctx->index), &val); in fsl_easrc_stop_context()
1350 regmap_read(easrc->regmap, REG_EASRC_IRQF, &val); in fsl_easrc_stop_context()
1353 regmap_write_bits(easrc->regmap, in fsl_easrc_stop_context()
1363 dev_warn(&easrc->pdev->dev, "RUN STOP fail\n"); in fsl_easrc_stop_context()
1366 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), in fsl_easrc_stop_context()
1368 regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), in fsl_easrc_stop_context()
1370 regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx->index), in fsl_easrc_stop_context()
1378 struct fsl_asrc *easrc = ctx->asrc; in fsl_easrc_get_dma_channel() local
1385 return dma_request_slave_channel(&easrc->pdev->dev, name); in fsl_easrc_get_dma_channel()
1442 struct fsl_asrc *easrc = snd_soc_dai_get_drvdata(dai); in fsl_easrc_hw_params() local
1444 struct device *dev = &easrc->pdev->dev; in fsl_easrc_hw_params()
1467 ctx_priv->out_params.sample_rate = easrc->asrc_rate; in fsl_easrc_hw_params()
1468 ctx_priv->out_params.sample_format = easrc->asrc_format; in fsl_easrc_hw_params()
1472 ctx_priv->in_params.sample_rate = easrc->asrc_rate; in fsl_easrc_hw_params()
1473 ctx_priv->in_params.sample_format = easrc->asrc_format; in fsl_easrc_hw_params()
1492 ret = fsl_easrc_config_context(easrc, ctx->index); in fsl_easrc_hw_params()
1536 struct fsl_asrc *easrc = dev_get_drvdata(cpu_dai->dev); in fsl_easrc_dai_probe() local
1539 &easrc->dma_params_tx, in fsl_easrc_dai_probe()
1540 &easrc->dma_params_rx); in fsl_easrc_dai_probe()
1576 .name = "fsl-easrc-dai",
1755 static void fsl_easrc_dump_firmware(struct fsl_asrc *easrc) in fsl_easrc_dump_firmware() argument
1757 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_dump_firmware()
1761 struct device *dev = &easrc->pdev->dev; in fsl_easrc_dump_firmware()
1800 static int fsl_easrc_get_firmware(struct fsl_asrc *easrc) in fsl_easrc_get_firmware() argument
1808 if (!easrc) in fsl_easrc_get_firmware()
1811 easrc_priv = easrc->private; in fsl_easrc_get_firmware()
1814 ret = request_firmware(fw_p, easrc_priv->fw_name, &easrc->pdev->dev); in fsl_easrc_get_firmware()
1836 fsl_easrc_dump_firmware(easrc); in fsl_easrc_get_firmware()
1844 struct fsl_asrc *easrc = (struct fsl_asrc *)dev_id; in fsl_easrc_isr() local
1845 struct device *dev = &easrc->pdev->dev; in fsl_easrc_isr()
1848 regmap_read(easrc->regmap, REG_EASRC_IRQF, &val); in fsl_easrc_isr()
1865 { .compatible = "fsl,imx8mn-easrc",},
1874 struct fsl_asrc *easrc; in fsl_easrc_probe() local
1881 easrc = devm_kzalloc(dev, sizeof(*easrc), GFP_KERNEL); in fsl_easrc_probe()
1882 if (!easrc) in fsl_easrc_probe()
1889 easrc->pdev = pdev; in fsl_easrc_probe()
1890 easrc->private = easrc_priv; in fsl_easrc_probe()
1897 easrc->paddr = res->start; in fsl_easrc_probe()
1899 easrc->regmap = devm_regmap_init_mmio(dev, regs, &fsl_easrc_regmap_config); in fsl_easrc_probe()
1900 if (IS_ERR(easrc->regmap)) { in fsl_easrc_probe()
1902 return PTR_ERR(easrc->regmap); in fsl_easrc_probe()
1910 dev_name(dev), easrc); in fsl_easrc_probe()
1916 easrc->mem_clk = devm_clk_get(dev, "mem"); in fsl_easrc_probe()
1917 if (IS_ERR(easrc->mem_clk)) { in fsl_easrc_probe()
1919 return PTR_ERR(easrc->mem_clk); in fsl_easrc_probe()
1923 easrc->channel_avail = 32; in fsl_easrc_probe()
1924 easrc->get_dma_channel = fsl_easrc_get_dma_channel; in fsl_easrc_probe()
1925 easrc->request_pair = fsl_easrc_request_context; in fsl_easrc_probe()
1926 easrc->release_pair = fsl_easrc_release_context; in fsl_easrc_probe()
1927 easrc->get_fifo_addr = fsl_easrc_get_fifo_addr; in fsl_easrc_probe()
1928 easrc->pair_priv_size = sizeof(struct fsl_easrc_ctx_priv); in fsl_easrc_probe()
1933 ret = of_property_read_u32(np, "fsl,asrc-rate", &easrc->asrc_rate); in fsl_easrc_probe()
1940 easrc->asrc_format = (__force snd_pcm_format_t)asrc_fmt; in fsl_easrc_probe()
1946 if (!(FSL_EASRC_FORMATS & (pcm_format_to_bits(easrc->asrc_format)))) { in fsl_easrc_probe()
1948 easrc->asrc_format = SNDRV_PCM_FORMAT_S24_LE; in fsl_easrc_probe()
1958 platform_set_drvdata(pdev, easrc); in fsl_easrc_probe()
1961 spin_lock_init(&easrc->lock); in fsl_easrc_probe()
1963 regcache_cache_only(easrc->regmap, true); in fsl_easrc_probe()
1993 struct fsl_asrc *easrc = dev_get_drvdata(dev); in fsl_easrc_runtime_suspend() local
1994 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_runtime_suspend()
1997 regcache_cache_only(easrc->regmap, true); in fsl_easrc_runtime_suspend()
1999 clk_disable_unprepare(easrc->mem_clk); in fsl_easrc_runtime_suspend()
2001 spin_lock_irqsave(&easrc->lock, lock_flags); in fsl_easrc_runtime_suspend()
2003 spin_unlock_irqrestore(&easrc->lock, lock_flags); in fsl_easrc_runtime_suspend()
2010 struct fsl_asrc *easrc = dev_get_drvdata(dev); in fsl_easrc_runtime_resume() local
2011 struct fsl_easrc_priv *easrc_priv = easrc->private; in fsl_easrc_runtime_resume()
2018 ret = clk_prepare_enable(easrc->mem_clk); in fsl_easrc_runtime_resume()
2022 regcache_cache_only(easrc->regmap, false); in fsl_easrc_runtime_resume()
2023 regcache_mark_dirty(easrc->regmap); in fsl_easrc_runtime_resume()
2024 regcache_sync(easrc->regmap); in fsl_easrc_runtime_resume()
2026 spin_lock_irqsave(&easrc->lock, lock_flags); in fsl_easrc_runtime_resume()
2028 spin_unlock_irqrestore(&easrc->lock, lock_flags); in fsl_easrc_runtime_resume()
2032 spin_unlock_irqrestore(&easrc->lock, lock_flags); in fsl_easrc_runtime_resume()
2034 ret = fsl_easrc_get_firmware(easrc); in fsl_easrc_runtime_resume()
2045 ret = fsl_easrc_resampler_config(easrc); in fsl_easrc_runtime_resume()
2052 ctx = easrc->pair[i]; in fsl_easrc_runtime_resume()
2065 ret = fsl_easrc_write_pf_coeff_mem(easrc, i, in fsl_easrc_runtime_resume()
2072 ret = fsl_easrc_write_pf_coeff_mem(easrc, i, in fsl_easrc_runtime_resume()
2084 clk_disable_unprepare(easrc->mem_clk); in fsl_easrc_runtime_resume()
2098 .name = "fsl-easrc",
2105 MODULE_DESCRIPTION("NXP Enhanced Asynchronous Sample Rate (eASRC) driver");