ASoC: amd: ps: remove the register read and write wrappers.
Subsystems (3)
PATCH 1/2 ASoC: amd: ps: remove the register read and write wrappers.
Instead of acp63_readl() and acp63_writel() wrappers readl and writel functions can be used directly. Remove acp63_readl() and acp63_writel() wrappers.
Signed-off-by Syed Saba Kareem <[email protected]>
Reviewed-by Vijendar Mukunda <[email protected]>
--- sound/soc/amd/ps/acp63.h | 10 ------ sound/soc/amd/ps/pci-ps.c | 33 +++++++++--------- sound/soc/amd/ps/ps-pdm-dma.c | 63 +++++++++++++++++------------------ 3 files changed, 46 insertions(+), 60 deletions(-)
sound/soc/amd/ps/acp63.h +0 -10
@@ -92,16 +92,6 @@ struct pdm_dev_data {struct snd_pcm_substream *capture_stream; }; -static inline u32 acp63_readl (void __iomem *base_addr) -{ -return readl (base_addr); -} - -static inline void acp63_writel (u32 val,void __iomem *base_addr) -{ -writel (val, base_addr); -} -struct acp63_dev_data {void __iomem *acp63_base;struct resource *res;
sound/soc/amd/ps/pci-ps.c +16 -17
@@ -22,16 +22,16 @@ static int acp63_power_on(void __iomem *acp_base)u32 val;int timeout; - val =acp63_readl (acp_base +ACP_PGFSM_STATUS ); + val =readl (acp_base +ACP_PGFSM_STATUS );if (!val)return val;if ((val &ACP_PGFSM_STATUS_MASK ) !=ACP_POWER_ON_IN_PROGRESS ) -acp63_writel (ACP_PGFSM_CNTL_POWER_ON_MASK , acp_base +ACP_PGFSM_CONTROL ); +writel (ACP_PGFSM_CNTL_POWER_ON_MASK , acp_base +ACP_PGFSM_CONTROL ); timeout =0 ;while (++timeout <500 ) { - val =acp63_readl (acp_base +ACP_PGFSM_STATUS ); + val =readl (acp_base +ACP_PGFSM_STATUS );if (!val)return 0 ;udelay (1 );
@@ -44,18 +44,18 @@ static int acp63_reset(void __iomem *acp_base)u32 val;int timeout; -acp63_writel (1 , acp_base +ACP_SOFT_RESET ); +writel (1 , acp_base +ACP_SOFT_RESET ); timeout =0 ;while (++timeout <500 ) { - val =acp63_readl (acp_base +ACP_SOFT_RESET ); + val =readl (acp_base +ACP_SOFT_RESET );if (val &ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK )break ;cpu_relax (); } -acp63_writel (0 , acp_base +ACP_SOFT_RESET ); +writel (0 , acp_base +ACP_SOFT_RESET ); timeout =0 ;while (++timeout <500 ) { - val =acp63_readl (acp_base +ACP_SOFT_RESET ); + val =readl (acp_base +ACP_SOFT_RESET );if (!val)return 0 ;cpu_relax ();
@@ -65,15 +65,14 @@ static int acp63_reset(void __iomem *acp_base)static void acp63_enable_interrupts (void __iomem *acp_base) { -acp63_writel (1 , acp_base +ACP_EXTERNAL_INTR_ENB ); +writel (1 , acp_base +ACP_EXTERNAL_INTR_ENB ); }static void acp63_disable_interrupts (void __iomem *acp_base) { -acp63_writel (ACP_EXT_INTR_STAT_CLEAR_MASK , acp_base + -ACP_EXTERNAL_INTR_STAT ); -acp63_writel (0 , acp_base +ACP_EXTERNAL_INTR_CNTL ); -acp63_writel (0 , acp_base +ACP_EXTERNAL_INTR_ENB ); +writel (ACP_EXT_INTR_STAT_CLEAR_MASK , acp_base +ACP_EXTERNAL_INTR_STAT ); +writel (0 , acp_base +ACP_EXTERNAL_INTR_CNTL ); +writel (0 , acp_base +ACP_EXTERNAL_INTR_ENB ); }static int acp63_init (void __iomem *acp_base,struct device *dev)
@@ -85,7 +84,7 @@ static int acp63_init(void __iomem *acp_base, struct device *dev)dev_err (dev,"ACP power on failed\n" );return ret; } -acp63_writel (0x01 , acp_base +ACP_CONTROL ); +writel (0x01 , acp_base +ACP_CONTROL ); ret =acp63_reset (acp_base);if (ret) {dev_err (dev,"ACP reset failed\n" );
@@ -105,7 +104,7 @@ static int acp63_deinit(void __iomem *acp_base, struct device *dev)dev_err (dev,"ACP reset failed\n" );return ret; } -acp63_writel (0 , acp_base +ACP_CONTROL ); +writel (0 , acp_base +ACP_CONTROL );return 0 ; }
@@ -120,11 +119,11 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id)if (!adata)return IRQ_NONE ; - val =acp63_readl (adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); + val =readl (adata->acp63_base +ACP_EXTERNAL_INTR_STAT );if (val &BIT (PDM_DMA_STAT )) { pdev_index = adata->pdm_dev_index; ps_pdm_data =dev_get_drvdata (&adata->pdev[pdev_index]->dev); -acp63_writel (BIT (PDM_DMA_STAT ), adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); +writel (BIT (PDM_DMA_STAT ), adata->acp63_base +ACP_EXTERNAL_INTR_STAT );if (ps_pdm_data->capture_stream)snd_pcm_period_elapsed (ps_pdm_data->capture_stream);return IRQ_HANDLED ;
@@ -302,7 +301,7 @@ static int snd_acp63_probe(struct pci_dev *pci,dev_err (&pci->dev,"ACP PCI IRQ request failed\n" ); goto de_init; } - val =acp63_readl (adata->acp63_base +ACP_PIN_CONFIG ); + val =readl (adata->acp63_base +ACP_PIN_CONFIG );get_acp63_device_config (val, pci, adata); ret =create_acp63_platform_devs (pci, adata, addr);if (ret <0 ) {
sound/soc/amd/ps/ps-pdm-dma.c +30 -33
147 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/2 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 <[email protected]>
Reviewed-by Vijendar Mukunda <[email protected]>
--- sound/soc/amd/ps/acp63.h | 3 +++ sound/soc/amd/ps/pci-ps.c | 38 +++++++++++++------------------------- 2 files changed, 16 insertions(+), 25 deletions(-)
sound/soc/amd/ps/acp63.h +3 -0
@@ -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 ,
sound/soc/amd/ps/pci-ps.c +13 -25
@@ -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)
Signature · 1 line
2.25.1
PATCH 2/2 ASoC: amd: ps: refactor acp power on and reset functions.
In reply to Syed Saba KareemInstead 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 <[email protected]>
Reviewed-by Vijendar Mukunda <[email protected]>
--- sound/soc/amd/ps/acp63.h | 3 +++ sound/soc/amd/ps/pci-ps.c | 38 +++++++++++++------------------------- 2 files changed, 16 insertions(+), 25 deletions(-)
sound/soc/amd/ps/acp63.h +3 -0
@@ -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 ,
sound/soc/amd/ps/pci-ps.c +13 -25
@@ -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)
Signature · 1 line
2.25.1