H A D | rt286.c | 2 * rt286.c -- RT286 ALSA SoC audio codec driver 31 #include <sound/rt286.h> 34 #include "rt286.h" 191 struct rt286_priv *rt286 = i2c_get_clientdata(client); rt286_hw_write() local 199 if (reg == rt286->index_cache[i].reg) { rt286_hw_write() 200 rt286->index_cache[i].def = value; rt286_hw_write() 279 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); rt286_index_sync() local 283 snd_soc_write(codec, rt286->index_cache[i].reg, rt286_index_sync() 284 rt286->index_cache[i].def); rt286_index_sync() 302 static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic) rt286_jack_detect() argument 309 if (!rt286->codec) rt286_jack_detect() 311 if (rt286->pdata.cbj_en) { rt286_jack_detect() 312 regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); rt286_jack_detect() 316 regmap_update_bits(rt286->regmap, rt286_jack_detect() 319 snd_soc_dapm_force_enable_pin(&rt286->codec->dapm, rt286_jack_detect() 321 snd_soc_dapm_force_enable_pin(&rt286->codec->dapm, rt286_jack_detect() 324 snd_soc_dapm_force_enable_pin(&rt286->codec->dapm, rt286_jack_detect() 326 snd_soc_dapm_sync(&rt286->codec->dapm); rt286_jack_detect() 328 regmap_write(rt286->regmap, RT286_SET_MIC1, 0x24); rt286_jack_detect() 331 regmap_update_bits(rt286->regmap, rt286_jack_detect() 334 regmap_read(rt286->regmap, RT286_CBJ_CTRL2, &val); rt286_jack_detect() 339 regmap_update_bits(rt286->regmap, rt286_jack_detect() 342 regmap_read(rt286->regmap, rt286_jack_detect() 349 regmap_update_bits(rt286->regmap, rt286_jack_detect() 354 regmap_write(rt286->regmap, RT286_SET_MIC1, 0x20); rt286_jack_detect() 357 regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); rt286_jack_detect() 359 regmap_read(rt286->regmap, RT286_GET_MIC1_SENSE, &buf); rt286_jack_detect() 363 snd_soc_dapm_disable_pin(&rt286->codec->dapm, "HV"); rt286_jack_detect() 364 snd_soc_dapm_disable_pin(&rt286->codec->dapm, "VREF"); rt286_jack_detect() 366 snd_soc_dapm_disable_pin(&rt286->codec->dapm, "LDO1"); rt286_jack_detect() 367 snd_soc_dapm_sync(&rt286->codec->dapm); rt286_jack_detect() 374 struct rt286_priv *rt286 = rt286_jack_detect_work() local 380 rt286_jack_detect(rt286, &hp, &mic); rt286_jack_detect_work() 388 snd_soc_jack_report(rt286->jack, status, rt286_jack_detect_work() 394 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); rt286_mic_detect() local 396 rt286->jack = jack; rt286_mic_detect() 400 if (rt286->jack->status & SND_JACK_HEADPHONE) rt286_mic_detect() 402 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x2); rt286_mic_detect() 404 snd_soc_jack_report(rt286->jack, rt286->jack->status, rt286_mic_detect() 408 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x0); rt286_mic_detect() 421 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); is_mclk_mode() local 423 if (rt286->clk_id == RT286_SCLK_S_MCLK) is_mclk_mode() 779 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); rt286_hw_params() local 795 switch (rt286->sys_clk) { rt286_hw_params() 800 params_rate(params), rt286->sys_clk); rt286_hw_params() 808 params_rate(params), rt286->sys_clk); rt286_hw_params() 907 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); rt286_set_dai_sysclk() local 961 rt286->sys_clk = freq; rt286_set_dai_sysclk() 962 rt286->clk_id = clk_id; rt286_set_dai_sysclk() 1022 struct rt286_priv *rt286 = data; rt286_irq() local 1027 rt286_jack_detect(rt286, &hp, &mic); rt286_irq() 1030 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x1, 0x1); rt286_irq() 1038 snd_soc_jack_report(rt286->jack, status, rt286_irq() 1041 pm_wakeup_event(&rt286->i2c->dev, 300); rt286_irq() 1048 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); rt286_probe() local 1050 rt286->codec = codec; rt286_probe() 1052 if (rt286->i2c->irq) { rt286_probe() 1053 regmap_update_bits(rt286->regmap, rt286_probe() 1056 INIT_DELAYED_WORK(&rt286->jack_detect_work, rt286_probe() 1058 schedule_delayed_work(&rt286->jack_detect_work, rt286_probe() 1067 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); rt286_remove() local 1069 cancel_delayed_work_sync(&rt286->jack_detect_work); rt286_remove() 1077 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); rt286_suspend() local 1079 regcache_cache_only(rt286->regmap, true); rt286_suspend() 1080 regcache_mark_dirty(rt286->regmap); rt286_suspend() 1087 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); rt286_resume() local 1089 regcache_cache_only(rt286->regmap, false); rt286_resume() 1091 regcache_sync(rt286->regmap); rt286_resume() 1113 .name = "rt286-aif1", 1133 .name = "rt286-aif2", 1184 {"rt286", 0}, 1221 struct rt286_priv *rt286; rt286_i2c_probe() local 1224 rt286 = devm_kzalloc(&i2c->dev, sizeof(*rt286), rt286_i2c_probe() 1226 if (NULL == rt286) rt286_i2c_probe() 1229 rt286->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt286_regmap); rt286_i2c_probe() 1230 if (IS_ERR(rt286->regmap)) { rt286_i2c_probe() 1231 ret = PTR_ERR(rt286->regmap); rt286_i2c_probe() 1237 ret = regmap_read(rt286->regmap, rt286_i2c_probe() 1245 "Device with ID register %x is not rt286\n", val); rt286_i2c_probe() 1249 rt286->index_cache = rt286_index_def; rt286_i2c_probe() 1250 rt286->i2c = i2c; rt286_i2c_probe() 1251 i2c_set_clientdata(i2c, rt286); rt286_i2c_probe() 1255 regmap_write(rt286->regmap, rt286->index_cache[i].reg, rt286_i2c_probe() 1256 rt286->index_cache[i].def); rt286_i2c_probe() 1258 regmap_write(rt286->regmap, rt286_reg[i].reg, rt286_i2c_probe() 1262 rt286->pdata = *pdata; rt286_i2c_probe() 1266 rt286->pdata.cbj_en = true; rt286_i2c_probe() 1268 regmap_write(rt286->regmap, RT286_SET_AUDIO_POWER, AC_PWRST_D3); rt286_i2c_probe() 1271 regmap_write(rt286->regmap, rt286_i2c_probe() 1275 if (!rt286->pdata.cbj_en) { rt286_i2c_probe() 1276 regmap_write(rt286->regmap, RT286_CBJ_CTRL2, 0x0000); rt286_i2c_probe() 1277 regmap_write(rt286->regmap, RT286_MIC1_DET_CTRL, 0x0816); rt286_i2c_probe() 1278 regmap_update_bits(rt286->regmap, rt286_i2c_probe() 1281 regmap_update_bits(rt286->regmap, rt286_i2c_probe() 1287 if (!rt286->pdata.gpio2_en) rt286_i2c_probe() 1288 regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0x4000); rt286_i2c_probe() 1290 regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0); rt286_i2c_probe() 1294 regmap_write(rt286->regmap, RT286_MISC_CTRL1, 0x0000); rt286_i2c_probe() 1296 regmap_update_bits(rt286->regmap, RT286_POWER_CTRL2, 0xc, 0x0); rt286_i2c_probe() 1297 regmap_update_bits(rt286->regmap, RT286_POWER_CTRL1, 0x1001, 0x1001); rt286_i2c_probe() 1300 regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL2, 0x403a, 0x401a); rt286_i2c_probe() 1301 regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL3, 0xf777, 0x4737); rt286_i2c_probe() 1302 regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL4, 0x00ff, 0x003f); rt286_i2c_probe() 1305 regmap_update_bits(rt286->regmap, rt286_i2c_probe() 1307 regmap_update_bits(rt286->regmap, rt286_i2c_probe() 1309 regmap_update_bits(rt286->regmap, rt286_i2c_probe() 1311 regmap_update_bits(rt286->regmap, rt286_i2c_probe() 1315 if (rt286->i2c->irq) { rt286_i2c_probe() 1316 ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq, rt286_i2c_probe() 1317 IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt286", rt286); rt286_i2c_probe() 1333 struct rt286_priv *rt286 = i2c_get_clientdata(i2c); rt286_i2c_remove() local 1336 free_irq(i2c->irq, rt286); rt286_i2c_remove() 1345 .name = "rt286",
|