]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
rtc: stmp3xxx: Don't reset the rtc in .probe() when watchdog is running
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sat, 9 Jun 2018 06:43:13 +0000 (08:43 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 11 Jul 2018 18:42:08 +0000 (20:42 +0200)
As pointed out in the added comment resetting the rtc also stops the
included watchdog. This is bad if the bootloader started the watchdog to
secure the boot process. So don't reset if the watchdog is running.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-stmp3xxx.c

index d578e40d5a506308a76307a5050fd61552fc9420..b76318fd5bb004b4fa492de45df151e9b46b9a35 100644 (file)
@@ -288,10 +288,22 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, rtc_data);
 
-       err = stmp_reset_block(rtc_data->io);
-       if (err) {
-               dev_err(&pdev->dev, "stmp_reset_block failed: %d\n", err);
-               return err;
+       /*
+        * Resetting the rtc stops the watchdog timer that is potentially
+        * running. So (assuming it is running on purpose) don't reset if the
+        * watchdog is enabled.
+        */
+       if (readl(rtc_data->io + STMP3XXX_RTC_CTRL) &
+           STMP3XXX_RTC_CTRL_WATCHDOGEN) {
+               dev_info(&pdev->dev,
+                        "Watchdog is running, skip resetting rtc\n");
+       } else {
+               err = stmp_reset_block(rtc_data->io);
+               if (err) {
+                       dev_err(&pdev->dev, "stmp_reset_block failed: %d\n",
+                               err);
+                       return err;
+               }
        }
 
        /*