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

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * ALSA SoC SPDIF Audio Layer
 *
 * Copyright 2015 Andrea Venturi <[email protected]>
 * Copyright 2015 Marcus Cooper <[email protected]>
 *
 * Based on the Allwinner SDK driver, released under the GPL.
 */

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/regmap.h>
#include <linux/of.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>
#include <linux/spinlock.h>
#include <sound/asoundef.h>
#include <sound/dmaengine_pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>

#define SUN4I_SPDIF_CTL
	#define SUN4I_SPDIF_CTL_MCLKDIV(v)
	#define SUN4I_SPDIF_CTL_MCLKOUTEN
	#define SUN4I_SPDIF_CTL_GEN
	#define SUN4I_SPDIF_CTL_RESET

#define SUN4I_SPDIF_TXCFG
	#define SUN4I_SPDIF_TXCFG_SINGLEMOD
	#define SUN4I_SPDIF_TXCFG_ASS
	#define SUN4I_SPDIF_TXCFG_NONAUDIO
	#define SUN4I_SPDIF_TXCFG_TXRATIO(v)
	#define SUN4I_SPDIF_TXCFG_TXRATIO_MASK
	#define SUN4I_SPDIF_TXCFG_FMTRVD
	#define SUN4I_SPDIF_TXCFG_FMT16BIT
	#define SUN4I_SPDIF_TXCFG_FMT20BIT
	#define SUN4I_SPDIF_TXCFG_FMT24BIT
	#define SUN4I_SPDIF_TXCFG_CHSTMODE
	#define SUN4I_SPDIF_TXCFG_TXEN

#define SUN4I_SPDIF_RXCFG
	#define SUN4I_SPDIF_RXCFG_LOCKFLAG
	#define SUN4I_SPDIF_RXCFG_CHSTSRC
	#define SUN4I_SPDIF_RXCFG_CHSTCP
	#define SUN4I_SPDIF_RXCFG_RXEN

#define SUN4I_SPDIF_TXFIFO

#define SUN4I_SPDIF_RXFIFO

#define SUN4I_SPDIF_FCTL
	#define SUN4I_SPDIF_FCTL_FIFOSRC
	#define SUN4I_SPDIF_FCTL_FTX
	#define SUN4I_SPDIF_FCTL_FRX
	#define SUN4I_SPDIF_FCTL_TXTL(v)
	#define SUN4I_SPDIF_FCTL_TXTL_MASK
	#define SUN4I_SPDIF_FCTL_RXTL(v)
	#define SUN4I_SPDIF_FCTL_RXTL_MASK
	#define SUN4I_SPDIF_FCTL_TXIM
	#define SUN4I_SPDIF_FCTL_RXOM(v)
	#define SUN4I_SPDIF_FCTL_RXOM_MASK

#define SUN50I_H6_SPDIF_FCTL
	#define SUN50I_H6_SPDIF_FCTL_HUB_EN
	#define SUN50I_H6_SPDIF_FCTL_FTX
	#define SUN50I_H6_SPDIF_FCTL_FRX
	#define SUN50I_H6_SPDIF_FCTL_TXTL(v)
	#define SUN50I_H6_SPDIF_FCTL_TXTL_MASK
	#define SUN50I_H6_SPDIF_FCTL_RXTL(v)
	#define SUN50I_H6_SPDIF_FCTL_RXTL_MASK
	#define SUN50I_H6_SPDIF_FCTL_TXIM
	#define SUN50I_H6_SPDIF_FCTL_RXOM(v)
	#define SUN50I_H6_SPDIF_FCTL_RXOM_MASK

#define SUN4I_SPDIF_FSTA
	#define SUN4I_SPDIF_FSTA_TXE
	#define SUN4I_SPDIF_FSTA_TXECNTSHT
	#define SUN4I_SPDIF_FSTA_RXA
	#define SUN4I_SPDIF_FSTA_RXACNTSHT

#define SUN4I_SPDIF_INT
	#define SUN4I_SPDIF_INT_RXLOCKEN
	#define SUN4I_SPDIF_INT_RXUNLOCKEN
	#define SUN4I_SPDIF_INT_RXPARERREN
	#define SUN4I_SPDIF_INT_TXDRQEN
	#define SUN4I_SPDIF_INT_TXUIEN
	#define SUN4I_SPDIF_INT_TXOIEN
	#define SUN4I_SPDIF_INT_TXEIEN
	#define SUN4I_SPDIF_INT_RXDRQEN
	#define SUN4I_SPDIF_INT_RXOIEN
	#define SUN4I_SPDIF_INT_RXAIEN

#define SUN4I_SPDIF_ISTA
	#define SUN4I_SPDIF_ISTA_RXLOCKSTA
	#define SUN4I_SPDIF_ISTA_RXUNLOCKSTA
	#define SUN4I_SPDIF_ISTA_RXPARERRSTA
	#define SUN4I_SPDIF_ISTA_TXUSTA
	#define SUN4I_SPDIF_ISTA_TXOSTA
	#define SUN4I_SPDIF_ISTA_TXESTA
	#define SUN4I_SPDIF_ISTA_RXOSTA
	#define SUN4I_SPDIF_ISTA_RXASTA

#define SUN8I_SPDIF_TXFIFO

#define SUN4I_SPDIF_TXCNT

#define SUN4I_SPDIF_RXCNT

