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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* riowd.c - driver for hw watchdog inside Super I/O of RIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2001, 2008 David S. Miller (davem@davemloft.net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/kernel.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/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/miscdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/watchdog.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/of_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /* RIO uses the NatSemi Super I/O power management logical device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * as its' watchdog.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * When the watchdog triggers, it asserts a line to the BBC (Boot Bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * Controller) of the machine.  The BBC can only be configured to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * trigger a power-on reset when the signal is asserted.  The BBC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * can be configured to ignore the signal entirely as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * The only Super I/O device register we care about is at index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * 0x05 (WDTO_INDEX) which is the watchdog time-out in minutes (1-255).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * If set to zero, this disables the watchdog.  When set, the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * must periodically (before watchdog expires) clear (set to zero) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * re-set the watchdog else it will trigger.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * There are two other indexed watchdog registers inside this Super I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * logical device, but they are unused.  The first, at index 0x06 is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * the watchdog control and can be used to make the watchdog timer re-set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * when the PS/2 mouse or serial lines show activity.  The second, at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * index 0x07 is merely a sampling of the line from the watchdog to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * BBC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * The watchdog device generates no interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) MODULE_DESCRIPTION("Hardware watchdog driver for Sun RIO");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) MODULE_SUPPORTED_DEVICE("watchdog");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define DRIVER_NAME	"riowd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define PFX		DRIVER_NAME ": "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) struct riowd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	void __iomem		*regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	spinlock_t		lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) static struct riowd *riowd_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #define WDTO_INDEX	0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static int riowd_timeout = 1;		/* in minutes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) module_param(riowd_timeout, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) MODULE_PARM_DESC(riowd_timeout, "Watchdog timeout in minutes");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) static void riowd_writereg(struct riowd *p, u8 val, int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	spin_lock_irqsave(&p->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	writeb(index, p->regs + 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	writeb(val, p->regs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	spin_unlock_irqrestore(&p->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static int riowd_open(struct inode *inode, struct file *filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	stream_open(inode, filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	return 0;
^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) static int riowd_release(struct inode *inode, struct file *filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static long riowd_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	static const struct watchdog_info info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		.options		= WDIOF_SETTIMEOUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		.firmware_version	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		.identity		= DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	void __user *argp = (void __user *)arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct riowd *p = riowd_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	unsigned int options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	int new_margin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	case WDIOC_GETSUPPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		if (copy_to_user(argp, &info, sizeof(info)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	case WDIOC_GETSTATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	case WDIOC_GETBOOTSTATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		if (put_user(0, (int __user *)argp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	case WDIOC_KEEPALIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		riowd_writereg(p, riowd_timeout, WDTO_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	case WDIOC_SETOPTIONS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		if (copy_from_user(&options, argp, sizeof(options)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		if (options & WDIOS_DISABLECARD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			riowd_writereg(p, 0, WDTO_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		else if (options & WDIOS_ENABLECARD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			riowd_writereg(p, riowd_timeout, WDTO_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	case WDIOC_SETTIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		if (get_user(new_margin, (int __user *)argp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		if ((new_margin < 60) || (new_margin > (255 * 60)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		riowd_timeout = (new_margin + 59) / 60;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		riowd_writereg(p, riowd_timeout, WDTO_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	case WDIOC_GETTIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		return put_user(riowd_timeout * 60, (int __user *)argp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static ssize_t riowd_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 						size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	struct riowd *p = riowd_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		riowd_writereg(p, riowd_timeout, WDTO_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		return 1;
^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) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static const struct file_operations riowd_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	.owner =		THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	.llseek =		no_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	.unlocked_ioctl =	riowd_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	.compat_ioctl	=	compat_ptr_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	.open =			riowd_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	.write =		riowd_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	.release =		riowd_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static struct miscdevice riowd_miscdev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	.minor	= WATCHDOG_MINOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	.name	= "watchdog",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	.fops	= &riowd_fops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static int riowd_probe(struct platform_device *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	struct riowd *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	int err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (riowd_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	spin_lock_init(&p->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	p->regs = of_ioremap(&op->resource[0], 0, 2, DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	if (!p->regs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		pr_err("Cannot map registers\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	/* Make miscdev useable right away */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	riowd_device = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	err = misc_register(&riowd_miscdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		pr_err("Cannot register watchdog misc device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		goto out_iounmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	pr_info("Hardware watchdog [%i minutes], regs at %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		riowd_timeout, p->regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	platform_set_drvdata(op, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) out_iounmap:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	riowd_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	of_iounmap(&op->resource[0], p->regs, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	return err;
^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 riowd_remove(struct platform_device *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	struct riowd *p = platform_get_drvdata(op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	misc_deregister(&riowd_miscdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	of_iounmap(&op->resource[0], p->regs, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) static const struct of_device_id riowd_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		.name = "pmc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	{},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) MODULE_DEVICE_TABLE(of, riowd_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static struct platform_driver riowd_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		.name = DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		.of_match_table = riowd_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	.probe		= riowd_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	.remove		= riowd_remove,
^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(riowd_driver);