diff options
| author | Vijendar Mukunda <Vijendar.Mukunda@amd.com> | 2026-05-07 23:41:33 +0530 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-05-22 00:15:04 +0100 |
| commit | 07d56a83ba7002c37890b536b01515ee8e928ee6 (patch) | |
| tree | cf18a8950fbda89ac56100cf7c1d7ae4624aca3d /sound | |
| parent | 533308171bf21c8b9434cd61827989800c49ff8b (diff) | |
| download | linux-next-history-07d56a83ba7002c37890b536b01515ee8e928ee6.tar.gz | |
ASoC: amd: acp7x: add system and runtime PM ops
Add ACP7.x PM callbacks and hook up system sleep and runtime PM ops for
the PCI driver.
Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Link: https://patch.msgid.link/20260507181251.20594-6-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
| -rw-r--r-- | sound/soc/amd/acp7x/acp7x-common.c | 43 | ||||
| -rw-r--r-- | sound/soc/amd/acp7x/acp7x.h | 3 | ||||
| -rw-r--r-- | sound/soc/amd/acp7x/pci-acp7x.c | 31 |
3 files changed, 77 insertions, 0 deletions
diff --git a/sound/soc/amd/acp7x/acp7x-common.c b/sound/soc/amd/acp7x/acp7x-common.c index 68f9b47766c48..df94864a1693c 100644 --- a/sound/soc/amd/acp7x/acp7x-common.c +++ b/sound/soc/amd/acp7x/acp7x-common.c @@ -75,8 +75,51 @@ static int acp7x_deinit(void __iomem *acp_base, struct device *dev) return 0; } +static int __maybe_unused snd_acp7x_suspend(struct device *dev) +{ + struct acp7x_dev_data *adata; + int ret; + + adata = dev_get_drvdata(dev); + ret = acp_hw_deinit(adata, dev); + if (ret) + dev_err(dev, "ACP de-init failed\n"); + return ret; +} + +static int __maybe_unused snd_acp7x_runtime_resume(struct device *dev) +{ + struct acp7x_dev_data *adata; + int ret; + + adata = dev_get_drvdata(dev); + ret = acp_hw_init(adata, dev); + if (ret) { + dev_err(dev, "ACP init failed\n"); + return ret; + } + return 0; +} + +static int __maybe_unused snd_acp7x_resume(struct device *dev) +{ + struct acp7x_dev_data *adata; + int ret; + + adata = dev_get_drvdata(dev); + ret = acp_hw_init(adata, dev); + if (ret) + dev_err(dev, "ACP init failed\n"); + + return ret; +} + void acp7x_hw_init_ops(struct acp_hw_ops *hw_ops) { hw_ops->acp_init = acp7x_init; hw_ops->acp_deinit = acp7x_deinit; + hw_ops->acp_suspend = snd_acp7x_suspend; + hw_ops->acp_resume = snd_acp7x_resume; + hw_ops->acp_suspend_runtime = snd_acp7x_suspend; + hw_ops->acp_resume_runtime = snd_acp7x_runtime_resume; } diff --git a/sound/soc/amd/acp7x/acp7x.h b/sound/soc/amd/acp7x/acp7x.h index d3a57705385af..ddb5eabf6828f 100644 --- a/sound/soc/amd/acp7x/acp7x.h +++ b/sound/soc/amd/acp7x/acp7x.h @@ -33,6 +33,9 @@ #define ACP7X_PGFSM_CNTL_POWER_ON_MASK 7 #define ACP7X_PGFSM_STATUS_MASK 0x3F +/* time in ms for runtime suspend delay */ +#define ACP_SUSPEND_DELAY_MS 2000 + struct acp_hw_ops { int (*acp_init)(void __iomem *acp_base, struct device *dev); int (*acp_deinit)(void __iomem *acp_base, struct device *dev); diff --git a/sound/soc/amd/acp7x/pci-acp7x.c b/sound/soc/amd/acp7x/pci-acp7x.c index 237eb06e3cadc..d29a149cf1751 100644 --- a/sound/soc/amd/acp7x/pci-acp7x.c +++ b/sound/soc/amd/acp7x/pci-acp7x.c @@ -11,6 +11,7 @@ #include <linux/io.h> #include <linux/module.h> #include <linux/pci.h> +#include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/types.h> @@ -92,6 +93,11 @@ static int snd_acp7x_probe(struct pci_dev *pci, ret = acp_hw_init(adata, &pci->dev); 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: @@ -102,6 +108,26 @@ disable_pci: return ret; } +static int __maybe_unused snd_acp_suspend(struct device *dev) +{ + return acp_hw_suspend(dev); +} + +static int __maybe_unused snd_acp_runtime_resume(struct device *dev) +{ + return acp_hw_runtime_resume(dev); +} + +static int __maybe_unused snd_acp_resume(struct device *dev) +{ + return acp_hw_resume(dev); +} + +static const struct dev_pm_ops acp7x_pm_ops = { + SET_RUNTIME_PM_OPS(snd_acp_suspend, snd_acp_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(snd_acp_suspend, snd_acp_resume) +}; + static void snd_acp7x_remove(struct pci_dev *pci) { struct acp7x_dev_data *adata; @@ -111,6 +137,8 @@ static void snd_acp7x_remove(struct pci_dev *pci) ret = acp_hw_deinit(adata, &pci->dev); 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); } @@ -128,6 +156,9 @@ static struct pci_driver acp7x_pci_driver = { .id_table = snd_acp7x_ids, .probe = snd_acp7x_probe, .remove = snd_acp7x_remove, + .driver = { + .pm = &acp7x_pm_ops, + } }; module_pci_driver(acp7x_pci_driver); |
