linux/sound/soc/sh/rcar/rsnd.h

// SPDX-License-Identifier: GPL-2.0
//
// Renesas R-Car
//
// Copyright (C) 2013 Renesas Solutions Corp.
// Kuninori Morimoto <[email protected]>

#ifndef RSND_H
#define RSND_H

#include <linux/clk.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/sh_dma.h>
#include <linux/workqueue.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>

#define RSND_BASE_ADG
#define RSND_BASE_SSI
#define RSND_BASE_SSIU
#define RSND_BASE_SCU
#define RSND_BASE_SDMC
#define RSND_BASE_MAX

/*
 *	pseudo register
 *
 * The register address offsets SRU/SCU/SSIU on Gen1/Gen2 are very different.
 * This driver uses pseudo register in order to hide it.
 * see gen1/gen2 for detail
 */
enum rsnd_reg {};
#define SRCIN_TIMSEL(i)
#define SRCOUT_TIMSEL(i)
#define CTU_SVxxR(i, j)
#define DVC_VOLxR(i)
#define AUDIO_CLK_SEL(i)
#define SSI_BUSIF_MODE(i)
#define SSI_BUSIF_ADINR(i)
#define SSI_BUSIF_DALIGN(i)
#define SSI9_BUSIF_MODE(i)
#define SSI9_BUSIF_ADINR(i)
#define SSI9_BUSIF_DALIGN(i)
#define SSI_SYS_STATUS(i)
#define SSI_SYS_INT_ENABLE(i)


struct rsnd_priv;
struct rsnd_mod;
struct rsnd_dai;
struct rsnd_dai_stream;

/*
 *	R-Car basic functions
 */
u32 rsnd_mod_read(struct rsnd_mod *mod, enum rsnd_reg reg);
void rsnd_mod_write(struct rsnd_mod *mod, enum rsnd_reg reg, u32 data);
void rsnd_mod_bset(struct rsnd_mod *mod, enum rsnd_reg reg, u32 mask, u32 data);
u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
u32 rsnd_get_busif_shift(struct rsnd_dai_stream *io, struct rsnd_mod *mod);

/*
 *	R-Car DMA
 */
int rsnd_dma_attach(struct rsnd_dai_stream *io,
		    struct rsnd_mod *mod, struct rsnd_mod **dma_mod);
int rsnd_dma_probe(struct rsnd_priv *priv);
struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, char *name,
					  struct rsnd_mod *mod, char *x);

/*
 *	R-Car sound mod
 */
enum rsnd_mod_type {};

struct rsnd_mod_ops {};

struct rsnd_dai_stream;
struct rsnd_mod {};
/*
 * status
 *
 * 0xH000DCB0
 *
 * B	0: init		1: quit
 * C	0: start	1: stop
 * D	0: hw_params	1: hw_free
 *
 * H is always called (see __rsnd_mod_call)
 */
#define __rsnd_mod_shift_init
#define __rsnd_mod_shift_quit
#define __rsnd_mod_shift_start
#define __rsnd_mod_shift_stop
#define __rsnd_mod_shift_hw_params
#define __rsnd_mod_shift_hw_free
#define __rsnd_mod_shift_probe
#define __rsnd_mod_shift_remove
#define __rsnd_mod_shift_irq
#define __rsnd_mod_shift_pcm_new
#define __rsnd_mod_shift_fallback
#define __rsnd_mod_shift_pointer
#define __rsnd_mod_shift_prepare
#define __rsnd_mod_shift_cleanup

#define __rsnd_mod_add_probe
#define __rsnd_mod_add_remove
#define __rsnd_mod_add_prepare
#define __rsnd_mod_add_cleanup
#define __rsnd_mod_add_init
#define __rsnd_mod_add_quit
#define __rsnd_mod_add_start
#define __rsnd_mod_add_stop
#define __rsnd_mod_add_hw_params
#define __rsnd_mod_add_hw_free
#define __rsnd_mod_add_irq
#define __rsnd_mod_add_pcm_new
#define __rsnd_mod_add_fallback
#define __rsnd_mod_add_pointer

#define __rsnd_mod_call_probe
#define __rsnd_mod_call_remove
#define __rsnd_mod_call_prepare
#define __rsnd_mod_call_cleanup
#define __rsnd_mod_call_init
#define __rsnd_mod_call_quit
#define __rsnd_mod_call_start
#define __rsnd_mod_call_stop
#define __rsnd_mod_call_hw_params
#define __rsnd_mod_call_hw_free
#define __rsnd_mod_call_irq
#define __rsnd_mod_call_pcm_new
#define __rsnd_mod_call_fallback
#define __rsnd_mod_call_pointer

