xref: /openbmc/linux/sound/soc/meson/axg-fifo.h (revision 864cee90d4bd870e5d5e5a0b1a6f055f4f951350)
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;
12*864cee90SJerome Brunet struct reg_field;
136dc4fa17SJerome Brunet struct regmap;
14*864cee90SJerome 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 #define AXG_FIFO_MIN_CNT		64
356dc4fa17SJerome Brunet #define AXG_FIFO_MIN_DEPTH		(AXG_FIFO_BURST * AXG_FIFO_MIN_CNT)
366dc4fa17SJerome Brunet 
376dc4fa17SJerome Brunet #define FIFO_INT_ADDR_FINISH		BIT(0)
386dc4fa17SJerome Brunet #define FIFO_INT_ADDR_INT		BIT(1)
396dc4fa17SJerome Brunet #define FIFO_INT_COUNT_REPEAT		BIT(2)
406dc4fa17SJerome Brunet #define FIFO_INT_COUNT_ONCE		BIT(3)
416dc4fa17SJerome Brunet #define FIFO_INT_FIFO_ZERO		BIT(4)
426dc4fa17SJerome Brunet #define FIFO_INT_FIFO_DEPTH		BIT(5)
436dc4fa17SJerome Brunet #define FIFO_INT_MASK			GENMASK(7, 0)
446dc4fa17SJerome Brunet 
456dc4fa17SJerome Brunet #define FIFO_CTRL0			0x00
466dc4fa17SJerome Brunet #define  CTRL0_DMA_EN			BIT(31)
476dc4fa17SJerome Brunet #define  CTRL0_INT_EN(x)		((x) << 16)
486dc4fa17SJerome Brunet #define  CTRL0_SEL_MASK			GENMASK(2, 0)
496dc4fa17SJerome Brunet #define  CTRL0_SEL_SHIFT		0
506dc4fa17SJerome Brunet #define FIFO_CTRL1			0x04
516dc4fa17SJerome Brunet #define  CTRL1_INT_CLR(x)		((x) << 0)
526dc4fa17SJerome Brunet #define  CTRL1_STATUS2_SEL_MASK		GENMASK(11, 8)
536dc4fa17SJerome Brunet #define  CTRL1_STATUS2_SEL(x)		((x) << 8)
546dc4fa17SJerome Brunet #define   STATUS2_SEL_DDR_READ		0
556dc4fa17SJerome Brunet #define  CTRL1_FRDDR_DEPTH_MASK		GENMASK(31, 24)
566dc4fa17SJerome Brunet #define  CTRL1_FRDDR_DEPTH(x)		((x) << 24)
576dc4fa17SJerome Brunet #define FIFO_START_ADDR			0x08
586dc4fa17SJerome Brunet #define FIFO_FINISH_ADDR		0x0c
596dc4fa17SJerome Brunet #define FIFO_INT_ADDR			0x10
606dc4fa17SJerome Brunet #define FIFO_STATUS1			0x14
616dc4fa17SJerome Brunet #define  STATUS1_INT_STS(x)		((x) << 0)
626dc4fa17SJerome Brunet #define FIFO_STATUS2			0x18
637c02509aSJerome Brunet #define FIFO_INIT_ADDR			0x24
6452dd80d8SJerome Brunet #define FIFO_CTRL2			0x28
656dc4fa17SJerome Brunet 
666dc4fa17SJerome Brunet struct axg_fifo {
676dc4fa17SJerome Brunet 	struct regmap *map;
686dc4fa17SJerome Brunet 	struct clk *pclk;
696dc4fa17SJerome Brunet 	struct reset_control *arb;
70*864cee90SJerome Brunet 	struct regmap_field *field_threshold;
716dc4fa17SJerome Brunet 	int irq;
726dc4fa17SJerome Brunet };
736dc4fa17SJerome Brunet 
746dc4fa17SJerome Brunet struct axg_fifo_match_data {
756dc4fa17SJerome Brunet 	const struct snd_soc_component_driver *component_drv;
766dc4fa17SJerome Brunet 	struct snd_soc_dai_driver *dai_drv;
77*864cee90SJerome Brunet 	struct reg_field field_threshold;
786dc4fa17SJerome Brunet };
796dc4fa17SJerome Brunet 
80bb4ba744SKuninori Morimoto int axg_fifo_pcm_open(struct snd_soc_component *component,
81bb4ba744SKuninori Morimoto 		      struct snd_pcm_substream *ss);
82bb4ba744SKuninori Morimoto int axg_fifo_pcm_close(struct snd_soc_component *component,
83bb4ba744SKuninori Morimoto 		       struct snd_pcm_substream *ss);
84bb4ba744SKuninori Morimoto int axg_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 g12a_fifo_pcm_hw_params(struct snd_soc_component *component,
88bb4ba744SKuninori Morimoto 			    struct snd_pcm_substream *ss,
89bb4ba744SKuninori Morimoto 			    struct snd_pcm_hw_params *params);
90bb4ba744SKuninori Morimoto int axg_fifo_pcm_hw_free(struct snd_soc_component *component,
91bb4ba744SKuninori Morimoto 			 struct snd_pcm_substream *ss);
92bb4ba744SKuninori Morimoto snd_pcm_uframes_t axg_fifo_pcm_pointer(struct snd_soc_component *component,
93bb4ba744SKuninori Morimoto 				       struct snd_pcm_substream *ss);
94bb4ba744SKuninori Morimoto int axg_fifo_pcm_trigger(struct snd_soc_component *component,
95bb4ba744SKuninori Morimoto 			 struct snd_pcm_substream *ss, int cmd);
966dc4fa17SJerome Brunet 
976dc4fa17SJerome Brunet int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type);
986dc4fa17SJerome Brunet int axg_fifo_probe(struct platform_device *pdev);
996dc4fa17SJerome Brunet 
1006dc4fa17SJerome Brunet #endif /* _MESON_AXG_FIFO_H */
101