ASoC: wm8960: Use snd_soc_update_bits for read-modify-write
Use snd_soc_update_bits for read-modify-write register access instead of open-coding it using snd_soc_read and snd_soc_write Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
4105ab846c
commit
16b24881a0
|
@ -543,30 +543,24 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,
|
||||||
static int wm8960_mute(struct snd_soc_dai *dai, int mute)
|
static int wm8960_mute(struct snd_soc_dai *dai, int mute)
|
||||||
{
|
{
|
||||||
struct snd_soc_codec *codec = dai->codec;
|
struct snd_soc_codec *codec = dai->codec;
|
||||||
u16 mute_reg = snd_soc_read(codec, WM8960_DACCTL1) & 0xfff7;
|
|
||||||
|
|
||||||
if (mute)
|
if (mute)
|
||||||
snd_soc_write(codec, WM8960_DACCTL1, mute_reg | 0x8);
|
snd_soc_update_bits(codec, WM8960_DACCTL1, 0x8, 0x8);
|
||||||
else
|
else
|
||||||
snd_soc_write(codec, WM8960_DACCTL1, mute_reg);
|
snd_soc_update_bits(codec, WM8960_DACCTL1, 0x8, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
|
static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
|
||||||
enum snd_soc_bias_level level)
|
enum snd_soc_bias_level level)
|
||||||
{
|
{
|
||||||
u16 reg;
|
|
||||||
|
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case SND_SOC_BIAS_ON:
|
case SND_SOC_BIAS_ON:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SND_SOC_BIAS_PREPARE:
|
case SND_SOC_BIAS_PREPARE:
|
||||||
/* Set VMID to 2x50k */
|
/* Set VMID to 2x50k */
|
||||||
reg = snd_soc_read(codec, WM8960_POWER1);
|
snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x80);
|
||||||
reg &= ~0x180;
|
|
||||||
reg |= 0x80;
|
|
||||||
snd_soc_write(codec, WM8960_POWER1, reg);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SND_SOC_BIAS_STANDBY:
|
case SND_SOC_BIAS_STANDBY:
|
||||||
|
@ -579,23 +573,19 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
|
||||||
WM8960_BUFDCOPEN | WM8960_BUFIOEN);
|
WM8960_BUFDCOPEN | WM8960_BUFIOEN);
|
||||||
|
|
||||||
/* Enable & ramp VMID at 2x50k */
|
/* Enable & ramp VMID at 2x50k */
|
||||||
reg = snd_soc_read(codec, WM8960_POWER1);
|
snd_soc_update_bits(codec, WM8960_POWER1, 0x80, 0x80);
|
||||||
reg |= 0x80;
|
|
||||||
snd_soc_write(codec, WM8960_POWER1, reg);
|
|
||||||
msleep(100);
|
msleep(100);
|
||||||
|
|
||||||
/* Enable VREF */
|
/* Enable VREF */
|
||||||
snd_soc_write(codec, WM8960_POWER1, reg | WM8960_VREF);
|
snd_soc_update_bits(codec, WM8960_POWER1, WM8960_VREF,
|
||||||
|
WM8960_VREF);
|
||||||
|
|
||||||
/* Disable anti-pop features */
|
/* Disable anti-pop features */
|
||||||
snd_soc_write(codec, WM8960_APOP1, WM8960_BUFIOEN);
|
snd_soc_write(codec, WM8960_APOP1, WM8960_BUFIOEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set VMID to 2x250k */
|
/* Set VMID to 2x250k */
|
||||||
reg = snd_soc_read(codec, WM8960_POWER1);
|
snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x100);
|
||||||
reg &= ~0x180;
|
|
||||||
reg |= 0x100;
|
|
||||||
snd_soc_write(codec, WM8960_POWER1, reg);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SND_SOC_BIAS_OFF:
|
case SND_SOC_BIAS_OFF:
|
||||||
|
@ -787,10 +777,8 @@ static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
||||||
|
|
||||||
/* Disable the PLL: even if we are changing the frequency the
|
/* Disable the PLL: even if we are changing the frequency the
|
||||||
* PLL needs to be disabled while we do so. */
|
* PLL needs to be disabled while we do so. */
|
||||||
snd_soc_write(codec, WM8960_CLOCK1,
|
snd_soc_update_bits(codec, WM8960_CLOCK1, 0x1, 0);
|
||||||
snd_soc_read(codec, WM8960_CLOCK1) & ~1);
|
snd_soc_update_bits(codec, WM8960_POWER2, 0x1, 0);
|
||||||
snd_soc_write(codec, WM8960_POWER2,
|
|
||||||
snd_soc_read(codec, WM8960_POWER2) & ~1);
|
|
||||||
|
|
||||||
if (!freq_in || !freq_out)
|
if (!freq_in || !freq_out)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -809,11 +797,9 @@ static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
||||||
snd_soc_write(codec, WM8960_PLL1, reg);
|
snd_soc_write(codec, WM8960_PLL1, reg);
|
||||||
|
|
||||||
/* Turn it on */
|
/* Turn it on */
|
||||||
snd_soc_write(codec, WM8960_POWER2,
|
snd_soc_update_bits(codec, WM8960_POWER2, 0x1, 0x1);
|
||||||
snd_soc_read(codec, WM8960_POWER2) | 1);
|
|
||||||
msleep(250);
|
msleep(250);
|
||||||
snd_soc_write(codec, WM8960_CLOCK1,
|
snd_soc_update_bits(codec, WM8960_CLOCK1, 0x1, 0x1);
|
||||||
snd_soc_read(codec, WM8960_CLOCK1) | 1);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -913,7 +899,6 @@ static int wm8960_probe(struct snd_soc_codec *codec)
|
||||||
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
|
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
|
||||||
struct wm8960_data *pdata = dev_get_platdata(codec->dev);
|
struct wm8960_data *pdata = dev_get_platdata(codec->dev);
|
||||||
int ret;
|
int ret;
|
||||||
u16 reg;
|
|
||||||
|
|
||||||
wm8960->set_bias_level = wm8960_set_bias_level_out3;
|
wm8960->set_bias_level = wm8960_set_bias_level_out3;
|
||||||
|
|
||||||
|
@ -944,26 +929,16 @@ static int wm8960_probe(struct snd_soc_codec *codec)
|
||||||
wm8960->set_bias_level(codec, SND_SOC_BIAS_STANDBY);
|
wm8960->set_bias_level(codec, SND_SOC_BIAS_STANDBY);
|
||||||
|
|
||||||
/* Latch the update bits */
|
/* Latch the update bits */
|
||||||
reg = snd_soc_read(codec, WM8960_LINVOL);
|
snd_soc_update_bits(codec, WM8960_LINVOL, 0x100, 0x100);
|
||||||
snd_soc_write(codec, WM8960_LINVOL, reg | 0x100);
|
snd_soc_update_bits(codec, WM8960_RINVOL, 0x100, 0x100);
|
||||||
reg = snd_soc_read(codec, WM8960_RINVOL);
|
snd_soc_update_bits(codec, WM8960_LADC, 0x100, 0x100);
|
||||||
snd_soc_write(codec, WM8960_RINVOL, reg | 0x100);
|
snd_soc_update_bits(codec, WM8960_RADC, 0x100, 0x100);
|
||||||
reg = snd_soc_read(codec, WM8960_LADC);
|
snd_soc_update_bits(codec, WM8960_LDAC, 0x100, 0x100);
|
||||||
snd_soc_write(codec, WM8960_LADC, reg | 0x100);
|
snd_soc_update_bits(codec, WM8960_RDAC, 0x100, 0x100);
|
||||||
reg = snd_soc_read(codec, WM8960_RADC);
|
snd_soc_update_bits(codec, WM8960_LOUT1, 0x100, 0x100);
|
||||||
snd_soc_write(codec, WM8960_RADC, reg | 0x100);
|
snd_soc_update_bits(codec, WM8960_ROUT1, 0x100, 0x100);
|
||||||
reg = snd_soc_read(codec, WM8960_LDAC);
|
snd_soc_update_bits(codec, WM8960_LOUT2, 0x100, 0x100);
|
||||||
snd_soc_write(codec, WM8960_LDAC, reg | 0x100);
|
snd_soc_update_bits(codec, WM8960_ROUT2, 0x100, 0x100);
|
||||||
reg = snd_soc_read(codec, WM8960_RDAC);
|
|
||||||
snd_soc_write(codec, WM8960_RDAC, reg | 0x100);
|
|
||||||
reg = snd_soc_read(codec, WM8960_LOUT1);
|
|
||||||
snd_soc_write(codec, WM8960_LOUT1, reg | 0x100);
|
|
||||||
reg = snd_soc_read(codec, WM8960_ROUT1);
|
|
||||||
snd_soc_write(codec, WM8960_ROUT1, reg | 0x100);
|
|
||||||
reg = snd_soc_read(codec, WM8960_LOUT2);
|
|
||||||
snd_soc_write(codec, WM8960_LOUT2, reg | 0x100);
|
|
||||||
reg = snd_soc_read(codec, WM8960_ROUT2);
|
|
||||||
snd_soc_write(codec, WM8960_ROUT2, reg | 0x100);
|
|
||||||
|
|
||||||
snd_soc_add_controls(codec, wm8960_snd_controls,
|
snd_soc_add_controls(codec, wm8960_snd_controls,
|
||||||
ARRAY_SIZE(wm8960_snd_controls));
|
ARRAY_SIZE(wm8960_snd_controls));
|
||||||
|
|
Loading…
Reference in New Issue