Lines Matching refs:rt5677

562 static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677,  in rt5677_dsp_mode_i2c_write_addr()  argument
565 struct snd_soc_component *component = rt5677->component; in rt5677_dsp_mode_i2c_write_addr()
568 mutex_lock(&rt5677->dsp_cmd_lock); in rt5677_dsp_mode_i2c_write_addr()
570 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB, in rt5677_dsp_mode_i2c_write_addr()
577 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB, in rt5677_dsp_mode_i2c_write_addr()
584 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, in rt5677_dsp_mode_i2c_write_addr()
591 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, in rt5677_dsp_mode_i2c_write_addr()
598 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE, in rt5677_dsp_mode_i2c_write_addr()
606 mutex_unlock(&rt5677->dsp_cmd_lock); in rt5677_dsp_mode_i2c_write_addr()
621 struct rt5677_priv *rt5677, unsigned int addr, unsigned int *value) in rt5677_dsp_mode_i2c_read_addr() argument
623 struct snd_soc_component *component = rt5677->component; in rt5677_dsp_mode_i2c_read_addr()
627 mutex_lock(&rt5677->dsp_cmd_lock); in rt5677_dsp_mode_i2c_read_addr()
629 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB, in rt5677_dsp_mode_i2c_read_addr()
636 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB, in rt5677_dsp_mode_i2c_read_addr()
643 ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE, in rt5677_dsp_mode_i2c_read_addr()
650 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, &msb); in rt5677_dsp_mode_i2c_read_addr()
651 regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, &lsb); in rt5677_dsp_mode_i2c_read_addr()
655 mutex_unlock(&rt5677->dsp_cmd_lock); in rt5677_dsp_mode_i2c_read_addr()
669 static int rt5677_dsp_mode_i2c_write(struct rt5677_priv *rt5677, in rt5677_dsp_mode_i2c_write() argument
672 return rt5677_dsp_mode_i2c_write_addr(rt5677, 0x18020000 + reg * 2, in rt5677_dsp_mode_i2c_write()
686 struct rt5677_priv *rt5677, unsigned int reg, unsigned int *value) in rt5677_dsp_mode_i2c_read() argument
688 int ret = rt5677_dsp_mode_i2c_read_addr(rt5677, 0x18020000 + reg * 2, in rt5677_dsp_mode_i2c_read()
696 static void rt5677_set_dsp_mode(struct rt5677_priv *rt5677, bool on) in rt5677_set_dsp_mode() argument
699 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, in rt5677_set_dsp_mode()
701 rt5677->is_dsp_mode = true; in rt5677_set_dsp_mode()
703 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, in rt5677_set_dsp_mode()
705 rt5677->is_dsp_mode = false; in rt5677_set_dsp_mode()
709 static unsigned int rt5677_set_vad_source(struct rt5677_priv *rt5677) in rt5677_set_vad_source() argument
712 snd_soc_component_get_dapm(rt5677->component); in rt5677_set_vad_source()
721 regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1, in rt5677_set_vad_source()
725 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, in rt5677_set_vad_source()
729 regmap_write(rt5677->regmap, RT5677_GLB_CLK2, in rt5677_set_vad_source()
733 regmap_write(rt5677->regmap, RT5677_VAD_CTRL2, 0x013f); in rt5677_set_vad_source()
735 regmap_write(rt5677->regmap, RT5677_VAD_CTRL3, 0x0ae5); in rt5677_set_vad_source()
740 regmap_update_bits(rt5677->regmap, RT5677_VAD_CTRL4, in rt5677_set_vad_source()
753 regmap_write(rt5677->regmap, RT5677_VAD_CTRL1, in rt5677_set_vad_source()
766 regmap_update_bits(rt5677->regmap, RT5677_PR_BASE + RT5677_BIAS_CUR4, in rt5677_set_vad_source()
772 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, in rt5677_set_vad_source()
779 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, in rt5677_set_vad_source()
789 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, in rt5677_set_vad_source()
802 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, in rt5677_set_vad_source()
813 static int rt5677_parse_and_load_dsp(struct rt5677_priv *rt5677, const u8 *buf, in rt5677_parse_and_load_dsp() argument
816 struct snd_soc_component *component = rt5677->component; in rt5677_parse_and_load_dsp()
857 static int rt5677_load_dsp_from_file(struct rt5677_priv *rt5677) in rt5677_load_dsp_from_file() argument
860 struct device *dev = rt5677->component->dev; in rt5677_load_dsp_from_file()
871 ret = rt5677_parse_and_load_dsp(rt5677, fwp->data, fwp->size); in rt5677_load_dsp_from_file()
878 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_set_dsp_vad() local
879 rt5677->dsp_vad_en_request = on; in rt5677_set_dsp_vad()
880 rt5677->dsp_vad_en = on; in rt5677_set_dsp_vad()
885 schedule_delayed_work(&rt5677->dsp_work, 0); in rt5677_set_dsp_vad()
891 struct rt5677_priv *rt5677 = in rt5677_dsp_work() local
894 bool enable = rt5677->dsp_vad_en; in rt5677_dsp_work()
898 dev_info(rt5677->component->dev, "DSP VAD: enable=%d, activity=%d\n", in rt5677_dsp_work()
914 rt5677_set_vad_source(rt5677); in rt5677_dsp_work()
915 rt5677_set_dsp_mode(rt5677, true); in rt5677_dsp_work()
919 regmap_read(rt5677->regmap, RT5677_PWR_DSP_ST, &val); in rt5677_dsp_work()
925 dev_err(rt5677->component->dev, "DSP Boot Timed Out!"); in rt5677_dsp_work()
930 rt5677_dsp_mode_i2c_write_addr(rt5677, RT5677_DSP_BOOT_VECTOR, in rt5677_dsp_work()
932 rt5677_dsp_mode_i2c_write_addr(rt5677, RT5677_DSP_BOOT_VECTOR, in rt5677_dsp_work()
934 rt5677_dsp_mode_i2c_write_addr(rt5677, RT5677_DSP_BOOT_VECTOR, in rt5677_dsp_work()
937 rt5677_load_dsp_from_file(rt5677); in rt5677_dsp_work()
940 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, in rt5677_dsp_work()
946 mutex_lock(&rt5677->irq_lock); in rt5677_dsp_work()
948 regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, in rt5677_dsp_work()
951 rt5677_set_dsp_mode(rt5677, false); in rt5677_dsp_work()
954 regmap_write(rt5677->regmap, RT5677_VAD_CTRL1, 0x2184); in rt5677_dsp_work()
957 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, in rt5677_dsp_work()
960 mutex_unlock(&rt5677->irq_lock); in rt5677_dsp_work()
984 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_dsp_vad_get() local
986 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en_request; in rt5677_dsp_vad_get()
1091 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in set_dmic_clk() local
1094 rate = rt5677->sysclk / rl6231_get_pre_div(rt5677->regmap, in set_dmic_clk()
1100 regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1, in set_dmic_clk()
1109 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in is_sys_clk_from_pll() local
1112 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val); in is_sys_clk_from_pll()
1124 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in is_using_asrc() local
1191 regmap_read(rt5677->regmap, reg, &val); in is_using_asrc()
1207 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in can_use_asrc() local
1209 if (rt5677->sysclk > rt5677->lrck[RT5677_AIF1] * 384) in can_use_asrc()
1232 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_sel_asrc_clk_src() local
1280 regmap_update_bits(rt5677->regmap, RT5677_ASRC_3, asrc3_mask, in rt5677_sel_asrc_clk_src()
1309 regmap_update_bits(rt5677->regmap, RT5677_ASRC_4, asrc4_mask, in rt5677_sel_asrc_clk_src()
1338 regmap_update_bits(rt5677->regmap, RT5677_ASRC_5, asrc5_mask, in rt5677_sel_asrc_clk_src()
1355 regmap_update_bits(rt5677->regmap, RT5677_ASRC_6, asrc6_mask, in rt5677_sel_asrc_clk_src()
1372 regmap_update_bits(rt5677->regmap, RT5677_ASRC_7, asrc7_mask, in rt5677_sel_asrc_clk_src()
1401 regmap_update_bits(rt5677->regmap, RT5677_ASRC_8, asrc8_mask, in rt5677_sel_asrc_clk_src()
1412 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_dmic_use_asrc() local
1417 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting); in rt5677_dmic_use_asrc()
1423 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting); in rt5677_dmic_use_asrc()
1429 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting); in rt5677_dmic_use_asrc()
1435 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting); in rt5677_dmic_use_asrc()
1441 regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting); in rt5677_dmic_use_asrc()
1447 regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting); in rt5677_dmic_use_asrc()
2573 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_bst1_event() local
2577 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, in rt5677_bst1_event()
2582 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, in rt5677_bst1_event()
2597 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_bst2_event() local
2601 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, in rt5677_bst2_event()
2606 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, in rt5677_bst2_event()
2621 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_set_pll1_event() local
2625 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2); in rt5677_set_pll1_event()
2629 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0); in rt5677_set_pll1_event()
2643 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_set_pll2_event() local
2647 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2); in rt5677_set_pll2_event()
2651 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0); in rt5677_set_pll2_event()
2665 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_set_micbias1_event() local
2669 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, in rt5677_set_micbias1_event()
2676 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, in rt5677_set_micbias1_event()
2692 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_if1_adc_tdm_event() local
2697 regmap_read(rt5677->regmap, RT5677_TDM1_CTRL2, &value); in rt5677_if1_adc_tdm_event()
2699 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, in rt5677_if1_adc_tdm_event()
2715 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_if2_adc_tdm_event() local
2720 regmap_read(rt5677->regmap, RT5677_TDM2_CTRL2, &value); in rt5677_if2_adc_tdm_event()
2722 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, in rt5677_if2_adc_tdm_event()
2738 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_vref_event() local
2743 !rt5677->is_vref_slow) { in rt5677_vref_event()
2745 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, in rt5677_vref_event()
2748 rt5677->is_vref_slow = true; in rt5677_vref_event()
4293 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_hw_params() local
4297 rt5677->lrck[dai->id] = params_rate(params); in rt5677_hw_params()
4298 pre_div = rl6231_get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]); in rt5677_hw_params()
4301 rt5677->sysclk, rt5677->lrck[dai->id]); in rt5677_hw_params()
4310 rt5677->bclk[dai->id] = rt5677->lrck[dai->id] * (32 << bclk_ms); in rt5677_hw_params()
4313 rt5677->bclk[dai->id], rt5677->lrck[dai->id]); in rt5677_hw_params()
4337 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP, in rt5677_hw_params()
4339 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, in rt5677_hw_params()
4345 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP, in rt5677_hw_params()
4347 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, in rt5677_hw_params()
4354 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP, in rt5677_hw_params()
4356 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, in rt5677_hw_params()
4363 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP, in rt5677_hw_params()
4365 regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, in rt5677_hw_params()
4378 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_set_dai_fmt() local
4383 rt5677->master[dai->id] = 1; in rt5677_set_dai_fmt()
4387 rt5677->master[dai->id] = 0; in rt5677_set_dai_fmt()
4421 regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP, in rt5677_set_dai_fmt()
4426 regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP, in rt5677_set_dai_fmt()
4431 regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP, in rt5677_set_dai_fmt()
4436 regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP, in rt5677_set_dai_fmt()
4452 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_set_dai_sysclk() local
4455 if (freq == rt5677->sysclk && clk_id == rt5677->sysclk_src) in rt5677_set_dai_sysclk()
4472 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, in rt5677_set_dai_sysclk()
4474 rt5677->sysclk = freq; in rt5677_set_dai_sysclk()
4475 rt5677->sysclk_src = clk_id; in rt5677_set_dai_sysclk()
4505 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_set_dai_pll() local
4509 if (source == rt5677->pll_src && freq_in == rt5677->pll_in && in rt5677_set_dai_pll()
4510 freq_out == rt5677->pll_out) in rt5677_set_dai_pll()
4516 rt5677->pll_in = 0; in rt5677_set_dai_pll()
4517 rt5677->pll_out = 0; in rt5677_set_dai_pll()
4518 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, in rt5677_set_dai_pll()
4525 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, in rt5677_set_dai_pll()
4534 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, in rt5677_set_dai_pll()
4538 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, in rt5677_set_dai_pll()
4542 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, in rt5677_set_dai_pll()
4546 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, in rt5677_set_dai_pll()
4568 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1, in rt5677_set_dai_pll()
4570 regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2, in rt5677_set_dai_pll()
4574 rt5677->pll_in = freq_in; in rt5677_set_dai_pll()
4575 rt5677->pll_out = freq_out; in rt5677_set_dai_pll()
4576 rt5677->pll_src = source; in rt5677_set_dai_pll()
4585 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_set_tdm_slot() local
4626 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 0x1f00, in rt5677_set_tdm_slot()
4628 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x8000, in rt5677_set_tdm_slot()
4632 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 0x1f00, in rt5677_set_tdm_slot()
4634 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x80, in rt5677_set_tdm_slot()
4647 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_set_bias_level() local
4658 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, in rt5677_set_bias_level()
4662 regmap_update_bits(rt5677->regmap, in rt5677_set_bias_level()
4665 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, in rt5677_set_bias_level()
4671 rt5677->is_vref_slow = false; in rt5677_set_bias_level()
4672 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, in rt5677_set_bias_level()
4674 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, in rt5677_set_bias_level()
4681 rt5677->dsp_vad_en_request) { in rt5677_set_bias_level()
4683 rt5677->dsp_vad_en = true; in rt5677_set_bias_level()
4685 schedule_delayed_work(&rt5677->dsp_work, in rt5677_set_bias_level()
4691 flush_delayed_work(&rt5677->dsp_work); in rt5677_set_bias_level()
4692 if (rt5677->is_dsp_mode) { in rt5677_set_bias_level()
4694 rt5677->dsp_vad_en = false; in rt5677_set_bias_level()
4695 schedule_delayed_work(&rt5677->dsp_work, 0); in rt5677_set_bias_level()
4696 flush_delayed_work(&rt5677->dsp_work); in rt5677_set_bias_level()
4699 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0); in rt5677_set_bias_level()
4700 regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000); in rt5677_set_bias_level()
4701 regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, in rt5677_set_bias_level()
4704 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, in rt5677_set_bias_level()
4706 regmap_update_bits(rt5677->regmap, in rt5677_set_bias_level()
4709 if (rt5677->dsp_vad_en) in rt5677_set_bias_level()
4723 struct rt5677_priv *rt5677 = gpiochip_get_data(chip); in rt5677_gpio_set() local
4727 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, in rt5677_gpio_set()
4732 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3, in rt5677_gpio_set()
4744 struct rt5677_priv *rt5677 = gpiochip_get_data(chip); in rt5677_gpio_direction_out() local
4748 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, in rt5677_gpio_direction_out()
4754 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3, in rt5677_gpio_direction_out()
4768 struct rt5677_priv *rt5677 = gpiochip_get_data(chip); in rt5677_gpio_get() local
4771 ret = regmap_read(rt5677->regmap, RT5677_GPIO_ST, &value); in rt5677_gpio_get()
4780 struct rt5677_priv *rt5677 = gpiochip_get_data(chip); in rt5677_gpio_direction_in() local
4784 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, in rt5677_gpio_direction_in()
4789 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3, in rt5677_gpio_direction_in()
4805 static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset, in rt5677_gpio_config() argument
4813 regmap_update_bits(rt5677->regmap, in rt5677_gpio_config()
4821 regmap_update_bits(rt5677->regmap, in rt5677_gpio_config()
4834 struct rt5677_priv *rt5677 = gpiochip_get_data(chip); in rt5677_to_irq() local
4837 if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) || in rt5677_to_irq()
4838 (rt5677->pdata.jd1_gpio == 2 && in rt5677_to_irq()
4840 (rt5677->pdata.jd1_gpio == 3 && in rt5677_to_irq()
4843 } else if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) || in rt5677_to_irq()
4844 (rt5677->pdata.jd2_gpio == 2 && in rt5677_to_irq()
4846 (rt5677->pdata.jd2_gpio == 3 && in rt5677_to_irq()
4849 } else if ((rt5677->pdata.jd3_gpio == 1 && in rt5677_to_irq()
4851 (rt5677->pdata.jd3_gpio == 2 && in rt5677_to_irq()
4853 (rt5677->pdata.jd3_gpio == 3 && in rt5677_to_irq()
4860 return irq_create_mapping(rt5677->domain, irq); in rt5677_to_irq()
4876 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); in rt5677_init_gpio() local
4879 rt5677->gpio_chip = rt5677_template_chip; in rt5677_init_gpio()
4880 rt5677->gpio_chip.ngpio = RT5677_GPIO_NUM; in rt5677_init_gpio()
4881 rt5677->gpio_chip.parent = &i2c->dev; in rt5677_init_gpio()
4882 rt5677->gpio_chip.base = -1; in rt5677_init_gpio()
4884 ret = gpiochip_add_data(&rt5677->gpio_chip, rt5677); in rt5677_init_gpio()
4891 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); in rt5677_free_gpio() local
4893 gpiochip_remove(&rt5677->gpio_chip); in rt5677_free_gpio()
4896 static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset, in rt5677_gpio_config() argument
4913 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_probe() local
4916 rt5677->component = component; in rt5677_probe()
4918 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) { in rt5677_probe()
4930 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, in rt5677_probe()
4932 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, in rt5677_probe()
4936 rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]); in rt5677_probe()
4938 mutex_init(&rt5677->dsp_cmd_lock); in rt5677_probe()
4939 mutex_init(&rt5677->dsp_pri_lock); in rt5677_probe()
4946 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_remove() local
4948 cancel_delayed_work_sync(&rt5677->dsp_work); in rt5677_remove()
4950 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); in rt5677_remove()
4951 gpiod_set_value_cansleep(rt5677->pow_ldo2, 0); in rt5677_remove()
4952 gpiod_set_value_cansleep(rt5677->reset_pin, 1); in rt5677_remove()
4958 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_suspend() local
4960 if (rt5677->irq) { in rt5677_suspend()
4961 cancel_delayed_work_sync(&rt5677->resume_irq_check); in rt5677_suspend()
4962 disable_irq(rt5677->irq); in rt5677_suspend()
4965 if (!rt5677->dsp_vad_en) { in rt5677_suspend()
4966 regcache_cache_only(rt5677->regmap, true); in rt5677_suspend()
4967 regcache_mark_dirty(rt5677->regmap); in rt5677_suspend()
4969 gpiod_set_value_cansleep(rt5677->pow_ldo2, 0); in rt5677_suspend()
4970 gpiod_set_value_cansleep(rt5677->reset_pin, 1); in rt5677_suspend()
4978 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); in rt5677_resume() local
4980 if (!rt5677->dsp_vad_en) { in rt5677_resume()
4981 rt5677->pll_src = 0; in rt5677_resume()
4982 rt5677->pll_in = 0; in rt5677_resume()
4983 rt5677->pll_out = 0; in rt5677_resume()
4984 gpiod_set_value_cansleep(rt5677->pow_ldo2, 1); in rt5677_resume()
4985 gpiod_set_value_cansleep(rt5677->reset_pin, 0); in rt5677_resume()
4986 if (rt5677->pow_ldo2 || rt5677->reset_pin) in rt5677_resume()
4989 regcache_cache_only(rt5677->regmap, false); in rt5677_resume()
4990 regcache_sync(rt5677->regmap); in rt5677_resume()
4993 if (rt5677->irq) { in rt5677_resume()
4994 enable_irq(rt5677->irq); in rt5677_resume()
4995 schedule_delayed_work(&rt5677->resume_irq_check, 0); in rt5677_resume()
5008 struct rt5677_priv *rt5677 = i2c_get_clientdata(client); in rt5677_read() local
5010 if (rt5677->is_dsp_mode) { in rt5677_read()
5012 mutex_lock(&rt5677->dsp_pri_lock); in rt5677_read()
5013 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX, in rt5677_read()
5015 rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val); in rt5677_read()
5016 mutex_unlock(&rt5677->dsp_pri_lock); in rt5677_read()
5018 rt5677_dsp_mode_i2c_read(rt5677, reg, val); in rt5677_read()
5021 regmap_read(rt5677->regmap_physical, reg, val); in rt5677_read()
5030 struct rt5677_priv *rt5677 = i2c_get_clientdata(client); in rt5677_write() local
5032 if (rt5677->is_dsp_mode) { in rt5677_write()
5034 mutex_lock(&rt5677->dsp_pri_lock); in rt5677_write()
5035 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX, in rt5677_write()
5037 rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA, in rt5677_write()
5039 mutex_unlock(&rt5677->dsp_pri_lock); in rt5677_write()
5041 rt5677_dsp_mode_i2c_write(rt5677, reg, val); in rt5677_write()
5044 regmap_write(rt5677->regmap_physical, reg, val); in rt5677_write()
5239 static void rt5677_read_device_properties(struct rt5677_priv *rt5677, in rt5677_read_device_properties() argument
5244 rt5677->pdata.in1_diff = in rt5677_read_device_properties()
5248 rt5677->pdata.in2_diff = in rt5677_read_device_properties()
5252 rt5677->pdata.lout1_diff = in rt5677_read_device_properties()
5256 rt5677->pdata.lout2_diff = in rt5677_read_device_properties()
5260 rt5677->pdata.lout3_diff = in rt5677_read_device_properties()
5265 rt5677->pdata.gpio_config, in rt5677_read_device_properties()
5270 rt5677->pdata.dmic2_clk_pin = val; in rt5677_read_device_properties()
5274 rt5677->pdata.jd1_gpio = val; in rt5677_read_device_properties()
5278 rt5677->pdata.jd2_gpio = val; in rt5677_read_device_properties()
5282 rt5677->pdata.jd3_gpio = val; in rt5677_read_device_properties()
5309 static bool rt5677_check_hotword(struct rt5677_priv *rt5677) in rt5677_check_hotword() argument
5313 if (!rt5677->is_dsp_mode) in rt5677_check_hotword()
5316 if (regmap_read(rt5677->regmap, RT5677_GPIO_CTRL1, &reg_gpio)) in rt5677_check_hotword()
5324 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, in rt5677_check_hotword()
5333 struct rt5677_priv *rt5677 = data; in rt5677_irq() local
5337 mutex_lock(&rt5677->irq_lock); in rt5677_irq()
5355 ret = regmap_read(rt5677->regmap, RT5677_IRQ_CTRL1, &reg_irq); in rt5677_irq()
5357 dev_err(rt5677->dev, "failed reading IRQ status: %d\n", in rt5677_irq()
5366 virq = irq_find_mapping(rt5677->domain, i); in rt5677_irq()
5382 if (!irq_fired && !rt5677_check_hotword(rt5677)) in rt5677_irq()
5385 ret = regmap_write(rt5677->regmap, RT5677_IRQ_CTRL1, reg_irq); in rt5677_irq()
5387 dev_err(rt5677->dev, "failed updating IRQ status: %d\n", in rt5677_irq()
5394 mutex_unlock(&rt5677->irq_lock); in rt5677_irq()
5404 struct rt5677_priv *rt5677 = in rt5677_resume_irq_check() local
5412 rt5677_irq(0, rt5677); in rt5677_resume_irq_check()
5423 mutex_lock(&rt5677->irq_lock); in rt5677_resume_irq_check()
5425 if (rt5677->irq_en & rt5677_irq_descs[i].enable_mask) { in rt5677_resume_irq_check()
5426 virq = irq_find_mapping(rt5677->domain, i); in rt5677_resume_irq_check()
5431 mutex_unlock(&rt5677->irq_lock); in rt5677_resume_irq_check()
5436 struct rt5677_priv *rt5677 = irq_data_get_irq_chip_data(data); in rt5677_irq_bus_lock() local
5438 mutex_lock(&rt5677->irq_lock); in rt5677_irq_bus_lock()
5443 struct rt5677_priv *rt5677 = irq_data_get_irq_chip_data(data); in rt5677_irq_bus_sync_unlock() local
5446 regmap_update_bits(rt5677->regmap, RT5677_IRQ_CTRL1, in rt5677_irq_bus_sync_unlock()
5448 RT5677_EN_IRQ_GPIO_JD3, rt5677->irq_en); in rt5677_irq_bus_sync_unlock()
5449 mutex_unlock(&rt5677->irq_lock); in rt5677_irq_bus_sync_unlock()
5454 struct rt5677_priv *rt5677 = irq_data_get_irq_chip_data(data); in rt5677_irq_enable() local
5456 rt5677->irq_en |= rt5677_irq_descs[data->hwirq].enable_mask; in rt5677_irq_enable()
5461 struct rt5677_priv *rt5677 = irq_data_get_irq_chip_data(data); in rt5677_irq_disable() local
5463 rt5677->irq_en &= ~rt5677_irq_descs[data->hwirq].enable_mask; in rt5677_irq_disable()
5477 struct rt5677_priv *rt5677 = h->host_data; in rt5677_irq_map() local
5479 irq_set_chip_data(virq, rt5677); in rt5677_irq_map()
5495 struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); in rt5677_init_irq() local
5498 if (!rt5677->pdata.jd1_gpio && in rt5677_init_irq()
5499 !rt5677->pdata.jd2_gpio && in rt5677_init_irq()
5500 !rt5677->pdata.jd3_gpio) in rt5677_init_irq()
5508 mutex_init(&rt5677->irq_lock); in rt5677_init_irq()
5509 INIT_DELAYED_WORK(&rt5677->resume_irq_check, rt5677_resume_irq_check); in rt5677_init_irq()
5516 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, in rt5677_init_irq()
5520 regmap_update_bits(rt5677->regmap, RT5677_GEN_CTRL1, 0xff, 0xff); in rt5677_init_irq()
5523 if (rt5677->pdata.jd1_gpio) { in rt5677_init_irq()
5525 jd_val |= rt5677->pdata.jd1_gpio << RT5677_SEL_GPIO_JD1_SFT; in rt5677_init_irq()
5527 if (rt5677->pdata.jd2_gpio) { in rt5677_init_irq()
5529 jd_val |= rt5677->pdata.jd2_gpio << RT5677_SEL_GPIO_JD2_SFT; in rt5677_init_irq()
5531 if (rt5677->pdata.jd3_gpio) { in rt5677_init_irq()
5533 jd_val |= rt5677->pdata.jd3_gpio << RT5677_SEL_GPIO_JD3_SFT; in rt5677_init_irq()
5535 regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1, jd_mask, jd_val); in rt5677_init_irq()
5538 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, in rt5677_init_irq()
5542 rt5677->domain = irq_domain_add_linear(i2c->dev.of_node, in rt5677_init_irq()
5543 RT5677_IRQ_NUM, &rt5677_domain_ops, rt5677); in rt5677_init_irq()
5544 if (!rt5677->domain) { in rt5677_init_irq()
5551 "rt5677", rt5677); in rt5677_init_irq()
5555 rt5677->irq = i2c->irq; in rt5677_init_irq()
5562 struct rt5677_priv *rt5677; in rt5677_i2c_probe() local
5566 rt5677 = devm_kzalloc(&i2c->dev, sizeof(struct rt5677_priv), in rt5677_i2c_probe()
5568 if (rt5677 == NULL) in rt5677_i2c_probe()
5571 rt5677->dev = &i2c->dev; in rt5677_i2c_probe()
5572 rt5677->set_dsp_vad = rt5677_set_dsp_vad; in rt5677_i2c_probe()
5573 INIT_DELAYED_WORK(&rt5677->dsp_work, rt5677_dsp_work); in rt5677_i2c_probe()
5574 i2c_set_clientdata(i2c, rt5677); in rt5677_i2c_probe()
5581 rt5677->type = (enum rt5677_type)match_id->data; in rt5677_i2c_probe()
5587 rt5677->type = (enum rt5677_type)acpi_id->driver_data; in rt5677_i2c_probe()
5592 rt5677_read_device_properties(rt5677, &i2c->dev); in rt5677_i2c_probe()
5598 rt5677->pow_ldo2 = devm_gpiod_get_optional(&i2c->dev, in rt5677_i2c_probe()
5600 if (IS_ERR(rt5677->pow_ldo2)) { in rt5677_i2c_probe()
5601 ret = PTR_ERR(rt5677->pow_ldo2); in rt5677_i2c_probe()
5605 rt5677->reset_pin = devm_gpiod_get_optional(&i2c->dev, in rt5677_i2c_probe()
5607 if (IS_ERR(rt5677->reset_pin)) { in rt5677_i2c_probe()
5608 ret = PTR_ERR(rt5677->reset_pin); in rt5677_i2c_probe()
5613 if (rt5677->pow_ldo2 || rt5677->reset_pin) { in rt5677_i2c_probe()
5621 rt5677->regmap_physical = devm_regmap_init_i2c(i2c, in rt5677_i2c_probe()
5623 if (IS_ERR(rt5677->regmap_physical)) { in rt5677_i2c_probe()
5624 ret = PTR_ERR(rt5677->regmap_physical); in rt5677_i2c_probe()
5630 rt5677->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt5677_regmap); in rt5677_i2c_probe()
5631 if (IS_ERR(rt5677->regmap)) { in rt5677_i2c_probe()
5632 ret = PTR_ERR(rt5677->regmap); in rt5677_i2c_probe()
5638 regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val); in rt5677_i2c_probe()
5645 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); in rt5677_i2c_probe()
5647 ret = regmap_register_patch(rt5677->regmap, init_list, in rt5677_i2c_probe()
5652 if (rt5677->pdata.in1_diff) in rt5677_i2c_probe()
5653 regmap_update_bits(rt5677->regmap, RT5677_IN1, in rt5677_i2c_probe()
5656 if (rt5677->pdata.in2_diff) in rt5677_i2c_probe()
5657 regmap_update_bits(rt5677->regmap, RT5677_IN1, in rt5677_i2c_probe()
5660 if (rt5677->pdata.lout1_diff) in rt5677_i2c_probe()
5661 regmap_update_bits(rt5677->regmap, RT5677_LOUT1, in rt5677_i2c_probe()
5664 if (rt5677->pdata.lout2_diff) in rt5677_i2c_probe()
5665 regmap_update_bits(rt5677->regmap, RT5677_LOUT1, in rt5677_i2c_probe()
5668 if (rt5677->pdata.lout3_diff) in rt5677_i2c_probe()
5669 regmap_update_bits(rt5677->regmap, RT5677_LOUT1, in rt5677_i2c_probe()
5672 if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) { in rt5677_i2c_probe()
5673 regmap_update_bits(rt5677->regmap, RT5677_GEN_CTRL2, in rt5677_i2c_probe()
5676 regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, in rt5677_i2c_probe()
5681 if (rt5677->pdata.micbias1_vdd_3v3) in rt5677_i2c_probe()
5682 regmap_update_bits(rt5677->regmap, RT5677_MICBIAS, in rt5677_i2c_probe()