aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorRajkumar Kasirajan <rajkumar.kasirajan@stericsson.com>2012-05-17 20:03:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-17 21:00:51 -0400
commitc0a5f4a05af588a0f9951f8d24e2564b09501918 (patch)
treef96b6f0e201978ad9d2cb03a59a83940304fbe3b /drivers/rtc
parent1be5f0b7575e090fd100a98b303860879b5800de (diff)
drivers/rtc/rtc-pl031.c: configure correct wday for 2000-01-01
The reset date of the ST Micro version of PL031 is 2000-01-01. The correct weekday for 2000-01-01 is saturday, but pl031 is initialized to sunday. This may lead to alarm malfunction, so configure the correct wday if RTC_DR indicates reset. Signed-off-by: Rajkumar Kasirajan <rajkumar.kasirajan@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Cc: Mattias Wallin <mattias.wallin@stericsson.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-pl031.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 684ef4bbfce4..f027c063fb20 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -312,6 +312,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
312 int ret; 312 int ret;
313 struct pl031_local *ldata; 313 struct pl031_local *ldata;
314 struct rtc_class_ops *ops = id->data; 314 struct rtc_class_ops *ops = id->data;
315 unsigned long time;
315 316
316 ret = amba_request_regions(adev, NULL); 317 ret = amba_request_regions(adev, NULL);
317 if (ret) 318 if (ret)
@@ -343,6 +344,23 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
343 writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, 344 writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN,
344 ldata->base + RTC_CR); 345 ldata->base + RTC_CR);
345 346
347 /*
348 * On ST PL031 variants, the RTC reset value does not provide correct
349 * weekday for 2000-01-01. Correct the erroneous sunday to saturday.
350 */
351 if (ldata->hw_designer == AMBA_VENDOR_ST) {
352 if (readl(ldata->base + RTC_YDR) == 0x2000) {
353 time = readl(ldata->base + RTC_DR);
354 if ((time &
355 (RTC_MON_MASK | RTC_MDAY_MASK | RTC_WDAY_MASK))
356 == 0x02120000) {
357 time = time | (0x7 << RTC_WDAY_SHIFT);
358 writel(0x2000, ldata->base + RTC_YLR);
359 writel(time, ldata->base + RTC_LR);
360 }
361 }
362 }
363
346 ldata->rtc = rtc_device_register("pl031", &adev->dev, ops, 364 ldata->rtc = rtc_device_register("pl031", &adev->dev, ops,
347 THIS_MODULE); 365 THIS_MODULE);
348 if (IS_ERR(ldata->rtc)) { 366 if (IS_ERR(ldata->rtc)) {