/* * SBC8360 Watchdog driver * * (c) Copyright 2005 Webcon, Inc. * * Based on ib700wdt.c, which is based on advantechwdt.c which is based * on acquirewdt.c which is based on wdt.c. * * (c) Copyright 2001 Charles Howes * * Based on advantechwdt.c which is based on acquirewdt.c which * is based on wdt.c. * * (c) Copyright 2000-2001 Marek Michalkiewicz * * Based on acquirewdt.c which is based on wdt.c. * Original copyright messages: * * (c) Copyright 1996 Alan Cox , * All Rights Reserved. * * 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 * * 14-Dec-2001 Matt Domsch * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT * Added timeout module option to override default * */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long sbc8360_is_open; static char expect_close; /* * * Watchdog Timer Configuration * * The function of the watchdog timer is to reset the system automatically * and is defined at I/O port 0120H and 0121H. To enable the watchdog timer * and allow the system to reset, write appropriate values from the table * below to I/O port 0120H and 0121H. To disable the timer, write a zero * value to I/O port 0121H for the system to stop the watchdog function. * * The following describes how the timer should be programmed (according to * the vendor documentation) * * Enabling Watchdog: * MOV AX,000AH (enable, phase I) * MOV DX,0120H * OUT DX,AX * MOV AX,000BH (enable, phase II) * MOV DX,0120H * OUT DX,AX * MOV AX,000nH (set multiplier n, from 1-4) * MOV DX,0120H * OUT DX,AX * MOV AX,000mH (set base timer m, from 0-F) * MOV DX,0121H * OUT DX,AX * * Reset timer: * MOV AX,000mH (same as set base timer, above) * MOV DX,0121H * OUT DX,AX * * Disabling Watchdog: * MOV AX,0000H (a zero value) * MOV DX,0120H * OUT DX,AX * * Watchdog timeout configuration values: * N * M | 1 2 3 4 * --|---------------------------------- * 0 | 0.5s 5s 50s 100s * 1 | 1s 10s 100s 200s * 2 | 1.5s 15s 150s 300s * 3 | 2s 20s 200s 400s * 4 | 2.5s 25s 250s 500s * 5 | 3s 30s 300s 600s * 6 | 3.5s 35s 350s 700s * 7 | 4s 40s 400s 800s * 8 | 4.5s 45s 450s 900s * 9 | 5s 50s 500s 1000s * A | 5.5s 55s 550s 1100s * B | 6s 60s 600s 1200s * C | 6.5s 65s 650s 1300s * D | 7s 70s 700s 1400s * E | 7.5s 75s 750s 1500s * F | 8s 80s 800s 1600s * * Another way to say the same things is: * For N=1, Timeout = (M+1) * 0.5s * For N=2, Timeout = (M+1) * 5s * For N=3, Timeout = (M+1) * 50s * For N=4, Timeout = (M+1) * 100s * */ static int wd_times[64][2] = { {0, 1}, /* 0 = 0.5s */ {1, 1}, /* 1 = 1s */ {2, 1}, /* 2 = 1.5s */ {3, 1}, /* 3 = 2s */ {4, 1}, /* 4 = 2.5s */ {5, 1}, /* 5 = 3s */ {6, 1}, /* 6 = 3.5s */ {7, 1}, /* 7 = 4s */ {8, 1}, /* 8 = 4.5s */ {9, 1}, /* 9 = 5s */ {0xA, 1}, /* 10 = 5.5s */ {0xB, 1}, /* 11 = 6s */ {0xC, 1}, /* 12 = 6.5s */ {0xD, 1}, /* 13 = 7s */ {0xE, 1}, /* 14 = 7.5s */ {0xF, 1}, /* 15 = 8s */ {0, 2}, /* 16 = 5s */ {1, 2}, /* 17 = 10s */ {2, 2}, /* 18 = 15s */ {3, 2}, /* 19 = 20s */ {4, 2}, /* 20 = 25s */ {5, 2}, /* 21 = 30s */ {6, 2}, /* 22 = 35s */ {7, 2}, /* 23 = 40s */ {8, 2}, /* 24 = 45s */ {9, 2}, /* 25 = 50s */ {0xA, 2}, /* 26 = 55s */ {0xB, 2}, /* 27 = 60s */ {0xC, 2}, /* 28 = 65s */ {0xD, 2}, /* 29 = 70s */ {0xE, 2}, /* 30 = 75s */ {0xF, 2}, /* 31 = 80s */ {0, 3}, /* 32 = 50s */ {1, 3}, /* 33 = 100s */ {2, 3}, /* 34 = 150s */ {3, 3}, /* 35 = 200s */ {4, 3}, /* 36 = 250s */ {5, 3}, /* 37 = 300s */ {6, 3}, /* 38 = 350s */ {7, 3}, /* 39 = 400s */ {8, 3}, /* 40 = 450s */ {9, 3}, /* 41 = 500s */ {0xA, 3}, /* 42 = 550s */ {0xB, 3}, /* 43 = 600s */ {0xC, 3}, /* 44 = 650s */ {0xD, 3}, /* 45 = 700s */ {0xE, 3}, /* 46 = 750s */ {0xF, 3}, /* 47 = 800s */ {0, 4}, /* 48 = 100s */ {1, 4}, /* 49 = 200s */ {2, 4}, /* 50 = 300s */ {3, 4}, /* 51 = 400s */ {4, 4}, /* 52 = 500s */ {5, 4}, /* 53 = 600s */ {6, 4}, /* 54 = 700s */ {7, 4}, /* 55 = 800s */ {8, 4}, /* 56 = 900s */ {