Watchdog timer for Acquire Inc SBC (patch)

David Woodhouse (D.W.Woodhouse@nortel.co.uk)
Wed, 20 Aug 1997 11:02:40 +0100


This is a multipart MIME message.

--===_0_Wed_Aug_20_11:00:31_BST_1997
Content-Type: text/plain; charset=us-ascii

Some companies are quite careful about buying hardware that's supported by the
operating system. Here they just seem to buy random hardware and vacation
students, the latter to make the operating system play nicely with the former.
Suits me fine - here's another one...

--===_0_Wed_Aug_20_11:00:31_BST_1997
Content-Type: application/octet-stream
Content-Description: acquirewdt-diff

diff -u --recursive --new-file linux-2.1.51/Documentation/Configure.help linux/Documentation/Configure.help
--- linux-2.1.51/Documentation/Configure.help Tue Aug 19 14:59:37 1997
+++ linux/Documentation/Configure.help Wed Aug 20 10:22:48 1997
@@ -4968,6 +4968,18 @@
module is called pcwd.o. If you want to compile it as a module, say
M here and read Documentation/modules.txt. Most people will say N.

+Acquire SBC Watchdog Timer
+CONFIG_ACQUIRE_WDT
+ This is the driver for the hardware watchdog on the PSC-6x86 Single
+ Board Computer produced by Acquire Inc (and others). This watchdog
+ simply watches your kernel to make sure it doesn't freeze, and if
+ it does, it resets your computer after a certain amount of time.
+ This driver is like the WDT501 driver but for different hardware.
+ This driver is also available as a module ( = code which can be
+ inserted in and removed from the running kernel whenever you want).
+ The module is called pscwdt.o. If you want to compile it as a module,
+ say M here and read Documentation/modules.txt. Most people will say N.
+
Enhanced Real Time Clock Support
CONFIG_RTC
If you say Y here and create a character special file /dev/rtc with
diff -u --recursive --new-file linux-2.1.51/drivers/char/Config.in linux/drivers/char/Config.in
--- linux-2.1.51/drivers/char/Config.in Tue Aug 12 00:57:59 1997
+++ linux/drivers/char/Config.in Wed Aug 20 10:23:20 1997
@@ -101,6 +101,7 @@
fi
tristate ' Software Watchdog' CONFIG_SOFT_WATCHDOG
tristate ' Berkshire Products PC Watchdog' CONFIG_PCWATCHDOG
+ tristate ' Acquire SBC Watchdog Timer' CONFIG_ACQUIRE_WDT
fi
bool 'Enhanced Real Time Clock Support' CONFIG_RTC
tristate '/dev/nvram support' CONFIG_NVRAM
diff -u --recursive --new-file linux-2.1.51/drivers/char/Makefile linux/drivers/char/Makefile
--- linux-2.1.51/drivers/char/Makefile Tue Aug 12 01:28:19 1997
+++ linux/drivers/char/Makefile Wed Aug 20 10:23:57 1997
@@ -204,6 +204,16 @@
endif
endif

