devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org
To: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	Lee Jones <lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>,
	Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Subject: [PATCH v3 03/11] dmaengine: bcm2835: use shared interrupt for channel 11 to 14.
Date: Sat,  5 Mar 2016 10:52:14 +0000	[thread overview]
Message-ID: <1457175142-28665-4-git-send-email-kernel@martin.sperl.org> (raw)
In-Reply-To: <1457175142-28665-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>

From: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>

The bcm2835 dma channel 11 to 14 only have a single shared irq line,
so this patch implements shared interrupts for these channels.

This patch also introduces 2 new device-tree properties
(optional for compatibility with older device-trees):
* brcm,dma-channel-shared-mask - default: 0x0780
* brcm,dma-shared-irq-index    - default: 11

With this patch applied we now have 11 dma channels available to
the ARM side of the SOC.

Signed-off-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Reviewed-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
---
 drivers/dma/bcm2835-dma.c | 64 ++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 58 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index e4ca980..fe7d5a6 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,20 @@ 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_DEFAULT \
+	(BIT(11) | BIT(12) | BIT(13) | BIT(14))
+#define BCM2835_DMA_IRQ_SHARED_DEFAULT	11
+#define BCM2835_DMA_IRQ_ALL_DEFAULT	12
+
 static inline struct bcm2835_dmadev *to_bcm2835_dma_dev(struct dma_device *d)
 {
 	return container_of(d, struct bcm2835_dmadev, ddev);
@@ -215,6 +231,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 +275,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 +552,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 +568,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,7 +614,8 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
 	int rc;
 	int i;
 	int irq;
-	uint32_t chans_available;
+	unsigned long irq_flags;
+	u32 chans_available, chans_shared_irq_mask, shared_irq_index;
 
 	if (!pdev->dev.dma_mask)
 		pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
@@ -637,14 +666,37 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
 		rc = -EINVAL;
 		goto err_no_dma;
 	}
+	/* we do not support more channels */
+	chans_available &= BIT(BCM2835_DMA_MAX_CHANNEL_NUMBER + 1) - 1;
+
+	/* get shared irq mask falling back to defaults */
+	chans_shared_irq_mask = BCM2835_DMA_IRQ_SHARED_MASK_DEFAULT;
+	of_property_read_u32(pdev->dev.of_node,
+			     "brcm,dma-channel-shared-mask",
+			     &chans_shared_irq_mask);
+
+	/* get shared irq index falling back to default */
+	shared_irq_index = BCM2835_DMA_IRQ_SHARED_DEFAULT;
+	of_property_read_u32(pdev->dev.of_node,
+			     "brcm,dma-shared-irq-index",
+			     &shared_irq_index);
+
+	/* loop over all channels */
+	for (i = 0; i <= fls(chans_available); i++) {
+		if (chans_shared_irq_mask & BIT(i)) {
+			irq = platform_get_irq(pdev,
+					       shared_irq_index);
+			irq_flags = IRQF_SHARED;
+		} else {
+			irq = platform_get_irq(pdev, i);
+			irq_flags = 0;
+		}
 
-	for (i = 0; i < pdev->num_resources; i++) {
-		irq = platform_get_irq(pdev, i);
 		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;
 		}
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-03-05 10:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-05 10:52 [PATCH v3 00/11] dmaengine: bcm2835: bugfix + enhancement of driver kernel-TqfNSX0MhmxHKSADF0wUEw
     [not found] ` <1457175142-28665-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-05 10:52   ` [PATCH v3 01/11] dmaengine: bcm2835: set residue_granularity field kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52   ` [PATCH v3 02/11] dmaengine: bcm2835: remove unnecessary masking of dma channels kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52   ` kernel-TqfNSX0MhmxHKSADF0wUEw [this message]
2016-03-05 10:52   ` [PATCH v3 04/11] ARM: bcm2835: dt: add bindings for shared interrupt properties kernel-TqfNSX0MhmxHKSADF0wUEw
     [not found]     ` <1457175142-28665-5-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-07 23:24       ` Eric Anholt
     [not found]         ` <87fuw1yipi.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2016-03-08 11:23           ` Martin Sperl
     [not found]             ` <3503D512-7E9C-46E8-91C7-CAD828DD48D1-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-11  5:53               ` Vinod Koul
2016-03-10  8:57       ` Mark Rutland
2016-03-11  8:51         ` Martin Sperl
     [not found]           ` <E60A6B56-0F3F-465C-8BF7-59EF35D41070-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-22  9:23             ` Martin Sperl
     [not found]               ` <56F10F21.9020709-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-22 10:24                 ` Mark Rutland
2016-03-05 10:52   ` [PATCH v3 05/11] dmaengine: bcm2835: add additional defines for DMA-registers kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52   ` [PATCH v3 06/11] dmaengine: bcm2835: move cyclic member from bcm2835_chan into bcm2835_desc kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52   ` [PATCH v3 07/11] dmaengine: bcm2835: move controlblock chain generation into separate method kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52   ` [PATCH v3 08/11] dmaengine: bcm2835: limit max length based on channel type kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52   ` [PATCH v3 09/11] dmaengine: bcm2835: add slave_sg support to bcm2835-dma kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52   ` [PATCH v3 10/11] dmaengine: bcm2835: add dma_memcopy " kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52   ` [PATCH v3 11/11] dmaengine: bcm2835: expose dma registers via debugfs kernel-TqfNSX0MhmxHKSADF0wUEw

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=1457175142-28665-4-git-send-email-kernel@martin.sperl.org \
    --to=kernel-tqfnsx0mhmxhksadf0wuew@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org \
    --cc=lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
    --cc=vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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).