From patchwork Thu Jan 19 10:06:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 91845 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp200665qgi; Thu, 19 Jan 2017 02:07:18 -0800 (PST) X-Received: by 10.99.65.67 with SMTP id o64mr9134867pga.119.1484820438311; Thu, 19 Jan 2017 02:07:18 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11si3077429pgp.204.2017.01.19.02.07.18; Thu, 19 Jan 2017 02:07:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-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-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751440AbdASKHP (ORCPT + 4 others); Thu, 19 Jan 2017 05:07:15 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:36253 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbdASKHN (ORCPT ); Thu, 19 Jan 2017 05:07:13 -0500 Received: by mail-wm0-f47.google.com with SMTP id c85so281782677wmi.1 for ; Thu, 19 Jan 2017 02:07:13 -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=v5Nt4/XC946+k57XQM7zDMScdlFDIlHVXq3iLX8LI78=; b=UpuZLKigJHTb4gF8YV58/ZC24K39YAW8y5XZ8RP/kGZHVf1eg2hksetCxzzbdlmFT3 8kcfL1SJPTAle+1Ks+wKC7rG3wJZiVtTqQJHxsq8koLC2xLUzAqo4wIcYJzVpSgNciAn Vyj9eWaZsFHV9iJeZAzKoy+XNX6T1LqDp9PmHHXXErEG+VUHr8G549HA7b4ce9J5sW9A yb82K3yz6nFnZfQsj+m/C0BqFLJNqmpFG+hsTIRja6XPFyz2OTyRQNmtBp3mVTHOZJ0c 3uOKRLU/+TjWOAa+VCSpelLDaLzkNqWU8jddWr41scJqmV6hKnV34lpFoXgiS7jDOu1r Vjpw== 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=v5Nt4/XC946+k57XQM7zDMScdlFDIlHVXq3iLX8LI78=; b=inUBWYFVe9UtvrDu1F/J365h2r20aedBrlXvsGJQvC1pcQRxTRJ2wG4FELqpdMgKsd a4Lys0+Fv5FtXFyM39iwilplpNxQGCU4WrkbnPTppzuwyzIlmv71olvWmfe6tshovV7Q PH4TPDX7HV0bmNCOJkX5T27pIJPh6rMGJRAJDO01CQGROKpKQgKOych7bC2rTPmsF0MS 3IFqEzhdrwA4cAjiS2if59wqMpbOhhsJfppMtsk2rUDhJhXaB7LhMCFkgqhCu8sRtA+v tMVr7bF6eqG7i0eqOgpaWIKuwTQSMeW4UnS2u4+nQW89sUsBVNtkJ4cfZgSazxwcvDwA UaAQ== X-Gm-Message-State: AIkVDXJqWJ2hmEphv2DhbygnMZynuWBtmbz+UaGwe+fmRBa6+2IEml7aoRmB7oI9Mfs6675c X-Received: by 10.28.222.11 with SMTP id v11mr23196942wmg.1.1484820432417; Thu, 19 Jan 2017 02:07:12 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id w197sm11703194wmd.11.2017.01.19.02.07.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 02:07:11 -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, grygorii.strashko@ti.com, linux-usb@vger.kernel.org, Alexandre Bailon Subject: [PATCH v3 1/3] usb: musb: dma: Add a DMA completion platform callback Date: Thu, 19 Jan 2017 11:06:57 +0100 Message-Id: <20170119100659.11370-2-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170119100659.11370-1-abailon@baylibre.com> References: <20170119100659.11370-1-abailon@baylibre.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Currently, the CPPI 4.1 driver is not completely generic and only work on dsps. This is because of IRQ management. Add a callback to dma_controller that could be invoked on DMA completion to acknodlege the IRQ. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/musb_cppi41.c | 7 +++++-- drivers/usb/musb/musb_dma.h | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" 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..8bea0cd 100644 --- a/drivers/usb/musb/musb_dma.h +++ b/drivers/usb/musb/musb_dma.h @@ -181,10 +181,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 + * @platform_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 +199,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 Thu Jan 19 10:06:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 91847 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp200706qgi; Thu, 19 Jan 2017 02:07:23 -0800 (PST) X-Received: by 10.84.136.7 with SMTP id 7mr12130786plk.100.1484820443629; Thu, 19 Jan 2017 02:07:23 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11si3077429pgp.204.2017.01.19.02.07.23; Thu, 19 Jan 2017 02:07:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-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-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751521AbdASKHT (ORCPT + 4 others); Thu, 19 Jan 2017 05:07:19 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:37750 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751527AbdASKHO (ORCPT ); Thu, 19 Jan 2017 05:07:14 -0500 Received: by mail-wm0-f42.google.com with SMTP id c206so69297890wme.0 for ; Thu, 19 Jan 2017 02:07:14 -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=I4iSOS6MeQOdGQog0c/+3dGHuJCe5kI/aKAcAfYBY4H26SXro5lC6uJw+dZhwR9ooZ zeO7hJKuTNlMtr/i67/3b7JkZ/B1imKvEh/RaqzIqC9ZChltAY/rH9446dK6wYgtanN4 UpQY05ghvF0FFv9KKeOlHJz4f+5xqg4l6yG5FUfrLxLHzJbaSsqv11iz9qnEcK34KipQ WTH8Lc8LldV4jWQBf8w0b57utdm+Wwoj+9LMlvKe9iXvOLtpAfl8qpRhIpV6SWKC3wdd hJpfZKcoHrem+JR/YglXB4IvE8mzE7hVyl4LDdwxMdMOHvwNJSLuuFeMMLCIfhY3Zm6L 9NSg== 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=HPPbp7KIgPhGh0m/AWvkeMtnQJ9soZtC8ShalgWizxzO4zVLMYG4YEjJvcl3h9WmWf tfqIA1b2vlDKj10uwcKxQfDnrzMRcdU8bMiFwr2t9K90SAXcko5puoFE/vjdDQ/dr797 FfftOEyaC//BOhdKvxOB/K8vygr+og92qjeoetuSUR7cZbVc21l2t7/p4i4GYE3Pew3H 48u/CJA81wxw66B94EfVCo0+mrDYR0/RpFCtVKmfcTc8Xse3MFvRHS/O/bldtJa42/0J WLvvHbHFWOlZjBkH6nSiD6DztPl02sS6waeLkqfoOg/YKs50VzklY4Ygum6kRcVOxmuY yAtg== X-Gm-Message-State: AIkVDXKz8XkzEPsmSbaq7az8yfZQBuOkeQw/meMYM1AsaVPxRPToBKDoEIbTjpuuVklBYayH X-Received: by 10.223.177.130 with SMTP id q2mr6800329wra.39.1484820433326; Thu, 19 Jan 2017 02:07:13 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id w197sm11703194wmd.11.2017.01.19.02.07.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 02:07:12 -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, grygorii.strashko@ti.com, linux-usb@vger.kernel.org, Alexandre Bailon Subject: [PATCH v3 2/3] usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback() Date: Thu, 19 Jan 2017 11:06:58 +0100 Message-Id: <20170119100659.11370-3-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170119100659.11370-1-abailon@baylibre.com> References: <20170119100659.11370-1-abailon@baylibre.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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-usb" 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 Thu Jan 19 10:06:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 91846 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp200699qgi; Thu, 19 Jan 2017 02:07:22 -0800 (PST) X-Received: by 10.99.237.69 with SMTP id m5mr9305477pgk.94.1484820442468; Thu, 19 Jan 2017 02:07:22 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11si3077429pgp.204.2017.01.19.02.07.22; Thu, 19 Jan 2017 02:07:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-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-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751537AbdASKHU (ORCPT + 4 others); Thu, 19 Jan 2017 05:07:20 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:36307 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751554AbdASKHS (ORCPT ); Thu, 19 Jan 2017 05:07:18 -0500 Received: by mail-wm0-f52.google.com with SMTP id c85so281785119wmi.1 for ; Thu, 19 Jan 2017 02:07: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=24GH2VKbdKohK4jo4kg/LkwWGxDk/IespWsW1uefKb8=; b=Cd/JiDL04baPnqmj96ucN+87WHO5cHuijeUoSeP5l2op7HFJX0ItBCNTjOSKLThqRo mo7zlXI0/H/BJ3ycRtlbYWj+GPEElG12nsqt2/hIYsWtcJd3b9nrVLFT+94WGe7T16MM qKgG4p2oWpVTUuQUUgqJzSBeb0kgBOBEcU6M8I2pbmyAXIslB1bc68AIAOah4IrxZoK5 zlAMJVa60G6qkNfCTgKTMCAOjohLZY6wTss6rzYpum9NwtYfiFc65D88i+MYMv+pOeqy NVQhGYgR96Nq8SWEJLt0JQstXqgoQiByj8ZyF04EeITdNGeRrjhDMA7oWHASIJOAubaC hLDg== 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=24GH2VKbdKohK4jo4kg/LkwWGxDk/IespWsW1uefKb8=; b=nxBbk/zq2Lec0hQDC4qjq9Kdw4IYtpeXCMqQOl5i2yN2GYAqbXtLIxPa7tL2uDqFEm znrQwcEP/qUHNyGUbkBF39ao2L8kQEO7qHPXYdh2l1PywSpUr4MXpTUPIhxo5wgvyxFP QGooKxkrGIa+AuLC92E5Ry4VFNKnMU2itmb4oDVlnwzKTpSVBg+fLrXYE9DbY/0XSRcV 5nrU2tJ20hZfEnovk0e71vIW6ps55uTaakCi/WSbnEAwsCl973UoKFwK2i2a0Bhdr1pU +5sTa3PQCMj+zhvyxn447ZAbyzNcu1640e7AljwHEbCYOGJ5qmZy5IOVxVD5SFAf1PGi CuWg== X-Gm-Message-State: AIkVDXKcS7scL2M0eYtlfWfQHkWb58d7QMNm+RpniS2x24+73Wuxz1yU311wFu+GRdervAH4 X-Received: by 10.28.127.13 with SMTP id a13mr6049295wmd.96.1484820436710; Thu, 19 Jan 2017 02:07:16 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id w197sm11703194wmd.11.2017.01.19.02.07.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 02:07:16 -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, grygorii.strashko@ti.com, linux-usb@vger.kernel.org, Alexandre Bailon Subject: [PATCH v3 3/3] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps Date: Thu, 19 Jan 2017 11:06:59 +0100 Message-Id: <20170119100659.11370-4-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170119100659.11370-1-abailon@baylibre.com> References: <20170119100659.11370-1-abailon@baylibre.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 | 77 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 23 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" 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..9dad3a6 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,72 @@ 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); +} + +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); +} +#else +static void dsps_dma_controller_suspend(struct dsps_glue *glue) {} +static void dsps_dma_controller_resume(struct dsps_glue *glue) {} +#endif + 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 +858,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 +949,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 +964,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);