From patchwork Wed Feb 15 13:56:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9574125 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 672A5601D8 for ; Wed, 15 Feb 2017 13:57:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DECE28451 for ; Wed, 15 Feb 2017 13:57:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51E7228478; Wed, 15 Feb 2017 13:57:03 +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=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 AC6D128451 for ; Wed, 15 Feb 2017 13:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751313AbdBON5A (ORCPT ); Wed, 15 Feb 2017 08:57:00 -0500 Received: from mail-wm0-f46.google.com ([74.125.82.46]:33104 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751315AbdBON44 (ORCPT ); Wed, 15 Feb 2017 08:56:56 -0500 Received: by mail-wm0-f46.google.com with SMTP id t18so20739835wmt.0 for ; Wed, 15 Feb 2017 05:56:50 -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=CtdgA/cpuEtwAeJnzZUtRYeMBZ5ZbCl6vwe0xqevWuw=; b=ieqWYa1qVYD0wYjl0DEmuPc3CUz7fCmeersysdOPkCt3+mapymcsmEQboDcwckLQC3 lnYJNxMSCQuuzmAA8Z/rRgITiwRvDfALz8EsdB5DeW7WyF6TJU0u/3lG5OF1We2nyGTJ IcbvvJw3qP5OGIO781LMM2vgroxdG6Zo+Wba/YpuVLa7ybyHJNpoHb0Y+30NIBX/03fX f2gd3lF+zH+yKr6/dQl52VMX830AMC2Q2DZ7DVjkf2WbhgTok9x8I0KrsmHucdEDLUXC giK4pfPjQs5BojBxnLG+YDFT59/P0iTR4Ok62GpY1rR4otQBYrvZ4l/KmVZvhv5rq+ES v98g== 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=CtdgA/cpuEtwAeJnzZUtRYeMBZ5ZbCl6vwe0xqevWuw=; b=lwZlNanRFTXPTWakf8L2HwMP9uLYraMgLIyPx0nYQgnfmXoUJkxHtyWbdyJ+sLvvY8 SFy+olQ22SPVlYh/MNWMGlvHvAJ2UF5o1og0FH0axsTn0JtjCLfwxBd9zy9bGSFYwbWz T8tu8zi9RjFlyKgjp2JZhiJ80rIn7kAzPODb0pDBNzam32hZrjAzWR1XWHX9q+SBEihP n7viCGZ/rarsMF80ZTtP0O+48J1GNRn8Er234Ci3J71s/rLToVD/AxN7ZQnUyIxCqbDB Jddrbqme3BdoxmKFQMyQacKWrQzKg5qokGSmqg11mgFrkbND7apFS81lc1vVLTY/0j9T QFNg== X-Gm-Message-State: AMke39maMgUV725VdMhid4hQUsu0ru7YNjtQ/ji1gNuaVyvIVJlzm8bzChTA0B/U+dj1LF7N X-Received: by 10.28.9.148 with SMTP id 142mr7917826wmj.24.1487167004643; Wed, 15 Feb 2017 05:56:44 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id a35sm5023174wra.21.2017.02.15.05.56.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Feb 2017 05:56:44 -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, linux-usb@vger.kernel.org, Alexandre Bailon Subject: [PATCH v5 4/5] dmaengine: cppi41: init_sched(): Get number of channels from DT Date: Wed, 15 Feb 2017 14:56:35 +0100 Message-Id: <20170215135636.31427-5-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170215135636.31427-1-abailon@baylibre.com> References: <20170215135636.31427-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 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 676228f..54337cd 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 */ @@ -742,13 +744,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. @@ -862,7 +859,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; @@ -872,7 +869,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); } @@ -897,6 +894,7 @@ static int init_cppi41(struct device *dev, struct cppi41_dd *cdd) cppi_writel(cdd->td_queue.submit, cdd->ctrl_mem + DMA_TDFDQ); init_sched(cdd); + return 0; err_td: deinit_cppi41(dev, cdd); @@ -1058,6 +1056,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; @@ -1100,6 +1103,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);