blob: 6bd63b0e95e2d363f229717400bc9623548bce55 [file] [log] [blame]
Sedji Gaouaou6c742502008-10-03 16:57:50 +02001/*
2 * at91-pcm.h - ALSA PCM interface for the Atmel AT91 SoC.
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2008 Atmel
6 *
7 * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
8 *
9 * Based on at91-pcm. by:
10 * Frank Mandarino <fmandarino@endrelia.com>
11 * Copyright 2006 Endrelia Technologies Inc.
12 *
13 * Based on pxa2xx-pcm.c by:
14 *
15 * Author: Nicolas Pitre
16 * Created: Nov 30, 2004
17 * Copyright: (C) 2004 MontaVista Software, Inc.
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 */
33
34#ifndef _ATMEL_PCM_H
35#define _ATMEL_PCM_H
36
37#include <linux/atmel-ssc.h>
38
Bo Shen92dfa612012-11-28 11:46:12 +080039#define ATMEL_SSC_DMABUF_SIZE (64 * 1024)
40
Sedji Gaouaou6c742502008-10-03 16:57:50 +020041/*
42 * Registers and status bits that are required by the PCM driver.
43 */
44struct atmel_pdc_regs {
45 unsigned int xpr; /* PDC recv/trans pointer */
46 unsigned int xcr; /* PDC recv/trans counter */
47 unsigned int xnpr; /* PDC next recv/trans pointer */
48 unsigned int xncr; /* PDC next recv/trans counter */
49 unsigned int ptcr; /* PDC transfer control */
50};
51
52struct atmel_ssc_mask {
53 u32 ssc_enable; /* SSC recv/trans enable */
54 u32 ssc_disable; /* SSC recv/trans disable */
55 u32 ssc_endx; /* SSC ENDTX or ENDRX */
56 u32 ssc_endbuf; /* SSC TXBUFE or RXBUFF */
57 u32 pdc_enable; /* PDC recv/trans enable */
58 u32 pdc_disable; /* PDC recv/trans disable */
59};
60
61/*
62 * This structure, shared between the PCM driver and the interface,
63 * contains all information required by the PCM driver to perform the
64 * PDC DMA operation. All fields except dma_intr_handler() are initialized
Nicolas Ferre97b4fc32011-05-26 13:44:11 +020065 * by the interface. The dma_intr_handler() pointer is set by the PCM
Sedji Gaouaou6c742502008-10-03 16:57:50 +020066 * driver and called by the interface SSC interrupt handler if it is
67 * non-NULL.
68 */
69struct atmel_pcm_dma_params {
70 char *name; /* stream identifier */
71 int pdc_xfer_size; /* PDC counter increment in bytes */
72 struct ssc_device *ssc; /* SSC device for stream */
73 struct atmel_pdc_regs *pdc; /* PDC receive or transmit registers */
74 struct atmel_ssc_mask *mask; /* SSC & PDC status bits */
75 struct snd_pcm_substream *substream;
76 void (*dma_intr_handler)(u32, struct snd_pcm_substream *);
77};
78
Sedji Gaouaou6c742502008-10-03 16:57:50 +020079/*
80 * SSC register access (since ssc_writel() / ssc_readl() require literal name)
81 */
82#define ssc_readx(base, reg) (__raw_readl((base) + (reg)))
83#define ssc_writex(base, reg, value) __raw_writel((value), (base) + (reg))
84
Bo Shen92dfa612012-11-28 11:46:12 +080085int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd);
86void atmel_pcm_free(struct snd_pcm *pcm);
87int atmel_pcm_mmap(struct snd_pcm_substream *substream,
88 struct vm_area_struct *vma);
89
90#ifdef CONFIG_SND_ATMEL_SOC_PDC
91int atmel_pcm_pdc_platform_register(struct device *dev);
92void atmel_pcm_pdc_platform_unregister(struct device *dev);
93#else
94static inline int atmel_pcm_pdc_platform_register(struct device *dev)
95{
96 return 0;
97}
98static inline void atmel_pcm_pdc_platform_unregister(struct device *dev)
99{
100}
101#endif
Bo Shenbe681a82012-11-14 18:09:09 +0800102
Sedji Gaouaou6c742502008-10-03 16:57:50 +0200103#endif /* _ATMEL_PCM_H */