max98390.c (dc5fb6d2e8dff0dd61c9b55508c46e73a67e9ea8) max98390.c (aa785705685e583215f598bc538703388267e76e)
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

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

673 MAX98390_PCM_RX_CH_SRC_SHIFT,
674 3, max98390_switch_text);
675
676static const struct snd_kcontrol_new max98390_dai_controls =
677 SOC_DAPM_ENUM("DAI Sel", dai_sel_enum);
678
679static const struct snd_soc_dapm_widget max98390_dapm_widgets[] = {
680 SND_SOC_DAPM_DAC_E("Amp Enable", "HiFi Playback",
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

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

673 MAX98390_PCM_RX_CH_SRC_SHIFT,
674 3, max98390_switch_text);
675
676static const struct snd_kcontrol_new max98390_dai_controls =
677 SOC_DAPM_ENUM("DAI Sel", dai_sel_enum);
678
679static const struct snd_soc_dapm_widget max98390_dapm_widgets[] = {
680 SND_SOC_DAPM_DAC_E("Amp Enable", "HiFi Playback",
681 SND_SOC_NOPM, 0, 0, max98390_dac_event,
681 MAX98390_R203A_AMP_EN, 0, 0, max98390_dac_event,
682 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
683 SND_SOC_DAPM_MUX("DAI Sel Mux", SND_SOC_NOPM, 0, 0,
684 &max98390_dai_controls),
685 SND_SOC_DAPM_OUTPUT("BE_OUT"),
686};
687
688static const struct snd_soc_dapm_route max98390_audio_map[] = {
689 /* Plabyack */

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

785 dev_err(component->dev,
786 "param fw is invalid.\n");
787 goto err_alloc;
788 }
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 ||
682 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
683 SND_SOC_DAPM_MUX("DAI Sel Mux", SND_SOC_NOPM, 0, 0,
684 &max98390_dai_controls),
685 SND_SOC_DAPM_OUTPUT("BE_OUT"),
686};
687
688static const struct snd_soc_dapm_route max98390_audio_map[] = {
689 /* Plabyack */

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

785 dev_err(component->dev,
786 "param fw is invalid.\n");
787 goto err_alloc;
788 }
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 ||
793 param_start_addr < MAX98390_IRQ_CTRL ||
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);
800 dsm_param += MAX98390_DSM_PAYLOAD_OFFSET;
801 regmap_bulk_write(max98390->regmap, param_start_addr,

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

837 rdc_integer, rdc_factor, rdc_cal_result, temp);
838
839 regmap_write(max98390->regmap, MAX98390_R23FF_GLOBAL_EN, 0x00);
840 regmap_write(max98390->regmap, MAX98390_R203A_AMP_EN, 0x80);
841
842 return 0;
843}
844
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);
800 dsm_param += MAX98390_DSM_PAYLOAD_OFFSET;
801 regmap_bulk_write(max98390->regmap, param_start_addr,

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

837 rdc_integer, rdc_factor, rdc_cal_result, temp);
838
839 regmap_write(max98390->regmap, MAX98390_R23FF_GLOBAL_EN, 0x00);
840 regmap_write(max98390->regmap, MAX98390_R203A_AMP_EN, 0x80);
841
842 return 0;
843}
844
845static void max98390_init_regs(struct snd_soc_component *component)
846{
847 struct max98390_priv *max98390 =
848 snd_soc_component_get_drvdata(component);
849
850 regmap_write(max98390->regmap, MAX98390_CLK_MON, 0x6f);
851 regmap_write(max98390->regmap, MAX98390_DAT_MON, 0x00);
852 regmap_write(max98390->regmap, MAX98390_PWR_GATE_CTL, 0x00);
853 regmap_write(max98390->regmap, MAX98390_PCM_RX_EN_A, 0x03);
854 regmap_write(max98390->regmap, MAX98390_ENV_TRACK_VOUT_HEADROOM, 0x0e);
855 regmap_write(max98390->regmap, MAX98390_BOOST_BYPASS1, 0x46);
856 regmap_write(max98390->regmap, MAX98390_FET_SCALING3, 0x03);
857}
858
845static int max98390_probe(struct snd_soc_component *component)
846{
847 struct max98390_priv *max98390 =
848 snd_soc_component_get_drvdata(component);
849
850 regmap_write(max98390->regmap, MAX98390_SOFTWARE_RESET, 0x01);
851 /* Sleep reset settle time */
852 msleep(20);
859static int max98390_probe(struct snd_soc_component *component)
860{
861 struct max98390_priv *max98390 =
862 snd_soc_component_get_drvdata(component);
863
864 regmap_write(max98390->regmap, MAX98390_SOFTWARE_RESET, 0x01);
865 /* Sleep reset settle time */
866 msleep(20);
867
868 /* Amp init setting */
869 max98390_init_regs(component);
853 /* Update dsm bin param */
854 max98390_dsm_init(component);
855
870 /* Update dsm bin param */
871 max98390_dsm_init(component);
872
856 /* Amp Setting */
857 regmap_write(max98390->regmap, MAX98390_CLK_MON, 0x6f);
858 regmap_write(max98390->regmap, MAX98390_PCM_RX_EN_A, 0x03);
859 regmap_write(max98390->regmap, MAX98390_PWR_GATE_CTL, 0x2d);
860 regmap_write(max98390->regmap, MAX98390_ENV_TRACK_VOUT_HEADROOM, 0x0e);
861 regmap_write(max98390->regmap, MAX98390_BOOST_BYPASS1, 0x46);
862 regmap_write(max98390->regmap, MAX98390_FET_SCALING3, 0x03);
863
864 /* Dsm Setting */
873 /* Dsm Setting */
865 regmap_write(max98390->regmap, DSM_VOL_CTRL, 0x94);
866 regmap_write(max98390->regmap, DSMIG_EN, 0x19);
867 regmap_write(max98390->regmap, MAX98390_R203A_AMP_EN, 0x80);
868 if (max98390->ref_rdc_value) {
869 regmap_write(max98390->regmap, DSM_TPROT_RECIP_RDC_ROOM_BYTE0,
870 max98390->ref_rdc_value & 0x000000ff);
871 regmap_write(max98390->regmap, DSM_TPROT_RECIP_RDC_ROOM_BYTE1,
872 (max98390->ref_rdc_value >> 8) & 0x000000ff);
873 regmap_write(max98390->regmap, DSM_TPROT_RECIP_RDC_ROOM_BYTE2,
874 (max98390->ref_rdc_value >> 16) & 0x000000ff);
875 }

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

933 .max_register = MAX98390_R24FF_REV_ID,
934 .reg_defaults = max98390_reg_defaults,
935 .num_reg_defaults = ARRAY_SIZE(max98390_reg_defaults),
936 .readable_reg = max98390_readable_register,
937 .volatile_reg = max98390_volatile_reg,
938 .cache_type = REGCACHE_RBTREE,
939};
940
874 if (max98390->ref_rdc_value) {
875 regmap_write(max98390->regmap, DSM_TPROT_RECIP_RDC_ROOM_BYTE0,
876 max98390->ref_rdc_value & 0x000000ff);
877 regmap_write(max98390->regmap, DSM_TPROT_RECIP_RDC_ROOM_BYTE1,
878 (max98390->ref_rdc_value >> 8) & 0x000000ff);
879 regmap_write(max98390->regmap, DSM_TPROT_RECIP_RDC_ROOM_BYTE2,
880 (max98390->ref_rdc_value >> 16) & 0x000000ff);
881 }

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

939 .max_register = MAX98390_R24FF_REV_ID,
940 .reg_defaults = max98390_reg_defaults,
941 .num_reg_defaults = ARRAY_SIZE(max98390_reg_defaults),
942 .readable_reg = max98390_readable_register,
943 .volatile_reg = max98390_volatile_reg,
944 .cache_type = REGCACHE_RBTREE,
945};
946
941#ifdef CONFIG_OF
942static const struct of_device_id max98390_dt_ids[] = {
943 { .compatible = "maxim,max98390", },
944 { }
945};
946MODULE_DEVICE_TABLE(of, max98390_dt_ids);
947#endif
948
949static int max98390_i2c_probe(struct i2c_client *i2c,
950 const struct i2c_device_id *id)
951{
952 int ret = 0;
953 int reg = 0;
954
955 struct max98390_priv *max98390 = NULL;
956 struct i2c_adapter *adapter = to_i2c_adapter(i2c->dev.parent);

--- 100 unchanged lines hidden ---
947static int max98390_i2c_probe(struct i2c_client *i2c,
948 const struct i2c_device_id *id)
949{
950 int ret = 0;
951 int reg = 0;
952
953 struct max98390_priv *max98390 = NULL;
954 struct i2c_adapter *adapter = to_i2c_adapter(i2c->dev.parent);

--- 100 unchanged lines hidden ---