From patchwork Tue Jan 17 13:45:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 91653 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp498752qgi; Tue, 17 Jan 2017 05:53:05 -0800 (PST) X-Received: by 10.99.222.17 with SMTP id f17mr12534417pgg.127.1484661185650; Tue, 17 Jan 2017 05:53:05 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si3430770pfb.281.2017.01.17.05.53.05; Tue, 17 Jan 2017 05:53:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751158AbdAQNxB (ORCPT + 4 others); Tue, 17 Jan 2017 08:53:01 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38495 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751177AbdAQNwy (ORCPT ); Tue, 17 Jan 2017 08:52:54 -0500 Received: by mail-wm0-f51.google.com with SMTP id r144so223383500wme.1 for ; Tue, 17 Jan 2017 05:52:51 -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=yn2569mM1Ru1tXAw1Bq1zzG+MK0NtIhB4kAFM+YAAHI=; b=k0WS2K7Xl1kRz+sfRblqnMF0YKidDn5NjhlUII+y74jfLIIH8EcMCpPIT9VyMsEap/ s+hHRMWcruxYhLPQ59v4r+Mktf2+0LIwnkeqsrnID2KbjxjE1wJYLce7HEooh62L2HMh LcH1QiABN/iW2pWNdccg8Bf+09Gpea9IiOD7BQDZ9vH8drcCMXxUmRh5sw9/mJKAALyY yivc93VrwA2Q9FY7tYZVwVUwLdz1QQPJG3v7DJHGoOpBr/dRdTgTk4VT78Ner4MMII31 g6Nh9/+h6NyzD63TJ3MFMnysPwz0z2EWC+9ryjlpI5DSRYpPc1CxPLDfdyd7LrhfvVTI 8Azg== 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=yn2569mM1Ru1tXAw1Bq1zzG+MK0NtIhB4kAFM+YAAHI=; b=OPS2B4UqDJEuQhhHrWmC57+UtxV8VpYTQXHCrbyUlZSp49WxsHY2/MUKk6ClhVJnvA m7u66fJ3lsZYM++ja1oFpDlERw8O6c04ZVwMFcKkoyUxnj3MYtYInIDsHurrPLGYEcTZ 6lvE6/0hi5y7FlGwBNNBb+To0Olu4ZbK2f9+qEGY9jmpm+bdOQCC7qkeRHJEnAoUhXzn 7jZhacW2vB85xmjtLbeG8fE1NHoGbqEK0EFlSApaYvPml6tfw0ZHy5W3LTtty1SJlKzT ZKobsu1pQ0H1t/5g3Qyf3RXyIebm/n6jWI3YwbLevZDJ0TM6AliTFUBDlW/DebW7Ietc Y9LQ== X-Gm-Message-State: AIkVDXJYVo14zgTFltcc7vCATOpu4B6072MbSYeJ9bikrZQ84RfxVk47m+K+mcyjN/GoaWK1 X-Received: by 10.28.216.14 with SMTP id p14mr15354850wmg.56.1484660756470; Tue, 17 Jan 2017 05:45:56 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id l187sm37064811wml.6.2017.01.17.05.45.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jan 2017 05:45:56 -0800 (PST) From: Alexandre Bailon To: vinod.koul@intel.com, b-liu@ti.com, robh+dt@kernel.org Cc: dmaengine@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, tony@atomide.com, linux-omap@vger.kernel.org, sergei.shtylyov@cogentembedded.com, devicetree@vger.kernel.org, Alexandre Bailon Subject: [PATCH v2 6/7] dmaengine: cppi41: init_sched(): Get number of channels from DT Date: Tue, 17 Jan 2017 14:45:39 +0100 Message-Id: <20170117134540.9988-7-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170117134540.9988-1-abailon@baylibre.com> References: <20170117134540.9988-1-abailon@baylibre.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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 | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 3b2f57f..303ccee 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 int 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,9 +847,11 @@ 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); + + return 0; } static int init_cppi41(struct device *dev, struct cppi41_dd *cdd) @@ -871,12 +870,14 @@ static int init_cppi41(struct device *dev, struct cppi41_dd *cdd) ret = init_descs(dev, cdd); if (ret) - goto err_td; + goto deinit; cppi_writel(cdd->td_queue.submit, cdd->ctrl_mem + DMA_TDFDQ); - init_sched(cdd); + ret = init_sched(dev, cdd); + if (ret) + goto deinit; return 0; -err_td: +deinit: deinit_cppi41(dev, cdd); return ret; } @@ -1030,6 +1031,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; @@ -1072,6 +1078,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); @@ -1128,7 +1135,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);