linux/sound/soc/codecs/max98396.c

// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2022, Analog Devices Inc.

#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <sound/pcm_params.h>
#include <linux/regulator/consumer.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#include "max98396.h"

static const char * const max98396_core_supplies[MAX98396_NUM_CORE_SUPPLIES] =;

static struct reg_default max98396_reg[] =;

static struct reg_default max98397_reg[] =;

static void max98396_global_enable_onoff(struct regmap *regmap, bool onoff)
{}

static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{}

#define MAX98396_BSEL_32
#define MAX98396_BSEL_48
#define MAX98396_BSEL_64
#define MAX98396_BSEL_96
#define MAX98396_BSEL_128
#define MAX98396_BSEL_192
#define MAX98396_BSEL_256
#define MAX98396_BSEL_384
#define MAX98396_BSEL_512
#define MAX98396_BSEL_320
#define MAX98396_BSEL_250
#define MAX98396_BSEL_125

/* Refer to table 5 in the datasheet */
static const struct max98396_pcm_config {} max98396_pcm_configs[] =;

static int max98396_pcm_config_index(int in_slots, int out_slots, int width)
{}

static int max98396_dai_hw_params(struct snd_pcm_substream *substream,
				  struct snd_pcm_hw_params *params,
				  struct snd_soc_dai *dai)
{}

static int max98396_dai_tdm_slot(struct snd_soc_dai *dai,
				 unsigned int tx_mask, unsigned int rx_mask,
				 int slots, int slot_width)
{}

#define MAX98396_RATES

#define MAX98396_FORMATS

static const struct snd_soc_dai_ops max98396_dai_ops =;

static int max98396_dac_event(struct snd_soc_dapm_widget *w,
			      struct snd_kcontrol *kcontrol, int event)
{}

static bool max98396_readable_register(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case MAX98396_R2001_INT_RAW1 ... MAX98396_R2004_INT_RAW4:
	case MAX98396_R2006_INT_STATE1 ... MAX98396_R2009_INT_STATE4:
	case MAX98396_R200B_INT_FLAG1 ... MAX98396_R200E_INT_FLAG4:
	case MAX98396_R2010_INT_EN1 ... MAX98396_R2013_INT_EN4:
	case MAX98396_R2015_INT_FLAG_CLR1 ... MAX98396_R2018_INT_FLAG_CLR4:
	case MAX98396_R201F_IRQ_CTRL ... MAX98396_R2024_THERM_FOLDBACK_SET:
	case MAX98396_R2027_THERM_FOLDBACK_EN:
	case MAX98396_R2030_NOISEGATE_MODE_CTRL:
	case MAX98396_R2033_NOISEGATE_MODE_EN:
	case MAX98396_R2038_CLK_MON_CTRL ... MAX98396_R2039_DATA_MON_CTRL:
	case MAX98396_R203F_ENABLE_CTRLS ... MAX98396_R2053_PCM_TX_HIZ_CTRL_8:
	case MAX98396_R2055_PCM_RX_SRC1 ... MAX98396_R2056_PCM_RX_SRC2:
	case MAX98396_R2058_PCM_BYPASS_SRC:
	case MAX98396_R205D_PCM_TX_SRC_EN ... MAX98396_R205F_PCM_TX_EN:
	case MAX98396_R2070_ICC_RX_EN_A... MAX98396_R2072_ICC_TX_CTRL:
	case MAX98396_R207F_ICC_EN:
	case MAX98396_R2083_TONE_GEN_DC_CFG ... MAX98396_R2086_TONE_GEN_DC_LVL3:
	case MAX98396_R208F_TONE_GEN_EN ... MAX98396_R209A_SPK_EDGE_CTRL:
	case MAX98396_R209C_SPK_EDGE_CTRL1 ... MAX98396_R20A0_AMP_SUPPLY_CTL:
	case MAX98396_R20AF_AMP_EN ... MAX98396_R20BF_ADC_LO_VBAT_READBACK_LSB:
	case MAX98396_R20C7_ADC_CFG:
	case MAX98396_R20D0_DHT_CFG1 ... MAX98396_R20D6_DHT_HYSTERESIS_CFG:
	case MAX98396_R20DF_DHT_EN:
	case MAX98396_R20E0_IV_SENSE_PATH_CFG:
	case MAX98396_R20E4_IV_SENSE_PATH_EN
		... MAX98396_R2106_BPE_THRESH_HYSTERESIS:
	case MAX98396_R2108_BPE_SUPPLY_SRC ... MAX98396_R210B_BPE_LOW_LIMITER:
	case MAX98396_R210D_BPE_EN ... MAX98396_R210F_GLOBAL_EN:
	case MAX98396_R21FF_REVISION_ID:
		return true;
	default:
		return false;
	}
};

