linux/sound/soc/sh/fsi.c

// SPDX-License-Identifier: GPL-2.0
//
// Fifo-attached Serial Interface (FSI) support for SH7724
//
// Copyright (C) 2009 Renesas Solutions Corp.
// Kuninori Morimoto <[email protected]>
//
// Based on ssi.c
// Copyright (c) 2007 Manuel Lauss <[email protected]>

#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/pm_runtime.h>
#include <linux/io.h>
#include <linux/of.h>
#include <linux/scatterlist.h>
#include <linux/sh_dma.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/workqueue.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>
#include <sound/sh_fsi.h>

/* PortA/PortB register */
#define REG_DO_FMT
#define REG_DOFF_CTL
#define REG_DOFF_ST
#define REG_DI_FMT
#define REG_DIFF_CTL
#define REG_DIFF_ST
#define REG_CKG1
#define REG_CKG2
#define REG_DIDT
#define REG_DODT
#define REG_MUTE_ST
#define REG_OUT_DMAC
#define REG_OUT_SEL
#define REG_IN_DMAC

/* master register */
#define MST_CLK_RST
#define MST_SOFT_RST
#define MST_FIFO_SZ

/* core register (depend on FSI version) */
#define A_MST_CTLR
#define B_MST_CTLR
#define CPU_INT_ST
#define CPU_IEMSK
#define CPU_IMSK
#define INT_ST
#define IEMSK
#define IMSK

/* DO_FMT */
/* DI_FMT */
#define CR_BWS_MASK
#define CR_BWS_24
#define CR_BWS_16
#define CR_BWS_20

#define CR_DTMD_PCM
#define CR_DTMD_SPDIF_PCM
#define CR_DTMD_SPDIF_STREAM

#define CR_MONO
#define CR_MONO_D
#define CR_PCM
#define CR_I2S
#define CR_TDM
#define CR_TDM_D

/* OUT_DMAC */
/* IN_DMAC */
#define VDMD_MASK
#define VDMD_FRONT
#define VDMD_BACK
#define VDMD_STREAM

#define DMA_ON

/* DOFF_CTL */
/* DIFF_CTL */
#define IRQ_HALF
#define FIFO_CLR

/* DOFF_ST */
#define ERR_OVER
#define ERR_UNDER
#define ST_ERR

/* CKG1 */
#define ACKMD_MASK
#define BPFMD_MASK
#define DIMD
#define DOMD

/* A/B MST_CTLR */
#define BP
#define SE

/* CLK_RST */
#define CRB
#define CRA

/* IO SHIFT / MACRO */
#define BI_SHIFT
#define BO_SHIFT
#define AI_SHIFT
#define AO_SHIFT
#define AB_IO(param, shift)

/* SOFT_RST */
#define PBSR
#define PASR
#define IR
#define FSISR

/* OUT_SEL (FSI2) */
#define DMMD
				 /*			1: Biphase and serial */

/* FIFO_SZ */
#define FIFO_SZ_MASK

#define FSI_RATES

#define FSI_FMTS

/*
 * bus options
 *
 * 0x000000BA
 *
 * A : sample widtht 16bit setting
 * B : sample widtht 24bit setting
 */

#define SHIFT_16DATA
#define SHIFT_24DATA

#define PACKAGE_24BITBUS_BACK
#define PACKAGE_24BITBUS_FRONT
#define PACKAGE_16BITBUS_STREAM

#define BUSOP_SET(s, a)
#define BUSOP_GET(s, a)

/*
 * FSI driver use below type name for variable
 *
 * xxx_num	: number of data
 * xxx_pos	: position of data
 * xxx_capa	: capacity of data
 */

/*
 *	period/frame/sample image
 *
 * ex) PCM (2ch)
 *
 * period pos					   period pos
 *   [n]					     [n + 1]
 *   |<-------------------- period--------------------->|
 * ==|============================================ ... =|==
 *   |							|
 *   ||<-----  frame ----->|<------ frame ----->|  ...	|
 *   |+--------------------+--------------------+- ...	|
 *   ||[ sample ][ sample ]|[ sample ][ sample ]|  ...	|
 *   |+--------------------+--------------------+- ...	|
 * ==|============================================ ... =|==
 */

/*
 *	FSI FIFO image
 *
 *	|	     |
 *	|	     |
 *	| [ sample ] |
 *	| [ sample ] |
 *	| [ sample ] |
 *	| [ sample ] |
 *		--> go to codecs
 */

/*
 *	FSI clock
 *
 * FSIxCLK [CPG] (ick) ------->	|
 *				|-> FSI_DIV (div)-> FSI2
 * FSIxCK [external] (xck) --->	|
 */

/*
 *		struct
 */

struct fsi_stream_handler;
struct fsi_stream {};

