From patchwork Tue Jan 22 13:20:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 156295 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7571843jaa; Tue, 22 Jan 2019 05:21:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN48PggqyMX5Ig32rbA+Ae9xpPWZLPIgZemdi/SrMZzkc87wc3N2nYkFYDtGF7bQj9ILKjSS X-Received: by 2002:a62:444b:: with SMTP id r72mr33994755pfa.184.1548163303844; Tue, 22 Jan 2019 05:21:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548163303; cv=none; d=google.com; s=arc-20160816; b=X+oVdH/F0hrEqgVtG4ZE4Mv7BOg7EFdS8SQLmYponrIiC075mw5P8kzFs4x4cUZc26 7R4YrRZJUl9VISqwz1lI5s3n+LoGXh/Wf3K38UFWkdO1hD6h2BX3BnwN01A3LAh5GfLL IpSacaSVtDEBrHEEDZgtxWb1vAIC4FMnYkbHvBFdcqsKwAUqxHp2OJ7h3gesO/6fR4Ix fhGmZ/YDpsJNc0ceFnv9jJhtOu8MGoKbzHE2T2VVHgSqdPgGj2+fx4alem9aqqYVnNZS b77O2nsNi0SogUsYJ1v7rsnw5o29Fq3Eu+UEjSDJLoZH1NC7Lu4JLOVYV5tfiEPUrlTb s4TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=euK4ZIyk6B19PT813VSDOnPJkx4d5LHCeMqPJd1aM7s=; b=0idwxpXFNxD2xZ25iS4IP1fvtLKmEmZsJm5Cvt2EG/3iXCggVP4TuuTYW7RNzb7+CF rHdOnQ24nWn7x5W73e6orDGSDkwoTBaTmONx0a/MLv+sBQBUsYT+mrwnRlLfh8LbY2Qo MMAOEGnt/8Vi3cjgTRp7W3v7WOx305YcJtCB++Y2ntLTgoIJLUAIuCm5SMAKN5Lc8sGt 7NhGPq2KtdWS6QPG1DMVDxnG14ZpLgNJRh1HtY6ukhmQ1kLHtS0vxQLLxxQ3fxh0rcda T7dgRba5wfMHp0Fc3/1dBjL9K46kS/QMRG4VLDhY7Tezo+JeUlDSpL1b84dZ7ISDZUAi 4cCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ifqNeXZW; spf=pass (google.com: best guess record for domain of dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t20si15563872pgl.211.2019.01.22.05.21.43; Tue, 22 Jan 2019 05:21:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ifqNeXZW; spf=pass (google.com: best guess record for domain of dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728460AbfAVNVn (ORCPT + 3 others); Tue, 22 Jan 2019 08:21:43 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:34876 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728454AbfAVNVm (ORCPT ); Tue, 22 Jan 2019 08:21:42 -0500 Received: by mail-pl1-f195.google.com with SMTP id p8so11496537plo.2 for ; Tue, 22 Jan 2019 05:21:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=euK4ZIyk6B19PT813VSDOnPJkx4d5LHCeMqPJd1aM7s=; b=ifqNeXZWBx+cSJs+BkrC38f3XF88AhaIyImBMv0oNKRrpwVKoNXtInlwfbqYw0UebY +4EH3Ry0FtdIIDBbkAC/8XAds81tNArKoVFQLhRvfGLJLLno7l4BP+zpVtIQOvVYCxfd UeXzZ3Hewmv+k0WwxS+vGHQykIMx64UYi/3z4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=euK4ZIyk6B19PT813VSDOnPJkx4d5LHCeMqPJd1aM7s=; b=KmXwxp95oQXv7peSBOA421SHRQM+xeE/gfU38YakvlEg/kMZHn5AiM87NGRmSyM1kg pyisCZHTQhKkSXVLwl/IgAWO8F5w8abYUKAp4rv2vwKdGh0NxnhygRZ5h7fRS9hP7k1v tsU6onRy++dnCoqF+Ayq3jQPC7lqqfHCtySiqAU1f6DBOZHPKVYEPi46pxFEA4RiBAEM P4PQZk0rbOjRe5Ux6UFfVYOcRH8JoeNNzXokEXV4uZ7kFJXtdsQYtnfbs5Q5BeMHJNFW IQZX4YfU3Ds4UKpUwSDUoeLUlwUvT1TTn+Ictyc18NMZ60zOeYyEyKDZdpEfO6LICI9l YegQ== X-Gm-Message-State: AJcUukd32gSna5RoZW1imOeTxQZcQCpTTCaL7diaG2ccL9tFYtqTveVN UTC0Q1p7Ne5g5f2hbVnblmxTRw== X-Received: by 2002:a17:902:583:: with SMTP id f3mr35085581plf.202.1548163302104; Tue, 22 Jan 2019 05:21:42 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id l185sm21609574pfl.54.2019.01.22.05.21.37 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Jan 2019 05:21:41 -0800 (PST) From: Baolin Wang To: vkoul@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: arnd@arndb.de, olof@lixom.net, orsonzhai@gmail.com, zhang.lyra@gmail.com, dan.j.williams@intel.com, devicetree@vger.kernel.org, arm@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, eric.long@unisoc.com, broonie@kernel.org, baolin.wang@linaro.org Subject: [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id Date: Tue, 22 Jan 2019 21:20:51 +0800 Message-Id: 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 The DMA engine clients can trigger DMA engine automatically by setting the corresponding hardware slave id for the DMA engine. Thus add one cell to present the hardware slave id for DMA clients. Signed-off-by: Baolin Wang --- Documentation/devicetree/bindings/dma/sprd-dma.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 1.7.9.5 Acked-by: Arnd Bergmann diff --git a/Documentation/devicetree/bindings/dma/sprd-dma.txt b/Documentation/devicetree/bindings/dma/sprd-dma.txt index 7a10fea..7812cf0 100644 --- a/Documentation/devicetree/bindings/dma/sprd-dma.txt +++ b/Documentation/devicetree/bindings/dma/sprd-dma.txt @@ -6,8 +6,8 @@ Required properties: - compatible: Should be "sprd,sc9860-dma". - 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. +- #dma-cells: must be <2>. Used to represent the channel id and slave id + of integer cells in the dmas property of client device. - #dma-channels : Number of DMA channels supported. Should be 32. - clock-names: Should contain the clock of the DMA controller. - clocks: Should contain a clock specifier for each entry in clock-names. @@ -28,14 +28,16 @@ apdma: dma-controller@20100000 { Client: DMA clients connected to the Spreadtrum DMA controller must use the format -described in the dma.txt file, using a two-cell specifier for each channel. -The two cells in order are: +described in the dma.txt file, using a three-cell specifier for each channel. +The three cells in order are: 1. A phandle pointing to the DMA controller. 2. The channel id. +3. The hardware slave id which is used for clients to trigger DMA engine +automatically. spi0: spi@70a00000{ ... dma-names = "rx_chn", "tx_chn"; - dmas = <&apdma 11>, <&apdma 12>; + dmas = <&apdma 11 11>, <&apdma 12 12>; ... }; From patchwork Tue Jan 22 13:20:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 156296 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7571920jaa; Tue, 22 Jan 2019 05:21:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mCpNLLtXzohNYoHt8IbDbn4y9HfnXWWCP1Kg8cQvVfIeKk7myZYruVwV43O719Q08Y8Va X-Received: by 2002:a63:2b01:: with SMTP id r1mr31700564pgr.432.1548163309557; Tue, 22 Jan 2019 05:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548163309; cv=none; d=google.com; s=arc-20160816; b=nrSO5bhe7cvTzyuGZ7Jw6W7PrthVNmEoVujPP3YOGiS46XRP8318Cvee3TifC7rXb3 dYIkcO9P09TWcd5llvAIOJuEuPvzgmUNUE9wjj26TVV/Oq0clv26hzHGbJT+EFn1hbCA m7IJ4xAEqYTVV5UqjidVzEiRwU4GCbxV1Te3ziPb1QS+VIX5bJyShK2koF5XW8uL/DXQ CSr39o+SOVBxWEHCDOhe3D+sv8EnAw0p8C8MELAvG/sH1a19awryJokboiTR5cHMjgPC xoHmMRffbDA4dNVgmMCWEeGCZUmcIARtXJ4GIgx1O4N4mpq+qNGuKOZZo0wrYNhLWRC2 JUEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=aThP/Y0UG/Bg6pZXhNtucLsiLRzzJRNdslnI1cWQFgk=; b=RcYXD1x2CdUgc8PckrcF4v9DHL7jEHogor6wS1EscD/4Yp1MnNGELH5IYy0PvjDUT6 efOuD7Wk0C6U8VOxHDyquu6BY3zaCqosg0G7HZZrcVw3C9rQVGi937b/5xhg4QXaX6h7 Ap3M2N8SdMRLcIAIIsAsq7RJKD5V67tw+UMERXLCfH4HQTFRn5bfMBb9kNH7AZjv91uQ 2GcV3BwjONkrhbVO5PQ8qxLvB1+XoRtBIVDm/6LhWtE4fZ15nUOyCG/31rplYvDFjE9z kxqOqig2n74ZdtQlUB7uWAepv4L2nb3ND3/HD6AsULwfpCMXTN3BNPg2Ds5RbiNqtOnJ 4FPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L3KhXxkK; spf=pass (google.com: best guess record for domain of dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si15511365plv.258.2019.01.22.05.21.49; Tue, 22 Jan 2019 05:21:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L3KhXxkK; spf=pass (google.com: best guess record for domain of dmaengine-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=dmaengine-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728501AbfAVNVt (ORCPT + 3 others); Tue, 22 Jan 2019 08:21:49 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45358 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728439AbfAVNVs (ORCPT ); Tue, 22 Jan 2019 08:21:48 -0500 Received: by mail-pg1-f195.google.com with SMTP id y4so11055988pgc.12 for ; Tue, 22 Jan 2019 05:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=aThP/Y0UG/Bg6pZXhNtucLsiLRzzJRNdslnI1cWQFgk=; b=L3KhXxkKfjsH+L/BnnSqvkjQnyke/EFblv6Xj9LR5HpaDYCG2SW+L1rZPux21lQZOy 6QlGOs3Fk+PCVOn136Z1R+D+jrRAPLWxAxVmDq5npItzATHgmUGDTEYJ19DG8oRODYc7 elvbX1t+aPoMNLPjK3juuGj4wpVIYB0zb/f+w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=aThP/Y0UG/Bg6pZXhNtucLsiLRzzJRNdslnI1cWQFgk=; b=IDMUxJen0Tzb47g40yHeAP9hWcOZcB1biuaz4DjEneSSIZkDXq3tSbIb0/+NFUKsQR Gg9jer13VC9UlC/ro/aP0Hqd23PBJvPUMAPTUzjZry/pMx1iJIQzYCzjp3wOAYl9At2c Ce12tYdFQmbDOxA/AXG0xya7JXbER/NUWTF23qSBNecLam0dneTolwxe96dIh1aC3p2t Cct2tP11276bx0uzSJfLgUR4WdPhwFRtxlSz6XRaPx3fRidnJOl7rOM+g4DD+SPFQ1Ai Y4sP+Ik3RgCqrbCEWZpeY3XU0VndE7ZjcZ9ex7QJvmhvh70nMkSVBTT1/4tSEowTFWrU lPkQ== X-Gm-Message-State: AJcUukcGM23utBG8SOycrEHb+jkX1SeIyatLnFub+lLiClnrkGzTfC4L KbI/p2lGSDKZN4Ru2jclaph4lA== X-Received: by 2002:a62:35c7:: with SMTP id c190mr34406112pfa.76.1548163307648; Tue, 22 Jan 2019 05:21:47 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id l185sm21609574pfl.54.2019.01.22.05.21.42 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Jan 2019 05:21:46 -0800 (PST) From: Baolin Wang To: vkoul@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: arnd@arndb.de, olof@lixom.net, orsonzhai@gmail.com, zhang.lyra@gmail.com, dan.j.williams@intel.com, devicetree@vger.kernel.org, arm@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, eric.long@unisoc.com, broonie@kernel.org, baolin.wang@linaro.org Subject: [PATCH 2/3] dmaengine: sprd: Add new DMA engine translation function Date: Tue, 22 Jan 2019 21:20:52 +0800 Message-Id: <529bc30b34a14bf7849fc852c7cbff34dee47aaa.1548158832.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Add new DMA engine translation function to get the hardware slave id of the corresponding DMA engine channel. Meanwhile we do not need to set default slave id in sprd_dma_alloc_chan_resources(), remove it. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 49 ++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index e2f0167..7d180bb 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -204,9 +204,9 @@ struct sprd_dma_dev { struct sprd_dma_chn channels[0]; }; -static bool sprd_dma_filter_fn(struct dma_chan *chan, void *param); -static struct of_dma_filter_info sprd_dma_info = { - .filter_fn = sprd_dma_filter_fn, +struct sprd_dma_filter_param { + u32 chn_id; + u32 slave_id; }; static inline struct sprd_dma_chn *to_sprd_dma_chan(struct dma_chan *c) @@ -580,15 +580,7 @@ static irqreturn_t dma_irq_handle(int irq, void *dev_id) static int sprd_dma_alloc_chan_resources(struct dma_chan *chan) { - struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); - int ret; - - ret = pm_runtime_get_sync(chan->device->dev); - if (ret < 0) - return ret; - - schan->dev_id = SPRD_DMA_SOFTWARE_UID; - return 0; + return pm_runtime_get_sync(chan->device->dev); } static void sprd_dma_free_chan_resources(struct dma_chan *chan) @@ -1022,12 +1014,31 @@ static bool sprd_dma_filter_fn(struct dma_chan *chan, void *param) { struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); struct sprd_dma_dev *sdev = to_sprd_dma_dev(&schan->vc.chan); - u32 req = *(u32 *)param; + struct sprd_dma_filter_param *sparam = param; - if (req < sdev->total_chns) - return req == schan->chn_num + 1; - else - return false; + if (sparam->chn_id < sdev->total_chns && + sparam->chn_id == schan->chn_num + 1) { + schan->dev_id = sparam->slave_id; + return true; + } + + return false; +} + +static struct dma_chan *sprd_dma_xlate(struct of_phandle_args *dma_spec, + struct of_dma *ofdma) +{ + struct sprd_dma_dev *sdev = ofdma->of_dma_data; + dma_cap_mask_t mask = sdev->dma_dev.cap_mask; + struct sprd_dma_filter_param param; + + if (dma_spec->args_count != 2) + return NULL; + + param.chn_id = dma_spec->args[0]; + param.slave_id = dma_spec->args[1]; + + return dma_request_channel(mask, sprd_dma_filter_fn, ¶m); } static int sprd_dma_probe(struct platform_device *pdev) @@ -1133,9 +1144,7 @@ static int sprd_dma_probe(struct platform_device *pdev) goto err_register; } - sprd_dma_info.dma_cap = sdev->dma_dev.cap_mask; - ret = of_dma_controller_register(np, of_dma_simple_xlate, - &sprd_dma_info); + ret = of_dma_controller_register(np, sprd_dma_xlate, sdev); if (ret) goto err_of_register;