linux/drivers/watchdog/smsc37b787_wdt.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *	SMsC 37B787 Watchdog Timer driver for Linux 2.6.x.x
 *
 *	Based on acquirewdt.c by Alan Cox <[email protected]>
 *	and some other existing drivers
 *
 *	The authors do NOT admit liability nor provide warranty for
 *	any of this software. This material is provided "AS-IS" in
 *	the hope that it may be useful for others.
 *
 *	(C) Copyright 2003-2006  Sven Anders <[email protected]>
 *
 *  History:
 *	2003 - Created version 1.0 for Linux 2.4.x.
 *	2006 - Ported to Linux 2.6, added nowayout and MAGICCLOSE
 *	       features. Released version 1.1
 *
 *  Theory of operation:
 *
 *	A Watchdog Timer (WDT) is a hardware circuit that can
 *	reset the computer system in case of a software fault.
 *	You probably knew that already.
 *
 *	Usually a userspace daemon will notify the kernel WDT driver
 *	via the /dev/watchdog special device file that userspace is
 *	still alive, at regular intervals.  When such a notification
 *	occurs, the driver will usually tell the hardware watchdog
 *	that everything is in order, and that the watchdog should wait
 *	for yet another little while to reset the system.
 *	If userspace fails (RAM error, kernel bug, whatever), the
 *	notifications cease to occur, and the hardware watchdog will
 *	reset the system (causing a reboot) after the timeout occurs.
 *
 * Create device with:
 *  mknod /dev/watchdog c 10 130
 *
 * For an example userspace keep-alive daemon, see:
 *   Documentation/watchdog/wdt.rst
 */

#define pr_fmt(fmt)

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


/* enable support for minutes as units? */
/* (does not always work correctly, so disabled by default!) */
#define SMSC_SUPPORT_MINUTES
#undef SMSC_SUPPORT_MINUTES

#define MAX_TIMEOUT

#define UNIT_SECOND
#define UNIT_MINUTE

#define VERSION

#define IOPORT
#define IOPORT_SIZE
#define IODEV_NO

static int unit =;	/* timer's unit */
static int timeout =;	/* timeout value: default is 60 "units" */
static unsigned long timer_enabled;   /* is the timer enabled? */

static char expect_close;       /* is the close expected? */

static DEFINE_SPINLOCK(io_lock);/* to guard the watchdog from io races */

static bool nowayout = WATCHDOG_NOWAYOUT;

/* -- Low level function ----------------------------------------*/

/* unlock the IO chip */

static inline void open_io_config(void)
{}

/* lock the IO chip */
static inline void close_io_config(void)
{}

/* select the IO device */
static inline void select_io_device(unsigned char devno)
{}

/* write to the control register */
static inline void write_io_cr(unsigned char reg, unsigned char data)
{}

/* read from the control register */
static inline char read_io_cr(unsigned char reg)
{}

/* -- Medium level functions ------------------------------------*/

static inline void gpio_bit12(unsigned char reg)
{}

static inline void gpio_bit13(unsigned char reg)
{}

static inline void wdt_timer_units(unsigned char new_units)
{}

static inline void wdt_timeout_value(unsigned char new_timeout)
{}

static inline void wdt_timer_conf(unsigned char conf)
{}

static inline void wdt_timer_ctrl(unsigned char reg)
{}

/* -- Higher level functions ------------------------------------*/

/* initialize watchdog */

static void wb_smsc_wdt_initialize(void)
{}

/* shutdown the watchdog */

static void wb_smsc_wdt_shutdown(void)
{}

/* set timeout => enable watchdog */

static void wb_smsc_wdt_set_timeout(unsigned char new_timeout)
{}

/* get timeout */

static unsigned char wb_smsc_wdt_get_timeout(void)
{}

/* disable watchdog */

static void wb_smsc_wdt_disable(void)
{}

/* enable watchdog by setting the current timeout */

static void wb_smsc_wdt_enable(void)
{}

/* reset the timer */

static void wb_smsc_wdt_reset_timer(void)
{}

/* return, if the watchdog is enabled (timeout is set...) */

static int wb_smsc_wdt_status(void)
{}


/* -- File operations -------------------------------------------*/

/* open => enable watchdog and set initial timeout */

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

/* close => shut off the timer */

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

/* write => update the timer to keep the machine alive */

static ssize_t wb_smsc_wdt_write(struct file *file, const char __user *data,
				 size_t len, loff_t *ppos)
{}

/* ioctl => control interface */

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

/* -- Notifier funtions -----------------------------------------*/

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

/* -- Module's structures ---------------------------------------*/

static const struct file_operations wb_smsc_wdt_fops =;

static struct notifier_block wb_smsc_wdt_notifier =;

static struct miscdevice wb_smsc_wdt_miscdev =;

/* -- Module init functions -------------------------------------*/

/* module's "constructor" */

static int __init wb_smsc_wdt_init(void)
{}

/* module's "destructor" */

static void __exit wb_smsc_wdt_exit(void)
{}

module_init();
module_exit(wb_smsc_wdt_exit);

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

#ifdef SMSC_SUPPORT_MINUTES
module_param(unit, int, 0);
MODULE_PARM_DESC(unit,
		"set unit to use, 0=seconds or 1=minutes, default is 0");
#endif

module_param(timeout, int, 0);
MODULE_PARM_DESC();

module_param(nowayout, bool, 0);
MODULE_PARM_DESC();