From patchwork Wed Sep 20 19:26:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9962169 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 CF39260208 for ; Wed, 20 Sep 2017 19:26:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C29FB291FA for ; Wed, 20 Sep 2017 19:26:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B768D291FC; Wed, 20 Sep 2017 19:26:27 +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=ham 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 27F8F291FA for ; Wed, 20 Sep 2017 19:26:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751686AbdITT0Y (ORCPT ); Wed, 20 Sep 2017 15:26:24 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:54982 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751000AbdITT0W (ORCPT ); Wed, 20 Sep 2017 15:26:22 -0400 Received: by mail-wr0-f174.google.com with SMTP id g29so2966181wrg.11 for ; Wed, 20 Sep 2017 12:26:22 -0700 (PDT) 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=RElje/I99LgI5VTknRv+2U+5N5l9byQWPhYVfABJInA=; b=si+zRBcxzbmQKkfIqd4zr+15O/JnkaTgrDJqANPO1+BICPbcklh8kqULuXd+4iHCeH sjQ4hixERrZBzQQoHERkcIIOOQVlnl/GKwHN15t9dFTt9ER093kvhbzyZmVEcQ3RDoNe mk5J2Qia1pl0LZGf48jwyal39DYAoEGijokWTPOfddRg9LnK8cJqzSSjaOH6Rh8nKQb9 2wGgjF7YVHOlzYBK0G2wa+nXCN51hOT7+jpA+7sKLhZM8GH5PCvk4PiHOUs6VHukuIug I5XwZm9Bojw2UJs3jtsb+tx7UaTNTeD8/rRQ/Lq9QOdZPNYQ3ZXvClXWOkedeM85QzG2 BT7Q== 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=RElje/I99LgI5VTknRv+2U+5N5l9byQWPhYVfABJInA=; b=Vwj+GkBa4AHeFURMsqLiFv/lFKFIv7bx6SDgq3EzsR8MxVdSYjZ0Tsu6ipNZrf0Fef iAifGbGFqXX+W9H6TsEjwXT6QutJrKR/JY6iV4VlZ1gb7EeYJNCmGAJ6MzVKPRA6/OvK hvqT0fSeu6SMCBXWMNoVVVavzYwmoiOhcWvEnUJAHLd4K8I41r48IVQ5PMdrCtE0uSmt 4fGk2xI9VIQXErh6TKn+uZGuMqfOj00npgbqiYATNrHkoQIFqjbO3E/CpDRa/ZHmIRQ1 s13lbYblbI4UPzPgkEBY5H0ME3V7I/QcJzbGlktFFZka7CxYG8fzr0Alb15TIxGC3nC2 B13w== X-Gm-Message-State: AHPjjUgOCeRYSvD/ARwp+MK0AR8xx87foXLzCLVOkXrTD6tox0zGzwvm dnudxEqVYAJWui/dCYYvNWEWgA== X-Google-Smtp-Source: AOwi7QBt8L3uW3IgQgp5R7CXqUUvjD34H7+MN/bERNRDBu6wkWbgYpqUZ7044PTuPnXx6kWJ/LFTxQ== X-Received: by 10.223.151.55 with SMTP id r52mr5837101wrb.69.1505935581427; Wed, 20 Sep 2017 12:26:21 -0700 (PDT) Received: from localhost.localdomain (car75-h02-176-137-58-115.dsl.sta.abo.bbox.fr. [176.137.58.115]) by smtp.gmail.com with ESMTPSA id u40sm2680796wrb.21.2017.09.20.12.26.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 12:26:20 -0700 (PDT) From: Alexandre Bailon To: b-liu@ti.com Cc: linux-usb@vger.kernel.org, nsekhar@ti.com, ptitiano@baylibre.com, sergei.shtylyov@cogentembedded.com, linux-omap@vger.kernel.org, Alexandre Bailon Subject: [PATCH v3 2/4] usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx Date: Wed, 20 Sep 2017 21:26:10 +0200 Message-Id: <20170920192612.16169-3-abailon@baylibre.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170920192612.16169-1-abailon@baylibre.com> References: <20170920192612.16169-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 The way to configure the DMA mode on DA8xx is different from DSPS. Add a new function to configure DMA mode on DA8xx and use a callback to call the right function based on the platform. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/musb_cppi41.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index d66416a27146..b2b1306c01cf 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -26,6 +26,7 @@ #define MUSB_DMA_NUM_CHANNELS 15 +#define DA8XX_USB_MODE 0x10 #define DA8XX_USB_AUTOREQ 0x14 #define DA8XX_USB_TEARDOWN 0x1c @@ -41,6 +42,9 @@ struct cppi41_dma_controller { u32 tdown_reg; u32 autoreq_reg; + + void (*set_dma_mode)(struct cppi41_dma_channel *cppi41_channel, + unsigned int mode); }; static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel) @@ -355,6 +359,32 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel *cppi41_channel, } } +static void da8xx_set_dma_mode(struct cppi41_dma_channel *cppi41_channel, + unsigned int mode) +{ + struct cppi41_dma_controller *controller = cppi41_channel->controller; + struct musb *musb = controller->controller.musb; + unsigned int shift; + u32 port; + u32 new_mode; + u32 old_mode; + + old_mode = controller->tx_mode; + port = cppi41_channel->port_num; + + shift = (port - 1) * 4; + if (!cppi41_channel->is_tx) + shift += 16; + new_mode = old_mode & ~(3 << shift); + new_mode |= mode << shift; + + if (new_mode == old_mode) + return; + controller->tx_mode = new_mode; + musb_writel(musb->ctrl_base, DA8XX_USB_MODE, new_mode); +} + + static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel, unsigned mode) { @@ -379,6 +409,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel, dma_addr_t dma_addr, u32 len) { struct cppi41_dma_channel *cppi41_channel = channel->private_data; + struct cppi41_dma_controller *controller = cppi41_channel->controller; struct dma_chan *dc = cppi41_channel->dc; struct dma_async_tx_descriptor *dma_desc; enum dma_transfer_direction direction; @@ -404,7 +435,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel, musb_writel(musb->ctrl_base, RNDIS_REG(cppi41_channel->port_num), len); /* gen rndis */ - cppi41_set_dma_mode(cppi41_channel, + controller->set_dma_mode(cppi41_channel, EP_MODE_DMA_GEN_RNDIS); /* auto req */ @@ -413,14 +444,15 @@ static bool cppi41_configure_channel(struct dma_channel *channel, } else { musb_writel(musb->ctrl_base, RNDIS_REG(cppi41_channel->port_num), 0); - cppi41_set_dma_mode(cppi41_channel, + controller->set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT); cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE); } } else { /* fallback mode */ - cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT); + controller->set_dma_mode(cppi41_channel, + EP_MODE_DMA_TRANSPARENT); cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE); len = min_t(u32, packet_sz, len); } @@ -737,9 +769,11 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) if (musb->io.quirks & MUSB_DA8XX) { controller->tdown_reg = DA8XX_USB_TEARDOWN; controller->autoreq_reg = DA8XX_USB_AUTOREQ; + controller->set_dma_mode = da8xx_set_dma_mode; } else { controller->tdown_reg = USB_TDOWN; controller->autoreq_reg = USB_CTRL_AUTOREQ; + controller->set_dma_mode = cppi41_set_dma_mode; } ret = cppi41_dma_controller_start(controller);