Skip to content

Commit c0a5f4a

Browse files
Rajkumar Kasirajantorvalds
Rajkumar Kasirajan
authored andcommitted
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 <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Cc: Mattias Wallin <[email protected]> Cc: Alessandro Zummo <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1be5f0b commit c0a5f4a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/rtc/rtc-pl031.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
312312
int ret;
313313
struct pl031_local *ldata;
314314
struct rtc_class_ops *ops = id->data;
315+
unsigned long time;
315316

316317
ret = amba_request_regions(adev, NULL);
317318
if (ret)
@@ -343,6 +344,23 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
343344
writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN,
344345
ldata->base + RTC_CR);
345346

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+
346364
ldata->rtc = rtc_device_register("pl031", &adev->dev, ops,
347365
THIS_MODULE);
348366
if (IS_ERR(ldata->rtc)) {

0 commit comments

Comments
 (0)