From patchwork Wed Feb 14 14:44:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 10219189 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 B50E5601C2 for ; Wed, 14 Feb 2018 14:48:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6EBA28ED0 for ; Wed, 14 Feb 2018 14:48:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B9B528FDF; Wed, 14 Feb 2018 14:48:43 +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 4F70F28ED0 for ; Wed, 14 Feb 2018 14:48:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030419AbeBNOsS (ORCPT ); Wed, 14 Feb 2018 09:48:18 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:46061 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031056AbeBNOrM (ORCPT ); Wed, 14 Feb 2018 09:47:12 -0500 Received: by mail-wr0-f193.google.com with SMTP id h9so176710wre.12 for ; Wed, 14 Feb 2018 06:47:12 -0800 (PST) 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; bh=neKD4A5jlNJJIS5VZQ4XQDX32JtRMXJkjTuSrWCcOpk=; b=Z00YqiO1MWOK7olBvOnLdxjBGOEAHFzQRgJZ5P+OmqF2sEvT8Ko6BzYcKHYTtS/JEM li8YVoxssCHpAHb7cQNzAQCnGJHFq9pEt5Za+g8pnHOnL/Eq/Svxi5zZluiPTddDteKY m3TPa60vPjGLRUzGLmevDEw9IuCv75oFShAFA= 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=neKD4A5jlNJJIS5VZQ4XQDX32JtRMXJkjTuSrWCcOpk=; b=Ktg4BRQFTdN6RoR49w2CsokLeg4DAaNry+G+d9s5GAqqHFbGIcjMhcOcbZ6exluSEK 18+5ItOAKQ9QSevCDUEVBC2mWiayQi0lrEmkUuBgLaaQq8dyN1NlLj1vjVEhjkqQCxQN B5xDVMeXmEkfpXMRGTWRiviSGM/DRM+f+y/7N2/KPlUaRB0Zi/soZmVNZW0VutyeRyFX b08TP1n3T/4sGryrO1cdKMDSZFMHipRjLCtWkczW8Df093/5VLHaUiHCkRcGLqWa/EMH Re3vin/F9GruQAcNTpP70J3LbQA8AgskG+PMFjXc9xqE5HH+aolXzYMZ9WB3kiYjRuuD 89LQ== X-Gm-Message-State: APf1xPDToyIe7wzokCrscjibVeiXTMPxGzMWK8yDfr2cGkEHZWeemOEB e0Kt2SOTHHZF4QRcz3NxAY9YAA== X-Google-Smtp-Source: AH8x226D1Hxssn1nc90uSkDZlyzB7RRMB2Z/YtmXEF6ZC8vCk/xI7XD02orODuVk+fkTLqiBCbpUbA== X-Received: by 10.223.161.15 with SMTP id o15mr4452695wro.274.1518619631455; Wed, 14 Feb 2018 06:47:11 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id u20sm7675965wrg.13.2018.02.14.06.47.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Feb 2018 06:47:10 -0800 (PST) From: srinivas.kandagatla@linaro.org To: vinod.koul@intel.com, andy.gross@linaro.org, dmaengine@vger.kernel.org Cc: robh+dt@kernel.org, mark.rutland@arm.com, david.brown@linaro.org, dan.j.williams@intel.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, yanhe@quicinc.com, ramkri@qti.qualcomm.com, sdharia@quicinc.com, Srinivas Kandagatla Subject: [PATCH v2 3/5] dmaengine: qcom: bam_dma: get num-channels and num-ees from dt Date: Wed, 14 Feb 2018 14:44:57 +0000 Message-Id: <20180214144459.29813-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180214144459.29813-1-srinivas.kandagatla@linaro.org> References: <20180214144459.29813-1-srinivas.kandagatla@linaro.org> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Srinivas Kandagatla When Linux is master of BAM, it can directly read registers to know number of supported channels, however when its remotely controlled reading these registers would trigger a crash if the BAM is not yet initialized or powered up on the remote side. This patch allows driver to read num-channels and num-ees from Device Tree for remotely controlled BAM. Signed-off-by: Srinivas Kandagatla --- drivers/dma/qcom/bam_dma.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c index ae4c7b6930b8..146b5d03256f 100644 --- a/drivers/dma/qcom/bam_dma.c +++ b/drivers/dma/qcom/bam_dma.c @@ -393,6 +393,7 @@ struct bam_device { struct device_dma_parameters dma_parms; struct bam_chan *channels; u32 num_channels; + u32 num_ees; /* execution environment ID, from DT */ u32 ee; @@ -1128,15 +1129,19 @@ static int bam_init(struct bam_device *bdev) u32 val; /* read revision and configuration information */ - val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION)) >> NUM_EES_SHIFT; - val &= NUM_EES_MASK; + if (!bdev->num_ees) { + val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION)); + bdev->num_ees = (val >> NUM_EES_SHIFT) & NUM_EES_MASK; + } /* check that configured EE is within range */ - if (bdev->ee >= val) + if (bdev->ee >= bdev->num_ees) return -EINVAL; - val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES)); - bdev->num_channels = val & BAM_NUM_PIPES_MASK; + if (!bdev->num_channels) { + val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES)); + bdev->num_channels = val & BAM_NUM_PIPES_MASK; + } if (bdev->controlled_remotely) return 0; @@ -1232,6 +1237,18 @@ static int bam_dma_probe(struct platform_device *pdev) bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node, "qcom,controlled-remotely"); + if (bdev->controlled_remotely) { + ret = of_property_read_u32(pdev->dev.of_node, "num-channels", + &bdev->num_channels); + if (ret) + dev_err(bdev->dev, "num-channels unspecified in dt\n"); + + ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-ees", + &bdev->num_ees); + if (ret) + dev_err(bdev->dev, "num-ees unspecified in dt\n"); + } + bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk"); if (IS_ERR(bdev->bamclk)) { bdev->bamclk = NULL;