From patchwork Tue Jan 17 14:35:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9521203 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 D6350601C3 for ; Tue, 17 Jan 2017 14:35:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCC6427F80 for ; Tue, 17 Jan 2017 14:35:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C196B28583; Tue, 17 Jan 2017 14:35:48 +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 5514027F80 for ; Tue, 17 Jan 2017 14:35:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751399AbdAQOfr (ORCPT ); Tue, 17 Jan 2017 09:35:47 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:36923 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751339AbdAQOfk (ORCPT ); Tue, 17 Jan 2017 09:35:40 -0500 Received: by mail-wm0-f51.google.com with SMTP id c206so225716738wme.0 for ; Tue, 17 Jan 2017 06:35:39 -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=bOhzKQXBV+lOXVdQi2ouTHD+PVxVUUhsAwQ0SXg5SoM=; b=j+WLxIUYj+ovEgejzq4Z68/MmUkWRkBPwI6Zy4tYvkTrjYSb+8XCWjCUiC+hJTVTXB x/fOs26ZII4JjD+yXORGl4zDvGY+zHr7X51v+MnokoWmJbe3Y6m+qw0MiBiRIV7ruOgp 05QDNMQDoi2dTSXf9NCb/rtqrEfI/MbbOMIM1jHYPWSVC1RnZkeHWsGDt/fpuDrHQdx7 s1ZAZi9A27RJPTfRP/WAiU2nHs3QSg64kP7p2QM026HrG128LP4IrGjzJhAX1iW8yW4S Np/v8OQYyQbvPzXX7T0w8NjYzwkITa4I1CZ6dgtlOnqzycod8GMWdcmsjCtcO5RuqRl9 Y92A== 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=bOhzKQXBV+lOXVdQi2ouTHD+PVxVUUhsAwQ0SXg5SoM=; b=EJNpNglxMIu3gQqIDX0q87sWVA1Cziv5L5Ik1WmXQf8UscLBj6af6q5jf0yZ5pa/RZ ikp5tFRKJqB5jQgkwLhMBcp6YXIRJR5pVU8HGu8OILZORvmKWRXmx6/JgcZozgEIsjLY awPwn3+KLiNr9URArb8SauOZG3gVIV3+Hm1RFad9WbwJl6yOfFrDS0cI1VeSkfZ8/uaE ZBahMYpVuviG12/OjaCLWiYK7uSjgKuJR/AYtSSshzctPe/kV+raPkZw+VbtX1x0ZofO WTupevFJnumJTODSZ+fKflezWWNL7vrdu6NkvpI7bWJ1MsnwF3CMZ0M2hI8v1VIIHpER 6N1w== X-Gm-Message-State: AIkVDXIJifoTqVUo1w/crlvkJeSYCkZmLnTMD+gIsX45m8+a6MhrMkuBoZpsoNhYSHnt8tHb X-Received: by 10.223.166.106 with SMTP id k97mr31613827wrc.170.1484663738474; Tue, 17 Jan 2017 06:35:38 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id k11sm37394939wmb.18.2017.01.17.06.35.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jan 2017 06:35:37 -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 v2 3/5] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx Date: Tue, 17 Jan 2017 15:35:26 +0100 Message-Id: <20170117143528.11404-4-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170117143528.11404-1-abailon@baylibre.com> References: <20170117143528.11404-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, only the PIO mode is supported. This add support of CPPI 4.1 to DA8xx. As the In DA8xx the CPPI 4.1 DMA is a part of the USB. Create the CPPI 4.1 device as a child of USB. Signed-off-by: Alexandre Bailon --- drivers/dma/Kconfig | 2 +- drivers/usb/musb/Kconfig | 4 ++-- drivers/usb/musb/da8xx.c | 32 +++++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 0d6a96e..8fe9de7 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -515,7 +515,7 @@ config TIMB_DMA config TI_CPPI41 tristate "AM33xx CPPI41 DMA support" - depends on ARCH_OMAP + depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) select DMA_ENGINE help The Communications Port Programming Interface (CPPI) 4.1 DMA engine diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 72a2a50..3018518 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA Enable DMA transfers when TI CPPI DMA is available. config USB_TI_CPPI41_DMA - bool 'TI CPPI 4.1 (AM335x)' - depends on ARCH_OMAP && DMADEVICES + bool 'TI CPPI 4.1 (AM335x or DA8xx)' + depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES select TI_CPPI41 config USB_TUSB_OMAP_DMA diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index cd3d763..be2d0eb 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,8 @@ struct da8xx_glue { struct phy *phy; }; +static void da8xx_dma_controller_callback(struct musb *musb); + /* * Because we don't set CTRL.UINT, it's "important" to: * - not read/write INTRUSB/INTRUSBE (except during @@ -457,12 +460,35 @@ static inline u8 get_vbus_power(struct device *dev) return current_uA / 1000 / 2; } +static struct dma_controller * +da8xx_dma_controller_create(struct musb *musb, void __iomem *base) +{ + struct dma_controller *controller; + + controller = cppi41_dma_controller_create(musb, base); + if (!IS_ERR_OR_NULL(controller)) + cppi41_register_dma_callback(controller, + da8xx_dma_controller_callback); + return controller; +} + +static void da8xx_dma_controller_callback(struct musb *musb) +{ + void __iomem *reg_base = musb->ctrl_base; + + musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0); +} + static const struct musb_platform_ops da8xx_ops = { - .quirks = MUSB_INDEXED_EP, + .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41, .init = da8xx_musb_init, .exit = da8xx_musb_exit, .fifo_mode = 2, +#ifdef CONFIG_USB_TI_CPPI41_DMA + .dma_init = da8xx_dma_controller_create, + .dma_exit = cppi41_dma_controller_destroy, +#endif .enable = da8xx_musb_enable, .disable = da8xx_musb_disable, @@ -534,6 +560,10 @@ static int da8xx_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, glue); + ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); + if (ret) + return ret; + memset(musb_resources, 0x00, sizeof(*musb_resources) * ARRAY_SIZE(musb_resources));