linux/sound/soc/sunxi/sun4i-codec.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright 2014 Emilio López <[email protected]>
 * Copyright 2014 Jon Smirl <[email protected]>
 * Copyright 2015 Maxime Ripard <[email protected]>
 * Copyright 2015 Adam Sampson <[email protected]>
 * Copyright 2016 Chen-Yu Tsai <[email protected]>
 *
 * Based on the Allwinner SDK driver, released under the GPL.
 */

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/clk.h>
#include <linux/regmap.h>
#include <linux/reset.h>
#include <linux/gpio/consumer.h>

#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#include <sound/initval.h>
#include <sound/dmaengine_pcm.h>

/* Codec DAC digital controls and FIFO registers */
#define SUN4I_CODEC_DAC_DPC
#define SUN4I_CODEC_DAC_DPC_EN_DA
#define SUN4I_CODEC_DAC_DPC_DVOL
#define SUN4I_CODEC_DAC_FIFOC
#define SUN4I_CODEC_DAC_FIFOC_DAC_FS
#define SUN4I_CODEC_DAC_FIFOC_FIR_VERSION
#define SUN4I_CODEC_DAC_FIFOC_SEND_LASAT
#define SUN4I_CODEC_DAC_FIFOC_TX_FIFO_MODE
#define SUN4I_CODEC_DAC_FIFOC_DRQ_CLR_CNT
#define SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL
#define SUN4I_CODEC_DAC_FIFOC_MONO_EN
#define SUN4I_CODEC_DAC_FIFOC_TX_SAMPLE_BITS
#define SUN4I_CODEC_DAC_FIFOC_DAC_DRQ_EN
#define SUN4I_CODEC_DAC_FIFOC_FIFO_FLUSH
#define SUN4I_CODEC_DAC_FIFOS
#define SUN4I_CODEC_DAC_TXDATA

/* Codec DAC side analog signal controls */
#define SUN4I_CODEC_DAC_ACTL
#define SUN4I_CODEC_DAC_ACTL_DACAENR
#define SUN4I_CODEC_DAC_ACTL_DACAENL
#define SUN4I_CODEC_DAC_ACTL_MIXEN
#define SUN4I_CODEC_DAC_ACTL_LNG
#define SUN4I_CODEC_DAC_ACTL_FMG
#define SUN4I_CODEC_DAC_ACTL_MICG
#define SUN4I_CODEC_DAC_ACTL_LLNS
#define SUN4I_CODEC_DAC_ACTL_RLNS
#define SUN4I_CODEC_DAC_ACTL_LFMS
#define SUN4I_CODEC_DAC_ACTL_RFMS
#define SUN4I_CODEC_DAC_ACTL_LDACLMIXS
#define SUN4I_CODEC_DAC_ACTL_RDACRMIXS
#define SUN4I_CODEC_DAC_ACTL_LDACRMIXS
#define SUN4I_CODEC_DAC_ACTL_MIC1LS
#define SUN4I_CODEC_DAC_ACTL_MIC1RS
#define SUN4I_CODEC_DAC_ACTL_MIC2LS
#define SUN4I_CODEC_DAC_ACTL_MIC2RS
#define SUN4I_CODEC_DAC_ACTL_DACPAS
#define SUN4I_CODEC_DAC_ACTL_MIXPAS
#define SUN4I_CODEC_DAC_ACTL_PA_MUTE
#define SUN4I_CODEC_DAC_ACTL_PA_VOL
#define SUN4I_CODEC_DAC_TUNE
#define SUN4I_CODEC_DAC_DEBUG

/* Codec ADC digital controls and FIFO registers */
#define SUN4I_CODEC_ADC_FIFOC
#define SUN4I_CODEC_ADC_FIFOC_ADC_FS
#define SUN4I_CODEC_ADC_FIFOC_EN_AD
#define SUN4I_CODEC_ADC_FIFOC_RX_FIFO_MODE
#define SUN4I_CODEC_ADC_FIFOC_RX_TRIG_LEVEL
#define SUN4I_CODEC_ADC_FIFOC_MONO_EN
#define SUN4I_CODEC_ADC_FIFOC_RX_SAMPLE_BITS
#define SUN4I_CODEC_ADC_FIFOC_ADC_DRQ_EN
#define SUN4I_CODEC_ADC_FIFOC_FIFO_FLUSH
#define SUN4I_CODEC_ADC_FIFOS
#define SUN4I_CODEC_ADC_RXDATA

