max98390.c (f77d26a9fc525286bcef3d4f98b52e17482cf49c) max98390.c (4008b29eb47433c15ed3f242ee0132ba27dbdb67)
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

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

695
696static bool max98390_readable_register(struct device *dev, unsigned int reg)
697{
698 switch (reg) {
699 case MAX98390_SOFTWARE_RESET ... MAX98390_INT_EN3:
700 case MAX98390_IRQ_CTRL ... MAX98390_WDOG_CTRL:
701 case MAX98390_MEAS_ADC_THERM_WARN_THRESH
702 ... MAX98390_BROWNOUT_INFINITE_HOLD:
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

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

695
696static bool max98390_readable_register(struct device *dev, unsigned int reg)
697{
698 switch (reg) {
699 case MAX98390_SOFTWARE_RESET ... MAX98390_INT_EN3:
700 case MAX98390_IRQ_CTRL ... MAX98390_WDOG_CTRL:
701 case MAX98390_MEAS_ADC_THERM_WARN_THRESH
702 ... MAX98390_BROWNOUT_INFINITE_HOLD:
703 case MAX98390_BROWNOUT_LVL_HOLD ... THERMAL_COILTEMP_RD_BACK_BYTE0:
704 case DSMIG_DEBUZZER_THRESHOLD ... MAX98390_R24FF_REV_ID:
703 case MAX98390_BROWNOUT_LVL_HOLD ... DSMIG_DEBUZZER_THRESHOLD:
704 case DSM_VOL_ENA ... MAX98390_R24FF_REV_ID:
705 return true;
706 default:
707 return false;
708 }
709};
710
711static bool max98390_volatile_reg(struct device *dev, unsigned int reg)
712{
713 switch (reg) {
714 case MAX98390_SOFTWARE_RESET ... MAX98390_INT_EN3:
715 case MAX98390_MEAS_ADC_CH0_READ ... MAX98390_MEAS_ADC_CH2_READ:
716 case MAX98390_PWR_GATE_STATUS ... MAX98390_BROWNOUT_STATUS:
717 case MAX98390_BROWNOUT_LOWEST_STATUS:
718 case MAX98390_ENV_TRACK_BOOST_VOUT_READ:
719 case DSM_STBASS_HPF_B0_BYTE0 ... DSM_DEBUZZER_ATTACK_TIME_BYTE2:
705 return true;
706 default:
707 return false;
708 }
709};
710
711static bool max98390_volatile_reg(struct device *dev, unsigned int reg)
712{
713 switch (reg) {
714 case MAX98390_SOFTWARE_RESET ... MAX98390_INT_EN3:
715 case MAX98390_MEAS_ADC_CH0_READ ... MAX98390_MEAS_ADC_CH2_READ:
716 case MAX98390_PWR_GATE_STATUS ... MAX98390_BROWNOUT_STATUS:
717 case MAX98390_BROWNOUT_LOWEST_STATUS:
718 case MAX98390_ENV_TRACK_BOOST_VOUT_READ:
719 case DSM_STBASS_HPF_B0_BYTE0 ... DSM_DEBUZZER_ATTACK_TIME_BYTE2:
720 case THERMAL_RDC_RD_BACK_BYTE1 ... THERMAL_COILTEMP_RD_BACK_BYTE0:
720 case THERMAL_RDC_RD_BACK_BYTE1 ... DSMIG_DEBUZZER_THRESHOLD:
721 case DSM_THERMAL_GAIN ... DSM_WBDRC_GAIN:
722 return true;
723 default:
724 return false;
725 }
726}
727
728#define MAX98390_RATES SNDRV_PCM_RATE_8000_48000

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

749 },
750 .ops = &max98390_dai_ops,
751 }
752};
753
754static int max98390_dsm_init(struct snd_soc_component *component)
755{
756 int ret;
721 case DSM_THERMAL_GAIN ... DSM_WBDRC_GAIN:
722 return true;
723 default:
724 return false;
725 }
726}
727
728#define MAX98390_RATES SNDRV_PCM_RATE_8000_48000

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

