From patchwork Thu Sep 25 02:13:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 4972851 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0BD1FBEEA6 for ; Thu, 25 Sep 2014 03:20:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 294552025A for ; Thu, 25 Sep 2014 03:20:45 +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 1B9BD201EF for ; Thu, 25 Sep 2014 03:20:44 +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 1XWzZx-0005tX-Nk; Thu, 25 Sep 2014 03:18:49 +0000 Received: from mail-by2on0125.outbound.protection.outlook.com ([207.46.100.125] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWzZu-0005nD-Mm for linux-arm-kernel@lists.infradead.org; Thu, 25 Sep 2014 03:18:47 +0000 Received: from DM2PR03CA0003.namprd03.prod.outlook.com (10.141.96.13) by DM2PR03MB349.namprd03.prod.outlook.com (10.141.54.11) with Microsoft SMTP Server (TLS) id 15.0.1034.8; Thu, 25 Sep 2014 03:18:24 +0000 Received: from BY2FFO11FD003.protection.gbl (2a01:111:f400:7c0c::193) by DM2PR03CA0003.outlook.office365.com (2a01:111:e400:2428::13) with Microsoft SMTP Server (TLS) id 15.0.1029.13 via Frontend Transport; Thu, 25 Sep 2014 03:18:23 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD003.mail.protection.outlook.com (10.1.14.125) with Microsoft SMTP Server (TLS) id 15.0.1029.15 via Frontend Transport; Thu, 25 Sep 2014 03:18:23 +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 s8P3IEHF009952; Wed, 24 Sep 2014 20:18:16 -0700 From: Robin Gong To: , , , , , , , , , Subject: [PATCH v1] rtc: snvs: add poweroff function Date: Thu, 25 Sep 2014 10:13:53 +0800 Message-ID: <1411611233-29919-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:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(50466002)(81342003)(19580395003)(46102003)(50226001)(68736004)(77982003)(21056001)(31966008)(47776003)(81542003)(44976005)(74502003)(83072002)(20776003)(92566001)(83322001)(6806004)(10300001)(90102001)(89996001)(104016003)(87286001)(120916001)(104166001)(36756003)(33646002)(92726001)(106466001)(99396003)(229853001)(87936001)(77156001)(80022003)(107046002)(88136002)(50986999)(64706001)(19580405001)(74662003)(85306004)(102836001)(85852003)(79102003)(48376002)(95666004)(97736003)(84676001)(2201001)(105606002)(76482002)(4396001)(93916002)(62966002)(921003)(1121002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR03MB349; H:tx30smr01.am.freescale.net; FPR:; MLV:sfv; 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:DM2PR03MB349; X-Forefront-PRVS: 0345CFD558 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-20140924_201846_787493_80003335 X-CRM114-Status: UNSURE ( 8.69 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) Cc: devicetree@vger.kernel.org, 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=-2.6 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 On i.mx6 chips, PMIC_ON_REQ can be pulled by snvs LPCR. That can be used poweroff system if PMIC_ON_REQ connected with external PMIC or power control circuit.Power up again if PMIC_ON_REQ pulled high. Signed-off-by: Robin Gong --- Documentation/devicetree/bindings/crypto/fsl-sec4.txt | 4 ++++ drivers/rtc/rtc-snvs.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt index e402277..00d67f2 100644 --- a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt +++ b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt @@ -363,11 +363,15 @@ Secure Non-Volatile Storage (SNVS) Low Power (LP) RTC Node Value type: Definition: A standard property. Specifies the physical address and length of the SNVS LP configuration registers. + - fsl,poweroff + Usage: opertional, recommend if PMIC_ON_REQ connected with external + PMIC or power control circuit. EXAMPLE sec_mon_rtc_lp@314000 { compatible = "fsl,sec-v4.0-mon-rtc-lp"; reg = <0x34 0x58>; + fsl,poweroff; }; ===================================================================== diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index fa384fe..ef32541 100644 --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c @@ -29,6 +29,8 @@ #define SNVS_LPCR_SRTC_ENV (1 << 0) #define SNVS_LPCR_LPTA_EN (1 << 1) #define SNVS_LPCR_LPWUI_EN (1 << 3) +#define SNVS_LPCR_DP (1 << 5) +#define SNVS_LPCR_TOP (1 << 6) #define SNVS_LPSR_LPTA (1 << 0) #define SNVS_LPPGDR_INIT 0x41736166 @@ -41,6 +43,8 @@ struct snvs_rtc_data { spinlock_t lock; }; +static void __iomem *snvs_base; + static u32 rtc_read_lp_counter(void __iomem *ioaddr) { u64 read1, read2; @@ -241,8 +245,17 @@ static irqreturn_t snvs_rtc_irq_handler(int irq, void *dev_id) return events ? IRQ_HANDLED : IRQ_NONE; } +static void snvs_poweroff(void) +{ + u32 value; + + value = readl(snvs_base + SNVS_LPCR); + writel(value | SNVS_LPCR_DP | SNVS_LPCR_TOP, snvs_base + SNVS_LPCR); +} + static int snvs_rtc_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; struct snvs_rtc_data *data; struct resource *res; int ret; @@ -260,6 +273,11 @@ static int snvs_rtc_probe(struct platform_device *pdev) if (data->irq < 0) return data->irq; + if (np && of_get_property(np, "fsl,poweroff", NULL)) { + snvs_base = data->ioaddr; + pm_power_off = snvs_poweroff; + } + platform_set_drvdata(pdev, data); spin_lock_init(&data->lock);