/* Codec ADC side analog signal controls */
#define SUN4I_CODEC_ADC_ACTL
#define SUN4I_CODEC_ADC_ACTL_ADC_R_EN
#define SUN4I_CODEC_ADC_ACTL_ADC_L_EN
#define SUN4I_CODEC_ADC_ACTL_PREG1EN
#define SUN4I_CODEC_ADC_ACTL_PREG2EN
#define SUN4I_CODEC_ADC_ACTL_VMICEN
#define SUN4I_CODEC_ADC_ACTL_PREG1
#define SUN4I_CODEC_ADC_ACTL_PREG2
#define SUN4I_CODEC_ADC_ACTL_VADCG
#define SUN4I_CODEC_ADC_ACTL_ADCIS
#define SUN4I_CODEC_ADC_ACTL_LNPREG
#define SUN4I_CODEC_ADC_ACTL_PA_EN
#define SUN4I_CODEC_ADC_ACTL_DDE
#define SUN4I_CODEC_ADC_DEBUG

/* FIFO counters */
#define SUN4I_CODEC_DAC_TXCNT
#define SUN4I_CODEC_ADC_RXCNT

/* Calibration register (sun7i only) */
#define SUN7I_CODEC_AC_DAC_CAL

/* Microphone controls (sun7i only) */
#define SUN7I_CODEC_AC_MIC_PHONE_CAL

#define SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG1
#define SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG2

/*
 * sun6i specific registers
 *
 * sun6i shares the same digital control and FIFO registers as sun4i,
 * but only the DAC digital controls are at the same offset. The others
 * have been moved around to accommodate extra analog controls.
 */

/* Codec DAC digital controls and FIFO registers */
#define SUN6I_CODEC_ADC_FIFOC
#define SUN6I_CODEC_ADC_FIFOC_EN_AD
#define SUN6I_CODEC_ADC_FIFOS
#define SUN6I_CODEC_ADC_RXDATA

/* Output mixer and gain controls */
#define SUN6I_CODEC_OM_DACA_CTRL
#define SUN6I_CODEC_OM_DACA_CTRL_DACAREN
#define SUN6I_CODEC_OM_DACA_CTRL_DACALEN
#define SUN6I_CODEC_OM_DACA_CTRL_RMIXEN
#define SUN6I_CODEC_OM_DACA_CTRL_LMIXEN
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_MIC1
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_MIC2
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_PHONE
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_PHONEP
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_LINEINR
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_DACR
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_DACL
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_MIC1
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_MIC2
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_PHONE
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_PHONEN
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_LINEINL
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_DACL
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_DACR
#define SUN6I_CODEC_OM_DACA_CTRL_RHPIS
#define SUN6I_CODEC_OM_DACA_CTRL_LHPIS
#define SUN6I_CODEC_OM_DACA_CTRL_RHPPAMUTE
#define SUN6I_CODEC_OM_DACA_CTRL_LHPPAMUTE
#define SUN6I_CODEC_OM_DACA_CTRL_HPVOL
#define SUN6I_CODEC_OM_PA_CTRL
#define SUN6I_CODEC_OM_PA_CTRL_HPPAEN
#define SUN6I_CODEC_OM_PA_CTRL_HPCOM_CTL
#define SUN6I_CODEC_OM_PA_CTRL_COMPTEN
#define SUN6I_CODEC_OM_PA_CTRL_MIC1G
#define SUN6I_CODEC_OM_PA_CTRL_MIC2G
#define SUN6I_CODEC_OM_PA_CTRL_LINEING
#define SUN6I_CODEC_OM_PA_CTRL_PHONEG
#define SUN6I_CODEC_OM_PA_CTRL_PHONEPG
#define SUN6I_CODEC_OM_PA_CTRL_PHONENG

