Skip to content

Commit 1255296

Browse files
Akshu Agrawalbroonie
authored andcommitted
ASoC: AMD: Restore PME_EN state at Power On
PME_EN state needs to restored to the value set by fmw. For the devices which are not using I2S wake event which gets enabled by PME_EN bit, keeping PME_EN enabled burns considerable amount of power as it blocks low power state. For the devices using I2S wake event, PME_EN gets enabled in fmw and the state should be maintained after ACP Power On. Signed-off-by: Akshu Agrawal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 3aecfc7 commit 1255296

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

sound/soc/amd/raven/pci-acp3x.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ struct acp3x_dev_data {
1919
bool acp3x_audio_mode;
2020
struct resource *res;
2121
struct platform_device *pdev[ACP3x_DEVS];
22+
u32 pme_en;
2223
};
2324

24-
static int acp3x_power_on(void __iomem *acp3x_base)
25+
static int acp3x_power_on(struct acp3x_dev_data *adata)
2526
{
27+
void __iomem *acp3x_base = adata->acp3x_base;
2628
u32 val;
2729
int timeout;
2830

@@ -39,10 +41,10 @@ static int acp3x_power_on(void __iomem *acp3x_base)
3941
while (++timeout < 500) {
4042
val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS);
4143
if (!val) {
42-
/* Set PME_EN as after ACP power On,
43-
* PME_EN gets cleared
44+
/* ACP power On clears PME_EN.
45+
* Restore the value to its prior state
4446
*/
45-
rv_writel(0x1, acp3x_base + mmACP_PME_EN);
47+
rv_writel(adata->pme_en, acp3x_base + mmACP_PME_EN);
4648
return 0;
4749
}
4850
udelay(1);
@@ -74,12 +76,13 @@ static int acp3x_reset(void __iomem *acp3x_base)
7476
return -ETIMEDOUT;
7577
}
7678

77-
static int acp3x_init(void __iomem *acp3x_base)
79+
static int acp3x_init(struct acp3x_dev_data *adata)
7880
{
81+
void __iomem *acp3x_base = adata->acp3x_base;
7982
int ret;
8083

8184
/* power on */
82-
ret = acp3x_power_on(acp3x_base);
85+
ret = acp3x_power_on(adata);
8386
if (ret) {
8487
pr_err("ACP3x power on failed\n");
8588
return ret;
@@ -151,7 +154,9 @@ static int snd_acp3x_probe(struct pci_dev *pci,
151154
}
152155
pci_set_master(pci);
153156
pci_set_drvdata(pci, adata);
154-
ret = acp3x_init(adata->acp3x_base);
157+
/* Save ACP_PME_EN state */
158+
adata->pme_en = rv_readl(adata->acp3x_base + mmACP_PME_EN);
159+
ret = acp3x_init(adata);
155160
if (ret)
156161
goto disable_msi;
157162

@@ -274,7 +279,7 @@ static int snd_acp3x_resume(struct device *dev)
274279
struct acp3x_dev_data *adata;
275280

276281
adata = dev_get_drvdata(dev);
277-
ret = acp3x_init(adata->acp3x_base);
282+
ret = acp3x_init(adata);
278283
if (ret) {
279284
dev_err(dev, "ACP init failed\n");
280285
return ret;

0 commit comments

Comments
 (0)