From patchwork Thu Mar 27 08:03:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 3896601 X-Patchwork-Delegate: vinod.koul@intel.com Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 045819F2B6 for ; Thu, 27 Mar 2014 08:03:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30BDA20221 for ; Thu, 27 Mar 2014 08:03:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DB892021C for ; Thu, 27 Mar 2014 08:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752211AbaC0ID4 (ORCPT ); Thu, 27 Mar 2014 04:03:56 -0400 Received: from mail-pb0-f51.google.com ([209.85.160.51]:33854 "EHLO mail-pb0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751978AbaC0IDw (ORCPT ); Thu, 27 Mar 2014 04:03:52 -0400 Received: by mail-pb0-f51.google.com with SMTP id uo5so3143052pbc.10 for ; Thu, 27 Mar 2014 01:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=KKCpWcaeIy39aCMNb8IpqfC9vw9hTm0V+A3RMwC8Erw=; b=Fm7fmsf7ldlQavP5SRJwZmEh2NBi1ZKJQZI+O5sDxvdnew/Bm0Lzv3tuOQyfLnxDbJ lZn4Ghkj1NZ+ynllf/5BAfqUSfbi/esQ3a3S39IAp9Pm8HOBMpw1HqUj0uncLaolbzZM DlT4vg+V8HhildqDlA/GZDSYVh2nz1nzgiiQ6C+hB6VDTM46C1wi8jc5W1YW05h8wjfy 1fV6ASeGIVsTHxAm0MrwFqo+RXWdl2afEIrYCA1mq2cnqJyweD2ZCDrRlPgdL9E9GXdJ zjZ6GenowgRNQYqWq+ObRD/E3ZJNC+5aKRPRX+ZYnyglgiDYHFzhWhx18bmkjobTtrKM PuhA== X-Received: by 10.68.132.130 with SMTP id ou2mr279267pbb.107.1395907431560; Thu, 27 Mar 2014 01:03:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.237.173 with HTTP; Thu, 27 Mar 2014 01:03:31 -0700 (PDT) In-Reply-To: <20140319144359.GI1976@intel.com> References: <1389190369-2012-1-git-send-email-21cnbao@gmail.com> <20140319144359.GI1976@intel.com> From: Barry Song <21cnbao@gmail.com> Date: Thu, 27 Mar 2014 16:03:31 +0800 Message-ID: Subject: Re: [PATCH v5] dmaengine: sirf: enable generic dt binding for dma channels To: Vinod Koul Cc: robh+dt@kernel.org, Pawel Moll , Mark Rutland , ijc+devicetree@hellion.org.uk, Kumar Gala , "devicetree@vger.kernel.org" , "dmaengine@vger.kernel.org" , DL-SHA-WorkGroupLinux , Lars-Peter Clausen , Barry Song Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 2014-03-19 22:43 GMT+08:00 Vinod Koul : > On Sun, Jan 26, 2014 at 10:08:45AM +0800, Barry Song wrote: >> From: Barry Song >> >> move to support of_dma_request_slave_channel() and dma_request_slave_channel. >> we add a xlate() to let dma clients be able to find right dma_chan by generic >> "dmas" properties in dts. >> >> Cc: Mark Rutland >> Cc: Lars-Peter Clausen >> Signed-off-by: Barry Song > > I tried applying this but it failed to apply. > > Can you pls rebase quickly and resend. While at it pls add the Acks recived! Hi Vinod, attached see the rebased version for master. -barry From 3b720f21783f1df32ceaed35aa01ee2da1d2d26a Mon Sep 17 00:00:00 2001 From: Barry Song Date: Thu, 27 Mar 2014 15:49:31 +0800 Subject: [PATCH] dmaengine: sirf: enable generic dt binding for dma channels move to support of_dma_request_slave_channel() and dma_request_slave_channel. we add a xlate() to let dma clients be able to find right dma_chan by generic "dmas" properties in dts. Cc: Mark Rutland Cc: Lars-Peter Clausen Signed-off-by: Barry Song Acked-by: Arnd Bergmann --- .../devicetree/bindings/dma/sirfsoc-dma.txt | 43 ++++++++++++++++++++ arch/arm/boot/dts/atlas6.dtsi | 2 + arch/arm/boot/dts/prima2.dtsi | 2 + drivers/dma/sirf-dma.c | 23 ++++++++++ 4 files changed, 70 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/sirfsoc-dma.txt diff --git a/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt new file mode 100644 index 0000000..ecbc96a --- /dev/null +++ b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt @@ -0,0 +1,43 @@ +* CSR SiRFSoC DMA controller + +See dma.txt first + +Required properties: +- compatible: Should be "sirf,prima2-dmac" or "sirf,marco-dmac" +- reg: Should contain DMA registers location and length. +- interrupts: Should contain one interrupt shared by all channel +- #dma-cells: must be <1>. used to represent the number of integer + cells in the dmas property of client device. +- clocks: clock required + +Example: + +Controller: +dmac0: dma-controller@b00b0000 { + compatible = "sirf,prima2-dmac"; + reg = <0xb00b0000 0x10000>; + interrupts = <12>; + clocks = <&clks 24>; + #dma-cells = <1>; +}; + + +Client: +Fill the specific dma request line in dmas. In the below example, spi0 read +channel request line is 9 of the 2nd dma controller, while write channel uses +4 of the 2nd dma controller; spi1 read channel request line is 12 of the 1st +dma controller, while write channel uses 13 of the 1st dma controller: + +spi0: spi@b00d0000 { + compatible = "sirf,prima2-spi"; + dmas = <&dmac1 9>, + <&dmac1 4>; + dma-names = "rx", "tx"; +}; + +spi1: spi@b0170000 { + compatible = "sirf,prima2-spi"; + dmas = <&dmac0 12>, + <&dmac0 13>; + dma-names = "rx", "tx"; +}; diff --git a/arch/arm/boot/dts/atlas6.dtsi b/arch/arm/boot/dts/atlas6.dtsi index f8674bc..ec23b5c 100644 --- a/arch/arm/boot/dts/atlas6.dtsi +++ b/arch/arm/boot/dts/atlas6.dtsi @@ -269,6 +269,7 @@ reg = <0xb00b0000 0x10000>; interrupts = <12>; clocks = <&clks 24>; + #dma-cells = <1>; }; dmac1: dma-controller@b0160000 { @@ -277,6 +278,7 @@ reg = <0xb0160000 0x10000>; interrupts = <13>; clocks = <&clks 25>; + #dma-cells = <1>; }; vip@b00C0000 { diff --git a/arch/arm/boot/dts/prima2.dtsi b/arch/arm/boot/dts/prima2.dtsi index 0e21993..3a15dee 100644 --- a/arch/arm/boot/dts/prima2.dtsi +++ b/arch/arm/boot/dts/prima2.dtsi @@ -286,6 +286,7 @@ reg = <0xb00b0000 0x10000>; interrupts = <12>; clocks = <&clks 24>; + #dma-cells = <1>; }; dmac1: dma-controller@b0160000 { @@ -294,6 +295,7 @@ reg = <0xb0160000 0x10000>; interrupts = <13>; clocks = <&clks 25>; + #dma-cells = <1>; }; vip@b00C0000 { diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c index d4d3a31..a1bd829 100644 --- a/drivers/dma/sirf-dma.c +++ b/drivers/dma/sirf-dma.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "dmaengine.h" @@ -659,6 +660,18 @@ static int sirfsoc_dma_device_slave_caps(struct dma_chan *dchan, return 0; } +static struct dma_chan *of_dma_sirfsoc_xlate(struct of_phandle_args *dma_spec, + struct of_dma *ofdma) +{ + struct sirfsoc_dma *sdma = ofdma->of_dma_data; + unsigned int request = dma_spec->args[0]; + + if (request > SIRFSOC_DMA_CHANNELS) + return NULL; + + return dma_get_slave_channel(&sdma->channels[request].chan); +} + static int sirfsoc_dma_probe(struct platform_device *op) { struct device_node *dn = op->dev.of_node; @@ -764,11 +777,20 @@ static int sirfsoc_dma_probe(struct platform_device *op) if (ret) goto free_irq; + /* Device-tree DMA controller registration */ + ret = of_dma_controller_register(dn, of_dma_sirfsoc_xlate, sdma); + if (ret) { + dev_err(dev, "failed to register DMA controller\n"); + goto unreg_dma_dev; + } + pm_runtime_enable(&op->dev); dev_info(dev, "initialized SIRFSOC DMAC driver\n"); return 0; +unreg_dma_dev: + dma_async_device_unregister(dma); free_irq: free_irq(sdma->irq, sdma); irq_dispose: @@ -781,6 +803,7 @@ static int sirfsoc_dma_remove(struct platform_device *op) struct device *dev = &op->dev; struct sirfsoc_dma *sdma = dev_get_drvdata(dev); + of_dma_controller_free(op->dev.of_node); dma_async_device_unregister(&sdma->dma); free_irq(sdma->irq, sdma); irq_dispose_mapping(sdma->irq); -- 1.7.5.4