/* Microphone, line out and phone out controls */
#define SUN6I_CODEC_MIC_CTRL
#define SUN6I_CODEC_MIC_CTRL_HBIASEN
#define SUN6I_CODEC_MIC_CTRL_MBIASEN
#define SUN6I_CODEC_MIC_CTRL_MIC1AMPEN
#define SUN6I_CODEC_MIC_CTRL_MIC1BOOST
#define SUN6I_CODEC_MIC_CTRL_MIC2AMPEN
#define SUN6I_CODEC_MIC_CTRL_MIC2BOOST
#define SUN6I_CODEC_MIC_CTRL_MIC2SLT
#define SUN6I_CODEC_MIC_CTRL_LINEOUTLEN
#define SUN6I_CODEC_MIC_CTRL_LINEOUTREN
#define SUN6I_CODEC_MIC_CTRL_LINEOUTLSRC
#define SUN6I_CODEC_MIC_CTRL_LINEOUTRSRC
#define SUN6I_CODEC_MIC_CTRL_LINEOUTVC
#define SUN6I_CODEC_MIC_CTRL_PHONEPREG

/* ADC mixer controls */
#define SUN6I_CODEC_ADC_ACTL
#define SUN6I_CODEC_ADC_ACTL_ADCREN
#define SUN6I_CODEC_ADC_ACTL_ADCLEN
#define SUN6I_CODEC_ADC_ACTL_ADCRG
#define SUN6I_CODEC_ADC_ACTL_ADCLG
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_MIC1
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_MIC2
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_PHONE
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_PHONEP
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_LINEINR
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_OMIXR
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_OMIXL
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_MIC1
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_MIC2
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_PHONE
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_PHONEN
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_LINEINL
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_OMIXL
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_OMIXR

/* Analog performance tuning controls */
#define SUN6I_CODEC_ADDA_TUNE

/* Calibration controls */
#define SUN6I_CODEC_CALIBRATION

/* FIFO counters */
#define SUN6I_CODEC_DAC_TXCNT
#define SUN6I_CODEC_ADC_RXCNT

/* headset jack detection and button support registers */
#define SUN6I_CODEC_HMIC_CTL
#define SUN6I_CODEC_HMIC_DATA

/* TODO sun6i DAP (Digital Audio Processing) bits */

/* FIFO counters moved on A23 */
#define SUN8I_A23_CODEC_DAC_TXCNT
#define SUN8I_A23_CODEC_ADC_RXCNT

/* TX FIFO moved on H3 */
#define SUN8I_H3_CODEC_DAC_TXDATA
#define SUN8I_H3_CODEC_DAC_DBG
#define SUN8I_H3_CODEC_ADC_DBG

/* TODO H3 DAP (Digital Audio Processing) bits */

struct sun4i_codec {};

static void sun4i_codec_start_playback(struct sun4i_codec *scodec)
{}

static void sun4i_codec_stop_playback(struct sun4i_codec *scodec)
{}

static void sun4i_codec_start_capture(struct sun4i_codec *scodec)
{}

static void sun4i_codec_stop_capture(struct sun4i_codec *scodec)
{}

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

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

static int sun4i_codec_prepare_playback(struct snd_pcm_substream *substream,
					struct snd_soc_dai *dai)
{
	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
	struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card);
	u32 val;

	/* Flush the TX FIFO */
	regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
			   BIT(SUN4I_CODEC_DAC_FIFOC_FIFO_FLUSH));

	/* Set TX FIFO Empty Trigger Level */
	regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
			   0x3f << SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL,
			   0xf << SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL);

	if (substream->runtime->rate > 32000)
		/* Use 64 bits FIR filter */
		val = 0;
	else
		/* Use 32 bits FIR filter */
		val = BIT(SUN4I_CODEC_DAC_FIFOC_FIR_VERSION);

	regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
			   BIT(SUN4I_CODEC_DAC_FIFOC_FIR_VERSION),
			   val);

	/* Send zeros when we have an underrun */
	regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
			   BIT(SUN4I_CODEC_DAC_FIFOC_SEND_LASAT));

	return 0;
};

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

static unsigned long sun4i_codec_get_mod_freq(struct snd_pcm_hw_params *params)
{}

static int sun4i_codec_get_hw_rate(struct snd_pcm_hw_params *params)
{}

static int sun4i_codec_hw_params_capture(struct sun4i_codec *scodec,
					 struct snd_pcm_hw_params *params,
					 unsigned int hwrate)
{}

static int sun4i_codec_hw_params_playback(struct sun4i_codec *scodec,
					  struct snd_pcm_hw_params *params,
					  unsigned int hwrate)
{}

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


static unsigned int sun4i_codec_src_rates[] =;


