linux/sound/soc/codecs/nau8540.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * NAU85L40 ALSA SoC audio driver
 *
 * Copyright 2016 Nuvoton Technology Corp.
 * Author: John Hsu <[email protected]>
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include "nau8540.h"

#define NAU_FREF_MAX
#define NAU_FVCO_MAX
#define NAU_FVCO_MIN

/* the maximum frequency of CLK_ADC */
#define CLK_ADC_MAX

/* scaling for mclk from sysclk_src output */
static const struct nau8540_fll_attr mclk_src_scaling[] =;

/* ratio for input clk freq */
static const struct nau8540_fll_attr fll_ratio[] =;

static const struct nau8540_fll_attr fll_pre_scalar[] =;

/* over sampling rate */
static const struct nau8540_osr_attr osr_adc_sel[] =;

static const struct reg_default nau8540_reg_defaults[] =;

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

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

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


static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -12800, 3600);
static const DECLARE_TLV_DB_MINMAX(fepga_gain_tlv, -100, 3600);

static const struct snd_kcontrol_new nau8540_snd_controls[] =;

static const char * const adc_channel[] =;
static SOC_ENUM_SINGLE_DECL(
	digital_ch4_enum, NAU8540_REG_DIGITAL_MUX, 6, adc_channel);

static const struct snd_kcontrol_new digital_ch4_mux =;

static SOC_ENUM_SINGLE_DECL(
	digital_ch3_enum, NAU8540_REG_DIGITAL_MUX, 4, adc_channel);

static const struct snd_kcontrol_new digital_ch3_mux =;

static SOC_ENUM_SINGLE_DECL(
	digital_ch2_enum, NAU8540_REG_DIGITAL_MUX, 2, adc_channel);

static const struct snd_kcontrol_new digital_ch2_mux =;

static SOC_ENUM_SINGLE_DECL(
	digital_ch1_enum, NAU8540_REG_DIGITAL_MUX, 0, adc_channel);

static const struct snd_kcontrol_new digital_ch1_mux =;

static int nau8540_fepga_event(struct snd_soc_dapm_widget *w,
			       struct snd_kcontrol *k, int event)
{}

static int nau8540_precharge_event(struct snd_soc_dapm_widget *w,
				   struct snd_kcontrol *k, int event)
{}

static int adc_power_control(struct snd_soc_dapm_widget *w,
		struct snd_kcontrol *k, int  event)
{}

static int aiftx_power_control(struct snd_soc_dapm_widget *w,
		struct snd_kcontrol *k, int  event)
{}

static const struct snd_soc_dapm_widget nau8540_dapm_widgets[] =;

static const struct snd_soc_dapm_route nau8540_dapm_routes[] =;

static const struct nau8540_osr_attr *
nau8540_get_osr(struct nau8540 *nau8540)
{}

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

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

static int nau8540_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{}

/**
 * nau8540_set_tdm_slot - configure DAI TX TDM.
 * @dai: DAI
 * @tx_mask: bitmask representing active TX slots. Ex.
 *                 0xf for normal 4 channel TDM.
 *                 0xf0 for shifted 4 channel TDM
 * @rx_mask: no used.
 * @slots: Number of slots in use.
 * @slot_width: Width in bits for each slot.
 *
 * Configures a DAI for TDM operation. Only support 4 slots TDM.
 */
static int nau8540_set_tdm_slot(struct snd_soc_dai *dai,
	unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
{}

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

static const struct snd_soc_dai_ops nau8540_dai_ops =;

#define NAU8540_RATES
#define NAU8540_FORMATS

static struct snd_soc_dai_driver nau8540_dai =;

/**
 * nau8540_calc_fll_param - Calculate FLL parameters.
 * @fll_in: external clock provided to codec.
 * @fs: sampling rate.
 * @fll_param: Pointer to structure of FLL parameters.
 *
 * Calculate FLL parameters to configure codec.
 *
 * Returns 0 for success or negative error code.
 */
static int nau8540_calc_fll_param(unsigned int fll_in,
	unsigned int fs, struct nau8540_fll *fll_param)
{}

static void nau8540_fll_apply(struct regmap *regmap,
	struct nau8540_fll *fll_param)
{}

/* freq_out must be 256*Fs in order to achieve the best performance */
static int nau8540_set_pll(struct snd_soc_component *component, int pll_id, int source,
		unsigned int freq_in, unsigned int freq_out)
{}

static int nau8540_set_sysclk(struct snd_soc_component *component,
	int clk_id, int source, unsigned int freq, int dir)
{}

static void nau8540_reset_chip(struct regmap *regmap)
{}

static void nau8540_init_regs(struct nau8540 *nau8540)
{}

static int __maybe_unused nau8540_suspend(struct snd_soc_component *component)
{}

static int __maybe_unused nau8540_resume(struct snd_soc_component *component)
{}

static const struct snd_soc_component_driver nau8540_component_driver =;

static const struct regmap_config nau8540_regmap_config =;

static int nau8540_i2c_probe(struct i2c_client *i2c)
{}

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

#ifdef CONFIG_OF
static const struct of_device_id nau8540_of_ids[] =;
MODULE_DEVICE_TABLE(of, nau8540_of_ids);
#endif

static struct i2c_driver nau8540_i2c_driver =;
module_i2c_driver();

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