linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] ASoC: SOF: amd: remove unused code
@ 2023-04-03  7:16 Vijendar Mukunda
  2023-04-03  7:16 ` [PATCH 2/6] ASoC: SOF: amd: remove acp_dai_probe() function Vijendar Mukunda
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Vijendar Mukunda @ 2023-04-03  7:16 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Vijendar Mukunda, Pierre-Louis Bossart, Liam Girdwood,
	Peter Ujfalusi, Bard Liao, Ranjani Sridharan, Kai Vehmanen,
	Daniel Baluta, Jaroslav Kysela, Takashi Iwai, Ajit Kumar Pandey,
	Rander Wang, V sujith kumar Reddy, Zheng Bin,
	moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS,
	open list

During initial SOF driver bring up on AMD platforms, only DMIC
support was added. As of today, we have a complete SOF solution for
I2S endpoints along with DMIC endpoint.
This code is no longer required.
Remove unused code from RMB and RN platform ACP PCI driver.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/sof/amd/pci-rmb.c | 70 +------------------------------------
 sound/soc/sof/amd/pci-rn.c  | 70 +------------------------------------
 2 files changed, 2 insertions(+), 138 deletions(-)

diff --git a/sound/soc/sof/amd/pci-rmb.c b/sound/soc/sof/amd/pci-rmb.c
index 4e1de462b431..d0a56e8f09c0 100644
--- a/sound/soc/sof/amd/pci-rmb.c
+++ b/sound/soc/sof/amd/pci-rmb.c
@@ -27,22 +27,6 @@
 #define ACP6x_REG_END		0x125C000
 
 static struct platform_device *dmic_dev;
-static struct platform_device *pdev;
-
-static const struct resource rembrandt_res[] = {
-	{
-		.start = 0,
-		.end = ACP6x_REG_END - ACP6x_REG_START,
-		.name = "acp_mem",
-		.flags = IORESOURCE_MEM,
-	},
-	{
-		.start = 0,
-		.end = 0,
-		.name = "acp_dai_irq",
-		.flags = IORESOURCE_IRQ,
-	},
-};
 
 static const struct sof_amd_acp_desc rembrandt_chip_info = {
 	.rev		= 6,
@@ -83,11 +67,8 @@ static const struct sof_dev_desc rembrandt_desc = {
 
 static int acp_pci_rmb_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
-	struct platform_device_info pdevinfo;
 	struct device *dev = &pci->dev;
-	const struct resource *res_i2s;
-	struct resource *res;
-	unsigned int flag, i, addr;
+	unsigned int flag;
 	int ret;
 
 	flag = snd_amd_acp_find_config(pci);
@@ -104,53 +85,6 @@ static int acp_pci_rmb_probe(struct pci_dev *pci, const struct pci_device_id *pc
 		sof_pci_remove(pci);
 		return PTR_ERR(dmic_dev);
 	}
-
-	/* Register platform device only if flag set to FLAG_AMD_SOF_ONLY_DMIC */
-	if (flag != FLAG_AMD_SOF_ONLY_DMIC)
-		return 0;
-
-	addr = pci_resource_start(pci, 0);
-	res = devm_kzalloc(&pci->dev, sizeof(struct resource) * ARRAY_SIZE(rembrandt_res),
-			   GFP_KERNEL);
-	if (!res) {
-		platform_device_unregister(dmic_dev);
-		sof_pci_remove(pci);
-		return -ENOMEM;
-	}
-
-	res_i2s = rembrandt_res;
-	for (i = 0; i < ARRAY_SIZE(rembrandt_res); i++, res_i2s++) {
-		res[i].name = res_i2s->name;
-		res[i].flags = res_i2s->flags;
-		res[i].start = addr + res_i2s->start;
-		res[i].end = addr + res_i2s->end;
-		if (res_i2s->flags == IORESOURCE_IRQ) {
-			res[i].start = pci->irq;
-			res[i].end = res[i].start;
-		}
-	}
-
-	memset(&pdevinfo, 0, sizeof(pdevinfo));
-
-	/*
-	 * We have common PCI driver probe for ACP device but we have to support I2S without SOF
-	 * for some distributions. Register platform device that will be used to support non dsp
-	 * ACP's audio ends points on some machines.
-	 */
-	pdevinfo.name = "acp_asoc_rembrandt";
-	pdevinfo.id = 0;
-	pdevinfo.parent = &pci->dev;
-	pdevinfo.num_res = ARRAY_SIZE(rembrandt_res);
-	pdevinfo.res = &res[0];
-
-	pdev = platform_device_register_full(&pdevinfo);
-	if (IS_ERR(pdev)) {
-		dev_err(&pci->dev, "cannot register %s device\n", pdevinfo.name);
-		platform_device_unregister(dmic_dev);
-		sof_pci_remove(pci);
-		ret = PTR_ERR(pdev);
-	}
-
 	return ret;
 };
 
@@ -158,8 +92,6 @@ static void acp_pci_rmb_remove(struct pci_dev *pci)
 {
 	if (dmic_dev)
 		platform_device_unregister(dmic_dev);
-	if (pdev)
-		platform_device_unregister(pdev);
 
 	sof_pci_remove(pci);
 }
diff --git a/sound/soc/sof/amd/pci-rn.c b/sound/soc/sof/amd/pci-rn.c
index fca40b261671..faab4c33a24d 100644
--- a/sound/soc/sof/amd/pci-rn.c
+++ b/sound/soc/sof/amd/pci-rn.c
@@ -27,22 +27,6 @@
 #define ACP3x_REG_END		0x125C000
 
 static struct platform_device *dmic_dev;
-static struct platform_device *pdev;
-
-static const struct resource renoir_res[] = {
-	{
-		.start = 0,
-		.end = ACP3x_REG_END - ACP3x_REG_START,
-		.name = "acp_mem",
-		.flags = IORESOURCE_MEM,
-	},
-	{
-		.start = 0,
-		.end = 0,
-		.name = "acp_dai_irq",
-		.flags = IORESOURCE_IRQ,
-	},
-};
 
 static const struct sof_amd_acp_desc renoir_chip_info = {
 	.rev		= 3,
@@ -83,11 +67,8 @@ static const struct sof_dev_desc renoir_desc = {
 
 static int acp_pci_rn_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
-	struct platform_device_info pdevinfo;
 	struct device *dev = &pci->dev;
-	const struct resource *res_i2s;
-	struct resource *res;
-	unsigned int flag, i, addr;
+	unsigned int flag;
 	int ret;
 
 	flag = snd_amd_acp_find_config(pci);
@@ -104,53 +85,6 @@ static int acp_pci_rn_probe(struct pci_dev *pci, const struct pci_device_id *pci
 		sof_pci_remove(pci);
 		return PTR_ERR(dmic_dev);
 	}
-
-	/* Register platform device only if flag set to FLAG_AMD_SOF_ONLY_DMIC */
-	if (flag != FLAG_AMD_SOF_ONLY_DMIC)
-		return 0;
-
-	addr = pci_resource_start(pci, 0);
-	res = devm_kzalloc(&pci->dev, sizeof(struct resource) * ARRAY_SIZE(renoir_res), GFP_KERNEL);
-	if (!res) {
-		sof_pci_remove(pci);
-		platform_device_unregister(dmic_dev);
-		return -ENOMEM;
-	}
-
-	res_i2s = renoir_res;
-	for (i = 0; i < ARRAY_SIZE(renoir_res); i++, res_i2s++) {
-		res[i].name = res_i2s->name;
-		res[i].flags = res_i2s->flags;
-		res[i].start = addr + res_i2s->start;
-		res[i].end = addr + res_i2s->end;
-		if (res_i2s->flags == IORESOURCE_IRQ) {
-			res[i].start = pci->irq;
-			res[i].end = res[i].start;
-		}
-	}
-
-	memset(&pdevinfo, 0, sizeof(pdevinfo));
-
-	/*
-	 * We have common PCI driver probe for ACP device but we have to support I2S without SOF
-	 * for some distributions. Register platform device that will be used to support non dsp
-	 * ACP's audio ends points on some machines.
-	 */
-
-	pdevinfo.name = "acp_asoc_renoir";
-	pdevinfo.id = 0;
-	pdevinfo.parent = &pci->dev;
-	pdevinfo.num_res = ARRAY_SIZE(renoir_res);
-	pdevinfo.res = &res[0];
-
-	pdev = platform_device_register_full(&pdevinfo);
-	if (IS_ERR(pdev)) {
-		dev_err(&pci->dev, "cannot register %s device\n", pdevinfo.name);
-		sof_pci_remove(pci);
-		platform_device_unregister(dmic_dev);
-		ret = PTR_ERR(pdev);
-	}
-
 	return ret;
 };
 
@@ -158,8 +92,6 @@ static void acp_pci_rn_remove(struct pci_dev *pci)
 {
 	if (dmic_dev)
 		platform_device_unregister(dmic_dev);
-	if (pdev)
-		platform_device_unregister(pdev);
 
 	return sof_pci_remove(pci);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/6] ASoC: SOF: amd: remove acp_dai_probe() function
  2023-04-03  7:16 [PATCH 1/6] ASoC: SOF: amd: remove unused code Vijendar Mukunda
@ 2023-04-03  7:16 ` Vijendar Mukunda
  2023-04-03  7:16 ` [PATCH 3/6] ASoC: SOF: amd: remove unused variables Vijendar Mukunda
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Vijendar Mukunda @ 2023-04-03  7:16 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Vijendar Mukunda, Pierre-Louis Bossart, Liam Girdwood,
	Peter Ujfalusi, Bard Liao, Ranjani Sridharan, Kai Vehmanen,
	Daniel Baluta, Jaroslav Kysela, Takashi Iwai,
	V sujith kumar Reddy, Ajit Kumar Pandey,
	moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS,
	open list

ACP SOF driver supports different audio configurations.
Explicit condition check for I2S configuration will break
other audio endpoint configurations.

acp_dai_probe() function is not required as we have
machine select logic to select the exact machine.

Remove acp_dai_probe() from existing AMD PCI driver code base.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/sof/amd/acp-common.c | 16 ----------------
 sound/soc/sof/amd/acp.h        |  1 -
 sound/soc/sof/amd/rembrandt.c  |  4 ----
 sound/soc/sof/amd/renoir.c     |  3 ---
 4 files changed, 24 deletions(-)

diff --git a/sound/soc/sof/amd/acp-common.c b/sound/soc/sof/amd/acp-common.c
index 8ce4c8956933..df36b411a12e 100644
--- a/sound/soc/sof/amd/acp-common.c
+++ b/sound/soc/sof/amd/acp-common.c
@@ -18,22 +18,6 @@
 #include "acp-dsp-offset.h"
 #include <sound/sof/xtensa.h>
 
-int acp_dai_probe(struct snd_soc_dai *dai)
-{
-	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(dai->component);
-	const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata);
-	unsigned int val;
-
-	val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, desc->i2s_pin_config_offset);
-	if (val != desc->i2s_mode) {
-		dev_err(sdev->dev, "I2S Mode is not supported (I2S_PIN_CONFIG: %#x)\n", val);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL_NS(acp_dai_probe, SND_SOC_SOF_AMD_COMMON);
-
 /**
  * amd_sof_ipc_dump() - This function is called when IPC tx times out.
  * @sdev: SOF device.
diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h
index acad57947616..d7fc24917b3c 100644
--- a/sound/soc/sof/amd/acp.h
+++ b/sound/soc/sof/amd/acp.h
@@ -248,7 +248,6 @@ int sof_renoir_ops_init(struct snd_sof_dev *sdev);
 extern struct snd_sof_dsp_ops sof_rembrandt_ops;
 int sof_rembrandt_ops_init(struct snd_sof_dev *sdev);
 
-int acp_dai_probe(struct snd_soc_dai *dai);
 struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev);
 /* Machine configuration */
 int snd_amd_acp_find_config(struct pci_dev *pci);
diff --git a/sound/soc/sof/amd/rembrandt.c b/sound/soc/sof/amd/rembrandt.c
index 5288ab882fc9..f1d1ba57ab3a 100644
--- a/sound/soc/sof/amd/rembrandt.c
+++ b/sound/soc/sof/amd/rembrandt.c
@@ -48,7 +48,6 @@ static struct snd_soc_dai_driver rembrandt_sof_dai[] = {
 			.rate_min = 8000,
 			.rate_max = 48000,
 		},
-		.probe = &acp_dai_probe,
 	},
 
 	[I2S_BT_INSTANCE] = {
@@ -73,7 +72,6 @@ static struct snd_soc_dai_driver rembrandt_sof_dai[] = {
 			.rate_min = 8000,
 			.rate_max = 48000,
 		},
-		.probe = &acp_dai_probe,
 	},
 
 	[I2S_SP_INSTANCE] = {
@@ -98,7 +96,6 @@ static struct snd_soc_dai_driver rembrandt_sof_dai[] = {
 			.rate_min = 8000,
 			.rate_max = 48000,
 		},
-		.probe = &acp_dai_probe,
 	},
 
 	[PDM_DMIC_INSTANCE] = {
@@ -126,7 +123,6 @@ static struct snd_soc_dai_driver rembrandt_sof_dai[] = {
 			.rate_min = 8000,
 			.rate_max = 96000,
 		},
-		.probe = &acp_dai_probe,
 	},
 };
 
diff --git a/sound/soc/sof/amd/renoir.c b/sound/soc/sof/amd/renoir.c
index adade2e3d3be..47b863f6258c 100644
--- a/sound/soc/sof/amd/renoir.c
+++ b/sound/soc/sof/amd/renoir.c
@@ -47,7 +47,6 @@ static struct snd_soc_dai_driver renoir_sof_dai[] = {
 			.rate_min = 8000,
 			.rate_max = 48000,
 		},
-		.probe = &acp_dai_probe,
 	},
 
 	[I2S_SP_INSTANCE] = {
@@ -72,7 +71,6 @@ static struct snd_soc_dai_driver renoir_sof_dai[] = {
 			.rate_min = 8000,
 			.rate_max = 48000,
 		},
-		.probe = &acp_dai_probe,
 	},
 
 	[PDM_DMIC_INSTANCE] = {
@@ -100,7 +98,6 @@ static struct snd_soc_dai_driver renoir_sof_dai[] = {
 			.rate_min = 8000,
 			.rate_max = 96000,
 		},
-		.probe = &acp_dai_probe,
 	},
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/6] ASoC: SOF: amd: remove unused variables
  2023-04-03  7:16 [PATCH 1/6] ASoC: SOF: amd: remove unused code Vijendar Mukunda
  2023-04-03  7:16 ` [PATCH 2/6] ASoC: SOF: amd: remove acp_dai_probe() function Vijendar Mukunda
