From patchwork Tue Apr 10 07:46:03 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: 133058 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1029179ljb; Tue, 10 Apr 2018 00:46:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx49yhCXjqZdNwXuVGvmAg/s/yq7yaGTFAcsM29gWVgJXooxlaR4nf0t7IMiOzx13JFg1HLfB X-Received: by 10.99.191.12 with SMTP id v12mr5001099pgf.54.1523346402657; Tue, 10 Apr 2018 00:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523346402; cv=none; d=google.com; s=arc-20160816; b=LWTvOiv2BoaRmX5ePYCCK1zkxfIMgOtgfvZkRIXZs9jMrBjQyCks14zG0fRI3R/4Y3 DAOOyVsPHLEr49sDeTx7GWsGGP6SEXjmNIwX3vCzKyUFZsFUrh4PEbKgoVT3FRwScfgi LQ6VMg+qe2S1sDpM6NurAN56NtmmwWsVxF5aXYrcc+sJFon1u2F+nE6iWBjgFIJpjrO6 V1/XbURr50gAeA0RK5g/T6QtsoLiC1q2MRRrwEsQZHoYet8MKx5xjazfoLGOrqLUxFIm ZZs/e8EZx+2JOD6sTpXROZxpY/mzUA1Wky538uPmcfBuGkWcLVsFQ3O0CfKUsNSRc/NE ejLA== 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=w79L65rOvc47yyfbyc4jTlWwancETpryqzoDL61LG5I=; b=N69tI4CktEpK2UlgLTYpTeNIvJ+p31duoDoLmuDK05iFhAZ49DN5r71dUEYLkhFpF1 D6Q+W/KmdF/ntV2aKiKKUf0FXfLQy2b0oKIyKk8RodbnFhN/U0KH5xo6+Jbs+KodV7UW Hh1hrjqlSeN71hvseb64hscy8hNdCpNQw+9SA4pD16VY6IJAnbiNYQtyQDXf5ddUO3UE uA2ZnSzhD1SvihOmluJHAbFg6S5h4V/Pyrr1zDHqU4HmO5D7uIADdlqs8HkiDh8BNM3Q VDbrStQSISx03nB8MiOczu+A5BdpVs3kDidQT8ZeQ7j3WtUt8e7j1294TL5RfSMyDuOm bFKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kwCammK4; 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 e9-v6si2096314pln.439.2018.04.10.00.46.42; Tue, 10 Apr 2018 00:46: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=kwCammK4; 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 S1752394AbeDJHqj (ORCPT + 29 others); Tue, 10 Apr 2018 03:46:39 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:41202 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751978AbeDJHqi (ORCPT ); Tue, 10 Apr 2018 03:46:38 -0400 Received: by mail-pl0-f67.google.com with SMTP id bj1-v6so6918578plb.8 for ; Tue, 10 Apr 2018 00:46:38 -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=w79L65rOvc47yyfbyc4jTlWwancETpryqzoDL61LG5I=; b=kwCammK4xErXLwGBnbi29QSbBL+gPVr01Nn4SJGBRyL7sYrVa8JT3GJrIUjIWKflJ8 NzIWGq2bC1sXTCvs3r+d1LBbDuIruE9PWaV9B5KDnO42WPlgB82XpxuEoc+75NVrG6dB /cJPgx4Cxd0LpUv1S7dfZzEPPUaFAtku7RTdk= 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=w79L65rOvc47yyfbyc4jTlWwancETpryqzoDL61LG5I=; b=Z+HHou2PmgAT1PArQsgtUpotHQy+vO2y/+Fqy9v5nDGw4mluefDjdawVQ71bMTj7Hy gJBK8S6QF9ruH1pLYzfI+mxDF6bW1TELGXeWILYmk3xHsQcA/S38OzznQ+IayGTILQFY U2LITB44S0xQRgakXZk8nsLadjDCERD/7sCU9bJBgle0uKO/+C+WyoFALMpYgni2oGUs kw7JntXxziKN9Qxdv54gwW9hcIxlh2GFHNSOlW+gUZRPYLb7FMVMriWFh6VfjvRG4cBv iZHG9SRffbyBVnZ/v+lV8/9tGyz0tfORoIGzrdM1kccgYO09K9VRMtiiFQVlOMTbx1Mk MOoQ== X-Gm-Message-State: AElRT7Frkt/d9mok+u+tpZvyTxS8JyIjDrIVJo7TB3G1VqDaoVFmGfdH vxtKl8vcy1sb0NDa1UrrNl615w== X-Received: by 2002:a17:902:a981:: with SMTP id bh1-v6mr43196413plb.255.1523346397860; Tue, 10 Apr 2018 00:46:37 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id x17sm3095279pfm.161.2018.04.10.00.46.35 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 00:46:37 -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 1/5] dmaengine: sprd: Define the DMA transfer step type Date: Tue, 10 Apr 2018 15:46:03 +0800 Message-Id: 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 --- drivers/dma/sprd-dma.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index b106e8a..af9c156 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -169,6 +169,22 @@ enum sprd_dma_int_type { SPRD_DMA_CFGERR_INT, }; +/* + * enum sprd_dma_step: define the DMA transfer step type + * @SPRD_DMA_NONE_STEP: transfer do not need step + * @SPRD_DMA_BYTE_STEP: transfer step is one byte + * @SPRD_DMA_SHORT_STEP: transfer step is two bytes + * @SPRD_DMA_WORD_STEP: transfer step is one word + * @SPRD_DMA_DWORD_STEP: transfer step is double word + */ +enum sprd_dma_step { + SPRD_DMA_NONE_STEP, + SPRD_DMA_BYTE_STEP = BIT(0), + SPRD_DMA_SHORT_STEP = BIT(1), + SPRD_DMA_WORD_STEP = BIT(2), + SPRD_DMA_DWORD_STEP = BIT(3), +}; + /* dma channel hardware configuration */ struct sprd_dma_chn_hw { u32 pause; @@ -598,16 +614,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 Tue Apr 10 07:46:04 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: 133059 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1029240ljb; Tue, 10 Apr 2018 00:46:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+RaPsJPSO7fLTSS0cpFFVV2ZqfgD4cmh9IErY4WV9PGf9G/ud3grH7R0byCkA92K8PcfdP X-Received: by 2002:a17:902:8e86:: with SMTP id bg6-v6mr41692330plb.91.1523346408227; Tue, 10 Apr 2018 00:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523346408; cv=none; d=google.com; s=arc-20160816; b=s7NEqPp7B00vLRcTRt4fR27pyGHA/E7rE3JyAHEGJWuvn8SPaVWKUnBD7NX443+LhJ bekVfOj2IQlPj6g5y/4V4tchWXSJOQgEI8jjvf2aotonsi8DL3UoAMy0LOGqppTOoSru JmzpE4s4wJgloWF4a51+KyNGq8lo2fuOYWI4vrnF94UuVnA0o6p7uj8g/RchGwbjIPme sHPHYBPT+2UCRA+fK02AqO88Zz0Vmcv2hS1UKmqXRK4twgqCRWntk6xlxbo8tKm4z876 dNKFYJmdmzt2eQQrWvaMg5y3Ox5JUzOzXtNuc88H2r7Tn4Mr/tWF2G92gmHliiMigTkP bnIw== 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=/B8Z7SuimBAoytmzIiPGRvRsxqNt+/JUJOGQdhegUFc=; b=c/UmY8gTPMkGxxaJLZQWY4GcYTP8c1sRAtmmK+lcG0pVT2V/gVK3qlL6Mk95qEQ6/J diFLG2/eaADy3sHMab7UYgfOJbCdnlIvLRXAZWnR/joCZBkvtm5OqB7KURFNaWdhjU4a ld22FW5EdMTqR2nkTqvj7lPnJjOsWAD5Y21/2Y0tJOVCBFxsjmPbwOaNuEqkRpoZ6rp4 MeYsLw5h1uTwOUiHOvweRMXZRE58J7m8d4NDJOzl8OfxVBcCQGamI95kRmDF+l7+rapa 6hMNZYMTF3/Ai8ullR+IGgEN/Ng6V2mWkGi4YgdUQIxyCwySSmNNvbCL6lFnbIgbtIFa RZ6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TaPV+Lik; 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 v61-v6si2145484plb.297.2018.04.10.00.46.47; Tue, 10 Apr 2018 00:46:48 -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=TaPV+Lik; 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 S1752438AbeDJHqp (ORCPT + 29 others); Tue, 10 Apr 2018 03:46:45 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:46287 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751978AbeDJHql (ORCPT ); Tue, 10 Apr 2018 03:46:41 -0400 Received: by mail-pl0-f65.google.com with SMTP id 59-v6so6914379plc.13 for ; Tue, 10 Apr 2018 00:46:40 -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=/B8Z7SuimBAoytmzIiPGRvRsxqNt+/JUJOGQdhegUFc=; b=TaPV+LikTjFdN+I3sWqvkF/wUghvMbDc3Dr48VKXryg8bDSDpYN+IgB76BYlNZCeTA +cd6pMDbmUq+ttz8+Bg0t4nLPHAD1iVo/Jtbgt2qB3GTlvsefCrRezWnGTi8Zm0xPY3G TID73zgAREdaS5UaeW3vJ8EUOnU4OorM1Os78= 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=/B8Z7SuimBAoytmzIiPGRvRsxqNt+/JUJOGQdhegUFc=; b=nMJu6OsYkLKBByxW16g55vqxkGfN36KOZhSgUY+I1eyVWk9d1HbS+8c9Xlk6KmXaaU qlvVJ64mHnfYoG2AgmakHwDW49JW5ThF1xcpnceb6bvJapXwtR9DO5qy/ZHVSmQK8Oay muPof2mGFsu46AG6MWxo38u38b7GTfglOSPzmD29Idm5j9550NHY0l4qAS2j7NPO5zJI 7k2VskDSgXJvRgjjdBjkor+vagsgyRVyKdOC72A19hnTJqVjJqXjRXC7vV5GGxe5JNZh Uz37PbKN60sH0NxPy2y1iE7Zt8dPDc7PvXlWAT2Rgnwumf305+UjO+IzjRyESa9lEiKO JmAA== X-Gm-Message-State: AElRT7F7BdiIOC9CF9J+zsn3wOnnnVzXjdUtvKNBk6+/RUb9ko76MmZl jU6JmNaq6khPl9XHfJEu9f2/Rw== X-Received: by 2002:a17:902:9a82:: with SMTP id w2-v6mr41624451plp.6.1523346400359; Tue, 10 Apr 2018 00:46:40 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id x17sm3095279pfm.161.2018.04.10.00.46.38 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 00:46:39 -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 2/5] dmaengine: sprd: Define the DMA data width type Date: Tue, 10 Apr 2018 15:46:04 +0800 Message-Id: <695931ac827adb5b2c5a7939341ff61ba00af1a1.1523346135.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: 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 --- 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 af9c156..9f44d6f 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -185,6 +185,14 @@ enum sprd_dma_step { SPRD_DMA_DWORD_STEP = BIT(3), }; +/* 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; @@ -613,15 +621,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 Tue Apr 10 07:46:05 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: 133062 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1029815ljb; Tue, 10 Apr 2018 00:47:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/DdK2X0hi0Hcs6NF5xafnSEJCAHER9p36rSVNX4cLVu7CUYXrWOI5E+d6xQjs/UqZDQnGZ X-Received: by 10.99.173.7 with SMTP id g7mr27118644pgf.170.1523346459901; Tue, 10 Apr 2018 00:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523346459; cv=none; d=google.com; s=arc-20160816; b=YmrEwe/GiXD4Dr7XdxMq9CAt8jrjG6bA3cJAwDEOBlrlxqWyeFX/GSj1aPbLQQtq25 Z8h5RacndcLOtwBZrJY5eo2QDrujKiQO3rq7YyYoLUxdZY9IbyZVQdv7NKY+Egm5P3iM jI7dO7BtpWtrguO3v/3CdcHaw96/s8cJMN7iL0N45xsmLNN00Bln4vEltIWGNh7D7BpP I/A10e0kAwQPVeRyF9FXzhbs2WhMUQHfjkE6ENwAHIyAaewbDT5xXzZSDHEKgG1LdAOz uMx0cN5r04NWSqNN0ju1vUscyhD5ESzXfMTOh73e8jkMh2wOTzv8dAp8hFNSc0FbnN/C lckA== 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=FYYz8O2A6U899g1YhvxbY4bR2BkFwQSs2Y3MeaWDAWc=; b=ftHJuxRd1uRCCQXYsMh63GRHIIxL4HYmUlT98V83tYkGfC7/y4koFmgL1HyPXmYlM5 8R9pNnsHwOcIrFAA8bdtVc1c1GPJurAgf2KiI9QSkyRti3yXiYtxqZzEdCMFhoFcwGIf tLtjUX+rmkbgVc0A4l+RraBE27gpJaP8gO111ItkmH9y6DG8qUvlouGcsEzwZksIrfJR J/q8Mj0jJCa9+5A3D/hfuB7Z6agIJwFDZ+tw3TB0EOLlb8nO9Zx/B8sS2IYgTkQSUHUn NaCH3kAacSl+Er/0fwtuopd2h1mCPOdOVv8PKWTKl6QcgHa41pRW0UdpzpJzDsf0ig02 7xzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b+Ab1a2M; 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 s4si1651008pfe.252.2018.04.10.00.47.39; Tue, 10 Apr 2018 00:47:39 -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=b+Ab1a2M; 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 S1752576AbeDJHrg (ORCPT + 29 others); Tue, 10 Apr 2018 03:47:36 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:40730 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752406AbeDJHqn (ORCPT ); Tue, 10 Apr 2018 03:46:43 -0400 Received: by mail-pl0-f66.google.com with SMTP id x4-v6so6929607pln.7 for ; Tue, 10 Apr 2018 00:46:43 -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=FYYz8O2A6U899g1YhvxbY4bR2BkFwQSs2Y3MeaWDAWc=; b=b+Ab1a2MBe3ifgmwfSrNzMaO0nDuDIzI9/pfx2U9HDr8salxBFLR8o0hyiKOxuJnqr hSSjGuhuzc7EU+h25gS/TL9tywp1ulc7R6kMrSpjAm8TlDRwrzhfimFaajcRv7HvcWp/ GJ8VEQ1AxP8o2xZtpa9dmwzpstKI3G464cYdI= 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=FYYz8O2A6U899g1YhvxbY4bR2BkFwQSs2Y3MeaWDAWc=; b=gVd9aXGYd6jO2C7/yJM5xrM378lYEAALvVIyDhTj9h+S7fpXvI56iyvLCSVfMMgwoo d7Z04N8J7TzHMC9jaKlg05uiG7hhdaUO+2MQ9w1YLhsmKyNQD52coP8SWGMHDsJ58SvD ooT9mjxXCB7/c0dQYCqYMvZYISOXaGhs7F+sz7CJM+vf7N5gLdOZGHhSdua1FEpfZTQa STAKc6J/iVpDrxJvVRK1ZirGW6Xx/0zV17jYzZbsFrKqsnL8f9PxZ9FBtlQyEyWOVDGP KQ2L3E19/zsiw0N/Nupb5NAtX1fV7P1crrwjr8aJwOJyONIkRGuHp7Y7kjrYlT9NslRF NN7Q== X-Gm-Message-State: AElRT7HBZwM2J3YhgqDKM1RQQgxndh7X0PrOj5HUjphWPmqKA2kcaZHM tK6h9vp4ZedmBvXhrVzywHVjtep5BpY= X-Received: by 2002:a17:902:341:: with SMTP id 59-v6mr40933652pld.407.1523346402711; Tue, 10 Apr 2018 00:46:42 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id x17sm3095279pfm.161.2018.04.10.00.46.40 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 00:46:42 -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 3/5] dmaengine: sprd: Move DMA request mode and interrupt type into head file Date: Tue, 10 Apr 2018 15:46:05 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: 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. And other special SPRD DMA configurations will be added in the following patches. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- 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 9f44d6f..5c26fde 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -119,57 +120,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, -}; - -/* * enum sprd_dma_step: define the DMA transfer step type * @SPRD_DMA_NONE_STEP: transfer do not need step * @SPRD_DMA_BYTE_STEP: transfer step is one 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 Tue Apr 10 07:46:06 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: 133060 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1029267ljb; Tue, 10 Apr 2018 00:46:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx493TYu6tl+g46t5W9LOFg/1OlcFz7mUf+tUJ+KR42q9esbr43NcOSk5MJLUNB8oq2T8zwxn X-Received: by 2002:a17:902:b28:: with SMTP id 37-v6mr41547186plq.207.1523346411871; Tue, 10 Apr 2018 00:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523346411; cv=none; d=google.com; s=arc-20160816; b=JUqi1/nnCjjkAd3H5kAoJjx1ChFRHSZgN1tD9GKqTHLOJrPvsRCIclosU6VA3WBCi7 sP7cXvJoKQDpJsi1I63mkctKnLB5NGUivRKcCA5/hhfV6upAW2iF/GKBm9hUC2ODkqHi 3D68PmxLO9+VddtBPS5XfxNiLEF68Zx3rsrsiWQKcVL+XlnPTgveRHZss82HqbaZ/wH3 1DtiCmUfx7P1luFJZPAoahz0qhs5kCxB4CrXi0f3NsqNPiU5YYHejE1elPaPRM8GubJ3 dvZf0ts7B01k+c38ghxFU0orvybnAcTIyiQXnRgC/8hpIE4CzkFy9A8GaL130M0aMbRD g/Cw== 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=AxRAhk8yiRD4McquXt/HHBFBztcPYEiSDpYIBo0Z7ao=; b=04i3oThRqdpGLWIPUvmnZ96TVH01LCVbXVe9Wo3EsuxmySoSUV1kzfl488QmhzlT1n TVEvgCbvO5HbZ9aTqTsOfNW/EksVa7tNPL0HWrF7vupCFqiItmoJm6p4bK3/X712II3l Msv414s4E0agthIBtjGSHfZptfMoYAvrd4KR75TQ6NeYBEH3L6b3hJc64BygS8FKPgIO TdZyJRY4vd0p3lR5yXLco/pVw0/1ImcyXdqFCockEApEj4P82VTyqp5xCHqgr25iUT5R bL5lEEZ5VHPi9WfWvDIv9bHTWjO34xdaTez1hrO0LQFT+iRLob9cnHAEBg2g8OAhjCea m+zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hcx1M/4f; 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 v61-v6si2145484plb.297.2018.04.10.00.46.51; Tue, 10 Apr 2018 00:46: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=hcx1M/4f; 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 S1752482AbeDJHqt (ORCPT + 29 others); Tue, 10 Apr 2018 03:46:49 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36269 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751978AbeDJHqp (ORCPT ); Tue, 10 Apr 2018 03:46:45 -0400 Received: by mail-pf0-f196.google.com with SMTP id g14so7581656pfh.3 for ; Tue, 10 Apr 2018 00:46:45 -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=AxRAhk8yiRD4McquXt/HHBFBztcPYEiSDpYIBo0Z7ao=; b=hcx1M/4flbZNAjylrVcmQ/nenlwfxD6qK29a5pjHEl3CPx6cTOISFEKnz+ILd9xnMp vyvYsqbnSPESIrmOu6nao0B9hPFNZmAxbeJL/WOfjAb79IMpqkvN3VZwvf5WN9Oyfptk ZVs9bBfbl9givdYRu3XzOUMQPq1mLacfWGstw= 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=AxRAhk8yiRD4McquXt/HHBFBztcPYEiSDpYIBo0Z7ao=; b=KNgs2TC4UtiLkthDTFPNF0Q5CK5KYS9S9mLiCdKy8QHY1rtXWmjHsfTXHhGGBu4IXs YM+PImlmaiBfDZyI/Zg/VJEgsn3m576txq+ZO0xviK4NX+tge2U45VFMESoXsx/ectNO azsjvJbWkR5wBU+3k1ShYXs6mjRZ6qM3BV+piKSMilJuX+MToYc9BrdLjOBjo9oIhmb2 L7bA0KeIoyrS71OXaBzEBGM4MjFHMhQ/Pe9FcJZC+3WM1R8qa4azTlkVKfwndED9J8yC ARcTbwhOBoYnq1XnUF6liq5kypK6RbD2A/o3ROCN+oNswW6P4WLRymqAzfqdfVICmMPq FESg== X-Gm-Message-State: AElRT7GLaWw8BCH+HxhrVGelxRIfV8exNvv13hS9QaGS4griUgBuvQ6k KqIZ0rdy9df0xF9utUAmgVMSUQ== X-Received: by 10.99.174.67 with SMTP id e3mr27408839pgp.139.1523346405170; Tue, 10 Apr 2018 00:46:45 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id x17sm3095279pfm.161.2018.04.10.00.46.42 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 00:46:44 -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 4/5] dmaengine: sprd: Add Spreadtrum DMA configuration Date: Tue, 10 Apr 2018 15:46:06 +0800 Message-Id: <0c2b76aba6a49e583f920ae582d6815fa9cc4361.1523346135.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are some Spreadtrum special configuration for DMA controller, thus this patch adds one 'struct sprd_dma_config' structure for users to configure. Moreover this patch 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 --- drivers/dma/sprd-dma.c | 262 ++++++++++++++++++++++++++++++++++-------- include/linux/dma/sprd-dma.h | 25 ++++ 2 files changed, 238 insertions(+), 49 deletions(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 5c26fde..f8038de 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 @@ -173,6 +175,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; @@ -561,52 +564,162 @@ 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 int sprd_dma_get_step(enum dma_slave_buswidth buswidth, + enum dma_transfer_direction dir, + enum sprd_dma_step *src_step, + enum sprd_dma_step *dst_step) +{ + switch (dir) { + case DMA_MEM_TO_MEM: + switch (buswidth) { + case DMA_SLAVE_BUSWIDTH_1_BYTE: + *src_step = SPRD_DMA_BYTE_STEP; + *dst_step = SPRD_DMA_BYTE_STEP; + break; + + case DMA_SLAVE_BUSWIDTH_2_BYTES: + *src_step = SPRD_DMA_SHORT_STEP; + *dst_step = SPRD_DMA_SHORT_STEP; + break; + + case DMA_SLAVE_BUSWIDTH_4_BYTES: + *src_step = SPRD_DMA_WORD_STEP; + *dst_step = SPRD_DMA_WORD_STEP; + break; + + case DMA_SLAVE_BUSWIDTH_8_BYTES: + *src_step = SPRD_DMA_DWORD_STEP; + *dst_step = SPRD_DMA_DWORD_STEP; + break; + + default: + *src_step = SPRD_DMA_WORD_STEP; + *dst_step = SPRD_DMA_WORD_STEP; + break; + } + break; + + case DMA_MEM_TO_DEV: + switch (buswidth) { + case DMA_SLAVE_BUSWIDTH_1_BYTE: + *src_step = SPRD_DMA_BYTE_STEP; + break; + + case DMA_SLAVE_BUSWIDTH_2_BYTES: + *src_step = SPRD_DMA_SHORT_STEP; + break; + + case DMA_SLAVE_BUSWIDTH_4_BYTES: + *src_step = SPRD_DMA_WORD_STEP; + break; + + case DMA_SLAVE_BUSWIDTH_8_BYTES: + *src_step = SPRD_DMA_DWORD_STEP; + break; + + default: + *src_step = SPRD_DMA_WORD_STEP; + break; + } + + *dst_step = SPRD_DMA_NONE_STEP; + break; + + case DMA_DEV_TO_MEM: + switch (buswidth) { + case DMA_SLAVE_BUSWIDTH_1_BYTE: + *dst_step = SPRD_DMA_BYTE_STEP; + break; + + case DMA_SLAVE_BUSWIDTH_2_BYTES: + *dst_step = SPRD_DMA_SHORT_STEP; + break; + + case DMA_SLAVE_BUSWIDTH_4_BYTES: + *dst_step = SPRD_DMA_WORD_STEP; + break; + + case DMA_SLAVE_BUSWIDTH_8_BYTES: + *dst_step = SPRD_DMA_DWORD_STEP; + break; + + default: + *dst_step = SPRD_DMA_WORD_STEP; + break; + } + + *src_step = SPRD_DMA_NONE_STEP; + break; + + case DMA_DEV_TO_DEV: + *src_step = SPRD_DMA_NONE_STEP; + *dst_step = SPRD_DMA_NONE_STEP; + break; + + default: + return -EINVAL; + } + + return 0; +} + 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; + u32 fix_mode = 0, fix_en = 0, wrap_en = 0, wrap_mode = 0; + enum sprd_dma_step src_step, dst_step; + enum sprd_dma_datawidth src_datawidth, dst_datawidth; + int ret; - 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; + ret = sprd_dma_get_step(slave_cfg->config.src_addr_width, + slave_cfg->config.direction, + &src_step, &dst_step); + if (ret) { + dev_err(sdev->dma_dev.dev, "invalid step values\n"); + return ret; } - 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->config.slave_id) + schan->dev_id = slave_cfg->config.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->config.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->config.dst_addr >> SPRD_DMA_HIGH_ADDR_OFFSET) & + SPRD_DMA_HIGH_ADDR_MASK)); + + hw->src_addr = + (u32)(slave_cfg->config.src_addr & SPRD_DMA_LOW_ADDR_MASK); + hw->des_addr = + (u32)(slave_cfg->config.dst_addr & SPRD_DMA_LOW_ADDR_MASK); + + if ((src_step != 0 && dst_step != 0) || (src_step | dst_step) == 0) { fix_en = 0; } else { fix_en = 1; @@ -616,17 +729,37 @@ static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, 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 | + if (slave_cfg->wrap_ptr && slave_cfg->wrap_to) { + wrap_en = 1; + if (slave_cfg->wrap_to == slave_cfg->config.src_addr) { + wrap_mode = 0; + } else if (slave_cfg->wrap_to == slave_cfg->config.dst_addr) { + wrap_mode = 1; + } else { + dev_err(sdev->dma_dev.dev, "invalid wrap mode\n"); + return -EINVAL; + } + } + + src_datawidth = + sprd_dma_get_datawidth(slave_cfg->config.src_addr_width); + dst_datawidth = + sprd_dma_get_datawidth(slave_cfg->config.dst_addr_width); + + hw->frg_len = src_datawidth << SPRD_DMA_SRC_DATAWIDTH_OFFSET | + 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 | - (fragment_len & SPRD_DMA_FRG_LEN_MASK); - hw->blk_len = block_len & SPRD_DMA_BLK_LEN_MASK; + (slave_cfg->fragment_len & SPRD_DMA_FRG_LEN_MASK); + + hw->blk_len = slave_cfg->block_len & SPRD_DMA_BLK_LEN_MASK; hw->intc = SPRD_DMA_CFG_ERR_INT_EN; - switch (irq_mode) { + switch (slave_cfg->int_mode) { case SPRD_DMA_NO_INT: break; @@ -667,12 +800,13 @@ static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, return -EINVAL; } - if (transcation_len == 0) - hw->trsc_len = block_len & SPRD_DMA_TRSC_LEN_MASK; + if (slave_cfg->transcation_len == 0) + hw->trsc_len = slave_cfg->block_len & SPRD_DMA_TRSC_LEN_MASK; else - hw->trsc_len = transcation_len & SPRD_DMA_TRSC_LEN_MASK; + hw->trsc_len = + slave_cfg->transcation_len & SPRD_DMA_TRSC_LEN_MASK; - hw->trsf_step = (des_step & SPRD_DMA_TRSF_STEP_MASK) << + hw->trsf_step = (dst_step & SPRD_DMA_TRSF_STEP_MASK) << SPRD_DMA_DEST_TRSF_STEP_OFFSET | (src_step & SPRD_DMA_TRSF_STEP_MASK) << SPRD_DMA_SRC_TRSF_STEP_OFFSET; @@ -680,7 +814,6 @@ static int sprd_dma_config(struct dma_chan *chan, struct sprd_dma_desc *sdesc, hw->frg_step = 0; hw->src_blk_step = 0; hw->des_blk_step = 0; - hw->src_blk_step = 0; return 0; } @@ -689,6 +822,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; @@ -696,7 +830,37 @@ 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->config.src_addr = src; + slave_cfg->config.dst_addr = dest; + slave_cfg->config.direction = DMA_MEM_TO_MEM; + + if (IS_ALIGNED(len, 4)) { + slave_cfg->config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + slave_cfg->config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + } else if (IS_ALIGNED(len, 2)) { + slave_cfg->config.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; + slave_cfg->config.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; + } else { + slave_cfg->config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + slave_cfg->config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + } + + slave_cfg->fragment_len = SPRD_DMA_MEMCPY_MIN_SIZE; + if (len <= SPRD_DMA_BLK_LEN_MASK) { + slave_cfg->block_len = len; + slave_cfg->transcation_len = 0; + slave_cfg->req_mode = SPRD_DMA_BLK_REQ; + slave_cfg->int_mode = SPRD_DMA_BLK_INT; + } else { + slave_cfg->block_len = SPRD_DMA_MEMCPY_MIN_SIZE; + slave_cfg->transcation_len = len; + slave_cfg->req_mode = SPRD_DMA_TRANS_REQ; + slave_cfg->int_mode = SPRD_DMA_TRANS_INT; + } + + ret = sprd_dma_config(chan, sdesc, slave_cfg); if (ret) { kfree(sdesc); return NULL; diff --git a/include/linux/dma/sprd-dma.h b/include/linux/dma/sprd-dma.h index c545162..8bda7d7 100644 --- a/include/linux/dma/sprd-dma.h +++ b/include/linux/dma/sprd-dma.h @@ -3,6 +3,8 @@ #ifndef _SPRD_DMA_H_ #define _SPRD_DMA_H_ +#include + /* * enum sprd_dma_req_mode: define the DMA request mode * @SPRD_DMA_FRAG_REQ: fragment request mode @@ -54,4 +56,27 @@ enum sprd_dma_int_type { SPRD_DMA_CFGERR_INT, }; +/* + * struct sprd_dma_config - DMA configuration structure + * @config: dma slave channel config + * @fragment_len: specify one fragment transfer length + * @block_len: specify one block transfer length + * @transcation_len: specify one transcation transfer length + * @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 + */ +struct sprd_dma_config { + struct dma_slave_config config; + u32 fragment_len; + u32 block_len; + u32 transcation_len; + phys_addr_t wrap_ptr; + phys_addr_t wrap_to; + enum sprd_dma_req_mode req_mode; + enum sprd_dma_int_type int_mode; +}; + #endif From patchwork Tue Apr 10 07:46:07 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: 133061 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1029483ljb; Tue, 10 Apr 2018 00:47:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+LkdBgeUwxdS1w1UJRcb6K9I7nZSJauPpZLdoAEypMa7UF2E93cCSvUgF/5TSxR5gjvEzb X-Received: by 10.99.127.80 with SMTP id p16mr12293194pgn.326.1523346430369; Tue, 10 Apr 2018 00:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523346430; cv=none; d=google.com; s=arc-20160816; b=JCdpWwQtWWTCfzBwuGUShxD1WpZn938BeKFcJLKWNgQfAggvYiFQ/ebiNbg+OZxm9a 5UFKmYLIuGFnzWbLEneszwrnkZ+mJLn/A9X5rKxndu3IDcWUY0OLn7CCI8m1bM/tevVs EJwiXqzpZhGwcjWnPuyz/kIkzs9b2m4A3o01YTklqw4Mj/50OKOr5Ep4ZqSQTYtxQ2zt +WQhmyRV5eQrxiKZ5RyA32ZFZaHhb1p3Q42wftXpZTETHnyWJNg1PKTcqyZSB6ePPK9H LRVp4ra8rwHBkjpb1aUeq1wFxJjsOkPAj6qu4HHVbZlRsZzn9+Ylrj/wdtJRb6Cur4AZ cg9Q== 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=syrD9BTlMcWs8JRyoH9ISAuckniMkpKO45CIjIeq0TU=; b=x7qquEpEzEAfyYMQwSaGfLxsyfWU2+Kl71a5g2QM9bwWToOj06LCPnzj07Gzj5KgYG b0+lgRLpJ82ct1hMMcNlHKdOrxpO1Tftxn7IMwImzI45fb5REtBnp1mURVbr7QmsGpN+ PXzFFBq+3rwr/Uhuh1Fg58DLyqmin1iiDpADZwR4rYY/fXDJl90CJKqpW1Vop3Fv/iny 9FUdTBdlAXQp4oNYLbqtQwSPm+A7nUGd8EcZHnQ7Lmj0IQmNYmi69ZvBomMwQlAF6EGR WCL0n5tzyE/MzU3Rp9zr94UUrrQaTZaQSyK5MpRMef8Ysmc6n/EtDvq6yher751HbfyE yR7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CpUqyaMI; 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 bg7-v6si2214964plb.537.2018.04.10.00.47.10; Tue, 10 Apr 2018 00:47:10 -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=CpUqyaMI; 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 S1752517AbeDJHrE (ORCPT + 29 others); Tue, 10 Apr 2018 03:47:04 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:37613 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbeDJHqr (ORCPT ); Tue, 10 Apr 2018 03:46:47 -0400 Received: by mail-pf0-f196.google.com with SMTP id p6so4023129pfn.4 for ; Tue, 10 Apr 2018 00:46:47 -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=syrD9BTlMcWs8JRyoH9ISAuckniMkpKO45CIjIeq0TU=; b=CpUqyaMIaJJwuBsv+DimwUMKihelKcnrB3GnuYqqtBAZbQshjxy39l07JKbnGBur6A JR0PVFeFfZ4vSaat88dKIkuqeQYFjwr7AXnGNvePTHMGjnO7mmFajRvucafSZplMlzN7 QGYAsn2zECwhRCjqeTMAvfucRJpbsMl2wspuU= 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=syrD9BTlMcWs8JRyoH9ISAuckniMkpKO45CIjIeq0TU=; b=D2aGy1JL2wUw4jX/lKZ3SpXEtvBESrztfxA1Wm0/FxPONmXuRpeRGaJE50Iawi2RRd arypKaBcOAtMr16J9YySDu6ZumL+Q3tdgTiVIG9V8NpYlLz8Z3U/KnCBMjTyZW8A38nO dKtUh1ddspxsoHL+WseLTW/X1t9tyhbk56kH7332sVw6QMi7uU+uUMU+Naod+sg7U4UF LwrYd5/B48+ouA9gY+SF5oetT89AW01hbLW6wzMxKbkzeI8YlsBEbYcE+HVpJaPFV4aC egEFgajDLl1SNEzFH1YMdazsTxMUH0jtcdLoBRiyf9foSO6kJZbo0yvL1BCxrXsW/dQY lDeA== X-Gm-Message-State: ALQs6tAmiAv+wpH2tuidYnWjuGhAj2BEEtg4xAYCd336OA090X+MX+ye SuWksTZnkA9sI3WTMAiIvo/Nnw== X-Received: by 10.98.133.139 with SMTP id m11mr1837734pfk.49.1523346407380; Tue, 10 Apr 2018 00:46:47 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id x17sm3095279pfm.161.2018.04.10.00.46.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 00:46:46 -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 5/5] dmaengine: sprd: Add 'device_config' and 'device_prep_slave_sg' interfaces Date: Tue, 10 Apr 2018 15:46:07 +0800 Message-Id: <0a9fa618bd74e74c135ebee2e40b30d361c1d905.1523346135.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds the 'device_config' and 'device_prep_slave_sg' interfaces for users to configure DMA. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index f8038de..c923fb0 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -869,6 +869,52 @@ 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(slave_cfg->config.direction) || sglen > 1) + return NULL; + + sdesc = kzalloc(sizeof(*sdesc), GFP_NOWAIT); + if (!sdesc) + return NULL; + + for_each_sg(sgl, sg, sglen, i) { + if (slave_cfg->config.direction == DMA_MEM_TO_DEV) + slave_cfg->config.src_addr = sg_dma_address(sg); + else + slave_cfg->config.dst_addr = sg_dma_address(sg); + } + + 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 = + container_of(config, struct sprd_dma_config, config); + + memcpy(&schan->slave_cfg, slave_cfg, sizeof(*slave_cfg)); + return 0; +} + static int sprd_dma_pause(struct dma_chan *chan) { struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); @@ -996,6 +1042,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;