static bool max98396_volatile_reg(struct device *dev, unsigned int reg)
{}

static bool max98397_readable_register(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case MAX98396_R2001_INT_RAW1 ... MAX98396_R2004_INT_RAW4:
	case MAX98396_R2006_INT_STATE1 ... MAX98396_R2009_INT_STATE4:
	case MAX98396_R200B_INT_FLAG1 ... MAX98396_R200E_INT_FLAG4:
	case MAX98396_R2010_INT_EN1 ... MAX98396_R2013_INT_EN4:
	case MAX98396_R2015_INT_FLAG_CLR1 ... MAX98396_R2018_INT_FLAG_CLR4:
	case MAX98396_R201F_IRQ_CTRL ... MAX98396_R2024_THERM_FOLDBACK_SET:
	case MAX98396_R2027_THERM_FOLDBACK_EN:
	case MAX98396_R2030_NOISEGATE_MODE_CTRL:
	case MAX98396_R2033_NOISEGATE_MODE_EN:
	case MAX98396_R2038_CLK_MON_CTRL ... MAX98397_R203A_SPK_MON_THRESH:
	case MAX98396_R203F_ENABLE_CTRLS ... MAX98397_R2054_PCM_TX_HIZ_CTRL_8:
	case MAX98397_R2056_PCM_RX_SRC1... MAX98396_R2058_PCM_BYPASS_SRC:
	case MAX98396_R205D_PCM_TX_SRC_EN ... MAX98397_R2060_PCM_TX_SUPPLY_SEL:
	case MAX98396_R2070_ICC_RX_EN_A... MAX98396_R2072_ICC_TX_CTRL:
	case MAX98396_R207F_ICC_EN:
	case MAX98396_R2083_TONE_GEN_DC_CFG ... MAX98396_R2086_TONE_GEN_DC_LVL3:
	case MAX98396_R208F_TONE_GEN_EN ... MAX98396_R209F_BYPASS_PATH_CFG:
	case MAX98396_R20AF_AMP_EN ... MAX98397_R20C5_MEAS_ADC_OPTIMAL_MODE:
	case MAX98396_R20C7_ADC_CFG:
	case MAX98396_R20D0_DHT_CFG1 ... MAX98396_R20D6_DHT_HYSTERESIS_CFG:
	case MAX98396_R20DF_DHT_EN:
	case MAX98396_R20E0_IV_SENSE_PATH_CFG:
	case MAX98396_R20E4_IV_SENSE_PATH_EN
		... MAX98396_R2106_BPE_THRESH_HYSTERESIS:
	case MAX98396_R2108_BPE_SUPPLY_SRC ... MAX98396_R210B_BPE_LOW_LIMITER:
	case MAX98396_R210D_BPE_EN ... MAX98396_R210F_GLOBAL_EN:
	case MAX98397_R22FF_REVISION_ID:
		return true;
	default:
		return false;
	}
};

static bool max98397_volatile_reg(struct device *dev, unsigned int reg)
{}

static const char * const max98396_op_mod_text[] =;

static SOC_ENUM_SINGLE_DECL(max98396_op_mod_enum,
			    MAX98396_R2098_SPK_CLS_DG_MODE,
			    0, max98396_op_mod_text);

static DECLARE_TLV_DB_SCALE(max98396_digital_tlv, -6350, 50, 1);
static const DECLARE_TLV_DB_RANGE(max98396_spk_tlv,
	0, 0x11, TLV_DB_SCALE_ITEM(400, 100, 0),
);
static DECLARE_TLV_DB_RANGE(max98397_digital_tlv,
	0, 0x4A, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
	0x4B, 0xFF, TLV_DB_SCALE_ITEM(-9000, 50, 0),
);
static const DECLARE_TLV_DB_RANGE(max98397_spk_tlv,
	0, 0x15, TLV_DB_SCALE_ITEM(600, 100, 0),
);

static int max98396_mux_get(struct snd_kcontrol *kcontrol,
			    struct snd_ctl_elem_value *ucontrol)
{}

static int max98396_mux_put(struct snd_kcontrol *kcontrol,
			    struct snd_ctl_elem_value *ucontrol)
{}

