linux/sound/soc/codecs/wcd938x.c

// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.

#include <linux/module.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/pm_runtime.h>
#include <linux/component.h>
#include <sound/tlv.h>
#include <linux/of_gpio.h>
#include <linux/of.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <linux/regmap.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <linux/regulator/consumer.h>

#include "wcd-clsh-v2.h"
#include "wcd-mbhc-v2.h"
#include "wcd938x.h"

#define WCD938X_MAX_MICBIAS
#define WCD938X_MAX_SUPPLY
#define WCD938X_MBHC_MAX_BUTTONS
#define TX_ADC_MAX

#define WCD938X_RATES_MASK
/* Fractional Rates */
#define WCD938X_FRAC_RATES_MASK
#define WCD938X_FORMATS_S16_S24_LE
#define SWR_CLK_RATE_0P6MHZ
#define SWR_CLK_RATE_1P2MHZ
#define SWR_CLK_RATE_2P4MHZ
#define SWR_CLK_RATE_4P8MHZ
#define SWR_CLK_RATE_9P6MHZ
#define SWR_CLK_RATE_11P2896MHZ

#define EAR_RX_PATH_AUX

#define ADC_MODE_VAL_HIFI
#define ADC_MODE_VAL_LO_HIF
#define ADC_MODE_VAL_NORMAL
#define ADC_MODE_VAL_LP
#define ADC_MODE_VAL_ULP1
#define ADC_MODE_VAL_ULP2

/* Z value defined in milliohm */
#define WCD938X_ZDET_VAL_32
#define WCD938X_ZDET_VAL_400
#define WCD938X_ZDET_VAL_1200
#define WCD938X_ZDET_VAL_100K
/* Z floating defined in ohms */
#define WCD938X_ZDET_FLOATING_IMPEDANCE
#define WCD938X_ZDET_NUM_MEASUREMENTS
#define WCD938X_MBHC_GET_C1(c)
#define WCD938X_MBHC_GET_X1(x)
/* Z value compared in milliOhm */
#define WCD938X_MBHC_IS_SECOND_RAMP_REQUIRED(z)
#define WCD938X_MBHC_ZDET_CONST
#define WCD_MBHC_HS_V_MAX

#define WCD938X_EAR_PA_GAIN_TLV(xname, reg, shift, max, invert, tlv_array)

enum {};

enum {};

enum {};

enum {};

enum {};

static u8 tx_mode_bit[] =;

struct wcd938x_priv {};

static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800);
static const DECLARE_TLV_DB_SCALE(line_gain, -3000, 150, 0);
static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(analog_gain, 0, 3000);

struct wcd938x_mbhc_zdet_param {};

static const struct wcd_mbhc_field wcd_mbhc_fields[WCD_MBHC_REG_FUNC_MAX] =;

static const struct regmap_irq wcd938x_irqs[WCD938X_NUM_IRQS] =;

static struct regmap_irq_chip wcd938x_regmap_irq_chip =;

static int wcd938x_get_clk_rate(int mode)
{}

static int wcd938x_set_swr_clk_rate(struct snd_soc_component *component, int rate, int bank)
{}

static int wcd938x_io_init(struct wcd938x_priv *wcd938x)
{}

static int wcd938x_sdw_connect_port(const struct wcd938x_sdw_ch_info *ch_info,
				    struct sdw_port_config *port_config,
				    u8 enable)
{}

static int wcd938x_connect_port(struct wcd938x_sdw_priv *wcd, u8 port_num, u8 ch_id, u8 enable)
{}

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

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

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

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

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

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

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

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

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

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

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

static int wcd938x_get_adc_mode(int val)
{}

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

static void wcd938x_tx_channel_config(struct snd_soc_component *component,
				     int channel, int mode)
{}

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

static int wcd938x_micbias_control(struct snd_soc_component *component,
				   int micb_num, int req, bool is_dapm)
{}

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

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

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

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

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

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

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

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

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

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

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

static const char * const tx_mode_mux_text_wcd9380[] =;

static const char * const tx_mode_mux_text[] =;

static const char * const rx_hph_mode_mux_text_wcd9380[] =;

