Lines Matching +full:analog +full:- +full:out

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>
49 /* Codec DAC side analog signal controls */
88 /* Codec ADC side analog signal controls */
122 * have been moved around to accommodate extra analog controls.
167 /* Microphone, line out and phone out controls */
204 /* Analog performance tuning controls */
288 regmap_field_set_bits(scodec->reg_dac_fifoc, in sun4i_codec_start_playback()
292 regmap_field_set_bits(scodec->reg_dac_fifoc, in sun4i_codec_start_playback()
299 regmap_field_clear_bits(scodec->reg_dac_fifoc, in sun4i_codec_stop_playback()
306 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_start_capture()
313 regmap_field_clear_bits(scodec->reg_adc_fifoc, in sun4i_codec_stop_capture()
321 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_trigger()
327 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in sun4i_codec_trigger()
336 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in sun4i_codec_trigger()
343 return -EINVAL; in sun4i_codec_trigger()
353 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_prepare_capture()
357 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_prepare_capture()
362 regmap_field_update_bits(scodec->reg_adc_fifoc, in sun4i_codec_prepare_capture()
371 if (of_device_is_compatible(scodec->dev->of_node, in sun4i_codec_prepare_capture()
372 "allwinner,sun4i-a10-codec") || in sun4i_codec_prepare_capture()
373 of_device_is_compatible(scodec->dev->of_node, in sun4i_codec_prepare_capture()
374 "allwinner,sun7i-a20-codec")) { in sun4i_codec_prepare_capture()
375 regmap_update_bits(scodec->regmap, SUN4I_CODEC_ADC_ACTL, in sun4i_codec_prepare_capture()
380 if (of_device_is_compatible(scodec->dev->of_node, in sun4i_codec_prepare_capture()
381 "allwinner,sun7i-a20-codec")) in sun4i_codec_prepare_capture()
383 regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_TUNE, in sun4i_codec_prepare_capture()
394 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_prepare_playback()
398 regmap_field_set_bits(scodec->reg_dac_fifoc, in sun4i_codec_prepare_playback()
402 regmap_field_update_bits(scodec->reg_dac_fifoc, in sun4i_codec_prepare_playback()
406 if (substream->runtime->rate > 32000) in sun4i_codec_prepare_playback()
413 regmap_field_update_bits(scodec->reg_dac_fifoc, in sun4i_codec_prepare_playback()
418 regmap_field_clear_bits(scodec->reg_dac_fifoc, in sun4i_codec_prepare_playback()
427 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in sun4i_codec_prepare()
501 return -EINVAL; in sun4i_codec_get_hw_rate()
510 regmap_field_update_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
516 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
519 regmap_field_clear_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
523 if (hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min == 32) { in sun4i_codec_hw_params_capture()
524 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
527 regmap_field_clear_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
530 scodec->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in sun4i_codec_hw_params_capture()
532 regmap_field_clear_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
536 regmap_field_set_bits(scodec->reg_adc_fifoc, in sun4i_codec_hw_params_capture()
539 scodec->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sun4i_codec_hw_params_capture()
552 regmap_field_update_bits(scodec->reg_dac_fifoc, in sun4i_codec_hw_params_playback()
562 regmap_field_update_bits(scodec->reg_dac_fifoc, in sun4i_codec_hw_params_playback()
567 if (hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min == 32) { in sun4i_codec_hw_params_playback()
568 regmap_field_set_bits(scodec->reg_dac_fifoc, in sun4i_codec_hw_params_playback()
572 regmap_field_clear_bits(scodec->reg_dac_fifoc, in sun4i_codec_hw_params_playback()
575 scodec->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in sun4i_codec_hw_params_playback()
577 regmap_field_clear_bits(scodec->reg_dac_fifoc, in sun4i_codec_hw_params_playback()
581 regmap_field_set_bits(scodec->reg_dac_fifoc, in sun4i_codec_hw_params_playback()
584 scodec->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sun4i_codec_hw_params_playback()
595 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_hw_params()
601 return -EINVAL; in sun4i_codec_hw_params()
603 ret = clk_set_rate(scodec->clk_module, clk_freq); in sun4i_codec_hw_params()
611 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in sun4i_codec_hw_params()
623 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_startup()
629 regmap_field_set_bits(scodec->reg_dac_fifoc, in sun4i_codec_startup()
632 return clk_prepare_enable(scodec->clk_module); in sun4i_codec_startup()
639 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); in sun4i_codec_shutdown()
641 clk_disable_unprepare(scodec->clk_module); in sun4i_codec_shutdown()
691 static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1);
692 static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_loopback_gain_scale, -150, 150,
694 static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_preamp_gain_scale, -1200, 300,
696 static DECLARE_TLV_DB_SCALE(sun4i_codec_fmin_loopback_gain_scale, -450, 150,
698 static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150,
797 /* Analog parts of the ADCs */
803 /* Analog parts of the DACs */
825 /* Mic Pre-Amplifiers */
826 SND_SOC_DAPM_PGA("MIC1 Pre-Amplifier", SUN4I_CODEC_ADC_ACTL,
828 SND_SOC_DAPM_PGA("MIC2 Pre-Amplifier", SUN4I_CODEC_ADC_ACTL,
865 { "Right Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" },
866 { "Right Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
873 { "Left Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" },
874 { "Left Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
888 { "Left ADC", NULL, "MIC1 Pre-Amplifier" },
889 { "Right ADC", NULL, "MIC1 Pre-Amplifier" },
890 { "MIC1 Pre-Amplifier", NULL, "Mic1"},
894 { "Left ADC", NULL, "MIC2 Pre-Amplifier" },
895 { "Right ADC", NULL, "MIC2 Pre-Amplifier" },
896 { "MIC2 Pre-Amplifier", NULL, "Mic2"},
1005 /* line out controls */
1017 SOC_DAPM_ENUM("Line Out Source Playback Route",
1022 static const DECLARE_TLV_DB_SCALE(sun6i_codec_dvol_scale, -7308, 116, 0);
1023 static const DECLARE_TLV_DB_SCALE(sun6i_codec_hp_vol_scale, -6300, 100, 1);
1025 -450, 150, 0);
1028 2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0),
1043 SOC_SINGLE_TLV("Line Out Playback Volume",
1051 SOC_DOUBLE("Line Out Playback Switch",
1055 /* Mixer pre-gains */
1107 /* Analog parts of the ADCs */
1124 /* Analog parts of the DACs */
1151 /* Line Out path */
1152 SND_SOC_DAPM_MUX("Line Out Source Playback Route",
1205 /* Line Out Routes */
1206 { "Line Out Source Playback Route", "Stereo", "Left Mixer" },
1207 { "Line Out Source Playback Route", "Stereo", "Right Mixer" },
1208 { "Line Out Source Playback Route", "Mono Differential", "Left Mixer" },
1209 { "Line Out Source Playback Route", "Mono Differential", "Right Mixer" },
1210 { "LINEOUT", NULL, "Line Out Source Playback Route" },
1259 .name = "sun4i-codec",
1274 snd_soc_dai_init_dma_data(dai, &scodec->playback_dma_data, in sun4i_codec_dai_probe()
1275 &scodec->capture_dma_data); in sun4i_codec_dai_probe()
1285 .name = "sun4i-codec-cpu-dai",
1315 link->cpus = &dlc[0]; in sun4i_codec_create_link()
1316 link->codecs = &dlc[1]; in sun4i_codec_create_link()
1317 link->platforms = &dlc[2]; in sun4i_codec_create_link()
1319 link->num_cpus = 1; in sun4i_codec_create_link()
1320 link->num_codecs = 1; in sun4i_codec_create_link()
1321 link->num_platforms = 1; in sun4i_codec_create_link()
1323 link->name = "cdc"; in sun4i_codec_create_link()
1324 link->stream_name = "CDC PCM"; in sun4i_codec_create_link()
1325 link->codecs->dai_name = "Codec"; in sun4i_codec_create_link()
1326 link->cpus->dai_name = dev_name(dev); in sun4i_codec_create_link()
1327 link->codecs->name = dev_name(dev); in sun4i_codec_create_link()
1328 link->platforms->name = dev_name(dev); in sun4i_codec_create_link()
1329 link->dai_fmt = SND_SOC_DAIFMT_I2S; in sun4i_codec_create_link()
1339 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(w->dapm->card); in sun4i_codec_spk_event()
1341 gpiod_set_value_cansleep(scodec->gpio_pa, in sun4i_codec_spk_event()
1371 return ERR_PTR(-ENOMEM); in sun4i_codec_create_card()
1373 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun4i_codec_create_card()
1374 if (!card->dai_link) in sun4i_codec_create_card()
1375 return ERR_PTR(-ENOMEM); in sun4i_codec_create_card()
1377 card->dev = dev; in sun4i_codec_create_card()
1378 card->owner = THIS_MODULE; in sun4i_codec_create_card()
1379 card->name = "sun4i-codec"; in sun4i_codec_create_card()
1380 card->dapm_widgets = sun4i_codec_card_dapm_widgets; in sun4i_codec_create_card()
1381 card->num_dapm_widgets = ARRAY_SIZE(sun4i_codec_card_dapm_widgets); in sun4i_codec_create_card()
1382 card->dapm_routes = sun4i_codec_card_dapm_routes; in sun4i_codec_create_card()
1383 card->num_dapm_routes = ARRAY_SIZE(sun4i_codec_card_dapm_routes); in sun4i_codec_create_card()
1391 SND_SOC_DAPM_LINE("Line Out", NULL),
1404 return ERR_PTR(-ENOMEM); in sun6i_codec_create_card()
1406 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun6i_codec_create_card()
1407 if (!card->dai_link) in sun6i_codec_create_card()
1408 return ERR_PTR(-ENOMEM); in sun6i_codec_create_card()
1410 card->dev = dev; in sun6i_codec_create_card()
1411 card->owner = THIS_MODULE; in sun6i_codec_create_card()
1412 card->name = "A31 Audio Codec"; in sun6i_codec_create_card()
1413 card->dapm_widgets = sun6i_codec_card_dapm_widgets; in sun6i_codec_create_card()
1414 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); in sun6i_codec_create_card()
1415 card->fully_routed = true; in sun6i_codec_create_card()
1417 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); in sun6i_codec_create_card()
1419 dev_warn(dev, "failed to parse audio-routing: %d\n", ret); in sun6i_codec_create_card()
1424 /* Connect digital side enables to analog side widgets */
1450 return ERR_PTR(-ENOMEM); in sun8i_a23_codec_create_card()
1452 aux_dev.dlc.of_node = of_parse_phandle(dev->of_node, in sun8i_a23_codec_create_card()
1453 "allwinner,codec-analog-controls", in sun8i_a23_codec_create_card()
1456 dev_err(dev, "Can't find analog controls for codec.\n"); in sun8i_a23_codec_create_card()
1457 return ERR_PTR(-EINVAL); in sun8i_a23_codec_create_card()
1460 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun8i_a23_codec_create_card()
1461 if (!card->dai_link) in sun8i_a23_codec_create_card()
1462 return ERR_PTR(-ENOMEM); in sun8i_a23_codec_create_card()
1464 card->dev = dev; in sun8i_a23_codec_create_card()
1465 card->owner = THIS_MODULE; in sun8i_a23_codec_create_card()
1466 card->name = "A23 Audio Codec"; in sun8i_a23_codec_create_card()
1467 card->dapm_widgets = sun6i_codec_card_dapm_widgets; in sun8i_a23_codec_create_card()
1468 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); in sun8i_a23_codec_create_card()
1469 card->dapm_routes = sun8i_codec_card_routes; in sun8i_a23_codec_create_card()
1470 card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes); in sun8i_a23_codec_create_card()
1471 card->aux_dev = &aux_dev; in sun8i_a23_codec_create_card()
1472 card->num_aux_devs = 1; in sun8i_a23_codec_create_card()
1473 card->fully_routed = true; in sun8i_a23_codec_create_card()
1475 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); in sun8i_a23_codec_create_card()
1477 dev_warn(dev, "failed to parse audio-routing: %d\n", ret); in sun8i_a23_codec_create_card()
1489 return ERR_PTR(-ENOMEM); in sun8i_h3_codec_create_card()
1491 aux_dev.dlc.of_node = of_parse_phandle(dev->of_node, in sun8i_h3_codec_create_card()
1492 "allwinner,codec-analog-controls", in sun8i_h3_codec_create_card()
1495 dev_err(dev, "Can't find analog controls for codec.\n"); in sun8i_h3_codec_create_card()
1496 return ERR_PTR(-EINVAL); in sun8i_h3_codec_create_card()
1499 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun8i_h3_codec_create_card()
1500 if (!card->dai_link) in sun8i_h3_codec_create_card()
1501 return ERR_PTR(-ENOMEM); in sun8i_h3_codec_create_card()
1503 card->dev = dev; in sun8i_h3_codec_create_card()
1504 card->owner = THIS_MODULE; in sun8i_h3_codec_create_card()
1505 card->name = "H3 Audio Codec"; in sun8i_h3_codec_create_card()
1506 card->dapm_widgets = sun6i_codec_card_dapm_widgets; in sun8i_h3_codec_create_card()
1507 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); in sun8i_h3_codec_create_card()
1508 card->dapm_routes = sun8i_codec_card_routes; in sun8i_h3_codec_create_card()
1509 card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes); in sun8i_h3_codec_create_card()
1510 card->aux_dev = &aux_dev; in sun8i_h3_codec_create_card()
1511 card->num_aux_devs = 1; in sun8i_h3_codec_create_card()
1512 card->fully_routed = true; in sun8i_h3_codec_create_card()
1514 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); in sun8i_h3_codec_create_card()
1516 dev_warn(dev, "failed to parse audio-routing: %d\n", ret); in sun8i_h3_codec_create_card()
1528 return ERR_PTR(-ENOMEM); in sun8i_v3s_codec_create_card()
1530 aux_dev.dlc.of_node = of_parse_phandle(dev->of_node, in sun8i_v3s_codec_create_card()
1531 "allwinner,codec-analog-controls", in sun8i_v3s_codec_create_card()
1534 dev_err(dev, "Can't find analog controls for codec.\n"); in sun8i_v3s_codec_create_card()
1535 return ERR_PTR(-EINVAL); in sun8i_v3s_codec_create_card()
1538 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun8i_v3s_codec_create_card()
1539 if (!card->dai_link) in sun8i_v3s_codec_create_card()
1540 return ERR_PTR(-ENOMEM); in sun8i_v3s_codec_create_card()
1542 card->dev = dev; in sun8i_v3s_codec_create_card()
1543 card->owner = THIS_MODULE; in sun8i_v3s_codec_create_card()
1544 card->name = "V3s Audio Codec"; in sun8i_v3s_codec_create_card()
1545 card->dapm_widgets = sun6i_codec_card_dapm_widgets; in sun8i_v3s_codec_create_card()
1546 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets); in sun8i_v3s_codec_create_card()
1547 card->dapm_routes = sun8i_codec_card_routes; in sun8i_v3s_codec_create_card()
1548 card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes); in sun8i_v3s_codec_create_card()
1549 card->aux_dev = &aux_dev; in sun8i_v3s_codec_create_card()
1550 card->num_aux_devs = 1; in sun8i_v3s_codec_create_card()
1551 card->fully_routed = true; in sun8i_v3s_codec_create_card()
1553 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); in sun8i_v3s_codec_create_card()
1555 dev_warn(dev, "failed to parse audio-routing: %d\n", ret); in sun8i_v3s_codec_create_card()
1564 SOC_SINGLE_TLV("Line Out Playback Volume",
1568 SOC_DOUBLE("Line Out Playback Switch",
1592 SOC_DAPM_ENUM("Line Out Source Playback Route",
1602 /* Analog parts of the DACs */
1618 /* Line Out path */
1619 SND_SOC_DAPM_MUX("Line Out Source Playback Route",
1621 SND_SOC_DAPM_OUT_DRV("Line Out Ramp Controller",
1642 SND_SOC_DAPM_LINE("Line Out", NULL),
1646 /* Connect digital side enables to analog side widgets */
1660 /* Line Out Routes */
1661 { "Line Out Source Playback Route", "Stereo", "Left Mixer" },
1662 { "Line Out Source Playback Route", "Stereo", "Right Mixer" },
1663 { "Line Out Source Playback Route", "Mono Differential", "Left Mixer" },
1664 { "Line Out Source Playback Route", "Mono Differential", "Right Mixer" },
1665 { "Line Out Ramp Controller", NULL, "Line Out Source Playback Route" },
1666 { "LINEOUT", NULL, "Line Out Ramp Controller" },
1676 return ERR_PTR(-ENOMEM); in sun50i_h616_codec_create_card()
1678 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); in sun50i_h616_codec_create_card()
1679 if (!card->dai_link) in sun50i_h616_codec_create_card()
1680 return ERR_PTR(-ENOMEM); in sun50i_h616_codec_create_card()
1682 card->dai_link->playback_only = true; in sun50i_h616_codec_create_card()
1683 card->dai_link->capture_only = false; in sun50i_h616_codec_create_card()
1685 card->dev = dev; in sun50i_h616_codec_create_card()
1686 card->owner = THIS_MODULE; in sun50i_h616_codec_create_card()
1687 card->name = "H616 Audio Codec"; in sun50i_h616_codec_create_card()
1688 card->driver_name = "sun4i-codec"; in sun50i_h616_codec_create_card()
1689 card->controls = sun50i_h616_card_controls; in sun50i_h616_codec_create_card()
1690 card->num_controls = ARRAY_SIZE(sun50i_h616_card_controls); in sun50i_h616_codec_create_card()
1691 card->dapm_widgets = sun50i_h616_codec_card_dapm_widgets; in sun50i_h616_codec_create_card()
1692 card->num_dapm_widgets = ARRAY_SIZE(sun50i_h616_codec_card_dapm_widgets); in sun50i_h616_codec_create_card()
1693 card->dapm_routes = sun50i_h616_codec_card_routes; in sun50i_h616_codec_create_card()
1694 card->num_dapm_routes = ARRAY_SIZE(sun50i_h616_codec_card_routes); in sun50i_h616_codec_create_card()
1695 card->fully_routed = true; in sun50i_h616_codec_create_card()
1697 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); in sun50i_h616_codec_create_card()
1699 dev_warn(dev, "failed to parse audio-routing: %d\n", ret); in sun50i_h616_codec_create_card()
1812 * This should be split out when adding digital audio
1827 * TODO The codec structure should be split out, like
1850 .compatible = "allwinner,sun4i-a10-codec",
1854 .compatible = "allwinner,sun6i-a31-codec",
1858 .compatible = "allwinner,sun7i-a20-codec",
1862 .compatible = "allwinner,sun8i-a23-codec",
1866 .compatible = "allwinner,sun8i-h3-codec",
1870 .compatible = "allwinner,sun8i-v3s-codec",
1874 .compatible = "allwinner,sun50i-h616-codec",
1890 scodec = devm_kzalloc(&pdev->dev, sizeof(*scodec), GFP_KERNEL); in sun4i_codec_probe()
1892 return -ENOMEM; in sun4i_codec_probe()
1894 scodec->dev = &pdev->dev; in sun4i_codec_probe()
1900 quirks = of_device_get_match_data(&pdev->dev); in sun4i_codec_probe()
1902 dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); in sun4i_codec_probe()
1903 return -ENODEV; in sun4i_codec_probe()
1906 scodec->regmap = devm_regmap_init_mmio(&pdev->dev, base, in sun4i_codec_probe()
1907 quirks->regmap_config); in sun4i_codec_probe()
1908 if (IS_ERR(scodec->regmap)) { in sun4i_codec_probe()
1909 dev_err(&pdev->dev, "Failed to create our regmap\n"); in sun4i_codec_probe()
1910 return PTR_ERR(scodec->regmap); in sun4i_codec_probe()
1914 scodec->clk_apb = devm_clk_get(&pdev->dev, "apb"); in sun4i_codec_probe()
1915 if (IS_ERR(scodec->clk_apb)) { in sun4i_codec_probe()
1916 dev_err(&pdev->dev, "Failed to get the APB clock\n"); in sun4i_codec_probe()
1917 return PTR_ERR(scodec->clk_apb); in sun4i_codec_probe()
1920 scodec->clk_module = devm_clk_get(&pdev->dev, "codec"); in sun4i_codec_probe()
1921 if (IS_ERR(scodec->clk_module)) { in sun4i_codec_probe()
1922 dev_err(&pdev->dev, "Failed to get the module clock\n"); in sun4i_codec_probe()
1923 return PTR_ERR(scodec->clk_module); in sun4i_codec_probe()
1926 if (quirks->has_reset) { in sun4i_codec_probe()
1927 scodec->rst = devm_reset_control_get_exclusive(&pdev->dev, in sun4i_codec_probe()
1929 if (IS_ERR(scodec->rst)) { in sun4i_codec_probe()
1930 dev_err(&pdev->dev, "Failed to get reset control\n"); in sun4i_codec_probe()
1931 return PTR_ERR(scodec->rst); in sun4i_codec_probe()
1935 scodec->gpio_pa = devm_gpiod_get_optional(&pdev->dev, "allwinner,pa", in sun4i_codec_probe()
1937 if (IS_ERR(scodec->gpio_pa)) { in sun4i_codec_probe()
1938 ret = PTR_ERR(scodec->gpio_pa); in sun4i_codec_probe()
1939 dev_err_probe(&pdev->dev, ret, "Failed to get pa gpio\n"); in sun4i_codec_probe()
1944 scodec->reg_adc_fifoc = devm_regmap_field_alloc(&pdev->dev, in sun4i_codec_probe()
1945 scodec->regmap, in sun4i_codec_probe()
1946 quirks->reg_adc_fifoc); in sun4i_codec_probe()
1947 if (IS_ERR(scodec->reg_adc_fifoc)) { in sun4i_codec_probe()
1948 ret = PTR_ERR(scodec->reg_adc_fifoc); in sun4i_codec_probe()
1949 dev_err(&pdev->dev, "Failed to create regmap fields: %d\n", in sun4i_codec_probe()
1954 scodec->reg_dac_fifoc = devm_regmap_field_alloc(&pdev->dev, in sun4i_codec_probe()
1955 scodec->regmap, in sun4i_codec_probe()
1956 quirks->reg_dac_fifoc); in sun4i_codec_probe()
1957 if (IS_ERR(scodec->reg_dac_fifoc)) { in sun4i_codec_probe()
1958 ret = PTR_ERR(scodec->reg_dac_fifoc); in sun4i_codec_probe()
1959 dev_err(&pdev->dev, "Failed to create regmap fields: %d\n", in sun4i_codec_probe()
1965 if (clk_prepare_enable(scodec->clk_apb)) { in sun4i_codec_probe()
1966 dev_err(&pdev->dev, "Failed to enable the APB clock\n"); in sun4i_codec_probe()
1967 return -EINVAL; in sun4i_codec_probe()
1971 if (scodec->rst) { in sun4i_codec_probe()
1972 ret = reset_control_deassert(scodec->rst); in sun4i_codec_probe()
1974 dev_err(&pdev->dev, in sun4i_codec_probe()
1981 scodec->playback_dma_data.addr = res->start + quirks->reg_dac_txdata; in sun4i_codec_probe()
1982 scodec->playback_dma_data.maxburst = 8; in sun4i_codec_probe()
1983 scodec->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sun4i_codec_probe()
1985 if (!quirks->playback_only) { in sun4i_codec_probe()
1987 scodec->capture_dma_data.addr = res->start + in sun4i_codec_probe()
1988 quirks->reg_adc_rxdata; in sun4i_codec_probe()
1989 scodec->capture_dma_data.maxburst = 8; in sun4i_codec_probe()
1990 scodec->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sun4i_codec_probe()
1993 ret = devm_snd_soc_register_component(&pdev->dev, quirks->codec, in sun4i_codec_probe()
1996 dev_err(&pdev->dev, "Failed to register our codec\n"); in sun4i_codec_probe()
2000 ret = devm_snd_soc_register_component(&pdev->dev, in sun4i_codec_probe()
2004 dev_err(&pdev->dev, "Failed to register our DAI\n"); in sun4i_codec_probe()
2008 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); in sun4i_codec_probe()
2010 dev_err(&pdev->dev, "Failed to register against DMAEngine\n"); in sun4i_codec_probe()
2014 card = quirks->create_card(&pdev->dev); in sun4i_codec_probe()
2017 dev_err(&pdev->dev, "Failed to create our card\n"); in sun4i_codec_probe()
2025 dev_err_probe(&pdev->dev, ret, "Failed to register our card\n"); in sun4i_codec_probe()
2032 if (scodec->rst) in sun4i_codec_probe()
2033 reset_control_assert(scodec->rst); in sun4i_codec_probe()
2035 clk_disable_unprepare(scodec->clk_apb); in sun4i_codec_probe()
2045 if (scodec->rst) in sun4i_codec_remove()
2046 reset_control_assert(scodec->rst); in sun4i_codec_remove()
2047 clk_disable_unprepare(scodec->clk_apb); in sun4i_codec_remove()
2052 .name = "sun4i-codec",
2063 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
2064 MODULE_AUTHOR("Chen-Yu Tsai <wens@csie.org>");