Exemplo n.º 1
0
static int wk_proc_cmd_write(struct file *file, const char *buf, size_t count, loff_t *data)
{
	int ret;
	int timeout;
	int mode;
	int kinterval;
	int en; //enable or disable ext wdt 1<-->enable 0<-->disable
	struct wd_api  *my_wd_api = NULL;
	 
	ret = get_wd_api(&my_wd_api);
	if(ret)
	{
	   printk("get public api error in wd common driver %d",ret);
	}
	
	if (count == 0)
		return -1;

	if(count > 255) 
		count = 255;

	ret = copy_from_user(cmd_buf, buf, count);
	if (ret < 0)
		return -1;
	
	cmd_buf[count] = '\0';

	dbgmsg("Write %s\n", cmd_buf);

	sscanf(cmd_buf, "%d %d %d %d %d", &mode, &kinterval, &timeout, &debug_sleep,&en);

	printk("[WDK] mode=%d interval=%d timeout=%d enable =%d\n", mode, kinterval, timeout,en);

	if (timeout < kinterval) {
		errmsg("The interval(%d) value should be smaller than timeout value(%d)\n", kinterval, timeout);
		return -1;
	}

	if ((timeout <  MIN_KICK_INTERVAL) || (timeout > MAX_KICK_INTERVAL)) {
		errmsg("The timeout(%d) is invalid (%d - %d)\n", kinterval, MIN_KICK_INTERVAL, MAX_KICK_INTERVAL);
		return -1;
	}

	if ((kinterval <  MIN_KICK_INTERVAL) || (kinterval > MAX_KICK_INTERVAL)) {
		errmsg("The interval(%d) is invalid (%d - %d)\n",kinterval,  MIN_KICK_INTERVAL, MAX_KICK_INTERVAL);
		return -1;
	}

	if (!((mode == WDT_IRQ_ONLY_MODE) || 
	      (mode == WDT_HW_REBOOT_ONLY_MODE)||
	      (mode == WDT_DUAL_MODE))) {
		errmsg("Tha watchdog kicker wdt mode is not correct %d\n",mode);
		return -1;
	}

	if(1 == en)
	{
	  mtk_wdt_enable(WK_WDT_EN);
	  #ifdef CONFIG_LOCAL_WDT
	  local_wdt_enable(WK_WDT_EN);
	  printk("[WDK] enable local wdt \n");
	  #endif
	  printk("[WDK] enable wdt \n");
	}
	if(0 == en)
	{
	  mtk_wdt_enable(WK_WDT_DIS);
	  #ifdef CONFIG_LOCAL_WDT
	  local_wdt_enable(WK_WDT_DIS);
	  printk("[WDK] disable local wdt \n");
	  #endif
	  printk("[WDK] disable wdt \n");
	}
			
    spin_lock(&lock);

    g_enable= en;
	g_kinterval = kinterval;
 
	g_wk_wdt_mode = mode;
	if(1 == mode)
	{
		//irq mode only usefull to 75
		mtk_wdt_swsysret_config(0x20000000,1);
		printk("[WDK] use irq mod \n");
	}
	else if(0 == mode)
	{
		//reboot mode only usefull to 75
		mtk_wdt_swsysret_config(0x20000000,0); 
		printk("[WDK] use reboot mod \n");
	}
	else if(2 == mode)
	{
		my_wd_api->wd_set_mode(WDT_IRQ_ONLY_MODE);
	}
	else
	{
		printk("[WDK] mode err \n");
	}
   
	g_timeout = timeout;
	if(mode != 2)
	{
        g_need_config = 1;
	}
    spin_unlock(&lock);

	return count;
}
Exemplo n.º 2
0
static int slt_scu_test_func(void *data)
{
    int ret = 0, loop, pass;
    int cpu = raw_smp_processor_id();
    unsigned long irq_flag;
    int cpu_cnt;

    unsigned long buf;
    unsigned long *mem_buf = (unsigned long *)data;
    unsigned long retry;

    //spin_lock(&scu_thread_lock[cpu]);
    //local_irq_save(irq_flag);
#if 0
    if(cpu == 0)
    {
        mtk_wdt_enable(WK_WDT_DIS);
    }
#endif

    if(!mem_buf)
    {
        printk(KERN_ERR, "allocate memory fail for cpu scu test\n");
        g_iCPU_PassFail = -1;
        goto scu_thread_out;
    }

    printk("\n>>slt_scu_test_func -- cpu id = %d, mem_buf = 0x%08x <<\n", cpu, mem_buf);

    msleep(50);

    if(!wait_slt_scu_state_sync(SCU_STATE_START, 1))
    {
        printk("cpu%d wait SCU_STATE_START timeout\n", cpu);

        goto scu_thread_out;
    }
    g_iCPU_PassFail = 0;
    g_iSCU_PassFail[cpu] = 1;

    for (loop = 0; loop < g_iScuLoopCount; loop++) {

        slt_scu_write_state(cpu, SCU_STATE_EXECUTE);
        spin_lock_irqsave(&scu_thread_irq_lock[cpu], irq_flag);
        if(!wait_slt_scu_state_sync(SCU_STATE_EXECUTE, 1))
        {
            spin_unlock_irqrestore(&scu_thread_irq_lock[cpu], irq_flag);
            printk("cpu%d wait SCU_STATE_EXECUTE timeout\n", cpu);
            goto scu_thread_out;
        }

        g_iSCU_PassFail[cpu] = fp6_scu_start(mem_buf);
        spin_unlock_irqrestore(&scu_thread_irq_lock[cpu], irq_flag);

        __cpuc_flush_dcache_area(g_iSCU_PassFail, 2*sizeof(int));

        printk("\n>>cpu%d scu : fp6_scu_start %s ret=0x%x<<\n", cpu, g_iSCU_PassFail[cpu] != 0xA? "fail" : "pass", g_iSCU_PassFail[cpu]);

        slt_scu_write_state(cpu, SCU_STATE_EXEEND);

        if(!wait_slt_scu_state_sync(SCU_STATE_EXEEND, 1))
        {
            printk("cpu%d wait SCU_STATE_EXEEND timeout\n", cpu);
            goto scu_thread_out;

        }

        if(cpu == 0)
        {
            pass = 1;
            for(cpu_cnt = 0; cpu_cnt < NR_CPUS; cpu_cnt++)
            {
                if(g_iSCU_PassFail[cpu_cnt] != 0xA)
                {
                    pass = 0;
                }
            }

            if(pass)
            {
                g_iCPU_PassFail += 1;
            }
        }
    }

scu_thread_out:

    slt_scu_write_state(cpu, SCU_STATE_IDEL);

    if(cpu == 0)
    {
        if (g_iCPU_PassFail == g_iScuLoopCount) {
            printk("\n>> CPU scu test pass <<\n\n");
        }else {
            printk("\n>> CPU scu test fail (loop count = %d)<<\n\n", g_iCPU_PassFail);
        }
        //mtk_wdt_enable(WK_WDT_EN);
    }

    wait_slt_scu_state_sync(SCU_STATE_IDEL, 1);

    printk("cpu%d scu thread out\n", cpu);

    //local_irq_restore(irq_flag);

    //spin_unlock(&scu_thread_lock[cpu]);
    return 0;

}
Exemplo n.º 3
0
static int disable_ext(void)
{
  mtk_wdt_enable(WK_WDT_DIS);
  return 0;
}
static int wk_proc_cmd_write(struct file *file, const char *buf, unsigned long count, void *data)
{
	int ret;
	//static int wdt_start = 0; // Adjust this variable to file view scope 
	int timeout;
	int mode;
	int kinterval;
	int en; //enable or disable ext wdt 1<-->enable 0<-->disable

	if (count == 0)
		return -1;

	if(count > 255) 
		count = 255;

	ret = copy_from_user(cmd_buf, buf, count);
	if (ret < 0)
		return -1;
	
	cmd_buf[count] = '\0';

	dbgmsg("Write %s\n", cmd_buf);

	sscanf(cmd_buf, "%d %d %d %d %d", &mode, &kinterval, &timeout, &debug_sleep,&en);

	printk("[WDK] mode=%d interval=%d timeout=%d enable =%d\n", mode, kinterval, timeout,en);

	if (timeout < kinterval) {
		errmsg("The interval(%d) value should be smaller than timeout value(%d)\n", kinterval, timeout);
		return -1;
	}

	if ((timeout <  MIN_KICK_INTERVAL) || (timeout > MAX_KICK_INTERVAL)) {
		errmsg("The timeout(%d) is invalid (%d - %d)\n", kinterval, MIN_KICK_INTERVAL, MAX_KICK_INTERVAL);
		return -1;
	}

	if ((kinterval <  MIN_KICK_INTERVAL) || (kinterval > MAX_KICK_INTERVAL)) {
		errmsg("The interval(%d) is invalid (%d - %d)\n",kinterval,  MIN_KICK_INTERVAL, MAX_KICK_INTERVAL);
		return -1;
	}

	if (!((mode == WDT_IRQ_ONLY_MODE) || 
	      (mode == WDT_HW_REBOOT_ONLY_MODE)||
	      (mode == WDT_DUAL_MODE))) {
		errmsg("Tha watchdog kicker wdt mode is not correct %d\n",mode);
		return -1;
	}

	if(1 == en)
	{
	  mtk_wdt_enable(WK_WDT_EN);
	  printk("[WDK] enable wdt \n");
	}
	if(0 == en)
	{
	  mtk_wdt_enable(WK_WDT_DIS);
	  printk("[WDK] disable wdt \n");
	}
			
    spin_lock(&lock);

    g_enable= en;
	g_kinterval = kinterval;
    #if 0 //CONFIG_MTK_AEE_FEATURE auto enable or disable WDT isr or hw mode
	g_wk_wdt_mode = WK_WDT_EXP_MODE;
	msg("Enable wdt with interrupt mode only %d\n", g_wk_wdt_mode);
    #else
	g_wk_wdt_mode = mode;
    #endif
	g_timeout = timeout;
    g_need_config = 1;
    spin_unlock(&lock);

	return count;
}