xref: /linux/sound/soc/codecs/wm8994.c (revision a234ca0faa65dcd5cc473915bd925130ebb7b74b)
1 /*
2  * wm8994.c  --  WM8994 ALSA SoC Audio driver
3  *
4  * Copyright 2009 Wolfson Microelectronics plc
5  *
6  * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7  *
8  *
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.
12  */
13 
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/init.h>
17 #include <linux/delay.h>
18 #include <linux/pm.h>
19 #include <linux/i2c.h>
20 #include <linux/platform_device.h>
21 #include <linux/regulator/consumer.h>
22 #include <linux/slab.h>
23 #include <sound/core.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
26 #include <sound/soc.h>
27 #include <sound/soc-dapm.h>
28 #include <sound/initval.h>
29 #include <sound/tlv.h>
30 
31 #include <linux/mfd/wm8994/core.h>
32 #include <linux/mfd/wm8994/registers.h>
33 #include <linux/mfd/wm8994/pdata.h>
34 #include <linux/mfd/wm8994/gpio.h>
35 
36 #include "wm8994.h"
37 #include "wm_hubs.h"
38 
39 static struct snd_soc_codec *wm8994_codec;
40 struct snd_soc_codec_device soc_codec_dev_wm8994;
41 
42 struct fll_config {
43 	int src;
44 	int in;
45 	int out;
46 };
47 
48 #define WM8994_NUM_DRC 3
49 #define WM8994_NUM_EQ  3
50 
51 static int wm8994_drc_base[] = {
52 	WM8994_AIF1_DRC1_1,
53 	WM8994_AIF1_DRC2_1,
54 	WM8994_AIF2_DRC_1,
55 };
56 
57 static int wm8994_retune_mobile_base[] = {
58 	WM8994_AIF1_DAC1_EQ_GAINS_1,
59 	WM8994_AIF1_DAC2_EQ_GAINS_1,
60 	WM8994_AIF2_EQ_GAINS_1,
61 };
62 
63 #define WM8994_REG_CACHE_SIZE  0x621
64 
65 struct wm8994_micdet {
66 	struct snd_soc_jack *jack;
67 	int det;
68 	int shrt;
69 };
70 
71 /* codec private data */
72 struct wm8994_priv {
73 	struct wm_hubs_data hubs;
74 	struct snd_soc_codec codec;
75 	u16 reg_cache[WM8994_REG_CACHE_SIZE + 1];
76 	int sysclk[2];
77 	int sysclk_rate[2];
78 	int mclk[2];
79 	int aifclk[2];
80 	struct fll_config fll[2], fll_suspend[2];
81 
82 	int dac_rates[2];
83 	int lrclk_shared[2];
84 
85 	/* Platform dependant DRC configuration */
86 	const char **drc_texts;
87 	int drc_cfg[WM8994_NUM_DRC];
88 	struct soc_enum drc_enum;
89 
90 	/* Platform dependant ReTune mobile configuration */
91 	int num_retune_mobile_texts;
92 	const char **retune_mobile_texts;
93 	int retune_mobile_cfg[WM8994_NUM_EQ];
94 	struct soc_enum retune_mobile_enum;
95 
96 	struct wm8994_micdet micdet[2];
97 
98 	int revision;
99 	struct wm8994_pdata *pdata;
100 };
101 
102 static struct {
103 	unsigned short  readable;   /* Mask of readable bits */
104 	unsigned short  writable;   /* Mask of writable bits */
105 	unsigned short  vol;        /* Mask of volatile bits */
106 } access_masks[] = {
107 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R0     - Software Reset */
108 	{ 0x3B37, 0x3B37, 0x0000 }, /* R1     - Power Management (1) */
109 	{ 0x6BF0, 0x6BF0, 0x0000 }, /* R2     - Power Management (2) */
110 	{ 0x3FF0, 0x3FF0, 0x0000 }, /* R3     - Power Management (3) */
111 	{ 0x3F3F, 0x3F3F, 0x0000 }, /* R4     - Power Management (4) */
112 	{ 0x3F0F, 0x3F0F, 0x0000 }, /* R5     - Power Management (5) */
113 	{ 0x003F, 0x003F, 0x0000 }, /* R6     - Power Management (6) */
114 	{ 0x0000, 0x0000, 0x0000 }, /* R7 */
115 	{ 0x0000, 0x0000, 0x0000 }, /* R8 */
116 	{ 0x0000, 0x0000, 0x0000 }, /* R9 */
117 	{ 0x0000, 0x0000, 0x0000 }, /* R10 */
118 	{ 0x0000, 0x0000, 0x0000 }, /* R11 */
119 	{ 0x0000, 0x0000, 0x0000 }, /* R12 */
120 	{ 0x0000, 0x0000, 0x0000 }, /* R13 */
121 	{ 0x0000, 0x0000, 0x0000 }, /* R14 */
122 	{ 0x0000, 0x0000, 0x0000 }, /* R15 */
123 	{ 0x0000, 0x0000, 0x0000 }, /* R16 */
124 	{ 0x0000, 0x0000, 0x0000 }, /* R17 */
125 	{ 0x0000, 0x0000, 0x0000 }, /* R18 */
126 	{ 0x0000, 0x0000, 0x0000 }, /* R19 */
127 	{ 0x0000, 0x0000, 0x0000 }, /* R20 */
128 	{ 0x01C0, 0x01C0, 0x0000 }, /* R21    - Input Mixer (1) */
129 	{ 0x0000, 0x0000, 0x0000 }, /* R22 */
130 	{ 0x0000, 0x0000, 0x0000 }, /* R23 */
131 	{ 0x00DF, 0x01DF, 0x0000 }, /* R24    - Left Line Input 1&2 Volume */
132 	{ 0x00DF, 0x01DF, 0x0000 }, /* R25    - Left Line Input 3&4 Volume */
133 	{ 0x00DF, 0x01DF, 0x0000 }, /* R26    - Right Line Input 1&2 Volume */
134 	{ 0x00DF, 0x01DF, 0x0000 }, /* R27    - Right Line Input 3&4 Volume */
135 	{ 0x00FF, 0x01FF, 0x0000 }, /* R28    - Left Output Volume */
136 	{ 0x00FF, 0x01FF, 0x0000 }, /* R29    - Right Output Volume */
137 	{ 0x0077, 0x0077, 0x0000 }, /* R30    - Line Outputs Volume */
138 	{ 0x0030, 0x0030, 0x0000 }, /* R31    - HPOUT2 Volume */
139 	{ 0x00FF, 0x01FF, 0x0000 }, /* R32    - Left OPGA Volume */
140 	{ 0x00FF, 0x01FF, 0x0000 }, /* R33    - Right OPGA Volume */
141 	{ 0x007F, 0x007F, 0x0000 }, /* R34    - SPKMIXL Attenuation */
142 	{ 0x017F, 0x017F, 0x0000 }, /* R35    - SPKMIXR Attenuation */
143 	{ 0x003F, 0x003F, 0x0000 }, /* R36    - SPKOUT Mixers */
144 	{ 0x003F, 0x003F, 0x0000 }, /* R37    - ClassD */
145 	{ 0x00FF, 0x01FF, 0x0000 }, /* R38    - Speaker Volume Left */
146 	{ 0x00FF, 0x01FF, 0x0000 }, /* R39    - Speaker Volume Right */
147 	{ 0x00FF, 0x00FF, 0x0000 }, /* R40    - Input Mixer (2) */
148 	{ 0x01B7, 0x01B7, 0x0000 }, /* R41    - Input Mixer (3) */
149 	{ 0x01B7, 0x01B7, 0x0000 }, /* R42    - Input Mixer (4) */
150 	{ 0x01C7, 0x01C7, 0x0000 }, /* R43    - Input Mixer (5) */
151 	{ 0x01C7, 0x01C7, 0x0000 }, /* R44    - Input Mixer (6) */
152 	{ 0x01FF, 0x01FF, 0x0000 }, /* R45    - Output Mixer (1) */
153 	{ 0x01FF, 0x01FF, 0x0000 }, /* R46    - Output Mixer (2) */
154 	{ 0x0FFF, 0x0FFF, 0x0000 }, /* R47    - Output Mixer (3) */
155 	{ 0x0FFF, 0x0FFF, 0x0000 }, /* R48    - Output Mixer (4) */
156 	{ 0x0FFF, 0x0FFF, 0x0000 }, /* R49    - Output Mixer (5) */
157 	{ 0x0FFF, 0x0FFF, 0x0000 }, /* R50    - Output Mixer (6) */
158 	{ 0x0038, 0x0038, 0x0000 }, /* R51    - HPOUT2 Mixer */
159 	{ 0x0077, 0x0077, 0x0000 }, /* R52    - Line Mixer (1) */
160 	{ 0x0077, 0x0077, 0x0000 }, /* R53    - Line Mixer (2) */
161 	{ 0x03FF, 0x03FF, 0x0000 }, /* R54    - Speaker Mixer */
162 	{ 0x00C1, 0x00C1, 0x0000 }, /* R55    - Additional Control */
163 	{ 0x00F0, 0x00F0, 0x0000 }, /* R56    - AntiPOP (1) */
164 	{ 0x01EF, 0x01EF, 0x0000 }, /* R57    - AntiPOP (2) */
165 	{ 0x00FF, 0x00FF, 0x0000 }, /* R58    - MICBIAS */
166 	{ 0x000F, 0x000F, 0x0000 }, /* R59    - LDO 1 */
167 	{ 0x0007, 0x0007, 0x0000 }, /* R60    - LDO 2 */
168 	{ 0x0000, 0x0000, 0x0000 }, /* R61 */
169 	{ 0x0000, 0x0000, 0x0000 }, /* R62 */
170 	{ 0x0000, 0x0000, 0x0000 }, /* R63 */
171 	{ 0x0000, 0x0000, 0x0000 }, /* R64 */
172 	{ 0x0000, 0x0000, 0x0000 }, /* R65 */
173 	{ 0x0000, 0x0000, 0x0000 }, /* R66 */
174 	{ 0x0000, 0x0000, 0x0000 }, /* R67 */
175 	{ 0x0000, 0x0000, 0x0000 }, /* R68 */
176 	{ 0x0000, 0x0000, 0x0000 }, /* R69 */
177 	{ 0x0000, 0x0000, 0x0000 }, /* R70 */
178 	{ 0x0000, 0x0000, 0x0000 }, /* R71 */
179 	{ 0x0000, 0x0000, 0x0000 }, /* R72 */
180 	{ 0x0000, 0x0000, 0x0000 }, /* R73 */
181 	{ 0x0000, 0x0000, 0x0000 }, /* R74 */
182 	{ 0x0000, 0x0000, 0x0000 }, /* R75 */
183 	{ 0x8000, 0x8000, 0x0000 }, /* R76    - Charge Pump (1) */
184 	{ 0x0000, 0x0000, 0x0000 }, /* R77 */
185 	{ 0x0000, 0x0000, 0x0000 }, /* R78 */
186 	{ 0x0000, 0x0000, 0x0000 }, /* R79 */
187 	{ 0x0000, 0x0000, 0x0000 }, /* R80 */
188 	{ 0x0301, 0x0301, 0x0000 }, /* R81    - Class W (1) */
189 	{ 0x0000, 0x0000, 0x0000 }, /* R82 */
190 	{ 0x0000, 0x0000, 0x0000 }, /* R83 */
191 	{ 0x333F, 0x333F, 0x0000 }, /* R84    - DC Servo (1) */
192 	{ 0x0FEF, 0x0FEF, 0x0000 }, /* R85    - DC Servo (2) */
193 	{ 0x0000, 0x0000, 0x0000 }, /* R86 */
194 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R87    - DC Servo (4) */
195 	{ 0x0333, 0x0000, 0x0000 }, /* R88    - DC Servo Readback */
196 	{ 0x0000, 0x0000, 0x0000 }, /* R89 */
197 	{ 0x0000, 0x0000, 0x0000 }, /* R90 */
198 	{ 0x0000, 0x0000, 0x0000 }, /* R91 */
199 	{ 0x0000, 0x0000, 0x0000 }, /* R92 */
200 	{ 0x0000, 0x0000, 0x0000 }, /* R93 */
201 	{ 0x0000, 0x0000, 0x0000 }, /* R94 */
202 	{ 0x0000, 0x0000, 0x0000 }, /* R95 */
203 	{ 0x00EE, 0x00EE, 0x0000 }, /* R96    - Analogue HP (1) */
204 	{ 0x0000, 0x0000, 0x0000 }, /* R97 */
205 	{ 0x0000, 0x0000, 0x0000 }, /* R98 */
206 	{ 0x0000, 0x0000, 0x0000 }, /* R99 */
207 	{ 0x0000, 0x0000, 0x0000 }, /* R100 */
208 	{ 0x0000, 0x0000, 0x0000 }, /* R101 */
209 	{ 0x0000, 0x0000, 0x0000 }, /* R102 */
210 	{ 0x0000, 0x0000, 0x0000 }, /* R103 */
211 	{ 0x0000, 0x0000, 0x0000 }, /* R104 */
212 	{ 0x0000, 0x0000, 0x0000 }, /* R105 */
213 	{ 0x0000, 0x0000, 0x0000 }, /* R106 */
214 	{ 0x0000, 0x0000, 0x0000 }, /* R107 */
215 	{ 0x0000, 0x0000, 0x0000 }, /* R108 */
216 	{ 0x0000, 0x0000, 0x0000 }, /* R109 */
217 	{ 0x0000, 0x0000, 0x0000 }, /* R110 */
218 	{ 0x0000, 0x0000, 0x0000 }, /* R111 */
219 	{ 0x0000, 0x0000, 0x0000 }, /* R112 */
220 	{ 0x0000, 0x0000, 0x0000 }, /* R113 */
221 	{ 0x0000, 0x0000, 0x0000 }, /* R114 */
222 	{ 0x0000, 0x0000, 0x0000 }, /* R115 */
223 	{ 0x0000, 0x0000, 0x0000 }, /* R116 */
224 	{ 0x0000, 0x0000, 0x0000 }, /* R117 */
225 	{ 0x0000, 0x0000, 0x0000 }, /* R118 */
226 	{ 0x0000, 0x0000, 0x0000 }, /* R119 */
227 	{ 0x0000, 0x0000, 0x0000 }, /* R120 */
228 	{ 0x0000, 0x0000, 0x0000 }, /* R121 */
229 	{ 0x0000, 0x0000, 0x0000 }, /* R122 */
230 	{ 0x0000, 0x0000, 0x0000 }, /* R123 */
231 	{ 0x0000, 0x0000, 0x0000 }, /* R124 */
232 	{ 0x0000, 0x0000, 0x0000 }, /* R125 */
233 	{ 0x0000, 0x0000, 0x0000 }, /* R126 */
234 	{ 0x0000, 0x0000, 0x0000 }, /* R127 */
235 	{ 0x0000, 0x0000, 0x0000 }, /* R128 */
236 	{ 0x0000, 0x0000, 0x0000 }, /* R129 */
237 	{ 0x0000, 0x0000, 0x0000 }, /* R130 */
238 	{ 0x0000, 0x0000, 0x0000 }, /* R131 */
239 	{ 0x0000, 0x0000, 0x0000 }, /* R132 */
240 	{ 0x0000, 0x0000, 0x0000 }, /* R133 */
241 	{ 0x0000, 0x0000, 0x0000 }, /* R134 */
242 	{ 0x0000, 0x0000, 0x0000 }, /* R135 */
243 	{ 0x0000, 0x0000, 0x0000 }, /* R136 */
244 	{ 0x0000, 0x0000, 0x0000 }, /* R137 */
245 	{ 0x0000, 0x0000, 0x0000 }, /* R138 */
246 	{ 0x0000, 0x0000, 0x0000 }, /* R139 */
247 	{ 0x0000, 0x0000, 0x0000 }, /* R140 */
248 	{ 0x0000, 0x0000, 0x0000 }, /* R141 */
249 	{ 0x0000, 0x0000, 0x0000 }, /* R142 */
250 	{ 0x0000, 0x0000, 0x0000 }, /* R143 */
251 	{ 0x0000, 0x0000, 0x0000 }, /* R144 */
252 	{ 0x0000, 0x0000, 0x0000 }, /* R145 */
253 	{ 0x0000, 0x0000, 0x0000 }, /* R146 */
254 	{ 0x0000, 0x0000, 0x0000 }, /* R147 */
255 	{ 0x0000, 0x0000, 0x0000 }, /* R148 */
256 	{ 0x0000, 0x0000, 0x0000 }, /* R149 */
257 	{ 0x0000, 0x0000, 0x0000 }, /* R150 */
258 	{ 0x0000, 0x0000, 0x0000 }, /* R151 */
259 	{ 0x0000, 0x0000, 0x0000 }, /* R152 */
260 	{ 0x0000, 0x0000, 0x0000 }, /* R153 */
261 	{ 0x0000, 0x0000, 0x0000 }, /* R154 */
262 	{ 0x0000, 0x0000, 0x0000 }, /* R155 */
263 	{ 0x0000, 0x0000, 0x0000 }, /* R156 */
264 	{ 0x0000, 0x0000, 0x0000 }, /* R157 */
265 	{ 0x0000, 0x0000, 0x0000 }, /* R158 */
266 	{ 0x0000, 0x0000, 0x0000 }, /* R159 */
267 	{ 0x0000, 0x0000, 0x0000 }, /* R160 */
268 	{ 0x0000, 0x0000, 0x0000 }, /* R161 */
269 	{ 0x0000, 0x0000, 0x0000 }, /* R162 */
270 	{ 0x0000, 0x0000, 0x0000 }, /* R163 */
271 	{ 0x0000, 0x0000, 0x0000 }, /* R164 */
272 	{ 0x0000, 0x0000, 0x0000 }, /* R165 */
273 	{ 0x0000, 0x0000, 0x0000 }, /* R166 */
274 	{ 0x0000, 0x0000, 0x0000 }, /* R167 */
275 	{ 0x0000, 0x0000, 0x0000 }, /* R168 */
276 	{ 0x0000, 0x0000, 0x0000 }, /* R169 */
277 	{ 0x0000, 0x0000, 0x0000 }, /* R170 */
278 	{ 0x0000, 0x0000, 0x0000 }, /* R171 */
279 	{ 0x0000, 0x0000, 0x0000 }, /* R172 */
280 	{ 0x0000, 0x0000, 0x0000 }, /* R173 */
281 	{ 0x0000, 0x0000, 0x0000 }, /* R174 */
282 	{ 0x0000, 0x0000, 0x0000 }, /* R175 */
283 	{ 0x0000, 0x0000, 0x0000 }, /* R176 */
284 	{ 0x0000, 0x0000, 0x0000 }, /* R177 */
285 	{ 0x0000, 0x0000, 0x0000 }, /* R178 */
286 	{ 0x0000, 0x0000, 0x0000 }, /* R179 */
287 	{ 0x0000, 0x0000, 0x0000 }, /* R180 */
288 	{ 0x0000, 0x0000, 0x0000 }, /* R181 */
289 	{ 0x0000, 0x0000, 0x0000 }, /* R182 */
290 	{ 0x0000, 0x0000, 0x0000 }, /* R183 */
291 	{ 0x0000, 0x0000, 0x0000 }, /* R184 */
292 	{ 0x0000, 0x0000, 0x0000 }, /* R185 */
293 	{ 0x0000, 0x0000, 0x0000 }, /* R186 */
294 	{ 0x0000, 0x0000, 0x0000 }, /* R187 */
295 	{ 0x0000, 0x0000, 0x0000 }, /* R188 */
296 	{ 0x0000, 0x0000, 0x0000 }, /* R189 */
297 	{ 0x0000, 0x0000, 0x0000 }, /* R190 */
298 	{ 0x0000, 0x0000, 0x0000 }, /* R191 */
299 	{ 0x0000, 0x0000, 0x0000 }, /* R192 */
300 	{ 0x0000, 0x0000, 0x0000 }, /* R193 */
301 	{ 0x0000, 0x0000, 0x0000 }, /* R194 */
302 	{ 0x0000, 0x0000, 0x0000 }, /* R195 */
303 	{ 0x0000, 0x0000, 0x0000 }, /* R196 */
304 	{ 0x0000, 0x0000, 0x0000 }, /* R197 */
305 	{ 0x0000, 0x0000, 0x0000 }, /* R198 */
306 	{ 0x0000, 0x0000, 0x0000 }, /* R199 */
307 	{ 0x0000, 0x0000, 0x0000 }, /* R200 */
308 	{ 0x0000, 0x0000, 0x0000 }, /* R201 */
309 	{ 0x0000, 0x0000, 0x0000 }, /* R202 */
310 	{ 0x0000, 0x0000, 0x0000 }, /* R203 */
311 	{ 0x0000, 0x0000, 0x0000 }, /* R204 */
312 	{ 0x0000, 0x0000, 0x0000 }, /* R205 */
313 	{ 0x0000, 0x0000, 0x0000 }, /* R206 */
314 	{ 0x0000, 0x0000, 0x0000 }, /* R207 */
315 	{ 0x0000, 0x0000, 0x0000 }, /* R208 */
316 	{ 0x0000, 0x0000, 0x0000 }, /* R209 */
317 	{ 0x0000, 0x0000, 0x0000 }, /* R210 */
318 	{ 0x0000, 0x0000, 0x0000 }, /* R211 */
319 	{ 0x0000, 0x0000, 0x0000 }, /* R212 */
320 	{ 0x0000, 0x0000, 0x0000 }, /* R213 */
321 	{ 0x0000, 0x0000, 0x0000 }, /* R214 */
322 	{ 0x0000, 0x0000, 0x0000 }, /* R215 */
323 	{ 0x0000, 0x0000, 0x0000 }, /* R216 */
324 	{ 0x0000, 0x0000, 0x0000 }, /* R217 */
325 	{ 0x0000, 0x0000, 0x0000 }, /* R218 */
326 	{ 0x0000, 0x0000, 0x0000 }, /* R219 */
327 	{ 0x0000, 0x0000, 0x0000 }, /* R220 */
328 	{ 0x0000, 0x0000, 0x0000 }, /* R221 */
329 	{ 0x0000, 0x0000, 0x0000 }, /* R222 */
330 	{ 0x0000, 0x0000, 0x0000 }, /* R223 */
331 	{ 0x0000, 0x0000, 0x0000 }, /* R224 */
332 	{ 0x0000, 0x0000, 0x0000 }, /* R225 */
333 	{ 0x0000, 0x0000, 0x0000 }, /* R226 */
334 	{ 0x0000, 0x0000, 0x0000 }, /* R227 */
335 	{ 0x0000, 0x0000, 0x0000 }, /* R228 */
336 	{ 0x0000, 0x0000, 0x0000 }, /* R229 */
337 	{ 0x0000, 0x0000, 0x0000 }, /* R230 */
338 	{ 0x0000, 0x0000, 0x0000 }, /* R231 */
339 	{ 0x0000, 0x0000, 0x0000 }, /* R232 */
340 	{ 0x0000, 0x0000, 0x0000 }, /* R233 */
341 	{ 0x0000, 0x0000, 0x0000 }, /* R234 */
342 	{ 0x0000, 0x0000, 0x0000 }, /* R235 */
343 	{ 0x0000, 0x0000, 0x0000 }, /* R236 */
344 	{ 0x0000, 0x0000, 0x0000 }, /* R237 */
345 	{ 0x0000, 0x0000, 0x0000 }, /* R238 */
346 	{ 0x0000, 0x0000, 0x0000 }, /* R239 */
347 	{ 0x0000, 0x0000, 0x0000 }, /* R240 */
348 	{ 0x0000, 0x0000, 0x0000 }, /* R241 */
349 	{ 0x0000, 0x0000, 0x0000 }, /* R242 */
350 	{ 0x0000, 0x0000, 0x0000 }, /* R243 */
351 	{ 0x0000, 0x0000, 0x0000 }, /* R244 */
352 	{ 0x0000, 0x0000, 0x0000 }, /* R245 */
353 	{ 0x0000, 0x0000, 0x0000 }, /* R246 */
354 	{ 0x0000, 0x0000, 0x0000 }, /* R247 */
355 	{ 0x0000, 0x0000, 0x0000 }, /* R248 */
356 	{ 0x0000, 0x0000, 0x0000 }, /* R249 */
357 	{ 0x0000, 0x0000, 0x0000 }, /* R250 */
358 	{ 0x0000, 0x0000, 0x0000 }, /* R251 */
359 	{ 0x0000, 0x0000, 0x0000 }, /* R252 */
360 	{ 0x0000, 0x0000, 0x0000 }, /* R253 */
361 	{ 0x0000, 0x0000, 0x0000 }, /* R254 */
362 	{ 0x0000, 0x0000, 0x0000 }, /* R255 */
363 	{ 0x000F, 0x0000, 0x0000 }, /* R256   - Chip Revision */
364 	{ 0x0074, 0x0074, 0x0000 }, /* R257   - Control Interface */
365 	{ 0x0000, 0x0000, 0x0000 }, /* R258 */
366 	{ 0x0000, 0x0000, 0x0000 }, /* R259 */
367 	{ 0x0000, 0x0000, 0x0000 }, /* R260 */
368 	{ 0x0000, 0x0000, 0x0000 }, /* R261 */
369 	{ 0x0000, 0x0000, 0x0000 }, /* R262 */
370 	{ 0x0000, 0x0000, 0x0000 }, /* R263 */
371 	{ 0x0000, 0x0000, 0x0000 }, /* R264 */
372 	{ 0x0000, 0x0000, 0x0000 }, /* R265 */
373 	{ 0x0000, 0x0000, 0x0000 }, /* R266 */
374 	{ 0x0000, 0x0000, 0x0000 }, /* R267 */
375 	{ 0x0000, 0x0000, 0x0000 }, /* R268 */
376 	{ 0x0000, 0x0000, 0x0000 }, /* R269 */
377 	{ 0x0000, 0x0000, 0x0000 }, /* R270 */
378 	{ 0x0000, 0x0000, 0x0000 }, /* R271 */
379 	{ 0x807F, 0x837F, 0x0000 }, /* R272   - Write Sequencer Ctrl (1) */
380 	{ 0x017F, 0x0000, 0x0000 }, /* R273   - Write Sequencer Ctrl (2) */
381 	{ 0x0000, 0x0000, 0x0000 }, /* R274 */
382 	{ 0x0000, 0x0000, 0x0000 }, /* R275 */
383 	{ 0x0000, 0x0000, 0x0000 }, /* R276 */
384 	{ 0x0000, 0x0000, 0x0000 }, /* R277 */
385 	{ 0x0000, 0x0000, 0x0000 }, /* R278 */
386 	{ 0x0000, 0x0000, 0x0000 }, /* R279 */
387 	{ 0x0000, 0x0000, 0x0000 }, /* R280 */
388 	{ 0x0000, 0x0000, 0x0000 }, /* R281 */
389 	{ 0x0000, 0x0000, 0x0000 }, /* R282 */
390 	{ 0x0000, 0x0000, 0x0000 }, /* R283 */
391 	{ 0x0000, 0x0000, 0x0000 }, /* R284 */
392 	{ 0x0000, 0x0000, 0x0000 }, /* R285 */
393 	{ 0x0000, 0x0000, 0x0000 }, /* R286 */
394 	{ 0x0000, 0x0000, 0x0000 }, /* R287 */
395 	{ 0x0000, 0x0000, 0x0000 }, /* R288 */
396 	{ 0x0000, 0x0000, 0x0000 }, /* R289 */
397 	{ 0x0000, 0x0000, 0x0000 }, /* R290 */
398 	{ 0x0000, 0x0000, 0x0000 }, /* R291 */
399 	{ 0x0000, 0x0000, 0x0000 }, /* R292 */
400 	{ 0x0000, 0x0000, 0x0000 }, /* R293 */
401 	{ 0x0000, 0x0000, 0x0000 }, /* R294 */
402 	{ 0x0000, 0x0000, 0x0000 }, /* R295 */
403 	{ 0x0000, 0x0000, 0x0000 }, /* R296 */
404 	{ 0x0000, 0x0000, 0x0000 }, /* R297 */
405 	{ 0x0000, 0x0000, 0x0000 }, /* R298 */
406 	{ 0x0000, 0x0000, 0x0000 }, /* R299 */
407 	{ 0x0000, 0x0000, 0x0000 }, /* R300 */
408 	{ 0x0000, 0x0000, 0x0000 }, /* R301 */
409 	{ 0x0000, 0x0000, 0x0000 }, /* R302 */
410 	{ 0x0000, 0x0000, 0x0000 }, /* R303 */
411 	{ 0x0000, 0x0000, 0x0000 }, /* R304 */
412 	{ 0x0000, 0x0000, 0x0000 }, /* R305 */
413 	{ 0x0000, 0x0000, 0x0000 }, /* R306 */
414 	{ 0x0000, 0x0000, 0x0000 }, /* R307 */
415 	{ 0x0000, 0x0000, 0x0000 }, /* R308 */
416 	{ 0x0000, 0x0000, 0x0000 }, /* R309 */
417 	{ 0x0000, 0x0000, 0x0000 }, /* R310 */
418 	{ 0x0000, 0x0000, 0x0000 }, /* R311 */
419 	{ 0x0000, 0x0000, 0x0000 }, /* R312 */
420 	{ 0x0000, 0x0000, 0x0000 }, /* R313 */
421 	{ 0x0000, 0x0000, 0x0000 }, /* R314 */
422 	{ 0x0000, 0x0000, 0x0000 }, /* R315 */
423 	{ 0x0000, 0x0000, 0x0000 }, /* R316 */
424 	{ 0x0000, 0x0000, 0x0000 }, /* R317 */
425 	{ 0x0000, 0x0000, 0x0000 }, /* R318 */
426 	{ 0x0000, 0x0000, 0x0000 }, /* R319 */
427 	{ 0x0000, 0x0000, 0x0000 }, /* R320 */
428 	{ 0x0000, 0x0000, 0x0000 }, /* R321 */
429 	{ 0x0000, 0x0000, 0x0000 }, /* R322 */
430 	{ 0x0000, 0x0000, 0x0000 }, /* R323 */
431 	{ 0x0000, 0x0000, 0x0000 }, /* R324 */
432 	{ 0x0000, 0x0000, 0x0000 }, /* R325 */
433 	{ 0x0000, 0x0000, 0x0000 }, /* R326 */
434 	{ 0x0000, 0x0000, 0x0000 }, /* R327 */
435 	{ 0x0000, 0x0000, 0x0000 }, /* R328 */
436 	{ 0x0000, 0x0000, 0x0000 }, /* R329 */
437 	{ 0x0000, 0x0000, 0x0000 }, /* R330 */
438 	{ 0x0000, 0x0000, 0x0000 }, /* R331 */
439 	{ 0x0000, 0x0000, 0x0000 }, /* R332 */
440 	{ 0x0000, 0x0000, 0x0000 }, /* R333 */
441 	{ 0x0000, 0x0000, 0x0000 }, /* R334 */
442 	{ 0x0000, 0x0000, 0x0000 }, /* R335 */
443 	{ 0x0000, 0x0000, 0x0000 }, /* R336 */
444 	{ 0x0000, 0x0000, 0x0000 }, /* R337 */
445 	{ 0x0000, 0x0000, 0x0000 }, /* R338 */
446 	{ 0x0000, 0x0000, 0x0000 }, /* R339 */
447 	{ 0x0000, 0x0000, 0x0000 }, /* R340 */
448 	{ 0x0000, 0x0000, 0x0000 }, /* R341 */
449 	{ 0x0000, 0x0000, 0x0000 }, /* R342 */
450 	{ 0x0000, 0x0000, 0x0000 }, /* R343 */
451 	{ 0x0000, 0x0000, 0x0000 }, /* R344 */
452 	{ 0x0000, 0x0000, 0x0000 }, /* R345 */
453 	{ 0x0000, 0x0000, 0x0000 }, /* R346 */
454 	{ 0x0000, 0x0000, 0x0000 }, /* R347 */
455 	{ 0x0000, 0x0000, 0x0000 }, /* R348 */
456 	{ 0x0000, 0x0000, 0x0000 }, /* R349 */
457 	{ 0x0000, 0x0000, 0x0000 }, /* R350 */
458 	{ 0x0000, 0x0000, 0x0000 }, /* R351 */
459 	{ 0x0000, 0x0000, 0x0000 }, /* R352 */
460 	{ 0x0000, 0x0000, 0x0000 }, /* R353 */
461 	{ 0x0000, 0x0000, 0x0000 }, /* R354 */
462 	{ 0x0000, 0x0000, 0x0000 }, /* R355 */
463 	{ 0x0000, 0x0000, 0x0000 }, /* R356 */
464 	{ 0x0000, 0x0000, 0x0000 }, /* R357 */
465 	{ 0x0000, 0x0000, 0x0000 }, /* R358 */
466 	{ 0x0000, 0x0000, 0x0000 }, /* R359 */
467 	{ 0x0000, 0x0000, 0x0000 }, /* R360 */
468 	{ 0x0000, 0x0000, 0x0000 }, /* R361 */
469 	{ 0x0000, 0x0000, 0x0000 }, /* R362 */
470 	{ 0x0000, 0x0000, 0x0000 }, /* R363 */
471 	{ 0x0000, 0x0000, 0x0000 }, /* R364 */
472 	{ 0x0000, 0x0000, 0x0000 }, /* R365 */
473 	{ 0x0000, 0x0000, 0x0000 }, /* R366 */
474 	{ 0x0000, 0x0000, 0x0000 }, /* R367 */
475 	{ 0x0000, 0x0000, 0x0000 }, /* R368 */
476 	{ 0x0000, 0x0000, 0x0000 }, /* R369 */
477 	{ 0x0000, 0x0000, 0x0000 }, /* R370 */
478 	{ 0x0000, 0x0000, 0x0000 }, /* R371 */
479 	{ 0x0000, 0x0000, 0x0000 }, /* R372 */
480 	{ 0x0000, 0x0000, 0x0000 }, /* R373 */
481 	{ 0x0000, 0x0000, 0x0000 }, /* R374 */
482 	{ 0x0000, 0x0000, 0x0000 }, /* R375 */
483 	{ 0x0000, 0x0000, 0x0000 }, /* R376 */
484 	{ 0x0000, 0x0000, 0x0000 }, /* R377 */
485 	{ 0x0000, 0x0000, 0x0000 }, /* R378 */
486 	{ 0x0000, 0x0000, 0x0000 }, /* R379 */
487 	{ 0x0000, 0x0000, 0x0000 }, /* R380 */
488 	{ 0x0000, 0x0000, 0x0000 }, /* R381 */
489 	{ 0x0000, 0x0000, 0x0000 }, /* R382 */
490 	{ 0x0000, 0x0000, 0x0000 }, /* R383 */
491 	{ 0x0000, 0x0000, 0x0000 }, /* R384 */
492 	{ 0x0000, 0x0000, 0x0000 }, /* R385 */
493 	{ 0x0000, 0x0000, 0x0000 }, /* R386 */
494 	{ 0x0000, 0x0000, 0x0000 }, /* R387 */
495 	{ 0x0000, 0x0000, 0x0000 }, /* R388 */
496 	{ 0x0000, 0x0000, 0x0000 }, /* R389 */
497 	{ 0x0000, 0x0000, 0x0000 }, /* R390 */
498 	{ 0x0000, 0x0000, 0x0000 }, /* R391 */
499 	{ 0x0000, 0x0000, 0x0000 }, /* R392 */
500 	{ 0x0000, 0x0000, 0x0000 }, /* R393 */
501 	{ 0x0000, 0x0000, 0x0000 }, /* R394 */
502 	{ 0x0000, 0x0000, 0x0000 }, /* R395 */
503 	{ 0x0000, 0x0000, 0x0000 }, /* R396 */
504 	{ 0x0000, 0x0000, 0x0000 }, /* R397 */
505 	{ 0x0000, 0x0000, 0x0000 }, /* R398 */
506 	{ 0x0000, 0x0000, 0x0000 }, /* R399 */
507 	{ 0x0000, 0x0000, 0x0000 }, /* R400 */
508 	{ 0x0000, 0x0000, 0x0000 }, /* R401 */
509 	{ 0x0000, 0x0000, 0x0000 }, /* R402 */
510 	{ 0x0000, 0x0000, 0x0000 }, /* R403 */
511 	{ 0x0000, 0x0000, 0x0000 }, /* R404 */
512 	{ 0x0000, 0x0000, 0x0000 }, /* R405 */
513 	{ 0x0000, 0x0000, 0x0000 }, /* R406 */
514 	{ 0x0000, 0x0000, 0x0000 }, /* R407 */
515 	{ 0x0000, 0x0000, 0x0000 }, /* R408 */
516 	{ 0x0000, 0x0000, 0x0000 }, /* R409 */
517 	{ 0x0000, 0x0000, 0x0000 }, /* R410 */
518 	{ 0x0000, 0x0000, 0x0000 }, /* R411 */
519 	{ 0x0000, 0x0000, 0x0000 }, /* R412 */
520 	{ 0x0000, 0x0000, 0x0000 }, /* R413 */
521 	{ 0x0000, 0x0000, 0x0000 }, /* R414 */
522 	{ 0x0000, 0x0000, 0x0000 }, /* R415 */
523 	{ 0x0000, 0x0000, 0x0000 }, /* R416 */
524 	{ 0x0000, 0x0000, 0x0000 }, /* R417 */
525 	{ 0x0000, 0x0000, 0x0000 }, /* R418 */
526 	{ 0x0000, 0x0000, 0x0000 }, /* R419 */
527 	{ 0x0000, 0x0000, 0x0000 }, /* R420 */
528 	{ 0x0000, 0x0000, 0x0000 }, /* R421 */
529 	{ 0x0000, 0x0000, 0x0000 }, /* R422 */
530 	{ 0x0000, 0x0000, 0x0000 }, /* R423 */
531 	{ 0x0000, 0x0000, 0x0000 }, /* R424 */
532 	{ 0x0000, 0x0000, 0x0000 }, /* R425 */
533 	{ 0x0000, 0x0000, 0x0000 }, /* R426 */
534 	{ 0x0000, 0x0000, 0x0000 }, /* R427 */
535 	{ 0x0000, 0x0000, 0x0000 }, /* R428 */
536 	{ 0x0000, 0x0000, 0x0000 }, /* R429 */
537 	{ 0x0000, 0x0000, 0x0000 }, /* R430 */
538 	{ 0x0000, 0x0000, 0x0000 }, /* R431 */
539 	{ 0x0000, 0x0000, 0x0000 }, /* R432 */
540 	{ 0x0000, 0x0000, 0x0000 }, /* R433 */
541 	{ 0x0000, 0x0000, 0x0000 }, /* R434 */
542 	{ 0x0000, 0x0000, 0x0000 }, /* R435 */
543 	{ 0x0000, 0x0000, 0x0000 }, /* R436 */
544 	{ 0x0000, 0x0000, 0x0000 }, /* R437 */
545 	{ 0x0000, 0x0000, 0x0000 }, /* R438 */
546 	{ 0x0000, 0x0000, 0x0000 }, /* R439 */
547 	{ 0x0000, 0x0000, 0x0000 }, /* R440 */
548 	{ 0x0000, 0x0000, 0x0000 }, /* R441 */
549 	{ 0x0000, 0x0000, 0x0000 }, /* R442 */
550 	{ 0x0000, 0x0000, 0x0000 }, /* R443 */
551 	{ 0x0000, 0x0000, 0x0000 }, /* R444 */
552 	{ 0x0000, 0x0000, 0x0000 }, /* R445 */
553 	{ 0x0000, 0x0000, 0x0000 }, /* R446 */
554 	{ 0x0000, 0x0000, 0x0000 }, /* R447 */
555 	{ 0x0000, 0x0000, 0x0000 }, /* R448 */
556 	{ 0x0000, 0x0000, 0x0000 }, /* R449 */
557 	{ 0x0000, 0x0000, 0x0000 }, /* R450 */
558 	{ 0x0000, 0x0000, 0x0000 }, /* R451 */
559 	{ 0x0000, 0x0000, 0x0000 }, /* R452 */
560 	{ 0x0000, 0x0000, 0x0000 }, /* R453 */
561 	{ 0x0000, 0x0000, 0x0000 }, /* R454 */
562 	{ 0x0000, 0x0000, 0x0000 }, /* R455 */
563 	{ 0x0000, 0x0000, 0x0000 }, /* R456 */
564 	{ 0x0000, 0x0000, 0x0000 }, /* R457 */
565 	{ 0x0000, 0x0000, 0x0000 }, /* R458 */
566 	{ 0x0000, 0x0000, 0x0000 }, /* R459 */
567 	{ 0x0000, 0x0000, 0x0000 }, /* R460 */
568 	{ 0x0000, 0x0000, 0x0000 }, /* R461 */
569 	{ 0x0000, 0x0000, 0x0000 }, /* R462 */
570 	{ 0x0000, 0x0000, 0x0000 }, /* R463 */
571 	{ 0x0000, 0x0000, 0x0000 }, /* R464 */
572 	{ 0x0000, 0x0000, 0x0000 }, /* R465 */
573 	{ 0x0000, 0x0000, 0x0000 }, /* R466 */
574 	{ 0x0000, 0x0000, 0x0000 }, /* R467 */
575 	{ 0x0000, 0x0000, 0x0000 }, /* R468 */
576 	{ 0x0000, 0x0000, 0x0000 }, /* R469 */
577 	{ 0x0000, 0x0000, 0x0000 }, /* R470 */
578 	{ 0x0000, 0x0000, 0x0000 }, /* R471 */
579 	{ 0x0000, 0x0000, 0x0000 }, /* R472 */
580 	{ 0x0000, 0x0000, 0x0000 }, /* R473 */
581 	{ 0x0000, 0x0000, 0x0000 }, /* R474 */
582 	{ 0x0000, 0x0000, 0x0000 }, /* R475 */
583 	{ 0x0000, 0x0000, 0x0000 }, /* R476 */
584 	{ 0x0000, 0x0000, 0x0000 }, /* R477 */
585 	{ 0x0000, 0x0000, 0x0000 }, /* R478 */
586 	{ 0x0000, 0x0000, 0x0000 }, /* R479 */
587 	{ 0x0000, 0x0000, 0x0000 }, /* R480 */
588 	{ 0x0000, 0x0000, 0x0000 }, /* R481 */
589 	{ 0x0000, 0x0000, 0x0000 }, /* R482 */
590 	{ 0x0000, 0x0000, 0x0000 }, /* R483 */
591 	{ 0x0000, 0x0000, 0x0000 }, /* R484 */
592 	{ 0x0000, 0x0000, 0x0000 }, /* R485 */
593 	{ 0x0000, 0x0000, 0x0000 }, /* R486 */
594 	{ 0x0000, 0x0000, 0x0000 }, /* R487 */
595 	{ 0x0000, 0x0000, 0x0000 }, /* R488 */
596 	{ 0x0000, 0x0000, 0x0000 }, /* R489 */
597 	{ 0x0000, 0x0000, 0x0000 }, /* R490 */
598 	{ 0x0000, 0x0000, 0x0000 }, /* R491 */
599 	{ 0x0000, 0x0000, 0x0000 }, /* R492 */
600 	{ 0x0000, 0x0000, 0x0000 }, /* R493 */
601 	{ 0x0000, 0x0000, 0x0000 }, /* R494 */
602 	{ 0x0000, 0x0000, 0x0000 }, /* R495 */
603 	{ 0x0000, 0x0000, 0x0000 }, /* R496 */
604 	{ 0x0000, 0x0000, 0x0000 }, /* R497 */
605 	{ 0x0000, 0x0000, 0x0000 }, /* R498 */
606 	{ 0x0000, 0x0000, 0x0000 }, /* R499 */
607 	{ 0x0000, 0x0000, 0x0000 }, /* R500 */
608 	{ 0x0000, 0x0000, 0x0000 }, /* R501 */
609 	{ 0x0000, 0x0000, 0x0000 }, /* R502 */
610 	{ 0x0000, 0x0000, 0x0000 }, /* R503 */
611 	{ 0x0000, 0x0000, 0x0000 }, /* R504 */
612 	{ 0x0000, 0x0000, 0x0000 }, /* R505 */
613 	{ 0x0000, 0x0000, 0x0000 }, /* R506 */
614 	{ 0x0000, 0x0000, 0x0000 }, /* R507 */
615 	{ 0x0000, 0x0000, 0x0000 }, /* R508 */
616 	{ 0x0000, 0x0000, 0x0000 }, /* R509 */
617 	{ 0x0000, 0x0000, 0x0000 }, /* R510 */
618 	{ 0x0000, 0x0000, 0x0000 }, /* R511 */
619 	{ 0x001F, 0x001F, 0x0000 }, /* R512   - AIF1 Clocking (1) */
620 	{ 0x003F, 0x003F, 0x0000 }, /* R513   - AIF1 Clocking (2) */
621 	{ 0x0000, 0x0000, 0x0000 }, /* R514 */
622 	{ 0x0000, 0x0000, 0x0000 }, /* R515 */
623 	{ 0x001F, 0x001F, 0x0000 }, /* R516   - AIF2 Clocking (1) */
624 	{ 0x003F, 0x003F, 0x0000 }, /* R517   - AIF2 Clocking (2) */
625 	{ 0x0000, 0x0000, 0x0000 }, /* R518 */
626 	{ 0x0000, 0x0000, 0x0000 }, /* R519 */
627 	{ 0x001F, 0x001F, 0x0000 }, /* R520   - Clocking (1) */
628 	{ 0x0777, 0x0777, 0x0000 }, /* R521   - Clocking (2) */
629 	{ 0x0000, 0x0000, 0x0000 }, /* R522 */
630 	{ 0x0000, 0x0000, 0x0000 }, /* R523 */
631 	{ 0x0000, 0x0000, 0x0000 }, /* R524 */
632 	{ 0x0000, 0x0000, 0x0000 }, /* R525 */
633 	{ 0x0000, 0x0000, 0x0000 }, /* R526 */
634 	{ 0x0000, 0x0000, 0x0000 }, /* R527 */
635 	{ 0x00FF, 0x00FF, 0x0000 }, /* R528   - AIF1 Rate */
636 	{ 0x00FF, 0x00FF, 0x0000 }, /* R529   - AIF2 Rate */
637 	{ 0x000F, 0x0000, 0x0000 }, /* R530   - Rate Status */
638 	{ 0x0000, 0x0000, 0x0000 }, /* R531 */
639 	{ 0x0000, 0x0000, 0x0000 }, /* R532 */
640 	{ 0x0000, 0x0000, 0x0000 }, /* R533 */
641 	{ 0x0000, 0x0000, 0x0000 }, /* R534 */
642 	{ 0x0000, 0x0000, 0x0000 }, /* R535 */
643 	{ 0x0000, 0x0000, 0x0000 }, /* R536 */
644 	{ 0x0000, 0x0000, 0x0000 }, /* R537 */
645 	{ 0x0000, 0x0000, 0x0000 }, /* R538 */
646 	{ 0x0000, 0x0000, 0x0000 }, /* R539 */
647 	{ 0x0000, 0x0000, 0x0000 }, /* R540 */
648 	{ 0x0000, 0x0000, 0x0000 }, /* R541 */
649 	{ 0x0000, 0x0000, 0x0000 }, /* R542 */
650 	{ 0x0000, 0x0000, 0x0000 }, /* R543 */
651 	{ 0x0007, 0x0007, 0x0000 }, /* R544   - FLL1 Control (1) */
652 	{ 0x3F77, 0x3F77, 0x0000 }, /* R545   - FLL1 Control (2) */
653 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R546   - FLL1 Control (3) */
654 	{ 0x7FEF, 0x7FEF, 0x0000 }, /* R547   - FLL1 Control (4) */
655 	{ 0x1FDB, 0x1FDB, 0x0000 }, /* R548   - FLL1 Control (5) */
656 	{ 0x0000, 0x0000, 0x0000 }, /* R549 */
657 	{ 0x0000, 0x0000, 0x0000 }, /* R550 */
658 	{ 0x0000, 0x0000, 0x0000 }, /* R551 */
659 	{ 0x0000, 0x0000, 0x0000 }, /* R552 */
660 	{ 0x0000, 0x0000, 0x0000 }, /* R553 */
661 	{ 0x0000, 0x0000, 0x0000 }, /* R554 */
662 	{ 0x0000, 0x0000, 0x0000 }, /* R555 */
663 	{ 0x0000, 0x0000, 0x0000 }, /* R556 */
664 	{ 0x0000, 0x0000, 0x0000 }, /* R557 */
665 	{ 0x0000, 0x0000, 0x0000 }, /* R558 */
666 	{ 0x0000, 0x0000, 0x0000 }, /* R559 */
667 	{ 0x0000, 0x0000, 0x0000 }, /* R560 */
668 	{ 0x0000, 0x0000, 0x0000 }, /* R561 */
669 	{ 0x0000, 0x0000, 0x0000 }, /* R562 */
670 	{ 0x0000, 0x0000, 0x0000 }, /* R563 */
671 	{ 0x0000, 0x0000, 0x0000 }, /* R564 */
672 	{ 0x0000, 0x0000, 0x0000 }, /* R565 */
673 	{ 0x0000, 0x0000, 0x0000 }, /* R566 */
674 	{ 0x0000, 0x0000, 0x0000 }, /* R567 */
675 	{ 0x0000, 0x0000, 0x0000 }, /* R568 */
676 	{ 0x0000, 0x0000, 0x0000 }, /* R569 */
677 	{ 0x0000, 0x0000, 0x0000 }, /* R570 */
678 	{ 0x0000, 0x0000, 0x0000 }, /* R571 */
679 	{ 0x0000, 0x0000, 0x0000 }, /* R572 */
680 	{ 0x0000, 0x0000, 0x0000 }, /* R573 */
681 	{ 0x0000, 0x0000, 0x0000 }, /* R574 */
682 	{ 0x0000, 0x0000, 0x0000 }, /* R575 */
683 	{ 0x0007, 0x0007, 0x0000 }, /* R576   - FLL2 Control (1) */
684 	{ 0x3F77, 0x3F77, 0x0000 }, /* R577   - FLL2 Control (2) */
685 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R578   - FLL2 Control (3) */
686 	{ 0x7FEF, 0x7FEF, 0x0000 }, /* R579   - FLL2 Control (4) */
687 	{ 0x1FDB, 0x1FDB, 0x0000 }, /* R580   - FLL2 Control (5) */
688 	{ 0x0000, 0x0000, 0x0000 }, /* R581 */
689 	{ 0x0000, 0x0000, 0x0000 }, /* R582 */
690 	{ 0x0000, 0x0000, 0x0000 }, /* R583 */
691 	{ 0x0000, 0x0000, 0x0000 }, /* R584 */
692 	{ 0x0000, 0x0000, 0x0000 }, /* R585 */
693 	{ 0x0000, 0x0000, 0x0000 }, /* R586 */
694 	{ 0x0000, 0x0000, 0x0000 }, /* R587 */
695 	{ 0x0000, 0x0000, 0x0000 }, /* R588 */
696 	{ 0x0000, 0x0000, 0x0000 }, /* R589 */
697 	{ 0x0000, 0x0000, 0x0000 }, /* R590 */
698 	{ 0x0000, 0x0000, 0x0000 }, /* R591 */
699 	{ 0x0000, 0x0000, 0x0000 }, /* R592 */
700 	{ 0x0000, 0x0000, 0x0000 }, /* R593 */
701 	{ 0x0000, 0x0000, 0x0000 }, /* R594 */
702 	{ 0x0000, 0x0000, 0x0000 }, /* R595 */
703 	{ 0x0000, 0x0000, 0x0000 }, /* R596 */
704 	{ 0x0000, 0x0000, 0x0000 }, /* R597 */
705 	{ 0x0000, 0x0000, 0x0000 }, /* R598 */
706 	{ 0x0000, 0x0000, 0x0000 }, /* R599 */
707 	{ 0x0000, 0x0000, 0x0000 }, /* R600 */
708 	{ 0x0000, 0x0000, 0x0000 }, /* R601 */
709 	{ 0x0000, 0x0000, 0x0000 }, /* R602 */
710 	{ 0x0000, 0x0000, 0x0000 }, /* R603 */
711 	{ 0x0000, 0x0000, 0x0000 }, /* R604 */
712 	{ 0x0000, 0x0000, 0x0000 }, /* R605 */
713 	{ 0x0000, 0x0000, 0x0000 }, /* R606 */
714 	{ 0x0000, 0x0000, 0x0000 }, /* R607 */
715 	{ 0x0000, 0x0000, 0x0000 }, /* R608 */
716 	{ 0x0000, 0x0000, 0x0000 }, /* R609 */
717 	{ 0x0000, 0x0000, 0x0000 }, /* R610 */
718 	{ 0x0000, 0x0000, 0x0000 }, /* R611 */
719 	{ 0x0000, 0x0000, 0x0000 }, /* R612 */
720 	{ 0x0000, 0x0000, 0x0000 }, /* R613 */
721 	{ 0x0000, 0x0000, 0x0000 }, /* R614 */
722 	{ 0x0000, 0x0000, 0x0000 }, /* R615 */
723 	{ 0x0000, 0x0000, 0x0000 }, /* R616 */
724 	{ 0x0000, 0x0000, 0x0000 }, /* R617 */
725 	{ 0x0000, 0x0000, 0x0000 }, /* R618 */
726 	{ 0x0000, 0x0000, 0x0000 }, /* R619 */
727 	{ 0x0000, 0x0000, 0x0000 }, /* R620 */
728 	{ 0x0000, 0x0000, 0x0000 }, /* R621 */
729 	{ 0x0000, 0x0000, 0x0000 }, /* R622 */
730 	{ 0x0000, 0x0000, 0x0000 }, /* R623 */
731 	{ 0x0000, 0x0000, 0x0000 }, /* R624 */
732 	{ 0x0000, 0x0000, 0x0000 }, /* R625 */
733 	{ 0x0000, 0x0000, 0x0000 }, /* R626 */
734 	{ 0x0000, 0x0000, 0x0000 }, /* R627 */
735 	{ 0x0000, 0x0000, 0x0000 }, /* R628 */
736 	{ 0x0000, 0x0000, 0x0000 }, /* R629 */
737 	{ 0x0000, 0x0000, 0x0000 }, /* R630 */
738 	{ 0x0000, 0x0000, 0x0000 }, /* R631 */
739 	{ 0x0000, 0x0000, 0x0000 }, /* R632 */
740 	{ 0x0000, 0x0000, 0x0000 }, /* R633 */
741 	{ 0x0000, 0x0000, 0x0000 }, /* R634 */
742 	{ 0x0000, 0x0000, 0x0000 }, /* R635 */
743 	{ 0x0000, 0x0000, 0x0000 }, /* R636 */
744 	{ 0x0000, 0x0000, 0x0000 }, /* R637 */
745 	{ 0x0000, 0x0000, 0x0000 }, /* R638 */
746 	{ 0x0000, 0x0000, 0x0000 }, /* R639 */
747 	{ 0x0000, 0x0000, 0x0000 }, /* R640 */
748 	{ 0x0000, 0x0000, 0x0000 }, /* R641 */
749 	{ 0x0000, 0x0000, 0x0000 }, /* R642 */
750 	{ 0x0000, 0x0000, 0x0000 }, /* R643 */
751 	{ 0x0000, 0x0000, 0x0000 }, /* R644 */
752 	{ 0x0000, 0x0000, 0x0000 }, /* R645 */
753 	{ 0x0000, 0x0000, 0x0000 }, /* R646 */
754 	{ 0x0000, 0x0000, 0x0000 }, /* R647 */
755 	{ 0x0000, 0x0000, 0x0000 }, /* R648 */
756 	{ 0x0000, 0x0000, 0x0000 }, /* R649 */
757 	{ 0x0000, 0x0000, 0x0000 }, /* R650 */
758 	{ 0x0000, 0x0000, 0x0000 }, /* R651 */
759 	{ 0x0000, 0x0000, 0x0000 }, /* R652 */
760 	{ 0x0000, 0x0000, 0x0000 }, /* R653 */
761 	{ 0x0000, 0x0000, 0x0000 }, /* R654 */
762 	{ 0x0000, 0x0000, 0x0000 }, /* R655 */
763 	{ 0x0000, 0x0000, 0x0000 }, /* R656 */
764 	{ 0x0000, 0x0000, 0x0000 }, /* R657 */
765 	{ 0x0000, 0x0000, 0x0000 }, /* R658 */
766 	{ 0x0000, 0x0000, 0x0000 }, /* R659 */
767 	{ 0x0000, 0x0000, 0x0000 }, /* R660 */
768 	{ 0x0000, 0x0000, 0x0000 }, /* R661 */
769 	{ 0x0000, 0x0000, 0x0000 }, /* R662 */
770 	{ 0x0000, 0x0000, 0x0000 }, /* R663 */
771 	{ 0x0000, 0x0000, 0x0000 }, /* R664 */
772 	{ 0x0000, 0x0000, 0x0000 }, /* R665 */
773 	{ 0x0000, 0x0000, 0x0000 }, /* R666 */
774 	{ 0x0000, 0x0000, 0x0000 }, /* R667 */
775 	{ 0x0000, 0x0000, 0x0000 }, /* R668 */
776 	{ 0x0000, 0x0000, 0x0000 }, /* R669 */
777 	{ 0x0000, 0x0000, 0x0000 }, /* R670 */
778 	{ 0x0000, 0x0000, 0x0000 }, /* R671 */
779 	{ 0x0000, 0x0000, 0x0000 }, /* R672 */
780 	{ 0x0000, 0x0000, 0x0000 }, /* R673 */
781 	{ 0x0000, 0x0000, 0x0000 }, /* R674 */
782 	{ 0x0000, 0x0000, 0x0000 }, /* R675 */
783 	{ 0x0000, 0x0000, 0x0000 }, /* R676 */
784 	{ 0x0000, 0x0000, 0x0000 }, /* R677 */
785 	{ 0x0000, 0x0000, 0x0000 }, /* R678 */
786 	{ 0x0000, 0x0000, 0x0000 }, /* R679 */
787 	{ 0x0000, 0x0000, 0x0000 }, /* R680 */
788 	{ 0x0000, 0x0000, 0x0000 }, /* R681 */
789 	{ 0x0000, 0x0000, 0x0000 }, /* R682 */
790 	{ 0x0000, 0x0000, 0x0000 }, /* R683 */
791 	{ 0x0000, 0x0000, 0x0000 }, /* R684 */
792 	{ 0x0000, 0x0000, 0x0000 }, /* R685 */
793 	{ 0x0000, 0x0000, 0x0000 }, /* R686 */
794 	{ 0x0000, 0x0000, 0x0000 }, /* R687 */
795 	{ 0x0000, 0x0000, 0x0000 }, /* R688 */
796 	{ 0x0000, 0x0000, 0x0000 }, /* R689 */
797 	{ 0x0000, 0x0000, 0x0000 }, /* R690 */
798 	{ 0x0000, 0x0000, 0x0000 }, /* R691 */
799 	{ 0x0000, 0x0000, 0x0000 }, /* R692 */
800 	{ 0x0000, 0x0000, 0x0000 }, /* R693 */
801 	{ 0x0000, 0x0000, 0x0000 }, /* R694 */
802 	{ 0x0000, 0x0000, 0x0000 }, /* R695 */
803 	{ 0x0000, 0x0000, 0x0000 }, /* R696 */
804 	{ 0x0000, 0x0000, 0x0000 }, /* R697 */
805 	{ 0x0000, 0x0000, 0x0000 }, /* R698 */
806 	{ 0x0000, 0x0000, 0x0000 }, /* R699 */
807 	{ 0x0000, 0x0000, 0x0000 }, /* R700 */
808 	{ 0x0000, 0x0000, 0x0000 }, /* R701 */
809 	{ 0x0000, 0x0000, 0x0000 }, /* R702 */
810 	{ 0x0000, 0x0000, 0x0000 }, /* R703 */
811 	{ 0x0000, 0x0000, 0x0000 }, /* R704 */
812 	{ 0x0000, 0x0000, 0x0000 }, /* R705 */
813 	{ 0x0000, 0x0000, 0x0000 }, /* R706 */
814 	{ 0x0000, 0x0000, 0x0000 }, /* R707 */
815 	{ 0x0000, 0x0000, 0x0000 }, /* R708 */
816 	{ 0x0000, 0x0000, 0x0000 }, /* R709 */
817 	{ 0x0000, 0x0000, 0x0000 }, /* R710 */
818 	{ 0x0000, 0x0000, 0x0000 }, /* R711 */
819 	{ 0x0000, 0x0000, 0x0000 }, /* R712 */
820 	{ 0x0000, 0x0000, 0x0000 }, /* R713 */
821 	{ 0x0000, 0x0000, 0x0000 }, /* R714 */
822 	{ 0x0000, 0x0000, 0x0000 }, /* R715 */
823 	{ 0x0000, 0x0000, 0x0000 }, /* R716 */
824 	{ 0x0000, 0x0000, 0x0000 }, /* R717 */
825 	{ 0x0000, 0x0000, 0x0000 }, /* R718 */
826 	{ 0x0000, 0x0000, 0x0000 }, /* R719 */
827 	{ 0x0000, 0x0000, 0x0000 }, /* R720 */
828 	{ 0x0000, 0x0000, 0x0000 }, /* R721 */
829 	{ 0x0000, 0x0000, 0x0000 }, /* R722 */
830 	{ 0x0000, 0x0000, 0x0000 }, /* R723 */
831 	{ 0x0000, 0x0000, 0x0000 }, /* R724 */
832 	{ 0x0000, 0x0000, 0x0000 }, /* R725 */
833 	{ 0x0000, 0x0000, 0x0000 }, /* R726 */
834 	{ 0x0000, 0x0000, 0x0000 }, /* R727 */
835 	{ 0x0000, 0x0000, 0x0000 }, /* R728 */
836 	{ 0x0000, 0x0000, 0x0000 }, /* R729 */
837 	{ 0x0000, 0x0000, 0x0000 }, /* R730 */
838 	{ 0x0000, 0x0000, 0x0000 }, /* R731 */
839 	{ 0x0000, 0x0000, 0x0000 }, /* R732 */
840 	{ 0x0000, 0x0000, 0x0000 }, /* R733 */
841 	{ 0x0000, 0x0000, 0x0000 }, /* R734 */
842 	{ 0x0000, 0x0000, 0x0000 }, /* R735 */
843 	{ 0x0000, 0x0000, 0x0000 }, /* R736 */
844 	{ 0x0000, 0x0000, 0x0000 }, /* R737 */
845 	{ 0x0000, 0x0000, 0x0000 }, /* R738 */
846 	{ 0x0000, 0x0000, 0x0000 }, /* R739 */
847 	{ 0x0000, 0x0000, 0x0000 }, /* R740 */
848 	{ 0x0000, 0x0000, 0x0000 }, /* R741 */
849 	{ 0x0000, 0x0000, 0x0000 }, /* R742 */
850 	{ 0x0000, 0x0000, 0x0000 }, /* R743 */
851 	{ 0x0000, 0x0000, 0x0000 }, /* R744 */
852 	{ 0x0000, 0x0000, 0x0000 }, /* R745 */
853 	{ 0x0000, 0x0000, 0x0000 }, /* R746 */
854 	{ 0x0000, 0x0000, 0x0000 }, /* R747 */
855 	{ 0x0000, 0x0000, 0x0000 }, /* R748 */
856 	{ 0x0000, 0x0000, 0x0000 }, /* R749 */
857 	{ 0x0000, 0x0000, 0x0000 }, /* R750 */
858 	{ 0x0000, 0x0000, 0x0000 }, /* R751 */
859 	{ 0x0000, 0x0000, 0x0000 }, /* R752 */
860 	{ 0x0000, 0x0000, 0x0000 }, /* R753 */
861 	{ 0x0000, 0x0000, 0x0000 }, /* R754 */
862 	{ 0x0000, 0x0000, 0x0000 }, /* R755 */
863 	{ 0x0000, 0x0000, 0x0000 }, /* R756 */
864 	{ 0x0000, 0x0000, 0x0000 }, /* R757 */
865 	{ 0x0000, 0x0000, 0x0000 }, /* R758 */
866 	{ 0x0000, 0x0000, 0x0000 }, /* R759 */
867 	{ 0x0000, 0x0000, 0x0000 }, /* R760 */
868 	{ 0x0000, 0x0000, 0x0000 }, /* R761 */
869 	{ 0x0000, 0x0000, 0x0000 }, /* R762 */
870 	{ 0x0000, 0x0000, 0x0000 }, /* R763 */
871 	{ 0x0000, 0x0000, 0x0000 }, /* R764 */
872 	{ 0x0000, 0x0000, 0x0000 }, /* R765 */
873 	{ 0x0000, 0x0000, 0x0000 }, /* R766 */
874 	{ 0x0000, 0x0000, 0x0000 }, /* R767 */
875 	{ 0xE1F8, 0xE1F8, 0x0000 }, /* R768   - AIF1 Control (1) */
876 	{ 0xCD1F, 0xCD1F, 0x0000 }, /* R769   - AIF1 Control (2) */
877 	{ 0xF000, 0xF000, 0x0000 }, /* R770   - AIF1 Master/Slave */
878 	{ 0x01F0, 0x01F0, 0x0000 }, /* R771   - AIF1 BCLK */
879 	{ 0x0FFF, 0x0FFF, 0x0000 }, /* R772   - AIF1ADC LRCLK */
880 	{ 0x0FFF, 0x0FFF, 0x0000 }, /* R773   - AIF1DAC LRCLK */
881 	{ 0x0003, 0x0003, 0x0000 }, /* R774   - AIF1DAC Data */
882 	{ 0x0003, 0x0003, 0x0000 }, /* R775   - AIF1ADC Data */
883 	{ 0x0000, 0x0000, 0x0000 }, /* R776 */
884 	{ 0x0000, 0x0000, 0x0000 }, /* R777 */
885 	{ 0x0000, 0x0000, 0x0000 }, /* R778 */
886 	{ 0x0000, 0x0000, 0x0000 }, /* R779 */
887 	{ 0x0000, 0x0000, 0x0000 }, /* R780 */
888 	{ 0x0000, 0x0000, 0x0000 }, /* R781 */
889 	{ 0x0000, 0x0000, 0x0000 }, /* R782 */
890 	{ 0x0000, 0x0000, 0x0000 }, /* R783 */
891 	{ 0xF1F8, 0xF1F8, 0x0000 }, /* R784   - AIF2 Control (1) */
892 	{ 0xFD1F, 0xFD1F, 0x0000 }, /* R785   - AIF2 Control (2) */
893 	{ 0xF000, 0xF000, 0x0000 }, /* R786   - AIF2 Master/Slave */
894 	{ 0x01F0, 0x01F0, 0x0000 }, /* R787   - AIF2 BCLK */
895 	{ 0x0FFF, 0x0FFF, 0x0000 }, /* R788   - AIF2ADC LRCLK */
896 	{ 0x0FFF, 0x0FFF, 0x0000 }, /* R789   - AIF2DAC LRCLK */
897 	{ 0x0003, 0x0003, 0x0000 }, /* R790   - AIF2DAC Data */
898 	{ 0x0003, 0x0003, 0x0000 }, /* R791   - AIF2ADC Data */
899 	{ 0x0000, 0x0000, 0x0000 }, /* R792 */
900 	{ 0x0000, 0x0000, 0x0000 }, /* R793 */
901 	{ 0x0000, 0x0000, 0x0000 }, /* R794 */
902 	{ 0x0000, 0x0000, 0x0000 }, /* R795 */
903 	{ 0x0000, 0x0000, 0x0000 }, /* R796 */
904 	{ 0x0000, 0x0000, 0x0000 }, /* R797 */
905 	{ 0x0000, 0x0000, 0x0000 }, /* R798 */
906 	{ 0x0000, 0x0000, 0x0000 }, /* R799 */
907 	{ 0x0000, 0x0000, 0x0000 }, /* R800 */
908 	{ 0x0000, 0x0000, 0x0000 }, /* R801 */
909 	{ 0x0000, 0x0000, 0x0000 }, /* R802 */
910 	{ 0x0000, 0x0000, 0x0000 }, /* R803 */
911 	{ 0x0000, 0x0000, 0x0000 }, /* R804 */
912 	{ 0x0000, 0x0000, 0x0000 }, /* R805 */
913 	{ 0x0000, 0x0000, 0x0000 }, /* R806 */
914 	{ 0x0000, 0x0000, 0x0000 }, /* R807 */
915 	{ 0x0000, 0x0000, 0x0000 }, /* R808 */
916 	{ 0x0000, 0x0000, 0x0000 }, /* R809 */
917 	{ 0x0000, 0x0000, 0x0000 }, /* R810 */
918 	{ 0x0000, 0x0000, 0x0000 }, /* R811 */
919 	{ 0x0000, 0x0000, 0x0000 }, /* R812 */
920 	{ 0x0000, 0x0000, 0x0000 }, /* R813 */
921 	{ 0x0000, 0x0000, 0x0000 }, /* R814 */
922 	{ 0x0000, 0x0000, 0x0000 }, /* R815 */
923 	{ 0x0000, 0x0000, 0x0000 }, /* R816 */
924 	{ 0x0000, 0x0000, 0x0000 }, /* R817 */
925 	{ 0x0000, 0x0000, 0x0000 }, /* R818 */
926 	{ 0x0000, 0x0000, 0x0000 }, /* R819 */
927 	{ 0x0000, 0x0000, 0x0000 }, /* R820 */
928 	{ 0x0000, 0x0000, 0x0000 }, /* R821 */
929 	{ 0x0000, 0x0000, 0x0000 }, /* R822 */
930 	{ 0x0000, 0x0000, 0x0000 }, /* R823 */
931 	{ 0x0000, 0x0000, 0x0000 }, /* R824 */
932 	{ 0x0000, 0x0000, 0x0000 }, /* R825 */
933 	{ 0x0000, 0x0000, 0x0000 }, /* R826 */
934 	{ 0x0000, 0x0000, 0x0000 }, /* R827 */
935 	{ 0x0000, 0x0000, 0x0000 }, /* R828 */
936 	{ 0x0000, 0x0000, 0x0000 }, /* R829 */
937 	{ 0x0000, 0x0000, 0x0000 }, /* R830 */
938 	{ 0x0000, 0x0000, 0x0000 }, /* R831 */
939 	{ 0x0000, 0x0000, 0x0000 }, /* R832 */
940 	{ 0x0000, 0x0000, 0x0000 }, /* R833 */
941 	{ 0x0000, 0x0000, 0x0000 }, /* R834 */
942 	{ 0x0000, 0x0000, 0x0000 }, /* R835 */
943 	{ 0x0000, 0x0000, 0x0000 }, /* R836 */
944 	{ 0x0000, 0x0000, 0x0000 }, /* R837 */
945 	{ 0x0000, 0x0000, 0x0000 }, /* R838 */
946 	{ 0x0000, 0x0000, 0x0000 }, /* R839 */
947 	{ 0x0000, 0x0000, 0x0000 }, /* R840 */
948 	{ 0x0000, 0x0000, 0x0000 }, /* R841 */
949 	{ 0x0000, 0x0000, 0x0000 }, /* R842 */
950 	{ 0x0000, 0x0000, 0x0000 }, /* R843 */
951 	{ 0x0000, 0x0000, 0x0000 }, /* R844 */
952 	{ 0x0000, 0x0000, 0x0000 }, /* R845 */
953 	{ 0x0000, 0x0000, 0x0000 }, /* R846 */
954 	{ 0x0000, 0x0000, 0x0000 }, /* R847 */
955 	{ 0x0000, 0x0000, 0x0000 }, /* R848 */
956 	{ 0x0000, 0x0000, 0x0000 }, /* R849 */
957 	{ 0x0000, 0x0000, 0x0000 }, /* R850 */
958 	{ 0x0000, 0x0000, 0x0000 }, /* R851 */
959 	{ 0x0000, 0x0000, 0x0000 }, /* R852 */
960 	{ 0x0000, 0x0000, 0x0000 }, /* R853 */
961 	{ 0x0000, 0x0000, 0x0000 }, /* R854 */
962 	{ 0x0000, 0x0000, 0x0000 }, /* R855 */
963 	{ 0x0000, 0x0000, 0x0000 }, /* R856 */
964 	{ 0x0000, 0x0000, 0x0000 }, /* R857 */
965 	{ 0x0000, 0x0000, 0x0000 }, /* R858 */
966 	{ 0x0000, 0x0000, 0x0000 }, /* R859 */
967 	{ 0x0000, 0x0000, 0x0000 }, /* R860 */
968 	{ 0x0000, 0x0000, 0x0000 }, /* R861 */
969 	{ 0x0000, 0x0000, 0x0000 }, /* R862 */
970 	{ 0x0000, 0x0000, 0x0000 }, /* R863 */
971 	{ 0x0000, 0x0000, 0x0000 }, /* R864 */
972 	{ 0x0000, 0x0000, 0x0000 }, /* R865 */
973 	{ 0x0000, 0x0000, 0x0000 }, /* R866 */
974 	{ 0x0000, 0x0000, 0x0000 }, /* R867 */
975 	{ 0x0000, 0x0000, 0x0000 }, /* R868 */
976 	{ 0x0000, 0x0000, 0x0000 }, /* R869 */
977 	{ 0x0000, 0x0000, 0x0000 }, /* R870 */
978 	{ 0x0000, 0x0000, 0x0000 }, /* R871 */
979 	{ 0x0000, 0x0000, 0x0000 }, /* R872 */
980 	{ 0x0000, 0x0000, 0x0000 }, /* R873 */
981 	{ 0x0000, 0x0000, 0x0000 }, /* R874 */
982 	{ 0x0000, 0x0000, 0x0000 }, /* R875 */
983 	{ 0x0000, 0x0000, 0x0000 }, /* R876 */
984 	{ 0x0000, 0x0000, 0x0000 }, /* R877 */
985 	{ 0x0000, 0x0000, 0x0000 }, /* R878 */
986 	{ 0x0000, 0x0000, 0x0000 }, /* R879 */
987 	{ 0x0000, 0x0000, 0x0000 }, /* R880 */
988 	{ 0x0000, 0x0000, 0x0000 }, /* R881 */
989 	{ 0x0000, 0x0000, 0x0000 }, /* R882 */
990 	{ 0x0000, 0x0000, 0x0000 }, /* R883 */
991 	{ 0x0000, 0x0000, 0x0000 }, /* R884 */
992 	{ 0x0000, 0x0000, 0x0000 }, /* R885 */
993 	{ 0x0000, 0x0000, 0x0000 }, /* R886 */
994 	{ 0x0000, 0x0000, 0x0000 }, /* R887 */
995 	{ 0x0000, 0x0000, 0x0000 }, /* R888 */
996 	{ 0x0000, 0x0000, 0x0000 }, /* R889 */
997 	{ 0x0000, 0x0000, 0x0000 }, /* R890 */
998 	{ 0x0000, 0x0000, 0x0000 }, /* R891 */
999 	{ 0x0000, 0x0000, 0x0000 }, /* R892 */
1000 	{ 0x0000, 0x0000, 0x0000 }, /* R893 */
1001 	{ 0x0000, 0x0000, 0x0000 }, /* R894 */
1002 	{ 0x0000, 0x0000, 0x0000 }, /* R895 */
1003 	{ 0x0000, 0x0000, 0x0000 }, /* R896 */
1004 	{ 0x0000, 0x0000, 0x0000 }, /* R897 */
1005 	{ 0x0000, 0x0000, 0x0000 }, /* R898 */
1006 	{ 0x0000, 0x0000, 0x0000 }, /* R899 */
1007 	{ 0x0000, 0x0000, 0x0000 }, /* R900 */
1008 	{ 0x0000, 0x0000, 0x0000 }, /* R901 */
1009 	{ 0x0000, 0x0000, 0x0000 }, /* R902 */
1010 	{ 0x0000, 0x0000, 0x0000 }, /* R903 */
1011 	{ 0x0000, 0x0000, 0x0000 }, /* R904 */
1012 	{ 0x0000, 0x0000, 0x0000 }, /* R905 */
1013 	{ 0x0000, 0x0000, 0x0000 }, /* R906 */
1014 	{ 0x0000, 0x0000, 0x0000 }, /* R907 */
1015 	{ 0x0000, 0x0000, 0x0000 }, /* R908 */
1016 	{ 0x0000, 0x0000, 0x0000 }, /* R909 */
1017 	{ 0x0000, 0x0000, 0x0000 }, /* R910 */
1018 	{ 0x0000, 0x0000, 0x0000 }, /* R911 */
1019 	{ 0x0000, 0x0000, 0x0000 }, /* R912 */
1020 	{ 0x0000, 0x0000, 0x0000 }, /* R913 */
1021 	{ 0x0000, 0x0000, 0x0000 }, /* R914 */
1022 	{ 0x0000, 0x0000, 0x0000 }, /* R915 */
1023 	{ 0x0000, 0x0000, 0x0000 }, /* R916 */
1024 	{ 0x0000, 0x0000, 0x0000 }, /* R917 */
1025 	{ 0x0000, 0x0000, 0x0000 }, /* R918 */
1026 	{ 0x0000, 0x0000, 0x0000 }, /* R919 */
1027 	{ 0x0000, 0x0000, 0x0000 }, /* R920 */
1028 	{ 0x0000, 0x0000, 0x0000 }, /* R921 */
1029 	{ 0x0000, 0x0000, 0x0000 }, /* R922 */
1030 	{ 0x0000, 0x0000, 0x0000 }, /* R923 */
1031 	{ 0x0000, 0x0000, 0x0000 }, /* R924 */
1032 	{ 0x0000, 0x0000, 0x0000 }, /* R925 */
1033 	{ 0x0000, 0x0000, 0x0000 }, /* R926 */
1034 	{ 0x0000, 0x0000, 0x0000 }, /* R927 */
1035 	{ 0x0000, 0x0000, 0x0000 }, /* R928 */
1036 	{ 0x0000, 0x0000, 0x0000 }, /* R929 */
1037 	{ 0x0000, 0x0000, 0x0000 }, /* R930 */
1038 	{ 0x0000, 0x0000, 0x0000 }, /* R931 */
1039 	{ 0x0000, 0x0000, 0x0000 }, /* R932 */
1040 	{ 0x0000, 0x0000, 0x0000 }, /* R933 */
1041 	{ 0x0000, 0x0000, 0x0000 }, /* R934 */
1042 	{ 0x0000, 0x0000, 0x0000 }, /* R935 */
1043 	{ 0x0000, 0x0000, 0x0000 }, /* R936 */
1044 	{ 0x0000, 0x0000, 0x0000 }, /* R937 */
1045 	{ 0x0000, 0x0000, 0x0000 }, /* R938 */
1046 	{ 0x0000, 0x0000, 0x0000 }, /* R939 */
1047 	{ 0x0000, 0x0000, 0x0000 }, /* R940 */
1048 	{ 0x0000, 0x0000, 0x0000 }, /* R941 */
1049 	{ 0x0000, 0x0000, 0x0000 }, /* R942 */
1050 	{ 0x0000, 0x0000, 0x0000 }, /* R943 */
1051 	{ 0x0000, 0x0000, 0x0000 }, /* R944 */
1052 	{ 0x0000, 0x0000, 0x0000 }, /* R945 */
1053 	{ 0x0000, 0x0000, 0x0000 }, /* R946 */
1054 	{ 0x0000, 0x0000, 0x0000 }, /* R947 */
1055 	{ 0x0000, 0x0000, 0x0000 }, /* R948 */
1056 	{ 0x0000, 0x0000, 0x0000 }, /* R949 */
1057 	{ 0x0000, 0x0000, 0x0000 }, /* R950 */
1058 	{ 0x0000, 0x0000, 0x0000 }, /* R951 */
1059 	{ 0x0000, 0x0000, 0x0000 }, /* R952 */
1060 	{ 0x0000, 0x0000, 0x0000 }, /* R953 */
1061 	{ 0x0000, 0x0000, 0x0000 }, /* R954 */
1062 	{ 0x0000, 0x0000, 0x0000 }, /* R955 */
1063 	{ 0x0000, 0x0000, 0x0000 }, /* R956 */
1064 	{ 0x0000, 0x0000, 0x0000 }, /* R957 */
1065 	{ 0x0000, 0x0000, 0x0000 }, /* R958 */
1066 	{ 0x0000, 0x0000, 0x0000 }, /* R959 */
1067 	{ 0x0000, 0x0000, 0x0000 }, /* R960 */
1068 	{ 0x0000, 0x0000, 0x0000 }, /* R961 */
1069 	{ 0x0000, 0x0000, 0x0000 }, /* R962 */
1070 	{ 0x0000, 0x0000, 0x0000 }, /* R963 */
1071 	{ 0x0000, 0x0000, 0x0000 }, /* R964 */
1072 	{ 0x0000, 0x0000, 0x0000 }, /* R965 */
1073 	{ 0x0000, 0x0000, 0x0000 }, /* R966 */
1074 	{ 0x0000, 0x0000, 0x0000 }, /* R967 */
1075 	{ 0x0000, 0x0000, 0x0000 }, /* R968 */
1076 	{ 0x0000, 0x0000, 0x0000 }, /* R969 */
1077 	{ 0x0000, 0x0000, 0x0000 }, /* R970 */
1078 	{ 0x0000, 0x0000, 0x0000 }, /* R971 */
1079 	{ 0x0000, 0x0000, 0x0000 }, /* R972 */
1080 	{ 0x0000, 0x0000, 0x0000 }, /* R973 */
1081 	{ 0x0000, 0x0000, 0x0000 }, /* R974 */
1082 	{ 0x0000, 0x0000, 0x0000 }, /* R975 */
1083 	{ 0x0000, 0x0000, 0x0000 }, /* R976 */
1084 	{ 0x0000, 0x0000, 0x0000 }, /* R977 */
1085 	{ 0x0000, 0x0000, 0x0000 }, /* R978 */
1086 	{ 0x0000, 0x0000, 0x0000 }, /* R979 */
1087 	{ 0x0000, 0x0000, 0x0000 }, /* R980 */
1088 	{ 0x0000, 0x0000, 0x0000 }, /* R981 */
1089 	{ 0x0000, 0x0000, 0x0000 }, /* R982 */
1090 	{ 0x0000, 0x0000, 0x0000 }, /* R983 */
1091 	{ 0x0000, 0x0000, 0x0000 }, /* R984 */
1092 	{ 0x0000, 0x0000, 0x0000 }, /* R985 */
1093 	{ 0x0000, 0x0000, 0x0000 }, /* R986 */
1094 	{ 0x0000, 0x0000, 0x0000 }, /* R987 */
1095 	{ 0x0000, 0x0000, 0x0000 }, /* R988 */
1096 	{ 0x0000, 0x0000, 0x0000 }, /* R989 */
1097 	{ 0x0000, 0x0000, 0x0000 }, /* R990 */
1098 	{ 0x0000, 0x0000, 0x0000 }, /* R991 */
1099 	{ 0x0000, 0x0000, 0x0000 }, /* R992 */
1100 	{ 0x0000, 0x0000, 0x0000 }, /* R993 */
1101 	{ 0x0000, 0x0000, 0x0000 }, /* R994 */
1102 	{ 0x0000, 0x0000, 0x0000 }, /* R995 */
1103 	{ 0x0000, 0x0000, 0x0000 }, /* R996 */
1104 	{ 0x0000, 0x0000, 0x0000 }, /* R997 */
1105 	{ 0x0000, 0x0000, 0x0000 }, /* R998 */
1106 	{ 0x0000, 0x0000, 0x0000 }, /* R999 */
1107 	{ 0x0000, 0x0000, 0x0000 }, /* R1000 */
1108 	{ 0x0000, 0x0000, 0x0000 }, /* R1001 */
1109 	{ 0x0000, 0x0000, 0x0000 }, /* R1002 */
1110 	{ 0x0000, 0x0000, 0x0000 }, /* R1003 */
1111 	{ 0x0000, 0x0000, 0x0000 }, /* R1004 */
1112 	{ 0x0000, 0x0000, 0x0000 }, /* R1005 */
1113 	{ 0x0000, 0x0000, 0x0000 }, /* R1006 */
1114 	{ 0x0000, 0x0000, 0x0000 }, /* R1007 */
1115 	{ 0x0000, 0x0000, 0x0000 }, /* R1008 */
1116 	{ 0x0000, 0x0000, 0x0000 }, /* R1009 */
1117 	{ 0x0000, 0x0000, 0x0000 }, /* R1010 */
1118 	{ 0x0000, 0x0000, 0x0000 }, /* R1011 */
1119 	{ 0x0000, 0x0000, 0x0000 }, /* R1012 */
1120 	{ 0x0000, 0x0000, 0x0000 }, /* R1013 */
1121 	{ 0x0000, 0x0000, 0x0000 }, /* R1014 */
1122 	{ 0x0000, 0x0000, 0x0000 }, /* R1015 */
1123 	{ 0x0000, 0x0000, 0x0000 }, /* R1016 */
1124 	{ 0x0000, 0x0000, 0x0000 }, /* R1017 */
1125 	{ 0x0000, 0x0000, 0x0000 }, /* R1018 */
1126 	{ 0x0000, 0x0000, 0x0000 }, /* R1019 */
1127 	{ 0x0000, 0x0000, 0x0000 }, /* R1020 */
1128 	{ 0x0000, 0x0000, 0x0000 }, /* R1021 */
1129 	{ 0x0000, 0x0000, 0x0000 }, /* R1022 */
1130 	{ 0x0000, 0x0000, 0x0000 }, /* R1023 */
1131 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1024  - AIF1 ADC1 Left Volume */
1132 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1025  - AIF1 ADC1 Right Volume */
1133 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1026  - AIF1 DAC1 Left Volume */
1134 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1027  - AIF1 DAC1 Right Volume */
1135 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1028  - AIF1 ADC2 Left Volume */
1136 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1029  - AIF1 ADC2 Right Volume */
1137 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1030  - AIF1 DAC2 Left Volume */
1138 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1031  - AIF1 DAC2 Right Volume */
1139 	{ 0x0000, 0x0000, 0x0000 }, /* R1032 */
1140 	{ 0x0000, 0x0000, 0x0000 }, /* R1033 */
1141 	{ 0x0000, 0x0000, 0x0000 }, /* R1034 */
1142 	{ 0x0000, 0x0000, 0x0000 }, /* R1035 */
1143 	{ 0x0000, 0x0000, 0x0000 }, /* R1036 */
1144 	{ 0x0000, 0x0000, 0x0000 }, /* R1037 */
1145 	{ 0x0000, 0x0000, 0x0000 }, /* R1038 */
1146 	{ 0x0000, 0x0000, 0x0000 }, /* R1039 */
1147 	{ 0xF800, 0xF800, 0x0000 }, /* R1040  - AIF1 ADC1 Filters */
1148 	{ 0x7800, 0x7800, 0x0000 }, /* R1041  - AIF1 ADC2 Filters */
1149 	{ 0x0000, 0x0000, 0x0000 }, /* R1042 */
1150 	{ 0x0000, 0x0000, 0x0000 }, /* R1043 */
1151 	{ 0x0000, 0x0000, 0x0000 }, /* R1044 */
1152 	{ 0x0000, 0x0000, 0x0000 }, /* R1045 */
1153 	{ 0x0000, 0x0000, 0x0000 }, /* R1046 */
1154 	{ 0x0000, 0x0000, 0x0000 }, /* R1047 */
1155 	{ 0x0000, 0x0000, 0x0000 }, /* R1048 */
1156 	{ 0x0000, 0x0000, 0x0000 }, /* R1049 */
1157 	{ 0x0000, 0x0000, 0x0000 }, /* R1050 */
1158 	{ 0x0000, 0x0000, 0x0000 }, /* R1051 */
1159 	{ 0x0000, 0x0000, 0x0000 }, /* R1052 */
1160 	{ 0x0000, 0x0000, 0x0000 }, /* R1053 */
1161 	{ 0x0000, 0x0000, 0x0000 }, /* R1054 */
1162 	{ 0x0000, 0x0000, 0x0000 }, /* R1055 */
1163 	{ 0x02B6, 0x02B6, 0x0000 }, /* R1056  - AIF1 DAC1 Filters (1) */
1164 	{ 0x3F00, 0x3F00, 0x0000 }, /* R1057  - AIF1 DAC1 Filters (2) */
1165 	{ 0x02B6, 0x02B6, 0x0000 }, /* R1058  - AIF1 DAC2 Filters (1) */
1166 	{ 0x3F00, 0x3F00, 0x0000 }, /* R1059  - AIF1 DAC2 Filters (2) */
1167 	{ 0x0000, 0x0000, 0x0000 }, /* R1060 */
1168 	{ 0x0000, 0x0000, 0x0000 }, /* R1061 */
1169 	{ 0x0000, 0x0000, 0x0000 }, /* R1062 */
1170 	{ 0x0000, 0x0000, 0x0000 }, /* R1063 */
1171 	{ 0x0000, 0x0000, 0x0000 }, /* R1064 */
1172 	{ 0x0000, 0x0000, 0x0000 }, /* R1065 */
1173 	{ 0x0000, 0x0000, 0x0000 }, /* R1066 */
1174 	{ 0x0000, 0x0000, 0x0000 }, /* R1067 */
1175 	{ 0x0000, 0x0000, 0x0000 }, /* R1068 */
1176 	{ 0x0000, 0x0000, 0x0000 }, /* R1069 */
1177 	{ 0x0000, 0x0000, 0x0000 }, /* R1070 */
1178 	{ 0x0000, 0x0000, 0x0000 }, /* R1071 */
1179 	{ 0x0000, 0x0000, 0x0000 }, /* R1072 */
1180 	{ 0x0000, 0x0000, 0x0000 }, /* R1073 */
1181 	{ 0x0000, 0x0000, 0x0000 }, /* R1074 */
1182 	{ 0x0000, 0x0000, 0x0000 }, /* R1075 */
1183 	{ 0x0000, 0x0000, 0x0000 }, /* R1076 */
1184 	{ 0x0000, 0x0000, 0x0000 }, /* R1077 */
1185 	{ 0x0000, 0x0000, 0x0000 }, /* R1078 */
1186 	{ 0x0000, 0x0000, 0x0000 }, /* R1079 */
1187 	{ 0x0000, 0x0000, 0x0000 }, /* R1080 */
1188 	{ 0x0000, 0x0000, 0x0000 }, /* R1081 */
1189 	{ 0x0000, 0x0000, 0x0000 }, /* R1082 */
1190 	{ 0x0000, 0x0000, 0x0000 }, /* R1083 */
1191 	{ 0x0000, 0x0000, 0x0000 }, /* R1084 */
1192 	{ 0x0000, 0x0000, 0x0000 }, /* R1085 */
1193 	{ 0x0000, 0x0000, 0x0000 }, /* R1086 */
1194 	{ 0x0000, 0x0000, 0x0000 }, /* R1087 */
1195 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1088  - AIF1 DRC1 (1) */
1196 	{ 0x1FFF, 0x1FFF, 0x0000 }, /* R1089  - AIF1 DRC1 (2) */
1197 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1090  - AIF1 DRC1 (3) */
1198 	{ 0x07FF, 0x07FF, 0x0000 }, /* R1091  - AIF1 DRC1 (4) */
1199 	{ 0x03FF, 0x03FF, 0x0000 }, /* R1092  - AIF1 DRC1 (5) */
1200 	{ 0x0000, 0x0000, 0x0000 }, /* R1093 */
1201 	{ 0x0000, 0x0000, 0x0000 }, /* R1094 */
1202 	{ 0x0000, 0x0000, 0x0000 }, /* R1095 */
1203 	{ 0x0000, 0x0000, 0x0000 }, /* R1096 */
1204 	{ 0x0000, 0x0000, 0x0000 }, /* R1097 */
1205 	{ 0x0000, 0x0000, 0x0000 }, /* R1098 */
1206 	{ 0x0000, 0x0000, 0x0000 }, /* R1099 */
1207 	{ 0x0000, 0x0000, 0x0000 }, /* R1100 */
1208 	{ 0x0000, 0x0000, 0x0000 }, /* R1101 */
1209 	{ 0x0000, 0x0000, 0x0000 }, /* R1102 */
1210 	{ 0x0000, 0x0000, 0x0000 }, /* R1103 */
1211 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1104  - AIF1 DRC2 (1) */
1212 	{ 0x1FFF, 0x1FFF, 0x0000 }, /* R1105  - AIF1 DRC2 (2) */
1213 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1106  - AIF1 DRC2 (3) */
1214 	{ 0x07FF, 0x07FF, 0x0000 }, /* R1107  - AIF1 DRC2 (4) */
1215 	{ 0x03FF, 0x03FF, 0x0000 }, /* R1108  - AIF1 DRC2 (5) */
1216 	{ 0x0000, 0x0000, 0x0000 }, /* R1109 */
1217 	{ 0x0000, 0x0000, 0x0000 }, /* R1110 */
1218 	{ 0x0000, 0x0000, 0x0000 }, /* R1111 */
1219 	{ 0x0000, 0x0000, 0x0000 }, /* R1112 */
1220 	{ 0x0000, 0x0000, 0x0000 }, /* R1113 */
1221 	{ 0x0000, 0x0000, 0x0000 }, /* R1114 */
1222 	{ 0x0000, 0x0000, 0x0000 }, /* R1115 */
1223 	{ 0x0000, 0x0000, 0x0000 }, /* R1116 */
1224 	{ 0x0000, 0x0000, 0x0000 }, /* R1117 */
1225 	{ 0x0000, 0x0000, 0x0000 }, /* R1118 */
1226 	{ 0x0000, 0x0000, 0x0000 }, /* R1119 */
1227 	{ 0x0000, 0x0000, 0x0000 }, /* R1120 */
1228 	{ 0x0000, 0x0000, 0x0000 }, /* R1121 */
1229 	{ 0x0000, 0x0000, 0x0000 }, /* R1122 */
1230 	{ 0x0000, 0x0000, 0x0000 }, /* R1123 */
1231 	{ 0x0000, 0x0000, 0x0000 }, /* R1124 */
1232 	{ 0x0000, 0x0000, 0x0000 }, /* R1125 */
1233 	{ 0x0000, 0x0000, 0x0000 }, /* R1126 */
1234 	{ 0x0000, 0x0000, 0x0000 }, /* R1127 */
1235 	{ 0x0000, 0x0000, 0x0000 }, /* R1128 */
1236 	{ 0x0000, 0x0000, 0x0000 }, /* R1129 */
1237 	{ 0x0000, 0x0000, 0x0000 }, /* R1130 */
1238 	{ 0x0000, 0x0000, 0x0000 }, /* R1131 */
1239 	{ 0x0000, 0x0000, 0x0000 }, /* R1132 */
1240 	{ 0x0000, 0x0000, 0x0000 }, /* R1133 */
1241 	{ 0x0000, 0x0000, 0x0000 }, /* R1134 */
1242 	{ 0x0000, 0x0000, 0x0000 }, /* R1135 */
1243 	{ 0x0000, 0x0000, 0x0000 }, /* R1136 */
1244 	{ 0x0000, 0x0000, 0x0000 }, /* R1137 */
1245 	{ 0x0000, 0x0000, 0x0000 }, /* R1138 */
1246 	{ 0x0000, 0x0000, 0x0000 }, /* R1139 */
1247 	{ 0x0000, 0x0000, 0x0000 }, /* R1140 */
1248 	{ 0x0000, 0x0000, 0x0000 }, /* R1141 */
1249 	{ 0x0000, 0x0000, 0x0000 }, /* R1142 */
1250 	{ 0x0000, 0x0000, 0x0000 }, /* R1143 */
1251 	{ 0x0000, 0x0000, 0x0000 }, /* R1144 */
1252 	{ 0x0000, 0x0000, 0x0000 }, /* R1145 */
1253 	{ 0x0000, 0x0000, 0x0000 }, /* R1146 */
1254 	{ 0x0000, 0x0000, 0x0000 }, /* R1147 */
1255 	{ 0x0000, 0x0000, 0x0000 }, /* R1148 */
1256 	{ 0x0000, 0x0000, 0x0000 }, /* R1149 */
1257 	{ 0x0000, 0x0000, 0x0000 }, /* R1150 */
1258 	{ 0x0000, 0x0000, 0x0000 }, /* R1151 */
1259 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1152  - AIF1 DAC1 EQ Gains (1) */
1260 	{ 0xFFC0, 0xFFC0, 0x0000 }, /* R1153  - AIF1 DAC1 EQ Gains (2) */
1261 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1154  - AIF1 DAC1 EQ Band 1 A */
1262 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1155  - AIF1 DAC1 EQ Band 1 B */
1263 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1156  - AIF1 DAC1 EQ Band 1 PG */
1264 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1157  - AIF1 DAC1 EQ Band 2 A */
1265 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1158  - AIF1 DAC1 EQ Band 2 B */
1266 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1159  - AIF1 DAC1 EQ Band 2 C */
1267 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1160  - AIF1 DAC1 EQ Band 2 PG */
1268 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1161  - AIF1 DAC1 EQ Band 3 A */
1269 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1162  - AIF1 DAC1 EQ Band 3 B */
1270 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1163  - AIF1 DAC1 EQ Band 3 C */
1271 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1164  - AIF1 DAC1 EQ Band 3 PG */
1272 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1165  - AIF1 DAC1 EQ Band 4 A */
1273 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1166  - AIF1 DAC1 EQ Band 4 B */
1274 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1167  - AIF1 DAC1 EQ Band 4 C */
1275 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1168  - AIF1 DAC1 EQ Band 4 PG */
1276 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1169  - AIF1 DAC1 EQ Band 5 A */
1277 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1170  - AIF1 DAC1 EQ Band 5 B */
1278 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1171  - AIF1 DAC1 EQ Band 5 PG */
1279 	{ 0x0000, 0x0000, 0x0000 }, /* R1172 */
1280 	{ 0x0000, 0x0000, 0x0000 }, /* R1173 */
1281 	{ 0x0000, 0x0000, 0x0000 }, /* R1174 */
1282 	{ 0x0000, 0x0000, 0x0000 }, /* R1175 */
1283 	{ 0x0000, 0x0000, 0x0000 }, /* R1176 */
1284 	{ 0x0000, 0x0000, 0x0000 }, /* R1177 */
1285 	{ 0x0000, 0x0000, 0x0000 }, /* R1178 */
1286 	{ 0x0000, 0x0000, 0x0000 }, /* R1179 */
1287 	{ 0x0000, 0x0000, 0x0000 }, /* R1180 */
1288 	{ 0x0000, 0x0000, 0x0000 }, /* R1181 */
1289 	{ 0x0000, 0x0000, 0x0000 }, /* R1182 */
1290 	{ 0x0000, 0x0000, 0x0000 }, /* R1183 */
1291 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1184  - AIF1 DAC2 EQ Gains (1) */
1292 	{ 0xFFC0, 0xFFC0, 0x0000 }, /* R1185  - AIF1 DAC2 EQ Gains (2) */
1293 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1186  - AIF1 DAC2 EQ Band 1 A */
1294 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1187  - AIF1 DAC2 EQ Band 1 B */
1295 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1188  - AIF1 DAC2 EQ Band 1 PG */
1296 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1189  - AIF1 DAC2 EQ Band 2 A */
1297 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1190  - AIF1 DAC2 EQ Band 2 B */
1298 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1191  - AIF1 DAC2 EQ Band 2 C */
1299 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1192  - AIF1 DAC2 EQ Band 2 PG */
1300 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1193  - AIF1 DAC2 EQ Band 3 A */
1301 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1194  - AIF1 DAC2 EQ Band 3 B */
1302 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1195  - AIF1 DAC2 EQ Band 3 C */
1303 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1196  - AIF1 DAC2 EQ Band 3 PG */
1304 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1197  - AIF1 DAC2 EQ Band 4 A */
1305 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1198  - AIF1 DAC2 EQ Band 4 B */
1306 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1199  - AIF1 DAC2 EQ Band 4 C */
1307 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1200  - AIF1 DAC2 EQ Band 4 PG */
1308 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1201  - AIF1 DAC2 EQ Band 5 A */
1309 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1202  - AIF1 DAC2 EQ Band 5 B */
1310 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1203  - AIF1 DAC2 EQ Band 5 PG */
1311 	{ 0x0000, 0x0000, 0x0000 }, /* R1204 */
1312 	{ 0x0000, 0x0000, 0x0000 }, /* R1205 */
1313 	{ 0x0000, 0x0000, 0x0000 }, /* R1206 */
1314 	{ 0x0000, 0x0000, 0x0000 }, /* R1207 */
1315 	{ 0x0000, 0x0000, 0x0000 }, /* R1208 */
1316 	{ 0x0000, 0x0000, 0x0000 }, /* R1209 */
1317 	{ 0x0000, 0x0000, 0x0000 }, /* R1210 */
1318 	{ 0x0000, 0x0000, 0x0000 }, /* R1211 */
1319 	{ 0x0000, 0x0000, 0x0000 }, /* R1212 */
1320 	{ 0x0000, 0x0000, 0x0000 }, /* R1213 */
1321 	{ 0x0000, 0x0000, 0x0000 }, /* R1214 */
1322 	{ 0x0000, 0x0000, 0x0000 }, /* R1215 */
1323 	{ 0x0000, 0x0000, 0x0000 }, /* R1216 */
1324 	{ 0x0000, 0x0000, 0x0000 }, /* R1217 */
1325 	{ 0x0000, 0x0000, 0x0000 }, /* R1218 */
1326 	{ 0x0000, 0x0000, 0x0000 }, /* R1219 */
1327 	{ 0x0000, 0x0000, 0x0000 }, /* R1220 */
1328 	{ 0x0000, 0x0000, 0x0000 }, /* R1221 */
1329 	{ 0x0000, 0x0000, 0x0000 }, /* R1222 */
1330 	{ 0x0000, 0x0000, 0x0000 }, /* R1223 */
1331 	{ 0x0000, 0x0000, 0x0000 }, /* R1224 */
1332 	{ 0x0000, 0x0000, 0x0000 }, /* R1225 */
1333 	{ 0x0000, 0x0000, 0x0000 }, /* R1226 */
1334 	{ 0x0000, 0x0000, 0x0000 }, /* R1227 */
1335 	{ 0x0000, 0x0000, 0x0000 }, /* R1228 */
1336 	{ 0x0000, 0x0000, 0x0000 }, /* R1229 */
1337 	{ 0x0000, 0x0000, 0x0000 }, /* R1230 */
1338 	{ 0x0000, 0x0000, 0x0000 }, /* R1231 */
1339 	{ 0x0000, 0x0000, 0x0000 }, /* R1232 */
1340 	{ 0x0000, 0x0000, 0x0000 }, /* R1233 */
1341 	{ 0x0000, 0x0000, 0x0000 }, /* R1234 */
1342 	{ 0x0000, 0x0000, 0x0000 }, /* R1235 */
1343 	{ 0x0000, 0x0000, 0x0000 }, /* R1236 */
1344 	{ 0x0000, 0x0000, 0x0000 }, /* R1237 */
1345 	{ 0x0000, 0x0000, 0x0000 }, /* R1238 */
1346 	{ 0x0000, 0x0000, 0x0000 }, /* R1239 */
1347 	{ 0x0000, 0x0000, 0x0000 }, /* R1240 */
1348 	{ 0x0000, 0x0000, 0x0000 }, /* R1241 */
1349 	{ 0x0000, 0x0000, 0x0000 }, /* R1242 */
1350 	{ 0x0000, 0x0000, 0x0000 }, /* R1243 */
1351 	{ 0x0000, 0x0000, 0x0000 }, /* R1244 */
1352 	{ 0x0000, 0x0000, 0x0000 }, /* R1245 */
1353 	{ 0x0000, 0x0000, 0x0000 }, /* R1246 */
1354 	{ 0x0000, 0x0000, 0x0000 }, /* R1247 */
1355 	{ 0x0000, 0x0000, 0x0000 }, /* R1248 */
1356 	{ 0x0000, 0x0000, 0x0000 }, /* R1249 */
1357 	{ 0x0000, 0x0000, 0x0000 }, /* R1250 */
1358 	{ 0x0000, 0x0000, 0x0000 }, /* R1251 */
1359 	{ 0x0000, 0x0000, 0x0000 }, /* R1252 */
1360 	{ 0x0000, 0x0000, 0x0000 }, /* R1253 */
1361 	{ 0x0000, 0x0000, 0x0000 }, /* R1254 */
1362 	{ 0x0000, 0x0000, 0x0000 }, /* R1255 */
1363 	{ 0x0000, 0x0000, 0x0000 }, /* R1256 */
1364 	{ 0x0000, 0x0000, 0x0000 }, /* R1257 */
1365 	{ 0x0000, 0x0000, 0x0000 }, /* R1258 */
1366 	{ 0x0000, 0x0000, 0x0000 }, /* R1259 */
1367 	{ 0x0000, 0x0000, 0x0000 }, /* R1260 */
1368 	{ 0x0000, 0x0000, 0x0000 }, /* R1261 */
1369 	{ 0x0000, 0x0000, 0x0000 }, /* R1262 */
1370 	{ 0x0000, 0x0000, 0x0000 }, /* R1263 */
1371 	{ 0x0000, 0x0000, 0x0000 }, /* R1264 */
1372 	{ 0x0000, 0x0000, 0x0000 }, /* R1265 */
1373 	{ 0x0000, 0x0000, 0x0000 }, /* R1266 */
1374 	{ 0x0000, 0x0000, 0x0000 }, /* R1267 */
1375 	{ 0x0000, 0x0000, 0x0000 }, /* R1268 */
1376 	{ 0x0000, 0x0000, 0x0000 }, /* R1269 */
1377 	{ 0x0000, 0x0000, 0x0000 }, /* R1270 */
1378 	{ 0x0000, 0x0000, 0x0000 }, /* R1271 */
1379 	{ 0x0000, 0x0000, 0x0000 }, /* R1272 */
1380 	{ 0x0000, 0x0000, 0x0000 }, /* R1273 */
1381 	{ 0x0000, 0x0000, 0x0000 }, /* R1274 */
1382 	{ 0x0000, 0x0000, 0x0000 }, /* R1275 */
1383 	{ 0x0000, 0x0000, 0x0000 }, /* R1276 */
1384 	{ 0x0000, 0x0000, 0x0000 }, /* R1277 */
1385 	{ 0x0000, 0x0000, 0x0000 }, /* R1278 */
1386 	{ 0x0000, 0x0000, 0x0000 }, /* R1279 */
1387 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1280  - AIF2 ADC Left Volume */
1388 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1281  - AIF2 ADC Right Volume */
1389 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1282  - AIF2 DAC Left Volume */
1390 	{ 0x00FF, 0x01FF, 0x0000 }, /* R1283  - AIF2 DAC Right Volume */
1391 	{ 0x0000, 0x0000, 0x0000 }, /* R1284 */
1392 	{ 0x0000, 0x0000, 0x0000 }, /* R1285 */
1393 	{ 0x0000, 0x0000, 0x0000 }, /* R1286 */
1394 	{ 0x0000, 0x0000, 0x0000 }, /* R1287 */
1395 	{ 0x0000, 0x0000, 0x0000 }, /* R1288 */
1396 	{ 0x0000, 0x0000, 0x0000 }, /* R1289 */
1397 	{ 0x0000, 0x0000, 0x0000 }, /* R1290 */
1398 	{ 0x0000, 0x0000, 0x0000 }, /* R1291 */
1399 	{ 0x0000, 0x0000, 0x0000 }, /* R1292 */
1400 	{ 0x0000, 0x0000, 0x0000 }, /* R1293 */
1401 	{ 0x0000, 0x0000, 0x0000 }, /* R1294 */
1402 	{ 0x0000, 0x0000, 0x0000 }, /* R1295 */
1403 	{ 0xF800, 0xF800, 0x0000 }, /* R1296  - AIF2 ADC Filters */
1404 	{ 0x0000, 0x0000, 0x0000 }, /* R1297 */
1405 	{ 0x0000, 0x0000, 0x0000 }, /* R1298 */
1406 	{ 0x0000, 0x0000, 0x0000 }, /* R1299 */
1407 	{ 0x0000, 0x0000, 0x0000 }, /* R1300 */
1408 	{ 0x0000, 0x0000, 0x0000 }, /* R1301 */
1409 	{ 0x0000, 0x0000, 0x0000 }, /* R1302 */
1410 	{ 0x0000, 0x0000, 0x0000 }, /* R1303 */
1411 	{ 0x0000, 0x0000, 0x0000 }, /* R1304 */
1412 	{ 0x0000, 0x0000, 0x0000 }, /* R1305 */
1413 	{ 0x0000, 0x0000, 0x0000 }, /* R1306 */
1414 	{ 0x0000, 0x0000, 0x0000 }, /* R1307 */
1415 	{ 0x0000, 0x0000, 0x0000 }, /* R1308 */
1416 	{ 0x0000, 0x0000, 0x0000 }, /* R1309 */
1417 	{ 0x0000, 0x0000, 0x0000 }, /* R1310 */
1418 	{ 0x0000, 0x0000, 0x0000 }, /* R1311 */
1419 	{ 0x02B6, 0x02B6, 0x0000 }, /* R1312  - AIF2 DAC Filters (1) */
1420 	{ 0x3F00, 0x3F00, 0x0000 }, /* R1313  - AIF2 DAC Filters (2) */
1421 	{ 0x0000, 0x0000, 0x0000 }, /* R1314 */
1422 	{ 0x0000, 0x0000, 0x0000 }, /* R1315 */
1423 	{ 0x0000, 0x0000, 0x0000 }, /* R1316 */
1424 	{ 0x0000, 0x0000, 0x0000 }, /* R1317 */
1425 	{ 0x0000, 0x0000, 0x0000 }, /* R1318 */
1426 	{ 0x0000, 0x0000, 0x0000 }, /* R1319 */
1427 	{ 0x0000, 0x0000, 0x0000 }, /* R1320 */
1428 	{ 0x0000, 0x0000, 0x0000 }, /* R1321 */
1429 	{ 0x0000, 0x0000, 0x0000 }, /* R1322 */
1430 	{ 0x0000, 0x0000, 0x0000 }, /* R1323 */
1431 	{ 0x0000, 0x0000, 0x0000 }, /* R1324 */
1432 	{ 0x0000, 0x0000, 0x0000 }, /* R1325 */
1433 	{ 0x0000, 0x0000, 0x0000 }, /* R1326 */
1434 	{ 0x0000, 0x0000, 0x0000 }, /* R1327 */
1435 	{ 0x0000, 0x0000, 0x0000 }, /* R1328 */
1436 	{ 0x0000, 0x0000, 0x0000 }, /* R1329 */
1437 	{ 0x0000, 0x0000, 0x0000 }, /* R1330 */
1438 	{ 0x0000, 0x0000, 0x0000 }, /* R1331 */
1439 	{ 0x0000, 0x0000, 0x0000 }, /* R1332 */
1440 	{ 0x0000, 0x0000, 0x0000 }, /* R1333 */
1441 	{ 0x0000, 0x0000, 0x0000 }, /* R1334 */
1442 	{ 0x0000, 0x0000, 0x0000 }, /* R1335 */
1443 	{ 0x0000, 0x0000, 0x0000 }, /* R1336 */
1444 	{ 0x0000, 0x0000, 0x0000 }, /* R1337 */
1445 	{ 0x0000, 0x0000, 0x0000 }, /* R1338 */
1446 	{ 0x0000, 0x0000, 0x0000 }, /* R1339 */
1447 	{ 0x0000, 0x0000, 0x0000 }, /* R1340 */
1448 	{ 0x0000, 0x0000, 0x0000 }, /* R1341 */
1449 	{ 0x0000, 0x0000, 0x0000 }, /* R1342 */
1450 	{ 0x0000, 0x0000, 0x0000 }, /* R1343 */
1451 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1344  - AIF2 DRC (1) */
1452 	{ 0x1FFF, 0x1FFF, 0x0000 }, /* R1345  - AIF2 DRC (2) */
1453 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1346  - AIF2 DRC (3) */
1454 	{ 0x07FF, 0x07FF, 0x0000 }, /* R1347  - AIF2 DRC (4) */
1455 	{ 0x03FF, 0x03FF, 0x0000 }, /* R1348  - AIF2 DRC (5) */
1456 	{ 0x0000, 0x0000, 0x0000 }, /* R1349 */
1457 	{ 0x0000, 0x0000, 0x0000 }, /* R1350 */
1458 	{ 0x0000, 0x0000, 0x0000 }, /* R1351 */
1459 	{ 0x0000, 0x0000, 0x0000 }, /* R1352 */
1460 	{ 0x0000, 0x0000, 0x0000 }, /* R1353 */
1461 	{ 0x0000, 0x0000, 0x0000 }, /* R1354 */
1462 	{ 0x0000, 0x0000, 0x0000 }, /* R1355 */
1463 	{ 0x0000, 0x0000, 0x0000 }, /* R1356 */
1464 	{ 0x0000, 0x0000, 0x0000 }, /* R1357 */
1465 	{ 0x0000, 0x0000, 0x0000 }, /* R1358 */
1466 	{ 0x0000, 0x0000, 0x0000 }, /* R1359 */
1467 	{ 0x0000, 0x0000, 0x0000 }, /* R1360 */
1468 	{ 0x0000, 0x0000, 0x0000 }, /* R1361 */
1469 	{ 0x0000, 0x0000, 0x0000 }, /* R1362 */
1470 	{ 0x0000, 0x0000, 0x0000 }, /* R1363 */
1471 	{ 0x0000, 0x0000, 0x0000 }, /* R1364 */
1472 	{ 0x0000, 0x0000, 0x0000 }, /* R1365 */
1473 	{ 0x0000, 0x0000, 0x0000 }, /* R1366 */
1474 	{ 0x0000, 0x0000, 0x0000 }, /* R1367 */
1475 	{ 0x0000, 0x0000, 0x0000 }, /* R1368 */
1476 	{ 0x0000, 0x0000, 0x0000 }, /* R1369 */
1477 	{ 0x0000, 0x0000, 0x0000 }, /* R1370 */
1478 	{ 0x0000, 0x0000, 0x0000 }, /* R1371 */
1479 	{ 0x0000, 0x0000, 0x0000 }, /* R1372 */
1480 	{ 0x0000, 0x0000, 0x0000 }, /* R1373 */
1481 	{ 0x0000, 0x0000, 0x0000 }, /* R1374 */
1482 	{ 0x0000, 0x0000, 0x0000 }, /* R1375 */
1483 	{ 0x0000, 0x0000, 0x0000 }, /* R1376 */
1484 	{ 0x0000, 0x0000, 0x0000 }, /* R1377 */
1485 	{ 0x0000, 0x0000, 0x0000 }, /* R1378 */
1486 	{ 0x0000, 0x0000, 0x0000 }, /* R1379 */
1487 	{ 0x0000, 0x0000, 0x0000 }, /* R1380 */
1488 	{ 0x0000, 0x0000, 0x0000 }, /* R1381 */
1489 	{ 0x0000, 0x0000, 0x0000 }, /* R1382 */
1490 	{ 0x0000, 0x0000, 0x0000 }, /* R1383 */
1491 	{ 0x0000, 0x0000, 0x0000 }, /* R1384 */
1492 	{ 0x0000, 0x0000, 0x0000 }, /* R1385 */
1493 	{ 0x0000, 0x0000, 0x0000 }, /* R1386 */
1494 	{ 0x0000, 0x0000, 0x0000 }, /* R1387 */
1495 	{ 0x0000, 0x0000, 0x0000 }, /* R1388 */
1496 	{ 0x0000, 0x0000, 0x0000 }, /* R1389 */
1497 	{ 0x0000, 0x0000, 0x0000 }, /* R1390 */
1498 	{ 0x0000, 0x0000, 0x0000 }, /* R1391 */
1499 	{ 0x0000, 0x0000, 0x0000 }, /* R1392 */
1500 	{ 0x0000, 0x0000, 0x0000 }, /* R1393 */
1501 	{ 0x0000, 0x0000, 0x0000 }, /* R1394 */
1502 	{ 0x0000, 0x0000, 0x0000 }, /* R1395 */
1503 	{ 0x0000, 0x0000, 0x0000 }, /* R1396 */
1504 	{ 0x0000, 0x0000, 0x0000 }, /* R1397 */
1505 	{ 0x0000, 0x0000, 0x0000 }, /* R1398 */
1506 	{ 0x0000, 0x0000, 0x0000 }, /* R1399 */
1507 	{ 0x0000, 0x0000, 0x0000 }, /* R1400 */
1508 	{ 0x0000, 0x0000, 0x0000 }, /* R1401 */
1509 	{ 0x0000, 0x0000, 0x0000 }, /* R1402 */
1510 	{ 0x0000, 0x0000, 0x0000 }, /* R1403 */
1511 	{ 0x0000, 0x0000, 0x0000 }, /* R1404 */
1512 	{ 0x0000, 0x0000, 0x0000 }, /* R1405 */
1513 	{ 0x0000, 0x0000, 0x0000 }, /* R1406 */
1514 	{ 0x0000, 0x0000, 0x0000 }, /* R1407 */
1515 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1408  - AIF2 EQ Gains (1) */
1516 	{ 0xFFC0, 0xFFC0, 0x0000 }, /* R1409  - AIF2 EQ Gains (2) */
1517 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1410  - AIF2 EQ Band 1 A */
1518 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1411  - AIF2 EQ Band 1 B */
1519 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1412  - AIF2 EQ Band 1 PG */
1520 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1413  - AIF2 EQ Band 2 A */
1521 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1414  - AIF2 EQ Band 2 B */
1522 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1415  - AIF2 EQ Band 2 C */
1523 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1416  - AIF2 EQ Band 2 PG */
1524 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1417  - AIF2 EQ Band 3 A */
1525 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1418  - AIF2 EQ Band 3 B */
1526 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1419  - AIF2 EQ Band 3 C */
1527 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1420  - AIF2 EQ Band 3 PG */
1528 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1421  - AIF2 EQ Band 4 A */
1529 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1422  - AIF2 EQ Band 4 B */
1530 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1423  - AIF2 EQ Band 4 C */
1531 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1424  - AIF2 EQ Band 4 PG */
1532 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1425  - AIF2 EQ Band 5 A */
1533 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1426  - AIF2 EQ Band 5 B */
1534 	{ 0xFFFF, 0xFFFF, 0x0000 }, /* R1427  - AIF2 EQ Band 5 PG */
1535 	{ 0x0000, 0x0000, 0x0000 }, /* R1428 */
1536 	{ 0x0000, 0x0000, 0x0000 }, /* R1429 */
1537 	{ 0x0000, 0x0000, 0x0000 }, /* R1430 */
1538 	{ 0x0000, 0x0000, 0x0000 }, /* R1431 */
1539 	{ 0x0000, 0x0000, 0x0000 }, /* R1432 */
1540 	{ 0x0000, 0x0000, 0x0000 }, /* R1433 */
1541 	{ 0x0000, 0x0000, 0x0000 }, /* R1434 */
1542 	{ 0x0000, 0x0000, 0x0000 }, /* R1435 */
1543 	{ 0x0000, 0x0000, 0x0000 }, /* R1436 */
1544 	{ 0x0000, 0x0000, 0x0000 }, /* R1437 */
1545 	{ 0x0000, 0x0000, 0x0000 }, /* R1438 */
1546 	{ 0x0000, 0x0000, 0x0000 }, /* R1439 */
1547 	{ 0x0000, 0x0000, 0x0000 }, /* R1440 */
1548 	{ 0x0000, 0x0000, 0x0000 }, /* R1441 */
1549 	{ 0x0000, 0x0000, 0x0000 }, /* R1442 */
1550 	{ 0x0000, 0x0000, 0x0000 }, /* R1443 */
1551 	{ 0x0000, 0x0000, 0x0000 }, /* R1444 */
1552 	{ 0x0000, 0x0000, 0x0000 }, /* R1445 */
1553 	{ 0x0000, 0x0000, 0x0000 }, /* R1446 */
1554 	{ 0x0000, 0x0000, 0x0000 }, /* R1447 */
1555 	{ 0x0000, 0x0000, 0x0000 }, /* R1448 */
1556 	{ 0x0000, 0x0000, 0x0000 }, /* R1449 */
1557 	{ 0x0000, 0x0000, 0x0000 }, /* R1450 */
1558 	{ 0x0000, 0x0000, 0x0000 }, /* R1451 */
1559 	{ 0x0000, 0x0000, 0x0000 }, /* R1452 */
1560 	{ 0x0000, 0x0000, 0x0000 }, /* R1453 */
1561 	{ 0x0000, 0x0000, 0x0000 }, /* R1454 */
1562 	{ 0x0000, 0x0000, 0x0000 }, /* R1455 */
1563 	{ 0x0000, 0x0000, 0x0000 }, /* R1456 */
1564 	{ 0x0000, 0x0000, 0x0000 }, /* R1457 */
1565 	{ 0x0000, 0x0000, 0x0000 }, /* R1458 */
1566 	{ 0x0000, 0x0000, 0x0000 }, /* R1459 */
1567 	{ 0x0000, 0x0000, 0x0000 }, /* R1460 */
1568 	{ 0x0000, 0x0000, 0x0000 }, /* R1461 */
1569 	{ 0x0000, 0x0000, 0x0000 }, /* R1462 */
1570 	{ 0x0000, 0x0000, 0x0000 }, /* R1463 */
1571 	{ 0x0000, 0x0000, 0x0000 }, /* R1464 */
1572 	{ 0x0000, 0x0000, 0x0000 }, /* R1465 */
1573 	{ 0x0000, 0x0000, 0x0000 }, /* R1466 */
1574 	{ 0x0000, 0x0000, 0x0000 }, /* R1467 */
1575 	{ 0x0000, 0x0000, 0x0000 }, /* R1468 */
1576 	{ 0x0000, 0x0000, 0x0000 }, /* R1469 */
1577 	{ 0x0000, 0x0000, 0x0000 }, /* R1470 */
1578 	{ 0x0000, 0x0000, 0x0000 }, /* R1471 */
1579 	{ 0x0000, 0x0000, 0x0000 }, /* R1472 */
1580 	{ 0x0000, 0x0000, 0x0000 }, /* R1473 */
1581 	{ 0x0000, 0x0000, 0x0000 }, /* R1474 */
1582 	{ 0x0000, 0x0000, 0x0000 }, /* R1475 */
1583 	{ 0x0000, 0x0000, 0x0000 }, /* R1476 */
1584 	{ 0x0000, 0x0000, 0x0000 }, /* R1477 */
1585 	{ 0x0000, 0x0000, 0x0000 }, /* R1478 */
1586 	{ 0x0000, 0x0000, 0x0000 }, /* R1479 */
1587 	{ 0x0000, 0x0000, 0x0000 }, /* R1480 */
1588 	{ 0x0000, 0x0000, 0x0000 }, /* R1481 */
1589 	{ 0x0000, 0x0000, 0x0000 }, /* R1482 */
1590 	{ 0x0000, 0x0000, 0x0000 }, /* R1483 */
1591 	{ 0x0000, 0x0000, 0x0000 }, /* R1484 */
1592 	{ 0x0000, 0x0000, 0x0000 }, /* R1485 */
1593 	{ 0x0000, 0x0000, 0x0000 }, /* R1486 */
1594 	{ 0x0000, 0x0000, 0x0000 }, /* R1487 */
1595 	{ 0x0000, 0x0000, 0x0000 }, /* R1488 */
1596 	{ 0x0000, 0x0000, 0x0000 }, /* R1489 */
1597 	{ 0x0000, 0x0000, 0x0000 }, /* R1490 */
1598 	{ 0x0000, 0x0000, 0x0000 }, /* R1491 */
1599 	{ 0x0000, 0x0000, 0x0000 }, /* R1492 */
1600 	{ 0x0000, 0x0000, 0x0000 }, /* R1493 */
1601 	{ 0x0000, 0x0000, 0x0000 }, /* R1494 */
1602 	{ 0x0000, 0x0000, 0x0000 }, /* R1495 */
1603 	{ 0x0000, 0x0000, 0x0000 }, /* R1496 */
1604 	{ 0x0000, 0x0000, 0x0000 }, /* R1497 */
1605 	{ 0x0000, 0x0000, 0x0000 }, /* R1498 */
1606 	{ 0x0000, 0x0000, 0x0000 }, /* R1499 */
1607 	{ 0x0000, 0x0000, 0x0000 }, /* R1500 */
1608 	{ 0x0000, 0x0000, 0x0000 }, /* R1501 */
1609 	{ 0x0000, 0x0000, 0x0000 }, /* R1502 */
1610 	{ 0x0000, 0x0000, 0x0000 }, /* R1503 */
1611 	{ 0x0000, 0x0000, 0x0000 }, /* R1504 */
1612 	{ 0x0000, 0x0000, 0x0000 }, /* R1505 */
1613 	{ 0x0000, 0x0000, 0x0000 }, /* R1506 */
1614 	{ 0x0000, 0x0000, 0x0000 }, /* R1507 */
1615 	{ 0x0000, 0x0000, 0x0000 }, /* R1508 */
1616 	{ 0x0000, 0x0000, 0x0000 }, /* R1509 */
1617 	{ 0x0000, 0x0000, 0x0000 }, /* R1510 */
1618 	{ 0x0000, 0x0000, 0x0000 }, /* R1511 */
1619 	{ 0x0000, 0x0000, 0x0000 }, /* R1512 */
1620 	{ 0x0000, 0x0000, 0x0000 }, /* R1513 */
1621 	{ 0x0000, 0x0000, 0x0000 }, /* R1514 */
1622 	{ 0x0000, 0x0000, 0x0000 }, /* R1515 */
1623 	{ 0x0000, 0x0000, 0x0000 }, /* R1516 */
1624 	{ 0x0000, 0x0000, 0x0000 }, /* R1517 */
1625 	{ 0x0000, 0x0000, 0x0000 }, /* R1518 */
1626 	{ 0x0000, 0x0000, 0x0000 }, /* R1519 */
1627 	{ 0x0000, 0x0000, 0x0000 }, /* R1520 */
1628 	{ 0x0000, 0x0000, 0x0000 }, /* R1521 */
1629 	{ 0x0000, 0x0000, 0x0000 }, /* R1522 */
1630 	{ 0x0000, 0x0000, 0x0000 }, /* R1523 */
1631 	{ 0x0000, 0x0000, 0x0000 }, /* R1524 */
1632 	{ 0x0000, 0x0000, 0x0000 }, /* R1525 */
1633 	{ 0x0000, 0x0000, 0x0000 }, /* R1526 */
1634 	{ 0x0000, 0x0000, 0x0000 }, /* R1527 */
1635 	{ 0x0000, 0x0000, 0x0000 }, /* R1528 */
1636 	{ 0x0000, 0x0000, 0x0000 }, /* R1529 */
1637 	{ 0x0000, 0x0000, 0x0000 }, /* R1530 */
1638 	{ 0x0000, 0x0000, 0x0000 }, /* R1531 */
1639 	{ 0x0000, 0x0000, 0x0000 }, /* R1532 */
1640 	{ 0x0000, 0x0000, 0x0000 }, /* R1533 */
1641 	{ 0x0000, 0x0000, 0x0000 }, /* R1534 */
1642 	{ 0x0000, 0x0000, 0x0000 }, /* R1535 */
1643 	{ 0x01EF, 0x01EF, 0x0000 }, /* R1536  - DAC1 Mixer Volumes */
1644 	{ 0x0037, 0x0037, 0x0000 }, /* R1537  - DAC1 Left Mixer Routing */
1645 	{ 0x0037, 0x0037, 0x0000 }, /* R1538  - DAC1 Right Mixer Routing */
1646 	{ 0x01EF, 0x01EF, 0x0000 }, /* R1539  - DAC2 Mixer Volumes */
1647 	{ 0x0037, 0x0037, 0x0000 }, /* R1540  - DAC2 Left Mixer Routing */
1648 	{ 0x0037, 0x0037, 0x0000 }, /* R1541  - DAC2 Right Mixer Routing */
1649 	{ 0x0003, 0x0003, 0x0000 }, /* R1542  - AIF1 ADC1 Left Mixer Routing */
1650 	{ 0x0003, 0x0003, 0x0000 }, /* R1543  - AIF1 ADC1 Right Mixer Routing */
1651 	{ 0x0003, 0x0003, 0x0000 }, /* R1544  - AIF1 ADC2 Left Mixer Routing */
1652 	{ 0x0003, 0x0003, 0x0000 }, /* R1545  - AIF1 ADC2 Right mixer Routing */
1653 	{ 0x0000, 0x0000, 0x0000 }, /* R1546 */
1654 	{ 0x0000, 0x0000, 0x0000 }, /* R1547 */
1655 	{ 0x0000, 0x0000, 0x0000 }, /* R1548 */
1656 	{ 0x0000, 0x0000, 0x0000 }, /* R1549 */
1657 	{ 0x0000, 0x0000, 0x0000 }, /* R1550 */
1658 	{ 0x0000, 0x0000, 0x0000 }, /* R1551 */
1659 	{ 0x02FF, 0x03FF, 0x0000 }, /* R1552  - DAC1 Left Volume */
1660 	{ 0x02FF, 0x03FF, 0x0000 }, /* R1553  - DAC1 Right Volume */
1661 	{ 0x02FF, 0x03FF, 0x0000 }, /* R1554  - DAC2 Left Volume */
1662 	{ 0x02FF, 0x03FF, 0x0000 }, /* R1555  - DAC2 Right Volume */
1663 	{ 0x0003, 0x0003, 0x0000 }, /* R1556  - DAC Softmute */
1664 	{ 0x0000, 0x0000, 0x0000 }, /* R1557 */
1665 	{ 0x0000, 0x0000, 0x0000 }, /* R1558 */
1666 	{ 0x0000, 0x0000, 0x0000 }, /* R1559 */
1667 	{ 0x0000, 0x0000, 0x0000 }, /* R1560 */
1668 	{ 0x0000, 0x0000, 0x0000 }, /* R1561 */
1669 	{ 0x0000, 0x0000, 0x0000 }, /* R1562 */
1670 	{ 0x0000, 0x0000, 0x0000 }, /* R1563 */
1671 	{ 0x0000, 0x0000, 0x0000 }, /* R1564 */
1672 	{ 0x0000, 0x0000, 0x0000 }, /* R1565 */
1673 	{ 0x0000, 0x0000, 0x0000 }, /* R1566 */
1674 	{ 0x0000, 0x0000, 0x0000 }, /* R1567 */
1675 	{ 0x0003, 0x0003, 0x0000 }, /* R1568  - Oversampling */
1676 	{ 0x03C3, 0x03C3, 0x0000 }, /* R1569  - Sidetone */
1677 };
1678 
1679 static int wm8994_readable(unsigned int reg)
1680 {
1681 	switch (reg) {
1682 	case WM8994_GPIO_1:
1683 	case WM8994_GPIO_2:
1684 	case WM8994_GPIO_3:
1685 	case WM8994_GPIO_4:
1686 	case WM8994_GPIO_5:
1687 	case WM8994_GPIO_6:
1688 	case WM8994_GPIO_7:
1689 	case WM8994_GPIO_8:
1690 	case WM8994_GPIO_9:
1691 	case WM8994_GPIO_10:
1692 	case WM8994_GPIO_11:
1693 	case WM8994_INTERRUPT_STATUS_1:
1694 	case WM8994_INTERRUPT_STATUS_2:
1695 	case WM8994_INTERRUPT_RAW_STATUS_2:
1696 		return 1;
1697 	default:
1698 		break;
1699 	}
1700 
1701 	if (reg >= ARRAY_SIZE(access_masks))
1702 		return 0;
1703 	return access_masks[reg].readable != 0;
1704 }
1705 
1706 static int wm8994_volatile(unsigned int reg)
1707 {
1708 	if (reg >= WM8994_REG_CACHE_SIZE)
1709 		return 1;
1710 
1711 	switch (reg) {
1712 	case WM8994_SOFTWARE_RESET:
1713 	case WM8994_CHIP_REVISION:
1714 	case WM8994_DC_SERVO_1:
1715 	case WM8994_DC_SERVO_READBACK:
1716 	case WM8994_RATE_STATUS:
1717 	case WM8994_LDO_1:
1718 	case WM8994_LDO_2:
1719 		return 1;
1720 	default:
1721 		return 0;
1722 	}
1723 }
1724 
1725 static int wm8994_write(struct snd_soc_codec *codec, unsigned int reg,
1726 	unsigned int value)
1727 {
1728 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1729 
1730 	BUG_ON(reg > WM8994_MAX_REGISTER);
1731 
1732 	if (!wm8994_volatile(reg))
1733 		wm8994->reg_cache[reg] = value;
1734 
1735 	dev_dbg(codec->dev, "0x%x = 0x%x\n", reg, value);
1736 
1737 	return wm8994_reg_write(codec->control_data, reg, value);
1738 }
1739 
1740 static unsigned int wm8994_read(struct snd_soc_codec *codec,
1741 				unsigned int reg)
1742 {
1743 	u16 *reg_cache = codec->reg_cache;
1744 
1745 	BUG_ON(reg > WM8994_MAX_REGISTER);
1746 
1747 	if (wm8994_volatile(reg))
1748 		return wm8994_reg_read(codec->control_data, reg);
1749 	else
1750 		return reg_cache[reg];
1751 }
1752 
1753 static int configure_aif_clock(struct snd_soc_codec *codec, int aif)
1754 {
1755 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1756 	int rate;
1757 	int reg1 = 0;
1758 	int offset;
1759 
1760 	if (aif)
1761 		offset = 4;
1762 	else
1763 		offset = 0;
1764 
1765 	switch (wm8994->sysclk[aif]) {
1766 	case WM8994_SYSCLK_MCLK1:
1767 		rate = wm8994->mclk[0];
1768 		break;
1769 
1770 	case WM8994_SYSCLK_MCLK2:
1771 		reg1 |= 0x8;
1772 		rate = wm8994->mclk[1];
1773 		break;
1774 
1775 	case WM8994_SYSCLK_FLL1:
1776 		reg1 |= 0x10;
1777 		rate = wm8994->fll[0].out;
1778 		break;
1779 
1780 	case WM8994_SYSCLK_FLL2:
1781 		reg1 |= 0x18;
1782 		rate = wm8994->fll[1].out;
1783 		break;
1784 
1785 	default:
1786 		return -EINVAL;
1787 	}
1788 
1789 	if (rate >= 13500000) {
1790 		rate /= 2;
1791 		reg1 |= WM8994_AIF1CLK_DIV;
1792 
1793 		dev_dbg(codec->dev, "Dividing AIF%d clock to %dHz\n",
1794 			aif + 1, rate);
1795 	}
1796 
1797 	if (rate && rate < 3000000)
1798 		dev_warn(codec->dev, "AIF%dCLK is %dHz, should be >=3MHz for optimal performance\n",
1799 			 aif + 1, rate);
1800 
1801 	wm8994->aifclk[aif] = rate;
1802 
1803 	snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1 + offset,
1804 			    WM8994_AIF1CLK_SRC_MASK | WM8994_AIF1CLK_DIV,
1805 			    reg1);
1806 
1807 	return 0;
1808 }
1809 
1810 static int configure_clock(struct snd_soc_codec *codec)
1811 {
1812 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1813 	int old, new;
1814 
1815 	/* Bring up the AIF clocks first */
1816 	configure_aif_clock(codec, 0);
1817 	configure_aif_clock(codec, 1);
1818 
1819 	/* Then switch CLK_SYS over to the higher of them; a change
1820 	 * can only happen as a result of a clocking change which can
1821 	 * only be made outside of DAPM so we can safely redo the
1822 	 * clocking.
1823 	 */
1824 
1825 	/* If they're equal it doesn't matter which is used */
1826 	if (wm8994->aifclk[0] == wm8994->aifclk[1])
1827 		return 0;
1828 
1829 	if (wm8994->aifclk[0] < wm8994->aifclk[1])
1830 		new = WM8994_SYSCLK_SRC;
1831 	else
1832 		new = 0;
1833 
1834 	old = snd_soc_read(codec, WM8994_CLOCKING_1) & WM8994_SYSCLK_SRC;
1835 
1836 	/* If there's no change then we're done. */
1837 	if (old == new)
1838 		return 0;
1839 
1840 	snd_soc_update_bits(codec, WM8994_CLOCKING_1, WM8994_SYSCLK_SRC, new);
1841 
1842 	snd_soc_dapm_sync(codec);
1843 
1844 	return 0;
1845 }
1846 
1847 static int check_clk_sys(struct snd_soc_dapm_widget *source,
1848 			 struct snd_soc_dapm_widget *sink)
1849 {
1850 	int reg = snd_soc_read(source->codec, WM8994_CLOCKING_1);
1851 	const char *clk;
1852 
1853 	/* Check what we're currently using for CLK_SYS */
1854 	if (reg & WM8994_SYSCLK_SRC)
1855 		clk = "AIF2CLK";
1856 	else
1857 		clk = "AIF1CLK";
1858 
1859 	return strcmp(source->name, clk) == 0;
1860 }
1861 
1862 static const char *sidetone_hpf_text[] = {
1863 	"2.7kHz", "1.35kHz", "675Hz", "370Hz", "180Hz", "90Hz", "45Hz"
1864 };
1865 
1866 static const struct soc_enum sidetone_hpf =
1867 	SOC_ENUM_SINGLE(WM8994_SIDETONE, 7, 7, sidetone_hpf_text);
1868 
1869 static const DECLARE_TLV_DB_SCALE(aif_tlv, 0, 600, 0);
1870 static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
1871 static const DECLARE_TLV_DB_SCALE(st_tlv, -3600, 300, 0);
1872 static const DECLARE_TLV_DB_SCALE(wm8994_3d_tlv, -1600, 183, 0);
1873 static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
1874 
1875 #define WM8994_DRC_SWITCH(xname, reg, shift) \
1876 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
1877 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
1878 	.put = wm8994_put_drc_sw, \
1879 	.private_value =  SOC_SINGLE_VALUE(reg, shift, 1, 0) }
1880 
1881 static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol,
1882 			     struct snd_ctl_elem_value *ucontrol)
1883 {
1884 	struct soc_mixer_control *mc =
1885 		(struct soc_mixer_control *)kcontrol->private_value;
1886 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1887 	int mask, ret;
1888 
1889 	/* Can't enable both ADC and DAC paths simultaneously */
1890 	if (mc->shift == WM8994_AIF1DAC1_DRC_ENA_SHIFT)
1891 		mask = WM8994_AIF1ADC1L_DRC_ENA_MASK |
1892 			WM8994_AIF1ADC1R_DRC_ENA_MASK;
1893 	else
1894 		mask = WM8994_AIF1DAC1_DRC_ENA_MASK;
1895 
1896 	ret = snd_soc_read(codec, mc->reg);
1897 	if (ret < 0)
1898 		return ret;
1899 	if (ret & mask)
1900 		return -EINVAL;
1901 
1902 	return snd_soc_put_volsw(kcontrol, ucontrol);
1903 }
1904 
1905 
1906 
1907 static void wm8994_set_drc(struct snd_soc_codec *codec, int drc)
1908 {
1909 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1910 	struct wm8994_pdata *pdata = wm8994->pdata;
1911 	int base = wm8994_drc_base[drc];
1912 	int cfg = wm8994->drc_cfg[drc];
1913 	int save, i;
1914 
1915 	/* Save any enables; the configuration should clear them. */
1916 	save = snd_soc_read(codec, base);
1917 	save &= WM8994_AIF1DAC1_DRC_ENA | WM8994_AIF1ADC1L_DRC_ENA |
1918 		WM8994_AIF1ADC1R_DRC_ENA;
1919 
1920 	for (i = 0; i < WM8994_DRC_REGS; i++)
1921 		snd_soc_update_bits(codec, base + i, 0xffff,
1922 				    pdata->drc_cfgs[cfg].regs[i]);
1923 
1924 	snd_soc_update_bits(codec, base, WM8994_AIF1DAC1_DRC_ENA |
1925 			     WM8994_AIF1ADC1L_DRC_ENA |
1926 			     WM8994_AIF1ADC1R_DRC_ENA, save);
1927 }
1928 
1929 /* Icky as hell but saves code duplication */
1930 static int wm8994_get_drc(const char *name)
1931 {
1932 	if (strcmp(name, "AIF1DRC1 Mode") == 0)
1933 		return 0;
1934 	if (strcmp(name, "AIF1DRC2 Mode") == 0)
1935 		return 1;
1936 	if (strcmp(name, "AIF2DRC Mode") == 0)
1937 		return 2;
1938 	return -EINVAL;
1939 }
1940 
1941 static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol,
1942 			       struct snd_ctl_elem_value *ucontrol)
1943 {
1944 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1945 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1946 	struct wm8994_pdata *pdata = wm8994->pdata;
1947 	int drc = wm8994_get_drc(kcontrol->id.name);
1948 	int value = ucontrol->value.integer.value[0];
1949 
1950 	if (drc < 0)
1951 		return drc;
1952 
1953 	if (value >= pdata->num_drc_cfgs)
1954 		return -EINVAL;
1955 
1956 	wm8994->drc_cfg[drc] = value;
1957 
1958 	wm8994_set_drc(codec, drc);
1959 
1960 	return 0;
1961 }
1962 
1963 static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol,
1964 			       struct snd_ctl_elem_value *ucontrol)
1965 {
1966 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1967 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1968 	int drc = wm8994_get_drc(kcontrol->id.name);
1969 
1970 	ucontrol->value.enumerated.item[0] = wm8994->drc_cfg[drc];
1971 
1972 	return 0;
1973 }
1974 
1975 static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block)
1976 {
1977 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1978 	struct wm8994_pdata *pdata = wm8994->pdata;
1979 	int base = wm8994_retune_mobile_base[block];
1980 	int iface, best, best_val, save, i, cfg;
1981 
1982 	if (!pdata || !wm8994->num_retune_mobile_texts)
1983 		return;
1984 
1985 	switch (block) {
1986 	case 0:
1987 	case 1:
1988 		iface = 0;
1989 		break;
1990 	case 2:
1991 		iface = 1;
1992 		break;
1993 	default:
1994 		return;
1995 	}
1996 
1997 	/* Find the version of the currently selected configuration
1998 	 * with the nearest sample rate. */
1999 	cfg = wm8994->retune_mobile_cfg[block];
2000 	best = 0;
2001 	best_val = INT_MAX;
2002 	for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) {
2003 		if (strcmp(pdata->retune_mobile_cfgs[i].name,
2004 			   wm8994->retune_mobile_texts[cfg]) == 0 &&
2005 		    abs(pdata->retune_mobile_cfgs[i].rate
2006 			- wm8994->dac_rates[iface]) < best_val) {
2007 			best = i;
2008 			best_val = abs(pdata->retune_mobile_cfgs[i].rate
2009 				       - wm8994->dac_rates[iface]);
2010 		}
2011 	}
2012 
2013 	dev_dbg(codec->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n",
2014 		block,
2015 		pdata->retune_mobile_cfgs[best].name,
2016 		pdata->retune_mobile_cfgs[best].rate,
2017 		wm8994->dac_rates[iface]);
2018 
2019 	/* The EQ will be disabled while reconfiguring it, remember the
2020 	 * current configuration.
2021 	 */
2022 	save = snd_soc_read(codec, base);
2023 	save &= WM8994_AIF1DAC1_EQ_ENA;
2024 
2025 	for (i = 0; i < WM8994_EQ_REGS; i++)
2026 		snd_soc_update_bits(codec, base + i, 0xffff,
2027 				pdata->retune_mobile_cfgs[best].regs[i]);
2028 
2029 	snd_soc_update_bits(codec, base, WM8994_AIF1DAC1_EQ_ENA, save);
2030 }
2031 
2032 /* Icky as hell but saves code duplication */
2033 static int wm8994_get_retune_mobile_block(const char *name)
2034 {
2035 	if (strcmp(name, "AIF1.1 EQ Mode") == 0)
2036 		return 0;
2037 	if (strcmp(name, "AIF1.2 EQ Mode") == 0)
2038 		return 1;
2039 	if (strcmp(name, "AIF2 EQ Mode") == 0)
2040 		return 2;
2041 	return -EINVAL;
2042 }
2043 
2044 static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
2045 					 struct snd_ctl_elem_value *ucontrol)
2046 {
2047 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2048 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
2049 	struct wm8994_pdata *pdata = wm8994->pdata;
2050 	int block = wm8994_get_retune_mobile_block(kcontrol->id.name);
2051 	int value = ucontrol->value.integer.value[0];
2052 
2053 	if (block < 0)
2054 		return block;
2055 
2056 	if (value >= pdata->num_retune_mobile_cfgs)
2057 		return -EINVAL;
2058 
2059 	wm8994->retune_mobile_cfg[block] = value;
2060 
2061 	wm8994_set_retune_mobile(codec, block);
2062 
2063 	return 0;
2064 }
2065 
2066 static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol,
2067 					 struct snd_ctl_elem_value *ucontrol)
2068 {
2069 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2070 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
2071 	int block = wm8994_get_retune_mobile_block(kcontrol->id.name);
2072 
2073 	ucontrol->value.enumerated.item[0] = wm8994->retune_mobile_cfg[block];
2074 
2075 	return 0;
2076 }
2077 
2078 static const struct snd_kcontrol_new wm8994_snd_controls[] = {
2079 SOC_DOUBLE_R_TLV("AIF1ADC1 Volume", WM8994_AIF1_ADC1_LEFT_VOLUME,
2080 		 WM8994_AIF1_ADC1_RIGHT_VOLUME,
2081 		 1, 119, 0, digital_tlv),
2082 SOC_DOUBLE_R_TLV("AIF1ADC2 Volume", WM8994_AIF1_ADC2_LEFT_VOLUME,
2083 		 WM8994_AIF1_ADC2_RIGHT_VOLUME,
2084 		 1, 119, 0, digital_tlv),
2085 SOC_DOUBLE_R_TLV("AIF2ADC Volume", WM8994_AIF2_ADC_LEFT_VOLUME,
2086 		 WM8994_AIF2_ADC_RIGHT_VOLUME,
2087 		 1, 119, 0, digital_tlv),
2088 
2089 SOC_DOUBLE_R_TLV("AIF1DAC1 Volume", WM8994_AIF1_DAC1_LEFT_VOLUME,
2090 		 WM8994_AIF1_DAC1_RIGHT_VOLUME, 1, 96, 0, digital_tlv),
2091 SOC_DOUBLE_R_TLV("AIF1DAC2 Volume", WM8994_AIF1_DAC2_LEFT_VOLUME,
2092 		 WM8994_AIF1_DAC2_RIGHT_VOLUME, 1, 96, 0, digital_tlv),
2093 SOC_DOUBLE_R_TLV("AIF2DAC Volume", WM8994_AIF2_DAC_LEFT_VOLUME,
2094 		 WM8994_AIF2_DAC_RIGHT_VOLUME, 1, 96, 0, digital_tlv),
2095 
2096 SOC_SINGLE_TLV("AIF1 Boost Volume", WM8994_AIF1_CONTROL_2, 10, 3, 0, aif_tlv),
2097 SOC_SINGLE_TLV("AIF2 Boost Volume", WM8994_AIF2_CONTROL_2, 10, 3, 0, aif_tlv),
2098 
2099 SOC_SINGLE("AIF1DAC1 EQ Switch", WM8994_AIF1_DAC1_EQ_GAINS_1, 0, 1, 0),
2100 SOC_SINGLE("AIF1DAC2 EQ Switch", WM8994_AIF1_DAC2_EQ_GAINS_1, 0, 1, 0),
2101 SOC_SINGLE("AIF2 EQ Switch", WM8994_AIF2_EQ_GAINS_1, 0, 1, 0),
2102 
2103 WM8994_DRC_SWITCH("AIF1DAC1 DRC Switch", WM8994_AIF1_DRC1_1, 2),
2104 WM8994_DRC_SWITCH("AIF1ADC1L DRC Switch", WM8994_AIF1_DRC1_1, 1),
2105 WM8994_DRC_SWITCH("AIF1ADC1R DRC Switch", WM8994_AIF1_DRC1_1, 0),
2106 
2107 WM8994_DRC_SWITCH("AIF1DAC2 DRC Switch", WM8994_AIF1_DRC2_1, 2),
2108 WM8994_DRC_SWITCH("AIF1ADC2L DRC Switch", WM8994_AIF1_DRC2_1, 1),
2109 WM8994_DRC_SWITCH("AIF1ADC2R DRC Switch", WM8994_AIF1_DRC2_1, 0),
2110 
2111 WM8994_DRC_SWITCH("AIF2DAC DRC Switch", WM8994_AIF2_DRC_1, 2),
2112 WM8994_DRC_SWITCH("AIF2ADCL DRC Switch", WM8994_AIF2_DRC_1, 1),
2113 WM8994_DRC_SWITCH("AIF2ADCR DRC Switch", WM8994_AIF2_DRC_1, 0),
2114 
2115 SOC_SINGLE_TLV("DAC1 Right Sidetone Volume", WM8994_DAC1_MIXER_VOLUMES,
2116 	       5, 12, 0, st_tlv),
2117 SOC_SINGLE_TLV("DAC1 Left Sidetone Volume", WM8994_DAC1_MIXER_VOLUMES,
2118 	       0, 12, 0, st_tlv),
2119 SOC_SINGLE_TLV("DAC2 Right Sidetone Volume", WM8994_DAC2_MIXER_VOLUMES,
2120 	       5, 12, 0, st_tlv),
2121 SOC_SINGLE_TLV("DAC2 Left Sidetone Volume", WM8994_DAC2_MIXER_VOLUMES,
2122 	       0, 12, 0, st_tlv),
2123 SOC_ENUM("Sidetone HPF Mux", sidetone_hpf),
2124 SOC_SINGLE("Sidetone HPF Switch", WM8994_SIDETONE, 6, 1, 0),
2125 
2126 SOC_DOUBLE_R_TLV("DAC1 Volume", WM8994_DAC1_LEFT_VOLUME,
2127 		 WM8994_DAC1_RIGHT_VOLUME, 1, 96, 0, digital_tlv),
2128 SOC_DOUBLE_R("DAC1 Switch", WM8994_DAC1_LEFT_VOLUME,
2129 	     WM8994_DAC1_RIGHT_VOLUME, 9, 1, 1),
2130 
2131 SOC_DOUBLE_R_TLV("DAC2 Volume", WM8994_DAC2_LEFT_VOLUME,
2132 		 WM8994_DAC2_RIGHT_VOLUME, 1, 96, 0, digital_tlv),
2133 SOC_DOUBLE_R("DAC2 Switch", WM8994_DAC2_LEFT_VOLUME,
2134 	     WM8994_DAC2_RIGHT_VOLUME, 9, 1, 1),
2135 
2136 SOC_SINGLE_TLV("SPKL DAC2 Volume", WM8994_SPKMIXL_ATTENUATION,
2137 	       6, 1, 1, wm_hubs_spkmix_tlv),
2138 SOC_SINGLE_TLV("SPKL DAC1 Volume", WM8994_SPKMIXL_ATTENUATION,
2139 	       2, 1, 1, wm_hubs_spkmix_tlv),
2140 
2141 SOC_SINGLE_TLV("SPKR DAC2 Volume", WM8994_SPKMIXR_ATTENUATION,
2142 	       6, 1, 1, wm_hubs_spkmix_tlv),
2143 SOC_SINGLE_TLV("SPKR DAC1 Volume", WM8994_SPKMIXR_ATTENUATION,
2144 	       2, 1, 1, wm_hubs_spkmix_tlv),
2145 
2146 SOC_SINGLE_TLV("AIF1DAC1 3D Stereo Volume", WM8994_AIF1_DAC1_FILTERS_2,
2147 	       10, 15, 0, wm8994_3d_tlv),
2148 SOC_SINGLE("AIF1DAC1 3D Stereo Switch", WM8994_AIF1_DAC2_FILTERS_2,
2149 	   8, 1, 0),
2150 SOC_SINGLE_TLV("AIF1DAC2 3D Stereo Volume", WM8994_AIF1_DAC2_FILTERS_2,
2151 	       10, 15, 0, wm8994_3d_tlv),
2152 SOC_SINGLE("AIF1DAC2 3D Stereo Switch", WM8994_AIF1_DAC2_FILTERS_2,
2153 	   8, 1, 0),
2154 SOC_SINGLE_TLV("AIF2DAC 3D Stereo Volume", WM8994_AIF1_DAC1_FILTERS_2,
2155 	       10, 15, 0, wm8994_3d_tlv),
2156 SOC_SINGLE("AIF2DAC 3D Stereo Switch", WM8994_AIF1_DAC2_FILTERS_2,
2157 	   8, 1, 0),
2158 };
2159 
2160 static const struct snd_kcontrol_new wm8994_eq_controls[] = {
2161 SOC_SINGLE_TLV("AIF1DAC1 EQ1 Volume", WM8994_AIF1_DAC1_EQ_GAINS_1, 11, 31, 0,
2162 	       eq_tlv),
2163 SOC_SINGLE_TLV("AIF1DAC1 EQ2 Volume", WM8994_AIF1_DAC1_EQ_GAINS_1, 6, 31, 0,
2164 	       eq_tlv),
2165 SOC_SINGLE_TLV("AIF1DAC1 EQ3 Volume", WM8994_AIF1_DAC1_EQ_GAINS_1, 1, 31, 0,
2166 	       eq_tlv),
2167 SOC_SINGLE_TLV("AIF1DAC1 EQ4 Volume", WM8994_AIF1_DAC1_EQ_GAINS_2, 11, 31, 0,
2168 	       eq_tlv),
2169 SOC_SINGLE_TLV("AIF1DAC1 EQ5 Volume", WM8994_AIF1_DAC1_EQ_GAINS_2, 6, 31, 0,
2170 	       eq_tlv),
2171 
2172 SOC_SINGLE_TLV("AIF1DAC2 EQ1 Volume", WM8994_AIF1_DAC2_EQ_GAINS_1, 11, 31, 0,
2173 	       eq_tlv),
2174 SOC_SINGLE_TLV("AIF1DAC2 EQ2 Volume", WM8994_AIF1_DAC2_EQ_GAINS_1, 6, 31, 0,
2175 	       eq_tlv),
2176 SOC_SINGLE_TLV("AIF1DAC2 EQ3 Volume", WM8994_AIF1_DAC2_EQ_GAINS_1, 1, 31, 0,
2177 	       eq_tlv),
2178 SOC_SINGLE_TLV("AIF1DAC2 EQ4 Volume", WM8994_AIF1_DAC2_EQ_GAINS_2, 11, 31, 0,
2179 	       eq_tlv),
2180 SOC_SINGLE_TLV("AIF1DAC2 EQ5 Volume", WM8994_AIF1_DAC2_EQ_GAINS_2, 6, 31, 0,
2181 	       eq_tlv),
2182 
2183 SOC_SINGLE_TLV("AIF2 EQ1 Volume", WM8994_AIF2_EQ_GAINS_1, 11, 31, 0,
2184 	       eq_tlv),
2185 SOC_SINGLE_TLV("AIF2 EQ2 Volume", WM8994_AIF2_EQ_GAINS_1, 6, 31, 0,
2186 	       eq_tlv),
2187 SOC_SINGLE_TLV("AIF2 EQ3 Volume", WM8994_AIF2_EQ_GAINS_1, 1, 31, 0,
2188 	       eq_tlv),
2189 SOC_SINGLE_TLV("AIF2 EQ4 Volume", WM8994_AIF2_EQ_GAINS_2, 11, 31, 0,
2190 	       eq_tlv),
2191 SOC_SINGLE_TLV("AIF2 EQ5 Volume", WM8994_AIF2_EQ_GAINS_2, 6, 31, 0,
2192 	       eq_tlv),
2193 };
2194 
2195 static int clk_sys_event(struct snd_soc_dapm_widget *w,
2196 			 struct snd_kcontrol *kcontrol, int event)
2197 {
2198 	struct snd_soc_codec *codec = w->codec;
2199 
2200 	switch (event) {
2201 	case SND_SOC_DAPM_PRE_PMU:
2202 		return configure_clock(codec);
2203 
2204 	case SND_SOC_DAPM_POST_PMD:
2205 		configure_clock(codec);
2206 		break;
2207 	}
2208 
2209 	return 0;
2210 }
2211 
2212 static void wm8994_update_class_w(struct snd_soc_codec *codec)
2213 {
2214 	int enable = 1;
2215 	int source = 0;  /* GCC flow analysis can't track enable */
2216 	int reg, reg_r;
2217 
2218 	/* Only support direct DAC->headphone paths */
2219 	reg = snd_soc_read(codec, WM8994_OUTPUT_MIXER_1);
2220 	if (!(reg & WM8994_DAC1L_TO_HPOUT1L)) {
2221 		dev_vdbg(codec->dev, "HPL connected to output mixer\n");
2222 		enable = 0;
2223 	}
2224 
2225 	reg = snd_soc_read(codec, WM8994_OUTPUT_MIXER_2);
2226 	if (!(reg & WM8994_DAC1R_TO_HPOUT1R)) {
2227 		dev_vdbg(codec->dev, "HPR connected to output mixer\n");
2228 		enable = 0;
2229 	}
2230 
2231 	/* We also need the same setting for L/R and only one path */
2232 	reg = snd_soc_read(codec, WM8994_DAC1_LEFT_MIXER_ROUTING);
2233 	switch (reg) {
2234 	case WM8994_AIF2DACL_TO_DAC1L:
2235 		dev_vdbg(codec->dev, "Class W source AIF2DAC\n");
2236 		source = 2 << WM8994_CP_DYN_SRC_SEL_SHIFT;
2237 		break;
2238 	case WM8994_AIF1DAC2L_TO_DAC1L:
2239 		dev_vdbg(codec->dev, "Class W source AIF1DAC2\n");
2240 		source = 1 << WM8994_CP_DYN_SRC_SEL_SHIFT;
2241 		break;
2242 	case WM8994_AIF1DAC1L_TO_DAC1L:
2243 		dev_vdbg(codec->dev, "Class W source AIF1DAC1\n");
2244 		source = 0 << WM8994_CP_DYN_SRC_SEL_SHIFT;
2245 		break;
2246 	default:
2247 		dev_vdbg(codec->dev, "DAC mixer setting: %x\n", reg);
2248 		enable = 0;
2249 		break;
2250 	}
2251 
2252 	reg_r = snd_soc_read(codec, WM8994_DAC1_RIGHT_MIXER_ROUTING);
2253 	if (reg_r != reg) {
2254 		dev_vdbg(codec->dev, "Left and right DAC mixers different\n");
2255 		enable = 0;
2256 	}
2257 
2258 	if (enable) {
2259 		dev_dbg(codec->dev, "Class W enabled\n");
2260 		snd_soc_update_bits(codec, WM8994_CLASS_W_1,
2261 				    WM8994_CP_DYN_PWR |
2262 				    WM8994_CP_DYN_SRC_SEL_MASK,
2263 				    source | WM8994_CP_DYN_PWR);
2264 
2265 	} else {
2266 		dev_dbg(codec->dev, "Class W disabled\n");
2267 		snd_soc_update_bits(codec, WM8994_CLASS_W_1,
2268 				    WM8994_CP_DYN_PWR, 0);
2269 	}
2270 }
2271 
2272 static const char *hp_mux_text[] = {
2273 	"Mixer",
2274 	"DAC",
2275 };
2276 
2277 #define WM8994_HP_ENUM(xname, xenum) \
2278 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2279 	.info = snd_soc_info_enum_double, \
2280  	.get = snd_soc_dapm_get_enum_double, \
2281  	.put = wm8994_put_hp_enum, \
2282   	.private_value = (unsigned long)&xenum }
2283 
2284 static int wm8994_put_hp_enum(struct snd_kcontrol *kcontrol,
2285 			      struct snd_ctl_elem_value *ucontrol)
2286 {
2287 	struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol);
2288 	struct snd_soc_codec *codec = w->codec;
2289 	int ret;
2290 
2291 	ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
2292 
2293 	wm8994_update_class_w(codec);
2294 
2295 	return ret;
2296 }
2297 
2298 static const struct soc_enum hpl_enum =
2299 	SOC_ENUM_SINGLE(WM8994_OUTPUT_MIXER_1, 8, 2, hp_mux_text);
2300 
2301 static const struct snd_kcontrol_new hpl_mux =
2302 	WM8994_HP_ENUM("Left Headphone Mux", hpl_enum);
2303 
2304 static const struct soc_enum hpr_enum =
2305 	SOC_ENUM_SINGLE(WM8994_OUTPUT_MIXER_2, 8, 2, hp_mux_text);
2306 
2307 static const struct snd_kcontrol_new hpr_mux =
2308 	WM8994_HP_ENUM("Right Headphone Mux", hpr_enum);
2309 
2310 static const char *adc_mux_text[] = {
2311 	"ADC",
2312 	"DMIC",
2313 };
2314 
2315 static const struct soc_enum adc_enum =
2316 	SOC_ENUM_SINGLE(0, 0, 2, adc_mux_text);
2317 
2318 static const struct snd_kcontrol_new adcl_mux =
2319 	SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum);
2320 
2321 static const struct snd_kcontrol_new adcr_mux =
2322 	SOC_DAPM_ENUM_VIRT("ADCR Mux", adc_enum);
2323 
2324 static const struct snd_kcontrol_new left_speaker_mixer[] = {
2325 SOC_DAPM_SINGLE("DAC2 Switch", WM8994_SPEAKER_MIXER, 9, 1, 0),
2326 SOC_DAPM_SINGLE("Input Switch", WM8994_SPEAKER_MIXER, 7, 1, 0),
2327 SOC_DAPM_SINGLE("IN1LP Switch", WM8994_SPEAKER_MIXER, 5, 1, 0),
2328 SOC_DAPM_SINGLE("Output Switch", WM8994_SPEAKER_MIXER, 3, 1, 0),
2329 SOC_DAPM_SINGLE("DAC1 Switch", WM8994_SPEAKER_MIXER, 1, 1, 0),
2330 };
2331 
2332 static const struct snd_kcontrol_new right_speaker_mixer[] = {
2333 SOC_DAPM_SINGLE("DAC2 Switch", WM8994_SPEAKER_MIXER, 8, 1, 0),
2334 SOC_DAPM_SINGLE("Input Switch", WM8994_SPEAKER_MIXER, 6, 1, 0),
2335 SOC_DAPM_SINGLE("IN1RP Switch", WM8994_SPEAKER_MIXER, 4, 1, 0),
2336 SOC_DAPM_SINGLE("Output Switch", WM8994_SPEAKER_MIXER, 2, 1, 0),
2337 SOC_DAPM_SINGLE("DAC1 Switch", WM8994_SPEAKER_MIXER, 0, 1, 0),
2338 };
2339 
2340 /* Debugging; dump chip status after DAPM transitions */
2341 static int post_ev(struct snd_soc_dapm_widget *w,
2342 	    struct snd_kcontrol *kcontrol, int event)
2343 {
2344 	struct snd_soc_codec *codec = w->codec;
2345 	dev_dbg(codec->dev, "SRC status: %x\n",
2346 		snd_soc_read(codec,
2347 			     WM8994_RATE_STATUS));
2348 	return 0;
2349 }
2350 
2351 static const struct snd_kcontrol_new aif1adc1l_mix[] = {
2352 SOC_DAPM_SINGLE("ADC/DMIC Switch", WM8994_AIF1_ADC1_LEFT_MIXER_ROUTING,
2353 		1, 1, 0),
2354 SOC_DAPM_SINGLE("AIF2 Switch", WM8994_AIF1_ADC1_LEFT_MIXER_ROUTING,
2355 		0, 1, 0),
2356 };
2357 
2358 static const struct snd_kcontrol_new aif1adc1r_mix[] = {
2359 SOC_DAPM_SINGLE("ADC/DMIC Switch", WM8994_AIF1_ADC1_RIGHT_MIXER_ROUTING,
2360 		1, 1, 0),
2361 SOC_DAPM_SINGLE("AIF2 Switch", WM8994_AIF1_ADC1_RIGHT_MIXER_ROUTING,
2362 		0, 1, 0),
2363 };
2364 
2365 static const struct snd_kcontrol_new aif1adc2l_mix[] = {
2366 SOC_DAPM_SINGLE("DMIC Switch", WM8994_AIF1_ADC2_LEFT_MIXER_ROUTING,
2367 		1, 1, 0),
2368 SOC_DAPM_SINGLE("AIF2 Switch", WM8994_AIF1_ADC2_LEFT_MIXER_ROUTING,
2369 		0, 1, 0),
2370 };
2371 
2372 static const struct snd_kcontrol_new aif1adc2r_mix[] = {
2373 SOC_DAPM_SINGLE("DMIC Switch", WM8994_AIF1_ADC2_RIGHT_MIXER_ROUTING,
2374 		1, 1, 0),
2375 SOC_DAPM_SINGLE("AIF2 Switch", WM8994_AIF1_ADC2_RIGHT_MIXER_ROUTING,
2376 		0, 1, 0),
2377 };
2378 
2379 static const struct snd_kcontrol_new aif2dac2l_mix[] = {
2380 SOC_DAPM_SINGLE("Right Sidetone Switch", WM8994_DAC2_LEFT_MIXER_ROUTING,
2381 		5, 1, 0),
2382 SOC_DAPM_SINGLE("Left Sidetone Switch", WM8994_DAC2_LEFT_MIXER_ROUTING,
2383 		4, 1, 0),
2384 SOC_DAPM_SINGLE("AIF2 Switch", WM8994_DAC2_LEFT_MIXER_ROUTING,
2385 		2, 1, 0),
2386 SOC_DAPM_SINGLE("AIF1.2 Switch", WM8994_DAC2_LEFT_MIXER_ROUTING,
2387 		1, 1, 0),
2388 SOC_DAPM_SINGLE("AIF1.1 Switch", WM8994_DAC2_LEFT_MIXER_ROUTING,
2389 		0, 1, 0),
2390 };
2391 
2392 static const struct snd_kcontrol_new aif2dac2r_mix[] = {
2393 SOC_DAPM_SINGLE("Right Sidetone Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING,
2394 		5, 1, 0),
2395 SOC_DAPM_SINGLE("Left Sidetone Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING,
2396 		4, 1, 0),
2397 SOC_DAPM_SINGLE("AIF2 Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING,
2398 		2, 1, 0),
2399 SOC_DAPM_SINGLE("AIF1.2 Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING,
2400 		1, 1, 0),
2401 SOC_DAPM_SINGLE("AIF1.1 Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING,
2402 		0, 1, 0),
2403 };
2404 
2405 #define WM8994_CLASS_W_SWITCH(xname, reg, shift, max, invert) \
2406 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
2407 	.info = snd_soc_info_volsw, \
2408 	.get = snd_soc_dapm_get_volsw, .put = wm8994_put_class_w, \
2409 	.private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) }
2410 
2411 static int wm8994_put_class_w(struct snd_kcontrol *kcontrol,
2412 			      struct snd_ctl_elem_value *ucontrol)
2413 {
2414 	struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol);
2415 	struct snd_soc_codec *codec = w->codec;
2416 	int ret;
2417 
2418 	ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol);
2419 
2420 	wm8994_update_class_w(codec);
2421 
2422 	return ret;
2423 }
2424 
2425 static const struct snd_kcontrol_new dac1l_mix[] = {
2426 WM8994_CLASS_W_SWITCH("Right Sidetone Switch", WM8994_DAC1_LEFT_MIXER_ROUTING,
2427 		      5, 1, 0),
2428 WM8994_CLASS_W_SWITCH("Left Sidetone Switch", WM8994_DAC1_LEFT_MIXER_ROUTING,
2429 		      4, 1, 0),
2430 WM8994_CLASS_W_SWITCH("AIF2 Switch", WM8994_DAC1_LEFT_MIXER_ROUTING,
2431 		      2, 1, 0),
2432 WM8994_CLASS_W_SWITCH("AIF1.2 Switch", WM8994_DAC1_LEFT_MIXER_ROUTING,
2433 		      1, 1, 0),
2434 WM8994_CLASS_W_SWITCH("AIF1.1 Switch", WM8994_DAC1_LEFT_MIXER_ROUTING,
2435 		      0, 1, 0),
2436 };
2437 
2438 static const struct snd_kcontrol_new dac1r_mix[] = {
2439 WM8994_CLASS_W_SWITCH("Right Sidetone Switch", WM8994_DAC1_RIGHT_MIXER_ROUTING,
2440 		      5, 1, 0),
2441 WM8994_CLASS_W_SWITCH("Left Sidetone Switch", WM8994_DAC1_RIGHT_MIXER_ROUTING,
2442 		      4, 1, 0),
2443 WM8994_CLASS_W_SWITCH("AIF2 Switch", WM8994_DAC1_RIGHT_MIXER_ROUTING,
2444 		      2, 1, 0),
2445 WM8994_CLASS_W_SWITCH("AIF1.2 Switch", WM8994_DAC1_RIGHT_MIXER_ROUTING,
2446 		      1, 1, 0),
2447 WM8994_CLASS_W_SWITCH("AIF1.1 Switch", WM8994_DAC1_RIGHT_MIXER_ROUTING,
2448 		      0, 1, 0),
2449 };
2450 
2451 static const char *sidetone_text[] = {
2452 	"ADC/DMIC1", "DMIC2",
2453 };
2454 
2455 static const struct soc_enum sidetone1_enum =
2456 	SOC_ENUM_SINGLE(WM8994_SIDETONE, 0, 2, sidetone_text);
2457 
2458 static const struct snd_kcontrol_new sidetone1_mux =
2459 	SOC_DAPM_ENUM("Left Sidetone Mux", sidetone1_enum);
2460 
2461 static const struct soc_enum sidetone2_enum =
2462 	SOC_ENUM_SINGLE(WM8994_SIDETONE, 1, 2, sidetone_text);
2463 
2464 static const struct snd_kcontrol_new sidetone2_mux =
2465 	SOC_DAPM_ENUM("Right Sidetone Mux", sidetone2_enum);
2466 
2467 static const char *aif1dac_text[] = {
2468 	"AIF1DACDAT", "AIF3DACDAT",
2469 };
2470 
2471 static const struct soc_enum aif1dac_enum =
2472 	SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 0, 2, aif1dac_text);
2473 
2474 static const struct snd_kcontrol_new aif1dac_mux =
2475 	SOC_DAPM_ENUM("AIF1DAC Mux", aif1dac_enum);
2476 
2477 static const char *aif2dac_text[] = {
2478 	"AIF2DACDAT", "AIF3DACDAT",
2479 };
2480 
2481 static const struct soc_enum aif2dac_enum =
2482 	SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 1, 2, aif2dac_text);
2483 
2484 static const struct snd_kcontrol_new aif2dac_mux =
2485 	SOC_DAPM_ENUM("AIF2DAC Mux", aif2dac_enum);
2486 
2487 static const char *aif2adc_text[] = {
2488 	"AIF2ADCDAT", "AIF3DACDAT",
2489 };
2490 
2491 static const struct soc_enum aif2adc_enum =
2492 	SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 2, 2, aif2adc_text);
2493 
2494 static const struct snd_kcontrol_new aif2adc_mux =
2495 	SOC_DAPM_ENUM("AIF2ADC Mux", aif2adc_enum);
2496 
2497 static const char *aif3adc_text[] = {
2498 	"AIF1ADCDAT", "AIF2ADCDAT", "AIF2DACDAT",
2499 };
2500 
2501 static const struct soc_enum aif3adc_enum =
2502 	SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 3, 3, aif3adc_text);
2503 
2504 static const struct snd_kcontrol_new aif3adc_mux =
2505 	SOC_DAPM_ENUM("AIF3ADC Mux", aif3adc_enum);
2506 
2507 static const struct snd_soc_dapm_widget wm8994_dapm_widgets[] = {
2508 SND_SOC_DAPM_INPUT("DMIC1DAT"),
2509 SND_SOC_DAPM_INPUT("DMIC2DAT"),
2510 SND_SOC_DAPM_INPUT("Clock"),
2511 
2512 SND_SOC_DAPM_SUPPLY("CLK_SYS", SND_SOC_NOPM, 0, 0, clk_sys_event,
2513 		    SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
2514 
2515 SND_SOC_DAPM_SUPPLY("DSP1CLK", WM8994_CLOCKING_1, 3, 0, NULL, 0),
2516 SND_SOC_DAPM_SUPPLY("DSP2CLK", WM8994_CLOCKING_1, 2, 0, NULL, 0),
2517 SND_SOC_DAPM_SUPPLY("DSPINTCLK", WM8994_CLOCKING_1, 1, 0, NULL, 0),
2518 
2519 SND_SOC_DAPM_SUPPLY("AIF1CLK", WM8994_AIF1_CLOCKING_1, 0, 0, NULL, 0),
2520 SND_SOC_DAPM_SUPPLY("AIF2CLK", WM8994_AIF2_CLOCKING_1, 0, 0, NULL, 0),
2521 
2522 SND_SOC_DAPM_AIF_OUT("AIF1ADC1L", "AIF1 Capture",
2523 		     0, WM8994_POWER_MANAGEMENT_4, 9, 0),
2524 SND_SOC_DAPM_AIF_OUT("AIF1ADC1R", "AIF1 Capture",
2525 		     0, WM8994_POWER_MANAGEMENT_4, 8, 0),
2526 SND_SOC_DAPM_AIF_IN("AIF1DAC1L", NULL, 0,
2527 		    WM8994_POWER_MANAGEMENT_5, 9, 0),
2528 SND_SOC_DAPM_AIF_IN("AIF1DAC1R", NULL, 0,
2529 		    WM8994_POWER_MANAGEMENT_5, 8, 0),
2530 
2531 SND_SOC_DAPM_AIF_OUT("AIF1ADC2L", "AIF1 Capture",
2532 		     0, WM8994_POWER_MANAGEMENT_4, 11, 0),
2533 SND_SOC_DAPM_AIF_OUT("AIF1ADC2R", "AIF1 Capture",
2534 		     0, WM8994_POWER_MANAGEMENT_4, 10, 0),
2535 SND_SOC_DAPM_AIF_IN("AIF1DAC2L", NULL, 0,
2536 		    WM8994_POWER_MANAGEMENT_5, 11, 0),
2537 SND_SOC_DAPM_AIF_IN("AIF1DAC2R", NULL, 0,
2538 		    WM8994_POWER_MANAGEMENT_5, 10, 0),
2539 
2540 SND_SOC_DAPM_MIXER("AIF1ADC1L Mixer", SND_SOC_NOPM, 0, 0,
2541 		   aif1adc1l_mix, ARRAY_SIZE(aif1adc1l_mix)),
2542 SND_SOC_DAPM_MIXER("AIF1ADC1R Mixer", SND_SOC_NOPM, 0, 0,
2543 		   aif1adc1r_mix, ARRAY_SIZE(aif1adc1r_mix)),
2544 
2545 SND_SOC_DAPM_MIXER("AIF1ADC2L Mixer", SND_SOC_NOPM, 0, 0,
2546 		   aif1adc2l_mix, ARRAY_SIZE(aif1adc2l_mix)),
2547 SND_SOC_DAPM_MIXER("AIF1ADC2R Mixer", SND_SOC_NOPM, 0, 0,
2548 		   aif1adc2r_mix, ARRAY_SIZE(aif1adc2r_mix)),
2549 
2550 SND_SOC_DAPM_MIXER("AIF2DAC2L Mixer", SND_SOC_NOPM, 0, 0,
2551 		   aif2dac2l_mix, ARRAY_SIZE(aif2dac2l_mix)),
2552 SND_SOC_DAPM_MIXER("AIF2DAC2R Mixer", SND_SOC_NOPM, 0, 0,
2553 		   aif2dac2r_mix, ARRAY_SIZE(aif2dac2r_mix)),
2554 
2555 SND_SOC_DAPM_MUX("Left Sidetone", SND_SOC_NOPM, 0, 0, &sidetone1_mux),
2556 SND_SOC_DAPM_MUX("Right Sidetone", SND_SOC_NOPM, 0, 0, &sidetone2_mux),
2557 
2558 SND_SOC_DAPM_MIXER("DAC1L Mixer", SND_SOC_NOPM, 0, 0,
2559 		   dac1l_mix, ARRAY_SIZE(dac1l_mix)),
2560 SND_SOC_DAPM_MIXER("DAC1R Mixer", SND_SOC_NOPM, 0, 0,
2561 		   dac1r_mix, ARRAY_SIZE(dac1r_mix)),
2562 
2563 SND_SOC_DAPM_AIF_OUT("AIF2ADCL", NULL, 0,
2564 		     WM8994_POWER_MANAGEMENT_4, 13, 0),
2565 SND_SOC_DAPM_AIF_OUT("AIF2ADCR", NULL, 0,
2566 		     WM8994_POWER_MANAGEMENT_4, 12, 0),
2567 SND_SOC_DAPM_AIF_IN("AIF2DACL", NULL, 0,
2568 		    WM8994_POWER_MANAGEMENT_5, 13, 0),
2569 SND_SOC_DAPM_AIF_IN("AIF2DACR", NULL, 0,
2570 		    WM8994_POWER_MANAGEMENT_5, 12, 0),
2571 
2572 SND_SOC_DAPM_AIF_IN("AIF1DACDAT", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
2573 SND_SOC_DAPM_AIF_IN("AIF2DACDAT", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
2574 SND_SOC_DAPM_AIF_OUT("AIF2ADCDAT", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
2575 
2576 SND_SOC_DAPM_MUX("AIF1DAC Mux", SND_SOC_NOPM, 0, 0, &aif1dac_mux),
2577 SND_SOC_DAPM_MUX("AIF2DAC Mux", SND_SOC_NOPM, 0, 0, &aif2dac_mux),
2578 SND_SOC_DAPM_MUX("AIF2ADC Mux", SND_SOC_NOPM, 0, 0, &aif2adc_mux),
2579 SND_SOC_DAPM_MUX("AIF3ADC Mux", SND_SOC_NOPM, 0, 0, &aif3adc_mux),
2580 
2581 SND_SOC_DAPM_AIF_IN("AIF3DACDAT", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
2582 SND_SOC_DAPM_AIF_IN("AIF3ADCDAT", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
2583 
2584 SND_SOC_DAPM_SUPPLY("TOCLK", WM8994_CLOCKING_1, 4, 0, NULL, 0),
2585 
2586 SND_SOC_DAPM_ADC("DMIC2L", NULL, WM8994_POWER_MANAGEMENT_4, 5, 0),
2587 SND_SOC_DAPM_ADC("DMIC2R", NULL, WM8994_POWER_MANAGEMENT_4, 4, 0),
2588 SND_SOC_DAPM_ADC("DMIC1L", NULL, WM8994_POWER_MANAGEMENT_4, 3, 0),
2589 SND_SOC_DAPM_ADC("DMIC1R", NULL, WM8994_POWER_MANAGEMENT_4, 2, 0),
2590 
2591 /* Power is done with the muxes since the ADC power also controls the
2592  * downsampling chain, the chip will automatically manage the analogue
2593  * specific portions.
2594  */
2595 SND_SOC_DAPM_ADC("ADCL", NULL, SND_SOC_NOPM, 1, 0),
2596 SND_SOC_DAPM_ADC("ADCR", NULL, SND_SOC_NOPM, 0, 0),
2597 
2598 SND_SOC_DAPM_MUX("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux),
2599 SND_SOC_DAPM_MUX("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux),
2600 
2601 SND_SOC_DAPM_DAC("DAC2L", NULL, WM8994_POWER_MANAGEMENT_5, 3, 0),
2602 SND_SOC_DAPM_DAC("DAC2R", NULL, WM8994_POWER_MANAGEMENT_5, 2, 0),
2603 SND_SOC_DAPM_DAC("DAC1L", NULL, WM8994_POWER_MANAGEMENT_5, 1, 0),
2604 SND_SOC_DAPM_DAC("DAC1R", NULL, WM8994_POWER_MANAGEMENT_5, 0, 0),
2605 
2606 SND_SOC_DAPM_MUX("Left Headphone Mux", SND_SOC_NOPM, 0, 0, &hpl_mux),
2607 SND_SOC_DAPM_MUX("Right Headphone Mux", SND_SOC_NOPM, 0, 0, &hpr_mux),
2608 
2609 SND_SOC_DAPM_MIXER("SPKL", WM8994_POWER_MANAGEMENT_3, 8, 0,
2610 		   left_speaker_mixer, ARRAY_SIZE(left_speaker_mixer)),
2611 SND_SOC_DAPM_MIXER("SPKR", WM8994_POWER_MANAGEMENT_3, 9, 0,
2612 		   right_speaker_mixer, ARRAY_SIZE(right_speaker_mixer)),
2613 
2614 SND_SOC_DAPM_POST("Debug log", post_ev),
2615 };
2616 
2617 static const struct snd_soc_dapm_route intercon[] = {
2618 
2619 	{ "CLK_SYS", NULL, "AIF1CLK", check_clk_sys },
2620 	{ "CLK_SYS", NULL, "AIF2CLK", check_clk_sys },
2621 
2622 	{ "DSP1CLK", NULL, "CLK_SYS" },
2623 	{ "DSP2CLK", NULL, "CLK_SYS" },
2624 	{ "DSPINTCLK", NULL, "CLK_SYS" },
2625 
2626 	{ "AIF1ADC1L", NULL, "AIF1CLK" },
2627 	{ "AIF1ADC1L", NULL, "DSP1CLK" },
2628 	{ "AIF1ADC1R", NULL, "AIF1CLK" },
2629 	{ "AIF1ADC1R", NULL, "DSP1CLK" },
2630 	{ "AIF1ADC1R", NULL, "DSPINTCLK" },
2631 
2632 	{ "AIF1DAC1L", NULL, "AIF1CLK" },
2633 	{ "AIF1DAC1L", NULL, "DSP1CLK" },
2634 	{ "AIF1DAC1R", NULL, "AIF1CLK" },
2635 	{ "AIF1DAC1R", NULL, "DSP1CLK" },
2636 	{ "AIF1DAC1R", NULL, "DSPINTCLK" },
2637 
2638 	{ "AIF1ADC2L", NULL, "AIF1CLK" },
2639 	{ "AIF1ADC2L", NULL, "DSP1CLK" },
2640 	{ "AIF1ADC2R", NULL, "AIF1CLK" },
2641 	{ "AIF1ADC2R", NULL, "DSP1CLK" },
2642 	{ "AIF1ADC2R", NULL, "DSPINTCLK" },
2643 
2644 	{ "AIF1DAC2L", NULL, "AIF1CLK" },
2645 	{ "AIF1DAC2L", NULL, "DSP1CLK" },
2646 	{ "AIF1DAC2R", NULL, "AIF1CLK" },
2647 	{ "AIF1DAC2R", NULL, "DSP1CLK" },
2648 	{ "AIF1DAC2R", NULL, "DSPINTCLK" },
2649 
2650 	{ "AIF2ADCL", NULL, "AIF2CLK" },
2651 	{ "AIF2ADCL", NULL, "DSP2CLK" },
2652 	{ "AIF2ADCR", NULL, "AIF2CLK" },
2653 	{ "AIF2ADCR", NULL, "DSP2CLK" },
2654 	{ "AIF2ADCR", NULL, "DSPINTCLK" },
2655 
2656 	{ "AIF2DACL", NULL, "AIF2CLK" },
2657 	{ "AIF2DACL", NULL, "DSP2CLK" },
2658 	{ "AIF2DACR", NULL, "AIF2CLK" },
2659 	{ "AIF2DACR", NULL, "DSP2CLK" },
2660 	{ "AIF2DACR", NULL, "DSPINTCLK" },
2661 
2662 	{ "DMIC1L", NULL, "DMIC1DAT" },
2663 	{ "DMIC1L", NULL, "CLK_SYS" },
2664 	{ "DMIC1R", NULL, "DMIC1DAT" },
2665 	{ "DMIC1R", NULL, "CLK_SYS" },
2666 	{ "DMIC2L", NULL, "DMIC2DAT" },
2667 	{ "DMIC2L", NULL, "CLK_SYS" },
2668 	{ "DMIC2R", NULL, "DMIC2DAT" },
2669 	{ "DMIC2R", NULL, "CLK_SYS" },
2670 
2671 	{ "ADCL", NULL, "AIF1CLK" },
2672 	{ "ADCL", NULL, "DSP1CLK" },
2673 	{ "ADCL", NULL, "DSPINTCLK" },
2674 
2675 	{ "ADCR", NULL, "AIF1CLK" },
2676 	{ "ADCR", NULL, "DSP1CLK" },
2677 	{ "ADCR", NULL, "DSPINTCLK" },
2678 
2679 	{ "ADCL Mux", "ADC", "ADCL" },
2680 	{ "ADCL Mux", "DMIC", "DMIC1L" },
2681 	{ "ADCR Mux", "ADC", "ADCR" },
2682 	{ "ADCR Mux", "DMIC", "DMIC1R" },
2683 
2684 	{ "DAC1L", NULL, "AIF1CLK" },
2685 	{ "DAC1L", NULL, "DSP1CLK" },
2686 	{ "DAC1L", NULL, "DSPINTCLK" },
2687 
2688 	{ "DAC1R", NULL, "AIF1CLK" },
2689 	{ "DAC1R", NULL, "DSP1CLK" },
2690 	{ "DAC1R", NULL, "DSPINTCLK" },
2691 
2692 	{ "DAC2L", NULL, "AIF2CLK" },
2693 	{ "DAC2L", NULL, "DSP2CLK" },
2694 	{ "DAC2L", NULL, "DSPINTCLK" },
2695 
2696 	{ "DAC2R", NULL, "AIF2DACR" },
2697 	{ "DAC2R", NULL, "AIF2CLK" },
2698 	{ "DAC2R", NULL, "DSP2CLK" },
2699 	{ "DAC2R", NULL, "DSPINTCLK" },
2700 
2701 	{ "TOCLK", NULL, "CLK_SYS" },
2702 
2703 	/* AIF1 outputs */
2704 	{ "AIF1ADC1L", NULL, "AIF1ADC1L Mixer" },
2705 	{ "AIF1ADC1L Mixer", "ADC/DMIC Switch", "ADCL Mux" },
2706 	{ "AIF1ADC1L Mixer", "AIF2 Switch", "AIF2DACL" },
2707 
2708 	{ "AIF1ADC1R", NULL, "AIF1ADC1R Mixer" },
2709 	{ "AIF1ADC1R Mixer", "ADC/DMIC Switch", "ADCR Mux" },
2710 	{ "AIF1ADC1R Mixer", "AIF2 Switch", "AIF2DACR" },
2711 
2712 	{ "AIF1ADC2L", NULL, "AIF1ADC2L Mixer" },
2713 	{ "AIF1ADC2L Mixer", "DMIC Switch", "DMIC2L" },
2714 	{ "AIF1ADC2L Mixer", "AIF2 Switch", "AIF2DACL" },
2715 
2716 	{ "AIF1ADC2R", NULL, "AIF1ADC2R Mixer" },
2717 	{ "AIF1ADC2R Mixer", "DMIC Switch", "DMIC2R" },
2718 	{ "AIF1ADC2R Mixer", "AIF2 Switch", "AIF2DACR" },
2719 
2720 	/* Pin level routing for AIF3 */
2721 	{ "AIF1DAC1L", NULL, "AIF1DAC Mux" },
2722 	{ "AIF1DAC1R", NULL, "AIF1DAC Mux" },
2723 	{ "AIF1DAC2L", NULL, "AIF1DAC Mux" },
2724 	{ "AIF1DAC2R", NULL, "AIF1DAC Mux" },
2725 
2726 	{ "AIF2DACL", NULL, "AIF2DAC Mux" },
2727 	{ "AIF2DACR", NULL, "AIF2DAC Mux" },
2728 
2729 	{ "AIF1DAC Mux", "AIF1DACDAT", "AIF1DACDAT" },
2730 	{ "AIF1DAC Mux", "AIF3DACDAT", "AIF3DACDAT" },
2731 	{ "AIF2DAC Mux", "AIF2DACDAT", "AIF2DACDAT" },
2732 	{ "AIF2DAC Mux", "AIF3DACDAT", "AIF3DACDAT" },
2733 	{ "AIF2ADC Mux", "AIF2ADCDAT", "AIF2ADCL" },
2734 	{ "AIF2ADC Mux", "AIF2ADCDAT", "AIF2ADCR" },
2735 	{ "AIF2ADC Mux", "AIF3DACDAT", "AIF3ADCDAT" },
2736 
2737 	/* DAC1 inputs */
2738 	{ "DAC1L", NULL, "DAC1L Mixer" },
2739 	{ "DAC1L Mixer", "AIF2 Switch", "AIF2DACL" },
2740 	{ "DAC1L Mixer", "AIF1.2 Switch", "AIF1DAC2L" },
2741 	{ "DAC1L Mixer", "AIF1.1 Switch", "AIF1DAC1L" },
2742 	{ "DAC1L Mixer", "Left Sidetone Switch", "Left Sidetone" },
2743 	{ "DAC1L Mixer", "Right Sidetone Switch", "Right Sidetone" },
2744 
2745 	{ "DAC1R", NULL, "DAC1R Mixer" },
2746 	{ "DAC1R Mixer", "AIF2 Switch", "AIF2DACR" },
2747 	{ "DAC1R Mixer", "AIF1.2 Switch", "AIF1DAC2R" },
2748 	{ "DAC1R Mixer", "AIF1.1 Switch", "AIF1DAC1R" },
2749 	{ "DAC1R Mixer", "Left Sidetone Switch", "Left Sidetone" },
2750 	{ "DAC1R Mixer", "Right Sidetone Switch", "Right Sidetone" },
2751 
2752 	/* DAC2/AIF2 outputs  */
2753 	{ "AIF2ADCL", NULL, "AIF2DAC2L Mixer" },
2754 	{ "DAC2L", NULL, "AIF2DAC2L Mixer" },
2755 	{ "AIF2DAC2L Mixer", "AIF2 Switch", "AIF2DACL" },
2756 	{ "AIF2DAC2L Mixer", "AIF1.2 Switch", "AIF1DAC2L" },
2757 	{ "AIF2DAC2L Mixer", "AIF1.1 Switch", "AIF1DAC1L" },
2758 	{ "AIF2DAC2L Mixer", "Left Sidetone Switch", "Left Sidetone" },
2759 	{ "AIF2DAC2L Mixer", "Right Sidetone Switch", "Right Sidetone" },
2760 
2761 	{ "AIF2ADCR", NULL, "AIF2DAC2R Mixer" },
2762 	{ "DAC2R", NULL, "AIF2DAC2R Mixer" },
2763 	{ "AIF2DAC2R Mixer", "AIF2 Switch", "AIF2DACR" },
2764 	{ "AIF2DAC2R Mixer", "AIF1.2 Switch", "AIF1DAC2R" },
2765 	{ "AIF2DAC2R Mixer", "AIF1.1 Switch", "AIF1DAC1R" },
2766 	{ "AIF2DAC2R Mixer", "Left Sidetone Switch", "Left Sidetone" },
2767 	{ "AIF2DAC2R Mixer", "Right Sidetone Switch", "Right Sidetone" },
2768 
2769 	{ "AIF2ADCDAT", NULL, "AIF2ADC Mux" },
2770 
2771 	/* AIF3 output */
2772 	{ "AIF3ADCDAT", "AIF1ADCDAT", "AIF1ADC1L" },
2773 	{ "AIF3ADCDAT", "AIF1ADCDAT", "AIF1ADC1R" },
2774 	{ "AIF3ADCDAT", "AIF1ADCDAT", "AIF1ADC2L" },
2775 	{ "AIF3ADCDAT", "AIF1ADCDAT", "AIF1ADC2R" },
2776 	{ "AIF3ADCDAT", "AIF2ADCDAT", "AIF2ADCL" },
2777 	{ "AIF3ADCDAT", "AIF2ADCDAT", "AIF2ADCR" },
2778 	{ "AIF3ADCDAT", "AIF2DACDAT", "AIF2DACL" },
2779 	{ "AIF3ADCDAT", "AIF2DACDAT", "AIF2DACR" },
2780 
2781 	/* Sidetone */
2782 	{ "Left Sidetone", "ADC/DMIC1", "ADCL Mux" },
2783 	{ "Left Sidetone", "DMIC2", "DMIC2L" },
2784 	{ "Right Sidetone", "ADC/DMIC1", "ADCR Mux" },
2785 	{ "Right Sidetone", "DMIC2", "DMIC2R" },
2786 
2787 	/* Output stages */
2788 	{ "Left Output Mixer", "DAC Switch", "DAC1L" },
2789 	{ "Right Output Mixer", "DAC Switch", "DAC1R" },
2790 
2791 	{ "SPKL", "DAC1 Switch", "DAC1L" },
2792 	{ "SPKL", "DAC2 Switch", "DAC2L" },
2793 
2794 	{ "SPKR", "DAC1 Switch", "DAC1R" },
2795 	{ "SPKR", "DAC2 Switch", "DAC2R" },
2796 
2797 	{ "Left Headphone Mux", "DAC", "DAC1L" },
2798 	{ "Right Headphone Mux", "DAC", "DAC1R" },
2799 };
2800 
2801 /* The size in bits of the FLL divide multiplied by 10
2802  * to allow rounding later */
2803 #define FIXED_FLL_SIZE ((1 << 16) * 10)
2804 
2805 struct fll_div {
2806 	u16 outdiv;
2807 	u16 n;
2808 	u16 k;
2809 	u16 clk_ref_div;
2810 	u16 fll_fratio;
2811 };
2812 
2813 static int wm8994_get_fll_config(struct fll_div *fll,
2814 				 int freq_in, int freq_out)
2815 {
2816 	u64 Kpart;
2817 	unsigned int K, Ndiv, Nmod;
2818 
2819 	pr_debug("FLL input=%dHz, output=%dHz\n", freq_in, freq_out);
2820 
2821 	/* Scale the input frequency down to <= 13.5MHz */
2822 	fll->clk_ref_div = 0;
2823 	while (freq_in > 13500000) {
2824 		fll->clk_ref_div++;
2825 		freq_in /= 2;
2826 
2827 		if (fll->clk_ref_div > 3)
2828 			return -EINVAL;
2829 	}
2830 	pr_debug("CLK_REF_DIV=%d, Fref=%dHz\n", fll->clk_ref_div, freq_in);
2831 
2832 	/* Scale the output to give 90MHz<=Fvco<=100MHz */
2833 	fll->outdiv = 3;
2834 	while (freq_out * (fll->outdiv + 1) < 90000000) {
2835 		fll->outdiv++;
2836 		if (fll->outdiv > 63)
2837 			return -EINVAL;
2838 	}
2839 	freq_out *= fll->outdiv + 1;
2840 	pr_debug("OUTDIV=%d, Fvco=%dHz\n", fll->outdiv, freq_out);
2841 
2842 	if (freq_in > 1000000) {
2843 		fll->fll_fratio = 0;
2844 	} else if (freq_in > 256000) {
2845 		fll->fll_fratio = 1;
2846 		freq_in *= 2;
2847 	} else if (freq_in > 128000) {
2848 		fll->fll_fratio = 2;
2849 		freq_in *= 4;
2850 	} else if (freq_in > 64000) {
2851 		fll->fll_fratio = 3;
2852 		freq_in *= 8;
2853 	} else {
2854 		fll->fll_fratio = 4;
2855 		freq_in *= 16;
2856 	}
2857 	pr_debug("FLL_FRATIO=%d, Fref=%dHz\n", fll->fll_fratio, freq_in);
2858 
2859 	/* Now, calculate N.K */
2860 	Ndiv = freq_out / freq_in;
2861 
2862 	fll->n = Ndiv;
2863 	Nmod = freq_out % freq_in;
2864 	pr_debug("Nmod=%d\n", Nmod);
2865 
2866 	/* Calculate fractional part - scale up so we can round. */
2867 	Kpart = FIXED_FLL_SIZE * (long long)Nmod;
2868 
2869 	do_div(Kpart, freq_in);
2870 
2871 	K = Kpart & 0xFFFFFFFF;
2872 
2873 	if ((K % 10) >= 5)
2874 		K += 5;
2875 
2876 	/* Move down to proper range now rounding is done */
2877 	fll->k = K / 10;
2878 
2879 	pr_debug("N=%x K=%x\n", fll->n, fll->k);
2880 
2881 	return 0;
2882 }
2883 
2884 static int wm8994_set_fll(struct snd_soc_dai *dai, int id, int src,
2885 			  unsigned int freq_in, unsigned int freq_out)
2886 {
2887 	struct snd_soc_codec *codec = dai->codec;
2888 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
2889 	int reg_offset, ret;
2890 	struct fll_div fll;
2891 	u16 reg, aif1, aif2;
2892 
2893 	aif1 = snd_soc_read(codec, WM8994_AIF1_CLOCKING_1)
2894 		& WM8994_AIF1CLK_ENA;
2895 
2896 	aif2 = snd_soc_read(codec, WM8994_AIF2_CLOCKING_1)
2897 		& WM8994_AIF2CLK_ENA;
2898 
2899 	switch (id) {
2900 	case WM8994_FLL1:
2901 		reg_offset = 0;
2902 		id = 0;
2903 		break;
2904 	case WM8994_FLL2:
2905 		reg_offset = 0x20;
2906 		id = 1;
2907 		break;
2908 	default:
2909 		return -EINVAL;
2910 	}
2911 
2912 	switch (src) {
2913 	case 0:
2914 		/* Allow no source specification when stopping */
2915 		if (freq_out)
2916 			return -EINVAL;
2917 		break;
2918 	case WM8994_FLL_SRC_MCLK1:
2919 	case WM8994_FLL_SRC_MCLK2:
2920 	case WM8994_FLL_SRC_LRCLK:
2921 	case WM8994_FLL_SRC_BCLK:
2922 		break;
2923 	default:
2924 		return -EINVAL;
2925 	}
2926 
2927 	/* Are we changing anything? */
2928 	if (wm8994->fll[id].src == src &&
2929 	    wm8994->fll[id].in == freq_in && wm8994->fll[id].out == freq_out)
2930 		return 0;
2931 
2932 	/* If we're stopping the FLL redo the old config - no
2933 	 * registers will actually be written but we avoid GCC flow
2934 	 * analysis bugs spewing warnings.
2935 	 */
2936 	if (freq_out)
2937 		ret = wm8994_get_fll_config(&fll, freq_in, freq_out);
2938 	else
2939 		ret = wm8994_get_fll_config(&fll, wm8994->fll[id].in,
2940 					    wm8994->fll[id].out);
2941 	if (ret < 0)
2942 		return ret;
2943 
2944 	/* Gate the AIF clocks while we reclock */
2945 	snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
2946 			    WM8994_AIF1CLK_ENA, 0);
2947 	snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
2948 			    WM8994_AIF2CLK_ENA, 0);
2949 
2950 	/* We always need to disable the FLL while reconfiguring */
2951 	snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_1 + reg_offset,
2952 			    WM8994_FLL1_ENA, 0);
2953 
2954 	reg = (fll.outdiv << WM8994_FLL1_OUTDIV_SHIFT) |
2955 		(fll.fll_fratio << WM8994_FLL1_FRATIO_SHIFT);
2956 	snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_2 + reg_offset,
2957 			    WM8994_FLL1_OUTDIV_MASK |
2958 			    WM8994_FLL1_FRATIO_MASK, reg);
2959 
2960 	snd_soc_write(codec, WM8994_FLL1_CONTROL_3 + reg_offset, fll.k);
2961 
2962 	snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_4 + reg_offset,
2963 			    WM8994_FLL1_N_MASK,
2964 				    fll.n << WM8994_FLL1_N_SHIFT);
2965 
2966 	snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_5 + reg_offset,
2967 			    WM8994_FLL1_REFCLK_DIV_MASK |
2968 			    WM8994_FLL1_REFCLK_SRC_MASK,
2969 			    (fll.clk_ref_div << WM8994_FLL1_REFCLK_DIV_SHIFT) |
2970 			    (src - 1));
2971 
2972 	/* Enable (with fractional mode if required) */
2973 	if (freq_out) {
2974 		if (fll.k)
2975 			reg = WM8994_FLL1_ENA | WM8994_FLL1_FRAC;
2976 		else
2977 			reg = WM8994_FLL1_ENA;
2978 		snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_1 + reg_offset,
2979 				    WM8994_FLL1_ENA | WM8994_FLL1_FRAC,
2980 				    reg);
2981 	}
2982 
2983 	wm8994->fll[id].in = freq_in;
2984 	wm8994->fll[id].out = freq_out;
2985 	wm8994->fll[id].src = src;
2986 
2987 	/* Enable any gated AIF clocks */
2988 	snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
2989 			    WM8994_AIF1CLK_ENA, aif1);
2990 	snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
2991 			    WM8994_AIF2CLK_ENA, aif2);
2992 
2993 	configure_clock(codec);
2994 
2995 	return 0;
2996 }
2997 
2998 static int opclk_divs[] = { 10, 20, 30, 40, 55, 60, 80, 120, 160 };
2999 
3000 static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,
3001 		int clk_id, unsigned int freq, int dir)
3002 {
3003 	struct snd_soc_codec *codec = dai->codec;
3004 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3005 	int i;
3006 
3007 	switch (dai->id) {
3008 	case 1:
3009 	case 2:
3010 		break;
3011 
3012 	default:
3013 		/* AIF3 shares clocking with AIF1/2 */
3014 		return -EINVAL;
3015 	}
3016 
3017 	switch (clk_id) {
3018 	case WM8994_SYSCLK_MCLK1:
3019 		wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_MCLK1;
3020 		wm8994->mclk[0] = freq;
3021 		dev_dbg(dai->dev, "AIF%d using MCLK1 at %uHz\n",
3022 			dai->id, freq);
3023 		break;
3024 
3025 	case WM8994_SYSCLK_MCLK2:
3026 		/* TODO: Set GPIO AF */
3027 		wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_MCLK2;
3028 		wm8994->mclk[1] = freq;
3029 		dev_dbg(dai->dev, "AIF%d using MCLK2 at %uHz\n",
3030 			dai->id, freq);
3031 		break;
3032 
3033 	case WM8994_SYSCLK_FLL1:
3034 		wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_FLL1;
3035 		dev_dbg(dai->dev, "AIF%d using FLL1\n", dai->id);
3036 		break;
3037 
3038 	case WM8994_SYSCLK_FLL2:
3039 		wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_FLL2;
3040 		dev_dbg(dai->dev, "AIF%d using FLL2\n", dai->id);
3041 		break;
3042 
3043 	case WM8994_SYSCLK_OPCLK:
3044 		/* Special case - a division (times 10) is given and
3045 		 * no effect on main clocking.
3046 		 */
3047 		if (freq) {
3048 			for (i = 0; i < ARRAY_SIZE(opclk_divs); i++)
3049 				if (opclk_divs[i] == freq)
3050 					break;
3051 			if (i == ARRAY_SIZE(opclk_divs))
3052 				return -EINVAL;
3053 			snd_soc_update_bits(codec, WM8994_CLOCKING_2,
3054 					    WM8994_OPCLK_DIV_MASK, i);
3055 			snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_2,
3056 					    WM8994_OPCLK_ENA, WM8994_OPCLK_ENA);
3057 		} else {
3058 			snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_2,
3059 					    WM8994_OPCLK_ENA, 0);
3060 		}
3061 
3062 	default:
3063 		return -EINVAL;
3064 	}
3065 
3066 	configure_clock(codec);
3067 
3068 	return 0;
3069 }
3070 
3071 static int wm8994_set_bias_level(struct snd_soc_codec *codec,
3072 				 enum snd_soc_bias_level level)
3073 {
3074 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3075 
3076 	switch (level) {
3077 	case SND_SOC_BIAS_ON:
3078 		break;
3079 
3080 	case SND_SOC_BIAS_PREPARE:
3081 		/* VMID=2x40k */
3082 		snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1,
3083 				    WM8994_VMID_SEL_MASK, 0x2);
3084 		break;
3085 
3086 	case SND_SOC_BIAS_STANDBY:
3087 		if (codec->bias_level == SND_SOC_BIAS_OFF) {
3088 			/* Tweak DC servo and DSP configuration for
3089 			 * improved performance. */
3090 			if (wm8994->revision < 4) {
3091 				/* Tweak DC servo and DSP configuration for
3092 				 * improved performance. */
3093 				snd_soc_write(codec, 0x102, 0x3);
3094 				snd_soc_write(codec, 0x56, 0x3);
3095 				snd_soc_write(codec, 0x817, 0);
3096 				snd_soc_write(codec, 0x102, 0);
3097 			}
3098 
3099 			/* Discharge LINEOUT1 & 2 */
3100 			snd_soc_update_bits(codec, WM8994_ANTIPOP_1,
3101 					    WM8994_LINEOUT1_DISCH |
3102 					    WM8994_LINEOUT2_DISCH,
3103 					    WM8994_LINEOUT1_DISCH |
3104 					    WM8994_LINEOUT2_DISCH);
3105 
3106 			/* Startup bias, VMID ramp & buffer */
3107 			snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
3108 					    WM8994_STARTUP_BIAS_ENA |
3109 					    WM8994_VMID_BUF_ENA |
3110 					    WM8994_VMID_RAMP_MASK,
3111 					    WM8994_STARTUP_BIAS_ENA |
3112 					    WM8994_VMID_BUF_ENA |
3113 					    (0x11 << WM8994_VMID_RAMP_SHIFT));
3114 
3115 			/* Main bias enable, VMID=2x40k */
3116 			snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1,
3117 					    WM8994_BIAS_ENA |
3118 					    WM8994_VMID_SEL_MASK,
3119 					    WM8994_BIAS_ENA | 0x2);
3120 
3121 			msleep(20);
3122 		}
3123 
3124 		/* VMID=2x500k */
3125 		snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1,
3126 				    WM8994_VMID_SEL_MASK, 0x4);
3127 
3128 		break;
3129 
3130 	case SND_SOC_BIAS_OFF:
3131 		if (codec->bias_level == SND_SOC_BIAS_STANDBY) {
3132 			/* Switch over to startup biases */
3133 			snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
3134 					    WM8994_BIAS_SRC |
3135 					    WM8994_STARTUP_BIAS_ENA |
3136 					    WM8994_VMID_BUF_ENA |
3137 					    WM8994_VMID_RAMP_MASK,
3138 					    WM8994_BIAS_SRC |
3139 					    WM8994_STARTUP_BIAS_ENA |
3140 					    WM8994_VMID_BUF_ENA |
3141 					    (1 << WM8994_VMID_RAMP_SHIFT));
3142 
3143 			/* Disable main biases */
3144 			snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1,
3145 					    WM8994_BIAS_ENA |
3146 					    WM8994_VMID_SEL_MASK, 0);
3147 
3148 			/* Discharge line */
3149 			snd_soc_update_bits(codec, WM8994_ANTIPOP_1,
3150 					    WM8994_LINEOUT1_DISCH |
3151 					    WM8994_LINEOUT2_DISCH,
3152 					    WM8994_LINEOUT1_DISCH |
3153 					    WM8994_LINEOUT2_DISCH);
3154 
3155 			msleep(5);
3156 
3157 			/* Switch off startup biases */
3158 			snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
3159 					    WM8994_BIAS_SRC |
3160 					    WM8994_STARTUP_BIAS_ENA |
3161 					    WM8994_VMID_BUF_ENA |
3162 					    WM8994_VMID_RAMP_MASK, 0);
3163 		}
3164 		break;
3165 	}
3166 	codec->bias_level = level;
3167 	return 0;
3168 }
3169 
3170 static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
3171 {
3172 	struct snd_soc_codec *codec = dai->codec;
3173 	int ms_reg;
3174 	int aif1_reg;
3175 	int ms = 0;
3176 	int aif1 = 0;
3177 
3178 	switch (dai->id) {
3179 	case 1:
3180 		ms_reg = WM8994_AIF1_MASTER_SLAVE;
3181 		aif1_reg = WM8994_AIF1_CONTROL_1;
3182 		break;
3183 	case 2:
3184 		ms_reg = WM8994_AIF2_MASTER_SLAVE;
3185 		aif1_reg = WM8994_AIF2_CONTROL_1;
3186 		break;
3187 	default:
3188 		return -EINVAL;
3189 	}
3190 
3191 	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
3192 	case SND_SOC_DAIFMT_CBS_CFS:
3193 		break;
3194 	case SND_SOC_DAIFMT_CBM_CFM:
3195 		ms = WM8994_AIF1_MSTR;
3196 		break;
3197 	default:
3198 		return -EINVAL;
3199 	}
3200 
3201 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
3202 	case SND_SOC_DAIFMT_DSP_B:
3203 		aif1 |= WM8994_AIF1_LRCLK_INV;
3204 	case SND_SOC_DAIFMT_DSP_A:
3205 		aif1 |= 0x18;
3206 		break;
3207 	case SND_SOC_DAIFMT_I2S:
3208 		aif1 |= 0x10;
3209 		break;
3210 	case SND_SOC_DAIFMT_RIGHT_J:
3211 		break;
3212 	case SND_SOC_DAIFMT_LEFT_J:
3213 		aif1 |= 0x8;
3214 		break;
3215 	default:
3216 		return -EINVAL;
3217 	}
3218 
3219 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
3220 	case SND_SOC_DAIFMT_DSP_A:
3221 	case SND_SOC_DAIFMT_DSP_B:
3222 		/* frame inversion not valid for DSP modes */
3223 		switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
3224 		case SND_SOC_DAIFMT_NB_NF:
3225 			break;
3226 		case SND_SOC_DAIFMT_IB_NF:
3227 			aif1 |= WM8994_AIF1_BCLK_INV;
3228 			break;
3229 		default:
3230 			return -EINVAL;
3231 		}
3232 		break;
3233 
3234 	case SND_SOC_DAIFMT_I2S:
3235 	case SND_SOC_DAIFMT_RIGHT_J:
3236 	case SND_SOC_DAIFMT_LEFT_J:
3237 		switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
3238 		case SND_SOC_DAIFMT_NB_NF:
3239 			break;
3240 		case SND_SOC_DAIFMT_IB_IF:
3241 			aif1 |= WM8994_AIF1_BCLK_INV | WM8994_AIF1_LRCLK_INV;
3242 			break;
3243 		case SND_SOC_DAIFMT_IB_NF:
3244 			aif1 |= WM8994_AIF1_BCLK_INV;
3245 			break;
3246 		case SND_SOC_DAIFMT_NB_IF:
3247 			aif1 |= WM8994_AIF1_LRCLK_INV;
3248 			break;
3249 		default:
3250 			return -EINVAL;
3251 		}
3252 		break;
3253 	default:
3254 		return -EINVAL;
3255 	}
3256 
3257 	snd_soc_update_bits(codec, aif1_reg,
3258 			    WM8994_AIF1_BCLK_INV | WM8994_AIF1_LRCLK_INV |
3259 			    WM8994_AIF1_FMT_MASK,
3260 			    aif1);
3261 	snd_soc_update_bits(codec, ms_reg, WM8994_AIF1_MSTR,
3262 			    ms);
3263 
3264 	return 0;
3265 }
3266 
3267 static struct {
3268 	int val, rate;
3269 } srs[] = {
3270 	{ 0,   8000 },
3271 	{ 1,  11025 },
3272 	{ 2,  12000 },
3273 	{ 3,  16000 },
3274 	{ 4,  22050 },
3275 	{ 5,  24000 },
3276 	{ 6,  32000 },
3277 	{ 7,  44100 },
3278 	{ 8,  48000 },
3279 	{ 9,  88200 },
3280 	{ 10, 96000 },
3281 };
3282 
3283 static int fs_ratios[] = {
3284 	64, 128, 192, 256, 348, 512, 768, 1024, 1408, 1536
3285 };
3286 
3287 static int bclk_divs[] = {
3288 	10, 15, 20, 30, 40, 50, 60, 80, 110, 120, 160, 220, 240, 320, 440, 480,
3289 	640, 880, 960, 1280, 1760, 1920
3290 };
3291 
3292 static int wm8994_hw_params(struct snd_pcm_substream *substream,
3293 			    struct snd_pcm_hw_params *params,
3294 			    struct snd_soc_dai *dai)
3295 {
3296 	struct snd_soc_codec *codec = dai->codec;
3297 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3298 	int aif1_reg;
3299 	int bclk_reg;
3300 	int lrclk_reg;
3301 	int rate_reg;
3302 	int aif1 = 0;
3303 	int bclk = 0;
3304 	int lrclk = 0;
3305 	int rate_val = 0;
3306 	int id = dai->id - 1;
3307 
3308 	int i, cur_val, best_val, bclk_rate, best;
3309 
3310 	switch (dai->id) {
3311 	case 1:
3312 		aif1_reg = WM8994_AIF1_CONTROL_1;
3313 		bclk_reg = WM8994_AIF1_BCLK;
3314 		rate_reg = WM8994_AIF1_RATE;
3315 		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
3316 		    wm8994->lrclk_shared[0])
3317 			lrclk_reg = WM8994_AIF1DAC_LRCLK;
3318 		else
3319 			lrclk_reg = WM8994_AIF1ADC_LRCLK;
3320 		break;
3321 	case 2:
3322 		aif1_reg = WM8994_AIF2_CONTROL_1;
3323 		bclk_reg = WM8994_AIF2_BCLK;
3324 		rate_reg = WM8994_AIF2_RATE;
3325 		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
3326 		    wm8994->lrclk_shared[1])
3327 			lrclk_reg = WM8994_AIF2DAC_LRCLK;
3328 		else
3329 			lrclk_reg = WM8994_AIF2ADC_LRCLK;
3330 		break;
3331 	default:
3332 		return -EINVAL;
3333 	}
3334 
3335 	bclk_rate = params_rate(params) * 2;
3336 	switch (params_format(params)) {
3337 	case SNDRV_PCM_FORMAT_S16_LE:
3338 		bclk_rate *= 16;
3339 		break;
3340 	case SNDRV_PCM_FORMAT_S20_3LE:
3341 		bclk_rate *= 20;
3342 		aif1 |= 0x20;
3343 		break;
3344 	case SNDRV_PCM_FORMAT_S24_LE:
3345 		bclk_rate *= 24;
3346 		aif1 |= 0x40;
3347 		break;
3348 	case SNDRV_PCM_FORMAT_S32_LE:
3349 		bclk_rate *= 32;
3350 		aif1 |= 0x60;
3351 		break;
3352 	default:
3353 		return -EINVAL;
3354 	}
3355 
3356 	/* Try to find an appropriate sample rate; look for an exact match. */
3357 	for (i = 0; i < ARRAY_SIZE(srs); i++)
3358 		if (srs[i].rate == params_rate(params))
3359 			break;
3360 	if (i == ARRAY_SIZE(srs))
3361 		return -EINVAL;
3362 	rate_val |= srs[i].val << WM8994_AIF1_SR_SHIFT;
3363 
3364 	dev_dbg(dai->dev, "Sample rate is %dHz\n", srs[i].rate);
3365 	dev_dbg(dai->dev, "AIF%dCLK is %dHz, target BCLK %dHz\n",
3366 		dai->id, wm8994->aifclk[id], bclk_rate);
3367 
3368 	if (wm8994->aifclk[id] == 0) {
3369 		dev_err(dai->dev, "AIF%dCLK not configured\n", dai->id);
3370 		return -EINVAL;
3371 	}
3372 
3373 	/* AIFCLK/fs ratio; look for a close match in either direction */
3374 	best = 0;
3375 	best_val = abs((fs_ratios[0] * params_rate(params))
3376 		       - wm8994->aifclk[id]);
3377 	for (i = 1; i < ARRAY_SIZE(fs_ratios); i++) {
3378 		cur_val = abs((fs_ratios[i] * params_rate(params))
3379 			      - wm8994->aifclk[id]);
3380 		if (cur_val >= best_val)
3381 			continue;
3382 		best = i;
3383 		best_val = cur_val;
3384 	}
3385 	dev_dbg(dai->dev, "Selected AIF%dCLK/fs = %d\n",
3386 		dai->id, fs_ratios[best]);
3387 	rate_val |= best;
3388 
3389 	/* We may not get quite the right frequency if using
3390 	 * approximate clocks so look for the closest match that is
3391 	 * higher than the target (we need to ensure that there enough
3392 	 * BCLKs to clock out the samples).
3393 	 */
3394 	best = 0;
3395 	for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) {
3396 		cur_val = (wm8994->aifclk[id] * 10 / bclk_divs[i]) - bclk_rate;
3397 		if (cur_val < 0) /* BCLK table is sorted */
3398 			break;
3399 		best = i;
3400 	}
3401 	bclk_rate = wm8994->aifclk[id] * 10 / bclk_divs[best];
3402 	dev_dbg(dai->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n",
3403 		bclk_divs[best], bclk_rate);
3404 	bclk |= best << WM8994_AIF1_BCLK_DIV_SHIFT;
3405 
3406 	lrclk = bclk_rate / params_rate(params);
3407 	dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n",
3408 		lrclk, bclk_rate / lrclk);
3409 
3410 	snd_soc_update_bits(codec, aif1_reg, WM8994_AIF1_WL_MASK, aif1);
3411 	snd_soc_update_bits(codec, bclk_reg, WM8994_AIF1_BCLK_DIV_MASK, bclk);
3412 	snd_soc_update_bits(codec, lrclk_reg, WM8994_AIF1DAC_RATE_MASK,
3413 			    lrclk);
3414 	snd_soc_update_bits(codec, rate_reg, WM8994_AIF1_SR_MASK |
3415 			    WM8994_AIF1CLK_RATE_MASK, rate_val);
3416 
3417 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
3418 		switch (dai->id) {
3419 		case 1:
3420 			wm8994->dac_rates[0] = params_rate(params);
3421 			wm8994_set_retune_mobile(codec, 0);
3422 			wm8994_set_retune_mobile(codec, 1);
3423 			break;
3424 		case 2:
3425 			wm8994->dac_rates[1] = params_rate(params);
3426 			wm8994_set_retune_mobile(codec, 2);
3427 			break;
3428 		}
3429 	}
3430 
3431 	return 0;
3432 }
3433 
3434 static int wm8994_aif_mute(struct snd_soc_dai *codec_dai, int mute)
3435 {
3436 	struct snd_soc_codec *codec = codec_dai->codec;
3437 	int mute_reg;
3438 	int reg;
3439 
3440 	switch (codec_dai->id) {
3441 	case 1:
3442 		mute_reg = WM8994_AIF1_DAC1_FILTERS_1;
3443 		break;
3444 	case 2:
3445 		mute_reg = WM8994_AIF2_DAC_FILTERS_1;
3446 		break;
3447 	default:
3448 		return -EINVAL;
3449 	}
3450 
3451 	if (mute)
3452 		reg = WM8994_AIF1DAC1_MUTE;
3453 	else
3454 		reg = 0;
3455 
3456 	snd_soc_update_bits(codec, mute_reg, WM8994_AIF1DAC1_MUTE, reg);
3457 
3458 	return 0;
3459 }
3460 
3461 static int wm8994_set_tristate(struct snd_soc_dai *codec_dai, int tristate)
3462 {
3463 	struct snd_soc_codec *codec = codec_dai->codec;
3464 	int reg, val, mask;
3465 
3466 	switch (codec_dai->id) {
3467 	case 1:
3468 		reg = WM8994_AIF1_MASTER_SLAVE;
3469 		mask = WM8994_AIF1_TRI;
3470 		break;
3471 	case 2:
3472 		reg = WM8994_AIF2_MASTER_SLAVE;
3473 		mask = WM8994_AIF2_TRI;
3474 		break;
3475 	case 3:
3476 		reg = WM8994_POWER_MANAGEMENT_6;
3477 		mask = WM8994_AIF3_TRI;
3478 		break;
3479 	default:
3480 		return -EINVAL;
3481 	}
3482 
3483 	if (tristate)
3484 		val = mask;
3485 	else
3486 		val = 0;
3487 
3488 	return snd_soc_update_bits(codec, reg, mask, reg);
3489 }
3490 
3491 #define WM8994_RATES SNDRV_PCM_RATE_8000_96000
3492 
3493 #define WM8994_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
3494 			SNDRV_PCM_FMTBIT_S24_LE)
3495 
3496 static struct snd_soc_dai_ops wm8994_aif1_dai_ops = {
3497 	.set_sysclk	= wm8994_set_dai_sysclk,
3498 	.set_fmt	= wm8994_set_dai_fmt,
3499 	.hw_params	= wm8994_hw_params,
3500 	.digital_mute	= wm8994_aif_mute,
3501 	.set_pll	= wm8994_set_fll,
3502 	.set_tristate	= wm8994_set_tristate,
3503 };
3504 
3505 static struct snd_soc_dai_ops wm8994_aif2_dai_ops = {
3506 	.set_sysclk	= wm8994_set_dai_sysclk,
3507 	.set_fmt	= wm8994_set_dai_fmt,
3508 	.hw_params	= wm8994_hw_params,
3509 	.digital_mute   = wm8994_aif_mute,
3510 	.set_pll	= wm8994_set_fll,
3511 	.set_tristate	= wm8994_set_tristate,
3512 };
3513 
3514 static struct snd_soc_dai_ops wm8994_aif3_dai_ops = {
3515 	.set_tristate	= wm8994_set_tristate,
3516 };
3517 
3518 struct snd_soc_dai wm8994_dai[] = {
3519 	{
3520 		.name = "WM8994 AIF1",
3521 		.id = 1,
3522 		.playback = {
3523 			.stream_name = "AIF1 Playback",
3524 			.channels_min = 2,
3525 			.channels_max = 2,
3526 			.rates = WM8994_RATES,
3527 			.formats = WM8994_FORMATS,
3528 		},
3529 		.capture = {
3530 			.stream_name = "AIF1 Capture",
3531 			.channels_min = 2,
3532 			.channels_max = 2,
3533 			.rates = WM8994_RATES,
3534 			.formats = WM8994_FORMATS,
3535 		 },
3536 		.ops = &wm8994_aif1_dai_ops,
3537 	},
3538 	{
3539 		.name = "WM8994 AIF2",
3540 		.id = 2,
3541 		.playback = {
3542 			.stream_name = "AIF2 Playback",
3543 			.channels_min = 2,
3544 			.channels_max = 2,
3545 			.rates = WM8994_RATES,
3546 			.formats = WM8994_FORMATS,
3547 		},
3548 		.capture = {
3549 			.stream_name = "AIF2 Capture",
3550 			.channels_min = 2,
3551 			.channels_max = 2,
3552 			.rates = WM8994_RATES,
3553 			.formats = WM8994_FORMATS,
3554 		},
3555 		.ops = &wm8994_aif2_dai_ops,
3556 	},
3557 	{
3558 		.name = "WM8994 AIF3",
3559 		.id = 3,
3560 		.playback = {
3561 			.stream_name = "AIF3 Playback",
3562 			.channels_min = 2,
3563 			.channels_max = 2,
3564 			.rates = WM8994_RATES,
3565 			.formats = WM8994_FORMATS,
3566 		},
3567 		.capture = {
3568 			.stream_name = "AIF3 Capture",
3569 			.channels_min = 2,
3570 			.channels_max = 2,
3571 			.rates = WM8994_RATES,
3572 			.formats = WM8994_FORMATS,
3573 		},
3574 		.ops = &wm8994_aif3_dai_ops,
3575 	}
3576 };
3577 EXPORT_SYMBOL_GPL(wm8994_dai);
3578 
3579 #ifdef CONFIG_PM
3580 static int wm8994_suspend(struct platform_device *pdev, pm_message_t state)
3581 {
3582 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
3583 	struct snd_soc_codec *codec = socdev->card->codec;
3584 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3585 	int i, ret;
3586 
3587 	for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) {
3588 		memcpy(&wm8994->fll_suspend[i], &wm8994->fll[i],
3589 		       sizeof(struct fll_config));
3590 		ret = wm8994_set_fll(&codec->dai[0], i + 1, 0, 0, 0);
3591 		if (ret < 0)
3592 			dev_warn(codec->dev, "Failed to stop FLL%d: %d\n",
3593 				 i + 1, ret);
3594 	}
3595 
3596 	wm8994_set_bias_level(codec, SND_SOC_BIAS_OFF);
3597 
3598 	return 0;
3599 }
3600 
3601 static int wm8994_resume(struct platform_device *pdev)
3602 {
3603 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
3604 	struct snd_soc_codec *codec = socdev->card->codec;
3605 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3606 	u16 *reg_cache = codec->reg_cache;
3607 	int i, ret;
3608 
3609 	/* Restore the registers */
3610 	for (i = 1; i < ARRAY_SIZE(wm8994->reg_cache); i++) {
3611 		switch (i) {
3612 		case WM8994_LDO_1:
3613 		case WM8994_LDO_2:
3614 		case WM8994_SOFTWARE_RESET:
3615 			/* Handled by other MFD drivers */
3616 			continue;
3617 		default:
3618 			break;
3619 		}
3620 
3621 		if (!access_masks[i].writable)
3622 			continue;
3623 
3624 		wm8994_reg_write(codec->control_data, i, reg_cache[i]);
3625 	}
3626 
3627 	wm8994_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
3628 
3629 	for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) {
3630 		if (!wm8994->fll_suspend[i].out)
3631 			continue;
3632 
3633 		ret = wm8994_set_fll(&codec->dai[0], i + 1,
3634 				     wm8994->fll_suspend[i].src,
3635 				     wm8994->fll_suspend[i].in,
3636 				     wm8994->fll_suspend[i].out);
3637 		if (ret < 0)
3638 			dev_warn(codec->dev, "Failed to restore FLL%d: %d\n",
3639 				 i + 1, ret);
3640 	}
3641 
3642 	return 0;
3643 }
3644 #else
3645 #define wm8994_suspend NULL
3646 #define wm8994_resume NULL
3647 #endif
3648 
3649 static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994)
3650 {
3651 	struct snd_soc_codec *codec = &wm8994->codec;
3652 	struct wm8994_pdata *pdata = wm8994->pdata;
3653 	struct snd_kcontrol_new controls[] = {
3654 		SOC_ENUM_EXT("AIF1.1 EQ Mode",
3655 			     wm8994->retune_mobile_enum,
3656 			     wm8994_get_retune_mobile_enum,
3657 			     wm8994_put_retune_mobile_enum),
3658 		SOC_ENUM_EXT("AIF1.2 EQ Mode",
3659 			     wm8994->retune_mobile_enum,
3660 			     wm8994_get_retune_mobile_enum,
3661 			     wm8994_put_retune_mobile_enum),
3662 		SOC_ENUM_EXT("AIF2 EQ Mode",
3663 			     wm8994->retune_mobile_enum,
3664 			     wm8994_get_retune_mobile_enum,
3665 			     wm8994_put_retune_mobile_enum),
3666 	};
3667 	int ret, i, j;
3668 	const char **t;
3669 
3670 	/* We need an array of texts for the enum API but the number
3671 	 * of texts is likely to be less than the number of
3672 	 * configurations due to the sample rate dependency of the
3673 	 * configurations. */
3674 	wm8994->num_retune_mobile_texts = 0;
3675 	wm8994->retune_mobile_texts = NULL;
3676 	for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) {
3677 		for (j = 0; j < wm8994->num_retune_mobile_texts; j++) {
3678 			if (strcmp(pdata->retune_mobile_cfgs[i].name,
3679 				   wm8994->retune_mobile_texts[j]) == 0)
3680 				break;
3681 		}
3682 
3683 		if (j != wm8994->num_retune_mobile_texts)
3684 			continue;
3685 
3686 		/* Expand the array... */
3687 		t = krealloc(wm8994->retune_mobile_texts,
3688 			     sizeof(char *) *
3689 			     (wm8994->num_retune_mobile_texts + 1),
3690 			     GFP_KERNEL);
3691 		if (t == NULL)
3692 			continue;
3693 
3694 		/* ...store the new entry... */
3695 		t[wm8994->num_retune_mobile_texts] =
3696 			pdata->retune_mobile_cfgs[i].name;
3697 
3698 		/* ...and remember the new version. */
3699 		wm8994->num_retune_mobile_texts++;
3700 		wm8994->retune_mobile_texts = t;
3701 	}
3702 
3703 	dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n",
3704 		wm8994->num_retune_mobile_texts);
3705 
3706 	wm8994->retune_mobile_enum.max = wm8994->num_retune_mobile_texts;
3707 	wm8994->retune_mobile_enum.texts = wm8994->retune_mobile_texts;
3708 
3709 	ret = snd_soc_add_controls(&wm8994->codec, controls,
3710 				   ARRAY_SIZE(controls));
3711 	if (ret != 0)
3712 		dev_err(wm8994->codec.dev,
3713 			"Failed to add ReTune Mobile controls: %d\n", ret);
3714 }
3715 
3716 static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
3717 {
3718 	struct snd_soc_codec *codec = &wm8994->codec;
3719 	struct wm8994_pdata *pdata = wm8994->pdata;
3720 	int ret, i;
3721 
3722 	if (!pdata)
3723 		return;
3724 
3725 	wm_hubs_handle_analogue_pdata(codec, pdata->lineout1_diff,
3726 				      pdata->lineout2_diff,
3727 				      pdata->lineout1fb,
3728 				      pdata->lineout2fb,
3729 				      pdata->jd_scthr,
3730 				      pdata->jd_thr,
3731 				      pdata->micbias1_lvl,
3732 				      pdata->micbias2_lvl);
3733 
3734 	dev_dbg(codec->dev, "%d DRC configurations\n", pdata->num_drc_cfgs);
3735 
3736 	if (pdata->num_drc_cfgs) {
3737 		struct snd_kcontrol_new controls[] = {
3738 			SOC_ENUM_EXT("AIF1DRC1 Mode", wm8994->drc_enum,
3739 				     wm8994_get_drc_enum, wm8994_put_drc_enum),
3740 			SOC_ENUM_EXT("AIF1DRC2 Mode", wm8994->drc_enum,
3741 				     wm8994_get_drc_enum, wm8994_put_drc_enum),
3742 			SOC_ENUM_EXT("AIF2DRC Mode", wm8994->drc_enum,
3743 				     wm8994_get_drc_enum, wm8994_put_drc_enum),
3744 		};
3745 
3746 		/* We need an array of texts for the enum API */
3747 		wm8994->drc_texts = kmalloc(sizeof(char *)
3748 					    * pdata->num_drc_cfgs, GFP_KERNEL);
3749 		if (!wm8994->drc_texts) {
3750 			dev_err(wm8994->codec.dev,
3751 				"Failed to allocate %d DRC config texts\n",
3752 				pdata->num_drc_cfgs);
3753 			return;
3754 		}
3755 
3756 		for (i = 0; i < pdata->num_drc_cfgs; i++)
3757 			wm8994->drc_texts[i] = pdata->drc_cfgs[i].name;
3758 
3759 		wm8994->drc_enum.max = pdata->num_drc_cfgs;
3760 		wm8994->drc_enum.texts = wm8994->drc_texts;
3761 
3762 		ret = snd_soc_add_controls(&wm8994->codec, controls,
3763 					   ARRAY_SIZE(controls));
3764 		if (ret != 0)
3765 			dev_err(wm8994->codec.dev,
3766 				"Failed to add DRC mode controls: %d\n", ret);
3767 
3768 		for (i = 0; i < WM8994_NUM_DRC; i++)
3769 			wm8994_set_drc(codec, i);
3770 	}
3771 
3772 	dev_dbg(codec->dev, "%d ReTune Mobile configurations\n",
3773 		pdata->num_retune_mobile_cfgs);
3774 
3775 	if (pdata->num_retune_mobile_cfgs)
3776 		wm8994_handle_retune_mobile_pdata(wm8994);
3777 	else
3778 		snd_soc_add_controls(&wm8994->codec, wm8994_eq_controls,
3779 				     ARRAY_SIZE(wm8994_eq_controls));
3780 }
3781 
3782 static int wm8994_probe(struct platform_device *pdev)
3783 {
3784 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
3785 	struct snd_soc_codec *codec;
3786 	int ret = 0;
3787 
3788 	if (wm8994_codec == NULL) {
3789 		dev_err(&pdev->dev, "Codec device not registered\n");
3790 		return -ENODEV;
3791 	}
3792 
3793 	socdev->card->codec = wm8994_codec;
3794 	codec = wm8994_codec;
3795 
3796 	/* register pcms */
3797 	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
3798 	if (ret < 0) {
3799 		dev_err(codec->dev, "failed to create pcms: %d\n", ret);
3800 		return ret;
3801 	}
3802 
3803 	wm8994_handle_pdata(snd_soc_codec_get_drvdata(codec));
3804 
3805 	wm_hubs_add_analogue_controls(codec);
3806 	snd_soc_add_controls(codec, wm8994_snd_controls,
3807 			     ARRAY_SIZE(wm8994_snd_controls));
3808 	snd_soc_dapm_new_controls(codec, wm8994_dapm_widgets,
3809 				  ARRAY_SIZE(wm8994_dapm_widgets));
3810 	wm_hubs_add_analogue_routes(codec, 0, 0);
3811 	snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon));
3812 
3813 	return 0;
3814 }
3815 
3816 static int wm8994_remove(struct platform_device *pdev)
3817 {
3818 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
3819 
3820 	snd_soc_free_pcms(socdev);
3821 	snd_soc_dapm_free(socdev);
3822 
3823 	return 0;
3824 }
3825 
3826 struct snd_soc_codec_device soc_codec_dev_wm8994 = {
3827 	.probe = 	wm8994_probe,
3828 	.remove = 	wm8994_remove,
3829 	.suspend = 	wm8994_suspend,
3830 	.resume =	wm8994_resume,
3831 };
3832 EXPORT_SYMBOL_GPL(soc_codec_dev_wm8994);
3833 
3834 /**
3835  * wm8994_mic_detect - Enable microphone detection via the WM8994 IRQ
3836  *
3837  * @codec:   WM8994 codec
3838  * @jack:    jack to report detection events on
3839  * @micbias: microphone bias to detect on
3840  * @det:     value to report for presence detection
3841  * @shrt:    value to report for short detection
3842  *
3843  * Enable microphone detection via IRQ on the WM8994.  If GPIOs are
3844  * being used to bring out signals to the processor then only platform
3845  * data configuration is needed for WM8903 and processor GPIOs should
3846  * be configured using snd_soc_jack_add_gpios() instead.
3847  *
3848  * Configuration of detection levels is available via the micbias1_lvl
3849  * and micbias2_lvl platform data members.
3850  */
3851 int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
3852 		      int micbias, int det, int shrt)
3853 {
3854 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3855 	struct wm8994_micdet *micdet;
3856 	int reg;
3857 
3858 	switch (micbias) {
3859 	case 1:
3860 		micdet = &wm8994->micdet[0];
3861 		break;
3862 	case 2:
3863 		micdet = &wm8994->micdet[1];
3864 		break;
3865 	default:
3866 		return -EINVAL;
3867 	}
3868 
3869 	dev_dbg(codec->dev, "Configuring microphone detection on %d: %x %x\n",
3870 		micbias, det, shrt);
3871 
3872 	/* Store the configuration */
3873 	micdet->jack = jack;
3874 	micdet->det = det;
3875 	micdet->shrt = shrt;
3876 
3877 	/* If either of the jacks is set up then enable detection */
3878 	if (wm8994->micdet[0].jack || wm8994->micdet[1].jack)
3879 		reg = WM8994_MICD_ENA;
3880 	else
3881 		reg = 0;
3882 
3883 	snd_soc_update_bits(codec, WM8994_MICBIAS, WM8994_MICD_ENA, reg);
3884 
3885 	return 0;
3886 }
3887 EXPORT_SYMBOL_GPL(wm8994_mic_detect);
3888 
3889 static irqreturn_t wm8994_mic_irq(int irq, void *data)
3890 {
3891 	struct wm8994_priv *priv = data;
3892 	struct snd_soc_codec *codec = &priv->codec;
3893 	int reg;
3894 	int report;
3895 
3896 	reg = snd_soc_read(codec, WM8994_INTERRUPT_RAW_STATUS_2);
3897 	if (reg < 0) {
3898 		dev_err(codec->dev, "Failed to read microphone status: %d\n",
3899 			reg);
3900 		return IRQ_HANDLED;
3901 	}
3902 
3903 	dev_dbg(codec->dev, "Microphone status: %x\n", reg);
3904 
3905 	report = 0;
3906 	if (reg & WM8994_MIC1_DET_STS)
3907 		report |= priv->micdet[0].det;
3908 	if (reg & WM8994_MIC1_SHRT_STS)
3909 		report |= priv->micdet[0].shrt;
3910 	snd_soc_jack_report(priv->micdet[0].jack, report,
3911 			    priv->micdet[0].det | priv->micdet[0].shrt);
3912 
3913 	report = 0;
3914 	if (reg & WM8994_MIC2_DET_STS)
3915 		report |= priv->micdet[1].det;
3916 	if (reg & WM8994_MIC2_SHRT_STS)
3917 		report |= priv->micdet[1].shrt;
3918 	snd_soc_jack_report(priv->micdet[1].jack, report,
3919 			    priv->micdet[1].det | priv->micdet[1].shrt);
3920 
3921 	return IRQ_HANDLED;
3922 }
3923 
3924 static int wm8994_codec_probe(struct platform_device *pdev)
3925 {
3926 	int ret;
3927 	struct wm8994_priv *wm8994;
3928 	struct snd_soc_codec *codec;
3929 	int i;
3930 
3931 	if (wm8994_codec) {
3932 		dev_err(&pdev->dev, "Another WM8994 is registered\n");
3933 		return -EINVAL;
3934 	}
3935 
3936 	wm8994 = kzalloc(sizeof(struct wm8994_priv), GFP_KERNEL);
3937 	if (!wm8994) {
3938 		dev_err(&pdev->dev, "Failed to allocate private data\n");
3939 		return -ENOMEM;
3940 	}
3941 
3942 	codec = &wm8994->codec;
3943 
3944 	mutex_init(&codec->mutex);
3945 	INIT_LIST_HEAD(&codec->dapm_widgets);
3946 	INIT_LIST_HEAD(&codec->dapm_paths);
3947 
3948 	snd_soc_codec_set_drvdata(codec, wm8994);
3949 	codec->control_data = dev_get_drvdata(pdev->dev.parent);
3950 	codec->name = "WM8994";
3951 	codec->owner = THIS_MODULE;
3952 	codec->read = wm8994_read;
3953 	codec->write = wm8994_write;
3954 	codec->readable_register = wm8994_readable;
3955 	codec->bias_level = SND_SOC_BIAS_OFF;
3956 	codec->set_bias_level = wm8994_set_bias_level;
3957 	codec->dai = &wm8994_dai[0];
3958 	codec->num_dai = 3;
3959 	codec->reg_cache_size = WM8994_MAX_REGISTER;
3960 	codec->reg_cache = &wm8994->reg_cache;
3961 	codec->dev = &pdev->dev;
3962 
3963 	wm8994->pdata = pdev->dev.parent->platform_data;
3964 
3965 	/* Fill the cache with physical values we inherited; don't reset */
3966 	ret = wm8994_bulk_read(codec->control_data, 0,
3967 			       ARRAY_SIZE(wm8994->reg_cache) - 1,
3968 			       codec->reg_cache);
3969 	if (ret < 0) {
3970 		dev_err(codec->dev, "Failed to fill register cache: %d\n",
3971 			ret);
3972 		goto err;
3973 	}
3974 
3975 	/* Clear the cached values for unreadable/volatile registers to
3976 	 * avoid potential confusion.
3977 	 */
3978 	for (i = 0; i < ARRAY_SIZE(wm8994->reg_cache); i++)
3979 		if (wm8994_volatile(i) || !wm8994_readable(i))
3980 			wm8994->reg_cache[i] = 0;
3981 
3982 	/* Set revision-specific configuration */
3983 	wm8994->revision = snd_soc_read(codec, WM8994_CHIP_REVISION);
3984 	switch (wm8994->revision) {
3985 	case 2:
3986 	case 3:
3987 		wm8994->hubs.dcs_codes = -5;
3988 		wm8994->hubs.hp_startup_mode = 1;
3989 		wm8994->hubs.dcs_readback_mode = 1;
3990 		break;
3991 	default:
3992 		wm8994->hubs.dcs_readback_mode = 1;
3993 		break;
3994 	}
3995 
3996 	ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_MIC1_DET,
3997 				 wm8994_mic_irq, "Mic 1 detect", wm8994);
3998 	if (ret != 0)
3999 		dev_warn(&pdev->dev,
4000 			 "Failed to request Mic1 detect IRQ: %d\n", ret);
4001 
4002 	ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT,
4003 				 wm8994_mic_irq, "Mic 1 short", wm8994);
4004 	if (ret != 0)
4005 		dev_warn(&pdev->dev,
4006 			 "Failed to request Mic1 short IRQ: %d\n", ret);
4007 
4008 	ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_MIC2_DET,
4009 				 wm8994_mic_irq, "Mic 2 detect", wm8994);
4010 	if (ret != 0)
4011 		dev_warn(&pdev->dev,
4012 			 "Failed to request Mic2 detect IRQ: %d\n", ret);
4013 
4014 	ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT,
4015 				 wm8994_mic_irq, "Mic 2 short", wm8994);
4016 	if (ret != 0)
4017 		dev_warn(&pdev->dev,
4018 			 "Failed to request Mic2 short IRQ: %d\n", ret);
4019 
4020 	/* Remember if AIFnLRCLK is configured as a GPIO.  This should be
4021 	 * configured on init - if a system wants to do this dynamically
4022 	 * at runtime we can deal with that then.
4023 	 */
4024 	ret = wm8994_reg_read(codec->control_data, WM8994_GPIO_1);
4025 	if (ret < 0) {
4026 		dev_err(codec->dev, "Failed to read GPIO1 state: %d\n", ret);
4027 		goto err_irq;
4028 	}
4029 	if ((ret & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) {
4030 		wm8994->lrclk_shared[0] = 1;
4031 		wm8994_dai[0].symmetric_rates = 1;
4032 	} else {
4033 		wm8994->lrclk_shared[0] = 0;
4034 	}
4035 
4036 	ret = wm8994_reg_read(codec->control_data, WM8994_GPIO_6);
4037 	if (ret < 0) {
4038 		dev_err(codec->dev, "Failed to read GPIO6 state: %d\n", ret);
4039 		goto err_irq;
4040 	}
4041 	if ((ret & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) {
4042 		wm8994->lrclk_shared[1] = 1;
4043 		wm8994_dai[1].symmetric_rates = 1;
4044 	} else {
4045 		wm8994->lrclk_shared[1] = 0;
4046 	}
4047 
4048 	for (i = 0; i < ARRAY_SIZE(wm8994_dai); i++)
4049 		wm8994_dai[i].dev = codec->dev;
4050 
4051 	wm8994_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
4052 
4053 	wm8994_codec = codec;
4054 
4055 	/* Latch volume updates (right only; we always do left then right). */
4056 	snd_soc_update_bits(codec, WM8994_AIF1_DAC1_RIGHT_VOLUME,
4057 			    WM8994_AIF1DAC1_VU, WM8994_AIF1DAC1_VU);
4058 	snd_soc_update_bits(codec, WM8994_AIF1_DAC2_RIGHT_VOLUME,
4059 			    WM8994_AIF1DAC2_VU, WM8994_AIF1DAC2_VU);
4060 	snd_soc_update_bits(codec, WM8994_AIF2_DAC_RIGHT_VOLUME,
4061 			    WM8994_AIF2DAC_VU, WM8994_AIF2DAC_VU);
4062 	snd_soc_update_bits(codec, WM8994_AIF1_ADC1_RIGHT_VOLUME,
4063 			    WM8994_AIF1ADC1_VU, WM8994_AIF1ADC1_VU);
4064 	snd_soc_update_bits(codec, WM8994_AIF1_ADC2_RIGHT_VOLUME,
4065 			    WM8994_AIF1ADC2_VU, WM8994_AIF1ADC2_VU);
4066 	snd_soc_update_bits(codec, WM8994_AIF2_ADC_RIGHT_VOLUME,
4067 			    WM8994_AIF2ADC_VU, WM8994_AIF1ADC2_VU);
4068 	snd_soc_update_bits(codec, WM8994_DAC1_RIGHT_VOLUME,
4069 			    WM8994_DAC1_VU, WM8994_DAC1_VU);
4070 	snd_soc_update_bits(codec, WM8994_DAC2_RIGHT_VOLUME,
4071 			    WM8994_DAC2_VU, WM8994_DAC2_VU);
4072 
4073 	/* Set the low bit of the 3D stereo depth so TLV matches */
4074 	snd_soc_update_bits(codec, WM8994_AIF1_DAC1_FILTERS_2,
4075 			    1 << WM8994_AIF1DAC1_3D_GAIN_SHIFT,
4076 			    1 << WM8994_AIF1DAC1_3D_GAIN_SHIFT);
4077 	snd_soc_update_bits(codec, WM8994_AIF1_DAC2_FILTERS_2,
4078 			    1 << WM8994_AIF1DAC2_3D_GAIN_SHIFT,
4079 			    1 << WM8994_AIF1DAC2_3D_GAIN_SHIFT);
4080 	snd_soc_update_bits(codec, WM8994_AIF2_DAC_FILTERS_2,
4081 			    1 << WM8994_AIF2DAC_3D_GAIN_SHIFT,
4082 			    1 << WM8994_AIF2DAC_3D_GAIN_SHIFT);
4083 
4084 	/* Unconditionally enable AIF1 ADC TDM mode; it only affects
4085 	 * behaviour on idle TDM clock cycles. */
4086 	snd_soc_update_bits(codec, WM8994_AIF1_CONTROL_1,
4087 			    WM8994_AIF1ADC_TDM, WM8994_AIF1ADC_TDM);
4088 
4089 	wm8994_update_class_w(codec);
4090 
4091 	ret = snd_soc_register_codec(codec);
4092 	if (ret != 0) {
4093 		dev_err(codec->dev, "Failed to register codec: %d\n", ret);
4094 		goto err_irq;
4095 	}
4096 
4097 	ret = snd_soc_register_dais(wm8994_dai, ARRAY_SIZE(wm8994_dai));
4098 	if (ret != 0) {
4099 		dev_err(codec->dev, "Failed to register DAIs: %d\n", ret);
4100 		goto err_codec;
4101 	}
4102 
4103 	platform_set_drvdata(pdev, wm8994);
4104 
4105 	return 0;
4106 
4107 err_codec:
4108 	snd_soc_unregister_codec(codec);
4109 err_irq:
4110 	wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT, wm8994);
4111 	wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET, wm8994);
4112 	wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT, wm8994);
4113 	wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET, wm8994);
4114 err:
4115 	kfree(wm8994);
4116 	return ret;
4117 }
4118 
4119 static int __devexit wm8994_codec_remove(struct platform_device *pdev)
4120 {
4121 	struct wm8994_priv *wm8994 = platform_get_drvdata(pdev);
4122 	struct snd_soc_codec *codec = &wm8994->codec;
4123 
4124 	wm8994_set_bias_level(codec, SND_SOC_BIAS_OFF);
4125 	snd_soc_unregister_dais(wm8994_dai, ARRAY_SIZE(wm8994_dai));
4126 	snd_soc_unregister_codec(&wm8994->codec);
4127 	wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT, wm8994);
4128 	wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET, wm8994);
4129 	wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT, wm8994);
4130 	wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET, wm8994);
4131 	kfree(wm8994);
4132 	wm8994_codec = NULL;
4133 
4134 	return 0;
4135 }
4136 
4137 static struct platform_driver wm8994_codec_driver = {
4138 	.driver = {
4139 		   .name = "wm8994-codec",
4140 		   .owner = THIS_MODULE,
4141 		   },
4142 	.probe = wm8994_codec_probe,
4143 	.remove = __devexit_p(wm8994_codec_remove),
4144 };
4145 
4146 static __init int wm8994_init(void)
4147 {
4148 	return platform_driver_register(&wm8994_codec_driver);
4149 }
4150 module_init(wm8994_init);
4151 
4152 static __exit void wm8994_exit(void)
4153 {
4154 	platform_driver_unregister(&wm8994_codec_driver);
4155 }
4156 module_exit(wm8994_exit);
4157 
4158 
4159 MODULE_DESCRIPTION("ASoC WM8994 driver");
4160 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
4161 MODULE_LICENSE("GPL");
4162 MODULE_ALIAS("platform:wm8994-codec");
4163