From patchwork Mon Jan 6 11:16:52 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: 3437141 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 2EF8B9F163 for ; Mon, 6 Jan 2014 11:17:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B534D20166 for ; Mon, 6 Jan 2014 11:17:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F38A20161 for ; Mon, 6 Jan 2014 11:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751934AbaAFLRR (ORCPT ); Mon, 6 Jan 2014 06:17:17 -0500 Received: from mail-pd0-f174.google.com ([209.85.192.174]:45842 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753655AbaAFLRM (ORCPT ); Mon, 6 Jan 2014 06:17:12 -0500 Received: by mail-pd0-f174.google.com with SMTP id x10so18145097pdj.33 for ; Mon, 06 Jan 2014 03:17:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=/7eXcxk8z7OEdRlY+yvQldeNNFQAg9l7CQrFveqO58U=; b=bmhrhcGH1mNkqirH8yDQSshNWph6why+bcPpeT56NO16cA0DEDkMQwsh0ogUrB9ays MOywHadTJDOvaEduU8joSfUBkSPmy5ewt2vqXX/qyD1eLjmUhIyUv1hP1Zw8ezwoTJzF sBEg4fr+5Gq/qQ11lJqOBSNtAhOJfNc67SdNlgg7z9XLhvQP7FeHHlgKol8MDfwxYhs1 6SA1qNoUaqFzaHL1e8XfNcoL/JF9q/P8z8Y3K7AneJdhcJP7oxBMJrUhlB8j0yTLsMFQ cIsrqBQ2ONkLbyF7uP/fFjGmxew/tXBZTSALZ8SgIVkXTodBd+NVPMUmLXQMcaoKDtyF vJFg== X-Received: by 10.68.139.100 with SMTP id qx4mr6505446pbb.144.1389007031587; Mon, 06 Jan 2014 03:17:11 -0800 (PST) Received: from localhost.localdomain ([117.136.8.30]) by mx.google.com with ESMTPSA id dq3sm128074141pbc.35.2014.01.06.03.17.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 Jan 2014 03:17:11 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: vinod.koul@intel.com, dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, workgroup.linux@csr.com, Barry Song , Lars-Peter Clausen Subject: [PATCH v3] dmaengine: sirf: enable generic dt binding for dma channels Date: Mon, 6 Jan 2014 19:16:52 +0800 Message-Id: <1389007012-10887-1-git-send-email-21cnbao@gmail.com> X-Mailer: git-send-email 1.7.9.5 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, UNPARSEABLE_RELAY autolearn=ham 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 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: Lars-Peter Clausen Signed-off-by: Barry Song --- -v3: drop unused variant cap pointed out by Lars-Peter; add dt-binding document .../devicetree/bindings/dma/sirfsoc-dma.txt | 42 ++++++++++++++++++++ arch/arm/boot/dts/atlas6.dtsi | 4 ++ arch/arm/boot/dts/prima2.dtsi | 4 ++ drivers/dma/sirf-dma.c | 23 +++++++++++ 4 files changed, 73 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..262cf8c --- /dev/null +++ b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt @@ -0,0 +1,42 @@ +* 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: see dma.txt, should be 1, para number +- dma-channels: physical channels supported +- clocks: clock required + +Example: + +Controller: +dmac0: dma-controller@b00b0000 { + compatible = "sirf,prima2-dmac"; + reg = <0xb00b0000 0x10000>; + interrupts = <12>; + clocks = <&clks 24>; +}; + + +Client: +Use specific request line passing from dmax +For 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 b63cfef..aa3ff43 100644 --- a/arch/arm/boot/dts/atlas6.dtsi +++ b/arch/arm/boot/dts/atlas6.dtsi @@ -260,6 +260,8 @@ reg = <0xb00b0000 0x10000>; interrupts = <12>; clocks = <&clks 24>; + #dma-cells = <1>; + #dma-channels = <16>; }; dmac1: dma-controller@b0160000 { @@ -268,6 +270,8 @@ reg = <0xb0160000 0x10000>; interrupts = <13>; clocks = <&clks 25>; + #dma-cells = <1>; + #dma-channels = <16>; }; vip@b00C0000 { diff --git a/arch/arm/boot/dts/prima2.dtsi b/arch/arm/boot/dts/prima2.dtsi index b292a5c..e543aba 100644 --- a/arch/arm/boot/dts/prima2.dtsi +++ b/arch/arm/boot/dts/prima2.dtsi @@ -277,6 +277,8 @@ reg = <0xb00b0000 0x10000>; interrupts = <12>; clocks = <&clks 24>; + #dma-cells = <1>; + #dma-channels = <16>; }; dmac1: dma-controller@b0160000 { @@ -285,6 +287,8 @@ reg = <0xb0160000 0x10000>; interrupts = <13>; clocks = <&clks 25>; + #dma-cells = <1>; + #dma-channels = <16>; }; vip@b00C0000 { diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c index 6aec3ad..ab32bbb 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" @@ -640,6 +641,18 @@ bool sirfsoc_dma_filter_id(struct dma_chan *chan, void *chan_id) } EXPORT_SYMBOL(sirfsoc_dma_filter_id); +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; @@ -744,11 +757,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: @@ -761,6 +783,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);