Lines Matching +full:mic +full:- +full:in +full:- +full:differential
1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (C) 2020 Texas Instruments Incorporated - https://www.ti.com/
41 "ti,gpo-config-1",
42 "ti,gpo-config-2",
43 "ti,gpo-config-3",
44 "ti,gpo-config-4",
163 /* Digital Volume control. From -100 to 27 dB in 0.5 dB steps */
164 static DECLARE_TLV_DB_SCALE(dig_vol_tlv, -10050, 50, 0);
166 /* ADC gain. From 0 to 42 dB in 1 dB steps */
169 /* DRE Level. From -12 dB to -66 dB in 1 dB steps */
170 static DECLARE_TLV_DB_SCALE(dre_thresh_tlv, -6600, 100, 0);
171 /* DRE Max Gain. From 2 dB to 26 dB in 2 dB steps */
174 /* AGC Level. From -6 dB to -36 dB in 2 dB steps */
175 static DECLARE_TLV_DB_SCALE(agc_thresh_tlv, -3600, 200, 0);
176 /* AGC Max Gain. From 3 dB to 42 dB in 3 dB steps */
180 "Linear Phase", "Low Latency", "Ultra-low Latency"
228 static const char * const adcx140_mic_sel_text[] = {"Analog", "Line In", "Digital"};
229 static const char * const adcx140_analog_sel_text[] = {"Analog", "Line In"};
353 /* Analog Differential Inputs */
455 SND_SOC_DAPM_MUX("IN1 Analog Mic Resistor", SND_SOC_NOPM, 0, 0,
457 SND_SOC_DAPM_MUX("IN2 Analog Mic Resistor", SND_SOC_NOPM, 0, 0,
459 SND_SOC_DAPM_MUX("IN3 Analog Mic Resistor", SND_SOC_NOPM, 0, 0,
461 SND_SOC_DAPM_MUX("IN4 Analog Mic Resistor", SND_SOC_NOPM, 0, 0,
499 {"Decimation Filter", "Ultra-low Latency", "DRE_ENABLE"},
511 /* Mic input */
517 {"MIC_GAIN_CTL_CH1", NULL, "IN1 Analog Mic Resistor"},
518 {"MIC_GAIN_CTL_CH1", NULL, "IN1 Analog Mic Resistor"},
519 {"MIC_GAIN_CTL_CH2", NULL, "IN2 Analog Mic Resistor"},
520 {"MIC_GAIN_CTL_CH2", NULL, "IN2 Analog Mic Resistor"},
521 {"MIC_GAIN_CTL_CH3", NULL, "IN3 Analog Mic Resistor"},
522 {"MIC_GAIN_CTL_CH3", NULL, "IN3 Analog Mic Resistor"},
523 {"MIC_GAIN_CTL_CH4", NULL, "IN4 Analog Mic Resistor"},
524 {"MIC_GAIN_CTL_CH4", NULL, "IN4 Analog Mic Resistor"},
526 {"IN1 Analog Mic Resistor", "2.5 kOhm", "MIC1P Input Mux"},
527 {"IN1 Analog Mic Resistor", "10 kOhm", "MIC1P Input Mux"},
528 {"IN1 Analog Mic Resistor", "20 kOhm", "MIC1P Input Mux"},
530 {"IN1 Analog Mic Resistor", "2.5 kOhm", "MIC1M Input Mux"},
531 {"IN1 Analog Mic Resistor", "10 kOhm", "MIC1M Input Mux"},
532 {"IN1 Analog Mic Resistor", "20 kOhm", "MIC1M Input Mux"},
534 {"IN2 Analog Mic Resistor", "2.5 kOhm", "MIC2P Input Mux"},
535 {"IN2 Analog Mic Resistor", "10 kOhm", "MIC2P Input Mux"},
536 {"IN2 Analog Mic Resistor", "20 kOhm", "MIC2P Input Mux"},
538 {"IN2 Analog Mic Resistor", "2.5 kOhm", "MIC2M Input Mux"},
539 {"IN2 Analog Mic Resistor", "10 kOhm", "MIC2M Input Mux"},
540 {"IN2 Analog Mic Resistor", "20 kOhm", "MIC2M Input Mux"},
542 {"IN3 Analog Mic Resistor", "2.5 kOhm", "MIC3P Input Mux"},
543 {"IN3 Analog Mic Resistor", "10 kOhm", "MIC3P Input Mux"},
544 {"IN3 Analog Mic Resistor", "20 kOhm", "MIC3P Input Mux"},
546 {"IN3 Analog Mic Resistor", "2.5 kOhm", "MIC3M Input Mux"},
547 {"IN3 Analog Mic Resistor", "10 kOhm", "MIC3M Input Mux"},
548 {"IN3 Analog Mic Resistor", "20 kOhm", "MIC3M Input Mux"},
550 {"IN4 Analog Mic Resistor", "2.5 kOhm", "MIC4P Input Mux"},
551 {"IN4 Analog Mic Resistor", "10 kOhm", "MIC4P Input Mux"},
552 {"IN4 Analog Mic Resistor", "20 kOhm", "MIC4P Input Mux"},
554 {"IN4 Analog Mic Resistor", "2.5 kOhm", "MIC4M Input Mux"},
555 {"IN4 Analog Mic Resistor", "10 kOhm", "MIC4M Input Mux"},
556 {"IN4 Analog Mic Resistor", "20 kOhm", "MIC4M Input Mux"},
572 {"MIC1 Analog Mux", "Line In", "MIC1P"},
573 {"MIC2 Analog Mux", "Line In", "MIC2P"},
574 {"MIC3 Analog Mux", "Line In", "MIC3P"},
575 {"MIC4 Analog Mux", "Line In", "MIC4P"},
606 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in adcx140_phase_calib_info()
607 uinfo->count = 1; in adcx140_phase_calib_info()
608 uinfo->value.integer.min = 0; in adcx140_phase_calib_info()
609 uinfo->value.integer.max = 1; in adcx140_phase_calib_info()
620 value->value.integer.value[0] = adcx140->phase_calib_on ? 1 : 0; in adcx140_phase_calib_get()
633 bool v = value->value.integer.value[0] ? true : false; in adcx140_phase_calib_put()
635 if (adcx140->phase_calib_on != v) { in adcx140_phase_calib_put()
636 adcx140->phase_calib_on = v; in adcx140_phase_calib_put()
643 SOC_SINGLE_TLV("Analog CH1 Mic Gain Volume", ADCX140_CH1_CFG1, 2, 42, 0,
645 SOC_SINGLE_TLV("Analog CH2 Mic Gain Volume", ADCX140_CH2_CFG1, 2, 42, 0,
647 SOC_SINGLE_TLV("Analog CH3 Mic Gain Volume", ADCX140_CH3_CFG1, 2, 42, 0,
649 SOC_SINGLE_TLV("Analog CH4 Mic Gain Volume", ADCX140_CH4_CFG1, 2, 42, 0,
685 if (adcx140->gpio_reset) { in adcx140_reset()
686 gpiod_direction_output(adcx140->gpio_reset, 0); in adcx140_reset()
689 gpiod_direction_output(adcx140->gpio_reset, 1); in adcx140_reset()
691 ret = regmap_write(adcx140->regmap, ADCX140_SW_RESET, in adcx140_reset()
705 struct snd_soc_component *component = adcx140->component; in adcx140_pwr_ctrl()
710 if (adcx140->micbias_vg && power_state) in adcx140_pwr_ctrl()
714 ret = regmap_write(adcx140->regmap, ADCX140_PHASE_CALIB, in adcx140_pwr_ctrl()
715 adcx140->phase_calib_on ? 0x00 : 0x40); in adcx140_pwr_ctrl()
717 dev_err(component->dev, "%s: register write error %d\n", in adcx140_pwr_ctrl()
721 regmap_update_bits(adcx140->regmap, ADCX140_PWR_CFG, in adcx140_pwr_ctrl()
729 struct snd_soc_component *component = dai->component; in adcx140_hw_params()
747 dev_err(component->dev, "%s: Unsupported width %d\n", in adcx140_hw_params()
749 return -EINVAL; in adcx140_hw_params()
765 struct snd_soc_component *component = codec_dai->component; in adcx140_set_dai_fmt()
780 dev_err(component->dev, "Invalid DAI clock provider\n"); in adcx140_set_dai_fmt()
781 return -EINVAL; in adcx140_set_dai_fmt()
800 dev_err(component->dev, "Invalid DAI interface format\n"); in adcx140_set_dai_fmt()
801 return -EINVAL; in adcx140_set_dai_fmt()
816 dev_err(component->dev, "Invalid DAI clock signal polarity\n"); in adcx140_set_dai_fmt()
817 return -EINVAL; in adcx140_set_dai_fmt()
823 adcx140->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in adcx140_set_dai_fmt()
848 struct snd_soc_component *component = codec_dai->component; in adcx140_set_dai_tdm_slot()
856 dev_err(component->dev, "Only lower adjacent slots are supported\n"); in adcx140_set_dai_tdm_slot()
857 return -EINVAL; in adcx140_set_dai_tdm_slot()
867 dev_err(component->dev, "Unsupported slot width %d\n", slot_width); in adcx140_set_dai_tdm_slot()
868 return -EINVAL; in adcx140_set_dai_tdm_slot()
871 adcx140->slot_width = slot_width; in adcx140_set_dai_tdm_slot()
890 ret = device_property_read_u32_array(adcx140->dev, in adcx140_configure_gpo()
898 dev_err(adcx140->dev, "GPO%d config out of range\n", i + 1); in adcx140_configure_gpo()
899 return -EINVAL; in adcx140_configure_gpo()
903 dev_err(adcx140->dev, "GPO%d drive out of range\n", i + 1); in adcx140_configure_gpo()
904 return -EINVAL; in adcx140_configure_gpo()
909 ret = regmap_write(adcx140->regmap, ADCX140_GPO_CFG0 + i, in adcx140_configure_gpo()
926 gpio_count = device_property_count_u32(adcx140->dev, in adcx140_configure_gpio()
927 "ti,gpio-config"); in adcx140_configure_gpio()
932 return -EINVAL; in adcx140_configure_gpio()
934 ret = device_property_read_u32_array(adcx140->dev, "ti,gpio-config", in adcx140_configure_gpio()
940 dev_err(adcx140->dev, "GPIO config out of range\n"); in adcx140_configure_gpio()
941 return -EINVAL; in adcx140_configure_gpio()
945 dev_err(adcx140->dev, "GPIO drive out of range\n"); in adcx140_configure_gpio()
946 return -EINVAL; in adcx140_configure_gpio()
952 return regmap_write(adcx140->regmap, ADCX140_GPIO_CFG0, gpio_output_val); in adcx140_configure_gpio()
972 ret = device_property_read_u32(adcx140->dev, "ti,mic-bias-source", in adcx140_codec_probe()
976 adcx140->micbias_vg = false; in adcx140_codec_probe()
978 adcx140->micbias_vg = true; in adcx140_codec_probe()
981 ret = device_property_read_u32(adcx140->dev, "ti,vref-source", in adcx140_codec_probe()
987 dev_err(adcx140->dev, "Mic Bias source value is invalid\n"); in adcx140_codec_probe()
988 return -EINVAL; in adcx140_codec_probe()
997 if (adcx140->supply_areg == NULL) in adcx140_codec_probe()
1000 ret = regmap_write(adcx140->regmap, ADCX140_SLEEP_CFG, sleep_cfg_val); in adcx140_codec_probe()
1002 dev_err(adcx140->dev, "setting sleep config failed %d\n", ret); in adcx140_codec_probe()
1009 pdm_count = device_property_count_u32(adcx140->dev, in adcx140_codec_probe()
1010 "ti,pdm-edge-select"); in adcx140_codec_probe()
1012 ret = device_property_read_u32_array(adcx140->dev, in adcx140_codec_probe()
1013 "ti,pdm-edge-select", in adcx140_codec_probe()
1019 pdm_edge_val |= pdm_edges[i] << (ADCX140_PDM_EDGE_SHIFT - i); in adcx140_codec_probe()
1021 ret = regmap_write(adcx140->regmap, ADCX140_PDM_CFG, in adcx140_codec_probe()
1027 gpi_count = device_property_count_u32(adcx140->dev, "ti,gpi-config"); in adcx140_codec_probe()
1029 ret = device_property_read_u32_array(adcx140->dev, in adcx140_codec_probe()
1030 "ti,gpi-config", in adcx140_codec_probe()
1038 ret = regmap_write(adcx140->regmap, ADCX140_GPI_CFG0, in adcx140_codec_probe()
1046 ret = regmap_write(adcx140->regmap, ADCX140_GPI_CFG1, in adcx140_codec_probe()
1060 ret = regmap_update_bits(adcx140->regmap, ADCX140_BIAS_CFG, in adcx140_codec_probe()
1064 dev_err(adcx140->dev, "setting MIC bias failed %d\n", ret); in adcx140_codec_probe()
1066 tx_high_z = device_property_read_bool(adcx140->dev, "ti,asi-tx-drive"); in adcx140_codec_probe()
1068 ret = regmap_update_bits(adcx140->regmap, ADCX140_ASI_CFG0, in adcx140_codec_probe()
1071 dev_err(adcx140->dev, "Setting Tx drive failed %d\n", ret); in adcx140_codec_probe()
1117 .name = "tlv320adcx140-codec",
1144 regulator_disable(adcx140->supply_areg); in adcx140_disable_regulator()
1152 adcx140 = devm_kzalloc(&i2c->dev, sizeof(*adcx140), GFP_KERNEL); in adcx140_i2c_probe()
1154 return -ENOMEM; in adcx140_i2c_probe()
1156 adcx140->phase_calib_on = false; in adcx140_i2c_probe()
1157 adcx140->dev = &i2c->dev; in adcx140_i2c_probe()
1159 adcx140->gpio_reset = devm_gpiod_get_optional(adcx140->dev, in adcx140_i2c_probe()
1161 if (IS_ERR(adcx140->gpio_reset)) in adcx140_i2c_probe()
1162 dev_info(&i2c->dev, "Reset GPIO not defined\n"); in adcx140_i2c_probe()
1164 adcx140->supply_areg = devm_regulator_get_optional(adcx140->dev, in adcx140_i2c_probe()
1166 if (IS_ERR(adcx140->supply_areg)) { in adcx140_i2c_probe()
1167 if (PTR_ERR(adcx140->supply_areg) == -EPROBE_DEFER) in adcx140_i2c_probe()
1168 return -EPROBE_DEFER; in adcx140_i2c_probe()
1170 adcx140->supply_areg = NULL; in adcx140_i2c_probe()
1172 ret = regulator_enable(adcx140->supply_areg); in adcx140_i2c_probe()
1174 dev_err(adcx140->dev, "Failed to enable areg\n"); in adcx140_i2c_probe()
1178 ret = devm_add_action_or_reset(&i2c->dev, adcx140_disable_regulator, adcx140); in adcx140_i2c_probe()
1183 adcx140->regmap = devm_regmap_init_i2c(i2c, &adcx140_i2c_regmap); in adcx140_i2c_probe()
1184 if (IS_ERR(adcx140->regmap)) { in adcx140_i2c_probe()
1185 ret = PTR_ERR(adcx140->regmap); in adcx140_i2c_probe()
1186 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in adcx140_i2c_probe()
1193 return devm_snd_soc_register_component(&i2c->dev, in adcx140_i2c_probe()
1208 .name = "tlv320adcx140-codec",