All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org,
	vijendar.mukunda@amd.com, tiwai@suse.de
Cc: Alex Deucher <alexander.deucher@amd.com>,
	Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Subject: [PATCH 04/14] ASoC: amd: create acp3x pdm platform device
Date: Tue,  5 May 2020 16:53:17 -0400	[thread overview]
Message-ID: <20200505205327.642282-5-alexander.deucher@amd.com> (raw)
In-Reply-To: <20200505205327.642282-1-alexander.deucher@amd.com>

From: Vijendar Mukunda <Vijendar.Mukunda@amd.com>

ACP 3x IP has PDM decoder as one of IP blocks.
Create a platform device for it, so that the PDM platform driver
can be bound to this device.
Pass PCI resources like MMIO, irq to this platform device.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 sound/soc/amd/renoir/rn-pci-acp3x.c | 61 ++++++++++++++++++++++++++++-
 sound/soc/amd/renoir/rn_acp3x.h     |  3 ++
 2 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
index 429813f6ba1c..362409ef0d85 100644
--- a/sound/soc/amd/renoir/rn-pci-acp3x.c
+++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
@@ -8,6 +8,8 @@
 #include <linux/module.h>
 #include <linux/io.h>
 #include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
 
 #include "rn_acp3x.h"
 
@@ -17,6 +19,8 @@ MODULE_PARM_DESC(acp_power_gating, "Enable acp power gating");
 
 struct acp_dev_data {
 	void __iomem *acp_base;
+	struct resource *res;
+	struct platform_device *pdev;
 };
 
 static int rn_acp_power_on(void __iomem *acp_base)
@@ -151,6 +155,8 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
 			    const struct pci_device_id *pci_id)
 {
 	struct acp_dev_data *adata;
+	struct platform_device_info pdevinfo;
+	unsigned int irqflags;
 	int ret;
 	u32 addr;
 
@@ -172,20 +178,70 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
 		goto release_regions;
 	}
 
+	/* check for msi interrupt support */
+	ret = pci_enable_msi(pci);
+	if (ret)
+		/* msi is not enabled */
+		irqflags = IRQF_SHARED;
+	else
+		/* msi is enabled */
+		irqflags = 0;
+
 	addr = pci_resource_start(pci, 0);
 	adata->acp_base = devm_ioremap(&pci->dev, addr,
 				       pci_resource_len(pci, 0));
 	if (!adata->acp_base) {
 		ret = -ENOMEM;
-		goto release_regions;
+		goto disable_msi;
 	}
 	pci_set_master(pci);
 	pci_set_drvdata(pci, adata);
 	ret = rn_acp_init(adata->acp_base);
 	if (ret)
-		goto release_regions;
+		goto disable_msi;
+
+	adata->res = devm_kzalloc(&pci->dev,
+				  sizeof(struct resource) * 2,
+				  GFP_KERNEL);
+	if (!adata->res) {
+		ret = -ENOMEM;
+		goto de_init;
+	}
+
+	adata->res[0].name = "acp_pdm_iomem";
+	adata->res[0].flags = IORESOURCE_MEM;
+	adata->res[0].start = addr;
+	adata->res[0].end = addr + (ACP_REG_END - ACP_REG_START);
+	adata->res[1].name = "acp_pdm_irq";
+	adata->res[1].flags = IORESOURCE_IRQ;
+	adata->res[1].start = pci->irq;
+	adata->res[1].end = pci->irq;
+
+	memset(&pdevinfo, 0, sizeof(pdevinfo));
+	pdevinfo.name = "acp_rn_pdm_dma";
+	pdevinfo.id = 0;
+	pdevinfo.parent = &pci->dev;
+	pdevinfo.num_res = 2;
+	pdevinfo.res = adata->res;
+	pdevinfo.data = &irqflags;
+	pdevinfo.size_data = sizeof(irqflags);
+
+	adata->pdev = platform_device_register_full(&pdevinfo);
+	if (IS_ERR(adata->pdev)) {
+		dev_err(&pci->dev, "cannot register %s device\n",
+			pdevinfo.name);
+		ret = PTR_ERR(adata->pdev);
+		goto unregister_devs;
+	}
 	return 0;
 
+unregister_devs:
+	platform_device_unregister(adata->pdev);
+de_init:
+	if (rn_acp_deinit(adata->acp_base))
+		dev_err(&pci->dev, "ACP de-init failed\n");
+disable_msi:
+	pci_disable_msi(pci);
 release_regions:
 	pci_release_regions(pci);
 disable_pci:
