From: Baolin Wang <baolin.wang@linaro.org>
To: vkoul@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com
Cc: devicetree@vger.kernel.org, eric.long@unisoc.com, arnd@arndb.de,
baolin.wang@linaro.org, zhang.lyra@gmail.com, broonie@kernel.org,
linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
arm@kernel.org, olof@lixom.net, orsonzhai@gmail.com,
dan.j.williams@intel.com, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] dmaengine: sprd: Add new DMA engine translation function
Date: Tue, 22 Jan 2019 21:20:52 +0800 [thread overview]
Message-ID: <529bc30b34a14bf7849fc852c7cbff34dee47aaa.1548158832.git.baolin.wang@linaro.org> (raw)
In-Reply-To: <a9718ae1e97a5911f47874fe23c00ef297d7fed8.1548158832.git.baolin.wang@linaro.org>
In-Reply-To: <a9718ae1e97a5911f47874fe23c00ef297d7fed8.1548158832.git.baolin.wang@linaro.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 <baolin.wang@linaro.org>
---
drivers/dma/sprd-dma.c | 49 ++++++++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 20 deletions(-)
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;
--
1.7.9.5
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-01-22 13:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-22 13:20 [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id Baolin Wang
2019-01-22 13:20 ` Baolin Wang [this message]
2019-01-22 13:20 ` [PATCH 3/3] arm64: dts: sprd: Change 2 cells to provide DMA controller specific information Baolin Wang
2019-01-30 16:51 ` [PATCH 1/3] dt-bindings: dmaengine: Add one new cell to present hardware slave id Arnd Bergmann
2019-02-01 11:53 ` Baolin Wang
2019-02-12 8:24 ` Baolin Wang
2019-02-18 10:31 ` Arnd Bergmann
2019-02-18 10:52 ` Baolin Wang
2019-02-18 12:23 ` Arnd Bergmann
2019-02-19 3:14 ` Baolin Wang
2019-02-19 9:30 ` Geert Uytterhoeven
2019-02-19 9:49 ` Baolin Wang
2019-02-19 12:20 ` Vinod Koul
2019-02-20 3:12 ` Baolin Wang
2019-02-20 9:07 ` Arnd Bergmann
2019-02-20 11:29 ` Baolin Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=529bc30b34a14bf7849fc852c7cbff34dee47aaa.1548158832.git.baolin.wang@linaro.org \
--to=baolin.wang@linaro.org \
--cc=arm@kernel.org \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=eric.long@unisoc.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=olof@lixom.net \
--cc=orsonzhai@gmail.com \
--cc=robh+dt@kernel.org \
--cc=vkoul@kernel.org \
--cc=zhang.lyra@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).