axg-fifo.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2. /*
  3. * Copyright (c) 2018 BayLibre, SAS.
  4. * Author: Jerome Brunet <jbrunet@baylibre.com>
  5. */
  6. #ifndef _MESON_AXG_FIFO_H
  7. #define _MESON_AXG_FIFO_H
  8. struct clk;
  9. struct platform_device;
  10. struct reg_field;
  11. struct regmap;
  12. struct regmap_field;
  13. struct reset_control;
  14. struct snd_soc_component_driver;
  15. struct snd_soc_dai;
  16. struct snd_soc_dai_driver;
  17. struct snd_soc_pcm_runtime;
  18. #define AXG_FIFO_CH_MAX 128
  19. #define AXG_FIFO_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
  20. SNDRV_PCM_FMTBIT_S16_LE | \
  21. SNDRV_PCM_FMTBIT_S20_LE | \
  22. SNDRV_PCM_FMTBIT_S24_LE | \
  23. SNDRV_PCM_FMTBIT_S32_LE | \
  24. SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
  25. #define AXG_FIFO_BURST 8
  26. #define FIFO_INT_ADDR_FINISH BIT(0)
  27. #define FIFO_INT_ADDR_INT BIT(1)
  28. #define FIFO_INT_COUNT_REPEAT BIT(2)
  29. #define FIFO_INT_COUNT_ONCE BIT(3)
  30. #define FIFO_INT_FIFO_ZERO BIT(4)
  31. #define FIFO_INT_FIFO_DEPTH BIT(5)
  32. #define FIFO_INT_MASK GENMASK(7, 0)
  33. #define FIFO_CTRL0 0x00
  34. #define CTRL0_DMA_EN BIT(31)
  35. #define CTRL0_INT_EN GENMASK(23, 16)
  36. #define CTRL0_SEL_MASK GENMASK(2, 0)
  37. #define CTRL0_SEL_SHIFT 0
  38. #define FIFO_CTRL1 0x04
  39. #define CTRL1_INT_CLR GENMASK(7, 0)
  40. #define CTRL1_STATUS2_SEL GENMASK(11, 8)
  41. #define STATUS2_SEL_DDR_READ 0
  42. #define CTRL1_FRDDR_DEPTH GENMASK(31, 24)
  43. #define FIFO_START_ADDR 0x08
  44. #define FIFO_FINISH_ADDR 0x0c
  45. #define FIFO_INT_ADDR 0x10
  46. #define FIFO_STATUS1 0x14
  47. #define STATUS1_INT_STS GENMASK(7, 0)
  48. #define FIFO_STATUS2 0x18
  49. #define FIFO_INIT_ADDR 0x24
  50. #define FIFO_CTRL2 0x28
  51. struct axg_fifo {
  52. struct regmap *map;
  53. struct clk *pclk;
  54. struct reset_control *arb;
  55. struct regmap_field *field_threshold;
  56. unsigned int depth;
  57. int irq;
  58. };
  59. struct axg_fifo_match_data {
  60. const struct snd_soc_component_driver *component_drv;
  61. struct snd_soc_dai_driver *dai_drv;
  62. struct reg_field field_threshold;
  63. };
  64. int axg_fifo_pcm_open(struct snd_soc_component *component,
  65. struct snd_pcm_substream *ss);
  66. int axg_fifo_pcm_close(struct snd_soc_component *component,
  67. struct snd_pcm_substream *ss);
  68. int axg_fifo_pcm_hw_params(struct snd_soc_component *component,
  69. struct snd_pcm_substream *ss,
  70. struct snd_pcm_hw_params *params);
  71. int g12a_fifo_pcm_hw_params(struct snd_soc_component *component,
  72. struct snd_pcm_substream *ss,
  73. struct snd_pcm_hw_params *params);
  74. int axg_fifo_pcm_hw_free(struct snd_soc_component *component,
  75. struct snd_pcm_substream *ss);
  76. snd_pcm_uframes_t axg_fifo_pcm_pointer(struct snd_soc_component *component,
  77. struct snd_pcm_substream *ss);
  78. int axg_fifo_pcm_trigger(struct snd_soc_component *component,
  79. struct snd_pcm_substream *ss, int cmd);
  80. int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type);
  81. int axg_fifo_probe(struct platform_device *pdev);
  82. #endif /* _MESON_AXG_FIFO_H */