--- linux-2.6.11-booke-wdt/drivers/char/watchdog/booke_wdt.c 2005-03-04 16:38:58.000000000 +0900 +++ linux-2.6.11-wdt/drivers/char/watchdog/booke_wdt.c 2005-03-07 03:35:34.000000000 +0900 @@ -76,86 +76,43 @@ /* Panic notifier */ extern struct notifier_block *panic_notifier_list; /* - * External linkage functions - */ -void booke_wdt_heartbeat(void); -void booke_wdt_setup_options(char *cmd_line); -void booke_wdt_exception(struct pt_regs *regs); -/* - * Internal linkage functions - */ -static __inline__ void __booke_wdt_setup_val(int period,int reset); -static __inline__ void __booke_wdt_enable(void); -static __inline__ void __booke_wdt_disable(void); -static __inline__ int __booke_wdt_is_enabled(void); -static __inline__ void __booke_wdt_clear_int_stat(void); -static __inline__ void __booke_wdt_set_timeout(int t); -static __inline__ void booke_wdt_init_device(void); -static __inline__ int booke_wdt_is_enabled(void); -static __inline__ int booke_wdt_start(void); -static __inline__ int booke_wdt_stop(void); -static __inline__ int booke_wdt_ping(void); -static __inline__ int booke_wdt_set_timeout(int t); -static __inline__ int booke_wdt_get_status(int *status); -static ssize_t booke_wdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos); -static int booke_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,unsigned long arg); -static int booke_wdt_open(struct inode *inode, struct file *file); -static int booke_wdt_release(struct inode *inode, struct file *file); -static int booke_wdt_notify_sys(struct notifier_block *this, unsigned long code,void *unused); -static int __init booke_wdt_init(void); -static void __exit booke_wdt_exit(void); - -/* * Watchdog operations on PPC4xx/e500 MPU */ - /** * __booke_wdt_setup_val * Enable Watchdog, sets up passed in values for TCR[WP], * TCR[WRC] * * @period: Input Watchdog Period - TCR[WP] - * 0 = 217 clocks - * 1 = 221 clocks - * 2 = 225 clocks - * 3 = 229 clocks - * @reset: Watchdog reset control - TCR[WRC] + * 0...2^17(PPC405) or 2^21(PPC440/e500) clocks + * 1...2^21(PPC405) or 2^25(PPC440/e500) clocks + * 2...2^25(PPC405) or 2^29(PPC440/e500) clocks + * 3...2^25(PPC405) or 2^29(PPC440/e500) clocks + * @reset: Watchdog reset control - TCR[WRC] * 0 = No reset * 1 = PPC Core reset only * 2 = PPC Chip reset * 3 = System reset - * Note: The meaning of period number is differ PPC440GP from PPC440GX. + * Note: The meaning of period number is differ PPC405 from PPC440. + * Current version assume that this function called with + * WRC_NONE as reset, if someone who want to remove this + * constraint, please note that when we disable WDT, we should + * set WRC with WRC_NONE and s/he should also modify + * disable/enable_wdt function. + * */ -#if defined(CONFIG_4xx) static __inline__ void __booke_wdt_setup_val(int period,int reset) { unsigned long val; /* Set up TCR */ - val=((period)<> 2 )&(WDT_TCR_WPEXT_BITMSK)) << WDT_TCR_WPEXT_SHIFT| - (reset)< WDT_HEARTBEAT_MAX)) return -EINVAL; @@ -360,6 +322,7 @@ static __inline__ int booke_wdt_get_status(int *status) { + if (wdt_enable) *status = WDIOS_ENABLECARD; else @@ -378,11 +341,12 @@ static void booke_wdt_init_device(void) { - /* Hardware WDT provided by the processor. + + /* Hardware WDT provided by the processor. * So, we set firmware version as processor version number. */ ident.firmware_version=mfspr(PVR); - __booke_wdt_setup_val(WDT_WP,WDT_RESET_NONE); + __booke_wdt_setup_val(WDT_WP,WRC_NONE); } /** * booke_wdt_write: @@ -401,22 +365,22 @@ { size_t i; - if (!nowayout) { - /* In case it was set long ago */ - clear_bit(WDT_STATE_STOP_ON_CLOSE, &driver_state); + if (!nowayout) { + /* In case it was set long ago */ + clear_bit(WDT_STATE_STOP_ON_CLOSE, &driver_state); - for (i = 0; i < count; i++) { - char c; + for (i = 0; i < count; i++) { + char c; - if (get_user(c, buf + i)) - return -EFAULT; + if (get_user(c, buf + i)) + return -EFAULT; - if (c == 'V') { - set_bit(WDT_STATE_STOP_ON_CLOSE, &driver_state); - } + if (c == 'V') { + set_bit(WDT_STATE_STOP_ON_CLOSE, &driver_state); } } - booke_wdt_ping(); + } + booke_wdt_ping(); return count; } @@ -523,12 +487,12 @@ booke_wdt_release(struct inode *inode, struct file *file) { if (test_bit(WDT_STATE_STOP_ON_CLOSE, &driver_state)) { - booke_wdt_note("WDT device is stopped.\n"); + booke_wdt_info("WDT device is stopped.\n"); booke_wdt_stop(); wdt_enable=0; } else { if ( (booke_wdt_is_enabled()) && (!nowayout) ) { - booke_wdt_note("WDT device may be closed unexpectedly. WDT will not stop!\n"); + booke_wdt_info("WDT device may be closed unexpectedly. WDT will not stop!\n"); booke_wdt_ping(); } } --- linux-2.6.11-booke-wdt/drivers/char/watchdog/booke_wdt.h 2005-03-04 16:38:58.000000000 +0900 +++ linux-2.6.11-wdt/drivers/char/watchdog/booke_wdt.h 2005-03-07 04:08:46.702851618 +0900 @@ -22,6 +22,7 @@ #include #include #include +#include /* * Driver state flags(bit position) @@ -32,32 +33,10 @@ * Configurations */ #define WDT_TIMO 60000 /* Default timeout = 60000 ms(1min) */ -#define WDT_HEARTBEAT_MIN 100 /* Minimum timeout = 100 ms */ -#define WDT_HEARTBEAT_MAX 600000 /* Maximum timeout = 600000ms(1hour) */ +#define WDT_HEARTBEAT_MIN 100 /* Minimum timeout = 100 ms */ +#define WDT_HEARTBEAT_MAX 600000 /* Maximum timeout = 600000ms(1hour) */ #ifdef __KERNEL__ //#define BOOKE_WDT_DEBUG /* Debug switch */ -/* - * Reset type - */ -#define WDT_RESET_NONE 0 -#define WDT_RESET_CORE 1 -#define WDT_RESET_CHIP 2 -#define WDT_RESET_SYS 3 -/* - * Bit positions in TCR register on PPC4xx/e500 series. - */ -#define WDT_TCR_WP_BIT 1 /* WP bit in TCR (bit[0..1]) */ -#define WDT_TCR_WRC_BIT 3 /* WRC bit in TCR (bit[2..3]) */ -#define WDT_TCR_WIE_BIT 4 /* WIE bit in TCR (bit[4]) */ -/* - * TCR[WP] relevant definitions - */ -#define WDT_TCR_WP_SHIFT (31 - WDT_TCR_WP_BIT) -#define WDT_TCR_WRC_SHIFT (31 - WDT_TCR_WRC_BIT) -#define WDT_TCR_WIE_SHIFT (31 - WDT_TCR_WIE_BIT) -#define WDT_TCR_WDT_ENABLE (1<>WDT_TCR_WP_BITLEN)& \ + (WDT_TCR_WPEXT_BITMSK)) +#define wdt_calculate_tcr(period,reset) \ + ( TCR_WP((period)&(WDT_TCR_WP_BITMSK)) |\ + TCR_WRC((reset)) |\ + ( WDT_WPEXT_VAL(period) << WDT_TCR_WPEXT_SHIFT)) #else #error "Book E WDT detects invalid configuration(Unknown CPU)" #endif /* CONFIG_E500 */ @@ -111,8 +98,6 @@ printk(KERN_NOTICE __BOOKE_WDT_MSG fmt,##arg) #define booke_wdt_err(fmt,arg...) \ printk(KERN_ALERT __BOOKE_WDT_MSG fmt,##arg) -#define booke_wdt_crit(fmt,arg...) \ - printk(KERN_ALERT __BOOKE_WDT_MSG fmt,##arg) #if defined(BOOKE_WDT_DEBUG) #define booke_wdt_dbg(fmt,arg...) \ printk(KERN_ALERT __BOOKE_WDT_MSG fmt,##arg)