コード例 #1
0
static int __init init_watchdog(void)
{
	if (enable) {
		tcsr_base = ioremap_nocache(TCSR_BASE, SZ_4K);
		if (tcsr_base == NULL)
			return -ENOMEM;
		writel(3, tcsr_base + TCSR_WDT_CFG);
		delay_time = msecs_to_jiffies(PET_DELAY);
		start_watchdog_timer();
		printk(KERN_INFO "MSM Watchdog Initialized\n");
	} else {
		printk(KERN_INFO "MSM Watchdog Not Initialized\n");
	}

	return 0;
}
コード例 #2
0
static int wd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
	int pair_no;
	int value;

	if( copy_from_user(&value, arg, sizeof(value)))
		return -EFAULT;
        switch(cmd)
        {
                case IOCTL_SYSTEM_OFF_BYPASS_STATE:
                        pair_no = value;
                        pair_no &= 0xff0;
                        switch(value & 0x0f)
                        {
                                case SYSTEM_OFF_BYPASS_STATE_ENABLE:
                                        set_bypass_enable_when_system_off(pair_no);
                                        break;

                                case SYSTEM_OFF_BYPASS_STATE_DISABLE:
                                        set_bypass_disable_when_system_off(pair_no);
                                        break;

                                default:
                                        return -EOPNOTSUPP;
                        }
                        break;

                case IOCTL_RUNTIME_BYPASS_STATE:
                        pair_no = value;
                        pair_no &= 0xff0;
                        switch(value & 0x0f)
                        {
                                case RUNTIME_BYPASS_STATE_ENABLE:
                                        set_runtime_bypass_enable(pair_no);
                                        break;

                                case RUNTIME_BYPASS_STATE_DISABLE:
                                        set_runtime_bypass_disable(pair_no);
                                        break;

                                default:
                                        return -EOPNOTSUPP;
                        }
                        break;
		/* Set system behavior once watchdog timer expired */
                case IOCTL_SET_WDTO_STATE:
                        switch(value)
                        {
                                case SET_WDTO_STATE_SYSTEM_RESET:
                                        set_wdto_state_system_reset();
                                        break;
                                case SET_WDTO_STATE_LAN_BYPASS:
                                        set_wdto_state_system_bypass();
                                        break;
                                default:
                                        return -EOPNOTSUPP;
                        }
                        break;
		/* Set the watchdog timer */
                case IOCTL_SET_WDTO_TIMER:
                        watchdog_time=value;
                        if ( (watchdog_time < 0 ) || (watchdog_time > 255))
                        {
                                printk(KERN_ERR "wd_drv error: Invalid time value\n");
                                watchdog_time=0;
                                return -EOPNOTSUPP;
                        }
                        break;
		/* Start/Stop watchdog timer */
                case IOCTL_START_STOP_WDT:
                        switch (value)
                        {
                                case START_WDT:
                                        start_watchdog_timer(watchdog_time);
                                        break;
                                case STOP_WDT:
                                        stop_watchdog_timer();
                                        break;
                                default:
                                        return -EOPNOTSUPP;
                        }
                        break;
                default:
                        return -EOPNOTSUPP;
        }
        return 0;

}