From patchwork Sun Apr 7 19:25:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Pargmann X-Patchwork-Id: 2404881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 57531DF2A1 for ; Mon, 8 Apr 2013 02:31:48 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UOwZ1-0001yS-T6; Sun, 07 Apr 2013 20:51:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UOvEC-0007ej-Jk; Sun, 07 Apr 2013 19:26:12 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UOvE7-0007eP-Cj for linux-arm-kernel@lists.infradead.org; Sun, 07 Apr 2013 19:26:09 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1UOvDy-00017K-Qc; Sun, 07 Apr 2013 21:25:58 +0200 Received: from mpa by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1UOvDu-0001bV-66; Sun, 07 Apr 2013 21:25:54 +0200 From: Markus Pargmann To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 02/11] ASoC: imx-pcm-dma: Add support for DMA init by device node Date: Sun, 7 Apr 2013 21:25:12 +0200 Message-Id: <1365362721-3731-3-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 1.8.2.rc2 In-Reply-To: <1365362721-3731-1-git-send-email-mpa@pengutronix.de> References: <1365362721-3731-1-git-send-email-mpa@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130407_152607_980486_7F3A40DC X-CRM114-Status: GOOD ( 18.66 ) X-Spam-Score: -4.3 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Fabio Estevam , alsa-devel@alsa-project.org, devicetree-discuss@lists.ozlabs.org, Mark Brown , Timur Tabi , Liam Girdwood , Grant Likely , Sascha Hauer , Markus Pargmann , Shawn Guo X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add support for DMA initialization using devicetree node. This patch adds two fields to imx_pcm_dma_params to pass device node information from other imx drivers to this one. If the dma_node is set, this driver tries to initialize a PCM DMA substream based on the dma_node and name. Signed-off-by: Markus Pargmann --- Notes: Changes in v2: - Use snd_dmaengine_generic_pcm_open instead of of_snd_dmaengine_pcm_open. - Pass the device in imx_pcm_dma_params. sound/soc/fsl/imx-pcm-dma.c | 31 ++++++++++++++++++++----------- sound/soc/fsl/imx-pcm.h | 6 ++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 500f8ce..2d15ca5 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -101,26 +101,35 @@ static int snd_imx_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct imx_pcm_dma_params *dma_params; - struct imx_dma_data *dma_data; + struct imx_dma_data *dma_data = NULL; int ret; snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware); dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL); - if (!dma_data) - return -ENOMEM; + if (dma_params->dma_client_dev) { + ret = snd_dmaengine_generic_pcm_open(substream, + dma_params->dma_client_dev, + dma_params->dma_req_name); + if (ret) + return ret; + } else { + dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL); + if (!dma_data) + return -ENOMEM; - dma_data->peripheral_type = dma_params->shared_peripheral ? + dma_data->peripheral_type = dma_params->shared_peripheral ? IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI; - dma_data->priority = DMA_PRIO_HIGH; - dma_data->dma_request = dma_params->dma; + dma_data->priority = DMA_PRIO_HIGH; + dma_data->dma_request = dma_params->dma; - ret = snd_dmaengine_pcm_open(substream, filter, dma_data); - if (ret) { - kfree(dma_data); - return ret; + ret = snd_dmaengine_pcm_open(substream, filter, dma_data); + + if (ret) { + kfree(dma_data); + return ret; + } } snd_dmaengine_pcm_set_data(substream, dma_data); diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h index 5ae13a1..ff0cfdf 100644 --- a/sound/soc/fsl/imx-pcm.h +++ b/sound/soc/fsl/imx-pcm.h @@ -23,6 +23,12 @@ struct imx_pcm_dma_params { unsigned long dma_addr; int burstsize; bool shared_peripheral; /* The peripheral is on SPBA bus */ + + /* If set, the DMA channel is requested using the generic handler while + * ignoring fields 'dma' and 'shared_peripheral'. They have to be set + * in devicetree according to the DMA Controller devicetree bindings. */ + struct device *dma_client_dev; + const char *dma_req_name; /* DMA Request name from devicetree */ }; int snd_imx_pcm_mmap(struct snd_pcm_substream *substream,