From patchwork Thu Apr 19 02:00:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 133681 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp105166ljf; Wed, 18 Apr 2018 19:01:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+KhkQd0ITgZr2tPpL9VPNBSa/AiiEfwpscx9r6Hy8lHw9BnH7gq5jv1ok1FCiMA3uaiwu5 X-Received: by 2002:a17:902:bb8c:: with SMTP id m12-v6mr4283404pls.53.1524103302728; Wed, 18 Apr 2018 19:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524103302; cv=none; d=google.com; s=arc-20160816; b=s60yOHOoZjt8mb259TK0yVjiwOGcLwTbjmUgr6Q/+W8CyNA5u7Igm65yAMjiEiQr88 FHdUSpdgVPy9AfhiPOBaCnZ3AUEw9vkKG7XkADxI1Qn15LR47h1ujVoo9vHOGLDUvDvW jUBpvud1W9Gtetpb9Cf6b+MW3zSFQMrH2OKaDaLd8gljm/n8S1aWNK5kzOW7pRlk5d/i Ky9ZteQy3dIXtxefR7LIqeryQ8EduZ95VoBJ2Nueybip0ANPZX8BmxVuxFTSwAnmTWRg 42fBQD+V5kD2HKLewNbIYmlnBAd6qOLvZdnG9qbF8PAwb/JdNa8xzSgdjBbZHGfyiBjk WXGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=3AIlnJI9SfwLmXT42iXI9BlF+8TtLhl6rh8h7xYBuAw=; b=tOx2rK1X0GleILm2IA2aBWsEVrD5isqGSXUNZqeRWNs49QhK2xlDTLM56C9ZxeL49C Esmv2zWLTckIgGRWXeGn9zMzzawwHqnxPC/Qq7ZgKBpwuygxVEj9bchOVoP1wlIZvs96 JXLIbSekVKZq+7eczyx0UKH/LkMHrNd3E9CJohHNKijIrJmuSoW5FB7JViAkHoneDc4/ p2Fd+ieLtKU9ThWQTxukozpHM5m+za6fyiv3quLtlzLkiA9/p6c5g9Wc6gV+z1cIQ+/V qmnl+EGir/bGubOKuHsafmUk4u1seqesY92JUoz6xpKMCnoJQ9HC3Tq3WHhJtLbiNX3s kddg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aTSSc4b5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w9-v6si2341131plp.389.2018.04.18.19.01.42; Wed, 18 Apr 2018 19:01:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aTSSc4b5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752504AbeDSCBf (ORCPT + 29 others); Wed, 18 Apr 2018 22:01:35 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:43427 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbeDSCBe (ORCPT ); Wed, 18 Apr 2018 22:01:34 -0400 Received: by mail-pg0-f67.google.com with SMTP id f132so1732124pgc.10 for ; Wed, 18 Apr 2018 19:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=3AIlnJI9SfwLmXT42iXI9BlF+8TtLhl6rh8h7xYBuAw=; b=aTSSc4b5dHXQwPg/Vefuh1GjN2dyYBm+UTAmLKw9ohuH8bETagEYDGkI0RS2dLBgzY H7w6s6+ITwO9R9ycOer3m7BNALrAeOkeOnyab2UJhZRNNM80WdUlNe9cwAPdirgTNpR2 ndgSu4U+D6Y4jz2szcF1dbaRYt+7RHnANQ/EA= 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; bh=3AIlnJI9SfwLmXT42iXI9BlF+8TtLhl6rh8h7xYBuAw=; b=FrPRmUORVVWJ5Z8/53LVyAZMTZAJe32Cc5xiMd1SVlzSgqRnzcgrp4bqaWhFsfRLjj q7lEfxiestpAy9Nabm4mPdpskzk83kxTLPfyhMbWI9yupGu6cKQwnqiE/fDNnYH11Mbv oAwtvOaQxxoRDVohRgEkw8EbkDnYXo9Rqxv2qt/oxI9NVg8N7qUhl5M/DzhGOnPtbCJw vGgbVevFyi8uDm8h3XPyYhgchXv1kpPMkC4PnDA+eSRRLswEBSf4fD5F9fLHx7bHS3lX heSBm7wyImcOUqJlq2WUHKs4xQDyACVEXni8i4zo0ihPDfjZLRkS6pWWsn9uJlJbgXw+ MmrQ== X-Gm-Message-State: ALQs6tBbeLge1lc5F7oxLMJ/AJPjJbwEyvAb3Q5LDsjQ1UJBOcJ6+6X+ neb7mE3qp9/Q86ll9P7HfbQQHg== X-Received: by 10.98.194.142 with SMTP id w14mr4023924pfk.226.1524103293716; Wed, 18 Apr 2018 19:01:33 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id e83sm6136938pfd.175.2018.04.18.19.01.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Apr 2018 19:01:33 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vinod.koul@intel.com Cc: eric.long@spreadtrum.com, broonie@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH v2 1/5] dmaengine: sprd: Define the DMA transfer step type Date: Thu, 19 Apr 2018 10:00:46 +0800 Message-Id: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Long Define the DMA transfer step type to make code more readable. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- Changes since v1: - Convert enum structure to macros definition for DMA step type. --- drivers/dma/sprd-dma.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index b106e8a..dcfa417 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -116,6 +116,13 @@ #define SPRD_DMA_SRC_TRSF_STEP_OFFSET 0 #define SPRD_DMA_TRSF_STEP_MASK GENMASK(15, 0) +/* define the DMA transfer step type */ +#define SPRD_DMA_NONE_STEP 0 +#define SPRD_DMA_BYTE_STEP 1 +#define SPRD_DMA_SHORT_STEP 2 +#define SPRD_DMA_WORD_STEP 4 +#define SPRD_DMA_DWORD_STEP 8 + #define SPRD_DMA_SOFTWARE_UID 0 /* @@ -598,16 +605,16 @@ static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, if (IS_ALIGNED(len, 4)) { datawidth = 2; - src_step = 4; - des_step = 4; + src_step = SPRD_DMA_WORD_STEP; + des_step = SPRD_DMA_WORD_STEP; } else if (IS_ALIGNED(len, 2)) { datawidth = 1; - src_step = 2; - des_step = 2; + src_step = SPRD_DMA_SHORT_STEP; + des_step = SPRD_DMA_SHORT_STEP; } else { datawidth = 0; - src_step = 1; - des_step = 1; + src_step = SPRD_DMA_BYTE_STEP; + des_step = SPRD_DMA_BYTE_STEP; } fragment_len = SPRD_DMA_MEMCPY_MIN_SIZE; From patchwork Thu Apr 19 02:00:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 133682 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp105294ljf; Wed, 18 Apr 2018 19:01:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48x7GdSPV4s1BQHWQuA53M6ZM70xGTxs4dNGmnX+D72YLBo+IJeZJ2Av5jrjgVgI1hGdTYC X-Received: by 10.99.179.68 with SMTP id x4mr3568213pgt.132.1524103310830; Wed, 18 Apr 2018 19:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524103310; cv=none; d=google.com; s=arc-20160816; b=ZBlCYID5vhpxbWSanDYvOEBOQtp41WV/PRP4ClsaXheSzm4bO1vnhvLaKL6XJpdLiz D+nM4nTPWEUzJ/IPvJX4QCd4KfqBQySGHvI++Sjxwbnw7EesiNzSHeE5FK5KJGkKMZA8 zoTCIj3j9fSAfcT8LVe/d8QFADcefq/EhKrMf/fEXXzS+GrJuXaoy87o9YikfsQpe2X0 ErLfoKubQ0oSJw1dcB5MvIA/+8lhuLMamDQxfr0tCBwguOt7IF2VDRel5SJryWQ+kYm0 yH+eeFWEHwhTwipIeZ1WGqy9cb/e+5i9Cb5lg6t1UsdOYgTHykNIRXoNQcmI52FM5NS4 rI3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=S8cxIwV1Mlsv0oDjoIxmzwGF/6p93zW1Ta6SI/c62Gw=; b=FZTEk/yXWF/4cUWmZeF09DZpIQuPKEZlTBh3or30viKFjammP0BYfQKJqfHldzdVRH 3RX7gnZ41hvPHny+cHMjg9YvJ5yVRXOQKQknxpetZj1bo5TiTNVTyuD8wNKx/gJ/XCir lhHpgBbfi0+UKe/S5LXSUsXZS+oAgf5wFrLUcHOjK7wUtb1Ia3Exdpai5C0cSoupm/8n LySRCSh07q03wMy3obr64W2UeC4A9Wc0PP5gDJ29dJJtIYJ0oAjvXtGHX6BdeyQrbmt/ OWQ1IYOvwoTM6jnOLJmspMURpssnQAGrGAvhABDr6s+PciqljnztvV0+lNFsELySImt2 7XiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eA/B8qxY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q127si2079709pga.326.2018.04.18.19.01.50; Wed, 18 Apr 2018 19:01:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eA/B8qxY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752810AbeDSCBm (ORCPT + 29 others); Wed, 18 Apr 2018 22:01:42 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:38316 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbeDSCBg (ORCPT ); Wed, 18 Apr 2018 22:01:36 -0400 Received: by mail-pl0-f66.google.com with SMTP id c7-v6so2245482plr.5 for ; Wed, 18 Apr 2018 19:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=S8cxIwV1Mlsv0oDjoIxmzwGF/6p93zW1Ta6SI/c62Gw=; b=eA/B8qxYeXg5/gCLW0cPFrHLnnlBkU3QmOeqlcUJisAzYZXzHvnIsn6tAznwqCb96c 6pC6/KzZbbhqgGxkNxeT3MRcySrFtnxVSgdCpMFWDC5Z9AuK4woy/lR+zU72ou6pznnS Mpnn5czVe0oRUfrciRkYii1SdfrRc5YntCxbk= 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:in-reply-to:references; bh=S8cxIwV1Mlsv0oDjoIxmzwGF/6p93zW1Ta6SI/c62Gw=; b=PQYomeP5M/SdNuhj91ceUKG8t8oG4pQRiDZp1gWfhvnc9pcQs4NtqxXC8FQN12oWN4 S9B5qVzOSl5DbPyFGQVdMPUQeao7u8GNEdVyjZpK47XVTCfGq2PvQUsENG23HOBMpE5r Ia57jAveOEo23fJOS6D0PBtOHYhtfFc2AZOtBDv2KBjtp1T3wL5hNPNXa5kY3NC4FdUa SJJwoMjUyxttWmB7CPzrjtU0AQ8IPAa65qNG4dFa91zTXinr/BZuvY/2CMeBG7YPy2wu Z2SMMXnXSTSaPh+INFS+VNiXrEt2bOTq/jO2DXIJQdCb4YqJVUq+x3QNmWVZZMZqSMbr +0SQ== X-Gm-Message-State: ALQs6tAeVvSDaq19Wx4Ya9VN4CU/HwDspl2zLOrInwRvph227B6SFdlF ycXJg1ZyRwDJqcSAJICbdaBMXg== X-Received: by 2002:a17:902:108a:: with SMTP id c10-v6mr3752734pla.111.1524103296514; Wed, 18 Apr 2018 19:01:36 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id e83sm6136938pfd.175.2018.04.18.19.01.33 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Apr 2018 19:01:35 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vinod.koul@intel.com Cc: eric.long@spreadtrum.com, broonie@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH v2 2/5] dmaengine: sprd: Define the DMA data width type Date: Thu, 19 Apr 2018 10:00:47 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> References: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> In-Reply-To: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> References: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Define the DMA data width type to make code more readable. Signed-off-by: Baolin Wang --- Changes since v1: - No updates. --- drivers/dma/sprd-dma.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index dcfa417..65ff0a58 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -176,6 +176,14 @@ enum sprd_dma_int_type { SPRD_DMA_CFGERR_INT, }; +/* dma data width values */ +enum sprd_dma_datawidth { + SPRD_DMA_DATAWIDTH_1_BYTE, + SPRD_DMA_DATAWIDTH_2_BYTES, + SPRD_DMA_DATAWIDTH_4_BYTES, + SPRD_DMA_DATAWIDTH_8_BYTES, +}; + /* dma channel hardware configuration */ struct sprd_dma_chn_hw { u32 pause; @@ -604,15 +612,15 @@ static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, u32 fix_mode = 0, fix_en = 0; if (IS_ALIGNED(len, 4)) { - datawidth = 2; + datawidth = SPRD_DMA_DATAWIDTH_4_BYTES; src_step = SPRD_DMA_WORD_STEP; des_step = SPRD_DMA_WORD_STEP; } else if (IS_ALIGNED(len, 2)) { - datawidth = 1; + datawidth = SPRD_DMA_DATAWIDTH_2_BYTES; src_step = SPRD_DMA_SHORT_STEP; des_step = SPRD_DMA_SHORT_STEP; } else { - datawidth = 0; + datawidth = SPRD_DMA_DATAWIDTH_1_BYTE; src_step = SPRD_DMA_BYTE_STEP; des_step = SPRD_DMA_BYTE_STEP; } From patchwork Thu Apr 19 02:00:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 133685 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp105721ljf; Wed, 18 Apr 2018 19:02:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx488UIe8KzxMW1Fm4LLAQNSRCri486jE77picgMnbn1JaY7HxVL3bR1j897y3fSFYJ/yiLrh X-Received: by 10.99.112.70 with SMTP id a6mr3522215pgn.294.1524103344183; Wed, 18 Apr 2018 19:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524103344; cv=none; d=google.com; s=arc-20160816; b=uN0kjzipiGXG1ZyH9VDtY8vg5mpZpwUTb8utmC5ZhJuwYwLbBIl3qQ9yibTttV4Dus jtSJW7LBd7r61CeAEPOUaFu6IaP46J5EPMjdHLiF36xSZExPkkfXVE0r0qPK0B37jtry q7VCAkBJDlRdHURNtA+E01KS4fC28P5bM9QD5l3bYhcD/sidV/Cr45gy6Au0arGxgIP0 ZWtG66oZIUe/I2C+v8XCdz7eU9PM80PDv8z2IyoEFILoywgGgpzeMNfxHnCALOAKvvlB GtrwtvpY5GTDyn6dPii0OaBuRQx9hze2LDfzpbJn4ga+IQc60s168V2Pmo8qcoUIavwo /VzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=VbPghuNDxyogCasTQ1bmBwkrEhCnQJnfeqHL8ukX/M8=; b=s876bKtRK43dRzQZllU7I4yXdhPGwvzlnRTNDZSGQOFkI6fRCGOuULyOrO5JX3g56p QMTJg5sTsDf8UrMpntl03kdKSWzfZ0zMNnoFpS/oWvXWdS+b5lfNH4+vHFa4z3mPDNW3 dp3TOruYiRUhqiQ870x+AVXZUmyJ2mMUOV5LKRSjxQgXqRmhiA5++9w65ifufW/aXydu qb5zO49oE3QYJ+3V6SWVi5DNcsnYEvIEv0sskjNxQ2vLiQkHegru4TI2BfGyfBEcCPer LttdQNaEszQcTIqDBYMSI5OuOnq7mSMxIdvORvGWmqd8FZDaPP8sOLAo2pDtPUzGGNLa qTWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcBjfdj8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si2111295pgr.405.2018.04.18.19.02.23; Wed, 18 Apr 2018 19:02:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcBjfdj8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753153AbeDSCCV (ORCPT + 29 others); Wed, 18 Apr 2018 22:02:21 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:46606 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752634AbeDSCBj (ORCPT ); Wed, 18 Apr 2018 22:01:39 -0400 Received: by mail-pf0-f196.google.com with SMTP id h69so1822199pfe.13 for ; Wed, 18 Apr 2018 19:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=VbPghuNDxyogCasTQ1bmBwkrEhCnQJnfeqHL8ukX/M8=; b=dcBjfdj82fipwEIw7A+3niym6AjmBkb68LefVHKLpIRjmj4IETibu4I4smsIAbflRc PzPQkyCCE7PkocQz9VQ1c4AsKNokjN4m7r6Wk5ysMh6HmnhEHLFgJmFbG13sH3Xhf8na qmjbVs6gQQA52DnAhTz3U5uaNkQIfnu1qVjGI= 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:in-reply-to:references; bh=VbPghuNDxyogCasTQ1bmBwkrEhCnQJnfeqHL8ukX/M8=; b=M6Olp5jmvr+UUXmsVMcUlMNhtlNgsJ7puImVQ03EGZcjfyvIur+HFnDj1CFQhuqlmj I6BL2XLeZhyEfxLwX5gt5zIQvkvb8X8pFeKN/sqGNNQGl+lPsXVnQ1nIqJw2M7iZ+CZY MIIkhGHg37a1LzK4fhybJ3i7GJSrhiGK5DoCLB7p+EHo2JEZvsTu6ZzNC9Ej7ooSDv1O A84K1D9hiTOGMdM0RYH04+I2saOnzrqNl/hI0PmW12iVTlsbTbJZN7G4wxVugb2JKuYu mB6fW9NguSkeSEceLUlP048gSd/gnAjKzXivx+Fx88UKxk38UvFG7xLwPGuFm5spf/Qx kVQg== X-Gm-Message-State: ALQs6tDIF+a32bEHJuWfdfraA1Te79uBGgwROCSv57EQJXaERifGrs59 1Ev963NoQ3d7+QZ/DI8toRHN5g== X-Received: by 10.98.207.130 with SMTP id b124mr4071114pfg.9.1524103298960; Wed, 18 Apr 2018 19:01:38 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id e83sm6136938pfd.175.2018.04.18.19.01.36 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Apr 2018 19:01:38 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vinod.koul@intel.com Cc: eric.long@spreadtrum.com, broonie@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH v2 3/5] dmaengine: sprd: Move DMA request mode and interrupt type into head file Date: Thu, 19 Apr 2018 10:00:48 +0800 Message-Id: <0ec72acc564401cdbada3ff1f4c9500d1233398e.1524054807.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> References: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> In-Reply-To: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> References: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Long This patch will move the Spreadtrum DMA request mode and interrupt type into one head file for user to configure. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- Changes since v1: - No updates. --- drivers/dma/sprd-dma.c | 52 +------------------------------------- include/linux/dma/sprd-dma.h | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 51 deletions(-) create mode 100644 include/linux/dma/sprd-dma.h -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 65ff0a58..ccdeb8f 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -125,57 +126,6 @@ #define SPRD_DMA_SOFTWARE_UID 0 -/* - * enum sprd_dma_req_mode: define the DMA request mode - * @SPRD_DMA_FRAG_REQ: fragment request mode - * @SPRD_DMA_BLK_REQ: block request mode - * @SPRD_DMA_TRANS_REQ: transaction request mode - * @SPRD_DMA_LIST_REQ: link-list request mode - * - * We have 4 types request mode: fragment mode, block mode, transaction mode - * and linklist mode. One transaction can contain several blocks, one block can - * contain several fragments. Link-list mode means we can save several DMA - * configuration into one reserved memory, then DMA can fetch each DMA - * configuration automatically to start transfer. - */ -enum sprd_dma_req_mode { - SPRD_DMA_FRAG_REQ, - SPRD_DMA_BLK_REQ, - SPRD_DMA_TRANS_REQ, - SPRD_DMA_LIST_REQ, -}; - -/* - * enum sprd_dma_int_type: define the DMA interrupt type - * @SPRD_DMA_NO_INT: do not need generate DMA interrupts. - * @SPRD_DMA_FRAG_INT: fragment done interrupt when one fragment request - * is done. - * @SPRD_DMA_BLK_INT: block done interrupt when one block request is done. - * @SPRD_DMA_BLK_FRAG_INT: block and fragment interrupt when one fragment - * or one block request is done. - * @SPRD_DMA_TRANS_INT: tansaction done interrupt when one transaction - * request is done. - * @SPRD_DMA_TRANS_FRAG_INT: transaction and fragment interrupt when one - * transaction request or fragment request is done. - * @SPRD_DMA_TRANS_BLK_INT: transaction and block interrupt when one - * transaction request or block request is done. - * @SPRD_DMA_LIST_INT: link-list done interrupt when one link-list request - * is done. - * @SPRD_DMA_CFGERR_INT: configure error interrupt when configuration is - * incorrect. - */ -enum sprd_dma_int_type { - SPRD_DMA_NO_INT, - SPRD_DMA_FRAG_INT, - SPRD_DMA_BLK_INT, - SPRD_DMA_BLK_FRAG_INT, - SPRD_DMA_TRANS_INT, - SPRD_DMA_TRANS_FRAG_INT, - SPRD_DMA_TRANS_BLK_INT, - SPRD_DMA_LIST_INT, - SPRD_DMA_CFGERR_INT, -}; - /* dma data width values */ enum sprd_dma_datawidth { SPRD_DMA_DATAWIDTH_1_BYTE, diff --git a/include/linux/dma/sprd-dma.h b/include/linux/dma/sprd-dma.h new file mode 100644 index 0000000..c545162 --- /dev/null +++ b/include/linux/dma/sprd-dma.h @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _SPRD_DMA_H_ +#define _SPRD_DMA_H_ + +/* + * enum sprd_dma_req_mode: define the DMA request mode + * @SPRD_DMA_FRAG_REQ: fragment request mode + * @SPRD_DMA_BLK_REQ: block request mode + * @SPRD_DMA_TRANS_REQ: transaction request mode + * @SPRD_DMA_LIST_REQ: link-list request mode + * + * We have 4 types request mode: fragment mode, block mode, transaction mode + * and linklist mode. One transaction can contain several blocks, one block can + * contain several fragments. Link-list mode means we can save several DMA + * configuration into one reserved memory, then DMA can fetch each DMA + * configuration automatically to start transfer. + */ +enum sprd_dma_req_mode { + SPRD_DMA_FRAG_REQ, + SPRD_DMA_BLK_REQ, + SPRD_DMA_TRANS_REQ, + SPRD_DMA_LIST_REQ, +}; + +/* + * enum sprd_dma_int_type: define the DMA interrupt type + * @SPRD_DMA_NO_INT: do not need generate DMA interrupts. + * @SPRD_DMA_FRAG_INT: fragment done interrupt when one fragment request + * is done. + * @SPRD_DMA_BLK_INT: block done interrupt when one block request is done. + * @SPRD_DMA_BLK_FRAG_INT: block and fragment interrupt when one fragment + * or one block request is done. + * @SPRD_DMA_TRANS_INT: tansaction done interrupt when one transaction + * request is done. + * @SPRD_DMA_TRANS_FRAG_INT: transaction and fragment interrupt when one + * transaction request or fragment request is done. + * @SPRD_DMA_TRANS_BLK_INT: transaction and block interrupt when one + * transaction request or block request is done. + * @SPRD_DMA_LIST_INT: link-list done interrupt when one link-list request + * is done. + * @SPRD_DMA_CFGERR_INT: configure error interrupt when configuration is + * incorrect. + */ +enum sprd_dma_int_type { + SPRD_DMA_NO_INT, + SPRD_DMA_FRAG_INT, + SPRD_DMA_BLK_INT, + SPRD_DMA_BLK_FRAG_INT, + SPRD_DMA_TRANS_INT, + SPRD_DMA_TRANS_FRAG_INT, + SPRD_DMA_TRANS_BLK_INT, + SPRD_DMA_LIST_INT, + SPRD_DMA_CFGERR_INT, +}; + +#endif From patchwork Thu Apr 19 02:00:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 133683 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp105301ljf; Wed, 18 Apr 2018 19:01:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/V4m7iJFnjWxnYp7w7ILC8G5fa2zsUGrdFpw0CRR3wOavYkCIugeRualZHoS0IzsF2O0Xu X-Received: by 10.99.64.3 with SMTP id n3mr3560862pga.13.1524103311484; Wed, 18 Apr 2018 19:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524103311; cv=none; d=google.com; s=arc-20160816; b=vThH6sCJJ2JhszwdFml/YAEhWiJP5IkmnoutVXL1VTYhPeAXs9ywGuLnb7xpI4s3Eo WPSZgYQWoorjuATm05H+8jArw+S8XAwyeWBx/8SZCd1/8zVP5Whk/Z4bI74VLhLK1kvD lPTH0JpfW+93MT21Zk3+7ZuWVl6+9s4xhbvfUqNVnUkVc8ed1W9+dti4h9dMcyphIYPL wgkylMMFLdR+AekaHFcdo/u/DQxEIRGFr4zcGq7CB4DfoXK4P02vA9kqJ6s8W0RMGpr/ baA9yDopp/fXNbBgqdwQH7Y0ILxt3/ayByx/Lou9eVUkRhcwmj6E1bI8rJ5/3cJUeNsD x0RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=77xE96fhMMXwIyfnqYlYR4SQftCR6/hg+NUjtZR5AZg=; b=Pk2sK42bjTvC1TSbSD+IUzpg7CEpYtPnkD4czS9+0Rn2T+KI2RT1xCYF3mPEg7xKg1 6oWy4BVmBC0304ww0RwNswaY8cB6SN4xxJJVIZyzBLV52O0OV225NRTloVqSEHCJmKCF H8Iy/5MLc93e/ydAb23uA6vjhywmFMAN4CoIWAUJXpEKcbqIeIR6SrYFJc5Hc6y0Nag2 H0rkntTGOpor1Bx4R8/D3qsWLww6/4g4zGon+6f3eM9RhLfg9ieaLtRDDWZDRQQtBEga YXPUXaLB2Zq1erDD0//e/4QiJ+k7+q7RH1ihQWLBhDDU5isG1jlkUtqDzWZPQbRAmzIq AW4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Eo3jM3rg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q127si2079709pga.326.2018.04.18.19.01.51; Wed, 18 Apr 2018 19:01:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Eo3jM3rg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753097AbeDSCBp (ORCPT + 29 others); Wed, 18 Apr 2018 22:01:45 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:45910 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752792AbeDSCBm (ORCPT ); Wed, 18 Apr 2018 22:01:42 -0400 Received: by mail-pf0-f196.google.com with SMTP id l27so1822582pfk.12 for ; Wed, 18 Apr 2018 19:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=77xE96fhMMXwIyfnqYlYR4SQftCR6/hg+NUjtZR5AZg=; b=Eo3jM3rggEF3L/6GKUmKJVg9Vo8wQ7huOrG4/v7NIX1HNfdN3Ywc0Qt5S06+0+sEN7 hkDxcBaytICb9peTAMFIiqmHYJCMI+inEiucq34hkgWKf5VuePxhGt6exm4+TIFkwnEF v6nh0D8RzoR/s8UMOLJZJtjw0+lvEUOWYk950= 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:in-reply-to:references; bh=77xE96fhMMXwIyfnqYlYR4SQftCR6/hg+NUjtZR5AZg=; b=i6a7cRnaxhD80SAF7PKre6VBznNm+nPKeVY902B2W/UjA6VyhsO/3KBNY24AAvO9rE mJ0AW8MmSgZVYkTqTBCF87Pen0aXdhnqWzl0WfHuTC1i/6fd0VaEQ30A1Sj028wmvkRk BtzpY8gGTKXkiCRlEOzwvIlRfA4ySL5zutayhFkMxrPyXRR/d9gX+lkkdCnU00qeEWP1 sI45+/1CX4bL1DgNRiic/LGjI+e9ZUMEzLhSYpmyQXb8p5Hmf9f4CFFhYMrhmxH31f9e QBAwPfcqAiCcx3O6Jhje+QZDtS0DtLEw3pJmUC2h7QAFXWF2UtX5T5qimON+AU1yLpW7 C42A== X-Gm-Message-State: ALQs6tAyvyb4Y5sNXtJhuZ9oJl08nCX+K4FOJBzy3o5EyXq7oCRgaqeF fK9FvREkogIOuylemGnsB8xksA== X-Received: by 10.98.130.140 with SMTP id w134mr4054692pfd.127.1524103301534; Wed, 18 Apr 2018 19:01:41 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id e83sm6136938pfd.175.2018.04.18.19.01.39 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Apr 2018 19:01:41 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vinod.koul@intel.com Cc: eric.long@spreadtrum.com, broonie@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH v2 4/5] dmaengine: sprd: Add Spreadtrum DMA configuration Date: Thu, 19 Apr 2018 10:00:49 +0800 Message-Id: <30ff22774f045db654d5e784716c3ee69e00775d.1524054807.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> References: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> In-Reply-To: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> References: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Long This patch adds one 'struct sprd_dma_config' structure to save Spreadtrum DMA configuration for each DMA channel. Meanwhile we also did some optimization for sprd_dma_config() and sprd_dma_prep_dma_memcpy() to prepare to configure DMA from users. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- Changes since v1: - Remove 'struct sprd_dma_config' structure in 'sprd_dma.h'. - Add 'struct sprd_dma_config' for DMA channel. - Remove sprd_dma_get_datawidth() and sprd_dma_get_step(). - Other optimization. --- drivers/dma/sprd-dma.c | 205 ++++++++++++++++++++++++++---------------------- 1 file changed, 110 insertions(+), 95 deletions(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index ccdeb8f..23846ed 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -100,6 +100,8 @@ #define SPRD_DMA_DES_DATAWIDTH_OFFSET 28 #define SPRD_DMA_SWT_MODE_OFFSET 26 #define SPRD_DMA_REQ_MODE_OFFSET 24 +#define SPRD_DMA_WRAP_SEL_OFFSET 23 +#define SPRD_DMA_WRAP_EN_OFFSET 22 #define SPRD_DMA_REQ_MODE_MASK GENMASK(1, 0) #define SPRD_DMA_FIX_SEL_OFFSET 21 #define SPRD_DMA_FIX_EN_OFFSET 20 @@ -154,6 +156,41 @@ struct sprd_dma_chn_hw { u32 des_blk_step; }; +/* + * struct sprd_dma_config - DMA configuration structure + * @src_addr: the physical address where DMA slave data should be read + * @dst_addr: the physical address where DMA slave data should be written + * @fragment_len: specify one fragment transfer length + * @block_len: specify one block transfer length + * @transcation_len: specify one transcation transfer length + * @src_step: source transfer step + * @dst_step: destination transfer step + * @src_datawidth: source transfer data width + * @dst_datawidth: destination transfer data width + * @wrap_ptr: wrap pointer address, once the transfer address reaches the + * 'wrap_ptr', the next transfer address will jump to the 'wrap_to' address. + * @wrap_to: wrap jump to address + * @req_mode: specify the DMA request mode + * @int_mode: specify the DMA interrupt type + * @slave_id: slave channel requester id + */ +struct sprd_dma_config { + phys_addr_t src_addr; + phys_addr_t dst_addr; + u32 fragment_len; + u32 block_len; + u32 transcation_len; + u32 src_step; + u32 dst_step; + enum sprd_dma_datawidth src_datawidth; + enum sprd_dma_datawidth dst_datawidth; + phys_addr_t wrap_ptr; + phys_addr_t wrap_to; + enum sprd_dma_req_mode req_mode; + enum sprd_dma_int_type int_mode; + u32 slave_id; +}; + /* dma request description */ struct sprd_dma_desc { struct virt_dma_desc vd; @@ -164,6 +201,7 @@ struct sprd_dma_desc { struct sprd_dma_chn { struct virt_dma_chan vc; void __iomem *chn_base; + struct sprd_dma_config slave_cfg; u32 chn_num; u32 dev_id; struct sprd_dma_desc *cur_desc; @@ -553,125 +591,74 @@ static void sprd_dma_issue_pending(struct dma_chan *chan) } static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, - dma_addr_t dest, dma_addr_t src, size_t len) + struct sprd_dma_config *slave_cfg) { struct sprd_dma_dev *sdev = to_sprd_dma_dev(chan); + struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); struct sprd_dma_chn_hw *hw = &sdesc->chn_hw; - u32 datawidth, src_step, des_step, fragment_len; - u32 block_len, req_mode, irq_mode, transcation_len; - u32 fix_mode = 0, fix_en = 0; - - if (IS_ALIGNED(len, 4)) { - datawidth = SPRD_DMA_DATAWIDTH_4_BYTES; - src_step = SPRD_DMA_WORD_STEP; - des_step = SPRD_DMA_WORD_STEP; - } else if (IS_ALIGNED(len, 2)) { - datawidth = SPRD_DMA_DATAWIDTH_2_BYTES; - src_step = SPRD_DMA_SHORT_STEP; - des_step = SPRD_DMA_SHORT_STEP; - } else { - datawidth = SPRD_DMA_DATAWIDTH_1_BYTE; - src_step = SPRD_DMA_BYTE_STEP; - des_step = SPRD_DMA_BYTE_STEP; - } + u32 fix_mode = 0, fix_en = 0, wrap_en = 0, wrap_mode = 0; - fragment_len = SPRD_DMA_MEMCPY_MIN_SIZE; - if (len <= SPRD_DMA_BLK_LEN_MASK) { - block_len = len; - transcation_len = 0; - req_mode = SPRD_DMA_BLK_REQ; - irq_mode = SPRD_DMA_BLK_INT; - } else { - block_len = SPRD_DMA_MEMCPY_MIN_SIZE; - transcation_len = len; - req_mode = SPRD_DMA_TRANS_REQ; - irq_mode = SPRD_DMA_TRANS_INT; - } + if (slave_cfg->slave_id) + schan->dev_id = slave_cfg->slave_id; hw->cfg = SPRD_DMA_DONOT_WAIT_BDONE << SPRD_DMA_WAIT_BDONE_OFFSET; - hw->wrap_ptr = (u32)((src >> SPRD_DMA_HIGH_ADDR_OFFSET) & - SPRD_DMA_HIGH_ADDR_MASK); - hw->wrap_to = (u32)((dest >> SPRD_DMA_HIGH_ADDR_OFFSET) & - SPRD_DMA_HIGH_ADDR_MASK); - - hw->src_addr = (u32)(src & SPRD_DMA_LOW_ADDR_MASK); - hw->des_addr = (u32)(dest & SPRD_DMA_LOW_ADDR_MASK); - - if ((src_step != 0 && des_step != 0) || (src_step | des_step) == 0) { + hw->wrap_ptr = (u32)((slave_cfg->wrap_ptr & SPRD_DMA_LOW_ADDR_MASK) | + ((slave_cfg->src_addr >> SPRD_DMA_HIGH_ADDR_OFFSET) & + SPRD_DMA_HIGH_ADDR_MASK)); + hw->wrap_to = (u32)((slave_cfg->wrap_to & SPRD_DMA_LOW_ADDR_MASK) | + ((slave_cfg->dst_addr >> SPRD_DMA_HIGH_ADDR_OFFSET) & + SPRD_DMA_HIGH_ADDR_MASK)); + + hw->src_addr = (u32)(slave_cfg->src_addr & SPRD_DMA_LOW_ADDR_MASK); + hw->des_addr = (u32)(slave_cfg->dst_addr & SPRD_DMA_LOW_ADDR_MASK); + + if ((slave_cfg->src_step != 0 && slave_cfg->dst_step != 0) + || (slave_cfg->src_step | slave_cfg->dst_step) == 0) { fix_en = 0; } else { fix_en = 1; - if (src_step) + if (slave_cfg->src_step) fix_mode = 1; else fix_mode = 0; } - hw->frg_len = datawidth << SPRD_DMA_SRC_DATAWIDTH_OFFSET | - datawidth << SPRD_DMA_DES_DATAWIDTH_OFFSET | - req_mode << SPRD_DMA_REQ_MODE_OFFSET | - fix_mode << SPRD_DMA_FIX_SEL_OFFSET | - fix_en << SPRD_DMA_FIX_EN_OFFSET | - (fragment_len & SPRD_DMA_FRG_LEN_MASK); - hw->blk_len = block_len & SPRD_DMA_BLK_LEN_MASK; - - hw->intc = SPRD_DMA_CFG_ERR_INT_EN; - - switch (irq_mode) { - case SPRD_DMA_NO_INT: - break; - - case SPRD_DMA_FRAG_INT: - hw->intc |= SPRD_DMA_FRAG_INT_EN; - break; - - case SPRD_DMA_BLK_INT: - hw->intc |= SPRD_DMA_BLK_INT_EN; - break; - - case SPRD_DMA_BLK_FRAG_INT: - hw->intc |= SPRD_DMA_BLK_INT_EN | SPRD_DMA_FRAG_INT_EN; - break; - - case SPRD_DMA_TRANS_INT: - hw->intc |= SPRD_DMA_TRANS_INT_EN; - break; - - case SPRD_DMA_TRANS_FRAG_INT: - hw->intc |= SPRD_DMA_TRANS_INT_EN | SPRD_DMA_FRAG_INT_EN; - break; + if (slave_cfg->wrap_ptr && slave_cfg->wrap_to) { + wrap_en = 1; + if (slave_cfg->wrap_to == slave_cfg->src_addr) { + wrap_mode = 0; + } else if (slave_cfg->wrap_to == slave_cfg->dst_addr) { + wrap_mode = 1; + } else { + dev_err(sdev->dma_dev.dev, "invalid wrap mode\n"); + return -EINVAL; + } + } - case SPRD_DMA_TRANS_BLK_INT: - hw->intc |= SPRD_DMA_TRANS_INT_EN | SPRD_DMA_BLK_INT_EN; - break; + hw->intc = slave_cfg->int_mode | SPRD_DMA_CFG_ERR_INT_EN; - case SPRD_DMA_LIST_INT: - hw->intc |= SPRD_DMA_LIST_INT_EN; - break; + hw->frg_len = + slave_cfg->src_datawidth << SPRD_DMA_SRC_DATAWIDTH_OFFSET | + slave_cfg->dst_datawidth << SPRD_DMA_DES_DATAWIDTH_OFFSET | + slave_cfg->req_mode << SPRD_DMA_REQ_MODE_OFFSET | + wrap_mode << SPRD_DMA_WRAP_SEL_OFFSET | + wrap_en << SPRD_DMA_WRAP_EN_OFFSET | + fix_mode << SPRD_DMA_FIX_SEL_OFFSET | + fix_en << SPRD_DMA_FIX_EN_OFFSET | + (slave_cfg->fragment_len & SPRD_DMA_FRG_LEN_MASK); - case SPRD_DMA_CFGERR_INT: - hw->intc |= SPRD_DMA_CFG_ERR_INT_EN; - break; + hw->blk_len = slave_cfg->block_len & SPRD_DMA_BLK_LEN_MASK; - default: - dev_err(sdev->dma_dev.dev, "invalid irq mode\n"); - return -EINVAL; - } + hw->trsc_len = slave_cfg->transcation_len & SPRD_DMA_TRSC_LEN_MASK; - if (transcation_len == 0) - hw->trsc_len = block_len & SPRD_DMA_TRSC_LEN_MASK; - else - hw->trsc_len = transcation_len & SPRD_DMA_TRSC_LEN_MASK; - - hw->trsf_step = (des_step & SPRD_DMA_TRSF_STEP_MASK) << + hw->trsf_step = (slave_cfg->dst_step & SPRD_DMA_TRSF_STEP_MASK) << SPRD_DMA_DEST_TRSF_STEP_OFFSET | - (src_step & SPRD_DMA_TRSF_STEP_MASK) << + (slave_cfg->src_step & SPRD_DMA_TRSF_STEP_MASK) << SPRD_DMA_SRC_TRSF_STEP_OFFSET; hw->frg_step = 0; hw->src_blk_step = 0; hw->des_blk_step = 0; - hw->src_blk_step = 0; return 0; } @@ -680,6 +667,7 @@ static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, size_t len, unsigned long flags) { struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); + struct sprd_dma_config *slave_cfg = &schan->slave_cfg; struct sprd_dma_desc *sdesc; int ret; @@ -687,7 +675,34 @@ static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, if (!sdesc) return NULL; - ret = sprd_dma_config(chan, sdesc, dest, src, len); + memset(slave_cfg, 0, sizeof(*slave_cfg)); + + slave_cfg->src_addr = src; + slave_cfg->dst_addr = dest; + slave_cfg->fragment_len = len; + slave_cfg->block_len = len; + slave_cfg->transcation_len = len; + slave_cfg->req_mode = SPRD_DMA_TRANS_REQ; + slave_cfg->int_mode = SPRD_DMA_TRANS_INT; + + if (IS_ALIGNED(len, 4)) { + slave_cfg->src_datawidth = SPRD_DMA_DATAWIDTH_4_BYTES; + slave_cfg->dst_datawidth = SPRD_DMA_DATAWIDTH_4_BYTES; + slave_cfg->src_step = SPRD_DMA_WORD_STEP; + slave_cfg->dst_step = SPRD_DMA_WORD_STEP; + } else if (IS_ALIGNED(len, 2)) { + slave_cfg->src_datawidth = SPRD_DMA_DATAWIDTH_2_BYTES; + slave_cfg->dst_datawidth = SPRD_DMA_DATAWIDTH_2_BYTES; + slave_cfg->src_step = SPRD_DMA_SHORT_STEP; + slave_cfg->dst_step = SPRD_DMA_SHORT_STEP; + } else { + slave_cfg->src_datawidth = SPRD_DMA_DATAWIDTH_1_BYTE; + slave_cfg->dst_datawidth = SPRD_DMA_DATAWIDTH_1_BYTE; + slave_cfg->src_step = SPRD_DMA_BYTE_STEP; + slave_cfg->dst_step = SPRD_DMA_BYTE_STEP; + } + + ret = sprd_dma_config(chan, sdesc, slave_cfg); if (ret) { kfree(sdesc); return NULL; From patchwork Thu Apr 19 02:00:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 133684 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp105445ljf; Wed, 18 Apr 2018 19:02:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx497xDTgXwzg0weJhhugn8qKtTQqVnU886m84Pp3X+Ve8M4v3Q4bHTynVMsuaaK24SM5yHj/ X-Received: by 2002:a17:902:4003:: with SMTP id b3-v6mr4130154pld.15.1524103322673; Wed, 18 Apr 2018 19:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524103322; cv=none; d=google.com; s=arc-20160816; b=Zba+ZyuQw2R1O7kNZRj36CYNYDb0HPHFXLllyuJFmHvGQZ8XcAaWcnd09jIlT8sMc3 8KAY9J3QW5FkSGs72/OnFe4FYKeoXPa1A6dmeSwVbpS3ezrRGkiDQGH8eV719reOnOxX PkfnNIkRnpXCZFAHFaBI/k0b/mhkgLKSTOBs+5mCxazoiXLlX8jl79mqH6hw5Rtj9u6j hvNdA6B0k/I90mxalORfX8DPjoX2thTnfKD6LLIOUUFHRMRNomq2VDbed6HKx9yxXizC qK/geNXfhUVCD/ZMJPleVL0dJ0l/hZqA1B+3tgHJC/pG5UDmJY1jR4zLZ9D5oA1lJVax yG1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=u/3qjb5C5bTzfE5TE9aNFaM74weWHJiI5xbTQ0Gb0Rk=; b=Cn3USrFuiO8TgYDqCkA2ACXV287EYtW8Mfv5tZrJT/AImOqpszcIguaf51oKsOzt1d K2vRIpezUizdrPQqB0DsLRpNeUz46hHkEJQGcCK3cRDfrb48J0T9h/QPNvmC9xU+ldda WAnGuoXKN8HQUaXSgRq2bjXRr/ZKxlcwa888PzeBBri8bzEJdj9xaXP2l0se2ywKk24l ojPrioIMID+1BlwWrQRdR0/s4wfZEe/hW01MzeYM2f+6Y+w/js6tjB7w6mq3T0DFQeqc 3Z2JMlfvB1Bs1dNdCpZoaDnSoO/+Rj+UnsBgtLBHmBJNymZDAqcW+FCYsQGACCBMkwBA NHbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=APUZr/GE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k70si2139188pga.118.2018.04.18.19.02.02; Wed, 18 Apr 2018 19:02:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=APUZr/GE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753239AbeDSCB7 (ORCPT + 29 others); Wed, 18 Apr 2018 22:01:59 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:41715 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbeDSCBo (ORCPT ); Wed, 18 Apr 2018 22:01:44 -0400 Received: by mail-pf0-f196.google.com with SMTP id a2so1825009pff.8 for ; Wed, 18 Apr 2018 19:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=u/3qjb5C5bTzfE5TE9aNFaM74weWHJiI5xbTQ0Gb0Rk=; b=APUZr/GE9mMpPq3rKecMM7aPr47hj6uobRHZu+q7jLVhkqFdnQzhQG9WRGPRZ8W991 SGoXkF/9ewoQ54YPDSTMxA8AkJySREiF8c9kT7maKJE/er7e8CsK0pqWHeB7OmOLnux3 kthzPvbKbMqkVNJJ3ym03OP+ayiaGkDuys07g= 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:in-reply-to:references; bh=u/3qjb5C5bTzfE5TE9aNFaM74weWHJiI5xbTQ0Gb0Rk=; b=aChHDANTwwec3eTVh1RRcvueXbpkfwBMu0h/Finw5XgyO1V0WEPBJwTtM+mBU7SASC bCgcb9xHeEre6QO9x9hTH+uIcnDGqyl/hR9uzhIMqZ3ViS7zkA0DU52vr2fSwBMFheeD DY7G3wp2GYRXamNFvDB8FrIWBGLeb9U1uPJQv8UW+xuur9+wBH0BHsgl4uwM0xE1owig Dy1/iy2XibHNFmKZrPEL6SzjmZNIx+tEDiidbilOM5yFzjA+yRN3mu8ifLqX0UxiDAph /IgQXnf5CpRnhCMQXOX39aKqBeVC7L2E7LGiz4+nH2+UR/eT6y+XCRqe6BtdzbcsXtkS /mew== X-Gm-Message-State: ALQs6tC/gU7RIOWEP+xEjO7IoZpqYHoi+kiMZ5ufVEDmAbw7eyegF3kh BXehqaoDVFn7UG4O3iHE1KAf/A== X-Received: by 10.99.184.1 with SMTP id p1mr3539580pge.250.1524103303980; Wed, 18 Apr 2018 19:01:43 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id e83sm6136938pfd.175.2018.04.18.19.01.41 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Apr 2018 19:01:43 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vinod.koul@intel.com Cc: eric.long@spreadtrum.com, broonie@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH v2 5/5] dmaengine: sprd: Add 'device_config' and 'device_prep_slave_sg' interfaces Date: Thu, 19 Apr 2018 10:00:50 +0800 Message-Id: <2efb90f1d86529a51e566824566016b9430f56ea.1524054807.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> References: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> In-Reply-To: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> References: <2ec1e8ddade0be5b4412b031b98d0d69a1af421f.1524054807.git.baolin.wang@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Long This patch adds the 'device_config' and 'device_prep_slave_sg' interfaces for users to configure DMA. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- Changes since v1: - The request mode and interrupt type will be passed from flags. - Add sprd_dma_get_step() to get src/dst step. - Add sprd_dma_get_datawidth() to convert data width values which can be used by Spreadtrum DMA. --- drivers/dma/sprd-dma.c | 115 ++++++++++++++++++++++++++++++++++++++++++ include/linux/dma/sprd-dma.h | 4 ++ 2 files changed, 119 insertions(+) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 23846ed..f2598ed 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -590,6 +590,47 @@ static void sprd_dma_issue_pending(struct dma_chan *chan) spin_unlock_irqrestore(&schan->vc.lock, flags); } +static enum sprd_dma_datawidth +sprd_dma_get_datawidth(enum dma_slave_buswidth buswidth) +{ + switch (buswidth) { + case DMA_SLAVE_BUSWIDTH_1_BYTE: + return SPRD_DMA_DATAWIDTH_1_BYTE; + + case DMA_SLAVE_BUSWIDTH_2_BYTES: + return SPRD_DMA_DATAWIDTH_2_BYTES; + + case DMA_SLAVE_BUSWIDTH_4_BYTES: + return SPRD_DMA_DATAWIDTH_4_BYTES; + + case DMA_SLAVE_BUSWIDTH_8_BYTES: + return SPRD_DMA_DATAWIDTH_8_BYTES; + + default: + return SPRD_DMA_DATAWIDTH_4_BYTES; + } +} + +static u32 sprd_dma_get_step(enum sprd_dma_datawidth datawidth) +{ + switch (datawidth) { + case SPRD_DMA_DATAWIDTH_1_BYTE: + return SPRD_DMA_BYTE_STEP; + + case SPRD_DMA_DATAWIDTH_2_BYTES: + return SPRD_DMA_SHORT_STEP; + + case SPRD_DMA_DATAWIDTH_4_BYTES: + return SPRD_DMA_WORD_STEP; + + case SPRD_DMA_DATAWIDTH_8_BYTES: + return SPRD_DMA_DWORD_STEP; + + default: + return SPRD_DMA_DWORD_STEP; + } +} + static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, struct sprd_dma_config *slave_cfg) { @@ -711,6 +752,78 @@ static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, return vchan_tx_prep(&schan->vc, &sdesc->vd, flags); } +static struct dma_async_tx_descriptor * +sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, + unsigned int sglen, enum dma_transfer_direction dir, + unsigned long flags, void *context) +{ + struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); + struct sprd_dma_config *slave_cfg = &schan->slave_cfg; + struct sprd_dma_desc *sdesc; + struct scatterlist *sg; + int ret, i; + + /* TODO: now we only support one sg for each DMA configuration. */ + if (!is_slave_direction(dir) || sglen > 1) + return NULL; + + sdesc = kzalloc(sizeof(*sdesc), GFP_NOWAIT); + if (!sdesc) + return NULL; + + for_each_sg(sgl, sg, sglen, i) { + if (dir == DMA_MEM_TO_DEV) { + slave_cfg->src_addr = sg_dma_address(sg); + slave_cfg->src_step = + sprd_dma_get_step(slave_cfg->src_datawidth); + slave_cfg->dst_step = SPRD_DMA_NONE_STEP; + } else { + slave_cfg->dst_addr = sg_dma_address(sg); + slave_cfg->src_step = SPRD_DMA_NONE_STEP; + slave_cfg->dst_step = + sprd_dma_get_step(slave_cfg->dst_datawidth); + } + + slave_cfg->block_len = sg_dma_len(sg); + slave_cfg->transcation_len = sg_dma_len(sg); + } + + slave_cfg->req_mode = + (flags >> SPRD_DMA_REQ_SHIFT) & SPRD_DMA_REQ_MODE_MASK; + slave_cfg->int_mode = flags & SPRD_DMA_INT_MASK; + + ret = sprd_dma_config(chan, sdesc, slave_cfg); + if (ret) { + kfree(sdesc); + return NULL; + } + + return vchan_tx_prep(&schan->vc, &sdesc->vd, flags); +} + +static int sprd_dma_slave_config(struct dma_chan *chan, + struct dma_slave_config *config) +{ + struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); + struct sprd_dma_config *slave_cfg = &schan->slave_cfg; + + if (!is_slave_direction(config->direction)) + return -EINVAL; + + memset(slave_cfg, 0, sizeof(*slave_cfg)); + + slave_cfg->slave_id = config->slave_id; + slave_cfg->src_addr = config->src_addr; + slave_cfg->dst_addr = config->dst_addr; + slave_cfg->fragment_len = config->src_maxburst; + slave_cfg->src_datawidth = + sprd_dma_get_datawidth(config->src_addr_width); + slave_cfg->dst_datawidth = + sprd_dma_get_datawidth(config->dst_addr_width); + + return 0; +} + static int sprd_dma_pause(struct dma_chan *chan) { struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); @@ -838,6 +951,8 @@ static int sprd_dma_probe(struct platform_device *pdev) sdev->dma_dev.device_tx_status = sprd_dma_tx_status; sdev->dma_dev.device_issue_pending = sprd_dma_issue_pending; sdev->dma_dev.device_prep_dma_memcpy = sprd_dma_prep_dma_memcpy; + sdev->dma_dev.device_prep_slave_sg = sprd_dma_prep_slave_sg; + sdev->dma_dev.device_config = sprd_dma_slave_config; sdev->dma_dev.device_pause = sprd_dma_pause; sdev->dma_dev.device_resume = sprd_dma_resume; sdev->dma_dev.device_terminate_all = sprd_dma_terminate_all; diff --git a/include/linux/dma/sprd-dma.h b/include/linux/dma/sprd-dma.h index c545162..b0115e3 100644 --- a/include/linux/dma/sprd-dma.h +++ b/include/linux/dma/sprd-dma.h @@ -3,6 +3,10 @@ #ifndef _SPRD_DMA_H_ #define _SPRD_DMA_H_ +#define SPRD_DMA_REQ_SHIFT 16 +#define SPRD_DMA_FLAGS(req_mode, int_type) \ + ((req_mode) << SPRD_DMA_REQ_SHIFT | (int_type)) + /* * enum sprd_dma_req_mode: define the DMA request mode * @SPRD_DMA_FRAG_REQ: fragment request mode