Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1162330pxb; Tue, 17 Aug 2021 05:27:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJb6jVE7SN7vqYZIirHlCsOd/EN1RR5Ap4wyunkeWiVPgG2nHjIpHBLS7RMNkx5bFu5Hl5 X-Received: by 2002:a92:a801:: with SMTP id o1mr2250801ilh.128.1629203221179; Tue, 17 Aug 2021 05:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629203221; cv=none; d=google.com; s=arc-20160816; b=YCUYWzaruKwLat6xwqI3ljZ0V71eTinBfHI/wMpmVBJv2xY0HoYRDD5jrQ3mRD8Kt8 HmIcIObk5NF0Bq7QwOZlKFnyeCogf+RqJb9Syubp/R2kJehWr0h2i+fV+nZhr0L1sRTN VuARlvE6CJWhYZI1R0Z2fvVnsqzAZttxdmzCNbm5/03y3cA7QRUXmVoAqHx50+0YQeve ELBkt8wVqbe0/5mGcmUKmJ0O9MZoFhnSgnsk6Sp471JRM2uL499No3RpJuMLys4S4tWC bUmS6u7akFrHKivZDWXzxh4jwFVPneBe3Sw+ZgZCRO0Y5GSo21kHRzctP/6Nm9xCBOv+ TCkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=TU/MnP/Ispxno03X/H+vw4FlTcQAWLirWTDzLEu24rw=; b=dmhFjB8VCUlQO3Vh4/1ME50rU/CJilXO7GoURI0C8W3EY9h+ZMaoSOFiUHYfaXK119 uQwpG7Nf1lnurl2X9cCjBSGWot99/Omrt14kJzJC0VW1gDm4J8MkVYQljgLmjdaEb1N0 fe+EUPM+3w5IDxvkWvstFLKcHUlcBpG/VUgb3hhY59iaPRASNtSlnAIK2FT4vGRFlxTr fzqPB2hCemz0LaXjK3uk/9jnvdvriTJS9f7Fyxc23fRa1wcon4txonoZ997oeLC3UjjI Edow2D9fG7Jj1Fn5WBnVoA+A5OLjmwN2+ZaiJ2bL3ibTE3lEXMUz6bZe3/Q6BW1sOt8T rurg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p1si2239288ios.38.2021.08.17.05.26.50; Tue, 17 Aug 2021 05:27:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237214AbhHQMZk (ORCPT + 99 others); Tue, 17 Aug 2021 08:25:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237197AbhHQMZj (ORCPT ); Tue, 17 Aug 2021 08:25:39 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE1FBC061764 for ; Tue, 17 Aug 2021 05:25:05 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit 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-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.30.2