int mpcore_wdt_restart(WD_RES_TYPE type)

{
	struct mpcore_wdt *wdt = &mp_wdt;
	mpcore_wdt_print("enter:type:%d\n", type);
	mpcore_wdt_stop(wdt);
	mpcore_wdt_start(wdt);
#ifndef WDT_CPU0	
	mpcore_wdt_irq_enable(wdt->irq);
#endif		
	return 0;
}
Ejemplo n.º 2
0
static int mpcore_wdt_open(struct inode *inode, struct file *file)
{
	struct mpcore_wdt *wdt = platform_get_drvdata(mpcore_wdt_dev);

	if (test_and_set_bit(0, &wdt->timer_alive))
		return -EBUSY;

	if (nowayout)
		__module_get(THIS_MODULE);

	file->private_data = wdt;

	
	mpcore_wdt_start(wdt);

	return nonseekable_open(inode, file);
}
Ejemplo n.º 3
0
static int mpcore_wdt_ioctl(struct inode *inode, struct file *file,
			     unsigned int cmd, unsigned long arg)
{
	struct mpcore_wdt *wdt = file->private_data;
	int ret;
	union {
		struct watchdog_info ident;
		int i;
	} uarg;

	if (_IOC_DIR(cmd) && _IOC_SIZE(cmd) > sizeof(uarg))
		return -ENOIOCTLCMD;

	if (_IOC_DIR(cmd) & _IOC_WRITE) {
		ret = copy_from_user(&uarg, (void __user *)arg, _IOC_SIZE(cmd));
		if (ret)
			return -EFAULT;
	}

	switch (cmd) {
	case WDIOC_GETSUPPORT:
		uarg.ident = ident;
		ret = 0;
		break;

	case WDIOC_SETOPTIONS:
		ret = -EINVAL;
		if (uarg.i & WDIOS_DISABLECARD) {
			mpcore_wdt_stop(wdt);
			ret = 0;
		}
		if (uarg.i & WDIOS_ENABLECARD) {
			mpcore_wdt_start(wdt);
			ret = 0;
		}
		break;

	case WDIOC_GETSTATUS:
	case WDIOC_GETBOOTSTATUS:
		uarg.i = 0;
		ret = 0;
		break;

	case WDIOC_KEEPALIVE:
		mpcore_wdt_keepalive(wdt);
		ret = 0;
		break;

	case WDIOC_SETTIMEOUT:
		ret = mpcore_wdt_set_heartbeat(uarg.i);
		if (ret)
			break;

		mpcore_wdt_keepalive(wdt);
		/* Fall */
	case WDIOC_GETTIMEOUT:
		uarg.i = mpcore_margin;
		ret = 0;
		break;

	default:
		return -ENOIOCTLCMD;
	}

	if (ret == 0 && _IOC_DIR(cmd) & _IOC_READ) {
		ret = copy_to_user((void __user *)arg, &uarg, _IOC_SIZE(cmd));
		if (ret)
			ret = -EFAULT;
	}
	return ret;
}
static int __devinit mpcore_wdt_probe(struct platform_device *dev)
{
	struct mpcore_wdt *wdt = &mp_wdt;
//	struct resource *res;
	int ret;
	
	/* We only accept one device, and it must have an id of -1 */
	printk("mpcore wdt probe ++\n");
	if (dev->id != -1)
		return -ENODEV;

	wdt->dev = &dev->dev;
	wdt->irq = GIC_PPI_WATCHDOG_TIMER;
	
	wdt->base = (void __iomem*)0xF000A600;

#ifdef WDT_CPU0 
	ret = request_irq(wdt->irq, mpcore_wdt_fire, IRQF_TRIGGER_HIGH,
							"mpcore_wdt", wdt);
	if (ret) {
		printk(DEBUG_INFO"cannot register IRQ%d for watchdog\n", wdt->irq);
		goto err_irq;
	}
#endif	

#if defined(CONFIG_FIQ_GLUE)
	/*
	 * NoteXXX: The FIQ handler's initialization will use one SMP call.
	 *          Thus it cannot be used via another SMP call. 
	 *          We need to do this initialization on the current CPU first.
	 */
	fiq_wdt_init(NULL);
	smp_call_function(fiq_wdt_init, NULL, 1);
#else
      irq_wdt_init();
#endif
	#ifdef  CONFIG_MTK_WD_KICKER	// Initialize to enable wdt
  	//enable local wdt
  	//mpcore_wdt_restart(WD_TYPE_NORMAL);
	//mpcore_wdt_stop(wdt);
	//mpcore_wdt_irq_enable(wdt->irq);
	//mpcore_wdt_start(wdt);
	//smp_call_function(mpcore_wdt_restart,WD_TYPE_NORMAL,1);
	mpcore_wdt_start(wdt);
	smp_call_function(mpcore_wdt_restart,WD_TYPE_NORMAL,1);
	//on_each_cpu((smp_call_func_t)(mpcore_wdt_restart(WD_TYPE_NORMAL)), NULL, 0);
	printk("mpcore wdt enable\n");
	#else
	//disable local wdt
	printk("mpcore wdt do not enable\n");
	#endif

	printk("mpcore wdt probe success\n");
	return 0;

#ifdef WDT_CPU0 
err_irq:

err_out:
#endif
	
	return ret;
}