From patchwork Sat Mar 5 10:52:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 8509961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 68F91C0553 for ; Sat, 5 Mar 2016 10:55:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6891E2022A for ; Sat, 5 Mar 2016 10:55:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 64D3B20268 for ; Sat, 5 Mar 2016 10:55:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ac9pz-00048r-4c; Sat, 05 Mar 2016 10:53:31 +0000 Received: from 212-186-180-163.dynamic.surfer.at ([212.186.180.163] helo=cgate.sperl.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ac9pb-0003zl-M5; Sat, 05 Mar 2016 10:53:09 +0000 Received: from rasp3a.intern.sperl.org (account martin@sperl.org [10.10.10.43] verified) by sperl.org (CommuniGate Pro SMTP 6.1.2) with ESMTPSA id 6405648; Sat, 05 Mar 2016 10:52:35 +0000 From: kernel@martin.sperl.org To: Rob Herring , Stephen Warren , Lee Jones , Eric Anholt , Vinod Koul , devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.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 Message-Id: <1457175142-28665-4-git-send-email-kernel@martin.sperl.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1457175142-28665-1-git-send-email-kernel@martin.sperl.org> References: <1457175142-28665-1-git-send-email-kernel@martin.sperl.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160305_025308_199300_FD1D2823 X-CRM114-Status: GOOD ( 16.65 ) X-Spam-Score: -0.9 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Sperl MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Sperl 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 Reviewed-by: Eric Anholt --- 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; }