Lines Matching +full:ch3 +full:- +full:0
2 * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system
39 #include <sound/soc-dapm.h>
62 /* Power-up register defaults */
64 { 0x0, 0x63 },
65 { 0x1, 0x80 },
66 { 0x2, 0xdf },
67 { 0x3, 0x40 },
68 { 0x4, 0xc2 },
69 { 0x5, 0x5c },
70 { 0x6, 0x00 },
71 { 0x7, 0xff },
72 { 0x8, 0x60 },
73 { 0x9, 0x60 },
74 { 0xa, 0x60 },
75 { 0xb, 0x00 },
76 { 0xc, 0x00 },
77 { 0xd, 0x00 },
78 { 0xe, 0x00 },
79 { 0xf, 0x40 },
80 { 0x10, 0x80 },
81 { 0x11, 0x77 },
82 { 0x12, 0x6a },
83 { 0x13, 0x69 },
84 { 0x14, 0x6a },
85 { 0x15, 0x69 },
86 { 0x16, 0x00 },
87 { 0x17, 0x00 },
88 { 0x18, 0x00 },
89 { 0x19, 0x00 },
90 { 0x1a, 0x00 },
91 { 0x1b, 0x00 },
92 { 0x1c, 0x00 },
93 { 0x1d, 0x00 },
94 { 0x1e, 0x00 },
95 { 0x1f, 0x00 },
96 { 0x20, 0x00 },
97 { 0x21, 0x00 },
98 { 0x22, 0x00 },
99 { 0x23, 0x00 },
100 { 0x24, 0x00 },
101 { 0x25, 0x00 },
102 { 0x26, 0x00 },
103 { 0x27, 0x2a },
104 { 0x28, 0xc0 },
105 { 0x29, 0xf3 },
106 { 0x2a, 0x33 },
107 { 0x2b, 0x00 },
108 { 0x2c, 0x0c },
109 { 0x31, 0x00 },
110 { 0x36, 0x00 },
111 { 0x37, 0x00 },
112 { 0x38, 0x00 },
113 { 0x39, 0x01 },
114 { 0x3a, 0xee },
115 { 0x3b, 0xff },
116 { 0x3c, 0x7e },
117 { 0x3d, 0xc0 },
118 { 0x3e, 0x26 },
119 { 0x3f, 0x00 },
120 { 0x48, 0x00 },
121 { 0x49, 0x00 },
122 { 0x4a, 0x00 },
123 { 0x4b, 0x04 },
124 { 0x4c, 0x00 },
163 "vdd-dig", /* digital supply, 3.3V */
164 "vdd-pll", /* pll supply, 3.3V */
165 "vcc" /* power amp supply, 5V - 26V */
186 static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12750, 50, 1);
187 static const DECLARE_TLV_DB_SCALE(chvol_tlv, -7950, 50, 1);
188 static const DECLARE_TLV_DB_SCALE(tone_tlv, -1200, 200, 0);
191 "Anti-Clipping", "Dynamic Range Compression"
203 "FFX 3-state output - normal operation", "Binary output"
223 0, 7, TLV_DB_SCALE_ITEM(-1200, 200, 0),
224 8, 16, TLV_DB_SCALE_ITEM(300, 100, 0),
228 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
229 1, 1, TLV_DB_SCALE_ITEM(-2900, 0, 0),
230 2, 2, TLV_DB_SCALE_ITEM(-2000, 0, 0),
231 3, 8, TLV_DB_SCALE_ITEM(-1400, 200, 0),
232 8, 16, TLV_DB_SCALE_ITEM(-700, 100, 0),
236 0, 7, TLV_DB_SCALE_ITEM(-3100, 200, 0),
237 8, 13, TLV_DB_SCALE_ITEM(-1600, 100, 0),
238 14, 16, TLV_DB_SCALE_ITEM(-1000, 300, 0),
242 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
243 1, 2, TLV_DB_SCALE_ITEM(-3800, 200, 0),
244 3, 4, TLV_DB_SCALE_ITEM(-3300, 200, 0),
245 5, 12, TLV_DB_SCALE_ITEM(-3000, 200, 0),
246 13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0),
303 int numcoef = kcontrol->private_value >> 16; in sta350_coefficient_info()
304 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in sta350_coefficient_info()
305 uinfo->count = 3 * numcoef; in sta350_coefficient_info()
306 return 0; in sta350_coefficient_info()
314 int numcoef = kcontrol->private_value >> 16; in sta350_coefficient_get()
315 int index = kcontrol->private_value & 0xffff; in sta350_coefficient_get()
317 int i, ret = 0; in sta350_coefficient_get()
319 mutex_lock(&sta350->coeff_lock); in sta350_coefficient_get()
322 regmap_read(sta350->regmap, STA350_CFUD, &cfud); in sta350_coefficient_get()
323 cfud &= 0xf0; in sta350_coefficient_get()
328 regmap_write(sta350->regmap, STA350_CFUD, cfud); in sta350_coefficient_get()
330 regmap_write(sta350->regmap, STA350_CFADDR2, index); in sta350_coefficient_get()
332 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x04); in sta350_coefficient_get()
334 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x08); in sta350_coefficient_get()
336 ret = -EINVAL; in sta350_coefficient_get()
340 for (i = 0; i < 3 * numcoef; i++) { in sta350_coefficient_get()
341 regmap_read(sta350->regmap, STA350_B1CF1 + i, &val); in sta350_coefficient_get()
342 ucontrol->value.bytes.data[i] = val; in sta350_coefficient_get()
346 mutex_unlock(&sta350->coeff_lock); in sta350_coefficient_get()
356 int numcoef = kcontrol->private_value >> 16; in sta350_coefficient_put()
357 int index = kcontrol->private_value & 0xffff; in sta350_coefficient_put()
362 regmap_read(sta350->regmap, STA350_CFUD, &cfud); in sta350_coefficient_put()
363 cfud &= 0xf0; in sta350_coefficient_put()
368 regmap_write(sta350->regmap, STA350_CFUD, cfud); in sta350_coefficient_put()
370 regmap_write(sta350->regmap, STA350_CFADDR2, index); in sta350_coefficient_put()
371 for (i = 0; i < numcoef && (index + i < STA350_COEF_COUNT); i++) in sta350_coefficient_put()
372 sta350->coef_shadow[index + i] = in sta350_coefficient_put()
373 (ucontrol->value.bytes.data[3 * i] << 16) in sta350_coefficient_put()
374 | (ucontrol->value.bytes.data[3 * i + 1] << 8) in sta350_coefficient_put()
375 | (ucontrol->value.bytes.data[3 * i + 2]); in sta350_coefficient_put()
376 for (i = 0; i < 3 * numcoef; i++) in sta350_coefficient_put()
377 regmap_write(sta350->regmap, STA350_B1CF1 + i, in sta350_coefficient_put()
378 ucontrol->value.bytes.data[i]); in sta350_coefficient_put()
380 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01); in sta350_coefficient_put()
382 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x02); in sta350_coefficient_put()
384 return -EINVAL; in sta350_coefficient_put()
386 return 0; in sta350_coefficient_put()
396 regmap_read(sta350->regmap, STA350_CFUD, &cfud); in sta350_sync_coef_shadow()
397 cfud &= 0xf0; in sta350_sync_coef_shadow()
399 for (i = 0; i < STA350_COEF_COUNT; i++) { in sta350_sync_coef_shadow()
400 regmap_write(sta350->regmap, STA350_CFADDR2, i); in sta350_sync_coef_shadow()
401 regmap_write(sta350->regmap, STA350_B1CF1, in sta350_sync_coef_shadow()
402 (sta350->coef_shadow[i] >> 16) & 0xff); in sta350_sync_coef_shadow()
403 regmap_write(sta350->regmap, STA350_B1CF2, in sta350_sync_coef_shadow()
404 (sta350->coef_shadow[i] >> 8) & 0xff); in sta350_sync_coef_shadow()
405 regmap_write(sta350->regmap, STA350_B1CF3, in sta350_sync_coef_shadow()
406 (sta350->coef_shadow[i]) & 0xff); in sta350_sync_coef_shadow()
409 * self-clearing, so do it explicitly in sta350_sync_coef_shadow()
411 regmap_write(sta350->regmap, STA350_CFUD, cfud); in sta350_sync_coef_shadow()
412 regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01); in sta350_sync_coef_shadow()
414 return 0; in sta350_sync_coef_shadow()
424 regmap_read(sta350->regmap, STA350_CFUD, &mute); in sta350_cache_sync()
425 regmap_write(sta350->regmap, STA350_MMUTE, mute | STA350_MMUTE_MMUTE); in sta350_cache_sync()
427 rc = regcache_sync(sta350->regmap); in sta350_cache_sync()
428 regmap_write(sta350->regmap, STA350_MMUTE, mute); in sta350_cache_sync()
447 SOC_SINGLE_TLV("Master Volume", STA350_MVOL, 0, 0xff, 1, mvol_tlv),
449 SOC_SINGLE_TLV("Ch1 Volume", STA350_C1VOL, 0, 0xff, 1, chvol_tlv),
450 SOC_SINGLE_TLV("Ch2 Volume", STA350_C2VOL, 0, 0xff, 1, chvol_tlv),
451 SOC_SINGLE_TLV("Ch3 Volume", STA350_C3VOL, 0, 0xff, 1, chvol_tlv),
455 SOC_SINGLE("De-emphasis Filter Switch",
456 STA350_CONFD, STA350_CONFD_DEMP_SHIFT, 1, 0),
458 STA350_CONFD, STA350_CONFD_DSPB_SHIFT, 1, 0),
459 SOC_SINGLE("Post-scale Link Switch",
460 STA350_CONFD, STA350_CONFD_PSL_SHIFT, 1, 0),
462 STA350_CONFD, STA350_CONFD_BQL_SHIFT, 1, 0),
465 SOC_SINGLE("Zero-detect Mute Enable Switch",
466 STA350_CONFD, STA350_CONFD_ZDE_SHIFT, 1, 0),
468 STA350_CONFD, STA350_CONFD_SME_SHIFT, 1, 0),
470 SOC_SINGLE("Zero Cross Switch", STA350_CONFE, STA350_CONFE_ZCE_SHIFT, 1, 0),
471 SOC_SINGLE("Soft Ramp Switch", STA350_CONFE, STA350_CONFE_SVE_SHIFT, 1, 0),
476 SOC_SINGLE("Ch3 Switch", STA350_MMUTE, STA350_MMUTE_C3M_SHIFT, 1, 1),
482 STA350_C1CFG, STA350_CxCFG_TCB_SHIFT, 1, 0),
484 STA350_C2CFG, STA350_CxCFG_TCB_SHIFT, 1, 0),
486 STA350_C1CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0),
488 STA350_C2CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0),
490 STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
492 STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
493 SOC_SINGLE("Ch3 Master Volume Bypass Switch",
494 STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
497 SOC_ENUM("Ch3 Binary Output Select", sta350_binary_output_ch3_enum),
500 SOC_ENUM("Ch3 Limiter Select", sta350_limiter_ch3_enum),
503 STA350_TONE, STA350_TONE_BTC_SHIFT, 1, 13, 0, tone_tlv),
505 STA350_TONE, STA350_TONE_TTC_SHIFT, 1, 13, 0, tone_tlv),
517 16, 0, sta350_limiter_ac_attack_tlv),
520 16, 0, sta350_limiter_ac_attack_tlv),
523 16, 0, sta350_limiter_ac_release_tlv),
526 16, 0, sta350_limiter_ac_release_tlv),
529 16, 0, sta350_limiter_drc_attack_tlv),
532 16, 0, sta350_limiter_drc_attack_tlv),
535 16, 0, sta350_limiter_drc_release_tlv),
538 16, 0, sta350_limiter_drc_release_tlv),
540 BIQUAD_COEFS("Ch1 - Biquad 1", 0),
541 BIQUAD_COEFS("Ch1 - Biquad 2", 5),
542 BIQUAD_COEFS("Ch1 - Biquad 3", 10),
543 BIQUAD_COEFS("Ch1 - Biquad 4", 15),
544 BIQUAD_COEFS("Ch2 - Biquad 1", 20),
545 BIQUAD_COEFS("Ch2 - Biquad 2", 25),
546 BIQUAD_COEFS("Ch2 - Biquad 3", 30),
547 BIQUAD_COEFS("Ch2 - Biquad 4", 35),
548 BIQUAD_COEFS("High-pass", 40),
549 BIQUAD_COEFS("Low-pass", 45),
550 SINGLE_COEF("Ch1 - Prescale", 50),
551 SINGLE_COEF("Ch2 - Prescale", 51),
552 SINGLE_COEF("Ch1 - Postscale", 52),
553 SINGLE_COEF("Ch2 - Postscale", 53),
554 SINGLE_COEF("Ch3 - Postscale", 54),
555 SINGLE_COEF("Thermal warning - Postscale", 55),
556 SINGLE_COEF("Ch1 - Mix 1", 56),
557 SINGLE_COEF("Ch1 - Mix 2", 57),
558 SINGLE_COEF("Ch2 - Mix 1", 58),
559 SINGLE_COEF("Ch2 - Mix 2", 59),
560 SINGLE_COEF("Ch3 - Mix 1", 60),
561 SINGLE_COEF("Ch3 - Mix 2", 61),
565 SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0),
583 { 32000, 0 },
584 { 44100, 0 },
585 { 48000, 0 },
595 { 384, 256, 192, 128, 64, 0 },
596 { 192, 128, 96, 64, 32, 0 },
600 * sta350_set_dai_sysclk - configure MCLK
616 struct snd_soc_component *component = codec_dai->component; in sta350_set_dai_sysclk()
619 dev_dbg(component->dev, "mclk=%u\n", freq); in sta350_set_dai_sysclk()
620 sta350->mclk = freq; in sta350_set_dai_sysclk()
622 return 0; in sta350_set_dai_sysclk()
626 * sta350_set_dai_fmt - configure the codec for the selected audio format
636 struct snd_soc_component *component = codec_dai->component; in sta350_set_dai_fmt()
638 unsigned int confb = 0; in sta350_set_dai_fmt()
644 return -EINVAL; in sta350_set_dai_fmt()
651 sta350->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in sta350_set_dai_fmt()
654 return -EINVAL; in sta350_set_dai_fmt()
665 return -EINVAL; in sta350_set_dai_fmt()
668 return regmap_update_bits(sta350->regmap, STA350_CONFB, in sta350_set_dai_fmt()
673 * sta350_hw_params - program the STA350 with the given hardware parameters.
685 struct snd_soc_component *component = dai->component; in sta350_hw_params()
687 int i, mcs = -EINVAL, ir = -EINVAL; in sta350_hw_params()
692 if (!sta350->mclk) { in sta350_hw_params()
693 dev_err(component->dev, in sta350_hw_params()
694 "sta350->mclk is unset. Unable to determine ratio\n"); in sta350_hw_params()
695 return -EIO; in sta350_hw_params()
699 ratio = sta350->mclk / rate; in sta350_hw_params()
700 dev_dbg(component->dev, "rate: %u, ratio: %u\n", rate, ratio); in sta350_hw_params()
702 for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) { in sta350_hw_params()
709 if (ir < 0) { in sta350_hw_params()
710 dev_err(component->dev, "Unsupported samplerate: %u\n", rate); in sta350_hw_params()
711 return -EINVAL; in sta350_hw_params()
714 for (i = 0; i < 6; i++) { in sta350_hw_params()
721 if (mcs < 0) { in sta350_hw_params()
722 dev_err(component->dev, "Unresolvable ratio: %u\n", ratio); in sta350_hw_params()
723 return -EINVAL; in sta350_hw_params()
728 confb = 0; in sta350_hw_params()
732 dev_dbg(component->dev, "24bit\n"); in sta350_hw_params()
735 dev_dbg(component->dev, "24bit or 32bit\n"); in sta350_hw_params()
736 switch (sta350->format) { in sta350_hw_params()
738 confb |= 0x0; in sta350_hw_params()
741 confb |= 0x1; in sta350_hw_params()
744 confb |= 0x2; in sta350_hw_params()
750 dev_dbg(component->dev, "20bit\n"); in sta350_hw_params()
751 switch (sta350->format) { in sta350_hw_params()
753 confb |= 0x4; in sta350_hw_params()
756 confb |= 0x5; in sta350_hw_params()
759 confb |= 0x6; in sta350_hw_params()
765 dev_dbg(component->dev, "18bit\n"); in sta350_hw_params()
766 switch (sta350->format) { in sta350_hw_params()
768 confb |= 0x8; in sta350_hw_params()
771 confb |= 0x9; in sta350_hw_params()
774 confb |= 0xa; in sta350_hw_params()
780 dev_dbg(component->dev, "16bit\n"); in sta350_hw_params()
781 switch (sta350->format) { in sta350_hw_params()
783 confb |= 0x0; in sta350_hw_params()
786 confb |= 0xd; in sta350_hw_params()
789 confb |= 0xe; in sta350_hw_params()
795 return -EINVAL; in sta350_hw_params()
798 ret = regmap_update_bits(sta350->regmap, STA350_CONFA, in sta350_hw_params()
801 if (ret < 0) in sta350_hw_params()
804 ret = regmap_update_bits(sta350->regmap, STA350_CONFB, in sta350_hw_params()
807 if (ret < 0) in sta350_hw_params()
810 return 0; in sta350_hw_params()
815 if (sta350->gpiod_power_down) in sta350_startup_sequence()
816 gpiod_set_value(sta350->gpiod_power_down, 1); in sta350_startup_sequence()
818 if (sta350->gpiod_nreset) { in sta350_startup_sequence()
819 gpiod_set_value(sta350->gpiod_nreset, 0); in sta350_startup_sequence()
821 gpiod_set_value(sta350->gpiod_nreset, 1); in sta350_startup_sequence()
825 return 0; in sta350_startup_sequence()
829 * sta350_set_bias_level - DAPM callback
843 dev_dbg(component->dev, "level = %d\n", level); in sta350_set_bias_level()
850 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_set_bias_level()
858 ARRAY_SIZE(sta350->supplies), in sta350_set_bias_level()
859 sta350->supplies); in sta350_set_bias_level()
860 if (ret < 0) { in sta350_set_bias_level()
861 dev_err(component->dev, in sta350_set_bias_level()
871 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_set_bias_level()
873 0); in sta350_set_bias_level()
879 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_set_bias_level()
880 STA350_CONFF_PWDN | STA350_CONFF_EAPD, 0); in sta350_set_bias_level()
883 if (sta350->gpiod_power_down) in sta350_set_bias_level()
884 gpiod_set_value(sta350->gpiod_power_down, 0); in sta350_set_bias_level()
886 if (sta350->gpiod_nreset) in sta350_set_bias_level()
887 gpiod_set_value(sta350->gpiod_nreset, 0); in sta350_set_bias_level()
889 regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), in sta350_set_bias_level()
890 sta350->supplies); in sta350_set_bias_level()
893 return 0; in sta350_set_bias_level()
903 .name = "sta350-hifi",
917 struct sta350_platform_data *pdata = sta350->pdata; in sta350_probe()
918 int i, ret = 0, thermal = 0; in sta350_probe()
920 ret = regulator_bulk_enable(ARRAY_SIZE(sta350->supplies), in sta350_probe()
921 sta350->supplies); in sta350_probe()
922 if (ret < 0) { in sta350_probe()
923 dev_err(component->dev, "Failed to enable supplies: %d\n", ret); in sta350_probe()
928 if (ret < 0) { in sta350_probe()
929 dev_err(component->dev, "Failed to startup device\n"); in sta350_probe()
934 if (!pdata->thermal_warning_recovery) in sta350_probe()
936 if (!pdata->thermal_warning_adjustment) in sta350_probe()
938 if (!pdata->fault_detect_recovery) in sta350_probe()
940 regmap_update_bits(sta350->regmap, STA350_CONFA, in sta350_probe()
946 regmap_update_bits(sta350->regmap, STA350_CONFC, in sta350_probe()
948 pdata->ffx_power_output_mode in sta350_probe()
950 regmap_update_bits(sta350->regmap, STA350_CONFC, in sta350_probe()
952 pdata->drop_compensation_ns in sta350_probe()
954 regmap_update_bits(sta350->regmap, in sta350_probe()
957 pdata->oc_warning_adjustment ? in sta350_probe()
958 STA350_CONFC_OCRB : 0); in sta350_probe()
961 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
963 pdata->max_power_use_mpcc ? in sta350_probe()
964 STA350_CONFE_MPCV : 0); in sta350_probe()
965 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
967 pdata->max_power_correction ? in sta350_probe()
968 STA350_CONFE_MPC : 0); in sta350_probe()
969 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
971 pdata->am_reduction_mode ? in sta350_probe()
972 STA350_CONFE_AME : 0); in sta350_probe()
973 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
975 pdata->odd_pwm_speed_mode ? in sta350_probe()
976 STA350_CONFE_PWMS : 0); in sta350_probe()
977 regmap_update_bits(sta350->regmap, STA350_CONFE, in sta350_probe()
979 pdata->distortion_compensation ? in sta350_probe()
980 STA350_CONFE_DCCV : 0); in sta350_probe()
982 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_probe()
984 pdata->invalid_input_detect_mute ? in sta350_probe()
985 STA350_CONFF_IDE : 0); in sta350_probe()
986 regmap_update_bits(sta350->regmap, STA350_CONFF, in sta350_probe()
988 pdata->output_conf in sta350_probe()
992 regmap_update_bits(sta350->regmap, STA350_C1CFG, in sta350_probe()
994 pdata->ch1_output_mapping in sta350_probe()
996 regmap_update_bits(sta350->regmap, STA350_C2CFG, in sta350_probe()
998 pdata->ch2_output_mapping in sta350_probe()
1000 regmap_update_bits(sta350->regmap, STA350_C3CFG, in sta350_probe()
1002 pdata->ch3_output_mapping in sta350_probe()
1006 regmap_update_bits(sta350->regmap, STA350_MISC1, in sta350_probe()
1008 pdata->activate_mute_output ? in sta350_probe()
1009 STA350_MISC1_CPWMEN : 0); in sta350_probe()
1010 regmap_update_bits(sta350->regmap, STA350_MISC1, in sta350_probe()
1012 pdata->bridge_immediate_off ? in sta350_probe()
1013 STA350_MISC1_BRIDGOFF : 0); in sta350_probe()
1014 regmap_update_bits(sta350->regmap, STA350_MISC1, in sta350_probe()
1016 pdata->noise_shape_dc_cut ? in sta350_probe()
1017 STA350_MISC1_NSHHPEN : 0); in sta350_probe()
1018 regmap_update_bits(sta350->regmap, STA350_MISC1, in sta350_probe()
1020 pdata->powerdown_master_vol ? in sta350_probe()
1021 STA350_MISC1_RPDNEN: 0); in sta350_probe()
1023 regmap_update_bits(sta350->regmap, STA350_MISC2, in sta350_probe()
1025 pdata->powerdown_delay_divider in sta350_probe()
1030 sta350->coef_shadow[i] = 0x400000; in sta350_probe()
1032 sta350->coef_shadow[i] = 0x7fffff; in sta350_probe()
1033 sta350->coef_shadow[55] = 0x5a9df7; in sta350_probe()
1034 sta350->coef_shadow[56] = 0x7fffff; in sta350_probe()
1035 sta350->coef_shadow[59] = 0x7fffff; in sta350_probe()
1036 sta350->coef_shadow[60] = 0x400000; in sta350_probe()
1037 sta350->coef_shadow[61] = 0x400000; in sta350_probe()
1041 regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); in sta350_probe()
1043 return 0; in sta350_probe()
1050 regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); in sta350_remove()
1090 [STA350_FFX_PM_DROP_COMP] = "drop-compensation",
1091 [STA350_FFX_PM_TAPERED_COMP] = "tapered-compensation",
1092 [STA350_FFX_PM_FULL_POWER] = "full-power-mode",
1093 [STA350_FFX_PM_VARIABLE_DROP_COMP] = "variable-drop-compensation",
1098 struct device_node *np = dev->of_node; in sta350_probe_dt()
1106 return -ENOMEM; in sta350_probe_dt()
1108 of_property_read_u8(np, "st,output-conf", in sta350_probe_dt()
1109 &pdata->output_conf); in sta350_probe_dt()
1110 of_property_read_u8(np, "st,ch1-output-mapping", in sta350_probe_dt()
1111 &pdata->ch1_output_mapping); in sta350_probe_dt()
1112 of_property_read_u8(np, "st,ch2-output-mapping", in sta350_probe_dt()
1113 &pdata->ch2_output_mapping); in sta350_probe_dt()
1114 of_property_read_u8(np, "st,ch3-output-mapping", in sta350_probe_dt()
1115 &pdata->ch3_output_mapping); in sta350_probe_dt()
1117 if (of_get_property(np, "st,thermal-warning-recovery", NULL)) in sta350_probe_dt()
1118 pdata->thermal_warning_recovery = 1; in sta350_probe_dt()
1119 if (of_get_property(np, "st,thermal-warning-adjustment", NULL)) in sta350_probe_dt()
1120 pdata->thermal_warning_adjustment = 1; in sta350_probe_dt()
1121 if (of_get_property(np, "st,fault-detect-recovery", NULL)) in sta350_probe_dt()
1122 pdata->fault_detect_recovery = 1; in sta350_probe_dt()
1124 pdata->ffx_power_output_mode = STA350_FFX_PM_VARIABLE_DROP_COMP; in sta350_probe_dt()
1125 if (!of_property_read_string(np, "st,ffx-power-output-mode", in sta350_probe_dt()
1127 int i, mode = -EINVAL; in sta350_probe_dt()
1129 for (i = 0; i < ARRAY_SIZE(sta350_ffx_modes); i++) in sta350_probe_dt()
1133 if (mode < 0) in sta350_probe_dt()
1137 pdata->ffx_power_output_mode = mode; in sta350_probe_dt()
1141 of_property_read_u16(np, "st,drop-compensation-ns", &tmp); in sta350_probe_dt()
1142 pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20; in sta350_probe_dt()
1144 if (of_get_property(np, "st,overcurrent-warning-adjustment", NULL)) in sta350_probe_dt()
1145 pdata->oc_warning_adjustment = 1; in sta350_probe_dt()
1148 if (of_get_property(np, "st,max-power-use-mpcc", NULL)) in sta350_probe_dt()
1149 pdata->max_power_use_mpcc = 1; in sta350_probe_dt()
1151 if (of_get_property(np, "st,max-power-correction", NULL)) in sta350_probe_dt()
1152 pdata->max_power_correction = 1; in sta350_probe_dt()
1154 if (of_get_property(np, "st,am-reduction-mode", NULL)) in sta350_probe_dt()
1155 pdata->am_reduction_mode = 1; in sta350_probe_dt()
1157 if (of_get_property(np, "st,odd-pwm-speed-mode", NULL)) in sta350_probe_dt()
1158 pdata->odd_pwm_speed_mode = 1; in sta350_probe_dt()
1160 if (of_get_property(np, "st,distortion-compensation", NULL)) in sta350_probe_dt()
1161 pdata->distortion_compensation = 1; in sta350_probe_dt()
1164 if (of_get_property(np, "st,invalid-input-detect-mute", NULL)) in sta350_probe_dt()
1165 pdata->invalid_input_detect_mute = 1; in sta350_probe_dt()
1168 if (of_get_property(np, "st,activate-mute-output", NULL)) in sta350_probe_dt()
1169 pdata->activate_mute_output = 1; in sta350_probe_dt()
1171 if (of_get_property(np, "st,bridge-immediate-off", NULL)) in sta350_probe_dt()
1172 pdata->bridge_immediate_off = 1; in sta350_probe_dt()
1174 if (of_get_property(np, "st,noise-shape-dc-cut", NULL)) in sta350_probe_dt()
1175 pdata->noise_shape_dc_cut = 1; in sta350_probe_dt()
1177 if (of_get_property(np, "st,powerdown-master-volume", NULL)) in sta350_probe_dt()
1178 pdata->powerdown_master_vol = 1; in sta350_probe_dt()
1180 if (!of_property_read_u8(np, "st,powerdown-delay-divider", &tmp8)) { in sta350_probe_dt()
1182 pdata->powerdown_delay_divider = ilog2(tmp8); in sta350_probe_dt()
1188 sta350->pdata = pdata; in sta350_probe_dt()
1190 return 0; in sta350_probe_dt()
1197 struct device *dev = &i2c->dev; in sta350_i2c_probe()
1203 return -ENOMEM; in sta350_i2c_probe()
1205 mutex_init(&sta350->coeff_lock); in sta350_i2c_probe()
1206 sta350->pdata = dev_get_platdata(dev); in sta350_i2c_probe()
1209 if (dev->of_node) { in sta350_i2c_probe()
1211 if (ret < 0) in sta350_i2c_probe()
1217 sta350->gpiod_nreset = devm_gpiod_get_optional(dev, "reset", in sta350_i2c_probe()
1219 if (IS_ERR(sta350->gpiod_nreset)) in sta350_i2c_probe()
1220 return PTR_ERR(sta350->gpiod_nreset); in sta350_i2c_probe()
1222 sta350->gpiod_power_down = devm_gpiod_get_optional(dev, "power-down", in sta350_i2c_probe()
1224 if (IS_ERR(sta350->gpiod_power_down)) in sta350_i2c_probe()
1225 return PTR_ERR(sta350->gpiod_power_down); in sta350_i2c_probe()
1228 for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++) in sta350_i2c_probe()
1229 sta350->supplies[i].supply = sta350_supply_names[i]; in sta350_i2c_probe()
1231 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(sta350->supplies), in sta350_i2c_probe()
1232 sta350->supplies); in sta350_i2c_probe()
1233 if (ret < 0) { in sta350_i2c_probe()
1238 sta350->regmap = devm_regmap_init_i2c(i2c, &sta350_regmap); in sta350_i2c_probe()
1239 if (IS_ERR(sta350->regmap)) { in sta350_i2c_probe()
1240 ret = PTR_ERR(sta350->regmap); in sta350_i2c_probe()
1248 if (ret < 0) in sta350_i2c_probe()
1256 return 0; in sta350_i2c_remove()
1260 { "sta350", 0 },