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