linux/sound/soc/codecs/wm8900.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * wm8900.c  --  WM8900 ALSA Soc Audio driver
 *
 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
 *
 * Author: Mark Brown <[email protected]>
 *
 * TODO:
 *  - Tristating.
 *  - TDM.
 *  - Jack detect.
 *  - FLL source configuration, currently only MCLK is supported.
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/spi/spi.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/tlv.h>

#include "wm8900.h"

/* WM8900 register space */
#define WM8900_REG_RESET
#define WM8900_REG_ID
#define WM8900_REG_POWER1
#define WM8900_REG_POWER2
#define WM8900_REG_POWER3
#define WM8900_REG_AUDIO1
#define WM8900_REG_AUDIO2
#define WM8900_REG_CLOCKING1
#define WM8900_REG_CLOCKING2
#define WM8900_REG_AUDIO3
#define WM8900_REG_AUDIO4
#define WM8900_REG_DACCTRL
#define WM8900_REG_LDAC_DV
#define WM8900_REG_RDAC_DV
#define WM8900_REG_SIDETONE
#define WM8900_REG_ADCCTRL
#define WM8900_REG_LADC_DV
#define WM8900_REG_RADC_DV
#define WM8900_REG_GPIO
#define WM8900_REG_INCTL
#define WM8900_REG_LINVOL
#define WM8900_REG_RINVOL
#define WM8900_REG_INBOOSTMIX1
#define WM8900_REG_INBOOSTMIX2
#define WM8900_REG_ADCPATH
#define WM8900_REG_AUXBOOST
#define WM8900_REG_ADDCTL
#define WM8900_REG_FLLCTL1
#define WM8900_REG_FLLCTL2
#define WM8900_REG_FLLCTL3
#define WM8900_REG_FLLCTL4
#define WM8900_REG_FLLCTL5
#define WM8900_REG_FLLCTL6
#define WM8900_REG_LOUTMIXCTL1
#define WM8900_REG_ROUTMIXCTL1
#define WM8900_REG_BYPASS1
#define WM8900_REG_BYPASS2
#define WM8900_REG_AUXOUT_CTL
#define WM8900_REG_LOUT1CTL
#define WM8900_REG_ROUT1CTL
#define WM8900_REG_LOUT2CTL
#define WM8900_REG_ROUT2CTL
#define WM8900_REG_HPCTL1
#define WM8900_REG_OUTBIASCTL

#define WM8900_MAXREG

#define WM8900_REG_ADDCTL_OUT1_DIS
#define WM8900_REG_ADDCTL_OUT2_DIS
#define WM8900_REG_ADDCTL_VMID_DIS
#define WM8900_REG_ADDCTL_BIAS_SRC
#define WM8900_REG_ADDCTL_VMID_SOFTST
#define WM8900_REG_ADDCTL_TEMP_SD

#define WM8900_REG_GPIO_TEMP_ENA

#define WM8900_REG_POWER1_STARTUP_BIAS_ENA
#define WM8900_REG_POWER1_BIAS_ENA
#define WM8900_REG_POWER1_VMID_BUF_ENA
#define WM8900_REG_POWER1_FLL_ENA

#define WM8900_REG_POWER2_SYSCLK_ENA
#define WM8900_REG_POWER2_ADCL_ENA
#define WM8900_REG_POWER2_ADCR_ENA

#define WM8900_REG_POWER3_DACL_ENA
#define WM8900_REG_POWER3_DACR_ENA

#define WM8900_REG_AUDIO1_AIF_FMT_MASK
#define WM8900_REG_AUDIO1_LRCLK_INV
#define WM8900_REG_AUDIO1_BCLK_INV

#define WM8900_REG_CLOCKING1_BCLK_DIR
#define WM8900_REG_CLOCKING1_MCLK_SRC
#define WM8900_REG_CLOCKING1_BCLK_MASK
#define WM8900_REG_CLOCKING1_OPCLK_MASK

#define WM8900_REG_CLOCKING2_ADC_CLKDIV
#define WM8900_REG_CLOCKING2_DAC_CLKDIV

#define WM8900_REG_DACCTRL_MUTE
#define WM8900_REG_DACCTRL_DAC_SB_FILT
#define WM8900_REG_DACCTRL_AIF_LRCLKRATE

#define WM8900_REG_AUDIO3_ADCLRC_DIR

#define WM8900_REG_AUDIO4_DACLRC_DIR

#define WM8900_REG_FLLCTL1_OSC_ENA

#define WM8900_REG_FLLCTL6_FLL_SLOW_LOCK_REF

#define WM8900_REG_HPCTL1_HP_IPSTAGE_ENA
#define WM8900_REG_HPCTL1_HP_OPSTAGE_ENA
#define WM8900_REG_HPCTL1_HP_CLAMP_IP
#define WM8900_REG_HPCTL1_HP_CLAMP_OP
#define WM8900_REG_HPCTL1_HP_SHORT
#define WM8900_REG_HPCTL1_HP_SHORT2

#define WM8900_LRC_MASK

struct wm8900_priv {};

/*
 * wm8900 register cache.  We can't read the entire register space and we
 * have slow control buses so we cache the registers.
 */
static const struct reg_default wm8900_reg_defaults[] =;

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

static void wm8900_reset(struct snd_soc_component *component)
{}

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

static const DECLARE_TLV_DB_SCALE(out_pga_tlv, -5700, 100, 0);

static const DECLARE_TLV_DB_SCALE(out_mix_tlv, -1500, 300, 0);

static const DECLARE_TLV_DB_SCALE(in_boost_tlv, -1200, 600, 0);

static const DECLARE_TLV_DB_SCALE(in_pga_tlv, -1200, 100, 0);

static const DECLARE_TLV_DB_SCALE(dac_boost_tlv, 0, 600, 0);

static const DECLARE_TLV_DB_SCALE(dac_tlv, -7200, 75, 1);

static const DECLARE_TLV_DB_SCALE(adc_svol_tlv, -3600, 300, 0);

static const DECLARE_TLV_DB_SCALE(adc_tlv, -7200, 75, 1);

static const char *mic_bias_level_txt[] =;

static SOC_ENUM_SINGLE_DECL(mic_bias_level,
			    WM8900_REG_INCTL, 8, mic_bias_level_txt);

static const char *dac_mute_rate_txt[] =;

static SOC_ENUM_SINGLE_DECL(dac_mute_rate,
			    WM8900_REG_DACCTRL, 7, dac_mute_rate_txt);

static const char *dac_deemphasis_txt[] =;

static SOC_ENUM_SINGLE_DECL(dac_deemphasis,
			    WM8900_REG_DACCTRL, 4, dac_deemphasis_txt);

static const char *adc_hpf_cut_txt[] =;

static SOC_ENUM_SINGLE_DECL(adc_hpf_cut,
			    WM8900_REG_ADCCTRL, 5, adc_hpf_cut_txt);

static const char *lr_txt[] =;

static SOC_ENUM_SINGLE_DECL(aifl_src,
			    WM8900_REG_AUDIO1, 15, lr_txt);

static SOC_ENUM_SINGLE_DECL(aifr_src,
			    WM8900_REG_AUDIO1, 14, lr_txt);

static SOC_ENUM_SINGLE_DECL(dacl_src,
			    WM8900_REG_AUDIO2, 15, lr_txt);

static SOC_ENUM_SINGLE_DECL(dacr_src,
			    WM8900_REG_AUDIO2, 14, lr_txt);

static const char *sidetone_txt[] =;

static SOC_ENUM_SINGLE_DECL(dacl_sidetone,
			    WM8900_REG_SIDETONE, 2, sidetone_txt);

static SOC_ENUM_SINGLE_DECL(dacr_sidetone,
			    WM8900_REG_SIDETONE, 0, sidetone_txt);

static const struct snd_kcontrol_new wm8900_snd_controls[] =;

static const struct snd_kcontrol_new wm8900_loutmix_controls[] =;

static const struct snd_kcontrol_new wm8900_routmix_controls[] =;

static const struct snd_kcontrol_new wm8900_linmix_controls[] =;

static const struct snd_kcontrol_new wm8900_rinmix_controls[] =;

static const struct snd_kcontrol_new wm8900_linpga_controls[] =;

static const struct snd_kcontrol_new wm8900_rinpga_controls[] =;

static const char *wm8900_lp_mux[] =;

static SOC_ENUM_SINGLE_DECL(wm8900_lineout2_lp_mux,
			    WM8900_REG_LOUTMIXCTL1, 1, wm8900_lp_mux);

static const struct snd_kcontrol_new wm8900_lineout2_lp =;

static const struct snd_soc_dapm_widget wm8900_dapm_widgets[] =;

/* Target, Path, Source */
static const struct snd_soc_dapm_route wm8900_dapm_routes[] =;

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

/* FLL divisors */
struct _fll_div {};

/* The size in bits of the FLL divide multiplied by 10
 * to allow rounding later */
#define FIXED_FLL_SIZE

static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
		       unsigned int Fout)
{}

static int wm8900_set_fll(struct snd_soc_component *component,
	int fll_id, unsigned int freq_in, unsigned int freq_out)
{}

static int wm8900_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
		int source, unsigned int freq_in, unsigned int freq_out)
{}

static int wm8900_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
				 int div_id, int div)
{}


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

static int wm8900_mute(struct snd_soc_dai *codec_dai, int mute, int direction)
{}

#define WM8900_RATES

#define WM8900_PCM_FORMATS

static const struct snd_soc_dai_ops wm8900_dai_ops =;

static struct snd_soc_dai_driver wm8900_dai =;

static int wm8900_set_bias_level(struct snd_soc_component *component,
				 enum snd_soc_bias_level level)
{}

static int wm8900_suspend(struct snd_soc_component *component)
{}

static int wm8900_resume(struct snd_soc_component *component)
{}

static int wm8900_probe(struct snd_soc_component *component)
{}

static const struct snd_soc_component_driver soc_component_dev_wm8900 =;

static const struct regmap_config wm8900_regmap =;

#if defined(CONFIG_SPI_MASTER)
static int wm8900_spi_probe(struct spi_device *spi)
{}

static struct spi_driver wm8900_spi_driver =;
#endif /* CONFIG_SPI_MASTER */

#if IS_ENABLED(CONFIG_I2C)
static int wm8900_i2c_probe(struct i2c_client *i2c)
{}

static void wm8900_i2c_remove(struct i2c_client *client)
{}

static const struct i2c_device_id wm8900_i2c_id[] =;
MODULE_DEVICE_TABLE(i2c, wm8900_i2c_id);

static struct i2c_driver wm8900_i2c_driver =;
#endif

static int __init wm8900_modinit(void)
{}
module_init();

static void __exit wm8900_exit(void)
{}
module_exit(wm8900_exit);

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