Commit db49c146 authored by Dimitris Papastamos's avatar Dimitris Papastamos Committed by Mark Brown

ASoC: Delegate to hw specific read for volatile registers

Ensure that reads on volatile registers will correctly delegate
to the bus specific read function.
Signed-off-by: default avatarDimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 3e13f65e
......@@ -19,8 +19,15 @@ static unsigned int snd_soc_4_12_read(struct snd_soc_codec *codec,
unsigned int reg)
{
u16 *cache = codec->reg_cache;
if (reg >= codec->driver->reg_cache_size)
if (reg >= codec->driver->reg_cache_size ||
snd_soc_codec_volatile_register(codec, reg)) {
if (codec->cache_only)
return -1;
return codec->hw_read(codec, reg);
}
return cache[reg];
}
......@@ -31,12 +38,11 @@ static int snd_soc_4_12_write(struct snd_soc_codec *codec, unsigned int reg,
u8 data[2];
int ret;
BUG_ON(codec->driver->volatile_register);
data[0] = (reg << 4) | ((value >> 8) & 0x000f);
data[1] = value & 0x00ff;
if (reg < codec->driver->reg_cache_size)
if (!snd_soc_codec_volatile_register(codec, reg) &&
reg < codec->driver->reg_cache_size)
cache[reg] = value;
if (codec->cache_only) {
......@@ -89,8 +95,15 @@ static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec,
unsigned int reg)
{
u16 *cache = codec->reg_cache;
if (reg >= codec->driver->reg_cache_size)
if (reg >= codec->driver->reg_cache_size ||
snd_soc_codec_volatile_register(codec, reg)) {
if (codec->cache_only)
return -1;
return codec->hw_read(codec, reg);
}
return cache[reg];
}
......@@ -101,12 +114,11 @@ static int snd_soc_7_9_write(struct snd_soc_codec *codec, unsigned int reg,
u8 data[2];
int ret;
BUG_ON(codec->driver->volatile_register);
data[0] = (reg << 1) | ((value >> 8) & 0x0001);
data[1] = value & 0x00ff;
if (reg < codec->driver->reg_cache_size)
if (!snd_soc_codec_volatile_register(codec, reg) &&
reg < codec->driver->reg_cache_size)
cache[reg] = value;
if (codec->cache_only) {
......@@ -161,13 +173,12 @@ static int snd_soc_8_8_write(struct snd_soc_codec *codec, unsigned int reg,
u8 *cache = codec->reg_cache;
u8 data[2];
BUG_ON(codec->driver->volatile_register);
reg &= 0xff;
data[0] = reg;
data[1] = value & 0xff;
if (reg < codec->driver->reg_cache_size)
if (!snd_soc_codec_volatile_register(codec, value) &&
reg < codec->driver->reg_cache_size)
cache[reg] = value;
if (codec->cache_only) {
......@@ -187,9 +198,16 @@ static unsigned int snd_soc_8_8_read(struct snd_soc_codec *codec,
unsigned int reg)
{
u8 *cache = codec->reg_cache;
reg &= 0xff;
if (reg >= codec->driver->reg_cache_size)
if (reg >= codec->driver->reg_cache_size ||
snd_soc_codec_volatile_register(codec, reg)) {
if (codec->cache_only)
return -1;
return codec->hw_read(codec, reg);
}
return cache[reg];
}
......@@ -344,8 +362,14 @@ static unsigned int snd_soc_16_8_read(struct snd_soc_codec *codec,
u8 *cache = codec->reg_cache;
reg &= 0xff;
if (reg >= codec->driver->reg_cache_size)
if (reg >= codec->driver->reg_cache_size ||
snd_soc_codec_volatile_register(codec, reg)) {
if (codec->cache_only)
return -1;
return codec->hw_read(codec, reg);
}
return cache[reg];
}
......@@ -356,14 +380,13 @@ static int snd_soc_16_8_write(struct snd_soc_codec *codec, unsigned int reg,
u8 data[3];
int ret;
BUG_ON(codec->driver->volatile_register);
data[0] = (reg >> 8) & 0xff;
data[1] = reg & 0xff;
data[2] = value;
reg &= 0xff;
if (reg < codec->driver->reg_cache_size)
if (!snd_soc_codec_volatile_register(codec, reg) &&
reg < codec->driver->reg_cache_size)
cache[reg] = value;
if (codec->cache_only) {
......@@ -475,7 +498,8 @@ static int snd_soc_16_16_write(struct snd_soc_codec *codec, unsigned int reg,
data[2] = (value >> 8) & 0xff;
data[3] = value & 0xff;
if (reg < codec->driver->reg_cache_size)
if (!snd_soc_codec_volatile_register(codec, reg) &&
reg < codec->driver->reg_cache_size)
cache[reg] = value;
if (codec->cache_only) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment