3
* Marvell Orion Alsa Sound driver
5
* Author: Maen Suleiman
6
* Copyright (C) 2008 Marvell Ltd.
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License version 2 as
11
* published by the Free Software Foundation.
14
#define DRIVER_NAME "mv88fx_snd"
16
//#define MV88FX_SND_DEBUG
17
#ifdef MV88FX_SND_DEBUG
18
#define mv88fx_snd_debug(fmt, arg...) printk(KERN_DEBUG fmt, ##arg)
20
#define mv88fx_snd_debug(a...)
29
struct mv88fx_snd_stream {
30
struct snd_pcm_substream *substream;
32
int direction; /* playback or capture */
35
unsigned int dig_mode; /* i2s,spdif,both*/
38
int stereo; /* mono , stereo*/
39
int mono_mode; /* both mono, left mono, right mono*/
46
#define EXTERN_CLOCK 2
48
int stat_mem; /* Channel status source*/
50
#define SAMPLE_32IN32 0
51
#define SAMPLE_24IN32 1
52
#define SAMPLE_20IN32 2
53
#define SAMPLE_16IN32 3
54
#define SAMPLE_16IN16 4
55
unsigned int dma_addr;
56
unsigned int dma_size;
57
unsigned int period_size;
58
unsigned int spdif_status[4]; /* SPDIF status */
59
unsigned char *area; /* virtual pointer */
60
dma_addr_t addr; /* physical address */
65
struct mv88fx_snd_chip {
66
struct snd_card *card;
69
struct orion_i2s_platform_data *pdata; /* platform dara*/
70
struct mv88fx_snd_stream *stream[2]; /* run time values*/
71
struct mv88fx_snd_stream *stream_defaults[2]; /* default values*/
72
spinlock_t reg_lock; /* Register access spinlock */
73
struct resource *res; /* resource for IRQ and base*/
74
void __iomem *base; /* base address of the host */
76
int loopback; /* When Loopback is enabled, playback
77
data is looped back to be recorded */
78
int ch_stat_valid; /* Playback SPDIF channel validity bit
79
value when REG selected */
80
int burst; /* DMA Burst Size */
82
#define SPDIF_MEM_STAT 0
83
#define SPDIF_REG_STAT 1
84
unsigned int dco_ctrl_offst;
85
int pcm_mode; /* pcm, nonpcm*/
88
_audio_mem_info *mem_array;
91
#define MV88FX_SND_MIN_PERIODS 8
92
#define MV88FX_SND_MAX_PERIODS 16
93
#define MV88FX_SND_MIN_PERIOD_BYTES 0x4000
94
#define MV88FX_SND_MAX_PERIOD_BYTES 0x4000
97
/* read/write registers */
99
#define mv88fx_snd_writel(chip, offs, val) \
100
writel((val), (chip->base + offs))
102
static inline unsigned int mv88fx_snd_readl(struct mv88fx_snd_chip *chip,
105
unsigned int val = readl((chip->base + offs));
108
#define mv88fx_snd_bitset(chip, offs, bitmask) \
109
writel( (readl(chip->base + offs) | (bitmask)), \
112
#define mv88fx_snd_bitreset(chip, offs, bitmask) \
113
writel( (readl(chip->base + offs) & (~(bitmask))), \