xref: /openbmc/linux/sound/soc/meson/axg-fifo.h (revision 52dd80d8f7386483bc60b2b7470e47a2e6f61d7c)
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;
126dc4fa17SJerome Brunet struct regmap;
136dc4fa17SJerome Brunet struct reset_control;
146dc4fa17SJerome Brunet 
156dc4fa17SJerome Brunet struct snd_soc_component_driver;
166dc4fa17SJerome Brunet struct snd_soc_dai;
176dc4fa17SJerome Brunet struct snd_soc_dai_driver;
186dc4fa17SJerome Brunet struct snd_pcm_ops;
196dc4fa17SJerome Brunet struct snd_soc_pcm_runtime;
206dc4fa17SJerome Brunet 
216dc4fa17SJerome Brunet #define AXG_FIFO_CH_MAX			128
226dc4fa17SJerome Brunet #define AXG_FIFO_RATES			(SNDRV_PCM_RATE_5512 |		\
236dc4fa17SJerome Brunet 					 SNDRV_PCM_RATE_8000_192000)
246dc4fa17SJerome Brunet #define AXG_FIFO_FORMATS		(SNDRV_PCM_FMTBIT_S8 |		\
256dc4fa17SJerome Brunet 					 SNDRV_PCM_FMTBIT_S16_LE |	\
266dc4fa17SJerome Brunet 					 SNDRV_PCM_FMTBIT_S20_LE |	\
276dc4fa17SJerome Brunet 					 SNDRV_PCM_FMTBIT_S24_LE |	\
28984463a9SJerome Brunet 					 SNDRV_PCM_FMTBIT_S32_LE |	\
29984463a9SJerome Brunet 					 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
306dc4fa17SJerome Brunet 
316dc4fa17SJerome Brunet #define AXG_FIFO_BURST			8
326dc4fa17SJerome Brunet #define AXG_FIFO_MIN_CNT		64
336dc4fa17SJerome Brunet #define AXG_FIFO_MIN_DEPTH		(AXG_FIFO_BURST * AXG_FIFO_MIN_CNT)
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)
456dc4fa17SJerome Brunet #define  CTRL0_INT_EN(x)		((x) << 16)
466dc4fa17SJerome Brunet #define  CTRL0_SEL_MASK			GENMASK(2, 0)
476dc4fa17SJerome Brunet #define  CTRL0_SEL_SHIFT		0
486dc4fa17SJerome Brunet #define FIFO_CTRL1			0x04
496dc4fa17SJerome Brunet #define  CTRL1_INT_CLR(x)		((x) << 0)
506dc4fa17SJerome Brunet #define  CTRL1_STATUS2_SEL_MASK		GENMASK(11, 8)
516dc4fa17SJerome Brunet #define  CTRL1_STATUS2_SEL(x)		((x) << 8)
526dc4fa17SJerome Brunet #define   STATUS2_SEL_DDR_READ		0
536dc4fa17SJerome Brunet #define  CTRL1_THRESHOLD_MASK		GENMASK(23, 16)
546dc4fa17SJerome Brunet #define  CTRL1_THRESHOLD(x)		((x) << 16)
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
64*52dd80d8SJerome 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;
706dc4fa17SJerome Brunet 	int irq;
716dc4fa17SJerome Brunet };
726dc4fa17SJerome Brunet 
736dc4fa17SJerome Brunet struct axg_fifo_match_data {
746dc4fa17SJerome Brunet 	const struct snd_soc_component_driver *component_drv;
756dc4fa17SJerome Brunet 	struct snd_soc_dai_driver *dai_drv;
766dc4fa17SJerome Brunet };
776dc4fa17SJerome Brunet 
786dc4fa17SJerome Brunet extern const struct snd_pcm_ops axg_fifo_pcm_ops;
797c02509aSJerome Brunet extern const struct snd_pcm_ops g12a_fifo_pcm_ops;
806dc4fa17SJerome Brunet 
816dc4fa17SJerome Brunet int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type);
826dc4fa17SJerome Brunet int axg_fifo_probe(struct platform_device *pdev);
836dc4fa17SJerome Brunet 
846dc4fa17SJerome Brunet #endif /* _MESON_AXG_FIFO_H */
85