Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Syed Saba Kareem and committed by
Mark Brown
ea79b0a6 ec54f810

+16 -25
+3
sound/soc/amd/ps/acp63.h
··· 58 58 #define ACP63_PDM_DEV_MASK 1 59 59 #define ACP_DMIC_DEV 2 60 60 61 + /* time in ms for acp timeout */ 62 + #define ACP_TIMEOUT 500 63 + 61 64 enum acp_config { 62 65 ACP_CONFIG_0 = 0, 63 66 ACP_CONFIG_1,
+13 -25
sound/soc/amd/ps/pci-ps.c
··· 14 14 #include <linux/interrupt.h> 15 15 #include <sound/pcm_params.h> 16 16 #include <linux/pm_runtime.h> 17 + #include <linux/iopoll.h> 17 18 18 19 #include "acp63.h" 19 20 20 21 static int acp63_power_on(void __iomem *acp_base) 21 22 { 22 23 u32 val; 23 - int timeout; 24 24 25 25 val = readl(acp_base + ACP_PGFSM_STATUS); 26 26 ··· 29 29 30 30 if ((val & ACP_PGFSM_STATUS_MASK) != ACP_POWER_ON_IN_PROGRESS) 31 31 writel(ACP_PGFSM_CNTL_POWER_ON_MASK, acp_base + ACP_PGFSM_CONTROL); 32 - timeout = 0; 33 - while (++timeout < 500) { 34 - val = readl(acp_base + ACP_PGFSM_STATUS); 35 - if (!val) 36 - return 0; 37 - udelay(1); 38 - } 39 - return -ETIMEDOUT; 32 + 33 + return readl_poll_timeout(acp_base + ACP_PGFSM_STATUS, val, !val, DELAY_US, ACP_TIMEOUT); 40 34 } 41 35 42 36 static int acp63_reset(void __iomem *acp_base) 43 37 { 44 38 u32 val; 45 - int timeout; 39 + int ret; 46 40 47 41 writel(1, acp_base + ACP_SOFT_RESET); 48 - timeout = 0; 49 - while (++timeout < 500) { 50 - val = readl(acp_base + ACP_SOFT_RESET); 51 - if (val & ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK) 52 - break; 53 - cpu_relax(); 54 - } 42 + 43 + ret = readl_poll_timeout(acp_base + ACP_SOFT_RESET, val, 44 + val & ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK, 45 + DELAY_US, ACP_TIMEOUT); 46 + if (ret) 47 + return ret; 48 + 55 49 writel(0, acp_base + ACP_SOFT_RESET); 56 - timeout = 0; 57 - while (++timeout < 500) { 58 - val = readl(acp_base + ACP_SOFT_RESET); 59 - if (!val) 60 - return 0; 61 - cpu_relax(); 62 - } 63 - return -ETIMEDOUT; 50 + 51 + return readl_poll_timeout(acp_base + ACP_SOFT_RESET, val, !val, DELAY_US, ACP_TIMEOUT); 64 52 } 65 53 66 54 static void acp63_enable_interrupts(void __iomem *acp_base)