[PATCH v2 08/14] ASoC: amd: add ACP PDM DMA driver dai ops
Pierre-Louis Bossart
pierre-louis.bossart at linux.intel.com
Tue May 12 00:12:18 CEST 2020
> +static int start_pdm_dma(void __iomem *acp_base)
> +{
> + u32 pdm_enable;
> + u32 pdm_dma_enable;
> + int timeout;
> +
> + pdm_enable = 0x01;
> + pdm_dma_enable = 0x01;
> +
> + enable_pdm_clock(acp_base);
> + rn_writel(pdm_enable, acp_base + ACP_WOV_PDM_ENABLE);
> + rn_writel(pdm_dma_enable, acp_base + ACP_WOV_PDM_DMA_ENABLE);
> + pdm_dma_enable = 0x00;
> + timeout = 0;
> + while (++timeout < ACP_COUNTER) {
> + pdm_dma_enable = rn_readl(acp_base + ACP_WOV_PDM_DMA_ENABLE);
> + if ((pdm_dma_enable & 0x02) == ACP_PDM_DMA_EN_STATUS)
> + return 0;
> + udelay(DELAY_US);
> + }
> + return -ETIMEDOUT;
> +}
> +
> +static int stop_pdm_dma(void __iomem *acp_base)
> +{
> + u32 pdm_enable, pdm_dma_enable, pdm_fifo_flush;
> + int timeout;
> +
> + pdm_enable = 0x00;
> + pdm_dma_enable = 0x00;
> + pdm_fifo_flush = 0x00;
> +
> + pdm_enable = rn_readl(acp_base + ACP_WOV_PDM_ENABLE);
> + pdm_dma_enable = rn_readl(acp_base + ACP_WOV_PDM_DMA_ENABLE);
> + if (pdm_dma_enable & 0x01) {
> + pdm_dma_enable = 0x02;
> + rn_writel(pdm_dma_enable, acp_base + ACP_WOV_PDM_DMA_ENABLE);
> + pdm_dma_enable = 0x00;
> + timeout = 0;
> + while (++timeout < ACP_COUNTER) {
> + pdm_dma_enable = rn_readl(acp_base +
> + ACP_WOV_PDM_DMA_ENABLE);
> + if ((pdm_dma_enable & 0x02) == 0x00)
> + break;
> + udelay(DELAY_US);
> + }
> + if (timeout == ACP_COUNTER)
if you reach this point, timeout is by construction equal to ACP_COUNTER
so this test is useless
You could also use a helper where you check if the value is
ACP_PDM_DMA_EN_STATUS or zero so that you don't copy the same logic twice.
More information about the Alsa-devel
mailing list