From: Lee Jones <lee.jones@linaro.org>
To: Ravulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
Cc: , Sanju R Mehta <sanju.mehta@amd.com>,
"moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
MANAGEM..." <alsa-devel@alsa-project.org>,
Maruthi Srinivas Bayyavarapu <Maruthi.Bayyavarapu@amd.com>,
Vijendar Mukunda <Vijendar.Mukunda@amd.com>,
on@alsa-project.org, Takashi Iwai <tiwai@suse.com>,
open list <linux-kernel@vger.kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
To-header@alsa-project.org, Mark Brown <broonie@kernel.org>,
"input <"@alsa-project.org, no@alsa-project.org,
Alexander.Deucher@amd.com,
Colin Ian King <colin.king@canonical.com>,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [alsa-devel] [PATCH 2/7] ASoC: amd: Registering device endpoints using MFD framework
Date: Tue, 1 Oct 2019 07:45:39 +0100 [thread overview]
Message-ID: <20191001064539.GB11769@dell> (raw)
In-Reply-To: <1569891524-18875-2-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com>
On Tue, 01 Oct 2019, Ravulapati Vishnu vardhan rao wrote:
> Removed platform based endpoint registering in ACP-PCI driver.
> Now Registering PCM DMA and multiple I2S instances: SP and BT endpoint
> devices automatically by using MFD framework.
This is a hack.
Why are you using the MFD framework outside of drivers/mfd?
If this driver is an MFD, then please create an MFD driver.
If it's not, please do not use the MFD API.
> Signed-off-by: Ravulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
> ---
> sound/soc/amd/raven/acp3x.h | 8 +++
> sound/soc/amd/raven/pci-acp3x.c | 123 ++++++++++++++++++++++++++--------------
> 2 files changed, 90 insertions(+), 41 deletions(-)
>
> diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h
> index 4f2cadd..c122dc6 100644
> --- a/sound/soc/amd/raven/acp3x.h
> +++ b/sound/soc/amd/raven/acp3x.h
> @@ -7,13 +7,21 @@
>
> #include "chip_offset_byte.h"
>
> +#define ACP3x_DEVS 3
> #define ACP3x_PHY_BASE_ADDRESS 0x1240000
> #define ACP3x_I2S_MODE 0
> #define ACP3x_REG_START 0x1240000
> #define ACP3x_REG_END 0x1250200
> +#define ACP3x_I2STDM_REG_START 0x1242400
> +#define ACP3x_I2STDM_REG_END 0x1242410
> +#define ACP3x_BT_TDM_REG_START 0x1242800
> +#define ACP3x_BT_TDM_REG_END 0x1242810
> #define I2S_MODE 0x04
> +#define I2S_RX_THRESHOLD 27
> +#define I2S_TX_THRESHOLD 28
> #define BT_TX_THRESHOLD 26
> #define BT_RX_THRESHOLD 25
> +#define ACP_ERR_INTR_MASK 29
> #define ACP3x_POWER_ON 0x00
> #define ACP3x_POWER_ON_IN_PROGRESS 0x01
> #define ACP3x_POWER_OFF 0x02
> diff --git a/sound/soc/amd/raven/pci-acp3x.c b/sound/soc/amd/raven/pci-acp3x.c
> index 8f6bf00..d9f5bc0 100644
> --- a/sound/soc/amd/raven/pci-acp3x.c
> +++ b/sound/soc/amd/raven/pci-acp3x.c
> @@ -9,13 +9,21 @@
> #include <linux/io.h>
> #include <linux/platform_device.h>
> #include <linux/interrupt.h>
> +#include <linux/mfd/core.h>
>
> #include "acp3x.h"
>
> +struct i2s_platform_data {
> + unsigned int cap;
> + int channel;
> + u32 snd_rates;
> +};
> struct acp3x_dev_data {
> + struct device *parent;
> + struct mfd_cell *cell;
> + struct resource *res;
> void __iomem *acp3x_base;
> bool acp3x_audio_mode;
> - struct resource *res;
> struct platform_device *pdev;
> };
>
> @@ -23,9 +31,11 @@ static int snd_acp3x_probe(struct pci_dev *pci,
> const struct pci_device_id *pci_id)
> {
> int ret;
> - u32 addr, val;
> + resource_size_t addr;
> + int val, i, r;
> struct acp3x_dev_data *adata;
> - struct platform_device_info pdevinfo;
> + struct device *dev;
> + struct i2s_platform_data *i2s_pdata;
> unsigned int irqflags;
>
> if (pci_enable_device(pci)) {
> @@ -56,55 +66,87 @@ static int snd_acp3x_probe(struct pci_dev *pci,
> }
> pci_set_master(pci);
> pci_set_drvdata(pci, adata);
> -
> + adata->parent = &pci->dev;
> val = rv_readl(adata->acp3x_base + mmACP_I2S_PIN_CONFIG);
> switch (val) {
> case I2S_MODE:
> adata->res = devm_kzalloc(&pci->dev,
> - sizeof(struct resource) * 2,
> - GFP_KERNEL);
> - if (!adata->res) {
> + sizeof(struct resource) * 4,
> + GFP_KERNEL);
> + adata->cell = devm_kzalloc(&pci->dev,
> + sizeof(struct mfd_cell) * ACP3x_DEVS,
> + GFP_KERNEL);
> + if (!adata->cell) {
> ret = -ENOMEM;
> goto unmap_mmio;
> }
>
> - adata->res[0].name = "acp3x_i2s_iomem";
> - adata->res[0].flags = IORESOURCE_MEM;
> - adata->res[0].start = addr;
> - adata->res[0].end = addr + (ACP3x_REG_END - ACP3x_REG_START);
> -
> - adata->res[1].name = "acp3x_i2s_irq";
> - adata->res[1].flags = IORESOURCE_IRQ;
> - adata->res[1].start = pci->irq;
> - adata->res[1].end = pci->irq;
> -
> - adata->acp3x_audio_mode = ACP3x_I2S_MODE;
> -
> - memset(&pdevinfo, 0, sizeof(pdevinfo));
> - pdevinfo.name = "acp3x_rv_i2s";
> - pdevinfo.id = 0;
> - pdevinfo.parent = &pci->dev;
> - pdevinfo.num_res = 2;
> - pdevinfo.res = adata->res;
> - pdevinfo.data = &irqflags;
> - pdevinfo.size_data = sizeof(irqflags);
> -
> - adata->pdev = platform_device_register_full(&pdevinfo);
> - if (IS_ERR(adata->pdev)) {
> - dev_err(&pci->dev, "cannot register %s device\n",
> - pdevinfo.name);
> - ret = PTR_ERR(adata->pdev);
> - goto unmap_mmio;
> + i2s_pdata = devm_kzalloc(&pci->dev,
> + sizeof(struct i2s_platform_data) * ACP3x_DEVS,
> + GFP_KERNEL);
> + if (i2s_pdata == NULL) {
> + kfree(adata->res);
> + kfree(adata->cell);
> + return -ENOMEM;
> }
> + adata->res[0].name = "acp3x_i2s_iomem";
> + adata->res[0].flags = IORESOURCE_MEM;
> + adata->res[0].start = addr;
> + adata->res[0].end = addr +
> + (ACP3x_REG_END - ACP3x_REG_START);
> + i2s_pdata[0].cap = 0;
> + i2s_pdata[0].snd_rates = SNDRV_PCM_RATE_8000_96000;
> +
> + adata->res[1].name = "acp3x_i2s_sp_play_cap";
> + adata->res[1].flags = IORESOURCE_MEM;
> + adata->res[1].start = addr + ACP3x_I2STDM_REG_START;
> + adata->res[1].end = addr + ACP3x_I2STDM_REG_END;
> + i2s_pdata[1].cap = 0;
> + i2s_pdata[1].snd_rates = SNDRV_PCM_RATE_8000_96000;
> +
> + adata->res[2].name = "acp3x_i2s_bt_play_cap";
> + adata->res[2].flags = IORESOURCE_MEM;
> + adata->res[2].start = addr + ACP3x_BT_TDM_REG_START;
> + adata->res[2].end = addr + ACP3x_BT_TDM_REG_END;
> + i2s_pdata[2].cap = 0;
> + i2s_pdata[2].snd_rates = SNDRV_PCM_RATE_8000_96000;
> +
> + adata->res[3].name = "acp3x_i2s_irq";
> + adata->res[3].flags = IORESOURCE_IRQ;
> + adata->res[3].start = pci->irq;
> + adata->res[3].end = adata->res[3].start;
> +
> + adata->acp3x_audio_mode = ACP3x_I2S_MODE;
> +
> + adata->cell[0].name = "acp3x_rv_i2s_dma";
> + adata->cell[0].num_resources = 4;
> + adata->cell[0].resources = &adata->res[0];
> + adata->cell[0].platform_data = &irqflags;
> + adata->cell[0].pdata_size = sizeof(irqflags);
> +
> + adata->cell[1].name = "acp3x_i2s_playcap";
> + adata->cell[1].num_resources = 1;
> + adata->cell[1].resources = &adata->res[1];
> + adata->cell[1].platform_data = &i2s_pdata[0];
> + adata->cell[1].pdata_size =
> + sizeof(struct i2s_platform_data);
> +
> + adata->cell[2].name = "acp3x_i2s_playcap";
> + adata->cell[2].num_resources = 1;
> + adata->cell[2].resources = &adata->res[2];
> + adata->cell[2].platform_data = &i2s_pdata[1];
> + adata->cell[2].pdata_size =
> + sizeof(struct i2s_platform_data);
> + r = mfd_add_hotplug_devices(adata->parent,
> + adata->cell, ACP3x_DEVS);
> break;
> - default:
> - dev_err(&pci->dev, "Invalid ACP audio mode : %d\n", val);
> - ret = -ENODEV;
> - goto unmap_mmio;
> }
> return 0;
>
> unmap_mmio:
> + mfd_remove_devices(adata->parent);
> + kfree(adata->res);
> + kfree(adata->cell);
> iounmap(adata->acp3x_base);
> release_regions:
> pci_release_regions(pci);
> @@ -117,10 +159,8 @@ static int snd_acp3x_probe(struct pci_dev *pci,
> static void snd_acp3x_remove(struct pci_dev *pci)
> {
> struct acp3x_dev_data *adata = pci_get_drvdata(pci);
> -
> - platform_device_unregister(adata->pdev);
> + mfd_remove_devices(adata->parent);
> iounmap(adata->acp3x_base);
> -
> pci_release_regions(pci);
> pci_disable_device(pci);
> }
> @@ -142,6 +182,7 @@ static struct pci_driver acp3x_driver = {
>
> module_pci_driver(acp3x_driver);
>
> +MODULE_AUTHOR("Vishnuvardhanrao.Ravulapati@amd.com");
> MODULE_AUTHOR("Maruthi.Bayyavarapu@amd.com");
> MODULE_DESCRIPTION("AMD ACP3x PCI driver");
> MODULE_LICENSE("GPL v2");
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2019-10-01 6:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 0:58 [alsa-devel] [PATCH 1/7] ASoC: amd: No need PCI-MSI interrupts Ravulapati Vishnu vardhan rao
2019-10-01 0:58 ` [alsa-devel] [PATCH 2/7] ASoC: amd: Registering device endpoints using MFD framework Ravulapati Vishnu vardhan rao
2019-10-01 6:45 ` Lee Jones [this message]
2019-10-01 10:00 ` vishnu
2019-10-01 12:00 ` Lee Jones
2019-10-01 18:53 ` Deucher, Alexander
2019-10-02 12:37 ` Lee Jones
2019-10-02 13:11 ` Deucher, Alexander
2019-10-02 13:35 ` Lee Jones
2019-10-10 13:08 ` RAVULAPATI, VISHNU VARDHAN RAO
2019-10-14 7:03 ` Lee Jones
2019-10-17 9:26 ` vishnu
2019-10-01 0:58 ` [alsa-devel] [PATCH 3/7] ASoC: amd: Refactoring of DAI from DMA driver Ravulapati Vishnu vardhan rao
2019-10-01 0:58 ` [alsa-devel] [PATCH 4/7] ASoC: amd: Enabling I2S instance in DMA and DAI Ravulapati Vishnu vardhan rao
2019-10-01 0:58 ` [alsa-devel] [PATCH 5/7] ASoC: amd: add ACP3x TDM mode support Ravulapati Vishnu vardhan rao
2019-10-01 0:58 ` [alsa-devel] [PATCH 6/7] ASoC: AMD: handle ACP3x i2s-sp watermark interrupt Ravulapati Vishnu vardhan rao
2019-10-01 0:58 ` [alsa-devel] [PATCH 7/7] ASoc: amd: Added ACP3x system resume and runtime pm ops Ravulapati Vishnu vardhan rao
2019-10-01 17:23 ` [alsa-devel] [PATCH 1/7] ASoC: amd: No need PCI-MSI interrupts Deucher, Alexander
2019-10-01 17:29 ` Mark Brown
2019-10-10 10:40 ` vishnu
2019-10-17 9:33 ` vishnu
2019-10-17 11:12 ` Mark Brown
2019-10-17 13:56 ` Deucher, Alexander
2019-10-17 9:31 ` vishnu
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=20191001064539.GB11769@dell \
--to=lee.jones@linaro.org \
--cc="input <"@alsa-project.org \
--cc=Alexander.Deucher@amd.com \
--cc=Maruthi.Bayyavarapu@amd.com \
--cc=To-header@alsa-project.org \
--cc=Vijendar.Mukunda@amd.com \
--cc=Vishnuvardhanrao.Ravulapati@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=colin.king@canonical.com \
--cc=dan.carpenter@oracle.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=no@alsa-project.org \
--cc=on@alsa-project.org \
--cc=sanju.mehta@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