linux/drivers/watchdog/alim7101_wdt.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *	ALi M7101 PMU Computer Watchdog Timer driver
 *
 *	Based on w83877f_wdt.c by Scott Jennings <[email protected]>
 *	and the Cobalt kernel WDT timer driver by Tim Hockin
 *	                                      <[email protected]>
 *
 *	(c)2002 Steve Hill <[email protected]>
 *
 *  This WDT driver is different from most other Linux WDT
 *  drivers in that the driver will ping the watchdog by itself,
 *  because this particular WDT has a very short timeout (1.6
 *  seconds) and it would be insane to count on any userspace
 *  daemon always getting scheduled within that time frame.
 *
 *  Additions:
 *   Aug 23, 2004 - Added use_gpio module parameter for use on revision a1d PMUs
 *                  found on very old cobalt hardware.
 *                  -- Mike Waychison <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
#include <linux/timer.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
#include <linux/ioport.h>
#include <linux/notifier.h>
#include <linux/reboot.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/pci.h>
#include <linux/io.h>
#include <linux/uaccess.h>


#define WDT_ENABLE
#define WDT_DISABLE

#define ALI_7101_WDT
#define ALI_7101_GPIO
#define ALI_7101_GPIO_O
#define ALI_WDT_ARM

/*
 * We're going to use a 1 second timeout.
 * If we reset the watchdog every ~250ms we should be safe.  */

#define WDT_INTERVAL

/*
 * We must not require too good response from the userspace daemon.
 * Here we require the userspace daemon to send us a heartbeat
 * char to /dev/watchdog every 30 seconds.
 */

#define WATCHDOG_TIMEOUT
/* in seconds, will be multiplied by HZ to get seconds to wait for a ping */
static int timeout =;
module_param(timeout, int, 0);
MODULE_PARM_DESC();

static int use_gpio; /* Use the pic (for a1d revision alim7101) */
module_param(use_gpio, int, 0);
MODULE_PARM_DESC();

static void wdt_timer_ping(struct timer_list *);
static DEFINE_TIMER(timer, wdt_timer_ping);
static unsigned long next_heartbeat;
static unsigned long wdt_is_open;
static char wdt_expect_close;
static struct pci_dev *alim7101_pmu;

static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC();

/*
 *	Whack the dog
 */

static void wdt_timer_ping(struct timer_list *unused)
{}

/*
 * Utility routines
 */

static void wdt_change(int writeval)
{}

static void wdt_startup(void)
{}

static void wdt_turnoff(void)
{}

static void wdt_keepalive(void)
{}

/*
 * /dev/watchdog handling
 */

static ssize_t fop_write(struct file *file, const char __user *buf,
						size_t count, loff_t *ppos)
{}

static int fop_open(struct inode *inode, struct file *file)
{}

static int fop_close(struct inode *inode, struct file *file)
{}

static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{}

static const struct file_operations wdt_fops =;

static struct miscdevice wdt_miscdev =;

static int wdt_restart_handle(struct notifier_block *this, unsigned long mode,
			      void *cmd)
{}

static struct notifier_block wdt_restart_handler =;

/*
 *	Notifier for system down
 */

static int wdt_notify_sys(struct notifier_block *this,
					unsigned long code, void *unused)
{}

/*
 *	The WDT needs to learn about soft shutdowns in order to
 *	turn the timebomb registers off.
 */

static struct notifier_block wdt_notifier =;

static void __exit alim7101_wdt_unload(void)
{}

static int __init alim7101_wdt_init(void)
{}

module_init();
module_exit(alim7101_wdt_unload);

static const struct pci_device_id alim7101_pci_tbl[] __used =;

MODULE_DEVICE_TABLE(pci, alim7101_pci_tbl);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();