From patchwork Mon Jan 6 07:12:51 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: 3436231 X-Patchwork-Delegate: vinod.koul@intel.com Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 98F99C02DC for ; Mon, 6 Jan 2014 07:14:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A657C20165 for ; Mon, 6 Jan 2014 07:14:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3FC5200F0 for ; Mon, 6 Jan 2014 07:14:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752689AbaAFHOD (ORCPT ); Mon, 6 Jan 2014 02:14:03 -0500 Received: from mail-pd0-f177.google.com ([209.85.192.177]:59821 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751373AbaAFHOC (ORCPT ); Mon, 6 Jan 2014 02:14:02 -0500 Received: by mail-pd0-f177.google.com with SMTP id q10so17719156pdj.22 for ; Sun, 05 Jan 2014 23:14:01 -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=oOPKSO/CxKMIMGqrkXC443VWnoDf0bGKp9WSpSglfgY=; b=WAcRKcsXZSEhmvWXVsyKybezum5oorGfJ7sXhCHeeJEYri1aIX/zvZOOKAFtc3R0yu je0mW3VkwnVPdtaJxEY3D2UkVk5OMeX91IlpQ1Ljqcujha6olFuHBEKYHoLWsEKuvNA0 jlD6Ppe9BicyrqMzQ+PUqI2Y+bG8Rk2VEyyvTlSxlhYqCKDH6eUZqIjJgESo70f5p0Z2 PHoM4o/9Nl9U8KRT78p5oc8YsX8atL2MUo7FYr2Y9zmyS+tfrOLeIVNg6Et+whVin4Gh NS2a0qmU1RnPLblI2bTBJq3o+1G5OnypSd89nxkhixpjzDy2Oy6+uzLldI95d808+VTr bQsA== X-Received: by 10.68.164.4 with SMTP id ym4mr77834129pbb.53.1388992441846; Sun, 05 Jan 2014 23:14:01 -0800 (PST) Received: from localhost.localdomain ([117.136.8.35]) by mx.google.com with ESMTPSA id fm1sm27934702pab.22.2014.01.05.23.13.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 05 Jan 2014 23:14:01 -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 v2] dmaengine: sirf: enable generic dt binding for dma channels Date: Mon, 6 Jan 2014 15:12:51 +0800 Message-Id: <1388992371-7908-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 --- -v2: use dma_get_slave_channel() function which makes it a bit cleaner according to Lars-Peter's feedback arch/arm/boot/dts/atlas6.dtsi | 4 ++++ arch/arm/boot/dts/prima2.dtsi | 4 ++++ drivers/dma/sirf-dma.c | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 0 deletions(-) diff --git a/arch/arm/boot/dts/atlas6.dtsi b/arch/arm/boot/dts/atlas6.dtsi index 978bab4..afe0d76 100644 --- a/arch/arm/boot/dts/atlas6.dtsi +++ b/arch/arm/boot/dts/atlas6.dtsi @@ -259,6 +259,8 @@ reg = <0xb00b0000 0x10000>; interrupts = <12>; clocks = <&clks 24>; + #dma-cells = <1>; + #dma-channels = <16>; }; dmac1: dma-controller@b0160000 { @@ -267,6 +269,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 daee5894..38782e5 100644 --- a/arch/arm/boot/dts/prima2.dtsi +++ b/arch/arm/boot/dts/prima2.dtsi @@ -276,6 +276,8 @@ reg = <0xb00b0000 0x10000>; interrupts = <12>; clocks = <&clks 24>; + #dma-cells = <1>; + #dma-channels = <16>; }; dmac1: dma-controller@b0160000 { @@ -284,6 +286,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..546bf3b 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" @@ -81,6 +82,7 @@ struct sirfsoc_dma_regs { struct sirfsoc_dma { struct dma_device dma; + dma_cap_mask_t cap; struct tasklet_struct tasklet; struct sirfsoc_dma_chan channels[SIRFSOC_DMA_CHANNELS]; void __iomem *base; @@ -640,6 +642,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 +758,21 @@ 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) { + sdma->cap = dma->cap_mask; + 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 +785,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);