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: 128355 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp686840ljc; Wed, 14 Feb 2018 06:48:20 -0800 (PST) X-Google-Smtp-Source: AH8x225STcpJLEpDofGf/0y/ohtknpj6Vn8le1cDn87BSf1ahu/SEfqG4XZ7Be5ilOIzTA5Q7PBr X-Received: by 10.98.10.199 with SMTP id 68mr4995002pfk.202.1518619699874; Wed, 14 Feb 2018 06:48:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518619699; cv=none; d=google.com; s=arc-20160816; b=Y1dVn/p5pF2lBbYy0hvd5hdwqjLj0zjQEh+HYoDHyMej4n0PoajOC3yRU1m4voYzg4 Sr8reETEA3NVpv+0Bjm4Aied7V1CWPYx0pJNjXzTm5FTKziMWX95cEbF3J3EIL0nykm6 mkqtMvmVlDPZhQ4CD1JMaxljv7qSwl70GzJhfhzPP47DynLSgh8nMN9dgxxXMBvFGbio DA/Qezrp5aJMJ2ES/V72pwrSIYED1eEuYgOL0bVsv+6L5WmpPL5MxW7te6TZCnGBVexY cduZpGks9tYYxwQPPwr0iVk+RwRsMYJAKOxbSBMNn6WdQBtGm8CIEYhL3Q/B55X+ri88 xyGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Cbe05dpf0ezNNJOqvSbMfmAhij6v681JoFt5MiMQMsM=; b=Wx0WHj05NbBW+qYt8o/zmJ/vcvhiE5gcka9IU4i4NAbKagLCT4CgfhQEyfA2y2LbGT eom9NrcWTwD1uz3DYHX4IyedFTEbN9tcoLnnmzywf0P72mK8n6XB32CUbiWRMiROX7UU /xDKhHIzZSv8AKzhYuu0AUrmiH36TnSIou0u9r46zlyGXCk44RfNtxKFIXxLR3jNbVKm VRqBWMP6llRcKWH6LYFhlRxCohCMtsxJd+J8oau4XUKkfXAMWCVqHPFOUGrhZZTL22MR kHytnNitAmzBkKv7JPSCoOOIwdtm0aTI6cJ98sncBllINY/ZShApuC85fRd96FRrCItG GlpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Z00YqiO1; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v35-v6si1521940plg.724.2018.02.14.06.48.19; Wed, 14 Feb 2018 06:48:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b=Z00YqiO1; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030382AbeBNOsR (ORCPT + 10 others); Wed, 14 Feb 2018 09:48:17 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:41304 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031072AbeBNOrM (ORCPT ); Wed, 14 Feb 2018 09:47:12 -0500 Received: by mail-wr0-f196.google.com with SMTP id q11so188326wre.8 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=KbeZCuL9psztI47wWzk/dYEBwzXY8omWFE9HblJfRN7cym8u1OSN1Jvcvn8u6zaoQw BBMvuj5yFMSXMlREz7RCCx8RiVex7VolGLUgb8yIvwngxUqZtz2OoySYAvzjy/ThBh/h /kXpPeejGzd8Mk2jrlMy/yXoUHnpUGvgRtOFSDcPSNFCoyN36z0gGVZ8xMCm9DWXT06M Voxb48hdEvARszZuqjzIdVOzw+LWJegSIUV5WT05qNvqDEro13Qbe2YdJhs3sa8t4QYY ejBuLcpeXKsDTVDgiqdB/BDW0UGejSL14D5pEbImHx5d9lDkkqWXqRQxtYO0zlnW0IUf DbNQ== X-Gm-Message-State: APf1xPB325En67ON0GFgYl9FirjSF8aX9G9g8CEAehaWnwXN1RhOEdl2 tATeaA82Gu3nT+YQGz68rYtVgQ== 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: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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(-) -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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/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;