aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/88pm860x-codec.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-09-19 14:00:46 -0400
committerMark Brown <broonie@linaro.org>2013-09-20 05:40:51 -0400
commitf9ded3b2e761256301ebb8d90e87eb1b5443e3ea (patch)
tree350d5d84ead373b43f23e76b53c2c207ae46fb80 /sound/soc/codecs/88pm860x-codec.c
parentfa129ebeba6db2b4bcea45efe87a71d68181c04c (diff)
ASoC: 88pm860x: Use regmap for I/O
As part of a move to remove the duplication of regmap functionality in ASoC convert the 88pm860x driver to use the regmap from the MFD. This means that we no longer cache the registers so performance will be slightly reduced on I/O operations. Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/codecs/88pm860x-codec.c')
-rw-r--r--sound/soc/codecs/88pm860x-codec.c60
1 files changed, 5 insertions, 55 deletions
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c
index 3925cf34f751..4633e51b1500 100644
--- a/sound/soc/codecs/88pm860x-codec.c
+++ b/sound/soc/codecs/88pm860x-codec.c
@@ -16,6 +16,7 @@
16#include <linux/mfd/88pm860x.h> 16#include <linux/mfd/88pm860x.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/regmap.h>
19#include <sound/core.h> 20#include <sound/core.h>
20#include <sound/pcm.h> 21#include <sound/pcm.h>
21#include <sound/pcm_params.h> 22#include <sound/pcm_params.h>
@@ -140,6 +141,7 @@ struct pm860x_priv {
140 unsigned int filter; 141 unsigned int filter;
141 struct snd_soc_codec *codec; 142 struct snd_soc_codec *codec;
142 struct i2c_client *i2c; 143 struct i2c_client *i2c;
144 struct regmap *regmap;
143 struct pm860x_chip *chip; 145 struct pm860x_chip *chip;
144 struct pm860x_det det; 146 struct pm860x_det det;
145 147
@@ -269,48 +271,6 @@ static struct st_gain st_table[] = {
269 { -86, 29, 0}, { -56, 30, 0}, { -28, 31, 0}, { 0, 0, 0}, 271 { -86, 29, 0}, { -56, 30, 0}, { -28, 31, 0}, { 0, 0, 0},
270}; 272};
271 273
272static int pm860x_volatile(unsigned int reg)
273{
274 BUG_ON(reg >= REG_CACHE_SIZE);
275
276 switch (reg) {
277 case PM860X_AUDIO_SUPPLIES_2:
278 return 1;
279 }
280
281 return 0;
282}
283
284static unsigned int pm860x_read_reg_cache(struct snd_soc_codec *codec,
285 unsigned int reg)
286{
287 unsigned char *cache = codec->reg_cache;
288
289 BUG_ON(reg >= REG_CACHE_SIZE);
290
291 if (pm860x_volatile(reg))
292 return cache[reg];
293
294 reg += REG_CACHE_BASE;
295
296 return pm860x_reg_read(codec->control_data, reg);
297}
298
299static int pm860x_write_reg_cache(struct snd_soc_codec *codec,
300 unsigned int reg, unsigned int value)
301{
302 unsigned char *cache = codec->reg_cache;
303
304 BUG_ON(reg >= REG_CACHE_SIZE);
305
306 if (!pm860x_volatile(reg))
307 cache[reg] = (unsigned char)value;
308
309 reg += REG_CACHE_BASE;
310
311 return pm860x_reg_write(codec->control_data, reg, value);
312}
313
314static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, 274static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol,
315 struct snd_ctl_elem_value *ucontrol) 275 struct snd_ctl_elem_value *ucontrol)
316{ 276{
@@ -1364,7 +1324,7 @@ static int pm860x_probe(struct snd_soc_codec *codec)
1364 1324
1365 pm860x->codec = codec; 1325 pm860x->codec = codec;
1366 1326
1367 codec->control_data = pm860x->i2c; 1327 codec->control_data = pm860x->regmap;
1368 1328
1369 for (i = 0; i < 4; i++) { 1329 for (i = 0; i < 4; i++) {
1370 ret = request_threaded_irq(pm860x->irq[i], NULL, 1330 ret = request_threaded_irq(pm860x->irq[i], NULL,
@@ -1378,14 +1338,6 @@ static int pm860x_probe(struct snd_soc_codec *codec)
1378 1338
1379 pm860x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1339 pm860x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1380 1340
1381 ret = pm860x_bulk_read(pm860x->i2c, REG_CACHE_BASE,
1382 REG_CACHE_SIZE, codec->reg_cache);
1383 if (ret < 0) {
1384 dev_err(codec->dev, "Failed to fill register cache: %d\n",
1385 ret);
1386 goto out;
1387 }
1388
1389 return 0; 1341 return 0;
1390 1342
1391out: 1343out:
@@ -1408,10 +1360,6 @@ static int pm860x_remove(struct snd_soc_codec *codec)
1408static struct snd_soc_codec_driver soc_codec_dev_pm860x = { 1360static struct snd_soc_codec_driver soc_codec_dev_pm860x = {
1409 .probe = pm860x_probe, 1361 .probe = pm860x_probe,
1410 .remove = pm860x_remove, 1362 .remove = pm860x_remove,
1411 .read = pm860x_read_reg_cache,
1412 .write = pm860x_write_reg_cache,
1413 .reg_cache_size = REG_CACHE_SIZE,
1414 .reg_word_size = sizeof(u8),
1415 .set_bias_level = pm860x_set_bias_level, 1363 .set_bias_level = pm860x_set_bias_level,
1416 1364
1417 .controls = pm860x_snd_controls, 1365 .controls = pm860x_snd_controls,
@@ -1437,6 +1385,8 @@ static int pm860x_codec_probe(struct platform_device *pdev)
1437 pm860x->chip = chip; 1385 pm860x->chip = chip;
1438 pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client 1386 pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client
1439 : chip->companion; 1387 : chip->companion;
1388 pm860x->regmap = (chip->id == CHIP_PM8607) ? chip->regmap
1389 : chip->regmap_companion;
1440 platform_set_drvdata(pdev, pm860x); 1390 platform_set_drvdata(pdev, pm860x);
1441 1391
1442 for (i = 0; i < 4; i++) { 1392 for (i = 0; i < 4; i++) {