H A D | rt5670.c | 2 * rt5670.c -- RT5670 ALSA SoC audio codec driver 31 #include <sound/rt5670.h> 34 #include "rt5670.h" 35 #include "rt5670-dsp.h" 419 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_headset_detect() local 441 rt5670->jack_type = SND_JACK_HEADSET; rt5670_headset_detect() 448 rt5670->jack_type = SND_JACK_HEADPHONE; rt5670_headset_detect() 455 rt5670->jack_type = 0; rt5670_headset_detect() 460 return rt5670->jack_type; rt5670_headset_detect() 465 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_jack_suspend() local 467 rt5670->jack_type_saved = rt5670->jack_type; rt5670_jack_suspend() 474 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_jack_resume() local 476 if (rt5670->jack_type_saved) rt5670_jack_resume() 499 struct rt5670_priv *rt5670 = (struct rt5670_priv *)data; rt5670_irq_detection() local 500 struct snd_soc_jack_gpio *gpio = &rt5670->hp_gpio; rt5670_irq_detection() 501 struct snd_soc_jack *jack = rt5670->jack; rt5670_irq_detection() 504 if (rt5670->pdata.jd_mode == 1) /* 2 port */ rt5670_irq_detection() 505 val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0070; rt5670_irq_detection() 507 val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0020; rt5670_irq_detection() 513 if (rt5670->jack_type == 0) { rt5670_irq_detection() 514 report = rt5670_headset_detect(rt5670->codec, 1); rt5670_irq_detection() 520 if (snd_soc_read(rt5670->codec, RT5670_INT_IRQ_ST) & 0x4) { rt5670_irq_detection() 523 btn_type = rt5670_button_detect(rt5670->codec); rt5670_irq_detection() 535 dev_err(rt5670->codec->dev, rt5670_irq_detection() 542 report = rt5670->jack_type; rt5670_irq_detection() 550 snd_soc_update_bits(rt5670->codec, RT5670_INT_IRQ_ST, 0x1, 0x0); rt5670_irq_detection() 551 rt5670_headset_detect(rt5670->codec, 0); rt5670_irq_detection() 564 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_set_jack_detect() local 567 rt5670->jack = jack; rt5670_set_jack_detect() 568 rt5670->hp_gpio.gpiod_dev = codec->dev; rt5670_set_jack_detect() 569 rt5670->hp_gpio.name = "headphone detect"; rt5670_set_jack_detect() 570 rt5670->hp_gpio.report = SND_JACK_HEADSET | rt5670_set_jack_detect() 572 rt5670->hp_gpio.debounce_time = 150; rt5670_set_jack_detect() 573 rt5670->hp_gpio.wake = true; rt5670_set_jack_detect() 574 rt5670->hp_gpio.data = (struct rt5670_priv *)rt5670; rt5670_set_jack_detect() 575 rt5670->hp_gpio.jack_status_check = rt5670_irq_detection; rt5670_set_jack_detect() 577 ret = snd_soc_jack_add_gpios(rt5670->jack, 1, rt5670_set_jack_detect() 578 &rt5670->hp_gpio); rt5670_set_jack_detect() 684 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); set_dmic_clk() local 687 rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap, set_dmic_clk() 702 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); is_sys_clk_from_pll() local 704 if (rt5670->sysclk_src == RT5670_SCLK_S_PLL1) is_sys_clk_from_pll() 766 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); can_use_asrc() local 768 if (rt5670->sysclk > rt5670->lrck[RT5670_AIF1] * 384) can_use_asrc() 1416 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_hp_power_event() local 1420 regmap_update_bits(rt5670->regmap, RT5670_CHARGE_PUMP, rt5670_hp_power_event() 1422 regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, rt5670_hp_power_event() 1425 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, rt5670_hp_power_event() 1430 regmap_write(rt5670->regmap, RT5670_DEPOP_M2, 0x3100); rt5670_hp_power_event() 1431 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8009); rt5670_hp_power_event() 1432 regmap_write(rt5670->regmap, RT5670_PR_BASE + rt5670_hp_power_event() 1435 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); rt5670_hp_power_event() 1438 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x0004); rt5670_hp_power_event() 1452 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_hp_event() local 1457 regmap_write(rt5670->regmap, RT5670_PR_BASE + rt5670_hp_event() 1459 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); rt5670_hp_event() 1460 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x805d); rt5670_hp_event() 1461 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); rt5670_hp_event() 1462 regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, rt5670_hp_event() 1464 regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, rt5670_hp_event() 1467 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); rt5670_hp_event() 1472 regmap_write(rt5670->regmap, RT5670_PR_BASE + rt5670_hp_event() 1474 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); rt5670_hp_event() 1475 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x803d); rt5670_hp_event() 1477 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); rt5670_hp_event() 1479 regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, rt5670_hp_event() 1483 regmap_update_bits(rt5670->regmap, rt5670_hp_event() 1485 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); rt5670_hp_event() 1486 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0707); rt5670_hp_event() 1487 regmap_write(rt5670->regmap, RT5670_PR_BASE + rt5670_hp_event() 2320 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_hw_params() local 2324 rt5670->lrck[dai->id] = params_rate(params); rt5670_hw_params() 2325 pre_div = rl6231_get_clk_info(rt5670->sysclk, rt5670->lrck[dai->id]); rt5670_hw_params() 2328 rt5670->lrck[dai->id], dai->id); rt5670_hw_params() 2337 rt5670->bclk[dai->id] = rt5670->lrck[dai->id] * (32 << bclk_ms); rt5670_hw_params() 2340 rt5670->bclk[dai->id], rt5670->lrck[dai->id]); rt5670_hw_params() 2388 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_set_dai_fmt() local 2393 rt5670->master[dai->id] = 1; rt5670_set_dai_fmt() 2397 rt5670->master[dai->id] = 0; rt5670_set_dai_fmt() 2451 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_set_dai_sysclk() local 2470 rt5670->sysclk = freq; rt5670_set_dai_sysclk() 2472 rt5670->sysclk_src = clk_id; rt5670_set_dai_sysclk() 2483 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_set_dai_pll() local 2487 if (source == rt5670->pll_src && freq_in == rt5670->pll_in && rt5670_set_dai_pll() 2488 freq_out == rt5670->pll_out) rt5670_set_dai_pll() 2494 rt5670->pll_in = 0; rt5670_set_dai_pll() 2495 rt5670->pll_out = 0; rt5670_set_dai_pll() 2545 rt5670->pll_in = freq_in; rt5670_set_dai_pll() 2546 rt5670->pll_out = freq_out; rt5670_set_dai_pll() 2547 rt5670->pll_src = source; rt5670_set_dai_pll() 2601 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_set_bias_level() local 2631 if (rt5670->pdata.jd_mode) rt5670_set_bias_level() 2656 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_probe() local 2681 rt5670->codec = codec; rt5670_probe() 2688 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_remove() local 2690 regmap_write(rt5670->regmap, RT5670_RESET, 0); rt5670_remove() 2691 snd_soc_jack_free_gpios(rt5670->jack, 1, &rt5670->hp_gpio); rt5670_remove() 2698 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_suspend() local 2700 regcache_cache_only(rt5670->regmap, true); rt5670_suspend() 2701 regcache_mark_dirty(rt5670->regmap); rt5670_suspend() 2707 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); rt5670_resume() local 2709 regcache_cache_only(rt5670->regmap, false); rt5670_resume() 2710 regcache_sync(rt5670->regmap); rt5670_resume() 2733 .name = "rt5670-aif1", 2752 .name = "rt5670-aif2", 2803 { "rt5670", 0 }, 2833 struct rt5670_priv *rt5670; rt5670_i2c_probe() local 2837 rt5670 = devm_kzalloc(&i2c->dev, rt5670_i2c_probe() 2840 if (NULL == rt5670) rt5670_i2c_probe() 2843 i2c_set_clientdata(i2c, rt5670); rt5670_i2c_probe() 2846 rt5670->pdata = *pdata; rt5670_i2c_probe() 2849 rt5670->pdata.dmic_en = true; rt5670_i2c_probe() 2850 rt5670->pdata.dmic1_data_pin = RT5670_DMIC_DATA_IN2P; rt5670_i2c_probe() 2851 rt5670->pdata.dev_gpio = true; rt5670_i2c_probe() 2852 rt5670->pdata.jd_mode = 1; rt5670_i2c_probe() 2855 rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap); rt5670_i2c_probe() 2856 if (IS_ERR(rt5670->regmap)) { rt5670_i2c_probe() 2857 ret = PTR_ERR(rt5670->regmap); rt5670_i2c_probe() 2863 regmap_read(rt5670->regmap, RT5670_VENDOR_ID2, &val); rt5670_i2c_probe() 2866 "Device with ID register %#x is not rt5670/72\n", val); rt5670_i2c_probe() 2870 regmap_write(rt5670->regmap, RT5670_RESET, 0); rt5670_i2c_probe() 2871 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, rt5670_i2c_probe() 2876 regmap_write(rt5670->regmap, RT5670_RESET, 0); rt5670_i2c_probe() 2878 regmap_read(rt5670->regmap, RT5670_VENDOR_ID, &val); rt5670_i2c_probe() 2880 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0980); rt5670_i2c_probe() 2882 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0d00); rt5670_i2c_probe() 2884 ret = regmap_register_patch(rt5670->regmap, init_list, rt5670_i2c_probe() 2889 if (rt5670->pdata.in2_diff) rt5670_i2c_probe() 2890 regmap_update_bits(rt5670->regmap, RT5670_IN2, rt5670_i2c_probe() 2893 if (rt5670->pdata.dev_gpio) { rt5670_i2c_probe() 2895 regmap_write(rt5670->regmap, RT5670_IL_CMD, 0x0000); rt5670_i2c_probe() 2896 regmap_write(rt5670->regmap, RT5670_IL_CMD2, 0x0010); rt5670_i2c_probe() 2897 regmap_write(rt5670->regmap, RT5670_IL_CMD3, 0x0014); rt5670_i2c_probe() 2899 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, rt5670_i2c_probe() 2901 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, rt5670_i2c_probe() 2903 regmap_update_bits(rt5670->regmap, RT5670_DIG_MISC, 0x8, 0x8); rt5670_i2c_probe() 2906 if (rt5670->pdata.jd_mode) { rt5670_i2c_probe() 2907 regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK, rt5670_i2c_probe() 2909 rt5670->sysclk = 0; rt5670_i2c_probe() 2910 rt5670->sysclk_src = RT5670_SCLK_S_RCCLK; rt5670_i2c_probe() 2911 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, rt5670_i2c_probe() 2913 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG2, rt5670_i2c_probe() 2915 regmap_update_bits(rt5670->regmap, RT5670_IRQ_CTRL1, rt5670_i2c_probe() 2917 regmap_update_bits(rt5670->regmap, RT5670_JD_CTRL3, rt5670_i2c_probe() 2921 switch (rt5670->pdata.jd_mode) { rt5670_i2c_probe() 2923 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, rt5670_i2c_probe() 2928 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, rt5670_i2c_probe() 2933 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, rt5670_i2c_probe() 2942 if (rt5670->pdata.dmic_en) { rt5670_i2c_probe() 2943 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, rt5670_i2c_probe() 2947 switch (rt5670->pdata.dmic1_data_pin) { rt5670_i2c_probe() 2949 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, rt5670_i2c_probe() 2955 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, rt5670_i2c_probe() 2958 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, rt5670_i2c_probe() 2964 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, rt5670_i2c_probe() 2967 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, rt5670_i2c_probe() 2976 switch (rt5670->pdata.dmic2_data_pin) { rt5670_i2c_probe() 2978 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, rt5670_i2c_probe() 2984 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, rt5670_i2c_probe() 2987 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, rt5670_i2c_probe() 2996 switch (rt5670->pdata.dmic3_data_pin) { rt5670_i2c_probe() 2998 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL2, rt5670_i2c_probe() 3001 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, rt5670_i2c_probe() 3045 .name = "rt5670",
|