linux/sound/soc/codecs/wcd939x.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
 * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
 * Copyright (c) 2023, Linaro Limited
 */

#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_graph.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 <linux/usb/typec_mux.h>
#include <linux/usb/typec_altmode.h>

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

#define WCD939X_MAX_MICBIAS
#define WCD939X_MAX_SUPPLY
#define WCD939X_MBHC_MAX_BUTTONS
#define TX_ADC_MAX
#define WCD_MBHC_HS_V_MAX

enum {};

#define WCD939X_RATES_MASK
/* Fractional Rates */
#define WCD939X_FRAC_RATES_MASK
#define WCD939X_FORMATS

/* Convert from vout ctl to micbias voltage in mV */
#define WCD_VOUT_CTL_TO_MICB(v)
#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 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 WCD939X_ZDET_VAL_32
#define WCD939X_ZDET_VAL_400
#define WCD939X_ZDET_VAL_1200
#define WCD939X_ZDET_VAL_100K

/* Z floating defined in ohms */
#define WCD939X_ZDET_FLOATING_IMPEDANCE
#define WCD939X_ZDET_NUM_MEASUREMENTS
#define WCD939X_MBHC_GET_C1(c)
#define WCD939X_MBHC_GET_X1(x)

/* Z value compared in milliOhm */
#define WCD939X_ANA_MBHC_ZDET_CONST

enum {};

enum {};

enum {};

enum {};

enum {};

enum {};

static u8 tx_mode_bit[] =;

struct zdet_param {};

struct wcd939x_priv {};

static const SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(ear_pa_gain, 600, -1800);
static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);

static const struct wcd_mbhc_field wcd_mbhc_fields[WCD_MBHC_REG_FUNC_MAX] =;

static const struct regmap_irq wcd939x_irqs[WCD939X_NUM_IRQS] =;

static const struct regmap_irq_chip wcd939x_regmap_irq_chip =;

static int wcd939x_get_clk_rate(int mode)
{}

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

static int wcd939x_io_init(struct snd_soc_component *component)
{}

static int wcd939x_sdw_connect_port(const struct wcd939x_sdw_ch_info *ch_info,
				    struct sdw_port_config *port_config,
				    u8 enable)
{}

static int wcd939x_connect_port(struct wcd939x_sdw_priv *wcd, u8 port_num, u8 ch_id, u8 enable)
{}

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

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

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

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

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

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

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

/* TX Controls */

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

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

static int wcd939x_get_adc_mode(int val)
{}

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

static void wcd939x_tx_channel_config(struct snd_soc_component *component,
				      int channel, bool init)
{}

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

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

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

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

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

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

/* RX Controls */

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

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

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

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

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

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

static const char * const tx_mode_mux_text_wcd9390[] =;

static const struct soc_enum tx0_mode_mux_enum_wcd9390 =;

static const struct soc_enum tx1_mode_mux_enum_wcd9390 =;

static const struct soc_enum tx2_mode_mux_enum_wcd9390 =;

static const struct soc_enum tx3_mode_mux_enum_wcd9390 =;

static const char * const tx_mode_mux_text[] =;

static const struct soc_enum tx0_mode_mux_enum =;

static const struct soc_enum tx1_mode_mux_enum =;

static const struct soc_enum tx2_mode_mux_enum =;

static const struct soc_enum tx3_mode_mux_enum =;

static const char * const rx_hph_mode_mux_text_wcd9390[] =;

static const struct soc_enum rx_hph_mode_mux_enum_wcd9390 =;

static const char * const rx_hph_mode_mux_text[] =;

static const struct soc_enum rx_hph_mode_mux_enum =;

static const struct snd_kcontrol_new wcd9390_snd_controls[] =;

static const struct snd_kcontrol_new wcd9395_snd_controls[] =;

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 hphl_rdac_switch[] =;

static const struct snd_kcontrol_new hphr_rdac_switch[] =;

static const char * const adc1_mux_text[] =;

static const struct soc_enum adc1_enum =;

static const struct snd_kcontrol_new tx_adc1_mux =;

static const char * const adc2_mux_text[] =;

static const struct soc_enum adc2_enum =;

static const struct snd_kcontrol_new tx_adc2_mux =;

static const char * const adc3_mux_text[] =;

static const struct soc_enum adc3_enum =;

static const struct snd_kcontrol_new tx_adc3_mux =;

static const char * const adc4_mux_text[] =;

static const struct soc_enum adc4_enum =;

static const struct snd_kcontrol_new tx_adc4_mux =;

static const char * const rdac3_mux_text[] =;

static const struct soc_enum rdac3_enum =;

static const struct snd_kcontrol_new rx_rdac3_mux =;

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

