linux/drivers/watchdog/ar7_wdt.c
<<
on v4.4/spa > 4.4/form> 4.4a on v4. href="../linux+v3.7..4/drivers/watchdog/ar7_wdt.c">on v4.4img src="../.static/gfx/right.png" alt=">>">on4/spa > on4spa class="lxr_search">on von v4.4input typ> hidden" nam> navtarget" tion> ">on v4.4input typ> text" nam> search" id search">on v4.4butt/optyp> submit">Search 4.4/form> 4/spa > on4spa class="lxr_prefs"> 4.4a href="+prefs?return=drivers/watchdog/ar7_wdt.c"on v4. onclick="return ajax_prefs();">on v4.Prefs 4.4/a>on4/spa > v4. .4/div> v4. .4form ac ="ajax+*" method="post" onsubmit="return false;">on4input typ> hidden" nam> ajax_lookup" id ajax_lookup" tion> ">o v4. .4/form> o v4. .4div class="headingbott/m">
v4.
v4. 4. .4div id search_results" class="search_results" 4> v4. .4/div> 4div id content"> 4div id file_contents">

 L1">. .14/a>4spa  class="comment">/*4/spa >

 L2">. .24/a>4spa  class="comment"> * drivers/watchdog/ar7_wdt.c4/spa >

 L3">. .34/a>4spa  class="comment"> *4/spa >

 L4">. .44/a>4spa  class="comment"> * Copyright (C) 2007 Nicolas Thill <nico@openwrt.org>4/spa >

 L5">. .54/a>4spa  class="comment"> * Copyright (c) 2005 Enrik Berkha  <Enrik.Berkha @akk.org>4/spa >

 L6">. .64/a>4spa  class="comment"> *4/spa >

 L7">. .74/a>4spa  class="comment"> * Some code taken from:4/spa >

 L8">. .84/a>4spa  class="comment"> * Na
	  al Semiconductor SCx200 Watchdog support4/spa >

 L9">. .94/a>4spa  class="comment"> * Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>4/spa >

 L10">. .4.9a>4spa  class="comment"> *4/spa >

 L11">. 114/a>4spa  class="comment"> * This program is free software; you ca  redistribute it and/or modify4/spa >

 L12">. 124/a>4spa  class="comment"> * it under the terms of the GNU General Public License as published by4/spa >

 L13">. 134/a>4spa  class="comment"> * the Free Software Founda
	  ; either vers

 L14">. 144/a>4spa  class="comment"> * (at your 1"
	  ) any later vers

 L15">. 154/a>4spa  class="comment"> *4/spa >

 L16">. 164/a>4spa  class="comment"> * This program is distributed in the hope that it will be useful,4/spa >

 L17">. 174/a>4spa  class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of4/spa >

 L18">. 184/a>4spa  class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the4/spa >

 L19">. 194/a>4spa  class="comment"> * GNU General Public License for more details.4/spa >

 L20">. 24.9a>4spa  class="comment"> *4/spa >

 L21">. 214/a>4spa  class="comment"> * You should have received a copy of the GNU General Public License4/spa >

 L22">. 224/a>4spa  class="comment"> * along with this program; if not, write to the Free Software4/spa >

 L23">. 234/a>4spa  class="comment"> * Founda
	  , Inc., 51 Franklin St, Fifth Floor, Bost  , MA  02110-1301  USA4/spa >

 L24">. 244/a>4spa  class="comment"> */4/spa >

 L25">. 254/a>

 L26">. 264/a>#define.4a href="+code=pr_fmt" class="sref">pr_fmt4/a>(4a href="+code=fmt" class="sref">fmt4/a>).4a href="+code=KBUILD_MODNAME" class="sref">KBUILD_MODNAME4/a> 4spa  class="string">": "4/spa >.4a href="+code=fmt" class="sref">fmt4/a>

 L27">. 274/a>

 L28">. 284/a>#include <linux/module.h4/a>>

 L29">. 294/a>#include <linux/moduleparam.h4/a>>

 L30">. 304/a>#include <linux/errno.h4/a>>

 L31">. 314/a>#include <linux/init.h4/a>>

 L32">. 324/a>#include <linux/miscdevice.h4/a>>

 L33">. 334/a>#include <linux/platform_device.h4/a>>

 L34">. 344/a>#include <linux/watchdog.h4/a>>

 L35">. 354/a>#include <linux/fs.h4/a>>

 L36">. 364/a>#include <linux/ioport.h4/a>>

 L37">. 374/a>#include <linux/io.h4/a>>

 L38">. 384/a>#include <linux/uaccess.h4/a>>

 L39">. 394/a>#include <linux/clk.h4/a>>

 L40">. 404/a>

 L41">. 414/a>#include <asm/addrspace.h4/a>>

 L42">. 424/a>#include <asm/mach-ar7/ar7.h4/a>>

 L43">. 434/a>

 L44">. 444/a>#define.4a href="+code=LONGNAME" class="sref">LONGNAME4/a> 4spa  class="string">"TI AR7 Watchdog Timer"4/spa >

 L45">. 454/a>

 L46">. 464/a>4a href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHOR4/a>(4spa  class="string">"Nicolas Thill <nico@openwrt.org>"4/spa >);

 L47">. 474/a>4a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION4/a>(4a href="+code=LONGNAME" class="sref">LONGNAME4/a>);

 L48">. 484/a>4a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE4/a>(4spa  class="string">"GPL"4/spa >);

 L49">. 494/a>4a href="+code=MODULE_ALIAS_MISCDEV" class="sref">MODULE_ALIAS_MISCDEV4/a>(4a href="+code=WATCHDOG_MINOR" class="sref">WATCHDOG_MINOR4/a>);

 L50">. 504/a>

 L51">. 514/a>static int.4a href="+code=margin" class="sref">margin4/a> = 60;

 L52">. 524/a>4a href="+code=module_param" class="sref">module_param4/a>(4a href="+code=margin" class="sref">margin4/a>, int, 0);

 L53">. 534/a>4a href="+code=MODULE_PARM_DESC" class="sref">MODULE_PARM_DESC4/a>(4a href="+code=margin" class="sref">margin4/a>, 4spa  class="string">"Watchdog margin in seconds"4/spa >);

 L54">. 544/a>

 L55">. 554/a>static 4a href="+code=bool" class="sref">bool4/a> 4a href="+code=nowayout" class="sref">nowayout4/a> = 4a href="+code=WATCHDOG_NOWAYOUT" class="sref">WATCHDOG_NOWAYOUT4/a>;

 L56">. 564/a>4a href="+code=module_param" class="sref">module_param4/a>(4a href="+code=nowayout" class="sref">nowayout4/a>, 4a href="+code=bool" class="sref">bool4/a>, 0);

 L57">. 574/a>4a href="+code=MODULE_PARM_DESC" class="sref">MODULE_PARM_DESC4/a>(4a href="+code=nowayout" class="sref">nowayout4/a>, 4spa  class="string">"Disable watchdog shutdown o  close"4/spa >);

 L58">. 584/a>

 L59">. 594/a>#define.4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=x" class="sref">x4/a>).4a href="+code=readl" class="sref">readl4/a>((void.4a href="+code=__iomem" class="sref">__iomem4/a> *)&(4a href="+code=x" class="sref">x4/a>))

 L60">. 604/a>#define.4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=x" class="sref">x4/a>, 4a href="+code=v" class="sref">v4/a>).4a href="+code=writel" class="sref">writel4/a>((4a href="+code=v" class="sref">v4/a>), (void.4a href="+code=__iomem" class="sref">__iomem4/a> *)&(4a href="+code=x" class="sref">x4/a>))

 L61">. 614/a>

 L62">. 624/a>struct.4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a> {

 L63">. 634/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=kick_lock" class="sref">kick_lock4/a>;

 L64">. 644/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=kick" class="sref">kick4/a>;

 L65">. 654/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=change_lock" class="sref">change_lock4/a>;

 L66">. 664/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=change" class="sref">change4/a>;

 L67">. 674/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=disable_lock" class="sref">disable_lock4/a>;

 L68">. 684/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=disable" class="sref">disable4/a>;

 L69">. 694/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=prescale_lock" class="sref">prescale_lock4/a>;

 L70">. 704/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=prescale" class="sref">prescale4/a>;

 L71">. 714/a>};

 L72">. 724/a>

 L73">. 734/a>static unsigned long 4a href="+code=wdt_is_open" class="sref">wdt_is_open4/a>;

 L74">. 744/a>static unsigned 4a href="+code=expect_close" class="sref">expect_close4/a>;

 L75">. 754/a>static 4a href="+code=DEFINE_SPINLOCK" class="sref">DEFINE_SPINLOCK4/a>(4a href="+code=wdt_lock" class="sref">wdt_lock4/a>);

 L76">. 764/a>

 L77">. 774/a>4spa  class="comment">/* XXX currently fixed, allows max margin ~68.72 secs */4/spa >

 L78">. 784/a>#define.4a href="+code=prescale_tion>" class="sref">prescale_tion>4/a> 0xffff

 L79">. 794/a>

 L80">. 84.9a>4spa  class="comment">/* Resource of the WDT registers */4/spa >

 L81">. 814/a>static struct.4a href="+code=resource" class="sref">resource4/a> *4a href="+code=ar7_regs_wdt" class="sref">ar7_regs_wdt4/a>;

 L82">. 824/a>4spa  class="comment">/* Pointer to the remapped WDT IO space */4/spa >

 L83">. 834/a>static struct.4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a> *4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>;

 L84">. 844/a>

 L85">. 854/a>static struct.4a href="+code=clk" class="sref">clk4/a> *4a href="+code=vbus_clk" class="sref">vbus_clk4/a>;

 L86">. 864/a>

 L87">. 874/a>static void.4a href="+code=ar7_wdt_kick" class="sref">ar7_wdt_kick4/a>(4a href="+code=u32" class="sref">u324/a> 4a href="+code=tion>" class="sref">tion>4/a>)

 L88">. 884/a>{

 L89">. 894/a>        4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=kick_lock" class="sref">kick_lock4/a>, 0x5555);

 L90">. 904/a>        if ((4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=kick_lock" class="sref">kick_lock4/a>) & 3) == 1) {

 L91">. 914/a>                4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=kick_lock" class="sref">kick_lock4/a>, 0xaaaa);

 L92">. 924/a>                if ((4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=kick_lock" class="sref">kick_lock4/a>) & 3) == 3) {

 L93">. 934/a>                        4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=kick" class="sref">kick4/a>, 4a href="+code=vion>" class="sref">tion>4/a>);

 L94">. 944/a>                        return;

 L95">. 954/a>                }

 L96">. 964/a>        }

 L97">. 974/a>        4a href="+code=pr_err" class="sref">pr_err4/a>(4spa  class="string">"failed to unlock WDT kick reg\n"4/spa >);

 L98">. 984/a>}

 L99">. 994/a>

 L100">.1004/a>static void.4a href="+code=ar7_wdt_prescale" class="sref">ar7_wdt_prescale4/a>(4a href="+code=u32" class="sref">u324/a> 4a href="+code=tion>" class="sref">tion>4/a>)

 L101">.1014/a>{

 L102">.1024/a>        4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=prescale_lock" class="sref">prescale_lock4/a>, 0x5a5a);

 L103">.1034/a>        if ((4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=prescale_lock" class="sref">prescale_lock4/a>) & 3) == 1) {

 L104">.1044/a>                4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=prescale_lock" class="sref">prescale_lock4/a>, 0xa5a5);

 L105">.1054/a>                if ((4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=prescale_lock" class="sref">prescale_lock4/a>) & 3) == 3) {

 L106">.1064/a>                        4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=prescale" class="sref">prescale4/a>, 4a href="+code=vion>" class="sref">tion>4/a>);

 L107">.1074/a>                        return;

 L108">.1084/a>                }

 L109">.1094/a>        }

 L110">.1104/a>        4a href="+code=pr_err" class="sref">pr_err4/a>(4spa  class="string">"failed to unlock WDT prescale reg\n"4/spa >);

 L111">.1114/a>}

 L112">.1124/a>

 L113">.1134/a>static void.4a href="+code=ar7_wdt_change" class="sref">ar7_wdt_change4/a>(4a href="+code=u32" class="sref">u324/a> 4a href="+code=tion>" class="sref">tion>4/a>)

 L114">.1144/a>{

 L115">.1154/a>        4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=change_lock" class="sref">change_lock4/a>, 0x6666);

 L116">.1164/a>        if ((4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=change_lock" class="sref">change_lock4/a>) & 3) == 1) {

 L117">.1174/a>                4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=change_lock" class="sref">change_lock4/a>, 0xbbbb);

 L118">.1184/a>                if ((4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=change_lock" class="sref">change_lock4/a>) & 3) == 3) {

 L119">.1194/a>                        4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=change" class="sref">change4/a>, 4a href="+code=vion>" class="sref">tion>4/a>);

 L120">.1204/a>                        return;

 L121">.1214/a>                }

 L122">.1224/a>        }

 L123">.1234/a>        4a href="+code=pr_err" class="sref">pr_err4/a>(4spa  class="string">"failed to unlock WDT change reg\n"4/spa >);

 L124">.1244/a>}

 L125">.1254/a>

 L126">.1264/a>static void.4a href="+code=ar7_wdt_disable" class="sref">ar7_wdt_disable4/a>(4a href="+code=u32" class="sref">u324/a> 4a href="+code=tion>" class="sref">tion>4/a>)

 L127">.1274/a>{

 L128">.1284/a>        4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=disable_lock" class="sref">disable_lock4/a>, 0x7777);

 L129">.1294/a>        if ((4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=disable_lock" class="sref">disable_lock4/a>) & 3) == 1) {

 L130">.1304/a>                4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=disable_lock" class="sref">disable_lock4/a>, 0xcccc);

 L131">.1314/a>                if ((4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=disable_lock" class="sref">disable_lock4/a>) & 3) == 2) {

 L132">.1324/a>                        4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=disable_lock" class="sref">disable_lock4/a>, 0xdddd);

 L133">.1334/a>                        if ((4a href="+code=READ_REG" class="sref">READ_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=disable_lock" class="sref">disable_lock4/a>) & 3) == 3) {

 L134">.1344/a>                                4a href="+code=WRITE_REG" class="sref">WRITE_REG4/a>(4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>->4a href="+code=disable" class="sref">disable4/a>, 4a href="+code=vion>" class="sref">tion>4/a>);

 L135">.1354/a>                                return;

 L136">.1364/a>                        }

 L137">.1374/a>                }

 L138">.1384/a>        }

 L139">.1394/a>        4a href="+code=pr_err" class="sref">pr_err4/a>(4spa  class="string">"failed to unlock WDT disable reg\n"4/spa >);

 L140">.1404/a>}

 L141">.1414/a>

 L142">.1424/a>static void.4a href="+code=ar7_wdt_update_margin" class="sref">ar7_wdt_update_margin4/a>(int.4a href="+code=new_margin" class="sref">new_margin4/a>)

 L143">.1434/a>{

 L144">.1444/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=change" class="sref">change4/a>;

 L145">.1454/a>        4a href="+code=u32" class="sref">u324/a> 4a href="+code=vbus_rate" class="sref">tbus_rate4/a>;

 L146">.1464/a>

 L147">.1474/a>        4a href="+code=vbus_rate" class="sref">tbus_rate4/a> = 4a href="+code=clk_get_rate" class="sref">clk_get_rate4/a>(4a href="+code=vbus_clk" class="sref">vbus_clk4/a>);

 L148">.1484/a>        4a href="+code=change" class="sref">change4/a> = 4a href="+code=new_margin" class="sref">new_margin4/a> * (4a href="+code=vbus_rate" class="sref">tbus_rate4/a> /.4a href="+code=prescale_tion>" class="sref">prescale_tion>4/a>);

 L149">.1494/a>        if (4a href="+code=change" class="sref">change4/a> < 1)

 L150">.1504/a>                4a href="+code=change" class="sref">change4/a> = 1;

 L151">.1514/a>        if (4a href="+code=change" class="sref">change4/a> > 0xffff)

 L152">.1524/a>                4a href="+code=change" class="sref">change4/a> = 0xffff;

 L153">.1534/a>        4a href="+code=ar7_wdt_change" class="sref">ar7_wdt_change4/a>(4a href="+code=change" class="sref">change4/a>);

 L154">.1544/a>        4a href="+code=margin" class="sref">margin4/a> = 4a href="+code=change" class="sref">change4/a> *.4a href="+code=prescale_tion>" class="sref">prescale_tion>4/a> /.4a href="+code=vbus_rate" class="sref">tbus_rate4/a>;

 L155">.1554/a>        4a href="+code=pr_info" class="sref">pr_info4/a>(4spa  class="string">"timer margin %d seconds (prescale %d, change %d, freq %d)\n"4/spa >,

 L156">.1564/a>                4a href="+code=margin" class="sref">margin4/a>, 4a href="+code=prescale_tion>" class="sref">prescale_tion>4/a>, 4a href="+code=change" class="sref">change4/a>, 4a href="+code=vbus_rate" class="sref">tbus_rate4/a>);

 L157">.1574/a>}

 L158">.1584/a>

 L159">.1594/a>static void.4a href="+code=ar7_wdt_enable_wdt" class="sref">ar7_wdt_enable_wdt4/a>(void)

 L160">.1604/a>{

 L161">.1614/a>        4a href="+code=pr_debug" class="sref">pr_debug4/a>(4spa  class="string">"enabling watchdog timer\n"4/spa >);

 L162">.1624/a>        4a href="+code=ar7_wdt_disable" class="sref">ar7_wdt_disable4/a>(1);

 L163">.1634/a>        4a href="+code=ar7_wdt_kick" class="sref">ar7_wdt_kick4/a>(1);

 L164">.1644/a>}

 L165">.1654/a>

 L166">.1664/a>static void.4a href="+code=ar7_wdt_disable_wdt" class="sref">ar7_wdt_disable_wdt4/a>(void)

 L167">.1674/a>{

 L168">.1684/a>        4a href="+code=pr_debug" class="sref">pr_debug4/a>(4spa  class="string">"disabling watchdog timer\n"4/spa >);

 L169">.1694/a>        4a href="+code=ar7_wdt_disable" class="sref">ar7_wdt_disable4/a>(0);

 L170">.1704/a>}

 L171">.1714/a>

 L172">.1724/a>static int.4a href="+code=ar7_wdt_open" class="sref">ar7_wdt_open4/a>(struct.4a href="+code=inode" class="sref">inode4/a> *4a href="+code=inode" class="sref">inode4/a>, struct.4a href="+code=file" class="sref">file4/a> *4a href="+code=file" class="sref">file4/a>)

 L173">.1734/a>{

 L174">.1744/a>        4spa  class="comment">/* only allow one at a time */4/spa >

 L175">.1754/a>        if (4a href="+code=test_and_set_bit" class="sref">test_and_set_bit4/a>(0, &4a href="+code=wdt_is_open" class="sref">wdt_is_open4/a>))

 L176">.1764/a>                return -4a href="+code=EBUSY" class="sref">EBUSY4/a>;

 L177">.1774/a>        4a href="+code=ar7_wdt_enable_wdt" class="sref">ar7_wdt_enable_wdt4/a>();

 L178">.1784/a>        4a href="+code=expect_close" class="sref">expect_close4/a> = 0;

 L179">.1794/a>

 L180">.1804/a>        return 4a href="+code=nonseekable_open" class="sref">nonseekable_open4/a>(4a href="+code=inode" class="sref">inode4/a>, 4a href="+code=file" class="sref">file4/a>);

 L181">.1814/a>}

 L182">.1824/a>

 L183">.1834/a>static int.4a href="+code=ar7_wdt_release" class="sref">ar7_wdt_release4/a>(struct.4a href="+code=inode" class="sref">inode4/a> *4a href="+code=inode" class="sref">inode4/a>, struct.4a href="+code=file" class="sref">file4/a> *4a href="+code=file" class="sref">file4/a>)

 L184">.1844/a>{

 L185">.1854/a>        if (!4a href="+code=expect_close" class="sref">expect_close4/a>)

 L186">.1864/a>                4a href="+code=pr_warn" class="sref">pr_warn4/a>(4spa  class="string">"watchdog device closed unexpectedly, will not disable the watchdog timer\n"4/spa >);

 L187">.1874/a>        else if (!4a href="+code=nowayout" class="sref">nowayout4/a>)

 L188">.1884/a>                4a href="+code=ar7_wdt_disable_wdt" class="sref">ar7_wdt_disable_wdt4/a>();

 L189">.1894/a>        4a href="+code=clear_bit" class="sref">clear_bit4/a>(0, &4a href="+code=wdt_is_open" class="sref">wdt_is_open4/a>);

 L190">.1904/a>        return 0;

 L191">.1914/a>}

 L192">.1924/a>

 L193">.1934/a>static 4a href="+code=ssize_t" class="sref">ssize_t4/a> 4a href="+code=ar7_wdt_write" class="sref">ar7_wdt_write4/a>(struct.4a href="+code=file" class="sref">file4/a> *4a href="+code=file" class="sref">file4/a>, const char *4a href="+code=data" class="sref">data4/a>,

 L194">.1944/a>                             4a href="+code=size_t" class="sref">size_t4/a> 4a href="+code=len" class="sref">len4/a>, 4a href="+code=loff_t" class="sref">loff_t4/a> *4a href="+code=ppos" class="sref">ppos4/a>)

 L195">.1954/a>{

 L196">.1964/a>        4spa  class="comment">/* check for a magic close character */4/spa >

 L197">.1974/a>        if (4a href="+code=len" class="sref">len4/a>) {

 L198">.1984/a>                4a href="+code=size_t" class="sref">size_t4/a> 4a href="+code=i" class="sref">i4/a>;

 L199">.1994/a>

 L200">.2004/a>                4a href="+code=spin_lock" class="sref">spin_lock4/a>(&4a href="+code=wdt_lock" class="sref">wdt_lock4/a>);

 L201">.2014/a>                4a href="+code=ar7_wdt_kick" class="sref">ar7_wdt_kick4/a>(1);

 L202">.2024/a>                4a href="+code=spin_unlock" class="sref">spin_unlock4/a>(&4a href="+code=wdt_lock" class="sref">wdt_lock4/a>);

 L203">.2034/a>

 L204">.2044/a>                4a href="+code=expect_close" class="sref">expect_close4/a> = 0;

 L205">.2054/a>                for (4a href="+code=i" class="sref">i4/a> = 0; 4a href="+code=i" class="sref">i4/a> < 4a href="+code=len" class="sref">len4/a>; ++4a href="+code=i" class="sref">i4/a>) {

 L206">.2064/a>                        char 4a href="+code=c" class="sref">c4/a>;

 L207">.2074/a>                        if (4a href="+code=get_user" class="sref">get_user4/a>(4a href="+code=c" class="sref">c4/a>, 4a href="+code=data" class="sref">data4/a> + 4a href="+code=i" class="sref">i4/a>))

 L208">.2084/a>                                return -4a href="+code=EFAULT" class="sref">EFAULT4/a>;

 L209">.2094/a>                        if (4a href="+code=c" class="sref">c4/a> == 4spa  class="string">'V'4/spa >)

 L210">.2104/a>                                4a href="+code=expect_close" class="sref">expect_close4/a> = 1;

 L211">.2114/a>                }

 L212">.2124/a>

 L213">.2134/a>        }

 L214">.2144/a>        return 4a href="+code=len" class="sref">len4/a>;

 L215">.2154/a>}

 L216">.2164/a>

 L217">.2174/a>static long 4a href="+code=ar7_wdt_ioctl" class="sref">ar7_wdt_ioctl4/a>(struct.4a href="+code=file" class="sref">file4/a> *4a href="+code=file" class="sref">file4/a>,

 L218">.2184/a>                                        unsigned int.4a href="+code=cmd" class="sref">cmd4/a>, unsigned long 4a href="+code=arg" class="sref">arg4/a>)

 L219">.2194/a>{

 L220">.2204/a>        static const struct.4a href="+code=watchdog_info" class="sref">watchdog_info4/a> 4a href="+code=ident" class="sref">ident4/a> = {

 L221">.2214/a>                .4a href="+code=identity" class="sref">identity4/a> = 4a href="+code=LONGNAME" class="sref">LONGNAME4/a>,

 L222">.2224/a>                .4a href="+code=firmware_version" class="sref">firmware_version4/a> = 1,

 L223">.2234/a>                .4a href="+code=options" class="sref">options4/a> = (4a href="+code=WDIOF_SETTIMEOUT" class="sref">WDIOF_SETTIMEOUT4/a> | 4a href="+code=WDIOF_KEEPALIVEPING" class="sref">WDIOF_KEEPALIVEPING4/a> |

 L224">.2244/a>                                                4a href="+code=WDIOF_MAGICCLOSE" class="sref">WDIOF_MAGICCLOSE4/a>),

 L225">.2254/a>        };

 L226">.2264/a>        int.4a href="+code=new_margin" class="sref">new_margin4/a>;

 L227">.2274/a>

 L228">.2284/a>        switch (4a href="+code=cmd" class="sref">cmd4/a>) {

 L229">.2294/a>        case.4a href="+code=WDIOC_GETSUPPORT" class="sref">WDIOC_GETSUPPORT4/a>:

 L230">.2304/a>                if (4a href="+code=copy_to_user" class="sref">copy_to_user4/a>((struct.4a href="+code=watchdog_info" class="sref">watchdog_info4/a> *)4a href="+code=arg" class="sref">arg4/a>, &4a href="+code=ident" class="sref">ident4/a>,

 L231">.2314/a>                                sizeof(4a href="+code=ident" class="sref">ident4/a>)))

 L232">.2324/a>                        return -4a href="+code=EFAULT" class="sref">EFAULT4/a>;

 L233">.2334/a>                return 0;

 L234">.2344/a>        case.4a href="+code=WDIOC_GETSTATUS" class="sref">WDIOC_GETSTATUS4/a>:

 L235">.2354/a>        case.4a href="+code=WDIOC_GETBOOTSTATUS" class="sref">WDIOC_GETBOOTSTATUS4/a>:

 L236">.2364/a>                if (4a href="+code=put_user" class="sref">put_user4/a>(0, (int.*)4a href="+code=arg" class="sref">arg4/a>))

 L237">.2374/a>                        return -4a href="+code=EFAULT" class="sref">EFAULT4/a>;

 L238">.2384/a>                return 0;

 L239">.2394/a>        case.4a href="+code=WDIOC_KEEPALIVE" class="sref">WDIOC_KEEPALIVE4/a>:

 L240">.2404/a>                4a href="+code=ar7_wdt_kick" class="sref">ar7_wdt_kick4/a>(1);

 L241">.2414/a>                return 0;

 L242">.2424/a>        case.4a href="+code=WDIOC_SETTIMEOUT" class="sref">WDIOC_SETTIMEOUT4/a>:

 L243">.2434/a>                if (4a href="+code=get_user" class="sref">get_user4/a>(4a href="+code=new_margin" class="sref">new_margin4/a>, (int.*)4a href="+code=arg" class="sref">arg4/a>))

 L244">.2444/a>                        return -4a href="+code=EFAULT" class="sref">EFAULT4/a>;

 L245">.2454/a>                if (4a href="+code=new_margin" class="sref">new_margin4/a> < 1)

 L246">.2464/a>                        return -4a href="+code=EINVAL" class="sref">EINVAL4/a>;

 L247">.2474/a>

 L248">.2484/a>                4a href="+code=spin_lock" class="sref">spin_lock4/a>(&4a href="+code=wdt_lock" class="sref">wdt_lock4/a>);

 L249">.2494/a>                4a href="+code=ar7_wdt_update_margin" class="sref">ar7_wdt_update_margin4/a>(4a href="+code=new_margin" class="sref">new_margin4/a>);

 L250">.2504/a>                4a href="+code=ar7_wdt_kick" class="sref">ar7_wdt_kick4/a>(1);

 L251">.2514/a>                4a href="+code=spin_unlock" class="sref">spin_unlock4/a>(&4a href="+code=wdt_lock" class="sref">wdt_lock4/a>);

 L252">.2524/a>

 L253">.2534/a>        case.4a href="+code=WDIOC_GETTIMEOUT" class="sref">WDIOC_GETTIMEOUT4/a>:

 L254">.2544/a>                if (4a href="+code=put_user" class="sref">put_user4/a>(4a href="+code=margin" class="sref">margin4/a>, (int.*)4a href="+code=arg" class="sref">arg4/a>))

 L255">.2554/a>                        return -4a href="+code=EFAULT" class="sref">EFAULT4/a>;

 L256">.2564/a>                return 0;

 L257">.2574/a>        default:

 L258">.2584/a>                return -4a href="+code=ENOTTY" class="sref">ENOTTY4/a>;

 L259">.2594/a>        }

 L260">.2604/a>}

 L261">.2614/a>

 L262">.2624/a>static const struct.4a href="+code=file_operations" class="sref">file_operations4/a> 4a href="+code=ar7_wdt_fops" class="sref">ar7_wdt_fops4/a> = {

 L263">.2634/a>        .4a href="+code=owner" class="sref">owner4/a>          = 4a href="+code=THIS_MODULE" class="sref">THIS_MODULE4/a>,

 L264">.2644/a>        .4a href="+code=write" class="sref">write4/a>          = 4a href="+code=ar7_wdt_write" class="sref">ar7_wdt_write4/a>,

 L265">.2654/a>        .4a href="+code=unlocked_ioctl" class="sref">unlocked_ioctl4/a> = 4a href="+code=ar7_wdt_ioctl" class="sref">ar7_wdt_ioctl4/a>,

 L266">.2664/a>        .4a href="+code=open" class="sref">open4/a>           = 4a href="+code=ar7_wdt_open" class="sref">ar7_wdt_open4/a>,

 L267">.2674/a>        .4a href="+code=release" class="sref">release4/a>        = 4a href="+code=ar7_wdt_release" class="sref">ar7_wdt_release4/a>,

 L268">.2684/a>        .4a href="+code=llseek" class="sref">llseek4/a>         = 4a href="+code=no_llseek" class="sref">no_llseek4/a>,

 L269">.2694/a>};

 L270">.2704/a>

 L271">.2714/a>static struct.4a href="+code=miscdevice" class="sref">miscdevice4/a> 4a href="+code=ar7_wdt_miscdev" class="sref">ar7_wdt_miscdev4/a> = {

 L272">.2724/a>        .4a href="+code=minor" class="sref">minor4/a>          = 4a href="+code=WATCHDOG_MINOR" class="sref">WATCHDOG_MINOR4/a>,

 L273">.2734/a>        .4a href="+code=nam>" class="sref">nam>4/a>           = 4spa  class="string">"watchdog"4/spa >,

 L274">.2744/a>        .4a href="+code=fops" class="sref">fops4/a>           = &4a href="+code=ar7_wdt_fops" class="sref">ar7_wdt_fops4/a>,

 L275">.2754/a>};

 L276">.2764/a>

 L277">.2774/a>static int.4a href="+code=__devinit" class="sref">__devinit4/a> 4a href="+code=ar7_wdt_probe" class="sref">ar7_wdt_probe4/a>(struct.4a href="+code=platform_device" class="sref">platform_device4/a> *4a href="+code=pdev" class="sref">pdev4/a>)

 L278">.2784/a>{

 L279">.2794/a>        int.4a href="+code=rc" class="sref">rc4/a>;

 L280">.2804/a>

 L281">.2814/a>        4a href="+code=ar7_regs_wdt" class="sref">ar7_regs_wdt4/a> =

 L282">.2824/a>                4a href="+code=platform_get_resource_bynam>" class="sref">platform_get_resource_bynam>4/a>(4a href="+code=pdev" class="sref">pdev4/a>, 4a href="+code=IORESOURCE_MEM" class="sref">IORESOURCE_MEM4/a>, 4spa  class="string">"regs"4/spa >);

 L283">.2834/a>        if (!4a href="+code=ar7_regs_wdt" class="sref">ar7_regs_wdt4/a>) {

 L284">.2844/a>                4a href="+code=pr_err" class="sref">pr_err4/a>(4spa  class="string">"could not get registers resource\n"4/spa >);

 L285">.2854/a>                return -4a href="+code=ENODEV" class="sref">ENODEV4/a>;

 L286">.2864/a>        }

 L287">.2874/a>

 L288">.2884/a>        4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a> = 4a href="+code=devm_request_and_ioremap" class="sref">devm_request_and_ioremap4/a>(&4a href="+code=pdev" class="sref">pdev4/a>->4a href="+code=dev" class="sref">dev4/a>, 4a href="+code=ar7_regs_wdt" class="sref">ar7_regs_wdt4/a>);

 L289">.2894/a>        if (!4a href="+code=ar7_wdt" class="sref">ar7_wdt4/a>) {

 L290">.2904/a>                4a href="+code=pr_err" class="sref">pr_err4/a>(4spa  class="string">"could not ioremap registers\n"4/spa >);

 L291">.2914/a>                return -4a href="+code=ENXIO" class="sref">ENXIO4/a>;

 L292">.2924/a>        }

 L293">.2934/a>

 L294">.2944/a>        4a href="+code=vbus_clk" class="sref">vbus_clk4/a> = 4a href="+code=clk_get" class="sref">clk_get4/a>(4a href="+code=NULL" class="sref">NULL4/a>, 4spa  class="string">"vbus"4/spa >);

 L295">.2954/a>        if (4a href="+code=IS_ERR" class="sref">IS_ERR4/a>(4a href="+code=vbus_clk" class="sref">vbus_clk4/a>)) {

 L296">.2964/a>                4a href="+code=pr_err" class="sref">pr_err4/a>(4spa  class="string">"could not get vbus clock\n"4/spa >);

 L297">.2974/a>                return 4a href="+code=PTR_ERR" class="sref">PTR_ERR4/a>(4a href="+code=vbus_clk" class="sref">vbus_clk4/a>);

 L298">.29r" class="sref">pr_err4/a>(4spa  class="string">&quo299" id
 L299" class="line" nam>
 dt.c#L281" id
 L281" class="line" nreturn -4a href="+code=ENXIO" class="/egisters\n"4/spa >);
spin_lock4/a>(&4a href                 return -4a href="+code=EFA"watchdog de_/2isters\n"4/spa >);
);
<="line" nam>
 L290">.2904/a>              3
 L178">.1784/a>        >2904/a>   0ine" nam>
 L178">.1784/a>     elk" classref="+codL24T24" id
 L224" class="lin42i299" class="line"= href="drivers/watchdog/ar7_wdt.c#L1ss="sref">new_margin4/a>);
.1784/a>     elk" classref="+codL24T24" 3d
 L224" 294" class="line" nam>
3L204"3.2044/a>                4a href="+code=expec3_close" c3ass="sref">expect_close43a> = 30_get" class="sref">clk_get4/line" nam>
 L280">.2804">NULL4/a>, 4spa  >
 L_="line" iscdev4/a> = {
dev4/a>, 4a href="+wdt.c#L272" id
 L272" class="line" nam>
 L272">.2">.1784/a>     elk" classref="+codL24T24" 5lose" c3aIS_ERR4/a>(4a href="+co3+code30clk" class="sref">vbus_clk4/a>))line" nam>
 L280">.280464/a>                4a href="+code=pr_er3"+code=c"3class="sref">c4/a>;

 L href="am>
 L297">.2974/a>                return 4a href="+cod3+code=get3user" class="sref">get_u3er4/a3(4a href="+code=c" clago8osclass="sref">ar7lass="line" nam>
">.1884/a>                return 4a href="+cod3+8ode=get3u99" id
 L299" class="li3ef">E30
 dt.c#L281" id
 L281" class="line" nreturn -4a href3+code=c" 3lass="sref">c4/a> == 4sp3  cla3s="string">%">.2574/a>        default:
exp312814/a>        4a href="+code=ar7_regs_wdt"3tchdog/ar3_wdt.c#L212" id
 L212" c3ass="3ine" nclass="sref">ar7lass="line" nam>
">.1884/a>                return -4a href="+co3L213" id
3L213" class="line" nam>
3L213"31 href="drivers/watchdog/ar7_bus&plass="line" nam>
bus&plaar7_wdt.c#L298" id
 L298" class="line" nam>
 L298">.29r" class="sref">pr_err4/a>(4spa  class="s3r7_wdt.c#3214" id
 L214" class="li3e" na31"drivers/watchdog/ar7_wdt.c#a>(4a href="+code=NULL" class="sref">NULL4/a>, 4spa  "drivers/watchdog/ar7_wdt.c class="sref">pr_err4/a>(4spa  class="s3rclose" c3>len4/a>;

 L280">.2804/a>
3 L2163>.2164/a>

3L217"3.2174/a>static long 4a href="+code=ar7_wdt_i3ctl" clas3="sref">ar7_wdt_ioctl4/a3(stru31ar7_wdt_probe" class="sref">ar7_wdt_exobe4/a>(struct.4a hrefexobode=platform_device" class="remov268" class="line" nam>
 L2mov2f="+code=pdev" class="sref">pdev4/a>)

 L278">.2784/a>{
        int.4a href="+code=rc" class3#L220" id3 L220" class="line" nam>3 L22031code=wdt_is_open" class="sre = {
dev4/a>, 4a href="+wdt.c#L272" id
 L272" class="line" nam>
 L272">.2">.1784/a>     elk" classref="+codL24T24"+code=wat3hdog_info" class="sref">3atchd32ef="+code=EFA"watchdog bus&plass="line" nam>
bus&plaar7_wdt.c#L298" id
 L298" class="line" nam>
 L298">.29r" class="sref">pr_err4/a>(4spa  class="s3ity" clas3="sref">identity4/a> = 43 href322" clasuot;4/spa >);
<="linea>(4a href="+code=NULL" class="sref">NULL4/a>, 4spa  "drivers/watchdog/ar7_wdt.c class="sref">pr_err4/a>(4spa  class="s3are_versi3n" class="sref">firmware3versi3n4/a> = 1,
.2574/a>        default:
options4/a> = (4a3href=3+code=/a>


 L2(void)
pdev4/a>)

 L278">.2784/a>{
new_margin4/a>;

3L228"32og/ar7_wdt.c#L198dt.c#L188" id
 L188" class="line" nam>
 L188">.1884/a>                4a href="+code=ar7_w3lass="sre3">cmd4/a>) {

 L189">.1894/a>        4a href="+code=clear_bit" cl3SUPPORT" 3lass="sref">WDIOC_GETSUP3ORT4/3>:

copy_to_u3er4/a332814/a>        4a href="+code=ar7_regs_wdt"3f(4a href3"+code=ident" class="sre3">ide33code=ar7_wdt_miscdev" class="sref"tchdog/ar7a hreref="drivers/watchdog/ar7a hreode=platform_device" class="7a hreref="drivers/wa class="7a hre">.2724/a>        .4a href="+code=minor" class3ef="+code3EFAULT" class="sref">EFA3LT4/a33=WATCHDOG_MINOR" class="sref"sref">platform_devica href="+s/watchdog/ar7_wdt.c#L268"sref">platform_device4/a> *4a href="+/a>};
"watchdog"4/sremov268" class="lineL2mov2f="+s/watchdog/ar7_wdt hrefexob_pdev4/a>->4a  hrefexob_par7_wdt.c#L298" id
  class="remov268" class="line" nam>
 L2mov2f="+4/a>        };
WDIOC_GETSTAT3S4/a>33code=ar7_wdt_fops" class="sreshutdoww_margin4/a>);
);
        };
WDIOC_GET3OOTST33ef="+code=ar7_wdt_ioctl" clas7a hreref="drivers/wa7a hre">.2724/a>        .4a href="+code=minor" class3e class="3ass="sref">put_user4/a>(3, (in3.*)4a href="+code=arg" class="sref">THIS_MODULE4/a>,

 L264">.2644/a>        .4a href="+code=write" class3ef="+code3EFAULT" class="sref">EFA3LT4/a3;
.2744/a>        .4a href="+code=fops" class=3ivers/wat3hdog/ar7_wdt.c#L239" id
3L239"3class="line" n}/a>        .4a href="+code=fops" class=3iUPPORT" 3ass="sref">WDIOC_KEEPALI3E4/a>33>.2704/a>
ar7_wdt_kick43a>(1)342814/a>        4a href="+code=ar7_regs_wdt"3ivers/wat3hdog/ar7_wdt.c#L242" id
3L242"34ne" nclass="sref">armodu L1tchdog/ar7a hreref="drivers/wamodu L1tchdog/ar7a hrear7_wdt.c#L298" id
  class="7a hreref="drivers/wa class="7a hre">.24/a>        4a href="+code=clear_bit" cl3TIMEOUT" 3lass="sref">WDIOC_SETTIM3OUT4/3>:






The original LXR softe" n by187" >        http://ine" nog/ge.net/projects/lx i>LXR 7_wdundog/ar7,187is e" nridt.cal v>
 L22 by1>        mailto:lx @>WDux.no">lx @>WDux.no/ar7.


lx .>WDux.no kindly hone"d by1>        http://www.redpill->WDpro.no">Redpill LWDpro AS/ar7,1provide= of LWDuxef="+ult69" and f="drivers serwdt.s since">.25.