From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754225AbbDNJMO (ORCPT ); Tue, 14 Apr 2015 05:12:14 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:48931 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753038AbbDNJMB (ORCPT ); Tue, 14 Apr 2015 05:12:01 -0400 From: Juergen Borleis To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, kernel@pengutronix.de, Alessandro Zummo , linux-arm-kernel@lists.infradead.org, Robert Schwebel Subject: [PATCH 4/5] RTC/i.MX/DryIce: when locked, do not fail silently Date: Tue, 14 Apr 2015 11:11:55 +0200 Message-Id: <1429002716-19821-5-git-send-email-jbe@pengutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429002716-19821-1-git-send-email-jbe@pengutronix.de> References: <1429002716-19821-1-git-send-email-jbe@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: jbe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Juergen Borleis Signed-off-by: Robert Schwebel [rsc: got NDA clearance from Freescale] --- drivers/rtc/rtc-imxdi.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c index b04c64f..de1a2e4 100644 --- a/drivers/rtc/rtc-imxdi.c +++ b/drivers/rtc/rtc-imxdi.c @@ -581,14 +581,36 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm) static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs) { struct imxdi_dev *imxdi = dev_get_drvdata(dev); + u32 dcr, dsr; int rc; + dcr = __raw_readl(imxdi->ioaddr + DCR); + dsr = __raw_readl(imxdi->ioaddr + DSR); + + if (!(dcr & DCR_TCE) || (dsr & DSR_SVF)) { + if (dcr & DCR_TCHL) { + /* we are even more out of luck */ + di_what_is_to_be_done(imxdi, "battery"); + return -EPERM; + } + if ((dcr & DCR_TCSL) || (dsr & DSR_SVF)) { + /* we are out of luck for now */ + di_what_is_to_be_done(imxdi, "main"); + return -EPERM; + } + } + /* zero the fractional part first */ rc = di_write_wait(imxdi, 0, DTCLR); - if (rc == 0) - rc = di_write_wait(imxdi, secs, DTCMR); + if (rc != 0) + return rc; - return rc; + rc = di_write_wait(imxdi, secs, DTCMR); + if (rc != 0) + return rc; + + return di_write_wait(imxdi, __raw_readl(imxdi->ioaddr + DCR) | + DCR_TCE, DCR); } static int dryice_rtc_alarm_irq_enable(struct device *dev, -- 2.1.4 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de. [2001:6f8:1178:4:290:27ff:fe1d:cc33]) by gmr-mx.google.com with ESMTPS id ec7si57257wib.3.2015.04.14.02.12.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 14 Apr 2015 02:12:00 -0700 (PDT) From: Juergen Borleis To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, kernel@pengutronix.de, Alessandro Zummo , linux-arm-kernel@lists.infradead.org, Robert Schwebel Subject: [rtc-linux] [PATCH 4/5] RTC/i.MX/DryIce: when locked, do not fail silently Date: Tue, 14 Apr 2015 11:11:55 +0200 Message-Id: <1429002716-19821-5-git-send-email-jbe@pengutronix.de> In-Reply-To: <1429002716-19821-1-git-send-email-jbe@pengutronix.de> References: <1429002716-19821-1-git-send-email-jbe@pengutronix.de> Reply-To: rtc-linux@googlegroups.com Content-Type: text/plain; charset=UTF-8 List-ID: List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Juergen Borleis Signed-off-by: Robert Schwebel [rsc: got NDA clearance from Freescale] --- drivers/rtc/rtc-imxdi.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c index b04c64f..de1a2e4 100644 --- a/drivers/rtc/rtc-imxdi.c +++ b/drivers/rtc/rtc-imxdi.c @@ -581,14 +581,36 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm) static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs) { struct imxdi_dev *imxdi = dev_get_drvdata(dev); + u32 dcr, dsr; int rc; + dcr = __raw_readl(imxdi->ioaddr + DCR); + dsr = __raw_readl(imxdi->ioaddr + DSR); + + if (!(dcr & DCR_TCE) || (dsr & DSR_SVF)) { + if (dcr & DCR_TCHL) { + /* we are even more out of luck */ + di_what_is_to_be_done(imxdi, "battery"); + return -EPERM; + } + if ((dcr & DCR_TCSL) || (dsr & DSR_SVF)) { + /* we are out of luck for now */ + di_what_is_to_be_done(imxdi, "main"); + return -EPERM; + } + } + /* zero the fractional part first */ rc = di_write_wait(imxdi, 0, DTCLR); - if (rc == 0) - rc = di_write_wait(imxdi, secs, DTCMR); + if (rc != 0) + return rc; - return rc; + rc = di_write_wait(imxdi, secs, DTCMR); + if (rc != 0) + return rc; + + return di_write_wait(imxdi, __raw_readl(imxdi->ioaddr + DCR) | + DCR_TCE, DCR); } static int dryice_rtc_alarm_irq_enable(struct device *dev, -- 2.1.4 -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout. From mboxrd@z Thu Jan 1 00:00:00 1970 From: jbe@pengutronix.de (Juergen Borleis) Date: Tue, 14 Apr 2015 11:11:55 +0200 Subject: [PATCH 4/5] RTC/i.MX/DryIce: when locked, do not fail silently In-Reply-To: <1429002716-19821-1-git-send-email-jbe@pengutronix.de> References: <1429002716-19821-1-git-send-email-jbe@pengutronix.de> Message-ID: <1429002716-19821-5-git-send-email-jbe@pengutronix.de> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Signed-off-by: Juergen Borleis Signed-off-by: Robert Schwebel [rsc: got NDA clearance from Freescale] --- drivers/rtc/rtc-imxdi.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c index b04c64f..de1a2e4 100644 --- a/drivers/rtc/rtc-imxdi.c +++ b/drivers/rtc/rtc-imxdi.c @@ -581,14 +581,36 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm) static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs) { struct imxdi_dev *imxdi = dev_get_drvdata(dev); + u32 dcr, dsr; int rc; + dcr = __raw_readl(imxdi->ioaddr + DCR); + dsr = __raw_readl(imxdi->ioaddr + DSR); + + if (!(dcr & DCR_TCE) || (dsr & DSR_SVF)) { + if (dcr & DCR_TCHL) { + /* we are even more out of luck */ + di_what_is_to_be_done(imxdi, "battery"); + return -EPERM; + } + if ((dcr & DCR_TCSL) || (dsr & DSR_SVF)) { + /* we are out of luck for now */ + di_what_is_to_be_done(imxdi, "main"); + return -EPERM; + } + } + /* zero the fractional part first */ rc = di_write_wait(imxdi, 0, DTCLR); - if (rc == 0) - rc = di_write_wait(imxdi, secs, DTCMR); + if (rc != 0) + return rc; - return rc; + rc = di_write_wait(imxdi, secs, DTCMR); + if (rc != 0) + return rc; + + return di_write_wait(imxdi, __raw_readl(imxdi->ioaddr + DCR) | + DCR_TCE, DCR); } static int dryice_rtc_alarm_irq_enable(struct device *dev, -- 2.1.4