From patchwork Thu Jan 19 10:37:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9525451 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 A1EEE601AE for ; Thu, 19 Jan 2017 10:38:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C0AB28496 for ; Thu, 19 Jan 2017 10:38:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 810032850D; Thu, 19 Jan 2017 10:38:09 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham 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 B1C9028500 for ; Thu, 19 Jan 2017 10:38:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751832AbdASKhy (ORCPT ); Thu, 19 Jan 2017 05:37:54 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:35642 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751903AbdASKhs (ORCPT ); Thu, 19 Jan 2017 05:37:48 -0500 Received: by mail-wm0-f47.google.com with SMTP id r126so283675249wmr.0 for ; Thu, 19 Jan 2017 02:37:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4MwFrA1m2rCFCokWEo0ZGTAb0UoDmd52FnYJwH0gQs8=; b=LYD9gDAP+QYiyPGe5vw3ISVh5rjt2XagSJf7Dssw19kj+ceNcQalspkX010k8c71mH NA8jZ82hdLZ/5uYBEzeCtUkK44+TlSaQuZFCCVJC/zimhYU0y9CGq2+TBBlm2NpGeARY EoMYDa43do6KeQ9XMlHtfQpV/QiNgYPDzMyj7F5R53IbC8WPIUd3BPZkU9eecIXIV6EF WtmP95r5LSRJjmbM+Bh6NAQJurS4cM0r45sX2wy40NG136GAdqHulCgfyZ0kkgMzAw9N 3JkJimcuZKNvAU0Lzog2OMj7uXeNXo2cKL1bV45p6xrnFY3CbNHmEGGTYu87qr++OkCC SKpA== 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; bh=4MwFrA1m2rCFCokWEo0ZGTAb0UoDmd52FnYJwH0gQs8=; b=UKraXb4NVn9vGjWjmAlaz7dD95EVLoVoKVnx0g8CYxUlCPI6Go+dqCSIosU2kLyCIt 9MRb+LpwiZySfYZxtSCvvXej1uxuYp6Gubq+kgha0P9M31MPyGZNmY4aYv/h5nTFQi9x kEZ9PHGR9AskxqhiCZZXEjNyKKIinmO1aPqmke8hnVQYsTKe0STS8Lw34VSFJvU7JsER Nu5WTTGoZEvQazxGulUM33QCIbX1Di2gtgvjX73sRR8mSIHrfHdagWDc1FY6Pe7itTpO 3U3VgU5rru/NhSnliPjV6ouf9ihiPFfgrAf2WLxphkhutRG8IR4FiDf9osZwT6zmVvIV 8xmA== X-Gm-Message-State: AIkVDXIzPFuJSDYV7uHRvrIFrTlbDiHF8mnxUXW+I4QrbEas6525jDgork5JJHJzIYCxZPm4 X-Received: by 10.223.166.137 with SMTP id t9mr6818821wrc.15.1484822233375; Thu, 19 Jan 2017 02:37:13 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id c81sm11850470wmf.22.2017.01.19.02.37.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 02:37:12 -0800 (PST) From: Alexandre Bailon To: vinod.koul@intel.com Cc: dmaengine@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, tony@atomide.com, linux-omap@vger.kernel.org, b-liu@ti.com, sergei.shtylyov@cogentembedded.com, grygorii.strashko@ti.com, linux-usb@vger.kernel.org, Alexandre Bailon Subject: [PATCH v3 4/4] dmaengine: cppi41: init_sched(): Get number of channels from DT Date: Thu, 19 Jan 2017 11:37:05 +0100 Message-Id: <20170119103705.13532-5-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170119103705.13532-1-abailon@baylibre.com> References: <20170119103705.13532-1-abailon@baylibre.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Despite the driver is already using DT to get the number of channels, init_sched() is using an hardcoded value to get it. Use DT to get the number of channels. Signed-off-by: Alexandre Bailon --- drivers/dma/cppi41.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 5a40653..9767b97 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -139,6 +139,8 @@ struct cppi41_dd { struct chan_queues td_queue; u16 first_completion_queue; u16 qmgr_num_pend; + u32 n_chans; + u8 platform; struct list_head pending; /* Pending queued transfers */ spinlock_t lock; /* Lock for pending list */ @@ -720,13 +722,8 @@ static int cppi41_add_chans(struct device *dev, struct cppi41_dd *cdd) { struct cppi41_channel *cchan; int i; - int ret; - u32 n_chans; + u32 n_chans = cdd->n_chans; - ret = of_property_read_u32(dev->of_node, "#dma-channels", - &n_chans); - if (ret) - return ret; /* * The channels can only be used as TX or as RX. So we add twice * that much dma channels because USB can only do RX or TX. @@ -832,7 +829,7 @@ static int init_descs(struct device *dev, struct cppi41_dd *cdd) return 0; } -static void init_sched(struct cppi41_dd *cdd) +static void init_sched(struct device *dev, struct cppi41_dd *cdd) { unsigned ch; unsigned word; @@ -840,7 +837,7 @@ static void init_sched(struct cppi41_dd *cdd) word = 0; cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL); - for (ch = 0; ch < 15 * 2; ch += 2) { + for (ch = 0; ch < cdd->n_chans; ch += 2) { reg = SCHED_ENTRY0_CHAN(ch); reg |= SCHED_ENTRY1_CHAN(ch) | SCHED_ENTRY1_IS_RX; @@ -850,7 +847,7 @@ static void init_sched(struct cppi41_dd *cdd) cppi_writel(reg, cdd->sched_mem + DMA_SCHED_WORD(word)); word++; } - reg = 15 * 2 * 2 - 1; + reg = cdd->n_chans * 2 - 1; reg |= DMA_SCHED_CTRL_EN; cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL); } @@ -874,7 +871,8 @@ static int init_cppi41(struct device *dev, struct cppi41_dd *cdd) goto err_td; cppi_writel(cdd->td_queue.submit, cdd->ctrl_mem + DMA_TDFDQ); - init_sched(cdd); + init_sched(dev, cdd); + return 0; err_td: deinit_cppi41(dev, cdd); @@ -1036,6 +1034,11 @@ static int cppi41_dma_probe(struct platform_device *pdev) cdd->qmgr_num_pend = glue_info->qmgr_num_pend; cdd->first_completion_queue = glue_info->first_completion_queue; + ret = of_property_read_u32(dev->of_node, + "#dma-channels", &cdd->n_chans); + if (ret) + goto err_get_n_chans; + ret = init_cppi41(dev, cdd); if (ret) goto err_init_cppi; @@ -1078,6 +1081,7 @@ static int cppi41_dma_probe(struct platform_device *pdev) deinit_cppi41(dev, cdd); err_init_cppi: pm_runtime_dont_use_autosuspend(dev); +err_get_n_chans: err_get_sync: pm_runtime_put_sync(dev); pm_runtime_disable(dev); @@ -1134,7 +1138,7 @@ static int __maybe_unused cppi41_resume(struct device *dev) if (!c->is_tx) cppi_writel(c->q_num, c->gcr_reg + RXHPCRA0); - init_sched(cdd); + init_sched(dev, cdd); cppi_writel(cdd->dma_tdfdq, cdd->ctrl_mem + DMA_TDFDQ); cppi_writel(cdd->scratch_phys, cdd->qmgr_mem + QMGR_LRAM0_BASE);