From: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
To: <broonie@kernel.org>, <alsa-devel@alsa-project.org>
Cc: <Vijendar.Mukunda@amd.com>, <mario.limonciello@amd.com>,
<Basavaraj.Hiregoudar@amd.com>, <Sunil-kumar.Dommati@amd.com>,
<syed.sabakareem@amd.com>,
Venkata Prasad Potturu <venkataprasad.potturu@amd.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
"Peter Zijlstra" <peterz@infradead.org>,
Greg KH <gregkh@linuxfoundation.org>,
"Jeff Johnson" <quic_jjohnson@quicinc.com>,
"open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..."
<linux-sound@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: [PATCH 03/14] ASoC: amd: acp: Refactor dmic-codec platform device creation
Date: Mon, 10 Mar 2025 16:15:50 +0530 [thread overview]
Message-ID: <20250310104601.7325-4-venkataprasad.potturu@amd.com> (raw)
In-Reply-To: <20250310104601.7325-1-venkataprasad.potturu@amd.com>
Refactor dmic-codec platform driver creation using helper function.
Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
---
sound/soc/amd/acp/acp-pci.c | 49 +++++++++++++++++++++++++------------
sound/soc/amd/acp/amd.h | 1 +
2 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/sound/soc/amd/acp/acp-pci.c b/sound/soc/amd/acp/acp-pci.c
index b5eabd0280bc..95dbc9b01a70 100644
--- a/sound/soc/amd/acp/acp-pci.c
+++ b/sound/soc/amd/acp/acp-pci.c
@@ -26,7 +26,6 @@
#define ACP3x_REG_START 0x1240000
#define ACP3x_REG_END 0x125C000
-static struct platform_device *dmic_dev;
static struct platform_device *pdev;
static const struct resource acp_res[] = {
@@ -44,6 +43,26 @@ static const struct resource acp_res[] = {
},
};
+static int create_acp_platform_devs(struct pci_dev *pci, struct acp_chip_info *chip)
+{
+ int ret;
+
+ if (chip->is_pdm_dev && chip->is_pdm_config) {
+ chip->dmic_codec_dev = platform_device_register_data(&pci->dev,
+ "dmic-codec",
+ PLATFORM_DEVID_NONE,
+ NULL, 0);
+ if (IS_ERR(chip->dmic_codec_dev)) {
+ dev_err(&pci->dev, "failed to create DMIC device\n");
+ ret = PTR_ERR(chip->dmic_codec_dev);
+ goto err;
+ }
+ }
+ return 0;
+err:
+ return ret;
+}
+
static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
{
struct platform_device_info pdevinfo;
@@ -102,33 +121,33 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
goto release_regions;
}
chip->flag = flag;
- dmic_dev = platform_device_register_data(dev, "dmic-codec", PLATFORM_DEVID_NONE, NULL, 0);
- if (IS_ERR(dmic_dev)) {
- dev_err(dev, "failed to create DMIC device\n");
- ret = PTR_ERR(dmic_dev);
- goto release_regions;
- }
addr = pci_resource_start(pci, 0);
chip->base = devm_ioremap(&pci->dev, addr, pci_resource_len(pci, 0));
if (!chip->base) {
ret = -ENOMEM;
- goto unregister_dmic_dev;
+ goto release_regions;
}
chip->acp_hw_ops_init(chip);
ret = acp_hw_init(chip);
if (ret)
- goto unregister_dmic_dev;
+ goto release_regions;
check_acp_config(pci, chip);
if (!chip->is_pdm_dev && !chip->is_i2s_config)
goto skip_pdev_creation;
+ ret = create_acp_platform_devs(pci, chip);
+ if (ret < 0) {
+ dev_err(&pci->dev, "ACP platform devices creation failed\n");
+ goto de_init;
+ }
+
res = devm_kcalloc(&pci->dev, num_res, sizeof(struct resource), GFP_KERNEL);
if (!res) {
ret = -ENOMEM;
- goto unregister_dmic_dev;
+ goto de_init;
}
for (i = 0; i < num_res; i++, res_acp++) {
@@ -156,7 +175,7 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
if (IS_ERR(pdev)) {
dev_err(&pci->dev, "cannot register %s device\n", pdevinfo.name);
ret = PTR_ERR(pdev);
- goto unregister_dmic_dev;
+ goto de_init;
}
skip_pdev_creation:
@@ -168,8 +187,8 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
pm_runtime_allow(&pci->dev);
return ret;
-unregister_dmic_dev:
- platform_device_unregister(dmic_dev);
+de_init:
+ chip->acp_hw_ops->acp_deinit(chip);
release_regions:
pci_release_regions(pci);
disable_pci:
@@ -223,8 +242,8 @@ static void acp_pci_remove(struct pci_dev *pci)
chip = pci_get_drvdata(pci);
pm_runtime_forbid(&pci->dev);
pm_runtime_get_noresume(&pci->dev);
- if (dmic_dev)
- platform_device_unregister(dmic_dev);
+ if (chip->dmic_codec_dev)
+ platform_device_unregister(chip->dmic_codec_dev);
if (pdev)
platform_device_unregister(pdev);
ret = acp_hw_deinit(chip);
diff --git a/sound/soc/amd/acp/amd.h b/sound/soc/amd/acp/amd.h
index 2098afdddc60..d2b81a22638c 100644
--- a/sound/soc/amd/acp/amd.h
+++ b/sound/soc/amd/acp/amd.h
@@ -145,6 +145,7 @@ struct acp_chip_info {
struct snd_acp_hw_ops *acp_hw_ops;
int (*acp_hw_ops_init)(struct acp_chip_info *chip);
struct platform_device *chip_pdev;
+ struct platform_device *dmic_codec_dev;
unsigned int flag; /* Distinguish b/w Legacy or Only PDM */
bool is_pdm_dev; /* flag set to true when ACP PDM controller exists */
bool is_pdm_config; /* flag set to true when PDM configuration is selected from BIOS */
--
2.39.2
next prev parent reply other threads:[~2025-03-10 10:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250310104601.7325-1-venkataprasad.potturu@amd.com>
2025-03-10 10:45 ` [PATCH 01/14] ASoC: amd: acp: Remove redundant acp70 chip->name Venkata Prasad Potturu
2025-03-10 10:45 ` [PATCH 02/14] ASoC: amd: acp: Implement acp_common_hw_ops support for acp platforms Venkata Prasad Potturu
2025-03-10 11:25 ` Amadeusz Sławiński
2025-03-10 12:06 ` potturu venkata prasad
2025-03-10 10:45 ` Venkata Prasad Potturu [this message]
2025-03-10 11:30 ` [PATCH 03/14] ASoC: amd: acp: Refactor dmic-codec platform device creation Amadeusz Sławiński
2025-03-10 12:09 ` potturu venkata prasad
2025-03-10 10:45 ` [PATCH 04/14] ASoC: amd: acp: Refactor acp " Venkata Prasad Potturu
2025-03-10 10:45 ` [PATCH 05/14] ASoC: amd: acp: Refactor acp machine select Venkata Prasad Potturu
2025-03-10 10:45 ` [PATCH 06/14] ASoC: amd: acp: Add new interrupt handle callbacks in acp_common_hw_ops Venkata Prasad Potturu
2025-03-10 10:45 ` [PATCH 07/14] ASoC: amd: acp: Remove redundant acp_dev_data structure Venkata Prasad Potturu
2025-03-10 10:45 ` [PATCH 08/14] ASoC: amd: acp: Move spin_lock and list initialization to acp-pci driver Venkata Prasad Potturu
2025-03-10 10:45 ` [PATCH 09/14] ASoC: amd: acp: Remove white line Venkata Prasad Potturu
2025-03-10 10:45 ` [PATCH 10/14] ASoC: amd: acp: Refactor acp70 platform resource structure Venkata Prasad Potturu
2025-03-10 10:45 ` [PATCH 11/14] ASoC: amd: acp: Refactor acp63 " Venkata Prasad Potturu
2025-03-10 10:45 ` [PATCH 12/14] ASoC: amd: acp: Refactor rembrant " Venkata Prasad Potturu
2025-03-10 10:46 ` [PATCH 13/14] ASoC: amd: acp: Refactor renoir " Venkata Prasad Potturu
2025-03-10 10:46 ` [PATCH 14/14] ASoC: amd: acp: Fix for enabling DMIC on acp platforms via _DSD entry Venkata Prasad Potturu
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=20250310104601.7325-4-venkataprasad.potturu@amd.com \
--to=venkataprasad.potturu@amd.com \
--cc=Basavaraj.Hiregoudar@amd.com \
--cc=Sunil-kumar.Dommati@amd.com \
--cc=Vijendar.Mukunda@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=perex@perex.cz \
--cc=peterz@infradead.org \
--cc=quic_jjohnson@quicinc.com \
--cc=syed.sabakareem@amd.com \
--cc=tiwai@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox