lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241219054857.2070420-3-Vijendar.Mukunda@amd.com>
Date: Thu, 19 Dec 2024 11:18:38 +0530
From: Vijendar Mukunda <Vijendar.Mukunda@....com>
To: <broonie@...nel.org>
CC: <alsa-devel@...a-project.org>, <lgirdwood@...il.com>, <perex@...ex.cz>,
	<tiwai@...e.com>, <Basavaraj.Hiregoudar@....com>,
	<Sunil-kumar.Dommati@....com>, <venkataprasad.potturu@....com>,
	<Mario.Limonciello@....com>, <linux-sound@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, Vijendar Mukunda <Vijendar.Mukunda@....com>
Subject: [PATCH 02/21] ASoC: amd: acp70: add acp pci driver for ACP7.0 and ACP7.1 platforms

ACP is a PCI audio device.
This patch adds common PCI driver to bind to this device and get PCI
resources for ACP7.0 & ACP7.1 platforms.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@....com>
---
 sound/soc/amd/acp70/acp70.h     |  33 +++++++++++
 sound/soc/amd/acp70/pci-acp70.c | 100 ++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)
 create mode 100644 sound/soc/amd/acp70/acp70.h
 create mode 100644 sound/soc/amd/acp70/pci-acp70.c

diff --git a/sound/soc/amd/acp70/acp70.h b/sound/soc/amd/acp70/acp70.h
new file mode 100644
index 000000000000..28a46f0c2026
--- /dev/null
+++ b/sound/soc/amd/acp70/acp70.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * ACP 7.0 platform Common header file
+ *
+ * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#include <sound/acp70_chip_offset_byte.h>
+
+#define ACP_DEVICE_ID		0x15E2
+#define ACP70_REG_START		0x1240000
+#define ACP70_REG_END		0x125C000
+#define ACP70_PCI_REV		0x70
+#define ACP71_PCI_REV		0x71
+
+/**
+ * struct acp70_dev_data - acp pci driver context
+ * @acp70_base: acp mmio base
+ * @acp_lock: used to protect acp common registers
+ * @addr: pci ioremap address
+ * @reg_range: ACP reigister range
+ * @acp_rev : ACP PCI revision id
+ */
+
+struct acp70_dev_data {
+	void __iomem *acp70_base;
+	struct mutex acp_lock; /* protect shared registers */
+	u32 addr;
+	u32 reg_range;
+	u32 acp_rev;
+};
+
+int snd_amd_acp_find_config(struct pci_dev *pci);
diff --git a/sound/soc/amd/acp70/pci-acp70.c b/sound/soc/amd/acp70/pci-acp70.c
new file mode 100644
index 000000000000..23e47f619bd7
--- /dev/null
+++ b/sound/soc/amd/acp70/pci-acp70.c
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * AMD common ACP PCI driver for ACP7.0 & ACP7.1 platforms
+ *
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ */
+
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include "../mach-config.h"
+
+#include "acp70.h"
+
+static int snd_acp70_probe(struct pci_dev *pci,
+			   const struct pci_device_id *pci_id)
+{
+	struct acp70_dev_data *adata;
+	u32 addr, flag;
+	int ret;
+
+	/* Return if acp config flag is defined */
+	flag = snd_amd_acp_find_config(pci);
+	if (flag)
+		return -ENODEV;
+
+	/* Pink Sardine device check */
+	switch (pci->revision) {
+	case ACP70_PCI_REV:
+	case ACP71_PCI_REV:
+		break;
+	default:
+		dev_dbg(&pci->dev, "acp70 pci device not found\n");
+		return -ENODEV;
+	}
+	if (pci_enable_device(pci)) {
+		dev_err(&pci->dev, "pci_enable_device failed\n");
+		return -ENODEV;
+	}
+
+	ret = pci_request_regions(pci, "AMD ACP6.2 audio");
+	if (ret < 0) {
+		dev_err(&pci->dev, "pci_request_regions failed\n");
+		goto disable_pci;
+	}
+	adata = devm_kzalloc(&pci->dev, sizeof(struct acp70_dev_data),
+			     GFP_KERNEL);
+	if (!adata) {
+		ret = -ENOMEM;
+		goto release_regions;
+	}
+
+	addr = pci_resource_start(pci, 0);
+	adata->acp70_base = devm_ioremap(&pci->dev, addr,
+					 pci_resource_len(pci, 0));
+	if (!adata->acp70_base) {
+		ret = -ENOMEM;
+		goto release_regions;
+	}
+	adata->addr = addr;
+	adata->reg_range = ACP70_REG_END - ACP70_REG_START;
+	adata->acp_rev = pci->revision;
+	pci_set_master(pci);
+	pci_set_drvdata(pci, adata);
+	mutex_init(&adata->acp_lock);
+	return 0;
+release_regions:
+	pci_release_regions(pci);
+disable_pci:
+	pci_disable_device(pci);
+
+	return ret;
+}
+
+static void snd_acp70_remove(struct pci_dev *pci)
+{
+	pci_release_regions(pci);
+	pci_disable_device(pci);
+}
+
+static const struct pci_device_id snd_acp70_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_acp70_ids);
+
+static struct pci_driver ps_acp70_driver  = {
+	.name = KBUILD_MODNAME,
+	.id_table = snd_acp70_ids,
+	.probe = snd_acp70_probe,
+	.remove = snd_acp70_remove,
+};
+
+module_pci_driver(ps_acp70_driver);
+
+MODULE_AUTHOR("Vijendar.Mukunda@....com");
+MODULE_DESCRIPTION("AMD ACP7.0 PCI driver");
+MODULE_LICENSE("GPL");
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