Lines Matching +full:serial +full:- +full:output
1 // SPDX-License-Identifier: GPL-2.0-only
6 * Author: Lars-Peter Clausen <[email protected]>
25 #include "adau-utils.h"
126 static const DECLARE_TLV_DB_MINMAX(adau1372_digital_tlv, -9563, 0);
127 static const DECLARE_TLV_DB_SCALE(adau1372_pga_tlv, -1200, 75, 0);
190 SOC_ENUM("ADC 0+1 High-Pass-Filter", adau1372_hpf0_1_enum),
191 SOC_ENUM("ADC 2+3 High-Pass-Filter", adau1372_hpf2_3_enum),
268 SOC_DAPM_ENUM("Output ASRC0 Capture Mux", adau1372_asrco0_mux_enum);
270 SOC_DAPM_ENUM("Output ASRC1 Capture Mux", adau1372_asrco1_mux_enum);
272 SOC_DAPM_ENUM("Output ASRC2 Capture Mux", adau1372_asrco2_mux_enum);
274 SOC_DAPM_ENUM("Output ASRC3 Capture Mux", adau1372_asrco3_mux_enum);
281 "Output ASRC0",
282 "Output ASRC1",
283 "Output ASRC2",
284 "Output ASRC3",
285 "Serial Input 0",
286 "Serial Input 1",
287 "Serial Input 2",
288 "Serial Input 3",
289 "Serial Input 4",
290 "Serial Input 5",
291 "Serial Input 6",
292 "Serial Input 7",
313 SOC_DAPM_ENUM("Serial Output 0 Capture Mux", adau1372_sout0_mux_enum);
315 SOC_DAPM_ENUM("Serial Output 1 Capture Mux", adau1372_sout1_mux_enum);
317 SOC_DAPM_ENUM("Serial Output 2 Capture Mux", adau1372_sout2_mux_enum);
319 SOC_DAPM_ENUM("Serial Output 3 Capture Mux", adau1372_sout3_mux_enum);
321 SOC_DAPM_ENUM("Serial Output 4 Capture Mux", adau1372_sout4_mux_enum);
323 SOC_DAPM_ENUM("Serial Output 5 Capture Mux", adau1372_sout5_mux_enum);
325 SOC_DAPM_ENUM("Serial Output 6 Capture Mux", adau1372_sout6_mux_enum);
327 SOC_DAPM_ENUM("Serial Output 7 Capture Mux", adau1372_sout7_mux_enum);
330 "Serial Input 0+1",
331 "Serial Input 2+3",
332 "Serial Input 4+5",
333 "Serial Input 6+7",
385 SND_SOC_DAPM_SUPPLY("Output ASRC0 Decimator", ADAU1372_REG_DECIM_PWR, 4, 0, NULL, 0),
386 SND_SOC_DAPM_SUPPLY("Output ASRC1 Decimator", ADAU1372_REG_DECIM_PWR, 5, 0, NULL, 0),
387 SND_SOC_DAPM_SUPPLY("Output ASRC2 Decimator", ADAU1372_REG_DECIM_PWR, 6, 0, NULL, 0),
388 SND_SOC_DAPM_SUPPLY("Output ASRC3 Decimator", ADAU1372_REG_DECIM_PWR, 7, 0, NULL, 0),
395 SND_SOC_DAPM_MUX("Output ASRC0 Mux", SND_SOC_NOPM, 0, 0, &adau1372_asrco0_mux_control),
396 SND_SOC_DAPM_MUX("Output ASRC1 Mux", SND_SOC_NOPM, 0, 0, &adau1372_asrco1_mux_control),
397 SND_SOC_DAPM_MUX("Output ASRC2 Mux", SND_SOC_NOPM, 0, 0, &adau1372_asrco2_mux_control),
398 SND_SOC_DAPM_MUX("Output ASRC3 Mux", SND_SOC_NOPM, 0, 0, &adau1372_asrco3_mux_control),
399 SND_SOC_DAPM_MUX("Serial Output 0 Capture Mux", SND_SOC_NOPM, 0, 0,
401 SND_SOC_DAPM_MUX("Serial Output 1 Capture Mux", SND_SOC_NOPM, 0, 0,
403 SND_SOC_DAPM_MUX("Serial Output 2 Capture Mux", SND_SOC_NOPM, 0, 0,
405 SND_SOC_DAPM_MUX("Serial Output 3 Capture Mux", SND_SOC_NOPM, 0, 0,
407 SND_SOC_DAPM_MUX("Serial Output 4 Capture Mux", SND_SOC_NOPM, 0, 0,
409 SND_SOC_DAPM_MUX("Serial Output 5 Capture Mux", SND_SOC_NOPM, 0, 0,
411 SND_SOC_DAPM_MUX("Serial Output 6 Capture Mux", SND_SOC_NOPM, 0, 0,
413 SND_SOC_DAPM_MUX("Serial Output 7 Capture Mux", SND_SOC_NOPM, 0, 0,
416 SND_SOC_DAPM_AIF_IN("Serial Input 0", NULL, 0, SND_SOC_NOPM, 0, 0),
417 SND_SOC_DAPM_AIF_IN("Serial Input 1", NULL, 1, SND_SOC_NOPM, 0, 0),
418 SND_SOC_DAPM_AIF_IN("Serial Input 2", NULL, 2, SND_SOC_NOPM, 0, 0),
419 SND_SOC_DAPM_AIF_IN("Serial Input 3", NULL, 3, SND_SOC_NOPM, 0, 0),
420 SND_SOC_DAPM_AIF_IN("Serial Input 4", NULL, 4, SND_SOC_NOPM, 0, 0),
421 SND_SOC_DAPM_AIF_IN("Serial Input 5", NULL, 5, SND_SOC_NOPM, 0, 0),
422 SND_SOC_DAPM_AIF_IN("Serial Input 6", NULL, 6, SND_SOC_NOPM, 0, 0),
423 SND_SOC_DAPM_AIF_IN("Serial Input 7", NULL, 7, SND_SOC_NOPM, 0, 0),
425 SND_SOC_DAPM_AIF_OUT("Serial Output 0", NULL, 0, SND_SOC_NOPM, 0, 0),
426 SND_SOC_DAPM_AIF_OUT("Serial Output 1", NULL, 1, SND_SOC_NOPM, 0, 0),
427 SND_SOC_DAPM_AIF_OUT("Serial Output 2", NULL, 2, SND_SOC_NOPM, 0, 0),
428 SND_SOC_DAPM_AIF_OUT("Serial Output 3", NULL, 3, SND_SOC_NOPM, 0, 0),
429 SND_SOC_DAPM_AIF_OUT("Serial Output 4", NULL, 4, SND_SOC_NOPM, 0, 0),
430 SND_SOC_DAPM_AIF_OUT("Serial Output 5", NULL, 5, SND_SOC_NOPM, 0, 0),
431 SND_SOC_DAPM_AIF_OUT("Serial Output 6", NULL, 6, SND_SOC_NOPM, 0, 0),
432 SND_SOC_DAPM_AIF_OUT("Serial Output 7", NULL, 7, SND_SOC_NOPM, 0, 0),
434 SND_SOC_DAPM_SUPPLY("Output ASRC Supply", ADAU1372_REG_ASRC_MODE, 1, 0, NULL, 0),
461 { "Serial Output " #x " Capture Mux", "Output ASRC0", "Output ASRC0 Mux" }, \
462 { "Serial Output " #x " Capture Mux", "Output ASRC1", "Output ASRC1 Mux" }, \
463 { "Serial Output " #x " Capture Mux", "Output ASRC2", "Output ASRC2 Mux" }, \
464 { "Serial Output " #x " Capture Mux", "Output ASRC3", "Output ASRC3 Mux" }, \
465 { "Serial Output " #x " Capture Mux", "Serial Input 0", "Serial Input 0" }, \
466 { "Serial Output " #x " Capture Mux", "Serial Input 1", "Serial Input 1" }, \
467 { "Serial Output " #x " Capture Mux", "Serial Input 2", "Serial Input 2" }, \
468 { "Serial Output " #x " Capture Mux", "Serial Input 3", "Serial Input 3" }, \
469 { "Serial Output " #x " Capture Mux", "Serial Input 4", "Serial Input 4" }, \
470 { "Serial Output " #x " Capture Mux", "Serial Input 5", "Serial Input 5" }, \
471 { "Serial Output " #x " Capture Mux", "Serial Input 6", "Serial Input 6" }, \
472 { "Serial Output " #x " Capture Mux", "Serial Input 7", "Serial Input 7" }, \
473 { "Serial Output " #x, NULL, "Serial Output " #x " Capture Mux" }, \
474 { "Capture", NULL, "Serial Output " #x }
477 { "Output ASRC" #x " Mux", "Decimator0", "Decimator0 Mux" }, \
478 { "Output ASRC" #x " Mux", "Decimator1", "Decimator1 Mux" }, \
479 { "Output ASRC" #x " Mux", "Decimator2", "Decimator2 Mux" }, \
480 { "Output ASRC" #x " Mux", "Decimator3", "Decimator3 Mux" }
508 { "Output ASRC0 Mux", NULL, "Output ASRC Supply" },
509 { "Output ASRC1 Mux", NULL, "Output ASRC Supply" },
510 { "Output ASRC2 Mux", NULL, "Output ASRC Supply" },
511 { "Output ASRC3 Mux", NULL, "Output ASRC Supply" },
512 { "Output ASRC0 Mux", NULL, "Output ASRC0 Decimator" },
513 { "Output ASRC1 Mux", NULL, "Output ASRC1 Decimator" },
514 { "Output ASRC2 Mux", NULL, "Output ASRC2 Decimator" },
515 { "Output ASRC3 Mux", NULL, "Output ASRC3 Decimator" },
531 { "Serial Input 0", NULL, "Playback" },
532 { "Serial Input 1", NULL, "Playback" },
533 { "Serial Input 2", NULL, "Playback" },
534 { "Serial Input 3", NULL, "Playback" },
535 { "Serial Input 4", NULL, "Playback" },
536 { "Serial Input 5", NULL, "Playback" },
537 { "Serial Input 6", NULL, "Playback" },
538 { "Serial Input 7", NULL, "Playback" },
540 { "Input ASRC0 Mux", "Serial Input 0+1", "Serial Input 0" },
541 { "Input ASRC1 Mux", "Serial Input 0+1", "Serial Input 1" },
542 { "Input ASRC0 Mux", "Serial Input 2+3", "Serial Input 2" },
543 { "Input ASRC1 Mux", "Serial Input 2+3", "Serial Input 3" },
544 { "Input ASRC0 Mux", "Serial Input 4+5", "Serial Input 4" },
545 { "Input ASRC1 Mux", "Serial Input 4+5", "Serial Input 5" },
546 { "Input ASRC0 Mux", "Serial Input 6+7", "Serial Input 6" },
547 { "Input ASRC1 Mux", "Serial Input 6+7", "Serial Input 7" },
582 adau1372->clock_provider = true; in adau1372_set_dai_fmt()
586 adau1372->clock_provider = false; in adau1372_set_dai_fmt()
589 return -EINVAL; in adau1372_set_dai_fmt()
630 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI0, ADAU1372_SAI0_DELAY_MASK, sai0); in adau1372_set_dai_fmt()
631 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI1, in adau1372_set_dai_fmt()
653 return -EINVAL; in adau1372_hw_params()
657 slot_width = adau1372->slot_width; in adau1372_hw_params()
670 return -EINVAL; in adau1372_hw_params()
673 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI0, ADAU1372_SAI0_FS_MASK, sai0); in adau1372_hw_params()
674 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI1, ADAU1372_SAI1_BCLKRATE, sai1); in adau1372_hw_params()
688 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI0, in adau1372_set_tdm_slot()
690 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM2; in adau1372_set_tdm_slot()
691 adau1372->slot_width = 0; in adau1372_set_tdm_slot()
697 return -EINVAL; in adau1372_set_tdm_slot()
708 return -EINVAL; in adau1372_set_tdm_slot()
714 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM2; in adau1372_set_tdm_slot()
718 if (adau1372->clock_provider) in adau1372_set_tdm_slot()
719 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM4_MASTER; in adau1372_set_tdm_slot()
721 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM4; in adau1372_set_tdm_slot()
725 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM8; in adau1372_set_tdm_slot()
728 return -EINVAL; in adau1372_set_tdm_slot()
731 adau1372->slot_width = width; in adau1372_set_tdm_slot()
733 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI0, ADAU1372_SAI0_SAI_MASK, sai0); in adau1372_set_tdm_slot()
734 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI1, ADAU1372_SAI1_BCLK_TDMC, sai1); in adau1372_set_tdm_slot()
737 regmap_write(adau1372->regmap, ADAU1372_REG_SOUT_CTRL, ~tx_mask); in adau1372_set_tdm_slot()
752 return regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI1, ADAU1372_SAI1_TDM_TS, sai1); in adau1372_set_tristate()
759 snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in adau1372_startup()
760 &adau1372->rate_constraints); in adau1372_startup()
770 regmap_update_bits(adau1372->regmap, ADAU1372_REG_CLK_CTRL, in adau1372_enable_pll()
775 ret = regmap_read(adau1372->regmap, ADAU1372_REG_PLL(5), &val); in adau1372_enable_pll()
782 dev_err(adau1372->dev, "Failed to lock PLL\n"); in adau1372_enable_pll()
787 if (adau1372->enabled == enable) in adau1372_set_power()
793 clk_prepare_enable(adau1372->mclk); in adau1372_set_power()
794 if (adau1372->pd_gpio) in adau1372_set_power()
795 gpiod_set_value(adau1372->pd_gpio, 0); in adau1372_set_power()
797 if (adau1372->switch_mode) in adau1372_set_power()
798 adau1372->switch_mode(adau1372->dev); in adau1372_set_power()
800 regcache_cache_only(adau1372->regmap, false); in adau1372_set_power()
806 if (adau1372->use_pll) { in adau1372_set_power()
811 regmap_update_bits(adau1372->regmap, ADAU1372_REG_CLK_CTRL, in adau1372_set_power()
813 regcache_sync(adau1372->regmap); in adau1372_set_power()
815 if (adau1372->pd_gpio) { in adau1372_set_power()
821 gpiod_set_value(adau1372->pd_gpio, 1); in adau1372_set_power()
822 regcache_mark_dirty(adau1372->regmap); in adau1372_set_power()
824 regmap_update_bits(adau1372->regmap, ADAU1372_REG_CLK_CTRL, in adau1372_set_power()
827 clk_disable_unprepare(adau1372->mclk); in adau1372_set_power()
828 regcache_cache_only(adau1372->regmap, true); in adau1372_set_power()
831 adau1372->enabled = enable; in adau1372_set_power()
911 regmap_write(adau1372->regmap, ADAU1372_REG_PLL(i), regs[i]); in adau1372_setup_pll()
929 return -ENOMEM; in adau1372_probe()
931 adau1372->mclk = devm_clk_get(dev, "mclk"); in adau1372_probe()
932 if (IS_ERR(adau1372->mclk)) in adau1372_probe()
933 return PTR_ERR(adau1372->mclk); in adau1372_probe()
935 adau1372->pd_gpio = devm_gpiod_get_optional(dev, "powerdown", GPIOD_OUT_HIGH); in adau1372_probe()
936 if (IS_ERR(adau1372->pd_gpio)) in adau1372_probe()
937 return PTR_ERR(adau1372->pd_gpio); in adau1372_probe()
939 adau1372->regmap = regmap; in adau1372_probe()
940 adau1372->switch_mode = switch_mode; in adau1372_probe()
941 adau1372->dev = dev; in adau1372_probe()
942 adau1372->rate_constraints.list = adau1372_rates; in adau1372_probe()
943 adau1372->rate_constraints.count = ARRAY_SIZE(adau1372_rates); in adau1372_probe()
944 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM2; in adau1372_probe()
953 rate = clk_get_rate(adau1372->mclk); in adau1372_probe()
967 adau1372->use_pll = true; in adau1372_probe()
980 * No pinctrl support yet, put the multi-purpose pins in the most in adau1372_probe()
1072 MODULE_AUTHOR("Lars-Peter Clausen <[email protected]>");