From patchwork Fri Feb 9 12:43:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 10208939 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 C133160236 for ; Fri, 9 Feb 2018 12:48:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B583F289B6 for ; Fri, 9 Feb 2018 12:48:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA3E329846; Fri, 9 Feb 2018 12:48:50 +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=unavailable 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 2BDA3289B6 for ; Fri, 9 Feb 2018 12:48:49 +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: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:In-Reply-To: References:List-Owner; bh=ctU2mGNuV2wBRetBxLwX8CeDaGNwVIOe450FvirztBw=; b=tQi ylE96UkM0+o92C7lrFJsqIX+JqVAhvD20iQJjwh9KWVMp1H7Tn3NcDbqEH2UphLoOZ4810UyWbstF 5+cwQBwMPeuNn2USNKbRSuluUaR1UpsyGGN9IUIsjlg60j33JR6uK6fcGMGj5Q7P60NjxnVJIMYxD Lgq5VWvuQ3eCI7KMMYeDQ6EpT62NrlpggvCF/LEVjoOYWE1WSKuWE8rsX4RZq8Jymx5Woy/Rzjd9Y pr24BF7fGXi01PlERx/oBUgqk7rFU0eUujjFoG/p9C0AfJHQmDIDW5ItIAHexYd8iWWLDuSZiiSUO yrkXwBJkSsXF2yct86KzJ7U4mNwpqyg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ek86g-0000cn-1w; Fri, 09 Feb 2018 12:48:46 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ek86e-0000cT-F9 for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Feb 2018 12:48:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ygNHxxYOQPm8F9tinquPIcucmnU0ZBoPqyEtBMGUEJs=; b=HwZotBbkHD9DCfBEBQPS74OSC SNKmAa8nOoIAAVF9K1mUdrYA+QSepqefjSZETHdzLJiMNekPJDCnsk3u4U7ZVoZKq5tcj6Ipu+mdt 3JQxZDypP7uWSQl7NADoNUDkvOj2hDJDG6Tbk8OFoT3mjt9bZS8DcaI0Lh2oMZ/YdFxTwrMMVvPdR Mvf/cmw/m4NYUfDMlNpBtj0mI+Jhphf2KsTBHAPb7iFtKUvuQxp2qcDu06JmuVEGN3ZwhOVotxxMb K8HZBSrtD69tIyFSL+zBngHc5pNd8HObmeSuhc7zE84Kdimf0tUU/PJr7ShPqRhwU34MwxXcCE+hg +xxfi8HXA==; Received: from botnar.kaiser.cx ([176.28.20.183]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ek86a-0004vX-Pi for linux-arm-kernel@lists.infradead.org; Fri, 09 Feb 2018 12:48:42 +0000 Received: from pd956d63d.dip0.t-ipconnect.de ([217.86.214.61] helo=martin-debian-1.paytec.ch) by botnar.kaiser.cx with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.72) (envelope-from ) id 1ek81z-0008UR-On; Fri, 09 Feb 2018 13:43:56 +0100 From: Martin Kaiser To: Shawn Guo , Sascha Hauer , Fabio Estevam , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC] ARM: imx: avic: set low-power interrupt mask for imx25 Date: Fri, 9 Feb 2018 13:43:23 +0100 Message-Id: <1518180203-9698-1-git-send-email-martin@kaiser.cx> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180209_124840_858727_FC26251D X-CRM114-Status: GOOD ( 19.02 ) 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: Martin Kaiser 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 imx25 contains two registers (LPIMR0 and 1) to define which interrupts are enabled in low-power mode. As of today, those two registers are configured to enable all interrupts. Before going to low-power mode, the AVIC's INTENABLEH and INTENABLEL registers are configured to enable only those interrupts which are used as wakeup sources. It turned out that this approach is not sufficient if we want the imx25 to go into stop mode during suspend-to-ram. (Stop mode is the low-power mode that consumes the least power. The peripheral master clock is switched off in this mode). For stop mode to work, the LPIMR0 and 1 registers have to be configured with the set of interrupts that are allowed in low-power mode. Fortunately, the bits in the LPIMR registers are assigned to the same interrups as the bits in INTENABLEH and INTENABLEL. However, LPIMR uses 1 to mask an interrupt whereas the INTENABLE registers use 1 to enable an interrupt. This patch sets the LPIMR registers to the inverted bitmask of the INTENABLE registers during suspend and goes back to "all interrupts masked" when we wake up again. We also make this the default at startup. As far as I know, the other supported imx architectures have no similar mechanism. Since the LPIMR registers are part of the CCM module, we query the device tree for an imx25 ccm node in order to detect if we're running on imx25. Signed-off-by: Martin Kaiser --- Dear all, could you have a look at this first draft? The approach to detect imx25 looks a bit hackish, I'd appreciate your suggestions how to do this properly. Thanks & best regards, Martin arch/arm/mach-imx/avic.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/avic.c b/arch/arm/mach-imx/avic.c index 1afccae..bd6d3f2 100644 --- a/arch/arm/mach-imx/avic.c +++ b/arch/arm/mach-imx/avic.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -51,7 +52,10 @@ #define AVIC_NUM_IRQS 64 -static void __iomem *avic_base; +#define MX25_CCM_LPIMR0 0x68 +#define MX25_CCM_LPIMR1 0x6C + +static void __iomem *avic_base, *mx25_ccm_base; static struct irq_domain *domain; #ifdef CONFIG_FIQ @@ -93,6 +97,11 @@ static void avic_irq_suspend(struct irq_data *d) avic_saved_mask_reg[idx] = imx_readl(avic_base + ct->regs.mask); imx_writel(gc->wake_active, avic_base + ct->regs.mask); + if (mx25_ccm_base) { + u8 offs = d->hwirq < AVIC_NUM_IRQS / 2 ? + MX25_CCM_LPIMR0 : MX25_CCM_LPIMR1; + imx_writel(~gc->wake_active, mx25_ccm_base + offs); + } } static void avic_irq_resume(struct irq_data *d) @@ -102,6 +111,11 @@ static void avic_irq_resume(struct irq_data *d) int idx = d->hwirq >> 5; imx_writel(avic_saved_mask_reg[idx], avic_base + ct->regs.mask); + if (mx25_ccm_base) { + u8 offs = d->hwirq < AVIC_NUM_IRQS / 2 ? + MX25_CCM_LPIMR0 : MX25_CCM_LPIMR1; + imx_writel(0xffffffff, mx25_ccm_base + offs); + } } #else @@ -158,6 +172,14 @@ void __init mxc_init_irq(void __iomem *irqbase) avic_base = irqbase; + np = of_find_compatible_node(NULL, NULL, "fsl,imx25-ccm"); + mx25_ccm_base = of_iomap(np, 0); + + if (mx25_ccm_base) { + imx_writel(0xffffffff, mx25_ccm_base + MX25_CCM_LPIMR0); + imx_writel(0xffffffff, mx25_ccm_base + MX25_CCM_LPIMR1); + } + /* put the AVIC into the reset value with * all interrupts disabled */