From patchwork Fri Jun 9 14:07:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 773980 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wkkfw5qhPz9sNG for ; Sat, 10 Jun 2017 00:08:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gH/8RRBp"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="FYW5tikE"; dkim-atps=neutral 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=uSremfZTWaS4YTVVxIYWeayVTaHneYPu1QuwU7zOWDY=; b=gH/8RRBp8C/OgciX8BuAbzAdXc mpJgIWd6Nwo04jp9TSsIqF48LtpIVMS53BEMYFxrMO+ypyXJ7CVafMLpFGxRqVQ7YTGdHOQ5Ac9s6 TJZoKQ8ol6ITNOblAaaUeRSylt3EYNY9QdVr7XxFV8T/28ltl99Q23s1bvF9cPadPQzw3mWHJTilT mDUKmwygZkxaQmWktqQmngZWbMDuS6nO20fxn424XW0rxrsKuc4zrvdpUntBQ30yAkCQyQmKcAvvb vwM8YvjuRSnIkMEiBC5N6ncYK/YzEK0dNv8mpC4Hn8ULmDGxcdy9nJZBGNtjn91zRr1W4WReMvuaL SPYjgwDQ==; 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 1dJKas-0006bi-O7; Fri, 09 Jun 2017 14:08:54 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dJKaF-0005pm-JC for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Jun 2017 14:08:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To: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:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=b2rT2eXqa585mul7SN55ViyP5/wqU2DXYcQ6dx7WSwA=; b=FYW5tikEqW65uDKXmxFgGQeC+ g0RknwvuN1Mkf1gZ7zEHS04bmIkhyVm7yG9MXvxDV+PwRJhIdU0Zqv3kkGMEWv7AnCUeYzUX8mXkN ZzfkwG4iYB/dg8lZU87vGty3CqBYQy48Vdp7ROTC+xpN+GJenk41e3ir9GV37ktuGG6e26VG1gj6i wpNk84/OmURq0oZXYZSew8y1HN/lGu6xq9vfyBspatIvB7Q4F0lWknhQeK1hHRvOnX1+FPleWKQ7c R3PO0KH5HefWVpVPjgYT62IWsvVIskd0COXM345ickyzYxr2AYIv8T076i98sUYJwRAg30QJ590HF tRaKvn/Kg==; Received: from metis.ext.4.pengutronix.de ([92.198.50.35]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dJKaC-0007UP-Re for linux-arm-kernel@lists.infradead.org; Fri, 09 Jun 2017 14:08:14 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dJKZk-000306-Bs; Fri, 09 Jun 2017 16:07:44 +0200 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1dJKZi-00046h-U1; Fri, 09 Jun 2017 16:07:42 +0200 From: Oleksij Rempel To: Andrew Morton , devicetree@vger.kernel.org, Fabio Estevam , kernel@pengutronix.de, Liam Girdwood , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown , Mark Rutland , Michael Turquette , Rob Herring , Russell King , Shawn Guo , Stephen Boyd Subject: [PATCH v4 2/6] ARM: imx6: register pm_power_off handler if "fsl, pmic-stby-poweroff" is set Date: Fri, 9 Jun 2017 16:07:35 +0200 Message-Id: <20170609140739.15726-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170609140739.15726-1-o.rempel@pengutronix.de> References: <20170609140739.15726-1-o.rempel@pengutronix.de> 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-20170609_100813_072690_F2F4984B X-CRM114-Status: GOOD ( 13.81 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [92.198.50.35 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Oleksij Rempel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org One of the Freescale recommended sequences for power off with external PMIC is the following: ... 3. SoC is programming PMIC for power off when standby is asserted. 4. In CCM STOP mode, Standby is asserted, PMIC gates SoC supplies. See: http://www.nxp.com/assets/documents/data/en/reference-manuals/IMX6DQRM.pdf page 5083 This patch implements step 4. of this sequence. Signed-off-by: Oleksij Rempel --- arch/arm/mach-imx/pm-imx6.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c index e61b1d1027e1..3a4f8f289f4d 100644 --- a/arch/arm/mach-imx/pm-imx6.c +++ b/arch/arm/mach-imx/pm-imx6.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include "common.h" #include "hardware.h" @@ -602,6 +604,28 @@ static void __init imx6_pm_common_init(const struct imx6_pm_socdata IMX6Q_GPR1_GINT); } +static void imx6_pm_poweroff(void) +{ + imx6_set_lpm(STOP_POWER_OFF); + cpu_suspend(0, imx6q_suspend_finish); + + mdelay(1000); + + pr_emerg("Unable to poweroff system\n"); +} + +static int imx6_pm_poweroff_probe(void) +{ + if (pm_power_off) { + pr_warn("%s: pm_power_off already claimed %p %pf!\n", + __func__, pm_power_off, pm_power_off); + return -EBUSY; + } + + pm_power_off = imx6_pm_poweroff; + return 0; +} + void __init imx6_pm_ccm_init(const char *ccm_compat) { struct device_node *np; @@ -618,6 +642,9 @@ void __init imx6_pm_ccm_init(const char *ccm_compat) val = readl_relaxed(ccm_base + CLPCR); val &= ~BM_CLPCR_LPM; writel_relaxed(val, ccm_base + CLPCR); + + if (of_property_read_bool(np, "fsl,pmic-stby-poweroff")) + imx6_pm_poweroff_probe(); } void __init imx6q_pm_init(void)