From patchwork Mon Apr 22 12:32:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 2471711 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 81FCF3FD40 for ; Mon, 22 Apr 2013 12:34:18 +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 1UUFvo-0007u4-Hw; Mon, 22 Apr 2013 12:33:17 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUFvT-0007a0-GV; Mon, 22 Apr 2013 12:32:55 +0000 Received: from moutng.kundenserver.de ([212.227.17.9]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUFvQ-0007ZA-4A for linux-arm-kernel@lists.infradead.org; Mon, 22 Apr 2013 12:32:52 +0000 Received: from klappe2.localnet (HSI-KBW-095-208-002-043.hsi5.kabel-badenwuerttemberg.de [95.208.2.43]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MDU2z-1UHqmd1hu9-00HRfZ; Mon, 22 Apr 2013 14:32:50 +0200 From: Arnd Bergmann To: Linus Walleij Subject: Re: [PATCH 19/23] ARM: u300: add the COH 901 318 DMAC to device tree Date: Mon, 22 Apr 2013 14:32:47 +0200 User-Agent: KMail/1.12.2 (Linux/3.8.0-18-generic; KDE/4.3.2; x86_64; ; ) References: <1366624779-6820-1-git-send-email-linus.walleij@stericsson.com> In-Reply-To: <1366624779-6820-1-git-send-email-linus.walleij@stericsson.com> MIME-Version: 1.0 Message-Id: <201304221432.47444.arnd@arndb.de> X-Provags-ID: V02:K0:LczdXocGZXuYd/28TNDU+1PUNXkbsv0dcKy/zu+Q1Fl BJOMx2gy2bm4oD0qNhyN4/PoGvIZmS6DHdays8GF3WHD3BifE5 dOlV/mN2E1aibbJXFU0xsPCWoXtLjfA6B+okfMeIu9M6yACsKc ycEh6xxq/av94zNjuyNOiZyHxRIDR1Pi+KI87dLeTjh028Zpwu wSHylftyIgy5UJOLUYWUCscWZHEDkuV8Gt7kUt8dOnQugqGfed vUD0+TdawwSOEgu+x3a3Ridx215zVgrH1HpFk1OFoxK56ZdgGM sPm1JCE6W6fXXPULuvB5F+/323XR29BPVXmULTir3o/IGL8Kt2 HThyGLyA3MQoeRgQ0vCc= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130422_083252_426875_CF192CE1 X-CRM114-Status: GOOD ( 18.34 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.17.9 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Vinod Koul , devicetree-discuss@lists.ozlabs.org, Linus Walleij , linux-arm-kernel@lists.infradead.org, Dan Williams 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Monday 22 April 2013, Linus Walleij wrote: > From: Linus Walleij > > This adds the COH 901 318 DMA controller to the U300 > device tree. All devices now converted to device tree > so far will start to find their DMA channels. > > Note that the U300 is not yet using the device tree > to obtain DMA channels, but this is a first step. I think you definitely should implement the entire binding at once. It should be really trivial for this driver, see the patch below. I did not even build test it, but I'm sure you'll figure out the rest. 8<----- Subject: dma: coh901318: implement of_dma_controller API This provides a simple xlate and filter function pair for the coh901318 dma engine. Every request line is tied to one channel here, so this is really trivial: the only information we need to pass is the channel number. Signed-off-by: Arnd Bergmann diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c index 797940e..a90ba74 100644 --- a/drivers/dma/coh901318.c +++ b/drivers/dma/coh901318.c @@ -1788,6 +1788,35 @@ bool coh901318_filter_id(struct dma_chan *chan, void *chan_id) } EXPORT_SYMBOL(coh901318_filter_id); +struct coh901318_filter_args { + struct coh901318_base *base; + unsigned int ch_nr; +}; + +static bool coh901318_filter_base_and_id(struct dma_chan *chan, void *data) +{ + struct coh901318_filter_args *args = data; + + if (&args->base->dma_slave == chan->device && + args->ch_nr == to_coh901318_chan(chan)->id) + return true; + + return false; +} + +static struct dma_chan *coh901318_xlate(struct of_phandle_args *dma_spec, + struct of_dma *ofdma) +{ + struct coh901318_filter_args args = { + .base = ofdma->of_dma_data, + .ch_nr = dma_spec->args[0], + }; + dma_cap_mask_t cap; + dma_cap_zero(cap); + dma_cap_set(DMA_SLAVE, cap); + + return dma_request_channel(cap, coh901318_filter_base_and_id, args); +} /* * DMA channel allocation */ @@ -2735,12 +2764,18 @@ static int __init coh901318_probe(struct platform_device *pdev) if (err) goto err_register_memcpy; + ret = of_dma_controller_register(pdev->dev.of_node, coh901318_xlate, base); + if (err) + goto err_register_of_dma; + platform_set_drvdata(pdev, base); dev_info(&pdev->dev, "Initialized COH901318 DMA on virtual base 0x%08x\n", (u32) base->virtbase); return err; + err_register_of_dma: + dma_async_device_unregister(&base->dma_memcpy); err_register_memcpy: dma_async_device_unregister(&base->dma_slave); err_register_slave: @@ -2752,6 +2787,7 @@ static int __exit coh901318_remove(struct platform_device *pdev) { struct coh901318_base *base = platform_get_drvdata(pdev); + of_dma_controller_free(pdev->dev.of_node); dma_async_device_unregister(&base->dma_memcpy); dma_async_device_unregister(&base->dma_slave); coh901318_pool_destroy(&base->pool);