diff options
author | Syed Saba Kareem <Syed.SabaKareem@amd.com> | 2022-07-21 09:10:01 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2022-07-22 01:25:18 +0300 |
commit | bc1100f29d1d0bfcd36ba3690a945235ffe149c8 (patch) | |
tree | e94c38e775e104df1d0cca84f5761b86abe11147 /sound/soc/amd/rpl | |
parent | 10599205417ee3b1d29093c85bc210c9040a6bd4 (diff) | |
download | linux-bc1100f29d1d0bfcd36ba3690a945235ffe149c8.tar.xz |
ASoC: amd: add RPL Platform pci driver pm-ops
Add RPL Platform ACP PCI driver pm ops.
Signed-off-by: Syed Saba Kareem <Syed.SabaKareem@amd.com>
Reviewed-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Link: https://lore.kernel.org/r/20220721061035.91139-4-Syed.SabaKareem@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/amd/rpl')
-rw-r--r-- | sound/soc/amd/rpl/rpl-pci-acp6x.c | 40 | ||||
-rw-r--r-- | sound/soc/amd/rpl/rpl_acp6x.h | 15 |
2 files changed, 55 insertions, 0 deletions
diff --git a/sound/soc/amd/rpl/rpl-pci-acp6x.c b/sound/soc/amd/rpl/rpl-pci-acp6x.c index 71ae90a00f36..a8e548ed991b 100644 --- a/sound/soc/amd/rpl/rpl-pci-acp6x.c +++ b/sound/soc/amd/rpl/rpl-pci-acp6x.c @@ -10,6 +10,7 @@ #include <linux/io.h> #include <linux/delay.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> #include "rpl_acp6x.h" @@ -144,6 +145,11 @@ static int snd_rpl_probe(struct pci_dev *pci, ret = rpl_init(adata->acp6x_base); if (ret) goto release_regions; + pm_runtime_set_autosuspend_delay(&pci->dev, ACP_SUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(&pci->dev); + pm_runtime_put_noidle(&pci->dev); + pm_runtime_allow(&pci->dev); + return 0; release_regions: pci_release_regions(pci); @@ -153,6 +159,35 @@ disable_pci: return ret; } +static int __maybe_unused snd_rpl_suspend(struct device *dev) +{ + struct rpl_dev_data *adata; + int ret; + + adata = dev_get_drvdata(dev); + ret = rpl_deinit(adata->acp6x_base); + if (ret) + dev_err(dev, "ACP de-init failed\n"); + return ret; +} + +static int __maybe_unused snd_rpl_resume(struct device *dev) +{ + struct rpl_dev_data *adata; + int ret; + + adata = dev_get_drvdata(dev); + ret = rpl_init(adata->acp6x_base); + if (ret) + dev_err(dev, "ACP init failed\n"); + return ret; +} + +static const struct dev_pm_ops rpl_pm = { + SET_RUNTIME_PM_OPS(snd_rpl_suspend, snd_rpl_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(snd_rpl_suspend, snd_rpl_resume) +}; + static void snd_rpl_remove(struct pci_dev *pci) { struct rpl_dev_data *adata; @@ -162,6 +197,8 @@ static void snd_rpl_remove(struct pci_dev *pci) ret = rpl_deinit(adata->acp6x_base); if (ret) dev_err(&pci->dev, "ACP de-init failed\n"); + pm_runtime_forbid(&pci->dev); + pm_runtime_get_noresume(&pci->dev); pci_release_regions(pci); pci_disable_device(pci); } @@ -179,6 +216,9 @@ static struct pci_driver rpl_acp6x_driver = { .id_table = snd_rpl_ids, .probe = snd_rpl_probe, .remove = snd_rpl_remove, + .driver = { + .pm = &rpl_pm, + } }; module_pci_driver(rpl_acp6x_driver); diff --git a/sound/soc/amd/rpl/rpl_acp6x.h b/sound/soc/amd/rpl/rpl_acp6x.h index 5de19d5c892e..f5816a33632e 100644 --- a/sound/soc/amd/rpl/rpl_acp6x.h +++ b/sound/soc/amd/rpl/rpl_acp6x.h @@ -10,6 +10,21 @@ #define ACP_DEVICE_ID 0x15E2 #define ACP6x_PHY_BASE_ADDRESS 0x1240000 +#define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001 +#define ACP_PGFSM_CNTL_POWER_ON_MASK 1 +#define ACP_PGFSM_CNTL_POWER_OFF_MASK 0 +#define ACP_PGFSM_STATUS_MASK 3 +#define ACP_POWERED_ON 0 +#define ACP_POWER_ON_IN_PROGRESS 1 +#define ACP_POWERED_OFF 2 +#define ACP_POWER_OFF_IN_PROGRESS 3 + +#define DELAY_US 5 +#define ACP_COUNTER 20000 + +/* time in ms for runtime suspend delay */ +#define ACP_SUSPEND_DELAY_MS 2000 + static inline u32 rpl_acp_readl(void __iomem *base_addr) { return readl(base_addr - ACP6x_PHY_BASE_ADDRESS); |