static struct snd_pcm_hw_constraint_list sun4i_codec_constraints =;


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

static void sun4i_codec_shutdown(struct snd_pcm_substream *substream,
				 struct snd_soc_dai *dai)
{}

static const struct snd_soc_dai_ops sun4i_codec_dai_ops =;

static struct snd_soc_dai_driver sun4i_codec_dai =;

/*** sun4i Codec ***/
static const struct snd_kcontrol_new sun4i_codec_pa_mute =;

static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1);
static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_loopback_gain_scale, -150, 150,
			    0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_preamp_gain_scale, -1200, 300,
			    0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_fmin_loopback_gain_scale, -450, 150,
			    0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150,
			    0);
static DECLARE_TLV_DB_RANGE(sun4i_codec_micin_preamp_gain_scale,
			    0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
			    1, 7, TLV_DB_SCALE_ITEM(3500, 300, 0));
static DECLARE_TLV_DB_RANGE(sun7i_codec_micin_preamp_gain_scale,
			    0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
			    1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0));

static const struct snd_kcontrol_new sun4i_codec_controls[] =;

static const struct snd_kcontrol_new sun7i_codec_controls[] =;

static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] =;

static const struct snd_kcontrol_new sun4i_codec_pa_mixer_controls[] =;

static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] =;

static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] =;

static const struct snd_soc_component_driver sun4i_codec_codec =;

static const struct snd_soc_component_driver sun7i_codec_codec =;

/*** sun6i Codec ***/

/* mixer controls */
static const struct snd_kcontrol_new sun6i_codec_mixer_controls[] =;

/* ADC mixer controls */
static const struct snd_kcontrol_new sun6i_codec_adc_mixer_controls[] =;

/* headphone controls */
static const char * const sun6i_codec_hp_src_enum_text[] =;

static SOC_ENUM_DOUBLE_DECL(sun6i_codec_hp_src_enum,
			    SUN6I_CODEC_OM_DACA_CTRL,
			    SUN6I_CODEC_OM_DACA_CTRL_LHPIS,
			    SUN6I_CODEC_OM_DACA_CTRL_RHPIS,
			    sun6i_codec_hp_src_enum_text);

static const struct snd_kcontrol_new sun6i_codec_hp_src[] =;

/* microphone controls */
static const char * const sun6i_codec_mic2_src_enum_text[] =;

static SOC_ENUM_SINGLE_DECL(sun6i_codec_mic2_src_enum,
			    SUN6I_CODEC_MIC_CTRL,
			    SUN6I_CODEC_MIC_CTRL_MIC2SLT,
			    sun6i_codec_mic2_src_enum_text);

static const struct snd_kcontrol_new sun6i_codec_mic2_src[] =;

/* line out controls */
static const char * const sun6i_codec_lineout_src_enum_text[] =;

static SOC_ENUM_DOUBLE_DECL(sun6i_codec_lineout_src_enum,
			    SUN6I_CODEC_MIC_CTRL,
			    SUN6I_CODEC_MIC_CTRL_LINEOUTLSRC,
			    SUN6I_CODEC_MIC_CTRL_LINEOUTRSRC,
			    sun6i_codec_lineout_src_enum_text);

static const struct snd_kcontrol_new sun6i_codec_lineout_src[] =;

/* volume / mute controls */
static const DECLARE_TLV_DB_SCALE(sun6i_codec_dvol_scale, -7308, 116, 0);
static const DECLARE_TLV_DB_SCALE(sun6i_codec_hp_vol_scale, -6300, 100, 1);
static const DECLARE_TLV_DB_SCALE(sun6i_codec_out_mixer_pregain_scale,
				  -450, 150, 0);
static const DECLARE_TLV_DB_RANGE(sun6i_codec_lineout_vol_scale,
	0, 1, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
	2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0),
);
static const DECLARE_TLV_DB_RANGE(sun6i_codec_mic_gain_scale,
	0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
	1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0),
);

static const struct snd_kcontrol_new sun6i_codec_codec_widgets[] =;

static const struct snd_soc_dapm_widget sun6i_codec_codec_dapm_widgets[] =;

static const struct snd_soc_dapm_route sun6i_codec_codec_dapm_routes[] =;

static const struct snd_soc_component_driver sun6i_codec_codec =;