@@ -200,6 +256,7 @@ static void snd_rn_acp_remove(struct pci_dev *pci)
 	int ret;
 
 	adata = pci_get_drvdata(pci);
+	platform_device_unregister(adata->pdev);
 	ret = rn_acp_deinit(adata->acp_base);
 	if (ret)
 		dev_err(&pci->dev, "ACP de-init failed\n");
diff --git a/sound/soc/amd/renoir/rn_acp3x.h b/sound/soc/amd/renoir/rn_acp3x.h
index ec2a85085163..5e4fd99397d5 100644
--- a/sound/soc/amd/renoir/rn_acp3x.h
+++ b/sound/soc/amd/renoir/rn_acp3x.h
@@ -8,6 +8,9 @@
 #include "rn_chip_offset_byte.h"
 
 #define ACP_PHY_BASE_ADDRESS 0x1240000
+#define	ACP_REG_START	0x1240000
+#define	ACP_REG_END	0x1250200
+
 #define ACP_DEVICE_ID 0x15E2
 #define ACP_POWER_ON 0x00
 #define ACP_POWER_ON_IN_PROGRESS 0x01
-- 
2.25.4


  parent reply	other threads:[~2020-05-05 20:59 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 20:53 [PATCH 00/14] Add Renoir ACP driver Alex Deucher
2020-05-05 20:53 ` [PATCH 01/14] ASoC: amd: add Renoir ACP3x IP register header Alex Deucher
2020-05-05 20:53 ` [PATCH 02/14] ASoC: amd: add Renoir ACP PCI driver Alex Deucher
2020-05-05 20:53 ` [PATCH 03/14] ASoC: amd: add acp init/de-init functions Alex Deucher
2020-05-05 20:53 ` Alex Deucher [this message]
2020-05-05 20:53 ` [PATCH 05/14] ASoC: amd: add ACP3x PDM platform driver Alex Deucher
2020-05-05 22:03   ` Pierre-Louis Bossart
2020-05-06 17:20     ` Mukunda, Vijendar
2020-05-05 20:53 ` [PATCH 06/14] ASoC: amd: irq handler changes for ACP3x PDM dma driver Alex Deucher
2020-05-05 20:53 ` [PATCH 07/14] ASoC: amd: add acp3x pdm driver dma ops Alex Deucher
2020-05-05 21:59   ` Pierre-Louis Bossart
2020-05-06 17:30     ` Mukunda, Vijendar
2020-05-06 18:02       ` Pierre-Louis Bossart
2020-05-05 20:53 ` [PATCH 08/14] ASoC: amd: add ACP PDM DMA driver dai ops Alex Deucher
2020-05-05 21:55   ` Pierre-Louis Bossart
2020-05-06 17:12     ` Mukunda, Vijendar
2020-05-05 20:53 ` [PATCH 09/14] ASoC: amd: add Renoir ACP PCI driver PM ops Alex Deucher
2020-05-05 21:48   ` Pierre-Louis Bossart
2020-05-06 17:42     ` Mukunda, Vijendar
2020-05-06 17:58       ` Pierre-Louis Bossart
2020-05-05 20:53 ` [PATCH 10/14] ASoC: amd: add ACP PDM DMA driver pm ops Alex Deucher
2020-05-05 20:53 ` [PATCH 11/14] ASoC: amd: enable Renoir acp3x drivers build Alex Deucher
2020-05-05 20:53 ` [PATCH 12/14] ASoC: amd: create platform devices for Renoir Alex Deucher
2020-05-05 20:53 ` [PATCH 13/14] ASoC: amd: RN machine driver using dmic Alex Deucher
2020-05-05 21:37   ` Pierre-Louis Bossart
2020-05-06 16:01     ` Mukunda, Vijendar
2020-05-05 20:53 ` [PATCH 14/14] ASoC: amd: enable build for RN machine driver Alex Deucher
2020-05-05 21:39   ` Pierre-Louis Bossart
2020-05-06 15:54     ` Mukunda, Vijendar
2020-05-06 16:26     ` Mark Brown
2020-05-06 16:33       ` Mukunda, Vijendar
2020-05-06 16:43         ` Mark Brown
2020-05-06 17:17           ` Pierre-Louis Bossart
2020-05-06 17:25             ` Mark Brown
2020-05-06 17:27               ` Mukunda, Vijendar
2020-05-06 17:28                 ` 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=20200505205327.642282-5-alexander.deucher@amd.com \
    --to=alexdeucher@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=tiwai@suse.de \
    --cc=vijendar.mukunda@amd.com \
    /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.