aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/ab8500-codec.c13
-rw-r--r--sound/soc/codecs/ad1836.c88
-rw-r--r--sound/soc/codecs/ad193x.c50
-rw-r--r--sound/soc/codecs/ad1980.c1
-rw-r--r--sound/soc/codecs/adau1373.c12
-rw-r--r--sound/soc/codecs/adau1701.c12
-rw-r--r--sound/soc/codecs/ak4671.c12
-rw-r--r--sound/soc/codecs/arizona.c70
-rw-r--r--sound/soc/codecs/arizona.h6
-rw-r--r--sound/soc/codecs/cs4270.c152
-rw-r--r--sound/soc/codecs/cs42l51.c19
-rw-r--r--sound/soc/codecs/cs42l52.c1
-rw-r--r--sound/soc/codecs/isabelle.c1
-rw-r--r--sound/soc/codecs/lm4857.c12
-rw-r--r--sound/soc/codecs/max98088.c18
-rw-r--r--sound/soc/codecs/max98095.c18
-rw-r--r--sound/soc/codecs/max9850.c12
-rw-r--r--sound/soc/codecs/max9877.c12
-rw-r--r--sound/soc/codecs/mc13783.c68
-rw-r--r--sound/soc/codecs/sta32x.c151
-rw-r--r--sound/soc/codecs/sta529.c2
-rw-r--r--sound/soc/codecs/stac9766.c1
-rw-r--r--sound/soc/codecs/tlv320aic26.c12
-rw-r--r--sound/soc/codecs/tlv320aic32x4.c19
-rw-r--r--sound/soc/codecs/tlv320aic3x.c49
-rw-r--r--sound/soc/codecs/tlv320dac33.c19
-rw-r--r--sound/soc/codecs/tpa6130a2.c13
-rw-r--r--sound/soc/codecs/twl4030.c157
-rw-r--r--sound/soc/codecs/twl6040.c43
-rw-r--r--sound/soc/codecs/wm0010.c944
-rw-r--r--sound/soc/codecs/wm2000.c12
-rw-r--r--sound/soc/codecs/wm2200.c16
-rw-r--r--sound/soc/codecs/wm5100.c6
-rw-r--r--sound/soc/codecs/wm5102.c52
-rw-r--r--sound/soc/codecs/wm5110.c18
-rw-r--r--sound/soc/codecs/wm8510.c129
-rw-r--r--sound/soc/codecs/wm8523.c184
-rw-r--r--sound/soc/codecs/wm8580.c149
-rw-r--r--sound/soc/codecs/wm8711.c65
-rw-r--r--sound/soc/codecs/wm8728.c60
-rw-r--r--sound/soc/codecs/wm8737.c132
-rw-r--r--sound/soc/codecs/wm8741.c115
-rw-r--r--sound/soc/codecs/wm8770.c19
-rw-r--r--sound/soc/codecs/wm8776.c75
-rw-r--r--sound/soc/codecs/wm8900.c166
-rw-r--r--sound/soc/codecs/wm8903.c18
-rw-r--r--sound/soc/codecs/wm8904.c4
-rw-r--r--sound/soc/codecs/wm8940.c18
-rw-r--r--sound/soc/codecs/wm8955.c18
-rw-r--r--sound/soc/codecs/wm8958-dsp2.c28
-rw-r--r--sound/soc/codecs/wm8960.c150
-rw-r--r--sound/soc/codecs/wm8961.c492
-rw-r--r--sound/soc/codecs/wm8971.c18
-rw-r--r--sound/soc/codecs/wm8974.c18
-rw-r--r--sound/soc/codecs/wm8978.c18
-rw-r--r--sound/soc/codecs/wm8983.c162
-rw-r--r--sound/soc/codecs/wm8990.c8
-rw-r--r--sound/soc/codecs/wm8991.c25
-rw-r--r--sound/soc/codecs/wm8993.c2
-rw-r--r--sound/soc/codecs/wm8994.c132
-rw-r--r--sound/soc/codecs/wm8994.h12
-rw-r--r--sound/soc/codecs/wm8996.c2
-rw-r--r--sound/soc/codecs/wm9090.c12
-rw-r--r--sound/soc/codecs/wm9712.c12
-rw-r--r--sound/soc/codecs/wm9713.c1
-rw-r--r--sound/soc/codecs/wm_hubs.c114
-rw-r--r--sound/soc/codecs/wm_hubs.h6
69 files changed, 2869 insertions, 1592 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 9f8e8594aeb9..3684255e5fba 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -70,6 +70,7 @@ config SND_SOC_ALL_CODECS
70 select SND_SOC_UDA134X 70 select SND_SOC_UDA134X
71 select SND_SOC_UDA1380 if I2C 71 select SND_SOC_UDA1380 if I2C
72 select SND_SOC_WL1273 if MFD_WL1273_CORE 72 select SND_SOC_WL1273 if MFD_WL1273_CORE
73 select SND_SOC_WM0010 if SPI_MASTER
73 select SND_SOC_WM1250_EV1 if I2C 74 select SND_SOC_WM1250_EV1 if I2C
74 select SND_SOC_WM2000 if I2C 75 select SND_SOC_WM2000 if I2C
75 select SND_SOC_WM2200 if I2C 76 select SND_SOC_WM2200 if I2C
@@ -326,6 +327,9 @@ config SND_SOC_UDA1380
326config SND_SOC_WL1273 327config SND_SOC_WL1273
327 tristate 328 tristate
328 329
330config SND_SOC_WM0010
331 tristate
332
329config SND_SOC_WM1250_EV1 333config SND_SOC_WM1250_EV1
330 tristate 334 tristate
331 335
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 34148bb59c68..ca508b251df7 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -61,6 +61,7 @@ snd-soc-twl6040-objs := twl6040.o
61snd-soc-uda134x-objs := uda134x.o 61snd-soc-uda134x-objs := uda134x.o
62snd-soc-uda1380-objs := uda1380.o 62snd-soc-uda1380-objs := uda1380.o
63snd-soc-wl1273-objs := wl1273.o 63snd-soc-wl1273-objs := wl1273.o
64snd-soc-wm0010-objs := wm0010.o
64snd-soc-wm1250-ev1-objs := wm1250-ev1.o 65snd-soc-wm1250-ev1-objs := wm1250-ev1.o
65snd-soc-wm2000-objs := wm2000.o 66snd-soc-wm2000-objs := wm2000.o
66snd-soc-wm2200-objs := wm2200.o 67snd-soc-wm2200-objs := wm2200.o
@@ -177,6 +178,7 @@ obj-$(CONFIG_SND_SOC_TWL6040) += snd-soc-twl6040.o
177obj-$(CONFIG_SND_SOC_UDA134X) += snd-soc-uda134x.o 178obj-$(CONFIG_SND_SOC_UDA134X) += snd-soc-uda134x.o
178obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o 179obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o
179obj-$(CONFIG_SND_SOC_WL1273) += snd-soc-wl1273.o 180obj-$(CONFIG_SND_SOC_WL1273) += snd-soc-wl1273.o
181obj-$(CONFIG_SND_SOC_WM0010) += snd-soc-wm0010.o
180obj-$(CONFIG_SND_SOC_WM1250_EV1) += snd-soc-wm1250-ev1.o 182obj-$(CONFIG_SND_SOC_WM1250_EV1) += snd-soc-wm1250-ev1.o
181obj-$(CONFIG_SND_SOC_WM2000) += snd-soc-wm2000.o 183obj-$(CONFIG_SND_SOC_WM2000) += snd-soc-wm2000.o
182obj-$(CONFIG_SND_SOC_WM2200) += snd-soc-wm2200.o 184obj-$(CONFIG_SND_SOC_WM2200) += snd-soc-wm2200.o
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c
index 23b40186f9b8..2c1c2524ef8c 100644
--- a/sound/soc/codecs/ab8500-codec.c
+++ b/sound/soc/codecs/ab8500-codec.c
@@ -390,10 +390,10 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {
390 SND_SOC_DAPM_CLOCK_SUPPLY("audioclk"), 390 SND_SOC_DAPM_CLOCK_SUPPLY("audioclk"),
391 391
392 /* Regulators */ 392 /* Regulators */
393 SND_SOC_DAPM_REGULATOR_SUPPLY("V-AUD", 0), 393 SND_SOC_DAPM_REGULATOR_SUPPLY("V-AUD", 0, 0),
394 SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC1", 0), 394 SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC1", 0, 0),
395 SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC2", 0), 395 SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC2", 0, 0),
396 SND_SOC_DAPM_REGULATOR_SUPPLY("V-DMIC", 0), 396 SND_SOC_DAPM_REGULATOR_SUPPLY("V-DMIC", 0, 0),
397 397
398 /* Power */ 398 /* Power */
399 SND_SOC_DAPM_SUPPLY("Audio Power", 399 SND_SOC_DAPM_SUPPLY("Audio Power",
@@ -2405,10 +2405,7 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
2405 dev_dbg(dev, "%s: Enter.\n", __func__); 2405 dev_dbg(dev, "%s: Enter.\n", __func__);
2406 2406
2407 /* Setup AB8500 according to board-settings */ 2407 /* Setup AB8500 according to board-settings */
2408 pdata = (struct ab8500_platform_data *)dev_get_platdata(dev->parent); 2408 pdata = dev_get_platdata(dev->parent);
2409
2410 /* Inform SoC Core that we have our own I/O arrangements. */
2411 codec->control_data = (void *)true;
2412 2409
2413 status = ab8500_audio_setup_mics(codec, &pdata->codec->amics); 2410 status = ab8500_audio_setup_mics(codec, &pdata->codec->amics);
2414 if (status < 0) { 2411 if (status < 0) {
diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c
index c67b50d8b317..dce6ebeef452 100644
--- a/sound/soc/codecs/ad1836.c
+++ b/sound/soc/codecs/ad1836.c
@@ -19,6 +19,8 @@
19#include <sound/soc.h> 19#include <sound/soc.h>
20#include <sound/tlv.h> 20#include <sound/tlv.h>
21#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
22#include <linux/regmap.h>
23
22#include "ad1836.h" 24#include "ad1836.h"
23 25
24enum ad1836_type { 26enum ad1836_type {
@@ -30,6 +32,7 @@ enum ad1836_type {
30/* codec private data */ 32/* codec private data */
31struct ad1836_priv { 33struct ad1836_priv {
32 enum ad1836_type type; 34 enum ad1836_type type;
35 struct regmap *regmap;
33}; 36};
34 37
35/* 38/*
@@ -161,8 +164,8 @@ static int ad1836_hw_params(struct snd_pcm_substream *substream,
161 struct snd_pcm_hw_params *params, 164 struct snd_pcm_hw_params *params,
162 struct snd_soc_dai *dai) 165 struct snd_soc_dai *dai)
163{ 166{
167 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(dai->codec);
164 int word_len = 0; 168 int word_len = 0;
165 struct snd_soc_codec *codec = dai->codec;
166 169
167 /* bit size */ 170 /* bit size */
168 switch (params_format(params)) { 171 switch (params_format(params)) {
@@ -178,10 +181,12 @@ static int ad1836_hw_params(struct snd_pcm_substream *substream,
178 break; 181 break;
179 } 182 }
180 183
181 snd_soc_update_bits(codec, AD1836_DAC_CTRL1, AD1836_DAC_WORD_LEN_MASK, 184 regmap_update_bits(ad1836->regmap, AD1836_DAC_CTRL1,
185 AD1836_DAC_WORD_LEN_MASK,
182 word_len << AD1836_DAC_WORD_LEN_OFFSET); 186 word_len << AD1836_DAC_WORD_LEN_OFFSET);
183 187
184 snd_soc_update_bits(codec, AD1836_ADC_CTRL2, AD1836_ADC_WORD_LEN_MASK, 188 regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
189 AD1836_ADC_WORD_LEN_MASK,
185 word_len << AD1836_ADC_WORD_OFFSET); 190 word_len << AD1836_ADC_WORD_OFFSET);
186 191
187 return 0; 192 return 0;
@@ -223,15 +228,17 @@ static struct snd_soc_dai_driver ad183x_dais[] = {
223#ifdef CONFIG_PM 228#ifdef CONFIG_PM
224static int ad1836_suspend(struct snd_soc_codec *codec) 229static int ad1836_suspend(struct snd_soc_codec *codec)
225{ 230{
231 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec);
226 /* reset clock control mode */ 232 /* reset clock control mode */
227 return snd_soc_update_bits(codec, AD1836_ADC_CTRL2, 233 return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
228 AD1836_ADC_SERFMT_MASK, 0); 234 AD1836_ADC_SERFMT_MASK, 0);
229} 235}
230 236
231static int ad1836_resume(struct snd_soc_codec *codec) 237static int ad1836_resume(struct snd_soc_codec *codec)
232{ 238{
239 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec);
233 /* restore clock control mode */ 240 /* restore clock control mode */
234 return snd_soc_update_bits(codec, AD1836_ADC_CTRL2, 241 return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
235 AD1836_ADC_SERFMT_MASK, AD1836_ADC_AUX); 242 AD1836_ADC_SERFMT_MASK, AD1836_ADC_AUX);
236} 243}
237#else 244#else
@@ -250,37 +257,30 @@ static int ad1836_probe(struct snd_soc_codec *codec)
250 num_dacs = ad183x_dais[ad1836->type].playback.channels_max / 2; 257 num_dacs = ad183x_dais[ad1836->type].playback.channels_max / 2;
251 num_adcs = ad183x_dais[ad1836->type].capture.channels_max / 2; 258 num_adcs = ad183x_dais[ad1836->type].capture.channels_max / 2;
252 259
253 ret = snd_soc_codec_set_cache_io(codec, 4, 12, SND_SOC_SPI);
254 if (ret < 0) {
255 dev_err(codec->dev, "failed to set cache I/O: %d\n",
256 ret);
257 return ret;
258 }
259
260 /* default setting for ad1836 */ 260 /* default setting for ad1836 */
261 /* de-emphasis: 48kHz, power-on dac */ 261 /* de-emphasis: 48kHz, power-on dac */
262 snd_soc_write(codec, AD1836_DAC_CTRL1, 0x300); 262 regmap_write(ad1836->regmap, AD1836_DAC_CTRL1, 0x300);
263 /* unmute dac channels */ 263 /* unmute dac channels */
264 snd_soc_write(codec, AD1836_DAC_CTRL2, 0x0); 264 regmap_write(ad1836->regmap, AD1836_DAC_CTRL2, 0x0);
265 /* high-pass filter enable, power-on adc */ 265 /* high-pass filter enable, power-on adc */
266 snd_soc_write(codec, AD1836_ADC_CTRL1, 0x100); 266 regmap_write(ad1836->regmap, AD1836_ADC_CTRL1, 0x100);
267 /* unmute adc channles, adc aux mode */ 267 /* unmute adc channles, adc aux mode */
268 snd_soc_write(codec, AD1836_ADC_CTRL2, 0x180); 268 regmap_write(ad1836->regmap, AD1836_ADC_CTRL2, 0x180);
269 /* volume */ 269 /* volume */
270 for (i = 1; i <= num_dacs; ++i) { 270 for (i = 1; i <= num_dacs; ++i) {
271 snd_soc_write(codec, AD1836_DAC_L_VOL(i), 0x3FF); 271 regmap_write(ad1836->regmap, AD1836_DAC_L_VOL(i), 0x3FF);
272 snd_soc_write(codec, AD1836_DAC_R_VOL(i), 0x3FF); 272 regmap_write(ad1836->regmap, AD1836_DAC_R_VOL(i), 0x3FF);
273 } 273 }
274 274
275 if (ad1836->type == AD1836) { 275 if (ad1836->type == AD1836) {
276 /* left/right diff:PGA/MUX */ 276 /* left/right diff:PGA/MUX */
277 snd_soc_write(codec, AD1836_ADC_CTRL3, 0x3A); 277 regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x3A);
278 ret = snd_soc_add_codec_controls(codec, ad1836_controls, 278 ret = snd_soc_add_codec_controls(codec, ad1836_controls,
279 ARRAY_SIZE(ad1836_controls)); 279 ARRAY_SIZE(ad1836_controls));
280 if (ret) 280 if (ret)
281 return ret; 281 return ret;
282 } else { 282 } else {
283 snd_soc_write(codec, AD1836_ADC_CTRL3, 0x00); 283 regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x00);
284 } 284 }
285 285
286 ret = snd_soc_add_codec_controls(codec, ad183x_dac_controls, num_dacs * 2); 286 ret = snd_soc_add_codec_controls(codec, ad183x_dac_controls, num_dacs * 2);
@@ -313,8 +313,9 @@ static int ad1836_probe(struct snd_soc_codec *codec)
313/* power down chip */ 313/* power down chip */
314static int ad1836_remove(struct snd_soc_codec *codec) 314static int ad1836_remove(struct snd_soc_codec *codec)
315{ 315{
316 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec);
316 /* reset clock control mode */ 317 /* reset clock control mode */
317 return snd_soc_update_bits(codec, AD1836_ADC_CTRL2, 318 return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
318 AD1836_ADC_SERFMT_MASK, 0); 319 AD1836_ADC_SERFMT_MASK, 0);
319} 320}
320 321
@@ -323,8 +324,6 @@ static struct snd_soc_codec_driver soc_codec_dev_ad1836 = {
323 .remove = ad1836_remove, 324 .remove = ad1836_remove,
324 .suspend = ad1836_suspend, 325 .suspend = ad1836_suspend,
325 .resume = ad1836_resume, 326 .resume = ad1836_resume,
326 .reg_cache_size = AD1836_NUM_REGS,
327 .reg_word_size = sizeof(u16),
328 327
329 .controls = ad183x_controls, 328 .controls = ad183x_controls,
330 .num_controls = ARRAY_SIZE(ad183x_controls), 329 .num_controls = ARRAY_SIZE(ad183x_controls),
@@ -334,6 +333,33 @@ static struct snd_soc_codec_driver soc_codec_dev_ad1836 = {
334 .num_dapm_routes = ARRAY_SIZE(ad183x_dapm_routes), 333 .num_dapm_routes = ARRAY_SIZE(ad183x_dapm_routes),
335}; 334};
336 335
336static const struct reg_default ad1836_reg_defaults[] = {
337 { AD1836_DAC_CTRL1, 0x0000 },
338 { AD1836_DAC_CTRL2, 0x0000 },
339 { AD1836_DAC_L_VOL(0), 0x0000 },
340 { AD1836_DAC_R_VOL(0), 0x0000 },
341 { AD1836_DAC_L_VOL(1), 0x0000 },
342 { AD1836_DAC_R_VOL(1), 0x0000 },
343 { AD1836_DAC_L_VOL(2), 0x0000 },
344 { AD1836_DAC_R_VOL(2), 0x0000 },
345 { AD1836_DAC_L_VOL(3), 0x0000 },
346 { AD1836_DAC_R_VOL(3), 0x0000 },
347 { AD1836_ADC_CTRL1, 0x0000 },
348 { AD1836_ADC_CTRL2, 0x0000 },
349 { AD1836_ADC_CTRL3, 0x0000 },
350};
351
352static const struct regmap_config ad1836_regmap_config = {
353 .val_bits = 12,
354 .reg_bits = 4,
355 .read_flag_mask = 0x08,
356
357 .max_register = AD1836_ADC_CTRL3,
358 .reg_defaults = ad1836_reg_defaults,
359 .num_reg_defaults = ARRAY_SIZE(ad1836_reg_defaults),
360 .cache_type = REGCACHE_RBTREE,
361};
362
337static int __devinit ad1836_spi_probe(struct spi_device *spi) 363static int __devinit ad1836_spi_probe(struct spi_device *spi)
338{ 364{
339 struct ad1836_priv *ad1836; 365 struct ad1836_priv *ad1836;
@@ -344,6 +370,10 @@ static int __devinit ad1836_spi_probe(struct spi_device *spi)
344 if (ad1836 == NULL) 370 if (ad1836 == NULL)
345 return -ENOMEM; 371 return -ENOMEM;
346 372
373 ad1836->regmap = devm_regmap_init_spi(spi, &ad1836_regmap_config);
374 if (IS_ERR(ad1836->regmap))
375 return PTR_ERR(ad1836->regmap);
376
347 ad1836->type = spi_get_device_id(spi)->driver_data; 377 ad1836->type = spi_get_device_id(spi)->driver_data;
348 378
349 spi_set_drvdata(spi, ad1836); 379 spi_set_drvdata(spi, ad1836);
@@ -379,17 +409,7 @@ static struct spi_driver ad1836_spi_driver = {
379 .id_table = ad1836_ids, 409 .id_table = ad1836_ids,
380}; 410};
381 411
382static int __init ad1836_init(void) 412module_spi_driver(ad1836_spi_driver);
383{
384 return spi_register_driver(&ad1836_spi_driver);
385}
386module_init(ad1836_init);
387
388static void __exit ad1836_exit(void)
389{
390 spi_unregister_driver(&ad1836_spi_driver);
391}
392module_exit(ad1836_exit);
393 413
394MODULE_DESCRIPTION("ASoC ad1836 driver"); 414MODULE_DESCRIPTION("ASoC ad1836 driver");
395MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); 415MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c
index 13e62be4f990..2f752660f678 100644
--- a/sound/soc/codecs/ad193x.c
+++ b/sound/soc/codecs/ad193x.c
@@ -381,40 +381,25 @@ static const struct regmap_config ad193x_spi_regmap_config = {
381static int __devinit ad193x_spi_probe(struct spi_device *spi) 381static int __devinit ad193x_spi_probe(struct spi_device *spi)
382{ 382{
383 struct ad193x_priv *ad193x; 383 struct ad193x_priv *ad193x;
384 int ret;
385 384
386 ad193x = devm_kzalloc(&spi->dev, sizeof(struct ad193x_priv), 385 ad193x = devm_kzalloc(&spi->dev, sizeof(struct ad193x_priv),
387 GFP_KERNEL); 386 GFP_KERNEL);
388 if (ad193x == NULL) 387 if (ad193x == NULL)
389 return -ENOMEM; 388 return -ENOMEM;
390 389
391 ad193x->regmap = regmap_init_spi(spi, &ad193x_spi_regmap_config); 390 ad193x->regmap = devm_regmap_init_spi(spi, &ad193x_spi_regmap_config);
392 if (IS_ERR(ad193x->regmap)) { 391 if (IS_ERR(ad193x->regmap))
393 ret = PTR_ERR(ad193x->regmap); 392 return PTR_ERR(ad193x->regmap);
394 goto err_out;
395 }
396 393
397 spi_set_drvdata(spi, ad193x); 394 spi_set_drvdata(spi, ad193x);
398 395
399 ret = snd_soc_register_codec(&spi->dev, 396 return snd_soc_register_codec(&spi->dev, &soc_codec_dev_ad193x,
400 &soc_codec_dev_ad193x, &ad193x_dai, 1); 397 &ad193x_dai, 1);
401 if (ret < 0)
402 goto err_regmap_exit;
403
404 return 0;
405
406err_regmap_exit:
407 regmap_exit(ad193x->regmap);
408err_out:
409 return ret;
410} 398}
411 399
412static int __devexit ad193x_spi_remove(struct spi_device *spi) 400static int __devexit ad193x_spi_remove(struct spi_device *spi)
413{ 401{
414 struct ad193x_priv *ad193x = spi_get_drvdata(spi);
415
416 snd_soc_unregister_codec(&spi->dev); 402 snd_soc_unregister_codec(&spi->dev);
417 regmap_exit(ad193x->regmap);
418 return 0; 403 return 0;
419} 404}
420 405
@@ -449,40 +434,25 @@ static int __devinit ad193x_i2c_probe(struct i2c_client *client,
449 const struct i2c_device_id *id) 434 const struct i2c_device_id *id)
450{ 435{
451 struct ad193x_priv *ad193x; 436 struct ad193x_priv *ad193x;
452 int ret;
453 437
454 ad193x = devm_kzalloc(&client->dev, sizeof(struct ad193x_priv), 438 ad193x = devm_kzalloc(&client->dev, sizeof(struct ad193x_priv),
455 GFP_KERNEL); 439 GFP_KERNEL);
456 if (ad193x == NULL) 440 if (ad193x == NULL)
457 return -ENOMEM; 441 return -ENOMEM;
458 442
459 ad193x->regmap = regmap_init_i2c(client, &ad193x_i2c_regmap_config); 443 ad193x->regmap = devm_regmap_init_i2c(client, &ad193x_i2c_regmap_config);
460 if (IS_ERR(ad193x->regmap)) { 444 if (IS_ERR(ad193x->regmap))
461 ret = PTR_ERR(ad193x->regmap); 445 return PTR_ERR(ad193x->regmap);
462 goto err_out;
463 }
464 446
465 i2c_set_clientdata(client, ad193x); 447 i2c_set_clientdata(client, ad193x);
466 448
467 ret = snd_soc_register_codec(&client->dev, 449 return snd_soc_register_codec(&client->dev, &soc_codec_dev_ad193x,
468 &soc_codec_dev_ad193x, &ad193x_dai, 1); 450 &ad193x_dai, 1);
469 if (ret < 0)
470 goto err_regmap_exit;
471
472 return 0;
473
474err_regmap_exit:
475 regmap_exit(ad193x->regmap);
476err_out:
477 return ret;
478} 451}
479 452
480static int __devexit ad193x_i2c_remove(struct i2c_client *client) 453static int __devexit ad193x_i2c_remove(struct i2c_client *client)
481{ 454{
482 struct ad193x_priv *ad193x = i2c_get_clientdata(client);
483
484 snd_soc_unregister_codec(&client->dev); 455 snd_soc_unregister_codec(&client->dev);
485 regmap_exit(ad193x->regmap);
486 return 0; 456 return 0;
487} 457}
488 458
diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c
index 11b1b714b8b5..8c39dddd7d00 100644
--- a/sound/soc/codecs/ad1980.c
+++ b/sound/soc/codecs/ad1980.c
@@ -186,7 +186,6 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
186 186
187 printk(KERN_INFO "AD1980 SoC Audio Codec\n"); 187 printk(KERN_INFO "AD1980 SoC Audio Codec\n");
188 188
189 codec->control_data = codec; /* we don't use regmap! */
190 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); 189 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
191 if (ret < 0) { 190 if (ret < 0) {
192 printk(KERN_ERR "ad1980: failed to register AC97 codec\n"); 191 printk(KERN_ERR "ad1980: failed to register AC97 codec\n");
diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c
index 44f59064d8de..704544bfc90d 100644
--- a/sound/soc/codecs/adau1373.c
+++ b/sound/soc/codecs/adau1373.c
@@ -1392,17 +1392,7 @@ static struct i2c_driver adau1373_i2c_driver = {
1392 .id_table = adau1373_i2c_id, 1392 .id_table = adau1373_i2c_id,
1393}; 1393};
1394 1394
1395static int __init adau1373_init(void) 1395module_i2c_driver(adau1373_i2c_driver);
1396{
1397 return i2c_add_driver(&adau1373_i2c_driver);
1398}
1399module_init(adau1373_init);
1400
1401static void __exit adau1373_exit(void)
1402{
1403 i2c_del_driver(&adau1373_i2c_driver);
1404}
1405module_exit(adau1373_exit);
1406 1396
1407MODULE_DESCRIPTION("ASoC ADAU1373 driver"); 1397MODULE_DESCRIPTION("ASoC ADAU1373 driver");
1408MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); 1398MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
index 3d50fc8646b6..51f2f3cd8136 100644
--- a/sound/soc/codecs/adau1701.c
+++ b/sound/soc/codecs/adau1701.c
@@ -527,17 +527,7 @@ static struct i2c_driver adau1701_i2c_driver = {
527 .id_table = adau1701_i2c_id, 527 .id_table = adau1701_i2c_id,
528}; 528};
529 529
530static int __init adau1701_init(void) 530module_i2c_driver(adau1701_i2c_driver);
531{
532 return i2c_add_driver(&adau1701_i2c_driver);
533}
534module_init(adau1701_init);
535
536static void __exit adau1701_exit(void)
537{
538 i2c_del_driver(&adau1701_i2c_driver);
539}
540module_exit(adau1701_exit);
541 531
542MODULE_DESCRIPTION("ASoC ADAU1701 SigmaDSP driver"); 532MODULE_DESCRIPTION("ASoC ADAU1701 SigmaDSP driver");
543MODULE_AUTHOR("Cliff Cai <cliff.cai@analog.com>"); 533MODULE_AUTHOR("Cliff Cai <cliff.cai@analog.com>");
diff --git a/sound/soc/codecs/ak4671.c b/sound/soc/codecs/ak4671.c
index 5fb7c2a80e6d..2b457976a7bf 100644
--- a/sound/soc/codecs/ak4671.c
+++ b/sound/soc/codecs/ak4671.c
@@ -696,17 +696,7 @@ static struct i2c_driver ak4671_i2c_driver = {
696 .id_table = ak4671_i2c_id, 696 .id_table = ak4671_i2c_id,
697}; 697};
698 698
699static int __init ak4671_modinit(void) 699module_i2c_driver(ak4671_i2c_driver);
700{
701 return i2c_add_driver(&ak4671_i2c_driver);
702}
703module_init(ak4671_modinit);
704
705static void __exit ak4671_exit(void)
706{
707 i2c_del_driver(&ak4671_i2c_driver);
708}
709module_exit(ak4671_exit);
710 700
711MODULE_DESCRIPTION("ASoC AK4671 codec driver"); 701MODULE_DESCRIPTION("ASoC AK4671 codec driver");
712MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); 702MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 5c9cacaf2d52..c167c896eaee 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -229,6 +229,69 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w,
229} 229}
230EXPORT_SYMBOL_GPL(arizona_out_ev); 230EXPORT_SYMBOL_GPL(arizona_out_ev);
231 231
232static unsigned int arizona_sysclk_48k_rates[] = {
233 6144000,
234 12288000,
235 22579200,
236 49152000,
237};
238
239static unsigned int arizona_sysclk_44k1_rates[] = {
240 5644800,
241 11289600,
242 24576000,
243 45158400,
244};
245
246static int arizona_set_opclk(struct snd_soc_codec *codec, unsigned int clk,
247 unsigned int freq)
248{
249 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
250 unsigned int reg;
251 unsigned int *rates;
252 int ref, div, refclk;
253
254 switch (clk) {
255 case ARIZONA_CLK_OPCLK:
256 reg = ARIZONA_OUTPUT_SYSTEM_CLOCK;
257 refclk = priv->sysclk;
258 break;
259 case ARIZONA_CLK_ASYNC_OPCLK:
260 reg = ARIZONA_OUTPUT_ASYNC_CLOCK;
261 refclk = priv->asyncclk;
262 break;
263 default:
264 return -EINVAL;
265 }
266
267 if (refclk % 8000)
268 rates = arizona_sysclk_44k1_rates;
269 else
270 rates = arizona_sysclk_48k_rates;
271
272 for (ref = 0; ref < ARRAY_SIZE(arizona_sysclk_48k_rates) &&
273 rates[ref] <= refclk; ref++) {
274 div = 1;
275 while (rates[ref] / div >= freq && div < 32) {
276 if (rates[ref] / div == freq) {
277 dev_dbg(codec->dev, "Configured %dHz OPCLK\n",
278 freq);
279 snd_soc_update_bits(codec, reg,
280 ARIZONA_OPCLK_DIV_MASK |
281 ARIZONA_OPCLK_SEL_MASK,
282 (div <<
283 ARIZONA_OPCLK_DIV_SHIFT) |
284 ref);
285 return 0;
286 }
287 div++;
288 }
289 }
290
291 dev_err(codec->dev, "Unable to generate %dHz OPCLK\n", freq);
292 return -EINVAL;
293}
294
232int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id, 295int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id,
233 int source, unsigned int freq, int dir) 296 int source, unsigned int freq, int dir)
234{ 297{
@@ -252,6 +315,9 @@ int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id,
252 reg = ARIZONA_ASYNC_CLOCK_1; 315 reg = ARIZONA_ASYNC_CLOCK_1;
253 clk = &priv->asyncclk; 316 clk = &priv->asyncclk;
254 break; 317 break;
318 case ARIZONA_CLK_OPCLK:
319 case ARIZONA_CLK_ASYNC_OPCLK:
320 return arizona_set_opclk(codec, clk_id, freq);
255 default: 321 default:
256 return -EINVAL; 322 return -EINVAL;
257 } 323 }
@@ -426,7 +492,7 @@ static const int arizona_44k1_bclk_rates[] = {
426 940800, 492 940800,
427 1411200, 493 1411200,
428 1881600, 494 1881600,
429 2882400, 495 2822400,
430 3763200, 496 3763200,
431 5644800, 497 5644800,
432 7526400, 498 7526400,
@@ -666,7 +732,7 @@ static irqreturn_t arizona_fll_lock(int irq, void *data)
666{ 732{
667 struct arizona_fll *fll = data; 733 struct arizona_fll *fll = data;
668 734
669 arizona_fll_dbg(fll, "Locked\n"); 735 arizona_fll_dbg(fll, "Lock status changed\n");
670 736
671 complete(&fll->lock); 737 complete(&fll->lock);
672 738
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 59caca8865e8..eb66b52777c9 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -17,8 +17,10 @@
17 17
18#include <sound/soc.h> 18#include <sound/soc.h>
19 19
20#define ARIZONA_CLK_SYSCLK 1 20#define ARIZONA_CLK_SYSCLK 1
21#define ARIZONA_CLK_ASYNCCLK 2 21#define ARIZONA_CLK_ASYNCCLK 2
22#define ARIZONA_CLK_OPCLK 3
23#define ARIZONA_CLK_ASYNC_OPCLK 4
22 24
23#define ARIZONA_CLK_SRC_MCLK1 0x0 25#define ARIZONA_CLK_SRC_MCLK1 0x0
24#define ARIZONA_CLK_SRC_MCLK2 0x1 26#define ARIZONA_CLK_SRC_MCLK2 0x1
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index 047917f0b8ae..815b53bc2d27 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -29,6 +29,8 @@
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/regulator/consumer.h> 31#include <linux/regulator/consumer.h>
32#include <linux/of_device.h>
33#include <linux/of_gpio.h>
32 34
33/* 35/*
34 * The codec isn't really big-endian or little-endian, since the I2S 36 * The codec isn't really big-endian or little-endian, since the I2S
@@ -110,14 +112,15 @@
110 * This array contains the power-on default values of the registers, with the 112 * This array contains the power-on default values of the registers, with the
111 * exception of the "CHIPID" register (01h). The lower four bits of that 113 * exception of the "CHIPID" register (01h). The lower four bits of that
112 * register contain the hardware revision, so it is treated as volatile. 114 * register contain the hardware revision, so it is treated as volatile.
113 *
114 * Also note that on the CS4270, the first readable register is 1, but ASoC
115 * assumes the first register is 0. Therfore, the array must have an entry for
116 * register 0, but we use cs4270_reg_is_readable() to tell ASoC that it can't
117 * be read.
118 */ 115 */
119static const u8 cs4270_default_reg_cache[CS4270_LASTREG + 1] = { 116static const struct reg_default cs4270_reg_defaults[] = {
120 0x00, 0x00, 0x00, 0x30, 0x00, 0x60, 0x20, 0x00, 0x00 117 { 2, 0x00 },
118 { 3, 0x30 },
119 { 4, 0x00 },
120 { 5, 0x60 },
121 { 6, 0x20 },
122 { 7, 0x00 },
123 { 8, 0x00 },
121}; 124};
122 125
123static const char *supply_names[] = { 126static const char *supply_names[] = {
@@ -126,7 +129,7 @@ static const char *supply_names[] = {
126 129
127/* Private data for the CS4270 */ 130/* Private data for the CS4270 */
128struct cs4270_private { 131struct cs4270_private {
129 enum snd_soc_control_type control_type; 132 struct regmap *regmap;
130 unsigned int mclk; /* Input frequency of the MCLK pin */ 133 unsigned int mclk; /* Input frequency of the MCLK pin */
131 unsigned int mode; /* The mode (I2S or left-justified) */ 134 unsigned int mode; /* The mode (I2S or left-justified) */
132 unsigned int slave_mode; 135 unsigned int slave_mode;
@@ -191,12 +194,12 @@ static struct cs4270_mode_ratios cs4270_mode_ratios[] = {
191/* The number of MCLK/LRCK ratios supported by the CS4270 */ 194/* The number of MCLK/LRCK ratios supported by the CS4270 */
192#define NUM_MCLK_RATIOS ARRAY_SIZE(cs4270_mode_ratios) 195#define NUM_MCLK_RATIOS ARRAY_SIZE(cs4270_mode_ratios)
193 196
194static int cs4270_reg_is_readable(struct snd_soc_codec *codec, unsigned int reg) 197static bool cs4270_reg_is_readable(struct device *dev, unsigned int reg)
195{ 198{
196 return (reg >= CS4270_FIRSTREG) && (reg <= CS4270_LASTREG); 199 return (reg >= CS4270_FIRSTREG) && (reg <= CS4270_LASTREG);
197} 200}
198 201
199static int cs4270_reg_is_volatile(struct snd_soc_codec *codec, unsigned int reg) 202static bool cs4270_reg_is_volatile(struct device *dev, unsigned int reg)
200{ 203{
201 /* Unreadable registers are considered volatile */ 204 /* Unreadable registers are considered volatile */
202 if ((reg < CS4270_FIRSTREG) || (reg > CS4270_LASTREG)) 205 if ((reg < CS4270_FIRSTREG) || (reg > CS4270_LASTREG))
@@ -485,12 +488,12 @@ static struct snd_soc_dai_driver cs4270_dai = {
485static int cs4270_probe(struct snd_soc_codec *codec) 488static int cs4270_probe(struct snd_soc_codec *codec)
486{ 489{
487 struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); 490 struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec);
488 int i, ret; 491 int ret;
489 492
490 /* Tell ASoC what kind of I/O to use to read the registers. ASoC will 493 /* Tell ASoC what kind of I/O to use to read the registers. ASoC will
491 * then do the I2C transactions itself. 494 * then do the I2C transactions itself.
492 */ 495 */
493 ret = snd_soc_codec_set_cache_io(codec, 8, 8, cs4270->control_type); 496 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
494 if (ret < 0) { 497 if (ret < 0) {
495 dev_err(codec->dev, "failed to set cache I/O (ret=%i)\n", ret); 498 dev_err(codec->dev, "failed to set cache I/O (ret=%i)\n", ret);
496 return ret; 499 return ret;
@@ -519,33 +522,8 @@ static int cs4270_probe(struct snd_soc_codec *codec)
519 return ret; 522 return ret;
520 } 523 }
521 524
522 /* Add the non-DAPM controls */
523 ret = snd_soc_add_codec_controls(codec, cs4270_snd_controls,
524 ARRAY_SIZE(cs4270_snd_controls));
525 if (ret < 0) {
526 dev_err(codec->dev, "failed to add controls\n");
527 return ret;
528 }
529
530 /* get the power supply regulators */
531 for (i = 0; i < ARRAY_SIZE(supply_names); i++)
532 cs4270->supplies[i].supply = supply_names[i];
533
534 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(cs4270->supplies),
535 cs4270->supplies);
536 if (ret < 0)
537 return ret;
538
539 ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies), 525 ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies),
540 cs4270->supplies); 526 cs4270->supplies);
541 if (ret < 0)
542 goto error_free_regulators;
543
544 return 0;
545
546error_free_regulators:
547 regulator_bulk_free(ARRAY_SIZE(cs4270->supplies),
548 cs4270->supplies);
549 527
550 return ret; 528 return ret;
551} 529}
@@ -561,7 +539,6 @@ static int cs4270_remove(struct snd_soc_codec *codec)
561 struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); 539 struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec);
562 540
563 regulator_bulk_disable(ARRAY_SIZE(cs4270->supplies), cs4270->supplies); 541 regulator_bulk_disable(ARRAY_SIZE(cs4270->supplies), cs4270->supplies);
564 regulator_bulk_free(ARRAY_SIZE(cs4270->supplies), cs4270->supplies);
565 542
566 return 0; 543 return 0;
567}; 544};
@@ -611,7 +588,7 @@ static int cs4270_soc_resume(struct snd_soc_codec *codec)
611 ndelay(500); 588 ndelay(500);
612 589
613 /* first restore the entire register cache ... */ 590 /* first restore the entire register cache ... */
614 snd_soc_cache_sync(codec); 591 regcache_sync(cs4270->regmap);
615 592
616 /* ... then disable the power-down bits */ 593 /* ... then disable the power-down bits */
617 reg = snd_soc_read(codec, CS4270_PWRCTL); 594 reg = snd_soc_read(codec, CS4270_PWRCTL);
@@ -632,11 +609,30 @@ static const struct snd_soc_codec_driver soc_codec_device_cs4270 = {
632 .remove = cs4270_remove, 609 .remove = cs4270_remove,
633 .suspend = cs4270_soc_suspend, 610 .suspend = cs4270_soc_suspend,
634 .resume = cs4270_soc_resume, 611 .resume = cs4270_soc_resume,
635 .volatile_register = cs4270_reg_is_volatile, 612
636 .readable_register = cs4270_reg_is_readable, 613 .controls = cs4270_snd_controls,
637 .reg_cache_size = CS4270_LASTREG + 1, 614 .num_controls = ARRAY_SIZE(cs4270_snd_controls),
638 .reg_word_size = sizeof(u8), 615};
639 .reg_cache_default = cs4270_default_reg_cache, 616
617/*
618 * cs4270_of_match - the device tree bindings
619 */
620static const struct of_device_id cs4270_of_match[] = {
621 { .compatible = "cirrus,cs4270", },
622 { }
623};
624MODULE_DEVICE_TABLE(of, cs4270_of_match);
625
626static const struct regmap_config cs4270_regmap = {
627 .reg_bits = 8,
628 .val_bits = 8,
629 .max_register = CS4270_LASTREG,
630 .reg_defaults = cs4270_reg_defaults,
631 .num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults),
632 .cache_type = REGCACHE_RBTREE,
633
634 .readable_reg = cs4270_reg_is_readable,
635 .volatile_reg = cs4270_reg_is_volatile,
640}; 636};
641 637
642/** 638/**
@@ -650,19 +646,56 @@ static const struct snd_soc_codec_driver soc_codec_device_cs4270 = {
650static int cs4270_i2c_probe(struct i2c_client *i2c_client, 646static int cs4270_i2c_probe(struct i2c_client *i2c_client,
651 const struct i2c_device_id *id) 647 const struct i2c_device_id *id)
652{ 648{
649 struct device_node *np = i2c_client->dev.of_node;
653 struct cs4270_private *cs4270; 650 struct cs4270_private *cs4270;
654 int ret; 651 unsigned int val;
652 int ret, i;
655 653
656 /* Verify that we have a CS4270 */ 654 cs4270 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4270_private),
655 GFP_KERNEL);
656 if (!cs4270) {
657 dev_err(&i2c_client->dev, "could not allocate codec\n");
658 return -ENOMEM;
659 }
660
661 /* get the power supply regulators */
662 for (i = 0; i < ARRAY_SIZE(supply_names); i++)
663 cs4270->supplies[i].supply = supply_names[i];
664
665 ret = devm_regulator_bulk_get(&i2c_client->dev,
666 ARRAY_SIZE(cs4270->supplies),
667 cs4270->supplies);
668 if (ret < 0)
669 return ret;
670
671 /* See if we have a way to bring the codec out of reset */
672 if (np) {
673 enum of_gpio_flags flags;
674 int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags);
675
676 if (gpio_is_valid(gpio)) {
677 ret = devm_gpio_request_one(&i2c_client->dev, gpio,
678 flags & OF_GPIO_ACTIVE_LOW ?
679 GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH,
680 "cs4270 reset");
681 if (ret < 0)
682 return ret;
683 }
684 }
685
686 cs4270->regmap = devm_regmap_init_i2c(i2c_client, &cs4270_regmap);
687 if (IS_ERR(cs4270->regmap))
688 return PTR_ERR(cs4270->regmap);
657 689
658 ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID); 690 /* Verify that we have a CS4270 */
691 ret = regmap_read(cs4270->regmap, CS4270_CHIPID, &val);
659 if (ret < 0) { 692 if (ret < 0) {
660 dev_err(&i2c_client->dev, "failed to read i2c at addr %X\n", 693 dev_err(&i2c_client->dev, "failed to read i2c at addr %X\n",
661 i2c_client->addr); 694 i2c_client->addr);
662 return ret; 695 return ret;
663 } 696 }
664 /* The top four bits of the chip ID should be 1100. */ 697 /* The top four bits of the chip ID should be 1100. */
665 if ((ret & 0xF0) != 0xC0) { 698 if ((val & 0xF0) != 0xC0) {
666 dev_err(&i2c_client->dev, "device at addr %X is not a CS4270\n", 699 dev_err(&i2c_client->dev, "device at addr %X is not a CS4270\n",
667 i2c_client->addr); 700 i2c_client->addr);
668 return -ENODEV; 701 return -ENODEV;
@@ -670,17 +703,9 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
670 703
671 dev_info(&i2c_client->dev, "found device at i2c address %X\n", 704 dev_info(&i2c_client->dev, "found device at i2c address %X\n",
672 i2c_client->addr); 705 i2c_client->addr);
673 dev_info(&i2c_client->dev, "hardware revision %X\n", ret & 0xF); 706 dev_info(&i2c_client->dev, "hardware revision %X\n", val & 0xF);
674
675 cs4270 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4270_private),
676 GFP_KERNEL);
677 if (!cs4270) {
678 dev_err(&i2c_client->dev, "could not allocate codec\n");
679 return -ENOMEM;
680 }
681 707
682 i2c_set_clientdata(i2c_client, cs4270); 708 i2c_set_clientdata(i2c_client, cs4270);
683 cs4270->control_type = SND_SOC_I2C;
684 709
685 ret = snd_soc_register_codec(&i2c_client->dev, 710 ret = snd_soc_register_codec(&i2c_client->dev,
686 &soc_codec_device_cs4270, &cs4270_dai, 1); 711 &soc_codec_device_cs4270, &cs4270_dai, 1);
@@ -718,23 +743,14 @@ static struct i2c_driver cs4270_i2c_driver = {
718 .driver = { 743 .driver = {
719 .name = "cs4270", 744 .name = "cs4270",
720 .owner = THIS_MODULE, 745 .owner = THIS_MODULE,
746 .of_match_table = cs4270_of_match,
721 }, 747 },
722 .id_table = cs4270_id, 748 .id_table = cs4270_id,
723 .probe = cs4270_i2c_probe, 749 .probe = cs4270_i2c_probe,
724 .remove = cs4270_i2c_remove, 750 .remove = cs4270_i2c_remove,
725}; 751};
726 752
727static int __init cs4270_init(void) 753module_i2c_driver(cs4270_i2c_driver);
728{
729 return i2c_add_driver(&cs4270_i2c_driver);
730}
731module_init(cs4270_init);
732
733static void __exit cs4270_exit(void)
734{
735 i2c_del_driver(&cs4270_i2c_driver);
736}
737module_exit(cs4270_exit);
738 754
739MODULE_AUTHOR("Timur Tabi <timur@freescale.com>"); 755MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
740MODULE_DESCRIPTION("Cirrus Logic CS4270 ALSA SoC Codec Driver"); 756MODULE_DESCRIPTION("Cirrus Logic CS4270 ALSA SoC Codec Driver");
diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c
index 091d0193f507..1e0fa3b5f79a 100644
--- a/sound/soc/codecs/cs42l51.c
+++ b/sound/soc/codecs/cs42l51.c
@@ -614,24 +614,7 @@ static struct i2c_driver cs42l51_i2c_driver = {
614 .remove = cs42l51_i2c_remove, 614 .remove = cs42l51_i2c_remove,
615}; 615};
616 616
617static int __init cs42l51_init(void) 617module_i2c_driver(cs42l51_i2c_driver);
618{
619 int ret;
620
621 ret = i2c_add_driver(&cs42l51_i2c_driver);
622 if (ret != 0) {
623 printk(KERN_ERR "%s: can't add i2c driver\n", __func__);
624 return ret;
625 }
626 return 0;
627}
628module_init(cs42l51_init);
629
630static void __exit cs42l51_exit(void)
631{
632 i2c_del_driver(&cs42l51_i2c_driver);
633}
634module_exit(cs42l51_exit);
635 618
636MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); 619MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
637MODULE_DESCRIPTION("Cirrus Logic CS42L51 ALSA SoC Codec Driver"); 620MODULE_DESCRIPTION("Cirrus Logic CS42L51 ALSA SoC Codec Driver");
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 628daf6a1d97..61599298fb26 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -24,7 +24,6 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/slab.h>
28#include <sound/core.h> 27#include <sound/core.h>
29#include <sound/pcm.h> 28#include <sound/pcm.h>
30#include <sound/pcm_params.h> 29#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/isabelle.c b/sound/soc/codecs/isabelle.c
index 5d8f39e32978..1bf55602c9eb 100644
--- a/sound/soc/codecs/isabelle.c
+++ b/sound/soc/codecs/isabelle.c
@@ -13,7 +13,6 @@
13 */ 13 */
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/moduleparam.h> 15#include <linux/moduleparam.h>
16#include <linux/version.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
diff --git a/sound/soc/codecs/lm4857.c b/sound/soc/codecs/lm4857.c
index ba4fafb93e56..81a328c78838 100644
--- a/sound/soc/codecs/lm4857.c
+++ b/sound/soc/codecs/lm4857.c
@@ -250,17 +250,7 @@ static struct i2c_driver lm4857_i2c_driver = {
250 .id_table = lm4857_i2c_id, 250 .id_table = lm4857_i2c_id,
251}; 251};
252 252
253static int __init lm4857_init(void) 253module_i2c_driver(lm4857_i2c_driver);
254{
255 return i2c_add_driver(&lm4857_i2c_driver);
256}
257module_init(lm4857_init);
258
259static void __exit lm4857_exit(void)
260{
261 i2c_del_driver(&lm4857_i2c_driver);
262}
263module_exit(lm4857_exit);
264 254
265MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); 255MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
266MODULE_DESCRIPTION("LM4857 amplifier driver"); 256MODULE_DESCRIPTION("LM4857 amplifier driver");
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index af7324b79dd0..3264a5169306 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -2107,23 +2107,7 @@ static struct i2c_driver max98088_i2c_driver = {
2107 .id_table = max98088_i2c_id, 2107 .id_table = max98088_i2c_id,
2108}; 2108};
2109 2109
2110static int __init max98088_init(void) 2110module_i2c_driver(max98088_i2c_driver);
2111{
2112 int ret;
2113
2114 ret = i2c_add_driver(&max98088_i2c_driver);
2115 if (ret)
2116 pr_err("Failed to register max98088 I2C driver: %d\n", ret);
2117
2118 return ret;
2119}
2120module_init(max98088_init);
2121
2122static void __exit max98088_exit(void)
2123{
2124 i2c_del_driver(&max98088_i2c_driver);
2125}
2126module_exit(max98088_exit);
2127 2111
2128MODULE_DESCRIPTION("ALSA SoC MAX98088 driver"); 2112MODULE_DESCRIPTION("ALSA SoC MAX98088 driver");
2129MODULE_AUTHOR("Peter Hsiang, Jesse Marroquin"); 2113MODULE_AUTHOR("Peter Hsiang, Jesse Marroquin");
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index 7cd508e16a5c..38d43c59d3f4 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -2533,23 +2533,7 @@ static struct i2c_driver max98095_i2c_driver = {
2533 .id_table = max98095_i2c_id, 2533 .id_table = max98095_i2c_id,
2534}; 2534};
2535 2535
2536static int __init max98095_init(void) 2536module_i2c_driver(max98095_i2c_driver);
2537{
2538 int ret;
2539
2540 ret = i2c_add_driver(&max98095_i2c_driver);
2541 if (ret)
2542 pr_err("Failed to register max98095 I2C driver: %d\n", ret);
2543
2544 return ret;
2545}
2546module_init(max98095_init);
2547
2548static void __exit max98095_exit(void)
2549{
2550 i2c_del_driver(&max98095_i2c_driver);
2551}
2552module_exit(max98095_exit);
2553 2537
2554MODULE_DESCRIPTION("ALSA SoC MAX98095 driver"); 2538MODULE_DESCRIPTION("ALSA SoC MAX98095 driver");
2555MODULE_AUTHOR("Peter Hsiang"); 2539MODULE_AUTHOR("Peter Hsiang");
diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c
index a1913091f56c..efe535c37b39 100644
--- a/sound/soc/codecs/max9850.c
+++ b/sound/soc/codecs/max9850.c
@@ -369,17 +369,7 @@ static struct i2c_driver max9850_i2c_driver = {
369 .id_table = max9850_i2c_id, 369 .id_table = max9850_i2c_id,
370}; 370};
371 371
372static int __init max9850_init(void) 372module_i2c_driver(max9850_i2c_driver);
373{
374 return i2c_add_driver(&max9850_i2c_driver);
375}
376module_init(max9850_init);
377
378static void __exit max9850_exit(void)
379{
380 i2c_del_driver(&max9850_i2c_driver);
381}
382module_exit(max9850_exit);
383 373
384MODULE_AUTHOR("Christian Glindkamp <christian.glindkamp@taskit.de>"); 374MODULE_AUTHOR("Christian Glindkamp <christian.glindkamp@taskit.de>");
385MODULE_DESCRIPTION("ASoC MAX9850 codec driver"); 375MODULE_DESCRIPTION("ASoC MAX9850 codec driver");
diff --git a/sound/soc/codecs/max9877.c b/sound/soc/codecs/max9877.c
index 3a2ba3d8fd6d..d15e5943c85e 100644
--- a/sound/soc/codecs/max9877.c
+++ b/sound/soc/codecs/max9877.c
@@ -291,17 +291,7 @@ static struct i2c_driver max9877_i2c_driver = {
291 .id_table = max9877_i2c_id, 291 .id_table = max9877_i2c_id,
292}; 292};
293 293
294static int __init max9877_init(void) 294module_i2c_driver(max9877_i2c_driver);
295{
296 return i2c_add_driver(&max9877_i2c_driver);
297}
298module_init(max9877_init);
299
300static void __exit max9877_exit(void)
301{
302 i2c_del_driver(&max9877_i2c_driver);
303}
304module_exit(max9877_exit);
305 295
306MODULE_DESCRIPTION("ASoC MAX9877 amp driver"); 296MODULE_DESCRIPTION("ASoC MAX9877 amp driver");
307MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); 297MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c
index 8f726c063f42..bc955999c8aa 100644
--- a/sound/soc/codecs/mc13783.c
+++ b/sound/soc/codecs/mc13783.c
@@ -426,16 +426,16 @@ static int mc13783_set_tdm_slot_sync(struct snd_soc_dai *dai,
426} 426}
427 427
428static const struct snd_kcontrol_new mc1l_amp_ctl = 428static const struct snd_kcontrol_new mc1l_amp_ctl =
429 SOC_DAPM_SINGLE("Switch", 38, 7, 1, 0); 429 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_TX, 7, 1, 0);
430 430
431static const struct snd_kcontrol_new mc1r_amp_ctl = 431static const struct snd_kcontrol_new mc1r_amp_ctl =
432 SOC_DAPM_SINGLE("Switch", 38, 5, 1, 0); 432 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_TX, 5, 1, 0);
433 433
434static const struct snd_kcontrol_new mc2_amp_ctl = 434static const struct snd_kcontrol_new mc2_amp_ctl =
435 SOC_DAPM_SINGLE("Switch", 38, 9, 1, 0); 435 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_TX, 9, 1, 0);
436 436
437static const struct snd_kcontrol_new atx_amp_ctl = 437static const struct snd_kcontrol_new atx_amp_ctl =
438 SOC_DAPM_SINGLE("Switch", 38, 11, 1, 0); 438 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_TX, 11, 1, 0);
439 439
440 440
441/* Virtual mux. The chip does the input selection automatically 441/* Virtual mux. The chip does the input selection automatically
@@ -461,22 +461,22 @@ static const struct snd_kcontrol_new right_input_mux =
461 SOC_DAPM_ENUM_VIRT("Route", adcr_enum); 461 SOC_DAPM_ENUM_VIRT("Route", adcr_enum);
462 462
463static const struct snd_kcontrol_new samp_ctl = 463static const struct snd_kcontrol_new samp_ctl =
464 SOC_DAPM_SINGLE("Switch", 36, 3, 1, 0); 464 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 3, 1, 0);
465 465
466static const struct snd_kcontrol_new lamp_ctl = 466static const struct snd_kcontrol_new lamp_ctl =
467 SOC_DAPM_SINGLE("Switch", 36, 5, 1, 0); 467 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 5, 1, 0);
468 468
469static const struct snd_kcontrol_new hlamp_ctl = 469static const struct snd_kcontrol_new hlamp_ctl =
470 SOC_DAPM_SINGLE("Switch", 36, 10, 1, 0); 470 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 10, 1, 0);
471 471
472static const struct snd_kcontrol_new hramp_ctl = 472static const struct snd_kcontrol_new hramp_ctl =
473 SOC_DAPM_SINGLE("Switch", 36, 9, 1, 0); 473 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 9, 1, 0);
474 474
475static const struct snd_kcontrol_new llamp_ctl = 475static const struct snd_kcontrol_new llamp_ctl =
476 SOC_DAPM_SINGLE("Switch", 36, 16, 1, 0); 476 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 16, 1, 0);
477 477
478static const struct snd_kcontrol_new lramp_ctl = 478static const struct snd_kcontrol_new lramp_ctl =
479 SOC_DAPM_SINGLE("Switch", 36, 15, 1, 0); 479 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 15, 1, 0);
480 480
481static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = { 481static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = {
482/* Input */ 482/* Input */
@@ -487,13 +487,13 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = {
487 SND_SOC_DAPM_INPUT("RXINL"), 487 SND_SOC_DAPM_INPUT("RXINL"),
488 SND_SOC_DAPM_INPUT("TXIN"), 488 SND_SOC_DAPM_INPUT("TXIN"),
489 489
490 SND_SOC_DAPM_SUPPLY("MC1 Bias", 38, 0, 0, NULL, 0), 490 SND_SOC_DAPM_SUPPLY("MC1 Bias", MC13783_AUDIO_TX, 0, 0, NULL, 0),
491 SND_SOC_DAPM_SUPPLY("MC2 Bias", 38, 1, 0, NULL, 0), 491 SND_SOC_DAPM_SUPPLY("MC2 Bias", MC13783_AUDIO_TX, 1, 0, NULL, 0),
492 492
493 SND_SOC_DAPM_SWITCH("MC1L Amp", 38, 7, 0, &mc1l_amp_ctl), 493 SND_SOC_DAPM_SWITCH("MC1L Amp", MC13783_AUDIO_TX, 7, 0, &mc1l_amp_ctl),
494 SND_SOC_DAPM_SWITCH("MC1R Amp", 38, 5, 0, &mc1r_amp_ctl), 494 SND_SOC_DAPM_SWITCH("MC1R Amp", MC13783_AUDIO_TX, 5, 0, &mc1r_amp_ctl),
495 SND_SOC_DAPM_SWITCH("MC2 Amp", 38, 9, 0, &mc2_amp_ctl), 495 SND_SOC_DAPM_SWITCH("MC2 Amp", MC13783_AUDIO_TX, 9, 0, &mc2_amp_ctl),
496 SND_SOC_DAPM_SWITCH("TXIN Amp", 38, 11, 0, &atx_amp_ctl), 496 SND_SOC_DAPM_SWITCH("TXIN Amp", MC13783_AUDIO_TX, 11, 0, &atx_amp_ctl),
497 497
498 SND_SOC_DAPM_VIRT_MUX("PGA Left Input Mux", SND_SOC_NOPM, 0, 0, 498 SND_SOC_DAPM_VIRT_MUX("PGA Left Input Mux", SND_SOC_NOPM, 0, 0,
499 &left_input_mux), 499 &left_input_mux),
@@ -503,12 +503,12 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = {
503 SND_SOC_DAPM_PGA("PGA Left Input", SND_SOC_NOPM, 0, 0, NULL, 0), 503 SND_SOC_DAPM_PGA("PGA Left Input", SND_SOC_NOPM, 0, 0, NULL, 0),
504 SND_SOC_DAPM_PGA("PGA Right Input", SND_SOC_NOPM, 0, 0, NULL, 0), 504 SND_SOC_DAPM_PGA("PGA Right Input", SND_SOC_NOPM, 0, 0, NULL, 0),
505 505
506 SND_SOC_DAPM_ADC("ADC", "Capture", 40, 11, 0), 506 SND_SOC_DAPM_ADC("ADC", "Capture", MC13783_AUDIO_CODEC, 11, 0),
507 SND_SOC_DAPM_SUPPLY("ADC_Reset", 40, 15, 0, NULL, 0), 507 SND_SOC_DAPM_SUPPLY("ADC_Reset", MC13783_AUDIO_CODEC, 15, 0, NULL, 0),
508 508
509/* Output */ 509/* Output */
510 SND_SOC_DAPM_SUPPLY("DAC_E", 41, 11, 0, NULL, 0), 510 SND_SOC_DAPM_SUPPLY("DAC_E", MC13783_AUDIO_DAC, 11, 0, NULL, 0),
511 SND_SOC_DAPM_SUPPLY("DAC_Reset", 41, 15, 0, NULL, 0), 511 SND_SOC_DAPM_SUPPLY("DAC_Reset", MC13783_AUDIO_DAC, 15, 0, NULL, 0),
512 SND_SOC_DAPM_OUTPUT("RXOUTL"), 512 SND_SOC_DAPM_OUTPUT("RXOUTL"),
513 SND_SOC_DAPM_OUTPUT("RXOUTR"), 513 SND_SOC_DAPM_OUTPUT("RXOUTR"),
514 SND_SOC_DAPM_OUTPUT("HSL"), 514 SND_SOC_DAPM_OUTPUT("HSL"),
@@ -516,14 +516,18 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = {
516 SND_SOC_DAPM_OUTPUT("LSP"), 516 SND_SOC_DAPM_OUTPUT("LSP"),
517 SND_SOC_DAPM_OUTPUT("SP"), 517 SND_SOC_DAPM_OUTPUT("SP"),
518 518
519 SND_SOC_DAPM_SWITCH("Speaker Amp", 36, 3, 0, &samp_ctl), 519 SND_SOC_DAPM_SWITCH("Speaker Amp", MC13783_AUDIO_RX0, 3, 0, &samp_ctl),
520 SND_SOC_DAPM_SWITCH("Loudspeaker Amp", SND_SOC_NOPM, 0, 0, &lamp_ctl), 520 SND_SOC_DAPM_SWITCH("Loudspeaker Amp", SND_SOC_NOPM, 0, 0, &lamp_ctl),
521 SND_SOC_DAPM_SWITCH("Headset Amp Left", 36, 10, 0, &hlamp_ctl), 521 SND_SOC_DAPM_SWITCH("Headset Amp Left", MC13783_AUDIO_RX0, 10, 0,
522 SND_SOC_DAPM_SWITCH("Headset Amp Right", 36, 9, 0, &hramp_ctl), 522 &hlamp_ctl),
523 SND_SOC_DAPM_SWITCH("Line out Amp Left", 36, 16, 0, &llamp_ctl), 523 SND_SOC_DAPM_SWITCH("Headset Amp Right", MC13783_AUDIO_RX0, 9, 0,
524 SND_SOC_DAPM_SWITCH("Line out Amp Right", 36, 15, 0, &lramp_ctl), 524 &hramp_ctl),
525 SND_SOC_DAPM_DAC("DAC", "Playback", 36, 22, 0), 525 SND_SOC_DAPM_SWITCH("Line out Amp Left", MC13783_AUDIO_RX0, 16, 0,
526 SND_SOC_DAPM_PGA("DAC PGA", 37, 5, 0, NULL, 0), 526 &llamp_ctl),
527 SND_SOC_DAPM_SWITCH("Line out Amp Right", MC13783_AUDIO_RX0, 15, 0,
528 &lramp_ctl),
529 SND_SOC_DAPM_DAC("DAC", "Playback", MC13783_AUDIO_RX0, 22, 0),
530 SND_SOC_DAPM_PGA("DAC PGA", MC13783_AUDIO_RX1, 5, 0, NULL, 0),
527}; 531};
528 532
529static struct snd_soc_dapm_route mc13783_routes[] = { 533static struct snd_soc_dapm_route mc13783_routes[] = {
@@ -581,8 +585,6 @@ static int mc13783_probe(struct snd_soc_codec *codec)
581{ 585{
582 struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); 586 struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec);
583 587
584 codec->control_data = priv->mc13xxx;
585
586 mc13xxx_lock(priv->mc13xxx); 588 mc13xxx_lock(priv->mc13xxx);
587 589
588 /* these are the reset values */ 590 /* these are the reset values */
@@ -659,7 +661,7 @@ static struct snd_soc_dai_driver mc13783_dai_async[] = {
659 .id = MC13783_ID_STEREO_DAC, 661 .id = MC13783_ID_STEREO_DAC,
660 .playback = { 662 .playback = {
661 .stream_name = "Playback", 663 .stream_name = "Playback",
662 .channels_min = 1, 664 .channels_min = 2,
663 .channels_max = 2, 665 .channels_max = 2,
664 .rates = SNDRV_PCM_RATE_8000_96000, 666 .rates = SNDRV_PCM_RATE_8000_96000,
665 .formats = MC13783_FORMATS, 667 .formats = MC13783_FORMATS,
@@ -670,7 +672,7 @@ static struct snd_soc_dai_driver mc13783_dai_async[] = {
670 .id = MC13783_ID_STEREO_CODEC, 672 .id = MC13783_ID_STEREO_CODEC,
671 .capture = { 673 .capture = {
672 .stream_name = "Capture", 674 .stream_name = "Capture",
673 .channels_min = 1, 675 .channels_min = 2,
674 .channels_max = 2, 676 .channels_max = 2,
675 .rates = MC13783_RATES_RECORD, 677 .rates = MC13783_RATES_RECORD,
676 .formats = MC13783_FORMATS, 678 .formats = MC13783_FORMATS,
@@ -692,14 +694,14 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = {
692 .id = MC13783_ID_SYNC, 694 .id = MC13783_ID_SYNC,
693 .playback = { 695 .playback = {
694 .stream_name = "Playback", 696 .stream_name = "Playback",
695 .channels_min = 1, 697 .channels_min = 2,
696 .channels_max = 2, 698 .channels_max = 2,
697 .rates = SNDRV_PCM_RATE_8000_96000, 699 .rates = SNDRV_PCM_RATE_8000_96000,
698 .formats = MC13783_FORMATS, 700 .formats = MC13783_FORMATS,
699 }, 701 },
700 .capture = { 702 .capture = {
701 .stream_name = "Capture", 703 .stream_name = "Capture",
702 .channels_min = 1, 704 .channels_min = 2,
703 .channels_max = 2, 705 .channels_max = 2,
704 .rates = MC13783_RATES_RECORD, 706 .rates = MC13783_RATES_RECORD,
705 .formats = MC13783_FORMATS, 707 .formats = MC13783_FORMATS,
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index 8d717f4b5a87..0935bfe62471 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -24,6 +24,7 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/pm.h> 25#include <linux/pm.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/regmap.h>
27#include <linux/regulator/consumer.h> 28#include <linux/regulator/consumer.h>
28#include <linux/slab.h> 29#include <linux/slab.h>
29#include <linux/workqueue.h> 30#include <linux/workqueue.h>
@@ -55,12 +56,50 @@
55 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE) 56 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE)
56 57
57/* Power-up register defaults */ 58/* Power-up register defaults */
58static const u8 sta32x_regs[STA32X_REGISTER_COUNT] = { 59static const struct reg_default sta32x_regs[] = {
59 0x63, 0x80, 0xc2, 0x40, 0xc2, 0x5c, 0x10, 0xff, 0x60, 0x60, 60 { 0x0, 0x63 },
60 0x60, 0x80, 0x00, 0x00, 0x00, 0x40, 0x80, 0x77, 0x6a, 0x69, 61 { 0x1, 0x80 },
61 0x6a, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 62 { 0x2, 0xc2 },
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 63 { 0x3, 0x40 },
63 0xc0, 0xf3, 0x33, 0x00, 0x0c, 64 { 0x4, 0xc2 },
65 { 0x5, 0x5c },
66 { 0x6, 0x10 },
67 { 0x7, 0xff },
68 { 0x8, 0x60 },
69 { 0x9, 0x60 },
70 { 0xa, 0x60 },
71 { 0xb, 0x80 },
72 { 0xc, 0x00 },
73 { 0xd, 0x00 },
74 { 0xe, 0x00 },
75 { 0xf, 0x40 },
76 { 0x10, 0x80 },
77 { 0x11, 0x77 },
78 { 0x12, 0x6a },
79 { 0x13, 0x69 },
80 { 0x14, 0x6a },
81 { 0x15, 0x69 },
82 { 0x16, 0x00 },
83 { 0x17, 0x00 },
84 { 0x18, 0x00 },
85 { 0x19, 0x00 },
86 { 0x1a, 0x00 },
87 { 0x1b, 0x00 },
88 { 0x1c, 0x00 },
89 { 0x1d, 0x00 },
90 { 0x1e, 0x00 },
91 { 0x1f, 0x00 },
92 { 0x20, 0x00 },
93 { 0x21, 0x00 },
94 { 0x22, 0x00 },
95 { 0x23, 0x00 },
96 { 0x24, 0x00 },
97 { 0x25, 0x00 },
98 { 0x26, 0x00 },
99 { 0x27, 0x2d },
100 { 0x28, 0xc0 },
101 { 0x2b, 0x00 },
102 { 0x2c, 0x0c },
64}; 103};
65 104
66/* regulator power supply names */ 105/* regulator power supply names */
@@ -72,6 +111,7 @@ static const char *sta32x_supply_names[] = {
72 111
73/* codec private data */ 112/* codec private data */
74struct sta32x_priv { 113struct sta32x_priv {
114 struct regmap *regmap;
75 struct regulator_bulk_data supplies[ARRAY_SIZE(sta32x_supply_names)]; 115 struct regulator_bulk_data supplies[ARRAY_SIZE(sta32x_supply_names)];
76 struct snd_soc_codec *codec; 116 struct snd_soc_codec *codec;
77 struct sta32x_platform_data *pdata; 117 struct sta32x_platform_data *pdata;
@@ -291,17 +331,15 @@ static int sta32x_sync_coef_shadow(struct snd_soc_codec *codec)
291 331
292static int sta32x_cache_sync(struct snd_soc_codec *codec) 332static int sta32x_cache_sync(struct snd_soc_codec *codec)
293{ 333{
334 struct sta32x_priv *sta32x = codec->control_data;
294 unsigned int mute; 335 unsigned int mute;
295 int rc; 336 int rc;
296 337
297 if (!codec->cache_sync)
298 return 0;
299
300 /* mute during register sync */ 338 /* mute during register sync */
301 mute = snd_soc_read(codec, STA32X_MMUTE); 339 mute = snd_soc_read(codec, STA32X_MMUTE);
302 snd_soc_write(codec, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE); 340 snd_soc_write(codec, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE);
303 sta32x_sync_coef_shadow(codec); 341 sta32x_sync_coef_shadow(codec);
304 rc = snd_soc_cache_sync(codec); 342 rc = regcache_sync(sta32x->regmap);
305 snd_soc_write(codec, STA32X_MMUTE, mute); 343 snd_soc_write(codec, STA32X_MMUTE, mute);
306 return rc; 344 return rc;
307} 345}
@@ -316,11 +354,11 @@ static void sta32x_watchdog(struct work_struct *work)
316 354
317 /* check if sta32x has reset itself */ 355 /* check if sta32x has reset itself */
318 confa_cached = snd_soc_read(codec, STA32X_CONFA); 356 confa_cached = snd_soc_read(codec, STA32X_CONFA);
319 codec->cache_bypass = 1; 357 regcache_cache_bypass(sta32x->regmap, true);
320 confa = snd_soc_read(codec, STA32X_CONFA); 358 confa = snd_soc_read(codec, STA32X_CONFA);
321 codec->cache_bypass = 0; 359 regcache_cache_bypass(sta32x->regmap, false);
322 if (confa != confa_cached) { 360 if (confa != confa_cached) {
323 codec->cache_sync = 1; 361 regcache_mark_dirty(sta32x->regmap);
324 sta32x_cache_sync(codec); 362 sta32x_cache_sync(codec);
325 } 363 }
326 364
@@ -825,31 +863,21 @@ static int sta32x_probe(struct snd_soc_codec *codec)
825 sta32x->codec = codec; 863 sta32x->codec = codec;
826 sta32x->pdata = dev_get_platdata(codec->dev); 864 sta32x->pdata = dev_get_platdata(codec->dev);
827 865
828 /* regulators */
829 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++)
830 sta32x->supplies[i].supply = sta32x_supply_names[i];
831
832 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sta32x->supplies),
833 sta32x->supplies);
834 if (ret != 0) {
835 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
836 goto err;
837 }
838
839 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), 866 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies),
840 sta32x->supplies); 867 sta32x->supplies);
841 if (ret != 0) { 868 if (ret != 0) {
842 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); 869 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
843 goto err_get; 870 return ret;
844 } 871 }
845 872
846 /* Tell ASoC what kind of I/O to use to read the registers. ASoC will 873 /* Tell ASoC what kind of I/O to use to read the registers. ASoC will
847 * then do the I2C transactions itself. 874 * then do the I2C transactions itself.
848 */ 875 */
849 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); 876 codec->control_data = sta32x->regmap;
877 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
850 if (ret < 0) { 878 if (ret < 0) {
851 dev_err(codec->dev, "failed to set cache I/O (ret=%i)\n", ret); 879 dev_err(codec->dev, "failed to set cache I/O (ret=%i)\n", ret);
852 return ret; 880 goto err;
853 } 881 }
854 882
855 /* Chip documentation explicitly requires that the reset values 883 /* Chip documentation explicitly requires that the reset values
@@ -858,13 +886,15 @@ static int sta32x_probe(struct snd_soc_codec *codec)
858 * so the write to the these registers are suppressed by the cache 886 * so the write to the these registers are suppressed by the cache
859 * restore code when it skips writes of default registers. 887 * restore code when it skips writes of default registers.
860 */ 888 */
861 snd_soc_cache_write(codec, STA32X_CONFC, 0xc2); 889 regcache_cache_only(sta32x->regmap, true);
862 snd_soc_cache_write(codec, STA32X_CONFE, 0xc2); 890 snd_soc_write(codec, STA32X_CONFC, 0xc2);
863 snd_soc_cache_write(codec, STA32X_CONFF, 0x5c); 891 snd_soc_write(codec, STA32X_CONFE, 0xc2);
864 snd_soc_cache_write(codec, STA32X_MMUTE, 0x10); 892 snd_soc_write(codec, STA32X_CONFF, 0x5c);
865 snd_soc_cache_write(codec, STA32X_AUTO1, 0x60); 893 snd_soc_write(codec, STA32X_MMUTE, 0x10);
866 snd_soc_cache_write(codec, STA32X_AUTO3, 0x00); 894 snd_soc_write(codec, STA32X_AUTO1, 0x60);
867 snd_soc_cache_write(codec, STA32X_C3CFG, 0x40); 895 snd_soc_write(codec, STA32X_AUTO3, 0x00);
896 snd_soc_write(codec, STA32X_C3CFG, 0x40);
897 regcache_cache_only(sta32x->regmap, false);
868 898
869 /* set thermal warning adjustment and recovery */ 899 /* set thermal warning adjustment and recovery */
870 if (!(sta32x->pdata->thermal_conf & STA32X_THERMAL_ADJUSTMENT_ENABLE)) 900 if (!(sta32x->pdata->thermal_conf & STA32X_THERMAL_ADJUSTMENT_ENABLE))
@@ -915,9 +945,8 @@ static int sta32x_probe(struct snd_soc_codec *codec)
915 945
916 return 0; 946 return 0;
917 947
918err_get:
919 regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
920err: 948err:
949 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
921 return ret; 950 return ret;
922} 951}
923 952
@@ -928,13 +957,11 @@ static int sta32x_remove(struct snd_soc_codec *codec)
928 sta32x_watchdog_stop(sta32x); 957 sta32x_watchdog_stop(sta32x);
929 sta32x_set_bias_level(codec, SND_SOC_BIAS_OFF); 958 sta32x_set_bias_level(codec, SND_SOC_BIAS_OFF);
930 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); 959 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
931 regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
932 960
933 return 0; 961 return 0;
934} 962}
935 963
936static int sta32x_reg_is_volatile(struct snd_soc_codec *codec, 964static bool sta32x_reg_is_volatile(struct device *dev, unsigned int reg)
937 unsigned int reg)
938{ 965{
939 switch (reg) { 966 switch (reg) {
940 case STA32X_CONFA ... STA32X_L2ATRT: 967 case STA32X_CONFA ... STA32X_L2ATRT:
@@ -949,10 +976,6 @@ static const struct snd_soc_codec_driver sta32x_codec = {
949 .remove = sta32x_remove, 976 .remove = sta32x_remove,
950 .suspend = sta32x_suspend, 977 .suspend = sta32x_suspend,
951 .resume = sta32x_resume, 978 .resume = sta32x_resume,
952 .reg_cache_size = STA32X_REGISTER_COUNT,
953 .reg_word_size = sizeof(u8),
954 .reg_cache_default = sta32x_regs,
955 .volatile_register = sta32x_reg_is_volatile,
956 .set_bias_level = sta32x_set_bias_level, 979 .set_bias_level = sta32x_set_bias_level,
957 .controls = sta32x_snd_controls, 980 .controls = sta32x_snd_controls,
958 .num_controls = ARRAY_SIZE(sta32x_snd_controls), 981 .num_controls = ARRAY_SIZE(sta32x_snd_controls),
@@ -962,17 +985,45 @@ static const struct snd_soc_codec_driver sta32x_codec = {
962 .num_dapm_routes = ARRAY_SIZE(sta32x_dapm_routes), 985 .num_dapm_routes = ARRAY_SIZE(sta32x_dapm_routes),
963}; 986};
964 987
988static const struct regmap_config sta32x_regmap = {
989 .reg_bits = 8,
990 .val_bits = 8,
991 .max_register = STA32X_FDRC2,
992 .reg_defaults = sta32x_regs,
993 .num_reg_defaults = ARRAY_SIZE(sta32x_regs),
994 .cache_type = REGCACHE_RBTREE,
995 .volatile_reg = sta32x_reg_is_volatile,
996};
997
965static __devinit int sta32x_i2c_probe(struct i2c_client *i2c, 998static __devinit int sta32x_i2c_probe(struct i2c_client *i2c,
966 const struct i2c_device_id *id) 999 const struct i2c_device_id *id)
967{ 1000{
968 struct sta32x_priv *sta32x; 1001 struct sta32x_priv *sta32x;
969 int ret; 1002 int ret, i;
970 1003
971 sta32x = devm_kzalloc(&i2c->dev, sizeof(struct sta32x_priv), 1004 sta32x = devm_kzalloc(&i2c->dev, sizeof(struct sta32x_priv),
972 GFP_KERNEL); 1005 GFP_KERNEL);
973 if (!sta32x) 1006 if (!sta32x)
974 return -ENOMEM; 1007 return -ENOMEM;
975 1008
1009 /* regulators */
1010 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++)
1011 sta32x->supplies[i].supply = sta32x_supply_names[i];
1012
1013 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(sta32x->supplies),
1014 sta32x->supplies);
1015 if (ret != 0) {
1016 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
1017 return ret;
1018 }
1019
1020 sta32x->regmap = devm_regmap_init_i2c(i2c, &sta32x_regmap);
1021 if (IS_ERR(sta32x->regmap)) {
1022 ret = PTR_ERR(sta32x->regmap);
1023 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret);
1024 return ret;
1025 }
1026
976 i2c_set_clientdata(i2c, sta32x); 1027 i2c_set_clientdata(i2c, sta32x);
977 1028
978 ret = snd_soc_register_codec(&i2c->dev, &sta32x_codec, &sta32x_dai, 1); 1029 ret = snd_soc_register_codec(&i2c->dev, &sta32x_codec, &sta32x_dai, 1);
@@ -1006,17 +1057,7 @@ static struct i2c_driver sta32x_i2c_driver = {
1006 .id_table = sta32x_i2c_id, 1057 .id_table = sta32x_i2c_id,
1007}; 1058};
1008 1059
1009static int __init sta32x_init(void) 1060module_i2c_driver(sta32x_i2c_driver);
1010{
1011 return i2c_add_driver(&sta32x_i2c_driver);
1012}
1013module_init(sta32x_init);
1014
1015static void __exit sta32x_exit(void)
1016{
1017 i2c_del_driver(&sta32x_i2c_driver);
1018}
1019module_exit(sta32x_exit);
1020 1061
1021MODULE_DESCRIPTION("ASoC STA32X driver"); 1062MODULE_DESCRIPTION("ASoC STA32X driver");
1022MODULE_AUTHOR("Johannes Stezenbach <js@sig21.net>"); 1063MODULE_AUTHOR("Johannes Stezenbach <js@sig21.net>");
diff --git a/sound/soc/codecs/sta529.c b/sound/soc/codecs/sta529.c
index 0c225cd569d2..9e3144862386 100644
--- a/sound/soc/codecs/sta529.c
+++ b/sound/soc/codecs/sta529.c
@@ -358,7 +358,7 @@ static int sta529_resume(struct snd_soc_codec *codec)
358 return 0; 358 return 0;
359} 359}
360 360
361struct snd_soc_codec_driver sta529_codec_driver = { 361static const struct snd_soc_codec_driver sta529_codec_driver = {
362 .probe = sta529_probe, 362 .probe = sta529_probe,
363 .remove = sta529_remove, 363 .remove = sta529_remove,
364 .set_bias_level = sta529_set_bias_level, 364 .set_bias_level = sta529_set_bias_level,
diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c
index 33c0f3d39c87..982e437799a8 100644
--- a/sound/soc/codecs/stac9766.c
+++ b/sound/soc/codecs/stac9766.c
@@ -340,7 +340,6 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec)
340 340
341 printk(KERN_INFO "STAC9766 SoC Audio Codec %s\n", STAC9766_VERSION); 341 printk(KERN_INFO "STAC9766 SoC Audio Codec %s\n", STAC9766_VERSION);
342 342
343 codec->control_data = codec; /* we don't use regmap! */
344 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); 343 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
345 if (ret < 0) 344 if (ret < 0)
346 goto codec_err; 345 goto codec_err;
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
index 85944e953578..b1f6982c7c9c 100644
--- a/sound/soc/codecs/tlv320aic26.c
+++ b/sound/soc/codecs/tlv320aic26.c
@@ -444,14 +444,4 @@ static struct spi_driver aic26_spi = {
444 .remove = aic26_spi_remove, 444 .remove = aic26_spi_remove,
445}; 445};
446 446
447static int __init aic26_init(void) 447module_spi_driver(aic26_spi);
448{
449 return spi_register_driver(&aic26_spi);
450}
451module_init(aic26_init);
452
453static void __exit aic26_exit(void)
454{
455 spi_unregister_driver(&aic26_spi);
456}
457module_exit(aic26_exit);
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index b0a73d37ed52..f230292ba96b 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -746,24 +746,7 @@ static struct i2c_driver aic32x4_i2c_driver = {
746 .id_table = aic32x4_i2c_id, 746 .id_table = aic32x4_i2c_id,
747}; 747};
748 748
749static int __init aic32x4_modinit(void) 749module_i2c_driver(aic32x4_i2c_driver);
750{
751 int ret = 0;
752
753 ret = i2c_add_driver(&aic32x4_i2c_driver);
754 if (ret != 0) {
755 printk(KERN_ERR "Failed to register aic32x4 I2C driver: %d\n",
756 ret);
757 }
758 return ret;
759}
760module_init(aic32x4_modinit);
761
762static void __exit aic32x4_exit(void)
763{
764 i2c_del_driver(&aic32x4_i2c_driver);
765}
766module_exit(aic32x4_exit);
767 750
768MODULE_DESCRIPTION("ASoC tlv320aic32x4 codec driver"); 751MODULE_DESCRIPTION("ASoC tlv320aic32x4 codec driver");
769MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>"); 752MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>");
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index dc78f5a4bcbf..5708a973a776 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -40,6 +40,7 @@
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/gpio.h> 41#include <linux/gpio.h>
42#include <linux/regulator/consumer.h> 42#include <linux/regulator/consumer.h>
43#include <linux/of_gpio.h>
43#include <linux/slab.h> 44#include <linux/slab.h>
44#include <sound/core.h> 45#include <sound/core.h>
45#include <sound/pcm.h> 46#include <sound/pcm.h>
@@ -1457,6 +1458,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
1457{ 1458{
1458 struct aic3x_pdata *pdata = i2c->dev.platform_data; 1459 struct aic3x_pdata *pdata = i2c->dev.platform_data;
1459 struct aic3x_priv *aic3x; 1460 struct aic3x_priv *aic3x;
1461 struct aic3x_setup_data *ai3x_setup;
1462 struct device_node *np = i2c->dev.of_node;
1460 int ret; 1463 int ret;
1461 1464
1462 aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); 1465 aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL);
@@ -1471,6 +1474,25 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
1471 if (pdata) { 1474 if (pdata) {
1472 aic3x->gpio_reset = pdata->gpio_reset; 1475 aic3x->gpio_reset = pdata->gpio_reset;
1473 aic3x->setup = pdata->setup; 1476 aic3x->setup = pdata->setup;
1477 } else if (np) {
1478 ai3x_setup = devm_kzalloc(&i2c->dev, sizeof(*ai3x_setup),
1479 GFP_KERNEL);
1480 if (ai3x_setup == NULL) {
1481 dev_err(&i2c->dev, "failed to create private data\n");
1482 return -ENOMEM;
1483 }
1484
1485 ret = of_get_named_gpio(np, "gpio-reset", 0);
1486 if (ret >= 0)
1487 aic3x->gpio_reset = ret;
1488 else
1489 aic3x->gpio_reset = -1;
1490
1491 if (of_property_read_u32_array(np, "ai3x-gpio-func",
1492 ai3x_setup->gpio_func, 2) >= 0) {
1493 aic3x->setup = ai3x_setup;
1494 }
1495
1474 } else { 1496 } else {
1475 aic3x->gpio_reset = -1; 1497 aic3x->gpio_reset = -1;
1476 } 1498 }
@@ -1488,34 +1510,27 @@ static int aic3x_i2c_remove(struct i2c_client *client)
1488 return 0; 1510 return 0;
1489} 1511}
1490 1512
1513#if defined(CONFIG_OF)
1514static const struct of_device_id tlv320aic3x_of_match[] = {
1515 { .compatible = "ti,tlv320aic3x", },
1516 {},
1517};
1518MODULE_DEVICE_TABLE(of, tlv320aic3x_of_match);
1519#endif
1520
1491/* machine i2c codec control layer */ 1521/* machine i2c codec control layer */
1492static struct i2c_driver aic3x_i2c_driver = { 1522static struct i2c_driver aic3x_i2c_driver = {
1493 .driver = { 1523 .driver = {
1494 .name = "tlv320aic3x-codec", 1524 .name = "tlv320aic3x-codec",
1495 .owner = THIS_MODULE, 1525 .owner = THIS_MODULE,
1526 .of_match_table = of_match_ptr(tlv320aic3x_of_match),
1496 }, 1527 },
1497 .probe = aic3x_i2c_probe, 1528 .probe = aic3x_i2c_probe,
1498 .remove = aic3x_i2c_remove, 1529 .remove = aic3x_i2c_remove,
1499 .id_table = aic3x_i2c_id, 1530 .id_table = aic3x_i2c_id,
1500}; 1531};
1501 1532
1502static int __init aic3x_modinit(void) 1533module_i2c_driver(aic3x_i2c_driver);
1503{
1504 int ret = 0;
1505 ret = i2c_add_driver(&aic3x_i2c_driver);
1506 if (ret != 0) {
1507 printk(KERN_ERR "Failed to register TLV320AIC3x I2C driver: %d\n",
1508 ret);
1509 }
1510 return ret;
1511}
1512module_init(aic3x_modinit);
1513
1514static void __exit aic3x_exit(void)
1515{
1516 i2c_del_driver(&aic3x_i2c_driver);
1517}
1518module_exit(aic3x_exit);
1519 1534
1520MODULE_DESCRIPTION("ASoC TLV320AIC3X codec driver"); 1535MODULE_DESCRIPTION("ASoC TLV320AIC3X codec driver");
1521MODULE_AUTHOR("Vladimir Barinov"); 1536MODULE_AUTHOR("Vladimir Barinov");
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index 0dd41077ab79..d2e16c5d7d1f 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -1621,24 +1621,7 @@ static struct i2c_driver tlv320dac33_i2c_driver = {
1621 .id_table = tlv320dac33_i2c_id, 1621 .id_table = tlv320dac33_i2c_id,
1622}; 1622};
1623 1623
1624static int __init dac33_module_init(void) 1624module_i2c_driver(tlv320dac33_i2c_driver);
1625{
1626 int r;
1627 r = i2c_add_driver(&tlv320dac33_i2c_driver);
1628 if (r < 0) {
1629 printk(KERN_ERR "DAC33: driver registration failed\n");
1630 return r;
1631 }
1632 return 0;
1633}
1634module_init(dac33_module_init);
1635
1636static void __exit dac33_module_exit(void)
1637{
1638 i2c_del_driver(&tlv320dac33_i2c_driver);
1639}
1640module_exit(dac33_module_exit);
1641
1642 1625
1643MODULE_DESCRIPTION("ASoC TLV320DAC33 codec driver"); 1626MODULE_DESCRIPTION("ASoC TLV320DAC33 codec driver");
1644MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>"); 1627MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index 6fe4aa3ac544..565ff39ad3a3 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -487,19 +487,8 @@ static struct i2c_driver tpa6130a2_i2c_driver = {
487 .id_table = tpa6130a2_id, 487 .id_table = tpa6130a2_id,
488}; 488};
489 489
490static int __init tpa6130a2_init(void) 490module_i2c_driver(tpa6130a2_i2c_driver);
491{
492 return i2c_add_driver(&tpa6130a2_i2c_driver);
493}
494
495static void __exit tpa6130a2_exit(void)
496{
497 i2c_del_driver(&tpa6130a2_i2c_driver);
498}
499 491
500MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>"); 492MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
501MODULE_DESCRIPTION("TPA6130A2 Headphone amplifier driver"); 493MODULE_DESCRIPTION("TPA6130A2 Headphone amplifier driver");
502MODULE_LICENSE("GPL"); 494MODULE_LICENSE("GPL");
503
504module_init(tpa6130a2_init);
505module_exit(tpa6130a2_exit);
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 391fcfc7b63b..e7f608996c41 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -26,8 +26,11 @@
26#include <linux/pm.h> 26#include <linux/pm.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/of.h>
30#include <linux/of_gpio.h>
29#include <linux/i2c/twl.h> 31#include <linux/i2c/twl.h>
30#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/gpio.h>
31#include <sound/core.h> 34#include <sound/core.h>
32#include <sound/pcm.h> 35#include <sound/pcm.h>
33#include <sound/pcm_params.h> 36#include <sound/pcm_params.h>
@@ -152,8 +155,7 @@ struct twl4030_priv {
152 u8 predrivel_enabled, predriver_enabled; 155 u8 predrivel_enabled, predriver_enabled;
153 u8 carkitl_enabled, carkitr_enabled; 156 u8 carkitl_enabled, carkitr_enabled;
154 157
155 /* Delay needed after enabling the digimic interface */ 158 struct twl4030_codec_data *pdata;
156 unsigned int digimic_delay;
157}; 159};
158 160
159/* 161/*
@@ -295,13 +297,73 @@ static inline void twl4030_reset_registers(struct snd_soc_codec *codec)
295 297
296} 298}
297 299
298static void twl4030_init_chip(struct snd_soc_codec *codec) 300static void twl4030_setup_pdata_of(struct twl4030_codec_data *pdata,
301 struct device_node *node)
302{
303 int value;
304
305 of_property_read_u32(node, "ti,digimic_delay",
306 &pdata->digimic_delay);
307 of_property_read_u32(node, "ti,ramp_delay_value",
308 &pdata->ramp_delay_value);
309 of_property_read_u32(node, "ti,offset_cncl_path",
310 &pdata->offset_cncl_path);
311 if (!of_property_read_u32(node, "ti,hs_extmute", &value))
312 pdata->hs_extmute = value;
313
314 pdata->hs_extmute_gpio = of_get_named_gpio(node,
315 "ti,hs_extmute_gpio", 0);
316 if (gpio_is_valid(pdata->hs_extmute_gpio))
317 pdata->hs_extmute = 1;
318}
319
320static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec)
299{ 321{
300 struct twl4030_codec_data *pdata = dev_get_platdata(codec->dev); 322 struct twl4030_codec_data *pdata = dev_get_platdata(codec->dev);
323 struct device_node *twl4030_codec_node = NULL;
324
325 twl4030_codec_node = of_find_node_by_name(codec->dev->parent->of_node,
326 "codec");
327
328 if (!pdata && twl4030_codec_node) {
329 pdata = devm_kzalloc(codec->dev,
330 sizeof(struct twl4030_codec_data),
331 GFP_KERNEL);
332 if (!pdata) {
333 dev_err(codec->dev, "Can not allocate memory\n");
334 return NULL;
335 }
336 twl4030_setup_pdata_of(pdata, twl4030_codec_node);
337 }
338
339 return pdata;
340}
341
342static void twl4030_init_chip(struct snd_soc_codec *codec)
343{
344 struct twl4030_codec_data *pdata;
301 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 345 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
302 u8 reg, byte; 346 u8 reg, byte;
303 int i = 0; 347 int i = 0;
304 348
349 pdata = twl4030_get_pdata(codec);
350
351 if (pdata && pdata->hs_extmute &&
352 gpio_is_valid(pdata->hs_extmute_gpio)) {
353 int ret;
354
355 if (!pdata->hs_extmute_gpio)
356 dev_warn(codec->dev,
357 "Extmute GPIO is 0 is this correct?\n");
358
359 ret = gpio_request_one(pdata->hs_extmute_gpio,
360 GPIOF_OUT_INIT_LOW, "hs_extmute");
361 if (ret) {
362 dev_err(codec->dev, "Failed to get hs_extmute GPIO\n");
363 pdata->hs_extmute_gpio = -1;
364 }
365 }
366
305 /* Check defaults, if instructed before anything else */ 367 /* Check defaults, if instructed before anything else */
306 if (pdata && pdata->check_defaults) 368 if (pdata && pdata->check_defaults)
307 twl4030_check_defaults(codec); 369 twl4030_check_defaults(codec);
@@ -331,7 +393,7 @@ static void twl4030_init_chip(struct snd_soc_codec *codec)
331 if (!pdata) 393 if (!pdata)
332 return; 394 return;
333 395
334 twl4030->digimic_delay = pdata->digimic_delay; 396 twl4030->pdata = pdata;
335 397
336 reg = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); 398 reg = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET);
337 reg &= ~TWL4030_RAMP_DELAY; 399 reg &= ~TWL4030_RAMP_DELAY;
@@ -732,9 +794,9 @@ static int aif_event(struct snd_soc_dapm_widget *w,
732 794
733static void headset_ramp(struct snd_soc_codec *codec, int ramp) 795static void headset_ramp(struct snd_soc_codec *codec, int ramp)
734{ 796{
735 struct twl4030_codec_data *pdata = codec->dev->platform_data;
736 unsigned char hs_gain, hs_pop; 797 unsigned char hs_gain, hs_pop;
737 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 798 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
799 struct twl4030_codec_data *pdata = twl4030->pdata;
738 /* Base values for ramp delay calculation: 2^19 - 2^26 */ 800 /* Base values for ramp delay calculation: 2^19 - 2^26 */
739 unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304, 801 unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304,
740 8388608, 16777216, 33554432, 67108864}; 802 8388608, 16777216, 33554432, 67108864};
@@ -748,8 +810,8 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp)
748 /* Enable external mute control, this dramatically reduces 810 /* Enable external mute control, this dramatically reduces
749 * the pop-noise */ 811 * the pop-noise */
750 if (pdata && pdata->hs_extmute) { 812 if (pdata && pdata->hs_extmute) {
751 if (pdata->set_hs_extmute) { 813 if (gpio_is_valid(pdata->hs_extmute_gpio)) {
752 pdata->set_hs_extmute(1); 814 gpio_set_value(pdata->hs_extmute_gpio, 1);
753 } else { 815 } else {
754 hs_pop |= TWL4030_EXTMUTE; 816 hs_pop |= TWL4030_EXTMUTE;
755 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); 817 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
@@ -786,8 +848,8 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp)
786 848
787 /* Disable external mute */ 849 /* Disable external mute */
788 if (pdata && pdata->hs_extmute) { 850 if (pdata && pdata->hs_extmute) {
789 if (pdata->set_hs_extmute) { 851 if (gpio_is_valid(pdata->hs_extmute_gpio)) {
790 pdata->set_hs_extmute(0); 852 gpio_set_value(pdata->hs_extmute_gpio, 0);
791 } else { 853 } else {
792 hs_pop &= ~TWL4030_EXTMUTE; 854 hs_pop &= ~TWL4030_EXTMUTE;
793 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); 855 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
@@ -847,9 +909,10 @@ static int digimic_event(struct snd_soc_dapm_widget *w,
847 struct snd_kcontrol *kcontrol, int event) 909 struct snd_kcontrol *kcontrol, int event)
848{ 910{
849 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 911 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec);
912 struct twl4030_codec_data *pdata = twl4030->pdata;
850 913
851 if (twl4030->digimic_delay) 914 if (pdata && pdata->digimic_delay)
852 twl4030_wait_ms(twl4030->digimic_delay); 915 twl4030_wait_ms(pdata->digimic_delay);
853 return 0; 916 return 0;
854} 917}
855 918
@@ -999,7 +1062,7 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
999 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 1062 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
1000 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 1063 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1001 unsigned short val; 1064 unsigned short val;
1002 unsigned short mask, bitmask; 1065 unsigned short mask;
1003 1066
1004 if (twl4030->configured) { 1067 if (twl4030->configured) {
1005 dev_err(codec->dev, 1068 dev_err(codec->dev,
@@ -1007,18 +1070,16 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
1007 return -EBUSY; 1070 return -EBUSY;
1008 } 1071 }
1009 1072
1010 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
1011 ;
1012 if (ucontrol->value.enumerated.item[0] > e->max - 1) 1073 if (ucontrol->value.enumerated.item[0] > e->max - 1)
1013 return -EINVAL; 1074 return -EINVAL;
1014 1075
1015 val = ucontrol->value.enumerated.item[0] << e->shift_l; 1076 val = ucontrol->value.enumerated.item[0] << e->shift_l;
1016 mask = (bitmask - 1) << e->shift_l; 1077 mask = e->mask << e->shift_l;
1017 if (e->shift_l != e->shift_r) { 1078 if (e->shift_l != e->shift_r) {
1018 if (ucontrol->value.enumerated.item[1] > e->max - 1) 1079 if (ucontrol->value.enumerated.item[1] > e->max - 1)
1019 return -EINVAL; 1080 return -EINVAL;
1020 val |= ucontrol->value.enumerated.item[1] << e->shift_r; 1081 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
1021 mask |= (bitmask - 1) << e->shift_r; 1082 mask |= e->mask << e->shift_r;
1022 } 1083 }
1023 1084
1024 return snd_soc_update_bits(codec, e->reg, mask, val); 1085 return snd_soc_update_bits(codec, e->reg, mask, val);
@@ -1239,16 +1300,11 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
1239 SND_SOC_DAPM_OUTPUT("Virtual Voice OUT"), 1300 SND_SOC_DAPM_OUTPUT("Virtual Voice OUT"),
1240 1301
1241 /* DACs */ 1302 /* DACs */
1242 SND_SOC_DAPM_DAC("DAC Right1", "Right Front HiFi Playback", 1303 SND_SOC_DAPM_DAC("DAC Right1", NULL, SND_SOC_NOPM, 0, 0),
1243 SND_SOC_NOPM, 0, 0), 1304 SND_SOC_DAPM_DAC("DAC Left1", NULL, SND_SOC_NOPM, 0, 0),
1244 SND_SOC_DAPM_DAC("DAC Left1", "Left Front HiFi Playback", 1305 SND_SOC_DAPM_DAC("DAC Right2", NULL, SND_SOC_NOPM, 0, 0),
1245 SND_SOC_NOPM, 0, 0), 1306 SND_SOC_DAPM_DAC("DAC Left2", NULL, SND_SOC_NOPM, 0, 0),
1246 SND_SOC_DAPM_DAC("DAC Right2", "Right Rear HiFi Playback", 1307 SND_SOC_DAPM_DAC("DAC Voice", NULL, SND_SOC_NOPM, 0, 0),
1247 SND_SOC_NOPM, 0, 0),
1248 SND_SOC_DAPM_DAC("DAC Left2", "Left Rear HiFi Playback",
1249 SND_SOC_NOPM, 0, 0),
1250 SND_SOC_DAPM_DAC("DAC Voice", "Voice Playback",
1251 SND_SOC_NOPM, 0, 0),
1252 1308
1253 /* Analog bypasses */ 1309 /* Analog bypasses */
1254 SND_SOC_DAPM_SWITCH("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0, 1310 SND_SOC_DAPM_SWITCH("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0,
@@ -1377,14 +1433,10 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
1377 1433
1378 /* Introducing four virtual ADC, since TWL4030 have four channel for 1434 /* Introducing four virtual ADC, since TWL4030 have four channel for
1379 capture */ 1435 capture */
1380 SND_SOC_DAPM_ADC("ADC Virtual Left1", "Left Front Capture", 1436 SND_SOC_DAPM_ADC("ADC Virtual Left1", NULL, SND_SOC_NOPM, 0, 0),
1381 SND_SOC_NOPM, 0, 0), 1437 SND_SOC_DAPM_ADC("ADC Virtual Right1", NULL, SND_SOC_NOPM, 0, 0),
1382 SND_SOC_DAPM_ADC("ADC Virtual Right1", "Right Front Capture", 1438 SND_SOC_DAPM_ADC("ADC Virtual Left2", NULL, SND_SOC_NOPM, 0, 0),
1383 SND_SOC_NOPM, 0, 0), 1439 SND_SOC_DAPM_ADC("ADC Virtual Right2", NULL, SND_SOC_NOPM, 0, 0),
1384 SND_SOC_DAPM_ADC("ADC Virtual Left2", "Left Rear Capture",
1385 SND_SOC_NOPM, 0, 0),
1386 SND_SOC_DAPM_ADC("ADC Virtual Right2", "Right Rear Capture",
1387 SND_SOC_NOPM, 0, 0),
1388 1440
1389 /* Analog/Digital mic path selection. 1441 /* Analog/Digital mic path selection.
1390 TX1 Left/Right: either analog Left/Right or Digimic0 1442 TX1 Left/Right: either analog Left/Right or Digimic0
@@ -1428,6 +1480,23 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
1428}; 1480};
1429 1481
1430static const struct snd_soc_dapm_route intercon[] = { 1482static const struct snd_soc_dapm_route intercon[] = {
1483 /* Stream -> DAC mapping */
1484 {"DAC Right1", NULL, "HiFi Playback"},
1485 {"DAC Left1", NULL, "HiFi Playback"},
1486 {"DAC Right2", NULL, "HiFi Playback"},
1487 {"DAC Left2", NULL, "HiFi Playback"},
1488 {"DAC Voice", NULL, "Voice Playback"},
1489
1490 /* ADC -> Stream mapping */
1491 {"HiFi Capture", NULL, "ADC Virtual Left1"},
1492 {"HiFi Capture", NULL, "ADC Virtual Right1"},
1493 {"HiFi Capture", NULL, "ADC Virtual Left2"},
1494 {"HiFi Capture", NULL, "ADC Virtual Right2"},
1495 {"Voice Capture", NULL, "ADC Virtual Left1"},
1496 {"Voice Capture", NULL, "ADC Virtual Right1"},
1497 {"Voice Capture", NULL, "ADC Virtual Left2"},
1498 {"Voice Capture", NULL, "ADC Virtual Right2"},
1499
1431 {"Digital L1 Playback Mixer", NULL, "DAC Left1"}, 1500 {"Digital L1 Playback Mixer", NULL, "DAC Left1"},
1432 {"Digital R1 Playback Mixer", NULL, "DAC Right1"}, 1501 {"Digital R1 Playback Mixer", NULL, "DAC Right1"},
1433 {"Digital L2 Playback Mixer", NULL, "DAC Left2"}, 1502 {"Digital L2 Playback Mixer", NULL, "DAC Left2"},
@@ -2172,7 +2241,7 @@ static struct snd_soc_dai_driver twl4030_dai[] = {
2172 .formats = TWL4030_FORMATS, 2241 .formats = TWL4030_FORMATS,
2173 .sig_bits = 24,}, 2242 .sig_bits = 24,},
2174 .capture = { 2243 .capture = {
2175 .stream_name = "Capture", 2244 .stream_name = "HiFi Capture",
2176 .channels_min = 2, 2245 .channels_min = 2,
2177 .channels_max = 4, 2246 .channels_max = 4,
2178 .rates = TWL4030_RATES, 2247 .rates = TWL4030_RATES,
@@ -2189,7 +2258,7 @@ static struct snd_soc_dai_driver twl4030_dai[] = {
2189 .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, 2258 .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
2190 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 2259 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
2191 .capture = { 2260 .capture = {
2192 .stream_name = "Capture", 2261 .stream_name = "Voice Capture",
2193 .channels_min = 1, 2262 .channels_min = 1,
2194 .channels_max = 2, 2263 .channels_max = 2,
2195 .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, 2264 .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
@@ -2214,7 +2283,8 @@ static int twl4030_soc_probe(struct snd_soc_codec *codec)
2214{ 2283{
2215 struct twl4030_priv *twl4030; 2284 struct twl4030_priv *twl4030;
2216 2285
2217 twl4030 = kzalloc(sizeof(struct twl4030_priv), GFP_KERNEL); 2286 twl4030 = devm_kzalloc(codec->dev, sizeof(struct twl4030_priv),
2287 GFP_KERNEL);
2218 if (twl4030 == NULL) { 2288 if (twl4030 == NULL) {
2219 dev_err(codec->dev, "Can not allocate memory\n"); 2289 dev_err(codec->dev, "Can not allocate memory\n");
2220 return -ENOMEM; 2290 return -ENOMEM;
@@ -2231,11 +2301,15 @@ static int twl4030_soc_probe(struct snd_soc_codec *codec)
2231static int twl4030_soc_remove(struct snd_soc_codec *codec) 2301static int twl4030_soc_remove(struct snd_soc_codec *codec)
2232{ 2302{
2233 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 2303 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
2304 struct twl4030_codec_data *pdata = twl4030->pdata;
2234 2305
2235 /* Reset registers to their chip default before leaving */ 2306 /* Reset registers to their chip default before leaving */
2236 twl4030_reset_registers(codec); 2307 twl4030_reset_registers(codec);
2237 twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF); 2308 twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF);
2238 kfree(twl4030); 2309
2310 if (pdata && pdata->hs_extmute && gpio_is_valid(pdata->hs_extmute_gpio))
2311 gpio_free(pdata->hs_extmute_gpio);
2312
2239 return 0; 2313 return 0;
2240} 2314}
2241 2315
@@ -2262,13 +2336,6 @@ static struct snd_soc_codec_driver soc_codec_dev_twl4030 = {
2262 2336
2263static int __devinit twl4030_codec_probe(struct platform_device *pdev) 2337static int __devinit twl4030_codec_probe(struct platform_device *pdev)
2264{ 2338{
2265 struct twl4030_codec_data *pdata = pdev->dev.platform_data;
2266
2267 if (!pdata) {
2268 dev_err(&pdev->dev, "platform_data is missing\n");
2269 return -EINVAL;
2270 }
2271
2272 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_twl4030, 2339 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_twl4030,
2273 twl4030_dai, ARRAY_SIZE(twl4030_dai)); 2340 twl4030_dai, ARRAY_SIZE(twl4030_dai));
2274} 2341}
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index c084c549942e..e8f97af75928 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -727,10 +727,8 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
727 TWL6040_REG_MICRCTL, 1, 0, NULL, 0), 727 TWL6040_REG_MICRCTL, 1, 0, NULL, 0),
728 728
729 /* ADCs */ 729 /* ADCs */
730 SND_SOC_DAPM_ADC("ADC Left", "Left Front Capture", 730 SND_SOC_DAPM_ADC("ADC Left", NULL, TWL6040_REG_MICLCTL, 2, 0),
731 TWL6040_REG_MICLCTL, 2, 0), 731 SND_SOC_DAPM_ADC("ADC Right", NULL, TWL6040_REG_MICRCTL, 2, 0),
732 SND_SOC_DAPM_ADC("ADC Right", "Right Front Capture",
733 TWL6040_REG_MICRCTL, 2, 0),
734 732
735 /* Microphone bias */ 733 /* Microphone bias */
736 SND_SOC_DAPM_SUPPLY("Headset Mic Bias", 734 SND_SOC_DAPM_SUPPLY("Headset Mic Bias",
@@ -743,15 +741,12 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
743 TWL6040_REG_DMICBCTL, 4, 0, NULL, 0), 741 TWL6040_REG_DMICBCTL, 4, 0, NULL, 0),
744 742
745 /* DACs */ 743 /* DACs */
746 SND_SOC_DAPM_DAC("HSDAC Left", "Headset Playback", SND_SOC_NOPM, 0, 0), 744 SND_SOC_DAPM_DAC("HSDAC Left", NULL, SND_SOC_NOPM, 0, 0),
747 SND_SOC_DAPM_DAC("HSDAC Right", "Headset Playback", SND_SOC_NOPM, 0, 0), 745 SND_SOC_DAPM_DAC("HSDAC Right", NULL, SND_SOC_NOPM, 0, 0),
748 SND_SOC_DAPM_DAC("HFDAC Left", "Handsfree Playback", 746 SND_SOC_DAPM_DAC("HFDAC Left", NULL, TWL6040_REG_HFLCTL, 0, 0),
749 TWL6040_REG_HFLCTL, 0, 0), 747 SND_SOC_DAPM_DAC("HFDAC Right", NULL, TWL6040_REG_HFRCTL, 0, 0),
750 SND_SOC_DAPM_DAC("HFDAC Right", "Handsfree Playback",
751 TWL6040_REG_HFRCTL, 0, 0),
752 /* Virtual DAC for vibra path (DL4 channel) */ 748 /* Virtual DAC for vibra path (DL4 channel) */
753 SND_SOC_DAPM_DAC("VIBRA DAC", "Vibra Playback", 749 SND_SOC_DAPM_DAC("VIBRA DAC", NULL, SND_SOC_NOPM, 0, 0),
754 SND_SOC_NOPM, 0, 0),
755 750
756 SND_SOC_DAPM_MUX("Handsfree Left Playback", 751 SND_SOC_DAPM_MUX("Handsfree Left Playback",
757 SND_SOC_NOPM, 0, 0, &hfl_mux_controls), 752 SND_SOC_NOPM, 0, 0, &hfl_mux_controls),
@@ -810,6 +805,26 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
810}; 805};
811 806
812static const struct snd_soc_dapm_route intercon[] = { 807static const struct snd_soc_dapm_route intercon[] = {
808 /* Stream -> DAC mapping */
809 {"HSDAC Left", NULL, "Legacy Playback"},
810 {"HSDAC Left", NULL, "Headset Playback"},
811 {"HSDAC Right", NULL, "Legacy Playback"},
812 {"HSDAC Right", NULL, "Headset Playback"},
813
814 {"HFDAC Left", NULL, "Legacy Playback"},
815 {"HFDAC Left", NULL, "Handsfree Playback"},
816 {"HFDAC Right", NULL, "Legacy Playback"},
817 {"HFDAC Right", NULL, "Handsfree Playback"},
818
819 {"VIBRA DAC", NULL, "Legacy Playback"},
820 {"VIBRA DAC", NULL, "Vibra Playback"},
821
822 /* ADC -> Stream mapping */
823 {"ADC Left", NULL, "Legacy Capture"},
824 {"ADC Left", NULL, "Capture"},
825 {"ADC Right", NULL, "Legacy Capture"},
826 {"ADC Right", NULL, "Capture"},
827
813 /* Capture path */ 828 /* Capture path */
814 {"Analog Left Capture Route", "Headset Mic", "HSMIC"}, 829 {"Analog Left Capture Route", "Headset Mic", "HSMIC"},
815 {"Analog Left Capture Route", "Main Mic", "MAINMIC"}, 830 {"Analog Left Capture Route", "Main Mic", "MAINMIC"},
@@ -1028,14 +1043,14 @@ static struct snd_soc_dai_driver twl6040_dai[] = {
1028{ 1043{
1029 .name = "twl6040-legacy", 1044 .name = "twl6040-legacy",
1030 .playback = { 1045 .playback = {
1031 .stream_name = "Playback", 1046 .stream_name = "Legacy Playback",
1032 .channels_min = 1, 1047 .channels_min = 1,
1033 .channels_max = 5, 1048 .channels_max = 5,
1034 .rates = TWL6040_RATES, 1049 .rates = TWL6040_RATES,
1035 .formats = TWL6040_FORMATS, 1050 .formats = TWL6040_FORMATS,
1036 }, 1051 },
1037 .capture = { 1052 .capture = {
1038 .stream_name = "Capture", 1053 .stream_name = "Legacy Capture",
1039 .channels_min = 1, 1054 .channels_min = 1,
1040 .channels_max = 2, 1055 .channels_max = 2,
1041 .rates = TWL6040_RATES, 1056 .rates = TWL6040_RATES,
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c
new file mode 100644
index 000000000000..f8d6c31db870
--- /dev/null
+++ b/sound/soc/codecs/wm0010.c
@@ -0,0 +1,944 @@
1/*
2 * wm0010.c -- WM0010 DSP Driver
3 *
4 * Copyright 2012 Wolfson Microelectronics PLC.
5 *
6 * Authors: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 * Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
8 * Scott Ling <sl@opensource.wolfsonmicro.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/irqreturn.h>
18#include <linux/init.h>
19#include <linux/spi/spi.h>
20#include <linux/firmware.h>
21#include <linux/delay.h>
22#include <linux/fs.h>
23#include <linux/miscdevice.h>
24#include <linux/gpio.h>
25#include <linux/regulator/consumer.h>
26#include <linux/mutex.h>
27#include <linux/workqueue.h>
28
29#include <sound/soc.h>
30#include <sound/wm0010.h>
31
32#define DEVICE_ID_WM0010 10
33
34enum dfw_cmd {
35 DFW_CMD_FUSE = 0x01,
36 DFW_CMD_CODE_HDR,
37 DFW_CMD_CODE_DATA,
38 DFW_CMD_PLL,
39 DFW_CMD_INFO = 0xff
40};
41
42struct dfw_binrec {
43 u8 command;
44 u32 length:24;
45 u32 address;
46 uint8_t data[0];
47} __packed;
48
49struct dfw_pllrec {
50 u8 command;
51 u32 length:24;
52 u32 address;
53 u32 clkctrl1;
54 u32 clkctrl2;
55 u32 clkctrl3;
56 u32 ldetctrl;
57 u32 uart_div;
58 u32 spi_div;
59} __packed;
60
61static struct pll_clock_map {
62 int max_sysclk;
63 int max_pll_spi_speed;
64 u32 pll_clkctrl1;
65} pll_clock_map[] = { /* Dividers */
66 { 22000000, 26000000, 0x00201f11 }, /* 2,32,2 */
67 { 18000000, 26000000, 0x00203f21 }, /* 2,64,4 */
68 { 14000000, 26000000, 0x00202620 }, /* 1,39,4 */
69 { 10000000, 22000000, 0x00203120 }, /* 1,50,4 */
70 { 6500000, 22000000, 0x00204520 }, /* 1,70,4 */
71 { 5500000, 22000000, 0x00103f10 }, /* 1,64,2 */
72};
73
74enum wm0010_state {
75 WM0010_POWER_OFF,
76 WM0010_OUT_OF_RESET,
77 WM0010_BOOTROM,
78 WM0010_STAGE2,
79 WM0010_FIRMWARE,
80};
81
82struct wm0010_priv {
83 struct snd_soc_codec *codec;
84
85 struct mutex lock;
86 struct device *dev;
87
88 struct wm0010_pdata pdata;
89
90 int gpio_reset;
91 int gpio_reset_value;
92
93 struct regulator_bulk_data core_supplies[2];
94 struct regulator *dbvdd;
95
96 int sysclk;
97
98 enum wm0010_state state;
99 bool boot_failed;
100 int boot_done;
101 bool ready;
102 bool pll_running;
103 int max_spi_freq;
104 int board_max_spi_speed;
105 u32 pll_clkctrl1;
106
107 spinlock_t irq_lock;
108 int irq;
109
110 struct completion boot_completion;
111};
112
113struct wm0010_spi_msg {
114 struct spi_message m;
115 struct spi_transfer t;
116 u8 *tx_buf;
117 u8 *rx_buf;
118 size_t len;
119};
120
121static const struct snd_soc_dapm_widget wm0010_dapm_widgets[] = {
122SND_SOC_DAPM_SUPPLY("CLKIN", SND_SOC_NOPM, 0, 0, NULL, 0),
123};
124
125static const struct snd_soc_dapm_route wm0010_dapm_routes[] = {
126 { "SDI2 Capture", NULL, "SDI1 Playback" },
127 { "SDI1 Capture", NULL, "SDI2 Playback" },
128
129 { "SDI1 Capture", NULL, "CLKIN" },
130 { "SDI2 Capture", NULL, "CLKIN" },
131 { "SDI1 Playback", NULL, "CLKIN" },
132 { "SDI2 Playback", NULL, "CLKIN" },
133};
134
135static const char *wm0010_state_to_str(enum wm0010_state state)
136{
137 const char *state_to_str[] = {
138 "Power off",
139 "Out of reset",
140 "Boot ROM",
141 "Stage2",
142 "Firmware"
143 };
144
145 if (state < 0 || state >= ARRAY_SIZE(state_to_str))
146 return "null";
147 return state_to_str[state];
148}
149
150/* Called with wm0010->lock held */
151static void wm0010_halt(struct snd_soc_codec *codec)
152{
153 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
154 unsigned long flags;
155 enum wm0010_state state;
156
157 /* Fetch the wm0010 state */
158 spin_lock_irqsave(&wm0010->irq_lock, flags);
159 state = wm0010->state;
160 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
161
162 switch (state) {
163 case WM0010_POWER_OFF:
164 /* If there's nothing to do, bail out */
165 return;
166 case WM0010_OUT_OF_RESET:
167 case WM0010_BOOTROM:
168 case WM0010_STAGE2:
169 case WM0010_FIRMWARE:
170 /* Remember to put chip back into reset */
171 gpio_set_value(wm0010->gpio_reset, wm0010->gpio_reset_value);
172 /* Disable the regulators */
173 regulator_disable(wm0010->dbvdd);
174 regulator_bulk_disable(ARRAY_SIZE(wm0010->core_supplies),
175 wm0010->core_supplies);
176 break;
177 }
178
179 spin_lock_irqsave(&wm0010->irq_lock, flags);
180 wm0010->state = WM0010_POWER_OFF;
181 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
182}
183
184struct wm0010_boot_xfer {
185 struct list_head list;
186 struct snd_soc_codec *codec;
187 struct completion *done;
188 struct spi_message m;
189 struct spi_transfer t;
190};
191
192/* Called with wm0010->lock held */
193static void wm0010_mark_boot_failure(struct wm0010_priv *wm0010)
194{
195 enum wm0010_state state;
196 unsigned long flags;
197
198 spin_lock_irqsave(&wm0010->irq_lock, flags);
199 state = wm0010->state;
200 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
201
202 dev_err(wm0010->dev, "Failed to transition from `%s' state to `%s' state\n",
203 wm0010_state_to_str(state), wm0010_state_to_str(state + 1));
204
205 wm0010->boot_failed = true;
206}
207
208static void wm0010_boot_xfer_complete(void *data)
209{
210 struct wm0010_boot_xfer *xfer = data;
211 struct snd_soc_codec *codec = xfer->codec;
212 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
213 u32 *out32 = xfer->t.rx_buf;
214 int i;
215
216 if (xfer->m.status != 0) {
217 dev_err(codec->dev, "SPI transfer failed: %d\n",
218 xfer->m.status);
219 wm0010_mark_boot_failure(wm0010);
220 if (xfer->done)
221 complete(xfer->done);
222 return;
223 }
224
225 for (i = 0; i < xfer->t.len / 4; i++) {
226 dev_dbg(codec->dev, "%d: %04x\n", i, out32[i]);
227
228 switch (be32_to_cpu(out32[i])) {
229 case 0xe0e0e0e0:
230 dev_err(codec->dev,
231 "%d: ROM error reported in stage 2\n", i);
232 wm0010_mark_boot_failure(wm0010);
233 break;
234
235 case 0x55555555:
236 if (wm0010->boot_done == 0)
237 break;
238 dev_err(codec->dev,
239 "%d: ROM bootloader running in stage 2\n", i);
240 wm0010_mark_boot_failure(wm0010);
241 break;
242
243 case 0x0fed0000:
244 dev_dbg(codec->dev, "Stage2 loader running\n");
245 break;
246
247 case 0x0fed0007:
248 dev_dbg(codec->dev, "CODE_HDR packet received\n");
249 break;
250
251 case 0x0fed0008:
252 dev_dbg(codec->dev, "CODE_DATA packet received\n");
253 break;
254
255 case 0x0fed0009:
256 dev_dbg(codec->dev, "Download complete\n");
257 break;
258
259 case 0x0fed000c:
260 dev_dbg(codec->dev, "Application start\n");
261 break;
262
263 case 0x0fed000e:
264 dev_dbg(codec->dev, "PLL packet received\n");
265 wm0010->pll_running = true;
266 break;
267
268 case 0x0fed0025:
269 dev_err(codec->dev, "Device reports image too long\n");
270 wm0010_mark_boot_failure(wm0010);
271 break;
272
273 case 0x0fed002c:
274 dev_err(codec->dev, "Device reports bad SPI packet\n");
275 wm0010_mark_boot_failure(wm0010);
276 break;
277
278 case 0x0fed0031:
279 dev_err(codec->dev, "Device reports SPI read overflow\n");
280 wm0010_mark_boot_failure(wm0010);
281 break;
282
283 case 0x0fed0032:
284 dev_err(codec->dev, "Device reports SPI underclock\n");
285 wm0010_mark_boot_failure(wm0010);
286 break;
287
288 case 0x0fed0033:
289 dev_err(codec->dev, "Device reports bad header packet\n");
290 wm0010_mark_boot_failure(wm0010);
291 break;
292
293 case 0x0fed0034:
294 dev_err(codec->dev, "Device reports invalid packet type\n");
295 wm0010_mark_boot_failure(wm0010);
296 break;
297
298 case 0x0fed0035:
299 dev_err(codec->dev, "Device reports data before header error\n");
300 wm0010_mark_boot_failure(wm0010);
301 break;
302
303 case 0x0fed0038:
304 dev_err(codec->dev, "Device reports invalid PLL packet\n");
305 break;
306
307 case 0x0fed003a:
308 dev_err(codec->dev, "Device reports packet alignment error\n");
309 wm0010_mark_boot_failure(wm0010);
310 break;
311
312 default:
313 dev_err(codec->dev, "Unrecognised return 0x%x\n",
314 be32_to_cpu(out32[i]));
315 wm0010_mark_boot_failure(wm0010);
316 break;
317 }
318
319 if (wm0010->boot_failed)
320 break;
321 }
322
323 wm0010->boot_done++;
324 if (xfer->done)
325 complete(xfer->done);
326}
327
328static void byte_swap_64(u64 *data_in, u64 *data_out, u32 len)
329{
330 int i;
331
332 for (i = 0; i < len / 8; i++)
333 data_out[i] = cpu_to_be64(le64_to_cpu(data_in[i]));
334}
335
336static int wm0010_boot(struct snd_soc_codec *codec)
337{
338 struct spi_device *spi = to_spi_device(codec->dev);
339 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
340 unsigned long flags;
341 struct list_head xfer_list;
342 struct wm0010_boot_xfer *xfer;
343 int ret;
344 struct completion done;
345 const struct firmware *fw;
346 const struct dfw_binrec *rec;
347 struct spi_message m;
348 struct spi_transfer t;
349 struct dfw_pllrec pll_rec;
350 u32 *img, *p;
351 u64 *img_swap;
352 u8 *out;
353 u32 len, offset;
354 int i;
355
356 spin_lock_irqsave(&wm0010->irq_lock, flags);
357 if (wm0010->state != WM0010_POWER_OFF)
358 dev_warn(wm0010->dev, "DSP already powered up!\n");
359 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
360
361 if (wm0010->sysclk > 26000000) {
362 dev_err(codec->dev, "Max DSP clock frequency is 26MHz\n");
363 ret = -ECANCELED;
364 goto err;
365 }
366
367 INIT_LIST_HEAD(&xfer_list);
368
369 mutex_lock(&wm0010->lock);
370 wm0010->pll_running = false;
371
372 dev_dbg(codec->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq);
373
374 ret = regulator_bulk_enable(ARRAY_SIZE(wm0010->core_supplies),
375 wm0010->core_supplies);
376 if (ret != 0) {
377 dev_err(&spi->dev, "Failed to enable core supplies: %d\n",
378 ret);
379 mutex_unlock(&wm0010->lock);
380 goto err;
381 }
382
383 ret = regulator_enable(wm0010->dbvdd);
384 if (ret != 0) {
385 dev_err(&spi->dev, "Failed to enable DBVDD: %d\n", ret);
386 goto err_core;
387 }
388
389 /* Release reset */
390 gpio_set_value(wm0010->gpio_reset, !wm0010->gpio_reset_value);
391 spin_lock_irqsave(&wm0010->irq_lock, flags);
392 wm0010->state = WM0010_OUT_OF_RESET;
393 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
394
395 /* First the bootloader */
396 ret = request_firmware(&fw, "wm0010_stage2.bin", codec->dev);
397 if (ret != 0) {
398 dev_err(codec->dev, "Failed to request stage2 loader: %d\n",
399 ret);
400 goto abort;
401 }
402
403 if (!wait_for_completion_timeout(&wm0010->boot_completion,
404 msecs_to_jiffies(10)))
405 dev_err(codec->dev, "Failed to get interrupt from DSP\n");
406
407 spin_lock_irqsave(&wm0010->irq_lock, flags);
408 wm0010->state = WM0010_BOOTROM;
409 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
410
411 dev_dbg(codec->dev, "Downloading %zu byte stage 2 loader\n", fw->size);
412
413 /* Copy to local buffer first as vmalloc causes problems for dma */
414 img = kzalloc(fw->size, GFP_KERNEL);
415 if (!img) {
416 dev_err(codec->dev, "Failed to allocate image buffer\n");
417 goto abort;
418 }
419
420 out = kzalloc(fw->size, GFP_KERNEL);
421 if (!out) {
422 dev_err(codec->dev, "Failed to allocate output buffer\n");
423 goto abort;
424 }
425
426 memcpy(img, &fw->data[0], fw->size);
427
428 spi_message_init(&m);
429 memset(&t, 0, sizeof(t));
430 t.rx_buf = out;
431 t.tx_buf = img;
432 t.len = fw->size;
433 t.bits_per_word = 8;
434 t.speed_hz = wm0010->sysclk / 10;
435 spi_message_add_tail(&t, &m);
436
437 dev_dbg(codec->dev, "Starting initial download at %dHz\n",
438 t.speed_hz);
439
440 ret = spi_sync(spi, &m);
441 if (ret != 0) {
442 dev_err(codec->dev, "Initial download failed: %d\n", ret);
443 goto abort;
444 }
445
446 /* Look for errors from the boot ROM */
447 for (i = 0; i < fw->size; i++) {
448 if (out[i] != 0x55) {
449 ret = -EBUSY;
450 dev_err(codec->dev, "Boot ROM error: %x in %d\n",
451 out[i], i);
452 wm0010_mark_boot_failure(wm0010);
453 goto abort;
454 }
455 }
456
457 release_firmware(fw);
458 kfree(img);
459 kfree(out);
460
461 if (!wait_for_completion_timeout(&wm0010->boot_completion,
462 msecs_to_jiffies(10)))
463 dev_err(codec->dev, "Failed to get interrupt from DSP loader.\n");
464
465 spin_lock_irqsave(&wm0010->irq_lock, flags);
466 wm0010->state = WM0010_STAGE2;
467 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
468
469 /* Only initialise PLL if max_spi_freq initialised */
470 if (wm0010->max_spi_freq) {
471
472 /* Initialise a PLL record */
473 memset(&pll_rec, 0, sizeof(pll_rec));
474 pll_rec.command = DFW_CMD_PLL;
475 pll_rec.length = (sizeof(pll_rec) - 8);
476
477 /* On wm0010 only the CLKCTRL1 value is used */
478 pll_rec.clkctrl1 = wm0010->pll_clkctrl1;
479
480 len = pll_rec.length + 8;
481 out = kzalloc(len, GFP_KERNEL);
482 if (!out) {
483 dev_err(codec->dev,
484 "Failed to allocate RX buffer\n");
485 goto abort;
486 }
487
488 img_swap = kzalloc(len, GFP_KERNEL);
489 if (!img_swap) {
490 dev_err(codec->dev,
491 "Failed to allocate image buffer\n");
492 goto abort;
493 }
494
495 /* We need to re-order for 0010 */
496 byte_swap_64((u64 *)&pll_rec, img_swap, len);
497
498 spi_message_init(&m);
499 memset(&t, 0, sizeof(t));
500 t.rx_buf = out;
501 t.tx_buf = img_swap;
502 t.len = len;
503 t.bits_per_word = 8;
504 t.speed_hz = wm0010->sysclk / 6;
505 spi_message_add_tail(&t, &m);
506
507 ret = spi_sync(spi, &m);
508 if (ret != 0) {
509 dev_err(codec->dev, "First PLL write failed: %d\n", ret);
510 goto abort;
511 }
512
513 /* Use a second send of the message to get the return status */
514 ret = spi_sync(spi, &m);
515 if (ret != 0) {
516 dev_err(codec->dev, "Second PLL write failed: %d\n", ret);
517 goto abort;
518 }
519
520 p = (u32 *)out;
521
522 /* Look for PLL active code from the DSP */
523 for (i = 0; i < len / 4; i++) {
524 if (*p == 0x0e00ed0f) {
525 dev_dbg(codec->dev, "PLL packet received\n");
526 wm0010->pll_running = true;
527 break;
528 }
529 p++;
530 }
531
532 kfree(img_swap);
533 kfree(out);
534 } else
535 dev_dbg(codec->dev, "Not enabling DSP PLL.");
536
537 ret = request_firmware(&fw, "wm0010.dfw", codec->dev);
538 if (ret != 0) {
539 dev_err(codec->dev, "Failed to request application: %d\n",
540 ret);
541 goto abort;
542 }
543
544 rec = (const struct dfw_binrec *)fw->data;
545 offset = 0;
546 wm0010->boot_done = 0;
547 wm0010->boot_failed = false;
548 BUG_ON(!list_empty(&xfer_list));
549 init_completion(&done);
550
551 /* First record should be INFO */
552 if (rec->command != DFW_CMD_INFO) {
553 dev_err(codec->dev, "First record not INFO\r\n");
554 goto abort;
555 }
556
557 /* Check it's a 0010 file */
558 if (rec->data[0] != DEVICE_ID_WM0010) {
559 dev_err(codec->dev, "Not a WM0010 firmware file.\r\n");
560 goto abort;
561 }
562
563 /* Skip the info record as we don't need to send it */
564 offset += ((rec->length) + 8);
565 rec = (void *)&rec->data[rec->length];
566
567 while (offset < fw->size) {
568 dev_dbg(codec->dev,
569 "Packet: command %d, data length = 0x%x\r\n",
570 rec->command, rec->length);
571 len = rec->length + 8;
572
573 out = kzalloc(len, GFP_KERNEL);
574 if (!out) {
575 dev_err(codec->dev,
576 "Failed to allocate RX buffer\n");
577 goto abort;
578 }
579
580 img_swap = kzalloc(len, GFP_KERNEL);
581 if (!img_swap) {
582 dev_err(codec->dev,
583 "Failed to allocate image buffer\n");
584 goto abort;
585 }
586
587 /* We need to re-order for 0010 */
588 byte_swap_64((u64 *)&rec->command, img_swap, len);
589
590 xfer = kzalloc(sizeof(*xfer), GFP_KERNEL);
591 if (!xfer) {
592 dev_err(codec->dev, "Failed to allocate xfer\n");
593 goto abort;
594 }
595
596 xfer->codec = codec;
597 list_add_tail(&xfer->list, &xfer_list);
598
599 spi_message_init(&xfer->m);
600 xfer->m.complete = wm0010_boot_xfer_complete;
601 xfer->m.context = xfer;
602 xfer->t.tx_buf = img_swap;
603 xfer->t.rx_buf = out;
604 xfer->t.len = len;
605 xfer->t.bits_per_word = 8;
606
607 if (!wm0010->pll_running) {
608 xfer->t.speed_hz = wm0010->sysclk / 6;
609 } else {
610 xfer->t.speed_hz = wm0010->max_spi_freq;
611
612 if (wm0010->board_max_spi_speed &&
613 (wm0010->board_max_spi_speed < wm0010->max_spi_freq))
614 xfer->t.speed_hz = wm0010->board_max_spi_speed;
615 }
616
617 /* Store max usable spi frequency for later use */
618 wm0010->max_spi_freq = xfer->t.speed_hz;
619
620 spi_message_add_tail(&xfer->t, &xfer->m);
621
622 offset += ((rec->length) + 8);
623 rec = (void *)&rec->data[rec->length];
624
625 if (offset >= fw->size) {
626 dev_dbg(codec->dev, "All transfers scheduled\n");
627 xfer->done = &done;
628 }
629
630 ret = spi_async(spi, &xfer->m);
631 if (ret != 0) {
632 dev_err(codec->dev, "Write failed: %d\n", ret);
633 goto abort;
634 }
635
636 if (wm0010->boot_failed)
637 goto abort;
638 }
639
640 wait_for_completion(&done);
641
642 spin_lock_irqsave(&wm0010->irq_lock, flags);
643 wm0010->state = WM0010_FIRMWARE;
644 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
645
646 mutex_unlock(&wm0010->lock);
647
648 release_firmware(fw);
649
650 while (!list_empty(&xfer_list)) {
651 xfer = list_first_entry(&xfer_list, struct wm0010_boot_xfer,
652 list);
653 kfree(xfer->t.rx_buf);
654 kfree(xfer->t.tx_buf);
655 list_del(&xfer->list);
656 kfree(xfer);
657 }
658
659 return 0;
660
661abort:
662 /* Put the chip back into reset */
663 wm0010_halt(codec);
664 mutex_unlock(&wm0010->lock);
665 return ret;
666
667err_core:
668 mutex_unlock(&wm0010->lock);
669 regulator_bulk_disable(ARRAY_SIZE(wm0010->core_supplies),
670 wm0010->core_supplies);
671err:
672 return ret;
673}
674
675static int wm0010_set_bias_level(struct snd_soc_codec *codec,
676 enum snd_soc_bias_level level)
677{
678 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
679
680 switch (level) {
681 case SND_SOC_BIAS_ON:
682 if (codec->dapm.bias_level == SND_SOC_BIAS_PREPARE)
683 wm0010_boot(codec);
684 break;
685 case SND_SOC_BIAS_PREPARE:
686 break;
687 case SND_SOC_BIAS_STANDBY:
688 if (codec->dapm.bias_level == SND_SOC_BIAS_PREPARE) {
689 mutex_lock(&wm0010->lock);
690 wm0010_halt(codec);
691 mutex_unlock(&wm0010->lock);
692 }
693 break;
694 case SND_SOC_BIAS_OFF:
695 break;
696 }
697
698 codec->dapm.bias_level = level;
699
700 return 0;
701}
702
703static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source,
704 int clk_id, unsigned int freq, int dir)
705{
706 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
707 unsigned int i;
708
709 wm0010->sysclk = freq;
710
711 if (freq < pll_clock_map[ARRAY_SIZE(pll_clock_map)-1].max_sysclk) {
712 wm0010->max_spi_freq = 0;
713 } else {
714 for (i = 0; i < ARRAY_SIZE(pll_clock_map); i++)
715 if (freq >= pll_clock_map[i].max_sysclk)
716 break;
717
718 wm0010->max_spi_freq = pll_clock_map[i].max_pll_spi_speed;
719 wm0010->pll_clkctrl1 = pll_clock_map[i].pll_clkctrl1;
720 }
721
722 return 0;
723}
724
725static int wm0010_probe(struct snd_soc_codec *codec);
726
727static struct snd_soc_codec_driver soc_codec_dev_wm0010 = {
728 .probe = wm0010_probe,
729 .set_bias_level = wm0010_set_bias_level,
730 .set_sysclk = wm0010_set_sysclk,
731 .idle_bias_off = true,
732
733 .dapm_widgets = wm0010_dapm_widgets,
734 .num_dapm_widgets = ARRAY_SIZE(wm0010_dapm_widgets),
735 .dapm_routes = wm0010_dapm_routes,
736 .num_dapm_routes = ARRAY_SIZE(wm0010_dapm_routes),
737};
738
739#define WM0010_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
740#define WM0010_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\
741 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE |\
742 SNDRV_PCM_FMTBIT_S32_LE)
743
744static struct snd_soc_dai_driver wm0010_dai[] = {
745 {
746 .name = "wm0010-sdi1",
747 .playback = {
748 .stream_name = "SDI1 Playback",
749 .channels_min = 1,
750 .channels_max = 2,
751 .rates = WM0010_RATES,
752 .formats = WM0010_FORMATS,
753 },
754 .capture = {
755 .stream_name = "SDI1 Capture",
756 .channels_min = 1,
757 .channels_max = 2,
758 .rates = WM0010_RATES,
759 .formats = WM0010_FORMATS,
760 },
761 },
762 {
763 .name = "wm0010-sdi2",
764 .playback = {
765 .stream_name = "SDI2 Playback",
766 .channels_min = 1,
767 .channels_max = 2,
768 .rates = WM0010_RATES,
769 .formats = WM0010_FORMATS,
770 },
771 .capture = {
772 .stream_name = "SDI2 Capture",
773 .channels_min = 1,
774 .channels_max = 2,
775 .rates = WM0010_RATES,
776 .formats = WM0010_FORMATS,
777 },
778 },
779};
780
781static irqreturn_t wm0010_irq(int irq, void *data)
782{
783 struct wm0010_priv *wm0010 = data;
784
785 switch (wm0010->state) {
786 case WM0010_POWER_OFF:
787 case WM0010_OUT_OF_RESET:
788 case WM0010_BOOTROM:
789 case WM0010_STAGE2:
790 spin_lock(&wm0010->irq_lock);
791 complete(&wm0010->boot_completion);
792 spin_unlock(&wm0010->irq_lock);
793 return IRQ_HANDLED;
794 default:
795 return IRQ_NONE;
796 }
797
798 return IRQ_NONE;
799}
800
801static int wm0010_probe(struct snd_soc_codec *codec)
802{
803 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
804
805 wm0010->codec = codec;
806
807 return 0;
808}
809
810static int __devinit wm0010_spi_probe(struct spi_device *spi)
811{
812 unsigned long flags;
813 unsigned long gpio_flags;
814 int ret;
815 int trigger;
816 int irq;
817 struct wm0010_priv *wm0010;
818
819 wm0010 = devm_kzalloc(&spi->dev, sizeof(*wm0010),
820 GFP_KERNEL);
821 if (!wm0010)
822 return -ENOMEM;
823
824 mutex_init(&wm0010->lock);
825 spin_lock_init(&wm0010->irq_lock);
826
827 spi_set_drvdata(spi, wm0010);
828 wm0010->dev = &spi->dev;
829
830 if (dev_get_platdata(&spi->dev))
831 memcpy(&wm0010->pdata, dev_get_platdata(&spi->dev),
832 sizeof(wm0010->pdata));
833
834 init_completion(&wm0010->boot_completion);
835
836 wm0010->core_supplies[0].supply = "AVDD";
837 wm0010->core_supplies[1].supply = "DCVDD";
838 ret = devm_regulator_bulk_get(wm0010->dev, ARRAY_SIZE(wm0010->core_supplies),
839 wm0010->core_supplies);
840 if (ret != 0) {
841 dev_err(wm0010->dev, "Failed to obtain core supplies: %d\n",
842 ret);
843 return ret;
844 }
845
846 wm0010->dbvdd = devm_regulator_get(wm0010->dev, "DBVDD");
847 if (IS_ERR(wm0010->dbvdd)) {
848 ret = PTR_ERR(wm0010->dbvdd);
849 dev_err(wm0010->dev, "Failed to obtain DBVDD: %d\n", ret);
850 return ret;
851 }
852
853 if (wm0010->pdata.gpio_reset) {
854 wm0010->gpio_reset = wm0010->pdata.gpio_reset;
855
856 if (wm0010->pdata.reset_active_high)
857 wm0010->gpio_reset_value = 1;
858 else
859 wm0010->gpio_reset_value = 0;
860
861 if (wm0010->gpio_reset_value)
862 gpio_flags = GPIOF_OUT_INIT_HIGH;
863 else
864 gpio_flags = GPIOF_OUT_INIT_LOW;
865
866 ret = devm_gpio_request_one(wm0010->dev, wm0010->gpio_reset,
867 gpio_flags, "wm0010 reset");
868 if (ret < 0) {
869 dev_err(wm0010->dev,
870 "Failed to request GPIO for DSP reset: %d\n",
871 ret);
872 return ret;
873 }
874 } else {
875 dev_err(wm0010->dev, "No reset GPIO configured\n");
876 return -EINVAL;
877 }
878
879 irq = spi->irq;
880 if (wm0010->pdata.irq_flags)
881 trigger = wm0010->pdata.irq_flags;
882 else
883 trigger = IRQF_TRIGGER_FALLING;
884 trigger |= IRQF_ONESHOT;
885
886 ret = request_threaded_irq(irq, NULL, wm0010_irq, trigger | IRQF_ONESHOT,
887 "wm0010", wm0010);
888 if (ret) {
889 dev_err(wm0010->dev, "Failed to request IRQ %d: %d\n",
890 irq, ret);
891 return ret;
892 }
893 wm0010->irq = irq;
894
895 if (spi->max_speed_hz)
896 wm0010->board_max_spi_speed = spi->max_speed_hz;
897 else
898 wm0010->board_max_spi_speed = 0;
899
900 spin_lock_irqsave(&wm0010->irq_lock, flags);
901 wm0010->state = WM0010_POWER_OFF;
902 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
903
904 ret = snd_soc_register_codec(&spi->dev,
905 &soc_codec_dev_wm0010, wm0010_dai,
906 ARRAY_SIZE(wm0010_dai));
907 if (ret < 0)
908 return ret;
909
910 return 0;
911}
912
913static int __devexit wm0010_spi_remove(struct spi_device *spi)
914{
915 struct wm0010_priv *wm0010 = spi_get_drvdata(spi);
916
917 snd_soc_unregister_codec(&spi->dev);
918
919 if (wm0010->gpio_reset) {
920 /* Remember to put chip back into reset */
921 gpio_set_value(wm0010->gpio_reset, wm0010->gpio_reset_value);
922 }
923
924 if (wm0010->irq)
925 free_irq(wm0010->irq, wm0010);
926
927 return 0;
928}
929
930static struct spi_driver wm0010_spi_driver = {
931 .driver = {
932 .name = "wm0010",
933 .bus = &spi_bus_type,
934 .owner = THIS_MODULE,
935 },
936 .probe = wm0010_spi_probe,
937 .remove = __devexit_p(wm0010_spi_remove),
938};
939
940module_spi_driver(wm0010_spi_driver);
941
942MODULE_DESCRIPTION("ASoC WM0010 driver");
943MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
944MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index 3fd5b29dc933..89cd6fcad015 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -858,17 +858,7 @@ static struct i2c_driver wm2000_i2c_driver = {
858 .id_table = wm2000_i2c_id, 858 .id_table = wm2000_i2c_id,
859}; 859};
860 860
861static int __init wm2000_init(void) 861module_i2c_driver(wm2000_i2c_driver);
862{
863 return i2c_add_driver(&wm2000_i2c_driver);
864}
865module_init(wm2000_init);
866
867static void __exit wm2000_exit(void)
868{
869 i2c_del_driver(&wm2000_i2c_driver);
870}
871module_exit(wm2000_exit);
872 862
873MODULE_DESCRIPTION("ASoC WM2000 driver"); 863MODULE_DESCRIPTION("ASoC WM2000 driver");
874MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfonmicro.com>"); 864MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfonmicro.com>");
diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
index 32682c1b7cde..efa93dbb0191 100644
--- a/sound/soc/codecs/wm2200.c
+++ b/sound/soc/codecs/wm2200.c
@@ -1117,8 +1117,8 @@ SND_SOC_DAPM_SUPPLY("MICBIAS1", WM2200_MIC_BIAS_CTRL_1, WM2200_MICB1_ENA_SHIFT,
1117 0, NULL, 0), 1117 0, NULL, 0),
1118SND_SOC_DAPM_SUPPLY("MICBIAS2", WM2200_MIC_BIAS_CTRL_2, WM2200_MICB2_ENA_SHIFT, 1118SND_SOC_DAPM_SUPPLY("MICBIAS2", WM2200_MIC_BIAS_CTRL_2, WM2200_MICB2_ENA_SHIFT,
1119 0, NULL, 0), 1119 0, NULL, 0),
1120SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20), 1120SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
1121SND_SOC_DAPM_REGULATOR_SUPPLY("AVDD", 20), 1121SND_SOC_DAPM_REGULATOR_SUPPLY("AVDD", 20, 0),
1122 1122
1123SND_SOC_DAPM_INPUT("IN1L"), 1123SND_SOC_DAPM_INPUT("IN1L"),
1124SND_SOC_DAPM_INPUT("IN1R"), 1124SND_SOC_DAPM_INPUT("IN1R"),
@@ -2270,17 +2270,7 @@ static struct i2c_driver wm2200_i2c_driver = {
2270 .id_table = wm2200_i2c_id, 2270 .id_table = wm2200_i2c_id,
2271}; 2271};
2272 2272
2273static int __init wm2200_modinit(void) 2273module_i2c_driver(wm2200_i2c_driver);
2274{
2275 return i2c_add_driver(&wm2200_i2c_driver);
2276}
2277module_init(wm2200_modinit);
2278
2279static void __exit wm2200_exit(void)
2280{
2281 i2c_del_driver(&wm2200_i2c_driver);
2282}
2283module_exit(wm2200_exit);
2284 2274
2285MODULE_DESCRIPTION("ASoC WM2200 driver"); 2275MODULE_DESCRIPTION("ASoC WM2200 driver");
2286MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 2276MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c
index f4817292ef45..4da1b92b22c2 100644
--- a/sound/soc/codecs/wm5100.c
+++ b/sound/soc/codecs/wm5100.c
@@ -848,9 +848,9 @@ SND_SOC_DAPM_SUPPLY("SYSCLK", WM5100_CLOCKING_3, WM5100_SYSCLK_ENA_SHIFT, 0,
848SND_SOC_DAPM_SUPPLY("ASYNCCLK", WM5100_CLOCKING_6, WM5100_ASYNC_CLK_ENA_SHIFT, 848SND_SOC_DAPM_SUPPLY("ASYNCCLK", WM5100_CLOCKING_6, WM5100_ASYNC_CLK_ENA_SHIFT,
849 0, NULL, 0), 849 0, NULL, 0),
850 850
851SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20), 851SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
852SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0), 852SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0),
853SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0), 853SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0),
854 854
855SND_SOC_DAPM_SUPPLY("CP1", WM5100_HP_CHARGE_PUMP_1, WM5100_CP1_ENA_SHIFT, 0, 855SND_SOC_DAPM_SUPPLY("CP1", WM5100_HP_CHARGE_PUMP_1, WM5100_CP1_ENA_SHIFT, 0,
856 NULL, 0), 856 NULL, 0),
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index e33d327396ad..4a2db4e10885 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -274,18 +274,43 @@ ARIZONA_MIXER_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
274ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); 274ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
275ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); 275ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
276 276
277
278static const char *wm5102_aec_loopback_texts[] = {
279 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "EPOUT",
280 "SPKOUTL", "SPKOUTR", "SPKDAT1L", "SPKDAT1R",
281};
282
283static const unsigned int wm5102_aec_loopback_values[] = {
284 0, 1, 2, 3, 4, 6, 7, 8, 9,
285};
286
287static const struct soc_enum wm5102_aec_loopback =
288 SOC_VALUE_ENUM_SINGLE(ARIZONA_DAC_AEC_CONTROL_1,
289 ARIZONA_AEC_LOOPBACK_SRC_SHIFT,
290 ARIZONA_AEC_LOOPBACK_SRC_MASK,
291 ARRAY_SIZE(wm5102_aec_loopback_texts),
292 wm5102_aec_loopback_texts,
293 wm5102_aec_loopback_values);
294
295static const struct snd_kcontrol_new wm5102_aec_loopback_mux =
296 SOC_DAPM_VALUE_ENUM("AEC Loopback", wm5102_aec_loopback);
297
277static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = { 298static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = {
278SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT, 299SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
279 0, NULL, 0), 300 0, NULL, 0),
280SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1, 301SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
281 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), 302 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
282 303SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
283SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0), 304 ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0),
284SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0), 305SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
285SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20), 306 ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0),
286SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0), 307
287SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0), 308SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0),
288SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0), 309SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0),
310SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
311SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, 0),
312SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0, 0),
313SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0),
289 314
290SND_SOC_DAPM_SIGGEN("TONE"), 315SND_SOC_DAPM_SIGGEN("TONE"),
291SND_SOC_DAPM_SIGGEN("NOISE"), 316SND_SOC_DAPM_SIGGEN("NOISE"),
@@ -421,6 +446,9 @@ SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
421SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, 446SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
422 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0), 447 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0),
423 448
449SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
450 ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux),
451
424SND_SOC_DAPM_PGA_E("OUT1L", ARIZONA_OUTPUT_ENABLES_1, 452SND_SOC_DAPM_PGA_E("OUT1L", ARIZONA_OUTPUT_ENABLES_1,
425 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, 453 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
426 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 454 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
@@ -516,6 +544,7 @@ SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
516 { name, "Noise Generator", "Noise Generator" }, \ 544 { name, "Noise Generator", "Noise Generator" }, \
517 { name, "Tone Generator 1", "Tone Generator 1" }, \ 545 { name, "Tone Generator 1", "Tone Generator 1" }, \
518 { name, "Tone Generator 2", "Tone Generator 2" }, \ 546 { name, "Tone Generator 2", "Tone Generator 2" }, \
547 { name, "AEC", "AEC Loopback" }, \
519 { name, "IN1L", "IN1L PGA" }, \ 548 { name, "IN1L", "IN1L PGA" }, \
520 { name, "IN1R", "IN1R PGA" }, \ 549 { name, "IN1R", "IN1R PGA" }, \
521 { name, "IN2L", "IN2L PGA" }, \ 550 { name, "IN2L", "IN2L PGA" }, \
@@ -681,21 +710,30 @@ static const struct snd_soc_dapm_route wm5102_dapm_routes[] = {
681 ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"), 710 ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"),
682 ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"), 711 ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"),
683 712
713 { "AEC Loopback", "HPOUT1L", "OUT1L" },
714 { "AEC Loopback", "HPOUT1R", "OUT1R" },
684 { "HPOUT1L", NULL, "OUT1L" }, 715 { "HPOUT1L", NULL, "OUT1L" },
685 { "HPOUT1R", NULL, "OUT1R" }, 716 { "HPOUT1R", NULL, "OUT1R" },
686 717
718 { "AEC Loopback", "HPOUT2L", "OUT2L" },
719 { "AEC Loopback", "HPOUT2R", "OUT2R" },
687 { "HPOUT2L", NULL, "OUT2L" }, 720 { "HPOUT2L", NULL, "OUT2L" },
688 { "HPOUT2R", NULL, "OUT2R" }, 721 { "HPOUT2R", NULL, "OUT2R" },
689 722
723 { "AEC Loopback", "EPOUT", "OUT3L" },
690 { "EPOUTN", NULL, "OUT3L" }, 724 { "EPOUTN", NULL, "OUT3L" },
691 { "EPOUTP", NULL, "OUT3L" }, 725 { "EPOUTP", NULL, "OUT3L" },
692 726
727 { "AEC Loopback", "SPKOUTL", "OUT4L" },
693 { "SPKOUTLN", NULL, "OUT4L" }, 728 { "SPKOUTLN", NULL, "OUT4L" },
694 { "SPKOUTLP", NULL, "OUT4L" }, 729 { "SPKOUTLP", NULL, "OUT4L" },
695 730
731 { "AEC Loopback", "SPKOUTR", "OUT4R" },
696 { "SPKOUTRN", NULL, "OUT4R" }, 732 { "SPKOUTRN", NULL, "OUT4R" },
697 { "SPKOUTRP", NULL, "OUT4R" }, 733 { "SPKOUTRP", NULL, "OUT4R" },
698 734
735 { "AEC Loopback", "SPKDAT1L", "OUT5L" },
736 { "AEC Loopback", "SPKDAT1R", "OUT5R" },
699 { "SPKDAT1L", NULL, "OUT5L" }, 737 { "SPKDAT1L", NULL, "OUT5L" },
700 { "SPKDAT1R", NULL, "OUT5R" }, 738 { "SPKDAT1R", NULL, "OUT5R" },
701}; 739};
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index 01ebbcc5c6a4..bf47914234b3 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -305,13 +305,17 @@ SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
305 0, NULL, 0), 305 0, NULL, 0),
306SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1, 306SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
307 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), 307 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
308 308SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
309SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0), 309 ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0),
310SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0), 310SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
311SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20), 311 ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0),
312SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0), 312
313SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0), 313SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0),
314SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0), 314SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0),
315SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
316SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, 0),
317SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0, 0),
318SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0),
315 319
316SND_SOC_DAPM_SIGGEN("TONE"), 320SND_SOC_DAPM_SIGGEN("TONE"),
317SND_SOC_DAPM_SIGGEN("NOISE"), 321SND_SOC_DAPM_SIGGEN("NOISE"),
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c
index 56a049555e2c..c12a54e72e89 100644
--- a/sound/soc/codecs/wm8510.c
+++ b/sound/soc/codecs/wm8510.c
@@ -20,6 +20,7 @@
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/of_device.h> 22#include <linux/of_device.h>
23#include <linux/regmap.h>
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/pcm.h> 25#include <sound/pcm.h>
25#include <sound/pcm_params.h> 26#include <sound/pcm_params.h>
@@ -33,24 +34,75 @@
33 * We can't read the WM8510 register space when we are 34 * We can't read the WM8510 register space when we are
34 * using 2 wire for device control, so we cache them instead. 35 * using 2 wire for device control, so we cache them instead.
35 */ 36 */
36static const u16 wm8510_reg[WM8510_CACHEREGNUM] = { 37static const struct reg_default wm8510_reg_defaults[] = {
37 0x0000, 0x0000, 0x0000, 0x0000, 38 { 1, 0x0000 },
38 0x0050, 0x0000, 0x0140, 0x0000, 39 { 2, 0x0000 },
39 0x0000, 0x0000, 0x0000, 0x00ff, 40 { 3, 0x0000 },
40 0x0000, 0x0000, 0x0100, 0x00ff, 41 { 4, 0x0050 },
41 0x0000, 0x0000, 0x012c, 0x002c, 42 { 5, 0x0000 },
42 0x002c, 0x002c, 0x002c, 0x0000, 43 { 6, 0x0140 },
43 0x0032, 0x0000, 0x0000, 0x0000, 44 { 7, 0x0000 },
44 0x0000, 0x0000, 0x0000, 0x0000, 45 { 8, 0x0000 },
45 0x0038, 0x000b, 0x0032, 0x0000, 46 { 9, 0x0000 },
46 0x0008, 0x000c, 0x0093, 0x00e9, 47 { 10, 0x0000 },
47 0x0000, 0x0000, 0x0000, 0x0000, 48 { 11, 0x00ff },
48 0x0003, 0x0010, 0x0000, 0x0000, 49 { 12, 0x0000 },
49 0x0000, 0x0002, 0x0001, 0x0000, 50 { 13, 0x0000 },
50 0x0000, 0x0000, 0x0039, 0x0000, 51 { 14, 0x0100 },
51 0x0001, 52 { 15, 0x00ff },
53 { 16, 0x0000 },
54 { 17, 0x0000 },
55 { 18, 0x012c },
56 { 19, 0x002c },
57 { 20, 0x002c },
58 { 21, 0x002c },
59 { 22, 0x002c },
60 { 23, 0x0000 },
61 { 24, 0x0032 },
62 { 25, 0x0000 },
63 { 26, 0x0000 },
64 { 27, 0x0000 },
65 { 28, 0x0000 },
66 { 29, 0x0000 },
67 { 30, 0x0000 },
68 { 31, 0x0000 },
69 { 32, 0x0038 },
70 { 33, 0x000b },
71 { 34, 0x0032 },
72 { 35, 0x0000 },
73 { 36, 0x0008 },
74 { 37, 0x000c },
75 { 38, 0x0093 },
76 { 39, 0x00e9 },
77 { 40, 0x0000 },
78 { 41, 0x0000 },
79 { 42, 0x0000 },
80 { 43, 0x0000 },
81 { 44, 0x0003 },
82 { 45, 0x0010 },
83 { 46, 0x0000 },
84 { 47, 0x0000 },
85 { 48, 0x0000 },
86 { 49, 0x0002 },
87 { 50, 0x0001 },
88 { 51, 0x0000 },
89 { 52, 0x0000 },
90 { 53, 0x0000 },
91 { 54, 0x0039 },
92 { 55, 0x0000 },
93 { 56, 0x0001 },
52}; 94};
53 95
96static bool wm8510_volatile(struct device *dev, unsigned int reg)
97{
98 switch (reg) {
99 case WM8510_RESET:
100 return true;
101 default:
102 return false;
103 }
104}
105
54#define WM8510_POWER1_BIASEN 0x08 106#define WM8510_POWER1_BIASEN 0x08
55#define WM8510_POWER1_BUFIOEN 0x10 107#define WM8510_POWER1_BUFIOEN 0x10
56 108
@@ -58,7 +110,7 @@ static const u16 wm8510_reg[WM8510_CACHEREGNUM] = {
58 110
59/* codec private data */ 111/* codec private data */
60struct wm8510_priv { 112struct wm8510_priv {
61 enum snd_soc_control_type control_type; 113 struct regmap *regmap;
62}; 114};
63 115
64static const char *wm8510_companding[] = { "Off", "NC", "u-law", "A-law" }; 116static const char *wm8510_companding[] = { "Off", "NC", "u-law", "A-law" };
@@ -454,6 +506,7 @@ static int wm8510_mute(struct snd_soc_dai *dai, int mute)
454static int wm8510_set_bias_level(struct snd_soc_codec *codec, 506static int wm8510_set_bias_level(struct snd_soc_codec *codec,
455 enum snd_soc_bias_level level) 507 enum snd_soc_bias_level level)
456{ 508{
509 struct wm8510_priv *wm8510 = snd_soc_codec_get_drvdata(codec);
457 u16 power1 = snd_soc_read(codec, WM8510_POWER1) & ~0x3; 510 u16 power1 = snd_soc_read(codec, WM8510_POWER1) & ~0x3;
458 511
459 switch (level) { 512 switch (level) {
@@ -467,7 +520,7 @@ static int wm8510_set_bias_level(struct snd_soc_codec *codec,
467 power1 |= WM8510_POWER1_BIASEN | WM8510_POWER1_BUFIOEN; 520 power1 |= WM8510_POWER1_BIASEN | WM8510_POWER1_BUFIOEN;
468 521
469 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 522 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
470 snd_soc_cache_sync(codec); 523 regcache_sync(wm8510->regmap);
471 524
472 /* Initial cap charge at VMID 5k */ 525 /* Initial cap charge at VMID 5k */
473 snd_soc_write(codec, WM8510_POWER1, power1 | 0x3); 526 snd_soc_write(codec, WM8510_POWER1, power1 | 0x3);
@@ -536,10 +589,9 @@ static int wm8510_resume(struct snd_soc_codec *codec)
536 589
537static int wm8510_probe(struct snd_soc_codec *codec) 590static int wm8510_probe(struct snd_soc_codec *codec)
538{ 591{
539 struct wm8510_priv *wm8510 = snd_soc_codec_get_drvdata(codec);
540 int ret; 592 int ret;
541 593
542 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8510->control_type); 594 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
543 if (ret < 0) { 595 if (ret < 0) {
544 printk(KERN_ERR "wm8510: failed to set cache I/O: %d\n", ret); 596 printk(KERN_ERR "wm8510: failed to set cache I/O: %d\n", ret);
545 return ret; 597 return ret;
@@ -569,9 +621,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8510 = {
569 .suspend = wm8510_suspend, 621 .suspend = wm8510_suspend,
570 .resume = wm8510_resume, 622 .resume = wm8510_resume,
571 .set_bias_level = wm8510_set_bias_level, 623 .set_bias_level = wm8510_set_bias_level,
572 .reg_cache_size = ARRAY_SIZE(wm8510_reg),
573 .reg_word_size = sizeof(u16),
574 .reg_cache_default =wm8510_reg,
575 624
576 .controls = wm8510_snd_controls, 625 .controls = wm8510_snd_controls,
577 .num_controls = ARRAY_SIZE(wm8510_snd_controls), 626 .num_controls = ARRAY_SIZE(wm8510_snd_controls),
@@ -586,23 +635,38 @@ static const struct of_device_id wm8510_of_match[] = {
586 { }, 635 { },
587}; 636};
588 637
638static const struct regmap_config wm8510_regmap = {
639 .reg_bits = 7,
640 .val_bits = 9,
641 .max_register = WM8510_MONOMIX,
642
643 .reg_defaults = wm8510_reg_defaults,
644 .num_reg_defaults = ARRAY_SIZE(wm8510_reg_defaults),
645 .cache_type = REGCACHE_RBTREE,
646
647 .volatile_reg = wm8510_volatile,
648};
649
589#if defined(CONFIG_SPI_MASTER) 650#if defined(CONFIG_SPI_MASTER)
590static int __devinit wm8510_spi_probe(struct spi_device *spi) 651static int __devinit wm8510_spi_probe(struct spi_device *spi)
591{ 652{
592 struct wm8510_priv *wm8510; 653 struct wm8510_priv *wm8510;
593 int ret; 654 int ret;
594 655
595 wm8510 = kzalloc(sizeof(struct wm8510_priv), GFP_KERNEL); 656 wm8510 = devm_kzalloc(&spi->dev, sizeof(struct wm8510_priv),
657 GFP_KERNEL);
596 if (wm8510 == NULL) 658 if (wm8510 == NULL)
597 return -ENOMEM; 659 return -ENOMEM;
598 660
599 wm8510->control_type = SND_SOC_SPI; 661 wm8510->regmap = devm_regmap_init_spi(spi, &wm8510_regmap);
662 if (IS_ERR(wm8510->regmap))
663 return PTR_ERR(wm8510->regmap);
664
600 spi_set_drvdata(spi, wm8510); 665 spi_set_drvdata(spi, wm8510);
601 666
602 ret = snd_soc_register_codec(&spi->dev, 667 ret = snd_soc_register_codec(&spi->dev,
603 &soc_codec_dev_wm8510, &wm8510_dai, 1); 668 &soc_codec_dev_wm8510, &wm8510_dai, 1);
604 if (ret < 0) 669
605 kfree(wm8510);
606 return ret; 670 return ret;
607} 671}
608 672
@@ -630,17 +694,20 @@ static __devinit int wm8510_i2c_probe(struct i2c_client *i2c,
630 struct wm8510_priv *wm8510; 694 struct wm8510_priv *wm8510;
631 int ret; 695 int ret;
632 696
633 wm8510 = kzalloc(sizeof(struct wm8510_priv), GFP_KERNEL); 697 wm8510 = devm_kzalloc(&i2c->dev, sizeof(struct wm8510_priv),
698 GFP_KERNEL);
634 if (wm8510 == NULL) 699 if (wm8510 == NULL)
635 return -ENOMEM; 700 return -ENOMEM;
636 701
702 wm8510->regmap = devm_regmap_init_i2c(i2c, &wm8510_regmap);
703 if (IS_ERR(wm8510->regmap))
704 return PTR_ERR(wm8510->regmap);
705
637 i2c_set_clientdata(i2c, wm8510); 706 i2c_set_clientdata(i2c, wm8510);
638 wm8510->control_type = SND_SOC_I2C;
639 707
640 ret = snd_soc_register_codec(&i2c->dev, 708 ret = snd_soc_register_codec(&i2c->dev,
641 &soc_codec_dev_wm8510, &wm8510_dai, 1); 709 &soc_codec_dev_wm8510, &wm8510_dai, 1);
642 if (ret < 0) 710
643 kfree(wm8510);
644 return ret; 711 return ret;
645} 712}
646 713
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c
index 1c3ffb290cdc..8d5c27673501 100644
--- a/sound/soc/codecs/wm8523.c
+++ b/sound/soc/codecs/wm8523.c
@@ -17,6 +17,7 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/regmap.h>
20#include <linux/regulator/consumer.h> 21#include <linux/regulator/consumer.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
22#include <linux/of_device.h> 23#include <linux/of_device.h>
@@ -39,41 +40,34 @@ static const char *wm8523_supply_names[WM8523_NUM_SUPPLIES] = {
39 40
40/* codec private data */ 41/* codec private data */
41struct wm8523_priv { 42struct wm8523_priv {
42 enum snd_soc_control_type control_type; 43 struct regmap *regmap;
43 struct regulator_bulk_data supplies[WM8523_NUM_SUPPLIES]; 44 struct regulator_bulk_data supplies[WM8523_NUM_SUPPLIES];
44 unsigned int sysclk; 45 unsigned int sysclk;
45 unsigned int rate_constraint_list[WM8523_NUM_RATES]; 46 unsigned int rate_constraint_list[WM8523_NUM_RATES];
46 struct snd_pcm_hw_constraint_list rate_constraint; 47 struct snd_pcm_hw_constraint_list rate_constraint;
47}; 48};
48 49
49static const u16 wm8523_reg[WM8523_REGISTER_COUNT] = { 50static const struct reg_default wm8523_reg_defaults[] = {
50 0x8523, /* R0 - DEVICE_ID */ 51 { 2, 0x0000 }, /* R2 - PSCTRL1 */
51 0x0001, /* R1 - REVISION */ 52 { 3, 0x1812 }, /* R3 - AIF_CTRL1 */
52 0x0000, /* R2 - PSCTRL1 */ 53 { 4, 0x0000 }, /* R4 - AIF_CTRL2 */
53 0x1812, /* R3 - AIF_CTRL1 */ 54 { 5, 0x0001 }, /* R5 - DAC_CTRL3 */
54 0x0000, /* R4 - AIF_CTRL2 */ 55 { 6, 0x0190 }, /* R6 - DAC_GAINL */
55 0x0001, /* R5 - DAC_CTRL3 */ 56 { 7, 0x0190 }, /* R7 - DAC_GAINR */
56 0x0190, /* R6 - DAC_GAINL */ 57 { 8, 0x0000 }, /* R8 - ZERO_DETECT */
57 0x0190, /* R7 - DAC_GAINR */
58 0x0000, /* R8 - ZERO_DETECT */
59}; 58};
60 59
61static int wm8523_volatile_register(struct snd_soc_codec *codec, unsigned int reg) 60static bool wm8523_volatile_register(struct device *dev, unsigned int reg)
62{ 61{
63 switch (reg) { 62 switch (reg) {
64 case WM8523_DEVICE_ID: 63 case WM8523_DEVICE_ID:
65 case WM8523_REVISION: 64 case WM8523_REVISION:
66 return 1; 65 return true;
67 default: 66 default:
68 return 0; 67 return false;
69 } 68 }
70} 69}
71 70
72static int wm8523_reset(struct snd_soc_codec *codec)
73{
74 return snd_soc_write(codec, WM8523_DEVICE_ID, 0);
75}
76
77static const DECLARE_TLV_DB_SCALE(dac_tlv, -10000, 25, 0); 71static const DECLARE_TLV_DB_SCALE(dac_tlv, -10000, 25, 0);
78 72
79static const char *wm8523_zd_count_text[] = { 73static const char *wm8523_zd_count_text[] = {
@@ -301,8 +295,7 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
301 enum snd_soc_bias_level level) 295 enum snd_soc_bias_level level)
302{ 296{
303 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); 297 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
304 u16 *reg_cache = codec->reg_cache; 298 int ret;
305 int ret, i;
306 299
307 switch (level) { 300 switch (level) {
308 case SND_SOC_BIAS_ON: 301 case SND_SOC_BIAS_ON:
@@ -325,16 +318,13 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
325 return ret; 318 return ret;
326 } 319 }
327 320
321 /* Sync back default/cached values */
322 regcache_sync(wm8523->regmap);
323
328 /* Initial power up */ 324 /* Initial power up */
329 snd_soc_update_bits(codec, WM8523_PSCTRL1, 325 snd_soc_update_bits(codec, WM8523_PSCTRL1,
330 WM8523_SYS_ENA_MASK, 1); 326 WM8523_SYS_ENA_MASK, 1);
331 327
332 /* Sync back default/cached values */
333 for (i = WM8523_AIF_CTRL1;
334 i < WM8523_MAX_REGISTER; i++)
335 snd_soc_write(codec, i, reg_cache[i]);
336
337
338 msleep(100); 328 msleep(100);
339 } 329 }
340 330
@@ -402,60 +392,18 @@ static int wm8523_resume(struct snd_soc_codec *codec)
402static int wm8523_probe(struct snd_soc_codec *codec) 392static int wm8523_probe(struct snd_soc_codec *codec)
403{ 393{
404 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); 394 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
405 int ret, i; 395 int ret;
406 396
407 wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; 397 wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0];
408 wm8523->rate_constraint.count = 398 wm8523->rate_constraint.count =
409 ARRAY_SIZE(wm8523->rate_constraint_list); 399 ARRAY_SIZE(wm8523->rate_constraint_list);
410 400
411 ret = snd_soc_codec_set_cache_io(codec, 8, 16, wm8523->control_type); 401 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
412 if (ret != 0) { 402 if (ret != 0) {
413 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 403 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
414 return ret; 404 return ret;
415 } 405 }
416 406
417 for (i = 0; i < ARRAY_SIZE(wm8523->supplies); i++)
418 wm8523->supplies[i].supply = wm8523_supply_names[i];
419
420 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8523->supplies),
421 wm8523->supplies);
422 if (ret != 0) {
423 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
424 return ret;
425 }
426
427 ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies),
428 wm8523->supplies);
429 if (ret != 0) {
430 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
431 goto err_get;
432 }
433
434 ret = snd_soc_read(codec, WM8523_DEVICE_ID);
435 if (ret < 0) {
436 dev_err(codec->dev, "Failed to read ID register\n");
437 goto err_enable;
438 }
439 if (ret != wm8523_reg[WM8523_DEVICE_ID]) {
440 dev_err(codec->dev, "Device is not a WM8523, ID is %x\n", ret);
441 ret = -EINVAL;
442 goto err_enable;
443 }
444
445 ret = snd_soc_read(codec, WM8523_REVISION);
446 if (ret < 0) {
447 dev_err(codec->dev, "Failed to read revision register\n");
448 goto err_enable;
449 }
450 dev_info(codec->dev, "revision %c\n",
451 (ret & WM8523_CHIP_REV_MASK) + 'A');
452
453 ret = wm8523_reset(codec);
454 if (ret < 0) {
455 dev_err(codec->dev, "Failed to issue reset\n");
456 goto err_enable;
457 }
458
459 /* Change some default settings - latch VU and enable ZC */ 407 /* Change some default settings - latch VU and enable ZC */
460 snd_soc_update_bits(codec, WM8523_DAC_GAINR, 408 snd_soc_update_bits(codec, WM8523_DAC_GAINR,
461 WM8523_DACR_VU, WM8523_DACR_VU); 409 WM8523_DACR_VU, WM8523_DACR_VU);
@@ -463,25 +411,12 @@ static int wm8523_probe(struct snd_soc_codec *codec)
463 411
464 wm8523_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 412 wm8523_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
465 413
466 /* Bias level configuration will have done an extra enable */
467 regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies);
468
469 return 0; 414 return 0;
470
471err_enable:
472 regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies);
473err_get:
474 regulator_bulk_free(ARRAY_SIZE(wm8523->supplies), wm8523->supplies);
475
476 return ret;
477} 415}
478 416
479static int wm8523_remove(struct snd_soc_codec *codec) 417static int wm8523_remove(struct snd_soc_codec *codec)
480{ 418{
481 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
482
483 wm8523_set_bias_level(codec, SND_SOC_BIAS_OFF); 419 wm8523_set_bias_level(codec, SND_SOC_BIAS_OFF);
484 regulator_bulk_free(ARRAY_SIZE(wm8523->supplies), wm8523->supplies);
485 return 0; 420 return 0;
486} 421}
487 422
@@ -491,10 +426,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8523 = {
491 .suspend = wm8523_suspend, 426 .suspend = wm8523_suspend,
492 .resume = wm8523_resume, 427 .resume = wm8523_resume,
493 .set_bias_level = wm8523_set_bias_level, 428 .set_bias_level = wm8523_set_bias_level,
494 .reg_cache_size = WM8523_REGISTER_COUNT,
495 .reg_word_size = sizeof(u16),
496 .reg_cache_default = wm8523_reg,
497 .volatile_register = wm8523_volatile_register,
498 429
499 .controls = wm8523_controls, 430 .controls = wm8523_controls,
500 .num_controls = ARRAY_SIZE(wm8523_controls), 431 .num_controls = ARRAY_SIZE(wm8523_controls),
@@ -509,32 +440,97 @@ static const struct of_device_id wm8523_of_match[] = {
509 { }, 440 { },
510}; 441};
511 442
443static const struct regmap_config wm8523_regmap = {
444 .reg_bits = 8,
445 .val_bits = 16,
446 .max_register = WM8523_ZERO_DETECT,
447
448 .reg_defaults = wm8523_reg_defaults,
449 .num_reg_defaults = ARRAY_SIZE(wm8523_reg_defaults),
450 .cache_type = REGCACHE_RBTREE,
451
452 .volatile_reg = wm8523_volatile_register,
453};
454
512#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 455#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
513static __devinit int wm8523_i2c_probe(struct i2c_client *i2c, 456static __devinit int wm8523_i2c_probe(struct i2c_client *i2c,
514 const struct i2c_device_id *id) 457 const struct i2c_device_id *id)
515{ 458{
516 struct wm8523_priv *wm8523; 459 struct wm8523_priv *wm8523;
517 int ret; 460 unsigned int val;
461 int ret, i;
518 462
519 wm8523 = kzalloc(sizeof(struct wm8523_priv), GFP_KERNEL); 463 wm8523 = devm_kzalloc(&i2c->dev, sizeof(struct wm8523_priv),
464 GFP_KERNEL);
520 if (wm8523 == NULL) 465 if (wm8523 == NULL)
521 return -ENOMEM; 466 return -ENOMEM;
522 467
468 wm8523->regmap = devm_regmap_init_i2c(i2c, &wm8523_regmap);
469 if (IS_ERR(wm8523->regmap)) {
470 ret = PTR_ERR(wm8523->regmap);
471 dev_err(&i2c->dev, "Failed to create regmap: %d\n", ret);
472 return ret;
473 }
474
475 for (i = 0; i < ARRAY_SIZE(wm8523->supplies); i++)
476 wm8523->supplies[i].supply = wm8523_supply_names[i];
477
478 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8523->supplies),
479 wm8523->supplies);
480 if (ret != 0) {
481 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
482 return ret;
483 }
484
485 ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies),
486 wm8523->supplies);
487 if (ret != 0) {
488 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
489 return ret;
490 }
491
492 ret = regmap_read(wm8523->regmap, WM8523_DEVICE_ID, &val);
493 if (ret < 0) {
494 dev_err(&i2c->dev, "Failed to read ID register\n");
495 goto err_enable;
496 }
497 if (val != 0x8523) {
498 dev_err(&i2c->dev, "Device is not a WM8523, ID is %x\n", ret);
499 ret = -EINVAL;
500 goto err_enable;
501 }
502
503 ret = regmap_read(wm8523->regmap, WM8523_REVISION, &val);
504 if (ret < 0) {
505 dev_err(&i2c->dev, "Failed to read revision register\n");
506 goto err_enable;
507 }
508 dev_info(&i2c->dev, "revision %c\n",
509 (val & WM8523_CHIP_REV_MASK) + 'A');
510
511 ret = regmap_write(wm8523->regmap, WM8523_DEVICE_ID, 0x8523);
512 if (ret != 0) {
513 dev_err(&i2c->dev, "Failed to reset device: %d\n", ret);
514 goto err_enable;
515 }
516
517 regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies);
518
523 i2c_set_clientdata(i2c, wm8523); 519 i2c_set_clientdata(i2c, wm8523);
524 wm8523->control_type = SND_SOC_I2C;
525 520
526 ret = snd_soc_register_codec(&i2c->dev, 521 ret = snd_soc_register_codec(&i2c->dev,
527 &soc_codec_dev_wm8523, &wm8523_dai, 1); 522 &soc_codec_dev_wm8523, &wm8523_dai, 1);
528 if (ret < 0) 523
529 kfree(wm8523);
530 return ret; 524 return ret;
531 525
526err_enable:
527 regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies);
528 return ret;
532} 529}
533 530
534static __devexit int wm8523_i2c_remove(struct i2c_client *client) 531static __devexit int wm8523_i2c_remove(struct i2c_client *client)
535{ 532{
536 snd_soc_unregister_codec(&client->dev); 533 snd_soc_unregister_codec(&client->dev);
537 kfree(i2c_get_clientdata(client));
538 return 0; 534 return 0;
539} 535}
540 536
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c
index 7c68226376e4..5e9c40fa7eb2 100644
--- a/sound/soc/codecs/wm8580.c
+++ b/sound/soc/codecs/wm8580.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * wm8580.c -- WM8580 ALSA Soc Audio driver 2 * wm8580.c -- WM8580 ALSA Soc Audio driver
3 * 3 *
4 * Copyright 2008-11 Wolfson Microelectronics PLC. 4 * Copyright 2008-12 Wolfson Microelectronics PLC.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the 7 * under the terms of the GNU General Public License as published by the
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/pm.h> 24#include <linux/pm.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/regmap.h>
26#include <linux/regulator/consumer.h> 27#include <linux/regulator/consumer.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <linux/of_device.h> 29#include <linux/of_device.h>
@@ -157,23 +158,72 @@
157 * We can't read the WM8580 register space when we 158 * We can't read the WM8580 register space when we
158 * are using 2 wire for device control, so we cache them instead. 159 * are using 2 wire for device control, so we cache them instead.
159 */ 160 */
160static const u16 wm8580_reg[] = { 161static const struct reg_default wm8580_reg_defaults[] = {
161 0x0121, 0x017e, 0x007d, 0x0014, /*R3*/ 162 { 0, 0x0121 },
162 0x0121, 0x017e, 0x007d, 0x0194, /*R7*/ 163 { 1, 0x017e },
163 0x0010, 0x0002, 0x0002, 0x00c2, /*R11*/ 164 { 2, 0x007d },
164 0x0182, 0x0082, 0x000a, 0x0024, /*R15*/ 165 { 3, 0x0014 },
165 0x0009, 0x0000, 0x00ff, 0x0000, /*R19*/ 166 { 4, 0x0121 },
166 0x00ff, 0x00ff, 0x00ff, 0x00ff, /*R23*/ 167 { 5, 0x017e },
167 0x00ff, 0x00ff, 0x00ff, 0x00ff, /*R27*/ 168 { 6, 0x007d },
168 0x01f0, 0x0040, 0x0000, 0x0000, /*R31(0x1F)*/ 169 { 7, 0x0194 },
169 0x0000, 0x0000, 0x0031, 0x000b, /*R35*/ 170 { 8, 0x0010 },
170 0x0039, 0x0000, 0x0010, 0x0032, /*R39*/ 171 { 9, 0x0002 },
171 0x0054, 0x0076, 0x0098, 0x0000, /*R43(0x2B)*/ 172 { 10, 0x0002 },
172 0x0000, 0x0000, 0x0000, 0x0000, /*R47*/ 173 { 11, 0x00c2 },
173 0x0000, 0x0000, 0x005e, 0x003e, /*R51(0x33)*/ 174 { 12, 0x0182 },
174 0x0000, 0x0000 /*R53*/ 175 { 13, 0x0082 },
176 { 14, 0x000a },
177 { 15, 0x0024 },
178 { 16, 0x0009 },
179 { 17, 0x0000 },
180 { 18, 0x00ff },
181 { 19, 0x0000 },
182 { 20, 0x00ff },
183 { 21, 0x00ff },
184 { 22, 0x00ff },
185 { 23, 0x00ff },
186 { 24, 0x00ff },
187 { 25, 0x00ff },
188 { 26, 0x00ff },
189 { 27, 0x00ff },
190 { 28, 0x01f0 },
191 { 29, 0x0040 },
192 { 30, 0x0000 },
193 { 31, 0x0000 },
194 { 32, 0x0000 },
195 { 33, 0x0000 },
196 { 34, 0x0031 },
197 { 35, 0x000b },
198 { 36, 0x0039 },
199 { 37, 0x0000 },
200 { 38, 0x0010 },
201 { 39, 0x0032 },
202 { 40, 0x0054 },
203 { 41, 0x0076 },
204 { 42, 0x0098 },
205 { 43, 0x0000 },
206 { 44, 0x0000 },
207 { 45, 0x0000 },
208 { 46, 0x0000 },
209 { 47, 0x0000 },
210 { 48, 0x0000 },
211 { 49, 0x0000 },
212 { 50, 0x005e },
213 { 51, 0x003e },
214 { 52, 0x0000 },
175}; 215};
176 216
217static bool wm8580_volatile(struct device *dev, unsigned int reg)
218{
219 switch (reg) {
220 case WM8580_RESET:
221 return true;
222 default:
223 return false;
224 }
225}
226
177struct pll_state { 227struct pll_state {
178 unsigned int in; 228 unsigned int in;
179 unsigned int out; 229 unsigned int out;
@@ -188,7 +238,7 @@ static const char *wm8580_supply_names[WM8580_NUM_SUPPLIES] = {
188 238
189/* codec private data */ 239/* codec private data */
190struct wm8580_priv { 240struct wm8580_priv {
191 enum snd_soc_control_type control_type; 241 struct regmap *regmap;
192 struct regulator_bulk_data supplies[WM8580_NUM_SUPPLIES]; 242 struct regulator_bulk_data supplies[WM8580_NUM_SUPPLIES];
193 struct pll_state a; 243 struct pll_state a;
194 struct pll_state b; 244 struct pll_state b;
@@ -203,14 +253,16 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol,
203 struct soc_mixer_control *mc = 253 struct soc_mixer_control *mc =
204 (struct soc_mixer_control *)kcontrol->private_value; 254 (struct soc_mixer_control *)kcontrol->private_value;
205 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 255 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
206 u16 *reg_cache = codec->reg_cache; 256 struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
207 unsigned int reg = mc->reg; 257 unsigned int reg = mc->reg;
208 unsigned int reg2 = mc->rreg; 258 unsigned int reg2 = mc->rreg;
209 int ret; 259 int ret;
210 260
211 /* Clear the register cache so we write without VU set */ 261 /* Clear the register cache VU so we write without VU set */
212 reg_cache[reg] = 0; 262 regcache_cache_only(wm8580->regmap, true);
213 reg_cache[reg2] = 0; 263 regmap_update_bits(wm8580->regmap, reg, 0x100, 0x000);
264 regmap_update_bits(wm8580->regmap, reg2, 0x100, 0x000);
265 regcache_cache_only(wm8580->regmap, false);
214 266
215 ret = snd_soc_put_volsw(kcontrol, ucontrol); 267 ret = snd_soc_put_volsw(kcontrol, ucontrol);
216 if (ret < 0) 268 if (ret < 0)
@@ -815,24 +867,14 @@ static struct snd_soc_dai_driver wm8580_dai[] = {
815static int wm8580_probe(struct snd_soc_codec *codec) 867static int wm8580_probe(struct snd_soc_codec *codec)
816{ 868{
817 struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); 869 struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
818 int ret = 0,i; 870 int ret = 0;
819 871
820 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8580->control_type); 872 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
821 if (ret < 0) { 873 if (ret < 0) {
822 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 874 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
823 return ret; 875 return ret;
824 } 876 }
825 877
826 for (i = 0; i < ARRAY_SIZE(wm8580->supplies); i++)
827 wm8580->supplies[i].supply = wm8580_supply_names[i];
828
829 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8580->supplies),
830 wm8580->supplies);
831 if (ret != 0) {
832 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
833 return ret;
834 }
835
836 ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies), 878 ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies),
837 wm8580->supplies); 879 wm8580->supplies);
838 if (ret != 0) { 880 if (ret != 0) {
@@ -854,7 +896,6 @@ static int wm8580_probe(struct snd_soc_codec *codec)
854err_regulator_enable: 896err_regulator_enable:
855 regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); 897 regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
856err_regulator_get: 898err_regulator_get:
857 regulator_bulk_free(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
858 return ret; 899 return ret;
859} 900}
860 901
@@ -866,7 +907,6 @@ static int wm8580_remove(struct snd_soc_codec *codec)
866 wm8580_set_bias_level(codec, SND_SOC_BIAS_OFF); 907 wm8580_set_bias_level(codec, SND_SOC_BIAS_OFF);
867 908
868 regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); 909 regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
869 regulator_bulk_free(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
870 910
871 return 0; 911 return 0;
872} 912}
@@ -875,9 +915,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8580 = {
875 .probe = wm8580_probe, 915 .probe = wm8580_probe,
876 .remove = wm8580_remove, 916 .remove = wm8580_remove,
877 .set_bias_level = wm8580_set_bias_level, 917 .set_bias_level = wm8580_set_bias_level,
878 .reg_cache_size = ARRAY_SIZE(wm8580_reg),
879 .reg_word_size = sizeof(u16),
880 .reg_cache_default = wm8580_reg,
881 918
882 .controls = wm8580_snd_controls, 919 .controls = wm8580_snd_controls,
883 .num_controls = ARRAY_SIZE(wm8580_snd_controls), 920 .num_controls = ARRAY_SIZE(wm8580_snd_controls),
@@ -892,31 +929,55 @@ static const struct of_device_id wm8580_of_match[] = {
892 { }, 929 { },
893}; 930};
894 931
932static const struct regmap_config wm8580_regmap = {
933 .reg_bits = 7,
934 .val_bits = 9,
935 .max_register = WM8580_MAX_REGISTER,
936
937 .reg_defaults = wm8580_reg_defaults,
938 .num_reg_defaults = ARRAY_SIZE(wm8580_reg_defaults),
939 .cache_type = REGCACHE_RBTREE,
940
941 .volatile_reg = wm8580_volatile,
942};
943
895#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 944#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
896static int wm8580_i2c_probe(struct i2c_client *i2c, 945static int wm8580_i2c_probe(struct i2c_client *i2c,
897 const struct i2c_device_id *id) 946 const struct i2c_device_id *id)
898{ 947{
899 struct wm8580_priv *wm8580; 948 struct wm8580_priv *wm8580;
900 int ret; 949 int ret, i;
901 950
902 wm8580 = kzalloc(sizeof(struct wm8580_priv), GFP_KERNEL); 951 wm8580 = devm_kzalloc(&i2c->dev, sizeof(struct wm8580_priv),
952 GFP_KERNEL);
903 if (wm8580 == NULL) 953 if (wm8580 == NULL)
904 return -ENOMEM; 954 return -ENOMEM;
905 955
956 wm8580->regmap = devm_regmap_init_i2c(i2c, &wm8580_regmap);
957 if (IS_ERR(wm8580->regmap))
958 return PTR_ERR(wm8580->regmap);
959
960 for (i = 0; i < ARRAY_SIZE(wm8580->supplies); i++)
961 wm8580->supplies[i].supply = wm8580_supply_names[i];
962
963 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8580->supplies),
964 wm8580->supplies);
965 if (ret != 0) {
966 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
967 return ret;
968 }
969
906 i2c_set_clientdata(i2c, wm8580); 970 i2c_set_clientdata(i2c, wm8580);
907 wm8580->control_type = SND_SOC_I2C;
908 971
909 ret = snd_soc_register_codec(&i2c->dev, 972 ret = snd_soc_register_codec(&i2c->dev,
910 &soc_codec_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai)); 973 &soc_codec_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai));
911 if (ret < 0) 974
912 kfree(wm8580);
913 return ret; 975 return ret;
914} 976}
915 977
916static int wm8580_i2c_remove(struct i2c_client *client) 978static int wm8580_i2c_remove(struct i2c_client *client)
917{ 979{
918 snd_soc_unregister_codec(&client->dev); 980 snd_soc_unregister_codec(&client->dev);
919 kfree(i2c_get_clientdata(client));
920 return 0; 981 return 0;
921} 982}
922 983
diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c
index 0b76d1dca5ea..8b8bb70f1eb9 100644
--- a/sound/soc/codecs/wm8711.c
+++ b/sound/soc/codecs/wm8711.c
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/regmap.h>
21#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23#include <linux/of_device.h> 24#include <linux/of_device.h>
@@ -32,7 +33,7 @@
32 33
33/* codec private data */ 34/* codec private data */
34struct wm8711_priv { 35struct wm8711_priv {
35 enum snd_soc_control_type bus_type; 36 struct regmap *regmap;
36 unsigned int sysclk; 37 unsigned int sysclk;
37}; 38};
38 39
@@ -42,11 +43,21 @@ struct wm8711_priv {
42 * using 2 wire for device control, so we cache them instead. 43 * using 2 wire for device control, so we cache them instead.
43 * There is no point in caching the reset register 44 * There is no point in caching the reset register
44 */ 45 */
45static const u16 wm8711_reg[WM8711_CACHEREGNUM] = { 46static const struct reg_default wm8711_reg_defaults[] = {
46 0x0079, 0x0079, 0x000a, 0x0008, 47 { 0, 0x0079 }, { 1, 0x0079 }, { 2, 0x000a }, { 3, 0x0008 },
47 0x009f, 0x000a, 0x0000, 0x0000 48 { 4, 0x009f }, { 5, 0x000a }, { 6, 0x0000 }, { 7, 0x0000 },
48}; 49};
49 50
51static bool wm8711_volatile(struct device *dev, unsigned int reg)
52{
53 switch (reg) {
54 case WM8711_RESET:
55 return true;
56 default:
57 return false;
58 }
59}
60
50#define wm8711_reset(c) snd_soc_write(c, WM8711_RESET, 0) 61#define wm8711_reset(c) snd_soc_write(c, WM8711_RESET, 0)
51 62
52static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1); 63static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
@@ -289,6 +300,7 @@ static int wm8711_set_dai_fmt(struct snd_soc_dai *codec_dai,
289static int wm8711_set_bias_level(struct snd_soc_codec *codec, 300static int wm8711_set_bias_level(struct snd_soc_codec *codec,
290 enum snd_soc_bias_level level) 301 enum snd_soc_bias_level level)
291{ 302{
303 struct wm8711_priv *wm8711 = snd_soc_codec_get_drvdata(codec);
292 u16 reg = snd_soc_read(codec, WM8711_PWR) & 0xff7f; 304 u16 reg = snd_soc_read(codec, WM8711_PWR) & 0xff7f;
293 305
294 switch (level) { 306 switch (level) {
@@ -299,7 +311,7 @@ static int wm8711_set_bias_level(struct snd_soc_codec *codec,
299 break; 311 break;
300 case SND_SOC_BIAS_STANDBY: 312 case SND_SOC_BIAS_STANDBY:
301 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) 313 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
302 snd_soc_cache_sync(codec); 314 regcache_sync(wm8711->regmap);
303 315
304 snd_soc_write(codec, WM8711_PWR, reg | 0x0040); 316 snd_soc_write(codec, WM8711_PWR, reg | 0x0040);
305 break; 317 break;
@@ -353,10 +365,9 @@ static int wm8711_resume(struct snd_soc_codec *codec)
353 365
354static int wm8711_probe(struct snd_soc_codec *codec) 366static int wm8711_probe(struct snd_soc_codec *codec)
355{ 367{
356 struct wm8711_priv *wm8711 = snd_soc_codec_get_drvdata(codec);
357 int ret; 368 int ret;
358 369
359 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8711->bus_type); 370 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
360 if (ret < 0) { 371 if (ret < 0) {
361 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 372 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
362 return ret; 373 return ret;
@@ -391,9 +402,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8711 = {
391 .suspend = wm8711_suspend, 402 .suspend = wm8711_suspend,
392 .resume = wm8711_resume, 403 .resume = wm8711_resume,
393 .set_bias_level = wm8711_set_bias_level, 404 .set_bias_level = wm8711_set_bias_level,
394 .reg_cache_size = ARRAY_SIZE(wm8711_reg),
395 .reg_word_size = sizeof(u16),
396 .reg_cache_default = wm8711_reg,
397 .controls = wm8711_snd_controls, 405 .controls = wm8711_snd_controls,
398 .num_controls = ARRAY_SIZE(wm8711_snd_controls), 406 .num_controls = ARRAY_SIZE(wm8711_snd_controls),
399 .dapm_widgets = wm8711_dapm_widgets, 407 .dapm_widgets = wm8711_dapm_widgets,
@@ -408,30 +416,45 @@ static const struct of_device_id wm8711_of_match[] = {
408}; 416};
409MODULE_DEVICE_TABLE(of, wm8711_of_match); 417MODULE_DEVICE_TABLE(of, wm8711_of_match);
410 418
419static const struct regmap_config wm8711_regmap = {
420 .reg_bits = 7,
421 .val_bits = 9,
422 .max_register = WM8711_RESET,
423
424 .reg_defaults = wm8711_reg_defaults,
425 .num_reg_defaults = ARRAY_SIZE(wm8711_reg_defaults),
426 .cache_type = REGCACHE_RBTREE,
427
428 .volatile_reg = wm8711_volatile,
429};
430
411#if defined(CONFIG_SPI_MASTER) 431#if defined(CONFIG_SPI_MASTER)
412static int __devinit wm8711_spi_probe(struct spi_device *spi) 432static int __devinit wm8711_spi_probe(struct spi_device *spi)
413{ 433{
414 struct wm8711_priv *wm8711; 434 struct wm8711_priv *wm8711;
415 int ret; 435 int ret;
416 436
417 wm8711 = kzalloc(sizeof(struct wm8711_priv), GFP_KERNEL); 437 wm8711 = devm_kzalloc(&spi->dev, sizeof(struct wm8711_priv),
438 GFP_KERNEL);
418 if (wm8711 == NULL) 439 if (wm8711 == NULL)
419 return -ENOMEM; 440 return -ENOMEM;
420 441
442 wm8711->regmap = devm_regmap_init_spi(spi, &wm8711_regmap);
443 if (IS_ERR(wm8711->regmap))
444 return PTR_ERR(wm8711->regmap);
445
421 spi_set_drvdata(spi, wm8711); 446 spi_set_drvdata(spi, wm8711);
422 wm8711->bus_type = SND_SOC_SPI;
423 447
424 ret = snd_soc_register_codec(&spi->dev, 448 ret = snd_soc_register_codec(&spi->dev,
425 &soc_codec_dev_wm8711, &wm8711_dai, 1); 449 &soc_codec_dev_wm8711, &wm8711_dai, 1);
426 if (ret < 0) 450
427 kfree(wm8711);
428 return ret; 451 return ret;
429} 452}
430 453
431static int __devexit wm8711_spi_remove(struct spi_device *spi) 454static int __devexit wm8711_spi_remove(struct spi_device *spi)
432{ 455{
433 snd_soc_unregister_codec(&spi->dev); 456 snd_soc_unregister_codec(&spi->dev);
434 kfree(spi_get_drvdata(spi)); 457
435 return 0; 458 return 0;
436} 459}
437 460
@@ -453,24 +476,26 @@ static __devinit int wm8711_i2c_probe(struct i2c_client *client,
453 struct wm8711_priv *wm8711; 476 struct wm8711_priv *wm8711;
454 int ret; 477 int ret;
455 478
456 wm8711 = kzalloc(sizeof(struct wm8711_priv), GFP_KERNEL); 479 wm8711 = devm_kzalloc(&client->dev, sizeof(struct wm8711_priv),
480 GFP_KERNEL);
457 if (wm8711 == NULL) 481 if (wm8711 == NULL)
458 return -ENOMEM; 482 return -ENOMEM;
459 483
484 wm8711->regmap = devm_regmap_init_i2c(client, &wm8711_regmap);
485 if (IS_ERR(wm8711->regmap))
486 return PTR_ERR(wm8711->regmap);
487
460 i2c_set_clientdata(client, wm8711); 488 i2c_set_clientdata(client, wm8711);
461 wm8711->bus_type = SND_SOC_I2C;
462 489
463 ret = snd_soc_register_codec(&client->dev, 490 ret = snd_soc_register_codec(&client->dev,
464 &soc_codec_dev_wm8711, &wm8711_dai, 1); 491 &soc_codec_dev_wm8711, &wm8711_dai, 1);
465 if (ret < 0) 492
466 kfree(wm8711);
467 return ret; 493 return ret;
468} 494}
469 495
470static __devexit int wm8711_i2c_remove(struct i2c_client *client) 496static __devexit int wm8711_i2c_remove(struct i2c_client *client)
471{ 497{
472 snd_soc_unregister_codec(&client->dev); 498 snd_soc_unregister_codec(&client->dev);
473 kfree(i2c_get_clientdata(client));
474 return 0; 499 return 0;
475} 500}
476 501
diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c
index 1467f97dce21..00a12a0c3919 100644
--- a/sound/soc/codecs/wm8728.c
+++ b/sound/soc/codecs/wm8728.c
@@ -17,6 +17,7 @@
17#include <linux/pm.h> 17#include <linux/pm.h>
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/regmap.h>
20#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
22#include <linux/of_device.h> 23#include <linux/of_device.h>
@@ -35,16 +36,16 @@
35 * the volume update bits, mute the output and enable infinite zero 36 * the volume update bits, mute the output and enable infinite zero
36 * detect. 37 * detect.
37 */ 38 */
38static const u16 wm8728_reg_defaults[] = { 39static const struct reg_default wm8728_reg_defaults[] = {
39 0x1ff, 40 { 0, 0x1ff },
40 0x1ff, 41 { 1, 0x1ff },
41 0x001, 42 { 2, 0x001 },
42 0x100, 43 { 3, 0x100 },
43}; 44};
44 45
45/* codec private data */ 46/* codec private data */
46struct wm8728_priv { 47struct wm8728_priv {
47 enum snd_soc_control_type control_type; 48 struct regmap *regmap;
48}; 49};
49 50
50static const DECLARE_TLV_DB_SCALE(wm8728_tlv, -12750, 50, 1); 51static const DECLARE_TLV_DB_SCALE(wm8728_tlv, -12750, 50, 1);
@@ -162,8 +163,8 @@ static int wm8728_set_dai_fmt(struct snd_soc_dai *codec_dai,
162static int wm8728_set_bias_level(struct snd_soc_codec *codec, 163static int wm8728_set_bias_level(struct snd_soc_codec *codec,
163 enum snd_soc_bias_level level) 164 enum snd_soc_bias_level level)
164{ 165{
166 struct wm8728_priv *wm8728 = snd_soc_codec_get_drvdata(codec);
165 u16 reg; 167 u16 reg;
166 int i;
167 168
168 switch (level) { 169 switch (level) {
169 case SND_SOC_BIAS_ON: 170 case SND_SOC_BIAS_ON:
@@ -175,9 +176,7 @@ static int wm8728_set_bias_level(struct snd_soc_codec *codec,
175 snd_soc_write(codec, WM8728_DACCTL, reg & ~0x4); 176 snd_soc_write(codec, WM8728_DACCTL, reg & ~0x4);
176 177
177 /* ..then sync in the register cache. */ 178 /* ..then sync in the register cache. */
178 for (i = 0; i < ARRAY_SIZE(wm8728_reg_defaults); i++) 179 regcache_sync(wm8728->regmap);
179 snd_soc_write(codec, i,
180 snd_soc_read(codec, i));
181 } 180 }
182 break; 181 break;
183 182
@@ -229,10 +228,9 @@ static int wm8728_resume(struct snd_soc_codec *codec)
229 228
230static int wm8728_probe(struct snd_soc_codec *codec) 229static int wm8728_probe(struct snd_soc_codec *codec)
231{ 230{
232 struct wm8728_priv *wm8728 = snd_soc_codec_get_drvdata(codec);
233 int ret; 231 int ret;
234 232
235 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8728->control_type); 233 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
236 if (ret < 0) { 234 if (ret < 0) {
237 printk(KERN_ERR "wm8728: failed to configure cache I/O: %d\n", 235 printk(KERN_ERR "wm8728: failed to configure cache I/O: %d\n",
238 ret); 236 ret);
@@ -257,9 +255,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8728 = {
257 .suspend = wm8728_suspend, 255 .suspend = wm8728_suspend,
258 .resume = wm8728_resume, 256 .resume = wm8728_resume,
259 .set_bias_level = wm8728_set_bias_level, 257 .set_bias_level = wm8728_set_bias_level,
260 .reg_cache_size = ARRAY_SIZE(wm8728_reg_defaults),
261 .reg_word_size = sizeof(u16),
262 .reg_cache_default = wm8728_reg_defaults,
263 .controls = wm8728_snd_controls, 258 .controls = wm8728_snd_controls,
264 .num_controls = ARRAY_SIZE(wm8728_snd_controls), 259 .num_controls = ARRAY_SIZE(wm8728_snd_controls),
265 .dapm_widgets = wm8728_dapm_widgets, 260 .dapm_widgets = wm8728_dapm_widgets,
@@ -274,30 +269,43 @@ static const struct of_device_id wm8728_of_match[] = {
274}; 269};
275MODULE_DEVICE_TABLE(of, wm8728_of_match); 270MODULE_DEVICE_TABLE(of, wm8728_of_match);
276 271
272static const struct regmap_config wm8728_regmap = {
273 .reg_bits = 7,
274 .val_bits = 9,
275 .max_register = WM8728_IFCTL,
276
277 .reg_defaults = wm8728_reg_defaults,
278 .num_reg_defaults = ARRAY_SIZE(wm8728_reg_defaults),
279 .cache_type = REGCACHE_RBTREE,
280};
281
277#if defined(CONFIG_SPI_MASTER) 282#if defined(CONFIG_SPI_MASTER)
278static int __devinit wm8728_spi_probe(struct spi_device *spi) 283static int __devinit wm8728_spi_probe(struct spi_device *spi)
279{ 284{
280 struct wm8728_priv *wm8728; 285 struct wm8728_priv *wm8728;
281 int ret; 286 int ret;
282 287
283 wm8728 = kzalloc(sizeof(struct wm8728_priv), GFP_KERNEL); 288 wm8728 = devm_kzalloc(&spi->dev, sizeof(struct wm8728_priv),
289 GFP_KERNEL);
284 if (wm8728 == NULL) 290 if (wm8728 == NULL)
285 return -ENOMEM; 291 return -ENOMEM;
286 292
287 wm8728->control_type = SND_SOC_SPI; 293 wm8728->regmap = devm_regmap_init_spi(spi, &wm8728_regmap);
294 if (IS_ERR(wm8728->regmap))
295 return PTR_ERR(wm8728->regmap);
296
288 spi_set_drvdata(spi, wm8728); 297 spi_set_drvdata(spi, wm8728);
289 298
290 ret = snd_soc_register_codec(&spi->dev, 299 ret = snd_soc_register_codec(&spi->dev,
291 &soc_codec_dev_wm8728, &wm8728_dai, 1); 300 &soc_codec_dev_wm8728, &wm8728_dai, 1);
292 if (ret < 0) 301
293 kfree(wm8728);
294 return ret; 302 return ret;
295} 303}
296 304
297static int __devexit wm8728_spi_remove(struct spi_device *spi) 305static int __devexit wm8728_spi_remove(struct spi_device *spi)
298{ 306{
299 snd_soc_unregister_codec(&spi->dev); 307 snd_soc_unregister_codec(&spi->dev);
300 kfree(spi_get_drvdata(spi)); 308
301 return 0; 309 return 0;
302} 310}
303 311
@@ -319,24 +327,26 @@ static __devinit int wm8728_i2c_probe(struct i2c_client *i2c,
319 struct wm8728_priv *wm8728; 327 struct wm8728_priv *wm8728;
320 int ret; 328 int ret;
321 329
322 wm8728 = kzalloc(sizeof(struct wm8728_priv), GFP_KERNEL); 330 wm8728 = devm_kzalloc(&i2c->dev, sizeof(struct wm8728_priv),
331 GFP_KERNEL);
323 if (wm8728 == NULL) 332 if (wm8728 == NULL)
324 return -ENOMEM; 333 return -ENOMEM;
325 334
335 wm8728->regmap = devm_regmap_init_i2c(i2c, &wm8728_regmap);
336 if (IS_ERR(wm8728->regmap))
337 return PTR_ERR(wm8728->regmap);
338
326 i2c_set_clientdata(i2c, wm8728); 339 i2c_set_clientdata(i2c, wm8728);
327 wm8728->control_type = SND_SOC_I2C;
328 340
329 ret = snd_soc_register_codec(&i2c->dev, 341 ret = snd_soc_register_codec(&i2c->dev,
330 &soc_codec_dev_wm8728, &wm8728_dai, 1); 342 &soc_codec_dev_wm8728, &wm8728_dai, 1);
331 if (ret < 0) 343
332 kfree(wm8728);
333 return ret; 344 return ret;
334} 345}
335 346
336static __devexit int wm8728_i2c_remove(struct i2c_client *client) 347static __devexit int wm8728_i2c_remove(struct i2c_client *client)
337{ 348{
338 snd_soc_unregister_codec(&client->dev); 349 snd_soc_unregister_codec(&client->dev);
339 kfree(i2c_get_clientdata(client));
340 return 0; 350 return 0;
341} 351}
342 352
diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c
index d0520124616d..5c9634f4c1f0 100644
--- a/sound/soc/codecs/wm8737.c
+++ b/sound/soc/codecs/wm8737.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,29 +41,39 @@ static const char *wm8737_supply_names[WM8737_NUM_SUPPLIES] = {
40 41
41/* codec private data */ 42/* codec private data */
42struct wm8737_priv { 43struct wm8737_priv {
43 enum snd_soc_control_type control_type; 44 struct regmap *regmap;
44 struct regulator_bulk_data supplies[WM8737_NUM_SUPPLIES]; 45 struct regulator_bulk_data supplies[WM8737_NUM_SUPPLIES];
45 unsigned int mclk; 46 unsigned int mclk;
46}; 47};
47 48
48static const u16 wm8737_reg[WM8737_REGISTER_COUNT] = { 49static const struct reg_default wm8737_reg_defaults[] = {
49 0x00C3, /* R0 - Left PGA volume */ 50 { 0, 0x00C3 }, /* R0 - Left PGA volume */
50 0x00C3, /* R1 - Right PGA volume */ 51 { 1, 0x00C3 }, /* R1 - Right PGA volume */
51 0x0007, /* R2 - AUDIO path L */ 52 { 2, 0x0007 }, /* R2 - AUDIO path L */
52 0x0007, /* R3 - AUDIO path R */ 53 { 3, 0x0007 }, /* R3 - AUDIO path R */
53 0x0000, /* R4 - 3D Enhance */ 54 { 4, 0x0000 }, /* R4 - 3D Enhance */
54 0x0000, /* R5 - ADC Control */ 55 { 5, 0x0000 }, /* R5 - ADC Control */
55 0x0000, /* R6 - Power Management */ 56 { 6, 0x0000 }, /* R6 - Power Management */
56 0x000A, /* R7 - Audio Format */ 57 { 7, 0x000A }, /* R7 - Audio Format */
57 0x0000, /* R8 - Clocking */ 58 { 8, 0x0000 }, /* R8 - Clocking */
58 0x000F, /* R9 - MIC Preamp Control */ 59 { 9, 0x000F }, /* R9 - MIC Preamp Control */
59 0x0003, /* R10 - Misc Bias Control */ 60 { 10, 0x0003 }, /* R10 - Misc Bias Control */
60 0x0000, /* R11 - Noise Gate */ 61 { 11, 0x0000 }, /* R11 - Noise Gate */
61 0x007C, /* R12 - ALC1 */ 62 { 12, 0x007C }, /* R12 - ALC1 */
62 0x0000, /* R13 - ALC2 */ 63 { 13, 0x0000 }, /* R13 - ALC2 */
63 0x0032, /* R14 - ALC3 */ 64 { 14, 0x0032 }, /* R14 - ALC3 */
64}; 65};
65 66
67static bool wm8737_volatile(struct device *dev, unsigned int reg)
68{
69 switch (reg) {
70 case WM8737_RESET:
71 return true;
72 default:
73 return false;
74 }
75}
76
66static int wm8737_reset(struct snd_soc_codec *codec) 77static int wm8737_reset(struct snd_soc_codec *codec)
67{ 78{
68 return snd_soc_write(codec, WM8737_RESET, 0); 79 return snd_soc_write(codec, WM8737_RESET, 0);
@@ -479,7 +490,7 @@ static int wm8737_set_bias_level(struct snd_soc_codec *codec,
479 return ret; 490 return ret;
480 } 491 }
481 492
482 snd_soc_cache_sync(codec); 493 regcache_sync(wm8737->regmap);
483 494
484 /* Fast VMID ramp at 2*2.5k */ 495 /* Fast VMID ramp at 2*2.5k */
485 snd_soc_update_bits(codec, WM8737_MISC_BIAS_CONTROL, 496 snd_soc_update_bits(codec, WM8737_MISC_BIAS_CONTROL,
@@ -557,24 +568,14 @@ static int wm8737_resume(struct snd_soc_codec *codec)
557static int wm8737_probe(struct snd_soc_codec *codec) 568static int wm8737_probe(struct snd_soc_codec *codec)
558{ 569{
559 struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); 570 struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec);
560 int ret, i; 571 int ret;
561 572
562 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8737->control_type); 573 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
563 if (ret != 0) { 574 if (ret != 0) {
564 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 575 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
565 return ret; 576 return ret;
566 } 577 }
567 578
568 for (i = 0; i < ARRAY_SIZE(wm8737->supplies); i++)
569 wm8737->supplies[i].supply = wm8737_supply_names[i];
570
571 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8737->supplies),
572 wm8737->supplies);
573 if (ret != 0) {
574 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
575 return ret;
576 }
577
578 ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies), 579 ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies),
579 wm8737->supplies); 580 wm8737->supplies);
580 if (ret != 0) { 581 if (ret != 0) {
@@ -607,17 +608,12 @@ static int wm8737_probe(struct snd_soc_codec *codec)
607err_enable: 608err_enable:
608 regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); 609 regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies);
609err_get: 610err_get:
610 regulator_bulk_free(ARRAY_SIZE(wm8737->supplies), wm8737->supplies);
611
612 return ret; 611 return ret;
613} 612}
614 613
615static int wm8737_remove(struct snd_soc_codec *codec) 614static int wm8737_remove(struct snd_soc_codec *codec)
616{ 615{
617 struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec);
618
619 wm8737_set_bias_level(codec, SND_SOC_BIAS_OFF); 616 wm8737_set_bias_level(codec, SND_SOC_BIAS_OFF);
620 regulator_bulk_free(ARRAY_SIZE(wm8737->supplies), wm8737->supplies);
621 return 0; 617 return 0;
622} 618}
623 619
@@ -627,10 +623,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8737 = {
627 .suspend = wm8737_suspend, 623 .suspend = wm8737_suspend,
628 .resume = wm8737_resume, 624 .resume = wm8737_resume,
629 .set_bias_level = wm8737_set_bias_level, 625 .set_bias_level = wm8737_set_bias_level,
630
631 .reg_cache_size = WM8737_REGISTER_COUNT - 1, /* Skip reset */
632 .reg_word_size = sizeof(u16),
633 .reg_cache_default = wm8737_reg,
634}; 626};
635 627
636static const struct of_device_id wm8737_of_match[] = { 628static const struct of_device_id wm8737_of_match[] = {
@@ -640,24 +632,49 @@ static const struct of_device_id wm8737_of_match[] = {
640 632
641MODULE_DEVICE_TABLE(of, wm8737_of_match); 633MODULE_DEVICE_TABLE(of, wm8737_of_match);
642 634
635static const struct regmap_config wm8737_regmap = {
636 .reg_bits = 7,
637 .val_bits = 9,
638 .max_register = WM8737_MAX_REGISTER,
639
640 .reg_defaults = wm8737_reg_defaults,
641 .num_reg_defaults = ARRAY_SIZE(wm8737_reg_defaults),
642 .cache_type = REGCACHE_RBTREE,
643
644 .volatile_reg = wm8737_volatile,
645};
646
643#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 647#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
644static __devinit int wm8737_i2c_probe(struct i2c_client *i2c, 648static __devinit int wm8737_i2c_probe(struct i2c_client *i2c,
645 const struct i2c_device_id *id) 649 const struct i2c_device_id *id)
646{ 650{
647 struct wm8737_priv *wm8737; 651 struct wm8737_priv *wm8737;
648 int ret; 652 int ret, i;
649 653
650 wm8737 = kzalloc(sizeof(struct wm8737_priv), GFP_KERNEL); 654 wm8737 = devm_kzalloc(&i2c->dev, sizeof(struct wm8737_priv),
655 GFP_KERNEL);
651 if (wm8737 == NULL) 656 if (wm8737 == NULL)
652 return -ENOMEM; 657 return -ENOMEM;
653 658
659 for (i = 0; i < ARRAY_SIZE(wm8737->supplies); i++)
660 wm8737->supplies[i].supply = wm8737_supply_names[i];
661
662 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8737->supplies),
663 wm8737->supplies);
664 if (ret != 0) {
665 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
666 return ret;
667 }
668
669 wm8737->regmap = devm_regmap_init_i2c(i2c, &wm8737_regmap);
670 if (IS_ERR(wm8737->regmap))
671 return PTR_ERR(wm8737->regmap);
672
654 i2c_set_clientdata(i2c, wm8737); 673 i2c_set_clientdata(i2c, wm8737);
655 wm8737->control_type = SND_SOC_I2C;
656 674
657 ret = snd_soc_register_codec(&i2c->dev, 675 ret = snd_soc_register_codec(&i2c->dev,
658 &soc_codec_dev_wm8737, &wm8737_dai, 1); 676 &soc_codec_dev_wm8737, &wm8737_dai, 1);
659 if (ret < 0) 677
660 kfree(wm8737);
661 return ret; 678 return ret;
662 679
663} 680}
@@ -665,7 +682,7 @@ static __devinit int wm8737_i2c_probe(struct i2c_client *i2c,
665static __devexit int wm8737_i2c_remove(struct i2c_client *client) 682static __devexit int wm8737_i2c_remove(struct i2c_client *client)
666{ 683{
667 snd_soc_unregister_codec(&client->dev); 684 snd_soc_unregister_codec(&client->dev);
668 kfree(i2c_get_clientdata(client)); 685
669 return 0; 686 return 0;
670} 687}
671 688
@@ -691,26 +708,39 @@ static struct i2c_driver wm8737_i2c_driver = {
691static int __devinit wm8737_spi_probe(struct spi_device *spi) 708static int __devinit wm8737_spi_probe(struct spi_device *spi)
692{ 709{
693 struct wm8737_priv *wm8737; 710 struct wm8737_priv *wm8737;
694 int ret; 711 int ret, i;
695 712
696 wm8737 = kzalloc(sizeof(struct wm8737_priv), GFP_KERNEL); 713 wm8737 = devm_kzalloc(&spi->dev, sizeof(struct wm8737_priv),
714 GFP_KERNEL);
697 if (wm8737 == NULL) 715 if (wm8737 == NULL)
698 return -ENOMEM; 716 return -ENOMEM;
699 717
700 wm8737->control_type = SND_SOC_SPI; 718 for (i = 0; i < ARRAY_SIZE(wm8737->supplies); i++)
719 wm8737->supplies[i].supply = wm8737_supply_names[i];
720
721 ret = devm_regulator_bulk_get(&spi->dev, ARRAY_SIZE(wm8737->supplies),
722 wm8737->supplies);
723 if (ret != 0) {
724 dev_err(&spi->dev, "Failed to request supplies: %d\n", ret);
725 return ret;
726 }
727
728 wm8737->regmap = devm_regmap_init_spi(spi, &wm8737_regmap);
729 if (IS_ERR(wm8737->regmap))
730 return PTR_ERR(wm8737->regmap);
731
701 spi_set_drvdata(spi, wm8737); 732 spi_set_drvdata(spi, wm8737);
702 733
703 ret = snd_soc_register_codec(&spi->dev, 734 ret = snd_soc_register_codec(&spi->dev,
704 &soc_codec_dev_wm8737, &wm8737_dai, 1); 735 &soc_codec_dev_wm8737, &wm8737_dai, 1);
705 if (ret < 0) 736
706 kfree(wm8737);
707 return ret; 737 return ret;
708} 738}
709 739
710static int __devexit wm8737_spi_remove(struct spi_device *spi) 740static int __devexit wm8737_spi_remove(struct spi_device *spi)
711{ 741{
712 snd_soc_unregister_codec(&spi->dev); 742 snd_soc_unregister_codec(&spi->dev);
713 kfree(spi_get_drvdata(spi)); 743
714 return 0; 744 return 0;
715} 745}
716 746
diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c
index 35f3d23200e0..4281a0802138 100644
--- a/sound/soc/codecs/wm8741.c
+++ b/sound/soc/codecs/wm8741.c
@@ -18,6 +18,7 @@
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/regmap.h>
21#include <linux/regulator/consumer.h> 22#include <linux/regulator/consumer.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23#include <linux/of_device.h> 24#include <linux/of_device.h>
@@ -40,26 +41,43 @@ static const char *wm8741_supply_names[WM8741_NUM_SUPPLIES] = {
40 41
41/* codec private data */ 42/* codec private data */
42struct wm8741_priv { 43struct wm8741_priv {
43 enum snd_soc_control_type control_type; 44 struct regmap *regmap;
44 struct regulator_bulk_data supplies[WM8741_NUM_SUPPLIES]; 45 struct regulator_bulk_data supplies[WM8741_NUM_SUPPLIES];
45 unsigned int sysclk; 46 unsigned int sysclk;
46 struct snd_pcm_hw_constraint_list *sysclk_constraints; 47 struct snd_pcm_hw_constraint_list *sysclk_constraints;
47}; 48};
48 49
49static const u16 wm8741_reg_defaults[WM8741_REGISTER_COUNT] = { 50static const struct reg_default wm8741_reg_defaults[] = {
50 0x0000, /* R0 - DACLLSB Attenuation */ 51 { 0, 0x0000 }, /* R0 - DACLLSB Attenuation */
51 0x0000, /* R1 - DACLMSB Attenuation */ 52 { 1, 0x0000 }, /* R1 - DACLMSB Attenuation */
52 0x0000, /* R2 - DACRLSB Attenuation */ 53 { 2, 0x0000 }, /* R2 - DACRLSB Attenuation */
53 0x0000, /* R3 - DACRMSB Attenuation */ 54 { 3, 0x0000 }, /* R3 - DACRMSB Attenuation */
54 0x0000, /* R4 - Volume Control */ 55 { 4, 0x0000 }, /* R4 - Volume Control */
55 0x000A, /* R5 - Format Control */ 56 { 5, 0x000A }, /* R5 - Format Control */
56 0x0000, /* R6 - Filter Control */ 57 { 6, 0x0000 }, /* R6 - Filter Control */
57 0x0000, /* R7 - Mode Control 1 */ 58 { 7, 0x0000 }, /* R7 - Mode Control 1 */
58 0x0002, /* R8 - Mode Control 2 */ 59 { 8, 0x0002 }, /* R8 - Mode Control 2 */
59 0x0000, /* R9 - Reset */ 60 { 32, 0x0002 }, /* R32 - ADDITONAL_CONTROL_1 */
60 0x0002, /* R32 - ADDITONAL_CONTROL_1 */
61}; 61};
62 62
63static bool wm8741_readable(struct device *dev, unsigned int reg)
64{
65 switch (reg) {
66 case WM8741_DACLLSB_ATTENUATION:
67 case WM8741_DACLMSB_ATTENUATION:
68 case WM8741_DACRLSB_ATTENUATION:
69 case WM8741_DACRMSB_ATTENUATION:
70 case WM8741_VOLUME_CONTROL:
71 case WM8741_FORMAT_CONTROL:
72 case WM8741_FILTER_CONTROL:
73 case WM8741_MODE_CONTROL_1:
74 case WM8741_MODE_CONTROL_2:
75 case WM8741_ADDITIONAL_CONTROL_1:
76 return true;
77 default:
78 return false;
79 }
80}
63 81
64static int wm8741_reset(struct snd_soc_codec *codec) 82static int wm8741_reset(struct snd_soc_codec *codec)
65{ 83{
@@ -403,17 +421,6 @@ static int wm8741_probe(struct snd_soc_codec *codec)
403{ 421{
404 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 422 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
405 int ret = 0; 423 int ret = 0;
406 int i;
407
408 for (i = 0; i < ARRAY_SIZE(wm8741->supplies); i++)
409 wm8741->supplies[i].supply = wm8741_supply_names[i];
410
411 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8741->supplies),
412 wm8741->supplies);
413 if (ret != 0) {
414 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
415 goto err;
416 }
417 424
418 ret = regulator_bulk_enable(ARRAY_SIZE(wm8741->supplies), 425 ret = regulator_bulk_enable(ARRAY_SIZE(wm8741->supplies),
419 wm8741->supplies); 426 wm8741->supplies);
@@ -422,7 +429,7 @@ static int wm8741_probe(struct snd_soc_codec *codec)
422 goto err_get; 429 goto err_get;
423 } 430 }
424 431
425 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8741->control_type); 432 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
426 if (ret != 0) { 433 if (ret != 0) {
427 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 434 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
428 goto err_enable; 435 goto err_enable;
@@ -450,8 +457,6 @@ static int wm8741_probe(struct snd_soc_codec *codec)
450err_enable: 457err_enable:
451 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); 458 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies);
452err_get: 459err_get:
453 regulator_bulk_free(ARRAY_SIZE(wm8741->supplies), wm8741->supplies);
454err:
455 return ret; 460 return ret;
456} 461}
457 462
@@ -460,7 +465,6 @@ static int wm8741_remove(struct snd_soc_codec *codec)
460 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 465 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
461 466
462 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); 467 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies);
463 regulator_bulk_free(ARRAY_SIZE(wm8741->supplies), wm8741->supplies);
464 468
465 return 0; 469 return 0;
466} 470}
@@ -469,9 +473,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8741 = {
469 .probe = wm8741_probe, 473 .probe = wm8741_probe,
470 .remove = wm8741_remove, 474 .remove = wm8741_remove,
471 .resume = wm8741_resume, 475 .resume = wm8741_resume,
472 .reg_cache_size = ARRAY_SIZE(wm8741_reg_defaults),
473 .reg_word_size = sizeof(u16),
474 .reg_cache_default = wm8741_reg_defaults,
475 476
476 .controls = wm8741_snd_controls, 477 .controls = wm8741_snd_controls,
477 .num_controls = ARRAY_SIZE(wm8741_snd_controls), 478 .num_controls = ARRAY_SIZE(wm8741_snd_controls),
@@ -487,20 +488,48 @@ static const struct of_device_id wm8741_of_match[] = {
487}; 488};
488MODULE_DEVICE_TABLE(of, wm8741_of_match); 489MODULE_DEVICE_TABLE(of, wm8741_of_match);
489 490
491static const struct regmap_config wm8741_regmap = {
492 .reg_bits = 7,
493 .val_bits = 9,
494 .max_register = WM8741_MAX_REGISTER,
495
496 .reg_defaults = wm8741_reg_defaults,
497 .num_reg_defaults = ARRAY_SIZE(wm8741_reg_defaults),
498 .cache_type = REGCACHE_RBTREE,
499
500 .readable_reg = wm8741_readable,
501};
502
490#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 503#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
491static int wm8741_i2c_probe(struct i2c_client *i2c, 504static int wm8741_i2c_probe(struct i2c_client *i2c,
492 const struct i2c_device_id *id) 505 const struct i2c_device_id *id)
493{ 506{
494 struct wm8741_priv *wm8741; 507 struct wm8741_priv *wm8741;
495 int ret; 508 int ret, i;
496 509
497 wm8741 = devm_kzalloc(&i2c->dev, sizeof(struct wm8741_priv), 510 wm8741 = devm_kzalloc(&i2c->dev, sizeof(struct wm8741_priv),
498 GFP_KERNEL); 511 GFP_KERNEL);
499 if (wm8741 == NULL) 512 if (wm8741 == NULL)
500 return -ENOMEM; 513 return -ENOMEM;
501 514
515 for (i = 0; i < ARRAY_SIZE(wm8741->supplies); i++)
516 wm8741->supplies[i].supply = wm8741_supply_names[i];
517
518 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8741->supplies),
519 wm8741->supplies);
520 if (ret != 0) {
521 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
522 return ret;
523 }
524
525 wm8741->regmap = regmap_init_i2c(i2c, &wm8741_regmap);
526 if (IS_ERR(wm8741->regmap)) {
527 ret = PTR_ERR(wm8741->regmap);
528 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret);
529 return ret;
530 }
531
502 i2c_set_clientdata(i2c, wm8741); 532 i2c_set_clientdata(i2c, wm8741);
503 wm8741->control_type = SND_SOC_I2C;
504 533
505 ret = snd_soc_register_codec(&i2c->dev, 534 ret = snd_soc_register_codec(&i2c->dev,
506 &soc_codec_dev_wm8741, &wm8741_dai, 1); 535 &soc_codec_dev_wm8741, &wm8741_dai, 1);
@@ -536,14 +565,30 @@ static struct i2c_driver wm8741_i2c_driver = {
536static int __devinit wm8741_spi_probe(struct spi_device *spi) 565static int __devinit wm8741_spi_probe(struct spi_device *spi)
537{ 566{
538 struct wm8741_priv *wm8741; 567 struct wm8741_priv *wm8741;
539 int ret; 568 int ret, i;
540 569
541 wm8741 = devm_kzalloc(&spi->dev, sizeof(struct wm8741_priv), 570 wm8741 = devm_kzalloc(&spi->dev, sizeof(struct wm8741_priv),
542 GFP_KERNEL); 571 GFP_KERNEL);
543 if (wm8741 == NULL) 572 if (wm8741 == NULL)
544 return -ENOMEM; 573 return -ENOMEM;
545 574
546 wm8741->control_type = SND_SOC_SPI; 575 for (i = 0; i < ARRAY_SIZE(wm8741->supplies); i++)
576 wm8741->supplies[i].supply = wm8741_supply_names[i];
577
578 ret = devm_regulator_bulk_get(&spi->dev, ARRAY_SIZE(wm8741->supplies),
579 wm8741->supplies);
580 if (ret != 0) {
581 dev_err(&spi->dev, "Failed to request supplies: %d\n", ret);
582 return ret;
583 }
584
585 wm8741->regmap = regmap_init_spi(spi, &wm8741_regmap);
586 if (IS_ERR(wm8741->regmap)) {
587 ret = PTR_ERR(wm8741->regmap);
588 dev_err(&spi->dev, "Failed to init regmap: %d\n", ret);
589 return ret;
590 }
591
547 spi_set_drvdata(spi, wm8741); 592 spi_set_drvdata(spi, wm8741);
548 593
549 ret = snd_soc_register_codec(&spi->dev, 594 ret = snd_soc_register_codec(&spi->dev,
diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c
index a5127b4ff9e1..c7c0034d3966 100644
--- a/sound/soc/codecs/wm8770.c
+++ b/sound/soc/codecs/wm8770.c
@@ -724,24 +724,7 @@ static struct spi_driver wm8770_spi_driver = {
724 .remove = __devexit_p(wm8770_spi_remove) 724 .remove = __devexit_p(wm8770_spi_remove)
725}; 725};
726 726
727static int __init wm8770_modinit(void) 727module_spi_driver(wm8770_spi_driver);
728{
729 int ret = 0;
730
731 ret = spi_register_driver(&wm8770_spi_driver);
732 if (ret) {
733 printk(KERN_ERR "Failed to register wm8770 SPI driver: %d\n",
734 ret);
735 }
736 return ret;
737}
738module_init(wm8770_modinit);
739
740static void __exit wm8770_exit(void)
741{
742 spi_unregister_driver(&wm8770_spi_driver);
743}
744module_exit(wm8770_exit);
745 728
746MODULE_DESCRIPTION("ASoC WM8770 driver"); 729MODULE_DESCRIPTION("ASoC WM8770 driver");
747MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>"); 730MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>");
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index 879c356a9045..c32249ddb2e0 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -19,6 +19,7 @@
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/of_device.h> 21#include <linux/of_device.h>
22#include <linux/regmap.h>
22#include <linux/spi/spi.h> 23#include <linux/spi/spi.h>
23#include <linux/slab.h> 24#include <linux/slab.h>
24#include <sound/core.h> 25#include <sound/core.h>
@@ -37,18 +38,46 @@ enum wm8776_chip_type {
37 38
38/* codec private data */ 39/* codec private data */
39struct wm8776_priv { 40struct wm8776_priv {
40 enum snd_soc_control_type control_type; 41 struct regmap *regmap;
41 int sysclk[2]; 42 int sysclk[2];
42}; 43};
43 44
44static const u16 wm8776_reg[WM8776_CACHEREGNUM] = { 45static const struct reg_default wm8776_reg_defaults[] = {
45 0x79, 0x79, 0x79, 0xff, 0xff, /* 4 */ 46 { 0, 0x79 },
46 0xff, 0x00, 0x90, 0x00, 0x00, /* 9 */ 47 { 1, 0x79 },
47 0x22, 0x22, 0x22, 0x08, 0xcf, /* 14 */ 48 { 2, 0x79 },
48 0xcf, 0x7b, 0x00, 0x32, 0x00, /* 19 */ 49 { 3, 0xff },
49 0xa6, 0x01, 0x01 50 { 4, 0xff },
51 { 5, 0xff },
52 { 6, 0x00 },
53 { 7, 0x90 },
54 { 8, 0x00 },
55 { 9, 0x00 },
56 { 10, 0x22 },
57 { 11, 0x22 },
58 { 12, 0x22 },
59 { 13, 0x08 },
60 { 14, 0xcf },
61 { 15, 0xcf },
62 { 16, 0x7b },
63 { 17, 0x00 },
64 { 18, 0x32 },
65 { 19, 0x00 },
66 { 20, 0xa6 },
67 { 21, 0x01 },
68 { 22, 0x01 },
50}; 69};
51 70
71static bool wm8776_volatile(struct device *dev, unsigned int reg)
72{
73 switch (reg) {
74 case WM8776_RESET:
75 return true;
76 default:
77 return false;
78 }
79}
80
52static int wm8776_reset(struct snd_soc_codec *codec) 81static int wm8776_reset(struct snd_soc_codec *codec)
53{ 82{
54 return snd_soc_write(codec, WM8776_RESET, 0); 83 return snd_soc_write(codec, WM8776_RESET, 0);
@@ -306,6 +335,8 @@ static int wm8776_set_sysclk(struct snd_soc_dai *dai,
306static int wm8776_set_bias_level(struct snd_soc_codec *codec, 335static int wm8776_set_bias_level(struct snd_soc_codec *codec,
307 enum snd_soc_bias_level level) 336 enum snd_soc_bias_level level)
308{ 337{
338 struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec);
339
309 switch (level) { 340 switch (level) {
310 case SND_SOC_BIAS_ON: 341 case SND_SOC_BIAS_ON:
311 break; 342 break;
@@ -313,7 +344,7 @@ static int wm8776_set_bias_level(struct snd_soc_codec *codec,
313 break; 344 break;
314 case SND_SOC_BIAS_STANDBY: 345 case SND_SOC_BIAS_STANDBY:
315 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 346 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
316 snd_soc_cache_sync(codec); 347 regcache_sync(wm8776->regmap);
317 348
318 /* Disable the global powerdown; DAPM does the rest */ 349 /* Disable the global powerdown; DAPM does the rest */
319 snd_soc_update_bits(codec, WM8776_PWRDOWN, 1, 0); 350 snd_soc_update_bits(codec, WM8776_PWRDOWN, 1, 0);
@@ -396,10 +427,9 @@ static int wm8776_resume(struct snd_soc_codec *codec)
396 427
397static int wm8776_probe(struct snd_soc_codec *codec) 428static int wm8776_probe(struct snd_soc_codec *codec)
398{ 429{
399 struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec);
400 int ret = 0; 430 int ret = 0;
401 431
402 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8776->control_type); 432 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
403 if (ret < 0) { 433 if (ret < 0) {
404 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 434 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
405 return ret; 435 return ret;
@@ -434,9 +464,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8776 = {
434 .suspend = wm8776_suspend, 464 .suspend = wm8776_suspend,
435 .resume = wm8776_resume, 465 .resume = wm8776_resume,
436 .set_bias_level = wm8776_set_bias_level, 466 .set_bias_level = wm8776_set_bias_level,
437 .reg_cache_size = ARRAY_SIZE(wm8776_reg),
438 .reg_word_size = sizeof(u16),
439 .reg_cache_default = wm8776_reg,
440 467
441 .controls = wm8776_snd_controls, 468 .controls = wm8776_snd_controls,
442 .num_controls = ARRAY_SIZE(wm8776_snd_controls), 469 .num_controls = ARRAY_SIZE(wm8776_snd_controls),
@@ -452,6 +479,18 @@ static const struct of_device_id wm8776_of_match[] = {
452}; 479};
453MODULE_DEVICE_TABLE(of, wm8776_of_match); 480MODULE_DEVICE_TABLE(of, wm8776_of_match);
454 481
482static const struct regmap_config wm8776_regmap = {
483 .reg_bits = 7,
484 .val_bits = 9,
485 .max_register = WM8776_RESET,
486
487 .reg_defaults = wm8776_reg_defaults,
488 .num_reg_defaults = ARRAY_SIZE(wm8776_reg_defaults),
489 .cache_type = REGCACHE_RBTREE,
490
491 .volatile_reg = wm8776_volatile,
492};
493
455#if defined(CONFIG_SPI_MASTER) 494#if defined(CONFIG_SPI_MASTER)
456static int __devinit wm8776_spi_probe(struct spi_device *spi) 495static int __devinit wm8776_spi_probe(struct spi_device *spi)
457{ 496{
@@ -463,7 +502,10 @@ static int __devinit wm8776_spi_probe(struct spi_device *spi)
463 if (wm8776 == NULL) 502 if (wm8776 == NULL)
464 return -ENOMEM; 503 return -ENOMEM;
465 504
466 wm8776->control_type = SND_SOC_SPI; 505 wm8776->regmap = devm_regmap_init_spi(spi, &wm8776_regmap);
506 if (IS_ERR(wm8776->regmap))
507 return PTR_ERR(wm8776->regmap);
508
467 spi_set_drvdata(spi, wm8776); 509 spi_set_drvdata(spi, wm8776);
468 510
469 ret = snd_soc_register_codec(&spi->dev, 511 ret = snd_soc_register_codec(&spi->dev,
@@ -501,8 +543,11 @@ static __devinit int wm8776_i2c_probe(struct i2c_client *i2c,
501 if (wm8776 == NULL) 543 if (wm8776 == NULL)
502 return -ENOMEM; 544 return -ENOMEM;
503 545
546 wm8776->regmap = devm_regmap_init_i2c(i2c, &wm8776_regmap);
547 if (IS_ERR(wm8776->regmap))
548 return PTR_ERR(wm8776->regmap);
549
504 i2c_set_clientdata(i2c, wm8776); 550 i2c_set_clientdata(i2c, wm8776);
505 wm8776->control_type = SND_SOC_I2C;
506 551
507 ret = snd_soc_register_codec(&i2c->dev, 552 ret = snd_soc_register_codec(&i2c->dev,
508 &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); 553 &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai));
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c
index 077c9628c70d..e781f865e5d7 100644
--- a/sound/soc/codecs/wm8900.c
+++ b/sound/soc/codecs/wm8900.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/pm.h> 24#include <linux/pm.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/regmap.h>
26#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <sound/core.h> 29#include <sound/core.h>
@@ -137,7 +138,7 @@
137#define WM8900_LRC_MASK 0x03ff 138#define WM8900_LRC_MASK 0x03ff
138 139
139struct wm8900_priv { 140struct wm8900_priv {
140 enum snd_soc_control_type control_type; 141 struct regmap *regmap;
141 142
142 u32 fll_in; /* FLL input frequency */ 143 u32 fll_in; /* FLL input frequency */
143 u32 fll_out; /* FLL output frequency */ 144 u32 fll_out; /* FLL output frequency */
@@ -147,54 +148,77 @@ struct wm8900_priv {
147 * wm8900 register cache. We can't read the entire register space and we 148 * wm8900 register cache. We can't read the entire register space and we
148 * have slow control buses so we cache the registers. 149 * have slow control buses so we cache the registers.
149 */ 150 */
150static const u16 wm8900_reg_defaults[WM8900_MAXREG] = { 151static const struct reg_default wm8900_reg_defaults[] = {
151 0x8900, 0x0000, 152 { 1, 0x0000 },
152 0xc000, 0x0000, 153 { 2, 0xc000 },
153 0x4050, 0x4000, 154 { 3, 0x0000 },
154 0x0008, 0x0000, 155 { 4, 0x4050 },
155 0x0040, 0x0040, 156 { 5, 0x4000 },
156 0x1004, 0x00c0, 157 { 6, 0x0008 },
157 0x00c0, 0x0000, 158 { 7, 0x0000 },
158 0x0100, 0x00c0, 159 { 8, 0x0040 },
159 0x00c0, 0x0000, 160 { 9, 0x0040 },
160 0xb001, 0x0000, 161 { 10, 0x1004 },
161 0x0000, 0x0044, 162 { 11, 0x00c0 },
162 0x004c, 0x004c, 163 { 12, 0x00c0 },
163 0x0044, 0x0044, 164 { 13, 0x0000 },
164 0x0000, 0x0044, 165 { 14, 0x0100 },
165 0x0000, 0x0000, 166 { 15, 0x00c0 },
166 0x0002, 0x0000, 167 { 16, 0x00c0 },
167 0x0000, 0x0000, 168 { 17, 0x0000 },
168 0x0000, 0x0000, 169 { 18, 0xb001 },
169 0x0008, 0x0000, 170 { 19, 0x0000 },
170 0x0000, 0x0008, 171 { 20, 0x0000 },
171 0x0097, 0x0100, 172 { 21, 0x0044 },
172 0x0000, 0x0000, 173 { 22, 0x004c },
173 0x0050, 0x0050, 174 { 23, 0x004c },
174 0x0055, 0x0055, 175 { 24, 0x0044 },
175 0x0055, 0x0000, 176 { 25, 0x0044 },
176 0x0000, 0x0079, 177 { 26, 0x0000 },
177 0x0079, 0x0079, 178 { 27, 0x0044 },
178 0x0079, 0x0000, 179 { 28, 0x0000 },
179 /* Remaining registers all zero */ 180 { 29, 0x0000 },
181 { 30, 0x0002 },
182 { 31, 0x0000 },
183 { 32, 0x0000 },
184 { 33, 0x0000 },
185 { 34, 0x0000 },
186 { 35, 0x0000 },
187 { 36, 0x0008 },
188 { 37, 0x0000 },
189 { 38, 0x0000 },
190 { 39, 0x0008 },
191 { 40, 0x0097 },
192 { 41, 0x0100 },
193 { 42, 0x0000 },
194 { 43, 0x0000 },
195 { 44, 0x0050 },
196 { 45, 0x0050 },
197 { 46, 0x0055 },
198 { 47, 0x0055 },
199 { 48, 0x0055 },
200 { 49, 0x0000 },
201 { 50, 0x0000 },
202 { 51, 0x0079 },
203 { 52, 0x0079 },
204 { 53, 0x0079 },
205 { 54, 0x0079 },
206 { 55, 0x0000 },
180}; 207};
181 208
182static int wm8900_volatile_register(struct snd_soc_codec *codec, unsigned int reg) 209static bool wm8900_volatile_register(struct device *dev, unsigned int reg)
183{ 210{
184 switch (reg) { 211 switch (reg) {
185 case WM8900_REG_ID: 212 case WM8900_REG_ID:
186 return 1; 213 return true;
187 default: 214 default:
188 return 0; 215 return false;
189 } 216 }
190} 217}
191 218
192static void wm8900_reset(struct snd_soc_codec *codec) 219static void wm8900_reset(struct snd_soc_codec *codec)
193{ 220{
194 snd_soc_write(codec, WM8900_REG_RESET, 0); 221 snd_soc_write(codec, WM8900_REG_RESET, 0);
195
196 memcpy(codec->reg_cache, wm8900_reg_defaults,
197 sizeof(wm8900_reg_defaults));
198} 222}
199 223
200static int wm8900_hp_event(struct snd_soc_dapm_widget *w, 224static int wm8900_hp_event(struct snd_soc_dapm_widget *w,
@@ -469,10 +493,10 @@ SOC_DAPM_SINGLE("RINPUT2 Switch", WM8900_REG_INCTL, 1, 1, 0),
469SOC_DAPM_SINGLE("RINPUT3 Switch", WM8900_REG_INCTL, 0, 1, 0), 493SOC_DAPM_SINGLE("RINPUT3 Switch", WM8900_REG_INCTL, 0, 1, 0),
470}; 494};
471 495
472static const char *wm9700_lp_mux[] = { "Disabled", "Enabled" }; 496static const char *wm8900_lp_mux[] = { "Disabled", "Enabled" };
473 497
474static const struct soc_enum wm8900_lineout2_lp_mux = 498static const struct soc_enum wm8900_lineout2_lp_mux =
475SOC_ENUM_SINGLE(WM8900_REG_LOUTMIXCTL1, 1, 2, wm9700_lp_mux); 499SOC_ENUM_SINGLE(WM8900_REG_LOUTMIXCTL1, 1, 2, wm8900_lp_mux);
476 500
477static const struct snd_kcontrol_new wm8900_lineout2_lp = 501static const struct snd_kcontrol_new wm8900_lineout2_lp =
478SOC_DAPM_ENUM("Route", wm8900_lineout2_lp_mux); 502SOC_DAPM_ENUM("Route", wm8900_lineout2_lp_mux);
@@ -1119,13 +1143,16 @@ static int wm8900_suspend(struct snd_soc_codec *codec)
1119static int wm8900_resume(struct snd_soc_codec *codec) 1143static int wm8900_resume(struct snd_soc_codec *codec)
1120{ 1144{
1121 struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); 1145 struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec);
1122 u16 *cache; 1146 int ret;
1123 int i, ret;
1124
1125 cache = kmemdup(codec->reg_cache, sizeof(wm8900_reg_defaults),
1126 GFP_KERNEL);
1127 1147
1128 wm8900_reset(codec); 1148 wm8900_reset(codec);
1149
1150 ret = regcache_sync(wm8900->regmap);
1151 if (ret != 0) {
1152 dev_err(codec->dev, "Failed to restore cache: %d\n", ret);
1153 return ret;
1154 }
1155
1129 wm8900_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1156 wm8900_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1130 1157
1131 /* Restart the FLL? */ 1158 /* Restart the FLL? */
@@ -1139,27 +1166,18 @@ static int wm8900_resume(struct snd_soc_codec *codec)
1139 ret = wm8900_set_fll(codec, 0, fll_in, fll_out); 1166 ret = wm8900_set_fll(codec, 0, fll_in, fll_out);
1140 if (ret != 0) { 1167 if (ret != 0) {
1141 dev_err(codec->dev, "Failed to restart FLL\n"); 1168 dev_err(codec->dev, "Failed to restart FLL\n");
1142 kfree(cache);
1143 return ret; 1169 return ret;
1144 } 1170 }
1145 } 1171 }
1146 1172
1147 if (cache) {
1148 for (i = 0; i < WM8900_MAXREG; i++)
1149 snd_soc_write(codec, i, cache[i]);
1150 kfree(cache);
1151 } else
1152 dev_err(codec->dev, "Unable to allocate register cache\n");
1153
1154 return 0; 1173 return 0;
1155} 1174}
1156 1175
1157static int wm8900_probe(struct snd_soc_codec *codec) 1176static int wm8900_probe(struct snd_soc_codec *codec)
1158{ 1177{
1159 struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec);
1160 int ret = 0, reg; 1178 int ret = 0, reg;
1161 1179
1162 ret = snd_soc_codec_set_cache_io(codec, 8, 16, wm8900->control_type); 1180 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
1163 if (ret != 0) { 1181 if (ret != 0) {
1164 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 1182 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
1165 return ret; 1183 return ret;
@@ -1207,10 +1225,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8900 = {
1207 .suspend = wm8900_suspend, 1225 .suspend = wm8900_suspend,
1208 .resume = wm8900_resume, 1226 .resume = wm8900_resume,
1209 .set_bias_level = wm8900_set_bias_level, 1227 .set_bias_level = wm8900_set_bias_level,
1210 .volatile_register = wm8900_volatile_register,
1211 .reg_cache_size = ARRAY_SIZE(wm8900_reg_defaults),
1212 .reg_word_size = sizeof(u16),
1213 .reg_cache_default = wm8900_reg_defaults,
1214 1228
1215 .controls = wm8900_snd_controls, 1229 .controls = wm8900_snd_controls,
1216 .num_controls = ARRAY_SIZE(wm8900_snd_controls), 1230 .num_controls = ARRAY_SIZE(wm8900_snd_controls),
@@ -1220,30 +1234,44 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8900 = {
1220 .num_dapm_routes = ARRAY_SIZE(wm8900_dapm_routes), 1234 .num_dapm_routes = ARRAY_SIZE(wm8900_dapm_routes),
1221}; 1235};
1222 1236
1237static const struct regmap_config wm8900_regmap = {
1238 .reg_bits = 8,
1239 .val_bits = 16,
1240 .max_register = WM8900_MAXREG,
1241
1242 .reg_defaults = wm8900_reg_defaults,
1243 .num_reg_defaults = ARRAY_SIZE(wm8900_reg_defaults),
1244 .cache_type = REGCACHE_RBTREE,
1245
1246 .volatile_reg = wm8900_volatile_register,
1247};
1248
1223#if defined(CONFIG_SPI_MASTER) 1249#if defined(CONFIG_SPI_MASTER)
1224static int __devinit wm8900_spi_probe(struct spi_device *spi) 1250static int __devinit wm8900_spi_probe(struct spi_device *spi)
1225{ 1251{
1226 struct wm8900_priv *wm8900; 1252 struct wm8900_priv *wm8900;
1227 int ret; 1253 int ret;
1228 1254
1229 wm8900 = kzalloc(sizeof(struct wm8900_priv), GFP_KERNEL); 1255 wm8900 = devm_kzalloc(&spi->dev, sizeof(struct wm8900_priv),
1256 GFP_KERNEL);
1230 if (wm8900 == NULL) 1257 if (wm8900 == NULL)
1231 return -ENOMEM; 1258 return -ENOMEM;
1232 1259
1233 wm8900->control_type = SND_SOC_SPI; 1260 wm8900->regmap = devm_regmap_init_spi(spi, &wm8900_regmap);
1261 if (IS_ERR(wm8900->regmap))
1262 return PTR_ERR(wm8900->regmap);
1263
1234 spi_set_drvdata(spi, wm8900); 1264 spi_set_drvdata(spi, wm8900);
1235 1265
1236 ret = snd_soc_register_codec(&spi->dev, 1266 ret = snd_soc_register_codec(&spi->dev,
1237 &soc_codec_dev_wm8900, &wm8900_dai, 1); 1267 &soc_codec_dev_wm8900, &wm8900_dai, 1);
1238 if (ret < 0) 1268
1239 kfree(wm8900);
1240 return ret; 1269 return ret;
1241} 1270}
1242 1271
1243static int __devexit wm8900_spi_remove(struct spi_device *spi) 1272static int __devexit wm8900_spi_remove(struct spi_device *spi)
1244{ 1273{
1245 snd_soc_unregister_codec(&spi->dev); 1274 snd_soc_unregister_codec(&spi->dev);
1246 kfree(spi_get_drvdata(spi));
1247 return 0; 1275 return 0;
1248} 1276}
1249 1277
@@ -1264,24 +1292,26 @@ static __devinit int wm8900_i2c_probe(struct i2c_client *i2c,
1264 struct wm8900_priv *wm8900; 1292 struct wm8900_priv *wm8900;
1265 int ret; 1293 int ret;
1266 1294
1267 wm8900 = kzalloc(sizeof(struct wm8900_priv), GFP_KERNEL); 1295 wm8900 = devm_kzalloc(&i2c->dev, sizeof(struct wm8900_priv),
1296 GFP_KERNEL);
1268 if (wm8900 == NULL) 1297 if (wm8900 == NULL)
1269 return -ENOMEM; 1298 return -ENOMEM;
1270 1299
1300 wm8900->regmap = devm_regmap_init_i2c(i2c, &wm8900_regmap);
1301 if (IS_ERR(wm8900->regmap))
1302 return PTR_ERR(wm8900->regmap);
1303
1271 i2c_set_clientdata(i2c, wm8900); 1304 i2c_set_clientdata(i2c, wm8900);
1272 wm8900->control_type = SND_SOC_I2C;
1273 1305
1274 ret = snd_soc_register_codec(&i2c->dev, 1306 ret = snd_soc_register_codec(&i2c->dev,
1275 &soc_codec_dev_wm8900, &wm8900_dai, 1); 1307 &soc_codec_dev_wm8900, &wm8900_dai, 1);
1276 if (ret < 0) 1308
1277 kfree(wm8900);
1278 return ret; 1309 return ret;
1279} 1310}
1280 1311
1281static __devexit int wm8900_i2c_remove(struct i2c_client *client) 1312static __devexit int wm8900_i2c_remove(struct i2c_client *client)
1282{ 1313{
1283 snd_soc_unregister_codec(&client->dev); 1314 snd_soc_unregister_codec(&client->dev);
1284 kfree(i2c_get_clientdata(client));
1285 return 0; 1315 return 0;
1286} 1316}
1287 1317
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index 73f1c8d7bafb..839414f9e2ed 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -2241,23 +2241,7 @@ static struct i2c_driver wm8903_i2c_driver = {
2241 .id_table = wm8903_i2c_id, 2241 .id_table = wm8903_i2c_id,
2242}; 2242};
2243 2243
2244static int __init wm8903_modinit(void) 2244module_i2c_driver(wm8903_i2c_driver);
2245{
2246 int ret = 0;
2247 ret = i2c_add_driver(&wm8903_i2c_driver);
2248 if (ret != 0) {
2249 printk(KERN_ERR "Failed to register wm8903 I2C driver: %d\n",
2250 ret);
2251 }
2252 return ret;
2253}
2254module_init(wm8903_modinit);
2255
2256static void __exit wm8903_exit(void)
2257{
2258 i2c_del_driver(&wm8903_i2c_driver);
2259}
2260module_exit(wm8903_exit);
2261 2245
2262MODULE_DESCRIPTION("ASoC WM8903 driver"); 2246MODULE_DESCRIPTION("ASoC WM8903 driver");
2263MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.cm>"); 2247MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.cm>");
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 0013afe48e66..7c8df52a8d9d 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -100,7 +100,7 @@ static const struct reg_default wm8904_reg_defaults[] = {
100 { 14, 0x0000 }, /* R14 - Power Management 2 */ 100 { 14, 0x0000 }, /* R14 - Power Management 2 */
101 { 15, 0x0000 }, /* R15 - Power Management 3 */ 101 { 15, 0x0000 }, /* R15 - Power Management 3 */
102 { 18, 0x0000 }, /* R18 - Power Management 6 */ 102 { 18, 0x0000 }, /* R18 - Power Management 6 */
103 { 19, 0x945E }, /* R20 - Clock Rates 0 */ 103 { 20, 0x945E }, /* R20 - Clock Rates 0 */
104 { 21, 0x0C05 }, /* R21 - Clock Rates 1 */ 104 { 21, 0x0C05 }, /* R21 - Clock Rates 1 */
105 { 22, 0x0006 }, /* R22 - Clock Rates 2 */ 105 { 22, 0x0006 }, /* R22 - Clock Rates 2 */
106 { 24, 0x0050 }, /* R24 - Audio Interface 0 */ 106 { 24, 0x0050 }, /* R24 - Audio Interface 0 */
@@ -1185,8 +1185,6 @@ static int wm8904_add_widgets(struct snd_soc_codec *codec)
1185 snd_soc_dapm_new_controls(dapm, wm8904_dapm_widgets, 1185 snd_soc_dapm_new_controls(dapm, wm8904_dapm_widgets,
1186 ARRAY_SIZE(wm8904_dapm_widgets)); 1186 ARRAY_SIZE(wm8904_dapm_widgets));
1187 1187
1188 snd_soc_dapm_add_routes(dapm, core_intercon,
1189 ARRAY_SIZE(core_intercon));
1190 snd_soc_dapm_add_routes(dapm, adc_intercon, 1188 snd_soc_dapm_add_routes(dapm, adc_intercon,
1191 ARRAY_SIZE(adc_intercon)); 1189 ARRAY_SIZE(adc_intercon));
1192 snd_soc_dapm_add_routes(dapm, dac_intercon, 1190 snd_soc_dapm_add_routes(dapm, dac_intercon,
diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c
index 481a3d9cfe48..b20aa4e7c3f9 100644
--- a/sound/soc/codecs/wm8940.c
+++ b/sound/soc/codecs/wm8940.c
@@ -785,23 +785,7 @@ static struct i2c_driver wm8940_i2c_driver = {
785 .id_table = wm8940_i2c_id, 785 .id_table = wm8940_i2c_id,
786}; 786};
787 787
788static int __init wm8940_modinit(void) 788module_i2c_driver(wm8940_i2c_driver);
789{
790 int ret = 0;
791 ret = i2c_add_driver(&wm8940_i2c_driver);
792 if (ret != 0) {
793 printk(KERN_ERR "Failed to register wm8940 I2C driver: %d\n",
794 ret);
795 }
796 return ret;
797}
798module_init(wm8940_modinit);
799
800static void __exit wm8940_exit(void)
801{
802 i2c_del_driver(&wm8940_i2c_driver);
803}
804module_exit(wm8940_exit);
805 789
806MODULE_DESCRIPTION("ASoC WM8940 driver"); 790MODULE_DESCRIPTION("ASoC WM8940 driver");
807MODULE_AUTHOR("Jonathan Cameron"); 791MODULE_AUTHOR("Jonathan Cameron");
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c
index 61fe97433e73..2f1c075755b1 100644
--- a/sound/soc/codecs/wm8955.c
+++ b/sound/soc/codecs/wm8955.c
@@ -1071,23 +1071,7 @@ static struct i2c_driver wm8955_i2c_driver = {
1071 .id_table = wm8955_i2c_id, 1071 .id_table = wm8955_i2c_id,
1072}; 1072};
1073 1073
1074static int __init wm8955_modinit(void) 1074module_i2c_driver(wm8955_i2c_driver);
1075{
1076 int ret = 0;
1077 ret = i2c_add_driver(&wm8955_i2c_driver);
1078 if (ret != 0) {
1079 printk(KERN_ERR "Failed to register WM8955 I2C driver: %d\n",
1080 ret);
1081 }
1082 return ret;
1083}
1084module_init(wm8955_modinit);
1085
1086static void __exit wm8955_exit(void)
1087{
1088 i2c_del_driver(&wm8955_i2c_driver);
1089}
1090module_exit(wm8955_exit);
1091 1075
1092MODULE_DESCRIPTION("ASoC WM8955 driver"); 1076MODULE_DESCRIPTION("ASoC WM8955 driver");
1093MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 1077MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
index 1332692ef81b..00121ba36597 100644
--- a/sound/soc/codecs/wm8958-dsp2.c
+++ b/sound/soc/codecs/wm8958-dsp2.c
@@ -946,7 +946,7 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
946 wm8994->mbc_texts = kmalloc(sizeof(char *) 946 wm8994->mbc_texts = kmalloc(sizeof(char *)
947 * pdata->num_mbc_cfgs, GFP_KERNEL); 947 * pdata->num_mbc_cfgs, GFP_KERNEL);
948 if (!wm8994->mbc_texts) { 948 if (!wm8994->mbc_texts) {
949 dev_err(wm8994->codec->dev, 949 dev_err(wm8994->hubs.codec->dev,
950 "Failed to allocate %d MBC config texts\n", 950 "Failed to allocate %d MBC config texts\n",
951 pdata->num_mbc_cfgs); 951 pdata->num_mbc_cfgs);
952 return; 952 return;
@@ -958,9 +958,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
958 wm8994->mbc_enum.max = pdata->num_mbc_cfgs; 958 wm8994->mbc_enum.max = pdata->num_mbc_cfgs;
959 wm8994->mbc_enum.texts = wm8994->mbc_texts; 959 wm8994->mbc_enum.texts = wm8994->mbc_texts;
960 960
961 ret = snd_soc_add_codec_controls(wm8994->codec, control, 1); 961 ret = snd_soc_add_codec_controls(wm8994->hubs.codec,
962 control, 1);
962 if (ret != 0) 963 if (ret != 0)
963 dev_err(wm8994->codec->dev, 964 dev_err(wm8994->hubs.codec->dev,
964 "Failed to add MBC mode controls: %d\n", ret); 965 "Failed to add MBC mode controls: %d\n", ret);
965 } 966 }
966 967
@@ -974,7 +975,7 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
974 wm8994->vss_texts = kmalloc(sizeof(char *) 975 wm8994->vss_texts = kmalloc(sizeof(char *)
975 * pdata->num_vss_cfgs, GFP_KERNEL); 976 * pdata->num_vss_cfgs, GFP_KERNEL);
976 if (!wm8994->vss_texts) { 977 if (!wm8994->vss_texts) {
977 dev_err(wm8994->codec->dev, 978 dev_err(wm8994->hubs.codec->dev,
978 "Failed to allocate %d VSS config texts\n", 979 "Failed to allocate %d VSS config texts\n",
979 pdata->num_vss_cfgs); 980 pdata->num_vss_cfgs);
980 return; 981 return;
@@ -986,9 +987,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
986 wm8994->vss_enum.max = pdata->num_vss_cfgs; 987 wm8994->vss_enum.max = pdata->num_vss_cfgs;
987 wm8994->vss_enum.texts = wm8994->vss_texts; 988 wm8994->vss_enum.texts = wm8994->vss_texts;
988 989
989 ret = snd_soc_add_codec_controls(wm8994->codec, control, 1); 990 ret = snd_soc_add_codec_controls(wm8994->hubs.codec,
991 control, 1);
990 if (ret != 0) 992 if (ret != 0)
991 dev_err(wm8994->codec->dev, 993 dev_err(wm8994->hubs.codec->dev,
992 "Failed to add VSS mode controls: %d\n", ret); 994 "Failed to add VSS mode controls: %d\n", ret);
993 } 995 }
994 996
@@ -1003,7 +1005,7 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
1003 wm8994->vss_hpf_texts = kmalloc(sizeof(char *) 1005 wm8994->vss_hpf_texts = kmalloc(sizeof(char *)
1004 * pdata->num_vss_hpf_cfgs, GFP_KERNEL); 1006 * pdata->num_vss_hpf_cfgs, GFP_KERNEL);
1005 if (!wm8994->vss_hpf_texts) { 1007 if (!wm8994->vss_hpf_texts) {
1006 dev_err(wm8994->codec->dev, 1008 dev_err(wm8994->hubs.codec->dev,
1007 "Failed to allocate %d VSS HPF config texts\n", 1009 "Failed to allocate %d VSS HPF config texts\n",
1008 pdata->num_vss_hpf_cfgs); 1010 pdata->num_vss_hpf_cfgs);
1009 return; 1011 return;
@@ -1015,9 +1017,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
1015 wm8994->vss_hpf_enum.max = pdata->num_vss_hpf_cfgs; 1017 wm8994->vss_hpf_enum.max = pdata->num_vss_hpf_cfgs;
1016 wm8994->vss_hpf_enum.texts = wm8994->vss_hpf_texts; 1018 wm8994->vss_hpf_enum.texts = wm8994->vss_hpf_texts;
1017 1019
1018 ret = snd_soc_add_codec_controls(wm8994->codec, control, 1); 1020 ret = snd_soc_add_codec_controls(wm8994->hubs.codec,
1021 control, 1);
1019 if (ret != 0) 1022 if (ret != 0)
1020 dev_err(wm8994->codec->dev, 1023 dev_err(wm8994->hubs.codec->dev,
1021 "Failed to add VSS HPFmode controls: %d\n", 1024 "Failed to add VSS HPFmode controls: %d\n",
1022 ret); 1025 ret);
1023 } 1026 }
@@ -1033,7 +1036,7 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
1033 wm8994->enh_eq_texts = kmalloc(sizeof(char *) 1036 wm8994->enh_eq_texts = kmalloc(sizeof(char *)
1034 * pdata->num_enh_eq_cfgs, GFP_KERNEL); 1037 * pdata->num_enh_eq_cfgs, GFP_KERNEL);
1035 if (!wm8994->enh_eq_texts) { 1038 if (!wm8994->enh_eq_texts) {
1036 dev_err(wm8994->codec->dev, 1039 dev_err(wm8994->hubs.codec->dev,
1037 "Failed to allocate %d enhanced EQ config texts\n", 1040 "Failed to allocate %d enhanced EQ config texts\n",
1038 pdata->num_enh_eq_cfgs); 1041 pdata->num_enh_eq_cfgs);
1039 return; 1042 return;
@@ -1045,9 +1048,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
1045 wm8994->enh_eq_enum.max = pdata->num_enh_eq_cfgs; 1048 wm8994->enh_eq_enum.max = pdata->num_enh_eq_cfgs;
1046 wm8994->enh_eq_enum.texts = wm8994->enh_eq_texts; 1049 wm8994->enh_eq_enum.texts = wm8994->enh_eq_texts;
1047 1050
1048 ret = snd_soc_add_codec_controls(wm8994->codec, control, 1); 1051 ret = snd_soc_add_codec_controls(wm8994->hubs.codec,
1052 control, 1);
1049 if (ret != 0) 1053 if (ret != 0)
1050 dev_err(wm8994->codec->dev, 1054 dev_err(wm8994->hubs.codec->dev,
1051 "Failed to add enhanced EQ controls: %d\n", 1055 "Failed to add enhanced EQ controls: %d\n",
1052 ret); 1056 ret);
1053 } 1057 }
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index 96518ac8e24c..f0f6f6601785 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -52,25 +52,72 @@
52 * We can't read the WM8960 register space when we are 52 * We can't read the WM8960 register space when we are
53 * using 2 wire for device control, so we cache them instead. 53 * using 2 wire for device control, so we cache them instead.
54 */ 54 */
55static const u16 wm8960_reg[WM8960_CACHEREGNUM] = { 55static const struct reg_default wm8960_reg_defaults[] = {
56 0x0097, 0x0097, 0x0000, 0x0000, 56 { 0x0, 0x0097 },
57 0x0000, 0x0008, 0x0000, 0x000a, 57 { 0x1, 0x0097 },
58 0x01c0, 0x0000, 0x00ff, 0x00ff, 58 { 0x2, 0x0000 },
59 0x0000, 0x0000, 0x0000, 0x0000, 59 { 0x3, 0x0000 },
60 0x0000, 0x007b, 0x0100, 0x0032, 60 { 0x4, 0x0000 },
61 0x0000, 0x00c3, 0x00c3, 0x01c0, 61 { 0x5, 0x0008 },
62 0x0000, 0x0000, 0x0000, 0x0000, 62 { 0x6, 0x0000 },
63 0x0000, 0x0000, 0x0000, 0x0000, 63 { 0x7, 0x000a },
64 0x0100, 0x0100, 0x0050, 0x0050, 64 { 0x8, 0x01c0 },
65 0x0050, 0x0050, 0x0000, 0x0000, 65 { 0x9, 0x0000 },
66 0x0000, 0x0000, 0x0040, 0x0000, 66 { 0xa, 0x00ff },
67 0x0000, 0x0050, 0x0050, 0x0000, 67 { 0xb, 0x00ff },
68 0x0002, 0x0037, 0x004d, 0x0080, 68
69 0x0008, 0x0031, 0x0026, 0x00e9, 69 { 0x10, 0x0000 },
70 { 0x11, 0x007b },
71 { 0x12, 0x0100 },
72 { 0x13, 0x0032 },
73 { 0x14, 0x0000 },
74 { 0x15, 0x00c3 },
75 { 0x16, 0x00c3 },
76 { 0x17, 0x01c0 },
77 { 0x18, 0x0000 },
78 { 0x19, 0x0000 },
79 { 0x1a, 0x0000 },
80 { 0x1b, 0x0000 },
81 { 0x1c, 0x0000 },
82 { 0x1d, 0x0000 },
83
84 { 0x20, 0x0100 },
85 { 0x21, 0x0100 },
86 { 0x22, 0x0050 },
87
88 { 0x25, 0x0050 },
89 { 0x26, 0x0000 },
90 { 0x27, 0x0000 },
91 { 0x28, 0x0000 },
92 { 0x29, 0x0000 },
93 { 0x2a, 0x0040 },
94 { 0x2b, 0x0000 },
95 { 0x2c, 0x0000 },
96 { 0x2d, 0x0050 },
97 { 0x2e, 0x0050 },
98 { 0x2f, 0x0000 },
99 { 0x30, 0x0002 },
100 { 0x31, 0x0037 },
101
102 { 0x33, 0x0080 },
103 { 0x34, 0x0008 },
104 { 0x35, 0x0031 },
105 { 0x36, 0x0026 },
106 { 0x37, 0x00e9 },
70}; 107};
71 108
109static bool wm8960_volatile(struct device *dev, unsigned int reg)
110{
111 switch (reg) {
112 case WM8960_RESET:
113 return true;
114 default:
115 return false;
116 }
117}
118
72struct wm8960_priv { 119struct wm8960_priv {
73 enum snd_soc_control_type control_type; 120 struct regmap *regmap;
74 int (*set_bias_level)(struct snd_soc_codec *, 121 int (*set_bias_level)(struct snd_soc_codec *,
75 enum snd_soc_bias_level level); 122 enum snd_soc_bias_level level);
76 struct snd_soc_dapm_widget *lout1; 123 struct snd_soc_dapm_widget *lout1;
@@ -510,18 +557,25 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,
510 struct snd_soc_codec *codec = dai->codec; 557 struct snd_soc_codec *codec = dai->codec;
511 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); 558 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
512 u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3; 559 u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3;
560 snd_pcm_format_t format = params_format(params);
513 int i; 561 int i;
514 562
515 /* bit size */ 563 /* bit size */
516 switch (params_format(params)) { 564 switch (format) {
517 case SNDRV_PCM_FORMAT_S16_LE: 565 case SNDRV_PCM_FORMAT_S16_LE:
566 case SNDRV_PCM_FORMAT_S16_BE:
518 break; 567 break;
519 case SNDRV_PCM_FORMAT_S20_3LE: 568 case SNDRV_PCM_FORMAT_S20_3LE:
569 case SNDRV_PCM_FORMAT_S20_3BE:
520 iface |= 0x0004; 570 iface |= 0x0004;
521 break; 571 break;
522 case SNDRV_PCM_FORMAT_S24_LE: 572 case SNDRV_PCM_FORMAT_S24_LE:
573 case SNDRV_PCM_FORMAT_S24_BE:
523 iface |= 0x0008; 574 iface |= 0x0008;
524 break; 575 break;
576 default:
577 dev_err(codec->dev, "unsupported format %i\n", format);
578 return -EINVAL;
525 } 579 }
526 580
527 /* Update filters for the new rate */ 581 /* Update filters for the new rate */
@@ -555,6 +609,8 @@ static int wm8960_mute(struct snd_soc_dai *dai, int mute)
555static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, 609static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
556 enum snd_soc_bias_level level) 610 enum snd_soc_bias_level level)
557{ 611{
612 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
613
558 switch (level) { 614 switch (level) {
559 case SND_SOC_BIAS_ON: 615 case SND_SOC_BIAS_ON:
560 break; 616 break;
@@ -566,7 +622,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
566 622
567 case SND_SOC_BIAS_STANDBY: 623 case SND_SOC_BIAS_STANDBY:
568 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 624 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
569 snd_soc_cache_sync(codec); 625 regcache_sync(wm8960->regmap);
570 626
571 /* Enable anti-pop features */ 627 /* Enable anti-pop features */
572 snd_soc_write(codec, WM8960_APOP1, 628 snd_soc_write(codec, WM8960_APOP1,
@@ -667,7 +723,7 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
667 break; 723 break;
668 724
669 case SND_SOC_BIAS_OFF: 725 case SND_SOC_BIAS_OFF:
670 snd_soc_cache_sync(codec); 726 regcache_sync(wm8960->regmap);
671 break; 727 break;
672 default: 728 default:
673 break; 729 break;
@@ -906,16 +962,11 @@ static int wm8960_probe(struct snd_soc_codec *codec)
906 if (!pdata) { 962 if (!pdata) {
907 dev_warn(codec->dev, "No platform data supplied\n"); 963 dev_warn(codec->dev, "No platform data supplied\n");
908 } else { 964 } else {
909 if (pdata->dres > WM8960_DRES_MAX) {
910 dev_err(codec->dev, "Invalid DRES: %d\n", pdata->dres);
911 pdata->dres = 0;
912 }
913
914 if (pdata->capless) 965 if (pdata->capless)
915 wm8960->set_bias_level = wm8960_set_bias_level_capless; 966 wm8960->set_bias_level = wm8960_set_bias_level_capless;
916 } 967 }
917 968
918 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8960->control_type); 969 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
919 if (ret < 0) { 970 if (ret < 0) {
920 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 971 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
921 return ret; 972 return ret;
@@ -963,14 +1014,24 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8960 = {
963 .suspend = wm8960_suspend, 1014 .suspend = wm8960_suspend,
964 .resume = wm8960_resume, 1015 .resume = wm8960_resume,
965 .set_bias_level = wm8960_set_bias_level, 1016 .set_bias_level = wm8960_set_bias_level,
966 .reg_cache_size = ARRAY_SIZE(wm8960_reg), 1017};
967 .reg_word_size = sizeof(u16), 1018
968 .reg_cache_default = wm8960_reg, 1019static const struct regmap_config wm8960_regmap = {
1020 .reg_bits = 7,
1021 .val_bits = 9,
1022 .max_register = WM8960_PLL4,
1023
1024 .reg_defaults = wm8960_reg_defaults,
1025 .num_reg_defaults = ARRAY_SIZE(wm8960_reg_defaults),
1026 .cache_type = REGCACHE_RBTREE,
1027
1028 .volatile_reg = wm8960_volatile,
969}; 1029};
970 1030
971static __devinit int wm8960_i2c_probe(struct i2c_client *i2c, 1031static __devinit int wm8960_i2c_probe(struct i2c_client *i2c,
972 const struct i2c_device_id *id) 1032 const struct i2c_device_id *id)
973{ 1033{
1034 struct wm8960_data *pdata = dev_get_platdata(&i2c->dev);
974 struct wm8960_priv *wm8960; 1035 struct wm8960_priv *wm8960;
975 int ret; 1036 int ret;
976 1037
@@ -979,8 +1040,21 @@ static __devinit int wm8960_i2c_probe(struct i2c_client *i2c,
979 if (wm8960 == NULL) 1040 if (wm8960 == NULL)
980 return -ENOMEM; 1041 return -ENOMEM;
981 1042
1043 wm8960->regmap = regmap_init_i2c(i2c, &wm8960_regmap);
1044 if (IS_ERR(wm8960->regmap))
1045 return PTR_ERR(wm8960->regmap);
1046
1047 if (pdata && pdata->shared_lrclk) {
1048 ret = regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2,
1049 0x4, 0x4);
1050 if (ret != 0) {
1051 dev_err(&i2c->dev, "Failed to enable LRCM: %d\n",
1052 ret);
1053 return ret;
1054 }
1055 }
1056
982 i2c_set_clientdata(i2c, wm8960); 1057 i2c_set_clientdata(i2c, wm8960);
983 wm8960->control_type = SND_SOC_I2C;
984 1058
985 ret = snd_soc_register_codec(&i2c->dev, 1059 ret = snd_soc_register_codec(&i2c->dev,
986 &soc_codec_dev_wm8960, &wm8960_dai, 1); 1060 &soc_codec_dev_wm8960, &wm8960_dai, 1);
@@ -1010,23 +1084,7 @@ static struct i2c_driver wm8960_i2c_driver = {
1010 .id_table = wm8960_i2c_id, 1084 .id_table = wm8960_i2c_id,
1011}; 1085};
1012 1086
1013static int __init wm8960_modinit(void) 1087module_i2c_driver(wm8960_i2c_driver);
1014{
1015 int ret = 0;
1016 ret = i2c_add_driver(&wm8960_i2c_driver);
1017 if (ret != 0) {
1018 printk(KERN_ERR "Failed to register WM8960 I2C driver: %d\n",
1019 ret);
1020 }
1021 return ret;
1022}
1023module_init(wm8960_modinit);
1024
1025static void __exit wm8960_exit(void)
1026{
1027 i2c_del_driver(&wm8960_i2c_driver);
1028}
1029module_exit(wm8960_exit);
1030 1088
1031MODULE_DESCRIPTION("ASoC WM8960 driver"); 1089MODULE_DESCRIPTION("ASoC WM8960 driver");
1032MODULE_AUTHOR("Liam Girdwood"); 1090MODULE_AUTHOR("Liam Girdwood");
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c
index 01edbcc754d2..f387670d0d75 100644
--- a/sound/soc/codecs/wm8961.c
+++ b/sound/soc/codecs/wm8961.c
@@ -19,6 +19,7 @@
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/regmap.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/pcm.h> 25#include <sound/pcm.h>
@@ -31,283 +32,159 @@
31 32
32#define WM8961_MAX_REGISTER 0xFC 33#define WM8961_MAX_REGISTER 0xFC
33 34
34static u16 wm8961_reg_defaults[] = { 35static const struct reg_default wm8961_reg_defaults[] = {
35 0x009F, /* R0 - Left Input volume */ 36 { 0, 0x009F }, /* R0 - Left Input volume */
36 0x009F, /* R1 - Right Input volume */ 37 { 1, 0x009F }, /* R1 - Right Input volume */
37 0x0000, /* R2 - LOUT1 volume */ 38 { 2, 0x0000 }, /* R2 - LOUT1 volume */
38 0x0000, /* R3 - ROUT1 volume */ 39 { 3, 0x0000 }, /* R3 - ROUT1 volume */
39 0x0020, /* R4 - Clocking1 */ 40 { 4, 0x0020 }, /* R4 - Clocking1 */
40 0x0008, /* R5 - ADC & DAC Control 1 */ 41 { 5, 0x0008 }, /* R5 - ADC & DAC Control 1 */
41 0x0000, /* R6 - ADC & DAC Control 2 */ 42 { 6, 0x0000 }, /* R6 - ADC & DAC Control 2 */
42 0x000A, /* R7 - Audio Interface 0 */ 43 { 7, 0x000A }, /* R7 - Audio Interface 0 */
43 0x01F4, /* R8 - Clocking2 */ 44 { 8, 0x01F4 }, /* R8 - Clocking2 */
44 0x0000, /* R9 - Audio Interface 1 */ 45 { 9, 0x0000 }, /* R9 - Audio Interface 1 */
45 0x00FF, /* R10 - Left DAC volume */ 46 { 10, 0x00FF }, /* R10 - Left DAC volume */
46 0x00FF, /* R11 - Right DAC volume */ 47 { 11, 0x00FF }, /* R11 - Right DAC volume */
47 0x0000, /* R12 */ 48
48 0x0000, /* R13 */ 49 { 14, 0x0040 }, /* R14 - Audio Interface 2 */
49 0x0040, /* R14 - Audio Interface 2 */ 50
50 0x0000, /* R15 - Software Reset */ 51 { 17, 0x007B }, /* R17 - ALC1 */
51 0x0000, /* R16 */ 52 { 18, 0x0000 }, /* R18 - ALC2 */
52 0x007B, /* R17 - ALC1 */ 53 { 19, 0x0032 }, /* R19 - ALC3 */
53 0x0000, /* R18 - ALC2 */ 54 { 20, 0x0000 }, /* R20 - Noise Gate */
54 0x0032, /* R19 - ALC3 */ 55 { 21, 0x00C0 }, /* R21 - Left ADC volume */
55 0x0000, /* R20 - Noise Gate */ 56 { 22, 0x00C0 }, /* R22 - Right ADC volume */
56 0x00C0, /* R21 - Left ADC volume */ 57 { 23, 0x0120 }, /* R23 - Additional control(1) */
57 0x00C0, /* R22 - Right ADC volume */ 58 { 24, 0x0000 }, /* R24 - Additional control(2) */
58 0x0120, /* R23 - Additional control(1) */ 59 { 25, 0x0000 }, /* R25 - Pwr Mgmt (1) */
59 0x0000, /* R24 - Additional control(2) */ 60 { 26, 0x0000 }, /* R26 - Pwr Mgmt (2) */
60 0x0000, /* R25 - Pwr Mgmt (1) */ 61 { 27, 0x0000 }, /* R27 - Additional Control (3) */
61 0x0000, /* R26 - Pwr Mgmt (2) */ 62 { 28, 0x0000 }, /* R28 - Anti-pop */
62 0x0000, /* R27 - Additional Control (3) */ 63
63 0x0000, /* R28 - Anti-pop */ 64 { 30, 0x005F }, /* R30 - Clocking 3 */
64 0x0000, /* R29 */ 65
65 0x005F, /* R30 - Clocking 3 */ 66 { 32, 0x0000 }, /* R32 - ADCL signal path */
66 0x0000, /* R31 */ 67 { 33, 0x0000 }, /* R33 - ADCR signal path */
67 0x0000, /* R32 - ADCL signal path */ 68
68 0x0000, /* R33 - ADCR signal path */ 69 { 40, 0x0000 }, /* R40 - LOUT2 volume */
69 0x0000, /* R34 */ 70 { 41, 0x0000 }, /* R41 - ROUT2 volume */
70 0x0000, /* R35 */ 71
71 0x0000, /* R36 */ 72 { 47, 0x0000 }, /* R47 - Pwr Mgmt (3) */
72 0x0000, /* R37 */ 73 { 48, 0x0023 }, /* R48 - Additional Control (4) */
73 0x0000, /* R38 */ 74 { 49, 0x0000 }, /* R49 - Class D Control 1 */
74 0x0000, /* R39 */ 75
75 0x0000, /* R40 - LOUT2 volume */ 76 { 51, 0x0003 }, /* R51 - Class D Control 2 */
76 0x0000, /* R41 - ROUT2 volume */ 77
77 0x0000, /* R42 */ 78 { 56, 0x0106 }, /* R56 - Clocking 4 */
78 0x0000, /* R43 */ 79 { 57, 0x0000 }, /* R57 - DSP Sidetone 0 */
79 0x0000, /* R44 */ 80 { 58, 0x0000 }, /* R58 - DSP Sidetone 1 */
80 0x0000, /* R45 */ 81
81 0x0000, /* R46 */ 82 { 60, 0x0000 }, /* R60 - DC Servo 0 */
82 0x0000, /* R47 - Pwr Mgmt (3) */ 83 { 61, 0x0000 }, /* R61 - DC Servo 1 */
83 0x0023, /* R48 - Additional Control (4) */ 84
84 0x0000, /* R49 - Class D Control 1 */ 85 { 63, 0x015E }, /* R63 - DC Servo 3 */
85 0x0000, /* R50 */ 86
86 0x0003, /* R51 - Class D Control 2 */ 87 { 65, 0x0010 }, /* R65 - DC Servo 5 */
87 0x0000, /* R52 */ 88
88 0x0000, /* R53 */ 89 { 68, 0x0003 }, /* R68 - Analogue PGA Bias */
89 0x0000, /* R54 */ 90 { 69, 0x0000 }, /* R69 - Analogue HP 0 */
90 0x0000, /* R55 */ 91
91 0x0106, /* R56 - Clocking 4 */ 92 { 71, 0x01FB }, /* R71 - Analogue HP 2 */
92 0x0000, /* R57 - DSP Sidetone 0 */ 93 { 72, 0x0000 }, /* R72 - Charge Pump 1 */
93 0x0000, /* R58 - DSP Sidetone 1 */ 94
94 0x0000, /* R59 */ 95 { 82, 0x0000 }, /* R82 - Charge Pump B */
95 0x0000, /* R60 - DC Servo 0 */ 96
96 0x0000, /* R61 - DC Servo 1 */ 97 { 87, 0x0000 }, /* R87 - Write Sequencer 1 */
97 0x0000, /* R62 */ 98 { 88, 0x0000 }, /* R88 - Write Sequencer 2 */
98 0x015E, /* R63 - DC Servo 3 */ 99 { 89, 0x0000 }, /* R89 - Write Sequencer 3 */
99 0x0010, /* R64 */ 100 { 90, 0x0000 }, /* R90 - Write Sequencer 4 */
100 0x0010, /* R65 - DC Servo 5 */ 101 { 91, 0x0000 }, /* R91 - Write Sequencer 5 */
101 0x0000, /* R66 */ 102 { 92, 0x0000 }, /* R92 - Write Sequencer 6 */
102 0x0001, /* R67 */ 103 { 93, 0x0000 }, /* R93 - Write Sequencer 7 */
103 0x0003, /* R68 - Analogue PGA Bias */ 104
104 0x0000, /* R69 - Analogue HP 0 */ 105 { 252, 0x0001 }, /* R252 - General test 1 */
105 0x0060, /* R70 */
106 0x01FB, /* R71 - Analogue HP 2 */
107 0x0000, /* R72 - Charge Pump 1 */
108 0x0065, /* R73 */
109 0x005F, /* R74 */
110 0x0059, /* R75 */
111 0x006B, /* R76 */
112 0x0038, /* R77 */
113 0x000C, /* R78 */
114 0x000A, /* R79 */
115 0x006B, /* R80 */
116 0x0000, /* R81 */
117 0x0000, /* R82 - Charge Pump B */
118 0x0087, /* R83 */
119 0x0000, /* R84 */
120 0x005C, /* R85 */
121 0x0000, /* R86 */
122 0x0000, /* R87 - Write Sequencer 1 */
123 0x0000, /* R88 - Write Sequencer 2 */
124 0x0000, /* R89 - Write Sequencer 3 */
125 0x0000, /* R90 - Write Sequencer 4 */
126 0x0000, /* R91 - Write Sequencer 5 */
127 0x0000, /* R92 - Write Sequencer 6 */
128 0x0000, /* R93 - Write Sequencer 7 */
129 0x0000, /* R94 */
130 0x0000, /* R95 */
131 0x0000, /* R96 */
132 0x0000, /* R97 */
133 0x0000, /* R98 */
134 0x0000, /* R99 */
135 0x0000, /* R100 */
136 0x0000, /* R101 */
137 0x0000, /* R102 */
138 0x0000, /* R103 */
139 0x0000, /* R104 */
140 0x0000, /* R105 */
141 0x0000, /* R106 */
142 0x0000, /* R107 */
143 0x0000, /* R108 */
144 0x0000, /* R109 */
145 0x0000, /* R110 */
146 0x0000, /* R111 */
147 0x0000, /* R112 */
148 0x0000, /* R113 */
149 0x0000, /* R114 */
150 0x0000, /* R115 */
151 0x0000, /* R116 */
152 0x0000, /* R117 */
153 0x0000, /* R118 */
154 0x0000, /* R119 */
155 0x0000, /* R120 */
156 0x0000, /* R121 */
157 0x0000, /* R122 */
158 0x0000, /* R123 */
159 0x0000, /* R124 */
160 0x0000, /* R125 */
161 0x0000, /* R126 */
162 0x0000, /* R127 */
163 0x0000, /* R128 */
164 0x0000, /* R129 */
165 0x0000, /* R130 */
166 0x0000, /* R131 */
167 0x0000, /* R132 */
168 0x0000, /* R133 */
169 0x0000, /* R134 */
170 0x0000, /* R135 */
171 0x0000, /* R136 */
172 0x0000, /* R137 */
173 0x0000, /* R138 */
174 0x0000, /* R139 */
175 0x0000, /* R140 */
176 0x0000, /* R141 */
177 0x0000, /* R142 */
178 0x0000, /* R143 */
179 0x0000, /* R144 */
180 0x0000, /* R145 */
181 0x0000, /* R146 */
182 0x0000, /* R147 */
183 0x0000, /* R148 */
184 0x0000, /* R149 */
185 0x0000, /* R150 */
186 0x0000, /* R151 */
187 0x0000, /* R152 */
188 0x0000, /* R153 */
189 0x0000, /* R154 */
190 0x0000, /* R155 */
191 0x0000, /* R156 */
192 0x0000, /* R157 */
193 0x0000, /* R158 */
194 0x0000, /* R159 */
195 0x0000, /* R160 */
196 0x0000, /* R161 */
197 0x0000, /* R162 */
198 0x0000, /* R163 */
199 0x0000, /* R164 */
200 0x0000, /* R165 */
201 0x0000, /* R166 */
202 0x0000, /* R167 */
203 0x0000, /* R168 */
204 0x0000, /* R169 */
205 0x0000, /* R170 */
206 0x0000, /* R171 */
207 0x0000, /* R172 */
208 0x0000, /* R173 */
209 0x0000, /* R174 */
210 0x0000, /* R175 */
211 0x0000, /* R176 */
212 0x0000, /* R177 */
213 0x0000, /* R178 */
214 0x0000, /* R179 */
215 0x0000, /* R180 */
216 0x0000, /* R181 */
217 0x0000, /* R182 */
218 0x0000, /* R183 */
219 0x0000, /* R184 */
220 0x0000, /* R185 */
221 0x0000, /* R186 */
222 0x0000, /* R187 */
223 0x0000, /* R188 */
224 0x0000, /* R189 */
225 0x0000, /* R190 */
226 0x0000, /* R191 */
227 0x0000, /* R192 */
228 0x0000, /* R193 */
229 0x0000, /* R194 */
230 0x0000, /* R195 */
231 0x0030, /* R196 */
232 0x0006, /* R197 */
233 0x0000, /* R198 */
234 0x0060, /* R199 */
235 0x0000, /* R200 */
236 0x003F, /* R201 */
237 0x0000, /* R202 */
238 0x0000, /* R203 */
239 0x0000, /* R204 */
240 0x0001, /* R205 */
241 0x0000, /* R206 */
242 0x0181, /* R207 */
243 0x0005, /* R208 */
244 0x0008, /* R209 */
245 0x0008, /* R210 */
246 0x0000, /* R211 */
247 0x013B, /* R212 */
248 0x0000, /* R213 */
249 0x0000, /* R214 */
250 0x0000, /* R215 */
251 0x0000, /* R216 */
252 0x0070, /* R217 */
253 0x0000, /* R218 */
254 0x0000, /* R219 */
255 0x0000, /* R220 */
256 0x0000, /* R221 */
257 0x0000, /* R222 */
258 0x0003, /* R223 */
259 0x0000, /* R224 */
260 0x0000, /* R225 */
261 0x0001, /* R226 */
262 0x0008, /* R227 */
263 0x0000, /* R228 */
264 0x0000, /* R229 */
265 0x0000, /* R230 */
266 0x0000, /* R231 */
267 0x0004, /* R232 */
268 0x0000, /* R233 */
269 0x0000, /* R234 */
270 0x0000, /* R235 */
271 0x0000, /* R236 */
272 0x0000, /* R237 */
273 0x0080, /* R238 */
274 0x0000, /* R239 */
275 0x0000, /* R240 */
276 0x0000, /* R241 */
277 0x0000, /* R242 */
278 0x0000, /* R243 */
279 0x0000, /* R244 */
280 0x0052, /* R245 */
281 0x0110, /* R246 */
282 0x0040, /* R247 */
283 0x0000, /* R248 */
284 0x0030, /* R249 */
285 0x0000, /* R250 */
286 0x0000, /* R251 */
287 0x0001, /* R252 - General test 1 */
288}; 106};
289 107
290struct wm8961_priv { 108struct wm8961_priv {
291 enum snd_soc_control_type control_type; 109 struct regmap *regmap;
292 int sysclk; 110 int sysclk;
293}; 111};
294 112
295static int wm8961_volatile_register(struct snd_soc_codec *codec, unsigned int reg) 113static bool wm8961_volatile(struct device *dev, unsigned int reg)
296{ 114{
297 switch (reg) { 115 switch (reg) {
298 case WM8961_SOFTWARE_RESET: 116 case WM8961_SOFTWARE_RESET:
299 case WM8961_WRITE_SEQUENCER_7: 117 case WM8961_WRITE_SEQUENCER_7:
300 case WM8961_DC_SERVO_1: 118 case WM8961_DC_SERVO_1:
301 return 1; 119 return true;
302 120
303 default: 121 default:
304 return 0; 122 return false;
305 } 123 }
306} 124}
307 125
308static int wm8961_reset(struct snd_soc_codec *codec) 126static bool wm8961_readable(struct device *dev, unsigned int reg)
309{ 127{
310 return snd_soc_write(codec, WM8961_SOFTWARE_RESET, 0); 128 switch (reg) {
129 case WM8961_LEFT_INPUT_VOLUME:
130 case WM8961_RIGHT_INPUT_VOLUME:
131 case WM8961_LOUT1_VOLUME:
132 case WM8961_ROUT1_VOLUME:
133 case WM8961_CLOCKING1:
134 case WM8961_ADC_DAC_CONTROL_1:
135 case WM8961_ADC_DAC_CONTROL_2:
136 case WM8961_AUDIO_INTERFACE_0:
137 case WM8961_CLOCKING2:
138 case WM8961_AUDIO_INTERFACE_1:
139 case WM8961_LEFT_DAC_VOLUME:
140 case WM8961_RIGHT_DAC_VOLUME:
141 case WM8961_AUDIO_INTERFACE_2:
142 case WM8961_SOFTWARE_RESET:
143 case WM8961_ALC1:
144 case WM8961_ALC2:
145 case WM8961_ALC3:
146 case WM8961_NOISE_GATE:
147 case WM8961_LEFT_ADC_VOLUME:
148 case WM8961_RIGHT_ADC_VOLUME:
149 case WM8961_ADDITIONAL_CONTROL_1:
150 case WM8961_ADDITIONAL_CONTROL_2:
151 case WM8961_PWR_MGMT_1:
152 case WM8961_PWR_MGMT_2:
153 case WM8961_ADDITIONAL_CONTROL_3:
154 case WM8961_ANTI_POP:
155 case WM8961_CLOCKING_3:
156 case WM8961_ADCL_SIGNAL_PATH:
157 case WM8961_ADCR_SIGNAL_PATH:
158 case WM8961_LOUT2_VOLUME:
159 case WM8961_ROUT2_VOLUME:
160 case WM8961_PWR_MGMT_3:
161 case WM8961_ADDITIONAL_CONTROL_4:
162 case WM8961_CLASS_D_CONTROL_1:
163 case WM8961_CLASS_D_CONTROL_2:
164 case WM8961_CLOCKING_4:
165 case WM8961_DSP_SIDETONE_0:
166 case WM8961_DSP_SIDETONE_1:
167 case WM8961_DC_SERVO_0:
168 case WM8961_DC_SERVO_1:
169 case WM8961_DC_SERVO_3:
170 case WM8961_DC_SERVO_5:
171 case WM8961_ANALOGUE_PGA_BIAS:
172 case WM8961_ANALOGUE_HP_0:
173 case WM8961_ANALOGUE_HP_2:
174 case WM8961_CHARGE_PUMP_1:
175 case WM8961_CHARGE_PUMP_B:
176 case WM8961_WRITE_SEQUENCER_1:
177 case WM8961_WRITE_SEQUENCER_2:
178 case WM8961_WRITE_SEQUENCER_3:
179 case WM8961_WRITE_SEQUENCER_4:
180 case WM8961_WRITE_SEQUENCER_5:
181 case WM8961_WRITE_SEQUENCER_6:
182 case WM8961_WRITE_SEQUENCER_7:
183 case WM8961_GENERAL_TEST_1:
184 return true;
185 default:
186 return false;
187 }
311} 188}
312 189
313/* 190/*
@@ -962,33 +839,12 @@ static int wm8961_probe(struct snd_soc_codec *codec)
962 int ret = 0; 839 int ret = 0;
963 u16 reg; 840 u16 reg;
964 841
965 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); 842 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
966 if (ret != 0) { 843 if (ret != 0) {
967 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 844 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
968 return ret; 845 return ret;
969 } 846 }
970 847
971 reg = snd_soc_read(codec, WM8961_SOFTWARE_RESET);
972 if (reg != 0x1801) {
973 dev_err(codec->dev, "Device is not a WM8961: ID=0x%x\n", reg);
974 return -EINVAL;
975 }
976
977 /* This isn't volatile - readback doesn't correspond to write */
978 codec->cache_bypass = 1;
979 reg = snd_soc_read(codec, WM8961_RIGHT_INPUT_VOLUME);
980 codec->cache_bypass = 0;
981 dev_info(codec->dev, "WM8961 family %d revision %c\n",
982 (reg & WM8961_DEVICE_ID_MASK) >> WM8961_DEVICE_ID_SHIFT,
983 ((reg & WM8961_CHIP_REV_MASK) >> WM8961_CHIP_REV_SHIFT)
984 + 'A');
985
986 ret = wm8961_reset(codec);
987 if (ret < 0) {
988 dev_err(codec->dev, "Failed to issue reset\n");
989 return ret;
990 }
991
992 /* Enable class W */ 848 /* Enable class W */
993 reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_B); 849 reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_B);
994 reg |= WM8961_CP_DYN_PWR_MASK; 850 reg |= WM8961_CP_DYN_PWR_MASK;
@@ -1066,16 +922,26 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8961 = {
1066 .suspend = wm8961_suspend, 922 .suspend = wm8961_suspend,
1067 .resume = wm8961_resume, 923 .resume = wm8961_resume,
1068 .set_bias_level = wm8961_set_bias_level, 924 .set_bias_level = wm8961_set_bias_level,
1069 .reg_cache_size = ARRAY_SIZE(wm8961_reg_defaults), 925};
1070 .reg_word_size = sizeof(u16), 926
1071 .reg_cache_default = wm8961_reg_defaults, 927static const struct regmap_config wm8961_regmap = {
1072 .volatile_register = wm8961_volatile_register, 928 .reg_bits = 8,
929 .val_bits = 16,
930 .max_register = WM8961_MAX_REGISTER,
931
932 .reg_defaults = wm8961_reg_defaults,
933 .num_reg_defaults = ARRAY_SIZE(wm8961_reg_defaults),
934 .cache_type = REGCACHE_RBTREE,
935
936 .volatile_reg = wm8961_volatile,
937 .readable_reg = wm8961_readable,
1073}; 938};
1074 939
1075static __devinit int wm8961_i2c_probe(struct i2c_client *i2c, 940static __devinit int wm8961_i2c_probe(struct i2c_client *i2c,
1076 const struct i2c_device_id *id) 941 const struct i2c_device_id *id)
1077{ 942{
1078 struct wm8961_priv *wm8961; 943 struct wm8961_priv *wm8961;
944 unsigned int val;
1079 int ret; 945 int ret;
1080 946
1081 wm8961 = devm_kzalloc(&i2c->dev, sizeof(struct wm8961_priv), 947 wm8961 = devm_kzalloc(&i2c->dev, sizeof(struct wm8961_priv),
@@ -1083,6 +949,42 @@ static __devinit int wm8961_i2c_probe(struct i2c_client *i2c,
1083 if (wm8961 == NULL) 949 if (wm8961 == NULL)
1084 return -ENOMEM; 950 return -ENOMEM;
1085 951
952 wm8961->regmap = devm_regmap_init_i2c(i2c, &wm8961_regmap);
953 if (IS_ERR(wm8961->regmap))
954 return PTR_ERR(wm8961->regmap);
955
956 ret = regmap_read(wm8961->regmap, WM8961_SOFTWARE_RESET, &val);
957 if (ret != 0) {
958 dev_err(&i2c->dev, "Failed to read chip ID: %d\n", ret);
959 return ret;
960 }
961
962 if (val != 0x1801) {
963 dev_err(&i2c->dev, "Device is not a WM8961: ID=0x%x\n", val);
964 return -EINVAL;
965 }
966
967 /* This isn't volatile - readback doesn't correspond to write */
968 regcache_cache_bypass(wm8961->regmap, true);
969 ret = regmap_read(wm8961->regmap, WM8961_RIGHT_INPUT_VOLUME, &val);
970 regcache_cache_bypass(wm8961->regmap, false);
971
972 if (ret != 0) {
973 dev_err(&i2c->dev, "Failed to read chip revision: %d\n", ret);
974 return ret;
975 }
976
977 dev_info(&i2c->dev, "WM8961 family %d revision %c\n",
978 (val & WM8961_DEVICE_ID_MASK) >> WM8961_DEVICE_ID_SHIFT,
979 ((val & WM8961_CHIP_REV_MASK) >> WM8961_CHIP_REV_SHIFT)
980 + 'A');
981
982 ret = regmap_write(wm8961->regmap, WM8961_SOFTWARE_RESET, 0x1801);
983 if (ret != 0) {
984 dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret);
985 return ret;
986 }
987
1086 i2c_set_clientdata(i2c, wm8961); 988 i2c_set_clientdata(i2c, wm8961);
1087 989
1088 ret = snd_soc_register_codec(&i2c->dev, 990 ret = snd_soc_register_codec(&i2c->dev,
@@ -1114,23 +1016,7 @@ static struct i2c_driver wm8961_i2c_driver = {
1114 .id_table = wm8961_i2c_id, 1016 .id_table = wm8961_i2c_id,
1115}; 1017};
1116 1018
1117static int __init wm8961_modinit(void) 1019module_i2c_driver(wm8961_i2c_driver);
1118{
1119 int ret = 0;
1120 ret = i2c_add_driver(&wm8961_i2c_driver);
1121 if (ret != 0) {
1122 printk(KERN_ERR "Failed to register wm8961 I2C driver: %d\n",
1123 ret);
1124 }
1125 return ret;
1126}
1127module_init(wm8961_modinit);
1128
1129static void __exit wm8961_exit(void)
1130{
1131 i2c_del_driver(&wm8961_i2c_driver);
1132}
1133module_exit(wm8961_exit);
1134 1020
1135MODULE_DESCRIPTION("ASoC WM8961 driver"); 1021MODULE_DESCRIPTION("ASoC WM8961 driver");
1136MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 1022MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c
index eef783f6b6d6..5ce647758443 100644
--- a/sound/soc/codecs/wm8971.c
+++ b/sound/soc/codecs/wm8971.c
@@ -721,23 +721,7 @@ static struct i2c_driver wm8971_i2c_driver = {
721 .id_table = wm8971_i2c_id, 721 .id_table = wm8971_i2c_id,
722}; 722};
723 723
724static int __init wm8971_modinit(void) 724module_i2c_driver(wm8971_i2c_driver);
725{
726 int ret = 0;
727 ret = i2c_add_driver(&wm8971_i2c_driver);
728 if (ret != 0) {
729 printk(KERN_ERR "Failed to register WM8971 I2C driver: %d\n",
730 ret);
731 }
732 return ret;
733}
734module_init(wm8971_modinit);
735
736static void __exit wm8971_exit(void)
737{
738 i2c_del_driver(&wm8971_i2c_driver);
739}
740module_exit(wm8971_exit);
741 725
742MODULE_DESCRIPTION("ASoC WM8971 driver"); 726MODULE_DESCRIPTION("ASoC WM8971 driver");
743MODULE_AUTHOR("Lab126"); 727MODULE_AUTHOR("Lab126");
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c
index d93c03f820c9..9a39511af52a 100644
--- a/sound/soc/codecs/wm8974.c
+++ b/sound/soc/codecs/wm8974.c
@@ -659,23 +659,7 @@ static struct i2c_driver wm8974_i2c_driver = {
659 .id_table = wm8974_i2c_id, 659 .id_table = wm8974_i2c_id,
660}; 660};
661 661
662static int __init wm8974_modinit(void) 662module_i2c_driver(wm8974_i2c_driver);
663{
664 int ret = 0;
665 ret = i2c_add_driver(&wm8974_i2c_driver);
666 if (ret != 0) {
667 printk(KERN_ERR "Failed to register wm8974 I2C driver: %d\n",
668 ret);
669 }
670 return ret;
671}
672module_init(wm8974_modinit);
673
674static void __exit wm8974_exit(void)
675{
676 i2c_del_driver(&wm8974_i2c_driver);
677}
678module_exit(wm8974_exit);
679 663
680MODULE_DESCRIPTION("ASoC WM8974 driver"); 664MODULE_DESCRIPTION("ASoC WM8974 driver");
681MODULE_AUTHOR("Liam Girdwood"); 665MODULE_AUTHOR("Liam Girdwood");
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index a5be3adecf75..5421fd9fbcb5 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -1105,23 +1105,7 @@ static struct i2c_driver wm8978_i2c_driver = {
1105 .id_table = wm8978_i2c_id, 1105 .id_table = wm8978_i2c_id,
1106}; 1106};
1107 1107
1108static int __init wm8978_modinit(void) 1108module_i2c_driver(wm8978_i2c_driver);
1109{
1110 int ret = 0;
1111 ret = i2c_add_driver(&wm8978_i2c_driver);
1112 if (ret != 0) {
1113 printk(KERN_ERR "Failed to register WM8978 I2C driver: %d\n",
1114 ret);
1115 }
1116 return ret;
1117}
1118module_init(wm8978_modinit);
1119
1120static void __exit wm8978_exit(void)
1121{
1122 i2c_del_driver(&wm8978_i2c_driver);
1123}
1124module_exit(wm8978_exit);
1125 1109
1126MODULE_DESCRIPTION("ASoC WM8978 codec driver"); 1110MODULE_DESCRIPTION("ASoC WM8978 codec driver");
1127MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>"); 1111MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");
diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c
index 367388fdc486..d8879f262d27 100644
--- a/sound/soc/codecs/wm8983.c
+++ b/sound/soc/codecs/wm8983.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/spi/spi.h> 20#include <linux/spi/spi.h>
20#include <linux/slab.h> 21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
@@ -27,61 +28,60 @@
27 28
28#include "wm8983.h" 29#include "wm8983.h"
29 30
30static const u16 wm8983_reg_defs[WM8983_MAX_REGISTER + 1] = { 31static const struct reg_default wm8983_defaults[] = {
31 [0x00] = 0x0000, /* R0 - Software Reset */ 32 { 0x01, 0x0000 }, /* R1 - Power management 1 */
32 [0x01] = 0x0000, /* R1 - Power management 1 */ 33 { 0x02, 0x0000 }, /* R2 - Power management 2 */
33 [0x02] = 0x0000, /* R2 - Power management 2 */ 34 { 0x03, 0x0000 }, /* R3 - Power management 3 */
34 [0x03] = 0x0000, /* R3 - Power management 3 */ 35 { 0x04, 0x0050 }, /* R4 - Audio Interface */
35 [0x04] = 0x0050, /* R4 - Audio Interface */ 36 { 0x05, 0x0000 }, /* R5 - Companding control */
36 [0x05] = 0x0000, /* R5 - Companding control */ 37 { 0x06, 0x0140 }, /* R6 - Clock Gen control */
37 [0x06] = 0x0140, /* R6 - Clock Gen control */ 38 { 0x07, 0x0000 }, /* R7 - Additional control */
38 [0x07] = 0x0000, /* R7 - Additional control */ 39 { 0x08, 0x0000 }, /* R8 - GPIO Control */
39 [0x08] = 0x0000, /* R8 - GPIO Control */ 40 { 0x09, 0x0000 }, /* R9 - Jack Detect Control 1 */
40 [0x09] = 0x0000, /* R9 - Jack Detect Control 1 */ 41 { 0x0A, 0x0000 }, /* R10 - DAC Control */
41 [0x0A] = 0x0000, /* R10 - DAC Control */ 42 { 0x0B, 0x00FF }, /* R11 - Left DAC digital Vol */
42 [0x0B] = 0x00FF, /* R11 - Left DAC digital Vol */ 43 { 0x0C, 0x00FF }, /* R12 - Right DAC digital vol */
43 [0x0C] = 0x00FF, /* R12 - Right DAC digital vol */ 44 { 0x0D, 0x0000 }, /* R13 - Jack Detect Control 2 */
44 [0x0D] = 0x0000, /* R13 - Jack Detect Control 2 */ 45 { 0x0E, 0x0100 }, /* R14 - ADC Control */
45 [0x0E] = 0x0100, /* R14 - ADC Control */ 46 { 0x0F, 0x00FF }, /* R15 - Left ADC Digital Vol */
46 [0x0F] = 0x00FF, /* R15 - Left ADC Digital Vol */ 47 { 0x10, 0x00FF }, /* R16 - Right ADC Digital Vol */
47 [0x10] = 0x00FF, /* R16 - Right ADC Digital Vol */ 48 { 0x12, 0x012C }, /* R18 - EQ1 - low shelf */
48 [0x12] = 0x012C, /* R18 - EQ1 - low shelf */ 49 { 0x13, 0x002C }, /* R19 - EQ2 - peak 1 */
49 [0x13] = 0x002C, /* R19 - EQ2 - peak 1 */ 50 { 0x14, 0x002C }, /* R20 - EQ3 - peak 2 */
50 [0x14] = 0x002C, /* R20 - EQ3 - peak 2 */ 51 { 0x15, 0x002C }, /* R21 - EQ4 - peak 3 */
51 [0x15] = 0x002C, /* R21 - EQ4 - peak 3 */ 52 { 0x16, 0x002C }, /* R22 - EQ5 - high shelf */
52 [0x16] = 0x002C, /* R22 - EQ5 - high shelf */ 53 { 0x18, 0x0032 }, /* R24 - DAC Limiter 1 */
53 [0x18] = 0x0032, /* R24 - DAC Limiter 1 */ 54 { 0x19, 0x0000 }, /* R25 - DAC Limiter 2 */
54 [0x19] = 0x0000, /* R25 - DAC Limiter 2 */ 55 { 0x1B, 0x0000 }, /* R27 - Notch Filter 1 */
55 [0x1B] = 0x0000, /* R27 - Notch Filter 1 */ 56 { 0x1C, 0x0000 }, /* R28 - Notch Filter 2 */
56 [0x1C] = 0x0000, /* R28 - Notch Filter 2 */ 57 { 0x1D, 0x0000 }, /* R29 - Notch Filter 3 */
57 [0x1D] = 0x0000, /* R29 - Notch Filter 3 */ 58 { 0x1E, 0x0000 }, /* R30 - Notch Filter 4 */
58 [0x1E] = 0x0000, /* R30 - Notch Filter 4 */ 59 { 0x20, 0x0038 }, /* R32 - ALC control 1 */
59 [0x20] = 0x0038, /* R32 - ALC control 1 */ 60 { 0x21, 0x000B }, /* R33 - ALC control 2 */
60 [0x21] = 0x000B, /* R33 - ALC control 2 */ 61 { 0x22, 0x0032 }, /* R34 - ALC control 3 */
61 [0x22] = 0x0032, /* R34 - ALC control 3 */ 62 { 0x23, 0x0000 }, /* R35 - Noise Gate */
62 [0x23] = 0x0000, /* R35 - Noise Gate */ 63 { 0x24, 0x0008 }, /* R36 - PLL N */
63 [0x24] = 0x0008, /* R36 - PLL N */ 64 { 0x25, 0x000C }, /* R37 - PLL K 1 */
64 [0x25] = 0x000C, /* R37 - PLL K 1 */ 65 { 0x26, 0x0093 }, /* R38 - PLL K 2 */
65 [0x26] = 0x0093, /* R38 - PLL K 2 */ 66 { 0x27, 0x00E9 }, /* R39 - PLL K 3 */
66 [0x27] = 0x00E9, /* R39 - PLL K 3 */ 67 { 0x29, 0x0000 }, /* R41 - 3D control */
67 [0x29] = 0x0000, /* R41 - 3D control */ 68 { 0x2A, 0x0000 }, /* R42 - OUT4 to ADC */
68 [0x2A] = 0x0000, /* R42 - OUT4 to ADC */ 69 { 0x2B, 0x0000 }, /* R43 - Beep control */
69 [0x2B] = 0x0000, /* R43 - Beep control */ 70 { 0x2C, 0x0033 }, /* R44 - Input ctrl */
70 [0x2C] = 0x0033, /* R44 - Input ctrl */ 71 { 0x2D, 0x0010 }, /* R45 - Left INP PGA gain ctrl */
71 [0x2D] = 0x0010, /* R45 - Left INP PGA gain ctrl */ 72 { 0x2E, 0x0010 }, /* R46 - Right INP PGA gain ctrl */
72 [0x2E] = 0x0010, /* R46 - Right INP PGA gain ctrl */ 73 { 0x2F, 0x0100 }, /* R47 - Left ADC BOOST ctrl */
73 [0x2F] = 0x0100, /* R47 - Left ADC BOOST ctrl */ 74 { 0x30, 0x0100 }, /* R48 - Right ADC BOOST ctrl */
74 [0x30] = 0x0100, /* R48 - Right ADC BOOST ctrl */ 75 { 0x31, 0x0002 }, /* R49 - Output ctrl */
75 [0x31] = 0x0002, /* R49 - Output ctrl */ 76 { 0x32, 0x0001 }, /* R50 - Left mixer ctrl */
76 [0x32] = 0x0001, /* R50 - Left mixer ctrl */ 77 { 0x33, 0x0001 }, /* R51 - Right mixer ctrl */
77 [0x33] = 0x0001, /* R51 - Right mixer ctrl */ 78 { 0x34, 0x0039 }, /* R52 - LOUT1 (HP) volume ctrl */
78 [0x34] = 0x0039, /* R52 - LOUT1 (HP) volume ctrl */ 79 { 0x35, 0x0039 }, /* R53 - ROUT1 (HP) volume ctrl */
79 [0x35] = 0x0039, /* R53 - ROUT1 (HP) volume ctrl */ 80 { 0x36, 0x0039 }, /* R54 - LOUT2 (SPK) volume ctrl */
80 [0x36] = 0x0039, /* R54 - LOUT2 (SPK) volume ctrl */ 81 { 0x37, 0x0039 }, /* R55 - ROUT2 (SPK) volume ctrl */
81 [0x37] = 0x0039, /* R55 - ROUT2 (SPK) volume ctrl */ 82 { 0x38, 0x0001 }, /* R56 - OUT3 mixer ctrl */
82 [0x38] = 0x0001, /* R56 - OUT3 mixer ctrl */ 83 { 0x39, 0x0001 }, /* R57 - OUT4 (MONO) mix ctrl */
83 [0x39] = 0x0001, /* R57 - OUT4 (MONO) mix ctrl */ 84 { 0x3D, 0x0000 }, /* R61 - BIAS CTRL */
84 [0x3D] = 0x0000 /* R61 - BIAS CTRL */
85}; 85};
86 86
87static const struct wm8983_reg_access { 87static const struct wm8983_reg_access {
@@ -159,7 +159,7 @@ static const int vol_update_regs[] = {
159}; 159};
160 160
161struct wm8983_priv { 161struct wm8983_priv {
162 enum snd_soc_control_type control_type; 162 struct regmap *regmap;
163 u32 sysclk; 163 u32 sysclk;
164 u32 bclk; 164 u32 bclk;
165}; 165};
@@ -610,7 +610,7 @@ static int eqmode_put(struct snd_kcontrol *kcontrol,
610 return 0; 610 return 0;
611} 611}
612 612
613static int wm8983_readable(struct snd_soc_codec *codec, unsigned int reg) 613static bool wm8983_readable(struct device *dev, unsigned int reg)
614{ 614{
615 if (reg > WM8983_MAX_REGISTER) 615 if (reg > WM8983_MAX_REGISTER)
616 return 0; 616 return 0;
@@ -905,6 +905,7 @@ static int wm8983_set_sysclk(struct snd_soc_dai *dai,
905static int wm8983_set_bias_level(struct snd_soc_codec *codec, 905static int wm8983_set_bias_level(struct snd_soc_codec *codec,
906 enum snd_soc_bias_level level) 906 enum snd_soc_bias_level level)
907{ 907{
908 struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec);
908 int ret; 909 int ret;
909 910
910 switch (level) { 911 switch (level) {
@@ -917,7 +918,7 @@ static int wm8983_set_bias_level(struct snd_soc_codec *codec,
917 break; 918 break;
918 case SND_SOC_BIAS_STANDBY: 919 case SND_SOC_BIAS_STANDBY:
919 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 920 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
920 ret = snd_soc_cache_sync(codec); 921 ret = regcache_sync(wm8983->regmap);
921 if (ret < 0) { 922 if (ret < 0) {
922 dev_err(codec->dev, "Failed to sync cache: %d\n", ret); 923 dev_err(codec->dev, "Failed to sync cache: %d\n", ret);
923 return ret; 924 return ret;
@@ -994,10 +995,9 @@ static int wm8983_remove(struct snd_soc_codec *codec)
994static int wm8983_probe(struct snd_soc_codec *codec) 995static int wm8983_probe(struct snd_soc_codec *codec)
995{ 996{
996 int ret; 997 int ret;
997 struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec);
998 int i; 998 int i;
999 999
1000 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8983->control_type); 1000 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
1001 if (ret < 0) { 1001 if (ret < 0) {
1002 dev_err(codec->dev, "Failed to set cache i/o: %d\n", ret); 1002 dev_err(codec->dev, "Failed to set cache i/o: %d\n", ret);
1003 return ret; 1003 return ret;
@@ -1067,16 +1067,23 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8983 = {
1067 .suspend = wm8983_suspend, 1067 .suspend = wm8983_suspend,
1068 .resume = wm8983_resume, 1068 .resume = wm8983_resume,
1069 .set_bias_level = wm8983_set_bias_level, 1069 .set_bias_level = wm8983_set_bias_level,
1070 .reg_cache_size = ARRAY_SIZE(wm8983_reg_defs),
1071 .reg_word_size = sizeof(u16),
1072 .reg_cache_default = wm8983_reg_defs,
1073 .controls = wm8983_snd_controls, 1070 .controls = wm8983_snd_controls,
1074 .num_controls = ARRAY_SIZE(wm8983_snd_controls), 1071 .num_controls = ARRAY_SIZE(wm8983_snd_controls),
1075 .dapm_widgets = wm8983_dapm_widgets, 1072 .dapm_widgets = wm8983_dapm_widgets,
1076 .num_dapm_widgets = ARRAY_SIZE(wm8983_dapm_widgets), 1073 .num_dapm_widgets = ARRAY_SIZE(wm8983_dapm_widgets),
1077 .dapm_routes = wm8983_audio_map, 1074 .dapm_routes = wm8983_audio_map,
1078 .num_dapm_routes = ARRAY_SIZE(wm8983_audio_map), 1075 .num_dapm_routes = ARRAY_SIZE(wm8983_audio_map),
1079 .readable_register = wm8983_readable 1076};
1077
1078static const struct regmap_config wm8983_regmap = {
1079 .reg_bits = 7,
1080 .val_bits = 9,
1081
1082 .reg_defaults = wm8983_defaults,
1083 .num_reg_defaults = ARRAY_SIZE(wm8983_defaults),
1084 .cache_type = REGCACHE_RBTREE,
1085
1086 .readable_reg = wm8983_readable,
1080}; 1087};
1081 1088
1082#if defined(CONFIG_SPI_MASTER) 1089#if defined(CONFIG_SPI_MASTER)
@@ -1085,24 +1092,27 @@ static int __devinit wm8983_spi_probe(struct spi_device *spi)
1085 struct wm8983_priv *wm8983; 1092 struct wm8983_priv *wm8983;
1086 int ret; 1093 int ret;
1087 1094
1088 wm8983 = kzalloc(sizeof *wm8983, GFP_KERNEL); 1095 wm8983 = devm_kzalloc(&spi->dev, sizeof *wm8983, GFP_KERNEL);
1089 if (!wm8983) 1096 if (!wm8983)
1090 return -ENOMEM; 1097 return -ENOMEM;
1091 1098
1092 wm8983->control_type = SND_SOC_SPI; 1099 wm8983->regmap = devm_regmap_init_spi(spi, &wm8983_regmap);
1100 if (IS_ERR(wm8983->regmap)) {
1101 ret = PTR_ERR(wm8983->regmap);
1102 dev_err(&spi->dev, "Failed to init regmap: %d\n", ret);
1103 return ret;
1104 }
1105
1093 spi_set_drvdata(spi, wm8983); 1106 spi_set_drvdata(spi, wm8983);
1094 1107
1095 ret = snd_soc_register_codec(&spi->dev, 1108 ret = snd_soc_register_codec(&spi->dev,
1096 &soc_codec_dev_wm8983, &wm8983_dai, 1); 1109 &soc_codec_dev_wm8983, &wm8983_dai, 1);
1097 if (ret < 0)
1098 kfree(wm8983);
1099 return ret; 1110 return ret;
1100} 1111}
1101 1112
1102static int __devexit wm8983_spi_remove(struct spi_device *spi) 1113static int __devexit wm8983_spi_remove(struct spi_device *spi)
1103{ 1114{
1104 snd_soc_unregister_codec(&spi->dev); 1115 snd_soc_unregister_codec(&spi->dev);
1105 kfree(spi_get_drvdata(spi));
1106 return 0; 1116 return 0;
1107} 1117}
1108 1118
@@ -1123,24 +1133,28 @@ static __devinit int wm8983_i2c_probe(struct i2c_client *i2c,
1123 struct wm8983_priv *wm8983; 1133 struct wm8983_priv *wm8983;
1124 int ret; 1134 int ret;
1125 1135
1126 wm8983 = kzalloc(sizeof *wm8983, GFP_KERNEL); 1136 wm8983 = devm_kzalloc(&i2c->dev, sizeof *wm8983, GFP_KERNEL);
1127 if (!wm8983) 1137 if (!wm8983)
1128 return -ENOMEM; 1138 return -ENOMEM;
1129 1139
1130 wm8983->control_type = SND_SOC_I2C; 1140 wm8983->regmap = devm_regmap_init_i2c(i2c, &wm8983_regmap);
1141 if (IS_ERR(wm8983->regmap)) {
1142 ret = PTR_ERR(wm8983->regmap);
1143 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret);
1144 return ret;
1145 }
1146
1131 i2c_set_clientdata(i2c, wm8983); 1147 i2c_set_clientdata(i2c, wm8983);
1132 1148
1133 ret = snd_soc_register_codec(&i2c->dev, 1149 ret = snd_soc_register_codec(&i2c->dev,
1134 &soc_codec_dev_wm8983, &wm8983_dai, 1); 1150 &soc_codec_dev_wm8983, &wm8983_dai, 1);
1135 if (ret < 0) 1151
1136 kfree(wm8983);
1137 return ret; 1152 return ret;
1138} 1153}
1139 1154
1140static __devexit int wm8983_i2c_remove(struct i2c_client *client) 1155static __devexit int wm8983_i2c_remove(struct i2c_client *client)
1141{ 1156{
1142 snd_soc_unregister_codec(&client->dev); 1157 snd_soc_unregister_codec(&client->dev);
1143 kfree(i2c_get_clientdata(client));
1144 return 0; 1158 return 0;
1145} 1159}
1146 1160
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c
index db63c97ddf51..c28c83e5395d 100644
--- a/sound/soc/codecs/wm8990.c
+++ b/sound/soc/codecs/wm8990.c
@@ -1388,7 +1388,8 @@ static __devinit int wm8990_i2c_probe(struct i2c_client *i2c,
1388 struct wm8990_priv *wm8990; 1388 struct wm8990_priv *wm8990;
1389 int ret; 1389 int ret;
1390 1390
1391 wm8990 = kzalloc(sizeof(struct wm8990_priv), GFP_KERNEL); 1391 wm8990 = devm_kzalloc(&i2c->dev, sizeof(struct wm8990_priv),
1392 GFP_KERNEL);
1392 if (wm8990 == NULL) 1393 if (wm8990 == NULL)
1393 return -ENOMEM; 1394 return -ENOMEM;
1394 1395
@@ -1396,15 +1397,14 @@ static __devinit int wm8990_i2c_probe(struct i2c_client *i2c,
1396 1397
1397 ret = snd_soc_register_codec(&i2c->dev, 1398 ret = snd_soc_register_codec(&i2c->dev,
1398 &soc_codec_dev_wm8990, &wm8990_dai, 1); 1399 &soc_codec_dev_wm8990, &wm8990_dai, 1);
1399 if (ret < 0) 1400
1400 kfree(wm8990);
1401 return ret; 1401 return ret;
1402} 1402}
1403 1403
1404static __devexit int wm8990_i2c_remove(struct i2c_client *client) 1404static __devexit int wm8990_i2c_remove(struct i2c_client *client)
1405{ 1405{
1406 snd_soc_unregister_codec(&client->dev); 1406 snd_soc_unregister_codec(&client->dev);
1407 kfree(i2c_get_clientdata(client)); 1407
1408 return 0; 1408 return 0;
1409} 1409}
1410 1410
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index 9ac31ba9b82e..fe439f027e10 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -1363,7 +1363,7 @@ static __devinit int wm8991_i2c_probe(struct i2c_client *i2c,
1363 struct wm8991_priv *wm8991; 1363 struct wm8991_priv *wm8991;
1364 int ret; 1364 int ret;
1365 1365
1366 wm8991 = kzalloc(sizeof *wm8991, GFP_KERNEL); 1366 wm8991 = devm_kzalloc(&i2c->dev, sizeof(*wm8991), GFP_KERNEL);
1367 if (!wm8991) 1367 if (!wm8991)
1368 return -ENOMEM; 1368 return -ENOMEM;
1369 1369
@@ -1372,15 +1372,14 @@ static __devinit int wm8991_i2c_probe(struct i2c_client *i2c,
1372 1372
1373 ret = snd_soc_register_codec(&i2c->dev, 1373 ret = snd_soc_register_codec(&i2c->dev,
1374 &soc_codec_dev_wm8991, &wm8991_dai, 1); 1374 &soc_codec_dev_wm8991, &wm8991_dai, 1);
1375 if (ret < 0) 1375
1376 kfree(wm8991);
1377 return ret; 1376 return ret;
1378} 1377}
1379 1378
1380static __devexit int wm8991_i2c_remove(struct i2c_client *client) 1379static __devexit int wm8991_i2c_remove(struct i2c_client *client)
1381{ 1380{
1382 snd_soc_unregister_codec(&client->dev); 1381 snd_soc_unregister_codec(&client->dev);
1383 kfree(i2c_get_clientdata(client)); 1382
1384 return 0; 1383 return 0;
1385} 1384}
1386 1385
@@ -1400,23 +1399,7 @@ static struct i2c_driver wm8991_i2c_driver = {
1400 .id_table = wm8991_i2c_id, 1399 .id_table = wm8991_i2c_id,
1401}; 1400};
1402 1401
1403static int __init wm8991_modinit(void) 1402module_i2c_driver(wm8991_i2c_driver);
1404{
1405 int ret;
1406 ret = i2c_add_driver(&wm8991_i2c_driver);
1407 if (ret != 0) {
1408 printk(KERN_ERR "Failed to register WM8991 I2C driver: %d\n",
1409 ret);
1410 }
1411 return 0;
1412}
1413module_init(wm8991_modinit);
1414
1415static void __exit wm8991_exit(void)
1416{
1417 i2c_del_driver(&wm8991_i2c_driver);
1418}
1419module_exit(wm8991_exit);
1420 1403
1421MODULE_DESCRIPTION("ASoC WM8991 driver"); 1404MODULE_DESCRIPTION("ASoC WM8991 driver");
1422MODULE_AUTHOR("Graeme Gregory"); 1405MODULE_AUTHOR("Graeme Gregory");
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c
index 9fd80d688979..94737a30716b 100644
--- a/sound/soc/codecs/wm8993.c
+++ b/sound/soc/codecs/wm8993.c
@@ -1520,6 +1520,8 @@ static int wm8993_probe(struct snd_soc_codec *codec)
1520 wm8993->pdata.lineout2fb, 1520 wm8993->pdata.lineout2fb,
1521 wm8993->pdata.jd_scthr, 1521 wm8993->pdata.jd_scthr,
1522 wm8993->pdata.jd_thr, 1522 wm8993->pdata.jd_thr,
1523 wm8993->pdata.micbias1_delay,
1524 wm8993->pdata.micbias2_delay,
1523 wm8993->pdata.micbias1_lvl, 1525 wm8993->pdata.micbias1_lvl,
1524 wm8993->pdata.micbias2_lvl); 1526 wm8993->pdata.micbias2_lvl);
1525 1527
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 6c9eeca85b95..2b2dadc54dac 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -671,6 +671,18 @@ SOC_SINGLE_TLV("AIF2 EQ5 Volume", WM8994_AIF2_EQ_GAINS_2, 6, 31, 0,
671 eq_tlv), 671 eq_tlv),
672}; 672};
673 673
674static const struct snd_kcontrol_new wm8994_drc_controls[] = {
675SND_SOC_BYTES_MASK("AIF1.1 DRC", WM8994_AIF1_DRC1_1, 5,
676 WM8994_AIF1DAC1_DRC_ENA | WM8994_AIF1ADC1L_DRC_ENA |
677 WM8994_AIF1ADC1R_DRC_ENA),
678SND_SOC_BYTES_MASK("AIF1.2 DRC", WM8994_AIF1_DRC2_1, 5,
679 WM8994_AIF1DAC2_DRC_ENA | WM8994_AIF1ADC2L_DRC_ENA |
680 WM8994_AIF1ADC2R_DRC_ENA),
681SND_SOC_BYTES_MASK("AIF2 DRC", WM8994_AIF2_DRC_1, 5,
682 WM8994_AIF2DAC_DRC_ENA | WM8994_AIF2ADCL_DRC_ENA |
683 WM8994_AIF2ADCR_DRC_ENA),
684};
685
674static const char *wm8958_ng_text[] = { 686static const char *wm8958_ng_text[] = {
675 "30ms", "125ms", "250ms", "500ms", 687 "30ms", "125ms", "250ms", "500ms",
676}; 688};
@@ -789,11 +801,27 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w,
789 struct snd_kcontrol *kcontrol, int event) 801 struct snd_kcontrol *kcontrol, int event)
790{ 802{
791 struct snd_soc_codec *codec = w->codec; 803 struct snd_soc_codec *codec = w->codec;
804 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
792 805
793 switch (event) { 806 switch (event) {
794 case SND_SOC_DAPM_PRE_PMU: 807 case SND_SOC_DAPM_PRE_PMU:
795 return configure_clock(codec); 808 return configure_clock(codec);
796 809
810 case SND_SOC_DAPM_POST_PMU:
811 /*
812 * JACKDET won't run until we start the clock and it
813 * only reports deltas, make sure we notify the state
814 * up the stack on startup. Use a *very* generous
815 * timeout for paranoia, there's no urgency and we
816 * don't want false reports.
817 */
818 if (wm8994->jackdet && !wm8994->clk_has_run) {
819 schedule_delayed_work(&wm8994->jackdet_bootstrap,
820 msecs_to_jiffies(1000));
821 wm8994->clk_has_run = true;
822 }
823 break;
824
797 case SND_SOC_DAPM_POST_PMD: 825 case SND_SOC_DAPM_POST_PMD:
798 configure_clock(codec); 826 configure_clock(codec);
799 break; 827 break;
@@ -1632,7 +1660,8 @@ SND_SOC_DAPM_SUPPLY("VMID", SND_SOC_NOPM, 0, 0, vmid_event,
1632 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), 1660 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
1633 1661
1634SND_SOC_DAPM_SUPPLY("CLK_SYS", SND_SOC_NOPM, 0, 0, clk_sys_event, 1662SND_SOC_DAPM_SUPPLY("CLK_SYS", SND_SOC_NOPM, 0, 0, clk_sys_event,
1635 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 1663 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
1664 SND_SOC_DAPM_PRE_PMD),
1636 1665
1637SND_SOC_DAPM_SUPPLY("DSP1CLK", SND_SOC_NOPM, 3, 0, NULL, 0), 1666SND_SOC_DAPM_SUPPLY("DSP1CLK", SND_SOC_NOPM, 3, 0, NULL, 0),
1638SND_SOC_DAPM_SUPPLY("DSP2CLK", SND_SOC_NOPM, 2, 0, NULL, 0), 1667SND_SOC_DAPM_SUPPLY("DSP2CLK", SND_SOC_NOPM, 2, 0, NULL, 0),
@@ -2102,6 +2131,10 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
2102 case WM8994_FLL_SRC_LRCLK: 2131 case WM8994_FLL_SRC_LRCLK:
2103 case WM8994_FLL_SRC_BCLK: 2132 case WM8994_FLL_SRC_BCLK:
2104 break; 2133 break;
2134 case WM8994_FLL_SRC_INTERNAL:
2135 freq_in = 12000000;
2136 freq_out = 12000000;
2137 break;
2105 default: 2138 default:
2106 return -EINVAL; 2139 return -EINVAL;
2107 } 2140 }
@@ -2161,12 +2194,14 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
2161 2194
2162 snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_4 + reg_offset, 2195 snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_4 + reg_offset,
2163 WM8994_FLL1_N_MASK, 2196 WM8994_FLL1_N_MASK,
2164 fll.n << WM8994_FLL1_N_SHIFT); 2197 fll.n << WM8994_FLL1_N_SHIFT);
2165 2198
2166 snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_5 + reg_offset, 2199 snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_5 + reg_offset,
2167 WM8958_FLL1_BYP | 2200 WM8994_FLL1_FRC_NCO | WM8958_FLL1_BYP |
2168 WM8994_FLL1_REFCLK_DIV_MASK | 2201 WM8994_FLL1_REFCLK_DIV_MASK |
2169 WM8994_FLL1_REFCLK_SRC_MASK, 2202 WM8994_FLL1_REFCLK_SRC_MASK,
2203 ((src == WM8994_FLL_SRC_INTERNAL)
2204 << WM8994_FLL1_FRC_NCO_SHIFT) |
2170 (fll.clk_ref_div << WM8994_FLL1_REFCLK_DIV_SHIFT) | 2205 (fll.clk_ref_div << WM8994_FLL1_REFCLK_DIV_SHIFT) |
2171 (src - 1)); 2206 (src - 1));
2172 2207
@@ -2192,13 +2227,16 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
2192 } 2227 }
2193 } 2228 }
2194 2229
2230 reg = WM8994_FLL1_ENA;
2231
2195 if (fll.k) 2232 if (fll.k)
2196 reg = WM8994_FLL1_ENA | WM8994_FLL1_FRAC; 2233 reg |= WM8994_FLL1_FRAC;
2197 else 2234 if (src == WM8994_FLL_SRC_INTERNAL)
2198 reg = WM8994_FLL1_ENA; 2235 reg |= WM8994_FLL1_OSC_ENA;
2236
2199 snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_1 + reg_offset, 2237 snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_1 + reg_offset,
2200 WM8994_FLL1_ENA | WM8994_FLL1_FRAC, 2238 WM8994_FLL1_ENA | WM8994_FLL1_OSC_ENA |
2201 reg); 2239 WM8994_FLL1_FRAC, reg);
2202 2240
2203 if (wm8994->fll_locked_irq) { 2241 if (wm8994->fll_locked_irq) {
2204 timeout = wait_for_completion_timeout(&wm8994->fll_locked[id], 2242 timeout = wait_for_completion_timeout(&wm8994->fll_locked[id],
@@ -3027,7 +3065,7 @@ static int wm8994_codec_resume(struct snd_soc_codec *codec)
3027 3065
3028static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994) 3066static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994)
3029{ 3067{
3030 struct snd_soc_codec *codec = wm8994->codec; 3068 struct snd_soc_codec *codec = wm8994->hubs.codec;
3031 struct wm8994_pdata *pdata = wm8994->pdata; 3069 struct wm8994_pdata *pdata = wm8994->pdata;
3032 struct snd_kcontrol_new controls[] = { 3070 struct snd_kcontrol_new controls[] = {
3033 SOC_ENUM_EXT("AIF1.1 EQ Mode", 3071 SOC_ENUM_EXT("AIF1.1 EQ Mode",
@@ -3085,16 +3123,16 @@ static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994)
3085 wm8994->retune_mobile_enum.max = wm8994->num_retune_mobile_texts; 3123 wm8994->retune_mobile_enum.max = wm8994->num_retune_mobile_texts;
3086 wm8994->retune_mobile_enum.texts = wm8994->retune_mobile_texts; 3124 wm8994->retune_mobile_enum.texts = wm8994->retune_mobile_texts;
3087 3125
3088 ret = snd_soc_add_codec_controls(wm8994->codec, controls, 3126 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls,
3089 ARRAY_SIZE(controls)); 3127 ARRAY_SIZE(controls));
3090 if (ret != 0) 3128 if (ret != 0)
3091 dev_err(wm8994->codec->dev, 3129 dev_err(wm8994->hubs.codec->dev,
3092 "Failed to add ReTune Mobile controls: %d\n", ret); 3130 "Failed to add ReTune Mobile controls: %d\n", ret);
3093} 3131}
3094 3132
3095static void wm8994_handle_pdata(struct wm8994_priv *wm8994) 3133static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
3096{ 3134{
3097 struct snd_soc_codec *codec = wm8994->codec; 3135 struct snd_soc_codec *codec = wm8994->hubs.codec;
3098 struct wm8994_pdata *pdata = wm8994->pdata; 3136 struct wm8994_pdata *pdata = wm8994->pdata;
3099 int ret, i; 3137 int ret, i;
3100 3138
@@ -3107,6 +3145,8 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
3107 pdata->lineout2fb, 3145 pdata->lineout2fb,
3108 pdata->jd_scthr, 3146 pdata->jd_scthr,
3109 pdata->jd_thr, 3147 pdata->jd_thr,
3148 pdata->micb1_delay,
3149 pdata->micb2_delay,
3110 pdata->micbias1_lvl, 3150 pdata->micbias1_lvl,
3111 pdata->micbias2_lvl); 3151 pdata->micbias2_lvl);
3112 3152
@@ -3123,10 +3163,10 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
3123 }; 3163 };
3124 3164
3125 /* We need an array of texts for the enum API */ 3165 /* We need an array of texts for the enum API */
3126 wm8994->drc_texts = devm_kzalloc(wm8994->codec->dev, 3166 wm8994->drc_texts = devm_kzalloc(wm8994->hubs.codec->dev,
3127 sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL); 3167 sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL);
3128 if (!wm8994->drc_texts) { 3168 if (!wm8994->drc_texts) {
3129 dev_err(wm8994->codec->dev, 3169 dev_err(wm8994->hubs.codec->dev,
3130 "Failed to allocate %d DRC config texts\n", 3170 "Failed to allocate %d DRC config texts\n",
3131 pdata->num_drc_cfgs); 3171 pdata->num_drc_cfgs);
3132 return; 3172 return;
@@ -3138,23 +3178,28 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
3138 wm8994->drc_enum.max = pdata->num_drc_cfgs; 3178 wm8994->drc_enum.max = pdata->num_drc_cfgs;
3139 wm8994->drc_enum.texts = wm8994->drc_texts; 3179 wm8994->drc_enum.texts = wm8994->drc_texts;
3140 3180
3141 ret = snd_soc_add_codec_controls(wm8994->codec, controls, 3181 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls,
3142 ARRAY_SIZE(controls)); 3182 ARRAY_SIZE(controls));
3143 if (ret != 0)
3144 dev_err(wm8994->codec->dev,
3145 "Failed to add DRC mode controls: %d\n", ret);
3146
3147 for (i = 0; i < WM8994_NUM_DRC; i++) 3183 for (i = 0; i < WM8994_NUM_DRC; i++)
3148 wm8994_set_drc(codec, i); 3184 wm8994_set_drc(codec, i);
3185 } else {
3186 ret = snd_soc_add_codec_controls(wm8994->hubs.codec,
3187 wm8994_drc_controls,
3188 ARRAY_SIZE(wm8994_drc_controls));
3149 } 3189 }
3150 3190
3191 if (ret != 0)
3192 dev_err(wm8994->hubs.codec->dev,
3193 "Failed to add DRC mode controls: %d\n", ret);
3194
3195
3151 dev_dbg(codec->dev, "%d ReTune Mobile configurations\n", 3196 dev_dbg(codec->dev, "%d ReTune Mobile configurations\n",
3152 pdata->num_retune_mobile_cfgs); 3197 pdata->num_retune_mobile_cfgs);
3153 3198
3154 if (pdata->num_retune_mobile_cfgs) 3199 if (pdata->num_retune_mobile_cfgs)
3155 wm8994_handle_retune_mobile_pdata(wm8994); 3200 wm8994_handle_retune_mobile_pdata(wm8994);
3156 else 3201 else
3157 snd_soc_add_codec_controls(wm8994->codec, wm8994_eq_controls, 3202 snd_soc_add_codec_controls(wm8994->hubs.codec, wm8994_eq_controls,
3158 ARRAY_SIZE(wm8994_eq_controls)); 3203 ARRAY_SIZE(wm8994_eq_controls));
3159 3204
3160 for (i = 0; i < ARRAY_SIZE(pdata->micbias); i++) { 3205 for (i = 0; i < ARRAY_SIZE(pdata->micbias); i++) {
@@ -3236,6 +3281,12 @@ int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
3236 3281
3237 snd_soc_update_bits(codec, WM8994_MICBIAS, WM8994_MICD_ENA, reg); 3282 snd_soc_update_bits(codec, WM8994_MICBIAS, WM8994_MICD_ENA, reg);
3238 3283
3284 /* enable MICDET and MICSHRT deboune */
3285 snd_soc_update_bits(codec, WM8994_IRQ_DEBOUNCE,
3286 WM8994_MIC1_DET_DB_MASK | WM8994_MIC1_SHRT_DB_MASK |
3287 WM8994_MIC2_DET_DB_MASK | WM8994_MIC2_SHRT_DB_MASK,
3288 WM8994_MIC1_DET_DB | WM8994_MIC1_SHRT_DB);
3289
3239 snd_soc_dapm_sync(&codec->dapm); 3290 snd_soc_dapm_sync(&codec->dapm);
3240 3291
3241 return 0; 3292 return 0;
@@ -3309,7 +3360,7 @@ static void wm8994_mic_work(struct work_struct *work)
3309static irqreturn_t wm8994_mic_irq(int irq, void *data) 3360static irqreturn_t wm8994_mic_irq(int irq, void *data)
3310{ 3361{
3311 struct wm8994_priv *priv = data; 3362 struct wm8994_priv *priv = data;
3312 struct snd_soc_codec *codec = priv->codec; 3363 struct snd_soc_codec *codec = priv->hubs.codec;
3313 3364
3314#ifndef CONFIG_SND_SOC_WM8994_MODULE 3365#ifndef CONFIG_SND_SOC_WM8994_MODULE
3315 trace_snd_soc_jack_irq(dev_name(codec->dev)); 3366 trace_snd_soc_jack_irq(dev_name(codec->dev));
@@ -3345,7 +3396,7 @@ static void wm8958_default_micdet(u16 status, void *data)
3345 3396
3346 snd_soc_jack_report(wm8994->micdet[0].jack, 0, 3397 snd_soc_jack_report(wm8994->micdet[0].jack, 0,
3347 wm8994->btn_mask | 3398 wm8994->btn_mask |
3348 SND_JACK_HEADSET); 3399 SND_JACK_HEADSET);
3349 } 3400 }
3350 return; 3401 return;
3351 } 3402 }
@@ -3422,7 +3473,7 @@ static void wm8958_default_micdet(u16 status, void *data)
3422static irqreturn_t wm1811_jackdet_irq(int irq, void *data) 3473static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
3423{ 3474{
3424 struct wm8994_priv *wm8994 = data; 3475 struct wm8994_priv *wm8994 = data;
3425 struct snd_soc_codec *codec = wm8994->codec; 3476 struct snd_soc_codec *codec = wm8994->hubs.codec;
3426 int reg; 3477 int reg;
3427 bool present; 3478 bool present;
3428 3479
@@ -3499,10 +3550,22 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
3499 SND_JACK_MECHANICAL | SND_JACK_HEADSET | 3550 SND_JACK_MECHANICAL | SND_JACK_HEADSET |
3500 wm8994->btn_mask); 3551 wm8994->btn_mask);
3501 3552
3553 /* Since we only report deltas force an update, ensures we
3554 * avoid bootstrapping issues with the core. */
3555 snd_soc_jack_report(wm8994->micdet[0].jack, 0, 0);
3556
3502 pm_runtime_put(codec->dev); 3557 pm_runtime_put(codec->dev);
3503 return IRQ_HANDLED; 3558 return IRQ_HANDLED;
3504} 3559}
3505 3560
3561static void wm1811_jackdet_bootstrap(struct work_struct *work)
3562{
3563 struct wm8994_priv *wm8994 = container_of(work,
3564 struct wm8994_priv,
3565 jackdet_bootstrap.work);
3566 wm1811_jackdet_irq(0, wm8994);
3567}
3568
3506/** 3569/**
3507 * wm8958_mic_detect - Enable microphone detection via the WM8958 IRQ 3570 * wm8958_mic_detect - Enable microphone detection via the WM8958 IRQ
3508 * 3571 *
@@ -3573,6 +3636,10 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
3573 * otherwise jump straight to microphone detection. 3636 * otherwise jump straight to microphone detection.
3574 */ 3637 */
3575 if (wm8994->jackdet) { 3638 if (wm8994->jackdet) {
3639 /* Disable debounce for the initial detect */
3640 snd_soc_update_bits(codec, WM1811_JACKDET_CTRL,
3641 WM1811_JACKDET_DB, 0);
3642
3576 snd_soc_update_bits(codec, WM8958_MICBIAS2, 3643 snd_soc_update_bits(codec, WM8958_MICBIAS2,
3577 WM8958_MICB2_DISCH, 3644 WM8958_MICB2_DISCH,
3578 WM8958_MICB2_DISCH); 3645 WM8958_MICB2_DISCH);
@@ -3600,7 +3667,7 @@ EXPORT_SYMBOL_GPL(wm8958_mic_detect);
3600static irqreturn_t wm8958_mic_irq(int irq, void *data) 3667static irqreturn_t wm8958_mic_irq(int irq, void *data)
3601{ 3668{
3602 struct wm8994_priv *wm8994 = data; 3669 struct wm8994_priv *wm8994 = data;
3603 struct snd_soc_codec *codec = wm8994->codec; 3670 struct snd_soc_codec *codec = wm8994->hubs.codec;
3604 int reg, count; 3671 int reg, count;
3605 3672
3606 /* 3673 /*
@@ -3690,15 +3757,15 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3690 unsigned int reg; 3757 unsigned int reg;
3691 int ret, i; 3758 int ret, i;
3692 3759
3693 wm8994->codec = codec; 3760 wm8994->hubs.codec = codec;
3694 codec->control_data = control->regmap; 3761 codec->control_data = control->regmap;
3695 3762
3696 snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP); 3763 snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
3697 3764
3698 wm8994->codec = codec;
3699
3700 mutex_init(&wm8994->accdet_lock); 3765 mutex_init(&wm8994->accdet_lock);
3701 INIT_DELAYED_WORK(&wm8994->mic_work, wm8994_mic_work); 3766 INIT_DELAYED_WORK(&wm8994->mic_work, wm8994_mic_work);
3767 INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap,
3768 wm1811_jackdet_bootstrap);
3702 3769
3703 for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) 3770 for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++)
3704 init_completion(&wm8994->fll_locked[i]); 3771 init_completion(&wm8994->fll_locked[i]);
@@ -3756,14 +3823,17 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3756 wm8994->hubs.no_cache_dac_hp_direct = true; 3823 wm8994->hubs.no_cache_dac_hp_direct = true;
3757 wm8994->fll_byp = true; 3824 wm8994->fll_byp = true;
3758 3825
3759 switch (wm8994->revision) { 3826 switch (control->cust_id) {
3760 case 0: 3827 case 0:
3761 case 1:
3762 case 2: 3828 case 2:
3763 case 3:
3764 wm8994->hubs.dcs_codes_l = -9; 3829 wm8994->hubs.dcs_codes_l = -9;
3765 wm8994->hubs.dcs_codes_r = -7; 3830 wm8994->hubs.dcs_codes_r = -7;
3766 break; 3831 break;
3832 case 1:
3833 case 3:
3834 wm8994->hubs.dcs_codes_l = -8;
3835 wm8994->hubs.dcs_codes_r = -7;
3836 break;
3767 default: 3837 default:
3768 break; 3838 break;
3769 } 3839 }
@@ -3852,7 +3922,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3852 3922
3853 switch (control->type) { 3923 switch (control->type) {
3854 case WM1811: 3924 case WM1811:
3855 if (wm8994->revision > 1) { 3925 if (control->cust_id > 1 || wm8994->revision > 1) {
3856 ret = wm8994_request_irq(wm8994->wm8994, 3926 ret = wm8994_request_irq(wm8994->wm8994,
3857 WM8994_IRQ_GPIO(6), 3927 WM8994_IRQ_GPIO(6),
3858 wm1811_jackdet_irq, "JACKDET", 3928 wm1811_jackdet_irq, "JACKDET",
diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h
index d77e06f0a675..f142ec198db3 100644
--- a/sound/soc/codecs/wm8994.h
+++ b/sound/soc/codecs/wm8994.h
@@ -28,10 +28,11 @@
28#define WM8994_FLL1 1 28#define WM8994_FLL1 1
29#define WM8994_FLL2 2 29#define WM8994_FLL2 2
30 30
31#define WM8994_FLL_SRC_MCLK1 1 31#define WM8994_FLL_SRC_MCLK1 1
32#define WM8994_FLL_SRC_MCLK2 2 32#define WM8994_FLL_SRC_MCLK2 2
33#define WM8994_FLL_SRC_LRCLK 3 33#define WM8994_FLL_SRC_LRCLK 3
34#define WM8994_FLL_SRC_BCLK 4 34#define WM8994_FLL_SRC_BCLK 4
35#define WM8994_FLL_SRC_INTERNAL 5
35 36
36enum wm8994_vmid_mode { 37enum wm8994_vmid_mode {
37 WM8994_VMID_NORMAL, 38 WM8994_VMID_NORMAL,
@@ -72,7 +73,6 @@ struct wm8994;
72struct wm8994_priv { 73struct wm8994_priv {
73 struct wm_hubs_data hubs; 74 struct wm_hubs_data hubs;
74 struct wm8994 *wm8994; 75 struct wm8994 *wm8994;
75 struct snd_soc_codec *codec;
76 int sysclk[2]; 76 int sysclk[2];
77 int sysclk_rate[2]; 77 int sysclk_rate[2];
78 int mclk[2]; 78 int mclk[2];
@@ -81,6 +81,7 @@ struct wm8994_priv {
81 struct completion fll_locked[2]; 81 struct completion fll_locked[2];
82 bool fll_locked_irq; 82 bool fll_locked_irq;
83 bool fll_byp; 83 bool fll_byp;
84 bool clk_has_run;
84 85
85 int vmid_refcount; 86 int vmid_refcount;
86 int active_refcount; 87 int active_refcount;
@@ -134,6 +135,7 @@ struct wm8994_priv {
134 int btn_mask; 135 int btn_mask;
135 bool jackdet; 136 bool jackdet;
136 int jackdet_mode; 137 int jackdet_mode;
138 struct delayed_work jackdet_bootstrap;
137 139
138 wm8958_micdet_cb jack_cb; 140 wm8958_micdet_cb jack_cb;
139 void *jack_cb_data; 141 void *jack_cb_data;
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c
index 00f183dfa454..6dcb02c3666f 100644
--- a/sound/soc/codecs/wm8996.c
+++ b/sound/soc/codecs/wm8996.c
@@ -931,7 +931,7 @@ SND_SOC_DAPM_INPUT("IN2RP"),
931SND_SOC_DAPM_INPUT("DMIC1DAT"), 931SND_SOC_DAPM_INPUT("DMIC1DAT"),
932SND_SOC_DAPM_INPUT("DMIC2DAT"), 932SND_SOC_DAPM_INPUT("DMIC2DAT"),
933 933
934SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20), 934SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
935SND_SOC_DAPM_SUPPLY_S("SYSCLK", 1, WM8996_AIF_CLOCKING_1, 0, 0, NULL, 0), 935SND_SOC_DAPM_SUPPLY_S("SYSCLK", 1, WM8996_AIF_CLOCKING_1, 0, 0, NULL, 0),
936SND_SOC_DAPM_SUPPLY_S("SYSDSPCLK", 2, WM8996_CLOCKING_1, 1, 0, NULL, 0), 936SND_SOC_DAPM_SUPPLY_S("SYSDSPCLK", 2, WM8996_CLOCKING_1, 1, 0, NULL, 0),
937SND_SOC_DAPM_SUPPLY_S("AIFCLK", 2, WM8996_CLOCKING_1, 2, 0, NULL, 0), 937SND_SOC_DAPM_SUPPLY_S("AIFCLK", 2, WM8996_CLOCKING_1, 2, 0, NULL, 0),
diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c
index 2c2346fdd637..c7ddc56175d1 100644
--- a/sound/soc/codecs/wm9090.c
+++ b/sound/soc/codecs/wm9090.c
@@ -695,17 +695,7 @@ static struct i2c_driver wm9090_i2c_driver = {
695 .id_table = wm9090_id, 695 .id_table = wm9090_id,
696}; 696};
697 697
698static int __init wm9090_init(void) 698module_i2c_driver(wm9090_i2c_driver);
699{
700 return i2c_add_driver(&wm9090_i2c_driver);
701}
702module_init(wm9090_init);
703
704static void __exit wm9090_exit(void)
705{
706 i2c_del_driver(&wm9090_i2c_driver);
707}
708module_exit(wm9090_exit);
709 699
710MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 700MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
711MODULE_DESCRIPTION("WM9090 ASoC driver"); 701MODULE_DESCRIPTION("WM9090 ASoC driver");
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index c6d2076a796b..4dd73ea08d0b 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -132,8 +132,9 @@ SOC_SINGLE("Aux Playback Phone Volume", AC97_CD, 4, 7, 1),
132SOC_SINGLE("Phone Volume", AC97_PHONE, 0, 15, 1), 132SOC_SINGLE("Phone Volume", AC97_PHONE, 0, 15, 1),
133SOC_DOUBLE("Line Capture Volume", AC97_LINE, 8, 0, 31, 1), 133SOC_DOUBLE("Line Capture Volume", AC97_LINE, 8, 0, 31, 1),
134 134
135SOC_SINGLE("Capture 20dB Boost Switch", AC97_REC_SEL, 14, 1, 0), 135SOC_SINGLE_TLV("Capture Boost Switch", AC97_REC_SEL, 14, 1, 0, boost_tlv),
136SOC_SINGLE("Capture to Phone 20dB Boost Switch", AC97_REC_SEL, 11, 1, 1), 136SOC_SINGLE_TLV("Capture to Phone Boost Switch", AC97_REC_SEL, 11, 1, 1,
137 boost_tlv),
137 138
138SOC_SINGLE("3D Upper Cut-off Switch", AC97_3D_CONTROL, 5, 1, 1), 139SOC_SINGLE("3D Upper Cut-off Switch", AC97_3D_CONTROL, 5, 1, 1),
139SOC_SINGLE("3D Lower Cut-off Switch", AC97_3D_CONTROL, 4, 1, 1), 140SOC_SINGLE("3D Lower Cut-off Switch", AC97_3D_CONTROL, 4, 1, 1),
@@ -146,7 +147,7 @@ SOC_SINGLE("Playback Attenuate (-6dB) Switch", AC97_MASTER_TONE, 6, 1, 0),
146SOC_SINGLE("Bass Volume", AC97_MASTER_TONE, 8, 15, 1), 147SOC_SINGLE("Bass Volume", AC97_MASTER_TONE, 8, 15, 1),
147SOC_SINGLE("Treble Volume", AC97_MASTER_TONE, 0, 15, 1), 148SOC_SINGLE("Treble Volume", AC97_MASTER_TONE, 0, 15, 1),
148 149
149SOC_SINGLE("Capture ADC Switch", AC97_REC_GAIN, 15, 1, 1), 150SOC_SINGLE("Capture Switch", AC97_REC_GAIN, 15, 1, 1),
150SOC_ENUM("Capture Volume Steps", wm9712_enum[6]), 151SOC_ENUM("Capture Volume Steps", wm9712_enum[6]),
151SOC_DOUBLE("Capture Volume", AC97_REC_GAIN, 8, 0, 63, 0), 152SOC_DOUBLE("Capture Volume", AC97_REC_GAIN, 8, 0, 63, 0),
152SOC_SINGLE("Capture ZC Switch", AC97_REC_GAIN, 7, 1, 0), 153SOC_SINGLE("Capture ZC Switch", AC97_REC_GAIN, 7, 1, 0),
@@ -634,7 +635,6 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
634{ 635{
635 int ret = 0; 636 int ret = 0;
636 637
637 codec->control_data = codec; /* we don't use regmap! */
638 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); 638 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
639 if (ret < 0) { 639 if (ret < 0) {
640 printk(KERN_ERR "wm9712: failed to register AC97 codec\n"); 640 printk(KERN_ERR "wm9712: failed to register AC97 codec\n");
@@ -699,8 +699,8 @@ static int __devexit wm9712_remove(struct platform_device *pdev)
699 699
700static struct platform_driver wm9712_codec_driver = { 700static struct platform_driver wm9712_codec_driver = {
701 .driver = { 701 .driver = {
702 .name = "wm9712-codec", 702 .name = "wm9712-codec",
703 .owner = THIS_MODULE, 703 .owner = THIS_MODULE,
704 }, 704 },
705 705
706 .probe = wm9712_probe, 706 .probe = wm9712_probe,
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
index d0b8a3287a85..3eb19fb71d17 100644
--- a/sound/soc/codecs/wm9713.c
+++ b/sound/soc/codecs/wm9713.c
@@ -1196,7 +1196,6 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
1196 if (wm9713 == NULL) 1196 if (wm9713 == NULL)
1197 return -ENOMEM; 1197 return -ENOMEM;
1198 snd_soc_codec_set_drvdata(codec, wm9713); 1198 snd_soc_codec_set_drvdata(codec, wm9713);
1199 codec->control_data = wm9713; /* we don't use regmap! */
1200 1199
1201 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); 1200 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
1202 if (ret < 0) 1201 if (ret < 0)
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index 61baa48823cb..7a773a835b8e 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -199,15 +199,56 @@ static void wm_hubs_dcs_cache_set(struct snd_soc_codec *codec, u16 dcs_cfg)
199 list_add_tail(&cache->list, &hubs->dcs_cache); 199 list_add_tail(&cache->list, &hubs->dcs_cache);
200} 200}
201 201
202static void wm_hubs_read_dc_servo(struct snd_soc_codec *codec,
203 u16 *reg_l, u16 *reg_r)
204{
205 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
206 u16 dcs_reg, reg;
207
208 switch (hubs->dcs_readback_mode) {
209 case 2:
210 dcs_reg = WM8994_DC_SERVO_4E;
211 break;
212 case 1:
213 dcs_reg = WM8994_DC_SERVO_READBACK;
214 break;
215 default:
216 dcs_reg = WM8993_DC_SERVO_3;
217 break;
218 }
219
220 /* Different chips in the family support different readback
221 * methods.
222 */
223 switch (hubs->dcs_readback_mode) {
224 case 0:
225 *reg_l = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1)
226 & WM8993_DCS_INTEG_CHAN_0_MASK;
227 *reg_r = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2)
228 & WM8993_DCS_INTEG_CHAN_1_MASK;
229 break;
230 case 2:
231 case 1:
232 reg = snd_soc_read(codec, dcs_reg);
233 *reg_r = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK)
234 >> WM8993_DCS_DAC_WR_VAL_1_SHIFT;
235 *reg_l = reg & WM8993_DCS_DAC_WR_VAL_0_MASK;
236 break;
237 default:
238 WARN(1, "Unknown DCS readback method\n");
239 return;
240 }
241}
242
202/* 243/*
203 * Startup calibration of the DC servo 244 * Startup calibration of the DC servo
204 */ 245 */
205static void calibrate_dc_servo(struct snd_soc_codec *codec) 246static void enable_dc_servo(struct snd_soc_codec *codec)
206{ 247{
207 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); 248 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
208 struct wm_hubs_dcs_cache *cache; 249 struct wm_hubs_dcs_cache *cache;
209 s8 offset; 250 s8 offset;
210 u16 reg, reg_l, reg_r, dcs_cfg, dcs_reg; 251 u16 reg_l, reg_r, dcs_cfg, dcs_reg;
211 252
212 switch (hubs->dcs_readback_mode) { 253 switch (hubs->dcs_readback_mode) {
213 case 2: 254 case 2:
@@ -245,27 +286,7 @@ static void calibrate_dc_servo(struct snd_soc_codec *codec)
245 WM8993_DCS_TRIG_STARTUP_1); 286 WM8993_DCS_TRIG_STARTUP_1);
246 } 287 }
247 288
248 /* Different chips in the family support different readback 289 wm_hubs_read_dc_servo(codec, &reg_l, &reg_r);
249 * methods.
250 */
251 switch (hubs->dcs_readback_mode) {
252 case 0:
253 reg_l = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1)
254 & WM8993_DCS_INTEG_CHAN_0_MASK;
255 reg_r = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2)
256 & WM8993_DCS_INTEG_CHAN_1_MASK;
257 break;
258 case 2:
259 case 1:
260 reg = snd_soc_read(codec, dcs_reg);
261 reg_r = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK)
262 >> WM8993_DCS_DAC_WR_VAL_1_SHIFT;
263 reg_l = reg & WM8993_DCS_DAC_WR_VAL_0_MASK;
264 break;
265 default:
266 WARN(1, "Unknown DCS readback method\n");
267 return;
268 }
269 290
270 dev_dbg(codec->dev, "DCS input: %x %x\n", reg_l, reg_r); 291 dev_dbg(codec->dev, "DCS input: %x %x\n", reg_l, reg_r);
271 292
@@ -276,12 +297,16 @@ static void calibrate_dc_servo(struct snd_soc_codec *codec)
276 hubs->dcs_codes_l, hubs->dcs_codes_r); 297 hubs->dcs_codes_l, hubs->dcs_codes_r);
277 298
278 /* HPOUT1R */ 299 /* HPOUT1R */
279 offset = reg_r; 300 offset = (s8)reg_r;
301 dev_dbg(codec->dev, "DCS right %d->%d\n", offset,
302 offset + hubs->dcs_codes_r);
280 offset += hubs->dcs_codes_r; 303 offset += hubs->dcs_codes_r;
281 dcs_cfg = (u8)offset << WM8993_DCS_DAC_WR_VAL_1_SHIFT; 304 dcs_cfg = (u8)offset << WM8993_DCS_DAC_WR_VAL_1_SHIFT;
282 305
283 /* HPOUT1L */ 306 /* HPOUT1L */
284 offset = reg_l; 307 offset = (s8)reg_l;
308 dev_dbg(codec->dev, "DCS left %d->%d\n", offset,
309 offset + hubs->dcs_codes_l);
285 offset += hubs->dcs_codes_l; 310 offset += hubs->dcs_codes_l;
286 dcs_cfg |= (u8)offset; 311 dcs_cfg |= (u8)offset;
287 312
@@ -535,7 +560,7 @@ static int hp_event(struct snd_soc_dapm_widget *w,
535 snd_soc_update_bits(codec, WM8993_DC_SERVO_1, 560 snd_soc_update_bits(codec, WM8993_DC_SERVO_1,
536 WM8993_DCS_TIMER_PERIOD_01_MASK, 0); 561 WM8993_DCS_TIMER_PERIOD_01_MASK, 0);
537 562
538 calibrate_dc_servo(codec); 563 enable_dc_servo(codec);
539 564
540 reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT | 565 reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT |
541 WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT; 566 WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT;
@@ -619,6 +644,28 @@ static int lineout_event(struct snd_soc_dapm_widget *w,
619 return 0; 644 return 0;
620} 645}
621 646
647static int micbias_event(struct snd_soc_dapm_widget *w,
648 struct snd_kcontrol *kcontrol, int event)
649{
650 struct snd_soc_codec *codec = w->codec;
651 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
652
653 switch (w->shift) {
654 case WM8993_MICB1_ENA_SHIFT:
655 if (hubs->micb1_delay)
656 msleep(hubs->micb1_delay);
657 break;
658 case WM8993_MICB2_ENA_SHIFT:
659 if (hubs->micb2_delay)
660 msleep(hubs->micb2_delay);
661 break;
662 default:
663 return -EINVAL;
664 }
665
666 return 0;
667}
668
622void wm_hubs_update_class_w(struct snd_soc_codec *codec) 669void wm_hubs_update_class_w(struct snd_soc_codec *codec)
623{ 670{
624 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); 671 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
@@ -809,8 +856,10 @@ SND_SOC_DAPM_INPUT("IN1RP"),
809SND_SOC_DAPM_INPUT("IN2RN"), 856SND_SOC_DAPM_INPUT("IN2RN"),
810SND_SOC_DAPM_INPUT("IN2RP:VXRP"), 857SND_SOC_DAPM_INPUT("IN2RP:VXRP"),
811 858
812SND_SOC_DAPM_SUPPLY("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0, NULL, 0), 859SND_SOC_DAPM_SUPPLY("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0,
813SND_SOC_DAPM_SUPPLY("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0, NULL, 0), 860 micbias_event, SND_SOC_DAPM_POST_PMU),
861SND_SOC_DAPM_SUPPLY("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0,
862 micbias_event, SND_SOC_DAPM_POST_PMU),
814 863
815SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0, 864SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0,
816 in1l_pga, ARRAY_SIZE(in1l_pga)), 865 in1l_pga, ARRAY_SIZE(in1l_pga)),
@@ -1112,6 +1161,8 @@ int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec,
1112 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); 1161 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
1113 struct snd_soc_dapm_context *dapm = &codec->dapm; 1162 struct snd_soc_dapm_context *dapm = &codec->dapm;
1114 1163
1164 hubs->codec = codec;
1165
1115 INIT_LIST_HEAD(&hubs->dcs_cache); 1166 INIT_LIST_HEAD(&hubs->dcs_cache);
1116 init_completion(&hubs->dcs_done); 1167 init_completion(&hubs->dcs_done);
1117 1168
@@ -1143,13 +1194,16 @@ EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes);
1143int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, 1194int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec,
1144 int lineout1_diff, int lineout2_diff, 1195 int lineout1_diff, int lineout2_diff,
1145 int lineout1fb, int lineout2fb, 1196 int lineout1fb, int lineout2fb,
1146 int jd_scthr, int jd_thr, int micbias1_lvl, 1197 int jd_scthr, int jd_thr,
1147 int micbias2_lvl) 1198 int micbias1_delay, int micbias2_delay,
1199 int micbias1_lvl, int micbias2_lvl)
1148{ 1200{
1149 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); 1201 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
1150 1202
1151 hubs->lineout1_se = !lineout1_diff; 1203 hubs->lineout1_se = !lineout1_diff;
1152 hubs->lineout2_se = !lineout2_diff; 1204 hubs->lineout2_se = !lineout2_diff;
1205 hubs->micb1_delay = micbias1_delay;
1206 hubs->micb2_delay = micbias2_delay;
1153 1207
1154 if (!lineout1_diff) 1208 if (!lineout1_diff)
1155 snd_soc_update_bits(codec, WM8993_LINE_MIXER1, 1209 snd_soc_update_bits(codec, WM8993_LINE_MIXER1,
diff --git a/sound/soc/codecs/wm_hubs.h b/sound/soc/codecs/wm_hubs.h
index da2dc899ce6d..24c763df21f9 100644
--- a/sound/soc/codecs/wm_hubs.h
+++ b/sound/soc/codecs/wm_hubs.h
@@ -36,6 +36,9 @@ struct wm_hubs_data {
36 struct list_head dcs_cache; 36 struct list_head dcs_cache;
37 bool (*check_class_w_digital)(struct snd_soc_codec *); 37 bool (*check_class_w_digital)(struct snd_soc_codec *);
38 38
39 int micb1_delay;
40 int micb2_delay;
41
39 bool lineout1_se; 42 bool lineout1_se;
40 bool lineout1n_ena; 43 bool lineout1n_ena;
41 bool lineout1p_ena; 44 bool lineout1p_ena;
@@ -46,6 +49,8 @@ struct wm_hubs_data {
46 49
47 bool dcs_done_irq; 50 bool dcs_done_irq;
48 struct completion dcs_done; 51 struct completion dcs_done;
52
53 struct snd_soc_codec *codec;
49}; 54};
50 55
51extern int wm_hubs_add_analogue_controls(struct snd_soc_codec *); 56extern int wm_hubs_add_analogue_controls(struct snd_soc_codec *);
@@ -54,6 +59,7 @@ extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *,
54 int lineout1_diff, int lineout2_diff, 59 int lineout1_diff, int lineout2_diff,
55 int lineout1fb, int lineout2fb, 60 int lineout1fb, int lineout2fb,
56 int jd_scthr, int jd_thr, 61 int jd_scthr, int jd_thr,
62 int micbias1_dly, int micbias2_dly,
57 int micbias1_lvl, int micbias2_lvl); 63 int micbias1_lvl, int micbias2_lvl);
58 64
59extern irqreturn_t wm_hubs_dcs_done(int irq, void *data); 65extern irqreturn_t wm_hubs_dcs_done(int irq, void *data);