#define rsnd_mod_to_priv(mod)
#define rsnd_mod_power_on(mod)
#define rsnd_mod_power_off(mod)
#define rsnd_mod_get(ip)

int rsnd_mod_init(struct rsnd_priv *priv,
		  struct rsnd_mod *mod,
		  struct rsnd_mod_ops *ops,
		  struct clk *clk,
		  enum rsnd_mod_type type,
		  int id);
void rsnd_mod_quit(struct rsnd_mod *mod);
struct dma_chan *rsnd_mod_dma_req(struct rsnd_dai_stream *io,
				  struct rsnd_mod *mod);
void rsnd_mod_interrupt(struct rsnd_mod *mod,
			void (*callback)(struct rsnd_mod *mod,
					 struct rsnd_dai_stream *io));
u32 *rsnd_mod_get_status(struct rsnd_mod *mod,
			 struct rsnd_dai_stream *io,
			 enum rsnd_mod_type type);
int rsnd_mod_id(struct rsnd_mod *mod);
int rsnd_mod_id_raw(struct rsnd_mod *mod);
int rsnd_mod_id_sub(struct rsnd_mod *mod);
char *rsnd_mod_name(struct rsnd_mod *mod);
struct rsnd_mod *rsnd_mod_next(int *iterator,
			       struct rsnd_dai_stream *io,
			       enum rsnd_mod_type *array,
			       int array_size);
#define for_each_rsnd_mod(iterator, pos, io)
#define for_each_rsnd_mod_arrays(iterator, pos, io, array, size)
#define for_each_rsnd_mod_array(iterator, pos, io, array)

void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name,
		struct rsnd_mod* (*mod_get)(struct rsnd_priv *priv, int id),
		struct device_node *node,
		struct device_node *playback,
		struct device_node *capture);
int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name);
int rsnd_node_fixed_index(struct device *dev, struct device_node *node, char *name, int idx);

int rsnd_channel_normalization(int chan);
#define rsnd_runtime_channel_original(io)
int rsnd_runtime_channel_original_with_params(struct rsnd_dai_stream *io,
				struct snd_pcm_hw_params *params);
#define rsnd_runtime_channel_after_ctu(io)
int rsnd_runtime_channel_after_ctu_with_params(struct rsnd_dai_stream *io,
				struct snd_pcm_hw_params *params);
#define rsnd_runtime_channel_for_ssi(io)
int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io,
				 struct snd_pcm_hw_params *params);
int rsnd_runtime_is_multi_ssi(struct rsnd_dai_stream *io);
int rsnd_runtime_is_tdm(struct rsnd_dai_stream *io);
int rsnd_runtime_is_tdm_split(struct rsnd_dai_stream *io);

/*
 * DT
 */
#define rsnd_parse_of_node(priv, node)
#define RSND_NODE_DAI
#define RSND_NODE_SSI
#define RSND_NODE_SSIU
#define RSND_NODE_SRC
#define RSND_NODE_CTU
#define RSND_NODE_MIX
#define RSND_NODE_DVC

/*
 *	R-Car sound DAI
 */
#define RSND_DAI_NAME_SIZE
struct rsnd_dai_stream {};

/* flags */
#define RSND_STREAM_HDMI0
#define RSND_STREAM_HDMI1
#define RSND_STREAM_TDM_SPLIT
#define RSND_HW_RULE_ERR

#define rsnd_io_to_mod(io, i)
#define rsnd_io_to_mod_ssi(io)
#define rsnd_io_to_mod_ssiu(io)
#define rsnd_io_to_mod_ssip(io)
#define rsnd_io_to_mod_src(io)
#define rsnd_io_to_mod_ctu(io)
#define rsnd_io_to_mod_mix(io)
#define rsnd_io_to_mod_dvc(io)
#define rsnd_io_to_mod_cmd(io)
#define rsnd_io_to_rdai(io)
#define rsnd_io_to_priv(io)
#define rsnd_io_is_play(io)
#define rsnd_io_to_runtime(io)
#define rsnd_io_converted_rate(io)
#define rsnd_io_converted_chan(io)
int rsnd_io_is_working(struct rsnd_dai_stream *io);

