From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9003CC43381 for ; Wed, 20 Mar 2019 05:11:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 610FF2186A for ; Wed, 20 Mar 2019 05:11:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YR7lkaln" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 610FF2186A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CnVOz38wO9Oc2pO3B8nbeP00Qy++IA3NHUw/IxVRr9A=; b=YR7lkalnLNwpUg dmqIry0VD8SYoK/iO0AAvyl4arADCxcifHvzloAqTN2NPUSVCODQtUbgE/U/7bgBZ9vWX9elQ0itv CMb+sKnxeUl7sGKkZlPuaHDrVkDPOj8QoKVKIGV9u1J/wF6FFugSq648MfocFXpTO5QkGJvZF+dwC 54OCZTStjKIBe2y+NA4dXgOyPtGEUAP+VAV/p7XTiYry5m47MGxV6VBOu3P7km/yv/aciqtaJmhDO sKX7/VwkZP4yZDQl4W6soq6CKQNiHgOvM6BfJb0JAC1+Dyxkdt/H6aJtpx2TqjCOM8uFUsH6/cPJB +j/RCSMb5uH9RI5Y1oQg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6TVN-0007Ur-6B; Wed, 20 Mar 2019 05:11:09 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6TVK-0007UK-LH for linux-arm-kernel@lists.infradead.org; Wed, 20 Mar 2019 05:11:07 +0000 X-Originating-IP: 182.72.246.220 Received: from localhost (unknown [182.72.246.220]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 86BD5240002; Wed, 20 Mar 2019 05:10:56 +0000 (UTC) Date: Wed, 20 Mar 2019 06:10:51 +0100 From: Alexandre Belloni To: Keerthy Subject: Re: [PATCH] rtc: omap: let the core handle range Message-ID: <20190320051051.GJ29054@piout.net> References: <20190318124438.26327-1-alexandre.belloni@bootlin.com> <20190318124438.26327-2-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190319_221106_845000_C6A5A6F8 X-CRM114-Status: GOOD ( 17.29 ) 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: linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 20/03/2019 10:20:17+0530, Keerthy wrote: > > > On 18/03/19 6:14 PM, Alexandre Belloni wrote: > > Let the core handle the RTC range instead of open coding it. > > Tested for rtcwake and checked for rtc time ticking on am437x-gp-evm. > Thanks! BTW, I couldn't get the RTC to wake my BBB from suspend to mem. I used: echo +5 > /sys/class/rtc/rtc0/wakealarm ; echo mem > /sys/power/state The interrupt seems to fire correctly when I'm not suspended, is there something I'm missing? > Tested-by: Keerthy > Reviewed-by: Keerthy > > > > > Signed-off-by: Alexandre Belloni > > --- > > drivers/rtc/rtc-omap.c | 22 ++++++---------------- > > 1 file changed, 6 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c > > index bbff0e2deb84..ea0eb48f3bb9 100644 > > --- a/drivers/rtc/rtc-omap.c > > +++ b/drivers/rtc/rtc-omap.c > > @@ -271,7 +271,7 @@ static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) > > } > > /* this hardware doesn't support "don't care" alarm fields */ > > -static int tm2bcd(struct rtc_time *tm) > > +static void tm2bcd(struct rtc_time *tm) > > { > > tm->tm_sec = bin2bcd(tm->tm_sec); > > tm->tm_min = bin2bcd(tm->tm_min); > > @@ -279,13 +279,7 @@ static int tm2bcd(struct rtc_time *tm) > > tm->tm_mday = bin2bcd(tm->tm_mday); > > tm->tm_mon = bin2bcd(tm->tm_mon + 1); > > - > > - /* epoch == 1900 */ > > - if (tm->tm_year < 100 || tm->tm_year > 199) > > - return -EINVAL; > > tm->tm_year = bin2bcd(tm->tm_year - 100); > > - > > - return 0; > > } > > static void bcd2tm(struct rtc_time *tm) > > @@ -328,8 +322,7 @@ static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm) > > { > > struct omap_rtc *rtc = dev_get_drvdata(dev); > > - if (tm2bcd(tm) < 0) > > - return -EINVAL; > > + tm2bcd(tm); > > local_irq_disable(); > > rtc_wait_not_busy(rtc); > > @@ -378,8 +371,7 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) > > struct omap_rtc *rtc = dev_get_drvdata(dev); > > u8 reg, irqwake_reg = 0; > > - if (tm2bcd(&alm->time) < 0) > > - return -EINVAL; > > + tm2bcd(&alm->time); > > local_irq_disable(); > > rtc_wait_not_busy(rtc); > > @@ -444,11 +436,7 @@ static void omap_rtc_power_off(void) > > rtc_tm_to_time(&tm, &now); > > rtc_time_to_tm(now + 1, &tm); > > - if (tm2bcd(&tm) < 0) { > > - dev_err(&rtc->rtc->dev, "power off failed\n"); > > - rtc->type->lock(rtc); > > - return; > > - } > > + tm2bcd(&tm); > > rtc_wait_not_busy(rtc); > > @@ -845,6 +833,8 @@ static int omap_rtc_probe(struct platform_device *pdev) > > } > > rtc->rtc->ops = &omap_rtc_ops; > > + rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_1900; > > + rtc->rtc->range_max = RTC_TIMESTAMP_END_2099; > > omap_rtc_nvmem_config.priv = rtc; > > /* handle periodic and alarm irqs */ > > -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel