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;