아래 내용을 가지고 s3c2410_wdt.c라고 화일을 만들어서 /drivers/char 아래 넣고 드라이브를 만들어 쓰시면 될듯...
전 이렇게 만들어서 썼습니다. 허접하게 ㅡㅡ;;
한참 전 일이라 생각이 잘 않나네요 ㅡㅡ;;
이부분 값으로 wdt 시간을 조절하시면 될겁니다. //0xff1a = 40sec, 0xa01a = 25sec
Makefile에 "obj-$(CONFIG_S3C2410_WDT) +=s3c2410_wdt.o" 도추가해 주시구요...
커널 메뉴컨피그에도 추가했던거 같네요...
#include <linux/module.h>
#include <linux/config.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
#include <linux/reboot.h>
#include <linux/smp_lock.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <asm/hardware.h>
#include <asm/bitops.h>
#define WDIOC_RESET_ENABLE 0
#define WDIOC_RESET_DISABLE 1
#define WDIOC_COUNT_DISPLAY 2
static int watchdog_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
switch(cmd){
case WDIOC_RESET_ENABLE:
rWTCNT = (rWTCNT & ~(0xffff)) | 0xffff;
rWTCON |= 0x21; // RESET_ENABLE
return 0;
case WDIOC_RESET_DISABLE:
rWTCON &= ~0x21; // RESET_DISABLE
return 0;
case WDIOC_COUNT_DISPLAY: // COUNT_DISPLAY
return rWTCNT;
default :
printk("Watch dog io error");
return -1;
}
}
static struct file_operations watchdog_fops=
{
owner: THIS_MODULE,
ioctl: watchdog_ioctl,
};
static struct miscdevice watchdog_miscdev=
{
WATCHDOG_MINOR, // #define WATCHDOG_MINOR 130 //linux/miscdevice.h
"2410_watchdog",
&watchdog_fops
};
static int __init watchdog_init(void)
{
int ret;
ret = misc_register(&watchdog_miscdev);
if (ret)
return ret;
rWTCON = (rWTCON & ~(0xffff)) | 0xa01a; //0xff1a = 40sec, 0xa01a = 25sec
rWTDAT = (rWTDAT & ~(0xffff)) | 0x8000;
rWTCNT = (rWTCNT & ~(0xffff)) | 0x8000;
printk("S3C2410 Watchdog Timer: timer margin %d sec\n", rWTDAT);
return 0;
}
static void __exit watchdog_exit(void)
{
misc_deregister(&watchdog_miscdev);
}
module_init(watchdog_init);
module_exit(watchdog_exit);