struct rsnd_dai {};

#define rsnd_rdai_nr(priv)
#define rsnd_rdai_is_clk_master(rdai)
#define rsnd_rdai_to_priv(rdai)
#define for_each_rsnd_dai(rdai, priv, i)

struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id);

#define rsnd_rdai_channels_set(rdai, max_channels)
#define rsnd_rdai_channels_get(rdai)
int rsnd_rdai_channels_ctrl(struct rsnd_dai *rdai,
			    int max_channels);

#define rsnd_rdai_ssi_lane_set(rdai, ssi_lane)
#define rsnd_rdai_ssi_lane_get(rdai)
int rsnd_rdai_ssi_lane_ctrl(struct rsnd_dai *rdai,
			    int ssi_lane);

#define rsnd_rdai_width_set(rdai, width)
#define rsnd_rdai_width_get(rdai)
int rsnd_rdai_width_ctrl(struct rsnd_dai *rdai, int width);
int rsnd_dai_connect(struct rsnd_mod *mod,
		     struct rsnd_dai_stream *io,
		     enum rsnd_mod_type type);

/*
 *	R-Car Gen1/Gen2
 */
int rsnd_gen_probe(struct rsnd_priv *priv);
void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
			       struct rsnd_mod *mod,
			       enum rsnd_reg reg);
phys_addr_t rsnd_gen_get_phy_addr(struct rsnd_priv *priv, int reg_id);
#ifdef CONFIG_DEBUG_FS
void __iomem *rsnd_gen_get_base_addr(struct rsnd_priv *priv, int reg_id);
#endif

/*
 *	R-Car ADG
 */
int rsnd_adg_clk_query(struct rsnd_priv *priv, unsigned int rate);
int rsnd_adg_ssi_clk_stop(struct rsnd_mod *ssi_mod);
int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *ssi_mod, unsigned int rate);
int rsnd_adg_probe(struct rsnd_priv *priv);
void rsnd_adg_remove(struct rsnd_priv *priv);
int rsnd_adg_set_src_timesel_gen2(struct rsnd_mod *src_mod,
				  struct rsnd_dai_stream *io,
				  unsigned int in_rate,
				  unsigned int out_rate);
int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *cmd_mod,
				 struct rsnd_dai_stream *io);
#define rsnd_adg_clk_enable(priv)
#define rsnd_adg_clk_disable(priv)
void rsnd_adg_clk_control(struct rsnd_priv *priv, int enable);
void rsnd_adg_clk_dbg_info(struct rsnd_priv *priv, struct seq_file *m);

/*
 *	R-Car sound priv
 */
struct rsnd_priv {};

#define rsnd_priv_to_pdev(priv)
#define rsnd_priv_to_dev(priv)

#define rsnd_is_gen1(priv)
#define rsnd_is_gen2(priv)
#define rsnd_is_gen3(priv)
#define rsnd_is_gen4(priv)
#define rsnd_is_gen3_e3(priv)

#define rsnd_flags_has(p, f)
#define rsnd_flags_set(p, f)
#define rsnd_flags_del(p, f)

/*
 *	rsnd_kctrl
 */
struct rsnd_kctrl_cfg {};

#define RSND_MAX_CHANNELS
struct rsnd_kctrl_cfg_m {};

struct rsnd_kctrl_cfg_s {};
#define rsnd_kctrl_size(x)
#define rsnd_kctrl_max(x)
#define rsnd_kctrl_valm(x, i)
#define rsnd_kctrl_vals(x)

int rsnd_kctrl_accept_anytime(struct rsnd_dai_stream *io);
int rsnd_kctrl_accept_runtime(struct rsnd_dai_stream *io);
struct rsnd_kctrl_cfg *rsnd_kctrl_init_m(struct rsnd_kctrl_cfg_m *cfg);
struct rsnd_kctrl_cfg *rsnd_kctrl_init_s(struct rsnd_kctrl_cfg_s *cfg);
int rsnd_kctrl_new(struct rsnd_mod *mod,
		   struct rsnd_dai_stream *io,
		   struct snd_soc_pcm_runtime *rtd,
		   const unsigned char *name,
		   int (*accept)(struct rsnd_dai_stream *io),
		   void (*update)(struct rsnd_dai_stream *io,
				  struct rsnd_mod *mod),
		   struct rsnd_kctrl_cfg *cfg,
		   const char * const *texts,
		   int size,
		   u32 max);

