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 02/14] ASoC: amd: add Renoir ACP PCI driver
Date: Tue, 19 May 2020 01:16:52 +0800	[thread overview]
Message-ID: <20200518171704.24999-3-Vijendar.Mukunda@amd.com> (raw)
In-Reply-To: <20200518171704.24999-1-Vijendar.Mukunda@amd.com>

ACP is a PCI audio device.
This patch adds PCI driver to bind to this device and get
PCI resources.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/amd/renoir/rn-pci-acp3x.c | 87 +++++++++++++++++++++++++++++
 sound/soc/amd/renoir/rn_acp3x.h     | 21 +++++++
 2 files changed, 108 insertions(+)
 create mode 100644 sound/soc/amd/renoir/rn-pci-acp3x.c
 create mode 100644 sound/soc/amd/renoir/rn_acp3x.h

diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
new file mode 100644
index 000000000000..56b76e355cd4
--- /dev/null
+++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
@@ -0,0 +1,87 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// AMD Renoir ACP PCI Driver
+//
+//Copyright 2020 Advanced Micro Devices, Inc.
+
+#include <linux/pci.h>
+#include <linux/module.h>
+#include <linux/io.h>
+
+#include "rn_acp3x.h"
+
+struct acp_dev_data {
+	void __iomem *acp_base;
+};
+
+static int snd_rn_acp_probe(struct pci_dev *pci,
+			    const struct pci_device_id *pci_id)
+{
+	struct acp_dev_data *adata;
+	int ret;
+	u32 addr;
+
+	if (pci_enable_device(pci)) {
+		dev_err(&pci->dev, "pci_enable_device failed\n");
+		return -ENODEV;
+	}
+
+	ret = pci_request_regions(pci, "AMD ACP3x audio");
+	if (ret < 0) {
+		dev_err(&pci->dev, "pci_request_regions failed\n");
+		goto disable_pci;
+	}
+
+	adata = devm_kzalloc(&pci->dev, sizeof(struct acp_dev_data),
+			     GFP_KERNEL);
+	if (!adata) {
+		ret = -ENOMEM;
+		goto release_regions;
+	}
+
+	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;
+	}
+	pci_set_master(pci);
+	pci_set_drvdata(pci, adata);
+	return 0;
+
+release_regions:
+	pci_release_regions(pci);
+disable_pci:
+	pci_disable_device(pci);
+
+	return ret;
+}
+
+static void snd_rn_acp_remove(struct pci_dev *pci)
+{
+	pci_disable_msi(pci);
+	pci_release_regions(pci);
+	pci_disable_device(pci);
+}
+
+static const struct pci_device_id snd_rn_acp_ids[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_DEVICE_ID),
+	.class = PCI_CLASS_MULTIMEDIA_OTHER << 8,
+	.class_mask = 0xffffff },
+	{ 0, },
+};
+MODULE_DEVICE_TABLE(pci, snd_rn_acp_ids);
+
+static struct pci_driver rn_acp_driver  = {
+	.name = KBUILD_MODNAME,
+	.id_table = snd_rn_acp_ids,
+	.probe = snd_rn_acp_probe,
+	.remove = snd_rn_acp_remove,
+};
+
+module_pci_driver(rn_acp_driver);
+
+MODULE_AUTHOR("Vijendar.Mukunda@amd.com");
+MODULE_DESCRIPTION("AMD ACP Renoir PCI driver");
+MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/amd/renoir/rn_acp3x.h b/sound/soc/amd/renoir/rn_acp3x.h
new file mode 100644
index 000000000000..da5715759646
--- /dev/null
+++ b/sound/soc/amd/renoir/rn_acp3x.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * AMD ALSA SoC PDM Driver
+ *
+ * Copyright 2020 Advanced Micro Devices, Inc.
+ */
+
+#include "rn_chip_offset_byte.h"
+
+#define ACP_PHY_BASE_ADDRESS 0x1240000
+#define ACP_DEVICE_ID 0x15E2
+
+static inline u32 rn_readl(void __iomem *base_addr)
+{
+	return readl(base_addr - ACP_PHY_BASE_ADDRESS);
+}
+
+static inline void rn_writel(u32 val, void __iomem *base_addr)
+{
+	writel(val, base_addr - ACP_PHY_BASE_ADDRESS);
+}
-- 
2.26.2


  parent reply	other threads:[~2020-05-18 17:19 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 ` Vijendar Mukunda [this message]
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 ` [PATCH v3 06/14] ASoC: amd: irq handler changes for ACP3x PDM dma driver Vijendar Mukunda
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-3-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.