/* sun8i A23 codec */
static const struct snd_kcontrol_new sun8i_a23_codec_codec_controls[] =;

static const struct snd_soc_dapm_widget sun8i_a23_codec_codec_widgets[] =;

static const struct snd_soc_component_driver sun8i_a23_codec_codec =;

static const struct snd_soc_component_driver sun4i_codec_component =;

#define SUN4I_CODEC_RATES
#define SUN4I_CODEC_FORMATS

static int sun4i_codec_dai_probe(struct snd_soc_dai *dai)
{}

static const struct snd_soc_dai_ops dummy_dai_ops =;

static struct snd_soc_dai_driver dummy_cpu_dai =;

static struct snd_soc_dai_link *sun4i_codec_create_link(struct device *dev,
							int *num_links)
{
	struct snd_soc_dai_link *link = devm_kzalloc(dev, sizeof(*link),
						     GFP_KERNEL);
	struct snd_soc_dai_link_component *dlc = devm_kzalloc(dev,
						3 * sizeof(*dlc), GFP_KERNEL);
	if (!link || !dlc)
		return NULL;

	link->cpus	= &dlc[0];
	link->codecs	= &dlc[1];
	link->platforms	= &dlc[2];

	link->num_cpus		= 1;
	link->num_codecs	= 1;
	link->num_platforms	= 1;

	link->name		= "cdc";
	link->stream_name	= "CDC PCM";
	link->codecs->dai_name	= "Codec";
	link->cpus->dai_name	= dev_name(dev);
	link->codecs->name	= dev_name(dev);
	link->platforms->name	= dev_name(dev);
	link->dai_fmt		= SND_SOC_DAIFMT_I2S;

	*num_links = 1;

	return link;
};

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

static const struct snd_soc_dapm_widget sun4i_codec_card_dapm_widgets[] =;

static const struct snd_soc_dapm_route sun4i_codec_card_dapm_routes[] =;

static struct snd_soc_card *sun4i_codec_create_card(struct device *dev)
{
	struct snd_soc_card *card;

	card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
	if (!card)
		return ERR_PTR(-ENOMEM);

	card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
	if (!card->dai_link)
		return ERR_PTR(-ENOMEM);

	card->dev		= dev;
	card->owner		= THIS_MODULE;
	card->name		= "sun4i-codec";
	card->dapm_widgets	= sun4i_codec_card_dapm_widgets;
	card->num_dapm_widgets	= ARRAY_SIZE(sun4i_codec_card_dapm_widgets);
	card->dapm_routes	= sun4i_codec_card_dapm_routes;
	card->num_dapm_routes	= ARRAY_SIZE(sun4i_codec_card_dapm_routes);

	return card;
};

static const struct snd_soc_dapm_widget sun6i_codec_card_dapm_widgets[] =;

static struct snd_soc_card *sun6i_codec_create_card(struct device *dev)
{
	struct snd_soc_card *card;
	int ret;

	card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
	if (!card)
		return ERR_PTR(-ENOMEM);

	card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
	if (!card->dai_link)
		return ERR_PTR(-ENOMEM);

	card->dev		= dev;
	card->owner		= THIS_MODULE;
	card->name		= "A31 Audio Codec";
	card->dapm_widgets	= sun6i_codec_card_dapm_widgets;
	card->num_dapm_widgets	= ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
	card->fully_routed	= true;

	ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
	if (ret)
		dev_warn(dev, "failed to parse audio-routing: %d\n", ret);

	return card;
};

/* Connect digital side enables to analog side widgets */
static const struct snd_soc_dapm_route sun8i_codec_card_routes[] =;

static struct snd_soc_aux_dev aux_dev =;

static struct snd_soc_card *sun8i_a23_codec_create_card(struct device *dev)
{
	struct snd_soc_card *card;
	int ret;

	card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
	if (!card)
		return ERR_PTR(-ENOMEM);

	aux_dev.dlc.of_node = of_parse_phandle(dev->of_node,
						 "allwinner,codec-analog-controls",
						 0);
	if (!aux_dev.dlc.of_node) {
		dev_err(dev, "Can't find analog controls for codec.\n");
		return ERR_PTR(-EINVAL);
	}

	card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
	if (!card->dai_link)
		return ERR_PTR(-ENOMEM);

