···8485 Not sure? It's safe to say N.860000000000087config IXP4XX_WATCHDOG88 tristate "IXP4xx Watchdog"89 depends on WATCHDOG && ARCH_IXP4XX···108 which doesn't reset any peripherals. There are circumstances109 where the watchdog will fail to reset the board correctly110 (e.g., if the boot ROM is in an unreadable state).111-112- Say N if you are unsure.113-114-config IXP2000_WATCHDOG115- tristate "IXP2000 Watchdog"116- depends on WATCHDOG && ARCH_IXP2000117- help118- Say Y here if to include support for the watchdog timer119- in the Intel IXP2000(2400, 2800, 2850) network processors.120- This driver can be built as a module by choosing M. The module121- will be called ixp2000_wdt.122123 Say N if you are unsure.124···233234 Most people will say N.2350000000000236config WAFER_WDT237 tristate "ICP Wafer 5823 Single Board Computer Watchdog"238 depends on WATCHDOG && X86···252253 To compile this driver as a module, choose M here: the254 module will be called wafer5823wdt.0000000000255256config I8XX_TCO257 tristate "Intel i8xx TCO Timer/Watchdog"···318 You can compile this driver directly into the kernel, or use319 it as a module. The module will be called sbc60xxwdt.3200000000000000321config CPU5_WDT322 tristate "SMA CPU5 Watchdog"323 depends on WATCHDOG && X86···369370 Most people will say N.3710000000000000372config MACHZ_WDT373 tristate "ZF MachZ Watchdog"374 depends on WATCHDOG && X86···401 tristate "MPC8xx Watchdog Timer"402 depends on WATCHDOG && 8xx4030000404config BOOKE_WDT405 tristate "PowerPC Book-E Watchdog Timer"406 depends on WATCHDOG && (BOOKE || 4xx)407 ---help---408 Please see Documentation/watchdog/watchdog-api.txt for409 more information.00000000000410411# MIPS Architecture412···490 Say Y here to support the hardware watchdog capability on Sun RIO491 machines. The watchdog timeout period is normally one minute but492 can be changed with a boot-time parameter.493-494-# ppc64 RTAS watchdog495-config WATCHDOG_RTAS496- tristate "RTAS watchdog"497- depends on WATCHDOG && PPC_RTAS498- help499- This driver adds watchdog support for the RTAS watchdog.500-501- To compile this driver as a module, choose M here. The module502- will be called wdrtas.503504#505# ISA-based Watchdog Cards
···8485 Not sure? It's safe to say N.8687+config IXP2000_WATCHDOG88+ tristate "IXP2000 Watchdog"89+ depends on WATCHDOG && ARCH_IXP200090+ help91+ Say Y here if to include support for the watchdog timer92+ in the Intel IXP2000(2400, 2800, 2850) network processors.93+ This driver can be built as a module by choosing M. The module94+ will be called ixp2000_wdt.95+96+ Say N if you are unsure.97+98config IXP4XX_WATCHDOG99 tristate "IXP4xx Watchdog"100 depends on WATCHDOG && ARCH_IXP4XX···97 which doesn't reset any peripherals. There are circumstances98 where the watchdog will fail to reset the board correctly99 (e.g., if the boot ROM is in an unreadable state).00000000000100101 Say N if you are unsure.102···233234 Most people will say N.235236+config IBMASR237+ tristate "IBM Automatic Server Restart"238+ depends on WATCHDOG && X86239+ help240+ This is the driver for the IBM Automatic Server Restart watchdog241+ timer builtin into some eServer xSeries machines.242+243+ To compile this driver as a module, choose M here: the244+ module will be called ibmasr.245+246config WAFER_WDT247 tristate "ICP Wafer 5823 Single Board Computer Watchdog"248 depends on WATCHDOG && X86···242243 To compile this driver as a module, choose M here: the244 module will be called wafer5823wdt.245+246+config I6300ESB_WDT247+ tristate "Intel 6300ESB Timer/Watchdog"248+ depends on WATCHDOG && X86 && PCI249+ ---help---250+ Hardware driver for the watchdog timer built into the Intel251+ 6300ESB controller hub.252+253+ To compile this driver as a module, choose M here: the254+ module will be called i6300esb.255256config I8XX_TCO257 tristate "Intel i8xx TCO Timer/Watchdog"···298 You can compile this driver directly into the kernel, or use299 it as a module. The module will be called sbc60xxwdt.300301+config SBC8360_WDT302+ tristate "SBC8360 Watchdog Timer"303+ depends on WATCHDOG && X86304+ ---help---305+306+ This is the driver for the hardware watchdog on the SBC8360 Single307+ Board Computer produced by Axiomtek Co., Ltd. (www.axiomtek.com).308+309+ To compile this driver as a module, choose M here: the310+ module will be called sbc8360.ko.311+312+ Most people will say N.313+314config CPU5_WDT315 tristate "SMA CPU5 Watchdog"316 depends on WATCHDOG && X86···336337 Most people will say N.338339+config W83977F_WDT340+ tristate "W83977F (PCM-5335) Watchdog Timer"341+ depends on WATCHDOG && X86342+ ---help---343+ This is the driver for the hardware watchdog on the W83977F I/O chip344+ as used in AAEON's PCM-5335 SBC (and likely others). This345+ watchdog simply watches your kernel to make sure it doesn't freeze,346+ and if it does, it reboots your computer after a certain amount of347+ time.348+349+ To compile this driver as a module, choose M here: the350+ module will be called w83977f_wdt.351+352config MACHZ_WDT353 tristate "ZF MachZ Watchdog"354 depends on WATCHDOG && X86···355 tristate "MPC8xx Watchdog Timer"356 depends on WATCHDOG && 8xx357358+config MV64X60_WDT359+ tristate "MV64X60 (Marvell Discovery) Watchdog Timer"360+ depends on WATCHDOG && MV64X60361+362config BOOKE_WDT363 tristate "PowerPC Book-E Watchdog Timer"364 depends on WATCHDOG && (BOOKE || 4xx)365 ---help---366 Please see Documentation/watchdog/watchdog-api.txt for367 more information.368+369+# PPC64 Architecture370+371+config WATCHDOG_RTAS372+ tristate "RTAS watchdog"373+ depends on WATCHDOG && PPC_RTAS374+ help375+ This driver adds watchdog support for the RTAS watchdog.376+377+ To compile this driver as a module, choose M here. The module378+ will be called wdrtas.379380# MIPS Architecture381···429 Say Y here to support the hardware watchdog capability on Sun RIO430 machines. The watchdog timeout period is normally one minute but431 can be changed with a boot-time parameter.0000000000432433#434# ISA-based Watchdog Cards
···1+/*2+ * i6300esb: Watchdog timer driver for Intel 6300ESB chipset3+ *4+ * (c) Copyright 2004 Google Inc.5+ * (c) Copyright 2005 David H�rdeman <david@2gen.com>6+ *7+ * This program is free software; you can redistribute it and/or8+ * modify it under the terms of the GNU General Public License9+ * as published by the Free Software Foundation; either version10+ * 2 of the License, or (at your option) any later version.11+ *12+ * based on i810-tco.c which is in turn based on softdog.c13+ *14+ * The timer is implemented in the following I/O controller hubs:15+ * (See the intel documentation on http://developer.intel.com.)16+ * 6300ESB chip : document number 300641-00317+ *18+ * 2004YYZZ Ross Biro19+ * Initial version 0.0120+ * 2004YYZZ Ross Biro21+ * Version 0.0222+ * 20050210 David H�rdeman <david@2gen.com>23+ * Ported driver to kernel 2.624+ */25+26+/*27+ * Includes, defines, variables, module parameters, ...28+ */29+30+#include <linux/module.h>31+#include <linux/types.h>32+#include <linux/kernel.h>33+#include <linux/fs.h>34+#include <linux/mm.h>35+#include <linux/miscdevice.h>36+#include <linux/watchdog.h>37+#include <linux/reboot.h>38+#include <linux/init.h>39+#include <linux/pci.h>40+#include <linux/ioport.h>41+42+#include <asm/uaccess.h>43+#include <asm/io.h>44+45+/* Module and version information */46+#define ESB_VERSION "0.03"47+#define ESB_MODULE_NAME "i6300ESB timer"48+#define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION49+#define PFX ESB_MODULE_NAME ": "50+51+/* PCI configuration registers */52+#define ESB_CONFIG_REG 0x60 /* Config register */53+#define ESB_LOCK_REG 0x68 /* WDT lock register */54+55+/* Memory mapped registers */56+#define ESB_TIMER1_REG BASEADDR + 0x00 /* Timer1 value after each reset */57+#define ESB_TIMER2_REG BASEADDR + 0x04 /* Timer2 value after each reset */58+#define ESB_GINTSR_REG BASEADDR + 0x08 /* General Interrupt Status Register */59+#define ESB_RELOAD_REG BASEADDR + 0x0c /* Reload register */60+61+/* Lock register bits */62+#define ESB_WDT_FUNC ( 0x01 << 2 ) /* Watchdog functionality */63+#define ESB_WDT_ENABLE ( 0x01 << 1 ) /* Enable WDT */64+#define ESB_WDT_LOCK ( 0x01 << 0 ) /* Lock (nowayout) */65+66+/* Config register bits */67+#define ESB_WDT_REBOOT ( 0x01 << 5 ) /* Enable reboot on timeout */68+#define ESB_WDT_FREQ ( 0x01 << 2 ) /* Decrement frequency */69+#define ESB_WDT_INTTYPE ( 0x11 << 0 ) /* Interrupt type on timer1 timeout */70+71+/* Reload register bits */72+#define ESB_WDT_RELOAD ( 0x01 << 8 ) /* prevent timeout */73+74+/* Magic constants */75+#define ESB_UNLOCK1 0x80 /* Step 1 to unlock reset registers */76+#define ESB_UNLOCK2 0x86 /* Step 2 to unlock reset registers */77+78+/* internal variables */79+static void __iomem *BASEADDR;80+static spinlock_t esb_lock; /* Guards the hardware */81+static unsigned long timer_alive;82+static struct pci_dev *esb_pci;83+static unsigned short triggered; /* The status of the watchdog upon boot */84+static char esb_expect_close;85+86+/* module parameters */87+#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat (1<heartbeat<2*1023) */88+static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */89+module_param(heartbeat, int, 0);90+MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");91+92+static int nowayout = WATCHDOG_NOWAYOUT;93+module_param(nowayout, int, 0);94+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");95+96+/*97+ * Some i6300ESB specific functions98+ */99+100+/*101+ * Prepare for reloading the timer by unlocking the proper registers.102+ * This is performed by first writing 0x80 followed by 0x86 to the103+ * reload register. After this the appropriate registers can be written104+ * to once before they need to be unlocked again.105+ */106+static inline void esb_unlock_registers(void) {107+ writeb(ESB_UNLOCK1, ESB_RELOAD_REG);108+ writeb(ESB_UNLOCK2, ESB_RELOAD_REG);109+}110+111+static void esb_timer_start(void)112+{113+ u8 val;114+115+ /* Enable or Enable + Lock? */116+ val = 0x02 | (nowayout ? 0x01 : 0x00);117+118+ pci_write_config_byte(esb_pci, ESB_LOCK_REG, val);119+}120+121+static int esb_timer_stop(void)122+{123+ u8 val;124+125+ spin_lock(&esb_lock);126+ /* First, reset timers as suggested by the docs */127+ esb_unlock_registers();128+ writew(ESB_WDT_RELOAD, ESB_RELOAD_REG);129+ /* Then disable the WDT */130+ pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x0);131+ pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val);132+ spin_unlock(&esb_lock);133+134+ /* Returns 0 if the timer was disabled, non-zero otherwise */135+ return (val & 0x01);136+}137+138+static void esb_timer_keepalive(void)139+{140+ spin_lock(&esb_lock);141+ esb_unlock_registers();142+ writew(ESB_WDT_RELOAD, ESB_RELOAD_REG);143+ /* FIXME: Do we need to flush anything here? */144+ spin_unlock(&esb_lock);145+}146+147+static int esb_timer_set_heartbeat(int time)148+{149+ u32 val;150+151+ if (time < 0x1 || time > (2 * 0x03ff))152+ return -EINVAL;153+154+ spin_lock(&esb_lock);155+156+ /* We shift by 9, so if we are passed a value of 1 sec,157+ * val will be 1 << 9 = 512, then write that to two158+ * timers => 2 * 512 = 1024 (which is decremented at 1KHz)159+ */160+ val = time << 9;161+162+ /* Write timer 1 */163+ esb_unlock_registers();164+ writel(val, ESB_TIMER1_REG);165+166+ /* Write timer 2 */167+ esb_unlock_registers();168+ writel(val, ESB_TIMER2_REG);169+170+ /* Reload */171+ esb_unlock_registers();172+ writew(ESB_WDT_RELOAD, ESB_RELOAD_REG);173+174+ /* FIXME: Do we need to flush everything out? */175+176+ /* Done */177+ heartbeat = time;178+ spin_unlock(&esb_lock);179+ return 0;180+}181+182+static int esb_timer_read (void)183+{184+ u32 count;185+186+ /* This isn't documented, and doesn't take into187+ * acount which stage is running, but it looks188+ * like a 20 bit count down, so we might as well report it.189+ */190+ pci_read_config_dword(esb_pci, 0x64, &count);191+ return (int)count;192+}193+194+/*195+ * /dev/watchdog handling196+ */197+198+static int esb_open (struct inode *inode, struct file *file)199+{200+ /* /dev/watchdog can only be opened once */201+ if (test_and_set_bit(0, &timer_alive))202+ return -EBUSY;203+204+ /* Reload and activate timer */205+ esb_timer_keepalive ();206+ esb_timer_start ();207+208+ return nonseekable_open(inode, file);209+}210+211+static int esb_release (struct inode *inode, struct file *file)212+{213+ /* Shut off the timer. */214+ if (esb_expect_close == 42) {215+ esb_timer_stop ();216+ } else {217+ printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");218+ esb_timer_keepalive ();219+ }220+ clear_bit(0, &timer_alive);221+ esb_expect_close = 0;222+ return 0;223+}224+225+static ssize_t esb_write (struct file *file, const char __user *data,226+ size_t len, loff_t * ppos)227+{228+ /* See if we got the magic character 'V' and reload the timer */229+ if (len) {230+ if (!nowayout) {231+ size_t i;232+233+ /* note: just in case someone wrote the magic character234+ * five months ago... */235+ esb_expect_close = 0;236+237+ /* scan to see whether or not we got the magic character */238+ for (i = 0; i != len; i++) {239+ char c;240+ if(get_user(c, data+i))241+ return -EFAULT;242+ if (c == 'V')243+ esb_expect_close = 42;244+ }245+ }246+247+ /* someone wrote to us, we should reload the timer */248+ esb_timer_keepalive ();249+ }250+ return len;251+}252+253+static int esb_ioctl (struct inode *inode, struct file *file,254+ unsigned int cmd, unsigned long arg)255+{256+ int new_options, retval = -EINVAL;257+ int new_heartbeat;258+ void __user *argp = (void __user *)arg;259+ int __user *p = argp;260+ static struct watchdog_info ident = {261+ .options = WDIOF_SETTIMEOUT |262+ WDIOF_KEEPALIVEPING |263+ WDIOF_MAGICCLOSE,264+ .firmware_version = 0,265+ .identity = ESB_MODULE_NAME,266+ };267+268+ switch (cmd) {269+ case WDIOC_GETSUPPORT:270+ return copy_to_user(argp, &ident,271+ sizeof (ident)) ? -EFAULT : 0;272+273+ case WDIOC_GETSTATUS:274+ return put_user (esb_timer_read(), p);275+276+ case WDIOC_GETBOOTSTATUS:277+ return put_user (triggered, p);278+279+ case WDIOC_KEEPALIVE:280+ esb_timer_keepalive ();281+ return 0;282+283+ case WDIOC_SETOPTIONS:284+ {285+ if (get_user (new_options, p))286+ return -EFAULT;287+288+ if (new_options & WDIOS_DISABLECARD) {289+ esb_timer_stop ();290+ retval = 0;291+ }292+293+ if (new_options & WDIOS_ENABLECARD) {294+ esb_timer_keepalive ();295+ esb_timer_start ();296+ retval = 0;297+ }298+299+ return retval;300+ }301+302+ case WDIOC_SETTIMEOUT:303+ {304+ if (get_user(new_heartbeat, p))305+ return -EFAULT;306+307+ if (esb_timer_set_heartbeat(new_heartbeat))308+ return -EINVAL;309+310+ esb_timer_keepalive ();311+ /* Fall */312+ }313+314+ case WDIOC_GETTIMEOUT:315+ return put_user(heartbeat, p);316+317+ default:318+ return -ENOIOCTLCMD;319+ }320+}321+322+/*323+ * Notify system324+ */325+326+static int esb_notify_sys (struct notifier_block *this, unsigned long code, void *unused)327+{328+ if (code==SYS_DOWN || code==SYS_HALT) {329+ /* Turn the WDT off */330+ esb_timer_stop ();331+ }332+333+ return NOTIFY_DONE;334+}335+336+/*337+ * Kernel Interfaces338+ */339+340+static struct file_operations esb_fops = {341+ .owner = THIS_MODULE,342+ .llseek = no_llseek,343+ .write = esb_write,344+ .ioctl = esb_ioctl,345+ .open = esb_open,346+ .release = esb_release,347+};348+349+static struct miscdevice esb_miscdev = {350+ .minor = WATCHDOG_MINOR,351+ .name = "watchdog",352+ .fops = &esb_fops,353+};354+355+static struct notifier_block esb_notifier = {356+ .notifier_call = esb_notify_sys,357+};358+359+/*360+ * Data for PCI driver interface361+ *362+ * This data only exists for exporting the supported363+ * PCI ids via MODULE_DEVICE_TABLE. We do not actually364+ * register a pci_driver, because someone else might one day365+ * want to register another driver on the same PCI id.366+ */367+static struct pci_device_id esb_pci_tbl[] = {368+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9), },369+ { 0, }, /* End of list */370+};371+MODULE_DEVICE_TABLE (pci, esb_pci_tbl);372+373+/*374+ * Init & exit routines375+ */376+377+static unsigned char __init esb_getdevice (void)378+{379+ u8 val1;380+ unsigned short val2;381+382+ struct pci_dev *dev = NULL;383+ /*384+ * Find the PCI device385+ */386+387+ for_each_pci_dev(dev) {388+ if (pci_match_id(esb_pci_tbl, dev)) {389+ esb_pci = dev;390+ break;391+ }392+ }393+394+ if (esb_pci) {395+ if (pci_enable_device(esb_pci)) {396+ printk (KERN_ERR PFX "failed to enable device\n");397+ goto err_devput;398+ }399+400+ if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) {401+ printk (KERN_ERR PFX "failed to request region\n");402+ goto err_disable;403+ }404+405+ BASEADDR = ioremap(pci_resource_start(esb_pci, 0),406+ pci_resource_len(esb_pci, 0));407+ if (BASEADDR == NULL) {408+ /* Something's wrong here, BASEADDR has to be set */409+ printk (KERN_ERR PFX "failed to get BASEADDR\n");410+ goto err_release;411+ }412+413+ /*414+ * The watchdog has two timers, it can be setup so that the415+ * expiry of timer1 results in an interrupt and the expiry of416+ * timer2 results in a reboot. We set it to not generate417+ * any interrupts as there is not much we can do with it418+ * right now.419+ *420+ * We also enable reboots and set the timer frequency to421+ * the PCI clock divided by 2^15 (approx 1KHz).422+ */423+ pci_write_config_word(esb_pci, ESB_CONFIG_REG, 0x0003);424+425+ /* Check that the WDT isn't already locked */426+ pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1);427+ if (val1 & ESB_WDT_LOCK)428+ printk (KERN_WARNING PFX "nowayout already set\n");429+430+ /* Set the timer to watchdog mode and disable it for now */431+ pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00);432+433+ /* Check if the watchdog was previously triggered */434+ esb_unlock_registers();435+ val2 = readw(ESB_RELOAD_REG);436+ triggered = (val2 & (0x01 << 9) >> 9);437+438+ /* Reset trigger flag and timers */439+ esb_unlock_registers();440+ writew((0x11 << 8), ESB_RELOAD_REG);441+442+ /* Done */443+ return 1;444+445+err_release:446+ pci_release_region(esb_pci, 0);447+err_disable:448+ pci_disable_device(esb_pci);449+err_devput:450+ pci_dev_put(esb_pci);451+ }452+ return 0;453+}454+455+static int __init watchdog_init (void)456+{457+ int ret;458+459+ spin_lock_init(&esb_lock);460+461+ /* Check whether or not the hardware watchdog is there */462+ if (!esb_getdevice () || esb_pci == NULL)463+ return -ENODEV;464+465+ /* Check that the heartbeat value is within it's range ; if not reset to the default */466+ if (esb_timer_set_heartbeat (heartbeat)) {467+ esb_timer_set_heartbeat (WATCHDOG_HEARTBEAT);468+ printk(KERN_INFO PFX "heartbeat value must be 1<heartbeat<2046, using %d\n",469+ heartbeat);470+ }471+472+ ret = register_reboot_notifier(&esb_notifier);473+ if (ret != 0) {474+ printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",475+ ret);476+ goto err_unmap;477+ }478+479+ ret = misc_register(&esb_miscdev);480+ if (ret != 0) {481+ printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",482+ WATCHDOG_MINOR, ret);483+ goto err_notifier;484+ }485+486+ esb_timer_stop ();487+488+ printk (KERN_INFO PFX "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n",489+ BASEADDR, heartbeat, nowayout);490+491+ return 0;492+493+err_notifier:494+ unregister_reboot_notifier(&esb_notifier);495+err_unmap:496+ iounmap(BASEADDR);497+/* err_release: */498+ pci_release_region(esb_pci, 0);499+/* err_disable: */500+ pci_disable_device(esb_pci);501+/* err_devput: */502+ pci_dev_put(esb_pci);503+ return ret;504+}505+506+static void __exit watchdog_cleanup (void)507+{508+ /* Stop the timer before we leave */509+ if (!nowayout)510+ esb_timer_stop ();511+512+ /* Deregister */513+ misc_deregister(&esb_miscdev);514+ unregister_reboot_notifier(&esb_notifier);515+ iounmap(BASEADDR);516+ pci_release_region(esb_pci, 0);517+ pci_disable_device(esb_pci);518+ pci_dev_put(esb_pci);519+}520+521+module_init(watchdog_init);522+module_exit(watchdog_cleanup);523+524+MODULE_AUTHOR("Ross Biro and David H�rdeman");525+MODULE_DESCRIPTION("Watchdog driver for Intel 6300ESB chipsets");526+MODULE_LICENSE("GPL");527+MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
···29 * Includes, defines, variables, module parameters, ...30 */3132+#include <linux/config.h> /* For CONFIG_WATCHDOG_NOWAYOUT/... */33+#include <linux/module.h> /* For module specific items */34+#include <linux/moduleparam.h> /* For new moduleparam's */35+#include <linux/types.h> /* For standard types (like size_t) */36+#include <linux/errno.h> /* For the -ENODEV/... values */37+#include <linux/kernel.h> /* For printk/panic/... */38+#include <linux/delay.h> /* For mdelay function */39+#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */40+#include <linux/watchdog.h> /* For the watchdog specific items */41+#include <linux/notifier.h> /* For notifier support */42+#include <linux/reboot.h> /* For reboot_notifier stuff */43+#include <linux/init.h> /* For __init/__exit/... */44+#include <linux/fs.h> /* For file operations */45+#include <linux/pci.h> /* For pci functions */46+#include <linux/ioport.h> /* For io-port access */47+#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */4849+#include <asm/uaccess.h> /* For copy_to_user/put_user/... */50+#include <asm/io.h> /* For inb/outb/... */5152/* Module and version information */53#define WATCHDOG_VERSION "1.01"54+#define WATCHDOG_DATE "02 Sep 2005"55#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog"56#define WATCHDOG_NAME "pcwd_pci"57#define PFX WATCHDOG_NAME ": "···335 return -EFAULT;336337 if (new_options & WDIOS_DISABLECARD) {338+ if (pcipcwd_stop())339+ return -EIO;340 retval = 0;341 }342343 if (new_options & WDIOS_ENABLECARD) {344+ if (pcipcwd_start())345+ return -EIO;346 retval = 0;347 }348
+1-1
drivers/char/watchdog/s3c2410_wdt.c
···464static unsigned long wtcon_save;465static unsigned long wtdat_save;466467-static int s3c2410wdt_suspend(struct device *dev, u32 state, u32 level)468{469 if (level == SUSPEND_POWER_DOWN) {470 /* Save watchdog state, and turn it off. */
···464static unsigned long wtcon_save;465static unsigned long wtdat_save;466467+static int s3c2410wdt_suspend(struct device *dev, pm_message_t state, u32 level)468{469 if (level == SUSPEND_POWER_DOWN) {470 /* Save watchdog state, and turn it off. */
···1+/*2+ * W83977F Watchdog Timer Driver for Winbond W83977F I/O Chip3+ *4+ * (c) Copyright 2005 Jose Goncalves <jose.goncalves@inov.pt>5+ *6+ * Based on w83877f_wdt.c by Scott Jennings,7+ * and wdt977.c by Woody Suwalski8+ *9+ * -----------------------10+ *11+ * This program is free software; you can redistribute it and/or12+ * modify it under the terms of the GNU General Public License13+ * as published by the Free Software Foundation; either version14+ * 2 of the License, or (at your option) any later version.15+ *16+ */17+18+#include <linux/module.h>19+#include <linux/moduleparam.h>20+#include <linux/config.h>21+#include <linux/types.h>22+#include <linux/kernel.h>23+#include <linux/fs.h>24+#include <linux/miscdevice.h>25+#include <linux/init.h>26+#include <linux/ioport.h>27+#include <linux/watchdog.h>28+#include <linux/notifier.h>29+#include <linux/reboot.h>30+31+#include <asm/io.h>32+#include <asm/system.h>33+#include <asm/uaccess.h>34+35+#define WATCHDOG_VERSION "1.00"36+#define WATCHDOG_NAME "W83977F WDT"37+#define PFX WATCHDOG_NAME ": "38+#define DRIVER_VERSION WATCHDOG_NAME " driver, v" WATCHDOG_VERSION "\n"39+40+#define IO_INDEX_PORT 0x3F041+#define IO_DATA_PORT (IO_INDEX_PORT+1)42+43+#define UNLOCK_DATA 0x8744+#define LOCK_DATA 0xAA45+#define DEVICE_REGISTER 0x0746+47+#define DEFAULT_TIMEOUT 45 /* default timeout in seconds */48+49+static int timeout = DEFAULT_TIMEOUT;50+static int timeoutW; /* timeout in watchdog counter units */51+static unsigned long timer_alive;52+static int testmode;53+static char expect_close;54+static spinlock_t spinlock;55+56+module_param(timeout, int, 0);57+MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (15..7635), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")");58+module_param(testmode, int, 0);59+MODULE_PARM_DESC(testmode,"Watchdog testmode (1 = no reboot), default=0");60+61+static int nowayout = WATCHDOG_NOWAYOUT;62+module_param(nowayout, int, 0);63+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");64+65+/*66+ * Start the watchdog67+ */68+69+static int wdt_start(void)70+{71+ unsigned long flags;72+73+ spin_lock_irqsave(&spinlock, flags);74+75+ /* Unlock the SuperIO chip */76+ outb_p(UNLOCK_DATA,IO_INDEX_PORT);77+ outb_p(UNLOCK_DATA,IO_INDEX_PORT);78+79+ /*80+ * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4.81+ * F2 has the timeout in watchdog counter units.82+ * F3 is set to enable watchdog LED blink at timeout.83+ * F4 is used to just clear the TIMEOUT'ed state (bit 0).84+ */85+ outb_p(DEVICE_REGISTER,IO_INDEX_PORT);86+ outb_p(0x08,IO_DATA_PORT);87+ outb_p(0xF2,IO_INDEX_PORT);88+ outb_p(timeoutW,IO_DATA_PORT);89+ outb_p(0xF3,IO_INDEX_PORT);90+ outb_p(0x08,IO_DATA_PORT);91+ outb_p(0xF4,IO_INDEX_PORT);92+ outb_p(0x00,IO_DATA_PORT);93+94+ /* Set device Aux2 active */95+ outb_p(0x30,IO_INDEX_PORT);96+ outb_p(0x01,IO_DATA_PORT);97+98+ /* 99+ * Select device Aux1 (dev=7) to set GP16 as the watchdog output100+ * (in reg E6) and GP13 as the watchdog LED output (in reg E3).101+ * Map GP16 at pin 119.102+ * In test mode watch the bit 0 on F4 to indicate "triggered" or103+ * check watchdog LED on SBC.104+ */105+ outb_p(DEVICE_REGISTER,IO_INDEX_PORT);106+ outb_p(0x07,IO_DATA_PORT);107+ if (!testmode)108+ {109+ unsigned pin_map;110+111+ outb_p(0xE6,IO_INDEX_PORT);112+ outb_p(0x0A,IO_DATA_PORT);113+ outb_p(0x2C,IO_INDEX_PORT);114+ pin_map = inb_p(IO_DATA_PORT);115+ pin_map |= 0x10;116+ pin_map &= ~(0x20);117+ outb_p(0x2C,IO_INDEX_PORT);118+ outb_p(pin_map,IO_DATA_PORT);119+ }120+ outb_p(0xE3,IO_INDEX_PORT);121+ outb_p(0x08,IO_DATA_PORT);122+123+ /* Set device Aux1 active */124+ outb_p(0x30,IO_INDEX_PORT);125+ outb_p(0x01,IO_DATA_PORT);126+127+ /* Lock the SuperIO chip */128+ outb_p(LOCK_DATA,IO_INDEX_PORT);129+130+ spin_unlock_irqrestore(&spinlock, flags);131+132+ printk(KERN_INFO PFX "activated.\n");133+134+ return 0;135+}136+137+/*138+ * Stop the watchdog139+ */140+141+static int wdt_stop(void)142+{143+ unsigned long flags;144+145+ spin_lock_irqsave(&spinlock, flags);146+147+ /* Unlock the SuperIO chip */148+ outb_p(UNLOCK_DATA,IO_INDEX_PORT);149+ outb_p(UNLOCK_DATA,IO_INDEX_PORT);150+151+ /* 152+ * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4.153+ * F2 is reset to its default value (watchdog timer disabled).154+ * F3 is reset to its default state.155+ * F4 clears the TIMEOUT'ed state (bit 0) - back to default.156+ */157+ outb_p(DEVICE_REGISTER,IO_INDEX_PORT);158+ outb_p(0x08,IO_DATA_PORT);159+ outb_p(0xF2,IO_INDEX_PORT);160+ outb_p(0xFF,IO_DATA_PORT);161+ outb_p(0xF3,IO_INDEX_PORT);162+ outb_p(0x00,IO_DATA_PORT);163+ outb_p(0xF4,IO_INDEX_PORT);164+ outb_p(0x00,IO_DATA_PORT);165+ outb_p(0xF2,IO_INDEX_PORT);166+ outb_p(0x00,IO_DATA_PORT);167+168+ /*169+ * Select device Aux1 (dev=7) to set GP16 (in reg E6) and 170+ * Gp13 (in reg E3) as inputs.171+ */172+ outb_p(DEVICE_REGISTER,IO_INDEX_PORT);173+ outb_p(0x07,IO_DATA_PORT);174+ if (!testmode)175+ {176+ outb_p(0xE6,IO_INDEX_PORT);177+ outb_p(0x01,IO_DATA_PORT);178+ }179+ outb_p(0xE3,IO_INDEX_PORT);180+ outb_p(0x01,IO_DATA_PORT);181+182+ /* Lock the SuperIO chip */183+ outb_p(LOCK_DATA,IO_INDEX_PORT);184+185+ spin_unlock_irqrestore(&spinlock, flags);186+187+ printk(KERN_INFO PFX "shutdown.\n");188+189+ return 0;190+}191+192+/*193+ * Send a keepalive ping to the watchdog194+ * This is done by simply re-writing the timeout to reg. 0xF2195+ */196+197+static int wdt_keepalive(void)198+{199+ unsigned long flags;200+201+ spin_lock_irqsave(&spinlock, flags);202+203+ /* Unlock the SuperIO chip */204+ outb_p(UNLOCK_DATA,IO_INDEX_PORT);205+ outb_p(UNLOCK_DATA,IO_INDEX_PORT);206+207+ /* Select device Aux2 (device=8) to kick watchdog reg F2 */208+ outb_p(DEVICE_REGISTER,IO_INDEX_PORT);209+ outb_p(0x08,IO_DATA_PORT);210+ outb_p(0xF2,IO_INDEX_PORT);211+ outb_p(timeoutW,IO_DATA_PORT);212+213+ /* Lock the SuperIO chip */214+ outb_p(LOCK_DATA,IO_INDEX_PORT);215+216+ spin_unlock_irqrestore(&spinlock, flags);217+218+ return 0;219+}220+221+/*222+ * Set the watchdog timeout value223+ */224+225+static int wdt_set_timeout(int t)226+{227+ int tmrval;228+229+ /*230+ * Convert seconds to watchdog counter time units, rounding up.231+ * On PCM-5335 watchdog units are 30 seconds/step with 15 sec startup 232+ * value. This information is supplied in the PCM-5335 manual and was233+ * checked by me on a real board. This is a bit strange because W83977f234+ * datasheet says counter unit is in minutes!235+ */236+ if (t < 15)237+ return -EINVAL;238+239+ tmrval = ((t + 15) + 29) / 30;240+241+ if (tmrval > 255)242+ return -EINVAL;243+244+ /*245+ * timeout is the timeout in seconds, 246+ * timeoutW is the timeout in watchdog counter units.247+ */248+ timeoutW = tmrval;249+ timeout = (timeoutW * 30) - 15;250+ return 0;251+}252+253+/*254+ * Get the watchdog status255+ */256+257+static int wdt_get_status(int *status)258+{259+ int new_status;260+ unsigned long flags;261+262+ spin_lock_irqsave(&spinlock, flags);263+264+ /* Unlock the SuperIO chip */265+ outb_p(UNLOCK_DATA,IO_INDEX_PORT);266+ outb_p(UNLOCK_DATA,IO_INDEX_PORT);267+268+ /* Select device Aux2 (device=8) to read watchdog reg F4 */269+ outb_p(DEVICE_REGISTER,IO_INDEX_PORT);270+ outb_p(0x08,IO_DATA_PORT);271+ outb_p(0xF4,IO_INDEX_PORT);272+ new_status = inb_p(IO_DATA_PORT);273+274+ /* Lock the SuperIO chip */275+ outb_p(LOCK_DATA,IO_INDEX_PORT);276+277+ spin_unlock_irqrestore(&spinlock, flags);278+279+ *status = 0;280+ if (new_status & 1)281+ *status |= WDIOF_CARDRESET;282+283+ return 0;284+}285+286+287+/*288+ * /dev/watchdog handling289+ */290+291+static int wdt_open(struct inode *inode, struct file *file)292+{293+ /* If the watchdog is alive we don't need to start it again */294+ if( test_and_set_bit(0, &timer_alive) )295+ return -EBUSY;296+297+ if (nowayout)298+ __module_get(THIS_MODULE);299+300+ wdt_start();301+ return nonseekable_open(inode, file);302+}303+304+static int wdt_release(struct inode *inode, struct file *file)305+{306+ /*307+ * Shut off the timer.308+ * Lock it in if it's a module and we set nowayout309+ */310+ if (expect_close == 42)311+ {312+ wdt_stop();313+ clear_bit(0, &timer_alive);314+ } else {315+ wdt_keepalive();316+ printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n");317+ }318+ expect_close = 0;319+ return 0;320+}321+322+/*323+ * wdt_write:324+ * @file: file handle to the watchdog325+ * @buf: buffer to write (unused as data does not matter here326+ * @count: count of bytes327+ * @ppos: pointer to the position to write. No seeks allowed328+ *329+ * A write to a watchdog device is defined as a keepalive signal. Any330+ * write of data will do, as we we don't define content meaning.331+ */332+333+static ssize_t wdt_write(struct file *file, const char __user *buf,334+ size_t count, loff_t *ppos)335+{336+ /* See if we got the magic character 'V' and reload the timer */337+ if(count)338+ {339+ if (!nowayout)340+ {341+ size_t ofs;342+343+ /* note: just in case someone wrote the magic character long ago */344+ expect_close = 0;345+346+ /* scan to see whether or not we got the magic character */347+ for(ofs = 0; ofs != count; ofs++)348+ {349+ char c;350+ if (get_user(c, buf + ofs))351+ return -EFAULT;352+ if (c == 'V') {353+ expect_close = 42;354+ }355+ }356+ }357+358+ /* someone wrote to us, we should restart timer */359+ wdt_keepalive();360+ }361+ return count;362+}363+364+/*365+ * wdt_ioctl:366+ * @inode: inode of the device367+ * @file: file handle to the device368+ * @cmd: watchdog command369+ * @arg: argument pointer370+ *371+ * The watchdog API defines a common set of functions for all watchdogs372+ * according to their available features.373+ */374+375+static struct watchdog_info ident = {376+ .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,377+ .firmware_version = 1,378+ .identity = WATCHDOG_NAME,379+};380+381+static int wdt_ioctl(struct inode *inode, struct file *file,382+ unsigned int cmd, unsigned long arg)383+{384+ int status;385+ int new_options, retval = -EINVAL;386+ int new_timeout;387+ union {388+ struct watchdog_info __user *ident;389+ int __user *i;390+ } uarg;391+392+ uarg.i = (int __user *)arg;393+394+ switch(cmd)395+ {396+ default:397+ return -ENOIOCTLCMD;398+399+ case WDIOC_GETSUPPORT:400+ return copy_to_user(uarg.ident, &ident, sizeof(ident)) ? -EFAULT : 0;401+402+ case WDIOC_GETSTATUS:403+ wdt_get_status(&status);404+ return put_user(status, uarg.i);405+406+ case WDIOC_GETBOOTSTATUS:407+ return put_user(0, uarg.i);408+409+ case WDIOC_KEEPALIVE:410+ wdt_keepalive();411+ return 0;412+413+ case WDIOC_SETOPTIONS:414+ if (get_user (new_options, uarg.i))415+ return -EFAULT;416+417+ if (new_options & WDIOS_DISABLECARD) {418+ wdt_stop();419+ retval = 0;420+ }421+422+ if (new_options & WDIOS_ENABLECARD) {423+ wdt_start();424+ retval = 0;425+ }426+427+ return retval;428+429+ case WDIOC_SETTIMEOUT:430+ if (get_user(new_timeout, uarg.i))431+ return -EFAULT;432+433+ if (wdt_set_timeout(new_timeout))434+ return -EINVAL;435+436+ wdt_keepalive();437+ /* Fall */438+439+ case WDIOC_GETTIMEOUT:440+ return put_user(timeout, uarg.i);441+442+ }443+}444+445+static int wdt_notify_sys(struct notifier_block *this, unsigned long code,446+ void *unused)447+{448+ if (code==SYS_DOWN || code==SYS_HALT)449+ wdt_stop();450+ return NOTIFY_DONE;451+}452+453+static struct file_operations wdt_fops=454+{455+ .owner = THIS_MODULE,456+ .llseek = no_llseek,457+ .write = wdt_write,458+ .ioctl = wdt_ioctl,459+ .open = wdt_open,460+ .release = wdt_release,461+};462+463+static struct miscdevice wdt_miscdev=464+{465+ .minor = WATCHDOG_MINOR,466+ .name = "watchdog",467+ .fops = &wdt_fops,468+};469+470+static struct notifier_block wdt_notifier = {471+ .notifier_call = wdt_notify_sys,472+};473+474+static int __init w83977f_wdt_init(void)475+{476+ int rc;477+478+ printk(KERN_INFO PFX DRIVER_VERSION);479+480+ spin_lock_init(&spinlock);481+482+ /*483+ * Check that the timeout value is within it's range ; 484+ * if not reset to the default485+ */486+ if (wdt_set_timeout(timeout)) {487+ wdt_set_timeout(DEFAULT_TIMEOUT);488+ printk(KERN_INFO PFX "timeout value must be 15<=timeout<=7635, using %d\n",489+ DEFAULT_TIMEOUT);490+ }491+492+ if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME))493+ {494+ printk(KERN_ERR PFX "I/O address 0x%04x already in use\n",495+ IO_INDEX_PORT);496+ rc = -EIO;497+ goto err_out;498+ }499+500+ rc = misc_register(&wdt_miscdev);501+ if (rc)502+ {503+ printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",504+ wdt_miscdev.minor, rc);505+ goto err_out_region;506+ }507+508+ rc = register_reboot_notifier(&wdt_notifier);509+ if (rc)510+ {511+ printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",512+ rc);513+ goto err_out_miscdev;514+ }515+516+ printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n",517+ timeout, nowayout, testmode);518+519+ return 0;520+521+err_out_miscdev:522+ misc_deregister(&wdt_miscdev);523+err_out_region:524+ release_region(IO_INDEX_PORT,2);525+err_out:526+ return rc;527+}528+529+static void __exit w83977f_wdt_exit(void)530+{531+ wdt_stop();532+ misc_deregister(&wdt_miscdev);533+ unregister_reboot_notifier(&wdt_notifier);534+ release_region(IO_INDEX_PORT,2);535+}536+537+module_init(w83977f_wdt_init);538+module_exit(w83977f_wdt_exit);539+540+MODULE_AUTHOR("Jose Goncalves <jose.goncalves@inov.pt>");541+MODULE_DESCRIPTION("Driver for watchdog timer in W83977F I/O chip");542+MODULE_LICENSE("GPL");543+MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
+8
include/asm-ppc/mv64x60.h
···119120#define MV64x60_64BIT_WIN_COUNT 2412100000000122/*123 * Define a structure that's used to pass in config information to the124 * core routines.
···119120#define MV64x60_64BIT_WIN_COUNT 24121122+/* Watchdog Platform Device, Driver Data */123+#define MV64x60_WDT_NAME "wdt"124+125+struct mv64x60_wdt_pdata {126+ int timeout; /* watchdog expiry in seconds, default 10 */127+ int bus_clk; /* bus clock in MHz, default 133 */128+};129+130/*131 * Define a structure that's used to pass in config information to the132 * core routines.