Lines Matching +full:ch3 +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system
35 #include <sound/soc-dapm.h>
55 /* Power-up register defaults */
57 { 0x0, 0x63 },
58 { 0x1, 0x80 },
59 { 0x2, 0xdf },
60 { 0x3, 0x40 },
61 { 0x4, 0xc2 },
62 { 0x5, 0x5c },
63 { 0x6, 0x00 },
64 { 0x7, 0xff },
65 { 0x8, 0x60 },
66 { 0x9, 0x60 },
67 { 0xa, 0x60 },
68 { 0xb, 0x00 },
69 { 0xc, 0x00 },
70 { 0xd, 0x00 },
71 { 0xe, 0x00 },
72 { 0xf, 0x40 },
73 { 0x10, 0x80 },
74 { 0x11, 0x77 },
75 { 0x12, 0x6a },
76 { 0x13, 0x69 },
77 { 0x14, 0x6a },
78 { 0x15, 0x69 },
79 { 0x16, 0x00 },
80 { 0x17, 0x00 },
81 { 0x18, 0x00 },
82 { 0x19, 0x00 },
83 { 0x1a, 0x00 },
84 { 0x1b, 0x00 },
85 { 0x1c, 0x00 },
86 { 0x1d, 0x00 },
87 { 0x1e, 0x00 },
88 { 0x1f, 0x00 },
89 { 0x20, 0x00 },
90 { 0x21, 0x00 },
91 { 0x22, 0x00 },
92 { 0x23, 0x00 },
93 { 0x24, 0x00 },
94 { 0x25, 0x00 },
95 { 0x26, 0x00 },
96 { 0x27, 0x2a },
97 { 0x28, 0xc0 },
98 { 0x29, 0xf3 },
99 { 0x2a, 0x33 },
100 { 0x2b, 0x00 },
101 { 0x2c, 0x0c },
102 { 0x31, 0x00 },
103 { 0x36, 0x00 },
104 { 0x37, 0x00 },
105 { 0x38, 0x00 },
106 { 0x39, 0x01 },
107 { 0x3a, 0xee },
108 { 0x3b, 0xff },
109 { 0x3c, 0x7e },
110 { 0x3d, 0xc0 },
111 { 0x3e, 0x26 },
112 { 0x3f, 0x00 },
113 { 0x48, 0x00 },
114 { 0x49, 0x00 },
115 { 0x4a, 0x00 },
116 { 0x4b, 0x04 },
117 { 0x4c, 0x00 },
156 "vdd-dig", /* digital supply, 3.3V */
157 "vdd-pll", /* pll supply, 3.3V */
158 "vcc" /* power amp supply, 5V - 26V */
179 static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12750, 50, 1);
180 static const DECLARE_TLV_DB_SCALE(chvol_tlv, -7950, 50, 1);
181 static const DECLARE_TLV_DB_SCALE(tone_tlv, -1200, 200, 0);
184 "Anti-Clipping", "Dynamic Range Compression"
196 "FFX 3-state output - normal operation", "Binary output"
216 0, 7, TLV_DB_SCALE_ITEM(-1200, 200, 0),
217 8, 16, TLV_DB_SCALE_ITEM(300, 100, 0),
221 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
222 1, 1, TLV_DB_SCALE_ITEM(-2900, 0, 0),
223 2, 2, TLV_DB_SCALE_ITEM(-2000, 0, 0),
224 3, 8, TLV_DB_SCALE_ITEM(-1400, 200, 0),
225 8, 16, TLV_DB_SCALE_ITEM(-700, 100, 0),
229 0, 7, TLV_DB_SCALE_ITEM(-3100, 200, 0),
230 8, 13, TLV_DB_SCALE_ITEM(-1600, 100, 0),
231 14, 16, TLV_DB_SCALE_ITEM(-1000, 300, 0),
235 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
236 1, 2, TLV_DB_SCALE_ITEM(-3800, 200, 0),
237 3, 4, TLV_DB_SCALE_ITEM(-3300, 200, 0),
238 5, 12, TLV_DB_SCALE_ITEM(-3000, 200, 0),
239 13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0),
296 int numcoef = kcontrol->private_value >> 16; in sta350_coefficient_info()
297 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in sta350_coefficient_info()
298 uinfo->count = 3 * numcoef; in sta350_coefficient_info()
299 return 0; in sta350_coefficient_info()
307 int numcoef = kcontrol->private_value >> 16; in sta350_coefficient_get()
308 int index = kcontrol->private_value & 0xffff; in sta350_coefficient_get()
310 int i, ret = 0; in sta350_coefficient_get()
312 mutex_lock(&sta350->coeff_lock); in sta350_coefficient_get()
315 regmap_read(sta350->regmap, STA350_CFUD, &cfud); in sta350_coefficient_get()
316 cfud &= 0xf0; in sta350_coefficient_get()
321 regmap_write(sta350->regmap, STA350_CFUD, cfud); in sta350_coefficient_get()
323 regmap_write(sta350->regmap, STA350_CFADDR2, index); in sta350_coefficient_get()
325 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x04); in sta350_coefficient_get()
327 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x08); in sta350_coefficient_get()
329 ret = -EINVAL; in sta350_coefficient_get()
333 for (i = 0; i < 3 * numcoef; i++) { in sta350_coefficient_get()
334 regmap_read(sta350->regmap, STA350_B1CF1 + i, &val); in sta350_coefficient_get()
335 ucontrol->value.bytes.data[i] = val; in sta350_coefficient_get()
339 mutex_unlock(&sta350->coeff_lock); in sta350_coefficient_get()
349 int numcoef = kcontrol->private_value >> 16; in sta350_coefficient_put()
350 int index = kcontrol->private_value & 0xffff; in sta350_coefficient_put()
355 regmap_read(sta350->regmap, STA350_CFUD, &cfud); in sta350_coefficient_put()
356 cfud &= 0xf0; in sta350_coefficient_put()
361 regmap_write(sta350->regmap, STA350_CFUD, cfud); in sta350_coefficient_put()
363 regmap_write(sta350->regmap, STA350_CFADDR2, index); in sta350_coefficient_put()
364 for (i = 0; i < numcoef && (index + i < STA350_COEF_COUNT); i++) in sta350_coefficient_put()
365 sta350->coef_shadow[index + i] = in sta350_coefficient_put()
366 (ucontrol->value.bytes.data[3 * i] << 16) in sta350_coefficient_put()
367 | (ucontrol->value.bytes.data[3 * i + 1] << 8) in sta350_coefficient_put()
368 | (ucontrol->value.bytes.data[3 * i + 2]); in sta350_coefficient_put()
369 for (i = 0; i < 3 * numcoef; i++) in sta350_coefficient_put()
370 regmap_write(sta350->regmap, STA350_B1CF1 + i, in sta350_coefficient_put()
371 ucontrol->value.bytes.data[i]); in sta350_coefficient_put()
373 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01); in sta350_coefficient_put()
375 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x02); in sta350_coefficient_put()
377 return -EINVAL; in sta350_coefficient_put()
379 return 0; in sta350_coefficient_put()
389 regmap_read(sta350->regmap, STA350_CFUD, &cfud); in sta350_sync_coef_shadow()
390 cfud &= 0xf0; in sta350_sync_coef_shadow()
392 for (i = 0; i < STA350_COEF_COUNT; i++) { in sta350_sync_coef_shadow()
393 regmap_write(sta350->regmap, STA350_CFADDR2, i); in sta350_sync_coef_shadow()
394 regmap_write(sta350->regmap, STA350_B1CF1, in sta350_sync_coef_shadow()
395 (sta350->coef_shadow[i] >> 16) & 0xff); in sta350_sync_coef_shadow()
396 regmap_write(sta350->regmap, STA350_B1CF2, in sta350_sync_coef_shadow()
397 (sta350->coef_shadow[i] >> 8) & 0xff); in sta350_sync_coef_shadow()
398 regmap_write(sta350->regmap, STA350_B1CF3, in sta350_sync_coef_shadow()
399 (sta350->coef_shadow[i]) & 0xff); in sta350_sync_coef_shadow()
402 * self-clearing, so do it explicitly in sta350_sync_coef_shadow()
404 regmap_write(sta350->regmap, STA350_CFUD, cfud); in sta350_sync_coef_shadow()
405 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01); in sta350_sync_coef_shadow()
407 return 0; in sta350_sync_coef_shadow()
417 regmap_read(sta350->regmap, STA350_CFUD, &mute); in sta350_cache_sync()
418 regmap_write(sta350->regmap, STA350_MMUTE, mute | STA350_MMUTE_MMUTE); in sta350_cache_sync()
420 rc = regcache_sync(sta350->regmap); in sta350_cache_sync()
421 regmap_write(sta350->regmap, STA350_MMUTE, mute); in sta350_cache_sync()
440 SOC_SINGLE_TLV("Master Volume", STA350_MVOL, 0, 0xff, 1, mvol_tlv),
442 SOC_SINGLE_TLV("Ch1 Volume", STA350_C1VOL, 0, 0xff, 1, chvol_tlv),
443 SOC_SINGLE_TLV("Ch2 Volume", STA350_C2VOL, 0, 0xff, 1, chvol_tlv),
444 SOC_SINGLE_TLV("Ch3 Volume", STA350_C3VOL, 0, 0xff, 1, chvol_tlv),
448 SOC_SINGLE("De-emphasis Filter Switch",
449 STA350_CONFD, STA350_CONFD_DEMP_SHIFT, 1, 0),
451 STA350_CONFD, STA350_CONFD_DSPB_SHIFT, 1, 0),
452 SOC_SINGLE("Post-scale Link Switch",
453 STA350_CONFD, STA350_CONFD_PSL_SHIFT, 1, 0),
455 STA350_CONFD, STA350_CONFD_BQL_SHIFT, 1, 0),
458 SOC_SINGLE("Zero-detect Mute Enable Switch",
459 STA350_CONFD, STA350_CONFD_ZDE_SHIFT, 1, 0),
461 STA350_CONFD, STA350_CONFD_SME_SHIFT, 1, 0),
463 SOC_SINGLE("Zero Cross Switch", STA350_CONFE, STA350_CONFE_ZCE_SHIFT, 1, 0),
464 SOC_SINGLE("Soft Ramp Switch", STA350_CONFE, STA350_CONFE_SVE_SHIFT, 1, 0),
469 SOC_SINGLE("Ch3 Switch", STA350_MMUTE, STA350_MMUTE_C3M_SHIFT, 1, 1),
475 STA350_C1CFG, STA350_CxCFG_TCB_SHIFT, 1, 0),
477 STA350_C2CFG, STA350_CxCFG_TCB_SHIFT, 1, 0),
479 STA350_C1CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0),
481 STA350_C2CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0),
483 STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
485 STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
486 SOC_SINGLE("Ch3 Master Volume Bypass Switch",
487 STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
490 SOC_ENUM("Ch3 Binary Output Select", sta350_binary_output_ch3_enum),
493 SOC_ENUM("Ch3 Limiter Select", sta350_limiter_ch3_enum),
496 STA350_TONE, STA350_TONE_BTC_SHIFT, 1, 13, 0, tone_tlv),
498 STA350_TONE, STA350_TONE_TTC_SHIFT, 1, 13, 0, tone_tlv),
510 16, 0, sta350_limiter_ac_attack_tlv),
513 16, 0, sta350_limiter_ac_attack_tlv),
516 16, 0, sta350_limiter_ac_release_tlv),
519 16, 0, sta350_limiter_ac_release_tlv),
522 16, 0, sta350_limiter_drc_attack_tlv),
525 16, 0, sta350_limiter_drc_attack_tlv),
528 16, 0, sta350_limiter_drc_release_tlv),
531 16, 0, sta350_limiter_drc_release_tlv),
533 BIQUAD_COEFS("Ch1 - Biquad 1", 0),
534 BIQUAD_COEFS("Ch1 - Biquad 2", 5),
535 BIQUAD_COEFS("Ch1 - Biquad 3", 10),
536 BIQUAD_COEFS("Ch1 - Biquad 4", 15),
537 BIQUAD_COEFS("Ch2 - Biquad 1", 20),
538 BIQUAD_COEFS("Ch2 - Biquad 2", 25),
539 BIQUAD_COEFS("Ch2 - Biquad 3", 30),
540 BIQUAD_COEFS("Ch2 - Biquad 4", 35),
541 BIQUAD_COEFS("High-pass", 40),
542 BIQUAD_COEFS("Low-pass", 45),
543 SINGLE_COEF("Ch1 - Prescale", 50),
544 SINGLE_COEF("Ch2 - Prescale", 51),
545 SINGLE_COEF("Ch1 - Postscale", 52),
546 SINGLE_COEF("Ch2 - Postscale", 53),
547 SINGLE_COEF("Ch3 - Postscale", 54),
548 SINGLE_COEF("Thermal warning - Postscale", 55),
549 SINGLE_COEF("Ch1 - Mix 1", 56),
550 SINGLE_COEF("Ch1 - Mix 2", 57),
551 SINGLE_COEF("Ch2 - Mix 1", 58),
552 SINGLE_COEF("Ch2 - Mix 2", 59),
553 SINGLE_COEF("Ch3 - Mix 1", 60),
554 SINGLE_COEF("Ch3 - Mix 2", 61),
558 SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0),
576 { 32000, 0 },
577 { 44100, 0 },
578 { 48000, 0 },
588 { 384, 256, 192, 128, 64, 0 },
589 { 192, 128, 96, 64, 32, 0 },
593 * sta350_set_dai_sysclk - configure MCLK
609 struct snd_soc_component *component = codec_dai->component; in sta350_set_dai_sysclk()
612 dev_dbg(component->dev, "mclk=%u\n", freq); in sta350_set_dai_sysclk()
613 sta350->mclk = freq; in sta350_set_dai_sysclk()
615 return 0; in sta350_set_dai_sysclk()
619 * sta350_set_dai_fmt - configure the codec for the selected audio format
629 struct snd_soc_component *component = codec_dai->component; in sta350_set_dai_fmt()
631 unsigned int confb = 0; in sta350_set_dai_fmt()
637 return -EINVAL; in sta350_set_dai_fmt()
644 sta350->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in sta350_set_dai_fmt()
647 return -EINVAL; in sta350_set_dai_fmt()
658 return -EINVAL; in sta350_set_dai_fmt()
661 return regmap_update_bits(sta350->regmap, STA350_CONFB, in sta350_set_dai_fmt()
666 * sta350_hw_params - program the STA350 with the given hardware parameters.
678 struct snd_soc_component *component = dai->component; in sta350_hw_params()
680 int i, mcs = -EINVAL, ir = -EINVAL; in sta350_hw_params()
685 if (!sta350->mclk) { in sta350_hw_params()
686 dev_err(component->dev, in sta350_hw_params()
687 "sta350->mclk is unset. Unable to determine ratio\n"); in sta350_hw_params()
688 return -EIO; in sta350_hw_params()
692 ratio = sta350->mclk / rate; in sta350_hw_params()
693 dev_dbg(component->dev, "rate: %u, ratio: %u\n", rate, ratio); in sta350_hw_params()
695 for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) { in sta350_hw_params()
702 if (ir < 0) { in sta350_hw_params()
703 dev_err(component->dev, "Unsupported samplerate: %u\n", rate); in sta350_hw_params()
704 return -EINVAL; in sta350_hw_params()
707 for (i = 0; i < 6; i++) { in sta350_hw_params()
714 if (mcs < 0) { in sta350_hw_params()
715 dev_err(component->dev, "Unresolvable ratio: %u\n", ratio); in sta350_hw_params()
716 return -EINVAL; in sta350_hw_params()
721 confb = 0; in sta350_hw_params()
725 dev_dbg(component->dev, "24bit\n"); in sta350_hw_params()
728 dev_dbg(component->dev, "24bit or 32bit\n"); in sta350_hw_params()
729 switch (sta350->format) { in sta350_hw_params()
731 confb |= 0x0; in sta350_hw_params()
734 confb |= 0x1; in sta350_hw_params()
737 confb |= 0x2; in sta350_hw_params()
743 dev_dbg(component->dev, "20bit\n"); in sta350_hw_params()
744 switch (sta350->format) { in sta350_hw_params()
746 confb |= 0x4; in sta350_hw_params()
749 confb |= 0x5; in sta350_hw_params()
752 confb |= 0x6; in sta350_hw_params()
758 dev_dbg(component->dev, "18bit\n"); in sta350_hw_params()
759 switch (sta350->format) { in sta350_hw_params()
761 confb |= 0x8; in sta350_hw_params()
764 confb |= 0x9; in sta350_hw_params()
767 confb |= 0xa; in sta350_hw_params()
773 dev_dbg(component->dev, "16bit\n"); in sta350_hw_params()
774 switch (sta350->format) { in sta350_hw_params()
776 confb |= 0x0; in sta350_hw_params()
779 confb |= 0xd; in sta350_hw_params()
782 confb |= 0xe; in sta350_hw_params()
788 return -EINVAL; in sta350_hw_params()
791 ret = regmap_update_bits(sta350->regmap, STA350_CONFA, in sta350_hw_params()
794 if (ret < 0) in sta350_hw_params()
797 ret = regmap_update_bits(sta350->regmap, STA350_CONFB, in sta350_hw_params()
800 if (ret < 0) in sta350_hw_params()
803 return 0; in sta350_hw_params()
808 if (sta350->gpiod_power_down) in sta350_startup_sequence()
809 gpiod_set_value(sta350->gpiod_power_down, 1); in sta350_startup_sequence()
811 if (sta350->gpiod_nreset) { in sta350_startup_sequence()
812 gpiod_set_value(sta350->gpiod_nreset, 0); in sta350_startup_sequence()
814 gpiod_set_value(sta350->gpiod_nreset, 1); in sta350_startup_sequence()
818 return 0; in sta350_startup_sequence()
822 * sta350_set_bias_level - DAPM callback
836 dev_dbg(component->dev, "level = %d\n", level); in sta350_set_bias_level()
843 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_set_bias_level()
851 ARRAY_SIZE(sta350->supplies), in sta350_set_bias_level()
852 sta350->supplies); in sta350_set_bias_level()
853 if (ret < 0) { in sta350_set_bias_level()
854 dev_err(component->dev, in sta350_set_bias_level()
864 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_set_bias_level()
866 0); in sta350_set_bias_level()
872 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_set_bias_level()
873 STA350_CONFF_PWDN | STA350_CONFF_EAPD, 0); in sta350_set_bias_level()
876 if (sta350->gpiod_power_down) in sta350_set_bias_level()
877 gpiod_set_value(sta350->gpiod_power_down, 0); in sta350_set_bias_level()
879 if (sta350->gpiod_nreset) in sta350_set_bias_level()
880 gpiod_set_value(sta350->gpiod_nreset, 0); in sta350_set_bias_level()
882 regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), in sta350_set_bias_level()
883 sta350->supplies); in sta350_set_bias_level()
886 return 0; in sta350_set_bias_level()
896 .name = "sta350-hifi",
910 struct sta350_platform_data *pdata = sta350->pdata; in sta350_probe()
911 int i, ret = 0, thermal = 0; in sta350_probe()
913 ret = regulator_bulk_enable(ARRAY_SIZE(sta350->supplies), in sta350_probe()
914 sta350->supplies); in sta350_probe()
915 if (ret < 0) { in sta350_probe()
916 dev_err(component->dev, "Failed to enable supplies: %d\n", ret); in sta350_probe()
921 if (ret < 0) { in sta350_probe()
922 dev_err(component->dev, "Failed to startup device\n"); in sta350_probe()
927 if (!pdata->thermal_warning_recovery) in sta350_probe()
929 if (!pdata->thermal_warning_adjustment) in sta350_probe()
931 if (!pdata->fault_detect_recovery) in sta350_probe()
933 regmap_update_bits(sta350->regmap, STA350_CONFA, in sta350_probe()
939 regmap_update_bits(sta350->regmap, STA350_CONFC, in sta350_probe()
941 pdata->ffx_power_output_mode in sta350_probe()
943 regmap_update_bits(sta350->regmap, STA350_CONFC, in sta350_probe()
945 pdata->drop_compensation_ns in sta350_probe()
947 regmap_update_bits(sta350->regmap, in sta350_probe()
950 pdata->oc_warning_adjustment ? in sta350_probe()
951 STA350_CONFC_OCRB : 0); in sta350_probe()
954 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
956 pdata->max_power_use_mpcc ? in sta350_probe()
957 STA350_CONFE_MPCV : 0); in sta350_probe()
958 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
960 pdata->max_power_correction ? in sta350_probe()
961 STA350_CONFE_MPC : 0); in sta350_probe()
962 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
964 pdata->am_reduction_mode ? in sta350_probe()
965 STA350_CONFE_AME : 0); in sta350_probe()
966 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
968 pdata->odd_pwm_speed_mode ? in sta350_probe()
969 STA350_CONFE_PWMS : 0); in sta350_probe()
970 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
972 pdata->distortion_compensation ? in sta350_probe()
973 STA350_CONFE_DCCV : 0); in sta350_probe()
975 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_probe()
977 pdata->invalid_input_detect_mute ? in sta350_probe()
978 STA350_CONFF_IDE : 0); in sta350_probe()
979 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_probe()
981 pdata->output_conf in sta350_probe()
985 regmap_update_bits(sta350->regmap, STA350_C1CFG, in sta350_probe()
987 pdata->ch1_output_mapping in sta350_probe()
989 regmap_update_bits(sta350->regmap, STA350_C2CFG, in sta350_probe()
991 pdata->ch2_output_mapping in sta350_probe()
993 regmap_update_bits(sta350->regmap, STA350_C3CFG, in sta350_probe()
995 pdata->ch3_output_mapping in sta350_probe()
999 regmap_update_bits(sta350->regmap, STA350_MISC1, in sta350_probe()
1001 pdata->activate_mute_output ? in sta350_probe()
1002 STA350_MISC1_CPWMEN : 0); in sta350_probe()
1003 regmap_update_bits(sta350->regmap, STA350_MISC1, in sta350_probe()
1005 pdata->bridge_immediate_off ? in sta350_probe()
1006 STA350_MISC1_BRIDGOFF : 0); in sta350_probe()
1007 regmap_update_bits(sta350->regmap, STA350_MISC1, in sta350_probe()
1009 pdata->noise_shape_dc_cut ? in sta350_probe()
1010 STA350_MISC1_NSHHPEN : 0); in sta350_probe()
1011 regmap_update_bits(sta350->regmap, STA350_MISC1, in sta350_probe()
1013 pdata->powerdown_master_vol ? in sta350_probe()
1014 STA350_MISC1_RPDNEN: 0); in sta350_probe()
1016 regmap_update_bits(sta350->regmap, STA350_MISC2, in sta350_probe()
1018 pdata->powerdown_delay_divider in sta350_probe()
1023 sta350->coef_shadow[i] = 0x400000; in sta350_probe()
1025 sta350->coef_shadow[i] = 0x7fffff; in sta350_probe()
1026 sta350->coef_shadow[55] = 0x5a9df7; in sta350_probe()
1027 sta350->coef_shadow[56] = 0x7fffff; in sta350_probe()
1028 sta350->coef_shadow[59] = 0x7fffff; in sta350_probe()
1029 sta350->coef_shadow[60] = 0x400000; in sta350_probe()
1030 sta350->coef_shadow[61] = 0x400000; in sta350_probe()
1034 regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); in sta350_probe()
1036 return 0; in sta350_probe()
1043 regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); in sta350_remove()
1082 [STA350_FFX_PM_DROP_COMP] = "drop-compensation",
1083 [STA350_FFX_PM_TAPERED_COMP] = "tapered-compensation",
1084 [STA350_FFX_PM_FULL_POWER] = "full-power-mode",
1085 [STA350_FFX_PM_VARIABLE_DROP_COMP] = "variable-drop-compensation",
1090 struct device_node *np = dev->of_node; in sta350_probe_dt()
1098 return -ENOMEM; in sta350_probe_dt()
1100 of_property_read_u8(np, "st,output-conf", in sta350_probe_dt()
1101 &pdata->output_conf); in sta350_probe_dt()
1102 of_property_read_u8(np, "st,ch1-output-mapping", in sta350_probe_dt()
1103 &pdata->ch1_output_mapping); in sta350_probe_dt()
1104 of_property_read_u8(np, "st,ch2-output-mapping", in sta350_probe_dt()
1105 &pdata->ch2_output_mapping); in sta350_probe_dt()
1106 of_property_read_u8(np, "st,ch3-output-mapping", in sta350_probe_dt()
1107 &pdata->ch3_output_mapping); in sta350_probe_dt()
1109 if (of_get_property(np, "st,thermal-warning-recovery", NULL)) in sta350_probe_dt()
1110 pdata->thermal_warning_recovery = 1; in sta350_probe_dt()
1111 if (of_get_property(np, "st,thermal-warning-adjustment", NULL)) in sta350_probe_dt()
1112 pdata->thermal_warning_adjustment = 1; in sta350_probe_dt()
1113 if (of_get_property(np, "st,fault-detect-recovery", NULL)) in sta350_probe_dt()
1114 pdata->fault_detect_recovery = 1; in sta350_probe_dt()
1116 pdata->ffx_power_output_mode = STA350_FFX_PM_VARIABLE_DROP_COMP; in sta350_probe_dt()
1117 if (!of_property_read_string(np, "st,ffx-power-output-mode", in sta350_probe_dt()
1119 int i, mode = -EINVAL; in sta350_probe_dt()
1121 for (i = 0; i < ARRAY_SIZE(sta350_ffx_modes); i++) in sta350_probe_dt()
1125 if (mode < 0) in sta350_probe_dt()
1129 pdata->ffx_power_output_mode = mode; in sta350_probe_dt()
1133 of_property_read_u16(np, "st,drop-compensation-ns", &tmp); in sta350_probe_dt()
1134 pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20; in sta350_probe_dt()
1136 if (of_get_property(np, "st,overcurrent-warning-adjustment", NULL)) in sta350_probe_dt()
1137 pdata->oc_warning_adjustment = 1; in sta350_probe_dt()
1140 if (of_get_property(np, "st,max-power-use-mpcc", NULL)) in sta350_probe_dt()
1141 pdata->max_power_use_mpcc = 1; in sta350_probe_dt()
1143 if (of_get_property(np, "st,max-power-correction", NULL)) in sta350_probe_dt()
1144 pdata->max_power_correction = 1; in sta350_probe_dt()
1146 if (of_get_property(np, "st,am-reduction-mode", NULL)) in sta350_probe_dt()
1147 pdata->am_reduction_mode = 1; in sta350_probe_dt()
1149 if (of_get_property(np, "st,odd-pwm-speed-mode", NULL)) in sta350_probe_dt()
1150 pdata->odd_pwm_speed_mode = 1; in sta350_probe_dt()
1152 if (of_get_property(np, "st,distortion-compensation", NULL)) in sta350_probe_dt()
1153 pdata->distortion_compensation = 1; in sta350_probe_dt()
1156 if (of_get_property(np, "st,invalid-input-detect-mute", NULL)) in sta350_probe_dt()
1157 pdata->invalid_input_detect_mute = 1; in sta350_probe_dt()
1160 if (of_get_property(np, "st,activate-mute-output", NULL)) in sta350_probe_dt()
1161 pdata->activate_mute_output = 1; in sta350_probe_dt()
1163 if (of_get_property(np, "st,bridge-immediate-off", NULL)) in sta350_probe_dt()
1164 pdata->bridge_immediate_off = 1; in sta350_probe_dt()
1166 if (of_get_property(np, "st,noise-shape-dc-cut", NULL)) in sta350_probe_dt()
1167 pdata->noise_shape_dc_cut = 1; in sta350_probe_dt()
1169 if (of_get_property(np, "st,powerdown-master-volume", NULL)) in sta350_probe_dt()
1170 pdata->powerdown_master_vol = 1; in sta350_probe_dt()
1172 if (!of_property_read_u8(np, "st,powerdown-delay-divider", &tmp8)) { in sta350_probe_dt()
1174 pdata->powerdown_delay_divider = ilog2(tmp8); in sta350_probe_dt()
1180 sta350->pdata = pdata; in sta350_probe_dt()
1182 return 0; in sta350_probe_dt()
1188 struct device *dev = &i2c->dev; in sta350_i2c_probe()
1194 return -ENOMEM; in sta350_i2c_probe()
1196 mutex_init(&sta350->coeff_lock); in sta350_i2c_probe()
1197 sta350->pdata = dev_get_platdata(dev); in sta350_i2c_probe()
1200 if (dev->of_node) { in sta350_i2c_probe()
1202 if (ret < 0) in sta350_i2c_probe()
1208 sta350->gpiod_nreset = devm_gpiod_get_optional(dev, "reset", in sta350_i2c_probe()
1210 if (IS_ERR(sta350->gpiod_nreset)) in sta350_i2c_probe()
1211 return PTR_ERR(sta350->gpiod_nreset); in sta350_i2c_probe()
1213 sta350->gpiod_power_down = devm_gpiod_get_optional(dev, "power-down", in sta350_i2c_probe()
1215 if (IS_ERR(sta350->gpiod_power_down)) in sta350_i2c_probe()
1216 return PTR_ERR(sta350->gpiod_power_down); in sta350_i2c_probe()
1219 for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++) in sta350_i2c_probe()
1220 sta350->supplies[i].supply = sta350_supply_names[i]; in sta350_i2c_probe()
1222 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(sta350->supplies), in sta350_i2c_probe()
1223 sta350->supplies); in sta350_i2c_probe()
1224 if (ret < 0) { in sta350_i2c_probe()
1229 sta350->regmap = devm_regmap_init_i2c(i2c, &sta350_regmap); in sta350_i2c_probe()
1230 if (IS_ERR(sta350->regmap)) { in sta350_i2c_probe()
1231 ret = PTR_ERR(sta350->regmap); in sta350_i2c_probe()
1239 if (ret < 0) in sta350_i2c_probe()
1249 { "sta350", 0 },