summaryrefslogtreecommitdiffstats
path: root/sound/soc/amd
diff options
context:
space:
mode:
authorSyed Saba Kareem <Syed.SabaKareem@amd.com>2023-04-26 14:22:02 +0200
committerMark Brown <broonie@kernel.org>2023-05-08 01:48:50 +0200
commitea79b0a663f7bade8664d9ba5017019fc96b91f8 (patch)
tree5e513a75f948aa49a2073b581b4825eee541fe0f /sound/soc/amd
parentASoC: amd: ps: remove the register read and write wrappers. (diff)
downloadlinux-ea79b0a663f7bade8664d9ba5017019fc96b91f8.tar.xz
linux-ea79b0a663f7bade8664d9ba5017019fc96b91f8.zip
ASoC: amd: ps: refactor acp power on and reset functions.
Instead of a busy waiting while loop using udelay in acp63_power_on and acp63_reset functions use readl_poll_timeout function to check the condition. Signed-off-by: Syed Saba Kareem <Syed.SabaKareem@amd.com Reviewed-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com Link: https://lore.kernel.org/r/20230426122219.3745586-2-Syed.SabaKareem@amd.com Signed-off-by: Mark Brown <broonie@kernel.org
Diffstat (limited to 'sound/soc/amd')
-rw-r--r--sound/soc/amd/ps/acp63.h3
-rw-r--r--sound/soc/amd/ps/pci-ps.c38
2 files changed, 16 insertions, 25 deletions
diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h
index 903b812aa8e8..2f94448102d0 100644
--- a/sound/soc/amd/ps/acp63.h
+++ b/sound/soc/amd/ps/acp63.h
@@ -58,6 +58,9 @@
#define ACP63_PDM_DEV_MASK 1
#define ACP_DMIC_DEV 2
+/* time in ms for acp timeout */
+#define ACP_TIMEOUT 500
+
enum acp_config {
ACP_CONFIG_0 = 0,
ACP_CONFIG_1,
diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c
index 097fd5488534..c957718abefc 100644
--- a/sound/soc/amd/ps/pci-ps.c
+++ b/sound/soc/amd/ps/pci-ps.c
@@ -14,13 +14,13 @@
#include <linux/interrupt.h>
#include <sound/pcm_params.h>
#include <linux/pm_runtime.h>
+#include <linux/iopoll.h>
#include "acp63.h"
static int acp63_power_on(void __iomem *acp_base)
{
u32 val;
- int timeout;
val = readl(acp_base + ACP_PGFSM_STATUS);
@@ -29,38 +29,26 @@ static int acp63_power_on(void __iomem *acp_base)
if ((val & ACP_PGFSM_STATUS_MASK) != ACP_POWER_ON_IN_PROGRESS)
writel(ACP_PGFSM_CNTL_POWER_ON_MASK, acp_base + ACP_PGFSM_CONTROL);
- timeout = 0;
- while (++timeout < 500) {
- val = readl(acp_base + ACP_PGFSM_STATUS);
- if (!val)
- return 0;
- udelay(1);
- }
- return -ETIMEDOUT;
+
+ return readl_poll_timeout(acp_base + ACP_PGFSM_STATUS, val, !val, DELAY_US, ACP_TIMEOUT);
}
static int acp63_reset(void __iomem *acp_base)
{
u32 val;
- int timeout;
+ int ret;
writel(1, acp_base + ACP_SOFT_RESET);
- timeout = 0;
- while (++timeout < 500) {
- val = readl(acp_base + ACP_SOFT_RESET);
- if (val & ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK)
- break;
- cpu_relax();
- }
+
+ ret = readl_poll_timeout(acp_base + ACP_SOFT_RESET, val,
+ val & ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK,
+ DELAY_US, ACP_TIMEOUT);
+ if (ret)
+ return ret;
+
writel(0, acp_base + ACP_SOFT_RESET);
- timeout = 0;
- while (++timeout < 500) {
- val = readl(acp_base + ACP_SOFT_RESET);
- if (!val)
- return 0;
- cpu_relax();
- }
- return -ETIMEDOUT;
+
+ return readl_poll_timeout(acp_base + ACP_SOFT_RESET, val, !val, DELAY_US, ACP_TIMEOUT);
}
static void acp63_enable_interrupts(void __iomem *acp_base)