Lines Matching +full:ch3 +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Codec driver for ST STA32x 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, 0xc2 },
60 { 0x3, 0x40 },
61 { 0x4, 0xc2 },
62 { 0x5, 0x5c },
63 { 0x6, 0x10 },
64 { 0x7, 0xff },
65 { 0x8, 0x60 },
66 { 0x9, 0x60 },
67 { 0xa, 0x60 },
68 { 0xb, 0x80 },
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, 0x2d },
97 { 0x28, 0xc0 },
98 { 0x2b, 0x00 },
99 { 0x2c, 0x0c },
133 "Vcc" /* power amp spply, 10V - 36V */
154 static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12700, 50, 1);
155 static const DECLARE_TLV_DB_SCALE(chvol_tlv, -7950, 50, 1);
156 static const DECLARE_TLV_DB_SCALE(tone_tlv, -120, 200, 0);
159 "Anti-Clipping", "Dynamic Range Compression" };
170 "Hard", "Party", "Vocal", "Hip-Hop", "Dialog", "Bass-boost #1",
171 "Bass-boost #2", "Bass-boost #3", "Loudness 1", "Loudness 2",
186 0, 7, TLV_DB_SCALE_ITEM(-1200, 200, 0),
187 8, 16, TLV_DB_SCALE_ITEM(300, 100, 0),
191 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
192 1, 1, TLV_DB_SCALE_ITEM(-2900, 0, 0),
193 2, 2, TLV_DB_SCALE_ITEM(-2000, 0, 0),
194 3, 8, TLV_DB_SCALE_ITEM(-1400, 200, 0),
195 8, 16, TLV_DB_SCALE_ITEM(-700, 100, 0),
199 0, 7, TLV_DB_SCALE_ITEM(-3100, 200, 0),
200 8, 13, TLV_DB_SCALE_ITEM(-1600, 100, 0),
201 14, 16, TLV_DB_SCALE_ITEM(-1000, 300, 0),
205 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
206 1, 2, TLV_DB_SCALE_ITEM(-3800, 200, 0),
207 3, 4, TLV_DB_SCALE_ITEM(-3300, 200, 0),
208 5, 12, TLV_DB_SCALE_ITEM(-3000, 200, 0),
209 13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0),
259 int numcoef = kcontrol->private_value >> 16; in sta32x_coefficient_info()
260 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in sta32x_coefficient_info()
261 uinfo->count = 3 * numcoef; in sta32x_coefficient_info()
262 return 0; in sta32x_coefficient_info()
270 int numcoef = kcontrol->private_value >> 16; in sta32x_coefficient_get()
271 int index = kcontrol->private_value & 0xffff; in sta32x_coefficient_get()
273 int i, ret = 0; in sta32x_coefficient_get()
275 mutex_lock(&sta32x->coeff_lock); in sta32x_coefficient_get()
278 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_coefficient_get()
279 cfud &= 0xf0; in sta32x_coefficient_get()
284 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_coefficient_get()
286 regmap_write(sta32x->regmap, STA32X_CFADDR2, index); in sta32x_coefficient_get()
288 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x04); in sta32x_coefficient_get()
290 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x08); in sta32x_coefficient_get()
292 ret = -EINVAL; in sta32x_coefficient_get()
296 for (i = 0; i < 3 * numcoef; i++) { in sta32x_coefficient_get()
297 regmap_read(sta32x->regmap, STA32X_B1CF1 + i, &val); in sta32x_coefficient_get()
298 ucontrol->value.bytes.data[i] = val; in sta32x_coefficient_get()
302 mutex_unlock(&sta32x->coeff_lock); in sta32x_coefficient_get()
312 int numcoef = kcontrol->private_value >> 16; in sta32x_coefficient_put()
313 int index = kcontrol->private_value & 0xffff; in sta32x_coefficient_put()
318 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_coefficient_put()
319 cfud &= 0xf0; in sta32x_coefficient_put()
324 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_coefficient_put()
326 regmap_write(sta32x->regmap, STA32X_CFADDR2, index); in sta32x_coefficient_put()
327 for (i = 0; i < numcoef && (index + i < STA32X_COEF_COUNT); i++) in sta32x_coefficient_put()
328 sta32x->coef_shadow[index + i] = in sta32x_coefficient_put()
329 (ucontrol->value.bytes.data[3 * i] << 16) in sta32x_coefficient_put()
330 | (ucontrol->value.bytes.data[3 * i + 1] << 8) in sta32x_coefficient_put()
331 | (ucontrol->value.bytes.data[3 * i + 2]); in sta32x_coefficient_put()
332 for (i = 0; i < 3 * numcoef; i++) in sta32x_coefficient_put()
333 regmap_write(sta32x->regmap, STA32X_B1CF1 + i, in sta32x_coefficient_put()
334 ucontrol->value.bytes.data[i]); in sta32x_coefficient_put()
336 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); in sta32x_coefficient_put()
338 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x02); in sta32x_coefficient_put()
340 return -EINVAL; in sta32x_coefficient_put()
342 return 0; in sta32x_coefficient_put()
352 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_sync_coef_shadow()
353 cfud &= 0xf0; in sta32x_sync_coef_shadow()
355 for (i = 0; i < STA32X_COEF_COUNT; i++) { in sta32x_sync_coef_shadow()
356 regmap_write(sta32x->regmap, STA32X_CFADDR2, i); in sta32x_sync_coef_shadow()
357 regmap_write(sta32x->regmap, STA32X_B1CF1, in sta32x_sync_coef_shadow()
358 (sta32x->coef_shadow[i] >> 16) & 0xff); in sta32x_sync_coef_shadow()
359 regmap_write(sta32x->regmap, STA32X_B1CF2, in sta32x_sync_coef_shadow()
360 (sta32x->coef_shadow[i] >> 8) & 0xff); in sta32x_sync_coef_shadow()
361 regmap_write(sta32x->regmap, STA32X_B1CF3, in sta32x_sync_coef_shadow()
362 (sta32x->coef_shadow[i]) & 0xff); in sta32x_sync_coef_shadow()
365 * self-clearing, so do it explicitly in sta32x_sync_coef_shadow()
367 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_sync_coef_shadow()
368 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); in sta32x_sync_coef_shadow()
370 return 0; in sta32x_sync_coef_shadow()
380 regmap_read(sta32x->regmap, STA32X_MMUTE, &mute); in sta32x_cache_sync()
381 regmap_write(sta32x->regmap, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE); in sta32x_cache_sync()
383 rc = regcache_sync(sta32x->regmap); in sta32x_cache_sync()
384 regmap_write(sta32x->regmap, STA32X_MMUTE, mute); in sta32x_cache_sync()
393 struct snd_soc_component *component = sta32x->component; in sta32x_watchdog()
398 regcache_cache_bypass(sta32x->regmap, true); in sta32x_watchdog()
400 regcache_cache_bypass(sta32x->regmap, false); in sta32x_watchdog()
402 regcache_mark_dirty(sta32x->regmap); in sta32x_watchdog()
406 if (!sta32x->shutdown) in sta32x_watchdog()
408 &sta32x->watchdog_work, in sta32x_watchdog()
414 if (sta32x->pdata->needs_esd_watchdog) { in sta32x_watchdog_start()
415 sta32x->shutdown = 0; in sta32x_watchdog_start()
417 &sta32x->watchdog_work, in sta32x_watchdog_start()
424 if (sta32x->pdata->needs_esd_watchdog) { in sta32x_watchdog_stop()
425 sta32x->shutdown = 1; in sta32x_watchdog_stop()
426 cancel_delayed_work_sync(&sta32x->watchdog_work); in sta32x_watchdog_stop()
445 SOC_SINGLE_TLV("Master Volume", STA32X_MVOL, 0, 0xff, 1, mvol_tlv),
446 SOC_SINGLE("Master Switch", STA32X_MMUTE, 0, 1, 1),
449 SOC_SINGLE("Ch3 Switch", STA32X_MMUTE, 3, 1, 1),
450 SOC_SINGLE_TLV("Ch1 Volume", STA32X_C1VOL, 0, 0xff, 1, chvol_tlv),
451 SOC_SINGLE_TLV("Ch2 Volume", STA32X_C2VOL, 0, 0xff, 1, chvol_tlv),
452 SOC_SINGLE_TLV("Ch3 Volume", STA32X_C3VOL, 0, 0xff, 1, chvol_tlv),
453 SOC_SINGLE("De-emphasis Filter Switch", STA32X_CONFD, STA32X_CONFD_DEMP_SHIFT, 1, 0),
455 SOC_SINGLE("Miami Mode Switch", STA32X_CONFD, STA32X_CONFD_MME_SHIFT, 1, 0),
456 SOC_SINGLE("Zero Cross Switch", STA32X_CONFE, STA32X_CONFE_ZCE_SHIFT, 1, 0),
457 SOC_SINGLE("Soft Ramp Switch", STA32X_CONFE, STA32X_CONFE_SVE_SHIFT, 1, 0),
458 SOC_SINGLE("Auto-Mute Switch", STA32X_CONFF, STA32X_CONFF_IDE_SHIFT, 1, 0),
463 SOC_SINGLE("Ch1 Tone Control Bypass Switch", STA32X_C1CFG, STA32X_CxCFG_TCB_SHIFT, 1, 0),
464 SOC_SINGLE("Ch2 Tone Control Bypass Switch", STA32X_C2CFG, STA32X_CxCFG_TCB_SHIFT, 1, 0),
465 SOC_SINGLE("Ch1 EQ Bypass Switch", STA32X_C1CFG, STA32X_CxCFG_EQBP_SHIFT, 1, 0),
466 SOC_SINGLE("Ch2 EQ Bypass Switch", STA32X_C2CFG, STA32X_CxCFG_EQBP_SHIFT, 1, 0),
467 SOC_SINGLE("Ch1 Master Volume Bypass Switch", STA32X_C1CFG, STA32X_CxCFG_VBP_SHIFT, 1, 0),
468 SOC_SINGLE("Ch2 Master Volume Bypass Switch", STA32X_C1CFG, STA32X_CxCFG_VBP_SHIFT, 1, 0),
469 SOC_SINGLE("Ch3 Master Volume Bypass Switch", STA32X_C1CFG, STA32X_CxCFG_VBP_SHIFT, 1, 0),
472 SOC_ENUM("Ch3 Limiter Select", sta32x_limiter_ch3_enum),
473 SOC_SINGLE_TLV("Bass Tone Control", STA32X_TONE, STA32X_TONE_BTC_SHIFT, 15, 0, tone_tlv),
474 SOC_SINGLE_TLV("Treble Tone Control", STA32X_TONE, STA32X_TONE_TTC_SHIFT, 15, 0, tone_tlv),
484 16, 0, sta32x_limiter_ac_attack_tlv),
486 16, 0, sta32x_limiter_ac_attack_tlv),
488 16, 0, sta32x_limiter_ac_release_tlv),
490 16, 0, sta32x_limiter_ac_release_tlv),
492 16, 0, sta32x_limiter_drc_attack_tlv),
494 16, 0, sta32x_limiter_drc_attack_tlv),
496 16, 0, sta32x_limiter_drc_release_tlv),
498 16, 0, sta32x_limiter_drc_release_tlv),
500 BIQUAD_COEFS("Ch1 - Biquad 1", 0),
501 BIQUAD_COEFS("Ch1 - Biquad 2", 5),
502 BIQUAD_COEFS("Ch1 - Biquad 3", 10),
503 BIQUAD_COEFS("Ch1 - Biquad 4", 15),
504 BIQUAD_COEFS("Ch2 - Biquad 1", 20),
505 BIQUAD_COEFS("Ch2 - Biquad 2", 25),
506 BIQUAD_COEFS("Ch2 - Biquad 3", 30),
507 BIQUAD_COEFS("Ch2 - Biquad 4", 35),
508 BIQUAD_COEFS("High-pass", 40),
509 BIQUAD_COEFS("Low-pass", 45),
510 SINGLE_COEF("Ch1 - Prescale", 50),
511 SINGLE_COEF("Ch2 - Prescale", 51),
512 SINGLE_COEF("Ch1 - Postscale", 52),
513 SINGLE_COEF("Ch2 - Postscale", 53),
514 SINGLE_COEF("Ch3 - Postscale", 54),
515 SINGLE_COEF("Thermal warning - Postscale", 55),
516 SINGLE_COEF("Ch1 - Mix 1", 56),
517 SINGLE_COEF("Ch1 - Mix 2", 57),
518 SINGLE_COEF("Ch2 - Mix 1", 58),
519 SINGLE_COEF("Ch2 - Mix 2", 59),
520 SINGLE_COEF("Ch3 - Mix 1", 60),
521 SINGLE_COEF("Ch3 - Mix 2", 61),
525 SND_SOC_DAPM_DAC("DAC", "Playback", SND_SOC_NOPM, 0, 0),
542 { 32000, 0 },
543 { 44100, 0 },
544 { 48000, 0 },
553 { 768, 512, 384, 256, 128, 576, 0 },
554 { 384, 256, 192, 128, 64, 0 },
555 { 384, 256, 192, 128, 64, 0 },
559 * sta32x_set_dai_sysclk - configure MCLK
572 * For setups with variable MCLKs, pass 0 as 'freq' argument. This will cause
580 struct snd_soc_component *component = codec_dai->component; in sta32x_set_dai_sysclk()
583 dev_dbg(component->dev, "mclk=%u\n", freq); in sta32x_set_dai_sysclk()
584 sta32x->mclk = freq; in sta32x_set_dai_sysclk()
586 return 0; in sta32x_set_dai_sysclk()
590 * sta32x_set_dai_fmt - configure the codec for the selected audio format
600 struct snd_soc_component *component = codec_dai->component; in sta32x_set_dai_fmt()
602 u8 confb = 0; in sta32x_set_dai_fmt()
608 return -EINVAL; in sta32x_set_dai_fmt()
615 sta32x->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in sta32x_set_dai_fmt()
618 return -EINVAL; in sta32x_set_dai_fmt()
629 return -EINVAL; in sta32x_set_dai_fmt()
632 return regmap_update_bits(sta32x->regmap, STA32X_CONFB, in sta32x_set_dai_fmt()
637 * sta32x_hw_params - program the STA32X with the given hardware parameters.
649 struct snd_soc_component *component = dai->component; in sta32x_hw_params()
651 int i, mcs = -EINVAL, ir = -EINVAL; in sta32x_hw_params()
656 if (!sta32x->mclk) { in sta32x_hw_params()
657 dev_err(component->dev, in sta32x_hw_params()
658 "sta32x->mclk is unset. Unable to determine ratio\n"); in sta32x_hw_params()
659 return -EIO; in sta32x_hw_params()
663 ratio = sta32x->mclk / rate; in sta32x_hw_params()
664 dev_dbg(component->dev, "rate: %u, ratio: %u\n", rate, ratio); in sta32x_hw_params()
666 for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) { in sta32x_hw_params()
673 if (ir < 0) { in sta32x_hw_params()
674 dev_err(component->dev, "Unsupported samplerate: %u\n", rate); in sta32x_hw_params()
675 return -EINVAL; in sta32x_hw_params()
678 for (i = 0; i < 6; i++) { in sta32x_hw_params()
685 if (mcs < 0) { in sta32x_hw_params()
686 dev_err(component->dev, "Unresolvable ratio: %u\n", ratio); in sta32x_hw_params()
687 return -EINVAL; in sta32x_hw_params()
692 confb = 0; in sta32x_hw_params()
696 dev_dbg(component->dev, "24bit\n"); in sta32x_hw_params()
699 dev_dbg(component->dev, "24bit or 32bit\n"); in sta32x_hw_params()
700 switch (sta32x->format) { in sta32x_hw_params()
702 confb |= 0x0; in sta32x_hw_params()
705 confb |= 0x1; in sta32x_hw_params()
708 confb |= 0x2; in sta32x_hw_params()
714 dev_dbg(component->dev, "20bit\n"); in sta32x_hw_params()
715 switch (sta32x->format) { in sta32x_hw_params()
717 confb |= 0x4; in sta32x_hw_params()
720 confb |= 0x5; in sta32x_hw_params()
723 confb |= 0x6; in sta32x_hw_params()
729 dev_dbg(component->dev, "18bit\n"); in sta32x_hw_params()
730 switch (sta32x->format) { in sta32x_hw_params()
732 confb |= 0x8; in sta32x_hw_params()
735 confb |= 0x9; in sta32x_hw_params()
738 confb |= 0xa; in sta32x_hw_params()
744 dev_dbg(component->dev, "16bit\n"); in sta32x_hw_params()
745 switch (sta32x->format) { in sta32x_hw_params()
747 confb |= 0x0; in sta32x_hw_params()
750 confb |= 0xd; in sta32x_hw_params()
753 confb |= 0xe; in sta32x_hw_params()
759 return -EINVAL; in sta32x_hw_params()
762 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFA, in sta32x_hw_params()
765 if (ret < 0) in sta32x_hw_params()
768 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFB, in sta32x_hw_params()
771 if (ret < 0) in sta32x_hw_params()
774 return 0; in sta32x_hw_params()
779 if (sta32x->gpiod_nreset) { in sta32x_startup_sequence()
780 gpiod_set_value(sta32x->gpiod_nreset, 0); in sta32x_startup_sequence()
782 gpiod_set_value(sta32x->gpiod_nreset, 1); in sta32x_startup_sequence()
786 return 0; in sta32x_startup_sequence()
790 * sta32x_set_bias_level - DAPM callback
804 dev_dbg(component->dev, "level = %d\n", level); in sta32x_set_bias_level()
811 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
818 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), in sta32x_set_bias_level()
819 sta32x->supplies); in sta32x_set_bias_level()
820 if (ret != 0) { in sta32x_set_bias_level()
821 dev_err(component->dev, in sta32x_set_bias_level()
832 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
834 0); in sta32x_set_bias_level()
840 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
841 STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, 0); in sta32x_set_bias_level()
845 gpiod_set_value(sta32x->gpiod_nreset, 0); in sta32x_set_bias_level()
847 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), in sta32x_set_bias_level()
848 sta32x->supplies); in sta32x_set_bias_level()
851 return 0; in sta32x_set_bias_level()
861 .name = "sta32x-hifi",
875 struct sta32x_platform_data *pdata = sta32x->pdata; in sta32x_probe()
876 int i, ret = 0, thermal = 0; in sta32x_probe()
878 sta32x->component = component; in sta32x_probe()
880 if (sta32x->xti_clk) { in sta32x_probe()
881 ret = clk_prepare_enable(sta32x->xti_clk); in sta32x_probe()
882 if (ret != 0) { in sta32x_probe()
883 dev_err(component->dev, in sta32x_probe()
889 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), in sta32x_probe()
890 sta32x->supplies); in sta32x_probe()
891 if (ret != 0) { in sta32x_probe()
892 dev_err(component->dev, "Failed to enable supplies: %d\n", ret); in sta32x_probe()
897 if (ret < 0) { in sta32x_probe()
898 dev_err(component->dev, "Failed to startup device\n"); in sta32x_probe()
903 if (!pdata->thermal_warning_recovery) in sta32x_probe()
905 if (!pdata->thermal_warning_adjustment) in sta32x_probe()
907 if (!pdata->fault_detect_recovery) in sta32x_probe()
909 regmap_update_bits(sta32x->regmap, STA32X_CONFA, in sta32x_probe()
915 regmap_update_bits(sta32x->regmap, STA32X_CONFC, in sta32x_probe()
917 pdata->drop_compensation_ns in sta32x_probe()
921 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
923 pdata->max_power_use_mpcc ? in sta32x_probe()
924 STA32X_CONFE_MPCV : 0); in sta32x_probe()
925 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
927 pdata->max_power_correction ? in sta32x_probe()
928 STA32X_CONFE_MPC : 0); in sta32x_probe()
929 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
931 pdata->am_reduction_mode ? in sta32x_probe()
932 STA32X_CONFE_AME : 0); in sta32x_probe()
933 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
935 pdata->odd_pwm_speed_mode ? in sta32x_probe()
936 STA32X_CONFE_PWMS : 0); in sta32x_probe()
939 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_probe()
941 pdata->invalid_input_detect_mute ? in sta32x_probe()
942 STA32X_CONFF_IDE : 0); in sta32x_probe()
945 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_probe()
947 pdata->output_conf in sta32x_probe()
951 regmap_update_bits(sta32x->regmap, STA32X_C1CFG, in sta32x_probe()
953 pdata->ch1_output_mapping in sta32x_probe()
955 regmap_update_bits(sta32x->regmap, STA32X_C2CFG, in sta32x_probe()
957 pdata->ch2_output_mapping in sta32x_probe()
959 regmap_update_bits(sta32x->regmap, STA32X_C3CFG, in sta32x_probe()
961 pdata->ch3_output_mapping in sta32x_probe()
966 sta32x->coef_shadow[i] = 0x400000; in sta32x_probe()
968 sta32x->coef_shadow[i] = 0x7fffff; in sta32x_probe()
969 sta32x->coef_shadow[55] = 0x5a9df7; in sta32x_probe()
970 sta32x->coef_shadow[56] = 0x7fffff; in sta32x_probe()
971 sta32x->coef_shadow[59] = 0x7fffff; in sta32x_probe()
972 sta32x->coef_shadow[60] = 0x400000; in sta32x_probe()
973 sta32x->coef_shadow[61] = 0x400000; in sta32x_probe()
975 if (sta32x->pdata->needs_esd_watchdog) in sta32x_probe()
976 INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog); in sta32x_probe()
980 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_probe()
982 return 0; in sta32x_probe()
985 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_probe()
987 if (sta32x->xti_clk) in sta32x_probe()
988 clk_disable_unprepare(sta32x->xti_clk); in sta32x_probe()
997 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_remove()
999 if (sta32x->xti_clk) in sta32x_remove()
1000 clk_disable_unprepare(sta32x->xti_clk); in sta32x_remove()
1040 struct device_node *np = dev->of_node; in sta32x_probe_dt()
1046 return -ENOMEM; in sta32x_probe_dt()
1048 of_property_read_u8(np, "st,output-conf", in sta32x_probe_dt()
1049 &pdata->output_conf); in sta32x_probe_dt()
1050 of_property_read_u8(np, "st,ch1-output-mapping", in sta32x_probe_dt()
1051 &pdata->ch1_output_mapping); in sta32x_probe_dt()
1052 of_property_read_u8(np, "st,ch2-output-mapping", in sta32x_probe_dt()
1053 &pdata->ch2_output_mapping); in sta32x_probe_dt()
1054 of_property_read_u8(np, "st,ch3-output-mapping", in sta32x_probe_dt()
1055 &pdata->ch3_output_mapping); in sta32x_probe_dt()
1057 if (of_get_property(np, "st,fault-detect-recovery", NULL)) in sta32x_probe_dt()
1058 pdata->fault_detect_recovery = 1; in sta32x_probe_dt()
1059 if (of_get_property(np, "st,thermal-warning-recovery", NULL)) in sta32x_probe_dt()
1060 pdata->thermal_warning_recovery = 1; in sta32x_probe_dt()
1061 if (of_get_property(np, "st,thermal-warning-adjustment", NULL)) in sta32x_probe_dt()
1062 pdata->thermal_warning_adjustment = 1; in sta32x_probe_dt()
1064 pdata->needs_esd_watchdog = 1; in sta32x_probe_dt()
1067 of_property_read_u16(np, "st,drop-compensation-ns", &tmp); in sta32x_probe_dt()
1068 pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20; in sta32x_probe_dt()
1071 if (of_get_property(np, "st,max-power-use-mpcc", NULL)) in sta32x_probe_dt()
1072 pdata->max_power_use_mpcc = 1; in sta32x_probe_dt()
1074 if (of_get_property(np, "st,max-power-correction", NULL)) in sta32x_probe_dt()
1075 pdata->max_power_correction = 1; in sta32x_probe_dt()
1077 if (of_get_property(np, "st,am-reduction-mode", NULL)) in sta32x_probe_dt()
1078 pdata->am_reduction_mode = 1; in sta32x_probe_dt()
1080 if (of_get_property(np, "st,odd-pwm-speed-mode", NULL)) in sta32x_probe_dt()
1081 pdata->odd_pwm_speed_mode = 1; in sta32x_probe_dt()
1084 if (of_get_property(np, "st,invalid-input-detect-mute", NULL)) in sta32x_probe_dt()
1085 pdata->invalid_input_detect_mute = 1; in sta32x_probe_dt()
1087 sta32x->pdata = pdata; in sta32x_probe_dt()
1089 return 0; in sta32x_probe_dt()
1095 struct device *dev = &i2c->dev; in sta32x_i2c_probe()
1099 sta32x = devm_kzalloc(&i2c->dev, sizeof(struct sta32x_priv), in sta32x_i2c_probe()
1102 return -ENOMEM; in sta32x_i2c_probe()
1104 mutex_init(&sta32x->coeff_lock); in sta32x_i2c_probe()
1105 sta32x->pdata = dev_get_platdata(dev); in sta32x_i2c_probe()
1108 if (dev->of_node) { in sta32x_i2c_probe()
1110 if (ret < 0) in sta32x_i2c_probe()
1116 sta32x->xti_clk = devm_clk_get(dev, "xti"); in sta32x_i2c_probe()
1117 if (IS_ERR(sta32x->xti_clk)) { in sta32x_i2c_probe()
1118 ret = PTR_ERR(sta32x->xti_clk); in sta32x_i2c_probe()
1120 if (ret == -EPROBE_DEFER) in sta32x_i2c_probe()
1123 sta32x->xti_clk = NULL; in sta32x_i2c_probe()
1127 sta32x->gpiod_nreset = devm_gpiod_get_optional(dev, "reset", in sta32x_i2c_probe()
1129 if (IS_ERR(sta32x->gpiod_nreset)) in sta32x_i2c_probe()
1130 return PTR_ERR(sta32x->gpiod_nreset); in sta32x_i2c_probe()
1133 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++) in sta32x_i2c_probe()
1134 sta32x->supplies[i].supply = sta32x_supply_names[i]; in sta32x_i2c_probe()
1136 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(sta32x->supplies), in sta32x_i2c_probe()
1137 sta32x->supplies); in sta32x_i2c_probe()
1138 if (ret != 0) { in sta32x_i2c_probe()
1139 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); in sta32x_i2c_probe()
1143 sta32x->regmap = devm_regmap_init_i2c(i2c, &sta32x_regmap); in sta32x_i2c_probe()
1144 if (IS_ERR(sta32x->regmap)) { in sta32x_i2c_probe()
1145 ret = PTR_ERR(sta32x->regmap); in sta32x_i2c_probe()
1154 if (ret < 0) in sta32x_i2c_probe()
1161 { "sta326", 0 },
1162 { "sta328", 0 },
1163 { "sta329", 0 },