aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-10-24 06:24:08 -0400
committerMark Brown <broonie@linaro.org>2013-10-24 06:24:08 -0400
commited87aabf6078ee1169c04ee9da54f03e10cbd8a3 (patch)
tree24b66d5f8070d761360058d3a0cae2dc09d268bd
parent4131770d540820c9514ccd3cf363daba9c902882 (diff)
parent068416620c0d956b3b382d19dd3000119e280f8c (diff)
Merge remote-tracking branch 'asoc/topic/max9850' into asoc-next
-rw-r--r--sound/soc/codecs/max9850.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c
index 58c38a5b481c..c5dd61785f8d 100644
--- a/sound/soc/codecs/max9850.c
+++ b/sound/soc/codecs/max9850.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/regmap.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
23#include <sound/pcm_params.h> 24#include <sound/pcm_params.h>
@@ -27,18 +28,26 @@
27#include "max9850.h" 28#include "max9850.h"
28 29
29struct max9850_priv { 30struct max9850_priv {
31 struct regmap *regmap;
30 unsigned int sysclk; 32 unsigned int sysclk;
31}; 33};
32 34
33/* max9850 register cache */ 35/* max9850 register cache */
34static const u8 max9850_reg[MAX9850_CACHEREGNUM] = { 36static const struct reg_default max9850_reg[] = {
35 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 37 { 2, 0x0c },
38 { 3, 0x00 },
39 { 4, 0x00 },
40 { 5, 0x00 },
41 { 6, 0x00 },
42 { 7, 0x00 },
43 { 8, 0x00 },
44 { 9, 0x00 },
45 { 10, 0x00 },
36}; 46};
37 47
38/* these registers are not used at the moment but provided for the sake of 48/* these registers are not used at the moment but provided for the sake of
39 * completeness */ 49 * completeness */
40static int max9850_volatile_register(struct snd_soc_codec *codec, 50static bool max9850_volatile_register(struct device *dev, unsigned int reg)
41 unsigned int reg)
42{ 51{
43 switch (reg) { 52 switch (reg) {
44 case MAX9850_STATUSA: 53 case MAX9850_STATUSA:
@@ -49,6 +58,15 @@ static int max9850_volatile_register(struct snd_soc_codec *codec,
49 } 58 }
50} 59}
51 60
61static const struct regmap_config max9850_regmap = {
62 .reg_bits = 8,
63 .val_bits = 8,
64
65 .max_register = MAX9850_DIGITAL_AUDIO,
66 .volatile_reg = max9850_volatile_register,
67 .cache_type = REGCACHE_RBTREE,
68};
69
52static const unsigned int max9850_tlv[] = { 70static const unsigned int max9850_tlv[] = {
53 TLV_DB_RANGE_HEAD(4), 71 TLV_DB_RANGE_HEAD(4),
54 0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0), 72 0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0),
@@ -225,6 +243,7 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
225static int max9850_set_bias_level(struct snd_soc_codec *codec, 243static int max9850_set_bias_level(struct snd_soc_codec *codec,
226 enum snd_soc_bias_level level) 244 enum snd_soc_bias_level level)
227{ 245{
246 struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec);
228 int ret; 247 int ret;
229 248
230 switch (level) { 249 switch (level) {
@@ -234,7 +253,7 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec,
234 break; 253 break;
235 case SND_SOC_BIAS_STANDBY: 254 case SND_SOC_BIAS_STANDBY:
236 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 255 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
237 ret = snd_soc_cache_sync(codec); 256 ret = regcache_sync(max9850->regmap);
238 if (ret) { 257 if (ret) {
239 dev_err(codec->dev, 258 dev_err(codec->dev,
240 "Failed to sync cache: %d\n", ret); 259 "Failed to sync cache: %d\n", ret);
@@ -295,7 +314,7 @@ static int max9850_probe(struct snd_soc_codec *codec)
295{ 314{
296 int ret; 315 int ret;
297 316
298 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); 317 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
299 if (ret < 0) { 318 if (ret < 0) {
300 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 319 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
301 return ret; 320 return ret;
@@ -316,10 +335,6 @@ static struct snd_soc_codec_driver soc_codec_dev_max9850 = {
316 .suspend = max9850_suspend, 335 .suspend = max9850_suspend,
317 .resume = max9850_resume, 336 .resume = max9850_resume,
318 .set_bias_level = max9850_set_bias_level, 337 .set_bias_level = max9850_set_bias_level,
319 .reg_cache_size = ARRAY_SIZE(max9850_reg),
320 .reg_word_size = sizeof(u8),
321 .reg_cache_default = max9850_reg,
322 .volatile_register = max9850_volatile_register,
323 338
324 .controls = max9850_controls, 339 .controls = max9850_controls,
325 .num_controls = ARRAY_SIZE(max9850_controls), 340 .num_controls = ARRAY_SIZE(max9850_controls),
@@ -340,6 +355,10 @@ static int max9850_i2c_probe(struct i2c_client *i2c,
340 if (max9850 == NULL) 355 if (max9850 == NULL)
341 return -ENOMEM; 356 return -ENOMEM;
342 357
358 max9850->regmap = devm_regmap_init_i2c(i2c, &max9850_regmap);
359 if (IS_ERR(max9850->regmap))
360 return PTR_ERR(max9850->regmap);
361
343 i2c_set_clientdata(i2c, max9850); 362 i2c_set_clientdata(i2c, max9850);
344 363
345 ret = snd_soc_register_codec(&i2c->dev, 364 ret = snd_soc_register_codec(&i2c->dev,