Merge branch 'v4.16-fixes'

This commit is contained in:
Wim Van Sebroeck 2018-03-13 19:14:41 +01:00
commit 2e8ebed6ed
3 changed files with 33 additions and 12 deletions

View File

@ -232,11 +232,14 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC | WDT_CTRL_RESET_SYSTEM; wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC | WDT_CTRL_RESET_SYSTEM;
} else { } else {
if (!strcmp(reset_type, "cpu")) if (!strcmp(reset_type, "cpu"))
wdt->ctrl |= WDT_CTRL_RESET_MODE_ARM_CPU; wdt->ctrl |= WDT_CTRL_RESET_MODE_ARM_CPU |
WDT_CTRL_RESET_SYSTEM;
else if (!strcmp(reset_type, "soc")) else if (!strcmp(reset_type, "soc"))
wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC; wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC |
WDT_CTRL_RESET_SYSTEM;
else if (!strcmp(reset_type, "system")) else if (!strcmp(reset_type, "system"))
wdt->ctrl |= WDT_CTRL_RESET_SYSTEM; wdt->ctrl |= WDT_CTRL_RESET_MODE_FULL_CHIP |
WDT_CTRL_RESET_SYSTEM;
else if (strcmp(reset_type, "none")) else if (strcmp(reset_type, "none"))
return -EINVAL; return -EINVAL;
} }

View File

@ -34,6 +34,7 @@
#define WDOG_CONTROL_REG_OFFSET 0x00 #define WDOG_CONTROL_REG_OFFSET 0x00
#define WDOG_CONTROL_REG_WDT_EN_MASK 0x01 #define WDOG_CONTROL_REG_WDT_EN_MASK 0x01
#define WDOG_CONTROL_REG_RESP_MODE_MASK 0x02
#define WDOG_TIMEOUT_RANGE_REG_OFFSET 0x04 #define WDOG_TIMEOUT_RANGE_REG_OFFSET 0x04
#define WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT 4 #define WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT 4
#define WDOG_CURRENT_COUNT_REG_OFFSET 0x08 #define WDOG_CURRENT_COUNT_REG_OFFSET 0x08
@ -56,6 +57,9 @@ struct dw_wdt {
unsigned long rate; unsigned long rate;
struct watchdog_device wdd; struct watchdog_device wdd;
struct reset_control *rst; struct reset_control *rst;
/* Save/restore */
u32 control;
u32 timeout;
}; };
#define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd) #define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd)
@ -121,14 +125,23 @@ static int dw_wdt_set_timeout(struct watchdog_device *wdd, unsigned int top_s)
return 0; return 0;
} }
static void dw_wdt_arm_system_reset(struct dw_wdt *dw_wdt)
{
u32 val = readl(dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
/* Disable interrupt mode; always perform system reset. */
val &= ~WDOG_CONTROL_REG_RESP_MODE_MASK;
/* Enable watchdog. */
val |= WDOG_CONTROL_REG_WDT_EN_MASK;
writel(val, dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
}
static int dw_wdt_start(struct watchdog_device *wdd) static int dw_wdt_start(struct watchdog_device *wdd)
{ {
struct dw_wdt *dw_wdt = to_dw_wdt(wdd); struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
dw_wdt_set_timeout(wdd, wdd->timeout); dw_wdt_set_timeout(wdd, wdd->timeout);
dw_wdt_arm_system_reset(dw_wdt);
writel(WDOG_CONTROL_REG_WDT_EN_MASK,
dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
return 0; return 0;
} }
@ -152,16 +165,13 @@ static int dw_wdt_restart(struct watchdog_device *wdd,
unsigned long action, void *data) unsigned long action, void *data)
{ {
struct dw_wdt *dw_wdt = to_dw_wdt(wdd); struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
u32 val;
writel(0, dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET); writel(0, dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
val = readl(dw_wdt->regs + WDOG_CONTROL_REG_OFFSET); if (dw_wdt_is_enabled(dw_wdt))
if (val & WDOG_CONTROL_REG_WDT_EN_MASK)
writel(WDOG_COUNTER_RESTART_KICK_VALUE, writel(WDOG_COUNTER_RESTART_KICK_VALUE,
dw_wdt->regs + WDOG_COUNTER_RESTART_REG_OFFSET); dw_wdt->regs + WDOG_COUNTER_RESTART_REG_OFFSET);
else else
writel(WDOG_CONTROL_REG_WDT_EN_MASK, dw_wdt_arm_system_reset(dw_wdt);
dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
/* wait for reset to assert... */ /* wait for reset to assert... */
mdelay(500); mdelay(500);
@ -198,6 +208,9 @@ static int dw_wdt_suspend(struct device *dev)
{ {
struct dw_wdt *dw_wdt = dev_get_drvdata(dev); struct dw_wdt *dw_wdt = dev_get_drvdata(dev);
dw_wdt->control = readl(dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
dw_wdt->timeout = readl(dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
clk_disable_unprepare(dw_wdt->clk); clk_disable_unprepare(dw_wdt->clk);
return 0; return 0;
@ -211,6 +224,9 @@ static int dw_wdt_resume(struct device *dev)
if (err) if (err)
return err; return err;
writel(dw_wdt->timeout, dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
writel(dw_wdt->control, dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
dw_wdt_ping(&dw_wdt->wdd); dw_wdt_ping(&dw_wdt->wdd);
return 0; return 0;

View File

@ -154,8 +154,10 @@ static int sprd_wdt_enable(struct sprd_wdt *wdt)
if (ret) if (ret)
return ret; return ret;
ret = clk_prepare_enable(wdt->rtc_enable); ret = clk_prepare_enable(wdt->rtc_enable);
if (ret) if (ret) {
clk_disable_unprepare(wdt->enable);
return ret; return ret;
}
sprd_wdt_unlock(wdt->base); sprd_wdt_unlock(wdt->base);
val = readl_relaxed(wdt->base + SPRD_WDT_CTRL); val = readl_relaxed(wdt->base + SPRD_WDT_CTRL);