	card->dev		= dev;
	card->owner		= THIS_MODULE;
	card->name		= "A23 Audio Codec";
	card->dapm_widgets	= sun6i_codec_card_dapm_widgets;
	card->num_dapm_widgets	= ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
	card->dapm_routes	= sun8i_codec_card_routes;
	card->num_dapm_routes	= ARRAY_SIZE(sun8i_codec_card_routes);
	card->aux_dev		= &aux_dev;
	card->num_aux_devs	= 1;
	card->fully_routed	= true;

	ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
	if (ret)
		dev_warn(dev, "failed to parse audio-routing: %d\n", ret);

	return card;
};

static struct snd_soc_card *sun8i_h3_codec_create_card(struct device *dev)
{
	struct snd_soc_card *card;
	int ret;

	card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
	if (!card)
		return ERR_PTR(-ENOMEM);

	aux_dev.dlc.of_node = of_parse_phandle(dev->of_node,
						 "allwinner,codec-analog-controls",
						 0);
	if (!aux_dev.dlc.of_node) {
		dev_err(dev, "Can't find analog controls for codec.\n");
		return ERR_PTR(-EINVAL);
	}

	card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
	if (!card->dai_link)
		return ERR_PTR(-ENOMEM);

	card->dev		= dev;
	card->owner		= THIS_MODULE;
	card->name		= "H3 Audio Codec";
	card->dapm_widgets	= sun6i_codec_card_dapm_widgets;
	card->num_dapm_widgets	= ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
	card->dapm_routes	= sun8i_codec_card_routes;
	card->num_dapm_routes	= ARRAY_SIZE(sun8i_codec_card_routes);
	card->aux_dev		= &aux_dev;
	card->num_aux_devs	= 1;
	card->fully_routed	= true;

	ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
	if (ret)
		dev_warn(dev, "failed to parse audio-routing: %d\n", ret);

	return card;
};

static struct snd_soc_card *sun8i_v3s_codec_create_card(struct device *dev)
{
	struct snd_soc_card *card;
	int ret;

	card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
	if (!card)
		return ERR_PTR(-ENOMEM);

	aux_dev.dlc.of_node = of_parse_phandle(dev->of_node,
						 "allwinner,codec-analog-controls",
						 0);
	if (!aux_dev.dlc.of_node) {
		dev_err(dev, "Can't find analog controls for codec.\n");
		return ERR_PTR(-EINVAL);
	}

	card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
	if (!card->dai_link)
		return ERR_PTR(-ENOMEM);

	card->dev		= dev;
	card->owner		= THIS_MODULE;
	card->name		= "V3s Audio Codec";
	card->dapm_widgets	= sun6i_codec_card_dapm_widgets;
	card->num_dapm_widgets	= ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
	card->dapm_routes	= sun8i_codec_card_routes;
	card->num_dapm_routes	= ARRAY_SIZE(sun8i_codec_card_routes);
	card->aux_dev		= &aux_dev;
	card->num_aux_devs	= 1;
	card->fully_routed	= true;

	ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
	if (ret)
		dev_warn(dev, "failed to parse audio-routing: %d\n", ret);

	return card;
};

static const struct regmap_config sun4i_codec_regmap_config =;

static const struct regmap_config sun6i_codec_regmap_config =;

static const struct regmap_config sun7i_codec_regmap_config =;

static const struct regmap_config sun8i_a23_codec_regmap_config =;

static const struct regmap_config sun8i_h3_codec_regmap_config =;

static const struct regmap_config sun8i_v3s_codec_regmap_config =;

struct sun4i_codec_quirks {};

static const struct sun4i_codec_quirks sun4i_codec_quirks =;

static const struct sun4i_codec_quirks sun6i_a31_codec_quirks =;

static const struct sun4i_codec_quirks sun7i_codec_quirks =;

static const struct sun4i_codec_quirks sun8i_a23_codec_quirks =;

static const struct sun4i_codec_quirks sun8i_h3_codec_quirks =;

static const struct sun4i_codec_quirks sun8i_v3s_codec_quirks =;

static const struct of_device_id sun4i_codec_of_match[] =;
MODULE_DEVICE_TABLE(of, sun4i_codec_of_match);

static int sun4i_codec_probe(struct platform_device *pdev)
{}

static void sun4i_codec_remove(struct platform_device *pdev)
{}

static struct platform_driver sun4i_codec_driver =;
module_platform_driver();

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