static const char *version_to_str(u32 version)
{}

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

/* MBHC Related */

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

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

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

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

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

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

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

static int wcd939x_get_micb_vout_ctl_val(u32 micb_mv)
{}

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

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

/* Selected by WCD939X_MBHC_GET_C1() */
static const s16 wcd939x_wcd_mbhc_d1_a[4] =;

/* Selected by zdet_param.noff */
static const int wcd939x_mbhc_mincode_param[] =;

static const struct zdet_param wcd939x_mbhc_zdet_param =;

static void wcd939x_mbhc_get_result_params(struct snd_soc_component *component,
					   int32_t *zdet)
{}

static void wcd939x_mbhc_zdet_ramp(struct snd_soc_component *component,
				   s32 *zl, int32_t *zr)
{}

static void wcd939x_wcd_mbhc_qfuse_cal(struct snd_soc_component *component,
				       s32 *z_val, int flag_l_r)
{}

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

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

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

static void wcd939x_mbhc_moisture_config(struct snd_soc_component *component)
{}

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

static bool wcd939x_mbhc_get_moisture_status(struct snd_soc_component *component)
{}

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

static const struct wcd_mbhc_cb mbhc_cb =;

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

static int wcd939x_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 wcd939x_mbhc_init(struct snd_soc_component *component)
{}

static void wcd939x_mbhc_deinit(struct snd_soc_component *component)
{}

/* END MBHC */

static const struct snd_kcontrol_new wcd939x_snd_controls[] =;

static const struct snd_soc_dapm_widget wcd939x_dapm_widgets[] =;

static const struct snd_soc_dapm_route wcd939x_audio_map[] =;

static int wcd939x_set_micbias_data(struct wcd939x_priv *wcd939x)
{}

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

/*
 * Setup a virtual interrupt domain to hook regmap_irq
 * The root domain will have a single interrupt which mapping
 * will trigger the regmap_irq handler.
 *
 * root:
 *   wcd_irq_chip
 *     [0] wcd939x_regmap_irq_chip
 *       [0] MBHC_BUTTON_PRESS_DET
 *       [1] MBHC_BUTTON_RELEASE_DET
 *       ...
 *       [16] HPHR_SURGE_DET_INT
 *
 * Interrupt trigger:
 *   soundwire_interrupt_callback()
 *   \-handle_nested_irq(0)
 *     \- regmap_irq_thread()
 *         \- handle_nested_irq(i)
 */
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 wcd939x_irq_init(struct wcd939x_priv *wcd, struct device *dev)
{}

static int wcd939x_soc_codec_probe(struct snd_soc_component *component)
{}

static void wcd939x_soc_codec_remove(struct snd_soc_component *component)
{}

static int wcd939x_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_wcd939x =;

#if IS_ENABLED(CONFIG_TYPEC)
/* Get USB-C plug orientation to provide swap event for MBHC */
static int wcd939x_typec_switch_set(struct typec_switch_dev *sw,
				    enum typec_orientation orientation)
{}

static int wcd939x_typec_mux_set(struct typec_mux_dev *mux,
				 struct typec_mux_state *state)
{}
#endif /* CONFIG_TYPEC */

static void wcd939x_dt_parse_micbias_info(struct device *dev, struct wcd939x_priv *wcd)
{}

#if IS_ENABLED(CONFIG_TYPEC)
static bool wcd939x_swap_gnd_mic(struct snd_soc_component *component, bool active)
{}
#endif /* CONFIG_TYPEC */

static int wcd939x_populate_dt_data(struct wcd939x_priv *wcd939x, struct device *dev)
{}

static int wcd939x_reset(struct wcd939x_priv *wcd939x)
{}

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

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

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

static const struct snd_soc_dai_ops wcd939x_sdw_dai_ops =;

static struct snd_soc_dai_driver wcd939x_dais[] =;

static int wcd939x_bind(struct device *dev)
{}

static void wcd939x_unbind(struct device *dev)
{}

static const struct component_master_ops wcd939x_comp_ops =;

static void __maybe_unused wcd939x_typec_mux_unregister(void *data)
{}

static void __maybe_unused wcd939x_typec_switch_unregister(void *data)
{}

static int wcd939x_add_typec(struct wcd939x_priv *wcd939x, struct device *dev)
{}

static int wcd939x_add_slave_components(struct wcd939x_priv *wcd939x,
					struct device *dev,
					struct component_match **matchptr)
{}

static int wcd939x_probe(struct platform_device *pdev)
{}

static void wcd939x_remove(struct platform_device *pdev)
{}

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

static struct platform_driver wcd939x_codec_driver =;

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