#define rsnd_kctrl_new_m(mod, io, rtd, name, accept, update, cfg, size, max)

#define rsnd_kctrl_new_s(mod, io, rtd, name, accept, update, cfg, max)

#define rsnd_kctrl_new_e(mod, io, rtd, name, accept, update, cfg, texts, size)

extern const char * const volume_ramp_rate[];
#define VOLUME_RAMP_MAX_DVC
#define VOLUME_RAMP_MAX_MIX

/*
 *	R-Car SSI
 */
int rsnd_ssi_probe(struct rsnd_priv *priv);
void rsnd_ssi_remove(struct rsnd_priv *priv);
struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id);
int rsnd_ssi_use_busif(struct rsnd_dai_stream *io);
u32 rsnd_ssi_multi_secondaries_runtime(struct rsnd_dai_stream *io);
int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod);

#define rsnd_ssi_is_pin_sharing(io)
int __rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod);

#define rsnd_ssi_of_node(priv)
void rsnd_parse_connect_ssi(struct rsnd_dai *rdai,
			    struct device_node *playback,
			    struct device_node *capture);
unsigned int rsnd_ssi_clk_query(struct rsnd_dai *rdai,
		       int param1, int param2, int *idx);

/*
 *	R-Car SSIU
 */
int rsnd_ssiu_attach(struct rsnd_dai_stream *io,
		     struct rsnd_mod *mod);
int rsnd_ssiu_probe(struct rsnd_priv *priv);
void rsnd_ssiu_remove(struct rsnd_priv *priv);
void rsnd_parse_connect_ssiu(struct rsnd_dai *rdai,
			     struct device_node *playback,
			     struct device_node *capture);
#define rsnd_ssiu_of_node(priv)
bool rsnd_ssiu_busif_err_status_clear(struct rsnd_mod *mod);

/*
 *	R-Car SRC
 */
int rsnd_src_probe(struct rsnd_priv *priv);
void rsnd_src_remove(struct rsnd_priv *priv);
struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id);

#define rsnd_src_get_in_rate(priv, io)
#define rsnd_src_get_out_rate(priv, io)
unsigned int rsnd_src_get_rate(struct rsnd_priv *priv,
			       struct rsnd_dai_stream *io,
			       int is_in);

#define rsnd_src_of_node(priv)
#define rsnd_parse_connect_src(rdai, playback, capture)

/*
 *	R-Car CTU
 */
int rsnd_ctu_probe(struct rsnd_priv *priv);
void rsnd_ctu_remove(struct rsnd_priv *priv);
struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id);
#define rsnd_ctu_of_node(priv)
#define rsnd_parse_connect_ctu(rdai, playback, capture)

/*
 *	R-Car MIX
 */
int rsnd_mix_probe(struct rsnd_priv *priv);
void rsnd_mix_remove(struct rsnd_priv *priv);
struct rsnd_mod *rsnd_mix_mod_get(struct rsnd_priv *priv, int id);
#define rsnd_mix_of_node(priv)
#define rsnd_parse_connect_mix(rdai, playback, capture)

/*
 *	R-Car DVC
 */
int rsnd_dvc_probe(struct rsnd_priv *priv);
void rsnd_dvc_remove(struct rsnd_priv *priv);
struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id);
#define rsnd_dvc_of_node(priv)
#define rsnd_parse_connect_dvc(rdai, playback, capture)

/*
 *	R-Car CMD
 */
int rsnd_cmd_probe(struct rsnd_priv *priv);
void rsnd_cmd_remove(struct rsnd_priv *priv);
int rsnd_cmd_attach(struct rsnd_dai_stream *io, int id);

void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type);

/*
 * If you don't need interrupt status debug message,
 * define RSND_DEBUG_NO_IRQ_STATUS as 1 on top of src.c/ssi.c
 *
 * #define RSND_DEBUG_NO_IRQ_STATUS 1
 */
#define rsnd_print_irq_status(dev, param...)

#ifdef CONFIG_DEBUG_FS
int rsnd_debugfs_probe(struct snd_soc_component *component);
void rsnd_debugfs_reg_show(struct seq_file *m, phys_addr_t _addr,
			   void __iomem *base, int offset, int size);
void rsnd_debugfs_mod_reg_show(struct seq_file *m, struct rsnd_mod *mod,
			       int reg_id, int offset, int size);

#else
#define rsnd_debugfs_probe
#endif

#endif /* RSND_H */