From patchwork Mon Jan 23 16:48:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9533113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE7DC6020B for ; Mon, 23 Jan 2017 16:48:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2E8B2841B for ; Mon, 23 Jan 2017 16:48:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D484128375; Mon, 23 Jan 2017 16:48:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F2E128375 for ; Mon, 23 Jan 2017 16:48:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751332AbdAWQsc (ORCPT ); Mon, 23 Jan 2017 11:48:32 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:38262 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338AbdAWQsc (ORCPT ); Mon, 23 Jan 2017 11:48:32 -0500 Received: by mail-wm0-f47.google.com with SMTP id r144so164858063wme.1 for ; Mon, 23 Jan 2017 08:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l0diVk/x0C2hYHFgAMLCYylYsi9Eg2+NcvKNdF3Dt7A=; b=Z9gn92LZmpIvHxNF0ivvGSDqm4wV2vbUtH9Pdlf5B3xozNBtqhY7op2KBHNrWUP+t0 m1avy5zmT0JB+i0mTqwekVo+NnMw7T2Ma+gFt6G8WBgavpU0cBilp/hLwyohjonn7AWG ykY369z6Dkq43s5icppmVnDOqBzsEJfAJ9kOSS1Mdnt/MuQw50vkwMZLeIjVOxtFmNc5 mg9UlVxNYao4j0itnAMHwYW+pNN3grZtmYd18EAiit9bOvOCWoDtzu3VX47TnYxyl1MO 5dC0Ef9gnKvHrbGwMcXpvJpNQo/xTOotzNTctacKSfyxH+iE3JQYhVWvZsjVIYbrnGS+ JoSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l0diVk/x0C2hYHFgAMLCYylYsi9Eg2+NcvKNdF3Dt7A=; b=aIrHoUQjQedS1FVP1dtZUoUgDbsMN2qTaIxgOyxeHJujPUKeyFX8cA3JKQpGrEhApj TqMw9udYvkpvmSHBB4JSFaUgc74QgWIle6EmtgLkHv3VkPJZgWfmwWSdq0eW37kficU1 LCfE/Qj58FdVq59YkxQLeXPrdPBljseAdIxWefc+kEy+Zkbz9qJnY69gTg1Y9atJJnBf VOmxWZKl376q9tpC7IoRgch/k9k6WhpsHjudvMyNfOWuGK2Fax/bHtxk3c2oC7BPXCcR BoTBCWT1iFUrZb/PSbitzypIan67lebHcwjgMuti1d9K8km/a2HyUhwTScb6a60IpRSq 87cw== X-Gm-Message-State: AIkVDXIgRyFjskxPKn2Am/65gxT21hIPoBFiwGBWnT9EJM5BDXvH/kPX0K/K+58hSi7MUxlX X-Received: by 10.28.185.77 with SMTP id j74mr15158301wmf.76.1485190096588; Mon, 23 Jan 2017 08:48:16 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y127sm21907054wmg.12.2017.01.23.08.48.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jan 2017 08:48:15 -0800 (PST) From: Alexandre Bailon To: b-liu@ti.com Cc: vinod.koul@intel.com, dmaengine@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, tony@atomide.com, linux-omap@vger.kernel.org, sergei.shtylyov@cogentembedded.com, Alexandre Bailon Subject: [PATCH v4 1/6] usb: musb: dma: Add a DMA completion platform callback Date: Mon, 23 Jan 2017 17:48:03 +0100 Message-Id: <20170123164808.27936-2-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170123164808.27936-1-abailon@baylibre.com> References: <20170123164808.27936-1-abailon@baylibre.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the CPPI 4.1 driver is not completely generic and only works on DSPS. This is because of IRQ management. Add a callback to dma_controller that could be invoked on DMA completion to acknowledge the IRQ. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/musb_cppi41.c | 7 +++++-- drivers/usb/musb/musb_dma.h | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index 1636385..f7d3d27 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -217,6 +217,10 @@ static void cppi41_dma_callback(void *private_data) int is_hs = 0; bool empty; + controller = cppi41_channel->controller; + if (controller->controller.dma_callback) + controller->controller.dma_callback(&controller->controller); + spin_lock_irqsave(&musb->lock, flags); dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie, @@ -249,8 +253,6 @@ static void cppi41_dma_callback(void *private_data) * We spin on HS (no longer than than 25us and setup a timer on * FS to check for the bit and complete the transfer. */ - controller = cppi41_channel->controller; - if (is_host_active(musb)) { if (musb->port1_status & USB_PORT_STAT_HIGH_SPEED) is_hs = 1; @@ -695,6 +697,7 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) controller->controller.channel_program = cppi41_dma_channel_program; controller->controller.channel_abort = cppi41_dma_channel_abort; controller->controller.is_compatible = cppi41_is_compatible; + controller->controller.musb = musb; ret = cppi41_dma_controller_start(controller); if (ret) diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h index 46357e1..04c3bd8 100644 --- a/drivers/usb/musb/musb_dma.h +++ b/drivers/usb/musb/musb_dma.h @@ -173,6 +173,7 @@ dma_channel_status(struct dma_channel *c) /** * struct dma_controller - A DMA Controller. + * @musb: the usb controller * @start: call this to start a DMA controller; * return 0 on success, else negative errno * @stop: call this to stop a DMA controller @@ -181,10 +182,13 @@ dma_channel_status(struct dma_channel *c) * @channel_release: call this to release a DMA channel * @channel_abort: call this to abort a pending DMA transaction, * returning it to FREE (but allocated) state + * @dma_callback: invoked on DMA completion, useful to run platform + * code such IRQ acknowledgment. * * Controllers manage dma channels. */ struct dma_controller { + struct musb *musb; struct dma_channel *(*channel_alloc)(struct dma_controller *, struct musb_hw_ep *, u8 is_tx); void (*channel_release)(struct dma_channel *); @@ -196,6 +200,7 @@ struct dma_controller { int (*is_compatible)(struct dma_channel *channel, u16 maxpacket, void *buf, u32 length); + void (*dma_callback)(struct dma_controller *); }; /* called after channel_program(), may indicate a fault */