From patchwork Tue Aug 17 12:25:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 12441403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65F22C4338F for ; Tue, 17 Aug 2021 12:27:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B69A60F38 for ; Tue, 17 Aug 2021 12:27:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2B69A60F38 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4sfK2BCdtCaWuK8W7h2xjw9/LnSxfx/cecpeggpSk0I=; b=XpSsdjp78HgoZV WmHSrdNi6UMW1TqDbQGexVC48kBxasUvxgoc3cNHLferMUVjXhMPnNQA/3vWsHfW5APCFs+P9JWz6 SzQat4DK/YAIa0ZuBWPbaLqo60La6nNvt39lAKehUd4UjryCgQyF3aKQKAcZUdUbNAr/cndJmRnG/ Yos5MG+s8Ezf1TaLTrpJrbUuW25a5f0tF4XOZN1bJuxEhPnEUGcP6hpzn8Fd8TqC2SrihaaX9wXo3 DIgtVgeJ+qKq5JGgzExqzJeY4KHLL6utdggmPkVP6RTY4EpAWKvWbNeebnNzT6+0MjEDWF0kjZh/s XomzvIVxmyTEgERArrLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFy9w-002Rpf-LD; Tue, 17 Aug 2021 12:25:37 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFy9Q-002RhB-4u for linux-arm-kernel@lists.infradead.org; Tue, 17 Aug 2021 12:25:05 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mFy9N-00028R-S4; Tue, 17 Aug 2021 14:25:01 +0200 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mFy9N-0008TF-F9; Tue, 17 Aug 2021 14:25:01 +0200 From: Oleksij Rempel To: Shawn Guo , Sascha Hauer Cc: Oleksij Rempel , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Fabio Estevam , linux-imx@nxp.com Subject: [PATCH v2] ARM: imx6: mask all interrupts before calling stby-poweroff sequence Date: Tue, 17 Aug 2021 14:25:00 +0200 Message-Id: <20210817122500.31953-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210817_052504_249153_DAA8385A X-CRM114-Status: GOOD ( 13.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Any pending interrupt can prevent entering standby based power off state. To avoid it, mask all interrupts. Fixes: 8148d2136002 ("ARM: imx6: register pm_power_off handler if "fsl,pmic-stby-poweroff" is set") Signed-off-by: Oleksij Rempel --- arch/arm/mach-imx/pm-imx6.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c index 9244437cb1b9..63887ade411a 100644 --- a/arch/arm/mach-imx/pm-imx6.c +++ b/arch/arm/mach-imx/pm-imx6.c @@ -59,8 +59,11 @@ #define MX6Q_SUSPEND_OCRAM_SIZE 0x1000 #define MX6_MAX_MMDC_IO_NUM 33 +#define GIC_DIST_ENABLE_CLEAR 0x180 + static void __iomem *ccm_base; static void __iomem *suspend_ocram_base; +static void __iomem *gic_raw_dist_base; static void (*imx6_suspend_in_ocram_fn)(void __iomem *ocram_vbase); /* @@ -592,6 +595,7 @@ static int __init imx6q_suspend_init(const struct imx6_pm_socdata *socdata) static void __init imx6_pm_common_init(const struct imx6_pm_socdata *socdata) { + struct device_node *np; struct regmap *gpr; int ret; @@ -615,10 +619,29 @@ static void __init imx6_pm_common_init(const struct imx6_pm_socdata if (!IS_ERR(gpr)) regmap_update_bits(gpr, IOMUXC_GPR1, IMX6Q_GPR1_GINT, IMX6Q_GPR1_GINT); + + np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-gic"); + gic_raw_dist_base = of_iomap(np, 0); +} + +static void imx_gic_mask_all(void) +{ + int i; + + if (WARN_ON(!gic_raw_dist_base)) + return; + + for (i = 0; i < 4; i++) + writel_relaxed(~0, gic_raw_dist_base + GIC_DIST_ENABLE_CLEAR + 4 * i); } static void imx6_pm_stby_poweroff(void) { + /* + * A pending interrupt can prevent power off signal to be activated. + * So, mask all interrupts to avoid it. + */ + imx_gic_mask_all(); imx6_set_lpm(STOP_POWER_OFF); imx6q_suspend_finish(0);