18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2018 BayLibre, SAS. 48c2ecf20Sopenharmony_ci * Author: Jerome Brunet <jbrunet@baylibre.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _MESON_AXG_FIFO_H 88c2ecf20Sopenharmony_ci#define _MESON_AXG_FIFO_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cistruct clk; 118c2ecf20Sopenharmony_cistruct platform_device; 128c2ecf20Sopenharmony_cistruct reg_field; 138c2ecf20Sopenharmony_cistruct regmap; 148c2ecf20Sopenharmony_cistruct regmap_field; 158c2ecf20Sopenharmony_cistruct reset_control; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct snd_soc_component_driver; 188c2ecf20Sopenharmony_cistruct snd_soc_dai; 198c2ecf20Sopenharmony_cistruct snd_soc_dai_driver; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistruct snd_soc_pcm_runtime; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define AXG_FIFO_CH_MAX 128 248c2ecf20Sopenharmony_ci#define AXG_FIFO_RATES (SNDRV_PCM_RATE_5512 | \ 258c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_8000_192000) 268c2ecf20Sopenharmony_ci#define AXG_FIFO_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ 278c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S16_LE | \ 288c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S20_LE | \ 298c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE | \ 308c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE | \ 318c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define AXG_FIFO_BURST 8 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define FIFO_INT_ADDR_FINISH BIT(0) 368c2ecf20Sopenharmony_ci#define FIFO_INT_ADDR_INT BIT(1) 378c2ecf20Sopenharmony_ci#define FIFO_INT_COUNT_REPEAT BIT(2) 388c2ecf20Sopenharmony_ci#define FIFO_INT_COUNT_ONCE BIT(3) 398c2ecf20Sopenharmony_ci#define FIFO_INT_FIFO_ZERO BIT(4) 408c2ecf20Sopenharmony_ci#define FIFO_INT_FIFO_DEPTH BIT(5) 418c2ecf20Sopenharmony_ci#define FIFO_INT_MASK GENMASK(7, 0) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define FIFO_CTRL0 0x00 448c2ecf20Sopenharmony_ci#define CTRL0_DMA_EN BIT(31) 458c2ecf20Sopenharmony_ci#define CTRL0_INT_EN(x) ((x) << 16) 468c2ecf20Sopenharmony_ci#define CTRL0_SEL_MASK GENMASK(2, 0) 478c2ecf20Sopenharmony_ci#define CTRL0_SEL_SHIFT 0 488c2ecf20Sopenharmony_ci#define FIFO_CTRL1 0x04 498c2ecf20Sopenharmony_ci#define CTRL1_INT_CLR(x) ((x) << 0) 508c2ecf20Sopenharmony_ci#define CTRL1_STATUS2_SEL_MASK GENMASK(11, 8) 518c2ecf20Sopenharmony_ci#define CTRL1_STATUS2_SEL(x) ((x) << 8) 528c2ecf20Sopenharmony_ci#define STATUS2_SEL_DDR_READ 0 538c2ecf20Sopenharmony_ci#define CTRL1_FRDDR_DEPTH_MASK GENMASK(31, 24) 548c2ecf20Sopenharmony_ci#define CTRL1_FRDDR_DEPTH(x) ((x) << 24) 558c2ecf20Sopenharmony_ci#define FIFO_START_ADDR 0x08 568c2ecf20Sopenharmony_ci#define FIFO_FINISH_ADDR 0x0c 578c2ecf20Sopenharmony_ci#define FIFO_INT_ADDR 0x10 588c2ecf20Sopenharmony_ci#define FIFO_STATUS1 0x14 598c2ecf20Sopenharmony_ci#define STATUS1_INT_STS(x) ((x) << 0) 608c2ecf20Sopenharmony_ci#define FIFO_STATUS2 0x18 618c2ecf20Sopenharmony_ci#define FIFO_INIT_ADDR 0x24 628c2ecf20Sopenharmony_ci#define FIFO_CTRL2 0x28 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistruct axg_fifo { 658c2ecf20Sopenharmony_ci struct regmap *map; 668c2ecf20Sopenharmony_ci struct clk *pclk; 678c2ecf20Sopenharmony_ci struct reset_control *arb; 688c2ecf20Sopenharmony_ci struct regmap_field *field_threshold; 698c2ecf20Sopenharmony_ci unsigned int depth; 708c2ecf20Sopenharmony_ci int irq; 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistruct axg_fifo_match_data { 748c2ecf20Sopenharmony_ci const struct snd_soc_component_driver *component_drv; 758c2ecf20Sopenharmony_ci struct snd_soc_dai_driver *dai_drv; 768c2ecf20Sopenharmony_ci struct reg_field field_threshold; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciint axg_fifo_pcm_open(struct snd_soc_component *component, 808c2ecf20Sopenharmony_ci struct snd_pcm_substream *ss); 818c2ecf20Sopenharmony_ciint axg_fifo_pcm_close(struct snd_soc_component *component, 828c2ecf20Sopenharmony_ci struct snd_pcm_substream *ss); 838c2ecf20Sopenharmony_ciint axg_fifo_pcm_hw_params(struct snd_soc_component *component, 848c2ecf20Sopenharmony_ci struct snd_pcm_substream *ss, 858c2ecf20Sopenharmony_ci struct snd_pcm_hw_params *params); 868c2ecf20Sopenharmony_ciint g12a_fifo_pcm_hw_params(struct snd_soc_component *component, 878c2ecf20Sopenharmony_ci struct snd_pcm_substream *ss, 888c2ecf20Sopenharmony_ci struct snd_pcm_hw_params *params); 898c2ecf20Sopenharmony_ciint axg_fifo_pcm_hw_free(struct snd_soc_component *component, 908c2ecf20Sopenharmony_ci struct snd_pcm_substream *ss); 918c2ecf20Sopenharmony_cisnd_pcm_uframes_t axg_fifo_pcm_pointer(struct snd_soc_component *component, 928c2ecf20Sopenharmony_ci struct snd_pcm_substream *ss); 938c2ecf20Sopenharmony_ciint axg_fifo_pcm_trigger(struct snd_soc_component *component, 948c2ecf20Sopenharmony_ci struct snd_pcm_substream *ss, int cmd); 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ciint axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type); 978c2ecf20Sopenharmony_ciint axg_fifo_probe(struct platform_device *pdev); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#endif /* _MESON_AXG_FIFO_H */ 100