Lines Matching +full:adc +full:- +full:use +full:- +full:res

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright 2015 Maxime Ripard <maxime.ripard@free-electrons.com>
7 * Copyright 2016 Chen-Yu Tsai <wens@csie.org>
75 /* Codec ADC digital controls and FIFO registers */
88 /* Codec ADC side analog signal controls */
183 /* ADC mixer controls */
249 regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_start_playback()
253 regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_start_playback()
260 regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_stop_playback()
266 /* Enable ADC DRQ */ in sun4i_codec_start_capture()
267 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_start_capture()
273 /* Disable ADC DRQ */ in sun4i_codec_stop_capture()
274 regmap_field_clear_bits(scodec->reg_adc_fifoc, in sun4i_codec_stop_capture()
282 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_trigger()
288 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in sun4i_codec_trigger()
297 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in sun4i_codec_trigger()
304 return -EINVAL; in sun4i_codec_trigger()
314 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_prepare_capture()
318 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_prepare_capture()
323 regmap_field_update_bits(scodec->reg_adc_fifoc, in sun4i_codec_prepare_capture()
332 if (of_device_is_compatible(scodec->dev->of_node, in sun4i_codec_prepare_capture()
333 "allwinner,sun4i-a10-codec") || in sun4i_codec_prepare_capture()
334 of_device_is_compatible(scodec->dev->of_node, in sun4i_codec_prepare_capture()
335 "allwinner,sun7i-a20-codec")) { in sun4i_codec_prepare_capture()
336 regmap_update_bits(scodec->regmap, SUN4I_CODEC_ADC_ACTL, in sun4i_codec_prepare_capture()
341 if (of_device_is_compatible(scodec->dev->of_node, in sun4i_codec_prepare_capture()
342 "allwinner,sun7i-a20-codec")) in sun4i_codec_prepare_capture()
344 regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_TUNE, in sun4i_codec_prepare_capture()
355 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_prepare_playback()
359 regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_prepare_playback()
363 regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_prepare_playback()
367 if (substream->runtime->rate > 32000) in sun4i_codec_prepare_playback()
368 /* Use 64 bits FIR filter */ in sun4i_codec_prepare_playback()
371 /* Use 32 bits FIR filter */ in sun4i_codec_prepare_playback()
374 regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_prepare_playback()
379 regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_prepare_playback()
388 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in sun4i_codec_prepare()
462 return -EINVAL; in sun4i_codec_get_hw_rate()
470 /* Set ADC sample rate */ in sun4i_codec_hw_params_capture()
471 regmap_field_update_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
475 /* Set the number of channels we want to use */ in sun4i_codec_hw_params_capture()
477 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
480 regmap_field_clear_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
484 if (hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min == 32) { in sun4i_codec_hw_params_capture()
485 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
488 regmap_field_clear_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
491 scodec->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in sun4i_codec_hw_params_capture()
493 regmap_field_clear_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
497 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
500 scodec->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sun4i_codec_hw_params_capture()
513 regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_hw_params_playback()
517 /* Set the number of channels we want to use */ in sun4i_codec_hw_params_playback()
523 regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_hw_params_playback()
528 if (hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min == 32) { in sun4i_codec_hw_params_playback()
529 regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_hw_params_playback()
533 regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_hw_params_playback()
536 scodec->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in sun4i_codec_hw_params_playback()
538 regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_hw_params_playback()
542 regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_hw_params_playback()
545 scodec->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sun4i_codec_hw_params_playback()
556 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_hw_params()
562 return -EINVAL; in sun4i_codec_hw_params()
564 ret = clk_set_rate(scodec->clk_module, clk_freq); in sun4i_codec_hw_params()
572 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in sun4i_codec_hw_params()
584 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_startup()
590 regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC, in sun4i_codec_startup()
593 return clk_prepare_enable(scodec->clk_module); in sun4i_codec_startup()
600 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_shutdown()
602 clk_disable_unprepare(scodec->clk_module); in sun4i_codec_shutdown()
652 static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1);
653 static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_loopback_gain_scale, -150, 150,
655 static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_preamp_gain_scale, -1200, 300,
657 static DECLARE_TLV_DB_SCALE(sun4i_codec_fmin_loopback_gain_scale, -450, 150,
659 static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150,
749 SND_SOC_DAPM_SUPPLY("ADC", SUN4I_CODEC_ADC_FIFOC,
759 SND_SOC_DAPM_ADC("Left ADC", "Codec Capture", SUN4I_CODEC_ADC_ACTL,
761 SND_SOC_DAPM_ADC("Right ADC", "Codec Capture", SUN4I_CODEC_ADC_ACTL,
786 /* Mic Pre-Amplifiers */
787 SND_SOC_DAPM_PGA("MIC1 Pre-Amplifier", SUN4I_CODEC_ADC_ACTL,
789 SND_SOC_DAPM_PGA("MIC2 Pre-Amplifier", SUN4I_CODEC_ADC_ACTL,
812 /* Left ADC / DAC Routes */
813 { "Left ADC", NULL, "ADC" },
816 /* Right ADC / DAC Routes */
817 { "Right ADC", NULL, "ADC" },
826 { "Right Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" },
827 { "Right Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
834 { "Left Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" },
835 { "Left Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
849 { "Left ADC", NULL, "MIC1 Pre-Amplifier" },
850 { "Right ADC", NULL, "MIC1 Pre-Amplifier" },
851 { "MIC1 Pre-Amplifier", NULL, "Mic1"},
855 { "Left ADC", NULL, "MIC2 Pre-Amplifier" },
856 { "Right ADC", NULL, "MIC2 Pre-Amplifier" },
857 { "MIC2 Pre-Amplifier", NULL, "Mic2"},
911 /* ADC mixer controls */
983 static const DECLARE_TLV_DB_SCALE(sun6i_codec_dvol_scale, -7308, 116, 0);
984 static const DECLARE_TLV_DB_SCALE(sun6i_codec_hp_vol_scale, -6300, 100, 1);
986 -450, 150, 0);
989 2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0),
1016 /* Mixer pre-gains */
1034 SOC_DOUBLE_TLV("ADC Capture Volume",
1064 SND_SOC_DAPM_SUPPLY("ADC Enable", SUN6I_CODEC_ADC_FIFOC,
1069 SND_SOC_DAPM_ADC("Left ADC", "Codec Capture", SUN6I_CODEC_ADC_ACTL,
1071 SND_SOC_DAPM_ADC("Right ADC", "Codec Capture", SUN6I_CODEC_ADC_ACTL,
1074 /* ADC Mixers */
1075 SOC_MIXER_ARRAY("Left ADC Mixer", SND_SOC_NOPM, 0, 0,
1077 SOC_MIXER_ARRAY("Right ADC Mixer", SND_SOC_NOPM, 0, 0,
1143 /* Left ADC Mixer Routes */
1144 { "Left ADC Mixer", "Mixer Capture Switch", "Left Mixer" },
1145 { "Left ADC Mixer", "Mixer Reversed Capture Switch", "Right Mixer" },
1146 { "Left ADC Mixer", "Line In Capture Switch", "LINEIN" },
1147 { "Left ADC Mixer", "Mic1 Capture Switch", "Mic1 Amplifier" },
1148 { "Left ADC Mixer", "Mic2 Capture Switch", "Mic2 Amplifier" },
1150 /* Right ADC Mixer Routes */
1151 { "Right ADC Mixer", "Mixer Capture Switch", "Right Mixer" },
1152 { "Right ADC Mixer", "Mixer Reversed Capture Switch", "Left Mixer" },
1153 { "Right ADC Mixer", "Line In Capture Switch", "LINEIN" },
1154 { "Right ADC Mixer", "Mic1 Capture Switch", "Mic1 Amplifier" },
1155 { "Right ADC Mixer", "Mic2 Capture Switch", "Mic2 Amplifier" },
1173 /* ADC Routes */
1174 { "Left ADC", NULL, "ADC Enable" },
1175 { "Right ADC", NULL, "ADC Enable" },
1176 { "Left ADC", NULL, "Left ADC Mixer" },
1177 { "Right ADC", NULL, "Right ADC Mixer" },
1201 SND_SOC_DAPM_SUPPLY("ADC Enable", SUN6I_CODEC_ADC_FIFOC,
1220 .name = "sun4i-codec",
1235 snd_soc_dai_init_dma_data(dai, &scodec->playback_dma_data, in sun4i_codec_dai_probe()
1236 &scodec->capture_dma_data); in sun4i_codec_dai_probe()
1246 .name = "sun4i-codec-cpu-dai",
1276 link->cpus = &dlc[0]; in sun4i_codec_create_link()
1277 link->codecs = &dlc[1]; in sun4i_codec_create_link()
1278 link->platforms = &dlc[2]; in sun4i_codec_create_link()
1280 link->num_cpus = 1; in sun4i_codec_create_link()
1281 link->num_codecs = 1; in sun4i_codec_create_link()
1282 link->num_platforms = 1; in sun4i_codec_create_link()
1284 link->name = "cdc"; in sun4i_codec_create_link()
1285 link->stream_name = "CDC PCM"; in sun4i_codec_create_link()
1286 link->codecs->dai_name = "Codec"; in sun4i_codec_create_link()
1287 link->cpus->dai_name = dev_name(dev); in sun4i_codec_create_link()
1288 link->codecs->name = dev_name(dev); in sun4i_codec_create_link()
1289 link->platforms->name = dev_name(dev); in sun4i_codec_create_link()
1290 link->dai_fmt = SND_SOC_DAIFMT_I2S; in sun4i_codec_create_link()
1300 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(w->dapm->card); in sun4i_codec_spk_event()
1302 gpiod_set_value_cansleep(scodec->gpio_pa, in sun4i_codec_spk_event()
1332 return ERR_PTR(-ENOMEM); in sun4i_codec_create_card()
1334 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun4i_codec_create_card()
1335 if (!card->dai_link) in sun4i_codec_create_card()
1336 return ERR_PTR(-ENOMEM); in sun4i_codec_create_card()
1338 card->dev = dev; in sun4i_codec_create_card()
1339 card->owner = THIS_MODULE; in sun4i_codec_create_card()
1340 card->name = "sun4i-codec"; in sun4i_codec_create_card()
1341 card->dapm_widgets = sun4i_codec_card_dapm_widgets; in sun4i_codec_create_card()
1342 card->num_dapm_widgets = ARRAY_SIZE(sun4i_codec_card_dapm_widgets); in sun4i_codec_create_card()
1343 card->dapm_routes = sun4i_codec_card_dapm_routes; in sun4i_codec_create_card()
1344 card->num_dapm_routes = ARRAY_SIZE(sun4i_codec_card_dapm_routes); in sun4i_codec_create_card()
1365 return ERR_PTR(-ENOMEM); in sun6i_codec_create_card()
1367 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun6i_codec_create_card()
1368 if (!card->dai_link) in sun6i_codec_create_card()
1369 return ERR_PTR(-ENOMEM); in sun6i_codec_create_card()
1371 card->dev = dev; in sun6i_codec_create_card()
1372 card->owner = THIS_MODULE; in sun6i_codec_create_card()
1373 card->name = "A31 Audio Codec"; in sun6i_codec_create_card()
1374 card->dapm_widgets = sun6i_codec_card_dapm_widgets; in sun6i_codec_create_card()
1375 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); in sun6i_codec_create_card()
1376 card->fully_routed = true; in sun6i_codec_create_card()
1378 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); in sun6i_codec_create_card()
1380 dev_warn(dev, "failed to parse audio-routing: %d\n", ret); in sun6i_codec_create_card()
1387 /* ADC Routes */
1388 { "Left ADC", NULL, "ADC Enable" },
1389 { "Right ADC", NULL, "ADC Enable" },
1390 { "Codec Capture", NULL, "Left ADC" },
1391 { "Codec Capture", NULL, "Right ADC" },
1411 return ERR_PTR(-ENOMEM); in sun8i_a23_codec_create_card()
1413 aux_dev.dlc.of_node = of_parse_phandle(dev->of_node, in sun8i_a23_codec_create_card()
1414 "allwinner,codec-analog-controls", in sun8i_a23_codec_create_card()
1418 return ERR_PTR(-EINVAL); in sun8i_a23_codec_create_card()
1421 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun8i_a23_codec_create_card()
1422 if (!card->dai_link) in sun8i_a23_codec_create_card()
1423 return ERR_PTR(-ENOMEM); in sun8i_a23_codec_create_card()
1425 card->dev = dev; in sun8i_a23_codec_create_card()
1426 card->owner = THIS_MODULE; in sun8i_a23_codec_create_card()
1427 card->name = "A23 Audio Codec"; in sun8i_a23_codec_create_card()
1428 card->dapm_widgets = sun6i_codec_card_dapm_widgets; in sun8i_a23_codec_create_card()
1429 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); in sun8i_a23_codec_create_card()
1430 card->dapm_routes = sun8i_codec_card_routes; in sun8i_a23_codec_create_card()
1431 card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes); in sun8i_a23_codec_create_card()
1432 card->aux_dev = &aux_dev; in sun8i_a23_codec_create_card()
1433 card->num_aux_devs = 1; in sun8i_a23_codec_create_card()
1434 card->fully_routed = true; in sun8i_a23_codec_create_card()
1436 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); in sun8i_a23_codec_create_card()
1438 dev_warn(dev, "failed to parse audio-routing: %d\n", ret); in sun8i_a23_codec_create_card()
1450 return ERR_PTR(-ENOMEM); in sun8i_h3_codec_create_card()
1452 aux_dev.dlc.of_node = of_parse_phandle(dev->of_node, in sun8i_h3_codec_create_card()
1453 "allwinner,codec-analog-controls", in sun8i_h3_codec_create_card()
1457 return ERR_PTR(-EINVAL); in sun8i_h3_codec_create_card()
1460 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun8i_h3_codec_create_card()
1461 if (!card->dai_link) in sun8i_h3_codec_create_card()
1462 return ERR_PTR(-ENOMEM); in sun8i_h3_codec_create_card()
1464 card->dev = dev; in sun8i_h3_codec_create_card()
1465 card->owner = THIS_MODULE; in sun8i_h3_codec_create_card()
1466 card->name = "H3 Audio Codec"; in sun8i_h3_codec_create_card()
1467 card->dapm_widgets = sun6i_codec_card_dapm_widgets; in sun8i_h3_codec_create_card()
1468 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); in sun8i_h3_codec_create_card()
1469 card->dapm_routes = sun8i_codec_card_routes; in sun8i_h3_codec_create_card()
1470 card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes); in sun8i_h3_codec_create_card()
1471 card->aux_dev = &aux_dev; in sun8i_h3_codec_create_card()
1472 card->num_aux_devs = 1; in sun8i_h3_codec_create_card()
1473 card->fully_routed = true; in sun8i_h3_codec_create_card()
1475 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); in sun8i_h3_codec_create_card()
1477 dev_warn(dev, "failed to parse audio-routing: %d\n", ret); in sun8i_h3_codec_create_card()
1489 return ERR_PTR(-ENOMEM); in sun8i_v3s_codec_create_card()
1491 aux_dev.dlc.of_node = of_parse_phandle(dev->of_node, in sun8i_v3s_codec_create_card()
1492 "allwinner,codec-analog-controls", in sun8i_v3s_codec_create_card()
1496 return ERR_PTR(-EINVAL); in sun8i_v3s_codec_create_card()
1499 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun8i_v3s_codec_create_card()
1500 if (!card->dai_link) in sun8i_v3s_codec_create_card()
1501 return ERR_PTR(-ENOMEM); in sun8i_v3s_codec_create_card()
1503 card->dev = dev; in sun8i_v3s_codec_create_card()
1504 card->owner = THIS_MODULE; in sun8i_v3s_codec_create_card()
1505 card->name = "V3s Audio Codec"; in sun8i_v3s_codec_create_card()
1506 card->dapm_widgets = sun6i_codec_card_dapm_widgets; in sun8i_v3s_codec_create_card()
1507 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); in sun8i_v3s_codec_create_card()
1508 card->dapm_routes = sun8i_codec_card_routes; in sun8i_v3s_codec_create_card()
1509 card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes); in sun8i_v3s_codec_create_card()
1510 card->aux_dev = &aux_dev; in sun8i_v3s_codec_create_card()
1511 card->num_aux_devs = 1; in sun8i_v3s_codec_create_card()
1512 card->fully_routed = true; in sun8i_v3s_codec_create_card()
1514 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); in sun8i_v3s_codec_create_card()
1516 dev_warn(dev, "failed to parse audio-routing: %d\n", ret); in sun8i_v3s_codec_create_card()
1642 .compatible = "allwinner,sun4i-a10-codec",
1646 .compatible = "allwinner,sun6i-a31-codec",
1650 .compatible = "allwinner,sun7i-a20-codec",
1654 .compatible = "allwinner,sun8i-a23-codec",
1658 .compatible = "allwinner,sun8i-h3-codec",
1662 .compatible = "allwinner,sun8i-v3s-codec",
1674 struct resource *res; in sun4i_codec_probe() local
1678 scodec = devm_kzalloc(&pdev->dev, sizeof(*scodec), GFP_KERNEL); in sun4i_codec_probe()
1680 return -ENOMEM; in sun4i_codec_probe()
1682 scodec->dev = &pdev->dev; in sun4i_codec_probe()
1684 base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in sun4i_codec_probe()
1688 quirks = of_device_get_match_data(&pdev->dev); in sun4i_codec_probe()
1690 dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); in sun4i_codec_probe()
1691 return -ENODEV; in sun4i_codec_probe()
1694 scodec->regmap = devm_regmap_init_mmio(&pdev->dev, base, in sun4i_codec_probe()
1695 quirks->regmap_config); in sun4i_codec_probe()
1696 if (IS_ERR(scodec->regmap)) { in sun4i_codec_probe()
1697 dev_err(&pdev->dev, "Failed to create our regmap\n"); in sun4i_codec_probe()
1698 return PTR_ERR(scodec->regmap); in sun4i_codec_probe()
1702 scodec->clk_apb = devm_clk_get(&pdev->dev, "apb"); in sun4i_codec_probe()
1703 if (IS_ERR(scodec->clk_apb)) { in sun4i_codec_probe()
1704 dev_err(&pdev->dev, "Failed to get the APB clock\n"); in sun4i_codec_probe()
1705 return PTR_ERR(scodec->clk_apb); in sun4i_codec_probe()
1708 scodec->clk_module = devm_clk_get(&pdev->dev, "codec"); in sun4i_codec_probe()
1709 if (IS_ERR(scodec->clk_module)) { in sun4i_codec_probe()
1710 dev_err(&pdev->dev, "Failed to get the module clock\n"); in sun4i_codec_probe()
1711 return PTR_ERR(scodec->clk_module); in sun4i_codec_probe()
1714 if (quirks->has_reset) { in sun4i_codec_probe()
1715 scodec->rst = devm_reset_control_get_exclusive(&pdev->dev, in sun4i_codec_probe()
1717 if (IS_ERR(scodec->rst)) { in sun4i_codec_probe()
1718 dev_err(&pdev->dev, "Failed to get reset control\n"); in sun4i_codec_probe()
1719 return PTR_ERR(scodec->rst); in sun4i_codec_probe()
1723 scodec->gpio_pa = devm_gpiod_get_optional(&pdev->dev, "allwinner,pa", in sun4i_codec_probe()
1725 if (IS_ERR(scodec->gpio_pa)) { in sun4i_codec_probe()
1726 ret = PTR_ERR(scodec->gpio_pa); in sun4i_codec_probe()
1727 dev_err_probe(&pdev->dev, ret, "Failed to get pa gpio\n"); in sun4i_codec_probe()
1732 scodec->reg_adc_fifoc = devm_regmap_field_alloc(&pdev->dev, in sun4i_codec_probe()
1733 scodec->regmap, in sun4i_codec_probe()
1734 quirks->reg_adc_fifoc); in sun4i_codec_probe()
1735 if (IS_ERR(scodec->reg_adc_fifoc)) { in sun4i_codec_probe()
1736 ret = PTR_ERR(scodec->reg_adc_fifoc); in sun4i_codec_probe()
1737 dev_err(&pdev->dev, "Failed to create regmap fields: %d\n", in sun4i_codec_probe()
1743 if (clk_prepare_enable(scodec->clk_apb)) { in sun4i_codec_probe()
1744 dev_err(&pdev->dev, "Failed to enable the APB clock\n"); in sun4i_codec_probe()
1745 return -EINVAL; in sun4i_codec_probe()
1749 if (scodec->rst) { in sun4i_codec_probe()
1750 ret = reset_control_deassert(scodec->rst); in sun4i_codec_probe()
1752 dev_err(&pdev->dev, in sun4i_codec_probe()
1759 scodec->playback_dma_data.addr = res->start + quirks->reg_dac_txdata; in sun4i_codec_probe()
1760 scodec->playback_dma_data.maxburst = 8; in sun4i_codec_probe()
1761 scodec->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sun4i_codec_probe()
1764 scodec->capture_dma_data.addr = res->start + quirks->reg_adc_rxdata; in sun4i_codec_probe()
1765 scodec->capture_dma_data.maxburst = 8; in sun4i_codec_probe()
1766 scodec->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sun4i_codec_probe()
1768 ret = devm_snd_soc_register_component(&pdev->dev, quirks->codec, in sun4i_codec_probe()
1771 dev_err(&pdev->dev, "Failed to register our codec\n"); in sun4i_codec_probe()
1775 ret = devm_snd_soc_register_component(&pdev->dev, in sun4i_codec_probe()
1779 dev_err(&pdev->dev, "Failed to register our DAI\n"); in sun4i_codec_probe()
1783 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); in sun4i_codec_probe()
1785 dev_err(&pdev->dev, "Failed to register against DMAEngine\n"); in sun4i_codec_probe()
1789 card = quirks->create_card(&pdev->dev); in sun4i_codec_probe()
1792 dev_err(&pdev->dev, "Failed to create our card\n"); in sun4i_codec_probe()
1800 dev_err_probe(&pdev->dev, ret, "Failed to register our card\n"); in sun4i_codec_probe()
1807 if (scodec->rst) in sun4i_codec_probe()
1808 reset_control_assert(scodec->rst); in sun4i_codec_probe()
1810 clk_disable_unprepare(scodec->clk_apb); in sun4i_codec_probe()
1820 if (scodec->rst) in sun4i_codec_remove()
1821 reset_control_assert(scodec->rst); in sun4i_codec_remove()
1822 clk_disable_unprepare(scodec->clk_apb); in sun4i_codec_remove()
1827 .name = "sun4i-codec",
1838 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
1839 MODULE_AUTHOR("Chen-Yu Tsai <wens@csie.org>");