static const char * const rx_hph_mode_mux_text[] =;

static const char * const adc2_mux_text[] =;

static const char * const adc3_mux_text[] =;

static const char * const adc4_mux_text[] =;

static const char * const rdac3_mux_text[] =;

static const char * const hdr12_mux_text[] =;

static const char * const hdr34_mux_text[] =;

static const struct soc_enum tx0_mode_enum_wcd9380 =;

static const struct soc_enum tx1_mode_enum_wcd9380 =;

static const struct soc_enum tx2_mode_enum_wcd9380 =;

static const struct soc_enum tx3_mode_enum_wcd9380 =;

static const struct soc_enum tx0_mode_enum_wcd9385 =;

static const struct soc_enum tx1_mode_enum_wcd9385 =;

static const struct soc_enum tx2_mode_enum_wcd9385 =;

static const struct soc_enum tx3_mode_enum_wcd9385 =;

static const struct soc_enum rx_hph_mode_mux_enum_wcd9380 =;

static const struct soc_enum rx_hph_mode_mux_enum =;

static const struct soc_enum adc2_enum =;

static const struct soc_enum adc3_enum =;

static const struct soc_enum adc4_enum =;

static const struct soc_enum hdr12_enum =;

static const struct soc_enum hdr34_enum =;

static const struct soc_enum rdac3_enum =;

static const struct snd_kcontrol_new adc1_switch[] =;

static const struct snd_kcontrol_new adc2_switch[] =;

static const struct snd_kcontrol_new adc3_switch[] =;

static const struct snd_kcontrol_new adc4_switch[] =;

static const struct snd_kcontrol_new dmic1_switch[] =;

static const struct snd_kcontrol_new dmic2_switch[] =;

static const struct snd_kcontrol_new dmic3_switch[] =;

static const struct snd_kcontrol_new dmic4_switch[] =;

static const struct snd_kcontrol_new dmic5_switch[] =;

static const struct snd_kcontrol_new dmic6_switch[] =;

static const struct snd_kcontrol_new dmic7_switch[] =;

static const struct snd_kcontrol_new dmic8_switch[] =;

static const struct snd_kcontrol_new ear_rdac_switch[] =;

static const struct snd_kcontrol_new aux_rdac_switch[] =;

static const struct snd_kcontrol_new hphl_rdac_switch[] =;

static const struct snd_kcontrol_new hphr_rdac_switch[] =;

static const struct snd_kcontrol_new tx_adc2_mux =;

static const struct snd_kcontrol_new tx_adc3_mux =;

static const struct snd_kcontrol_new tx_adc4_mux =;

static const struct snd_kcontrol_new tx_hdr12_mux =;

static const struct snd_kcontrol_new tx_hdr34_mux =;

static const struct snd_kcontrol_new rx_rdac3_mux =;

static const struct snd_kcontrol_new wcd9380_snd_controls[] =;

static const struct snd_kcontrol_new wcd9385_snd_controls[] =;

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

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

/* MBHC related */
static void wcd938x_mbhc_clk_setup(struct snd_soc_component *component,
				   bool enable)
{}

static void wcd938x_mbhc_mbhc_bias_control(struct snd_soc_component *component,
					   bool enable)
{}

static void wcd938x_mbhc_program_btn_thr(struct snd_soc_component *component,
					 int *btn_low, int *btn_high,
					 int num_btn, bool is_micbias)
{}

static bool wcd938x_mbhc_micb_en_status(struct snd_soc_component *component, int micb_num)
{}

static void wcd938x_mbhc_hph_l_pull_up_control(struct snd_soc_component *component,
							int pull_up_cur)
{}

static int wcd938x_mbhc_request_micbias(struct snd_soc_component *component,
					int micb_num, int req)
{}

static void wcd938x_mbhc_micb_ramp_control(struct snd_soc_component *component,
					   bool enable)
{}

static int wcd938x_get_micb_vout_ctl_val(u32 micb_mv)
{}

static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
					    int req_volt, int micb_num)
{}

static int wcd938x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *component,
						int micb_num, bool req_en)
{}

