#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
#include <linux/timer.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/clk.h>
#include <linux/uaccess.h>
#include <linux/io.h>
#include <mach/regs-gpio.h>
#include <mach/map.h>
module_param(tmr_margin, int, 0); // 默认的看门狗喂狗时间
module_param(tmr_atboot, int, 0); // 系统启动时就使能看门狗,为1表示使能,为0表示关闭;
module_param(nowayout, int, 0); // 不允许看门狗关闭,为1表示不允许关闭,为0表示允许关闭;
module_param(soft_noboot, int, 0); // 是否重启
module_param(debug, int, 0); //否使用调试模式来调试
MODULE_PARM_DESC(tmr_margin, "Watchdog tmr_margin in seconds. default="
__MODULE_STRING(CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME) ")");
MODULE_PARM_DESC(tmr_atboot,
"Watchdog is started at boot time if set to 1, default="
__MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT));
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to \
reboot (default depends on ONLY_TESTING)");
MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug, (default 0)");
typedef enum close_state
{
CLOSE_STATE_NOT,
CLOSE_STATE_ALLOW = 0x4021
} close_state_t;
static unsigned long open_lock;
static struct device *wdt_dev; /* platform 设备 */
static struct resource *wdt_mem;//用来保存IO端口占用的内存资源
static struct resource *wdt_irq;//保存wdt中断号
static struct clk *wdt_clock;//保存从平台获取的watchdog时钟
static void __iomem *wdt_base;//经过ioremap后的内存基地址
static unsigned int wdt_count;//保存向WTCNT写的计数值
static close_state_t allow_close;
static DEFINE_SPINLOCK(wdt_lock);//定义一个自旋锁
/* watchdog control routines */
#define DBG(msg...) do { \
if (debug) \
printk(KERN_INFO msg); \
} while (0)
static void __s3c2410wdt_stop(void)
{
unsigned
mini2440看门狗驱动
最新推荐文章于 2021-12-07 20:22:54 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)