From patchwork Mon Nov 11 09:13:11 2013 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: 3166801 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 9D788C045B for ; Mon, 11 Nov 2013 09:14:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B8052025B for ; Mon, 11 Nov 2013 09:14:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03B9D2015A for ; Mon, 11 Nov 2013 09:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752616Ab3KKJOY (ORCPT ); Mon, 11 Nov 2013 04:14:24 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:39624 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750872Ab3KKJOX (ORCPT ); Mon, 11 Nov 2013 04:14:23 -0500 Received: by mail-pa0-f47.google.com with SMTP id ld10so835489pab.34 for ; Mon, 11 Nov 2013 01:14:23 -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=LmiVaxa+0+kpGfPRKjsBGi46BsUPISsqxYt11aZ8cV0=; b=qW2tDK1AoFWVvp7l+KEcZT4SHi+zE5TdrLHyS/YR95fw/CbdTW4nzGil74OsbMYQtP ggkDt56WZUvUGB57mtTheMoCOlqfrzmi03rxlt7+WXsdchcjp6Ksicb8CczNnXZWpAHL 6u1q+sGnJ0b/t4rCoo0MkcEHAjlZd3yWrulz1MoYKgyrkuYz8duf8t5+Ku4CFzERS0Iq 6nNe6vzFz56SEHgS6yljJo7G3K+5S6p58DzzlchvVKPGdrsmNR/sP92pgJj5eFWWfycx dN38dA/Eq6DXE1QsePw9bBuk8w+txwRu4lEbfTKF6dmNRph3p4i2uALyqFtZySeuW+y/ yIqg== X-Received: by 10.66.26.161 with SMTP id m1mr500732pag.11.1384161263018; Mon, 11 Nov 2013 01:14:23 -0800 (PST) Received: from localhost.localdomain ([117.136.8.58]) by mx.google.com with ESMTPSA id n10sm29463538pbg.28.2013.11.11.01.14.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 11 Nov 2013 01:14:22 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: vinod.koul@intel.com, dan.j.williams@intel.com Cc: dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, workgroup.linux@csr.com, Barry Song , Lars-Peter Clausen Subject: [PATCH] dmaengine: sirf: enable generic dt binding for dma channels Date: Mon, 11 Nov 2013 17:13:11 +0800 Message-Id: <1384161191-24140-1-git-send-email-Baohua.Song@csr.com> X-Mailer: git-send-email 1.8.2.3 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.8 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 move to support of_dma_request_slave_channel() and dma_request_slave_channel. we add a xlate and filter function 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 --- arch/arm/boot/dts/atlas6.dtsi | 4 ++++ arch/arm/boot/dts/prima2.dtsi | 4 ++++ drivers/dma/sirf-dma.c | 47 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/arch/arm/boot/dts/atlas6.dtsi b/arch/arm/boot/dts/atlas6.dtsi index 6db4f81..21fa6a7 100644 --- a/arch/arm/boot/dts/atlas6.dtsi +++ b/arch/arm/boot/dts/atlas6.dtsi @@ -233,6 +233,8 @@ reg = <0xb00b0000 0x10000>; interrupts = <12>; clocks = <&clks 24>; + #dma-cells = <1>; + #dma-channels = <16>; }; dmac1: dma-controller@b0160000 { @@ -241,6 +243,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 27ed9f5..a69004c 100644 --- a/arch/arm/boot/dts/prima2.dtsi +++ b/arch/arm/boot/dts/prima2.dtsi @@ -264,6 +264,8 @@ reg = <0xb00b0000 0x10000>; interrupts = <12>; clocks = <&clks 24>; + #dma-cells = <1>; + #dma-channels = <16>; }; dmac1: dma-controller@b0160000 { @@ -272,6 +274,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..6bb2f6e 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; @@ -90,6 +92,11 @@ struct sirfsoc_dma { struct sirfsoc_dma_regs regs_save; }; +struct sirfsoc_dma_filter_args { + struct sirfsoc_dma *sdma; + unsigned int chan_id; +}; + #define DRV_NAME "sirfsoc_dma" static int sirfsoc_dma_runtime_suspend(struct device *dev); @@ -624,6 +631,17 @@ sirfsoc_dma_prep_cyclic(struct dma_chan *chan, dma_addr_t addr, return &sdesc->desc; } +static bool sirfsoc_dma_dt_filter(struct dma_chan *chan, void *param) +{ + struct sirfsoc_dma_filter_args *fargs = param; + + if (chan->device != &fargs->sdma->dma) + return false; + + return (chan->chan_id == fargs->chan_id); +} + + /* * The DMA controller consists of 16 independent DMA channels. * Each channel is allocated to a different function @@ -640,6 +658,24 @@ 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; + struct sirfsoc_dma_filter_args fargs; + + if (!sdma) + return NULL; + + if (dma_spec->args_count != 1) + return NULL; + + fargs.sdma = sdma; + fargs.chan_id = dma_spec->args[0]; + + return dma_request_channel(sdma->cap, sirfsoc_dma_dt_filter, &fargs); +} + static int sirfsoc_dma_probe(struct platform_device *op) { struct device_node *dn = op->dev.of_node; @@ -744,11 +780,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 +807,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);