struct fsi_clk {};

struct fsi_priv {};

struct fsi_stream_handler {};
#define fsi_stream_handler_call(io, func, args...)

struct fsi_core {};

struct fsi_master {};

static inline int fsi_stream_is_play(struct fsi_priv *fsi,
				     struct fsi_stream *io)
{}


/*
 *		basic read write function
 */

static void __fsi_reg_write(u32 __iomem *reg, u32 data)
{}

static u32 __fsi_reg_read(u32 __iomem *reg)
{}

static void __fsi_reg_mask_set(u32 __iomem *reg, u32 mask, u32 data)
{}

#define fsi_reg_write(p, r, d)

#define fsi_reg_read(p, r)

#define fsi_reg_mask_set(p, r, m, d)

#define fsi_master_read(p, r)
#define fsi_core_read(p, r)
static u32 _fsi_master_read(struct fsi_master *master, u32 reg)
{}

#define fsi_master_mask_set(p, r, m, d)
#define fsi_core_mask_set(p, r, m, d)
static void _fsi_master_mask_set(struct fsi_master *master,
			       u32 reg, u32 mask, u32 data)
{}

/*
 *		basic function
 */
static int fsi_version(struct fsi_master *master)
{}

static struct fsi_master *fsi_get_master(struct fsi_priv *fsi)
{}

static int fsi_is_clk_master(struct fsi_priv *fsi)
{}

static int fsi_is_port_a(struct fsi_priv *fsi)
{}

static int fsi_is_spdif(struct fsi_priv *fsi)
{}

static int fsi_is_enable_stream(struct fsi_priv *fsi)
{}

static int fsi_is_play(struct snd_pcm_substream *substream)
{}

static struct snd_soc_dai *fsi_get_dai(struct snd_pcm_substream *substream)
{}

static struct fsi_priv *fsi_get_priv_frm_dai(struct snd_soc_dai *dai)
{}

static struct fsi_priv *fsi_get_priv(struct snd_pcm_substream *substream)
{}

