Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 1 | /* |
| 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 Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 8 | #define PSC_STREAM_NAME_LEN 32 |
| 9 | |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 10 | /** |
Jon Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 11 | * psc_ac97_stream - Data specific to a single stream (playback or capture) |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 12 | * @active: flag indicating if the stream is active |
Jon Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 13 | * @psc_dma: pointer back to parent psc_dma data structure |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 14 | * @bcom_task: bestcomm task structure |
| 15 | * @irq: irq number for bestcomm task |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 16 | * @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 Likely | c939e5c | 2009-11-07 01:34:43 -0700 | [diff] [blame] | 19 | * @ac97_slot_bits: Enable bits for turning on the correct AC97 slot |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 20 | */ |
Jon Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 21 | struct psc_dma_stream { |
Jon Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 22 | struct snd_pcm_runtime *runtime; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 23 | int active; |
Jon Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 24 | struct psc_dma *psc_dma; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 25 | struct bcom_task *bcom_task; |
| 26 | int irq; |
| 27 | struct snd_pcm_substream *stream; |
Grant Likely | 8f159d7 | 2009-11-07 01:33:53 -0700 | [diff] [blame] | 28 | int period_next; |
| 29 | int period_current; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 30 | int period_bytes; |
Grant Likely | c487827 | 2009-11-07 01:34:18 -0700 | [diff] [blame] | 31 | int period_count; |
Grant Likely | c939e5c | 2009-11-07 01:34:43 -0700 | [diff] [blame] | 32 | |
| 33 | /* AC97 state */ |
| 34 | u32 ac97_slot_bits; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | /** |
Jon Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 38 | * psc_dma - Private driver data |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 39 | * @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 Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 50 | struct psc_dma { |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 51 | 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 Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 56 | spinlock_t lock; |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 57 | struct mutex mutex; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 58 | u32 sicr; |
Jon Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 59 | uint sysclk; |
| 60 | int imr; |
| 61 | int id; |
| 62 | unsigned int slots; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 63 | |
| 64 | /* per-stream data */ |
Jon Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 65 | struct psc_dma_stream playback; |
| 66 | struct psc_dma_stream capture; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 67 | |
| 68 | /* Statistics */ |
| 69 | struct { |
Jon Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 70 | unsigned long overrun_count; |
| 71 | unsigned long underrun_count; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 72 | } stats; |
| 73 | }; |
| 74 | |
Grant Likely | 1d8222e | 2009-11-07 01:34:31 -0700 | [diff] [blame] | 75 | /* Utility for retrieving psc_dma_stream structure from a substream */ |
Grant Likely | f487537 | 2010-06-14 00:03:34 -0600 | [diff] [blame] | 76 | static inline struct psc_dma_stream * |
Grant Likely | 1d8222e | 2009-11-07 01:34:31 -0700 | [diff] [blame] | 77 | to_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 Millbrandt | f515b67 | 2012-09-13 17:43:11 -0400 | [diff] [blame] | 84 | int mpc5200_audio_dma_create(struct platform_device *op); |
| 85 | int mpc5200_audio_dma_destroy(struct platform_device *op); |
| 86 | |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 87 | #endif /* __SOUND_SOC_FSL_MPC5200_DMA_H__ */ |