CAFE

Q&A

Re:Watch Dog device driver는 어디에 있나요?

작성자태성이|작성시간04.07.13|조회수111 목록 댓글 4

아래 내용을 가지고 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);

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
  • 작성자kevin | 작성시간 04.07.15 생각지도 않았는데, 무지 감사합니다. 나중에제거 멋진걸로 보답하죠 ^^
  • 작성자태성이 작성자 본인 여부 작성자 | 작성시간 04.07.15 나중에 멋진거라면 여자친구가 좋을듯 ㅎㅎㅎㅎ ^^ 넝담
  • 작성자고도리 | 작성시간 04.07.15 nice!!!
  • 작성자돌팡 | 작성시간 04.07.26 Bravo!!!
댓글 전체보기
맨위로

카페 검색

카페 검색어 입력폼