static u32 fsi_get_port_shift(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static int fsi_frame2sample(struct fsi_priv *fsi, int frames)
{}

static int fsi_sample2frame(struct fsi_priv *fsi, int samples)
{}

static int fsi_get_current_fifo_samples(struct fsi_priv *fsi,
					struct fsi_stream *io)
{}

static void fsi_count_fifo_err(struct fsi_priv *fsi)
{}

/*
 *		fsi_stream_xx() function
 */
static inline struct fsi_stream *fsi_stream_get(struct fsi_priv *fsi,
					struct snd_pcm_substream *substream)
{}

static int fsi_stream_is_working(struct fsi_priv *fsi,
				 struct fsi_stream *io)
{}

static struct fsi_priv *fsi_stream_to_priv(struct fsi_stream *io)
{}

static void fsi_stream_init(struct fsi_priv *fsi,
			    struct fsi_stream *io,
			    struct snd_pcm_substream *substream)
{}

static void fsi_stream_quit(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static int fsi_stream_transfer(struct fsi_stream *io)
{}

#define fsi_stream_start(fsi, io)

#define fsi_stream_stop(fsi, io)

static int fsi_stream_probe(struct fsi_priv *fsi, struct device *dev)
{}

static int fsi_stream_remove(struct fsi_priv *fsi)
{}

/*
 *	format/bus/dma setting
 */
static void fsi_format_bus_setup(struct fsi_priv *fsi, struct fsi_stream *io,
				 u32 bus, struct device *dev)
{}

/*
 *		irq function
 */

static void fsi_irq_enable(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static void fsi_irq_disable(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static u32 fsi_irq_get_status(struct fsi_master *master)
{}

static void fsi_irq_clear_status(struct fsi_priv *fsi)
{}

/*
 *		SPDIF master clock function
 *
 * These functions are used later FSI2
 */
static void fsi_spdif_clk_ctrl(struct fsi_priv *fsi, int enable)
{}

/*
 *		clock function
 */
static int fsi_clk_init(struct device *dev,
			struct fsi_priv *fsi,
			int xck,
			int ick,
			int div,
			int (*set_rate)(struct device *dev,
					struct fsi_priv *fsi))
{}

#define fsi_clk_invalid(fsi)
static void fsi_clk_valid(struct fsi_priv *fsi, unsigned long rate)
{}

static int fsi_clk_is_valid(struct fsi_priv *fsi)
{}

static int fsi_clk_enable(struct device *dev,
			  struct fsi_priv *fsi)
{}

static int fsi_clk_disable(struct device *dev,
			    struct fsi_priv *fsi)
{}

static int fsi_clk_set_ackbpf(struct device *dev,
			      struct fsi_priv *fsi,
			      int ackmd, int bpfmd)
{}

static int fsi_clk_set_rate_external(struct device *dev,
				     struct fsi_priv *fsi)
{}

static int fsi_clk_set_rate_cpg(struct device *dev,
				struct fsi_priv *fsi)
{}

static void fsi_pointer_update(struct fsi_stream *io, int size)
{}

/*
 *		pio data transfer handler
 */
static void fsi_pio_push16(struct fsi_priv *fsi, u8 *_buf, int samples)
{}

static void fsi_pio_pop16(struct fsi_priv *fsi, u8 *_buf, int samples)
{}

static void fsi_pio_push32(struct fsi_priv *fsi, u8 *_buf, int samples)
{}

static void fsi_pio_pop32(struct fsi_priv *fsi, u8 *_buf, int samples)
{}

static u8 *fsi_pio_get_area(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static int fsi_pio_transfer(struct fsi_priv *fsi, struct fsi_stream *io,
		void (*run16)(struct fsi_priv *fsi, u8 *buf, int samples),
		void (*run32)(struct fsi_priv *fsi, u8 *buf, int samples),
		int samples)
{}

static int fsi_pio_pop(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static int fsi_pio_push(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static int fsi_pio_start_stop(struct fsi_priv *fsi, struct fsi_stream *io,
			       int enable)
{}

static int fsi_pio_push_init(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static int fsi_pio_pop_init(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static struct fsi_stream_handler fsi_pio_push_handler =;

static struct fsi_stream_handler fsi_pio_pop_handler =;

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

/*
 *		dma data transfer handler
 */
static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static void fsi_dma_complete(void *data)
{}

static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static int fsi_dma_push_start_stop(struct fsi_priv *fsi, struct fsi_stream *io,
				 int start)
{}

static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct device *dev)
{}

static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io)
{}

static struct fsi_stream_handler fsi_dma_push_handler =;

/*
 *		dai ops
 */
static void fsi_fifo_init(struct fsi_priv *fsi,
			  struct fsi_stream *io,
			  struct device *dev)
{}

static int fsi_hw_startup(struct fsi_priv *fsi,
			  struct fsi_stream *io,
			  struct device *dev)
{}

static int fsi_hw_shutdown(struct fsi_priv *fsi,
			    struct device *dev)
{}

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

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

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

static int fsi_set_fmt_dai(struct fsi_priv *fsi, unsigned int fmt)
{}

static int fsi_set_fmt_spdif(struct fsi_priv *fsi)
{}

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

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

/*
 * Select below from Sound Card, not auto
 *	SND_SOC_DAIFMT_CBC_CFC
 *	SND_SOC_DAIFMT_CBP_CFP
 */
static const u64 fsi_dai_formats =;

static const struct snd_soc_dai_ops fsi_dai_ops =;

/*
 *		pcm ops
 */

static const struct snd_pcm_hardware fsi_pcm_hardware =;

static int fsi_pcm_open(struct snd_soc_component *component,
			struct snd_pcm_substream *substream)
{}

static snd_pcm_uframes_t fsi_pointer(struct snd_soc_component *component,
				     struct snd_pcm_substream *substream)
{}

/*
 *		snd_soc_component
 */

#define PREALLOC_BUFFER
#define PREALLOC_BUFFER_MAX

static int fsi_pcm_new(struct snd_soc_component *component,
		       struct snd_soc_pcm_runtime *rtd)
{}

/*
 *		alsa struct
 */

static struct snd_soc_dai_driver fsi_soc_dai[] =;

static const struct snd_soc_component_driver fsi_soc_component =;

/*
 *		platform function
 */
static void fsi_of_parse(char *name,
			 struct device_node *np,
			 struct sh_fsi_port_info *info,
			 struct device *dev)
{}

static void fsi_port_info_init(struct fsi_priv *fsi,
			       struct sh_fsi_port_info *info)
{}

static void fsi_handler_init(struct fsi_priv *fsi,
			     struct sh_fsi_port_info *info)
{}

static const struct fsi_core fsi1_core =;

static const struct fsi_core fsi2_core =;

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

static const struct platform_device_id fsi_id_table[] =;
MODULE_DEVICE_TABLE(platform, fsi_id_table);

static int fsi_probe(struct platform_device *pdev)
{}

static void fsi_remove(struct platform_device *pdev)
{}

static void __fsi_suspend(struct fsi_priv *fsi,
			  struct fsi_stream *io,
			  struct device *dev)
{}

static void __fsi_resume(struct fsi_priv *fsi,
			 struct fsi_stream *io,
			 struct device *dev)
{}

static int fsi_suspend(struct device *dev)
{}

static int fsi_resume(struct device *dev)
{}

static const struct dev_pm_ops fsi_pm_ops =;

static struct platform_driver fsi_driver =;

module_platform_driver();

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