Lines Matching +full:asrc +full:- +full:format
1 // SPDX-License-Identifier: GPL-2.0
3 // Freescale ASRC ALSA SoC Digital Audio Interface (DAI) driver
11 #include <linux/dma-mapping.h>
14 #include <linux/platform_data/dma-imx.h>
25 dev_err(&asrc->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__)
28 dev_dbg(&asrc->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__)
155 * fsl_asrc_sel_proc - Select the pre-processing and post-processing options
158 * @pre_proc: return value for pre-processing option
159 * @post_proc: return value for post-processing option
188 /* Condition for selection of post-processing */ in fsl_asrc_sel_proc()
202 * fsl_asrc_request_pair - Request ASRC pair
206 * It assigns pair by the order of A->C->B because allocation of pair B,
207 * within range [ANCA, ANCA+ANCB-1], depends on the channels of pair A
213 struct fsl_asrc *asrc = pair->asrc; in fsl_asrc_request_pair() local
214 struct device *dev = &asrc->pdev->dev; in fsl_asrc_request_pair()
218 spin_lock_irqsave(&asrc->lock, lock_flags); in fsl_asrc_request_pair()
221 if (asrc->pair[i] != NULL) in fsl_asrc_request_pair()
232 ret = -EBUSY; in fsl_asrc_request_pair()
233 } else if (asrc->channel_avail < channels) { in fsl_asrc_request_pair()
235 ret = -EINVAL; in fsl_asrc_request_pair()
237 asrc->channel_avail -= channels; in fsl_asrc_request_pair()
238 asrc->pair[index] = pair; in fsl_asrc_request_pair()
239 pair->channels = channels; in fsl_asrc_request_pair()
240 pair->index = index; in fsl_asrc_request_pair()
243 spin_unlock_irqrestore(&asrc->lock, lock_flags); in fsl_asrc_request_pair()
249 * fsl_asrc_release_pair - Release ASRC pair
252 * It clears the resource from asrc and releases the occupied channels.
256 struct fsl_asrc *asrc = pair->asrc; in fsl_asrc_release_pair() local
257 enum asrc_pair_index index = pair->index; in fsl_asrc_release_pair()
261 regmap_update_bits(asrc->regmap, REG_ASRCTR, in fsl_asrc_release_pair()
264 spin_lock_irqsave(&asrc->lock, lock_flags); in fsl_asrc_release_pair()
266 asrc->channel_avail += pair->channels; in fsl_asrc_release_pair()
267 asrc->pair[index] = NULL; in fsl_asrc_release_pair()
268 pair->error = 0; in fsl_asrc_release_pair()
270 spin_unlock_irqrestore(&asrc->lock, lock_flags); in fsl_asrc_release_pair()
274 * fsl_asrc_set_watermarks- configure input and output thresholds
281 struct fsl_asrc *asrc = pair->asrc; in fsl_asrc_set_watermarks() local
282 enum asrc_pair_index index = pair->index; in fsl_asrc_set_watermarks()
284 regmap_update_bits(asrc->regmap, REG_ASRMCR(index), in fsl_asrc_set_watermarks()
294 * fsl_asrc_cal_asrck_divisor - Calculate the total divisor between asrck clock rate and sample rate
308 return ((div - 1) << ASRCDRi_AxCPi_WIDTH) | ps; in fsl_asrc_cal_asrck_divisor()
312 * fsl_asrc_set_ideal_ratio - Calculate and set the ratio for Ideal Ratio mode only
317 * The ratio is a 32-bit fixed point value with 26 fractional bits.
322 struct fsl_asrc *asrc = pair->asrc; in fsl_asrc_set_ideal_ratio() local
323 enum asrc_pair_index index = pair->index; in fsl_asrc_set_ideal_ratio()
329 return -EINVAL; in fsl_asrc_set_ideal_ratio()
344 ratio |= 1 << (IDEAL_RATIO_DECIMAL_DEPTH - i); in fsl_asrc_set_ideal_ratio()
345 inrate -= outrate; in fsl_asrc_set_ideal_ratio()
351 regmap_write(asrc->regmap, REG_ASRIDRL(index), ratio); in fsl_asrc_set_ideal_ratio()
352 regmap_write(asrc->regmap, REG_ASRIDRH(index), ratio >> 24); in fsl_asrc_set_ideal_ratio()
358 * fsl_asrc_config_pair - Configure the assigned ASRC pair
362 * It configures those ASRC registers according to a configuration instance
368 * Using IDEAL_RATIO_RATE gives a faster converting speed but overloads ASRC.
375 struct fsl_asrc_pair_priv *pair_priv = pair->private; in fsl_asrc_config_pair()
376 struct asrc_config *config = pair_priv->config; in fsl_asrc_config_pair()
377 struct fsl_asrc *asrc = pair->asrc; in fsl_asrc_config_pair() local
378 struct fsl_asrc_priv *asrc_priv = asrc->private; in fsl_asrc_config_pair()
379 enum asrc_pair_index index = pair->index; in fsl_asrc_config_pair()
392 return -EINVAL; in fsl_asrc_config_pair()
396 if (config->channel_num < 1 || config->channel_num > 10) { in fsl_asrc_config_pair()
397 pair_err("does not support %d channels\n", config->channel_num); in fsl_asrc_config_pair()
398 return -EINVAL; in fsl_asrc_config_pair()
401 switch (snd_pcm_format_width(config->input_format)) { in fsl_asrc_config_pair()
412 pair_err("does not support this input format, %d\n", in fsl_asrc_config_pair()
413 config->input_format); in fsl_asrc_config_pair()
414 return -EINVAL; in fsl_asrc_config_pair()
417 switch (snd_pcm_format_width(config->output_format)) { in fsl_asrc_config_pair()
425 pair_err("does not support this output format, %d\n", in fsl_asrc_config_pair()
426 config->output_format); in fsl_asrc_config_pair()
427 return -EINVAL; in fsl_asrc_config_pair()
430 inrate = config->input_sample_rate; in fsl_asrc_config_pair()
431 outrate = config->output_sample_rate; in fsl_asrc_config_pair()
432 ideal = config->inclk == INCLK_NONE; in fsl_asrc_config_pair()
441 return -EINVAL; in fsl_asrc_config_pair()
450 return -EINVAL; in fsl_asrc_config_pair()
457 return -EINVAL; in fsl_asrc_config_pair()
461 clk_index[IN] = asrc_priv->clk_map[IN][config->inclk]; in fsl_asrc_config_pair()
462 clk_index[OUT] = asrc_priv->clk_map[OUT][config->outclk]; in fsl_asrc_config_pair()
465 clk = asrc_priv->asrck_clk[clk_index[ideal ? OUT : IN]]; in fsl_asrc_config_pair()
471 * The divider range is [1, 1024], defined by the hardware. For non- in fsl_asrc_config_pair()
480 return -EINVAL; in fsl_asrc_config_pair()
485 clk = asrc_priv->asrck_clk[clk_index[OUT]]; in fsl_asrc_config_pair()
496 return -EINVAL; in fsl_asrc_config_pair()
502 channels = config->channel_num; in fsl_asrc_config_pair()
504 if (asrc_priv->soc->channel_bits < 4) in fsl_asrc_config_pair()
508 regmap_update_bits(asrc->regmap, REG_ASRCNCR, in fsl_asrc_config_pair()
509 ASRCNCR_ANCi_MASK(index, asrc_priv->soc->channel_bits), in fsl_asrc_config_pair()
510 ASRCNCR_ANCi(index, channels, asrc_priv->soc->channel_bits)); in fsl_asrc_config_pair()
513 regmap_update_bits(asrc->regmap, REG_ASRCTR, in fsl_asrc_config_pair()
515 regmap_update_bits(asrc->regmap, REG_ASRCTR, in fsl_asrc_config_pair()
519 regmap_update_bits(asrc->regmap, REG_ASRCSR, in fsl_asrc_config_pair()
529 regmap_update_bits(asrc->regmap, REG_ASRCDR(index), in fsl_asrc_config_pair()
535 regmap_update_bits(asrc->regmap, REG_ASRMCR1(index), in fsl_asrc_config_pair()
541 regmap_update_bits(asrc->regmap, REG_ASRMCR(index), in fsl_asrc_config_pair()
553 regmap_update_bits(asrc->regmap, REG_ASRCTR, in fsl_asrc_config_pair()
557 regmap_update_bits(asrc->regmap, REG_ASRCTR, in fsl_asrc_config_pair()
563 /* Apply configurations for pre- and post-processing */ in fsl_asrc_config_pair()
564 regmap_update_bits(asrc->regmap, REG_ASRCFG, in fsl_asrc_config_pair()
573 * fsl_asrc_start_pair - Start the assigned ASRC pair
580 struct fsl_asrc *asrc = pair->asrc; in fsl_asrc_start_pair() local
581 enum asrc_pair_index index = pair->index; in fsl_asrc_start_pair()
585 regmap_update_bits(asrc->regmap, REG_ASRCTR, in fsl_asrc_start_pair()
591 regmap_read(asrc->regmap, REG_ASRCFG, ®); in fsl_asrc_start_pair()
593 } while (!reg && --retry); in fsl_asrc_start_pair()
595 /* Make the input fifo to ASRC STALL level */ in fsl_asrc_start_pair()
596 regmap_read(asrc->regmap, REG_ASRCNCR, ®); in fsl_asrc_start_pair()
597 for (i = 0; i < pair->channels * 4; i++) in fsl_asrc_start_pair()
598 regmap_write(asrc->regmap, REG_ASRDI(index), 0); in fsl_asrc_start_pair()
601 regmap_write(asrc->regmap, REG_ASRIER, ASRIER_AOLIE); in fsl_asrc_start_pair()
605 * fsl_asrc_stop_pair - Stop the assigned ASRC pair
610 struct fsl_asrc *asrc = pair->asrc; in fsl_asrc_stop_pair() local
611 enum asrc_pair_index index = pair->index; in fsl_asrc_stop_pair()
614 regmap_update_bits(asrc->regmap, REG_ASRCTR, in fsl_asrc_stop_pair()
619 * fsl_asrc_get_dma_channel- Get DMA channel according to the pair and direction.
626 struct fsl_asrc *asrc = pair->asrc; in fsl_asrc_get_dma_channel() local
627 enum asrc_pair_index index = pair->index; in fsl_asrc_get_dma_channel()
632 return dma_request_slave_channel(&asrc->pdev->dev, name); in fsl_asrc_get_dma_channel()
638 struct fsl_asrc *asrc = snd_soc_dai_get_drvdata(dai); in fsl_asrc_dai_startup() local
639 struct fsl_asrc_priv *asrc_priv = asrc->private; in fsl_asrc_dai_startup()
641 /* Odd channel number is not valid for older ASRC (channel_bits==3) */ in fsl_asrc_dai_startup()
642 if (asrc_priv->soc->channel_bits == 3) in fsl_asrc_dai_startup()
643 snd_pcm_hw_constraint_step(substream->runtime, 0, in fsl_asrc_dai_startup()
647 return snd_pcm_hw_constraint_list(substream->runtime, 0, in fsl_asrc_dai_startup()
657 struct fsl_asrc_pair_priv *pair_priv = pair->private; in fsl_asrc_select_clk()
658 struct asrc_config *config = pair_priv->config; in fsl_asrc_select_clk()
669 clk_index = asrc_priv->clk_map[j][i]; in fsl_asrc_select_clk()
670 clk_rate = clk_get_rate(asrc_priv->asrck_clk[clk_index]); in fsl_asrc_select_clk()
685 config->inclk = select_clk[IN]; in fsl_asrc_select_clk()
686 config->outclk = select_clk[OUT]; in fsl_asrc_select_clk()
693 struct fsl_asrc *asrc = snd_soc_dai_get_drvdata(dai); in fsl_asrc_dai_hw_params() local
694 struct fsl_asrc_priv *asrc_priv = asrc->private; in fsl_asrc_dai_hw_params()
695 struct snd_pcm_runtime *runtime = substream->runtime; in fsl_asrc_dai_hw_params()
696 struct fsl_asrc_pair *pair = runtime->private_data; in fsl_asrc_dai_hw_params()
697 struct fsl_asrc_pair_priv *pair_priv = pair->private; in fsl_asrc_dai_hw_params()
705 dev_err(dai->dev, "fail to request asrc pair\n"); in fsl_asrc_dai_hw_params()
709 pair_priv->config = &config; in fsl_asrc_dai_hw_params()
711 config.pair = pair->index; in fsl_asrc_dai_hw_params()
714 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in fsl_asrc_dai_hw_params()
716 config.output_format = asrc->asrc_format; in fsl_asrc_dai_hw_params()
718 config.output_sample_rate = asrc->asrc_rate; in fsl_asrc_dai_hw_params()
720 config.input_format = asrc->asrc_format; in fsl_asrc_dai_hw_params()
722 config.input_sample_rate = asrc->asrc_rate; in fsl_asrc_dai_hw_params()
732 dev_err(dai->dev, "fail to config asrc pair\n"); in fsl_asrc_dai_hw_params()
742 struct snd_pcm_runtime *runtime = substream->runtime; in fsl_asrc_dai_hw_free()
743 struct fsl_asrc_pair *pair = runtime->private_data; in fsl_asrc_dai_hw_free()
754 struct snd_pcm_runtime *runtime = substream->runtime; in fsl_asrc_dai_trigger()
755 struct fsl_asrc_pair *pair = runtime->private_data; in fsl_asrc_dai_trigger()
769 return -EINVAL; in fsl_asrc_dai_trigger()
784 struct fsl_asrc *asrc = snd_soc_dai_get_drvdata(dai); in fsl_asrc_dai_probe() local
786 snd_soc_dai_init_dma_data(dai, &asrc->dma_params_tx, in fsl_asrc_dai_probe()
787 &asrc->dma_params_rx); in fsl_asrc_dai_probe()
799 .stream_name = "ASRC-Playback",
809 .stream_name = "ASRC-Capture",
964 * fsl_asrc_init - Initialize ASRC registers with a default configuration
965 * @asrc: ASRC context
967 static int fsl_asrc_init(struct fsl_asrc *asrc) in fsl_asrc_init() argument
971 /* Halt ASRC internal FP when input FIFO needs data for pair A, B, C */ in fsl_asrc_init()
972 regmap_write(asrc->regmap, REG_ASRCTR, ASRCTR_ASRCEN); in fsl_asrc_init()
975 regmap_write(asrc->regmap, REG_ASRIER, 0x0); in fsl_asrc_init()
978 regmap_write(asrc->regmap, REG_ASRPM1, 0x7fffff); in fsl_asrc_init()
979 regmap_write(asrc->regmap, REG_ASRPM2, 0x255555); in fsl_asrc_init()
980 regmap_write(asrc->regmap, REG_ASRPM3, 0xff7280); in fsl_asrc_init()
981 regmap_write(asrc->regmap, REG_ASRPM4, 0xff7280); in fsl_asrc_init()
982 regmap_write(asrc->regmap, REG_ASRPM5, 0xff7280); in fsl_asrc_init()
985 regmap_update_bits(asrc->regmap, REG_ASRTFR1, in fsl_asrc_init()
990 * the ASRC processing clock. in fsl_asrc_init()
993 ipg_rate = clk_get_rate(asrc->ipg_clk); in fsl_asrc_init()
994 regmap_write(asrc->regmap, REG_ASR76K, ipg_rate / 76000); in fsl_asrc_init()
995 return regmap_write(asrc->regmap, REG_ASR56K, ipg_rate / 56000); in fsl_asrc_init()
999 * fsl_asrc_isr- Interrupt handler for ASRC
1001 * @dev_id: ASRC context
1005 struct fsl_asrc *asrc = (struct fsl_asrc *)dev_id; in fsl_asrc_isr() local
1006 struct device *dev = &asrc->pdev->dev; in fsl_asrc_isr()
1010 regmap_read(asrc->regmap, REG_ASRSTR, &status); in fsl_asrc_isr()
1013 regmap_write(asrc->regmap, REG_ASRSTR, ASRSTR_AOLE); in fsl_asrc_isr()
1016 * We here use dev_dbg() for all exceptions because ASRC itself does in fsl_asrc_isr()
1021 if (!asrc->pair[index]) in fsl_asrc_isr()
1025 asrc->pair[index]->error |= ASRC_TASK_Q_OVERLOAD; in fsl_asrc_isr()
1026 dev_dbg(dev, "ASRC Task Queue FIFO overload\n"); in fsl_asrc_isr()
1030 asrc->pair[index]->error |= ASRC_OUTPUT_TASK_OVERLOAD; in fsl_asrc_isr()
1035 asrc->pair[index]->error |= ASRC_INPUT_TASK_OVERLOAD; in fsl_asrc_isr()
1040 asrc->pair[index]->error |= ASRC_OUTPUT_BUFFER_OVERFLOW; in fsl_asrc_isr()
1045 asrc->pair[index]->error |= ASRC_INPUT_BUFFER_UNDERRUN; in fsl_asrc_isr()
1060 struct device_node *np = pdev->dev.of_node; in fsl_asrc_probe()
1062 struct fsl_asrc *asrc; in fsl_asrc_probe() local
1070 asrc = devm_kzalloc(&pdev->dev, sizeof(*asrc), GFP_KERNEL); in fsl_asrc_probe()
1071 if (!asrc) in fsl_asrc_probe()
1072 return -ENOMEM; in fsl_asrc_probe()
1074 asrc_priv = devm_kzalloc(&pdev->dev, sizeof(*asrc_priv), GFP_KERNEL); in fsl_asrc_probe()
1076 return -ENOMEM; in fsl_asrc_probe()
1078 asrc->pdev = pdev; in fsl_asrc_probe()
1079 asrc->private = asrc_priv; in fsl_asrc_probe()
1083 regs = devm_ioremap_resource(&pdev->dev, res); in fsl_asrc_probe()
1087 asrc->paddr = res->start; in fsl_asrc_probe()
1089 asrc->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "mem", regs, in fsl_asrc_probe()
1091 if (IS_ERR(asrc->regmap)) { in fsl_asrc_probe()
1092 dev_err(&pdev->dev, "failed to init regmap\n"); in fsl_asrc_probe()
1093 return PTR_ERR(asrc->regmap); in fsl_asrc_probe()
1100 ret = devm_request_irq(&pdev->dev, irq, fsl_asrc_isr, 0, in fsl_asrc_probe()
1101 dev_name(&pdev->dev), asrc); in fsl_asrc_probe()
1103 dev_err(&pdev->dev, "failed to claim irq %u: %d\n", irq, ret); in fsl_asrc_probe()
1107 asrc->mem_clk = devm_clk_get(&pdev->dev, "mem"); in fsl_asrc_probe()
1108 if (IS_ERR(asrc->mem_clk)) { in fsl_asrc_probe()
1109 dev_err(&pdev->dev, "failed to get mem clock\n"); in fsl_asrc_probe()
1110 return PTR_ERR(asrc->mem_clk); in fsl_asrc_probe()
1113 asrc->ipg_clk = devm_clk_get(&pdev->dev, "ipg"); in fsl_asrc_probe()
1114 if (IS_ERR(asrc->ipg_clk)) { in fsl_asrc_probe()
1115 dev_err(&pdev->dev, "failed to get ipg clock\n"); in fsl_asrc_probe()
1116 return PTR_ERR(asrc->ipg_clk); in fsl_asrc_probe()
1119 asrc->spba_clk = devm_clk_get(&pdev->dev, "spba"); in fsl_asrc_probe()
1120 if (IS_ERR(asrc->spba_clk)) in fsl_asrc_probe()
1121 dev_warn(&pdev->dev, "failed to get spba clock\n"); in fsl_asrc_probe()
1125 asrc_priv->asrck_clk[i] = devm_clk_get(&pdev->dev, tmp); in fsl_asrc_probe()
1126 if (IS_ERR(asrc_priv->asrck_clk[i])) { in fsl_asrc_probe()
1127 dev_err(&pdev->dev, "failed to get %s clock\n", tmp); in fsl_asrc_probe()
1128 return PTR_ERR(asrc_priv->asrck_clk[i]); in fsl_asrc_probe()
1132 asrc_priv->soc = of_device_get_match_data(&pdev->dev); in fsl_asrc_probe()
1133 if (!asrc_priv->soc) { in fsl_asrc_probe()
1134 dev_err(&pdev->dev, "failed to get soc data\n"); in fsl_asrc_probe()
1135 return -ENODEV; in fsl_asrc_probe()
1138 asrc->use_edma = asrc_priv->soc->use_edma; in fsl_asrc_probe()
1139 asrc->get_dma_channel = fsl_asrc_get_dma_channel; in fsl_asrc_probe()
1140 asrc->request_pair = fsl_asrc_request_pair; in fsl_asrc_probe()
1141 asrc->release_pair = fsl_asrc_release_pair; in fsl_asrc_probe()
1142 asrc->get_fifo_addr = fsl_asrc_get_fifo_addr; in fsl_asrc_probe()
1143 asrc->pair_priv_size = sizeof(struct fsl_asrc_pair_priv); in fsl_asrc_probe()
1145 if (of_device_is_compatible(np, "fsl,imx35-asrc")) { in fsl_asrc_probe()
1146 asrc_priv->clk_map[IN] = input_clk_map_imx35; in fsl_asrc_probe()
1147 asrc_priv->clk_map[OUT] = output_clk_map_imx35; in fsl_asrc_probe()
1148 } else if (of_device_is_compatible(np, "fsl,imx53-asrc")) { in fsl_asrc_probe()
1149 asrc_priv->clk_map[IN] = input_clk_map_imx53; in fsl_asrc_probe()
1150 asrc_priv->clk_map[OUT] = output_clk_map_imx53; in fsl_asrc_probe()
1151 } else if (of_device_is_compatible(np, "fsl,imx8qm-asrc") || in fsl_asrc_probe()
1152 of_device_is_compatible(np, "fsl,imx8qxp-asrc")) { in fsl_asrc_probe()
1153 ret = of_property_read_u32(np, "fsl,asrc-clk-map", &map_idx); in fsl_asrc_probe()
1155 dev_err(&pdev->dev, "failed to get clk map index\n"); in fsl_asrc_probe()
1160 dev_err(&pdev->dev, "unsupported clk map index\n"); in fsl_asrc_probe()
1161 return -EINVAL; in fsl_asrc_probe()
1163 if (of_device_is_compatible(np, "fsl,imx8qm-asrc")) { in fsl_asrc_probe()
1164 asrc_priv->clk_map[IN] = clk_map_imx8qm[map_idx]; in fsl_asrc_probe()
1165 asrc_priv->clk_map[OUT] = clk_map_imx8qm[map_idx]; in fsl_asrc_probe()
1167 asrc_priv->clk_map[IN] = clk_map_imx8qxp[map_idx]; in fsl_asrc_probe()
1168 asrc_priv->clk_map[OUT] = clk_map_imx8qxp[map_idx]; in fsl_asrc_probe()
1172 ret = fsl_asrc_init(asrc); in fsl_asrc_probe()
1174 dev_err(&pdev->dev, "failed to init asrc %d\n", ret); in fsl_asrc_probe()
1178 asrc->channel_avail = 10; in fsl_asrc_probe()
1180 ret = of_property_read_u32(np, "fsl,asrc-rate", in fsl_asrc_probe()
1181 &asrc->asrc_rate); in fsl_asrc_probe()
1183 dev_err(&pdev->dev, "failed to get output rate\n"); in fsl_asrc_probe()
1187 ret = of_property_read_u32(np, "fsl,asrc-format", &asrc->asrc_format); in fsl_asrc_probe()
1189 ret = of_property_read_u32(np, "fsl,asrc-width", &width); in fsl_asrc_probe()
1191 dev_err(&pdev->dev, "failed to decide output format\n"); in fsl_asrc_probe()
1197 asrc->asrc_format = SNDRV_PCM_FORMAT_S16_LE; in fsl_asrc_probe()
1200 asrc->asrc_format = SNDRV_PCM_FORMAT_S24_LE; in fsl_asrc_probe()
1203 dev_warn(&pdev->dev, in fsl_asrc_probe()
1205 asrc->asrc_format = SNDRV_PCM_FORMAT_S24_LE; in fsl_asrc_probe()
1210 if (!(FSL_ASRC_FORMATS & (1ULL << asrc->asrc_format))) { in fsl_asrc_probe()
1211 dev_warn(&pdev->dev, "unsupported width, use default S24_LE\n"); in fsl_asrc_probe()
1212 asrc->asrc_format = SNDRV_PCM_FORMAT_S24_LE; in fsl_asrc_probe()
1215 platform_set_drvdata(pdev, asrc); in fsl_asrc_probe()
1216 pm_runtime_enable(&pdev->dev); in fsl_asrc_probe()
1217 spin_lock_init(&asrc->lock); in fsl_asrc_probe()
1218 regcache_cache_only(asrc->regmap, true); in fsl_asrc_probe()
1220 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_asrc_component, in fsl_asrc_probe()
1223 dev_err(&pdev->dev, "failed to register ASoC DAI\n"); in fsl_asrc_probe()
1233 struct fsl_asrc *asrc = dev_get_drvdata(dev); in fsl_asrc_runtime_resume() local
1234 struct fsl_asrc_priv *asrc_priv = asrc->private; in fsl_asrc_runtime_resume()
1238 ret = clk_prepare_enable(asrc->mem_clk); in fsl_asrc_runtime_resume()
1241 ret = clk_prepare_enable(asrc->ipg_clk); in fsl_asrc_runtime_resume()
1244 if (!IS_ERR(asrc->spba_clk)) { in fsl_asrc_runtime_resume()
1245 ret = clk_prepare_enable(asrc->spba_clk); in fsl_asrc_runtime_resume()
1250 ret = clk_prepare_enable(asrc_priv->asrck_clk[i]); in fsl_asrc_runtime_resume()
1256 regmap_read(asrc->regmap, REG_ASRCTR, &asrctr); in fsl_asrc_runtime_resume()
1257 regmap_update_bits(asrc->regmap, REG_ASRCTR, in fsl_asrc_runtime_resume()
1261 regcache_cache_only(asrc->regmap, false); in fsl_asrc_runtime_resume()
1262 regcache_mark_dirty(asrc->regmap); in fsl_asrc_runtime_resume()
1263 regcache_sync(asrc->regmap); in fsl_asrc_runtime_resume()
1265 regmap_update_bits(asrc->regmap, REG_ASRCFG, in fsl_asrc_runtime_resume()
1267 ASRCFG_PREMODi_ALL_MASK, asrc_priv->regcache_cfg); in fsl_asrc_runtime_resume()
1270 regmap_update_bits(asrc->regmap, REG_ASRCTR, in fsl_asrc_runtime_resume()
1276 for (i--; i >= 0; i--) in fsl_asrc_runtime_resume()
1277 clk_disable_unprepare(asrc_priv->asrck_clk[i]); in fsl_asrc_runtime_resume()
1278 if (!IS_ERR(asrc->spba_clk)) in fsl_asrc_runtime_resume()
1279 clk_disable_unprepare(asrc->spba_clk); in fsl_asrc_runtime_resume()
1281 clk_disable_unprepare(asrc->ipg_clk); in fsl_asrc_runtime_resume()
1283 clk_disable_unprepare(asrc->mem_clk); in fsl_asrc_runtime_resume()
1289 struct fsl_asrc *asrc = dev_get_drvdata(dev); in fsl_asrc_runtime_suspend() local
1290 struct fsl_asrc_priv *asrc_priv = asrc->private; in fsl_asrc_runtime_suspend()
1293 regmap_read(asrc->regmap, REG_ASRCFG, in fsl_asrc_runtime_suspend()
1294 &asrc_priv->regcache_cfg); in fsl_asrc_runtime_suspend()
1296 regcache_cache_only(asrc->regmap, true); in fsl_asrc_runtime_suspend()
1299 clk_disable_unprepare(asrc_priv->asrck_clk[i]); in fsl_asrc_runtime_suspend()
1300 if (!IS_ERR(asrc->spba_clk)) in fsl_asrc_runtime_suspend()
1301 clk_disable_unprepare(asrc->spba_clk); in fsl_asrc_runtime_suspend()
1302 clk_disable_unprepare(asrc->ipg_clk); in fsl_asrc_runtime_suspend()
1303 clk_disable_unprepare(asrc->mem_clk); in fsl_asrc_runtime_suspend()
1336 { .compatible = "fsl,imx35-asrc", .data = &fsl_asrc_imx35_data },
1337 { .compatible = "fsl,imx53-asrc", .data = &fsl_asrc_imx53_data },
1338 { .compatible = "fsl,imx8qm-asrc", .data = &fsl_asrc_imx8qm_data },
1339 { .compatible = "fsl,imx8qxp-asrc", .data = &fsl_asrc_imx8qxp_data },
1347 .name = "fsl-asrc",
1354 MODULE_DESCRIPTION("Freescale ASRC ASoC driver");
1356 MODULE_ALIAS("platform:fsl-asrc");