Пример #1
0
int mt5931_power_off(void) 
{ 
    printk(KERN_INFO "[mt5931_power_off] ++\n"); 
    if(_mt5931_powered_on == 1) { 
		_mt5931_powered_on = 0; 
#if 0
        mt_wifi_disable_irq();     
        printk(KERN_INFO "[mt5931_power_off] config EINT_PIN\n");         
        mt_set_gpio_mode(GPIO_WIFI_EINT_PIN, GPIO_WIFI_EINT_PIN_M_GPIO); /* GPIO mode */ 
		if(0 != sw_gpio_eint_set_enable(gpio_eint, 0))
		printk("set enable status failed\n");
		sw_gpio_setcfg(gpio_eint,0);//GPIO input
#endif

 
    printk(KERN_INFO "[mt5931_power_off] config GPIO_MT5931_RST/MT5931_PMU_EN - LOW\n"); 
	gpio_direction_output(GPIO_MT5931_RST, 0);
	gpio_direction_output(GPIO_MT5931_PMU_EN, 0);
	msleep(MT5931_RST_TIME);	
    }else{
    	printk("mt5931 unmatched power off\n");
    }
	
	
	gpio_free(GPIO_MT5931_PMU_EN);
	gpio_free(GPIO_MT5931_RST);

    printk(KERN_INFO "[mt5931_power_off] --\n"); 
    return 0; 
}
Пример #2
0
/*******************************************************
Function:
	Disable IRQ Function.

Input:
	ts:	i2c client private struct.
	
Output:
	None.
*******************************************************/
void gtp_irq_enable(struct goodix_ts_data *ts)
{	
        unsigned long irqflags;
        dprintk(DEBUG_INT_INFO, "%s start!\n", __func__);
			
        spin_lock_irqsave(&ts->irq_lock, irqflags);
        if (ts->irq_is_disable) 
        {		
                sw_gpio_eint_set_enable(CTP_IRQ_NUMBER,1);		
                ts->irq_is_disable = 0;	
        }	
        spin_unlock_irqrestore(&ts->irq_lock, irqflags);
}
Пример #3
0
static int mt5931_power_on(void) 
{ 

	int ret = 0;
    if(_mt5931_powered_on == 0) 
	{ 
        _mt5931_powered_on = 1;         
        printk(KERN_INFO "[mt5931_power_on] config EINT_PIN\n"); 
            
		ret = gpio_request(GPIO_MT5931_PMU_EN, "MT5931_PMU_EN");
		if (ret) 
		{          
			printk("failed to request MT5931_PMU_EN %d!\n", GPIO_MT5931_PMU_EN);          
			return -1;	      
		}         //set the gpio to output mode, low val  
		
            
		ret = gpio_request(GPIO_MT5931_RST, "MT5931_RST");  
		if (ret) 
		{          
			printk("failed to request MT5931_RST %d!\n", GPIO_MT5931_RST);          
			return -1;	      
		} 
              

	#if 0
		mt_wifi_disable_irq(); 
		mt_set_gpio_mode(GPIO_WIFI_EINT_PIN, GPIO_WIFI_EINT_PIN_M_EINT); /* EINT5 */ 
		mt_set_gpio_pull_enable(GPIO_WIFI_PMU_EN_PIN, GPIO_PULL_DISABLE);
		if(0 != sw_gpio_eint_set_enable(gpio_eint, 0))
			printk("set enable status failed\n");
				sw_gpio_setcfg(gpio_eint,6);//EINT6
		sw_gpio_setpull(gpio_dis,0);//pull disabled
	#endif

	
		
		gpio_direction_output(GPIO_MT5931_RST, 0);
		gpio_direction_output(GPIO_MT5931_PMU_EN, 0);
		msleep(MT5931_OFF_TIME);
		gpio_direction_output(GPIO_MT5931_PMU_EN, 1);
		msleep(MT5931_PMU_EN_TIME);
		gpio_direction_output(GPIO_MT5931_RST, 1);
		msleep(MT5931_RST_TIME);


    }else{
    	printk("mt5931 unmatched power on\n");
    } 
	return 0; 
}
Пример #4
0
bool ctp_set_int_enable(u32 enable)
{
    u32 sta_enable;
    int ret = -1;
    if((enable != 0) || (enable != 1)) {
        return false;
    }
    ret = ctp_get_int_enable(&sta_enable);
    if(ret == true) {
        if(sta_enable == enable)
            return true;
    }
    ret = sw_gpio_eint_set_enable(CTP_IRQ_NUMBER,enable);
    if(ret != 0) {
        return false;
    }
    return true;
}
Пример #5
0
/*******************************************************	
Function:
	Goodix tool write function.
Input:
  standard proc write function param.
Output:
	Return write length.
********************************************************/
static s32 goodix_tool_write(struct file *filp, const char __user *buff, unsigned long len, void *data)
{
    s32 ret = 0;
    GTP_DEBUG_FUNC();
    GTP_DEBUG_ARRAY((u8*)buff, len);
    
    ret = copy_from_user(&cmd_head, buff, CMD_HEAD_LENGTH);
    if(ret)
    {
        GTP_ERROR("copy_from_user failed.");
    }

    GTP_DEBUG("wr  :0x%02x.", cmd_head.wr);
    GTP_DEBUG("flag:0x%02x.", cmd_head.flag);
    GTP_DEBUG("flag addr:0x%02x%02x.", cmd_head.flag_addr[0], cmd_head.flag_addr[1]);
    GTP_DEBUG("flag val:0x%02x.", cmd_head.flag_val);
    GTP_DEBUG("flag rel:0x%02x.", cmd_head.flag_relation);
    GTP_DEBUG("circle  :%d.", (s32)cmd_head.circle);
    GTP_DEBUG("times   :%d.", (s32)cmd_head.times);
    GTP_DEBUG("retry   :%d.", (s32)cmd_head.retry);
    GTP_DEBUG("delay   :%d.", (s32)cmd_head.delay);
    GTP_DEBUG("data len:%d.", (s32)cmd_head.data_len);
    GTP_DEBUG("addr len:%d.", (s32)cmd_head.addr_len);
    GTP_DEBUG("addr:0x%02x%02x.", cmd_head.addr[0], cmd_head.addr[1]);
    GTP_DEBUG("len:%d.", (s32)len);
    GTP_DEBUG("buf[20]:0x%02x.", buff[CMD_HEAD_LENGTH]);
    
    if (1 == cmd_head.wr)
    {
      //  copy_from_user(&cmd_head.data[cmd_head.addr_len], &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
        ret = copy_from_user(&cmd_head.data[GTP_ADDR_LENGTH], &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
        if(ret)
        {
            GTP_ERROR("copy_from_user failed.");
        }
        memcpy(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len], cmd_head.addr, cmd_head.addr_len);

        GTP_DEBUG_ARRAY(cmd_head.data, cmd_head.data_len + cmd_head.addr_len);
        GTP_DEBUG_ARRAY((u8*)&buff[CMD_HEAD_LENGTH], cmd_head.data_len);

        if (1 == cmd_head.flag)
        {
            if (FAIL == comfirm())
            {
                GTP_ERROR("[WRITE]Comfirm fail!");
                return FAIL;
            }
        }
        else if (2 == cmd_head.flag)
        {
            //Need interrupt!
        }
        if (tool_i2c_write(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len],
            cmd_head.data_len + cmd_head.addr_len) <= 0)
        {
            GTP_ERROR("[WRITE]Write data failed!");
            return FAIL;
        }

        GTP_DEBUG_ARRAY(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len],cmd_head.data_len + cmd_head.addr_len);
        if (cmd_head.delay)
        {
            msleep(cmd_head.delay);
        }

        return cmd_head.data_len + CMD_HEAD_LENGTH;
    }
    else if (3 == cmd_head.wr)  //Write ic type
    {
	ret = copy_from_user(&cmd_head.data[0], &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
        if(ret)
        {
            GTP_ERROR("copy_from_user failed.");
        }
        memcpy(IC_TYPE, cmd_head.data, cmd_head.data_len);

        register_i2c_func();

        return cmd_head.data_len + CMD_HEAD_LENGTH;
    }
    else if (5 == cmd_head.wr)
    {
        //memcpy(IC_TYPE, cmd_head.data, cmd_head.data_len);

        return cmd_head.data_len + CMD_HEAD_LENGTH;
    }
    else if (7 == cmd_head.wr)//disable irq!
    {
        //gtp_irq_disable(i2c_get_clientdata(gt_client));
        sw_gpio_eint_set_enable(CTP_IRQ_NUMBER,0); 
        return CMD_HEAD_LENGTH;
    }
    else if (9 == cmd_head.wr) //enable irq!
    {
        //gtp_irq_enable(i2c_get_clientdata(gt_client));
        sw_gpio_eint_set_enable(CTP_IRQ_NUMBER,1); 
        return CMD_HEAD_LENGTH;
    }
    else if(17 == cmd_head.wr)
    {
        struct goodix_ts_data *ts = i2c_get_clientdata(gt_client);
        ret = copy_from_user(&cmd_head.data[GTP_ADDR_LENGTH], &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
        if(ret)
        {
            GTP_DEBUG("copy_from_user failed.");
        }
        if(cmd_head.data[GTP_ADDR_LENGTH])
        {
            GTP_DEBUG("gtp enter rawdiff.");
            ts->gtp_rawdiff_mode = true;
        }
        else
        {
            ts->gtp_rawdiff_mode = false;
            GTP_DEBUG("gtp leave rawdiff.");
        }
        return CMD_HEAD_LENGTH;
    }
#ifdef UPDATE_FUNCTIONS
    else if (11 == cmd_head.wr)//Enter update mode!
    {
        if (FAIL == gup_enter_update_mode(gt_client))
        {
            return FAIL;
        }
    }
    else if (13 == cmd_head.wr)//Leave update mode!
    {
        gup_leave_update_mode();
    }
    else if (15 == cmd_head.wr) //Update firmware!
    {
        show_len = 0;
        total_len = 0;
        memset(cmd_head.data, 0, cmd_head.data_len + 1);
        memcpy(cmd_head.data, &buff[CMD_HEAD_LENGTH], cmd_head.data_len);

        if (FAIL == gup_update_proc((void*)cmd_head.data))
        {
            return FAIL;
        }
    }
#endif

    return CMD_HEAD_LENGTH;
}