aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/max98090.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/max98090.c')
-rw-r--r--sound/soc/codecs/max98090.c193
1 files changed, 108 insertions, 85 deletions
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 51f9b3d16b41..f363de19be07 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -336,6 +336,7 @@ static bool max98090_readable_register(struct device *dev, unsigned int reg)
336 case M98090_REG_RECORD_TDM_SLOT: 336 case M98090_REG_RECORD_TDM_SLOT:
337 case M98090_REG_SAMPLE_RATE: 337 case M98090_REG_SAMPLE_RATE:
338 case M98090_REG_DMIC34_BIQUAD_BASE ... M98090_REG_DMIC34_BIQUAD_BASE + 0x0E: 338 case M98090_REG_DMIC34_BIQUAD_BASE ... M98090_REG_DMIC34_BIQUAD_BASE + 0x0E:
339 case M98090_REG_REVISION_ID:
339 return true; 340 return true;
340 default: 341 default:
341 return false; 342 return false;
@@ -512,65 +513,75 @@ static const char *max98090_perf_pwr_text[] =
512static const char *max98090_pwr_perf_text[] = 513static const char *max98090_pwr_perf_text[] =
513 { "Low Power", "High Performance" }; 514 { "Low Power", "High Performance" };
514 515
515static const struct soc_enum max98090_vcmbandgap_enum = 516static SOC_ENUM_SINGLE_DECL(max98090_vcmbandgap_enum,
516 SOC_ENUM_SINGLE(M98090_REG_BIAS_CONTROL, M98090_VCM_MODE_SHIFT, 517 M98090_REG_BIAS_CONTROL,
517 ARRAY_SIZE(max98090_pwr_perf_text), max98090_pwr_perf_text); 518 M98090_VCM_MODE_SHIFT,
519 max98090_pwr_perf_text);
518 520
519static const char *max98090_osr128_text[] = { "64*fs", "128*fs" }; 521static const char *max98090_osr128_text[] = { "64*fs", "128*fs" };
520 522
521static const struct soc_enum max98090_osr128_enum = 523static SOC_ENUM_SINGLE_DECL(max98090_osr128_enum,
522 SOC_ENUM_SINGLE(M98090_REG_ADC_CONTROL, M98090_OSR128_SHIFT, 524 M98090_REG_ADC_CONTROL,
523 ARRAY_SIZE(max98090_osr128_text), max98090_osr128_text); 525 M98090_OSR128_SHIFT,
526 max98090_osr128_text);
524 527
525static const char *max98090_mode_text[] = { "Voice", "Music" }; 528static const char *max98090_mode_text[] = { "Voice", "Music" };
526 529
527static const struct soc_enum max98090_mode_enum = 530static SOC_ENUM_SINGLE_DECL(max98090_mode_enum,
528 SOC_ENUM_SINGLE(M98090_REG_FILTER_CONFIG, M98090_MODE_SHIFT, 531 M98090_REG_FILTER_CONFIG,
529 ARRAY_SIZE(max98090_mode_text), max98090_mode_text); 532 M98090_MODE_SHIFT,
533 max98090_mode_text);
530 534
531static const struct soc_enum max98090_filter_dmic34mode_enum = 535static SOC_ENUM_SINGLE_DECL(max98090_filter_dmic34mode_enum,
532 SOC_ENUM_SINGLE(M98090_REG_FILTER_CONFIG, 536 M98090_REG_FILTER_CONFIG,
533 M98090_FLT_DMIC34MODE_SHIFT, 537 M98090_FLT_DMIC34MODE_SHIFT,
534 ARRAY_SIZE(max98090_mode_text), max98090_mode_text); 538 max98090_mode_text);
535 539
536static const char *max98090_drcatk_text[] = 540static const char *max98090_drcatk_text[] =
537 { "0.5ms", "1ms", "5ms", "10ms", "25ms", "50ms", "100ms", "200ms" }; 541 { "0.5ms", "1ms", "5ms", "10ms", "25ms", "50ms", "100ms", "200ms" };
538 542
539static const struct soc_enum max98090_drcatk_enum = 543static SOC_ENUM_SINGLE_DECL(max98090_drcatk_enum,
540 SOC_ENUM_SINGLE(M98090_REG_DRC_TIMING, M98090_DRCATK_SHIFT, 544 M98090_REG_DRC_TIMING,
541 ARRAY_SIZE(max98090_drcatk_text), max98090_drcatk_text); 545 M98090_DRCATK_SHIFT,
546 max98090_drcatk_text);
542 547
543static const char *max98090_drcrls_text[] = 548static const char *max98090_drcrls_text[] =
544 { "8s", "4s", "2s", "1s", "0.5s", "0.25s", "0.125s", "0.0625s" }; 549 { "8s", "4s", "2s", "1s", "0.5s", "0.25s", "0.125s", "0.0625s" };
545 550
546static const struct soc_enum max98090_drcrls_enum = 551static SOC_ENUM_SINGLE_DECL(max98090_drcrls_enum,
547 SOC_ENUM_SINGLE(M98090_REG_DRC_TIMING, M98090_DRCRLS_SHIFT, 552 M98090_REG_DRC_TIMING,
548 ARRAY_SIZE(max98090_drcrls_text), max98090_drcrls_text); 553 M98090_DRCRLS_SHIFT,
554 max98090_drcrls_text);
549 555
550static const char *max98090_alccmp_text[] = 556static const char *max98090_alccmp_text[] =
551 { "1:1", "1:1.5", "1:2", "1:4", "1:INF" }; 557 { "1:1", "1:1.5", "1:2", "1:4", "1:INF" };
552 558
553static const struct soc_enum max98090_alccmp_enum = 559static SOC_ENUM_SINGLE_DECL(max98090_alccmp_enum,
554 SOC_ENUM_SINGLE(M98090_REG_DRC_COMPRESSOR, M98090_DRCCMP_SHIFT, 560 M98090_REG_DRC_COMPRESSOR,
555 ARRAY_SIZE(max98090_alccmp_text), max98090_alccmp_text); 561 M98090_DRCCMP_SHIFT,
562 max98090_alccmp_text);
556 563
557static const char *max98090_drcexp_text[] = { "1:1", "2:1", "3:1" }; 564static const char *max98090_drcexp_text[] = { "1:1", "2:1", "3:1" };
558 565
559static const struct soc_enum max98090_drcexp_enum = 566static SOC_ENUM_SINGLE_DECL(max98090_drcexp_enum,
560 SOC_ENUM_SINGLE(M98090_REG_DRC_EXPANDER, M98090_DRCEXP_SHIFT, 567 M98090_REG_DRC_EXPANDER,
561 ARRAY_SIZE(max98090_drcexp_text), max98090_drcexp_text); 568 M98090_DRCEXP_SHIFT,
569 max98090_drcexp_text);
562 570
563static const struct soc_enum max98090_dac_perfmode_enum = 571static SOC_ENUM_SINGLE_DECL(max98090_dac_perfmode_enum,
564 SOC_ENUM_SINGLE(M98090_REG_DAC_CONTROL, M98090_PERFMODE_SHIFT, 572 M98090_REG_DAC_CONTROL,
565 ARRAY_SIZE(max98090_perf_pwr_text), max98090_perf_pwr_text); 573 M98090_PERFMODE_SHIFT,
574 max98090_perf_pwr_text);
566 575
567static const struct soc_enum max98090_dachp_enum = 576static SOC_ENUM_SINGLE_DECL(max98090_dachp_enum,
568 SOC_ENUM_SINGLE(M98090_REG_DAC_CONTROL, M98090_DACHP_SHIFT, 577 M98090_REG_DAC_CONTROL,
569 ARRAY_SIZE(max98090_pwr_perf_text), max98090_pwr_perf_text); 578 M98090_DACHP_SHIFT,
579 max98090_pwr_perf_text);
570 580
571static const struct soc_enum max98090_adchp_enum = 581static SOC_ENUM_SINGLE_DECL(max98090_adchp_enum,
572 SOC_ENUM_SINGLE(M98090_REG_ADC_CONTROL, M98090_ADCHP_SHIFT, 582 M98090_REG_ADC_CONTROL,
573 ARRAY_SIZE(max98090_pwr_perf_text), max98090_pwr_perf_text); 583 M98090_ADCHP_SHIFT,
584 max98090_pwr_perf_text);
574 585
575static const struct snd_kcontrol_new max98090_snd_controls[] = { 586static const struct snd_kcontrol_new max98090_snd_controls[] = {
576 SOC_ENUM("MIC Bias VCM Bandgap", max98090_vcmbandgap_enum), 587 SOC_ENUM("MIC Bias VCM Bandgap", max98090_vcmbandgap_enum),
@@ -841,39 +852,42 @@ static int max98090_micinput_event(struct snd_soc_dapm_widget *w,
841 852
842static const char *mic1_mux_text[] = { "IN12", "IN56" }; 853static const char *mic1_mux_text[] = { "IN12", "IN56" };
843 854
844static const struct soc_enum mic1_mux_enum = 855static SOC_ENUM_SINGLE_DECL(mic1_mux_enum,
845 SOC_ENUM_SINGLE(M98090_REG_INPUT_MODE, M98090_EXTMIC1_SHIFT, 856 M98090_REG_INPUT_MODE,
846 ARRAY_SIZE(mic1_mux_text), mic1_mux_text); 857 M98090_EXTMIC1_SHIFT,
858 mic1_mux_text);
847 859
848static const struct snd_kcontrol_new max98090_mic1_mux = 860static const struct snd_kcontrol_new max98090_mic1_mux =
849 SOC_DAPM_ENUM("MIC1 Mux", mic1_mux_enum); 861 SOC_DAPM_ENUM("MIC1 Mux", mic1_mux_enum);
850 862
851static const char *mic2_mux_text[] = { "IN34", "IN56" }; 863static const char *mic2_mux_text[] = { "IN34", "IN56" };
852 864
853static const struct soc_enum mic2_mux_enum = 865static SOC_ENUM_SINGLE_DECL(mic2_mux_enum,
854 SOC_ENUM_SINGLE(M98090_REG_INPUT_MODE, M98090_EXTMIC2_SHIFT, 866 M98090_REG_INPUT_MODE,
855 ARRAY_SIZE(mic2_mux_text), mic2_mux_text); 867 M98090_EXTMIC2_SHIFT,
868 mic2_mux_text);
856 869
857static const struct snd_kcontrol_new max98090_mic2_mux = 870static const struct snd_kcontrol_new max98090_mic2_mux =
858 SOC_DAPM_ENUM("MIC2 Mux", mic2_mux_enum); 871 SOC_DAPM_ENUM("MIC2 Mux", mic2_mux_enum);
859 872
860static const char *dmic_mux_text[] = { "ADC", "DMIC" }; 873static const char *dmic_mux_text[] = { "ADC", "DMIC" };
861 874
862static const struct soc_enum dmic_mux_enum = 875static SOC_ENUM_SINGLE_VIRT_DECL(dmic_mux_enum, dmic_mux_text);
863 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(dmic_mux_text), dmic_mux_text);
864 876
865static const struct snd_kcontrol_new max98090_dmic_mux = 877static const struct snd_kcontrol_new max98090_dmic_mux =
866 SOC_DAPM_ENUM_VIRT("DMIC Mux", dmic_mux_enum); 878 SOC_DAPM_ENUM_VIRT("DMIC Mux", dmic_mux_enum);
867 879
868static const char *max98090_micpre_text[] = { "Off", "On" }; 880static const char *max98090_micpre_text[] = { "Off", "On" };
869 881
870static const struct soc_enum max98090_pa1en_enum = 882static SOC_ENUM_SINGLE_DECL(max98090_pa1en_enum,
871 SOC_ENUM_SINGLE(M98090_REG_MIC1_INPUT_LEVEL, M98090_MIC_PA1EN_SHIFT, 883 M98090_REG_MIC1_INPUT_LEVEL,
872 ARRAY_SIZE(max98090_micpre_text), max98090_micpre_text); 884 M98090_MIC_PA1EN_SHIFT,
885 max98090_micpre_text);
873 886
874static const struct soc_enum max98090_pa2en_enum = 887static SOC_ENUM_SINGLE_DECL(max98090_pa2en_enum,
875 SOC_ENUM_SINGLE(M98090_REG_MIC2_INPUT_LEVEL, M98090_MIC_PA2EN_SHIFT, 888 M98090_REG_MIC2_INPUT_LEVEL,
876 ARRAY_SIZE(max98090_micpre_text), max98090_micpre_text); 889 M98090_MIC_PA2EN_SHIFT,
890 max98090_micpre_text);
877 891
878/* LINEA mixer switch */ 892/* LINEA mixer switch */
879static const struct snd_kcontrol_new max98090_linea_mixer_controls[] = { 893static const struct snd_kcontrol_new max98090_linea_mixer_controls[] = {
@@ -937,13 +951,15 @@ static const struct snd_kcontrol_new max98090_right_adc_mixer_controls[] = {
937 951
938static const char *lten_mux_text[] = { "Normal", "Loopthrough" }; 952static const char *lten_mux_text[] = { "Normal", "Loopthrough" };
939 953
940static const struct soc_enum ltenl_mux_enum = 954static SOC_ENUM_SINGLE_DECL(ltenl_mux_enum,
941 SOC_ENUM_SINGLE(M98090_REG_IO_CONFIGURATION, M98090_LTEN_SHIFT, 955 M98090_REG_IO_CONFIGURATION,
942 ARRAY_SIZE(lten_mux_text), lten_mux_text); 956 M98090_LTEN_SHIFT,
957 lten_mux_text);
943 958
944static const struct soc_enum ltenr_mux_enum = 959static SOC_ENUM_SINGLE_DECL(ltenr_mux_enum,
945 SOC_ENUM_SINGLE(M98090_REG_IO_CONFIGURATION, M98090_LTEN_SHIFT, 960 M98090_REG_IO_CONFIGURATION,
946 ARRAY_SIZE(lten_mux_text), lten_mux_text); 961 M98090_LTEN_SHIFT,
962 lten_mux_text);
947 963
948static const struct snd_kcontrol_new max98090_ltenl_mux = 964static const struct snd_kcontrol_new max98090_ltenl_mux =
949 SOC_DAPM_ENUM("LTENL Mux", ltenl_mux_enum); 965 SOC_DAPM_ENUM("LTENL Mux", ltenl_mux_enum);
@@ -953,13 +969,15 @@ static const struct snd_kcontrol_new max98090_ltenr_mux =
953 969
954static const char *lben_mux_text[] = { "Normal", "Loopback" }; 970static const char *lben_mux_text[] = { "Normal", "Loopback" };
955 971
956static const struct soc_enum lbenl_mux_enum = 972static SOC_ENUM_SINGLE_DECL(lbenl_mux_enum,
957 SOC_ENUM_SINGLE(M98090_REG_IO_CONFIGURATION, M98090_LBEN_SHIFT, 973 M98090_REG_IO_CONFIGURATION,
958 ARRAY_SIZE(lben_mux_text), lben_mux_text); 974 M98090_LBEN_SHIFT,
975 lben_mux_text);
959 976
960static const struct soc_enum lbenr_mux_enum = 977static SOC_ENUM_SINGLE_DECL(lbenr_mux_enum,
961 SOC_ENUM_SINGLE(M98090_REG_IO_CONFIGURATION, M98090_LBEN_SHIFT, 978 M98090_REG_IO_CONFIGURATION,
962 ARRAY_SIZE(lben_mux_text), lben_mux_text); 979 M98090_LBEN_SHIFT,
980 lben_mux_text);
963 981
964static const struct snd_kcontrol_new max98090_lbenl_mux = 982static const struct snd_kcontrol_new max98090_lbenl_mux =
965 SOC_DAPM_ENUM("LBENL Mux", lbenl_mux_enum); 983 SOC_DAPM_ENUM("LBENL Mux", lbenl_mux_enum);
@@ -971,13 +989,15 @@ static const char *stenl_mux_text[] = { "Normal", "Sidetone Left" };
971 989
972static const char *stenr_mux_text[] = { "Normal", "Sidetone Right" }; 990static const char *stenr_mux_text[] = { "Normal", "Sidetone Right" };
973 991
974static const struct soc_enum stenl_mux_enum = 992static SOC_ENUM_SINGLE_DECL(stenl_mux_enum,
975 SOC_ENUM_SINGLE(M98090_REG_ADC_SIDETONE, M98090_DSTSL_SHIFT, 993 M98090_REG_ADC_SIDETONE,
976 ARRAY_SIZE(stenl_mux_text), stenl_mux_text); 994 M98090_DSTSL_SHIFT,
995 stenl_mux_text);
977 996
978static const struct soc_enum stenr_mux_enum = 997static SOC_ENUM_SINGLE_DECL(stenr_mux_enum,
979 SOC_ENUM_SINGLE(M98090_REG_ADC_SIDETONE, M98090_DSTSR_SHIFT, 998 M98090_REG_ADC_SIDETONE,
980 ARRAY_SIZE(stenr_mux_text), stenr_mux_text); 999 M98090_DSTSR_SHIFT,
1000 stenr_mux_text);
981 1001
982static const struct snd_kcontrol_new max98090_stenl_mux = 1002static const struct snd_kcontrol_new max98090_stenl_mux =
983 SOC_DAPM_ENUM("STENL Mux", stenl_mux_enum); 1003 SOC_DAPM_ENUM("STENL Mux", stenl_mux_enum);
@@ -1085,9 +1105,10 @@ static const struct snd_kcontrol_new max98090_right_rcv_mixer_controls[] = {
1085 1105
1086static const char *linmod_mux_text[] = { "Left Only", "Left and Right" }; 1106static const char *linmod_mux_text[] = { "Left Only", "Left and Right" };
1087 1107
1088static const struct soc_enum linmod_mux_enum = 1108static SOC_ENUM_SINGLE_DECL(linmod_mux_enum,
1089 SOC_ENUM_SINGLE(M98090_REG_LOUTR_MIXER, M98090_LINMOD_SHIFT, 1109 M98090_REG_LOUTR_MIXER,
1090 ARRAY_SIZE(linmod_mux_text), linmod_mux_text); 1110 M98090_LINMOD_SHIFT,
1111 linmod_mux_text);
1091 1112
1092static const struct snd_kcontrol_new max98090_linmod_mux = 1113static const struct snd_kcontrol_new max98090_linmod_mux =
1093 SOC_DAPM_ENUM("LINMOD Mux", linmod_mux_enum); 1114 SOC_DAPM_ENUM("LINMOD Mux", linmod_mux_enum);
@@ -1097,16 +1118,18 @@ static const char *mixhpsel_mux_text[] = { "DAC Only", "HP Mixer" };
1097/* 1118/*
1098 * This is a mux as it selects the HP output, but to DAPM it is a Mixer enable 1119 * This is a mux as it selects the HP output, but to DAPM it is a Mixer enable
1099 */ 1120 */
1100static const struct soc_enum mixhplsel_mux_enum = 1121static SOC_ENUM_SINGLE_DECL(mixhplsel_mux_enum,
1101 SOC_ENUM_SINGLE(M98090_REG_HP_CONTROL, M98090_MIXHPLSEL_SHIFT, 1122 M98090_REG_HP_CONTROL,
1102 ARRAY_SIZE(mixhpsel_mux_text), mixhpsel_mux_text); 1123 M98090_MIXHPLSEL_SHIFT,
1124 mixhpsel_mux_text);
1103 1125
1104static const struct snd_kcontrol_new max98090_mixhplsel_mux = 1126static const struct snd_kcontrol_new max98090_mixhplsel_mux =
1105 SOC_DAPM_ENUM("MIXHPLSEL Mux", mixhplsel_mux_enum); 1127 SOC_DAPM_ENUM("MIXHPLSEL Mux", mixhplsel_mux_enum);
1106 1128
1107static const struct soc_enum mixhprsel_mux_enum = 1129static SOC_ENUM_SINGLE_DECL(mixhprsel_mux_enum,
1108 SOC_ENUM_SINGLE(M98090_REG_HP_CONTROL, M98090_MIXHPRSEL_SHIFT, 1130 M98090_REG_HP_CONTROL,
1109 ARRAY_SIZE(mixhpsel_mux_text), mixhpsel_mux_text); 1131 M98090_MIXHPRSEL_SHIFT,
1132 mixhpsel_mux_text);
1110 1133
1111static const struct snd_kcontrol_new max98090_mixhprsel_mux = 1134static const struct snd_kcontrol_new max98090_mixhprsel_mux =
1112 SOC_DAPM_ENUM("MIXHPRSEL Mux", mixhprsel_mux_enum); 1135 SOC_DAPM_ENUM("MIXHPRSEL Mux", mixhprsel_mux_enum);
@@ -1769,16 +1792,6 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec,
1769 1792
1770 switch (level) { 1793 switch (level) {
1771 case SND_SOC_BIAS_ON: 1794 case SND_SOC_BIAS_ON:
1772 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
1773 ret = regcache_sync(max98090->regmap);
1774
1775 if (ret != 0) {
1776 dev_err(codec->dev,
1777 "Failed to sync cache: %d\n", ret);
1778 return ret;
1779 }
1780 }
1781
1782 if (max98090->jack_state == M98090_JACK_STATE_HEADSET) { 1795 if (max98090->jack_state == M98090_JACK_STATE_HEADSET) {
1783 /* 1796 /*
1784 * Set to normal bias level. 1797 * Set to normal bias level.
@@ -1792,6 +1805,16 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec,
1792 break; 1805 break;
1793 1806
1794 case SND_SOC_BIAS_STANDBY: 1807 case SND_SOC_BIAS_STANDBY:
1808 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
1809 ret = regcache_sync(max98090->regmap);
1810 if (ret != 0) {
1811 dev_err(codec->dev,
1812 "Failed to sync cache: %d\n", ret);
1813 return ret;
1814 }
1815 }
1816 break;
1817
1795 case SND_SOC_BIAS_OFF: 1818 case SND_SOC_BIAS_OFF:
1796 /* Set internal pull-up to lowest power mode */ 1819 /* Set internal pull-up to lowest power mode */
1797 snd_soc_update_bits(codec, M98090_REG_JACK_DETECT, 1820 snd_soc_update_bits(codec, M98090_REG_JACK_DETECT,