+ifeq ($(CONFIG_ACQUIRE_WDT),y)
+M = y
+L_OBJS += acquirewdt.o
+else
+ ifeq ($(CONFIG_ACQUIRE_WDT),m)
+ M_OBJS += acquirewdt.o
+ MM = m
+ endif
+endif
+
ifeq ($(CONFIG_AMIGAMOUSE),y)
M = y
L_OBJS += amigamouse.o
diff -u --recursive --new-file linux-2.1.51/drivers/char/acquirewdt.c linux/drivers/char/acquirewdt.c
--- linux-2.1.51/drivers/char/acquirewdt.c Thu Jan 1 01:00:00 1970
+++ linux/drivers/char/acquirewdt.c Wed Aug 20 10:26:52 1997
@@ -0,0 +1,221 @@
+/*
+ * Acquire Single Board Computer Watchdog Timer driver for Linux 2.1.x
+ *
+ * Based on wdt.c. Original copyright messages:
+ *
+ * (c) Copyright 1996 Alan Cox <alan@cymru.net>, All Rights Reserved.
+ * http://www.cymru.net
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
+ * warranty for any of this software. This material is provided
+ * "AS-IS" and at no charge.
+ *
+ * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <linux/malloc.h>
+#include <linux/ioport.h>
+#include <linux/fcntl.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <linux/notifier.h>
+#include <linux/reboot.h>
+#include <linux/init.h>
+
+static int acq_is_open=0;
+
+/*
+ * You must set these - there is no sane way to probe for this board.
+ */
+
+#define WDT_STOP 0x43
+#define WDT_START 0x443
+#define WATCHDOG_MINOR 130
+
+#define WD_TIMO (100*60) /* 1 minute */
+
+
+/*
+ * Kernel methods.
+ */
+
+
+static void acq_ping(void)
+{
+ /* Write a watchdog value */
+ inb_p(WDT_START);
+}
+
+static long acq_write(struct inode *inode, struct file *file, const char *buf, unsigned long count)
+{
+ if(count)
+ {
+ acq_ping();
+ return 1;
+ }
+ return 0;
+}
+
+static long acq_read(struct inode *inode, struct file *file, char *buf, unsigned long count)
+{
+ return -EINVAL;
+}
+
+
+
+static int acq_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ static struct watchdog_info ident=
+ {
+ WDIOF_KEEPALIVEPING, 1, "Acquire WDT"
+ };
+
+ switch(cmd)
+ {
+ case WDIOC_GETSUPPORT:
+ if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
+ return -EFAULT;
+ break;
+
+ case WDIOC_GETSTATUS:
+ if (copy_to_user((int *)arg, &acq_is_open, sizeof(int)))
+ return -EFAULT;
+ break;
+
+ case WDIOC_KEEPALIVE:
+ acq_ping();
+ break;
+
+ default:
+ return -ENOIOCTLCMD;
+ }
+ return 0;
+}
+
+static int acq_open(struct inode *inode, struct file *file)
+{
+ switch(MINOR(inode->i_rdev))
+ {
+ case WATCHDOG_MINOR:
+ if(acq_is_open)
+ return -EBUSY;
+ MOD_INC_USE_COUNT;
+ /*
+ * Activate
+ */
+
+ acq_is_open=1;
+ inb_p(WDT_START);
+ return 0;
+ default:
+ return -ENODEV;
+ }
+}
+
+static int acq_close(struct inode *inode, struct file *file)
+{
+ if(MINOR(inode->i_rdev)==WATCHDOG_MINOR)
+ {
+#ifndef CONFIG_WATCHDOG_NOWAYOUT
+ inb_p(WDT_STOP);
+#endif
+ acq_is_open=0;
+ }
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+/*
+ * Notifier for system down
+ */
+
+static int acq_notify_sys(struct notifier_block *this, unsigned long code,
+ void *unused)
+{
+ if(code==SYS_DOWN || code==SYS_HALT)
+ {
+ /* Turn the card off */
+ inb_p(WDT_STOP);
+ }
+ return NOTIFY_DONE;
+}
+
+/*
+ * Kernel Interfaces
+ */
+
+
+static struct file_operations acq_fops = {
+ NULL,
+ acq_read,
+ acq_write,
+ NULL, /* No Readdir */
+ NULL, /* No Select */
+ acq_ioctl,
+ NULL, /* No mmap */
+ acq_open,
+ acq_close
+};
+
+static struct miscdevice acq_miscdev=
+{
+ WATCHDOG_MINOR,
+ "Acquire WDT",
+ &acq_fops
+};
+
+
+/*
+ * The WDT card needs to learn about soft shutdowns in order to
+ * turn the timebomb registers off.
+ */
+
+static struct notifier_block acq_notifier=
+{
+ acq_notify_sys,
+ NULL,
+ 0
+};
+
+#ifdef MODULE
+
+#define acq_init init_module
+
+void cleanup_module(void)
+{
+ misc_deregister(&acq_miscdev);
+ unregister_reboot_notifier(&acq_notifier);
+ release_region(WDT_STOP,1);
+ release_region(WDT_START,1);
+}
+
+#endif
+
+__initfunc(int acq_init(void))
+{
+ printk("WDT driver for Acquire single board computer initialising.\n");
+
+ misc_register(&acq_miscdev);
+ request_region(WDT_STOP, 1, "Acquire WDT");
+ request_region(WDT_START, 1, "Acquire WDT");
+ unregister_reboot_notifier(&acq_notifier);
+ return 0;
+}
+
diff -u --recursive --new-file linux-2.1.51/drivers/char/misc.c linux/drivers/char/misc.c
--- linux-2.1.51/drivers/char/misc.c Tue Aug 5 17:48:55 1997
+++ linux/drivers/char/misc.c Wed Aug 20 10:28:00 1997
@@ -71,6 +71,7 @@
extern int sun_mouse_init(void);
extern void watchdog_init(void);
extern void wdt_init(void);
+extern void acq_init(void);
extern void pcwatchdog_init(void);
extern int rtc_init(void);
extern int dsp56k_init(void);
@@ -230,6 +231,9 @@
#endif
#ifdef CONFIG_WDT
wdt_init();
+#endif
+#ifdef CONFIG_ACQUIRE_WDT
+ acq_init();
#endif
#ifdef CONFIG_SOFT_WATCHDOG
watchdog_init();

--===_0_Wed_Aug_20_11:00:31_BST_1997
Content-Type: text/plain; charset=us-ascii

David Woodhouse, CB3 9AN http://dwmw2.robinson.cam.ac.uk/
dwmw2@cam.ac.uk Tel: 0976 658355
D.W.Woodhouse@nortel.co.uk Tel: 01279 402332

--===_0_Wed_Aug_20_11:00:31_BST_1997--