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 |
| 16 | * @period_start: physical address of start of DMA region |
| 17 | * @period_end: physical address of end of DMA region |
| 18 | * @period_next_pt: physical address of next DMA buffer to enqueue |
| 19 | * @period_bytes: size of DMA period in bytes |
| 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; |
| 23 | snd_pcm_uframes_t appl_ptr; |
| 24 | |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 25 | int active; |
Jon Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 26 | struct psc_dma *psc_dma; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 27 | struct bcom_task *bcom_task; |
| 28 | int irq; |
| 29 | struct snd_pcm_substream *stream; |
| 30 | dma_addr_t period_start; |
| 31 | dma_addr_t period_end; |
| 32 | dma_addr_t period_next_pt; |
| 33 | dma_addr_t period_current_pt; |
| 34 | int period_bytes; |
Jon Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 35 | int period_size; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | /** |
Jon Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 39 | * psc_dma - Private driver data |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 40 | * @name: short name for this device ("PSC0", "PSC1", etc) |
| 41 | * @psc_regs: pointer to the PSC's registers |
| 42 | * @fifo_regs: pointer to the PSC's FIFO registers |
| 43 | * @irq: IRQ of this PSC |
| 44 | * @dev: struct device pointer |
| 45 | * @dai: the CPU DAI for this device |
| 46 | * @sicr: Base value used in serial interface control register; mode is ORed |
| 47 | * with this value. |
| 48 | * @playback: Playback stream context data |
| 49 | * @capture: Capture stream context data |
| 50 | */ |
Jon Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 51 | struct psc_dma { |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 52 | char name[32]; |
| 53 | struct mpc52xx_psc __iomem *psc_regs; |
| 54 | struct mpc52xx_psc_fifo __iomem *fifo_regs; |
| 55 | unsigned int irq; |
| 56 | struct device *dev; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 57 | spinlock_t lock; |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 58 | struct mutex mutex; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 59 | u32 sicr; |
Jon Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 60 | uint sysclk; |
| 61 | int imr; |
| 62 | int id; |
| 63 | unsigned int slots; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 64 | |
| 65 | /* per-stream data */ |
Jon Smirl | cebe776 | 2009-05-23 19:13:01 -0400 | [diff] [blame] | 66 | struct psc_dma_stream playback; |
| 67 | struct psc_dma_stream capture; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 68 | |
| 69 | /* Statistics */ |
| 70 | struct { |
Jon Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 71 | unsigned long overrun_count; |
| 72 | unsigned long underrun_count; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 73 | } stats; |
| 74 | }; |
| 75 | |
Jon Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 76 | int mpc5200_audio_dma_create(struct of_device *op); |
| 77 | int mpc5200_audio_dma_destroy(struct of_device *op); |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 78 | |
Jon Smirl | dbcc347 | 2009-05-26 08:34:08 -0400 | [diff] [blame] | 79 | extern struct snd_soc_platform mpc5200_audio_dma_platform; |
Jon Smirl | 89dd084 | 2009-05-23 19:12:59 -0400 | [diff] [blame] | 80 | |
| 81 | #endif /* __SOUND_SOC_FSL_MPC5200_DMA_H__ */ |