From: kernel@martin.sperl.org (kernel at martin.sperl.org)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 3/8] dmaengine: bcm2835: use shared interrupt for channel 11 to 14.
Date: Thu, 7 Jan 2016 17:33:01 +0000 [thread overview]
Message-ID: <1452187987-2605-4-git-send-email-kernel@martin.sperl.org> (raw)
In-Reply-To: <1452187987-2605-1-git-send-email-kernel@martin.sperl.org>
From: Martin Sperl <kernel@martin.sperl.org>
The bcm2835 dma channel 11 to 14 only have a single shared irq line,
so this patch implements shared interrupts for these channels.
To avoid changes to the device tree (with regards to interrupts listed,
which reflects on pdev->num_resources) a fixed channel count had
to get used in the code instead.
With this patch applied we now have 11 dma channels available to
the ARM side of the SOC.
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
---
drivers/dma/bcm2835-dma.c | 46 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 41 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index e4ca980..0c04236 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -81,7 +81,9 @@ struct bcm2835_chan {
struct dma_pool *cb_pool;
void __iomem *chan_base;
+
int irq_number;
+ unsigned long irq_flags;
};
struct bcm2835_desc {
@@ -127,6 +129,19 @@ struct bcm2835_desc {
#define BCM2835_DMA_CHAN(n) ((n) << 8) /* Base address */
#define BCM2835_DMA_CHANIO(base, n) ((base) + BCM2835_DMA_CHAN(n))
+/*
+ * number of dma channels we support
+ * we do not support DMA channel 15, as it is in a separate IO range,
+ * does not have a separate IRQ line except for the "catch all IRQ line"
+ * finally this channel is used by the firmware so is not available
+ */
+#define BCM2835_DMA_MAX_CHANNEL_NUMBER 14
+
+/* the DMA channels 11 to 14 share a common interrupt */
+#define BCM2835_DMA_IRQ_SHARED_MASK (BIT(11) | BIT(12) | BIT(13) | BIT(14))
+#define BCM2835_DMA_IRQ_SHARED 11
+#define BCM2835_DMA_IRQ_ALL 12
+
static inline struct bcm2835_dmadev *to_bcm2835_dma_dev(struct dma_device *d)
{
return container_of(d, struct bcm2835_dmadev, ddev);
@@ -215,6 +230,15 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data)
struct bcm2835_desc *d;
unsigned long flags;
+ /* check the shared interrupt */
+ if (c->irq_flags & IRQF_SHARED) {
+ /* check if the interrupt is enabled */
+ flags = readl(c->chan_base + BCM2835_DMA_CS);
+ /* if not set then we are not the reason for the irq */
+ if (!(flags & BCM2835_DMA_INT))
+ return IRQ_NONE;
+ }
+
spin_lock_irqsave(&c->vc.lock, flags);
/* Acknowledge interrupt */
@@ -250,7 +274,8 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan)
}
return request_irq(c->irq_number,
- bcm2835_dma_callback, 0, "DMA IRQ", c);
+ bcm2835_dma_callback,
+ c->irq_flags, "DMA IRQ", c);
}
static void bcm2835_dma_free_chan_resources(struct dma_chan *chan)
@@ -526,7 +551,8 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan)
return 0;
}
-static int bcm2835_dma_chan_init(struct bcm2835_dmadev *d, int chan_id, int irq)
+static int bcm2835_dma_chan_init(struct bcm2835_dmadev *d, int chan_id,
+ int irq, unsigned long irq_flags)
{
struct bcm2835_chan *c;
@@ -541,6 +567,7 @@ static int bcm2835_dma_chan_init(struct bcm2835_dmadev *d, int chan_id, int irq)
c->chan_base = BCM2835_DMA_CHANIO(d->base, chan_id);
c->ch = chan_id;
c->irq_number = irq;
+ c->irq_flags = irq_flags;
return 0;
}
@@ -586,6 +613,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
int rc;
int i;
int irq;
+ unsigned long irq_flags;
uint32_t chans_available;
if (!pdev->dev.dma_mask)
@@ -638,13 +666,21 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
goto err_no_dma;
}
- for (i = 0; i < pdev->num_resources; i++) {
- irq = platform_get_irq(pdev, i);
+ for (i = 0; i <= BCM2835_DMA_MAX_CHANNEL_NUMBER; i++) {
+ if (BCM2835_DMA_IRQ_SHARED_MASK & BIT(i)) {
+ irq = platform_get_irq(pdev,
+ BCM2835_DMA_IRQ_SHARED);
+ irq_flags = IRQF_SHARED;
+ } else {
+ irq = platform_get_irq(pdev, i);
+ irq_flags = 0;
+ }
+
if (irq < 0)
break;
if (chans_available & (1 << i)) {
- rc = bcm2835_dma_chan_init(od, i, irq);
+ rc = bcm2835_dma_chan_init(od, i, irq, irq_flags);
if (rc)
goto err_no_dma;
}
--
1.7.10.4
next prev parent reply other threads:[~2016-01-07 17:33 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-07 17:32 [PATCH V2 0/8] dmaengine: bcm2835: enhancement of driver kernel at martin.sperl.org
2016-01-07 17:32 ` [PATCH V2 1/8] dmaengine: bcm2835: set residue_granularity field kernel at martin.sperl.org
2016-01-28 19:53 ` Eric Anholt
2016-01-07 17:33 ` [PATCH V2 2/8] dmaengine: bcm2835: remove unnecessary masking of dma channels kernel at martin.sperl.org
2016-01-30 3:08 ` Eric Anholt
2016-01-07 17:33 ` kernel at martin.sperl.org [this message]
2016-01-13 12:26 ` [PATCH V2 3/8] dmaengine: bcm2835: use shared interrupt for channel 11 to 14 Vinod Koul
2016-01-13 13:30 ` Martin Sperl
2016-01-13 13:43 ` Vinod Koul
2016-01-13 14:24 ` Martin Sperl
2016-01-14 4:07 ` Vinod Koul
2016-01-14 8:48 ` Martin Sperl
2016-02-29 17:10 ` Martin Sperl
2016-03-03 15:45 ` Vinod Koul
2016-02-18 4:09 ` Eric Anholt
2016-01-07 17:33 ` [PATCH V2 4/8] dmaengine: bcm2835: add additional defines for DMA-registers kernel at martin.sperl.org
2016-01-13 12:32 ` Vinod Koul
2016-02-18 4:18 ` Eric Anholt
2016-01-07 17:33 ` [PATCH V2 5/8] dmaengine: bcm2835: move cyclic member from bcm2835_chan into bcm2835_desc kernel at martin.sperl.org
2016-02-18 4:19 ` Eric Anholt
2016-01-07 17:33 ` [PATCH V2 6/8] dmaengine: bcm2835: move controlblock chain generation into separate method kernel at martin.sperl.org
2016-01-13 13:23 ` Vinod Koul
2016-01-13 13:38 ` Martin Sperl
2016-02-18 3:24 ` Eric Anholt
2016-02-29 18:14 ` Martin Sperl
2016-01-07 17:33 ` [PATCH V2 7/8] dmaengine: bcm2835: add slave_sg support to bcm2835-dma kernel at martin.sperl.org
2016-02-18 4:39 ` Eric Anholt
2016-01-07 17:33 ` [PATCH V2 8/8] dmaengine: bcm2835: add dma_memcopy " kernel at martin.sperl.org
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=1452187987-2605-4-git-send-email-kernel@martin.sperl.org \
--to=kernel@martin.sperl.org \
--cc=linux-arm-kernel@lists.infradead.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).