From: Paul Cercueil <paul@crapouillou.net>
To: Bin Liu <b-liu@ti.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: od@zcrc.me, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
Paul Cercueil <paul@crapouillou.net>,
Artur Rojek <contact@artur-rojek.eu>
Subject: [PATCH v3 2/7] usb: musb: dma: Add support for shared IRQ
Date: Tue, 10 Dec 2019 18:11:05 +0100 [thread overview]
Message-ID: <20191210171110.62141-2-paul@crapouillou.net> (raw)
In-Reply-To: <20191210171110.62141-1-paul@crapouillou.net>
The implementation of the Inventra IP in some of the Ingenic JZ47xx SoCs
does not use a separate IRQ line for DMA transfers.
Allow these SoCs to be supported by adding a flag 'dma_share_usb_irq'
in the struct musb. If set, no extra IRQ line is required, and the musb
glue will need to call the API function musbhs_dma_controller_irq()
within its interrupt handler.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Artur Rojek <contact@artur-rojek.eu>
---
Notes:
v2: Rebase on 5.4-rc4
v3: Rebase on 5.5-rc1
drivers/usb/musb/musb_core.h | 2 ++
drivers/usb/musb/musb_dma.h | 1 +
drivers/usb/musb/musbhsdma.c | 27 ++++++++++++++++++++++-----
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 04203b7126d5..b7c31c717800 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -392,6 +392,8 @@ struct musb {
unsigned flush_irq_work:1;
+ unsigned dma_share_usb_irq:1;
+
u8 address;
u8 test_mode_nr;
u16 ackpend; /* ep0 */
diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 8f60271c0a9d..b3f65016a972 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -191,6 +191,7 @@ extern void (*musb_dma_controller_destroy)(struct dma_controller *);
extern struct dma_controller *
musbhs_dma_controller_create(struct musb *musb, void __iomem *base);
extern void musbhs_dma_controller_destroy(struct dma_controller *c);
+extern irqreturn_t musbhs_dma_controller_irq(struct dma_controller *c);
extern struct dma_controller *
tusb_dma_controller_create(struct musb *musb, void __iomem *base);
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 2d3751d885b4..898856e9974e 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -268,7 +268,7 @@ static int dma_channel_abort(struct dma_channel *channel)
return 0;
}
-static irqreturn_t dma_controller_irq(int irq, void *private_data)
+static irqreturn_t dma_controller_irq_cb(int irq, void *private_data)
{
struct musb_dma_controller *controller = private_data;
struct musb *musb = controller->private_data;
@@ -292,6 +292,9 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
int_hsdma = musb_readb(mbase, MUSB_HSDMA_INTR);
if (!int_hsdma) {
+ if (musb->dma_share_usb_irq)
+ goto done;
+
musb_dbg(musb, "spurious DMA irq");
for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) {
@@ -384,6 +387,15 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
return retval;
}
+irqreturn_t musbhs_dma_controller_irq(struct dma_controller *c)
+{
+ struct musb_dma_controller *controller = container_of(c,
+ struct musb_dma_controller, controller);
+
+ return dma_controller_irq_cb(controller->irq, controller);
+}
+EXPORT_SYMBOL_GPL(musbhs_dma_controller_irq);
+
void musbhs_dma_controller_destroy(struct dma_controller *c)
{
struct musb_dma_controller *controller = container_of(c,
@@ -404,9 +416,14 @@ struct dma_controller *musbhs_dma_controller_create(struct musb *musb,
struct musb_dma_controller *controller;
struct device *dev = musb->controller;
struct platform_device *pdev = to_platform_device(dev);
- int irq = platform_get_irq_byname(pdev, "dma");
+ int irq;
+
+ if (musb->dma_share_usb_irq)
+ irq = 0;
+ else
+ irq = platform_get_irq_byname(pdev, "dma");
- if (irq <= 0) {
+ if (irq < 0) {
dev_err(dev, "No DMA interrupt line!\n");
return NULL;
}
@@ -424,8 +441,8 @@ struct dma_controller *musbhs_dma_controller_create(struct musb *musb,
controller->controller.channel_program = dma_channel_program;
controller->controller.channel_abort = dma_channel_abort;
- if (request_irq(irq, dma_controller_irq, 0,
- dev_name(musb->controller), controller)) {
+ if (irq > 0 && request_irq(irq, dma_controller_irq_cb, 0,
+ dev_name(musb->controller), controller)) {
dev_err(dev, "request_irq %d failed!\n", irq);
musb_dma_controller_destroy(&controller->controller);
--
2.24.0
next prev parent reply other threads:[~2019-12-10 17:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-10 17:11 [PATCH v3 1/7] usb: musb: dma: Correct parameter passed to IRQ handler Paul Cercueil
2019-12-10 17:11 ` Paul Cercueil [this message]
2019-12-11 18:52 ` [PATCH v3 2/7] usb: musb: dma: Add support for shared IRQ Bin Liu
2019-12-17 14:42 ` Bin Liu
2019-12-17 21:04 ` Paul Cercueil
2019-12-17 21:17 ` Bin Liu
2019-12-10 17:11 ` [PATCH v3 3/7] usb: musb: jz4740: Add support for DMA Paul Cercueil
2019-12-11 18:52 ` Bin Liu
2019-12-10 17:11 ` [PATCH v3 4/7] usb: musb: jz4740: Drop dependency on NOP_USB_XCEIV Paul Cercueil
2019-12-11 18:53 ` Bin Liu
2019-12-10 17:11 ` [PATCH v3 5/7] usb: musb: jz4740: Silence error if code is -EPROBE_DEFER Paul Cercueil
2019-12-11 19:00 ` Bin Liu
2019-12-10 17:11 ` [PATCH v3 6/7] usb: musb: jz4740: Code cleanup Paul Cercueil
2019-12-10 19:59 ` Bin Liu
2019-12-14 11:30 ` Greg Kroah-Hartman
2019-12-10 17:11 ` [PATCH v3 7/7] usb: musb: jz4740: Disable pullup at init Paul Cercueil
2019-12-10 19:52 ` Bin Liu
2019-12-11 18:51 ` [PATCH v3 1/7] usb: musb: dma: Correct parameter passed to IRQ handler Bin Liu
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=20191210171110.62141-2-paul@crapouillou.net \
--to=paul@crapouillou.net \
--cc=b-liu@ti.com \
--cc=contact@artur-rojek.eu \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=od@zcrc.me \
/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).