Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp733368ybg; Fri, 18 Oct 2019 06:38:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdHMm2OTOE1gzWFC+z+00dz9U54K2h8N99LBaINTK3tGPp/c9Kt26xvKXch8RTVoG2mgOt X-Received: by 2002:a17:906:745:: with SMTP id z5mr8952713ejb.41.1571405880637; Fri, 18 Oct 2019 06:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571405880; cv=none; d=google.com; s=arc-20160816; b=QBczaiXGyxIIzwGC7qkbRFvggFwR9t2jXJ9Y2gzs0nddRNCq2zKTKsz6o363bPa9l0 vHzlE+GLICxjPYJVa1zYQd5siiF8bM8Jep9KtsKx0nVTH0odAuZv6ZZqDjI5PB6fTDX4 lR5lFm6BYaBpPDt/JsP5B2C7XOkkDXFZVOYVR6rcXPMSRBKILlC7yC7hPiD9N4VpaQbB BT3eJhjRX9meQeXCjFEjnKzRZnayxV4G67VFPsiyfvG3d1yvoFpR6RsgzTtqpdl/jbuU Sj1MGC7y3o2LwCrxAYMgr0J9snWrQ+EpTAYyx6KdcaiW/K9jnufO4pD1h3CuXva+4gPI jk+g== 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=BJMGm5E/xWb8wr6gfUbiCH/roQSoexF27RdNdc1OJPM=; b=Zaa0FVdJctqCzh8/IMYDaAVqaq94fzBCw7cQVKqN6BSNFjtB/ikLxyl8atwWAE1AHx DJgfEW9vNP1C8Mt5LykfL9vf8aftkzdPeLT+TAi0rlMDPyDh690QklUK6Yt3QHElLQIa sCyHVKLFxSwEas0Il1SN+e3124Hn8nza91wBnUfPzdJfyXQQBCcNikpwrlnsVAa2Ob9r GxxR3EctUcXHru0g9o5ccTaI//rKFW1QlW23VSJnFX7gy64VOf2IN6PiDbglr5Z7G6pd 3XbTrfzNcSzuaQwUKvwcV8S7TRJ47IcyDkFi45ANdsmhcHiBsDA3bldnoyV9K0rZmQrm D/+Q== 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 ck7si3261000ejb.250.2019.10.18.06.37.37; Fri, 18 Oct 2019 06:38:00 -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 S2408595AbfJQJll (ORCPT + 99 others); Thu, 17 Oct 2019 05:41:41 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:31387 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2439565AbfJQJlk (ORCPT ); Thu, 17 Oct 2019 05:41:40 -0400 X-UUID: 5e894a117bca4486a6ba85dfc1cd403f-20191017 X-UUID: 5e894a117bca4486a6ba85dfc1cd403f-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 1440948316; Thu, 17 Oct 2019 17:41:35 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 17 Oct 2019 17:41:33 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 17 Oct 2019 17:41:32 +0800 From: To: Bin Liu , Rob Herring CC: Greg Kroah-Hartman , Mark Rutland , Matthias Brugger , Alan Stern , , , , , , , , , Min Guo Subject: [PATCH v8 4/6] usb: musb: Add noirq type of dma create interface Date: Thu, 17 Oct 2019 17:41:24 +0800 Message-ID: <20191017094126.29045-5-min.guo@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20191017094126.29045-1-min.guo@mediatek.com> References: <20191017094126.29045-1-min.guo@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 8DFFAF5831C4F59931983C17492296CA544AD8F25B376C290273144417BE9AD82000: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 v8: 1. no changes 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