summaryrefslogtreecommitdiff
path: root/sound/soc/hisilicon/hi6210-i2s.h
blob: e816a9b63fdbc5c407c5c68eeba09c58421daefb (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * linux/sound/soc/hisilicon/hi6210-i2s.h
 *
 * Copyright (C) 2015 Linaro, Ltd
 * Author: Andy Green <andy.green@linaro.org>
 *
 * Note at least on 6220, S2 == BT, S1 == Digital FM Radio IF
 */

#ifndef _HI6210_I2S_H
#define _HI6210_I2S_H

#define HII2S_SW_RST_N				0

#define HII2S_SW_RST_N__STEREO_UPLINK_WORDLEN_SHIFT			28
#define HII2S_SW_RST_N__STEREO_UPLINK_WORDLEN_MASK			3
#define HII2S_SW_RST_N__THIRDMD_UPLINK_WORDLEN_SHIFT			26
#define HII2S_SW_RST_N__THIRDMD_UPLINK_WORDLEN_MASK			3
#define HII2S_SW_RST_N__VOICE_UPLINK_WORDLEN_SHIFT			24
#define HII2S_SW_RST_N__VOICE_UPLINK_WORDLEN_MASK			3
#define HII2S_SW_RST_N__ST_DL_WORDLEN_SHIFT				20
#define HII2S_SW_RST_N__ST_DL_WORDLEN_MASK				3
#define HII2S_SW_RST_N__THIRDMD_DLINK_WORDLEN_SHIFT			18
#define HII2S_SW_RST_N__THIRDMD_DLINK_WORDLEN_MASK			3
#define HII2S_SW_RST_N__VOICE_DLINK_WORDLEN_SHIFT			16
#define HII2S_SW_RST_N__VOICE_DLINK_WORDLEN_MASK			3

#define HII2S_SW_RST_N__SW_RST_N					BIT(0)

enum hi6210_bits {
	HII2S_BITS_16,
	HII2S_BITS_18,
	HII2S_BITS_20,
	HII2S_BITS_24,
};


#define HII2S_IF_CLK_EN_CFG			4

#define HII2S_IF_CLK_EN_CFG__THIRDMD_UPLINK_EN				BIT(25)
#define HII2S_IF_CLK_EN_CFG__THIRDMD_DLINK_EN				BIT(24)
#define HII2S_IF_CLK_EN_CFG__S3_IF_CLK_EN				BIT(20)
#define HII2S_IF_CLK_EN_CFG__S2_IF_CLK_EN				BIT(16)
#define HII2S_IF_CLK_EN_CFG__S2_OL_MIXER_EN				BIT(15)
#define HII2S_IF_CLK_EN_CFG__S2_OL_SRC_EN				BIT(14)
#define HII2S_IF_CLK_EN_CFG__S2_IR_PGA_EN				BIT(13)
#define HII2S_IF_CLK_EN_CFG__S2_IL_PGA_EN				BIT(12)
#define HII2S_IF_CLK_EN_CFG__S1_IR_PGA_EN				BIT(10)
#define HII2S_IF_CLK_EN_CFG__S1_IL_PGA_EN				BIT(9)
#define HII2S_IF_CLK_EN_CFG__S1_IF_CLK_EN				BIT(8)
#define HII2S_IF_CLK_EN_CFG__VOICE_DLINK_SRC_EN				BIT(7)
#define HII2S_IF_CLK_EN_CFG__VOICE_DLINK_EN				BIT(6)
#define HII2S_IF_CLK_EN_CFG__ST_DL_R_EN					BIT(5)
#define HII2S_IF_CLK_EN_CFG__ST_DL_L_EN					BIT(4)
#define HII2S_IF_CLK_EN_CFG__VOICE_UPLINK_R_EN				BIT(3)
#define HII2S_IF_CLK_EN_CFG__VOICE_UPLINK_L_EN				BIT(2)
#define HII2S_IF_CLK_EN_CFG__STEREO_UPLINK_R_EN				BIT(1)
#define HII2S_IF_CLK_EN_CFG__STEREO_UPLINK_L_EN				BIT(0)

#define HII2S_DIG_FILTER_CLK_EN_CFG		8
#define HII2S_DIG_FILTER_CLK_EN_CFG__DACR_SDM_EN			BIT(30)
#define HII2S_DIG_FILTER_CLK_EN_CFG__DACR_HBF2I_EN			BIT(28)
#define HII2S_DIG_FILTER_CLK_EN_CFG__DACR_MIXER_EN			BIT(25)
#define HII2S_DIG_FILTER_CLK_EN_CFG__DACR_AGC_EN			BIT(24)
#define HII2S_DIG_FILTER_CLK_EN_CFG__DACL_SDM_EN			BIT(22)
#define HII2S_DIG_FILTER_CLK_EN_CFG__DACL_HBF2I_EN			BIT(20)
#define HII2S_DIG_FILTER_CLK_EN_CFG__DACL_MIXER_EN			BIT(17)
#define HII2S_DIG_FILTER_CLK_EN_CFG__DACL_AGC_EN			BIT(16)

#define HII2S_FS_CFG				0xc

#define HII2S_FS_CFG__FS_S2_SHIFT					28
#define HII2S_FS_CFG__FS_S2_MASK					7
#define HII2S_FS_CFG__FS_S1_SHIFT					24
#define HII2S_FS_CFG__FS_S1_MASK					7
#define HII2S_FS_CFG__FS_ADCLR_SHIFT					20
#define HII2S_FS_CFG__FS_ADCLR_MASK					7
#define HII2S_FS_CFG__FS_DACLR_SHIFT					16
#define HII2S_FS_CFG__FS_DACLR_MASK					7
#define HII2S_FS_CFG__FS_ST_DL_R_SHIFT					8
#define HII2S_FS_CFG__FS_ST_DL_R_MASK					7
#define HII2S_FS_CFG__FS_ST_DL_L_SHIFT					4
#define HII2S_FS_CFG__FS_ST_DL_L_MASK					7
#define HII2S_FS_CFG__FS_VOICE_DLINK_SHIFT				0
#define HII2S_FS_CFG__FS_VOICE_DLINK_MASK				7

enum hi6210_i2s_rates {
	HII2S_FS_RATE_8KHZ = 0,
	HII2S_FS_RATE_16KHZ = 1,
	HII2S_FS_RATE_32KHZ = 2,
	HII2S_FS_RATE_48KHZ = 4,
	HII2S_FS_RATE_96KHZ = 5,
	HII2S_FS_RATE_192KHZ = 6,
};

#define HII2S_I2S_CFG				0x10

#define HII2S_I2S_CFG__S2_IF_TX_EN					BIT(31)
#define HII2S_I2S_CFG__S2_IF_RX_EN					BIT(30)
#define HII2S_I2S_CFG__S2_FRAME_MODE					BIT(29)
#define HII2S_I2S_CFG__S2_MST_SLV					BIT(28)
#define HII2S_I2S_CFG__S2_LRCK_MODE					BIT(27)
#define HII2S_I2S_CFG__S2_CHNNL_MODE					BIT(26)
#define HII2S_I2S_CFG__S2_CODEC_IO_WORDLENGTH_SHIFT			24
#define HII2S_I2S_CFG__S2_CODEC_IO_WORDLENGTH_MASK			3
#define HII2S_I2S_CFG__S2_DIRECT_LOOP_SHIFT				22
#define HII2S_I2S_CFG__S2_DIRECT_LOOP_MASK				3
#define HII2S_I2S_CFG__S2_TX_CLK_SEL					BIT(21)
#define HII2S_I2S_CFG__S2_RX_CLK_SEL					BIT(20)
#define HII2S_I2S_CFG__S2_CODEC_DATA_FORMAT				BIT(19)
#define HII2S_I2S_CFG__S2_FUNC_MODE_SHIFT				16
#define HII2S_I2S_CFG__S2_FUNC_MODE_MASK				7
#define HII2S_I2S_CFG__S1_IF_TX_EN					BIT(15)
#define HII2S_I2S_CFG__S1_IF_RX_EN					BIT(14)
#define HII2S_I2S_CFG__S1_FRAME_MODE					BIT(13)
#define HII2S_I2S_CFG__S1_MST_SLV					BIT(12)
#define HII2S_I2S_CFG__S1_LRCK_MODE					BIT(11)
#define HII2S_I2S_CFG__S1_CHNNL_MODE					BIT(10)
#define HII2S_I2S_CFG__S1_CODEC_IO_WORDLENGTH_SHIFT			8
#define HII2S_I2S_CFG__S1_CODEC_IO_WORDLENGTH_MASK			3
#define HII2S_I2S_CFG__S1_DIRECT_LOOP_SHIFT				6
#define HII2S_I2S_CFG__S1_DIRECT_LOOP_MASK				3
#define HII2S_I2S_CFG__S1_TX_CLK_SEL					BIT(5)
#define HII2S_I2S_CFG__S1_RX_CLK_SEL					BIT(4)
#define HII2S_I2S_CFG__S1_CODEC_DATA_FORMAT				BIT(3)
#define HII2S_I2S_CFG__S1_FUNC_MODE_SHIFT				0
#define HII2S_I2S_CFG__S1_FUNC_MODE_MASK				7

enum hi6210_i2s_formats {
	HII2S_FORMAT_I2S,
	HII2S_FORMAT_PCM_STD,
	HII2S_FORMAT_PCM_USER,
	HII2S_FORMAT_LEFT_JUST,
	HII2S_FORMAT_RIGHT_JUST,
};

#define HII2S_DIG_FILTER_MODULE_CFG		0x14

#define HII2S_DIG_FILTER_MODULE_CFG__DACR_MIXER_GAIN_SHIFT		28
#define HII2S_DIG_FILTER_MODULE_CFG__DACR_MIXER_GAIN_MASK		3
#define HII2S_DIG_FILTER_MODULE_CFG__DACR_MIXER_IN4_MUTE		BIT(27)
#define HII2S_DIG_FILTER_MODULE_CFG__DACR_MIXER_IN3_MUTE		BIT(26)
#define HII2S_DIG_FILTER_MODULE_CFG__DACR_MIXER_IN2_MUTE		BIT(25)
#define HII2S_DIG_FILTER_MODULE_CFG__DACR_MIXER_IN1_MUTE		BIT(24)
#define HII2S_DIG_FILTER_MODULE_CFG__DACL_MIXER_GAIN_SHIFT		20
#define HII2S_DIG_FILTER_MODULE_CFG__DACL_MIXER_GAIN_MASK		3
#define HII2S_DIG_FILTER_MODULE_CFG__DACL_MIXER_IN4_MUTE		BIT(19)
#define HII2S_DIG_FILTER_MODULE_CFG__DACL_MIXER_IN3_MUTE		BIT(18)
#define HII2S_DIG_FILTER_MODULE_CFG__DACL_MIXER_IN2_MUTE		BIT(17)
#define HII2S_DIG_FILTER_MODULE_CFG__DACL_MIXER_IN1_MUTE		BIT(16)
#define HII2S_DIG_FILTER_MODULE_CFG__SW_DACR_SDM_DITHER			BIT(9)
#define HII2S_DIG_FILTER_MODULE_CFG__SW_DACL_SDM_DITHER			BIT(8)
#define HII2S_DIG_FILTER_MODULE_CFG__LM_CODEC_DAC2ADC_SHIFT		4
#define HII2S_DIG_FILTER_MODULE_CFG__LM_CODEC_DAC2ADC_MASK		7
#define HII2S_DIG_FILTER_MODULE_CFG__RM_CODEC_DAC2ADC_SHIFT		0
#define HII2S_DIG_FILTER_MODULE_CFG__RM_CODEC_DAC2ADC_MASK		7

enum hi6210_gains {
	HII2S_GAIN_100PC,
	HII2S_GAIN_50PC,
	HII2S_GAIN_25PC,
};

#define HII2S_MUX_TOP_MODULE_CFG		0x18

#define HII2S_MUX_TOP_MODULE_CFG__VOICE_DLINK_MIXER_GAIN_SHIFT		14
#define HII2S_MUX_TOP_MODULE_CFG__VOICE_DLINK_MIXER_GAIN_MASK		3
#define HII2S_MUX_TOP_MODULE_CFG__VOICE_DLINK_MIXER_IN2_MUTE		BIT(13)
#define HII2S_MUX_TOP_MODULE_CFG__VOICE_DLINK_MIXER_IN1_MUTE		BIT(12)
#define HII2S_MUX_TOP_MODULE_CFG__S2_OL_MIXER_GAIN_SHIFT		10
#define HII2S_MUX_TOP_MODULE_CFG__S2_OL_MIXER_GAIN_MASK			3
#define HII2S_MUX_TOP_MODULE_CFG__S2_OL_MIXER_IN2_MUTE			BIT(9)
#define HII2S_MUX_TOP_MODULE_CFG__S2_OL_MIXER_IN1_MUTE			BIT(8)
#define HII2S_MUX_TOP_MODULE_CFG__S2_OL_SRC_RDY				BIT(6)
#define HII2S_MUX_TOP_MODULE_CFG__S2_OL_SRC_MODE_SHIFT			4
#define HII2S_MUX_TOP_MODULE_CFG__S2_OL_SRC_MODE_MASK			3
#define HII2S_MUX_TOP_MODULE_CFG__VOICE_DLINK_SRC_RDY			BIT(3)
#define HII2S_MUX_TOP_MODULE_CFG__VOICE_DLINK_SRC_MODE_SHIFT		0
#define HII2S_MUX_TOP_MODULE_CFG__VOICE_DLINK_SRC_MODE_MASK		7

enum hi6210_s2_src_mode {
	HII2S_S2_SRC_MODE_3,
	HII2S_S2_SRC_MODE_12,
	HII2S_S2_SRC_MODE_6,
	HII2S_S2_SRC_MODE_2,
};

enum hi6210_voice_dlink_src_mode {
	HII2S_VOICE_DL_SRC_MODE_12 = 1,
	HII2S_VOICE_DL_SRC_MODE_6,
	HII2S_VOICE_DL_SRC_MODE_2,
	HII2S_VOICE_DL_SRC_MODE_3,
};

#define HII2S_ADC_PGA_CFG			0x1c
#define HII2S_S1_INPUT_PGA_CFG			0x20
#define HII2S_S2_INPUT_PGA_CFG			0x24
#define HII2S_ST_DL_PGA_CFG			0x28
#define HII2S_VOICE_SIDETONE_DLINK_PGA_CFG	0x2c
#define HII2S_APB_AFIFO_CFG_1			0x30
#define HII2S_APB_AFIFO_CFG_2			0x34
#define HII2S_ST_DL_FIFO_TH_CFG			0x38

#define HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AEMPTY_SHIFT			24
#define HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AEMPTY_MASK			0x1f
#define HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AFULL_SHIFT			16
#define HII2S_ST_DL_FIFO_TH_CFG__ST_DL_R_AFULL_MASK			0x1f
#define HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AEMPTY_SHIFT			8
#define HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AEMPTY_MASK			0x1f
#define HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AFULL_SHIFT			0
#define HII2S_ST_DL_FIFO_TH_CFG__ST_DL_L_AFULL_MASK			0x1f

#define HII2S_STEREO_UPLINK_FIFO_TH_CFG		0x3c
#define HII2S_VOICE_UPLINK_FIFO_TH_CFG		0x40
#define HII2S_CODEC_IRQ_MASK			0x44
#define HII2S_CODEC_IRQ				0x48
#define HII2S_DACL_AGC_CFG_1			0x4c
#define HII2S_DACL_AGC_CFG_2			0x50
#define HII2S_DACR_AGC_CFG_1			0x54
#define HII2S_DACR_AGC_CFG_2			0x58
#define HII2S_DMIC_SIF_CFG			0x5c
#define HII2S_MISC_CFG				0x60

#define HII2S_MISC_CFG__THIRDMD_DLINK_TEST_SEL				BIT(17)
#define HII2S_MISC_CFG__THIRDMD_DLINK_DIN_SEL				BIT(16)
#define HII2S_MISC_CFG__S3_DOUT_RIGHT_SEL				BIT(14)
#define HII2S_MISC_CFG__S3_DOUT_LEFT_SEL				BIT(13)
#define HII2S_MISC_CFG__S3_DIN_TEST_SEL					BIT(12)
#define HII2S_MISC_CFG__VOICE_DLINK_SRC_UP_DOUT_VLD_SEL			BIT(8)
#define HII2S_MISC_CFG__VOICE_DLINK_TEST_SEL				BIT(7)
#define HII2S_MISC_CFG__VOICE_DLINK_DIN_SEL				BIT(6)
#define HII2S_MISC_CFG__ST_DL_TEST_SEL					BIT(4)
#define HII2S_MISC_CFG__S2_DOUT_RIGHT_SEL				BIT(3)
#define HII2S_MISC_CFG__S2_DOUT_TEST_SEL				BIT(2)
#define HII2S_MISC_CFG__S1_DOUT_TEST_SEL				BIT(1)
#define HII2S_MISC_CFG__S2_DOUT_LEFT_SEL				BIT(0)

#define HII2S_S2_SRC_CFG			0x64
#define HII2S_MEM_CFG				0x68
#define HII2S_THIRDMD_PCM_PGA_CFG		0x6c
#define HII2S_THIRD_MODEM_FIFO_TH		0x70
#define HII2S_S3_ANTI_FREQ_JITTER_TX_INC_CNT	0x74
#define HII2S_S3_ANTI_FREQ_JITTER_TX_DEC_CNT	0x78
#define HII2S_S3_ANTI_FREQ_JITTER_RX_INC_CNT	0x7c
#define HII2S_S3_ANTI_FREQ_JITTER_RX_DEC_CNT	0x80
#define HII2S_ANTI_FREQ_JITTER_EN		0x84
#define HII2S_CLK_SEL				0x88

/* 0 = BT owns the i2s */
#define HII2S_CLK_SEL__I2S_BT_FM_SEL					BIT(0)
/* 0 = internal source, 1 = ext */
#define HII2S_CLK_SEL__EXT_12_288MHZ_SEL				BIT(1)


#define HII2S_THIRDMD_DLINK_CHANNEL		0xe8
#define HII2S_THIRDMD_ULINK_CHANNEL		0xec
#define HII2S_VOICE_DLINK_CHANNEL		0xf0

/* shovel data in here for playback */
#define HII2S_ST_DL_CHANNEL			0xf4
#define HII2S_STEREO_UPLINK_CHANNEL		0xf8
#define HII2S_VOICE_UPLINK_CHANNEL		0xfc

#endif/* _HI6210_I2S_H */