via_wdt.c (86a1e1896c2710402e29a875d8d830244274244d) via_wdt.c (0197c1c49ef1ff386b2ebb6d3b0fc85a8e174b5c)
1/*
2 * VIA Chipset Watchdog Driver
3 *
4 * Copyright (C) 2011 Sigfox
5 * License terms: GNU General Public License (GPL) version 2
6 * Author: Marc Vertes <marc.vertes@sigfox.com>
7 * Based on a preliminary version from Harald Welte <HaraldWelte@viatech.com>
8 * Timer code by Wim Van Sebroeck <wim@iguana.be>

--- 87 unchanged lines hidden (view full) ---

96 mod_timer(&timer, jiffies + WDT_HEARTBEAT);
97 } else
98 pr_crit("I will reboot your machine !\n");
99}
100
101static int wdt_ping(struct watchdog_device *wdd)
102{
103 /* calculate when the next userspace timeout will be */
1/*
2 * VIA Chipset Watchdog Driver
3 *
4 * Copyright (C) 2011 Sigfox
5 * License terms: GNU General Public License (GPL) version 2
6 * Author: Marc Vertes <marc.vertes@sigfox.com>
7 * Based on a preliminary version from Harald Welte <HaraldWelte@viatech.com>
8 * Timer code by Wim Van Sebroeck <wim@iguana.be>

--- 87 unchanged lines hidden (view full) ---

96 mod_timer(&timer, jiffies + WDT_HEARTBEAT);
97 } else
98 pr_crit("I will reboot your machine !\n");
99}
100
101static int wdt_ping(struct watchdog_device *wdd)
102{
103 /* calculate when the next userspace timeout will be */
104 next_heartbeat = jiffies + timeout * HZ;
104 next_heartbeat = jiffies + wdd->timeout * HZ;
105 return 0;
106}
107
108static int wdt_start(struct watchdog_device *wdd)
109{
110 unsigned int ctl = readl(wdt_mem);
111
105 return 0;
106}
107
108static int wdt_start(struct watchdog_device *wdd)
109{
110 unsigned int ctl = readl(wdt_mem);
111
112 writel(timeout, wdt_mem + VIA_WDT_COUNT);
112 writel(wdd->timeout, wdt_mem + VIA_WDT_COUNT);
113 writel(ctl | VIA_WDT_RUNNING | VIA_WDT_TRIGGER, wdt_mem);
114 wdt_ping(wdd);
115 mod_timer(&timer, jiffies + WDT_HEARTBEAT);
116 return 0;
117}
118
119static int wdt_stop(struct watchdog_device *wdd)
120{
121 unsigned int ctl = readl(wdt_mem);
122
123 writel(ctl & ~VIA_WDT_RUNNING, wdt_mem);
124 return 0;
125}
126
127static int wdt_set_timeout(struct watchdog_device *wdd,
128 unsigned int new_timeout)
129{
130 writel(new_timeout, wdt_mem + VIA_WDT_COUNT);
113 writel(ctl | VIA_WDT_RUNNING | VIA_WDT_TRIGGER, wdt_mem);
114 wdt_ping(wdd);
115 mod_timer(&timer, jiffies + WDT_HEARTBEAT);
116 return 0;
117}
118
119static int wdt_stop(struct watchdog_device *wdd)
120{
121 unsigned int ctl = readl(wdt_mem);
122
123 writel(ctl & ~VIA_WDT_RUNNING, wdt_mem);
124 return 0;
125}
126
127static int wdt_set_timeout(struct watchdog_device *wdd,
128 unsigned int new_timeout)
129{
130 writel(new_timeout, wdt_mem + VIA_WDT_COUNT);
131 timeout = new_timeout;
131 wdd->timeout = new_timeout;
132 return 0;
133}
134
135static const struct watchdog_info wdt_info = {
136 .identity = "VIA watchdog",
137 .options = WDIOF_CARDRESET |
138 WDIOF_SETTIMEOUT |
139 WDIOF_MAGICCLOSE |

--- 131 unchanged lines hidden ---
132 return 0;
133}
134
135static const struct watchdog_info wdt_info = {
136 .identity = "VIA watchdog",
137 .options = WDIOF_CARDRESET |
138 WDIOF_SETTIMEOUT |
139 WDIOF_MAGICCLOSE |

--- 131 unchanged lines hidden ---