Lines Matching +full:spk +full:- +full:shutdown

1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8985.c -- WM8985 / WM8758 ALSA SoC Audio driver
49 { 1, 0x0000 }, /* R1 - Power management 1 */
50 { 2, 0x0000 }, /* R2 - Power management 2 */
51 { 3, 0x0000 }, /* R3 - Power management 3 */
52 { 4, 0x0050 }, /* R4 - Audio Interface */
53 { 5, 0x0000 }, /* R5 - Companding control */
54 { 6, 0x0140 }, /* R6 - Clock Gen control */
55 { 7, 0x0000 }, /* R7 - Additional control */
56 { 8, 0x0000 }, /* R8 - GPIO Control */
57 { 9, 0x0000 }, /* R9 - Jack Detect Control 1 */
58 { 10, 0x0000 }, /* R10 - DAC Control */
59 { 11, 0x00FF }, /* R11 - Left DAC digital Vol */
60 { 12, 0x00FF }, /* R12 - Right DAC digital vol */
61 { 13, 0x0000 }, /* R13 - Jack Detect Control 2 */
62 { 14, 0x0100 }, /* R14 - ADC Control */
63 { 15, 0x00FF }, /* R15 - Left ADC Digital Vol */
64 { 16, 0x00FF }, /* R16 - Right ADC Digital Vol */
65 { 18, 0x012C }, /* R18 - EQ1 - low shelf */
66 { 19, 0x002C }, /* R19 - EQ2 - peak 1 */
67 { 20, 0x002C }, /* R20 - EQ3 - peak 2 */
68 { 21, 0x002C }, /* R21 - EQ4 - peak 3 */
69 { 22, 0x002C }, /* R22 - EQ5 - high shelf */
70 { 24, 0x0032 }, /* R24 - DAC Limiter 1 */
71 { 25, 0x0000 }, /* R25 - DAC Limiter 2 */
72 { 27, 0x0000 }, /* R27 - Notch Filter 1 */
73 { 28, 0x0000 }, /* R28 - Notch Filter 2 */
74 { 29, 0x0000 }, /* R29 - Notch Filter 3 */
75 { 30, 0x0000 }, /* R30 - Notch Filter 4 */
76 { 32, 0x0038 }, /* R32 - ALC control 1 */
77 { 33, 0x000B }, /* R33 - ALC control 2 */
78 { 34, 0x0032 }, /* R34 - ALC control 3 */
79 { 35, 0x0000 }, /* R35 - Noise Gate */
80 { 36, 0x0008 }, /* R36 - PLL N */
81 { 37, 0x000C }, /* R37 - PLL K 1 */
82 { 38, 0x0093 }, /* R38 - PLL K 2 */
83 { 39, 0x00E9 }, /* R39 - PLL K 3 */
84 { 41, 0x0000 }, /* R41 - 3D control */
85 { 42, 0x0000 }, /* R42 - OUT4 to ADC */
86 { 43, 0x0000 }, /* R43 - Beep control */
87 { 44, 0x0033 }, /* R44 - Input ctrl */
88 { 45, 0x0010 }, /* R45 - Left INP PGA gain ctrl */
89 { 46, 0x0010 }, /* R46 - Right INP PGA gain ctrl */
90 { 47, 0x0100 }, /* R47 - Left ADC BOOST ctrl */
91 { 48, 0x0100 }, /* R48 - Right ADC BOOST ctrl */
92 { 49, 0x0002 }, /* R49 - Output ctrl */
93 { 50, 0x0001 }, /* R50 - Left mixer ctrl */
94 { 51, 0x0001 }, /* R51 - Right mixer ctrl */
95 { 52, 0x0039 }, /* R52 - LOUT1 (HP) volume ctrl */
96 { 53, 0x0039 }, /* R53 - ROUT1 (HP) volume ctrl */
97 { 54, 0x0039 }, /* R54 - LOUT2 (SPK) volume ctrl */
98 { 55, 0x0039 }, /* R55 - ROUT2 (SPK) volume ctrl */
99 { 56, 0x0001 }, /* R56 - OUT3 mixer ctrl */
100 { 57, 0x0001 }, /* R57 - OUT4 (MONO) mix ctrl */
101 { 60, 0x0004 }, /* R60 - OUTPUT ctrl */
102 { 61, 0x0000 }, /* R61 - BIAS CTRL */
219 static const DECLARE_TLV_DB_SCALE(dac_tlv, -12700, 50, 1);
220 static const DECLARE_TLV_DB_SCALE(adc_tlv, -12700, 50, 1);
221 static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0);
222 static const DECLARE_TLV_DB_SCALE(lim_thresh_tlv, -600, 100, 0);
224 static const DECLARE_TLV_DB_SCALE(alc_min_tlv, -1200, 600, 0);
225 static const DECLARE_TLV_DB_SCALE(alc_max_tlv, -675, 600, 0);
226 static const DECLARE_TLV_DB_SCALE(alc_tar_tlv, -2250, 150, 0);
227 static const DECLARE_TLV_DB_SCALE(pga_vol_tlv, -1200, 75, 0);
228 static const DECLARE_TLV_DB_SCALE(boost_tlv, -1200, 300, 1);
229 static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
230 static const DECLARE_TLV_DB_SCALE(aux_tlv, -1500, 300, 0);
231 static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
398 /* --- WM8985 only --- */
406 /* --- WM8985 only --- */
426 /* --- WM8985 only --- */
435 /* --- WM8985 only --- */
503 ARRAY_SIZE(left_out_mixer) - 1),
506 ARRAY_SIZE(right_out_mixer) - 1),
510 ARRAY_SIZE(left_boost_mixer) - 1),
513 ARRAY_SIZE(right_boost_mixer) - 1),
569 switch (wm8985->dev_type) { in wm8985_add_widgets()
597 ucontrol->value.enumerated.item[0] = 1; in eqmode_get()
599 ucontrol->value.enumerated.item[0] = 0; in eqmode_get()
611 if (ucontrol->value.enumerated.item[0] != 0 in eqmode_put()
612 && ucontrol->value.enumerated.item[0] != 1) in eqmode_put()
613 return -EINVAL; in eqmode_put()
618 if (!ucontrol->value.enumerated.item[0]) in eqmode_put()
622 if (ucontrol->value.enumerated.item[0]) in eqmode_put()
639 ucontrol->value.enumerated.item[0] in eqmode_put()
654 struct snd_soc_component *component = dai->component; in wm8985_dac_mute()
666 component = dai->component; in wm8985_set_fmt()
683 dev_err(dai->dev, "Unknown dai format\n"); in wm8985_set_fmt()
684 return -EINVAL; in wm8985_set_fmt()
698 dev_err(dai->dev, "Unknown master/slave configuration\n"); in wm8985_set_fmt()
699 return -EINVAL; in wm8985_set_fmt()
712 return -EINVAL; in wm8985_set_fmt()
735 dev_err(dai->dev, "Unknown polarity configuration\n"); in wm8985_set_fmt()
736 return -EINVAL; in wm8985_set_fmt()
757 component = dai->component; in wm8985_hw_params()
760 wm8985->bclk = snd_soc_params_to_bclk(params); in wm8985_hw_params()
761 if ((int)wm8985->bclk < 0) in wm8985_hw_params()
762 return wm8985->bclk; in wm8985_hw_params()
778 dev_err(dai->dev, "Unsupported word length %u\n", in wm8985_hw_params()
780 return -EINVAL; in wm8985_hw_params()
791 srate_best = abs(srates[0] - params_rate(params)); in wm8985_hw_params()
793 if (abs(srates[i] - params_rate(params)) >= srate_best) in wm8985_hw_params()
796 srate_best = abs(srates[i] - params_rate(params)); in wm8985_hw_params()
799 dev_dbg(dai->dev, "Selected SRATE = %d\n", srates[srate_idx]); in wm8985_hw_params()
803 dev_dbg(dai->dev, "Target BCLK = %uHz\n", wm8985->bclk); in wm8985_hw_params()
804 dev_dbg(dai->dev, "SYSCLK = %uHz\n", wm8985->sysclk); in wm8985_hw_params()
807 if (wm8985->sysclk / params_rate(params) in wm8985_hw_params()
813 dev_err(dai->dev, "Unable to configure MCLK ratio %u/%u\n", in wm8985_hw_params()
814 wm8985->sysclk, params_rate(params)); in wm8985_hw_params()
815 return -EINVAL; in wm8985_hw_params()
818 dev_dbg(dai->dev, "MCLK ratio = %dfs\n", fs_ratios[i].ratio); in wm8985_hw_params()
823 tmp = (wm8985->sysclk / fs_ratios[i].div) * 10; in wm8985_hw_params()
825 if (wm8985->bclk == tmp / bclk_divs[i]) in wm8985_hw_params()
830 dev_err(dai->dev, "No matching BCLK divider found\n"); in wm8985_hw_params()
831 return -EINVAL; in wm8985_hw_params()
834 dev_dbg(dai->dev, "BCLK div = %d\n", i); in wm8985_hw_params()
853 pll_div->div2 = 0; in pll_factors()
857 pll_div->div2 = 1; in pll_factors()
864 return -EINVAL; in pll_factors()
866 pll_div->n = Ndiv; in pll_factors()
877 pll_div->k = K; in pll_factors()
890 component = dai->component; in wm8985_set_pll()
924 component = dai->component; in wm8985_set_sysclk()
939 dev_err(dai->dev, "Unknown clock source %d\n", clk_id); in wm8985_set_sysclk()
940 return -EINVAL; in wm8985_set_sysclk()
943 wm8985->sysclk = freq; in wm8985_set_sysclk()
964 ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies), in wm8985_set_bias_level()
965 wm8985->supplies); in wm8985_set_bias_level()
967 dev_err(component->dev, in wm8985_set_bias_level()
973 regcache_sync(wm8985->regmap); in wm8985_set_bias_level()
975 /* enable anti-pop features */ in wm8985_set_bias_level()
979 /* enable thermal shutdown */ in wm8985_set_bias_level()
993 /* disable anti-pop features */ in wm8985_set_bias_level()
1003 /* disable thermal shutdown */ in wm8985_set_bias_level()
1016 regcache_mark_dirty(wm8985->regmap); in wm8985_set_bias_level()
1018 regulator_bulk_disable(ARRAY_SIZE(wm8985->supplies), in wm8985_set_bias_level()
1019 wm8985->supplies); in wm8985_set_bias_level()
1034 for (i = 0; i < ARRAY_SIZE(wm8985->supplies); i++) in wm8985_probe()
1035 wm8985->supplies[i].supply = wm8985_supply_names[i]; in wm8985_probe()
1037 ret = devm_regulator_bulk_get(component->dev, ARRAY_SIZE(wm8985->supplies), in wm8985_probe()
1038 wm8985->supplies); in wm8985_probe()
1040 dev_err(component->dev, "Failed to request supplies: %d\n", ret); in wm8985_probe()
1044 ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies), in wm8985_probe()
1045 wm8985->supplies); in wm8985_probe()
1047 dev_err(component->dev, "Failed to enable supplies: %d\n", ret); in wm8985_probe()
1053 dev_err(component->dev, "Failed to issue reset: %d\n", ret); in wm8985_probe()
1070 regulator_bulk_disable(ARRAY_SIZE(wm8985->supplies), wm8985->supplies); in wm8985_probe()
1087 .name = "wm8985-hifi",
1139 wm8985 = devm_kzalloc(&spi->dev, sizeof *wm8985, GFP_KERNEL); in wm8985_spi_probe()
1141 return -ENOMEM; in wm8985_spi_probe()
1145 wm8985->dev_type = WM8985; in wm8985_spi_probe()
1147 wm8985->regmap = devm_regmap_init_spi(spi, &wm8985_regmap); in wm8985_spi_probe()
1148 if (IS_ERR(wm8985->regmap)) { in wm8985_spi_probe()
1149 ret = PTR_ERR(wm8985->regmap); in wm8985_spi_probe()
1150 dev_err(&spi->dev, "Failed to allocate register map: %d\n", in wm8985_spi_probe()
1155 ret = devm_snd_soc_register_component(&spi->dev, in wm8985_spi_probe()
1177 wm8985 = devm_kzalloc(&i2c->dev, sizeof *wm8985, GFP_KERNEL); in wm8985_i2c_probe()
1179 return -ENOMEM; in wm8985_i2c_probe()
1183 wm8985->dev_type = id->driver_data; in wm8985_i2c_probe()
1185 wm8985->regmap = devm_regmap_init_i2c(i2c, &wm8985_regmap); in wm8985_i2c_probe()
1186 if (IS_ERR(wm8985->regmap)) { in wm8985_i2c_probe()
1187 ret = PTR_ERR(wm8985->regmap); in wm8985_i2c_probe()
1188 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in wm8985_i2c_probe()
1193 ret = devm_snd_soc_register_component(&i2c->dev, in wm8985_i2c_probe()