Merge remote-tracking branch 'remotes/tegra/android-tegra-2.6.36-honeycomb-mr1' into...
[firefly-linux-kernel-4.4.55.git] / drivers / rtc / rtc-wm831x.c
old mode 100644 (file)
new mode 100755 (executable)
index 82931dc..9f87cbc
@@ -424,7 +424,9 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
        int per_irq = platform_get_irq_byname(pdev, "PER");
        int alm_irq = platform_get_irq_byname(pdev, "ALM");
        int ret = 0;
+       struct rtc_time tm;
 
+       //printk("wm831x_rtc_probe\n");
        wm831x_rtc = kzalloc(sizeof(*wm831x_rtc), GFP_KERNEL);
        if (wm831x_rtc == NULL)
                return -ENOMEM;
@@ -440,6 +442,17 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
        if (ret & WM831X_RTC_ALM_ENA)
                wm831x_rtc->alarm_enabled = 1;
 
+       ret = wm831x_rtc_readtime(&pdev->dev, &tm);
+       if (ret < 0 || tm.tm_year < 111) {
+               if (ret)
+                       dev_err(&pdev->dev, "Failed to read RTC time\n");
+               else
+                       dev_err(&pdev->dev, "Invalid RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n",
+                               1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, tm.tm_wday,
+                               tm.tm_hour, tm.tm_min, tm.tm_sec);
+               wm831x_rtc_set_mmss(&pdev->dev, 1293883200); // 2011-01-01 12:00:00
+       }
+
        device_init_wakeup(&pdev->dev, 1);
 
        wm831x_rtc->rtc = rtc_device_register("wm831x", &pdev->dev,