From patchwork Mon Oct 2 23:13:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Mayer X-Patchwork-Id: 9981327 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 020F0602A0 for ; Mon, 2 Oct 2017 23:15:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8BFA288DB for ; Mon, 2 Oct 2017 23:15:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD72C28942; Mon, 2 Oct 2017 23:15:10 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8404A288DB for ; Mon, 2 Oct 2017 23:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qHnPnzoL9uSRF6St8ms0RAlBo0a2QoSSkBLITZVe0n0=; b=UvfH04dSbt201En8AGkm0ce0yt PGbxzgM19DEuWcAIW5oXuBHqDevJfaJZ4/lh27FaMwf1OVgMOXf5polR/Mnc4UedX24+NGs/VKwYV dSg5RpgV+gQ3MFnASf1guyZ5SvkGSuinakYuiHt/zGMmDSOwxx9rI0+pEsk+cnMU5PgSm2pJlTJDc AweR8TRFst/BuKf/uVwGox2GJB0IKvacKWSCAP/tczV0eGJlJD5C+vQjTe3ou4+lDLom9MaAxdYOp Tk/kQzuLBgL60/qGYtSZc7WkU/4DezSfRqW5zKDdkyqtEtMGhSOlkOtyIvgoeqeLnqnXXByMMvOtl lGiQFl2A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dz9vP-0000TX-L9; Mon, 02 Oct 2017 23:14:59 +0000 Received: from smtp-out-so.shaw.ca ([64.59.136.139]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dz9vC-00007S-95 for linux-arm-kernel@lists.infradead.org; Mon, 02 Oct 2017 23:14:50 +0000 Received: from triton.mmayer.net ([96.48.165.49]) by shaw.ca with SMTP id z9undFCa88LPZz9uodsXdx; Mon, 02 Oct 2017 17:14:24 -0600 X-Authority-Analysis: v=2.2 cv=e552ceh/ c=1 sm=1 tr=0 a=k5HOQ6ZN7M0zyjl8M7O1NA==:117 a=k5HOQ6ZN7M0zyjl8M7O1NA==:17 a=02M-m0pO-4AA:10 a=Q-fNiiVtAAAA:8 a=ARqTYPXHlEXjlNXjinkA:9 a=Fp8MccfUoT0GBdDC_Lng:22 Received: by triton.mmayer.net (Postfix, from userid 501) id CB5B3200568394; Mon, 2 Oct 2017 16:14:21 -0700 (PDT) From: Markus Mayer To: Florian Fainelli , Gregory Fong , Brian Norris Subject: [PATCH 1/2] memory: brcmstb: dpfe: introduce is_dcpu_enabled() Date: Mon, 2 Oct 2017 16:13:46 -0700 Message-Id: <20171002231347.8671-2-code@mmayer.net> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171002231347.8671-1-code@mmayer.net> References: <20171002231347.8671-1-code@mmayer.net> X-CMAE-Envelope: MS4wfLaP+h89BBBtCjKdyM3P13shFoR8eWI/eymXLEiP2utXom95BiHRL7o2ik3AHCE97JMy/U8M6glNiS7/0dglg5KuDGj9HsFzG30wYHlMj7vQoE0CnGsk 7/nHkYtRGs7mhNib/KP1wBZo2TT6y3foM1uLVSYqF9QLqa5JnEwIZ793HRY01Jz+LbUe5VlVE0r8NQ2i2iV3PEFFMnMSvOMbY7W3xl2kbOnUqRh/80Tntmbj +CT8w5t1HYnQzG86ZvjbjeR9N5PWmV9qiS4ozM3BmrpFJcz4Wu5DavYDh9SngwqbutssMsd9kzYaXX3JaKd1dSTxOUG9BOuOsQUt+YqH1nuR5eLHxK9Yjzyh AISNfZzw97w41ZcfNQeWuSBpkIJcOFYhZFWTa5tjuxdEC3HYRWCs866ucVh2lGHU9wCo4L1j3hHai6yIwOHasSxwEQH1ioouf6wFRQ6VOoxcHB8zmeY= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171002_161446_811197_4A8CE069 X-CRM114-Status: GOOD ( 10.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Device Tree List , Broadcom Kernel List , ARM Kernel List , Markus Mayer , Linux Kernel Mailing List MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Mayer In order to check whether or not the DCPU is running, we introduce a function called is_dcpu_enabled(). Signed-off-by: Markus Mayer --- drivers/memory/brcmstb_dpfe.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c index 21242c4..3516ee8 100644 --- a/drivers/memory/brcmstb_dpfe.c +++ b/drivers/memory/brcmstb_dpfe.c @@ -202,17 +202,26 @@ static const u32 dpfe_commands[DPFE_CMD_MAX][MSG_FIELD_MAX] = { }, }; +static bool is_dcpu_enabled(void __iomem *regs) +{ + u32 val; + + val = readl_relaxed(regs + REG_DCPU_RESET); + + return !(val & DCPU_RESET_MASK); +} + static void __disable_dcpu(void __iomem *regs) { u32 val; - /* Check if DCPU is running */ + if (!is_dcpu_enabled(regs)) + return; + + /* Put DCPU in reset if it's running. */ val = readl_relaxed(regs + REG_DCPU_RESET); - if (!(val & DCPU_RESET_MASK)) { - /* Put DCPU in reset */ - val |= (1 << DCPU_RESET_SHIFT); - writel_relaxed(val, regs + REG_DCPU_RESET); - } + val |= (1 << DCPU_RESET_SHIFT); + writel_relaxed(val, regs + REG_DCPU_RESET); } static void __enable_dcpu(void __iomem *regs)