@ 2023-04-03  7:16 ` Vijendar Mukunda
  2023-04-03  7:16 ` [PATCH 4/6] ASoC: SOF: amd: refactor get_chip_info callback Vijendar Mukunda
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Vijendar Mukunda @ 2023-04-03  7:16 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Vijendar Mukunda, Pierre-Louis Bossart, Liam Girdwood,
	Peter Ujfalusi, Bard Liao, Ranjani Sridharan, Kai Vehmanen,
	Daniel Baluta, Jaroslav Kysela, Takashi Iwai,
	V sujith kumar Reddy, Ajit Kumar Pandey, Rander Wang, Zheng Bin,
	moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS,
	open list

Remove unused variables - i2s_mode, i2s_pin_config_offset from code.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/sof/amd/acp.h     | 2 --
 sound/soc/sof/amd/pci-rmb.c | 2 --
 sound/soc/sof/amd/pci-rn.c  | 2 --
 3 files changed, 6 deletions(-)

diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h
index d7fc24917b3c..fd04e5ae7303 100644
--- a/sound/soc/sof/amd/acp.h
+++ b/sound/soc/sof/amd/acp.h
@@ -158,12 +158,10 @@ struct acp_dsp_stream {
 struct sof_amd_acp_desc {
 	unsigned int rev;
 	unsigned int host_bridge_id;
-	unsigned int i2s_mode;
 	u32 pgfsm_base;
 	u32 ext_intr_stat;
 	u32 dsp_intr_base;
 	u32 sram_pte_offset;
-	u32 i2s_pin_config_offset;
 	u32 hw_semaphore_offset;
 	u32 acp_clkmux_sel;
 	u32 fusion_dsp_offset;
diff --git a/sound/soc/sof/amd/pci-rmb.c b/sound/soc/sof/amd/pci-rmb.c
index d0a56e8f09c0..2b84f95072d3 100644
--- a/sound/soc/sof/amd/pci-rmb.c
+++ b/sound/soc/sof/amd/pci-rmb.c
@@ -31,12 +31,10 @@ static struct platform_device *dmic_dev;
 static const struct sof_amd_acp_desc rembrandt_chip_info = {
 	.rev		= 6,
 	.host_bridge_id = HOST_BRIDGE_RMB,
-	.i2s_mode	= 0x0a,
 	.pgfsm_base	= ACP6X_PGFSM_BASE,
 	.ext_intr_stat	= ACP6X_EXT_INTR_STAT,
 	.dsp_intr_base	= ACP6X_DSP_SW_INTR_BASE,
 	.sram_pte_offset = ACP6X_SRAM_PTE_OFFSET,
-	.i2s_pin_config_offset = ACP6X_I2S_PIN_CONFIG,
 	.hw_semaphore_offset = ACP6X_AXI2DAGB_SEM_0,
 	.acp_clkmux_sel = ACP6X_CLKMUX_SEL,
 	.fusion_dsp_offset = ACP6X_DSP_FUSION_RUNSTALL,
diff --git a/sound/soc/sof/amd/pci-rn.c b/sound/soc/sof/amd/pci-rn.c
index faab4c33a24d..a17b15552a7d 100644
--- a/sound/soc/sof/amd/pci-rn.c
+++ b/sound/soc/sof/amd/pci-rn.c
@@ -31,12 +31,10 @@ static struct platform_device *dmic_dev;
 static const struct sof_amd_acp_desc renoir_chip_info = {
 	.rev		= 3,
 	.host_bridge_id = HOST_BRIDGE_CZN,
-	.i2s_mode	= 0x04,
 	.pgfsm_base	= ACP3X_PGFSM_BASE,
 	.ext_intr_stat	= ACP3X_EXT_INTR_STAT,
 	.dsp_intr_base	= ACP3X_DSP_SW_INTR_BASE,
 	.sram_pte_offset = ACP3X_SRAM_PTE_OFFSET,
-	.i2s_pin_config_offset = ACP3X_I2S_PIN_CONFIG,
 	.hw_semaphore_offset = ACP3X_AXI2DAGB_SEM_0,
 	.acp_clkmux_sel	= ACP3X_CLKMUX_SEL,
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/6] ASoC: SOF: amd: refactor get_chip_info callback
  2023-04-03  7:16 [PATCH 1/6] ASoC: SOF: amd: remove unused code Vijendar Mukunda
  2023-04-03  7:16 ` [PATCH 2/6] ASoC: SOF: amd: remove acp_dai_probe() function Vijendar Mukunda
  2023-04-03  7:16 ` [PATCH 3/6] ASoC: SOF: amd: remove unused variables Vijendar Mukunda
@ 2023-04-03  7:16 ` Vijendar Mukunda
  2023-04-03  7:16 ` [PATCH 5/6] ASoC: SOF: amd: refactor error checks in probe call Vijendar Mukunda
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Vijendar Mukunda @ 2023-04-03  7:16 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Vijendar Mukunda, Pierre-Louis Bossart, Liam Girdwood,
	Peter Ujfalusi, Bard Liao, Ranjani Sridharan, Kai Vehmanen,
	Daniel Baluta, Jaroslav Kysela, Takashi Iwai,
	V sujith kumar Reddy, Ajit Kumar Pandey, Ajye Huang,
	moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS,
	open list

Move get_chip_info callback to the start of API.
This should be first check in probe() call.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/sof/amd/acp.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
index d5ccd4d09278..e8fe324c23d0 100644
--- a/sound/soc/sof/amd/acp.c
+++ b/sound/soc/sof/amd/acp.c
@@ -470,6 +470,11 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
 	unsigned int addr;
 	int ret;
 
+	chip = get_chip_info(sdev->pdata);
+	if (!chip) {
+		dev_err(sdev->dev, "no such device supported, chip id:%x\n", pci->device);
+		return -EIO;
+	}
 	adata = devm_kzalloc(sdev->dev, sizeof(struct acp_dev_data),
 			     GFP_KERNEL);
 	if (!adata)
@@ -486,13 +491,6 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
 	pci_set_master(pci);
 
 	sdev->pdata->hw_pdata = adata;
-
-	chip = get_chip_info(sdev->pdata);
-	if (!chip) {
-		dev_err(sdev->dev, "no such device supported, chip id:%x\n", pci->device);
-		return -EIO;
-	}
-
 	adata->smn_dev = pci_get_device(PCI_VENDOR_ID_AMD, chip->host_bridge_id, NULL);
 	if (!adata->smn_dev) {
 		dev_err(sdev->dev, "Failed to get host bridge device\n");
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/6] ASoC: SOF: amd: refactor error checks in probe call
  2023-04-03  7:16 [PATCH 1/6] ASoC: SOF: amd: remove unused code Vijendar Mukunda
                   ` (2 preceding siblings ...)
  2023-04-03  7:16 ` [PATCH 4/6] ASoC: SOF: amd: refactor get_chip_info callback Vijendar Mukunda
@ 2023-04-03  7:16 ` Vijendar Mukunda
  2023-04-03  7:16 ` [PATCH 6/6] ASoC: SOF: amd: refactor dmic codec platform device creation Vijendar Mukunda
  2023-04-03 15:07 ` [PATCH 1/6] ASoC: SOF: amd: remove unused code Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Vijendar Mukunda @ 2023-04-03  7:16 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Vijendar Mukunda, Pierre-Louis Bossart, Liam Girdwood,
	Peter Ujfalusi, Bard Liao, Ranjani Sridharan, Kai Vehmanen,
	Daniel Baluta, Jaroslav Kysela, Takashi Iwai,
	V sujith kumar Reddy, Ajit Kumar Pandey, Ajye Huang,
	moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS,
	open list

Refactor error checks code in probe() callback.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/sof/amd/acp.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
index e8fe324c23d0..dbf9ee6d79ed 100644
--- a/sound/soc/sof/amd/acp.c
+++ b/sound/soc/sof/amd/acp.c
@@ -503,16 +503,12 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
 	if (ret < 0) {
 		dev_err(sdev->dev, "failed to register IRQ %d\n",
 			sdev->ipc_irq);
-		pci_dev_put(adata->smn_dev);
-		return ret;
+		goto free_smn_dev;
 	}
 
 	ret = acp_init(sdev);
-	if (ret < 0) {
-		free_irq(sdev->ipc_irq, sdev);
-		pci_dev_put(adata->smn_dev);
-		return ret;
-	}
+	if (ret < 0)
+		goto free_ipc_irq;
 
 	sdev->dsp_box.offset = 0;
 	sdev->dsp_box.size = BOX_SIZE_512;
@@ -528,6 +524,12 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
 	acp_dsp_stream_init(sdev);
 
 	return 0;
+
+free_ipc_irq:
+	free_irq(sdev->ipc_irq, sdev);
+free_smn_dev:
+	pci_dev_put(adata->smn_dev);
+	return ret;
 }
 EXPORT_SYMBOL_NS(amd_sof_acp_probe, SND_SOC_SOF_AMD_COMMON);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/6] ASoC: SOF: amd: refactor dmic codec platform device creation
  2023-04-03  7:16 [PATCH 1/6] ASoC: SOF: amd: remove unused code Vijendar Mukunda
                   ` (3 preceding siblings ...)
  2023-04-03  7:16 ` [PATCH 5/6] ASoC: SOF: amd: refactor error checks in probe call Vijendar Mukunda
@ 2023-04-03  7:16 ` Vijendar Mukunda
  2023-04-03 15:07 ` [PATCH 1/6] ASoC: SOF: amd: remove unused code Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Vijendar Mukunda @ 2023-04-03  7:16 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Vijendar Mukunda, Pierre-Louis Bossart, Liam Girdwood,
	Peter Ujfalusi, Bard Liao, Ranjani Sridharan, Kai Vehmanen,
	Daniel Baluta, Jaroslav Kysela, Takashi Iwai,
	V sujith kumar Reddy, Ajit Kumar Pandey, Ajye Huang, Rander Wang,
	Zheng Bin,
	moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS,
	open list

Under snd_sof_dev device scope, create platform device for dmic
codec.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/sof/amd/acp.c     | 17 +++++++++++++++--
 sound/soc/sof/amd/acp.h     |  2 ++
 sound/soc/sof/amd/pci-rmb.c | 19 +------------------
 sound/soc/sof/amd/pci-rn.c  | 19 +------------------
 4 files changed, 19 insertions(+), 38 deletions(-)

diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
index dbf9ee6d79ed..2ae76bcd3590 100644
--- a/sound/soc/sof/amd/acp.c
+++ b/sound/soc/sof/amd/acp.c
@@ -481,11 +481,18 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
 		return -ENOMEM;
 
 	adata->dev = sdev;
+	adata->dmic_dev = platform_device_register_data(sdev->dev, "dmic-codec",
+							PLATFORM_DEVID_NONE, NULL, 0);
+	if (IS_ERR(adata->dmic_dev)) {
+		dev_err(sdev->dev, "failed to register platform for dmic codec\n");
+		return PTR_ERR(adata->dmic_dev);
+	}
 	addr = pci_resource_start(pci, ACP_DSP_BAR);
 	sdev->bar[ACP_DSP_BAR] = devm_ioremap(sdev->dev, addr, pci_resource_len(pci, ACP_DSP_BAR));
 	if (!sdev->bar[ACP_DSP_BAR]) {
 		dev_err(sdev->dev, "ioremap error\n");
-		return -ENXIO;
+		ret = -ENXIO;
+		goto unregister_dev;
 	}
 
 	pci_set_master(pci);
@@ -494,7 +501,8 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
 	adata->smn_dev = pci_get_device(PCI_VENDOR_ID_AMD, chip->host_bridge_id, NULL);
 	if (!adata->smn_dev) {
 		dev_err(sdev->dev, "Failed to get host bridge device\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto unregister_dev;
 	}
 
 	sdev->ipc_irq = pci->irq;
@@ -529,6 +537,8 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
 	free_irq(sdev->ipc_irq, sdev);
 free_smn_dev:
 	pci_dev_put(adata->smn_dev);
+unregister_dev:
+	platform_device_unregister(adata->dmic_dev);
 	return ret;
 }
 EXPORT_SYMBOL_NS(amd_sof_acp_probe, SND_SOC_SOF_AMD_COMMON);
@@ -543,6 +553,9 @@ int amd_sof_acp_remove(struct snd_sof_dev *sdev)
 	if (sdev->ipc_irq)
 		free_irq(sdev->ipc_irq, sdev);
 
+	if (adata->dmic_dev)
+		platform_device_unregister(adata->dmic_dev);
+
 	return acp_reset(sdev);
 }
 EXPORT_SYMBOL_NS(amd_sof_acp_remove, SND_SOC_SOF_AMD_COMMON);
diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h
index fd04e5ae7303..1c535cc6c3a9 100644
--- a/sound/soc/sof/amd/acp.h
+++ b/sound/soc/sof/amd/acp.h
@@ -170,6 +170,8 @@ struct sof_amd_acp_desc {
 /* Common device data struct for ACP devices */
 struct acp_dev_data {
 	struct snd_sof_dev  *dev;
+	/* DMIC device */
+	struct platform_device *dmic_dev;
 	unsigned int fw_bin_size;
 	unsigned int fw_data_bin_size;
 	u32 fw_bin_page_count;
diff --git a/sound/soc/sof/amd/pci-rmb.c b/sound/soc/sof/amd/pci-rmb.c
index 2b84f95072d3..eaf70ea6e556 100644
--- a/sound/soc/sof/amd/pci-rmb.c
+++ b/sound/soc/sof/amd/pci-rmb.c
@@ -26,8 +26,6 @@
 #define ACP6x_REG_START		0x1240000
 #define ACP6x_REG_END		0x125C000
 
-static struct platform_device *dmic_dev;
-
 static const struct sof_amd_acp_desc rembrandt_chip_info = {
 	.rev		= 6,
 	.host_bridge_id = HOST_BRIDGE_RMB,
@@ -65,32 +63,17 @@ static const struct sof_dev_desc rembrandt_desc = {
 
 static int acp_pci_rmb_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
-	struct device *dev = &pci->dev;
 	unsigned int flag;
-	int ret;
 
 	flag = snd_amd_acp_find_config(pci);
 	if (flag != FLAG_AMD_SOF && flag != FLAG_AMD_SOF_ONLY_DMIC)
 		return -ENODEV;
 
-	ret = sof_pci_probe(pci, pci_id);
-	if (ret != 0)
-		return ret;
-
-	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");
-		sof_pci_remove(pci);
-		return PTR_ERR(dmic_dev);
-	}
-	return ret;
+	return sof_pci_probe(pci, pci_id);
 };
 
 static void acp_pci_rmb_remove(struct pci_dev *pci)
 {
-	if (dmic_dev)
-		platform_device_unregister(dmic_dev);
-
 	sof_pci_remove(pci);
 }
 
diff --git a/sound/soc/sof/amd/pci-rn.c b/sound/soc/sof/amd/pci-rn.c
index a17b15552a7d..4809cb644152 100644
--- a/sound/soc/sof/amd/pci-rn.c
+++ b/sound/soc/sof/amd/pci-rn.c
@@ -26,8 +26,6 @@
 #define ACP3x_REG_START		0x1240000
 #define ACP3x_REG_END		0x125C000
 
-static struct platform_device *dmic_dev;
-
 static const struct sof_amd_acp_desc renoir_chip_info = {
 	.rev		= 3,
 	.host_bridge_id = HOST_BRIDGE_CZN,
@@ -65,32 +63,17 @@ static const struct sof_dev_desc renoir_desc = {
 
 static int acp_pci_rn_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
-	struct device *dev = &pci->dev;
 	unsigned int flag;
-	int ret;
 
 	flag = snd_amd_acp_find_config(pci);
 	if (flag != FLAG_AMD_SOF && flag != FLAG_AMD_SOF_ONLY_DMIC)
 		return -ENODEV;
 
-	ret = sof_pci_probe(pci, pci_id);
-	if (ret != 0)
-		return ret;
-
-	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");
-		sof_pci_remove(pci);
-		return PTR_ERR(dmic_dev);
-	}
-	return ret;
+	return sof_pci_probe(pci, pci_id);
 };
 
 static void acp_pci_rn_remove(struct pci_dev *pci)
 {
-	if (dmic_dev)
-		platform_device_unregister(dmic_dev);
-
 	return sof_pci_remove(pci);
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/6] ASoC: SOF: amd: remove unused code
  2023-04-03  7:16 [PATCH 1/6] ASoC: SOF: amd: remove unused code Vijendar Mukunda
                   ` (4 preceding siblings ...)
  2023-04-03  7:16 ` [PATCH 6/6] ASoC: SOF: amd: refactor dmic codec platform device creation Vijendar Mukunda
@ 2023-04-03 15:07 ` Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2023-04-03 15:07 UTC (permalink / raw)
  To: Vijendar Mukunda
  Cc: alsa-devel, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Pierre-Louis Bossart, Liam Girdwood, Peter Ujfalusi, Bard Liao,
	Ranjani Sridharan, Kai Vehmanen, Daniel Baluta, Jaroslav Kysela,
	Takashi Iwai, Ajit Kumar Pandey, Rander Wang,
	V sujith kumar Reddy, Zheng Bin,
	moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS,
	open list

On Mon, 03 Apr 2023 12:46:41 +0530, Vijendar Mukunda wrote:
> During initial SOF driver bring up on AMD platforms, only DMIC
> support was added. As of today, we have a complete SOF solution for
> I2S endpoints along with DMIC endpoint.
> This code is no longer required.
> Remove unused code from RMB and RN platform ACP PCI driver.
> 
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/6] ASoC: SOF: amd: remove unused code
      commit: 56e008146e5b46059c5469a8b47478ab78f5b895
[2/6] ASoC: SOF: amd: remove acp_dai_probe() function
      commit: 9eb48aeddd8dcf2defd94a837a65e052576cf42b
[3/6] ASoC: SOF: amd: remove unused variables
      commit: 2675de62de702dbda936eb0f9a20ce3d8fed5ab5
[4/6] ASoC: SOF: amd: refactor get_chip_info callback
      commit: 292b544ef4555ec5c69522e9c6eace6a90c4cd00
[5/6] ASoC: SOF: amd: refactor error checks in probe call
      commit: c7a3662f14d7e0add7b50dc2f971e77bebb333cc
[6/6] ASoC: SOF: amd: refactor dmic codec platform device creation
      commit: dd6bdd8b4d41b8f9db4b88dff2d10c0c62dbeb1d

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-04-03 15:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-03  7:16 [PATCH 1/6] ASoC: SOF: amd: remove unused code Vijendar Mukunda
2023-04-03  7:16 ` [PATCH 2/6] ASoC: SOF: amd: remove acp_dai_probe() function Vijendar Mukunda
2023-04-03  7:16 ` [PATCH 3/6] ASoC: SOF: amd: remove unused variables Vijendar Mukunda
2023-04-03  7:16 ` [PATCH 4/6] ASoC: SOF: amd: refactor get_chip_info callback Vijendar Mukunda
2023-04-03  7:16 ` [PATCH 5/6] ASoC: SOF: amd: refactor error checks in probe call Vijendar Mukunda
2023-04-03  7:16 ` [PATCH 6/6] ASoC: SOF: amd: refactor dmic codec platform device creation Vijendar Mukunda
2023-04-03 15:07 ` [PATCH 1/6] ASoC: SOF: amd: remove unused code Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).