#include <common.h>
#include <dm.h>
+#include <clk.h>
#include <wdt.h>
+#include <linux/kernel.h>
#include <asm/io.h>
#include <asm/arch/cpu.h>
#include <asm/arch/soc.h>
void __iomem *rstout;
void __iomem *rstout_mask;
u32 timeout;
+ unsigned long clk_rate;
+ struct clk clk;
};
#define RSTOUT_ENABLE_BIT BIT(8)
struct orion_wdt_priv *priv = dev_get_priv(dev);
/* Reload watchdog duration */
- writel(priv->timeout, priv->reg + priv->wdt_counter_offset);
+ writel(priv->clk_rate * priv->timeout,
+ priv->reg + priv->wdt_counter_offset);
return 0;
}
-static int orion_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
+static int orion_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
{
struct orion_wdt_priv *priv = dev_get_priv(dev);
u32 reg;
- priv->timeout = (u32) timeout;
+ priv->timeout = DIV_ROUND_UP(timeout_ms, 1000);
/* Enable the fixed watchdog clock input */
reg = readl(priv->reg + TIMER_CTRL);
writel(reg, priv->reg + TIMER_CTRL);
/* Set watchdog duration */
- writel(priv->timeout, priv->reg + priv->wdt_counter_offset);
+ writel(priv->clk_rate * priv->timeout,
+ priv->reg + priv->wdt_counter_offset);
/* Clear the watchdog expiration bit */
reg = readl(priv->reg + TIMER_A370_STATUS);
static int orion_wdt_probe(struct udevice *dev)
{
+ struct orion_wdt_priv *priv = dev_get_priv(dev);
+ int ret;
+
debug("%s: Probing wdt%u\n", __func__, dev->seq);
orion_wdt_stop(dev);
+ ret = clk_get_by_name(dev, "fixed", &priv->clk);
+ if (!ret)
+ priv->clk_rate = clk_get_rate(&priv->clk);
+ else
+ priv->clk_rate = 25000000;
+
return 0;
}