#define RTIWWDRXCTRL 0xa4
#define RTIWWDSIZECTRL 0xa8
-#define RTIWWDRX_NMI 0xa
+#define RTIWWDRXN_RST 0x5
+#define RTIWWDRXN_NMI 0xa
#define RTIWWDSIZE_50P 0x50
#define RTIWWDSIZE_25P 0x500
static int heartbeat;
+struct rti_wdt_data {
+ bool nmi;
+};
+
/*
* struct to hold data for each WDT device
* @base - base io address of WD device
* @freq - source clock frequency of WDT
* @wdd - hold watchdog device as is in WDT core
+ * @nmi - Set if this WDT instance supports generating NMI
*/
struct rti_wdt_device {
void __iomem *base;
unsigned long freq;
struct watchdog_device wdd;
+ bool nmi;
};
static int rti_wdt_start(struct watchdog_device *wdd)
{
u32 timer_margin;
struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd);
+ u8 reaction;
int ret;
ret = pm_runtime_resume_and_get(wdd->parent);
*/
wdd->min_hw_heartbeat_ms = 520 * wdd->timeout + MAX_HW_ERROR;
- /* Generate NMI when wdt expires */
- writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL);
+ /* When WDT expires, generate NMI or reset if NMI not supported */
+ if (wdt->nmi)
+ reaction = RTIWWDRXN_NMI;
+ else
+ reaction = RTIWWDRXN_RST;
+
+ writel_relaxed(reaction, wdt->base + RTIWWDRXCTRL);
/* Open window size 50%; this is the largest window size available */
writel_relaxed(RTIWWDSIZE_50P, wdt->base + RTIWWDSIZECTRL);
{
int ret = 0;
struct device *dev = &pdev->dev;
+ const struct rti_wdt_data *data;
struct watchdog_device *wdd;
struct rti_wdt_device *wdt;
struct clk *clk;
wdd->timeout = DEFAULT_HEARTBEAT;
wdd->parent = dev;
+ data = device_get_match_data(dev);
+ if (!data) {
+ ret = -ENODEV;
+ goto err_iomap;
+ }
+
+ wdt->nmi = data->nmi;
+
watchdog_set_drvdata(wdd, wdt);
watchdog_set_nowayout(wdd, 1);
watchdog_set_restart_priority(wdd, 128);
pm_runtime_disable(&pdev->dev);
}
+static const struct rti_wdt_data rti_wdt_j7_data = {
+ .nmi = true,
+};
+
+static const struct rti_wdt_data rti_wdt_am62l_data = {
+ .nmi = false,
+};
+
static const struct of_device_id rti_wdt_of_match[] = {
- { .compatible = "ti,j7-rti-wdt", },
+ { .compatible = "ti,j7-rti-wdt", .data = &rti_wdt_j7_data },
+ { .compatible = "ti,am62l-rti-wdt", .data = &rti_wdt_am62l_data },
{},
};
MODULE_DEVICE_TABLE(of, rti_wdt_of_match);