.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
| 2 | +// Copyright (c) 2016, The Linux Foundation. All rights reserved. |
---|
| 3 | + |
---|
1 | 4 | #include <linux/module.h> |
---|
2 | 5 | #include <linux/err.h> |
---|
3 | 6 | #include <linux/kernel.h> |
---|
.. | .. |
---|
225 | 228 | #define CDC_A_RX_EAR_CTL (0xf19E) |
---|
226 | 229 | #define RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK BIT(0) |
---|
227 | 230 | #define RX_EAR_CTL_SPK_VBAT_LDO_EN_ENABLE BIT(0) |
---|
| 231 | +#define RX_EAR_CTL_PA_EAR_PA_EN_MASK BIT(6) |
---|
| 232 | +#define RX_EAR_CTL_PA_EAR_PA_EN_ENABLE BIT(6) |
---|
| 233 | +#define RX_EAR_CTL_PA_SEL_MASK BIT(7) |
---|
| 234 | +#define RX_EAR_CTL_PA_SEL BIT(7) |
---|
228 | 235 | |
---|
229 | 236 | #define CDC_A_SPKR_DAC_CTL (0xf1B0) |
---|
230 | 237 | #define SPKR_DAC_CTL_DAC_RESET_MASK BIT(4) |
---|
.. | .. |
---|
309 | 316 | static const struct soc_enum hph_enum = SOC_ENUM_SINGLE_VIRT( |
---|
310 | 317 | ARRAY_SIZE(hph_text), hph_text); |
---|
311 | 318 | |
---|
| 319 | +static const struct snd_kcontrol_new ear_mux = SOC_DAPM_ENUM("EAR_S", hph_enum); |
---|
312 | 320 | static const struct snd_kcontrol_new hphl_mux = SOC_DAPM_ENUM("HPHL", hph_enum); |
---|
313 | 321 | static const struct snd_kcontrol_new hphr_mux = SOC_DAPM_ENUM("HPHR", hph_enum); |
---|
314 | 322 | |
---|
.. | .. |
---|
366 | 374 | |
---|
367 | 375 | } |
---|
368 | 376 | |
---|
369 | | -static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_component |
---|
370 | | - *component, int event, |
---|
371 | | - int reg, unsigned int cap_mode) |
---|
| 377 | +static int pm8916_wcd_analog_enable_micbias(struct snd_soc_component *component, |
---|
| 378 | + int event, unsigned int cap_mode) |
---|
372 | 379 | { |
---|
373 | 380 | switch (event) { |
---|
374 | 381 | case SND_SOC_DAPM_POST_PMU: |
---|
.. | .. |
---|
381 | 388 | return 0; |
---|
382 | 389 | } |
---|
383 | 390 | |
---|
384 | | -static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_component |
---|
385 | | - *component, int event, |
---|
386 | | - int reg, u32 cap_mode) |
---|
| 391 | +static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_dapm_widget *w, |
---|
| 392 | + struct snd_kcontrol *kcontrol, |
---|
| 393 | + int event) |
---|
387 | 394 | { |
---|
| 395 | + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
---|
388 | 396 | |
---|
389 | 397 | switch (event) { |
---|
390 | 398 | case SND_SOC_DAPM_PRE_PMU: |
---|
391 | | - snd_soc_component_update_bits(component, reg, MICB_1_EN_PULL_DOWN_EN_MASK, 0); |
---|
392 | 399 | snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, |
---|
393 | 400 | MICB_1_EN_OPA_STG2_TAIL_CURR_MASK, |
---|
394 | 401 | MICB_1_EN_OPA_STG2_TAIL_CURR_1_60UA); |
---|
395 | | - |
---|
396 | | - break; |
---|
397 | | - case SND_SOC_DAPM_POST_PMU: |
---|
398 | | - pm8916_wcd_analog_micbias_enable(component); |
---|
399 | | - snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, |
---|
400 | | - MICB_1_EN_BYP_CAP_MASK, cap_mode); |
---|
401 | 402 | break; |
---|
402 | 403 | } |
---|
403 | 404 | |
---|
404 | 405 | return 0; |
---|
405 | 406 | } |
---|
406 | 407 | |
---|
407 | | -static int pm8916_wcd_analog_enable_micbias_ext1(struct |
---|
408 | | - snd_soc_dapm_widget |
---|
409 | | - *w, struct snd_kcontrol |
---|
410 | | - *kcontrol, int event) |
---|
| 408 | +static int pm8916_wcd_analog_enable_micbias1(struct snd_soc_dapm_widget *w, |
---|
| 409 | + struct snd_kcontrol *kcontrol, |
---|
| 410 | + int event) |
---|
411 | 411 | { |
---|
412 | 412 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
---|
413 | 413 | struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); |
---|
414 | 414 | |
---|
415 | | - return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg, |
---|
416 | | - wcd->micbias1_cap_mode); |
---|
| 415 | + return pm8916_wcd_analog_enable_micbias(component, event, |
---|
| 416 | + wcd->micbias1_cap_mode); |
---|
417 | 417 | } |
---|
418 | 418 | |
---|
419 | | -static int pm8916_wcd_analog_enable_micbias_ext2(struct |
---|
420 | | - snd_soc_dapm_widget |
---|
421 | | - *w, struct snd_kcontrol |
---|
422 | | - *kcontrol, int event) |
---|
| 419 | +static int pm8916_wcd_analog_enable_micbias2(struct snd_soc_dapm_widget *w, |
---|
| 420 | + struct snd_kcontrol *kcontrol, |
---|
| 421 | + int event) |
---|
423 | 422 | { |
---|
424 | 423 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
---|
425 | 424 | struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); |
---|
426 | 425 | |
---|
427 | | - return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg, |
---|
428 | | - wcd->micbias2_cap_mode); |
---|
| 426 | + return pm8916_wcd_analog_enable_micbias(component, event, |
---|
| 427 | + wcd->micbias2_cap_mode); |
---|
429 | 428 | |
---|
430 | | -} |
---|
431 | | - |
---|
432 | | -static int pm8916_wcd_analog_enable_micbias_int1(struct |
---|
433 | | - snd_soc_dapm_widget |
---|
434 | | - *w, struct snd_kcontrol |
---|
435 | | - *kcontrol, int event) |
---|
436 | | -{ |
---|
437 | | - struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
---|
438 | | - struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); |
---|
439 | | - |
---|
440 | | - switch (event) { |
---|
441 | | - case SND_SOC_DAPM_PRE_PMU: |
---|
442 | | - snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS, |
---|
443 | | - MICB_1_INT_TX1_INT_RBIAS_EN_MASK, |
---|
444 | | - MICB_1_INT_TX1_INT_RBIAS_EN_ENABLE); |
---|
445 | | - break; |
---|
446 | | - } |
---|
447 | | - |
---|
448 | | - return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg, |
---|
449 | | - wcd->micbias1_cap_mode); |
---|
450 | 429 | } |
---|
451 | 430 | |
---|
452 | 431 | static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, |
---|
.. | .. |
---|
531 | 510 | DIG_CLK_CTL_D_MBHC_CLK_EN_MASK, |
---|
532 | 511 | DIG_CLK_CTL_D_MBHC_CLK_EN); |
---|
533 | 512 | |
---|
534 | | - if (snd_soc_component_read32(component, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) |
---|
| 513 | + if (snd_soc_component_read(component, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) |
---|
535 | 514 | micbias_enabled = true; |
---|
536 | 515 | |
---|
537 | 516 | pm8916_mbhc_configure_bias(wcd, micbias_enabled); |
---|
.. | .. |
---|
556 | 535 | |
---|
557 | 536 | switch (event) { |
---|
558 | 537 | case SND_SOC_DAPM_PRE_PMU: |
---|
559 | | - snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS, |
---|
560 | | - MICB_1_INT_TX2_INT_RBIAS_EN_MASK, |
---|
561 | | - MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); |
---|
| 538 | + snd_soc_component_update_bits(component, CDC_A_MICB_2_EN, |
---|
| 539 | + CDC_A_MICB_2_PULL_DOWN_EN_MASK, 0); |
---|
562 | 540 | break; |
---|
563 | 541 | case SND_SOC_DAPM_POST_PMU: |
---|
564 | 542 | pm8916_mbhc_configure_bias(wcd, true); |
---|
.. | .. |
---|
568 | 546 | break; |
---|
569 | 547 | } |
---|
570 | 548 | |
---|
571 | | - return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg, |
---|
572 | | - wcd->micbias2_cap_mode); |
---|
| 549 | + return pm8916_wcd_analog_enable_micbias_int(w, kcontrol, event); |
---|
573 | 550 | } |
---|
574 | 551 | |
---|
575 | 552 | static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w, |
---|
.. | .. |
---|
631 | 608 | case CDC_A_TX_2_EN: |
---|
632 | 609 | snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL, |
---|
633 | 610 | MICB_1_CTL_CFILT_REF_SEL_MASK, 0); |
---|
634 | | - /* fall through */ |
---|
| 611 | + fallthrough; |
---|
635 | 612 | case CDC_A_TX_3_EN: |
---|
636 | 613 | snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX2_CTL, |
---|
637 | 614 | CONN_TX2_SERIAL_TX2_MUX, |
---|
.. | .. |
---|
692 | 669 | return 0; |
---|
693 | 670 | } |
---|
694 | 671 | |
---|
| 672 | +static int pm8916_wcd_analog_enable_ear_pa(struct snd_soc_dapm_widget *w, |
---|
| 673 | + struct snd_kcontrol *kcontrol, |
---|
| 674 | + int event) |
---|
| 675 | +{ |
---|
| 676 | + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
---|
| 677 | + |
---|
| 678 | + switch (event) { |
---|
| 679 | + case SND_SOC_DAPM_PRE_PMU: |
---|
| 680 | + snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL, |
---|
| 681 | + RX_EAR_CTL_PA_SEL_MASK, RX_EAR_CTL_PA_SEL); |
---|
| 682 | + break; |
---|
| 683 | + case SND_SOC_DAPM_POST_PMU: |
---|
| 684 | + snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL, |
---|
| 685 | + RX_EAR_CTL_PA_EAR_PA_EN_MASK, |
---|
| 686 | + RX_EAR_CTL_PA_EAR_PA_EN_ENABLE); |
---|
| 687 | + break; |
---|
| 688 | + case SND_SOC_DAPM_POST_PMD: |
---|
| 689 | + snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL, |
---|
| 690 | + RX_EAR_CTL_PA_EAR_PA_EN_MASK, 0); |
---|
| 691 | + /* Delay to reduce ear turn off pop */ |
---|
| 692 | + usleep_range(7000, 7100); |
---|
| 693 | + snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL, |
---|
| 694 | + RX_EAR_CTL_PA_SEL_MASK, 0); |
---|
| 695 | + break; |
---|
| 696 | + } |
---|
| 697 | + return 0; |
---|
| 698 | +} |
---|
| 699 | + |
---|
695 | 700 | static const struct reg_default wcd_reg_defaults_2_0[] = { |
---|
696 | 701 | {CDC_A_RX_COM_OCP_CTL, 0xD1}, |
---|
697 | 702 | {CDC_A_RX_COM_OCP_COUNT, 0xFF}, |
---|
.. | .. |
---|
725 | 730 | snd_soc_component_init_regmap(component, |
---|
726 | 731 | dev_get_regmap(component->dev->parent, NULL)); |
---|
727 | 732 | snd_soc_component_set_drvdata(component, priv); |
---|
728 | | - priv->pmic_rev = snd_soc_component_read32(component, CDC_D_REVISION1); |
---|
729 | | - priv->codec_version = snd_soc_component_read32(component, CDC_D_PERPH_SUBTYPE); |
---|
| 733 | + priv->pmic_rev = snd_soc_component_read(component, CDC_D_REVISION1); |
---|
| 734 | + priv->codec_version = snd_soc_component_read(component, CDC_D_PERPH_SUBTYPE); |
---|
730 | 735 | |
---|
731 | 736 | dev_info(component->dev, "PMIC REV: %d\t CODEC Version: %d\n", |
---|
732 | 737 | priv->pmic_rev, priv->codec_version); |
---|
.. | .. |
---|
808 | 813 | {"PDM_TX", NULL, "A_MCLK2"}, |
---|
809 | 814 | {"A_MCLK2", NULL, "A_MCLK"}, |
---|
810 | 815 | |
---|
| 816 | + /* Earpiece (RX MIX1) */ |
---|
| 817 | + {"EAR", NULL, "EAR_S"}, |
---|
| 818 | + {"EAR_S", "Switch", "EAR PA"}, |
---|
| 819 | + {"EAR PA", NULL, "RX_BIAS"}, |
---|
| 820 | + {"EAR PA", NULL, "HPHL DAC"}, |
---|
| 821 | + {"EAR PA", NULL, "HPHR DAC"}, |
---|
| 822 | + {"EAR PA", NULL, "EAR CP"}, |
---|
| 823 | + |
---|
811 | 824 | /* Headset (RX MIX1 and RX MIX2) */ |
---|
812 | 825 | {"HEADPHONE", NULL, "HPHL PA"}, |
---|
813 | 826 | {"HEADPHONE", NULL, "HPHR PA"}, |
---|
814 | 827 | |
---|
815 | | - {"HPHL PA", NULL, "EAR_HPHL_CLK"}, |
---|
816 | | - {"HPHR PA", NULL, "EAR_HPHR_CLK"}, |
---|
| 828 | + {"HPHL DAC", NULL, "EAR_HPHL_CLK"}, |
---|
| 829 | + {"HPHR DAC", NULL, "EAR_HPHR_CLK"}, |
---|
817 | 830 | |
---|
818 | 831 | {"CP", NULL, "NCP_CLK"}, |
---|
819 | 832 | |
---|
.. | .. |
---|
834 | 847 | {"SPK PA", NULL, "SPK DAC"}, |
---|
835 | 848 | {"SPK DAC", "Switch", "PDM_RX3"}, |
---|
836 | 849 | |
---|
837 | | - {"MIC BIAS Internal1", NULL, "INT_LDO_H"}, |
---|
838 | | - {"MIC BIAS Internal2", NULL, "INT_LDO_H"}, |
---|
839 | | - {"MIC BIAS External1", NULL, "INT_LDO_H"}, |
---|
840 | | - {"MIC BIAS External2", NULL, "INT_LDO_H"}, |
---|
841 | | - {"MIC BIAS Internal1", NULL, "vdd-micbias"}, |
---|
842 | | - {"MIC BIAS Internal2", NULL, "vdd-micbias"}, |
---|
843 | | - {"MIC BIAS External1", NULL, "vdd-micbias"}, |
---|
844 | | - {"MIC BIAS External2", NULL, "vdd-micbias"}, |
---|
| 850 | + {"MIC_BIAS1", NULL, "INT_LDO_H"}, |
---|
| 851 | + {"MIC_BIAS2", NULL, "INT_LDO_H"}, |
---|
| 852 | + {"MIC_BIAS1", NULL, "vdd-micbias"}, |
---|
| 853 | + {"MIC_BIAS2", NULL, "vdd-micbias"}, |
---|
| 854 | + |
---|
| 855 | + {"MIC BIAS External1", NULL, "MIC_BIAS1"}, |
---|
| 856 | + {"MIC BIAS Internal1", NULL, "MIC_BIAS1"}, |
---|
| 857 | + {"MIC BIAS External2", NULL, "MIC_BIAS2"}, |
---|
| 858 | + {"MIC BIAS Internal2", NULL, "MIC_BIAS2"}, |
---|
| 859 | + {"MIC BIAS Internal3", NULL, "MIC_BIAS1"}, |
---|
845 | 860 | }; |
---|
846 | 861 | |
---|
847 | 862 | static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { |
---|
.. | .. |
---|
854 | 869 | SND_SOC_DAPM_INPUT("AMIC1"), |
---|
855 | 870 | SND_SOC_DAPM_INPUT("AMIC3"), |
---|
856 | 871 | SND_SOC_DAPM_INPUT("AMIC2"), |
---|
| 872 | + SND_SOC_DAPM_OUTPUT("EAR"), |
---|
857 | 873 | SND_SOC_DAPM_OUTPUT("HEADPHONE"), |
---|
858 | 874 | |
---|
859 | 875 | /* RX stuff */ |
---|
860 | 876 | SND_SOC_DAPM_SUPPLY("INT_LDO_H", SND_SOC_NOPM, 1, 0, NULL, 0), |
---|
| 877 | + |
---|
| 878 | + SND_SOC_DAPM_PGA_E("EAR PA", SND_SOC_NOPM, |
---|
| 879 | + 0, 0, NULL, 0, |
---|
| 880 | + pm8916_wcd_analog_enable_ear_pa, |
---|
| 881 | + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
---|
| 882 | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), |
---|
| 883 | + SND_SOC_DAPM_MUX("EAR_S", SND_SOC_NOPM, 0, 0, &ear_mux), |
---|
| 884 | + SND_SOC_DAPM_SUPPLY("EAR CP", CDC_A_NCP_EN, 4, 0, NULL, 0), |
---|
861 | 885 | |
---|
862 | 886 | SND_SOC_DAPM_PGA("HPHL PA", CDC_A_RX_HPH_CNP_EN, 5, 0, NULL, 0), |
---|
863 | 887 | SND_SOC_DAPM_MUX("HPHL", SND_SOC_NOPM, 0, 0, &hphl_mux), |
---|
.. | .. |
---|
884 | 908 | SND_SOC_DAPM_SUPPLY("RX_BIAS", CDC_A_RX_COM_BIAS_DAC, 7, 0, NULL, 0), |
---|
885 | 909 | |
---|
886 | 910 | /* TX */ |
---|
887 | | - SND_SOC_DAPM_SUPPLY("MIC BIAS Internal1", CDC_A_MICB_1_EN, 7, 0, |
---|
888 | | - pm8916_wcd_analog_enable_micbias_int1, |
---|
889 | | - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
---|
890 | | - SND_SOC_DAPM_POST_PMD), |
---|
891 | | - SND_SOC_DAPM_SUPPLY("MIC BIAS Internal2", CDC_A_MICB_2_EN, 7, 0, |
---|
| 911 | + SND_SOC_DAPM_SUPPLY("MIC_BIAS1", CDC_A_MICB_1_EN, 7, 0, |
---|
| 912 | + pm8916_wcd_analog_enable_micbias1, |
---|
| 913 | + SND_SOC_DAPM_POST_PMU), |
---|
| 914 | + SND_SOC_DAPM_SUPPLY("MIC_BIAS2", CDC_A_MICB_2_EN, 7, 0, |
---|
| 915 | + pm8916_wcd_analog_enable_micbias2, |
---|
| 916 | + SND_SOC_DAPM_POST_PMU), |
---|
| 917 | + |
---|
| 918 | + SND_SOC_DAPM_SUPPLY("MIC BIAS External1", SND_SOC_NOPM, 0, 0, NULL, 0), |
---|
| 919 | + SND_SOC_DAPM_SUPPLY("MIC BIAS External2", SND_SOC_NOPM, 0, 0, NULL, 0), |
---|
| 920 | + |
---|
| 921 | + SND_SOC_DAPM_SUPPLY("MIC BIAS Internal1", CDC_A_MICB_1_INT_RBIAS, 7, 0, |
---|
| 922 | + pm8916_wcd_analog_enable_micbias_int, |
---|
| 923 | + SND_SOC_DAPM_PRE_PMU), |
---|
| 924 | + SND_SOC_DAPM_SUPPLY("MIC BIAS Internal2", CDC_A_MICB_1_INT_RBIAS, 4, 0, |
---|
892 | 925 | pm8916_wcd_analog_enable_micbias_int2, |
---|
893 | 926 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
---|
894 | 927 | SND_SOC_DAPM_POST_PMD), |
---|
895 | | - |
---|
896 | | - SND_SOC_DAPM_SUPPLY("MIC BIAS External1", CDC_A_MICB_1_EN, 7, 0, |
---|
897 | | - pm8916_wcd_analog_enable_micbias_ext1, |
---|
898 | | - SND_SOC_DAPM_POST_PMU), |
---|
899 | | - SND_SOC_DAPM_SUPPLY("MIC BIAS External2", CDC_A_MICB_2_EN, 7, 0, |
---|
900 | | - pm8916_wcd_analog_enable_micbias_ext2, |
---|
901 | | - SND_SOC_DAPM_POST_PMU), |
---|
| 928 | + SND_SOC_DAPM_SUPPLY("MIC BIAS Internal3", CDC_A_MICB_1_INT_RBIAS, 1, 0, |
---|
| 929 | + pm8916_wcd_analog_enable_micbias_int, |
---|
| 930 | + SND_SOC_DAPM_PRE_PMU), |
---|
902 | 931 | |
---|
903 | 932 | SND_SOC_DAPM_ADC_E("ADC1", NULL, CDC_A_TX_1_EN, 7, 0, |
---|
904 | 933 | pm8916_wcd_analog_enable_adc, |
---|
.. | .. |
---|
961 | 990 | |
---|
962 | 991 | if (priv->detect_accessory_type) { |
---|
963 | 992 | struct snd_soc_component *component = priv->component; |
---|
964 | | - u32 val = snd_soc_component_read32(component, CDC_A_MBHC_RESULT_1); |
---|
| 993 | + u32 val = snd_soc_component_read(component, CDC_A_MBHC_RESULT_1); |
---|
965 | 994 | |
---|
966 | 995 | /* check if its BTN0 thats released */ |
---|
967 | 996 | if ((val != -1) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK)) |
---|
.. | .. |
---|
980 | 1009 | struct snd_soc_component *component = priv->component; |
---|
981 | 1010 | u32 btn_result; |
---|
982 | 1011 | |
---|
983 | | - btn_result = snd_soc_component_read32(component, CDC_A_MBHC_RESULT_1) & |
---|
| 1012 | + btn_result = snd_soc_component_read(component, CDC_A_MBHC_RESULT_1) & |
---|
984 | 1013 | CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK; |
---|
985 | 1014 | |
---|
986 | 1015 | switch (btn_result) { |
---|
.. | .. |
---|
1017 | 1046 | struct snd_soc_component *component = priv->component; |
---|
1018 | 1047 | bool ins = false; |
---|
1019 | 1048 | |
---|
1020 | | - if (snd_soc_component_read32(component, CDC_A_MBHC_DET_CTL_1) & |
---|
| 1049 | + if (snd_soc_component_read(component, CDC_A_MBHC_DET_CTL_1) & |
---|
1021 | 1050 | CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK) |
---|
1022 | 1051 | ins = true; |
---|
1023 | 1052 | |
---|
.. | .. |
---|
1030 | 1059 | if (ins) { /* hs insertion */ |
---|
1031 | 1060 | bool micbias_enabled = false; |
---|
1032 | 1061 | |
---|
1033 | | - if (snd_soc_component_read32(component, CDC_A_MICB_2_EN) & |
---|
| 1062 | + if (snd_soc_component_read(component, CDC_A_MICB_2_EN) & |
---|
1034 | 1063 | CDC_A_MICB_2_EN_ENABLE) |
---|
1035 | 1064 | micbias_enabled = true; |
---|
1036 | 1065 | |
---|
.. | .. |
---|
1193 | 1222 | |
---|
1194 | 1223 | irq = platform_get_irq_byname(pdev, "mbhc_switch_int"); |
---|
1195 | 1224 | if (irq < 0) { |
---|
1196 | | - dev_err(dev, "failed to get mbhc switch irq\n"); |
---|
1197 | | - return irq; |
---|
| 1225 | + ret = irq; |
---|
| 1226 | + goto err_disable_clk; |
---|
1198 | 1227 | } |
---|
1199 | 1228 | |
---|
1200 | 1229 | ret = devm_request_threaded_irq(dev, irq, NULL, |
---|
.. | .. |
---|
1208 | 1237 | if (priv->mbhc_btn_enabled) { |
---|
1209 | 1238 | irq = platform_get_irq_byname(pdev, "mbhc_but_press_det"); |
---|
1210 | 1239 | if (irq < 0) { |
---|
1211 | | - dev_err(dev, "failed to get button press irq\n"); |
---|
1212 | | - return irq; |
---|
| 1240 | + ret = irq; |
---|
| 1241 | + goto err_disable_clk; |
---|
1213 | 1242 | } |
---|
1214 | 1243 | |
---|
1215 | 1244 | ret = devm_request_threaded_irq(dev, irq, NULL, |
---|
.. | .. |
---|
1222 | 1251 | |
---|
1223 | 1252 | irq = platform_get_irq_byname(pdev, "mbhc_but_rel_det"); |
---|
1224 | 1253 | if (irq < 0) { |
---|
1225 | | - dev_err(dev, "failed to get button release irq\n"); |
---|
1226 | | - return irq; |
---|
| 1254 | + ret = irq; |
---|
| 1255 | + goto err_disable_clk; |
---|
1227 | 1256 | } |
---|
1228 | 1257 | |
---|
1229 | 1258 | ret = devm_request_threaded_irq(dev, irq, NULL, |
---|
.. | .. |
---|
1241 | 1270 | return devm_snd_soc_register_component(dev, &pm8916_wcd_analog, |
---|
1242 | 1271 | pm8916_wcd_analog_dai, |
---|
1243 | 1272 | ARRAY_SIZE(pm8916_wcd_analog_dai)); |
---|
| 1273 | + |
---|
| 1274 | +err_disable_clk: |
---|
| 1275 | + clk_disable_unprepare(priv->mclk); |
---|
| 1276 | + return ret; |
---|
1244 | 1277 | } |
---|
1245 | 1278 | |
---|
1246 | 1279 | static int pm8916_wcd_analog_spmi_remove(struct platform_device *pdev) |
---|