blob: dff253fde29a98268185e715b2425134099eb296 [file] [log] [blame]
Jon Smirl89dd0842009-05-23 19:12:59 -04001/*
2 * Freescale MPC5200 Audio DMA driver
3 */
4
5#ifndef __SOUND_SOC_FSL_MPC5200_DMA_H__
6#define __SOUND_SOC_FSL_MPC5200_DMA_H__
7
Jon Smirldbcc3472009-05-26 08:34:08 -04008#define PSC_STREAM_NAME_LEN 32
9
Jon Smirl89dd0842009-05-23 19:12:59 -040010/**
Jon Smirldbcc3472009-05-26 08:34:08 -040011 * psc_ac97_stream - Data specific to a single stream (playback or capture)
Jon Smirl89dd0842009-05-23 19:12:59 -040012 * @active: flag indicating if the stream is active
Jon Smirlcebe7762009-05-23 19:13:01 -040013 * @psc_dma: pointer back to parent psc_dma data structure
Jon Smirl89dd0842009-05-23 19:12:59 -040014 * @bcom_task: bestcomm task structure
15 * @irq: irq number for bestcomm task
Jon Smirl89dd0842009-05-23 19:12:59 -040016 * @period_end: physical address of end of DMA region
17 * @period_next_pt: physical address of next DMA buffer to enqueue
18 * @period_bytes: size of DMA period in bytes
Grant Likelyc939e5c2009-11-07 01:34:43 -070019 * @ac97_slot_bits: Enable bits for turning on the correct AC97 slot
Jon Smirl89dd0842009-05-23 19:12:59 -040020 */
Jon Smirlcebe7762009-05-23 19:13:01 -040021struct psc_dma_stream {
Jon Smirldbcc3472009-05-26 08:34:08 -040022 struct snd_pcm_runtime *runtime;
Jon Smirl89dd0842009-05-23 19:12:59 -040023 int active;
Jon Smirlcebe7762009-05-23 19:13:01 -040024 struct psc_dma *psc_dma;
Jon Smirl89dd0842009-05-23 19:12:59 -040025 struct bcom_task *bcom_task;
26 int irq;
27 struct snd_pcm_substream *stream;
Grant Likely8f159d72009-11-07 01:33:53 -070028 int period_next;
29 int period_current;
Jon Smirl89dd0842009-05-23 19:12:59 -040030 int period_bytes;
Grant Likelyc4878272009-11-07 01:34:18 -070031 int period_count;
Grant Likelyc939e5c2009-11-07 01:34:43 -070032
33 /* AC97 state */
34 u32 ac97_slot_bits;
Jon Smirl89dd0842009-05-23 19:12:59 -040035};
36
37/**
Jon Smirlcebe7762009-05-23 19:13:01 -040038 * psc_dma - Private driver data
Jon Smirl89dd0842009-05-23 19:12:59 -040039 * @name: short name for this device ("PSC0", "PSC1", etc)
40 * @psc_regs: pointer to the PSC's registers
41 * @fifo_regs: pointer to the PSC's FIFO registers
42 * @irq: IRQ of this PSC
43 * @dev: struct device pointer
44 * @dai: the CPU DAI for this device
45 * @sicr: Base value used in serial interface control register; mode is ORed
46 * with this value.
47 * @playback: Playback stream context data
48 * @capture: Capture stream context data
49 */
Jon Smirlcebe7762009-05-23 19:13:01 -040050struct psc_dma {
Jon Smirl89dd0842009-05-23 19:12:59 -040051 char name[32];
52 struct mpc52xx_psc __iomem *psc_regs;
53 struct mpc52xx_psc_fifo __iomem *fifo_regs;
54 unsigned int irq;
55 struct device *dev;
Jon Smirl89dd0842009-05-23 19:12:59 -040056 spinlock_t lock;
Grant Likely0827d6b2009-07-02 11:57:25 -060057 struct mutex mutex;
Jon Smirl89dd0842009-05-23 19:12:59 -040058 u32 sicr;
Jon Smirldbcc3472009-05-26 08:34:08 -040059 uint sysclk;
60 int imr;
61 int id;
62 unsigned int slots;
Jon Smirl89dd0842009-05-23 19:12:59 -040063
64 /* per-stream data */
Jon Smirlcebe7762009-05-23 19:13:01 -040065 struct psc_dma_stream playback;
66 struct psc_dma_stream capture;
Jon Smirl89dd0842009-05-23 19:12:59 -040067
68 /* Statistics */
69 struct {
Jon Smirldbcc3472009-05-26 08:34:08 -040070 unsigned long overrun_count;
71 unsigned long underrun_count;
Jon Smirl89dd0842009-05-23 19:12:59 -040072 } stats;
73};
74
Grant Likely1d8222e2009-11-07 01:34:31 -070075/* Utility for retrieving psc_dma_stream structure from a substream */
Grant Likelyf4875372010-06-14 00:03:34 -060076static inline struct psc_dma_stream *
Grant Likely1d8222e2009-11-07 01:34:31 -070077to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma)
78{
79 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
80 return &psc_dma->capture;
81 return &psc_dma->playback;
82}
83
Eric Millbrandtf515b672012-09-13 17:43:11 -040084int mpc5200_audio_dma_create(struct platform_device *op);
85int mpc5200_audio_dma_destroy(struct platform_device *op);
86
Jon Smirl89dd0842009-05-23 19:12:59 -040087#endif /* __SOUND_SOC_FSL_MPC5200_DMA_H__ */