Skip to content

Commit 665dd18

Browse files
vijendarmukundabroonie
authored andcommitted
ASoC: amd: ps: add SoundWire dma driver
SoundWire DMA platform driver binds to the platform device created by ACP PCI device. SoundWire DMA driver registers ALSA DMA component with ASoC framework. Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com> Link: https://lore.kernel.org/r/20230612095903.2113464-4-Vijendar.Mukunda@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent e1cb350 commit 665dd18

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

sound/soc/amd/ps/acp63.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ struct pdm_dev_data {
137137
struct snd_pcm_substream *capture_stream;
138138
};
139139

140+
struct sdw_dma_dev_data {
141+
void __iomem *acp_base;
142+
struct mutex *acp_lock; /* used to protect acp common register access */
143+
};
144+
140145
/**
141146
* struct acp63_dev_data - acp pci driver context
142147
* @acp63_base: acp mmio base

sound/soc/amd/ps/ps-sdw-dma.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
/*
3+
* AMD ALSA SoC Pink Sardine SoundWire DMA Driver
4+
*
5+
* Copyright 2023 Advanced Micro Devices, Inc.
6+
*/
7+
8+
#include <linux/err.h>
9+
#include <linux/io.h>
10+
#include <linux/module.h>
11+
#include <linux/platform_device.h>
12+
#include <sound/pcm_params.h>
13+
#include <sound/soc.h>
14+
#include <sound/soc-dai.h>
15+
#include "acp63.h"
16+
17+
#define DRV_NAME "amd_ps_sdw_dma"
18+
19+
static const struct snd_soc_component_driver acp63_sdw_component = {
20+
.name = DRV_NAME,
21+
};
22+
23+
static int acp63_sdw_platform_probe(struct platform_device *pdev)
24+
{
25+
struct resource *res;
26+
struct sdw_dma_dev_data *sdw_data;
27+
struct acp63_dev_data *acp_data;
28+
struct device *parent;
29+
int status;
30+
31+
parent = pdev->dev.parent;
32+
acp_data = dev_get_drvdata(parent);
33+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
34+
if (!res) {
35+
dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n");
36+
return -ENODEV;
37+
}
38+
39+
sdw_data = devm_kzalloc(&pdev->dev, sizeof(*sdw_data), GFP_KERNEL);
40+
if (!sdw_data)
41+
return -ENOMEM;
42+
43+
sdw_data->acp_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
44+
if (!sdw_data->acp_base)
45+
return -ENOMEM;
46+
47+
sdw_data->acp_lock = &acp_data->acp_lock;
48+
dev_set_drvdata(&pdev->dev, sdw_data);
49+
status = devm_snd_soc_register_component(&pdev->dev,
50+
&acp63_sdw_component,
51+
NULL, 0);
52+
if (status)
53+
dev_err(&pdev->dev, "Fail to register sdw dma component\n");
54+
55+
return status;
56+
}
57+
58+
static struct platform_driver acp63_sdw_dma_driver = {
59+
.probe = acp63_sdw_platform_probe,
60+
.driver = {
61+
.name = "amd_ps_sdw_dma",
62+
},
63+
};
64+
65+
module_platform_driver(acp63_sdw_dma_driver);
66+
67+
MODULE_AUTHOR("Vijendar.Mukunda@amd.com");
68+
MODULE_DESCRIPTION("AMD ACP6.3 PS SDW DMA Driver");
69+
MODULE_LICENSE("GPL");
70+
MODULE_ALIAS("platform:" DRV_NAME);

0 commit comments

Comments
 (0)