From patchwork Fri Jan 13 14:58:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9515775 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 A4F35601DA for ; Fri, 13 Jan 2017 14:58:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98EEB286D2 for ; Fri, 13 Jan 2017 14:58:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DC5028671; Fri, 13 Jan 2017 14:58:44 +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 3503B28671 for ; Fri, 13 Jan 2017 14:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751745AbdAMO6m (ORCPT ); Fri, 13 Jan 2017 09:58:42 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:35747 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751806AbdAMO6l (ORCPT ); Fri, 13 Jan 2017 09:58:41 -0500 Received: by mail-wm0-f47.google.com with SMTP id r126so68671046wmr.0 for ; Fri, 13 Jan 2017 06:58:40 -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=g4Vued6jFy2sx5Q0uekxM4bEMydEuRo2CHR89Mc4ApM=; b=tnseU+MWYqkzSTXrx7P/AFO/0sKkN9iEFI/bbapFtv/zscUdnhYMxXzMxVaskSLpFv BePCVXrgV1b/iseBSUAy0rdYLELw9/K158AUHjomeoTpuyUYzyNaA0WfVHKroyVSVE0A EAna1c8I1eGz4l0R4OsTRmhwcITRkYlZip8AdcXa1gUs9m5juAwISddI8NWhnoFCuMUv fYUxedesuocfC+4/DglH54fdFvhU4ZmArYqW4FLUGa+mYenSHTAfk05BBtOm+KIfebrZ 9uU4IMJ2krmc3sCNWFJ3i/TuP+AOHY8qy0hAwr8xL+83a0ZflqRANXLze2m7yVgy1vDg JxAw== 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=g4Vued6jFy2sx5Q0uekxM4bEMydEuRo2CHR89Mc4ApM=; b=IIFbUgG5ZrExPQ1WPM+3P8ZPYsGJrjfOOIqO719Zf1CSla9XOfvKBcnYTe/qWa22Nd cKWDvg0ARgsbXqumIJvpfnNqZvMcmFMOLPIJ19tRJ4YFicd40/U77rwggQAGoWNLd7gN CrwxgJmse0jlNjJONnjnvwnny/jWyycyGMxeww1qjDL8YEQY0Gas5YCqeZqyGCSR9ccj TvwJIsXKytGPixZxz6/8ts1ekW3DjgPi2i/eYeW0jEkfhJvsS3vWXB6l/sfPlUgZ+nIW haJXVWo0Bhxea81xqTzwL7BrkJRk7ULvnEYc6vh/ofjYaHesMc4cNJE5FVvsYAUapYU9 FdTQ== X-Gm-Message-State: AIkVDXJrpSqrDhRLG/mBU+q87HKok+DOgpNbyq1JAHXAa/nG8nWqscQxMu1UZ6BH7i1d+X7g X-Received: by 10.28.164.196 with SMTP id n187mr2561408wme.44.1484319520049; Fri, 13 Jan 2017 06:58:40 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id e14sm4801258wmd.14.2017.01.13.06.58.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jan 2017 06:58:39 -0800 (PST) From: Alexandre Bailon To: vinod.koul@intel.com Cc: dmaengine@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, tony@atomide.com, linux-omap@vger.kernel.org, b-liu@ti.com, sergei.shtylyov@cogentembedded.com, Alexandre Bailon Subject: [PATCH 1/3] usb: musb: cppi41: Add new methods for platform driver Date: Fri, 13 Jan 2017 15:58:32 +0100 Message-Id: <20170113145834.23967-2-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170113145834.23967-1-abailon@baylibre.com> References: <20170113145834.23967-1-abailon@baylibre.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the CPPI 4.1 driver is not completely generic and only work on dsps. Add two methods which will help to move platform code from CPPI 4.1 to MUSB glue driver: - cppi41_register_dma_callback() to register a platform dma_callback (e.g to acknowledge interrupt on DMA completion). - cppi41_dma_controller_to_musb() to convert a dma_controller pointer to a musb pointer. This required to get a musb pointer from DMA callbacks. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/musb_cppi41.c | 27 +++++++++++++++++++++++++-- drivers/usb/musb/musb_dma.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index 1636385..d76022b 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -36,6 +36,8 @@ struct cppi41_dma_controller { u32 rx_mode; u32 tx_mode; u32 auto_req; + + cppi41_platform_dma_callback dma_callback; }; static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel) @@ -217,6 +219,10 @@ static void cppi41_dma_callback(void *private_data) int is_hs = 0; bool empty; + controller = cppi41_channel->controller; + if (controller->dma_callback) + controller->dma_callback(musb); + spin_lock_irqsave(&musb->lock, flags); dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie, @@ -249,8 +255,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; @@ -288,6 +292,16 @@ static void cppi41_dma_callback(void *private_data) spin_unlock_irqrestore(&musb->lock, flags); } +void cppi41_register_dma_callback(struct dma_controller *c, + cppi41_platform_dma_callback callback) +{ + struct cppi41_dma_controller *controller = container_of(c, + struct cppi41_dma_controller, controller); + + controller->dma_callback = callback; +} +EXPORT_SYMBOL_GPL(cppi41_register_dma_callback); + static u32 update_ep_mode(unsigned ep, unsigned mode, u32 old) { unsigned shift; @@ -709,3 +723,12 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) return NULL; } EXPORT_SYMBOL_GPL(cppi41_dma_controller_create); + +struct musb *cppi41_dma_controller_to_musb(struct dma_controller *c) +{ + struct cppi41_dma_controller *controller = container_of(c, + struct cppi41_dma_controller, controller); + + return controller->musb; +} +EXPORT_SYMBOL_GPL(cppi41_dma_controller_to_musb); diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h index 46357e1..7f3c585 100644 --- a/drivers/usb/musb/musb_dma.h +++ b/drivers/usb/musb/musb_dma.h @@ -231,9 +231,13 @@ extern struct dma_controller * cppi_dma_controller_create(struct musb *musb, void __iomem *base); extern void cppi_dma_controller_destroy(struct dma_controller *c); +typedef void (*cppi41_platform_dma_callback)(struct musb *musb); extern struct dma_controller * cppi41_dma_controller_create(struct musb *musb, void __iomem *base); extern void cppi41_dma_controller_destroy(struct dma_controller *c); +extern struct musb *cppi41_dma_controller_to_musb(struct dma_controller *c); +extern void cppi41_register_dma_callback(struct dma_controller *c, + cppi41_platform_dma_callback callback); extern struct dma_controller * ux500_dma_controller_create(struct musb *musb, void __iomem *base);