From patchwork Mon Oct 22 21:24:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 149402 Delivered-To: patch@linaro.org Received: by 2002:a2e:29db:0:0:0:0:0 with SMTP id p88-v6csp153323ljp; Mon, 22 Oct 2018 14:25:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV62nKg9wZJaE2tnPPhAgRbmX2+ZrBRZst7ZioNs86BU/3mFQIDcYa/ygP75sY+gkNfHa37WA X-Received: by 2002:a17:906:ca1:: with SMTP id k1-v6mr36157887ejh.7.1540243554622; Mon, 22 Oct 2018 14:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540243554; cv=none; d=google.com; s=arc-20160816; b=zRfQCoDwVqVn1OTi0zeZ60b78U0rPAk+0/8c5g9t4N2ZceLqWHBInPSN7/mDnKVqbb qBQ8GrF4Vpsp5Vsb6Jh9CEUkFc9e3Xn2iE8FU5nBeTfxq2+sRbGouPho/cBVrBkUaIIY rqzRR0Syb0nvfka2uhaiUl6Bd/iIi0tlxB1XNJj21FmJrHzNKFFxBRcmxP+AEvppsoMz AHFnd/zdnzXEJFJmVRP2Iv2ZxyuZkXYg5u6g3T8FfiC++KgIIRFP7Sy1yT6rrWaxp0zD +5FGsItZEvEGSfmyuu7metNEbeIgLpOVXv0zgUNdVpIFn/8vVRSylfFBOBG/G98WCFX5 CS/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:message-id:date:to:from; bh=NbKctsNo1+bINqILuBfKrTCrSr+hX//z9vkA5yWZS0c=; b=gPnprCl3nKtP/aITsWMLtvrTMnnv0YfdTT4o350fjowUev190vPvdEI8BDmjwllAKl SCN5sf5uGjuiWKcAxF7RwLIXtPSB9L4Xh/S2AUMX3wIby6StVJA39SItoqkvw+ZIDLn3 H+BaLykS0JPWib6iLoIFpqFfRUH02S9u61W+TUK/0MHlmNK4+Qo79ykxhwBHbPqtsA+d 0TTazMIMSueTyFvAroQEIZJersNdwbceUXHTY1CQMugC4qe/NvCtVB+LiHdbozCYDz9e G5dMesSvE5rq52Fs4JZ4W+zsrNg2v60iRafpFwlLrgXU9Nmid//w0tXo5kz1IthbQw8t 7oUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id o32-v6si2074715eda.267.2018.10.22.14.25.54; Mon, 22 Oct 2018 14:25:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: by lists.denx.de (Postfix, from userid 105) id 361A1C21EA7; Mon, 22 Oct 2018 21:25:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 747DBC21E62; Mon, 22 Oct 2018 21:25:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 20653C21DF3; Mon, 22 Oct 2018 21:25:06 +0000 (UTC) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lists.denx.de (Postfix) with ESMTPS id 86057C21C93 for ; Mon, 22 Oct 2018 21:25:05 +0000 (UTC) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w9MLP2D3092750; Mon, 22 Oct 2018 16:25:02 -0500 Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id w9MLP2hw080551 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 22 Oct 2018 16:25:02 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 22 Oct 2018 16:25:02 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Mon, 22 Oct 2018 16:25:02 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w9MLP1xW015513; Mon, 22 Oct 2018 16:25:01 -0500 Received: from localhost (uda0226610.dhcp.ti.com [128.247.59.147]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w9MLP1x06940; Mon, 22 Oct 2018 16:25:01 -0500 (CDT) From: Grygorii Strashko To: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , Joe Hershberger , Tom Rini , Simon Glass Date: Mon, 22 Oct 2018 16:24:55 -0500 Message-ID: <20181022212500.17162-1-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.10.5 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de, Jagan Teki Subject: [U-Boot] [PATCH v6 0/5] dma: add channels support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Hi All, This series is the next try to add DMA channels support for DMA controllers which last version was posted by Álvaro Fernández Rojas [1]. i've kept version numbering. Comparing to the original post I've added few changes: - added possibility to pass DMA driver/channel's specific data per each transfer using additional parameter "metadata" in dma_send/dma_receive() API. For example, port number for network packets to be directed to the specific port on multi port ethernet controllers. - added new dma_prepare_rcv_buf() API which allows to implement zero-copy DEV_TO_MEM transfer using DMA streaming channels which is usual case for Networking. - added dma-uclass test - removed unused function dma_get_by_index_platdata() - updated comments Hence, originally DMA channels support was introduced to add support for "bmips: add bcm6348-enet support" - that series can be easily updated following DMA channels API changes (if still actual). Patches 5-6 - Here I'm providing DMA and networking drivers for the new TI AM65x SoC [2] as an illustration of DMA channels API usage only. Unfortunately, those drivers are still under development so NOT-FOR-MERGE (!will not build!) - we'd like code/bindings to be accepted in LKML first. Full sources can be found at [3]. [1] https://patchwork.ozlabs.org/cover/881642/ [2] http://www.ti.com/lit/ug/spruid7b/spruid7b.pdf [3] git@git.ti.com:~gragst/ti-u-boot/gragsts-ti-u-boot.git branch: master-am6-dma-wip === A DMA is a feature of computer systems that allows certain hardware subsystems to access main system memory, independent of the CPU. DMA channels are typically generated externally to the HW module consuming them, by an entity this API calls a DMA provider. This API provides a standard means for drivers to enable and disable DMAs, and to copy, send and receive data using DMA. DMA channel API: dma_get_by_index() dma_get_by_name() dma_request() dma_free() dma_enable() dma_disable() dma_prepare_rcv_buf() dma_receive() dma_send() A driver that implements UCLASS_DMA is a DMA provider. A provider will often implement multiple separate DMAs channels, since the hardware it manages often has this capability. dma_uclass.h describes the interface which DMA providers must implement. DMA consumers/clients are the HW modules driven by the DMA channels. DMA consumer DMA_MEM_TO_DEV (transmit) usage example (based on networking). Note. In u-boot dma_send() is sync operation always - it'll start transfer and will poll for it to complete: - get/request dma channel struct dma dma_tx; ret = dma_get_by_name(common->dev, "tx0", &dma_tx); if (ret) ... - enable dma channel ret = dma_enable(&dma_tx); if (ret) ... - dma transmit DMA_MEM_TO_DEV. struct ti_drv_packet_data packet_data; packet_data.opt1 = val1; packet_data.opt2 = val2; ret = dma_send(&dma_tx, packet, length, &packet_data); if (ret) .. DMA consumer DMA_DEV_TO_MEM (receive) usage example (based on networking). Note. dma_receive() is sync operation always - it'll start transfer (if required) and will poll for it to complete (or for any previously configured dev2mem transfer to complete): - get/request dma channel struct dma dma_rx; ret = dma_get_by_name(common->dev, "rx0", &dma_rx); if (ret) ... - enable dma channel ret = dma_enable(&dma_rx); if (ret) ... - dma receive DMA_DEV_TO_MEM. struct ti_drv_packet_data packet_data; len = dma_receive(&dma_rx, (void **)packet, &packet_data); if (ret < 0) ... DMA consumer DMA_DEV_TO_MEM (receive) zero-copy usage example (based on networking). Networking subsystem allows to configure and use few receive buffers (dev2mem), as Networking RX DMA channels usually implemented as streaming interface - get/request dma channel struct dma dma_rx; ret = dma_get_by_name(common->dev, "rx0", &dma_rx); if (ret) ... for (i = 0; i < RX_DESC_NUM; i++) { ret = dma_prepare_rcv_buf(&dma_rx, net_rx_packets[i], RX_BUF_SIZE); if (ret) ... } - enable dma channel ret = dma_enable(&dma_rx); if (ret) ... - dma receive DMA_DEV_TO_MEM. struct ti_drv_packet_data packet_data; void *packet; len = dma_receive(&dma_rx, &packet, &packet_data); if (ret < 0) .. /* packet - points on buffer prepared by dma_prepare_rcv_buf(). process packet*/ - return buffer back to DAM channel ret = dma_prepare_rcv_buf(&dma_rx, net_rx_packets[rx_next], RX_BUF_SIZE); Grygorii Strashko (2): test: dma: add dma-uclass test net: ethernet: ti: introduce am654 gigabit eth switch subsystem driver Vignesh R (1): dma: ti: add driver to K3 UDMA Álvaro Fernández Rojas (2): dma: move dma_ops to dma-uclass.h dma: add channels support arch/sandbox/dts/test.dts | 8 + configs/sandbox_defconfig | 3 + drivers/dma/Kconfig | 16 + drivers/dma/Makefile | 3 + drivers/dma/dma-uclass.c | 183 +++- drivers/dma/sandbox-dma-test.c | 284 +++++++ drivers/dma/ti-edma3.c | 2 +- drivers/dma/ti/Kconfig | 14 + drivers/dma/ti/Makefile | 3 + drivers/dma/ti/k3-udma-hwdef.h | 184 ++++ drivers/dma/ti/k3-udma.c | 1661 +++++++++++++++++++++++++++++++++++++ drivers/net/Kconfig | 8 + drivers/net/Makefile | 1 + drivers/net/am65-cpsw-nuss.c | 962 +++++++++++++++++++++ include/dma-uclass.h | 128 +++ include/dma.h | 282 ++++++- include/dt-bindings/dma/k3-udma.h | 26 + include/linux/soc/ti/ti-udma.h | 24 + test/dm/Makefile | 1 + test/dm/dma.c | 121 +++ 20 files changed, 3884 insertions(+), 30 deletions(-) create mode 100644 drivers/dma/sandbox-dma-test.c create mode 100644 drivers/dma/ti/Kconfig create mode 100644 drivers/dma/ti/Makefile create mode 100644 drivers/dma/ti/k3-udma-hwdef.h create mode 100644 drivers/dma/ti/k3-udma.c create mode 100644 drivers/net/am65-cpsw-nuss.c create mode 100644 include/dma-uclass.h create mode 100644 include/dt-bindings/dma/k3-udma.h create mode 100644 include/linux/soc/ti/ti-udma.h create mode 100644 test/dm/dma.c