From patchwork Mon Oct 27 22:40:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 5166601 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 A6ACAC11AC for ; Mon, 27 Oct 2014 22:43:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0002201C8 for ; Mon, 27 Oct 2014 22:43:31 +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 DC8AE201B4 for ; Mon, 27 Oct 2014 22:43:30 +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 1Xisy7-00075P-Mi; Mon, 27 Oct 2014 22:40:55 +0000 Received: from mail.linuxfoundation.org ([140.211.169.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xisy4-00071x-IM for linux-arm-kernel@lists.infradead.org; Mon, 27 Oct 2014 22:40:53 +0000 Received: from akpm3.mtv.corp.google.com (unknown [216.239.45.95]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 54355A54; Mon, 27 Oct 2014 22:40:30 +0000 (UTC) Date: Mon, 27 Oct 2014 15:40:31 -0700 From: Andrew Morton To: Johan Hovold Subject: Re: [PATCH v3] rtc: omap: add support for pmic_power_en Message-Id: <20141027154031.4492ea11d401045ca04a3ff8@linux-foundation.org> In-Reply-To: <1414397368-26480-1-git-send-email-johan@kernel.org> References: <1413913086-12730-1-git-send-email-johan@kernel.org> <1414397368-26480-1-git-send-email-johan@kernel.org> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141027_154052_630024_9A57531B X-CRM114-Status: GOOD ( 18.60 ) X-Spam-Score: -2.3 (--) Cc: Alessandro Zummo , rtc-linux@googlegroups.com, devicetree@vger.kernel.org, Tony Lindgren , j-keerthy@ti.com, nsekhar@ti.com, linux-kernel@vger.kernel.org, Felipe Balbi , t-kristo@ti.com, Lokesh Vutla , linux-arm-kernel@lists.infradead.org, =?ISO-8859-1?Q?Beno=EEt?= Cousson , linux-omap@vger.kernel.org, Guenter Roeck 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.5 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 Mon, 27 Oct 2014 09:09:28 +0100 Johan Hovold wrote: > Add new property "ti,system-power-controller" to register the RTC as a > power-off handler. > > Some RTC IP revisions can control an external PMIC via the pmic_power_en > pin, which can be configured to transition to OFF on ALARM2 events and > back to ON on subsequent ALARM (wakealarm) events. > > This is based on earlier work by Colin Foe-Parker and AnilKumar Ch. [1] > > [1] https://www.mail-archive.com/linux-omap@vger.kernel.org/msg82127.html > > Tested-by: Felipe Balbi > Signed-off-by: Johan Hovold > --- > > Changes since v2: > - add two-second delay to allow alarm to trigger before returning hmpf. As this sentence is below the ^--- it doesn't get into the changelog. > ... > > +static void omap_rtc_power_off(void) > +{ > + struct omap_rtc *rtc = omap_rtc_power_off_rtc; > + struct rtc_time tm; > + unsigned long now; > + u32 val; > + > + /* enable pmic_power_en control */ > + val = rtc_readl(rtc, OMAP_RTC_PMIC_REG); > + rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN); > + > + /* set alarm two seconds from now */ > + omap_rtc_read_time_raw(rtc, &tm); > + bcd2tm(&tm); > + rtc_tm_to_time(&tm, &now); > + rtc_time_to_tm(now + 2, &tm); > + > + if (tm2bcd(&tm) < 0) { > + dev_err(&rtc->rtc->dev, "power off failed\n"); > + return; > + } > + > + rtc_wait_not_busy(rtc); > + > + rtc_write(rtc, OMAP_RTC_ALARM2_SECONDS_REG, tm.tm_sec); > + rtc_write(rtc, OMAP_RTC_ALARM2_MINUTES_REG, tm.tm_min); > + rtc_write(rtc, OMAP_RTC_ALARM2_HOURS_REG, tm.tm_hour); > + rtc_write(rtc, OMAP_RTC_ALARM2_DAYS_REG, tm.tm_mday); > + rtc_write(rtc, OMAP_RTC_ALARM2_MONTHS_REG, tm.tm_mon); > + rtc_write(rtc, OMAP_RTC_ALARM2_YEARS_REG, tm.tm_year); > + > + /* > + * enable ALARM2 interrupt > + * > + * NOTE: this fails on AM3352 if rtc_write (writeb) is used > + */ > + val = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG); > + rtc_writel(rtc, OMAP_RTC_INTERRUPTS_REG, > + val | OMAP_RTC_INTERRUPTS_IT_ALARM2); > + > + mdelay(2000); And it is uncommented. How on earth is a reader to know why this is here? I can do this But it doesn't explain *why* we want the alarm to trigger before returning. --- a/drivers/rtc/rtc-omap.c~rtc-omap-add-support-for-pmic_power_en-v3-fix +++ a/drivers/rtc/rtc-omap.c @@ -417,6 +417,7 @@ static void omap_rtc_power_off(void) rtc_writel(rtc, OMAP_RTC_INTERRUPTS_REG, val | OMAP_RTC_INTERRUPTS_IT_ALARM2); + /* Allow alarm to trigger before returning */ mdelay(2000); }