749 },
750 .ops = &max98390_dai_ops,
751 }
752};
753
754static int max98390_dsm_init(struct snd_soc_component *component)
755{
756 int ret;
757 int param_size, param_start_addr;
757 char filename[128];
758 const char *vendor, *product;
759 struct max98390_priv *max98390 =
760 snd_soc_component_get_drvdata(component);
761 const struct firmware *fw;
762 char *dsm_param;
763
764 vendor = dmi_get_system_info(DMI_SYS_VENDOR);

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

773 ret = request_firmware(&fw, filename, component->dev);
774 if (ret) {
775 ret = request_firmware(&fw, "dsm_param.bin", component->dev);
776 if (ret)
777 goto err;
778 }
779
780 dev_dbg(component->dev,
758 char filename[128];
759 const char *vendor, *product;
760 struct max98390_priv *max98390 =
761 snd_soc_component_get_drvdata(component);
762 const struct firmware *fw;
763 char *dsm_param;
764
765 vendor = dmi_get_system_info(DMI_SYS_VENDOR);

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

774 ret = request_firmware(&fw, filename, component->dev);
775 if (ret) {
776 ret = request_firmware(&fw, "dsm_param.bin", component->dev);
777 if (ret)
778 goto err;
779 }
780
781 dev_dbg(component->dev,
781 "max98390: param fw size %ld\n",
782 "max98390: param fw size %zd\n",
782 fw->size);
783 fw->size);
784 if (fw->size < MAX98390_DSM_PARAM_MIN_SIZE) {
785 dev_err(component->dev,
786 "param fw is invalid.\n");
787 goto err_alloc;
788 }
783 dsm_param = (char *)fw->data;
789 dsm_param = (char *)fw->data;
790 param_start_addr = (dsm_param[0] & 0xff) | (dsm_param[1] & 0xff) << 8;
791 param_size = (dsm_param[2] & 0xff) | (dsm_param[3] & 0xff) << 8;
792 if (param_size > MAX98390_DSM_PARAM_MAX_SIZE ||
793 param_start_addr < DSM_STBASS_HPF_B0_BYTE0 ||
794 fw->size < param_size + MAX98390_DSM_PAYLOAD_OFFSET) {
795 dev_err(component->dev,
796 "param fw is invalid.\n");
797 goto err_alloc;
798 }
799 regmap_write(max98390->regmap, MAX98390_R203A_AMP_EN, 0x80);
784 dsm_param += MAX98390_DSM_PAYLOAD_OFFSET;
800 dsm_param += MAX98390_DSM_PAYLOAD_OFFSET;
785 regmap_bulk_write(max98390->regmap, DSM_EQ_BQ1_B0_BYTE0,
786 dsm_param,
787 fw->size - MAX98390_DSM_PAYLOAD_OFFSET);
788 release_firmware(fw);
801 regmap_bulk_write(max98390->regmap, param_start_addr,
802 dsm_param, param_size);
789 regmap_write(max98390->regmap, MAX98390_R23E1_DSP_GLOBAL_EN, 0x01);
790
803 regmap_write(max98390->regmap, MAX98390_R23E1_DSP_GLOBAL_EN, 0x01);
804
805err_alloc:
806 release_firmware(fw);
791err:
792 return ret;
793}
794
795static int max98390_dsm_calibrate(struct snd_soc_component *component)
796{
797 unsigned int rdc, rdc_cal_result, temp;
798 unsigned int rdc_integer, rdc_factor;

--- 242 unchanged lines hidden ---
807err:
808 return ret;
809}
810
811static int max98390_dsm_calibrate(struct snd_soc_component *component)
812{
813 unsigned int rdc, rdc_cal_result, temp;
814 unsigned int rdc_integer, rdc_factor;

--- 242 unchanged lines hidden ---