mpc5200_dma.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Freescale MPC5200 Audio DMA driver
  4. */
  5. #ifndef __SOUND_SOC_FSL_MPC5200_DMA_H__
  6. #define __SOUND_SOC_FSL_MPC5200_DMA_H__
  7. #define PSC_STREAM_NAME_LEN 32
  8. /**
  9. * psc_ac97_stream - Data specific to a single stream (playback or capture)
  10. * @active: flag indicating if the stream is active
  11. * @psc_dma: pointer back to parent psc_dma data structure
  12. * @bcom_task: bestcomm task structure
  13. * @irq: irq number for bestcomm task
  14. * @period_end: physical address of end of DMA region
  15. * @period_next_pt: physical address of next DMA buffer to enqueue
  16. * @period_bytes: size of DMA period in bytes
  17. * @ac97_slot_bits: Enable bits for turning on the correct AC97 slot
  18. */
  19. struct psc_dma_stream {
  20. struct snd_pcm_runtime *runtime;
  21. int active;
  22. struct psc_dma *psc_dma;
  23. struct bcom_task *bcom_task;
  24. int irq;
  25. struct snd_pcm_substream *stream;
  26. int period_next;
  27. int period_current;
  28. int period_bytes;
  29. int period_count;
  30. /* AC97 state */
  31. u32 ac97_slot_bits;
  32. };
  33. /**
  34. * psc_dma - Private driver data
  35. * @name: short name for this device ("PSC0", "PSC1", etc)
  36. * @psc_regs: pointer to the PSC's registers
  37. * @fifo_regs: pointer to the PSC's FIFO registers
  38. * @irq: IRQ of this PSC
  39. * @dev: struct device pointer
  40. * @dai: the CPU DAI for this device
  41. * @sicr: Base value used in serial interface control register; mode is ORed
  42. * with this value.
  43. * @playback: Playback stream context data
  44. * @capture: Capture stream context data
  45. */
  46. struct psc_dma {
  47. char name[32];
  48. struct mpc52xx_psc __iomem *psc_regs;
  49. struct mpc52xx_psc_fifo __iomem *fifo_regs;
  50. unsigned int irq;
  51. struct device *dev;
  52. spinlock_t lock;
  53. struct mutex mutex;
  54. u32 sicr;
  55. uint sysclk;
  56. int imr;
  57. int id;
  58. unsigned int slots;
  59. /* per-stream data */
  60. struct psc_dma_stream playback;
  61. struct psc_dma_stream capture;
  62. /* Statistics */
  63. struct {
  64. unsigned long overrun_count;
  65. unsigned long underrun_count;
  66. } stats;
  67. };
  68. /* Utility for retrieving psc_dma_stream structure from a substream */
  69. static inline struct psc_dma_stream *
  70. to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma)
  71. {
  72. if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
  73. return &psc_dma->capture;
  74. return &psc_dma->playback;
  75. }
  76. int mpc5200_audio_dma_create(struct platform_device *op);
  77. int mpc5200_audio_dma_destroy(struct platform_device *op);
  78. #endif /* __SOUND_SOC_FSL_MPC5200_DMA_H__ */