^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Driver for the MTX-1 Watchdog.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * (C) Copyright 2005 4G Systems <info@4g-systems.biz>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * http://www.4g-systems.biz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * (C) Copyright 2007 OpenWrt.org, Florian Fainelli <florian@openwrt.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * (c) Copyright 2005 4G Systems <info@4g-systems.biz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Release 0.01.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Author: Michael Stickel michael.stickel@4g-systems.biz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Release 0.02.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Author: Florian Fainelli florian@openwrt.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * use the Linux watchdog/timer APIs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * The Watchdog is configured to reset the MTX-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * if it is not triggered for 100 seconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * It should not be triggered more often than 1.6 seconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * A timer triggers the watchdog every 5 seconds, until
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * it is opened for the first time. After the first open
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * it MUST be triggered every 2..95 seconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/miscdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/watchdog.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <linux/gpio/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <asm/mach-au1x00/au1000.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define MTX1_WDT_INTERVAL (5 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static int ticks = 100 * HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct completion stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int running;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int default_ticks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) unsigned long inuse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct gpio_desc *gpiod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) unsigned int gstate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) } mtx1_wdt_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static void mtx1_wdt_trigger(struct timer_list *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) spin_lock(&mtx1_wdt_device.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if (mtx1_wdt_device.running)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ticks--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /* toggle wdt gpio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) gpiod_set_value(mtx1_wdt_device.gpiod, mtx1_wdt_device.gstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) if (mtx1_wdt_device.queue && ticks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) complete(&mtx1_wdt_device.stop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) spin_unlock(&mtx1_wdt_device.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static void mtx1_wdt_reset(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) ticks = mtx1_wdt_device.default_ticks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static void mtx1_wdt_start(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (!mtx1_wdt_device.queue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) mtx1_wdt_device.queue = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) mtx1_wdt_device.gstate = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) gpiod_set_value(mtx1_wdt_device.gpiod, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) mtx1_wdt_device.running++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static int mtx1_wdt_stop(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (mtx1_wdt_device.queue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) mtx1_wdt_device.queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) mtx1_wdt_device.gstate = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) gpiod_set_value(mtx1_wdt_device.gpiod, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ticks = mtx1_wdt_device.default_ticks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /* Filesystem functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static int mtx1_wdt_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) if (test_and_set_bit(0, &mtx1_wdt_device.inuse))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) return stream_open(inode, file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static int mtx1_wdt_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) clear_bit(0, &mtx1_wdt_device.inuse);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static long mtx1_wdt_ioctl(struct file *file, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) void __user *argp = (void __user *)arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) int __user *p = (int __user *)argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) unsigned int value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static const struct watchdog_info ident = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) .options = WDIOF_CARDRESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) .identity = "MTX-1 WDT",
^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) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) case WDIOC_GETSUPPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if (copy_to_user(argp, &ident, sizeof(ident)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) case WDIOC_GETSTATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) case WDIOC_GETBOOTSTATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) put_user(0, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) case WDIOC_SETOPTIONS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) if (get_user(value, p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (value & WDIOS_ENABLECARD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) mtx1_wdt_start();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) else if (value & WDIOS_DISABLECARD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) mtx1_wdt_stop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) case WDIOC_KEEPALIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) mtx1_wdt_reset();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) return -ENOTTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static ssize_t mtx1_wdt_write(struct file *file, const char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (!count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) mtx1_wdt_reset();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) static const struct file_operations mtx1_wdt_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) .llseek = no_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) .unlocked_ioctl = mtx1_wdt_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) .compat_ioctl = compat_ptr_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) .open = mtx1_wdt_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) .write = mtx1_wdt_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) .release = mtx1_wdt_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static struct miscdevice mtx1_wdt_misc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) .minor = WATCHDOG_MINOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) .name = "watchdog",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) .fops = &mtx1_wdt_fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) static int mtx1_wdt_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) mtx1_wdt_device.gpiod = devm_gpiod_get(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) NULL, GPIOD_OUT_HIGH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (IS_ERR(mtx1_wdt_device.gpiod)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) dev_err(&pdev->dev, "failed to request gpio");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) return PTR_ERR(mtx1_wdt_device.gpiod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) spin_lock_init(&mtx1_wdt_device.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) init_completion(&mtx1_wdt_device.stop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) mtx1_wdt_device.queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) clear_bit(0, &mtx1_wdt_device.inuse);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) timer_setup(&mtx1_wdt_device.timer, mtx1_wdt_trigger, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) mtx1_wdt_device.default_ticks = ticks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) ret = misc_register(&mtx1_wdt_misc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) dev_err(&pdev->dev, "failed to register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) mtx1_wdt_start();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) dev_info(&pdev->dev, "MTX-1 Watchdog driver\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static int mtx1_wdt_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /* FIXME: do we need to lock this test ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (mtx1_wdt_device.queue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) mtx1_wdt_device.queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) wait_for_completion(&mtx1_wdt_device.stop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) misc_deregister(&mtx1_wdt_misc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static struct platform_driver mtx1_wdt_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) .probe = mtx1_wdt_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .remove = mtx1_wdt_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) .driver.name = "mtx1-wdt",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) .driver.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) module_platform_driver(mtx1_wdt_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) MODULE_AUTHOR("Michael Stickel, Florian Fainelli");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) MODULE_DESCRIPTION("Driver for the MTX-1 watchdog");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) MODULE_ALIAS("platform:mtx1-wdt");