dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jisheng Zhang <jszhang@kernel.org>
To: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,
	Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 08/11] dmaengine: dw-axi-dmac: support dma-channel-mask
Date: Sun, 21 May 2023 18:12:13 +0800	[thread overview]
Message-ID: <20230521101216.4084-9-jszhang@kernel.org> (raw)
In-Reply-To: <20230521101216.4084-1-jszhang@kernel.org>

Some dma channels may not be available, so we need to tell the driver
the available dma channels, use the general dt binding
"dma-channel-mask" for this purpose.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
 .../dma/dw-axi-dmac/dw-axi-dmac-platform.c    | 19 +++++++++++++++++++
 drivers/dma/dw-axi-dmac/dw-axi-dmac.h         |  1 +
 2 files changed, 20 insertions(+)

diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index 3f3db48822e3..f0bd8a7e3caf 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -223,6 +223,8 @@ static void axi_dma_hw_init(struct axi_dma_chip *chip)
 	u32 i;
 
 	for (i = 0; i < chip->dw->hdata->nr_channels; i++) {
+		if (!(chip->dw->hdata->channels_mask & (1 << i)))
+			continue;
 		axi_chan_irq_disable(&chip->dw->chan[i], DWAXIDMAC_IRQ_ALL);
 		axi_chan_disable(&chip->dw->chan[i]);
 	}
@@ -1397,6 +1399,14 @@ static int parse_device_properties(struct axi_dma_chip *chip)
 		chip->dw->hdata->axi_rw_burst_len = tmp;
 	}
 
+	/*
+	 * Use all channels if there's no dma-channel-mask property
+	 */
+	ret = device_property_read_u32(dev, "dma-channel-mask", &tmp);
+	if (ret)
+		tmp = GENMASK(chip->dw->hdata->nr_channels - 1, 0);
+	chip->dw->hdata->channels_mask = tmp;
+
 	chip->dw->hdata->perch_irq = device_property_read_bool(dev, "snps,perch_irq");
 
 	return 0;
@@ -1471,6 +1481,10 @@ static int dw_probe(struct platform_device *pdev)
 	if (hdata->perch_irq) {
 		char irqname[8];
 		for (i = 0; i < hdata->nr_channels; i++) {
+			if (!(hdata->channels_mask & (1 << i))) {
+				dw->chan[i].irq = -1;
+				continue;
+			}
 			snprintf(irqname, sizeof(irqname), "ch%u", i);
 			dw->chan[i].irq = platform_get_irq_byname(pdev, irqname);
 			if (dw->chan[i].irq < 0)
@@ -1496,6 +1510,9 @@ static int dw_probe(struct platform_device *pdev)
 	for (i = 0; i < hdata->nr_channels; i++) {
 		struct axi_dma_chan *chan = &dw->chan[i];
 
+		if (!(hdata->channels_mask & (1 << i)))
+			continue;
+
 		chan->chip = chip;
 		chan->id = i;
 		chan->chan_regs = chip->regs + COMMON_REG_LEN + i * CHAN_REG_LEN;
@@ -1593,6 +1610,8 @@ static int dw_remove(struct platform_device *pdev)
 	clk_prepare_enable(chip->core_clk);
 	axi_dma_irq_disable(chip);
 	for (i = 0; i < dw->hdata->nr_channels; i++) {
+		if (!(dw->hdata->channels_mask & (1 << i)))
+			continue;
 		axi_chan_disable(&chip->dw->chan[i]);
 		axi_chan_irq_disable(&chip->dw->chan[i], DWAXIDMAC_IRQ_ALL);
 	}
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
index 49210a248c27..1f9772e9be30 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
@@ -30,6 +30,7 @@ struct dw_axi_dma_hcfg {
 	u32	priority[DMAC_MAX_CHANNELS];
 	/* maximum supported axi burst length */
 	u32	axi_rw_burst_len;
+	u32	channels_mask;
 	/* Register map for DMAX_NUM_CHANNELS <= 8 */
 	bool	reg_map_8_channels;
 	bool	restrict_axi_burst_len;
-- 
2.40.0


  parent reply	other threads:[~2023-05-21 10:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-21 10:12 [PATCH v3 00/11] dmaengine: dw-axi_dmac: bug fix clean up and more features Jisheng Zhang
2023-05-21 10:12 ` [PATCH v3 01/11] dmaengine: dw-axi-dmac: fix reading register when runtime suspended Jisheng Zhang
2023-05-21 10:12 ` [PATCH v3 02/11] dmaengine: dw-axi-dmac: remove unnecessary devm_free_irq() calling Jisheng Zhang
2023-05-21 10:12 ` [PATCH v3 03/11] dmaengine: dw-axi-dmac: remove unnecessary axi_dma_enable() calling Jisheng Zhang
2023-05-21 10:12 ` [PATCH v3 04/11] dmaengine: dw-axi-dmac: remove redundant axi_dma_disable() calling Jisheng Zhang
2023-05-21 10:12 ` [PATCH v3 05/11] dmaengine: dw-axi-dmac: delay irq getting until request_irq Jisheng Zhang
2023-05-21 10:12 ` [PATCH v3 06/11] dmaengine: dw-axi-dmac: move ch irq handling into common routine Jisheng Zhang
2023-05-21 10:12 ` [PATCH v3 07/11] dmaengine: dw-axi-dmac: support per channel irq Jisheng Zhang
2023-05-21 10:12 ` Jisheng Zhang [this message]
2023-05-21 10:12 ` [PATCH v3 09/11] dmaengine: dw-axi-dmac: try best to get residue when tx is running Jisheng Zhang
2023-05-21 10:12 ` [PATCH v3 10/11] dmaengine: dw-axi-dmac: move dma_chan_tx_status() Jisheng Zhang
2023-05-21 10:12 ` [PATCH v3 11/11] dmaengine: dw-axi-dmac: support polled mode Jisheng Zhang

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=20230521101216.4084-9-jszhang@kernel.org \
    --to=jszhang@kernel.org \
    --cc=Eugeniy.Paltsev@synopsys.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /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).