diff options
author | Juergen Borleis <jbe@pengutronix.de> | 2015-04-27 09:59:51 -0400 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2015-06-19 14:03:21 -0400 |
commit | 9bb698c60a12d3b5db62f99a0874565c791e998b (patch) | |
tree | 29cc1d45d227b0ab8296e5f05d71fb28d9858936 /drivers/rtc/rtc-imxdi.c | |
parent | a7c535e3a8e50e625750d2aa0ed4f84591ca7bfa (diff) |
rtc: imxdi: when locked, do not fail silently
If the DryICE unit is locked it is impossible to set the time. Provide an
error message for this case.
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
Signed-off-by: Robert Schwebel <rsc@pengutronix.de>
[rsc: got NDA clearance from Freescale]
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc/rtc-imxdi.c')
-rw-r--r-- | drivers/rtc/rtc-imxdi.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c index a08da4a353db..7bffd7f0e306 100644 --- a/drivers/rtc/rtc-imxdi.c +++ b/drivers/rtc/rtc-imxdi.c | |||
@@ -566,14 +566,35 @@ static int dryice_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
566 | static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs) | 566 | static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs) |
567 | { | 567 | { |
568 | struct imxdi_dev *imxdi = dev_get_drvdata(dev); | 568 | struct imxdi_dev *imxdi = dev_get_drvdata(dev); |
569 | u32 dcr, dsr; | ||
569 | int rc; | 570 | int rc; |
570 | 571 | ||
572 | dcr = readl(imxdi->ioaddr + DCR); | ||
573 | dsr = readl(imxdi->ioaddr + DSR); | ||
574 | |||
575 | if (!(dcr & DCR_TCE) || (dsr & DSR_SVF)) { | ||
576 | if (dcr & DCR_TCHL) { | ||
577 | /* we are even more out of luck */ | ||
578 | di_what_is_to_be_done(imxdi, "battery"); | ||
579 | return -EPERM; | ||
580 | } | ||
581 | if ((dcr & DCR_TCSL) || (dsr & DSR_SVF)) { | ||
582 | /* we are out of luck for now */ | ||
583 | di_what_is_to_be_done(imxdi, "main"); | ||
584 | return -EPERM; | ||
585 | } | ||
586 | } | ||
587 | |||
571 | /* zero the fractional part first */ | 588 | /* zero the fractional part first */ |
572 | rc = di_write_wait(imxdi, 0, DTCLR); | 589 | rc = di_write_wait(imxdi, 0, DTCLR); |
573 | if (rc == 0) | 590 | if (rc != 0) |
574 | rc = di_write_wait(imxdi, secs, DTCMR); | 591 | return rc; |
575 | 592 | ||
576 | return rc; | 593 | rc = di_write_wait(imxdi, secs, DTCMR); |
594 | if (rc != 0) | ||
595 | return rc; | ||
596 | |||
597 | return di_write_wait(imxdi, readl(imxdi->ioaddr + DCR) | DCR_TCE, DCR); | ||
577 | } | 598 | } |
578 | 599 | ||
579 | static int dryice_rtc_alarm_irq_enable(struct device *dev, | 600 | static int dryice_rtc_alarm_irq_enable(struct device *dev, |