Skip to content

Commit e40e0b5

Browse files
committed
ASoC: wm8974: Convert to direct regmap API usage
Moves us towards removing the ASoC level I/O functions. Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
1 parent 6ce4eac commit e40e0b5

1 file changed

Lines changed: 33 additions & 21 deletions

File tree

‎sound/soc/codecs/wm8974.c‎

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/delay.h>
1818
#include <linux/pm.h>
1919
#include <linux/i2c.h>
20+
#include <linux/regmap.h>
2021
#include <linux/slab.h>
2122
#include <sound/core.h>
2223
#include <sound/pcm.h>
@@ -27,22 +28,22 @@
2728

2829
#include "wm8974.h"
2930

30-
static const u16 wm8974_reg[WM8974_CACHEREGNUM] = {
31-
0x0000, 0x0000, 0x0000, 0x0000,
32-
0x0050, 0x0000, 0x0140, 0x0000,
33-
0x0000, 0x0000, 0x0000, 0x00ff,
34-
0x0000, 0x0000, 0x0100, 0x00ff,
35-
0x0000, 0x0000, 0x012c, 0x002c,
36-
0x002c, 0x002c, 0x002c, 0x0000,
37-
0x0032, 0x0000, 0x0000, 0x0000,
38-
0x0000, 0x0000, 0x0000, 0x0000,
39-
0x0038, 0x000b, 0x0032, 0x0000,
40-
0x0008, 0x000c, 0x0093, 0x00e9,
41-
0x0000, 0x0000, 0x0000, 0x0000,
42-
0x0003, 0x0010, 0x0000, 0x0000,
43-
0x0000, 0x0002, 0x0000, 0x0000,
44-
0x0000, 0x0000, 0x0039, 0x0000,
45-
0x0000,
31+
static const struct reg_default wm8974_reg_defaults[] = {
32+
{ 0, 0x0000 }, { 1, 0x0000 }, { 2, 0x0000 }, { 3, 0x0000 },
33+
{ 4, 0x0050 }, { 5, 0x0000 }, { 6, 0x0140 }, { 7, 0x0000 },
34+
{ 8, 0x0000 }, { 9, 0x0000 }, { 10, 0x0000 }, { 11, 0x00ff },
35+
{ 12, 0x0000 }, { 13, 0x0000 }, { 14, 0x0100 }, { 15, 0x00ff },
36+
{ 16, 0x0000 }, { 17, 0x0000 }, { 18, 0x012c }, { 19, 0x002c },
37+
{ 20, 0x002c }, { 21, 0x002c }, { 22, 0x002c }, { 23, 0x0000 },
38+
{ 24, 0x0032 }, { 25, 0x0000 }, { 26, 0x0000 }, { 27, 0x0000 },
39+
{ 28, 0x0000 }, { 29, 0x0000 }, { 30, 0x0000 }, { 31, 0x0000 },
40+
{ 32, 0x0038 }, { 33, 0x000b }, { 34, 0x0032 }, { 35, 0x0000 },
41+
{ 36, 0x0008 }, { 37, 0x000c }, { 38, 0x0093 }, { 39, 0x00e9 },
42+
{ 40, 0x0000 }, { 41, 0x0000 }, { 42, 0x0000 }, { 43, 0x0000 },
43+
{ 44, 0x0003 }, { 45, 0x0010 }, { 46, 0x0000 }, { 47, 0x0000 },
44+
{ 48, 0x0000 }, { 49, 0x0002 }, { 50, 0x0000 }, { 51, 0x0000 },
45+
{ 52, 0x0000 }, { 53, 0x0000 }, { 54, 0x0039 }, { 55, 0x0000 },
46+
{ 56, 0x0000 },
4647
};
4748

4849
#define WM8974_POWER1_BIASEN 0x08
@@ -514,7 +515,7 @@ static int wm8974_set_bias_level(struct snd_soc_codec *codec,
514515
power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN;
515516

516517
if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
517-
snd_soc_cache_sync(codec);
518+
regcache_sync(dev_get_regmap(codec->dev, NULL));
518519

519520
/* Initial cap charge at VMID 5k */
520521
snd_soc_write(codec, WM8974_POWER1, power1 | 0x3);
@@ -579,11 +580,20 @@ static int wm8974_resume(struct snd_soc_codec *codec)
579580
return 0;
580581
}
581582

583+
static 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+
582592
static int wm8974_probe(struct snd_soc_codec *codec)
583593
{
584594
int ret = 0;
585595

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);
587597
if (ret < 0) {
588598
dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
589599
return ret;
@@ -613,9 +623,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8974 = {
613623
.suspend = wm8974_suspend,
614624
.resume = wm8974_resume,
615625
.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,
619626

620627
.controls = wm8974_snd_controls,
621628
.num_controls = ARRAY_SIZE(wm8974_snd_controls),
@@ -628,8 +635,13 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8974 = {
628635
static int wm8974_i2c_probe(struct i2c_client *i2c,
629636
const struct i2c_device_id *id)
630637
{
638+
struct regmap *regmap;
631639
int ret;
632640

641+
regmap = devm_regmap_init_i2c(i2c, &wm8974_regmap);
642+
if (IS_ERR(regmap))
643+
return PTR_ERR(regmap);
644+
633645
ret = snd_soc_register_codec(&i2c->dev,
634646
&soc_codec_dev_wm8974, &wm8974_dai, 1);
635647

0 commit comments

Comments
 (0)