From: Jyri Sarha <jsarha@ti.com>
To: Misael Lopez Cruz <misael.lopez@ti.com>,
alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
linux-omap@vger.kernel.org
Cc: peter.ujfalusi@ti.com, broonie@kernel.org,
liam.r.girdwood@linux.intel.com, bcousson@baylibre.com
Subject: Re: [PATCH v2] ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller
Date: Tue, 2 Jun 2015 23:04:46 +0300 [thread overview]
Message-ID: <556E0C5E.6040603@ti.com> (raw)
In-Reply-To: <556DD6EB.5010504@ti.com>
On 06/02/15 19:16, Misael Lopez Cruz wrote:
> Jyri,
>
> On 06/02/2015 08:49 AM, Jyri Sarha wrote:
>> Find the configured DMA controller by asking for a DMA channel in the
>> probe phase and releasing it right after. The controller device can be
>> found via the dma_chan struct and the controller is recognized from
>> the compatible property of its device node. The patch assumes EDMA if
>> there is no device node.
>>
>> Signed-off-by: Jyri Sarha <jsarha@ti.com>
>> ---
>> Changes since first patch version:
>> - Change enum names from MCASP_?DMA to PCM_?DMA
>> - Return PCM_EDMA if !mcasp->dev->of_node
>> - Do not ignore possible error code returned by
>> davinci_mcasp_get_dma_type()
>>
>> sound/soc/davinci/davinci-mcasp.c | 68
>> +++++++++++++++++++++++++++++++++------
>> 1 file changed, 58 insertions(+), 10 deletions(-)
>>
>> diff --git a/sound/soc/davinci/davinci-mcasp.c
>> b/sound/soc/davinci/davinci-mcasp.c
>> index d793494..3b78c3e 100644
>> --- a/sound/soc/davinci/davinci-mcasp.c
>> +++ b/sound/soc/davinci/davinci-mcasp.c
>> @@ -1565,6 +1565,49 @@ static int
>> davinci_mcasp_init_ch_constraints(struct davinci_mcasp *mcasp)
>> return ret;
>> }
>>
>> +enum {
>> + PCM_EDMA,
>> + PCM_SDMA,
>> +};
>> +static const char *sdma_prefix = "ti,omap";
>> +
>> +static int davinci_mcasp_get_dma_type(struct davinci_mcasp *mcasp)
>> +{
>> + struct dma_chan *chan;
>> + const char *tmp;
>> + int ret = PCM_EDMA;
>> +
>> + if (!mcasp->dev->of_node)
>> + return PCM_EDMA;
>> +
>> + tmp = mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data;
>> + chan = dma_request_slave_channel_reason(mcasp->dev, tmp);
>> + if (IS_ERR(chan)) {
>> + if (PTR_ERR(chan) != -EPROBE_DEFER)
>> + dev_err(mcasp->dev,
>> + "Can't verify DMA configuration (%ld)\n",
>> + PTR_ERR(chan));
>> + return PTR_ERR(chan);
>> + }
>> + BUG_ON(!chan->device || !chan->device->dev);
>> +
>> + if (chan->device->dev->of_node)
>> + ret = of_property_read_string(chan->device->dev->of_node,
>> + "compatible", &tmp);
>
> I wonder how this is going to play out when the DMA crossbar is present
> (i.e. dra7 family).
>
> In that case, isn't the 'compatible' string here that of the DMA
> crossbar (not the one from the DMA controller)?
That is exactly why I am requesting a channel and going from there. The
DMA router will do its thing in the middle and the device pointer found
via the returned dma_chan is pointing at the actual DMA controller.
I have tested the code on am57xx-beagle-x15, which is also using the DMA
crossbar.
>
>> + else
>> + dev_dbg(mcasp->dev, "DMA controller has no of-node\n");
>> +
>> + dma_release_channel(chan);
>> + if (ret)
>> + return ret;
>> +
>> + dev_dbg(mcasp->dev, "DMA controller compatible = \"%s\"\n", tmp);
>> + if (!strncmp(tmp, sdma_prefix, strlen(sdma_prefix)))
>> + return PCM_SDMA;
>> +
>> + return PCM_EDMA;
>> +}
>> +
>> static int davinci_mcasp_probe(struct platform_device *pdev)
>> {
>> struct snd_dmaengine_dai_dma_data *dma_data;
>> @@ -1763,27 +1806,32 @@ static int davinci_mcasp_probe(struct
>> platform_device *pdev)
>> if (ret != 0)
>> goto err;
>>
>> - switch (mcasp->version) {
>> + ret = davinci_mcasp_get_dma_type(mcasp);
>> + switch (ret) {
>> + case PCM_EDMA:
>> #if IS_BUILTIN(CONFIG_SND_EDMA_SOC) || \
>> (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
>> IS_MODULE(CONFIG_SND_EDMA_SOC))
>> - case MCASP_VERSION_1:
>> - case MCASP_VERSION_2:
>> - case MCASP_VERSION_3:
>> ret = edma_pcm_platform_register(&pdev->dev);
>> - break;
>> +#else
>> + dev_err(&pdev->dev, "Missing SND_EDMA_SOC\n");
>> + ret = -EINVAL;
>> #endif
>> + break;
>> + case PCM_SDMA:
>> #if IS_BUILTIN(CONFIG_SND_OMAP_SOC) || \
>> (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
>> IS_MODULE(CONFIG_SND_OMAP_SOC))
>> - case MCASP_VERSION_4:
>> ret = omap_pcm_platform_register(&pdev->dev);
>> - break;
>> +#else
>> + dev_err(&pdev->dev, "Missing SND_SDMA_SOC\n");
>> + ret = -EINVAL;
>> #endif
>> + break;
>> + case -EPROBE_DEFER:
>> + break;
>> default:
>> - dev_err(&pdev->dev, "Invalid McASP version: %d\n",
>> - mcasp->version);
>> - ret = -EINVAL;
>> + dev_err(&pdev->dev, "No DMA controller found (%d)\n", ret);
>> break;
>> }
>>
>>
prev parent reply other threads:[~2015-06-02 20:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-02 13:49 [PATCH v2] ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller Jyri Sarha
2015-06-02 16:16 ` Misael Lopez Cruz
2015-06-02 20:04 ` Jyri Sarha [this message]
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=556E0C5E.6040603@ti.com \
--to=jsarha@ti.com \
--cc=alsa-devel@alsa-project.org \
--cc=bcousson@baylibre.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=linux-omap@vger.kernel.org \
--cc=misael.lopez@ti.com \
--cc=peter.ujfalusi@ti.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;
as well as URLs for NNTP newsgroup(s).