All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
To: <alsa-devel@alsa-project.org>, <broonie@kernel.org>, <tiwai@suse.de>
Cc: Alexander.Deucher@amd.com, Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Subject: [PATCH v3 06/14] ASoC: amd: irq handler changes for ACP3x PDM dma driver
Date: Tue, 19 May 2020 01:16:56 +0800	[thread overview]
Message-ID: <20200518171704.24999-7-Vijendar.Mukunda@amd.com> (raw)
In-Reply-To: <20200518171704.24999-1-Vijendar.Mukunda@amd.com>

Whenever audio data equal to the PDM watermark level
are consumed, interrupt is generated.
Acknowledge the interrupt.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/amd/renoir/acp3x-pdm-dma.c | 38 ++++++++++++++++++++++++++++
 sound/soc/amd/renoir/rn_acp3x.h      |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/sound/soc/amd/renoir/acp3x-pdm-dma.c b/sound/soc/amd/renoir/acp3x-pdm-dma.c
index 1dda8cf2edd2..fdac2c1e3acd 100644
--- a/sound/soc/amd/renoir/acp3x-pdm-dma.c
+++ b/sound/soc/amd/renoir/acp3x-pdm-dma.c
@@ -16,6 +16,31 @@
 
 #define DRV_NAME "acp_rn_pdm_dma"
 
+static irqreturn_t pdm_irq_handler(int irq, void *dev_id)
+{
+	struct pdm_dev_data *rn_pdm_data;
+	u16 cap_flag;
+	u32 val;
+
+	rn_pdm_data = dev_id;
+	if (!rn_pdm_data)
+		return IRQ_NONE;
+
+	cap_flag = 0;
+	val = rn_readl(rn_pdm_data->acp_base + ACP_EXTERNAL_INTR_STAT);
+	if ((val & BIT(PDM_DMA_STAT)) && rn_pdm_data->capture_stream) {
+		rn_writel(BIT(PDM_DMA_STAT), rn_pdm_data->acp_base +
+			  ACP_EXTERNAL_INTR_STAT);
+		snd_pcm_period_elapsed(rn_pdm_data->capture_stream);
+		cap_flag = 1;
+	}
+
+	if (cap_flag)
+		return IRQ_HANDLED;
+	else
+		return IRQ_NONE;
+}
+
 static struct snd_soc_dai_driver acp_pdm_dai_driver = {
 	.capture = {
 		.rates = SNDRV_PCM_RATE_48000,
@@ -60,6 +85,13 @@ static int acp_pdm_audio_probe(struct platform_device *pdev)
 	if (!adata->acp_base)
 		return -ENOMEM;
 
+	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!res) {
+		dev_err(&pdev->dev, "IORESOURCE_IRQ FAILED\n");
+		return -ENODEV;
+	}
+
+	adata->pdm_irq = res->start;
 	adata->capture_stream = NULL;
 
 	dev_set_drvdata(&pdev->dev, adata);
@@ -71,6 +103,12 @@ static int acp_pdm_audio_probe(struct platform_device *pdev)
 
 		return -ENODEV;
 	}
+	status = devm_request_irq(&pdev->dev, adata->pdm_irq, pdm_irq_handler,
+				  irqflags, "ACP_PDM_IRQ", adata);
+	if (status) {
+		dev_err(&pdev->dev, "ACP PDM IRQ request failed\n");
+		return -ENODEV;
+	}
 	return 0;
 }
 
diff --git a/sound/soc/amd/renoir/rn_acp3x.h b/sound/soc/amd/renoir/rn_acp3x.h
index 0b450882c6c4..1ad8a7845fda 100644
--- a/sound/soc/amd/renoir/rn_acp3x.h
+++ b/sound/soc/amd/renoir/rn_acp3x.h
@@ -28,8 +28,10 @@
 
 #define ACP_ERROR_MASK 0x20000000
 #define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF
+#define PDM_DMA_STAT 0x10
 
 struct pdm_dev_data {
+	u32 pdm_irq;
 	void __iomem *acp_base;
 	struct snd_pcm_substream *capture_stream;
 };
-- 
2.26.2


  parent reply	other threads:[~2020-05-18 17:22 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18 17:16 [PATCH v3 00/14] Add Renoir ACP driver Vijendar Mukunda
2020-05-18 17:16 ` [PATCH v3 01/14] ASoC: amd: add Renoir ACP3x IP register header Vijendar Mukunda
2020-05-18 17:16 ` [PATCH v3 02/14] ASoC: amd: add Renoir ACP PCI driver Vijendar Mukunda
2020-05-18 17:16 ` [PATCH v3 03/14] ASoC: amd: add acp init/de-init functions Vijendar Mukunda
2020-05-18 17:16 ` [PATCH v3 04/14] ASoC: amd: create acp3x pdm platform device Vijendar Mukunda
2020-05-19 10:53   ` Mark Brown
2020-05-19 11:03     ` Mukunda, Vijendar
2020-05-19 14:40       ` Deucher, Alexander
2020-05-19 15:45         ` Mark Brown
2020-05-18 17:16 ` [PATCH v3 05/14] ASoC: amd: add ACP3x PDM platform driver Vijendar Mukunda
2020-05-19 10:54   ` Mark Brown
2020-05-19 11:10     ` Mukunda, Vijendar
2020-05-19 11:32       ` Mark Brown
2020-05-18 17:16 ` Vijendar Mukunda [this message]
2020-05-18 17:16 ` [PATCH v3 07/14] ASoC: amd: add acp3x pdm driver dma ops Vijendar Mukunda
2020-05-18 17:16 ` [PATCH v3 08/14] ASoC: amd: add ACP PDM DMA driver dai ops Vijendar Mukunda
2020-05-19 11:19   ` Mark Brown
2020-05-19 11:37     ` Mukunda, Vijendar
2020-05-19 11:40       ` Mark Brown
2020-05-19 11:42         ` Mukunda, Vijendar
2020-05-18 17:16 ` [PATCH v3 09/14] ASoC: amd: add Renoir ACP PCI driver PM ops Vijendar Mukunda
2020-05-19 11:33   ` Mark Brown
2020-05-19 11:39     ` Mukunda, Vijendar
2020-05-18 17:17 ` [PATCH v3 10/14] ASoC: amd: add ACP PDM DMA driver pm ops Vijendar Mukunda
2020-05-18 17:17 ` [PATCH v3 11/14] ASoC: amd: enable Renoir acp3x drivers build Vijendar Mukunda
2020-05-19 11:59   ` kbuild test robot
2020-05-19 14:46     ` Mukunda, Vijendar
2020-05-18 17:17 ` [PATCH v3 12/14] ASoC: amd: create platform devices for Renoir Vijendar Mukunda
2020-05-18 17:17 ` [PATCH v3 13/14] ASoC: amd: RN machine driver using dmic Vijendar Mukunda
2020-05-18 17:17 ` [PATCH v3 14/14] ASoC: amd: enable build for RN machine driver Vijendar Mukunda
2020-05-18 17:31 ` [PATCH v3 00/14] Add Renoir ACP driver Pierre-Louis Bossart
2020-05-19 11:38 ` Mark Brown
2020-05-19 11:43   ` Mukunda, Vijendar
2020-05-19 12:45     ` Mukunda, Vijendar
2020-05-19 13:19 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200518171704.24999-7-Vijendar.Mukunda@amd.com \
    --to=vijendar.mukunda@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.