Source
x
dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)",
/*
* Meson Watchdog Driver
*
* Copyright (c) 2014 Carlo Caione
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int timeout;
struct meson_wdt_data {
unsigned int enable;
unsigned int terminal_count_mask;
unsigned int count_unit;
};
static struct meson_wdt_data meson6_wdt_data = {
.enable = BIT(22),
.terminal_count_mask = 0x3fffff,
.count_unit = 100000, /* 10 us */
};
static struct meson_wdt_data meson8b_wdt_data = {
.enable = BIT(19),
.terminal_count_mask = 0xffff,
.count_unit = 7812, /* 128 us */
};
struct meson_wdt_dev {
struct watchdog_device wdt_dev;
void __iomem *wdt_base;
const struct meson_wdt_data *data;
};
static int meson_wdt_restart(struct watchdog_device *wdt_dev,
unsigned long action, void *data)
{
struct meson_wdt_dev *meson_wdt = watchdog_get_drvdata(wdt_dev);
u32 tc_reboot = MESON_WDT_DC_RESET;
tc_reboot |= meson_wdt->data->enable;
while (1) {
writel(tc_reboot, meson_wdt->wdt_base + MESON_WDT_TC);
mdelay(5);
}
return 0;
}
static int meson_wdt_ping(struct watchdog_device *wdt_dev)
{
struct meson_wdt_dev *meson_wdt = watchdog_get_drvdata(wdt_dev);
writel(0, meson_wdt->wdt_base + MESON_WDT_RESET);
return 0;
}
static void meson_wdt_change_timeout(struct watchdog_device *wdt_dev,
unsigned int timeout)
{