Lines Matching +full:adc +full:- +full:channel +full:- +full:clk +full:- +full:src

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
25 #include "adau-utils.h"
324 0, 7, TLV_DB_SCALE_ITEM(-7900, 400, 1),
325 8, 15, TLV_DB_SCALE_ITEM(-4700, 300, 0),
326 16, 23, TLV_DB_SCALE_ITEM(-2300, 200, 0),
327 24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0)
330 static const DECLARE_TLV_DB_MINMAX(adau1373_digital_tlv, -9563, 0);
331 static const DECLARE_TLV_DB_SCALE(adau1373_in_pga_tlv, -1300, 100, 1);
332 static const DECLARE_TLV_DB_SCALE(adau1373_ep_tlv, -600, 600, 1);
340 "Channel 1",
341 "Channel 2",
342 "Channel 3",
343 "Channel 4",
344 "Channel 5",
384 0, 2, TLV_DB_SCALE_ITEM(-600, 600, 1),
417 1, 7, TLV_DB_LINEAR_ITEM(-1800, -120)
422 "Right Channel (L+R)",
423 "Left Channel (L+R)",
442 SOC_DOUBLE_R_TLV("ADC Capture Volume", ADAU1373_ADC_RECL_VOL,
492 SOC_DOUBLE_TLV("ADC Boost Capture Volume", ADAU1373_VOL_GAIN3, 4, 5,
516 SOC_ENUM("HPF Channel", adau1373_hpf_channel_enum),
524 SOC_ENUM("Bass Channel", adau1373_bass_channel_enum),
531 SOC_ENUM("3D Channel", adau1373_bass_channel_enum),
543 SOC_ENUM("DRC1 Channel", adau1373_drc1_channel_enum),
544 SOC_ENUM("DRC2 Channel", adau1373_drc2_channel_enum),
545 SOC_ENUM("DRC3 Channel", adau1373_drc3_channel_enum),
551 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in adau1373_pll_event()
553 unsigned int pll_id = w->name[3] - '1'; in adau1373_pll_event()
561 regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id), in adau1373_pll_event()
571 "ADC",
646 SOC_DAPM_SINGLE("ADC/DMIC1 Swapped Switch", _reg, 4, 1, 0), \
647 SOC_DAPM_SINGLE("ADC/DMIC1 Switch", _reg, 3, 1, 0), \
685 /* Datasheet claims Left ADC is bit 6 and Right ADC is bit 7, but that
687 SND_SOC_DAPM_ADC("Left ADC", NULL, ADAU1373_PWDN_CTRL1, 7, 0),
688 SND_SOC_DAPM_ADC("Right ADC", NULL, ADAU1373_PWDN_CTRL1, 6, 0),
709 SOC_MIXER_ARRAY("Left ADC Mixer", SND_SOC_NOPM, 0, 0,
711 SOC_MIXER_ARRAY("Right ADC Mixer", SND_SOC_NOPM, 0, 0,
736 SND_SOC_DAPM_SUPPLY("AIF1 CLK", ADAU1373_SRC_DAI_CTRL(0), 0, 0,
738 SND_SOC_DAPM_SUPPLY("AIF2 CLK", ADAU1373_SRC_DAI_CTRL(1), 0, 0,
740 SND_SOC_DAPM_SUPPLY("AIF3 CLK", ADAU1373_SRC_DAI_CTRL(2), 0, 0,
742 SND_SOC_DAPM_SUPPLY("AIF1 IN SRC", ADAU1373_SRC_DAI_CTRL(0), 2, 0,
744 SND_SOC_DAPM_SUPPLY("AIF1 OUT SRC", ADAU1373_SRC_DAI_CTRL(0), 1, 0,
746 SND_SOC_DAPM_SUPPLY("AIF2 IN SRC", ADAU1373_SRC_DAI_CTRL(1), 2, 0,
748 SND_SOC_DAPM_SUPPLY("AIF2 OUT SRC", ADAU1373_SRC_DAI_CTRL(1), 1, 0,
750 SND_SOC_DAPM_SUPPLY("AIF3 IN SRC", ADAU1373_SRC_DAI_CTRL(2), 2, 0,
752 SND_SOC_DAPM_SUPPLY("AIF3 OUT SRC", ADAU1373_SRC_DAI_CTRL(2), 1, 0,
823 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in adau1373_check_aif_clk()
826 const char *clk; in adau1373_check_aif_clk() local
828 dai = sink->name[3] - '1'; in adau1373_check_aif_clk()
830 if (!adau1373->dais[dai].master) in adau1373_check_aif_clk()
833 if (adau1373->dais[dai].clk_src == ADAU1373_CLK_SRC_PLL1) in adau1373_check_aif_clk()
834 clk = "SYSCLK1"; in adau1373_check_aif_clk()
836 clk = "SYSCLK2"; in adau1373_check_aif_clk()
838 return strcmp(source->name, clk) == 0; in adau1373_check_aif_clk()
844 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in adau1373_check_src()
848 dai = sink->name[3] - '1'; in adau1373_check_src()
850 return adau1373->dais[dai].enable_src; in adau1373_check_src()
856 { _sink, "ADC/DMIC1 Swapped Switch", "Decimator Mux" }, \
857 { _sink, "ADC/DMIC1 Switch", "Decimator Mux" }, \
890 { "Left ADC Mixer", "DAC1 Switch", "Left DAC1" },
891 { "Left ADC Mixer", "Input 1 Switch", "IN1PGA" },
892 { "Left ADC Mixer", "Input 2 Switch", "IN2PGA" },
893 { "Left ADC Mixer", "Input 3 Switch", "IN3PGA" },
894 { "Left ADC Mixer", "Input 4 Switch", "IN4PGA" },
896 { "Right ADC Mixer", "DAC1 Switch", "Right DAC1" },
897 { "Right ADC Mixer", "Input 1 Switch", "IN1PGA" },
898 { "Right ADC Mixer", "Input 2 Switch", "IN2PGA" },
899 { "Right ADC Mixer", "Input 3 Switch", "IN3PGA" },
900 { "Right ADC Mixer", "Input 4 Switch", "IN4PGA" },
902 { "Left ADC", NULL, "Left ADC Mixer" },
903 { "Right ADC", NULL, "Right ADC Mixer" },
905 { "Decimator Mux", "ADC", "Left ADC" },
906 { "Decimator Mux", "ADC", "Right ADC" },
987 { "Left ADC", NULL, "SYSCLK1" },
988 { "Right ADC", NULL, "SYSCLK1" },
999 { "Left ADC Mixer", NULL, "Recording Engine A" },
1000 { "Right ADC Mixer", NULL, "Recording Engine A" },
1002 { "AIF1 CLK", NULL, "SYSCLK1", adau1373_check_aif_clk },
1003 { "AIF2 CLK", NULL, "SYSCLK1", adau1373_check_aif_clk },
1004 { "AIF3 CLK", NULL, "SYSCLK1", adau1373_check_aif_clk },
1005 { "AIF1 CLK", NULL, "SYSCLK2", adau1373_check_aif_clk },
1006 { "AIF2 CLK", NULL, "SYSCLK2", adau1373_check_aif_clk },
1007 { "AIF3 CLK", NULL, "SYSCLK2", adau1373_check_aif_clk },
1009 { "AIF1 IN", NULL, "AIF1 CLK" },
1010 { "AIF1 OUT", NULL, "AIF1 CLK" },
1011 { "AIF2 IN", NULL, "AIF2 CLK" },
1012 { "AIF2 OUT", NULL, "AIF2 CLK" },
1013 { "AIF3 IN", NULL, "AIF3 CLK" },
1014 { "AIF3 OUT", NULL, "AIF3 CLK" },
1015 { "AIF1 IN", NULL, "AIF1 IN SRC", adau1373_check_src },
1016 { "AIF1 OUT", NULL, "AIF1 OUT SRC", adau1373_check_src },
1017 { "AIF2 IN", NULL, "AIF2 IN SRC", adau1373_check_src },
1018 { "AIF2 OUT", NULL, "AIF2 OUT SRC", adau1373_check_src },
1019 { "AIF3 IN", NULL, "AIF3 IN SRC", adau1373_check_src },
1020 { "AIF3 OUT", NULL, "AIF3 OUT SRC", adau1373_check_src },
1033 struct snd_soc_component *component = dai->component; in adau1373_hw_params()
1035 struct adau1373_dai *adau1373_dai = &adau1373->dais[dai->id]; in adau1373_hw_params()
1040 freq = adau1373_dai->sysclk; in adau1373_hw_params()
1043 return -EINVAL; in adau1373_hw_params()
1068 return -EINVAL; in adau1373_hw_params()
1071 adau1373_dai->enable_src = (div != 0); in adau1373_hw_params()
1073 regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id), in adau1373_hw_params()
1091 return -EINVAL; in adau1373_hw_params()
1094 return regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id), in adau1373_hw_params()
1100 struct snd_soc_component *component = dai->component; in adau1373_set_dai_fmt()
1102 struct adau1373_dai *adau1373_dai = &adau1373->dais[dai->id]; in adau1373_set_dai_fmt()
1108 adau1373_dai->master = true; in adau1373_set_dai_fmt()
1112 adau1373_dai->master = false; in adau1373_set_dai_fmt()
1115 return -EINVAL; in adau1373_set_dai_fmt()
1132 return -EINVAL; in adau1373_set_dai_fmt()
1148 return -EINVAL; in adau1373_set_dai_fmt()
1151 regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id), in adau1373_set_dai_fmt()
1160 struct adau1373 *adau1373 = snd_soc_component_get_drvdata(dai->component); in adau1373_set_dai_sysclk()
1161 struct adau1373_dai *adau1373_dai = &adau1373->dais[dai->id]; in adau1373_set_dai_sysclk()
1168 return -EINVAL; in adau1373_set_dai_sysclk()
1171 adau1373_dai->sysclk = freq; in adau1373_set_dai_sysclk()
1172 adau1373_dai->clk_src = clk_id; in adau1373_set_dai_sysclk()
1174 regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id), in adau1373_set_dai_sysclk()
1192 .name = "adau1373-aif1",
1212 .name = "adau1373-aif2",
1232 .name = "adau1373-aif3",
1265 return -EINVAL; in adau1373_set_pll()
1283 return -EINVAL; in adau1373_set_pll()
1287 return -EINVAL; in adau1373_set_pll()
1290 return -EINVAL; in adau1373_set_pll()
1301 return -EINVAL; in adau1373_set_pll()
1304 dpll_div = 11 - dpll_div; in adau1373_set_pll()
1305 regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id), in adau1373_set_pll()
1308 regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id), in adau1373_set_pll()
1313 regmap_write(adau1373->regmap, ADAU1373_DPLL_CTRL(pll_id), in adau1373_set_pll()
1315 regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL1(pll_id), pll_regs[0]); in adau1373_set_pll()
1316 regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL2(pll_id), pll_regs[1]); in adau1373_set_pll()
1317 regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL3(pll_id), pll_regs[2]); in adau1373_set_pll()
1318 regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL4(pll_id), pll_regs[3]); in adau1373_set_pll()
1319 regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL5(pll_id), pll_regs[4]); in adau1373_set_pll()
1322 regmap_update_bits(adau1373->regmap, ADAU1373_CLK_SRC_DIV(pll_id), 0x3f, 0x09); in adau1373_set_pll()
1333 regmap_write(adau1373->regmap, ADAU1373_DRC(nr) + i, drc[i]); in adau1373_load_drc_settings()
1353 struct adau1373_platform_data *pdata = component->dev->platform_data; in adau1373_probe()
1359 if (pdata->num_drc > ARRAY_SIZE(pdata->drc_setting)) in adau1373_probe()
1360 return -EINVAL; in adau1373_probe()
1362 if (!adau1373_valid_micbias(pdata->micbias1) || in adau1373_probe()
1363 !adau1373_valid_micbias(pdata->micbias2)) in adau1373_probe()
1364 return -EINVAL; in adau1373_probe()
1366 for (i = 0; i < pdata->num_drc; ++i) { in adau1373_probe()
1368 pdata->drc_setting[i]); in adau1373_probe()
1372 pdata->num_drc); in adau1373_probe()
1376 if (pdata->input_differential[i]) in adau1373_probe()
1379 regmap_write(adau1373->regmap, ADAU1373_INPUT_MODE, val); in adau1373_probe()
1382 if (pdata->lineout_differential) in adau1373_probe()
1384 if (pdata->lineout_ground_sense) in adau1373_probe()
1386 regmap_write(adau1373->regmap, ADAU1373_OUTPUT_CTRL, val); in adau1373_probe()
1388 lineout_differential = pdata->lineout_differential; in adau1373_probe()
1390 regmap_write(adau1373->regmap, ADAU1373_EP_CTRL, in adau1373_probe()
1391 (pdata->micbias1 << ADAU1373_EP_CTRL_MICBIAS1_OFFSET) | in adau1373_probe()
1392 (pdata->micbias2 << ADAU1373_EP_CTRL_MICBIAS2_OFFSET)); in adau1373_probe()
1400 regmap_write(adau1373->regmap, ADAU1373_ADC_CTRL, in adau1373_probe()
1417 regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3, in adau1373_set_bias_level()
1421 regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3, in adau1373_set_bias_level()
1432 regcache_sync(adau1373->regmap); in adau1373_resume()
1482 adau1373 = devm_kzalloc(&client->dev, sizeof(*adau1373), GFP_KERNEL); in adau1373_i2c_probe()
1484 return -ENOMEM; in adau1373_i2c_probe()
1486 adau1373->regmap = devm_regmap_init_i2c(client, in adau1373_i2c_probe()
1488 if (IS_ERR(adau1373->regmap)) in adau1373_i2c_probe()
1489 return PTR_ERR(adau1373->regmap); in adau1373_i2c_probe()
1491 regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00); in adau1373_i2c_probe()
1493 dev_set_drvdata(&client->dev, adau1373); in adau1373_i2c_probe()
1495 ret = devm_snd_soc_register_component(&client->dev, in adau1373_i2c_probe()
1518 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");