guoxiaorong188的ChinaUnix博客
guoxiaorong188
全部博文(135)
块设备驱动(0)
网络设备驱动(0)
字符设备驱动(1)
驱动混杂(0)
MMC/SD/SDIO(2)
input 子系统(10)
alsa audio驱动(2)
TTY/Uart(3)
SPI(0)
USB(4)
I2C(2)
TCP/IP网络协议栈(10)
2012年(135)
iteakey
ccx_wz
小超hide
cynthia
浪花小雨
yangchao
风吹叶落
Pierkaso
老顽童熊
风鹏正举
ygw98290
zhangjie
分类:
2012-09-19 11:39:23
原文地址:UBOOT WDT驱动流程 作者:iibull
#define ms_to_ticks(t) (((t << 8) / 1000) - 1) #define ticks_to_ms(t) (((t + 1) * 1000) >> 8) /* Hardware timeout in seconds */ #define WDT_HW_TIMEOUT 2 /* * Set the watchdog time interval in 1/256Hz (write-once) * Counter is 12 bit. */ static int wdt_settimeout(unsigned int timeout) { unsigned int reg; wdt_t *wd = (wdt_t *) WDT_BASE; /* Check if disabled */ if (readl(&wd->mr) & WDT_MR_WDDIS) { printf("sorry, watchdog is disabled\n"); return -1; } /* * All counting occurs at SLOW_CLOCK / 128 = 256 Hz * * Since WDV is a 12-bit counter, the maximum period is * 4096 / 256 = 16 seconds. */ reg = WDT_MR_WDRSTEN /* causes watchdog reset */ | WDT_MR_WDDBGHLT /* disabled in debug mode */ | WDT_MR_WDD(0xfff) /* restart at any time */ | WDT_MR_WDV(timeout); /* timer value */ writel(reg, &wd->mr); return 0; } void hw_watchdog_reset(void) { wdt_t *wd = (wdt_t *) WDT_BASE; writel(WDT_CR_WDRSTT | WDT_CR_KEY, &wd->cr); } void hw_watchdog_init(void) { /* 16 seconds timer, resets enabled */ at91_wdt_settimeout(ms_to_ticks(WDT_HW_TIMEOUT * 1000)); }
上一篇:UBOOT RTC驱动流程
下一篇:UBOOT 网口测试
登录 注册