linux/drivers/watchdog/w83627hf_wdt.c
<<
" " " o/spa.18" ospa. class="lxr_search">" " " " typ Search18 " " o/spa.18 " oinput typ " 8 odiv id/ /1o/a>ospa. class="comment">/*o/spa.18/ /2o/a>ospa. class="comment"> * / /3o/a>ospa. class="comment"> *o/spa.18/ /4o/a>ospa. class="comment"> * / /5o/a>ospa. class="comment"> * / /6o/a>ospa. class="comment"> *o/spa.18/ /7o/a>ospa. class="comment"> * / /8o/a>ospa. class="comment"> *o/spa.18/ /9o/a>ospa. class="comment"> * advantechwdt.c which is based n> wdt.c.o/spa.18/ >a>ospa. class="comment"> * / 11o/a>ospa. class="comment"> *o/spa.18/ 12o/a>ospa. class="comment"> * / 13o/a>ospa. class="comment"> *o/spa.18/ 14o/a>ospa. class="comment"> * / 15o/a>ospa. class="comment"> * / 16o/a>ospa. class="comment"> *o/spa.18/ 17o/a>ospa. class="comment"> * / 18o/a>ospa. class="comment"> * / 19o/a>ospa. class="comment"> * / 2 >a>ospa. class="comment"> * / 21o/a>ospa. class="comment"> *o/spa.18/ 22o/a>ospa. class="comment"> * / 23o/a>ospa. class="comment"> * / 24o/a>ospa. class="comment"> * / 25o/a>ospa. class="comment"> *o/spa.18/ 26o/a>ospa. class="comment"> * / 27o/a>ospa. class="comment"> */o/spa.18/ 28o/a>8/ 29o/a>#define/oa href="+code=pr_fmt" class="sref">pr_fmto/a>(oa href="+code=fmt" class="sref">fmto/a>)/oa href="+code=KBUILD_MODNAME" class="sref">KBUILD_MODNAMEo/a> ospa. class="string">":/"o/spa.1/oa href="+code=fmt" class="sref">fmto/a>8/ 30o/a>8/ 31o/a>#include <linux/module.ho/a>>8/ 32o/a>#include <linux/moduleparam.ho/a>>8/ 33o/a>#include <linux/typ s.ho/a>>8/ 34o/a>#include <linux/miscdevice.ho/a>>8/ 35o/a>#include <linux/watchdog.ho/a>>8/ 36o/a>#include <linux/fs.ho/a>>8/ 37o/a>#include <linux/ioport.ho/a>>8/ 38o/a>#include <linux/notifier.ho/a>>8/ 39o/a>#include <linux/reboot.ho/a>>8/ 40o/a>#include <linux/init.ho/a>>8/ 41o/a>#include <linux/spinlock.ho/a>>8/ 42o/a>#include <linux/io.ho/a>>8/ 43o/a>#include <linux/uaccess.ho/a>>8/ 44o/a>8/ 45o/a>8/ 46o/a>#define/oa href="+code=WATCHDOG_NAME" class="sref">WATCHDOG_NAMEo/a> ospa. class="string">"w83627hf/thf/hg/dhg WDT"o/spa.18/ 47o/a>#define/oa href="+code=WATCHDOG_TIMEOUT" class="sref">WATCHDOG_TIMEOUTo/a> 60/////////////ospa. class="comment">/* 60/sec default timeout */o/spa.18/ 48o/a>8/ 49o/a>static unsigned long/oa href="+code=wdt_is_open" class="sref">wdt_is_openo/a>;8/ 50o/a>static char/oa href="+code=expect_close" class="sref">expect_closeo/a>;8/ 51o/a>static oa href="+code=DEFINE_SPINLOCK" class="sref">DEFINE_SPINLOCKo/a>(oa href="+code=io_lock" class="sref">io_locko/a>);8/ 52o/a>8/ 53o/a>ospa. class="comment">/* You must/set this - there is no sane/way to probe for this board. */o/spa.18/ 54o/a>static int/oa href="+code=wdt_io" class="sref">wdt_ioo/a> = 0x2E;8/ 55o/a>oa href="+code=module_param" class="sref">module_paramo/a>(oa href="+code=wdt_io" class="sref">wdt_ioo/a>, int, 0);8/ 56o/a>oa href="+code=MODULE_PARM_DESC" class="sref">MODULE_PARM_DESCo/a>(oa href="+code=wdt_io" class="sref">wdt_ioo/a>, ospa. class="string">"w83627hf/thf WDT io port (default 0x2E)"o/spa.1);8/ 57o/a>8/ 58o/a>static int/oa href="+code=timeout" class="sref">timeouto/a> = oa href="+code=WATCHDOG_TIMEOUT" class="sref">WATCHDOG_TIMEOUTo/a>;//ospa. class="comment">/* in/seconds */o/spa.18/ 59o/a>oa href="+code=module_param" class="sref">module_paramo/a>(oa href="+code=timeout" class="sref">timeouto/a>, int, 0);8/ 60o/a>oa href="+code=MODULE_PARM_DESC" class="sref">MODULE_PARM_DESCo/a>(oa href="+code=timeout" class="sref">timeouto/a>,8/ 61o/a>////////////////ospa. class="string">"Watchdog timeout in/seconds. 1 <= timeout <= 255, default="o/spa.18/ 62o/a>////////////////////////////////oa href="+code=__MODULE_STRING" class="sref">__MODULE_STRINGo/a>(oa href="+code=WATCHDOG_TIMEOUT" class="sref">WATCHDOG_TIMEOUTo/a>)/ospa. class="string">"."o/spa.1);8/ 63o/a>8/ 64o/a>static oa href="+code=bool" class="sref">boolo/a> oa href="+code=nowayout" class="sref">nowayouto/a> = oa href="+code=WATCHDOG_NOWAYOUT" class="sref">WATCHDOG_NOWAYOUTo/a>;8/ 65o/a>oa href="+code=module_param" class="sref">module_paramo/a>(oa href="+code=nowayout" class="sref">nowayouto/a>, oa href="+code=bool" class="sref">boolo/a>, 0);8/ 66o/a>oa href="+code=MODULE_PARM_DESC" class="sref">MODULE_PARM_DESCo/a>(oa href="+code=nowayout" class="sref">nowayouto/a>,8/ 67o/a>////////////////ospa. class="string">"Watchdog cannot be stopped n>ce started (default="o/spa.18/ 68o/a>////////////////////////////////oa href="+code=__MODULE_STRING" class="sref">__MODULE_STRINGo/a>(oa href="+code=WATCHDOG_NOWAYOUT" class="sref">WATCHDOG_NOWAYOUTo/a>)/ospa. class="string">")"o/spa.1);8/ 69o/a>8/ 7 >a>ospa. class="comment">/*o/spa.18/ 71o/a>ospa. class="comment"> *//////Kernel methods.o/spa.18/ 72o/a>ospa. class="comment"> */o/spa.18/ 73o/a>8/ 74o/a>#define/oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>/(oa href="+code=wdt_io" class="sref">wdt_ioo/a>+0)///ospa. class="comment">/* Extended Func v3. Enable Registers */o/spa.18/ 75o/a>#define/oa href="+code=WDT_EFIR" class="sref">WDT_EFIRo/a>/(oa href="+code=wdt_io" class="sref">wdt_ioo/a>+0)///ospa. class="comment">/* Extended Func v3. Index Registero/spa.18/ 76o/a>ospa. class="comment"> (sam /as EFER) */o/spa.18/ 77o/a>#define/oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>/(oa href="+code=WDT_EFIR" class="sref">WDT_EFIRo/a>+1)/ospa. class="comment">/* Extended Func v3. Data Register */o/spa.18/ 78o/a>8/ 79o/a>static void/oa href="+code=w83627hf_select_wd_register" class="sref">w83627hf_select_wd_registero/a>(void)8/ 8 >a>{8/ 81o/a>////////unsigned char/oa href="+code=c" class="sref">co/a>;8/ 82o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0x87, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* Enter extended func v3. mode */o/spa.18/ 83o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0x87, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* Again according to manual */o/spa.18/ 84o/a>8/ 85o/a>////////oa href="+code=outb" class="sref">outbo/a>(0x20, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);///ospa. class="comment">/* check chip versv3.///*/o/spa.18/ 86o/a>////////oa href="+code=c" class="sref">co/a> = oa href="+code=inb" class="sref">inbo/a>(oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);8/ 87o/a>////////if/(oa href="+code=c" class="sref">co/a> == 0x82) {////////ospa. class="comment">/* W83627THF */o/spa.18/ 88o/a>////////////////oa href="+code=outb_p" class="sref">outb_po/a>(0x2b, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* select GPIO3 */o/spa.18/ 89o/a>////////////////oa href="+code=c" class="sref">co/a> = ((oa href="+code=inb_p" class="sref">inb_po/a>(oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>) & 0xf7) | 0x04);/ospa. class="comment">/* select WDT0 */o/spa.18/ 90o/a>////////////////oa href="+code=outb_p" class="sref">outb_po/a>(0x2b, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);8/ 91o/a>////////////////oa href="+code=outb_p" class="sref">outb_po/a>(oa href="+code=c" class="sref">co/a>, oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);////ospa. class="comment">/* set GPIO3 to WDT0 */o/spa.18/ 92o/a>////////} else/if/(oa href="+code=c" class="sref">co/a> == 0x88 ||/oa href="+code=c" class="sref">co/a> == 0xa0) {////ospa. class="comment">/* W83627EHF / W83627DHG */o/spa.18/ 93o/a>////////////////oa href="+code=outb_p" class="sref">outb_po/a>(0x2d, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* select GPIO5 */o/spa.18/ 94o/a>////////////////oa href="+code=c" class="sref">co/a> = oa href="+code=inb_p" class="sref">inb_po/a>(oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>) & ~0x01;/ospa. class="comment">/* PIN77 -> WDT0# */o/spa.18/ 95o/a>////////////////oa href="+code=outb_p" class="sref">outb_po/a>(0x2d, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);8/ 96o/a>////////////////oa href="+code=outb_p" class="sref">outb_po/a>(oa href="+code=c" class="sref">co/a>, oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);/ospa. class="comment">/* set GPIO5 to WDT0 */o/spa.18/ 97o/a>////////}8/ 98o/a>8/ 99o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0x07, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* point/to logical device number reg */o/spa.18/100o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0x08, oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);/ospa. class="comment">/* select logical device 8 (GPIO2) */o/spa.18/101o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0x30, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* select CR30 */o/spa.18/102o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0x01, oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);/ospa. class="comment">/* set bit 0/to ac vvate GPIO2 */o/spa.18/103o/a>}8/104o/a>8/105o/a>static void/oa href="+code=w83627hf_unselect_wd_register" class="sref">w83627hf_unselect_wd_registero/a>(void)8/106 >a>{8/107o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0xAA, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* Leave extended func v3. mode */o/spa.18/108o/a>}8/109o/a>8/1 >a>ospa. class="comment">/* tya. motherboards seem/to set F5 to 0x4C ?o/spa.18/111o/a>ospa. class="comment"> * So explicitly init/to appropriate . */o/spa.18/112o/a>8/113o/a>static void/oa href="+code=w83627hf_init" class="sref">w83627hf_inito/a>(void)8/114o/a>{8/115o/a>////////unsigned char/oa href="+code=t" class="sref">to/a>;8/116o/a>8/117o/a>////////oa href="+code=w83627hf_select_wd_register" class="sref">w83627hf_select_wd_registero/a>();8/118o/a>8/119o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0xF6, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* Select CRF6 */o/spa.18/120o/a>////////oa href="+code=t" class="sref">to/a> = oa href="+code=inb_p" class="sref">inb_po/a>(oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);//////ospa. class="comment">/* read CRF6 */o/spa.18/121o/a>////////if/(oa href="+code=t" class="sref">to/a> != 0) {8/122o/a>////////////////oa href="+code=pr_info" class="sref">pr_infoo/a>(ospa. class="string">"Watchdog already running. Resetting timeout to %d/sec\n"o/spa.1,8/123o/a>////////////////////////oa href="+code=timeout" class="sref">timeouto/a>);8/124o/a>////////////////oa href="+code=outb_p" class="sref">outb_po/a>(oa href="+code=timeout" class="sref">timeouto/a>, oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);////ospa. class="comment">/* Write back to CRF6 */o/spa.18/125o/a>////////}8/126o/a>8/127o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0xF5, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* Select CRF5 */o/spa.18/128o/a>////////oa href="+code=t" class="sref">to/a> = oa href="+code=inb_p" class="sref">inb_po/a>(oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);//////ospa. class="comment">/* read CRF5 */o/spa.18/129o/a>////////oa href="+code=t" class="sref">to/a> &= ~0x0C;///////////////ospa. class="comment">/* set second mode & disable keyboardo/spa.18/13 >a>ospa. class="comment"> turning off watchdog */o/spa.18/131o/a>////////oa href="+code=t" class="sref">to/a> |= 0x02;////////////////ospa. class="comment">/* enable the WDTO# output low pulseo/spa.18/132o/a>ospa. class="comment"> to the KBRST# pin (PIN60) */o/spa.18/133o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(oa href="+code=t" class="sref">to/a>, oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);////ospa. class="comment">/* Write back to CRF5 */o/spa.18/134o/a>8/135o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0xF7, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);/ospa. class="comment">/* Select CRF7 */o/spa.18/136o/a>////////oa href="+code=t" class="sref">to/a> = oa href="+code=inb_p" class="sref">inb_po/a>(oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);//////ospa. class="comment">/* read CRF7 */o/spa.18/137o/a>////////oa href="+code=t" class="sref">to/a> &= ~0xC0;///////////////ospa. class="comment">/* disable keyboard & mouse turning offo/spa.18/138o/a>ospa. class="comment"> watchdog */o/spa.18/139o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(oa href="+code=t" class="sref">to/a>, oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);////ospa. class="comment">/* Write back to CRF7 */o/spa.18/140o/a>8/141o/a>////////oa href="+code=w83627hf_unselect_wd_register" class="sref">w83627hf_unselect_wd_registero/a>();8/142o/a>}8/143o/a>8/144o/a>static void/oa href="+code=wdt_set_time" class="sref">wdt_set_timeo/a>(int/oa href="+code=timeout" class="sref">timeouto/a>)8/145o/a>{8/146o/a>////////oa href="+code=spin_lock" class="sref">spin_locko/a>(&oa href="+code=io_lock" class="sref">io_locko/a>);8/147o/a>8/148o/a>////////oa href="+code=w83627hf_select_wd_register" class="sref">w83627hf_select_wd_registero/a>();8/149o/a>8/150o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0xF6, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);////ospa. class="comment">/* Select CRF6 */o/spa.18/151o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(oa href="+code=timeout" class="sref">timeouto/a>, oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);/ospa. class="comment">/* Write Timeout counter to CRF6 */o/spa.18/152o/a>8/153o/a>////////oa href="+code=w83627hf_unselect_wd_register" class="sref">w83627hf_unselect_wd_registero/a>();8/154o/a>8/155o/a>////////oa href="+code=spin_unlock" class="sref">spin_unlocko/a>(&oa href="+code=io_lock" class="sref">io_locko/a>);8/156o/a>}8/157o/a>8/158o/a>static int/oa href="+code=wdt_ping" class="sref">wdt_pingo/a>(void)8/159o/a>{8/160o/a>////////oa href="+code=wdt_set_time" class="sref">wdt_set_timeo/a>(oa href="+code=timeout" class="sref">timeouto/a>);8/161o/a>////////return 0;8/162o/a>}8/163o/a>8/164o/a>static int/oa href="+code=wdt_disable" class="sref">wdt_disableo/a>(void)8/165o/a>{8/166o/a>////////oa href="+code=wdt_set_time" class="sref">wdt_set_timeo/a>(0);8/167o/a>////////return 0;8/168o/a>}8/169o/a>8/170o/a>static int/oa href="+code=wdt_set_heartbeat" class="sref">wdt_set_heartbeato/a>(int/oa href="+code=t" class="sref">to/a>)8/171o/a>{8/172o/a>////////if/(oa href="+code=t" class="sref">to/a> < 1 ||/oa href="+code=t" class="sref">to/a> > 255)8/173o/a>////////////////return -oa href="+code=EINVAL" class="sref">EINVALo/a>;8/174o/a>////////oa href="+code=timeout" class="sref">timeouto/a> = oa href="+code=t" class="sref">to/a>;8/175o/a>////////return 0;8/176o/a>}8/177o/a>8/178o/a>static int/oa href="+code=wdt_get_time" class="sref">wdt_get_timeo/a>(void)8/179o/a>{8/180o/a>////////int/oa href="+code=timeleft" class="sref">timelefto/a>;8/181o/a>8/182o/a>////////oa href="+code=spin_lock" class="sref">spin_locko/a>(&oa href="+code=io_lock" class="sref">io_locko/a>);8/183o/a>8/184o/a>////////oa href="+code=w83627hf_select_wd_register" class="sref">w83627hf_select_wd_registero/a>();8/185o/a>8/186o/a>////////oa href="+code=outb_p" class="sref">outb_po/a>(0xF6, oa href="+code=WDT_EFER" class="sref">WDT_EFERo/a>);////ospa. class="comment">/* Select CRF6 */o/spa.18/187o/a>////////oa href="+code=timeleft" class="sref">timelefto/a> = oa href="+code=inb_p" class="sref">inb_po/a>(oa href="+code=WDT_EFDR" class="sref">WDT_EFDRo/a>);/ospa. class="comment">/* Read Timeout counter to CRF6 */o/spa.18/188o/a>8/189o/a>////////oa href="+code=w83627hf_unselect_wd_register" class="sref">w83627hf_unselect_wd_registero/a>();8/190o/a>8/191o/a>////////oa href="+code=spin_unlock" class="sref">spin_unlocko/a>(&oa href="+code=io_lock" class="sref">io_locko/a>);8/192o/a>8/193o/a>////////return oa href="+code=timeleft" class="sref">timelefto/a>;8/194o/a>}8/195o/a>8/196o/a>static oa href="+code=ssize_t" class="sref">ssize_to/a>/oa href="+code=wdt_write" class="sref">wdt_writeo/a>(struct/oa href="+code=file" class="sref">fileo/a>/*oa href="+code=file" class="sref">fileo/a>, const char/oa href="+code=__user" class="sref">__usero/a>/*oa href="+code=buf" class="sref">bufo/a>,8/197o/a>////////////////////////////////////////////////oa href="+code=size_t" class="sref">size_to/a>/oa href="+code=count" class="sref">counto/a>, oa href="+code=loff_t" class="sref">loff_to/a>/*oa href="+code=ppos" class="sref">pposo/a>)8/198o/a>{8/199o/a>////////if/(oa href="+code=count" class="sref">counto/a>) {8/200o/a>////////////////if/(!oa href="+code=nowayout" class="sref">nowayouto/a>) {8/201o/a>////////////////////////oa href="+code=size_t" class="sref">size_to/a>/oa href="+code=i" class="sref">io/a>;8/202o/a>8/203o/a>////////////////////////oa href="+code=expect_close" class="sref">expect_closeo/a> = 0;8/204o/a>8/205o/a>////////////////////////for (oa href="+code=i" class="sref">io/a> = 0;/oa href="+code=i" class="sref">io/a> != oa href="+code=count" class="sref">counto/a>;/oa href="+code=i" class="sref">io/a>++) {8/206o/a>////////////////////////////////char/oa href="+code=c" class="sref">co/a>;8/207o/a>////////////////////////////////if/(oa href="+code=get_user" class="sref">get_usero/a>(oa href="+code=c" class="sref">co/a>, oa href="+code=buf" class="sref">bufo/a> +/oa href="+code=i" class="sref">io/a>))8/208o/a>////////////////////////////////////////return -oa href="+code=EFAULT" class="sref">EFAULTo/a>;8/209o/a>////////////////////////////////if/(oa href="+code=c" class="sref">co/a> == ospa. class="string">'V'o/spa.1)8/210o/a>////////////////////////////////////////oa href="+code=expect_close" class="sref">expect_closeo/a> = 42;8/211o/a>////////////////////////}8/212o/a>////////////////}8/213o/a>////////////////oa href="+code=wdt_ping" class="sref">wdt_pingo/a>();8/214o/a>////////}8/215o/a>////////return oa href="+code=count" class="sref">counto/a>;8/216o/a>}8/217o/a>8/218o/a>static long/oa href="+code=wdt_ioctl" class="sref">wdt_ioctlo/a>(struct/oa href="+code=file" class="sref">fileo/a>/*oa href="+code=file" class="sref">fileo/a>, unsigned int/oa href="+code=cmd" class="sref">cmdo/a>, unsigned long/oa href="+code=arg" class="sref">argo/a>)8/219o/a>{8/220o/a>////////void/oa href="+code=__user" class="sref">__usero/a>/*oa href="+code=argp" class="sref">argpo/a> = (void/oa href="+code=__user" class="sref">__usero/a>/*)oa href="+code=arg" class="sref">argo/a>;8/221o/a>////////int/oa href="+code=__user" class="sref">__usero/a>/*oa href="+code=p" class="sref">po/a> = oa href="+code=argp" class="sref">argpo/a>;8/222o/a>////////int/oa href="+code=timeval" class="sref">timevalo/a>;8/223o/a>////////static const struct/oa href="+code=watchdog_info" class="sref">watchdog_infoo/a>/oa href="+code=ident" class="sref">idento/a> = {8/224o/a>////////////////.oa href="+code=op v3.s" class="sref">op v3.so/a> = oa href="+code=WDIOF_KEEPALIVEPING" class="sref">WDIOF_KEEPALIVEPINGo/a> |/oa href="+code=WDIOF_SETTIMEOUT" class="sref">WDIOF_SETTIMEOUTo/a> |8/225o/a>////////////////////////////////////////////////////////oa href="+code=WDIOF_MAGICCLOSE" class="sref">WDIOF_MAGICCLOSEo/a>,8/226o/a>////////////////.oa href="+code=firmware_versv3." class="sref">firmware_versv3.o/a> = 1,8/227o/a>////////////////.oa href="+code=identity" class="sref">identityo/a> = ospa. class="string">"W83627HF WDT"o/spa.1,8/228o/a>////////};8/229o/a>8/230o/a>////////switch/(oa href="+code=cmd" class="sref">cmdo/a>) {8/231o/a>////////case/oa href="+code=WDIOC_GETSUPPORT" class="sref">WDIOC_GETSUPPORTo/a>:8/232o/a>////////////////if/(oa href="+code=copy_to_user" class="sref">copy_to_usero/a>(oa href="+code=argp" class="sref">argpo/a>, &oa href="+code=ident" class="sref">idento/a>, sizeof(oa href="+code=ident" class="sref">idento/a>)))8/233o/a>////////////////////////return -oa href="+code=EFAULT" class="sref">EFAULTo/a>;8/234o/a>////////////////break;8/235o/a>////////case/oa href="+code=WDIOC_GETSTATUS" class="sref">WDIOC_GETSTATUSo/a>:8/236o/a>////////case/oa href="+code=WDIOC_GETBOOTSTATUS" class="sref">WDIOC_GETBOOTSTATUSo/a>:8/237o/a>////////////////return oa href="+code=put_user" class="sref">put_usero/a>(0, oa href="+code=p" class="sref">po/a>);8/238o/a>////////case/oa href="+code=WDIOC_SETOPTIONS" class="sref">WDIOC_SETOPTIONSo/a>:8/239o/a>////////{8/240o/a>////////////////int/oa href="+code=op v3.s" class="sref">op v3.so/a>, oa href="+code=retval" class="sref">retvalo/a> = -oa href="+code=EINVAL" class="sref">EINVALo/a>;8/241o/a>8/242o/a>////////////////if/(oa href="+code=get_user" class="sref">get_usero/a>(oa href="+code=op v3.s" class="sref">op v3.so/a>, oa href="+code=p" class="sref">po/a>))8/243o/a>////////////////////////return -oa href="+code=EFAULT" class="sref">EFAULTo/a>;8/244o/a>////////////////if/(oa href="+code=op v3.s" class="sref">op v3.so/a> & oa href="+code=WDIOS_DISABLECARD" class="sref">WDIOS_DISABLECARDo/a>) {8/245o/a>////////////////////////oa href="+code=wdt_disable" class="sref">wdt_disableo/a>();8/246o/a>////////////////////////oa href="+code=retval" class="sref">retvalo/a> = 0;8/247o/a>////////////////}8/248o/a>////////////////if/(oa href="+code=op v3.s" class="sref">op v3.so/a> & oa href="+code=WDIOS_ENABLECARD" class="sref">WDIOS_ENABLECARDo/a>) {8/249o/a>////////////////////////oa href="+code=wdt_ping" class="sref">wdt_pingo/a>();8/250o/a>////////////////////////oa href="+code=retval" class="sref">retvalo/a> = 0;8/251o/a>////////////////}8/252o/a>////////////////return oa href="+code=retval" class="sref">retvalo/a>;8/253o/a>////////}8/254o/a>////////case/oa href="+code=WDIOC_KEEPALIVE" class="sref">WDIOC_KEEPALIVEo/a>:8/255o/a>////////////////oa href="+code=wdt_ping" class="sref">wdt_pingo/a>();8/256o/a>////////////////break;8/257o/a>////////case/oa href="+code=WDIOC_SETTIMEOUT" class="sref">WDIOC_SETTIMEOUTo/a>:8/258o/a>////////////////if/(oa href="+code=get_user" class="sref">get_usero/a>(oa href="+code=timeval" class="sref">timevalo/a>, oa href="+code=p" class="sref">po/a>))8/259o/a>////////////////////////return -oa href="+code=EFAULT" class="sref">EFAULTo/a>;8/260o/a>////////////////if/(oa href="+code=wdt_set_heartbeat" class="sref">wdt_set_heartbeato/a>(oa href="+code=timeval" class="sref">timevalo/a>))8/261o/a>////////////////////////return -oa href="+code=EINVAL" class="sref">EINVALo/a>;8/262o/a>////////////////oa href="+code=wdt_ping" class="sref">wdt_pingo/a>();8/263o/a>////////////////ospa. class="comment">/* Fall */o/spa.18/264o/a>////////case/oa href="+code=WDIOC_GETTIMEOUT" class="sref">WDIOC_GETTIMEOUTo/a>:8/265o/a>////////////////return oa href="+code=put_user" class="sref">put_usero/a>(oa href="+code=timeout" class="sref">timeouto/a>, oa href="+code=p" class="sref">po/a>);8/266o/a>////////case/oa href="+code=WDIOC_GETTIMELEFT" class="sref">WDIOC_GETTIMELEFTo/a>:8/267o/a>////////////////oa href="+code=timeval" class="sref">timevalo/a> = oa href="+code=wdt_get_time" class="sref">wdt_get_timeo/a>();8/268o/a>////////////////return oa href="+code=put_user" class="sref">put_usero/a>(oa href="+code=timeval" class="sref">timevalo/a>, oa href="+code=p" class="sref">po/a>);8/269o/a>////////default:8/270o/a>////////////////return -oa href="+code=ENOTTY" class="sref">ENOTTYo/a>;8/271o/a>////////}8/272o/a>////////return 0;8/273o/a>}8/274o/a>8/275o/a>static int/oa href="+code=wdt_ope." class="sref">wdt_ope.o/a>(struct/oa href="+code=inode" class="sref">inodeo/a>/*oa href="+code=inode" class="sref">inodeo/a>, struct/oa href="+code=file" class="sref">fileo/a>/*oa href="+code=file" class="sref">fileo/a>)8/276 >a>{8/277o/a>////////if/(oa href="+code=test_and_set_bit" class="sref">test_and_set_bito/a>(0, &oa href="+code=wdt_is_ope." class="sref">wdt_is_ope.o/a>))8/278o/a>////////////////return -oa href="+code=EBUSY" class="sref">EBUSYo/a>;8/279o/a>////////ospa. class="comment">/*o/spa.18/28 >a>ospa. class="comment"> * Ac vvateo/spa.18/281o/a>ospa. class="comment"> */o/spa.18/282o/a>8/283o/a>////////oa href="+code=wdt_ping" class="sref">wdt_pingo/a>();8/284o/a>////////return oa href="+code=nonseekable_ope." class="sref">nonseekable_ope.o/a>(oa href="+code=inode" class="sref">inodeo/a>, oa href="+code=file" class="sref">fileo/a>);8/285o/a>}8/286o/a>8/287o/a>static int/oa href="+code=wdt_close" class="sref">wdt_closeo/a>(struct/oa href="+code=inode" class="sref">inodeo/a>/*oa href="+code=inode" class="sref">inodeo/a>, struct/oa href="+code=file" class="sref">fileo/a>/*oa href="+code=file" class="sref">fileo/a>)8/288o/a>{8/289o/a>////////if/(oa href="+code=expect_close" class="sref">expect_closeo/a> == 42)8/290o/a>////////////////oa href="+code=wdt_disable" class="sref">wdt_disableo/a>();8/291o/a>////////else/{8/292o/a>////////////////oa href="+code=pr_crit" class="sref">pr_crito/a>(ospa. class="string">"Unexpected close, not stopping watchdog!\n"o/spa.1);8/293o/a>////////////////oa href="+code=wdt_ping" class="sref">wdt_pingo/a>();8/294o/a>////////}8/295o/a>////////oa href="+code=expect_close" class="sref">expect_closeo/a> = 0;8/296o/a>////////oa href="+code=clear_bit" class="sref">clear_bito/a>(0, &oa href="+code=wdt_is_ope." class="sref">wdt_is_ope.o/a>);8/297o/a>////////return 0;8/298o/a>}8/299o/a>8/30 >a>ospa. class="comment">/*o/spa.18/301o/a>ospa. class="comment"> * Notifier/for system downo/spa.18/302o/a>ospa. class="comment"> */o/spa.18/303o/a>8/304o/a>static int/oa href="+code=wdt_notify_sys" class="sref">wdt_notify_syso/a>(struct/oa href="+code=notifier_block" class="sref">notifier_blocko/a>/*oa href="+code=this" class="sref">thiso/a>, unsigned long/oa href="+code=code" class="sref">codeo/a>,8/305o/a>////////void/*oa href="+code=unused" class="sref">unusedo/a>)8/306 >a>{8/307o/a>////////if/(oa href="+code=code" class="sref">codeo/a> == oa href="+code=SYS_DOWN" class="sref">SYS_DOWNo/a> ||/oa href="+code=code" class="sref">codeo/a> == oa href="+code=SYS_HALT" class="sref">SYS_HALTo/a>)8/308o/a>////////////////oa href="+code=wdt_disable" class="sref">wdt_disableo/a>();//ospa. class="comment">/* Turn the WDT off */o/spa.18/309o/a>8/310o/a>////////return oa href="+code=NOTIFY_DONE" class="sref">NOTIFY_DONEo/a>;8/311o/a>}8/312o/a>8/313o/a>ospa. class="comment">/*o/spa.18/314o/a>ospa. class="comment"> * Kernel Interfaceso/spa.18/315o/a>ospa. class="comment"> */o/spa.18/316o/a>8/317o/a>static const struct/oa href="+code=file_opera v3.s" class="sref">file_opera v3.so/a>/oa href="+code=wdt_fops" class="sref">wdt_fopso/a> = {8/318o/a>////////.oa href="+code=owner" class="sref">ownero/a>//////////= oa href="+code=THIS_MODULE" class="sref">THIS_MODULEo/a>,8/319o/a>////////.oa href="+code=llseek" class="sref">llseeko/a>/////////= oa href="+code=no_llseek" class="sref">no_llseeko/a>,8/320o/a>////////.oa href="+code=write" class="sref">writeo/a>//////////= oa href="+code=wdt_write" class="sref">wdt_writeo/a>,8/321o/a>////////.oa href="+code=unlocked_ioctl" class="sref">unlocked_ioctlo/a> = oa href="+code=wdt_ioctl" class="sref">wdt_ioctlo/a>,8/322o/a>////////.oa href="+code=ope." class="sref">ope.o/a> //////////= oa href="+code=wdt_ope." class="sref">wdt_ope.o/a>,8/323o/a>////////.oa href="+code=release" class="sref">releaseo/a>////////= oa href="+code=wdt_close" class="sref">wdt_closeo/a>,8/324o/a>};8/325o/a>8/326o/a>static struct/oa href="+code=miscdevice" class="sref">miscdeviceo/a>/oa href="+code=wdt_miscdev" class="sref">wdt_miscdevo/a> = {8/327o/a>////////.oa href="+code=minor" class="sref">minoro/a> = oa href="+code=WATCHDOG_MINOR" class="sref">WATCHDOG_MINORo/a>,8/328o/a>////////.oa href="+code=nam " class="sref">nameo/a> = ospa. class="string">"watchdog"o/spa.1,8/329o/a>////////.oa href="+code=fops" class="sref">fopso/a> = &oa href="+code=wdt_fops" class="sref">wdt_fopso/a>,8/330o/a>};8/331o/a>8/332o/a>ospa. class="comment">/*o/spa.18/333o/a>ospa. class="comment"> * The WDT needs to learn about soft shutdowns in order too/spa.18/334o/a>ospa. class="comment"> * turn the timebomb registers off.o/spa.18/335o/a>ospa. class="comment"> */o/spa.18/336o/a>8/337o/a>static struct/oa href="+code=notifier_block" class="sref">notifier_blocko/a>/oa href="+code=wdt_notifier" class="sref">wdt_notifiero/a> = {8/338o/a>////////.oa href="+code=notifier_call" class="sref">notifier_callo/a> = oa href="+code=wdt_notify_sys" class="sref">wdt_notify_syso/a>,8/339o/a>};8/340o/a>8/341o/a>static int/oa href="+code=__init" class="sref">__inito/a>/oa href="+code=wdt_init" class="sref">wdt_inito/a>(void)8/342o/a>{8/343o/a>////////int/oa href="+code=ret" class="sref">reto/a>;8/344o/a>8/345o/a>////////oa href="+code=pr_info" class="sref">pr_infoo/a>(ospa. class="string">"WDT driver/for the Winbond(TM) W83627HF/THF/HG/DHG Super/I/O chip initialising\n"o/spa.1);8/346o/a>8/347o/a>////////if/(oa href="+code=wdt_set_heartbeat" class="sref">wdt_set_heartbeato/a>(oa href="+code=timeout" class="sref">timeouto/a>)) {8/348o/a>////////////////oa href="+code=wdt_set_heartbeat" class="sref">wdt_set_heartbeato/a>(oa href="+code=WATCHDOG_TIMEOUT" class="sref">WATCHDOG_TIMEOUTo/a>);8/349o/a>////////////////oa href="+code=pr_info" class="sref">pr_infoo/a>(ospa. class="string">"timeout value must be 1 <= timeout <= 255, using %d\n"o/spa.1,8/350o/a>////////////////////////oa href="+code=WATCHDOG_TIMEOUT" class="sref">WATCHDOG_TIMEOUTo/a>);8/351o/a>////////}8/352o/a>8/353o/a>////////if/(!oa href="+code=request_regi3." class="sref">request_regi3.o/a>(oa href="+code=wdt_io" class="sref">wdt_ioo/a>, 1, oa href="+code=WATCHDOG_NAME" class="sref">WATCHDOG_NAMEo/a>)) {8/354o/a>////////////////oa href="+code=pr_err" class="sref">pr_erro/a>(ospa. class="string">"I/O address 0x%04x already in use\n"o/spa.1, oa href="+code=wdt_io" class="sref">wdt_ioo/a>);8/355o/a>////////////////oa href="+code=ret" class="sref">reto/a> = -oa href="+code=EIO" class="sref">EIOo/a>;8/356o/a>////////////////goto oa href="+code=out" class="sref">outo/a>;8/357o/a>////////}8/358o/a>8/359o/a>////////oa href="+code=w83627hf_init" class="sref">w83627hf_inito/a>();8/360o/a>8/361o/a>////////oa href="+code=ret" class="sref">reto/a> = oa href="+code=register_reboot_notifier" class="sref">register_reboot_notifiero/a>(&oa href="+code=wdt_notifier" class="sref">wdt_notifiero/a>);8/362o/a>////////if/(oa href="+code=ret" class="sref">reto/a> != 0) {8/363o/a>////////////////oa href="+code=pr_err" class="sref">pr_erro/a>(ospa. class="string">"cannot register reboot notifier (err=%d)\n"o/spa.1, oa href="+code=ret" class="sref">reto/a>);8/364o/a>////////////////goto oa href="+code=unreg_regi3.s" class="sref">unreg_regi3.so/a>;8/365o/a>////////}8/366o/a>8/367o/a>////////oa href="+code=ret" class="sref">reto/a> = oa href="+code=misc_register" class="sref">misc_registero/a>(&oa href="+code=wdt_miscdev" class="sref">wdt_miscdevo/a>);8/368o/a>////////if/(oa href="+code=ret" class="sref">reto/a> != 0) {8/369o/a>////////////////oa href="+code=pr_err" class="sref">pr_erro/a>(ospa. class="string">"cannot register miscdev on minor=%d (err=%d)\n"o/spa.1,8/370o/a>///////////////////////oa href="+code=WATCHDOG_MINOR" class="sref">WATCHDOG_MINORo/a>, oa href="+code=ret" class="sref">reto/a>);8/371o/a>////////////////goto oa href="+code=unreg_reboot" class="sref">unreg_rebooto/a>;8/372o/a>////////}8/373o/a>8/374o/a>////////oa href="+code=pr_info" class="sref">pr_infoo/a>(ospa. class="string">"initialized. timeout=%d sec (nowayout=%d)\n"o/spa.1,8/375o/a>////////////////oa href="+code=timeout" class="sref">timeouto/a>, oa href="+code=nowayout" class="sref">nowayouto/a>);8/376o/a>8/377o/a>oa href="+code=out" class="sref">outo/a>:8/378o/a>////////return oa href="+code=ret" class="sref">reto/a>;8/379o/a>oa href="+code=unreg_reboot" class="sref">unreg_rebooto/a>:8/380o/a>////////oa href="+code=unregister_reboot_notifier" class="sref">unregister_reboot_notifiero/a>(&oa href="+code=wdt_notifier" class="sref">wdt_notifiero/a>);8/381o/a>oa href="+code=unreg_regi3.s" class="sref">unreg_regi3.so/a>:8/382o/a>////////oa href="+code=release_regi3." class="sref">release_regi3.o/a>(oa href="+code=wdt_io" class="sref">wdt_ioo/a>, 1);8/383o/a>////////goto oa href="+code=out" class="sref">outo/a>;8/384o/a>}8/385o/a>8/386o/a>static void/oa href="+code=__exit" class="sref">__exito/a>/oa href="+code=wdt_exit" class="sref">wdt_exito/a>(void)8/387o/a>{8/388o/a>////////oa href="+code=misc_deregister" class="sref">misc_deregistero/a>(&oa href="+code=wdt_miscdev" class="sref">wdt_miscdevo/a>);8/389o/a>////////oa href="+code=unregister_reboot_notifier" class="sref">unregister_reboot_notifiero/a>(&oa href="+code=wdt_notifier" class="sref">wdt_notifiero/a>);8/390o/a>////////oa href="+code=release_regi3." class="sref">release_regi3.o/a>(oa href="+code=wdt_io" class="sref">wdt_ioo/a>, 1);8/391o/a>}8/392o/a>8/393o/a>oa href="+code=module_init" class="sref">module_inito/a>(oa href="+code=wdt_init" class="sref">wdt_inito/a>);8/394o/a>oa href="+code=module_exit" class="sref">module_exito/a>(oa href="+code=wdt_exit" class="sref">wdt_exito/a>);8/395o/a>8/396o/a>oa href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSEo/a>(ospa. class="string">"GPL"o/spa.1);8/397o/a>oa href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHORo/a>(ospa. class="string">"Pádraig Brady <P@draigBrady.com>"o/spa.1);8/398o/a>oa href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTIONo/a>(ospa. class="string">"w83627hf/thf WDT driver"o/spa.1);8/399o/a>oa href="+code=MODULE_ALIAS_MISCDEV" class="sref">MODULE_ALIAS_MISCDEVo/a>(oa href="+code=WATCHDOG_MINOR" class="sref">WATCHDOG_MINORo/a>);8/40 >a>o/pre>o/div> o/div>