blob: 5173c9b529baa8de29db965e969b5aa31453ab60 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Sedji Gaouaou6c742502008-10-03 16:57:50 +02002/*
3 * at91-pcm.h - ALSA PCM interface for the Atmel AT91 SoC.
4 *
5 * Copyright (C) 2005 SAN People
6 * Copyright (C) 2008 Atmel
7 *
8 * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
9 *
10 * Based on at91-pcm. by:
11 * Frank Mandarino <fmandarino@endrelia.com>
12 * Copyright 2006 Endrelia Technologies Inc.
13 *
14 * Based on pxa2xx-pcm.c by:
15 *
16 * Author: Nicolas Pitre
17 * Created: Nov 30, 2004
18 * Copyright: (C) 2004 MontaVista Software, Inc.
Sedji Gaouaou6c742502008-10-03 16:57:50 +020019 */
20
21#ifndef _ATMEL_PCM_H
22#define _ATMEL_PCM_H
23
24#include <linux/atmel-ssc.h>
25
Bo Shen92dfa612012-11-28 11:46:12 +080026#define ATMEL_SSC_DMABUF_SIZE (64 * 1024)
27
Sedji Gaouaou6c742502008-10-03 16:57:50 +020028/*
29 * Registers and status bits that are required by the PCM driver.
30 */
31struct atmel_pdc_regs {
32 unsigned int xpr; /* PDC recv/trans pointer */
33 unsigned int xcr; /* PDC recv/trans counter */
34 unsigned int xnpr; /* PDC next recv/trans pointer */
35 unsigned int xncr; /* PDC next recv/trans counter */
36 unsigned int ptcr; /* PDC transfer control */
37};
38
39struct atmel_ssc_mask {
40 u32 ssc_enable; /* SSC recv/trans enable */
41 u32 ssc_disable; /* SSC recv/trans disable */
Bo Shen3951e4a2012-11-28 11:46:13 +080042 u32 ssc_error; /* SSC error conditions */
Sedji Gaouaou6c742502008-10-03 16:57:50 +020043 u32 ssc_endx; /* SSC ENDTX or ENDRX */
44 u32 ssc_endbuf; /* SSC TXBUFE or RXBUFF */
45 u32 pdc_enable; /* PDC recv/trans enable */
46 u32 pdc_disable; /* PDC recv/trans disable */
47};
48
49/*
50 * This structure, shared between the PCM driver and the interface,
51 * contains all information required by the PCM driver to perform the
52 * PDC DMA operation. All fields except dma_intr_handler() are initialized
Nicolas Ferre97b4fc32011-05-26 13:44:11 +020053 * by the interface. The dma_intr_handler() pointer is set by the PCM
Sedji Gaouaou6c742502008-10-03 16:57:50 +020054 * driver and called by the interface SSC interrupt handler if it is
55 * non-NULL.
56 */
57struct atmel_pcm_dma_params {
58 char *name; /* stream identifier */
59 int pdc_xfer_size; /* PDC counter increment in bytes */
60 struct ssc_device *ssc; /* SSC device for stream */
61 struct atmel_pdc_regs *pdc; /* PDC receive or transmit registers */
62 struct atmel_ssc_mask *mask; /* SSC & PDC status bits */
63 struct snd_pcm_substream *substream;
64 void (*dma_intr_handler)(u32, struct snd_pcm_substream *);
65};
66
Sedji Gaouaou6c742502008-10-03 16:57:50 +020067/*
68 * SSC register access (since ssc_writel() / ssc_readl() require literal name)
69 */
70#define ssc_readx(base, reg) (__raw_readl((base) + (reg)))
71#define ssc_writex(base, reg, value) __raw_writel((value), (base) + (reg))
72
Takashi Iwaicd187752017-05-15 11:32:01 +020073#if IS_ENABLED(CONFIG_SND_ATMEL_SOC_PDC)
Bo Shen92dfa612012-11-28 11:46:12 +080074int atmel_pcm_pdc_platform_register(struct device *dev);
75void atmel_pcm_pdc_platform_unregister(struct device *dev);
76#else
77static inline int atmel_pcm_pdc_platform_register(struct device *dev)
78{
79 return 0;
80}
81static inline void atmel_pcm_pdc_platform_unregister(struct device *dev)
82{
83}
84#endif
Bo Shenbe681a82012-11-14 18:09:09 +080085
Takashi Iwaicd187752017-05-15 11:32:01 +020086#if IS_ENABLED(CONFIG_SND_ATMEL_SOC_DMA)
Bo Shen3951e4a2012-11-28 11:46:13 +080087int atmel_pcm_dma_platform_register(struct device *dev);
88void atmel_pcm_dma_platform_unregister(struct device *dev);
89#else
90static inline int atmel_pcm_dma_platform_register(struct device *dev)
91{
92 return 0;
93}
94static inline void atmel_pcm_dma_platform_unregister(struct device *dev)
95{
96}
97#endif
98
Sedji Gaouaou6c742502008-10-03 16:57:50 +020099#endif /* _ATMEL_PCM_H */