Lines Matching +full:codec +full:- +full:aif2 +full:- +full:bclk

1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5645.c -- RT5645 ALSA SoC audio codec driver
26 #include <sound/soc-dapm.h>
41 static unsigned int quirk = -1;
438 /* Some (package) variants have the headset-mic pin not-connected */
462 int bclk[RT5645_AIFS];
670 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
671 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
672 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
673 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
687 /* {-6, -4.5, -3, -1.5, 0, 0.82, 1.58, 2.28} dB */
689 0, 4, TLV_DB_SCALE_ITEM(-600, 150, 0),
698 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
699 uinfo->count = RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s);
710 (struct rt5645_eq_param_s_be16 *)ucontrol->value.bytes.data;
714 eq_param[i].reg = cpu_to_be16(rt5645->eq_param[i].reg);
715 eq_param[i].val = cpu_to_be16(rt5645->eq_param[i].val);
736 (struct rt5645_eq_param_s_be16 *)ucontrol->value.bytes.data;
740 rt5645->eq_param[i].reg = be16_to_cpu(eq_param[i].reg);
741 rt5645->eq_param[i].val = be16_to_cpu(eq_param[i].val);
745 for (i = RT5645_HWEQ_NUM - 1; i >= 0; i--) {
746 if (rt5645->eq_param[i].reg == 0)
748 else if (rt5645->eq_param[i].reg != RT5645_EQ_CTRL2)
755 if (!rt5645_validate_hweq(rt5645->eq_param[i].reg) &&
756 rt5645->eq_param[i].reg != 0)
758 else if (rt5645->eq_param[i].reg == 0)
779 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS,
784 mod_delayed_work(system_power_efficient_wq, &rt5645->rcclock_work,
870 * set_dmic_clk - Set parameter of dmic.
880 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
884 rate = rt5645->sysclk / rl6231_get_pre_div(rt5645->regmap,
888 dev_err(component->dev, "Failed to set DMIC clock\n");
898 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
912 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
915 switch (source->shift) {
963 if (rt5645_validate_hweq(rt5645->eq_param[i].reg))
964 regmap_write(rt5645->regmap, rt5645->eq_param[i].reg,
965 rt5645->eq_param[i].val);
974 * rt5645_sel_asrc_clk_src - select ASRC clock source for a set of filters
983 * for codec. This function provides an API to select the clock source for a
984 * set of filters specified by the mask. And the codec driver will turn on ASRC
1003 return -EINVAL;
1280 /*DAC1 L/R source*/ /* MX-29 [9:8] [11:10] */
1299 /*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */
1323 /* MX-27 [12] */
1335 /* MX-27 [11] */
1347 /* MX-27 [8] */
1360 /* MX-28 [12] */
1371 /* MX-28 [11] */
1383 /* MX-28 [8] */
1394 /* MX-28 [1:0] */
1401 /* MX-28 [4] */
1412 /* MX-28 [3] */
1424 /* MX-77 [9:8] */
1437 /* MX-78 [4:0] */
1475 /* MX-78 [15:14][13:12][11:10] */
1498 /* MX-77 [7:6][5:4][3:2] */
1517 /* MX-79 [14:12][10:8][6:4][2:0] */
1546 /* MX-7a [14:12][10:8][6:4][2:0] */
1571 /* MX-2d [3] [2] */
1590 /* MX-2d [1] [0] */
1609 /* MX-2F [13:12] */
1621 /* MX-31 [15] [13] [11] [9] */
1640 /* MX-9D [9:8] */
1684 if (rt5645->codec_type == CODEC_TYPE_RT5650) {
1689 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1693 regmap_read(rt5645->regmap, RT5645_PR_BASE +
1700 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1703 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1715 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1737 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1739 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1745 hp_amp_power_count--;
1747 if (rt5645->codec_type == CODEC_TYPE_RT5650) {
1748 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1751 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1781 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1788 if (rt5645->codec_type == CODEC_TYPE_RT5645) {
1795 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1815 if (rt5645->codec_type == CODEC_TYPE_RT5645) {
1822 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1847 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1880 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1910 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1933 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1958 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
2153 SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
2154 SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
2754 struct snd_soc_component *component = dai->component;
2759 rt5645->lrck[dai->id] = params_rate(params);
2760 pre_div = rl6231_get_clk_info(rt5645->sysclk, rt5645->lrck[dai->id]);
2762 dev_err(component->dev, "Unsupported clock setting\n");
2763 return -EINVAL;
2767 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size);
2768 return -EINVAL;
2771 switch (rt5645->codec_type) {
2781 rt5645->bclk[dai->id] = rt5645->lrck[dai->id] * (32 << bclk_ms);
2783 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n",
2784 rt5645->bclk[dai->id], rt5645->lrck[dai->id]);
2785 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n",
2786 bclk_ms, pre_div, dai->id);
2801 return -EINVAL;
2804 switch (dai->id) {
2821 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id);
2822 return -EINVAL;
2830 struct snd_soc_component *component = dai->component;
2834 switch (rt5645->codec_type) {
2845 rt5645->master[dai->id] = 1;
2849 rt5645->master[dai->id] = 0;
2852 return -EINVAL;
2862 return -EINVAL;
2878 return -EINVAL;
2880 switch (dai->id) {
2892 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id);
2893 return -EINVAL;
2901 struct snd_soc_component *component = dai->component;
2905 if (freq == rt5645->sysclk && clk_id == rt5645->sysclk_src)
2919 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id);
2920 return -EINVAL;
2924 rt5645->sysclk = freq;
2925 rt5645->sysclk_src = clk_id;
2927 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id);
2935 struct snd_soc_component *component = dai->component;
2940 if (source == rt5645->pll_src && freq_in == rt5645->pll_in &&
2941 freq_out == rt5645->pll_out)
2945 dev_dbg(component->dev, "PLL disabled\n");
2947 rt5645->pll_in = 0;
2948 rt5645->pll_out = 0;
2961 switch (dai->id) {
2971 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id);
2972 return -EINVAL;
2976 dev_err(component->dev, "Unknown PLL source %d\n", source);
2977 return -EINVAL;
2982 dev_err(component->dev, "Unsupported input clock %d\n", freq_in);
2986 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n",
2996 rt5645->pll_in = freq_in;
2997 rt5645->pll_out = freq_out;
2998 rt5645->pll_src = source;
3006 struct snd_soc_component *component = dai->component;
3011 switch (rt5645->codec_type) {
3029 if (rt5645->codec_type == CODEC_TYPE_RT5645)
3104 if (rt5645->en_button_func)
3106 &rt5645->jack_detect_work,
3113 if (!rt5645->en_button_func)
3176 regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0206);
3182 if (!snd_soc_card_is_instantiated(dapm->card)) {
3185 regmap_update_bits(rt5645->regmap, RT5645_PWR_ANLG1,
3188 regmap_update_bits(rt5645->regmap, RT5645_PWR_MIXER,
3190 regmap_update_bits(rt5645->regmap, RT5645_PWR_VOL,
3194 regmap_write(rt5645->regmap, RT5645_JD_CTRL3, 0x00f0);
3195 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2,
3197 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1,
3200 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2,
3203 if (rt5645->gpiod_cbj_sleeve)
3204 gpiod_set_value(rt5645->gpiod_cbj_sleeve, 1);
3207 regmap_read(rt5645->regmap, RT5645_IN1_CTRL3, &val);
3209 dev_dbg(component->dev, "val = %d\n", val);
3211 if ((val == 1 || val == 2) && !rt5645->pdata.no_headset_mic) {
3212 rt5645->jack_type = SND_JACK_HEADSET;
3213 if (rt5645->en_button_func) {
3217 if (rt5645->en_button_func)
3221 rt5645->jack_type = SND_JACK_HEADPHONE;
3222 if (rt5645->gpiod_cbj_sleeve)
3223 gpiod_set_value(rt5645->gpiod_cbj_sleeve, 0);
3225 if (rt5645->pdata.level_trigger_irq)
3226 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
3229 regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0e06);
3231 rt5645->jack_type = 0;
3233 regmap_update_bits(rt5645->regmap, RT5645_HP_VOL,
3236 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2,
3238 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1,
3241 if (rt5645->en_button_func)
3244 if (rt5645->pdata.jd_mode == 0)
3248 if (rt5645->pdata.level_trigger_irq)
3249 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
3252 if (rt5645->gpiod_cbj_sleeve)
3253 gpiod_set_value(rt5645->gpiod_cbj_sleeve, 0);
3256 return rt5645->jack_type;
3279 rt5645->hp_jack = hp_jack;
3280 rt5645->mic_jack = mic_jack;
3281 rt5645->btn_jack = btn_jack;
3282 if (rt5645->btn_jack && rt5645->codec_type == CODEC_TYPE_RT5650) {
3283 rt5645->en_button_func = true;
3284 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
3286 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL1,
3288 regmap_update_bits(rt5645->regmap, RT5645_DEPOP_M1,
3323 if (!rt5645->component)
3326 mutex_lock(&rt5645->jd_mutex);
3328 switch (rt5645->pdata.jd_mode) {
3330 if (rt5645->gpiod_hp_det) {
3331 gpio_state = gpiod_get_value(rt5645->gpiod_hp_det);
3332 if (rt5645->pdata.inv_hp_pol)
3334 dev_dbg(rt5645->component->dev, "gpio_state = %d\n",
3336 report = rt5645_jack_detect(rt5645->component, gpio_state);
3338 snd_soc_jack_report(rt5645->hp_jack,
3340 snd_soc_jack_report(rt5645->mic_jack,
3342 mutex_unlock(&rt5645->jd_mutex);
3345 val = snd_soc_component_read(rt5645->component, RT5645_A_JD_CTRL1) & 0x0020;
3348 val = snd_soc_component_read(rt5645->component, RT5645_INT_IRQ_ST) & 0x1000;
3353 if (!val && (rt5645->jack_type == 0)) { /* jack in */
3354 report = rt5645_jack_detect(rt5645->component, 1);
3355 } else if (!val && rt5645->jack_type == SND_JACK_HEADSET) {
3358 if (snd_soc_component_read(rt5645->component, RT5645_INT_IRQ_ST) & 0x4) {
3361 btn_type = rt5645_button_detect(rt5645->component);
3391 dev_err(rt5645->component->dev,
3398 report = rt5645->jack_type;
3400 mod_timer(&rt5645->btn_check_timer,
3406 snd_soc_component_update_bits(rt5645->component,
3408 rt5645_jack_detect(rt5645->component, 0);
3411 mutex_unlock(&rt5645->jd_mutex);
3413 snd_soc_jack_report(rt5645->hp_jack, report, SND_JACK_HEADPHONE);
3414 snd_soc_jack_report(rt5645->mic_jack, report, SND_JACK_MICROPHONE);
3415 if (rt5645->en_button_func)
3416 snd_soc_jack_report(rt5645->btn_jack,
3426 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS,
3435 &rt5645->jack_detect_work, msecs_to_jiffies(250));
3445 &rt5645->jack_detect_work, msecs_to_jiffies(5));
3453 rt5645->component = component;
3455 switch (rt5645->codec_type) {
3463 if (rt5645->v_id < 3) {
3482 if (rt5645->pdata.jd_mode) {
3488 if (rt5645->pdata.long_name)
3489 component->card->long_name = rt5645->pdata.long_name;
3491 rt5645->eq_param = devm_kcalloc(component->dev,
3495 if (!rt5645->eq_param)
3496 return -ENOMEM;
3511 regcache_cache_only(rt5645->regmap, true);
3512 regcache_mark_dirty(rt5645->regmap);
3521 regcache_cache_only(rt5645->regmap, false);
3522 regcache_sync(rt5645->regmap);
3545 .name = "rt5645-aif1",
3564 .name = "rt5645-aif2",
3567 .stream_name = "AIF2 Playback",
3574 .stream_name = "AIF2 Capture",
3690 .long_name = "gpd-win-pocket-rt5645",
3747 { "hp-detect-gpios", &ef20_hp_detect, 1 },
3829 .ident = "MINIX Z83-4",
3832 DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
3849 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "MIIX 310-10ICR"),
3858 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
3871 * DF-BI-7-S70CR100-*
3872 * DF-BI-7-S70CR110-*
3873 * DF-BI-7-S70CR200-*
3874 * LP-BS-7-S70CR700-*
3905 .ident = "Acer Switch V 10 (SW5-017)",
3908 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SW5-017"),
3927 if (device_property_present(dev, "realtek,in2-differential") ||
3928 device_property_present(dev, "realtek,dmic1-data-pin") ||
3929 device_property_present(dev, "realtek,dmic2-data-pin") ||
3930 device_property_present(dev, "realtek,jd-mode"))
3938 pdata->in2_diff = device_property_read_bool(dev, "realtek,in2-differential");
3939 device_property_read_u32(dev, "realtek,dmic1-data-pin", &pdata->dmic1_data_pin);
3940 device_property_read_u32(dev, "realtek,dmic2-data-pin", &pdata->dmic2_data_pin);
3941 device_property_read_u32(dev, "realtek,jd-mode", &pdata->jd_mode);
3950 dev_info(codec_dev, "Detected %s platform\n", dmi_data->ident);
3951 *pdata = *((struct rt5645_platform_data *)dmi_data->driver_data);
3958 if (quirk != -1) {
3959 pdata->in2_diff = QUIRK_IN2_DIFF(quirk);
3960 pdata->level_trigger_irq = QUIRK_LEVEL_IRQ(quirk);
3961 pdata->inv_jd1_1 = QUIRK_INV_JD1_1(quirk);
3962 pdata->inv_hp_pol = QUIRK_INV_HP_POL(quirk);
3963 pdata->jd_mode = QUIRK_JD_MODE(quirk);
3964 pdata->dmic1_data_pin = QUIRK_DMIC1_DATA_PIN(quirk);
3965 pdata->dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk);
3990 snprintf(buf, sizeof(buf), "cfg-spk:%d cfg-mic:%s", spk, mic);
4003 rt5645 = devm_kzalloc(&i2c->dev, sizeof(struct rt5645_priv),
4006 return -ENOMEM;
4008 rt5645->i2c = i2c;
4010 rt5645_get_pdata(&i2c->dev, &rt5645->pdata);
4012 if (has_acpi_companion(&i2c->dev)) {
4014 if (devm_acpi_dev_add_driver_gpios(&i2c->dev, cht_rt5645_gpios))
4015 dev_dbg(&i2c->dev, "Failed to add driver gpios\n");
4018 /* The ALC3270 package has the headset-mic pin not-connected */
4019 if (acpi_dev_hid_uid_match(ACPI_COMPANION(&i2c->dev), "10EC3270", NULL))
4020 rt5645->pdata.no_headset_mic = true;
4023 rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect",
4026 if (IS_ERR(rt5645->gpiod_hp_det)) {
4027 dev_info(&i2c->dev, "failed to initialize gpiod\n");
4028 ret = PTR_ERR(rt5645->gpiod_hp_det);
4031 * errors, including -EPROBE_DEFER
4033 if (ret != -ENOENT)
4037 rt5645->gpiod_cbj_sleeve = devm_gpiod_get_optional(&i2c->dev, "cbj-sleeve",
4040 if (IS_ERR(rt5645->gpiod_cbj_sleeve)) {
4041 ret = PTR_ERR(rt5645->gpiod_cbj_sleeve);
4042 dev_info(&i2c->dev, "failed to initialize gpiod, ret=%d\n", ret);
4043 if (ret != -ENOENT)
4047 for (i = 0; i < ARRAY_SIZE(rt5645->supplies); i++)
4048 rt5645->supplies[i].supply = rt5645_supply_names[i];
4050 ret = devm_regulator_bulk_get(&i2c->dev,
4051 ARRAY_SIZE(rt5645->supplies),
4052 rt5645->supplies);
4054 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
4058 ret = regulator_bulk_enable(ARRAY_SIZE(rt5645->supplies),
4059 rt5645->supplies);
4061 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
4068 dev_err(&i2c->dev, "Failed to allocate temp register map: %d\n",
4080 dev_err(&i2c->dev, "Failed to read: 0x%02X\n, ret = %d", RT5645_VENDOR_ID2, ret);
4086 rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5645_regmap);
4087 rt5645->codec_type = CODEC_TYPE_RT5645;
4090 rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5650_regmap);
4091 rt5645->codec_type = CODEC_TYPE_RT5650;
4094 dev_err(&i2c->dev,
4097 ret = -ENODEV;
4101 if (IS_ERR(rt5645->regmap)) {
4102 ret = PTR_ERR(rt5645->regmap);
4103 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
4108 regmap_write(rt5645->regmap, RT5645_RESET, 0);
4111 rt5645->v_id = val & 0xff;
4113 regmap_write(rt5645->regmap, RT5645_AD_DA_MIXER, 0x8080);
4115 ret = regmap_multi_reg_write(rt5645->regmap, init_list,
4118 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
4120 if (rt5645->codec_type == CODEC_TYPE_RT5650) {
4121 ret = regmap_multi_reg_write(rt5645->regmap, rt5650_init_list,
4124 dev_warn(&i2c->dev, "Apply rt5650 patch failed: %d\n",
4128 regmap_update_bits(rt5645->regmap, RT5645_CLSD_OUT_CTRL, 0xc0, 0xc0);
4130 if (rt5645->pdata.in2_diff)
4131 regmap_update_bits(rt5645->regmap, RT5645_IN2_CTRL,
4134 if (rt5645->pdata.dmic1_data_pin || rt5645->pdata.dmic2_data_pin) {
4135 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
4138 switch (rt5645->pdata.dmic1_data_pin) {
4140 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
4145 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
4147 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
4149 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
4154 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
4156 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
4165 switch (rt5645->pdata.dmic2_data_pin) {
4167 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
4172 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
4174 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
4179 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
4181 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
4187 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
4189 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
4198 if (rt5645->pdata.jd_mode) {
4199 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3,
4202 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS,
4204 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
4206 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3,
4208 regmap_update_bits(rt5645->regmap, RT5645_HPO_MIXER,
4210 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS,
4212 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
4214 switch (rt5645->pdata.jd_mode) {
4216 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1,
4221 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1,
4227 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1,
4234 if (rt5645->pdata.inv_jd1_1) {
4235 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
4240 regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1,
4243 if (rt5645->pdata.level_trigger_irq) {
4244 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
4247 timer_setup(&rt5645->btn_check_timer, rt5645_btn_check_callback, 0);
4249 mutex_init(&rt5645->jd_mutex);
4250 INIT_DELAYED_WORK(&rt5645->jack_detect_work, rt5645_jack_detect_work);
4251 INIT_DELAYED_WORK(&rt5645->rcclock_work, rt5645_rcclock_work);
4253 if (rt5645->i2c->irq) {
4254 ret = request_threaded_irq(rt5645->i2c->irq, NULL, rt5645_irq,
4258 dev_err(&i2c->dev, "Failed to request IRQ: %d\n", ret);
4263 ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5645,
4271 if (rt5645->i2c->irq)
4272 free_irq(rt5645->i2c->irq, rt5645);
4274 regulator_bulk_disable(ARRAY_SIZE(rt5645->supplies), rt5645->supplies);
4282 if (i2c->irq)
4283 free_irq(i2c->irq, rt5645);
4289 del_timer_sync(&rt5645->btn_check_timer);
4291 cancel_delayed_work_sync(&rt5645->jack_detect_work);
4292 cancel_delayed_work_sync(&rt5645->rcclock_work);
4294 if (rt5645->gpiod_cbj_sleeve)
4295 gpiod_set_value(rt5645->gpiod_cbj_sleeve, 0);
4297 regulator_bulk_disable(ARRAY_SIZE(rt5645->supplies), rt5645->supplies);
4304 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3,
4306 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2, RT5645_CBJ_MN_JD,
4308 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, RT5645_CBJ_BST1_EN,
4311 regmap_write(rt5645->regmap, RT5645_RESET, 0);
4313 if (rt5645->gpiod_cbj_sleeve)
4314 gpiod_set_value(rt5645->gpiod_cbj_sleeve, 0);
4321 del_timer_sync(&rt5645->btn_check_timer);
4322 cancel_delayed_work_sync(&rt5645->jack_detect_work);
4323 cancel_delayed_work_sync(&rt5645->rcclock_work);
4325 regcache_cache_only(rt5645->regmap, true);
4326 regcache_mark_dirty(rt5645->regmap);
4334 regcache_cache_only(rt5645->regmap, false);
4335 regcache_sync(rt5645->regmap);
4337 if (rt5645->hp_jack) {
4338 rt5645->jack_type = 0;
4339 rt5645_jack_detect_work(&rt5645->jack_detect_work.work);