xref: /openbmc/linux/sound/soc/meson/axg-fifo.h (revision e0d77d0f38aa60ca61b3ce6e60d64fad2aa0853d)
16dc4fa17SJerome Brunet /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
26dc4fa17SJerome Brunet /*
36dc4fa17SJerome Brunet  * Copyright (c) 2018 BayLibre, SAS.
46dc4fa17SJerome Brunet  * Author: Jerome Brunet <jbrunet@baylibre.com>
56dc4fa17SJerome Brunet  */
66dc4fa17SJerome Brunet 
76dc4fa17SJerome Brunet #ifndef _MESON_AXG_FIFO_H
86dc4fa17SJerome Brunet #define _MESON_AXG_FIFO_H
96dc4fa17SJerome Brunet 
106dc4fa17SJerome Brunet struct clk;
116dc4fa17SJerome Brunet struct platform_device;
12864cee90SJerome Brunet struct reg_field;
136dc4fa17SJerome Brunet struct regmap;
14864cee90SJerome Brunet struct regmap_field;
156dc4fa17SJerome Brunet struct reset_control;
166dc4fa17SJerome Brunet 
176dc4fa17SJerome Brunet struct snd_soc_component_driver;
186dc4fa17SJerome Brunet struct snd_soc_dai;
196dc4fa17SJerome Brunet struct snd_soc_dai_driver;
20bb4ba744SKuninori Morimoto 
216dc4fa17SJerome Brunet struct snd_soc_pcm_runtime;
226dc4fa17SJerome Brunet 
236dc4fa17SJerome Brunet #define AXG_FIFO_CH_MAX			128
246dc4fa17SJerome Brunet #define AXG_FIFO_RATES			(SNDRV_PCM_RATE_5512 |		\
256dc4fa17SJerome Brunet 					 SNDRV_PCM_RATE_8000_192000)
266dc4fa17SJerome Brunet #define AXG_FIFO_FORMATS		(SNDRV_PCM_FMTBIT_S8 |		\
276dc4fa17SJerome Brunet 					 SNDRV_PCM_FMTBIT_S16_LE |	\
286dc4fa17SJerome Brunet 					 SNDRV_PCM_FMTBIT_S20_LE |	\
296dc4fa17SJerome Brunet 					 SNDRV_PCM_FMTBIT_S24_LE |	\
30984463a9SJerome Brunet 					 SNDRV_PCM_FMTBIT_S32_LE |	\
31984463a9SJerome Brunet 					 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
326dc4fa17SJerome Brunet 
336dc4fa17SJerome Brunet #define AXG_FIFO_BURST			8
346dc4fa17SJerome Brunet 
356dc4fa17SJerome Brunet #define FIFO_INT_ADDR_FINISH		BIT(0)
366dc4fa17SJerome Brunet #define FIFO_INT_ADDR_INT		BIT(1)
376dc4fa17SJerome Brunet #define FIFO_INT_COUNT_REPEAT		BIT(2)
386dc4fa17SJerome Brunet #define FIFO_INT_COUNT_ONCE		BIT(3)
396dc4fa17SJerome Brunet #define FIFO_INT_FIFO_ZERO		BIT(4)
406dc4fa17SJerome Brunet #define FIFO_INT_FIFO_DEPTH		BIT(5)
416dc4fa17SJerome Brunet #define FIFO_INT_MASK			GENMASK(7, 0)
426dc4fa17SJerome Brunet 
436dc4fa17SJerome Brunet #define FIFO_CTRL0			0x00
446dc4fa17SJerome Brunet #define  CTRL0_DMA_EN			BIT(31)
45*af8e6bbfSJerome Brunet #define  CTRL0_INT_EN			GENMASK(23, 16)
466dc4fa17SJerome Brunet #define  CTRL0_SEL_MASK			GENMASK(2, 0)
476dc4fa17SJerome Brunet #define  CTRL0_SEL_SHIFT		0
486dc4fa17SJerome Brunet #define FIFO_CTRL1			0x04
49*af8e6bbfSJerome Brunet #define  CTRL1_INT_CLR			GENMASK(7, 0)
50*af8e6bbfSJerome Brunet #define  CTRL1_STATUS2_SEL		GENMASK(11, 8)
516dc4fa17SJerome Brunet #define   STATUS2_SEL_DDR_READ		0
52*af8e6bbfSJerome Brunet #define  CTRL1_FRDDR_DEPTH		GENMASK(31, 24)
536dc4fa17SJerome Brunet #define FIFO_START_ADDR			0x08
546dc4fa17SJerome Brunet #define FIFO_FINISH_ADDR		0x0c
556dc4fa17SJerome Brunet #define FIFO_INT_ADDR			0x10
566dc4fa17SJerome Brunet #define FIFO_STATUS1			0x14
57*af8e6bbfSJerome Brunet #define  STATUS1_INT_STS		GENMASK(7, 0)
586dc4fa17SJerome Brunet #define FIFO_STATUS2			0x18
597c02509aSJerome Brunet #define FIFO_INIT_ADDR			0x24
6052dd80d8SJerome Brunet #define FIFO_CTRL2			0x28
616dc4fa17SJerome Brunet 
626dc4fa17SJerome Brunet struct axg_fifo {
636dc4fa17SJerome Brunet 	struct regmap *map;
646dc4fa17SJerome Brunet 	struct clk *pclk;
656dc4fa17SJerome Brunet 	struct reset_control *arb;
66864cee90SJerome Brunet 	struct regmap_field *field_threshold;
6723b89e1dSJerome Brunet 	unsigned int depth;
686dc4fa17SJerome Brunet 	int irq;
696dc4fa17SJerome Brunet };
706dc4fa17SJerome Brunet 
716dc4fa17SJerome Brunet struct axg_fifo_match_data {
726dc4fa17SJerome Brunet 	const struct snd_soc_component_driver *component_drv;
736dc4fa17SJerome Brunet 	struct snd_soc_dai_driver *dai_drv;
74864cee90SJerome Brunet 	struct reg_field field_threshold;
756dc4fa17SJerome Brunet };
766dc4fa17SJerome Brunet 
77bb4ba744SKuninori Morimoto int axg_fifo_pcm_open(struct snd_soc_component *component,
78bb4ba744SKuninori Morimoto 		      struct snd_pcm_substream *ss);
79bb4ba744SKuninori Morimoto int axg_fifo_pcm_close(struct snd_soc_component *component,
80bb4ba744SKuninori Morimoto 		       struct snd_pcm_substream *ss);
81bb4ba744SKuninori Morimoto int axg_fifo_pcm_hw_params(struct snd_soc_component *component,
82bb4ba744SKuninori Morimoto 			   struct snd_pcm_substream *ss,
83bb4ba744SKuninori Morimoto 			   struct snd_pcm_hw_params *params);
84bb4ba744SKuninori Morimoto int g12a_fifo_pcm_hw_params(struct snd_soc_component *component,
85bb4ba744SKuninori Morimoto 			    struct snd_pcm_substream *ss,
86bb4ba744SKuninori Morimoto 			    struct snd_pcm_hw_params *params);
87bb4ba744SKuninori Morimoto int axg_fifo_pcm_hw_free(struct snd_soc_component *component,
88bb4ba744SKuninori Morimoto 			 struct snd_pcm_substream *ss);
89bb4ba744SKuninori Morimoto snd_pcm_uframes_t axg_fifo_pcm_pointer(struct snd_soc_component *component,
90bb4ba744SKuninori Morimoto 				       struct snd_pcm_substream *ss);
91bb4ba744SKuninori Morimoto int axg_fifo_pcm_trigger(struct snd_soc_component *component,
92bb4ba744SKuninori Morimoto 			 struct snd_pcm_substream *ss, int cmd);
936dc4fa17SJerome Brunet 
946dc4fa17SJerome Brunet int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type);
956dc4fa17SJerome Brunet int axg_fifo_probe(struct platform_device *pdev);
966dc4fa17SJerome Brunet 
976dc4fa17SJerome Brunet #endif /* _MESON_AXG_FIFO_H */
98