#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看门狗驱动
最新推荐文章于 2022-03-20 14:02:16 发布
本文档详细介绍了S3C2410平台的看门狗驱动实现,包括模块参数、看门狗启动、停止、保持活动、设置心跳间隔等功能。同时,展示了如何处理看门狗中断和复位行为,并提供了驱动的初始化和注销流程。
摘要由CSDN通过智能技术生成