static const char * const max98396_switch_text[] =;

static SOC_ENUM_SINGLE_DECL(dai_sel_enum, SND_SOC_NOPM, 0,
			    max98396_switch_text);

static const struct snd_kcontrol_new max98396_dai_mux =;

static const struct snd_kcontrol_new max98396_vi_control =;

static const struct snd_soc_dapm_widget max98396_dapm_widgets[] =;

static const char * const max98396_thermal_thresh_text[] =;

static SOC_ENUM_SINGLE_DECL(max98396_thermal_warn_thresh1_enum,
			    MAX98396_R2020_THERM_WARN_THRESH, 0,
			    max98396_thermal_thresh_text);

static SOC_ENUM_SINGLE_DECL(max98396_thermal_warn_thresh2_enum,
			    MAX98396_R2021_THERM_WARN_THRESH2, 0,
			    max98396_thermal_thresh_text);

static SOC_ENUM_SINGLE_DECL(max98396_thermal_shdn_thresh_enum,
			    MAX98396_R2022_THERM_SHDN_THRESH, 0,
			    max98396_thermal_thresh_text);

static const char * const max98396_thermal_hyteresis_text[] =;

static SOC_ENUM_SINGLE_DECL(max98396_thermal_hysteresis_enum,
			    MAX98396_R2023_THERM_HYSTERESIS, 0,
			    max98396_thermal_hyteresis_text);

static const char * const max98396_foldback_slope_text[] =;

static SOC_ENUM_SINGLE_DECL(max98396_thermal_fb_slope1_enum,
			    MAX98396_R2024_THERM_FOLDBACK_SET,
			    MAX98396_THERM_FB_SLOPE1_SHIFT,
			    max98396_foldback_slope_text);

static SOC_ENUM_SINGLE_DECL(max98396_thermal_fb_slope2_enum,
			    MAX98396_R2024_THERM_FOLDBACK_SET,
			    MAX98396_THERM_FB_SLOPE2_SHIFT,
			    max98396_foldback_slope_text);

static const char * const max98396_foldback_reltime_text[] =;

static SOC_ENUM_SINGLE_DECL(max98396_thermal_fb_reltime_enum,
			    MAX98396_R2024_THERM_FOLDBACK_SET,
			    MAX98396_THERM_FB_REL_SHIFT,
			    max98396_foldback_reltime_text);

static const char * const max98396_foldback_holdtime_text[] =;

static SOC_ENUM_SINGLE_DECL(max98396_thermal_fb_holdtime_enum,
			    MAX98396_R2024_THERM_FOLDBACK_SET,
			    MAX98396_THERM_FB_HOLD_SHIFT,
			    max98396_foldback_holdtime_text);

static int max98396_adc_value_get(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new max98396_snd_controls[] =;

static const struct snd_kcontrol_new max98397_snd_controls[] =;

static const struct snd_soc_dapm_route max98396_audio_map[] =;

static struct snd_soc_dai_driver max98396_dai[] =;

static struct snd_soc_dai_driver max98397_dai[] =;

static void max98396_reset(struct max98396_priv *max98396, struct device *dev)
{}

static int max98396_probe(struct snd_soc_component *component)
{}

#ifdef CONFIG_PM_SLEEP
static int max98396_suspend(struct device *dev)
{}

static int max98396_resume(struct device *dev)
{}
#endif

static const struct dev_pm_ops max98396_pm =;

static const struct snd_soc_component_driver soc_codec_dev_max98396 =;

static const struct snd_soc_component_driver soc_codec_dev_max98397 =;

static const struct regmap_config max98396_regmap =;

static const struct regmap_config max98397_regmap =;

static void max98396_read_device_property(struct device *dev,
					  struct max98396_priv *max98396)
{}

static void max98396_core_supplies_disable(void *priv)
{}

static void max98396_supply_disable(void *r)
{}

static int max98396_i2c_probe(struct i2c_client *i2c)
{}

static const struct i2c_device_id max98396_i2c_id[] =;

MODULE_DEVICE_TABLE(i2c, max98396_i2c_id);

#if defined(CONFIG_OF)
static const struct of_device_id max98396_of_match[] =;
MODULE_DEVICE_TABLE(of, max98396_of_match);
#endif

#ifdef CONFIG_ACPI
static const struct acpi_device_id max98396_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, max98396_acpi_match);
#endif

static struct i2c_driver max98396_i2c_driver =;

module_i2c_driver()

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();