Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp508868ybg; Fri, 18 Oct 2019 03:15:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtVHJuELrXmUP+78bb+8X+CBmCCMErmzlxUGca/jhcvC5fInO4VgAoNtI8wHpr477vlyAy X-Received: by 2002:a17:906:160f:: with SMTP id m15mr7583807ejd.217.1571393741733; Fri, 18 Oct 2019 03:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571393741; cv=none; d=google.com; s=arc-20160816; b=LqYKvykRfb5DZTkUuD/TN7Cmsgi2LL1Qd0fldop0OmOlmlGOkRIMas5dMOaFrlY9/z He0+3D/yztXFVpxm3GK0aiUW0TWM+RP9agTfrm9Quh1PZ9sl1djZ180kLLgUi4KBUHIn Fi7JFcIjfdU7Yn3Lmbm6MBdvlVwmdgM0hBOF9REX+mbSnaU2+1K5TKLBPPnaV4b+sKRk IFnARrK2ERwONNdvEUMAVVEtDjMvvOcUwNmW9SuymX1c3xVkMQyyObAVWzpe9rU9zwuJ x1qqiQJxUJ5/HxFI2XnwgZgIEcgXnN9UtFESLaO/pRckzS98PMZdboHasuYCVkPYhuP/ rMCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=bo+KWQc0iV5go53wk/nxz8zDtTlUCls8i8slfrZfNHA=; b=1HpRUJrmfnRXcVN/NcT/wtDApejxGpgUNWeEfKNH2plbMtLKPgG36XJUmZvneUd5Y4 tTfk4aUd6DH6D90m/yf4BKrz6bAGdD1F3ebGg6tYIzusy9Oxjnce5ms8Wi/oulB8K8DE BjaEWqd37sH95WLOO5LW9x7+dju+4kXt2cJyQyZLSgUW96ZEb6m1uDPvSmBF0Z4g6etO kdz+MvCfPtrtQLSDOEJgn8MBjPJHQgdk0r57KNOCMTnu8LTom1F4hlXqQRDL29C2mrCW Nbb9zrsCNAYaqqdXgWFofHwSyZO2TI35gJOnse0XGe/iMK1aAyJf/KeFrOZZb9TmxEs+ puGw== ARC-Authentication-Results: i=1; mx.google.com; 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=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si2897129ejk.264.2019.10.18.03.15.18; Fri, 18 Oct 2019 03:15:41 -0700 (PDT) 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; 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=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438867AbfJQI0a (ORCPT + 99 others); Thu, 17 Oct 2019 04:26:30 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:37497 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2393068AbfJQI02 (ORCPT ); Thu, 17 Oct 2019 04:26:28 -0400 X-UUID: 14933d35c3bd4972b17ffa5663f75a04-20191017 X-UUID: 14933d35c3bd4972b17ffa5663f75a04-20191017 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1665337815; Thu, 17 Oct 2019 16:26:21 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 17 Oct 2019 16:26:19 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 17 Oct 2019 16:26:19 +0800 From: To: Bin Liu , Rob Herring CC: Greg Kroah-Hartman , Mark Rutland , Matthias Brugger , Alan Stern , , , , , , , , , Min Guo Subject: [PATCH RESEND v7 4/6] usb: musb: Add noirq type of dma create interface Date: Thu, 17 Oct 2019 16:25:52 +0800 Message-ID: <20191017082554.27953-5-min.guo@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20191017082554.27953-1-min.guo@mediatek.com> References: <20191017082554.27953-1-min.guo@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: E80B03EA88119ABE9E9C7ECCC5E0FEDF6CB6A42358AAED9D6AFC42BF9A81E0D22000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Min Guo Add noirq type of dma create interface for platform which do not have dedicated DMA interrupt line, move musbhsdma macro definition to musb_dma.h Signed-off-by: Min Guo --- changes in v7: 1. no changes changes in v6: 1. no changes changes in v5: 1. no changes new patch based on v4: --- drivers/usb/musb/musb_dma.h | 9 ++++++++ drivers/usb/musb/musbhsdma.c | 54 ++++++++++++++++++++++++++++++-------------- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h index 8f60271..05103ea3 100644 --- a/drivers/usb/musb/musb_dma.h +++ b/drivers/usb/musb/musb_dma.h @@ -35,6 +35,12 @@ * whether shared with the Inventra core or separate. */ +#define MUSB_HSDMA_BASE 0x200 +#define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0) +#define MUSB_HSDMA_CONTROL 0x4 +#define MUSB_HSDMA_ADDRESS 0x8 +#define MUSB_HSDMA_COUNT 0xc + #define DMA_ADDR_INVALID (~(dma_addr_t)0) #ifdef CONFIG_MUSB_PIO_ONLY @@ -191,6 +197,9 @@ static inline void musb_dma_controller_destroy(struct dma_controller *d) { } 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 struct dma_controller * +musbhs_dma_controller_create_noirq(struct musb *musb, void __iomem *base); +extern irqreturn_t dma_controller_irq(int irq, void *private_data); 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 5fc6825..d549c0b 100644 --- a/drivers/usb/musb/musbhsdma.c +++ b/drivers/usb/musb/musbhsdma.c @@ -10,12 +10,7 @@ #include #include #include "musb_core.h" - -#define MUSB_HSDMA_BASE 0x200 -#define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0) -#define MUSB_HSDMA_CONTROL 0x4 -#define MUSB_HSDMA_ADDRESS 0x8 -#define MUSB_HSDMA_COUNT 0xc +#include "musb_dma.h" #define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \ (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset) @@ -268,7 +263,7 @@ static int dma_channel_abort(struct dma_channel *channel) return 0; } -static irqreturn_t dma_controller_irq(int irq, void *private_data) +irqreturn_t dma_controller_irq(int irq, void *private_data) { struct musb_dma_controller *controller = private_data; struct musb *musb = controller->private_data; @@ -383,6 +378,7 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data) spin_unlock_irqrestore(&musb->lock, flags); return retval; } +EXPORT_SYMBOL_GPL(dma_controller_irq); void musbhs_dma_controller_destroy(struct dma_controller *c) { @@ -398,18 +394,10 @@ void musbhs_dma_controller_destroy(struct dma_controller *c) } EXPORT_SYMBOL_GPL(musbhs_dma_controller_destroy); -struct dma_controller *musbhs_dma_controller_create(struct musb *musb, - void __iomem *base) +static struct musb_dma_controller * +dma_controller_alloc(struct musb *musb, void __iomem *base) { 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"); - - if (irq <= 0) { - dev_err(dev, "No DMA interrupt line!\n"); - return NULL; - } controller = kzalloc(sizeof(*controller), GFP_KERNEL); if (!controller) @@ -423,6 +411,25 @@ struct dma_controller *musbhs_dma_controller_create(struct musb *musb, controller->controller.channel_release = dma_channel_release; controller->controller.channel_program = dma_channel_program; controller->controller.channel_abort = dma_channel_abort; + return controller; +} + +struct dma_controller * +musbhs_dma_controller_create(struct musb *musb, void __iomem *base) +{ + 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"); + + if (irq <= 0) { + dev_err(dev, "No DMA interrupt line!\n"); + return NULL; + } + + controller = dma_controller_alloc(musb, base); + if (!controller) + return NULL; if (request_irq(irq, dma_controller_irq, 0, dev_name(musb->controller), &controller->controller)) { @@ -437,3 +444,16 @@ struct dma_controller *musbhs_dma_controller_create(struct musb *musb, return &controller->controller; } EXPORT_SYMBOL_GPL(musbhs_dma_controller_create); + +struct dma_controller * +musbhs_dma_controller_create_noirq(struct musb *musb, void __iomem *base) +{ + struct musb_dma_controller *controller; + + controller = dma_controller_alloc(musb, base); + if (!controller) + return NULL; + + return &controller->controller; +} +EXPORT_SYMBOL_GPL(musbhs_dma_controller_create_noirq); -- 1.9.1