aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8974.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/wm8974.c')
-rw-r--r--sound/soc/codecs/wm8974.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c
index a2d01d10a5dd..15f45c7bd833 100644
--- a/sound/soc/codecs/wm8974.c
+++ b/sound/soc/codecs/wm8974.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/slab.h> 21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
@@ -27,22 +28,22 @@
27 28
28#include "wm8974.h" 29#include "wm8974.h"
29 30
30static const u16 wm8974_reg[WM8974_CACHEREGNUM] = { 31static const struct reg_default wm8974_reg_defaults[] = {
31 0x0000, 0x0000, 0x0000, 0x0000, 32 { 0, 0x0000 }, { 1, 0x0000 }, { 2, 0x0000 }, { 3, 0x0000 },
32 0x0050, 0x0000, 0x0140, 0x0000, 33 { 4, 0x0050 }, { 5, 0x0000 }, { 6, 0x0140 }, { 7, 0x0000 },
33 0x0000, 0x0000, 0x0000, 0x00ff, 34 { 8, 0x0000 }, { 9, 0x0000 }, { 10, 0x0000 }, { 11, 0x00ff },
34 0x0000, 0x0000, 0x0100, 0x00ff, 35 { 12, 0x0000 }, { 13, 0x0000 }, { 14, 0x0100 }, { 15, 0x00ff },
35 0x0000, 0x0000, 0x012c, 0x002c, 36 { 16, 0x0000 }, { 17, 0x0000 }, { 18, 0x012c }, { 19, 0x002c },
36 0x002c, 0x002c, 0x002c, 0x0000, 37 { 20, 0x002c }, { 21, 0x002c }, { 22, 0x002c }, { 23, 0x0000 },
37 0x0032, 0x0000, 0x0000, 0x0000, 38 { 24, 0x0032 }, { 25, 0x0000 }, { 26, 0x0000 }, { 27, 0x0000 },
38 0x0000, 0x0000, 0x0000, 0x0000, 39 { 28, 0x0000 }, { 29, 0x0000 }, { 30, 0x0000 }, { 31, 0x0000 },
39 0x0038, 0x000b, 0x0032, 0x0000, 40 { 32, 0x0038 }, { 33, 0x000b }, { 34, 0x0032 }, { 35, 0x0000 },
40 0x0008, 0x000c, 0x0093, 0x00e9, 41 { 36, 0x0008 }, { 37, 0x000c }, { 38, 0x0093 }, { 39, 0x00e9 },
41 0x0000, 0x0000, 0x0000, 0x0000, 42 { 40, 0x0000 }, { 41, 0x0000 }, { 42, 0x0000 }, { 43, 0x0000 },
42 0x0003, 0x0010, 0x0000, 0x0000, 43 { 44, 0x0003 }, { 45, 0x0010 }, { 46, 0x0000 }, { 47, 0x0000 },
43 0x0000, 0x0002, 0x0000, 0x0000, 44 { 48, 0x0000 }, { 49, 0x0002 }, { 50, 0x0000 }, { 51, 0x0000 },
44 0x0000, 0x0000, 0x0039, 0x0000, 45 { 52, 0x0000 }, { 53, 0x0000 }, { 54, 0x0039 }, { 55, 0x0000 },
45 0x0000, 46 { 56, 0x0000 },
46}; 47};
47 48
48#define WM8974_POWER1_BIASEN 0x08 49#define WM8974_POWER1_BIASEN 0x08
@@ -514,7 +515,7 @@ static int wm8974_set_bias_level(struct snd_soc_codec *codec,
514 power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; 515 power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN;
515 516
516 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 517 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
517 snd_soc_cache_sync(codec); 518 regcache_sync(dev_get_regmap(codec->dev, NULL));
518 519
519 /* Initial cap charge at VMID 5k */ 520 /* Initial cap charge at VMID 5k */
520 snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); 521 snd_soc_write(codec, WM8974_POWER1, power1 | 0x3);
@@ -579,11 +580,20 @@ static int wm8974_resume(struct snd_soc_codec *codec)
579 return 0; 580 return 0;
580} 581}
581 582
583static const struct regmap_config wm8974_regmap = {
584 .reg_bits = 7,
585 .val_bits = 9,
586
587 .max_register = WM8974_MONOMIX,
588 .reg_defaults = wm8974_reg_defaults,
589 .num_reg_defaults = ARRAY_SIZE(wm8974_reg_defaults),
590};
591
582static int wm8974_probe(struct snd_soc_codec *codec) 592static int wm8974_probe(struct snd_soc_codec *codec)
583{ 593{
584 int ret = 0; 594 int ret = 0;
585 595
586 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_I2C); 596 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
587 if (ret < 0) { 597 if (ret < 0) {
588 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 598 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
589 return ret; 599 return ret;
@@ -613,9 +623,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8974 = {
613 .suspend = wm8974_suspend, 623 .suspend = wm8974_suspend,
614 .resume = wm8974_resume, 624 .resume = wm8974_resume,
615 .set_bias_level = wm8974_set_bias_level, 625 .set_bias_level = wm8974_set_bias_level,
616 .reg_cache_size = ARRAY_SIZE(wm8974_reg),
617 .reg_word_size = sizeof(u16),
618 .reg_cache_default = wm8974_reg,
619 626
620 .controls = wm8974_snd_controls, 627 .controls = wm8974_snd_controls,
621 .num_controls = ARRAY_SIZE(wm8974_snd_controls), 628 .num_controls = ARRAY_SIZE(wm8974_snd_controls),
@@ -628,8 +635,13 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8974 = {
628static int wm8974_i2c_probe(struct i2c_client *i2c, 635static int wm8974_i2c_probe(struct i2c_client *i2c,
629 const struct i2c_device_id *id) 636 const struct i2c_device_id *id)
630{ 637{
638 struct regmap *regmap;
631 int ret; 639 int ret;
632 640
641 regmap = devm_regmap_init_i2c(i2c, &wm8974_regmap);
642 if (IS_ERR(regmap))
643 return PTR_ERR(regmap);
644
633 ret = snd_soc_register_codec(&i2c->dev, 645 ret = snd_soc_register_codec(&i2c->dev,
634 &soc_codec_dev_wm8974, &wm8974_dai, 1); 646 &soc_codec_dev_wm8974, &wm8974_dai, 1);
635 647