From patchwork Mon Jan 9 16:06:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9505355 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 4F947606E1 for ; Mon, 9 Jan 2017 16:08:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41F8528474 for ; Mon, 9 Jan 2017 16:08:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36B6C28497; Mon, 9 Jan 2017 16:08:35 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 D628628474 for ; Mon, 9 Jan 2017 16:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970210AbdAIQIS (ORCPT ); Mon, 9 Jan 2017 11:08:18 -0500 Received: from mail-wm0-f46.google.com ([74.125.82.46]:37201 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970219AbdAIQHX (ORCPT ); Mon, 9 Jan 2017 11:07:23 -0500 Received: by mail-wm0-f46.google.com with SMTP id c206so37927685wme.0 for ; Mon, 09 Jan 2017 08:07:22 -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=ulYwB3LwENizVpSV1pvJphbecAGyOfP3a94TWLaTwNA=; b=ZLf8i7Tpshf+MBDzT2YgmXY57MT4YB6dc3fQCypGdwRCG6Wj89elPFqbviNqHYUnsn 68apdEefQIxS3FESWLwv20sEaaOnQ88Yn6xtnYVfTAWMPZQzPuWFJI2llSAOvrwlXOP1 NOsCTYICGe3WM/94SdBDaSUQ6UU1KfOZ/i6up76hblYs6Idmgc7Or1bUr/kXgP3jLHlL 17XyDykj9Fy6sFQb3toiOW9WTd32BldDLqSxUFEjhDV4/alSd3WQp9Rs6vGGgAM4cvMd s3EkRrXXngKc9gwerErnCWrcOWrchhyrVUMyJbPhOUC+2c0FKIhsa8e+7J+KD6hhU1Zy eVuA== 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=ulYwB3LwENizVpSV1pvJphbecAGyOfP3a94TWLaTwNA=; b=MDYxrNeG5gL4DN6fo26v0z4JIHs7aLRKHDQUQTIM0cP7ewfOhWCDp6DfJ1Ecn1y0kh ldjyjwhkUZVHrM3I4lSb2eYB9ZJVHRKrF+yhYFu6txyuoFlPS5zsw/5+vjCDA1j4enUM PS9gPlSMZ2UK0GRiezP7evHDWmtJ/0QhOpLzj1eHvlqNE/Bo7lLXtdSfI1IhpdtmGTkh gYcDhUtXAqso9rFbEiESzrEBNolwMKWhZWNzc46YSZuJi8QrQVP+NuT/3xeeF2GREYLr /tVw3zYBZysAFAkCWwiQ4Lk1Dym/9C3QYjvKvRvXNutQIRjvX+ZNV0E65DKHOhVIENA9 vbGw== X-Gm-Message-State: AIkVDXJJBaOVDbl7VwsxhkDTKU3H3pmOIrLNocbv4UlVBJpsNwvA5vLSz3AWv3tnGvvkMMCQ X-Received: by 10.28.45.142 with SMTP id t136mr5591671wmt.110.1483978041424; Mon, 09 Jan 2017 08:07:21 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id w18sm19656244wme.9.2017.01.09.08.07.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jan 2017 08:07:20 -0800 (PST) From: Alexandre Bailon To: vinod.koul@intel.com Cc: dmaengine@vger.kernel.org, linux-usb@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, tony@atomide.com, linux-omap@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org, b-liu@ti.com, Alexandre Bailon Subject: [PATCH 04/11] dmaengine: cppi41: init_sched(): Get number of channels from DT Date: Mon, 9 Jan 2017 17:06:49 +0100 Message-Id: <20170109160656.3470-5-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170109160656.3470-1-abailon@baylibre.com> References: <20170109160656.3470-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 | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index d0d3bdd..8d7965d 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -148,6 +148,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 */ @@ -734,13 +736,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. @@ -846,7 +843,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; @@ -854,7 +851,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; @@ -864,9 +861,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) @@ -885,12 +884,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; } @@ -1045,6 +1046,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; @@ -1090,6 +1096,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); @@ -1150,7 +1157,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);