From patchwork Thu Feb 15 12:25:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 10221073 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 2C2056055C for ; Thu, 15 Feb 2018 12:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B7122877B for ; Thu, 15 Feb 2018 12:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DF8428784; Thu, 15 Feb 2018 12:28:04 +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=ham 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 6794C2877B for ; Thu, 15 Feb 2018 12:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031396AbeBOM2C (ORCPT ); Thu, 15 Feb 2018 07:28:02 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:41915 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031393AbeBOM1U (ORCPT ); Thu, 15 Feb 2018 07:27:20 -0500 Received: by mail-wr0-f194.google.com with SMTP id f8so733577wrh.8 for ; Thu, 15 Feb 2018 04:27:20 -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=A4QAN1jtmvpNinr3ldIbonLTuonbdZ/0Smk9V2tktiw=; b=N66z5S89N1LgbJmPl9hTD/VXWUAJq3NyxPgljnD4eR7GHytd5sSpvB/LKBzw95fqHx xRWLUv8+CChiKf0y1Cz9C1/oDzkVH63ZPadVcPMRmO0k0DZ+zOUMEExwPdBBbfJkkc/+ ZWwSwlFd7DjX6nw2e1nZTjBdU1KO2+9SNLegA= 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=A4QAN1jtmvpNinr3ldIbonLTuonbdZ/0Smk9V2tktiw=; b=kCNEo94/AcXstK8W8XhkTxiStfIKCylt/v2wqNMPlLXqpVCPwUrNowgv+xgDOv9j3W 9u+Z2UjSBsXv5XtxZlYGkv4rM2i3X1ho+8QH7GmpD6E5Jd5hqvu8KMFHGtf3r12GeYqq Znf36I4M/pDYCSPkB72J4PrU93VJafts+JmjQUKIdqMu6WU3nHm1SLa0m8dLXg35+mI3 MdMuvNx/9Z1fAB5abI3muF4LUkPBC6LFFmQ20UJTcIAk8PlVcWm0i+GYxjOOXtmPtXSA SA7XLIqO1rFq8iVKOfv1M9FZ5/Whd6Jm1mJAH1WY11hdW75+Dm51ivP4wGot0OSbLVIg YOxw== X-Gm-Message-State: APf1xPB8iXwA1mLiVd0AXysD3nnyNf3m371VHzVcQZcE0XCeeq+cPCnQ dyiEidR48+tw7o4hXzBWGU7xFg== X-Google-Smtp-Source: AH8x2279SuhrdCskvuD+29EFHGoxElw6ibtYGHcgky1HS0W+UmM4Nd5iYHVbUfpqFVKnZ3zc/APCtQ== X-Received: by 10.223.129.76 with SMTP id 70mr2246035wrm.255.1518697639641; Thu, 15 Feb 2018 04:27:19 -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 s9sm15632778wra.4.2018.02.15.04.27.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Feb 2018 04:27:19 -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-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-soc@vger.kernel.org, yanhe@quicinc.com, ramkri@qti.qualcomm.com, sdharia@quicinc.com, Srinivas Kandagatla Subject: [PATCH v3 3/5] dmaengine: qcom: bam_dma: get num-channels and num-ees from dt Date: Thu, 15 Feb 2018 12:25:09 +0000 Message-Id: <20180215122511.13517-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180215122511.13517-1-srinivas.kandagatla@linaro.org> References: <20180215122511.13517-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 b79691fcc82d..139e9f5e47a9 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)) { if (!bdev->controlled_remotely)