max98390.c (2a906db2824b75444982f5e9df870106982afca8) max98390.c (6ac246105b4fd737ed51b8ac3ef031f837686dee)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * max98390.c -- MAX98390 ALSA Soc Audio driver
4 *
5 * Copyright (C) 2020 Maxim Integrated Products
6 *
7 */
8

--- 621 unchanged lines hidden (view full) ---

630{
631 /* Do nothing */
632 return 0;
633}
634
635static int max98390_dsm_calib_put(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
637{
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * max98390.c -- MAX98390 ALSA Soc Audio driver
4 *
5 * Copyright (C) 2020 Maxim Integrated Products
6 *
7 */
8

--- 621 unchanged lines hidden (view full) ---

630{
631 /* Do nothing */
632 return 0;
633}
634
635static int max98390_dsm_calib_put(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
637{
638 unsigned int val;
638 struct snd_soc_component *component =
639 snd_soc_kcontrol_component(kcontrol);
639 struct snd_soc_component *component =
640 snd_soc_kcontrol_component(kcontrol);
641 struct max98390_priv *max98390 =
642 snd_soc_component_get_drvdata(component);
640
643
641 max98390_dsm_calibrate(component);
644 regmap_read(max98390->regmap, MAX98390_R23FF_GLOBAL_EN, &val);
645 if (val == 0x1)
646 max98390_dsm_calibrate(component);
647 else {
648 dev_err(component->dev, "AMP is not ready to run calibration\n");
649 return -ECANCELED;
650 }
642
643 return 0;
644}
645
646static const struct snd_kcontrol_new max98390_snd_controls[] = {
647 SOC_SINGLE_TLV("Digital Volume", DSM_VOL_CTRL,
648 0, 184, 0,
649 max98390_digital_tlv),

--- 171 unchanged lines hidden (view full) ---

821
822static int max98390_dsm_calibrate(struct snd_soc_component *component)
823{
824 unsigned int rdc, rdc_cal_result, temp;
825 unsigned int rdc_integer, rdc_factor;
826 struct max98390_priv *max98390 =
827 snd_soc_component_get_drvdata(component);
828
651
652 return 0;
653}
654
655static const struct snd_kcontrol_new max98390_snd_controls[] = {
656 SOC_SINGLE_TLV("Digital Volume", DSM_VOL_CTRL,
657 0, 184, 0,
658 max98390_digital_tlv),

--- 171 unchanged lines hidden (view full) ---

830
831static int max98390_dsm_calibrate(struct snd_soc_component *component)
832{
833 unsigned int rdc, rdc_cal_result, temp;
834 unsigned int rdc_integer, rdc_factor;
835 struct max98390_priv *max98390 =
836 snd_soc_component_get_drvdata(component);
837
829 regmap_write(max98390->regmap, MAX98390_R203A_AMP_EN, 0x81);
830 regmap_write(max98390->regmap, MAX98390_R23FF_GLOBAL_EN, 0x01);
831
832 regmap_read(max98390->regmap,
833 THERMAL_RDC_RD_BACK_BYTE1, &rdc);
834 regmap_read(max98390->regmap,
835 THERMAL_RDC_RD_BACK_BYTE0, &rdc_cal_result);
836 rdc_cal_result |= (rdc << 8) & 0x0000FFFF;
837 if (rdc_cal_result)
838 max98390->ref_rdc_value = 268435456U / rdc_cal_result;
839
840 regmap_read(max98390->regmap, MAX98390_MEAS_ADC_CH2_READ, &temp);
841 max98390->ambient_temp_value = temp * 52 - 1188;
842
843 rdc_integer = rdc_cal_result * 937 / 65536;
844 rdc_factor = ((rdc_cal_result * 937 * 100) / 65536)
845 - (rdc_integer * 100);
846
847 dev_info(component->dev, "rdc resistance about %d.%02d ohm, reg=0x%X temp reg=0x%X\n",
848 rdc_integer, rdc_factor, rdc_cal_result, temp);
849
838 regmap_read(max98390->regmap,
839 THERMAL_RDC_RD_BACK_BYTE1, &rdc);
840 regmap_read(max98390->regmap,
841 THERMAL_RDC_RD_BACK_BYTE0, &rdc_cal_result);
842 rdc_cal_result |= (rdc << 8) & 0x0000FFFF;
843 if (rdc_cal_result)
844 max98390->ref_rdc_value = 268435456U / rdc_cal_result;
845
846 regmap_read(max98390->regmap, MAX98390_MEAS_ADC_CH2_READ, &temp);
847 max98390->ambient_temp_value = temp * 52 - 1188;
848
849 rdc_integer = rdc_cal_result * 937 / 65536;
850 rdc_factor = ((rdc_cal_result * 937 * 100) / 65536)
851 - (rdc_integer * 100);
852
853 dev_info(component->dev, "rdc resistance about %d.%02d ohm, reg=0x%X temp reg=0x%X\n",
854 rdc_integer, rdc_factor, rdc_cal_result, temp);
855
850 regmap_write(max98390->regmap, MAX98390_R23FF_GLOBAL_EN, 0x00);
851 regmap_write(max98390->regmap, MAX98390_R203A_AMP_EN, 0x80);
852
853 return 0;
854}
855
856static void max98390_init_regs(struct snd_soc_component *component)
857{
858 struct max98390_priv *max98390 =
859 snd_soc_component_get_drvdata(component);
860

--- 282 unchanged lines hidden ---
856 return 0;
857}
858
859static void max98390_init_regs(struct snd_soc_component *component)
860{
861 struct max98390_priv *max98390 =
862 snd_soc_component_get_drvdata(component);
863

--- 282 unchanged lines hidden ---