#define SUN4I_SPDIF_TXCHSTA0
	#define SUN4I_SPDIF_TXCHSTA0_CLK(v)
	#define SUN4I_SPDIF_TXCHSTA0_SAMFREQ(v)
	#define SUN4I_SPDIF_TXCHSTA0_SAMFREQ_MASK
	#define SUN4I_SPDIF_TXCHSTA0_CHNUM(v)
	#define SUN4I_SPDIF_TXCHSTA0_CHNUM_MASK
	#define SUN4I_SPDIF_TXCHSTA0_SRCNUM(v)
	#define SUN4I_SPDIF_TXCHSTA0_CATACOD(v)
	#define SUN4I_SPDIF_TXCHSTA0_MODE(v)
	#define SUN4I_SPDIF_TXCHSTA0_EMPHASIS(v)
	#define SUN4I_SPDIF_TXCHSTA0_CP
	#define SUN4I_SPDIF_TXCHSTA0_AUDIO
	#define SUN4I_SPDIF_TXCHSTA0_PRO

#define SUN4I_SPDIF_TXCHSTA1
	#define SUN4I_SPDIF_TXCHSTA1_CGMSA(v)
	#define SUN4I_SPDIF_TXCHSTA1_ORISAMFREQ(v)
	#define SUN4I_SPDIF_TXCHSTA1_ORISAMFREQ_MASK
	#define SUN4I_SPDIF_TXCHSTA1_SAMWORDLEN(v)
	#define SUN4I_SPDIF_TXCHSTA1_MAXWORDLEN

#define SUN4I_SPDIF_RXCHSTA0
	#define SUN4I_SPDIF_RXCHSTA0_CLK(v)
	#define SUN4I_SPDIF_RXCHSTA0_SAMFREQ(v)
	#define SUN4I_SPDIF_RXCHSTA0_CHNUM(v)
	#define SUN4I_SPDIF_RXCHSTA0_SRCNUM(v)
	#define SUN4I_SPDIF_RXCHSTA0_CATACOD(v)
	#define SUN4I_SPDIF_RXCHSTA0_MODE(v)
	#define SUN4I_SPDIF_RXCHSTA0_EMPHASIS(v)
	#define SUN4I_SPDIF_RXCHSTA0_CP
	#define SUN4I_SPDIF_RXCHSTA0_AUDIO
	#define SUN4I_SPDIF_RXCHSTA0_PRO

#define SUN4I_SPDIF_RXCHSTA1
	#define SUN4I_SPDIF_RXCHSTA1_CGMSA(v)
	#define SUN4I_SPDIF_RXCHSTA1_ORISAMFREQ(v)
	#define SUN4I_SPDIF_RXCHSTA1_SAMWORDLEN(v)
	#define SUN4I_SPDIF_RXCHSTA1_MAXWORDLEN

/* Defines for Sampling Frequency */
#define SUN4I_SPDIF_SAMFREQ_44_1KHZ
#define SUN4I_SPDIF_SAMFREQ_NOT_INDICATED
#define SUN4I_SPDIF_SAMFREQ_48KHZ
#define SUN4I_SPDIF_SAMFREQ_32KHZ
#define SUN4I_SPDIF_SAMFREQ_22_05KHZ
#define SUN4I_SPDIF_SAMFREQ_24KHZ
#define SUN4I_SPDIF_SAMFREQ_88_2KHZ
#define SUN4I_SPDIF_SAMFREQ_76_8KHZ
#define SUN4I_SPDIF_SAMFREQ_96KHZ
#define SUN4I_SPDIF_SAMFREQ_176_4KHZ
#define SUN4I_SPDIF_SAMFREQ_192KHZ

/**
 * struct sun4i_spdif_quirks - Differences between SoC variants.
 *
 * @reg_dac_txdata: TX FIFO offset for DMA config.
 * @has_reset: SoC needs reset deasserted.
 * @val_fctl_ftx: TX FIFO flush bitmask.
 */
struct sun4i_spdif_quirks {};

struct sun4i_spdif_dev {};

static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
{}

static void sun4i_snd_txctrl_on(struct snd_pcm_substream *substream,
				struct sun4i_spdif_dev *host)
{}

static void sun4i_snd_txctrl_off(struct snd_pcm_substream *substream,
				 struct sun4i_spdif_dev *host)
{}

static int sun4i_spdif_startup(struct snd_pcm_substream *substream,
			       struct snd_soc_dai *cpu_dai)
{}

static int sun4i_spdif_hw_params(struct snd_pcm_substream *substream,
				 struct snd_pcm_hw_params *params,
				 struct snd_soc_dai *cpu_dai)
{}

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

static int sun4i_spdif_info(struct snd_kcontrol *kcontrol,
			    struct snd_ctl_elem_info *uinfo)
{}

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

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

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

static struct snd_kcontrol_new sun4i_spdif_controls[] =;

static int sun4i_spdif_soc_dai_probe(struct snd_soc_dai *dai)
{}

static const struct snd_soc_dai_ops sun4i_spdif_dai_ops =;

static const struct regmap_config sun4i_spdif_regmap_config =;

#define SUN4I_RATES

#define SUN4I_FORMATS

static struct snd_soc_dai_driver sun4i_spdif_dai =;

static const struct sun4i_spdif_quirks sun4i_a10_spdif_quirks =;

static const struct sun4i_spdif_quirks sun6i_a31_spdif_quirks =;

static const struct sun4i_spdif_quirks sun8i_h3_spdif_quirks =;

static const struct sun4i_spdif_quirks sun50i_h6_spdif_quirks =;

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

static const struct snd_soc_component_driver sun4i_spdif_component =;

static int sun4i_spdif_runtime_suspend(struct device *dev)
{}

static int sun4i_spdif_runtime_resume(struct device *dev)
{}

static int sun4i_spdif_probe(struct platform_device *pdev)
{}

static void sun4i_spdif_remove(struct platform_device *pdev)
{}

static const struct dev_pm_ops sun4i_spdif_pm =;

static struct platform_driver sun4i_spdif_driver =;

module_platform_driver();

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