aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/mxs/mxs-saif.h
blob: 3cb342e5bc902b2c9b39eff62023015a43c7fe70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */


#ifndef _MXS_SAIF_H
#define _MXS_SAIF_H

#define SAIF_CTRL	0x0
#define SAIF_STAT	0x10
#define SAIF_DATA	0x20
#define SAIF_VERSION	0X30

/* SAIF_CTRL */
#define BM_SAIF_CTRL_SFTRST		0x80000000
#define BM_SAIF_CTRL_CLKGATE		0x40000000
#define BP_SAIF_CTRL_BITCLK_MULT_RATE	27
#define BM_SAIF_CTRL_BITCLK_MULT_RATE	0x38000000
#define BF_SAIF_CTRL_BITCLK_MULT_RATE(v) \
		(((v) << 27) & BM_SAIF_CTRL_BITCLK_MULT_RATE)
#define BM_SAIF_CTRL_BITCLK_BASE_RATE	0x04000000
#define BM_SAIF_CTRL_FIFO_ERROR_IRQ_EN	0x02000000
#define BM_SAIF_CTRL_FIFO_SERVICE_IRQ_EN	0x01000000
#define BP_SAIF_CTRL_RSRVD2		21
#define BM_SAIF_CTRL_RSRVD2		0x00E00000

#define BP_SAIF_CTRL_DMAWAIT_COUNT	16
#define BM_SAIF_CTRL_DMAWAIT_COUNT	0x001F0000
#define BF_SAIF_CTRL_DMAWAIT_COUNT(v) \
		(((v) << 16) & BM_SAIF_CTRL_DMAWAIT_COUNT)
#define BP_SAIF_CTRL_CHANNEL_NUM_SELECT 14
#define BM_SAIF_CTRL_CHANNEL_NUM_SELECT 0x0000C000
#define BF_SAIF_CTRL_CHANNEL_NUM_SELECT(v) \
		(((v) << 14) & BM_SAIF_CTRL_CHANNEL_NUM_SELECT)
#define BM_SAIF_CTRL_LRCLK_PULSE	0x00002000
#define BM_SAIF_CTRL_BIT_ORDER		0x00001000
#define BM_SAIF_CTRL_DELAY		0x00000800
#define BM_SAIF_CTRL_JUSTIFY		0x00000400
#define BM_SAIF_CTRL_LRCLK_POLARITY	0x00000200
#define BM_SAIF_CTRL_BITCLK_EDGE	0x00000100
#define BP_SAIF_CTRL_WORD_LENGTH	4
#define BM_SAIF_CTRL_WORD_LENGTH	0x000000F0
#define BF_SAIF_CTRL_WORD_LENGTH(v) \
		(((v) << 4) & BM_SAIF_CTRL_WORD_LENGTH)
#define BM_SAIF_CTRL_BITCLK_48XFS_ENABLE	0x00000008
#define BM_SAIF_CTRL_SLAVE_MODE		0x00000004
#define BM_SAIF_CTRL_READ_MODE		0x00000002
#define BM_SAIF_CTRL_RUN		0x00000001

/* SAIF_STAT */
#define BM_SAIF_STAT_PRESENT		0x80000000
#define BP_SAIF_STAT_RSRVD2		17
#define BM_SAIF_STAT_RSRVD2		0x7FFE0000
#define BF_SAIF_STAT_RSRVD2(v) \
		(((v) << 17) & BM_SAIF_STAT_RSRVD2)
#define BM_SAIF_STAT_DMA_PREQ		0x00010000
#define BP_SAIF_STAT_RSRVD1		7
#define BM_SAIF_STAT_RSRVD1		0x0000FF80
#define BF_SAIF_STAT_RSRVD1(v) \
		(((v) << 7) & BM_SAIF_STAT_RSRVD1)

#define BM_SAIF_STAT_FIFO_UNDERFLOW_IRQ 0x00000040
#define BM_SAIF_STAT_FIFO_OVERFLOW_IRQ	0x00000020
#define BM_SAIF_STAT_FIFO_SERVICE_IRQ	0x00000010
#define BP_SAIF_STAT_RSRVD0		1
#define BM_SAIF_STAT_RSRVD0		0x0000000E
#define BF_SAIF_STAT_RSRVD0(v) \
		(((v) << 1) & BM_SAIF_STAT_RSRVD0)
#define BM_SAIF_STAT_BUSY		0x00000001

/* SAFI_DATA */
#define BP_SAIF_DATA_PCM_RIGHT		16
#define BM_SAIF_DATA_PCM_RIGHT		0xFFFF0000
#define BF_SAIF_DATA_PCM_RIGHT(v) \
		(((v) << 16) & BM_SAIF_DATA_PCM_RIGHT)
#define BP_SAIF_DATA_PCM_LEFT		0
#define BM_SAIF_DATA_PCM_LEFT		0x0000FFFF
#define BF_SAIF_DATA_PCM_LEFT(v)	\
		(((v) << 0) & BM_SAIF_DATA_PCM_LEFT)

/* SAIF_VERSION */
#define BP_SAIF_VERSION_MAJOR		24
#define BM_SAIF_VERSION_MAJOR		0xFF000000
#define BF_SAIF_VERSION_MAJOR(v) \
		(((v) << 24) & BM_SAIF_VERSION_MAJOR)
#define BP_SAIF_VERSION_MINOR		16
#define BM_SAIF_VERSION_MINOR		0x00FF0000
#define BF_SAIF_VERSION_MINOR(v) \
		(((v) << 16) & BM_SAIF_VERSION_MINOR)
#define BP_SAIF_VERSION_STEP		0
#define BM_SAIF_VERSION_STEP		0x0000FFFF
#define BF_SAIF_VERSION_STEP(v) \
		(((v) << 0) & BM_SAIF_VERSION_STEP)

#define MXS_SAIF_MCLK		0

#include "mxs-pcm.h"

struct mxs_saif {
	struct device *dev;
	struct clk *clk;
	unsigned int mclk;
	unsigned int mclk_in_use;
	void __iomem *base;
	int irq;
	struct mxs_pcm_dma_params dma_param;
	unsigned int id;
	unsigned int master_id;
	unsigned int cur_rate;
	unsigned int ongoing;

	u32 fifo_underrun;
	u32 fifo_overrun;
};

extern int mxs_saif_put_mclk(unsigned int saif_id);
extern int mxs_saif_get_mclk(unsigned int saif_id, unsigned int mclk,
					unsigned int rate);
#endif