From patchwork Thu Sep 11 06:41:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 4882471 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4A1B29F32F for ; Thu, 11 Sep 2014 07:48:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B1B420225 for ; Thu, 11 Sep 2014 07:48:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2DE872020F for ; Thu, 11 Sep 2014 07:48:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XRz4B-0007pI-IO; Thu, 11 Sep 2014 07:45:19 +0000 Received: from mail-bl2on0113.outbound.protection.outlook.com ([65.55.169.113] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XRz47-0006f8-UD for linux-arm-kernel@lists.infradead.org; Thu, 11 Sep 2014 07:45:17 +0000 Received: from BN3PR0301CA0070.namprd03.prod.outlook.com (25.160.152.166) by BLUPR03MB344.namprd03.prod.outlook.com (10.141.48.24) with Microsoft SMTP Server (TLS) id 15.0.1034.8; Thu, 11 Sep 2014 07:44:51 +0000 Received: from BL2FFO11FD023.protection.gbl (2a01:111:f400:7c09::178) by BN3PR0301CA0070.outlook.office365.com (2a01:111:e400:401e::38) with Microsoft SMTP Server (TLS) id 15.0.1024.12 via Frontend Transport; Thu, 11 Sep 2014 07:44:51 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD023.mail.protection.outlook.com (10.173.161.102) with Microsoft SMTP Server (TLS) id 15.0.1019.14 via Frontend Transport; Thu, 11 Sep 2014 07:44:51 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s8B7iiKZ020494; Thu, 11 Sep 2014 00:44:45 -0700 From: Robin Gong To: , , Subject: [PATCH v1] ARM: imx6: add pm_power_off support for i.mx6 chips Date: Thu, 11 Sep 2014 14:41:07 +0800 Message-ID: <1410417667-6436-1-git-send-email-b38343@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(62966002)(87286001)(85306004)(229853001)(104166001)(74662001)(31966008)(21056001)(107046002)(74502001)(26826002)(68736004)(83322001)(6806004)(44976005)(19580405001)(97736003)(84676001)(19580395003)(77156001)(90102001)(102836001)(36756003)(20776003)(33646002)(106466001)(47776003)(76482001)(93916002)(99396002)(92566001)(2201001)(92726001)(83072002)(50466002)(85852003)(105606002)(80022001)(64706001)(50226001)(104016003)(4396001)(46102001)(77982001)(81342001)(48376002)(95666004)(81542001)(87936001)(89996001)(88136002)(79102001)(50986999)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB344; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB344; X-Forefront-PRVS: 03319F6FEF Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=yibin.gong@freescale.com; X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140911_004516_128080_E5860DDF X-CRM114-Status: UNSURE ( 9.96 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.8 (-) Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All chips of i.mx6 can be powered off by programming SNVS. For example : On i.mx6q-sabresd board, PMIC_ON_REQ connect with external pmic ON/OFF pin, that will cause the whole PMIC powered off except VSNVS. And system can restart once PMIC_ON_REQ goes high by push POWRER key. Signed-off-by: Robin Gong --- arch/arm/mach-imx/common.h | 1 + arch/arm/mach-imx/mach-imx6q.c | 2 ++ arch/arm/mach-imx/mach-imx6sl.c | 2 ++ arch/arm/mach-imx/mach-imx6sx.c | 2 ++ arch/arm/mach-imx/system.c | 22 +++++++++++++++++++++- 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h index 1dabf43..baca11a 100644 --- a/arch/arm/mach-imx/common.h +++ b/arch/arm/mach-imx/common.h @@ -62,6 +62,7 @@ void mxc_set_cpu_type(unsigned int type); void mxc_restart(enum reboot_mode, const char *); void mxc_arch_reset_init(void __iomem *); void mxc_arch_reset_init_dt(void); +void mxc_power_off_init(void); int mx51_revision(void); int mx53_revision(void); void imx_set_aips(void __iomem *); diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index d51c6e9..3d6610d 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c @@ -270,6 +270,8 @@ static void __init imx6q_init_machine(void) mxc_arch_reset_init_dt(); + mxc_power_off_init(); + parent = imx_soc_device_init(); if (parent == NULL) pr_warn("failed to initialize soc device\n"); diff --git a/arch/arm/mach-imx/mach-imx6sl.c b/arch/arm/mach-imx/mach-imx6sl.c index ed263a2..c07e6e8 100644 --- a/arch/arm/mach-imx/mach-imx6sl.c +++ b/arch/arm/mach-imx/mach-imx6sl.c @@ -50,6 +50,8 @@ static void __init imx6sl_init_machine(void) mxc_arch_reset_init_dt(); + mxc_power_off_init(); + parent = imx_soc_device_init(); if (parent == NULL) pr_warn("failed to initialize soc device\n"); diff --git a/arch/arm/mach-imx/mach-imx6sx.c b/arch/arm/mach-imx/mach-imx6sx.c index 3de3b73..68ea070 100644 --- a/arch/arm/mach-imx/mach-imx6sx.c +++ b/arch/arm/mach-imx/mach-imx6sx.c @@ -20,6 +20,8 @@ static void __init imx6sx_init_machine(void) mxc_arch_reset_init_dt(); + mxc_power_off_init(); + parent = imx_soc_device_init(); if (parent == NULL) pr_warn("failed to initialize soc device\n"); diff --git a/arch/arm/mach-imx/system.c b/arch/arm/mach-imx/system.c index d14c33f..925fb29 100644 --- a/arch/arm/mach-imx/system.c +++ b/arch/arm/mach-imx/system.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -32,7 +33,9 @@ #include "common.h" #include "hardware.h" -static void __iomem *wdog_base; +#define SNVS_LPCR 0x04 + +static void __iomem *wdog_base, *snvs_base; static struct clk *wdog_clk; /* @@ -104,6 +107,23 @@ void __init mxc_arch_reset_init_dt(void) clk_prepare(wdog_clk); } +static void power_off_snvs(void) +{ + u32 value = readl(snvs_base + SNVS_LPCR); + /* set TOP and DP_EN bit */ + writel(value | 0x60, snvs_base + SNVS_LPCR); +} + +void __init mxc_power_off_init(void) +{ + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0-mon-rtc-lp"); + snvs_base = of_iomap(np, 0); + WARN_ON(!snvs_base); + pm_power_off = power_off_snvs; +} + #ifdef CONFIG_CACHE_L2X0 void __init imx_init_l2cache(void) {