Lines Matching +full:dmic1 +full:- +full:data +full:- +full:pin
1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt274.c -- RT274 ALSA SoC audio codec driver
23 #include <sound/soc-dapm.h>
344 snd_soc_component_write(component, rt274->index_cache[i].reg, in rt274_index_sync()
345 rt274->index_cache[i].def); in rt274_index_sync()
358 if (!rt274->component) in rt274_jack_detect()
359 return -EINVAL; in rt274_jack_detect()
361 ret = regmap_read(rt274->regmap, RT274_GET_HP_SENSE, &buf); in rt274_jack_detect()
366 ret = regmap_read(rt274->regmap, RT274_GET_MIC_SENSE, &buf); in rt274_jack_detect()
394 snd_soc_jack_report(rt274->jack, status, in rt274_jack_detect_work()
398 static irqreturn_t rt274_irq(int irq, void *data);
401 struct snd_soc_jack *jack, void *data) in rt274_mic_detect() argument
405 rt274->jack = jack; in rt274_mic_detect()
409 regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, in rt274_mic_detect()
415 regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, in rt274_mic_detect()
424 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6350, 50, 0);
478 /* HP-OUT source */
494 SND_SOC_DAPM_INPUT("DMIC1 Pin"),
495 SND_SOC_DAPM_INPUT("DMIC2 Pin"),
501 SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0),
555 SND_SOC_DAPM_OUTPUT("HPO Pin"),
561 {"DMIC1", NULL, "DMIC1 Pin"},
562 {"DMIC2", NULL, "DMIC2 Pin"},
565 {"ADC 0 Mux", "Dmic", "DMIC1"},
609 {"HPO Pin", NULL, "HPO L"},
610 {"HPO Pin", NULL, "HPO R"},
617 struct snd_soc_component *component = dai->component; in rt274_hw_params()
628 dev_err(component->dev, "Unsupported sample rate %d\n", in rt274_hw_params()
630 return -EINVAL; in rt274_hw_params()
632 switch (rt274->sys_clk) { in rt274_hw_params()
636 dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", in rt274_hw_params()
637 params_rate(params), rt274->sys_clk); in rt274_hw_params()
638 return -EINVAL; in rt274_hw_params()
644 dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", in rt274_hw_params()
645 params_rate(params), rt274->sys_clk); in rt274_hw_params()
646 return -EINVAL; in rt274_hw_params()
653 val |= (params_channels(params) - 1); in rt274_hw_params()
655 dev_err(component->dev, "Unsupported channels %d\n", in rt274_hw_params()
657 return -EINVAL; in rt274_hw_params()
687 return -EINVAL; in rt274_hw_params()
690 if (rt274->master) in rt274_hw_params()
695 dev_dbg(component->dev, "format val = 0x%x\n", val); in rt274_hw_params()
705 struct snd_soc_component *component = dai->component; in rt274_set_dai_fmt()
712 rt274->master = true; in rt274_set_dai_fmt()
717 rt274->master = false; in rt274_set_dai_fmt()
720 return -EINVAL; in rt274_set_dai_fmt()
741 return -EINVAL; in rt274_set_dai_fmt()
743 /* bit 15 Stream Type 0:PCM 1:Non-PCM */ in rt274_set_dai_fmt()
753 struct snd_soc_component *component = dai->component; in rt274_set_dai_pll()
762 dev_warn(component->dev, "invalid pll source, use BCLK\n"); in rt274_set_dai_pll()
773 switch (rt274->fs) { in rt274_set_dai_pll()
790 dev_warn(component->dev, "invalid freq_in, assume 4.8M\n"); in rt274_set_dai_pll()
806 struct snd_soc_component *component = dai->component; in rt274_set_dai_sysclk()
810 dev_dbg(component->dev, "%s freq=%d\n", __func__, freq); in rt274_set_dai_sysclk()
828 dev_warn(component->dev, "invalid sysclk source, use PLL1\n"); in rt274_set_dai_sysclk()
839 dev_err(component->dev, "Should not use MCLK\n"); in rt274_set_dai_sysclk()
840 return -EINVAL; in rt274_set_dai_sysclk()
847 dev_err(component->dev, "Should not use MCLK\n"); in rt274_set_dai_sysclk()
848 return -EINVAL; in rt274_set_dai_sysclk()
864 dev_err(component->dev, "Unsupported system clock\n"); in rt274_set_dai_sysclk()
865 return -EINVAL; in rt274_set_dai_sysclk()
868 rt274->sys_clk = freq; in rt274_set_dai_sysclk()
869 rt274->clk_id = clk_id; in rt274_set_dai_sysclk()
876 struct snd_soc_component *component = dai->component; in rt274_set_bclk_ratio()
879 dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); in rt274_set_bclk_ratio()
880 rt274->fs = ratio; in rt274_set_bclk_ratio()
896 struct snd_soc_component *component = dai->component; in rt274_set_tdm_slot()
917 dev_err(component->dev, in rt274_set_tdm_slot()
919 return -EINVAL; in rt274_set_tdm_slot()
949 static irqreturn_t rt274_irq(int irq, void *data) in rt274_irq() argument
951 struct rt274_priv *rt274 = data; in rt274_irq()
957 regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, in rt274_irq()
969 snd_soc_jack_report(rt274->jack, status, in rt274_irq()
972 pm_wakeup_event(&rt274->i2c->dev, 300); in rt274_irq()
982 rt274->component = component; in rt274_probe()
983 INIT_DELAYED_WORK(&rt274->jack_detect_work, rt274_jack_detect_work); in rt274_probe()
985 if (rt274->i2c->irq) in rt274_probe()
986 schedule_delayed_work(&rt274->jack_detect_work, in rt274_probe()
995 cancel_delayed_work_sync(&rt274->jack_detect_work); in rt274_remove()
996 rt274->component = NULL; in rt274_remove()
1004 regcache_cache_only(rt274->regmap, true); in rt274_suspend()
1005 regcache_mark_dirty(rt274->regmap); in rt274_suspend()
1014 regcache_cache_only(rt274->regmap, false); in rt274_resume()
1016 regcache_sync(rt274->regmap); in rt274_resume()
1040 .name = "rt274-aif1",
1121 rt274 = devm_kzalloc(&i2c->dev, sizeof(*rt274), in rt274_i2c_probe()
1124 return -ENOMEM; in rt274_i2c_probe()
1126 rt274->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt274_regmap); in rt274_i2c_probe()
1127 if (IS_ERR(rt274->regmap)) { in rt274_i2c_probe()
1128 ret = PTR_ERR(rt274->regmap); in rt274_i2c_probe()
1129 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt274_i2c_probe()
1134 ret = regmap_read(rt274->regmap, in rt274_i2c_probe()
1140 dev_err(&i2c->dev, in rt274_i2c_probe()
1142 return -ENODEV; in rt274_i2c_probe()
1145 rt274->index_cache = devm_kmemdup(&i2c->dev, rt274_index_def, in rt274_i2c_probe()
1147 if (!rt274->index_cache) in rt274_i2c_probe()
1148 return -ENOMEM; in rt274_i2c_probe()
1150 rt274->index_cache_size = INDEX_CACHE_SIZE; in rt274_i2c_probe()
1151 rt274->i2c = i2c; in rt274_i2c_probe()
1155 regmap_write(rt274->regmap, RT274_RESET, 0); in rt274_i2c_probe()
1156 regmap_update_bits(rt274->regmap, 0x1a, 0x4000, 0x4000); in rt274_i2c_probe()
1159 regmap_update_bits(rt274->regmap, RT274_PAD_CTRL12, 0x3, 0x0); in rt274_i2c_probe()
1160 regmap_write(rt274->regmap, RT274_COEF5b_INDEX, 0x01); in rt274_i2c_probe()
1161 regmap_write(rt274->regmap, RT274_COEF5b_COEF, 0x8540); in rt274_i2c_probe()
1162 regmap_update_bits(rt274->regmap, 0x6f, 0x0100, 0x0100); in rt274_i2c_probe()
1164 regmap_write(rt274->regmap, 0x4a, 0x201b); in rt274_i2c_probe()
1166 regmap_update_bits(rt274->regmap, 0x6f, 0x3000, 0x2000); in rt274_i2c_probe()
1168 regmap_update_bits(rt274->regmap, 0x6f, 0xf, 0x0); in rt274_i2c_probe()
1170 regmap_write(rt274->regmap, RT274_COEF58_INDEX, 0x00); in rt274_i2c_probe()
1171 regmap_write(rt274->regmap, RT274_COEF58_COEF, 0xb888); in rt274_i2c_probe()
1173 regmap_update_bits(rt274->regmap, 0x6f, 0xf, 0xb); in rt274_i2c_probe()
1174 regmap_write(rt274->regmap, RT274_COEF58_INDEX, 0x00); in rt274_i2c_probe()
1175 regmap_write(rt274->regmap, RT274_COEF58_COEF, 0x3888); in rt274_i2c_probe()
1176 /* Set pin widget */ in rt274_i2c_probe()
1177 regmap_write(rt274->regmap, RT274_SET_PIN_HPO, 0x40); in rt274_i2c_probe()
1178 regmap_write(rt274->regmap, RT274_SET_PIN_LOUT3, 0x40); in rt274_i2c_probe()
1179 regmap_write(rt274->regmap, RT274_SET_MIC, 0x20); in rt274_i2c_probe()
1180 regmap_write(rt274->regmap, RT274_SET_PIN_DMIC1, 0x20); in rt274_i2c_probe()
1182 regmap_update_bits(rt274->regmap, RT274_I2S_CTRL2, 0xc004, 0x4004); in rt274_i2c_probe()
1183 regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, in rt274_i2c_probe()
1187 regmap_write(rt274->regmap, RT274_UNSOLICITED_HP_OUT, 0x81); in rt274_i2c_probe()
1188 regmap_write(rt274->regmap, RT274_UNSOLICITED_MIC, 0x82); in rt274_i2c_probe()
1190 if (rt274->i2c->irq) { in rt274_i2c_probe()
1191 ret = request_threaded_irq(rt274->i2c->irq, NULL, rt274_irq, in rt274_i2c_probe()
1194 dev_err(&i2c->dev, in rt274_i2c_probe()
1200 ret = devm_snd_soc_register_component(&i2c->dev, in rt274_i2c_probe()
1211 if (i2c->irq) in rt274_i2c_remove()
1212 free_irq(i2c->irq, rt274); in rt274_i2c_remove()