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: 10332471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CEF5160365 for ; Tue, 10 Apr 2018 07:47:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C66A028C99 for ; Tue, 10 Apr 2018 07:47:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAB7128CA6; Tue, 10 Apr 2018 07:47:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4928428C9C for ; Tue, 10 Apr 2018 07:47:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752487AbeDJHrD (ORCPT ); Tue, 10 Apr 2018 03:47:03 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:40666 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751825AbeDJHqr (ORCPT ); Tue, 10 Apr 2018 03:46:47 -0400 Received: by mail-pf0-f195.google.com with SMTP id y66so7583292pfi.7 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=fzlS5G3VPW2mpkaN5ifTqgbJs8+w4eS5l6vQ3RghUzSGq3eOwKVQioOSQPhaQKI+10 OKsiFyBupD0er1Ggctrcszp0fbswanqyobT47uyqrMNbiBLxC/sUsxppGgrXBENPIZkP 5wknUvPy/8xxLiI14KMXxgkASiHT44RKX+x19hF9BxEw133vw+h3hTPl5YU5jfLnbU6p 8vnv0gQ73NI95ntUus6Y8q3WjcPXmA5r3REMc8feu7aV4+VPLWus6AK260/WcUdbcT8l vICzF/g6Ri+mJ1hvUgsGgv6O4cHQIggL9hw9Ox+OOtuLb/f4k8YwIG6EVCgrhkctax8b tZtQ== X-Gm-Message-State: ALQs6tDTqX154UxY+/7ySRDop+hK7fWpxJxZLDq1zqnrS/xrHOqoIMSu TMo3VGXzRAQHJ8vjxwS58XzkGA== X-Google-Smtp-Source: AIpwx48PWxDZyyORE8HoE+oQeAfTp/rFEkNju894M5Dl657NqNLzbKmpw3H3IoziHZ0Il9Lm3q+xVw== 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: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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;