コード例 #1
0
ファイル: mxc_wdt.c プロジェクト: jhlxz2003/mx27_drv
static int mxc_wdt_open(struct inode *inode, struct file *file)
{
    if (test_and_set_bit(1, (unsigned long *)&mxc_wdt_users))
        return -EBUSY;

    mxc_wdt_config();
    mxc_wdt_set_timeout();
    mxc_wdt_enable();
    mxc_wdt_ping();

    return 0;
}
コード例 #2
0
static int mxc_wdt_open(struct inode *inode, struct file *file)
{

	if (test_and_set_bit(1, (unsigned long *)&mxc_wdt_users))
		return -EBUSY;

	mxc_wdt_config(wdt_base_reg);
	mxc_wdt_set_timeout(wdt_base_reg);
	mxc_wdt_enable(wdt_base_reg);
	mxc_wdt_ping(wdt_base_reg);
#ifdef CONFIG_MACH_MX51_ERDOS
	opened = 1;
#endif /* CONFIG_MACH_MX51_ERDOS */

	return 0;
}
コード例 #3
0
static int
mxc_wdt_ioctl(struct inode *inode, struct file *file,
	      unsigned int cmd, unsigned long arg)
{
	int new_margin;
	int bootr;

	static struct watchdog_info ident = {
		.identity = "MXC Watchdog",
		.options = WDIOF_SETTIMEOUT,
		.firmware_version = 0,
	};

	switch (cmd) {
	default:
		return -ENOIOCTLCMD;
	case WDIOC_GETSUPPORT:
		return copy_to_user((struct watchdog_info __user *)arg, &ident,
				    sizeof(ident));
	case WDIOC_GETSTATUS:
		return put_user(0, (int __user *)arg);
	case WDIOC_GETBOOTSTATUS:
		bootr = mxc_wdt_get_bootreason(wdt_base_reg);
		return put_user(bootr, (int __user *)arg);
	case WDIOC_KEEPALIVE:
		mxc_wdt_ping(wdt_base_reg);
#ifdef CONFIG_MACH_MX51_ERDOS
		mxc_wdt_staticstics [2]++;
#endif /* CONFIG_MACH_MX51_ERDOS */
			return 0;
	case WDIOC_SETTIMEOUT:
		if (get_user(new_margin, (int __user *)arg))
			return -EFAULT;

		mxc_wdt_adjust_timeout(new_margin);
		mxc_wdt_disable(wdt_base_reg);
		mxc_wdt_set_timeout(wdt_base_reg);
		mxc_wdt_enable(wdt_base_reg);
		mxc_wdt_ping(wdt_base_reg);
		return 0;

	case WDIOC_GETTIMEOUT:
		mxc_wdt_ping(wdt_base_reg);
		new_margin = mxc_wdt_get_timeout(wdt_base_reg);
		return put_user(new_margin, (int __user *)arg);
	}
}

static struct file_operations mxc_wdt_fops = {
	.owner = THIS_MODULE,
	.write = mxc_wdt_write,
	.ioctl = mxc_wdt_ioctl,
	.open = mxc_wdt_open,
	.release = mxc_wdt_release,
};

static struct miscdevice mxc_wdt_miscdev = {
	.minor = WATCHDOG_MINOR,
	.name = "watchdog",
	.fops = &mxc_wdt_fops
};

#ifdef CONFIG_MACH_MX51_ERDOS
/*
 * wdt_self_workqueue_handler 
 */
static void wdt_self_workqueue_handler (struct work_struct *work)
{
	mxc_wdt_staticstics [0]++;
	if (opened == 0) {
	/*
	 * WDT heartbeat
	 */
	mxc_wdt_staticstics [1]++;
	mxc_wdt_ping (wdt_base_reg);
	/*
	 * next interval
	 */
	schedule_delayed_work (&wdt_self_work, 60 * HZ);
	}
}

/*
 * wdt_self_start 
 */
static void wdt_self_start (void)
{
	/*
	 * delay work create
	 */
	INIT_DELAYED_WORK (&wdt_self_work, wdt_self_workqueue_handler);
	schedule_delayed_work (&wdt_self_work, HZ);
	mxc_wdt_config (wdt_base_reg);
	mxc_wdt_set_timeout (wdt_base_reg);
	mxc_wdt_enable (wdt_base_reg);
}