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: 92230 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1304187obz; Mon, 23 Jan 2017 08:48:26 -0800 (PST) X-Received: by 10.98.28.129 with SMTP id c123mr33089915pfc.92.1485190106092; Mon, 23 Jan 2017 08:48:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j130si16200199pfc.6.2017.01.23.08.48.25; Mon, 23 Jan 2017 08:48:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751261AbdAWQsT (ORCPT + 4 others); Mon, 23 Jan 2017 11:48:19 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:37015 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751319AbdAWQsS (ORCPT ); Mon, 23 Jan 2017 11:48:18 -0500 Received: by mail-wm0-f53.google.com with SMTP id c206so165142013wme.0 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=FDZUuDVUvyA+7nNSdbQmlYehdKy3vMl1js8f8vF1+AfkS8/2Cnqg3pKnMScRd/9WG+ rl3aq94BGBHgRM6QivWjG3FM6wwE87ajWYniyXkvI5r7XNfh+wWxkMX0wZsGTjbalIwF +FvVF0B5sVlGmj5dKEqGN111c9PR3Yxwv0JbLjA6PqopsXfUflUee4iRr7BJDtOscGX0 qGvnkidinwqsrNMZ4hTTHF4cNQy5Vt0r94KmnF60jHnxuzKGPlezw+AYJYBJFxnbIIpy uXHUQTogxHnLm7bR11nO38VgcXwTHyZwR3qjnYD0MuEaB/r1a2ddoYrCK6BRG+Gf9gMQ kHjQ== X-Gm-Message-State: AIkVDXJoYjJdw5HY7EKFe7X1q4QenW4MG/r0x7gb/il++MYA9R0EGb586ax5cHN/IKvg41o5 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: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 */ From patchwork Mon Jan 23 16:48:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 92231 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1304189obz; Mon, 23 Jan 2017 08:48:26 -0800 (PST) X-Received: by 10.98.7.150 with SMTP id 22mr33436920pfh.69.1485190106285; Mon, 23 Jan 2017 08:48:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j130si16200199pfc.6.2017.01.23.08.48.26; Mon, 23 Jan 2017 08:48:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751102AbdAWQsW (ORCPT + 4 others); Mon, 23 Jan 2017 11:48:22 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:36664 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751326AbdAWQsU (ORCPT ); Mon, 23 Jan 2017 11:48:20 -0500 Received: by mail-wm0-f44.google.com with SMTP id c85so141577371wmi.1 for ; Mon, 23 Jan 2017 08:48:19 -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=M3JGUCPukR36GxqCxOt+9YFra680uwO0q/ypxhNKYh4=; b=pDW8aUTWRCdbYbsQdCjoGWtLic48TBhl+EDadquFE/tMg0S2J5PhvxBuTSdT/LJrPK WTZq4IT8fRz4mAxJEsINaPNHdaU005M+rmIA3RIg23CdX3RQb3HKVXzWtBsVFzuy7iAI MEbRXv+ahqqpKaeNFJPnOugB/a0Fp9ImHhRSoL5FmOf1EdBddgA81HVjCzIka7+ksgse f+NRoI738V/H6A/Dmv+8dr37nDYUi34Puu5dE3z2OgnrGSFpDBtzs5J7DMtMNHvwCrK0 trU4k+ZCBEhNPX42uN+Xik2Hl8M7Mhi1RiUlh/Z1dlft79Ank+POm9LLzXC3/63hFpz6 aOKg== 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=M3JGUCPukR36GxqCxOt+9YFra680uwO0q/ypxhNKYh4=; b=gH/hwLdOkvFeGMqUDLGWUN9TrYEu0yNe9EY6QfA8UV5TZw/3ivuO4Wm9Sbrsohyu86 cNYDTCmoBqGMP368frg9d17Dngr9S/k7ltslIgcj2eSdIkJQiz3ZCUQYQPUf4yyMn42j svw/GDRMB6dNGmDDBCJnVx0ZxFfYil61jrKR/zUMu57XCj7l6cCyDeGEtkaYONu/H1W7 lAfxjNZbg9C80OcL2T0E5691y/LyKis+/K3M2430M6BFCuNyme7DIH+l8Wg4OtBZxfJR vPPeLmaYXzU6Qm1My0hOTbAmLJ880mgAq/KovhrgsV4IKheCmsJPsG/RLznvuKddpxuA gSDQ== X-Gm-Message-State: AIkVDXI7w6TCbunSE3gHZQukpMiqbl5Y2n2zeL73YMdEFB0UVeHNvZ4bXBFcQ2/DccPRE8q+ X-Received: by 10.28.54.226 with SMTP id y95mr13937525wmh.105.1485190098605; Mon, 23 Jan 2017 08:48:18 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y127sm21907054wmg.12.2017.01.23.08.48.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jan 2017 08:48:18 -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 2/6] usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback() Date: Mon, 23 Jan 2017 17:48:04 +0100 Message-Id: <20170123164808.27936-3-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: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Update cppi41_dma_callback() to detect an aborted transfer. This was not required before because cppi41_dma_callback() was only invoked on transfer completion. In order to make CPPI 4.1 driver more generic, cppi41_dma_callback() will be invoked after a transfer abort in order to let the MUSB driver perform some action such as acknowledge the interrupt that may be fired during a teardown. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/musb_cppi41.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index f7d3d27..1fe7eae 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -99,7 +99,8 @@ static bool musb_is_tx_fifo_empty(struct musb_hw_ep *hw_ep) return true; } -static void cppi41_dma_callback(void *private_data); +static void cppi41_dma_callback(void *private_data, + const struct dmaengine_result *result); static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel) { @@ -154,7 +155,7 @@ static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel) if (WARN_ON(!dma_desc)) return; - dma_desc->callback = cppi41_dma_callback; + dma_desc->callback_result = cppi41_dma_callback; dma_desc->callback_param = &cppi41_channel->channel; cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); trace_musb_cppi41_cont(cppi41_channel); @@ -204,7 +205,8 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer) return ret; } -static void cppi41_dma_callback(void *private_data) +static void cppi41_dma_callback(void *private_data, + const struct dmaengine_result *result) { struct dma_channel *channel = private_data; struct cppi41_dma_channel *cppi41_channel = channel->private_data; @@ -221,6 +223,9 @@ static void cppi41_dma_callback(void *private_data) if (controller->controller.dma_callback) controller->controller.dma_callback(&controller->controller); + if (result->result == DMA_TRANS_ABORTED) + return; + spin_lock_irqsave(&musb->lock, flags); dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie, @@ -403,7 +408,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel, if (!dma_desc) return false; - dma_desc->callback = cppi41_dma_callback; + dma_desc->callback_result = cppi41_dma_callback; dma_desc->callback_param = channel; cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); cppi41_channel->channel.rx_packet_done = false; From patchwork Mon Jan 23 16:48:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 92235 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1304212obz; Mon, 23 Jan 2017 08:48:28 -0800 (PST) X-Received: by 10.84.136.34 with SMTP id 31mr43836935plk.52.1485190108574; Mon, 23 Jan 2017 08:48:28 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j130si16200199pfc.6.2017.01.23.08.48.28; Mon, 23 Jan 2017 08:48:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751016AbdAWQs1 (ORCPT + 4 others); Mon, 23 Jan 2017 11:48:27 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35266 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338AbdAWQs0 (ORCPT ); Mon, 23 Jan 2017 11:48:26 -0500 Received: by mail-wm0-f51.google.com with SMTP id r126so142044513wmr.0 for ; Mon, 23 Jan 2017 08:48:25 -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=EUxBeGQaSeLBSUZ5ev9Yo4Ozf50cl11kniI/8hukyFU=; b=kXNGpUPVEqh3PZnD6DnZCry3uXG3sfZqdyel/sLn/ZBzKAJIy6uS0B0p8Ozw2GaxB5 zOYLHiV0gPdtJWOYV85YbCBZBKcX3cubOZdLy6s/3h1RuBsTJkVUtfFa8B7q8DOduwJA 4XhMijGMTIeMbT1qbPhzHgdy/oFuHMoowOL4O/UX57gfUUuQZDy/nvGz/XMlr0vknOF6 ypcHyt1cn6aimMdnRBIw3F97lB1Og1GMwPVNha2rSb5koLOcdprGT4RrgkJgWQ1z+phX 2+bOcouwy/iSubNAowkRFbtznPtP7tFUQm+6Am3ZgFnleqYh482Fh076hTIBpBJFwYe6 U3pg== 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=EUxBeGQaSeLBSUZ5ev9Yo4Ozf50cl11kniI/8hukyFU=; b=OipybKmQo/ka5J0ACvgyCCVoFM7zlNYnULZI8AMf2cparSkyDPTSzbX0BMI2I0N5DH E53Pr1XSDsDLnepbd20ewgVrWiQTMg/M8TvjVo/Qpl5A1h6mNhU/EnwjXZ2TMl5Kt75Y ivl6JO8OfaDzsAeUHoJW9Fsm4tHW/eeUnP29HqpPj7jf3UDvNz9DfLzfyfQQdwX+Etfr 7OHij0j1GnmkbklMwExjLtuEafUi+N2Z60Wju0VwEiuaHeDz8WWG9O2Idx1uGcADucnd 0sn+lBG9+wwQFg7UIaRzV7flKUN2DmBdqsAreV4KKgVBvw74LCRDLGDUkL4GQTwyv/yq bwXg== X-Gm-Message-State: AIkVDXJVi9nKUqr0LH5s0X1SPQmYosCHWYPN5+VuDS3wpd83xxV3aK+8Dt97NiEmNF/9+xsL X-Received: by 10.28.93.68 with SMTP id r65mr15980648wmb.133.1485190099687; Mon, 23 Jan 2017 08:48:19 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y127sm21907054wmg.12.2017.01.23.08.48.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jan 2017 08:48:19 -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 3/6] usb: musb: cppi_dma: Clean up cppi structure Date: Mon, 23 Jan 2017 17:48:05 +0100 Message-Id: <20170123164808.27936-4-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: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org A pointer to musb is now present in the dma_controller structure. Remove the one present in cppi structure. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/cppi_dma.c | 26 +++++++++++++------------- drivers/usb/musb/cppi_dma.h | 1 - 2 files changed, 13 insertions(+), 14 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c index 1ae48e6..d82d166 100644 --- a/drivers/usb/musb/cppi_dma.c +++ b/drivers/usb/musb/cppi_dma.c @@ -224,7 +224,7 @@ static void cppi_controller_stop(struct cppi *controller) int i; struct musb *musb; - musb = controller->musb; + musb = controller->controller.musb; tibase = controller->tibase; /* DISABLE INDIVIDUAL CHANNEL Interrupts */ @@ -288,7 +288,7 @@ cppi_channel_allocate(struct dma_controller *c, controller = container_of(c, struct cppi, controller); tibase = controller->tibase; - musb = controller->musb; + musb = controller->controller.musb; /* ep0 doesn't use DMA; remember cppi indices are 0..N-1 */ index = ep->epnum - 1; @@ -336,7 +336,7 @@ static void cppi_channel_release(struct dma_channel *channel) c = container_of(channel, struct cppi_channel, channel); tibase = c->controller->tibase; if (!c->hw_ep) - musb_dbg(c->controller->musb, + musb_dbg(c->controller->controller.musb, "releasing idle DMA channel %p", c); else if (!c->transmit) core_rxirq_enable(tibase, c->index + 1); @@ -355,7 +355,7 @@ cppi_dump_rx(int level, struct cppi_channel *c, const char *tag) musb_ep_select(base, c->index + 1); - musb_dbg(c->controller->musb, + musb_dbg(c->controller->controller.musb, "RX DMA%d%s: %d left, csr %04x, " "%08x H%08x S%08x C%08x, " "B%08x L%08x %08x .. %08x", @@ -385,7 +385,7 @@ cppi_dump_tx(int level, struct cppi_channel *c, const char *tag) musb_ep_select(base, c->index + 1); - musb_dbg(c->controller->musb, + musb_dbg(c->controller->controller.musb, "TX DMA%d%s: csr %04x, " "H%08x S%08x C%08x %08x, " "F%08x L%08x .. %08x", @@ -954,7 +954,7 @@ static int cppi_channel_program(struct dma_channel *ch, cppi_ch = container_of(ch, struct cppi_channel, channel); controller = cppi_ch->controller; - musb = controller->musb; + musb = controller->controller.musb; switch (ch->status) { case MUSB_DMA_STATUS_BUS_ABORT: @@ -1009,7 +1009,7 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch) int i; dma_addr_t safe2ack; void __iomem *regs = rx->hw_ep->regs; - struct musb *musb = cppi->musb; + struct musb *musb = cppi->controller.musb; cppi_dump_rx(6, rx, "/K"); @@ -1121,7 +1121,7 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch) * setting it here "should" be racey, but seems to work */ csr = musb_readw(rx->hw_ep->regs, MUSB_RXCSR); - if (is_host_active(cppi->musb) + if (is_host_active(cppi->controller.musb) && bd && !(csr & MUSB_RXCSR_H_REQPKT)) { csr |= MUSB_RXCSR_H_REQPKT; @@ -1311,7 +1311,7 @@ cppi_dma_controller_create(struct musb *musb, void __iomem *mregs) controller->mregs = mregs; controller->tibase = mregs - DAVINCI_BASE_OFFSET; - controller->musb = musb; + controller->controller.musb = musb; controller->controller.channel_alloc = cppi_channel_allocate; controller->controller.channel_release = cppi_channel_release; controller->controller.channel_program = cppi_channel_program; @@ -1323,7 +1323,7 @@ cppi_dma_controller_create(struct musb *musb, void __iomem *mregs) /* setup BufferPool */ controller->pool = dma_pool_create("cppi", - controller->musb->controller, + controller->controller.musb->controller, sizeof(struct cppi_descriptor), CPPI_DESCRIPTOR_ALIGN, 0); if (!controller->pool) { @@ -1357,7 +1357,7 @@ void cppi_dma_controller_destroy(struct dma_controller *c) cppi_controller_stop(cppi); if (cppi->irq) - free_irq(cppi->irq, cppi->musb); + free_irq(cppi->irq, cppi->controller.musb); /* assert: caller stopped the controller first */ dma_pool_destroy(cppi->pool); @@ -1469,7 +1469,7 @@ static int cppi_channel_abort(struct dma_channel *channel) core_rxirq_disable(tibase, cppi_ch->index + 1); /* for host, ensure ReqPkt is never set again */ - if (is_host_active(cppi_ch->controller->musb)) { + if (is_host_active(cppi_ch->controller->controller.musb)) { value = musb_readl(tibase, DAVINCI_AUTOREQ_REG); value &= ~((0x3) << (cppi_ch->index * 2)); musb_writel(tibase, DAVINCI_AUTOREQ_REG, value); @@ -1478,7 +1478,7 @@ static int cppi_channel_abort(struct dma_channel *channel) csr = musb_readw(regs, MUSB_RXCSR); /* for host, clear (just) ReqPkt at end of current packet(s) */ - if (is_host_active(cppi_ch->controller->musb)) { + if (is_host_active(cppi_ch->controller->controller.musb)) { csr |= MUSB_RXCSR_H_WZC_BITS; csr &= ~MUSB_RXCSR_H_REQPKT; } else diff --git a/drivers/usb/musb/cppi_dma.h b/drivers/usb/musb/cppi_dma.h index 7fdfb71..9bb7c5e 100644 --- a/drivers/usb/musb/cppi_dma.h +++ b/drivers/usb/musb/cppi_dma.h @@ -107,7 +107,6 @@ struct cppi_channel { /* CPPI DMA controller object */ struct cppi { struct dma_controller controller; - struct musb *musb; void __iomem *mregs; /* Mentor regs */ void __iomem *tibase; /* TI/CPPI regs */ From patchwork Mon Jan 23 16:48:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 92233 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1304195obz; Mon, 23 Jan 2017 08:48:26 -0800 (PST) X-Received: by 10.98.215.27 with SMTP id b27mr33283323pfh.70.1485190106826; Mon, 23 Jan 2017 08:48:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j130si16200199pfc.6.2017.01.23.08.48.26; Mon, 23 Jan 2017 08:48:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751349AbdAWQsX (ORCPT + 4 others); Mon, 23 Jan 2017 11:48:23 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:37096 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751331AbdAWQsW (ORCPT ); Mon, 23 Jan 2017 11:48:22 -0500 Received: by mail-wm0-f50.google.com with SMTP id c206so165145923wme.0 for ; Mon, 23 Jan 2017 08:48:21 -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=MIf9AjQJxzXq5eagv3pM/eKDnzub8S8jHE6LRMjVYFk=; b=CYYmkDB/gApbZN7LmDwzjB4Y6UdhP0xVOUhnWYRXZf3Wy6Gc4sWIgew3JYB4UG6+1I D6qclDdgtt+COSQbMr3CYnB+KfkMhypaRg0ZDjgVStpTmQNeMK0JDbWkxpF/t2ktT4jf EVsrUdakER0f9FVuPRIJ35HE/ubzonaD4Ym9WfQW3HTS3M6uO3rTDbFajQ4+sL/J6X2k sQeNCwhNIPUQS106xT7j86kUv8u/22n+rghUgJDNY2VWTXW1vuKvxG8Vx6gXAcWpIVP0 fbmVXkrtrPA8rRBLQDcN7uAELIkTCzOfTZWY8x4K4ZRjfh/k+acBJpHONed1+gpF2kSb HF3g== 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=MIf9AjQJxzXq5eagv3pM/eKDnzub8S8jHE6LRMjVYFk=; b=cZBIIO5RTZOH/Eqku18ET4tOx8CPZJ616mxNZltPv9AJ/TC5/QdLZkFoegHEu9s3pf B7F4KzltDSnhMiG7k35ck1vge4tn0wbco1l+DHalA9X8xdA8UX3UYZYblJ9GA8V7jI0j GJTVpBcKzHJOwtoZfe9hMvu4PXqJv8ive18uhD3IMP5DkakCFtijW3qwYqZZGkM7jvLF sE+M6LE/0wX69z5Q1MR0F6ByJG+zt9tpMbCdjnc2r7j4gDuT6lsA2M7g/ISySX3hwshq Lf0OIOXzojs/Y3nFzBpULa1qOaVQssioZq5zCjRh/5/A5gLgXbSkHH4bSPsvIQ7VyJw/ lHLw== X-Gm-Message-State: AIkVDXK+pIbvfOwPtr3TVLpSXTgfuZa2ZlQuZZPgschNorA4LQmzD0zwjwIo/pGV9bL4eg/C X-Received: by 10.28.185.77 with SMTP id j74mr15158559wmf.76.1485190101091; Mon, 23 Jan 2017 08:48:21 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y127sm21907054wmg.12.2017.01.23.08.48.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jan 2017 08:48:20 -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 4/6] usb: musb: cppi_dma: Clean up cppi41_dma_controller structure Date: Mon, 23 Jan 2017 17:48:06 +0100 Message-Id: <20170123164808.27936-5-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: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org A pointer to musb is now present in the dma_controller structure. Remove the one present in cppi41_dma_controller structure. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/musb_cppi41.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index 1fe7eae..7253ea1 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -30,7 +30,6 @@ struct cppi41_dma_controller { struct dma_controller controller; struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS]; struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS]; - struct musb *musb; struct hrtimer early_tx; struct list_head early_tx_list; u32 rx_mode; @@ -45,7 +44,7 @@ static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel) if (cppi41_channel->is_tx) return; - if (!is_host_active(cppi41_channel->controller->musb)) + if (!is_host_active(cppi41_channel->controller->controller.musb)) return; csr = musb_readw(cppi41_channel->hw_ep->regs, MUSB_RXCSR); @@ -78,7 +77,7 @@ static void update_rx_toggle(struct cppi41_dma_channel *cppi41_channel) if (!toggle && toggle == cppi41_channel->usb_toggle) { csr |= MUSB_RXCSR_H_DATATOGGLE | MUSB_RXCSR_H_WR_DATATOGGLE; musb_writew(cppi41_channel->hw_ep->regs, MUSB_RXCSR, csr); - musb_dbg(cppi41_channel->controller->musb, + musb_dbg(cppi41_channel->controller->controller.musb, "Restoring DATA1 toggle."); } @@ -180,7 +179,7 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer) controller = container_of(timer, struct cppi41_dma_controller, early_tx); - musb = controller->musb; + musb = controller->controller.musb; spin_lock_irqsave(&musb->lock, flags); list_for_each_entry_safe(cppi41_channel, n, &controller->early_tx_list, @@ -309,6 +308,7 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel *cppi41_channel, unsigned mode) { struct cppi41_dma_controller *controller = cppi41_channel->controller; + struct musb *musb = controller->controller.musb; u32 port; u32 new_mode; u32 old_mode; @@ -324,12 +324,10 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel *cppi41_channel, return; if (cppi41_channel->is_tx) { controller->tx_mode = new_mode; - musb_writel(controller->musb->ctrl_base, USB_CTRL_TX_MODE, - new_mode); + musb_writel(musb->ctrl_base, USB_CTRL_TX_MODE, new_mode); } else { controller->rx_mode = new_mode; - musb_writel(controller->musb->ctrl_base, USB_CTRL_RX_MODE, - new_mode); + musb_writel(musb->ctrl_base, USB_CTRL_RX_MODE, new_mode); } } @@ -348,7 +346,8 @@ static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel, if (new_mode == old_mode) return; controller->auto_req = new_mode; - musb_writel(controller->musb->ctrl_base, USB_CTRL_AUTOREQ, new_mode); + musb_writel(controller->controller.musb->ctrl_base, USB_CTRL_AUTOREQ, + new_mode); } static bool cppi41_configure_channel(struct dma_channel *channel, @@ -359,7 +358,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel, struct dma_chan *dc = cppi41_channel->dc; struct dma_async_tx_descriptor *dma_desc; enum dma_transfer_direction direction; - struct musb *musb = cppi41_channel->controller->musb; + struct musb *musb = cppi41_channel->controller->controller.musb; unsigned use_gen_rndis = 0; cppi41_channel->buf_addr = dma_addr; @@ -472,7 +471,7 @@ static int cppi41_dma_channel_program(struct dma_channel *channel, BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || channel->status == MUSB_DMA_STATUS_BUSY); - if (is_host_active(cppi41_channel->controller->musb)) { + if (is_host_active(cppi41_channel->controller->controller.musb)) { if (cppi41_channel->is_tx) hb_mult = cppi41_channel->hw_ep->out_qh->hb_mult; else @@ -497,7 +496,7 @@ static int cppi41_is_compatible(struct dma_channel *channel, u16 maxpacket, { struct cppi41_dma_channel *cppi41_channel = channel->private_data; struct cppi41_dma_controller *controller = cppi41_channel->controller; - struct musb *musb = controller->musb; + struct musb *musb = controller->controller.musb; if (is_host_active(musb)) { WARN_ON(1); @@ -515,7 +514,7 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel) { struct cppi41_dma_channel *cppi41_channel = channel->private_data; struct cppi41_dma_controller *controller = cppi41_channel->controller; - struct musb *musb = controller->musb; + struct musb *musb = controller->controller.musb; void __iomem *epio = cppi41_channel->hw_ep->regs; int tdbit; int ret; @@ -600,7 +599,7 @@ static void cppi41_dma_controller_stop(struct cppi41_dma_controller *controller) static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller) { - struct musb *musb = controller->musb; + struct musb *musb = controller->controller.musb; struct device *dev = musb->controller; struct device_node *np = dev->parent->of_node; struct cppi41_dma_channel *cppi41_channel; @@ -695,7 +694,6 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) hrtimer_init(&controller->early_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL); controller->early_tx.function = cppi41_recheck_tx_req; INIT_LIST_HEAD(&controller->early_tx_list); - controller->musb = musb; controller->controller.channel_alloc = cppi41_dma_channel_allocate; controller->controller.channel_release = cppi41_dma_channel_release; From patchwork Mon Jan 23 16:48:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 92234 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1304204obz; Mon, 23 Jan 2017 08:48:27 -0800 (PST) X-Received: by 10.98.144.218 with SMTP id q87mr33141559pfk.51.1485190107863; Mon, 23 Jan 2017 08:48:27 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j130si16200199pfc.6.2017.01.23.08.48.27; Mon, 23 Jan 2017 08:48:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751355AbdAWQsY (ORCPT + 4 others); Mon, 23 Jan 2017 11:48:24 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38363 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbdAWQsX (ORCPT ); Mon, 23 Jan 2017 11:48:23 -0500 Received: by mail-wm0-f51.google.com with SMTP id r144so164862889wme.1 for ; Mon, 23 Jan 2017 08:48:23 -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=NK5aA3VtaOA9h5vHNwwnUh3sySIEybqq/zGfwqma2+w=; b=oDSGNd+a9/HoTTrGh2uJEgAn+wKm0larrLi2/oQ3VdLYrbCB+FcgBFooSt9m9MB8RM 4jDDhuCVSYomWwdUYVoNfNtd7IKYsjhlfrgi6hhgPF7MiMe1JHnIkZROPjXo5Qg7htt4 vwZ5x0/T3gzXw5jVzNQJQJ5giTzxao0cBvaoWpquQIRANvi+ER+AExXrTFZt8RPidwgi 8by/O3JHOxY+KStNMkSlV4v32HUtUmQ/OttZZiBMjOtv6XHl6/+ExOZXRqvlLtHP+kNZ hBpGAKTO+mFolhB4pzVnnasPlS/ZNIETi8cSwUifgV5igY+EagZaEjj1jvta5OBT3Wp9 mOEg== 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=NK5aA3VtaOA9h5vHNwwnUh3sySIEybqq/zGfwqma2+w=; b=AqjvT78yQ6u66luZwHmxCwnuXNs3K1JjPTwhpD8P2R7KDFqznjtUwxu/Gpukh6mEUl GDVDQzcsGa6ccXGsSh8z40xmz/HZrBqSQAtZ0bBaev972WTrnW+2LORCaTeqcrmMLHKJ JeABrkZIfXh4/X04Wrlx/1Una7Wdigtne/xBq+bBpzseoG7oiTJqUx+JaIK0SiYJOHmx hXEklljcvqPeYEV3kBJyUF6x+mzbmYeGCNChUka2Ihol7jTfIW6K6bQ8ZZY0L2aHl/YJ gtbA2FsKrxvtiTLoMAB1ms8GDdwcMoBYhLvYmHVAaReCVmQrph19cRKdlF9Yy2BtUczA OIMw== X-Gm-Message-State: AIkVDXI17WGqtiqJSblwOB7rx6dcbhjCTPCfn/bNiQhscQCxjmz7bZzW8wxVCdshePGHu8dx X-Received: by 10.28.41.135 with SMTP id p129mr15714588wmp.59.1485190102341; Mon, 23 Jan 2017 08:48:22 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y127sm21907054wmg.12.2017.01.23.08.48.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jan 2017 08:48:21 -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 5/6] usb: musb: cppi_dma: Clean up tusb_omap_dma structure Date: Mon, 23 Jan 2017 17:48:07 +0100 Message-Id: <20170123164808.27936-6-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: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org A pointer to musb is now present in the dma_controller structure. Remove the one present in tusb_omap_dma structure. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/tusb6010_omap.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c index e6959cc..8b43c4b 100644 --- a/drivers/usb/musb/tusb6010_omap.c +++ b/drivers/usb/musb/tusb6010_omap.c @@ -56,7 +56,6 @@ struct tusb_omap_dma_ch { struct tusb_omap_dma { struct dma_controller controller; - struct musb *musb; void __iomem *tbase; int ch; @@ -497,7 +496,7 @@ tusb_omap_dma_allocate(struct dma_controller *c, u32 reg; tusb_dma = container_of(c, struct tusb_omap_dma, controller); - musb = tusb_dma->musb; + musb = tusb_dma->controller.musb; tbase = musb->ctrl_base; reg = musb_readl(tbase, TUSB_DMA_INT_MASK); @@ -534,7 +533,7 @@ tusb_omap_dma_allocate(struct dma_controller *c, dev_name = "TUSB receive"; } - chdat->musb = tusb_dma->musb; + chdat->musb = tusb_dma->controller.musb; chdat->tbase = tusb_dma->tbase; chdat->hw_ep = hw_ep; chdat->epnum = hw_ep->epnum; @@ -667,7 +666,7 @@ tusb_dma_controller_create(struct musb *musb, void __iomem *base) if (!tusb_dma) goto out; - tusb_dma->musb = musb; + tusb_dma->controller.musb = musb; tusb_dma->tbase = musb->ctrl_base; tusb_dma->ch = -1; From patchwork Mon Jan 23 16:48:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 92236 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1304246obz; Mon, 23 Jan 2017 08:48:32 -0800 (PST) X-Received: by 10.99.65.67 with SMTP id o64mr11702413pga.119.1485190112892; Mon, 23 Jan 2017 08:48:32 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j130si16200199pfc.6.2017.01.23.08.48.32; Mon, 23 Jan 2017 08:48:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751360AbdAWQsb (ORCPT + 4 others); Mon, 23 Jan 2017 11:48:31 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:36751 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338AbdAWQsa (ORCPT ); Mon, 23 Jan 2017 11:48:30 -0500 Received: by mail-wm0-f48.google.com with SMTP id c85so141581559wmi.1 for ; Mon, 23 Jan 2017 08:48:24 -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=jyaekH5mElzQReiYKFnidl8c/YIu+UjecT/LJbsCd5w=; b=nmMQ63+4RDIz2ifGXUllv3kpeINinFjiGL1qLyN5tkAtc1T2PnSaRxBK8gMBpHOrxm r6MobjHbpS0fpHUt3oH2balbkFFB4UMBtc9V76BWamQbK8sxLn8NpAJEHZTVELSWXMR4 WcuWUsZLBC+uLb7EiTEBE9yJqcr9Y4ZaX0HQ2f19RlvrobpH6tmAxdV+F1N/halHeIxf zwIHDiNQa8XlV7FNDoj4vUOiOOibek/ssk9I6e6G9+4sd+k6xeuBsyTNZ1TNJQJd6Tlc cxpDGLliu8SubalLSFcWT8IzaUEgfDw0uePu84x/iv+7waicTiJa6+pjuEIJ6bWIWRBO t2gA== 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=jyaekH5mElzQReiYKFnidl8c/YIu+UjecT/LJbsCd5w=; b=IG4X/fCtPVx6aAXEE2rCPalH+8DC/fYgZceTXlWKSZerjUypUhqBLIvRohZAQRAKXs ZFpUJUoEDUlkorhWcUe32JoNKaizy9eAkfG9bWZPI7W3MqEgFGNXr00BTK6SJh573ZMn 4jhLRLAwVxZZaY1AOFdEPQFo54A0QMzvwPfG/XFeCOZ8++tsdGkZXDcNGn45N2jTxT+U Y8adQM8Cg7bogTp6xeHMtW9kQ77BOOTEuNt0AEeUmbdlMJ+Q+INuBMwz5Cd2yVNYL7KY QMePbsEAaiYsVVuOz5WPxiZ/sgbPuDhUU6joqqKeycIcbCV340P3rp/Npr2I5idoemZ8 F6WQ== X-Gm-Message-State: AIkVDXJd5dSnWr13OBcK47YIt1zMvT+m+0EWe9w09yca7DUz1xWLjbkGmrQi/aSlmaMw6T0y X-Received: by 10.28.109.218 with SMTP id b87mr13785763wmi.52.1485190103596; Mon, 23 Jan 2017 08:48:23 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y127sm21907054wmg.12.2017.01.23.08.48.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jan 2017 08:48:23 -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 6/6] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in DSPS Date: Mon, 23 Jan 2017 17:48:08 +0100 Message-Id: <20170123164808.27936-7-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: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Despite the CPPI 4.1 is a generic DMA, it is tied to USB. On the DSPS, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue). Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver maps and accesses to USBSS's register, which making CPPI 4.1 driver not really generic. Move the interrupt management to DSPS driver. Signed-off-by: Alexandre Bailon --- drivers/dma/cppi41.c | 28 ++++----------- drivers/usb/musb/musb_dsps.c | 81 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 23 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index d5ba43a..4999e7d 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -79,14 +79,6 @@ #define QMGR_QUEUE_C(n) (0x2008 + (n) * 0x10) #define QMGR_QUEUE_D(n) (0x200c + (n) * 0x10) -/* Glue layer specific */ -/* USBSS / USB AM335x */ -#define USBSS_IRQ_STATUS 0x28 -#define USBSS_IRQ_ENABLER 0x2c -#define USBSS_IRQ_CLEARR 0x30 - -#define USBSS_IRQ_PD_COMP (1 << 2) - /* Packet Descriptor */ #define PD2_ZERO_LENGTH (1 << 19) @@ -288,14 +280,8 @@ static irqreturn_t cppi41_irq(int irq, void *data) { struct cppi41_dd *cdd = data; struct cppi41_channel *c; - u32 status; int i; - status = cppi_readl(cdd->usbss_mem + USBSS_IRQ_STATUS); - if (!(status & USBSS_IRQ_PD_COMP)) - return IRQ_NONE; - cppi_writel(status, cdd->usbss_mem + USBSS_IRQ_STATUS); - for (i = QMGR_PENDING_SLOT_Q(FIST_COMPLETION_QUEUE); i < QMGR_NUM_PEND; i++) { u32 val; @@ -599,6 +585,7 @@ static void cppi41_compute_td_desc(struct cppi41_desc *d) static int cppi41_tear_down_chan(struct cppi41_channel *c) { + struct dmaengine_result abort_result; struct cppi41_dd *cdd = c->cdd; struct cppi41_desc *td; u32 reg; @@ -682,6 +669,12 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c) c->td_seen = 0; c->td_desc_seen = 0; cppi_writel(0, c->gcr_reg); + + /* Invoke the callback to do the necessary clean-up */ + abort_result.result = DMA_TRANS_ABORTED; + dma_cookie_complete(&c->txd); + dmaengine_desc_get_callback_invoke(&c->txd, &abort_result); + return 0; } @@ -1044,8 +1037,6 @@ static int cppi41_dma_probe(struct platform_device *pdev) goto err_irq; } - cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER); - ret = devm_request_irq(&pdev->dev, irq, glue_info->isr, IRQF_SHARED, dev_name(dev), cdd); if (ret) @@ -1069,7 +1060,6 @@ static int cppi41_dma_probe(struct platform_device *pdev) dma_async_device_unregister(&cdd->ddev); err_dma_reg: err_irq: - cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); cleanup_chans(cdd); err_chans: deinit_cppi41(dev, cdd); @@ -1097,7 +1087,6 @@ static int cppi41_dma_remove(struct platform_device *pdev) of_dma_controller_free(pdev->dev.of_node); dma_async_device_unregister(&cdd->ddev); - cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); devm_free_irq(&pdev->dev, cdd->irq, cdd); cleanup_chans(cdd); deinit_cppi41(&pdev->dev, cdd); @@ -1116,7 +1105,6 @@ static int __maybe_unused cppi41_suspend(struct device *dev) struct cppi41_dd *cdd = dev_get_drvdata(dev); cdd->dma_tdfdq = cppi_readl(cdd->ctrl_mem + DMA_TDFDQ); - cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); disable_sched(cdd); return 0; @@ -1142,8 +1130,6 @@ static int __maybe_unused cppi41_resume(struct device *dev) cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE); cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE); - cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER); - return 0; } diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 9f125e1..461bc09 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -121,6 +121,7 @@ struct dsps_glue { struct timer_list timer; /* otg_workaround timer */ unsigned long last_timer; /* last timer data for each instance */ bool sw_babble_enabled; + void __iomem *usbss_base; struct dsps_context context; struct debugfs_regset32 regset; @@ -145,6 +146,13 @@ static const struct debugfs_reg32 dsps_musb_regs[] = { { "mode", 0xe8 }, }; +/* USBSS / USB AM335x */ +#define USBSS_IRQ_STATUS 0x28 +#define USBSS_IRQ_ENABLER 0x2c +#define USBSS_IRQ_CLEARR 0x30 + +#define USBSS_IRQ_PD_COMP (1 << 2) + /** * dsps_musb_enable - enable interrupts */ @@ -619,14 +627,76 @@ static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) } } +#ifdef CONFIG_USB_TI_CPPI41_DMA +static void dsps_dma_controller_callback(struct dma_controller *c) +{ + struct musb *musb = c->musb; + struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); + void __iomem *usbss_base = glue->usbss_base; + u32 status; + + status = musb_readl(usbss_base, USBSS_IRQ_STATUS); + if (status & USBSS_IRQ_PD_COMP) + musb_writel(usbss_base, USBSS_IRQ_STATUS, USBSS_IRQ_PD_COMP); +} + +static struct dma_controller * +dsps_dma_controller_create(struct musb *musb, void __iomem *base) +{ + struct dma_controller *controller; + struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); + void __iomem *usbss_base = glue->usbss_base; + + controller = cppi41_dma_controller_create(musb, base); + if (IS_ERR_OR_NULL(controller)) + return controller; + + musb_writel(usbss_base, USBSS_IRQ_ENABLER, USBSS_IRQ_PD_COMP); + controller->dma_callback = dsps_dma_controller_callback; + + return controller; +} + +static void dsps_dma_controller_destroy(struct dma_controller *c) +{ + struct musb *musb = c->musb; + struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); + void __iomem *usbss_base = glue->usbss_base; + + musb_writel(usbss_base, USBSS_IRQ_CLEARR, USBSS_IRQ_PD_COMP); + cppi41_dma_controller_destroy(c); +} + +#ifdef CONFIG_PM_SLEEP +static void dsps_dma_controller_suspend(struct dsps_glue *glue) +{ + void __iomem *usbss_base = glue->usbss_base; + + musb_writel(usbss_base, USBSS_IRQ_CLEARR, USBSS_IRQ_PD_COMP); +} + +static void dsps_dma_controller_resume(struct dsps_glue *glue) +{ + void __iomem *usbss_base = glue->usbss_base; + + musb_writel(usbss_base, USBSS_IRQ_ENABLER, USBSS_IRQ_PD_COMP); +} +#endif +#else /* CONFIG_USB_TI_CPPI41_DMA */ +#ifdef CONFIG_PM_SLEEP +static void dsps_dma_controller_suspend(struct dsps_glue *glue) {} +static void dsps_dma_controller_resume(struct dsps_glue *glue) {} +#endif +#endif /* CONFIG_USB_TI_CPPI41_DMA */ + static struct musb_platform_ops dsps_ops = { .quirks = MUSB_DMA_CPPI41 | MUSB_INDEXED_EP, .init = dsps_musb_init, .exit = dsps_musb_exit, #ifdef CONFIG_USB_TI_CPPI41_DMA - .dma_init = cppi41_dma_controller_create, - .dma_exit = cppi41_dma_controller_destroy, + .dma_init = dsps_dma_controller_create, + .dma_exit = dsps_dma_controller_destroy, #endif .enable = dsps_musb_enable, .disable = dsps_musb_disable, @@ -792,6 +862,9 @@ static int dsps_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->wrp = wrp; + glue->usbss_base = of_iomap(pdev->dev.parent->of_node, 0); + if (!glue->usbss_base) + return -ENXIO; platform_set_drvdata(pdev, glue); pm_runtime_enable(&pdev->dev); @@ -880,6 +953,8 @@ static int dsps_suspend(struct device *dev) glue->context.tx_mode = musb_readl(mbase, wrp->tx_mode); glue->context.rx_mode = musb_readl(mbase, wrp->rx_mode); + dsps_dma_controller_suspend(glue); + return 0; } @@ -893,6 +968,8 @@ static int dsps_resume(struct device *dev) if (!musb) return 0; + dsps_dma_controller_resume(glue); + mbase = musb->ctrl_base; musb_writel(mbase, wrp->control, glue->context.control); musb_writel(mbase, wrp->epintr_set, glue->context.epintr);