mini2440看门狗驱动

本文档详细介绍了S3C2410平台的看门狗驱动实现,包括模块参数、看门狗启动、停止、保持活动、设置心跳间隔等功能。同时,展示了如何处理看门狗中断和复位行为,并提供了驱动的初始化和注销流程。
摘要由CSDN通过智能技术生成
#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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值