aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8993.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-13 22:53:06 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-01-20 08:58:20 -0500
commitd0ad0af0432f7b4fe439a6a46e7a31f8dd5d3d55 (patch)
treeb206504b91d46cb6627a3a261fa5e98ebf50689a /sound/soc/codecs/wm8993.c
parent391d9e4e5ce50bf14400ed04d13821e7b56e84f7 (diff)
ASoC: Convert wm8993 to direct regmap API usage
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8993.c')
-rw-r--r--sound/soc/codecs/wm8993.c420
1 files changed, 271 insertions, 149 deletions
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c
index 7c7fd925db8d..53213020caf7 100644
--- a/sound/soc/codecs/wm8993.c
+++ b/sound/soc/codecs/wm8993.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/pm.h> 17#include <linux/pm.h>
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/regmap.h>
19#include <linux/regulator/consumer.h> 20#include <linux/regulator/consumer.h>
20#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
@@ -40,134 +41,112 @@ static const char *wm8993_supply_names[WM8993_NUM_SUPPLIES] = {
40 "SPKVDD", 41 "SPKVDD",
41}; 42};
42 43
43static u16 wm8993_reg_defaults[WM8993_REGISTER_COUNT] = { 44static struct reg_default wm8993_reg_defaults[] = {
44 0x8993, /* R0 - Software Reset */ 45 { 1, 0x0000 }, /* R1 - Power Management (1) */
45 0x0000, /* R1 - Power Management (1) */ 46 { 2, 0x6000 }, /* R2 - Power Management (2) */
46 0x6000, /* R2 - Power Management (2) */ 47 { 3, 0x0000 }, /* R3 - Power Management (3) */
47 0x0000, /* R3 - Power Management (3) */ 48 { 4, 0x4050 }, /* R4 - Audio Interface (1) */
48 0x4050, /* R4 - Audio Interface (1) */ 49 { 5, 0x4000 }, /* R5 - Audio Interface (2) */
49 0x4000, /* R5 - Audio Interface (2) */ 50 { 6, 0x01C8 }, /* R6 - Clocking 1 */
50 0x01C8, /* R6 - Clocking 1 */ 51 { 7, 0x0000 }, /* R7 - Clocking 2 */
51 0x0000, /* R7 - Clocking 2 */ 52 { 8, 0x0000 }, /* R8 - Audio Interface (3) */
52 0x0000, /* R8 - Audio Interface (3) */ 53 { 9, 0x0040 }, /* R9 - Audio Interface (4) */
53 0x0040, /* R9 - Audio Interface (4) */ 54 { 10, 0x0004 }, /* R10 - DAC CTRL */
54 0x0004, /* R10 - DAC CTRL */ 55 { 11, 0x00C0 }, /* R11 - Left DAC Digital Volume */
55 0x00C0, /* R11 - Left DAC Digital Volume */ 56 { 12, 0x00C0 }, /* R12 - Right DAC Digital Volume */
56 0x00C0, /* R12 - Right DAC Digital Volume */ 57 { 13, 0x0000 }, /* R13 - Digital Side Tone */
57 0x0000, /* R13 - Digital Side Tone */ 58 { 14, 0x0300 }, /* R14 - ADC CTRL */
58 0x0300, /* R14 - ADC CTRL */ 59 { 15, 0x00C0 }, /* R15 - Left ADC Digital Volume */
59 0x00C0, /* R15 - Left ADC Digital Volume */ 60 { 16, 0x00C0 }, /* R16 - Right ADC Digital Volume */
60 0x00C0, /* R16 - Right ADC Digital Volume */ 61 { 18, 0x0000 }, /* R18 - GPIO CTRL 1 */
61 0x0000, /* R17 */ 62 { 19, 0x0010 }, /* R19 - GPIO1 */
62 0x0000, /* R18 - GPIO CTRL 1 */ 63 { 20, 0x0000 }, /* R20 - IRQ_DEBOUNCE */
63 0x0010, /* R19 - GPIO1 */ 64 { 21, 0x8000 }, /* R22 - GPIOCTRL 2 */
64 0x0000, /* R20 - IRQ_DEBOUNCE */ 65 { 22, 0x0800 }, /* R23 - GPIO_POL */
65 0x0000, /* R21 */ 66 { 24, 0x008B }, /* R24 - Left Line Input 1&2 Volume */
66 0x8000, /* R22 - GPIOCTRL 2 */ 67 { 25, 0x008B }, /* R25 - Left Line Input 3&4 Volume */
67 0x0800, /* R23 - GPIO_POL */ 68 { 26, 0x008B }, /* R26 - Right Line Input 1&2 Volume */
68 0x008B, /* R24 - Left Line Input 1&2 Volume */ 69 { 27, 0x008B }, /* R27 - Right Line Input 3&4 Volume */
69 0x008B, /* R25 - Left Line Input 3&4 Volume */ 70 { 28, 0x006D }, /* R28 - Left Output Volume */
70 0x008B, /* R26 - Right Line Input 1&2 Volume */ 71 { 29, 0x006D }, /* R29 - Right Output Volume */
71 0x008B, /* R27 - Right Line Input 3&4 Volume */ 72 { 30, 0x0066 }, /* R30 - Line Outputs Volume */
72 0x006D, /* R28 - Left Output Volume */ 73 { 31, 0x0020 }, /* R31 - HPOUT2 Volume */
73 0x006D, /* R29 - Right Output Volume */ 74 { 32, 0x0079 }, /* R32 - Left OPGA Volume */
74 0x0066, /* R30 - Line Outputs Volume */ 75 { 33, 0x0079 }, /* R33 - Right OPGA Volume */
75 0x0020, /* R31 - HPOUT2 Volume */ 76 { 34, 0x0003 }, /* R34 - SPKMIXL Attenuation */
76 0x0079, /* R32 - Left OPGA Volume */ 77 { 35, 0x0003 }, /* R35 - SPKMIXR Attenuation */
77 0x0079, /* R33 - Right OPGA Volume */ 78 { 36, 0x0011 }, /* R36 - SPKOUT Mixers */
78 0x0003, /* R34 - SPKMIXL Attenuation */ 79 { 37, 0x0100 }, /* R37 - SPKOUT Boost */
79 0x0003, /* R35 - SPKMIXR Attenuation */ 80 { 38, 0x0079 }, /* R38 - Speaker Volume Left */
80 0x0011, /* R36 - SPKOUT Mixers */ 81 { 39, 0x0079 }, /* R39 - Speaker Volume Right */
81 0x0100, /* R37 - SPKOUT Boost */ 82 { 40, 0x0000 }, /* R40 - Input Mixer2 */
82 0x0079, /* R38 - Speaker Volume Left */ 83 { 41, 0x0000 }, /* R41 - Input Mixer3 */
83 0x0079, /* R39 - Speaker Volume Right */ 84 { 42, 0x0000 }, /* R42 - Input Mixer4 */
84 0x0000, /* R40 - Input Mixer2 */ 85 { 43, 0x0000 }, /* R43 - Input Mixer5 */
85 0x0000, /* R41 - Input Mixer3 */ 86 { 44, 0x0000 }, /* R44 - Input Mixer6 */
86 0x0000, /* R42 - Input Mixer4 */ 87 { 45, 0x0000 }, /* R45 - Output Mixer1 */
87 0x0000, /* R43 - Input Mixer5 */ 88 { 46, 0x0000 }, /* R46 - Output Mixer2 */
88 0x0000, /* R44 - Input Mixer6 */ 89 { 47, 0x0000 }, /* R47 - Output Mixer3 */
89 0x0000, /* R45 - Output Mixer1 */ 90 { 48, 0x0000 }, /* R48 - Output Mixer4 */
90 0x0000, /* R46 - Output Mixer2 */ 91 { 49, 0x0000 }, /* R49 - Output Mixer5 */
91 0x0000, /* R47 - Output Mixer3 */ 92 { 50, 0x0000 }, /* R50 - Output Mixer6 */
92 0x0000, /* R48 - Output Mixer4 */ 93 { 51, 0x0000 }, /* R51 - HPOUT2 Mixer */
93 0x0000, /* R49 - Output Mixer5 */ 94 { 52, 0x0000 }, /* R52 - Line Mixer1 */
94 0x0000, /* R50 - Output Mixer6 */ 95 { 53, 0x0000 }, /* R53 - Line Mixer2 */
95 0x0000, /* R51 - HPOUT2 Mixer */ 96 { 54, 0x0000 }, /* R54 - Speaker Mixer */
96 0x0000, /* R52 - Line Mixer1 */ 97 { 55, 0x0000 }, /* R55 - Additional Control */
97 0x0000, /* R53 - Line Mixer2 */ 98 { 56, 0x0000 }, /* R56 - AntiPOP1 */
98 0x0000, /* R54 - Speaker Mixer */ 99 { 57, 0x0000 }, /* R57 - AntiPOP2 */
99 0x0000, /* R55 - Additional Control */ 100 { 58, 0x0000 }, /* R58 - MICBIAS */
100 0x0000, /* R56 - AntiPOP1 */ 101 { 60, 0x0000 }, /* R60 - FLL Control 1 */
101 0x0000, /* R57 - AntiPOP2 */ 102 { 61, 0x0000 }, /* R61 - FLL Control 2 */
102 0x0000, /* R58 - MICBIAS */ 103 { 62, 0x0000 }, /* R62 - FLL Control 3 */
103 0x0000, /* R59 */ 104 { 63, 0x2EE0 }, /* R63 - FLL Control 4 */
104 0x0000, /* R60 - FLL Control 1 */ 105 { 64, 0x0002 }, /* R64 - FLL Control 5 */
105 0x0000, /* R61 - FLL Control 2 */ 106 { 65, 0x2287 }, /* R65 - Clocking 3 */
106 0x0000, /* R62 - FLL Control 3 */ 107 { 66, 0x025F }, /* R66 - Clocking 4 */
107 0x2EE0, /* R63 - FLL Control 4 */ 108 { 67, 0x0000 }, /* R67 - MW Slave Control */
108 0x0002, /* R64 - FLL Control 5 */ 109 { 69, 0x0002 }, /* R69 - Bus Control 1 */
109 0x2287, /* R65 - Clocking 3 */ 110 { 70, 0x0000 }, /* R70 - Write Sequencer 0 */
110 0x025F, /* R66 - Clocking 4 */ 111 { 71, 0x0000 }, /* R71 - Write Sequencer 1 */
111 0x0000, /* R67 - MW Slave Control */ 112 { 72, 0x0000 }, /* R72 - Write Sequencer 2 */
112 0x0000, /* R68 */ 113 { 73, 0x0000 }, /* R73 - Write Sequencer 3 */
113 0x0002, /* R69 - Bus Control 1 */ 114 { 74, 0x0000 }, /* R74 - Write Sequencer 4 */
114 0x0000, /* R70 - Write Sequencer 0 */ 115 { 75, 0x0000 }, /* R75 - Write Sequencer 5 */
115 0x0000, /* R71 - Write Sequencer 1 */ 116 { 76, 0x1F25 }, /* R76 - Charge Pump 1 */
116 0x0000, /* R72 - Write Sequencer 2 */ 117 { 81, 0x0000 }, /* R81 - Class W 0 */
117 0x0000, /* R73 - Write Sequencer 3 */ 118 { 85, 0x054A }, /* R85 - DC Servo 1 */
118 0x0000, /* R74 - Write Sequencer 4 */ 119 { 87, 0x0000 }, /* R87 - DC Servo 3 */
119 0x0000, /* R75 - Write Sequencer 5 */ 120 { 96, 0x0100 }, /* R96 - Analogue HP 0 */
120 0x1F25, /* R76 - Charge Pump 1 */ 121 { 98, 0x0000 }, /* R98 - EQ1 */
121 0x0000, /* R77 */ 122 { 99, 0x000C }, /* R99 - EQ2 */
122 0x0000, /* R78 */ 123 { 100, 0x000C }, /* R100 - EQ3 */
123 0x0000, /* R79 */ 124 { 101, 0x000C }, /* R101 - EQ4 */
124 0x0000, /* R80 */ 125 { 102, 0x000C }, /* R102 - EQ5 */
125 0x0000, /* R81 - Class W 0 */ 126 { 103, 0x000C }, /* R103 - EQ6 */
126 0x0000, /* R82 */ 127 { 104, 0x0FCA }, /* R104 - EQ7 */
127 0x0000, /* R83 */ 128 { 105, 0x0400 }, /* R105 - EQ8 */
128 0x0000, /* R84 - DC Servo 0 */ 129 { 106, 0x00D8 }, /* R106 - EQ9 */
129 0x054A, /* R85 - DC Servo 1 */ 130 { 107, 0x1EB5 }, /* R107 - EQ10 */
130 0x0000, /* R86 */ 131 { 108, 0xF145 }, /* R108 - EQ11 */
131 0x0000, /* R87 - DC Servo 3 */ 132 { 109, 0x0B75 }, /* R109 - EQ12 */
132 0x0000, /* R88 - DC Servo Readback 0 */ 133 { 110, 0x01C5 }, /* R110 - EQ13 */
133 0x0000, /* R89 - DC Servo Readback 1 */ 134 { 111, 0x1C58 }, /* R111 - EQ14 */
134 0x0000, /* R90 - DC Servo Readback 2 */ 135 { 112, 0xF373 }, /* R112 - EQ15 */
135 0x0000, /* R91 */ 136 { 113, 0x0A54 }, /* R113 - EQ16 */
136 0x0000, /* R92 */ 137 { 114, 0x0558 }, /* R114 - EQ17 */
137 0x0000, /* R93 */ 138 { 115, 0x168E }, /* R115 - EQ18 */
138 0x0000, /* R94 */ 139 { 116, 0xF829 }, /* R116 - EQ19 */
139 0x0000, /* R95 */ 140 { 117, 0x07AD }, /* R117 - EQ20 */
140 0x0100, /* R96 - Analogue HP 0 */ 141 { 118, 0x1103 }, /* R118 - EQ21 */
141 0x0000, /* R97 */ 142 { 119, 0x0564 }, /* R119 - EQ22 */
142 0x0000, /* R98 - EQ1 */ 143 { 120, 0x0559 }, /* R120 - EQ23 */
143 0x000C, /* R99 - EQ2 */ 144 { 121, 0x4000 }, /* R121 - EQ24 */
144 0x000C, /* R100 - EQ3 */ 145 { 122, 0x0000 }, /* R122 - Digital Pulls */
145 0x000C, /* R101 - EQ4 */ 146 { 123, 0x0F08 }, /* R123 - DRC Control 1 */
146 0x000C, /* R102 - EQ5 */ 147 { 124, 0x0000 }, /* R124 - DRC Control 2 */
147 0x000C, /* R103 - EQ6 */ 148 { 125, 0x0080 }, /* R125 - DRC Control 3 */
148 0x0FCA, /* R104 - EQ7 */ 149 { 126, 0x0000 }, /* R126 - DRC Control 4 */
149 0x0400, /* R105 - EQ8 */
150 0x00D8, /* R106 - EQ9 */
151 0x1EB5, /* R107 - EQ10 */
152 0xF145, /* R108 - EQ11 */
153 0x0B75, /* R109 - EQ12 */
154 0x01C5, /* R110 - EQ13 */
155 0x1C58, /* R111 - EQ14 */
156 0xF373, /* R112 - EQ15 */
157 0x0A54, /* R113 - EQ16 */
158 0x0558, /* R114 - EQ17 */
159 0x168E, /* R115 - EQ18 */
160 0xF829, /* R116 - EQ19 */
161 0x07AD, /* R117 - EQ20 */
162 0x1103, /* R118 - EQ21 */
163 0x0564, /* R119 - EQ22 */
164 0x0559, /* R120 - EQ23 */
165 0x4000, /* R121 - EQ24 */
166 0x0000, /* R122 - Digital Pulls */
167 0x0F08, /* R123 - DRC Control 1 */
168 0x0000, /* R124 - DRC Control 2 */
169 0x0080, /* R125 - DRC Control 3 */
170 0x0000, /* R126 - DRC Control 4 */
171}; 150};
172 151
173static struct { 152static struct {
@@ -225,9 +204,9 @@ static struct {
225 204
226struct wm8993_priv { 205struct wm8993_priv {
227 struct wm_hubs_data hubs_data; 206 struct wm_hubs_data hubs_data;
207 struct regmap *regmap;
228 struct regulator_bulk_data supplies[WM8993_NUM_SUPPLIES]; 208 struct regulator_bulk_data supplies[WM8993_NUM_SUPPLIES];
229 struct wm8993_platform_data pdata; 209 struct wm8993_platform_data pdata;
230 enum snd_soc_control_type control_type;
231 int master; 210 int master;
232 int sysclk_source; 211 int sysclk_source;
233 int tdm_slots; 212 int tdm_slots;
@@ -242,7 +221,7 @@ struct wm8993_priv {
242 int fll_src; 221 int fll_src;
243}; 222};
244 223
245static int wm8993_volatile(struct snd_soc_codec *codec, unsigned int reg) 224static bool wm8993_volatile(struct device *dev, unsigned int reg)
246{ 225{
247 switch (reg) { 226 switch (reg) {
248 case WM8993_SOFTWARE_RESET: 227 case WM8993_SOFTWARE_RESET:
@@ -250,9 +229,128 @@ static int wm8993_volatile(struct snd_soc_codec *codec, unsigned int reg)
250 case WM8993_DC_SERVO_READBACK_0: 229 case WM8993_DC_SERVO_READBACK_0:
251 case WM8993_DC_SERVO_READBACK_1: 230 case WM8993_DC_SERVO_READBACK_1:
252 case WM8993_DC_SERVO_READBACK_2: 231 case WM8993_DC_SERVO_READBACK_2:
253 return 1; 232 return true;
254 default: 233 default:
255 return 0; 234 return false;
235 }
236}
237
238static bool wm8993_readable(struct device *dev, unsigned int reg)
239{
240 switch (reg) {
241 case WM8993_SOFTWARE_RESET:
242 case WM8993_POWER_MANAGEMENT_1:
243 case WM8993_POWER_MANAGEMENT_2:
244 case WM8993_POWER_MANAGEMENT_3:
245 case WM8993_AUDIO_INTERFACE_1:
246 case WM8993_AUDIO_INTERFACE_2:
247 case WM8993_CLOCKING_1:
248 case WM8993_CLOCKING_2:
249 case WM8993_AUDIO_INTERFACE_3:
250 case WM8993_AUDIO_INTERFACE_4:
251 case WM8993_DAC_CTRL:
252 case WM8993_LEFT_DAC_DIGITAL_VOLUME:
253 case WM8993_RIGHT_DAC_DIGITAL_VOLUME:
254 case WM8993_DIGITAL_SIDE_TONE:
255 case WM8993_ADC_CTRL:
256 case WM8993_LEFT_ADC_DIGITAL_VOLUME:
257 case WM8993_RIGHT_ADC_DIGITAL_VOLUME:
258 case WM8993_GPIO_CTRL_1:
259 case WM8993_GPIO1:
260 case WM8993_IRQ_DEBOUNCE:
261 case WM8993_GPIOCTRL_2:
262 case WM8993_GPIO_POL:
263 case WM8993_LEFT_LINE_INPUT_1_2_VOLUME:
264 case WM8993_LEFT_LINE_INPUT_3_4_VOLUME:
265 case WM8993_RIGHT_LINE_INPUT_1_2_VOLUME:
266 case WM8993_RIGHT_LINE_INPUT_3_4_VOLUME:
267 case WM8993_LEFT_OUTPUT_VOLUME:
268 case WM8993_RIGHT_OUTPUT_VOLUME:
269 case WM8993_LINE_OUTPUTS_VOLUME:
270 case WM8993_HPOUT2_VOLUME:
271 case WM8993_LEFT_OPGA_VOLUME:
272 case WM8993_RIGHT_OPGA_VOLUME:
273 case WM8993_SPKMIXL_ATTENUATION:
274 case WM8993_SPKMIXR_ATTENUATION:
275 case WM8993_SPKOUT_MIXERS:
276 case WM8993_SPKOUT_BOOST:
277 case WM8993_SPEAKER_VOLUME_LEFT:
278 case WM8993_SPEAKER_VOLUME_RIGHT:
279 case WM8993_INPUT_MIXER2:
280 case WM8993_INPUT_MIXER3:
281 case WM8993_INPUT_MIXER4:
282 case WM8993_INPUT_MIXER5:
283 case WM8993_INPUT_MIXER6:
284 case WM8993_OUTPUT_MIXER1:
285 case WM8993_OUTPUT_MIXER2:
286 case WM8993_OUTPUT_MIXER3:
287 case WM8993_OUTPUT_MIXER4:
288 case WM8993_OUTPUT_MIXER5:
289 case WM8993_OUTPUT_MIXER6:
290 case WM8993_HPOUT2_MIXER:
291 case WM8993_LINE_MIXER1:
292 case WM8993_LINE_MIXER2:
293 case WM8993_SPEAKER_MIXER:
294 case WM8993_ADDITIONAL_CONTROL:
295 case WM8993_ANTIPOP1:
296 case WM8993_ANTIPOP2:
297 case WM8993_MICBIAS:
298 case WM8993_FLL_CONTROL_1:
299 case WM8993_FLL_CONTROL_2:
300 case WM8993_FLL_CONTROL_3:
301 case WM8993_FLL_CONTROL_4:
302 case WM8993_FLL_CONTROL_5:
303 case WM8993_CLOCKING_3:
304 case WM8993_CLOCKING_4:
305 case WM8993_MW_SLAVE_CONTROL:
306 case WM8993_BUS_CONTROL_1:
307 case WM8993_WRITE_SEQUENCER_0:
308 case WM8993_WRITE_SEQUENCER_1:
309 case WM8993_WRITE_SEQUENCER_2:
310 case WM8993_WRITE_SEQUENCER_3:
311 case WM8993_WRITE_SEQUENCER_4:
312 case WM8993_WRITE_SEQUENCER_5:
313 case WM8993_CHARGE_PUMP_1:
314 case WM8993_CLASS_W_0:
315 case WM8993_DC_SERVO_0:
316 case WM8993_DC_SERVO_1:
317 case WM8993_DC_SERVO_3:
318 case WM8993_DC_SERVO_READBACK_0:
319 case WM8993_DC_SERVO_READBACK_1:
320 case WM8993_DC_SERVO_READBACK_2:
321 case WM8993_ANALOGUE_HP_0:
322 case WM8993_EQ1:
323 case WM8993_EQ2:
324 case WM8993_EQ3:
325 case WM8993_EQ4:
326 case WM8993_EQ5:
327 case WM8993_EQ6:
328 case WM8993_EQ7:
329 case WM8993_EQ8:
330 case WM8993_EQ9:
331 case WM8993_EQ10:
332 case WM8993_EQ11:
333 case WM8993_EQ12:
334 case WM8993_EQ13:
335 case WM8993_EQ14:
336 case WM8993_EQ15:
337 case WM8993_EQ16:
338 case WM8993_EQ17:
339 case WM8993_EQ18:
340 case WM8993_EQ19:
341 case WM8993_EQ20:
342 case WM8993_EQ21:
343 case WM8993_EQ22:
344 case WM8993_EQ23:
345 case WM8993_EQ24:
346 case WM8993_DIGITAL_PULLS:
347 case WM8993_DRC_CONTROL_1:
348 case WM8993_DRC_CONTROL_2:
349 case WM8993_DRC_CONTROL_3:
350 case WM8993_DRC_CONTROL_4:
351 return true;
352 default:
353 return false;
256 } 354 }
257} 355}
258 356
@@ -963,7 +1061,8 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec,
963 if (ret != 0) 1061 if (ret != 0)
964 return ret; 1062 return ret;
965 1063
966 snd_soc_cache_sync(codec); 1064 regcache_cache_only(wm8993->regmap, false);
1065 regcache_sync(wm8993->regmap);
967 1066
968 /* Tune DC servo configuration */ 1067 /* Tune DC servo configuration */
969 snd_soc_write(codec, 0x44, 3); 1068 snd_soc_write(codec, 0x44, 3);
@@ -1024,14 +1123,8 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec,
1024 WM8993_VMID_RAMP_MASK | 1123 WM8993_VMID_RAMP_MASK |
1025 WM8993_BIAS_SRC, 0); 1124 WM8993_BIAS_SRC, 0);
1026 1125
1027#ifdef CONFIG_REGULATOR 1126 regcache_cache_only(wm8993->regmap, true);
1028 /* Post 2.6.34 we will be able to get a callback when 1127 regcache_mark_dirty(wm8993->regmap);
1029 * the regulators are disabled which we can use but
1030 * for now just assume that the power will be cut if
1031 * the regulator API is in use.
1032 */
1033 codec->cache_sync = 1;
1034#endif
1035 1128
1036 regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), 1129 regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies),
1037 wm8993->supplies); 1130 wm8993->supplies);
@@ -1425,7 +1518,8 @@ static int wm8993_probe(struct snd_soc_codec *codec)
1425 wm8993->hubs_data.dcs_codes_r = -2; 1518 wm8993->hubs_data.dcs_codes_r = -2;
1426 wm8993->hubs_data.series_startup = 1; 1519 wm8993->hubs_data.series_startup = 1;
1427 1520
1428 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); 1521 codec->control_data = wm8993->regmap;
1522 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
1429 if (ret != 0) { 1523 if (ret != 0) {
1430 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 1524 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
1431 return ret; 1525 return ret;
@@ -1449,7 +1543,7 @@ static int wm8993_probe(struct snd_soc_codec *codec)
1449 } 1543 }
1450 1544
1451 val = snd_soc_read(codec, WM8993_SOFTWARE_RESET); 1545 val = snd_soc_read(codec, WM8993_SOFTWARE_RESET);
1452 if (val != wm8993_reg_defaults[WM8993_SOFTWARE_RESET]) { 1546 if (val != 0x8993) {
1453 dev_err(codec->dev, "Invalid ID register value %x\n", val); 1547 dev_err(codec->dev, "Invalid ID register value %x\n", val);
1454 ret = -EINVAL; 1548 ret = -EINVAL;
1455 goto err_enable; 1549 goto err_enable;
@@ -1459,7 +1553,7 @@ static int wm8993_probe(struct snd_soc_codec *codec)
1459 if (ret != 0) 1553 if (ret != 0)
1460 goto err_enable; 1554 goto err_enable;
1461 1555
1462 codec->cache_only = 1; 1556 regcache_cache_only(wm8993->regmap, true);
1463 1557
1464 /* By default we're using the output mixers */ 1558 /* By default we're using the output mixers */
1465 wm8993->class_w_users = 2; 1559 wm8993->class_w_users = 2;
@@ -1578,16 +1672,25 @@ static int wm8993_resume(struct snd_soc_codec *codec)
1578#define wm8993_resume NULL 1672#define wm8993_resume NULL
1579#endif 1673#endif
1580 1674
1675static const struct regmap_config wm8993_regmap = {
1676 .reg_bits = 8,
1677 .val_bits = 16,
1678
1679 .max_register = WM8993_MAX_REGISTER,
1680 .volatile_reg = wm8993_volatile,
1681 .readable_reg = wm8993_readable,
1682
1683 .cache_type = REGCACHE_RBTREE,
1684 .reg_defaults = wm8993_reg_defaults,
1685 .num_reg_defaults = ARRAY_SIZE(wm8993_reg_defaults),
1686};
1687
1581static struct snd_soc_codec_driver soc_codec_dev_wm8993 = { 1688static struct snd_soc_codec_driver soc_codec_dev_wm8993 = {
1582 .probe = wm8993_probe, 1689 .probe = wm8993_probe,
1583 .remove = wm8993_remove, 1690 .remove = wm8993_remove,
1584 .suspend = wm8993_suspend, 1691 .suspend = wm8993_suspend,
1585 .resume = wm8993_resume, 1692 .resume = wm8993_resume,
1586 .set_bias_level = wm8993_set_bias_level, 1693 .set_bias_level = wm8993_set_bias_level,
1587 .reg_cache_size = ARRAY_SIZE(wm8993_reg_defaults),
1588 .reg_word_size = sizeof(u16),
1589 .reg_cache_default = wm8993_reg_defaults,
1590 .volatile_register = wm8993_volatile,
1591}; 1694};
1592 1695
1593#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1696#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
@@ -1602,17 +1705,36 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c,
1602 if (wm8993 == NULL) 1705 if (wm8993 == NULL)
1603 return -ENOMEM; 1706 return -ENOMEM;
1604 1707
1708 wm8993->regmap = regmap_init_i2c(i2c, &wm8993_regmap);
1709 if (IS_ERR(wm8993->regmap)) {
1710 ret = PTR_ERR(wm8993->regmap);
1711 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
1712 return ret;
1713 }
1714
1605 i2c_set_clientdata(i2c, wm8993); 1715 i2c_set_clientdata(i2c, wm8993);
1606 1716
1607 ret = snd_soc_register_codec(&i2c->dev, 1717 ret = snd_soc_register_codec(&i2c->dev,
1608 &soc_codec_dev_wm8993, &wm8993_dai, 1); 1718 &soc_codec_dev_wm8993, &wm8993_dai, 1);
1719 if (ret != 0) {
1720 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
1721 goto err;
1722 }
1723
1724 return ret;
1725
1726err:
1727 regmap_exit(wm8993->regmap);
1609 return ret; 1728 return ret;
1610} 1729}
1611 1730
1612static __devexit int wm8993_i2c_remove(struct i2c_client *client) 1731static __devexit int wm8993_i2c_remove(struct i2c_client *client)
1613{ 1732{
1733 struct wm8993_priv *wm8993 = i2c_get_clientdata(client);
1734
1614 snd_soc_unregister_codec(&client->dev); 1735 snd_soc_unregister_codec(&client->dev);
1615 kfree(i2c_get_clientdata(client)); 1736 regmap_exit(wm8993->regmap);
1737
1616 return 0; 1738 return 0;
1617} 1739}
1618 1740