Skip to content

Commit 8d452ac

Browse files
TE-N-ShengjiuWangbroonie
authored andcommitted
ASoC: wm8962: Clear master mode when enter runtime suspend
The enabled master mode causes power consumption to increase in idle state. Clear the MSTR bit in runtime supsend and recover it in runtime resume to reduce power. Signed-off-by: Shengjiu Wang <[email protected]> Reviewed-by: Charles Keepax <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent eb3bb14 commit 8d452ac

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sound/soc/codecs/wm8962.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct wm8962_priv {
8282
#endif
8383

8484
int irq;
85+
bool master_flag;
8586
};
8687

8788
/* We can't use the same notifier block for more than one supply and
@@ -2715,6 +2716,7 @@ static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
27152716
static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
27162717
{
27172718
struct snd_soc_component *component = dai->component;
2719+
struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
27182720
int aif0 = 0;
27192721

27202722
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -2761,9 +2763,11 @@ static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
27612763
return -EINVAL;
27622764
}
27632765

2766+
wm8962->master_flag = false;
27642767
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
27652768
case SND_SOC_DAIFMT_CBP_CFP:
27662769
aif0 |= WM8962_MSTR;
2770+
wm8962->master_flag = true;
27672771
break;
27682772
case SND_SOC_DAIFMT_CBC_CFC:
27692773
break;
@@ -3903,6 +3907,9 @@ static int wm8962_runtime_resume(struct device *dev)
39033907
WM8962_BIAS_ENA | WM8962_VMID_SEL_MASK,
39043908
WM8962_BIAS_ENA | 0x180);
39053909

3910+
if (wm8962->master_flag)
3911+
regmap_update_bits(wm8962->regmap, WM8962_AUDIO_INTERFACE_0,
3912+
WM8962_MSTR, WM8962_MSTR);
39063913
msleep(5);
39073914

39083915
return 0;
@@ -3916,6 +3923,10 @@ static int wm8962_runtime_suspend(struct device *dev)
39163923
{
39173924
struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
39183925

3926+
if (wm8962->master_flag)
3927+
regmap_update_bits(wm8962->regmap, WM8962_AUDIO_INTERFACE_0,
3928+
WM8962_MSTR, 0);
3929+
39193930
regmap_update_bits(wm8962->regmap, WM8962_PWR_MGMT_1,
39203931
WM8962_VMID_SEL_MASK | WM8962_BIAS_ENA, 0);
39213932

0 commit comments

Comments
 (0)