static void wcd938x_mbhc_get_result_params(struct snd_soc_component *component,
						s16 *d1_a, u16 noff,
						int32_t *zdet)
{}

static void wcd938x_mbhc_zdet_ramp(struct snd_soc_component *component,
				 struct wcd938x_mbhc_zdet_param *zdet_param,
				 int32_t *zl, int32_t *zr, s16 *d1_a)
{}

static void wcd938x_wcd_mbhc_qfuse_cal(struct snd_soc_component *component,
					int32_t *z_val, int flag_l_r)
{}

static void wcd938x_wcd_mbhc_calc_impedance(struct snd_soc_component *component,
					    uint32_t *zl, uint32_t *zr)
{}

static void wcd938x_mbhc_gnd_det_ctrl(struct snd_soc_component *component,
			bool enable)
{}

static void wcd938x_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component,
					  bool enable)
{}

static void wcd938x_mbhc_moisture_config(struct snd_soc_component *component)
{}

static void wcd938x_mbhc_moisture_detect_en(struct snd_soc_component *component, bool enable)
{}

static bool wcd938x_mbhc_get_moisture_status(struct snd_soc_component *component)
{}

static void wcd938x_mbhc_moisture_polling_ctrl(struct snd_soc_component *component,
						bool enable)
{}

static const struct wcd_mbhc_cb mbhc_cb =;

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

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

static const struct snd_kcontrol_new hph_type_detect_controls[] =;

static const struct snd_kcontrol_new impedance_detect_controls[] =;

static int wcd938x_mbhc_init(struct snd_soc_component *component)
{}

static void wcd938x_mbhc_deinit(struct snd_soc_component *component)
{}

/* END MBHC */

static const struct snd_kcontrol_new wcd938x_snd_controls[] =;

static const struct snd_soc_dapm_widget wcd938x_dapm_widgets[] =;

static const struct snd_soc_dapm_route wcd938x_audio_map[] =;

static int wcd938x_set_micbias_data(struct wcd938x_priv *wcd938x)
{}

static irqreturn_t wcd938x_wd_handle_irq(int irq, void *data)
{}

static const struct irq_chip wcd_irq_chip =;

static int wcd_irq_chip_map(struct irq_domain *irqd, unsigned int virq,
			irq_hw_number_t hw)
{}

static const struct irq_domain_ops wcd_domain_ops =;

static int wcd938x_irq_init(struct wcd938x_priv *wcd, struct device *dev)
{}

static int wcd938x_soc_codec_probe(struct snd_soc_component *component)
{}

static void wcd938x_soc_codec_remove(struct snd_soc_component *component)
{}

static int wcd938x_codec_set_jack(struct snd_soc_component *comp,
				  struct snd_soc_jack *jack, void *data)
{}

static const struct snd_soc_component_driver soc_codec_dev_wcd938x =;

static void wcd938x_dt_parse_micbias_info(struct device *dev, struct wcd938x_priv *wcd)
{}

static bool wcd938x_swap_gnd_mic(struct snd_soc_component *component, bool active)
{}


static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device *dev)
{}

static int wcd938x_reset(struct wcd938x_priv *wcd938x)
{}

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

static int wcd938x_codec_free(struct snd_pcm_substream *substream,
			      struct snd_soc_dai *dai)
{}

static int wcd938x_codec_set_sdw_stream(struct snd_soc_dai *dai,
				  void *stream, int direction)
{}

static const struct snd_soc_dai_ops wcd938x_sdw_dai_ops =;

static struct snd_soc_dai_driver wcd938x_dais[] =;

static int wcd938x_bind(struct device *dev)
{}

static void wcd938x_unbind(struct device *dev)
{}

static const struct component_master_ops wcd938x_comp_ops =;

static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x,
					struct device *dev,
					struct component_match **matchptr)
{}

static int wcd938x_probe(struct platform_device *pdev)
{}

static void wcd938x_remove(struct platform_device *pdev)
{}

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

static struct platform_driver wcd938x_codec_driver =;

module_platform_driver();
MODULE_DESCRIPTION();
MODULE_LICENSE();