watchdog: aspeed: Allow configuring for alternate boot
authorMilton Miller <miltonm@us.ibm.com>
Thu, 15 Mar 2018 16:02:06 +0000 (11:02 -0500)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sat, 24 Mar 2018 09:19:39 +0000 (10:19 +0100)
Allow the device tree to specify a watchdog to fallover to
the alternate boot source.

The aspeeed watchdog can set a latch directing flash chip select 0 to
chip select 1, allowing boot from an alternate media if the watchdog
is not reset in time.  On the ast2400 bank 1 also goes to flash bank 1,
while on the ast2500 the chip selects are swapped.

Also clear the secondary boot bit during the machine restart operation.
Otherwise, the system will switch to the alternate boot after every
reboot, which is not desired.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
Signed-off-by: Eddie James <eajames@linux.vnet.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/aspeed_wdt.c

index ca5b91e2eb9257c1be5da003fec6282dff64ca5a..65f23201c63ac4bf1123dddf4654f5a773f12e8f 100644 (file)
@@ -46,6 +46,7 @@ MODULE_DEVICE_TABLE(of, aspeed_wdt_of_table);
 #define WDT_RELOAD_VALUE       0x04
 #define WDT_RESTART            0x08
 #define WDT_CTRL               0x0C
+#define   WDT_CTRL_BOOT_SECONDARY      BIT(7)
 #define   WDT_CTRL_RESET_MODE_SOC      (0x00 << 5)
 #define   WDT_CTRL_RESET_MODE_FULL_CHIP        (0x01 << 5)
 #define   WDT_CTRL_RESET_MODE_ARM_CPU  (0x10 << 5)
@@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd,
 {
        struct aspeed_wdt *wdt = to_aspeed_wdt(wdd);
 
+       wdt->ctrl &= ~WDT_CTRL_BOOT_SECONDARY;
        aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000);
 
        mdelay(1000);
@@ -242,6 +244,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
        }
        if (of_property_read_bool(np, "aspeed,external-signal"))
                wdt->ctrl |= WDT_CTRL_WDT_EXT;
+       if (of_property_read_bool(np, "aspeed,alt-boot"))
+               wdt->ctrl |= WDT_CTRL_BOOT_SECONDARY;
 
        if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE)  {
                /*