Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2016 National Instruments Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/watchdog.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define LOCK			0xA5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define UNLOCK			0x5A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define WDT_CTRL_RESET_EN	BIT(7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define WDT_RELOAD_PORT_EN	BIT(7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define WDT_CTRL		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define WDT_RELOAD_CTRL		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define WDT_PRESET_PRESCALE	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define WDT_REG_LOCK		5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define WDT_COUNT		6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define WDT_RELOAD_PORT		7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define WDT_MIN_TIMEOUT		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define WDT_MAX_TIMEOUT		464
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define WDT_DEFAULT_TIMEOUT	80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define WDT_MAX_COUNTER		15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static unsigned int timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) module_param(timeout, uint, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) MODULE_PARM_DESC(timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		 "Watchdog timeout in seconds. (default="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		 __MODULE_STRING(WDT_DEFAULT_TIMEOUT) ")");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static bool nowayout = WATCHDOG_NOWAYOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) module_param(nowayout, bool, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) MODULE_PARM_DESC(nowayout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		 "Watchdog cannot be stopped once started. (default="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) struct nic7018_wdt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	u16 io_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	u32 period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	struct watchdog_device wdd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) struct nic7018_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	u32 period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	u8 divider;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) static const struct nic7018_config nic7018_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	{  2, 4 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	{ 32, 5 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) static inline u32 nic7018_timeout(u32 period, u8 counter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	return period * counter - period / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static const struct nic7018_config *nic7018_get_config(u32 timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 						       u8 *counter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	const struct nic7018_config *config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	u8 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	if (timeout < 30 && timeout != 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		config = &nic7018_configs[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		count = timeout / 2 + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		config = &nic7018_configs[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		count = DIV_ROUND_UP(timeout + 16, 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		if (count > WDT_MAX_COUNTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			count = WDT_MAX_COUNTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	*counter = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	return config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) static int nic7018_set_timeout(struct watchdog_device *wdd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			       unsigned int timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct nic7018_wdt *wdt = watchdog_get_drvdata(wdd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	const struct nic7018_config *config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	u8 counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	config = nic7018_get_config(timeout, &counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	outb(counter << 4 | config->divider,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	     wdt->io_base + WDT_PRESET_PRESCALE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	wdd->timeout = nic7018_timeout(config->period, counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	wdt->period = config->period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static int nic7018_start(struct watchdog_device *wdd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	struct nic7018_wdt *wdt = watchdog_get_drvdata(wdd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	u8 control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	nic7018_set_timeout(wdd, wdd->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	control = inb(wdt->io_base + WDT_RELOAD_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	outb(control | WDT_RELOAD_PORT_EN, wdt->io_base + WDT_RELOAD_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	outb(1, wdt->io_base + WDT_RELOAD_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	control = inb(wdt->io_base + WDT_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	outb(control | WDT_CTRL_RESET_EN, wdt->io_base + WDT_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static int nic7018_stop(struct watchdog_device *wdd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	struct nic7018_wdt *wdt = watchdog_get_drvdata(wdd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	outb(0, wdt->io_base + WDT_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	outb(0, wdt->io_base + WDT_RELOAD_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	outb(0xF0, wdt->io_base + WDT_PRESET_PRESCALE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static int nic7018_ping(struct watchdog_device *wdd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	struct nic7018_wdt *wdt = watchdog_get_drvdata(wdd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	outb(1, wdt->io_base + WDT_RELOAD_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static unsigned int nic7018_get_timeleft(struct watchdog_device *wdd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	struct nic7018_wdt *wdt = watchdog_get_drvdata(wdd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	u8 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	count = inb(wdt->io_base + WDT_COUNT) & 0xF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (!count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	return nic7018_timeout(wdt->period, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) static const struct watchdog_info nic7018_wdd_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	.identity = "NIC7018 Watchdog",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static const struct watchdog_ops nic7018_wdd_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	.start = nic7018_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	.stop = nic7018_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	.ping = nic7018_ping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	.set_timeout = nic7018_set_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	.get_timeleft = nic7018_get_timeleft,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static int nic7018_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	struct device *dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	struct watchdog_device *wdd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	struct nic7018_wdt *wdt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	struct resource *io_rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	if (!wdt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	platform_set_drvdata(pdev, wdt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	io_rc = platform_get_resource(pdev, IORESOURCE_IO, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (!io_rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		dev_err(dev, "missing IO resources\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	if (!devm_request_region(dev, io_rc->start, resource_size(io_rc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 				 KBUILD_MODNAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		dev_err(dev, "failed to get IO region\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	wdt->io_base = io_rc->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	wdd = &wdt->wdd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	wdd->info = &nic7018_wdd_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	wdd->ops = &nic7018_wdd_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	wdd->min_timeout = WDT_MIN_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	wdd->max_timeout = WDT_MAX_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	wdd->timeout = WDT_DEFAULT_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	wdd->parent = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	watchdog_set_drvdata(wdd, wdt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	watchdog_set_nowayout(wdd, nowayout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	watchdog_init_timeout(wdd, timeout, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	/* Unlock WDT register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	outb(UNLOCK, wdt->io_base + WDT_REG_LOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	ret = watchdog_register_device(wdd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		outb(LOCK, wdt->io_base + WDT_REG_LOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	dev_dbg(dev, "io_base=0x%04X, timeout=%d, nowayout=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		wdt->io_base, timeout, nowayout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) static int nic7018_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	struct nic7018_wdt *wdt = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	watchdog_unregister_device(&wdt->wdd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	/* Lock WDT register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	outb(LOCK, wdt->io_base + WDT_REG_LOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static const struct acpi_device_id nic7018_device_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	{"NIC7018", 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	{"", 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) MODULE_DEVICE_TABLE(acpi, nic7018_device_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static struct platform_driver watchdog_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	.probe = nic7018_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	.remove = nic7018_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		.name = KBUILD_MODNAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		.acpi_match_table = ACPI_PTR(nic7018_device_ids),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) module_platform_driver(watchdog_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) MODULE_DESCRIPTION("National Instruments NIC7018 Watchdog driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) MODULE_AUTHOR("Hui Chun Ong <hui.chun.ong@ni.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) MODULE_LICENSE("GPL");