Lines Matching +full:dmic1 +full:- +full:data +full:- +full:pin
1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt286.c -- RT286 ALSA SoC audio codec driver
23 #include <sound/soc-dapm.h>
196 snd_soc_component_write(component, rt286->index_cache[i].reg,
197 rt286->index_cache[i].def);
223 if (!rt286->component)
224 return -EINVAL;
226 dapm = snd_soc_component_get_dapm(rt286->component);
228 if (rt286->pdata.cbj_en) {
229 regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf);
233 regmap_update_bits(rt286->regmap,
242 regmap_write(rt286->regmap, RT286_SET_MIC1, 0x24);
245 regmap_update_bits(rt286->regmap,
248 regmap_read(rt286->regmap, RT286_CBJ_CTRL2, &val);
253 regmap_update_bits(rt286->regmap,
256 regmap_read(rt286->regmap,
262 regmap_update_bits(rt286->regmap,
268 regmap_update_bits(rt286->regmap,
273 regmap_write(rt286->regmap, RT286_SET_MIC1, 0x20);
274 regmap_update_bits(rt286->regmap,
278 regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf);
280 regmap_read(rt286->regmap, RT286_GET_MIC1_SENSE, &buf);
310 snd_soc_jack_report(rt286->jack, status,
315 struct snd_soc_jack *jack, void *data)
320 rt286->jack = jack;
324 if (rt286->jack->status & SND_JACK_HEADPHONE)
326 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x2);
328 snd_soc_jack_report(rt286->jack, rt286->jack->status,
332 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x0);
343 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
346 if (rt286->clk_id == RT286_SCLK_S_MCLK)
352 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6350, 50, 0);
426 /* HP-OUT source */
433 /* SPK-OUT source */
443 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
465 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
484 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
503 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
542 SND_SOC_DAPM_INPUT("DMIC1 Pin"),
543 SND_SOC_DAPM_INPUT("DMIC2 Pin"),
549 SND_SOC_DAPM_PGA_E("DMIC1", RT286_SET_POWER(RT286_DMIC1), 0, 1,
607 SND_SOC_DAPM_OUTPUT("HPO Pin"),
631 {"DMIC1", NULL, "DMIC1 Pin"},
632 {"DMIC2", NULL, "DMIC2 Pin"},
633 {"DMIC1", NULL, "DMIC Receiver"},
640 {"ADC 0 Mux", "Dmic", "DMIC1"},
675 {"HPO Pin", NULL, "HPO L"},
676 {"HPO Pin", NULL, "HPO R"},
683 struct snd_soc_component *component = dai->component;
696 dev_err(component->dev, "Unsupported sample rate %d\n",
698 return -EINVAL;
700 switch (rt286->sys_clk) {
704 dev_err(component->dev, "Sys_clk is not matched (%d %d)\n",
705 params_rate(params), rt286->sys_clk);
706 return -EINVAL;
712 dev_err(component->dev, "Sys_clk is not matched (%d %d)\n",
713 params_rate(params), rt286->sys_clk);
714 return -EINVAL;
721 val |= (params_channels(params) - 1);
723 dev_err(component->dev, "Unsupported channels %d\n",
725 return -EINVAL;
750 return -EINVAL;
755 dev_dbg(component->dev, "format val = 0x%x\n", val);
765 struct snd_soc_component *component = dai->component;
777 return -EINVAL;
798 return -EINVAL;
800 /* bit 15 Stream Type 0:PCM 1:Non-PCM */
810 struct snd_soc_component *component = dai->component;
813 dev_dbg(component->dev, "%s freq=%d\n", __func__, freq);
832 dev_err(component->dev, "Should not use MCLK\n");
833 return -EINVAL;
840 dev_err(component->dev, "Should not use MCLK\n");
841 return -EINVAL;
861 dev_err(component->dev, "Unsupported system clock\n");
862 return -EINVAL;
865 rt286->sys_clk = freq;
866 rt286->clk_id = clk_id;
873 struct snd_soc_component *component = dai->component;
875 dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio);
919 static irqreturn_t rt286_irq(int irq, void *data)
921 struct rt286_priv *rt286 = data;
929 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x1, 0x1);
937 snd_soc_jack_report(rt286->jack, status,
940 pm_wakeup_event(&rt286->i2c->dev, 300);
949 rt286->component = component;
950 INIT_DELAYED_WORK(&rt286->jack_detect_work, rt286_jack_detect_work);
952 if (rt286->i2c->irq)
953 schedule_delayed_work(&rt286->jack_detect_work,
962 cancel_delayed_work_sync(&rt286->jack_detect_work);
963 rt286->component = NULL;
971 regcache_cache_only(rt286->regmap, true);
972 regcache_mark_dirty(rt286->regmap);
981 regcache_cache_only(rt286->regmap, false);
983 regcache_sync(rt286->regmap);
1005 .name = "rt286-aif1",
1025 .name = "rt286-aif2",
1135 struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev);
1139 rt286 = devm_kzalloc(&i2c->dev, sizeof(*rt286),
1142 return -ENOMEM;
1144 rt286->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt286_regmap);
1145 if (IS_ERR(rt286->regmap)) {
1146 ret = PTR_ERR(rt286->regmap);
1147 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
1152 ret = regmap_read(rt286->regmap,
1155 dev_err(&i2c->dev, "I2C error %d\n", ret);
1159 dev_err(&i2c->dev,
1162 return -ENODEV;
1165 rt286->index_cache = devm_kmemdup(&i2c->dev, rt286_index_def,
1167 if (!rt286->index_cache)
1168 return -ENOMEM;
1170 rt286->index_cache_size = INDEX_CACHE_SIZE;
1171 rt286->i2c = i2c;
1176 regmap_write(rt286->regmap, rt286->index_cache[i].reg,
1177 rt286->index_cache[i].def);
1179 regmap_write(rt286->regmap, rt286_reg[i].reg,
1183 rt286->pdata = *pdata;
1187 rt286->pdata.cbj_en = true;
1189 regmap_write(rt286->regmap, RT286_SET_AUDIO_POWER, AC_PWRST_D3);
1192 regmap_write(rt286->regmap,
1196 if (!rt286->pdata.cbj_en) {
1197 regmap_write(rt286->regmap, RT286_CBJ_CTRL2, 0x0000);
1198 regmap_write(rt286->regmap, RT286_MIC1_DET_CTRL, 0x0816);
1199 regmap_update_bits(rt286->regmap,
1202 regmap_update_bits(rt286->regmap,
1208 if (!rt286->pdata.gpio2_en)
1209 regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0x40);
1211 regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0);
1215 regmap_write(rt286->regmap, RT286_MISC_CTRL1, 0x0000);
1217 regmap_update_bits(rt286->regmap, RT286_POWER_CTRL2, 0xc, 0x0);
1218 regmap_update_bits(rt286->regmap, RT286_POWER_CTRL1, 0x1001, 0x1001);
1221 regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL2, 0x403a, 0x401a);
1222 regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL3, 0xf777, 0x4737);
1223 regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL4, 0x00ff, 0x003f);
1226 regmap_update_bits(rt286->regmap,
1228 regmap_update_bits(rt286->regmap,
1230 regmap_update_bits(rt286->regmap,
1232 regmap_update_bits(rt286->regmap,
1236 if (rt286->i2c->irq) {
1237 ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq,
1240 dev_err(&i2c->dev,
1246 ret = devm_snd_soc_register_component(&i2c->dev,
1257 if (i2c->irq)
1258 free_irq(i2c->irq, rt286);