@@ -2,6 +2,8 @@
# ACP 7.0 platform Support
snd-pci-acp70-y := pci-acp70.o
snd-acp70-pdm-dma-y := acp70-pdm-dma.o
+snd-acp70-sdw-dma-y := acp70-sdw-dma.o
obj-$(CONFIG_SND_SOC_AMD_ACP70) += snd-pci-acp70.o
obj-$(CONFIG_SND_SOC_AMD_ACP70) += snd-acp70-pdm-dma.o
+obj-$(CONFIG_SND_SOC_AMD_ACP70) += snd-acp70-sdw-dma.o
new file mode 100644
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * AMD ALSA SoC common SoundWire DMA Driver for ACP 7.0 and
+ * ACP 7.1 platforms.
+ *
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ */
+
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dai.h>
+#include <linux/soundwire/sdw_amd.h>
+#include "acp70.h"
+
+#define DRV_NAME "amd_acp70_sdw_dma"
+
+static const struct snd_soc_component_driver acp70_sdw_component = {
+ .name = DRV_NAME,
+ .use_dai_pcm_id = true,
+};
+
+static int acp70_sdw_platform_probe(struct platform_device *pdev)
+{
+ struct resource *res;
+ struct sdw_dma_dev_data *sdw_data;
+ struct acp70_dev_data *acp_data;
+ struct device *parent;
+ int status;
+
+ parent = pdev->dev.parent;
+ acp_data = dev_get_drvdata(parent);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n");
+ return -ENODEV;
+ }
+
+ sdw_data = devm_kzalloc(&pdev->dev, sizeof(*sdw_data), GFP_KERNEL);
+ if (!sdw_data)
+ return -ENOMEM;
+
+ sdw_data->acp_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+ if (!sdw_data->acp_base)
+ return -ENOMEM;
+
+ sdw_data->acp_lock = &acp_data->acp_lock;
+ dev_set_drvdata(&pdev->dev, sdw_data);
+ status = devm_snd_soc_register_component(&pdev->dev,
+ &acp70_sdw_component,
+ NULL, 0);
+ if (status) {
+ dev_err(&pdev->dev, "Fail to register sdw dma component\n");
+ return status;
+ }
+ return 0;
+}
+
+static struct platform_driver acp70_sdw_dma_driver = {
+ .probe = acp70_sdw_platform_probe,
+ .driver = {
+ .name = "amd_acp70_sdw_dma",
+ },
+};
+
+module_platform_driver(acp70_sdw_dma_driver);
+
+MODULE_AUTHOR("Vijendar.Mukunda@amd.com");
+MODULE_DESCRIPTION("AMD ACP7.0 SDW DMA Driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:" DRV_NAME);
@@ -97,6 +97,11 @@ struct pdm_dev_data {
struct snd_pcm_substream *capture_stream;
};
+struct sdw_dma_dev_data {
+ void __iomem *acp_base;
+ struct mutex *acp_lock; /* used to protect acp common register access */
+};
+
/**
* struct acp70_dev_data - acp pci driver context
* @acp70_base: acp mmio base
SoundWire DMA platform driver binds to the platform device created by ACP PCI device. SoundWire DMA driver registers ALSA DMA component with ASoC framework. Add common SoundWire dma driver for ACP7.0 and ACP7.1 platforms. Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com> --- sound/soc/amd/acp70/Makefile | 2 + sound/soc/amd/acp70/acp70-sdw-dma.c | 74 +++++++++++++++++++++++++++++ sound/soc/amd/acp70/acp70.h | 5 ++ 3 files changed, 81 insertions(+) create mode 100644 sound/soc/amd/acp70/acp70-sdw-dma.c