Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5645218ybl; Tue, 10 Dec 2019 09:13:15 -0800 (PST) X-Google-Smtp-Source: APXvYqyVC3xk+m+NB0M/Oa1LD0mR/E8j7GHRjNAov5eXKEKa5PhTQIPUIUYUQMZvGre4//p7PiSB X-Received: by 2002:a9d:730e:: with SMTP id e14mr25142968otk.62.1575997995679; Tue, 10 Dec 2019 09:13:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575997995; cv=none; d=google.com; s=arc-20160816; b=yk7V/n3+bf9Dqfb+SyBjQJnDbi2waPjbR5eeIX4TxILw6E+HRZVfD8LNu+T1nAh6W1 H4nLiRoAdYhNltJnKBtVX74MZesmfvKn6UKzCSSj4hX+cWzT3hH1LHyCZ5kgQ9mWnD6A a6A2nokIgs6N05myhsFTlqEvNLOR5/4i24Y9rWiZ257UVPpQ/A/IvMPA4VSjI390H53E Ic6wMp87mzrwnVWGjfxj4nR4u6kP7PYK3PGABSVlX6OSSLX96OQ6qus6c6VJHWS5z/jA 8piPdUKK9/Chx7eZv9xP7WAztzlf4wuZ4NY2vjQYAwYfsGXDqUFLU1GmpBQHHFNM2V33 p1pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GCB2kEfKlMoJDOKt8Tg1TaktvZregxG9Kvxvr/Rr6Ks=; b=HOwVmSFnRx0t4JV1Y5UwLd2cNMM0uB/xgIOiXWeaWo8sN8Kr5I2LVH3b086ua7v/z8 Np/A6Ai4tI5UoW63cHXMLfu+pu553wApGAyajg6YN4SVTcZJBhGXnXqWQ+aisl6Yqr9W 5mR7Qim5CVsQf0idi/UGR2KrbbE1puPtvis1lOfZzGrHDO9vD3l5rve8b7N8Lt1AuuRH S3XUggDp29GniDQYUPvG10zqRlYLYxSZPid9+XE4FjsG3hAmX/Esy/C43fe57ggwbJ5n tmev3Pm31BaWGWE9M+qCpP0SLipXOmFH2JViitKG9NaPN5M58URT0dES96Yzjxx7tUcc baMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b="u/T7YqBH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a205si2279008oii.95.2019.12.10.09.13.02; Tue, 10 Dec 2019 09:13:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b="u/T7YqBH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727822AbfLJRL0 (ORCPT + 99 others); Tue, 10 Dec 2019 12:11:26 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:44592 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbfLJRLZ (ORCPT ); Tue, 10 Dec 2019 12:11:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1575997876; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GCB2kEfKlMoJDOKt8Tg1TaktvZregxG9Kvxvr/Rr6Ks=; b=u/T7YqBHCd/741IVEz1Bf0jbIzQoapW08VpmqohOpNwt3DuMbv+6BJGVL/9WEcI91gjZwG lm9BVFXr/a26nI1rF2j+eJYEFa4s1GowWhO+xy0mfmMgY4qq3Ums7SBIZxGOXC3hj+bpfs AGRkc1kvoGdcxzWgb6R7+7AkQGv4sAU= From: Paul Cercueil To: Bin Liu , Greg Kroah-Hartman Cc: od@zcrc.me, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil , Artur Rojek Subject: [PATCH v3 2/7] usb: musb: dma: Add support for shared IRQ Date: Tue, 10 Dec 2019 18:11:05 +0100 Message-Id: <20191210171110.62141-2-paul@crapouillou.net> In-Reply-To: <20191210171110.62141-1-paul@crapouillou.net> References: <20191210171110.62141-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tested-by: Artur Rojek --- 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