Lines Matching +full:bypass +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm8991.c -- WM8991 ALSA Soc Audio driver
5 * Copyright 2007-2010 Wolfson Microelectronics PLC.
23 #include <sound/soc-dapm.h>
36 { 1, 0x0000 }, /* R1 - Power Management (1) */
37 { 2, 0x6000 }, /* R2 - Power Management (2) */
38 { 3, 0x0000 }, /* R3 - Power Management (3) */
39 { 4, 0x4050 }, /* R4 - Audio Interface (1) */
40 { 5, 0x4000 }, /* R5 - Audio Interface (2) */
41 { 6, 0x01C8 }, /* R6 - Clocking (1) */
42 { 7, 0x0000 }, /* R7 - Clocking (2) */
43 { 8, 0x0040 }, /* R8 - Audio Interface (3) */
44 { 9, 0x0040 }, /* R9 - Audio Interface (4) */
45 { 10, 0x0004 }, /* R10 - DAC CTRL */
46 { 11, 0x00C0 }, /* R11 - Left DAC Digital Volume */
47 { 12, 0x00C0 }, /* R12 - Right DAC Digital Volume */
48 { 13, 0x0000 }, /* R13 - Digital Side Tone */
49 { 14, 0x0100 }, /* R14 - ADC CTRL */
50 { 15, 0x00C0 }, /* R15 - Left ADC Digital Volume */
51 { 16, 0x00C0 }, /* R16 - Right ADC Digital Volume */
53 { 18, 0x0000 }, /* R18 - GPIO CTRL 1 */
54 { 19, 0x1000 }, /* R19 - GPIO1 & GPIO2 */
55 { 20, 0x1010 }, /* R20 - GPIO3 & GPIO4 */
56 { 21, 0x1010 }, /* R21 - GPIO5 & GPIO6 */
57 { 22, 0x8000 }, /* R22 - GPIOCTRL 2 */
58 { 23, 0x0800 }, /* R23 - GPIO_POL */
59 { 24, 0x008B }, /* R24 - Left Line Input 1&2 Volume */
60 { 25, 0x008B }, /* R25 - Left Line Input 3&4 Volume */
61 { 26, 0x008B }, /* R26 - Right Line Input 1&2 Volume */
62 { 27, 0x008B }, /* R27 - Right Line Input 3&4 Volume */
63 { 28, 0x0000 }, /* R28 - Left Output Volume */
64 { 29, 0x0000 }, /* R29 - Right Output Volume */
65 { 30, 0x0066 }, /* R30 - Line Outputs Volume */
66 { 31, 0x0022 }, /* R31 - Out3/4 Volume */
67 { 32, 0x0079 }, /* R32 - Left OPGA Volume */
68 { 33, 0x0079 }, /* R33 - Right OPGA Volume */
69 { 34, 0x0003 }, /* R34 - Speaker Volume */
70 { 35, 0x0003 }, /* R35 - ClassD1 */
72 { 37, 0x0100 }, /* R37 - ClassD3 */
74 { 39, 0x0000 }, /* R39 - Input Mixer1 */
75 { 40, 0x0000 }, /* R40 - Input Mixer2 */
76 { 41, 0x0000 }, /* R41 - Input Mixer3 */
77 { 42, 0x0000 }, /* R42 - Input Mixer4 */
78 { 43, 0x0000 }, /* R43 - Input Mixer5 */
79 { 44, 0x0000 }, /* R44 - Input Mixer6 */
80 { 45, 0x0000 }, /* R45 - Output Mixer1 */
81 { 46, 0x0000 }, /* R46 - Output Mixer2 */
82 { 47, 0x0000 }, /* R47 - Output Mixer3 */
83 { 48, 0x0000 }, /* R48 - Output Mixer4 */
84 { 49, 0x0000 }, /* R49 - Output Mixer5 */
85 { 50, 0x0000 }, /* R50 - Output Mixer6 */
86 { 51, 0x0180 }, /* R51 - Out3/4 Mixer */
87 { 52, 0x0000 }, /* R52 - Line Mixer1 */
88 { 53, 0x0000 }, /* R53 - Line Mixer2 */
89 { 54, 0x0000 }, /* R54 - Speaker Mixer */
90 { 55, 0x0000 }, /* R55 - Additional Control */
91 { 56, 0x0000 }, /* R56 - AntiPOP1 */
92 { 57, 0x0000 }, /* R57 - AntiPOP2 */
93 { 58, 0x0000 }, /* R58 - MICBIAS */
95 { 60, 0x0008 }, /* R60 - PLL1 */
96 { 61, 0x0031 }, /* R61 - PLL2 */
97 { 62, 0x0026 }, /* R62 - PLL3 */
110 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(in_pga_tlv, -1650, 150, 0);
111 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(out_mix_tlv, -2100, 300, 0);
114 0x30, 0x7f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-7300, 100, 0),
117 0x00, 0xbf, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-71625, 375, 1),
121 0x00, 0xef, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-71625, 375, 1),
125 0x00, 0x0c, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-3600, 300, 0),
133 int reg = kcontrol->private_value & 0xff; in wm899x_outpga_put_volsw_vu()
160 {"Hi-fi mode", "Voice mode 1", "Voice mode 2", "Voice mode 3"};
176 SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8991_OUTPUT_MIXER3,
178 SOC_SINGLE_TLV("LOMIX RIN12 PGA Bypass Volume", WM8991_OUTPUT_MIXER3,
180 SOC_SINGLE_TLV("LOMIX LIN12 PGA Bypass Volume", WM8991_OUTPUT_MIXER3,
182 SOC_SINGLE_TLV("LOMIX RIN3 Bypass Volume", WM8991_OUTPUT_MIXER5,
184 SOC_SINGLE_TLV("LOMIX AINRMUX Bypass Volume", WM8991_OUTPUT_MIXER5,
186 SOC_SINGLE_TLV("LOMIX AINLMUX Bypass Volume", WM8991_OUTPUT_MIXER5,
190 SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8991_OUTPUT_MIXER4,
192 SOC_SINGLE_TLV("ROMIX LIN12 PGA Bypass Volume", WM8991_OUTPUT_MIXER4,
194 SOC_SINGLE_TLV("ROMIX RIN12 PGA Bypass Volume", WM8991_OUTPUT_MIXER4,
196 SOC_SINGLE_TLV("ROMIX LIN3 Bypass Volume", WM8991_OUTPUT_MIXER6,
198 SOC_SINGLE_TLV("ROMIX AINLMUX Bypass Volume", WM8991_OUTPUT_MIXER6,
200 SOC_SINGLE_TLV("ROMIX AINRMUX Bypass Volume", WM8991_OUTPUT_MIXER6,
360 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in outmixer_event()
361 u32 reg_shift = kcontrol->private_value & 0xfff; in outmixer_event()
371 ret = -1; in outmixer_event()
380 ret = -1; in outmixer_event()
389 ret = -1; in outmixer_event()
398 ret = -1; in outmixer_event()
407 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(in_mix_tlv, -1200, 300, 1);
481 SOC_DAPM_SINGLE("LOMIX Right ADC Bypass Switch", WM8991_OUTPUT_MIXER1,
483 SOC_DAPM_SINGLE("LOMIX Left ADC Bypass Switch", WM8991_OUTPUT_MIXER1,
485 SOC_DAPM_SINGLE("LOMIX RIN3 Bypass Switch", WM8991_OUTPUT_MIXER1,
487 SOC_DAPM_SINGLE("LOMIX LIN3 Bypass Switch", WM8991_OUTPUT_MIXER1,
489 SOC_DAPM_SINGLE("LOMIX RIN12 PGA Bypass Switch", WM8991_OUTPUT_MIXER1,
491 SOC_DAPM_SINGLE("LOMIX LIN12 PGA Bypass Switch", WM8991_OUTPUT_MIXER1,
499 SOC_DAPM_SINGLE("ROMIX Left ADC Bypass Switch", WM8991_OUTPUT_MIXER2,
501 SOC_DAPM_SINGLE("ROMIX Right ADC Bypass Switch", WM8991_OUTPUT_MIXER2,
503 SOC_DAPM_SINGLE("ROMIX LIN3 Bypass Switch", WM8991_OUTPUT_MIXER2,
505 SOC_DAPM_SINGLE("ROMIX RIN3 Bypass Switch", WM8991_OUTPUT_MIXER2,
507 SOC_DAPM_SINGLE("ROMIX LIN12 PGA Bypass Switch", WM8991_OUTPUT_MIXER2,
509 SOC_DAPM_SINGLE("ROMIX RIN12 PGA Bypass Switch", WM8991_OUTPUT_MIXER2,
527 SOC_DAPM_SINGLE("LOPMIX Right Mic Bypass Switch", WM8991_LINE_MIXER1,
529 SOC_DAPM_SINGLE("LOPMIX Left Mic Bypass Switch", WM8991_LINE_MIXER1,
547 SOC_DAPM_SINGLE("ROPMIX Left Mic Bypass Switch", WM8991_LINE_MIXER2,
549 SOC_DAPM_SINGLE("ROPMIX Right Mic Bypass Switch", WM8991_LINE_MIXER2,
557 SOC_DAPM_SINGLE("OUT3MIX LIN4RXN Bypass Switch", WM8991_OUT3_4_MIXER,
567 SOC_DAPM_SINGLE("OUT4MIX RIN4RXP Bypass Switch", WM8991_OUT3_4_MIXER,
573 SOC_DAPM_SINGLE("SPKMIX LIN2 Bypass Switch", WM8991_SPEAKER_MIXER,
575 SOC_DAPM_SINGLE("SPKMIX LADC Bypass Switch", WM8991_SPEAKER_MIXER,
585 SOC_DAPM_SINGLE("SPKMIX RADC Bypass Switch", WM8991_SPEAKER_MIXER,
587 SOC_DAPM_SINGLE("SPKMIX RIN2 Bypass Switch", WM8991_SPEAKER_MIXER,
792 {"LOMIX", "LOMIX RIN3 Bypass Switch", "RIN3"},
793 {"LOMIX", "LOMIX LIN3 Bypass Switch", "LIN3"},
794 {"LOMIX", "LOMIX LIN12 PGA Bypass Switch", "LIN12 PGA"},
795 {"LOMIX", "LOMIX RIN12 PGA Bypass Switch", "RIN12 PGA"},
796 {"LOMIX", "LOMIX Right ADC Bypass Switch", "AINRMUX"},
797 {"LOMIX", "LOMIX Left ADC Bypass Switch", "AINLMUX"},
801 {"ROMIX", "ROMIX RIN3 Bypass Switch", "RIN3"},
802 {"ROMIX", "ROMIX LIN3 Bypass Switch", "LIN3"},
803 {"ROMIX", "ROMIX LIN12 PGA Bypass Switch", "LIN12 PGA"},
804 {"ROMIX", "ROMIX RIN12 PGA Bypass Switch", "RIN12 PGA"},
805 {"ROMIX", "ROMIX Right ADC Bypass Switch", "AINRMUX"},
806 {"ROMIX", "ROMIX Left ADC Bypass Switch", "AINLMUX"},
810 {"SPKMIX", "SPKMIX LIN2 Bypass Switch", "LIN2"},
811 {"SPKMIX", "SPKMIX RIN2 Bypass Switch", "RIN2"},
812 {"SPKMIX", "SPKMIX LADC Bypass Switch", "AINLMUX"},
813 {"SPKMIX", "SPKMIX RADC Bypass Switch", "AINRMUX"},
825 {"LOPMIX", "LOPMIX Right Mic Bypass Switch", "RIN12 PGA"},
826 {"LOPMIX", "LOPMIX Left Mic Bypass Switch", "LIN12 PGA"},
830 {"OUT3MIX", "OUT3MIX LIN4RXN Bypass Switch", "LIN4RXN"},
835 {"OUT4MIX", "OUT4MIX RIN4RXP Bypass Switch", "RIN4RXP"},
843 {"ROPMIX", "ROPMIX Left Mic Bypass Switch", "LIN12 PGA"},
844 {"ROPMIX", "ROPMIX Right Mic Bypass Switch", "RIN12 PGA"},
887 pll_div->div2 = 1; in pll_factors()
890 pll_div->div2 = 0; in pll_factors()
896 pll_div->n = Ndiv; in pll_factors()
911 pll_div->k = K; in pll_factors()
918 struct snd_soc_component *component = codec_dai->component; in wm8991_set_dai_pll()
933 /* set up N , fractional mode and pre-divisor if necessary */ in wm8991_set_dai_pll()
953 struct snd_soc_component *component = codec_dai->component; in wm8991_set_dai_fmt()
968 return -EINVAL; in wm8991_set_dai_fmt()
995 return -EINVAL; in wm8991_set_dai_fmt()
1006 struct snd_soc_component *component = codec_dai->component; in wm8991_set_dai_clkdiv()
1031 return -EINVAL; in wm8991_set_dai_clkdiv()
1044 struct snd_soc_component *component = dai->component; in wm8991_hw_params()
1069 struct snd_soc_component *component = dai->component; in wm8991_mute()
1099 regcache_sync(wm8991->regmap); in wm8991_set_bias_level()
1100 /* Enable all output discharge bits */ in wm8991_set_bias_level()
1106 /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ in wm8991_set_bias_level()
1121 /* Enable outputs */ in wm8991_set_bias_level()
1126 /* Enable VMID at 2x50k */ in wm8991_set_bias_level()
1131 /* Enable VREF */ in wm8991_set_bias_level()
1136 /* Enable BUFIOEN */ in wm8991_set_bias_level()
1155 /* Enable POBCTRL and SOFT_ST */ in wm8991_set_bias_level()
1159 /* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ in wm8991_set_bias_level()
1168 /* Enable any disabled outputs */ in wm8991_set_bias_level()
1176 /* Enable all output discharge bits */ in wm8991_set_bias_level()
1187 regcache_mark_dirty(wm8991->regmap); in wm8991_set_bias_level()
1265 wm8991 = devm_kzalloc(&i2c->dev, sizeof(*wm8991), GFP_KERNEL); in wm8991_i2c_probe()
1267 return -ENOMEM; in wm8991_i2c_probe()
1269 wm8991->regmap = devm_regmap_init_i2c(i2c, &wm8991_regmap); in wm8991_i2c_probe()
1270 if (IS_ERR(wm8991->regmap)) in wm8991_i2c_probe()
1271 return PTR_ERR(wm8991->regmap); in wm8991_i2c_probe()
1275 ret = regmap_read(wm8991->regmap, WM8991_RESET, &val); in wm8991_i2c_probe()
1277 dev_err(&i2c->dev, "Failed to read device ID: %d\n", ret); in wm8991_i2c_probe()
1281 dev_err(&i2c->dev, "Device with ID %x is not a WM8991\n", val); in wm8991_i2c_probe()
1282 return -EINVAL; in wm8991_i2c_probe()
1285 ret = regmap_write(wm8991->regmap, WM8991_RESET, 0); in wm8991_i2c_probe()
1287 dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); in wm8991_i2c_probe()
1291 regmap_update_bits(wm8991->regmap, WM8991_AUDIO_INTERFACE_4, in wm8991_i2c_probe()
1294 regmap_update_bits(wm8991->regmap, WM8991_GPIO1_GPIO2, in wm8991_i2c_probe()
1297 regmap_update_bits(wm8991->regmap, WM8991_POWER_MANAGEMENT_1, in wm8991_i2c_probe()
1301 regmap_update_bits(wm8991->regmap, WM8991_POWER_MANAGEMENT_2, in wm8991_i2c_probe()
1304 regmap_write(wm8991->regmap, WM8991_DAC_CTRL, 0); in wm8991_i2c_probe()
1305 regmap_write(wm8991->regmap, WM8991_LEFT_OUTPUT_VOLUME, in wm8991_i2c_probe()
1307 regmap_write(wm8991->regmap, WM8991_RIGHT_OUTPUT_VOLUME, in wm8991_i2c_probe()
1310 ret = devm_snd_soc_register_component(&i2c->dev, in wm8991_i2c_probe()