/*   
 | 
 * Copyright (C) 2014 Rockchip Corporation.  
 | 
 *  
 | 
 * This software is licensed under the terms of the GNU General Public  
 | 
 * License version 2, as published by the Free Software Foundation, and  
 | 
 * may be copied, distributed, and modified under those terms.  
 | 
 *  
 | 
 * This program is distributed in the hope that it will be useful,  
 | 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of  
 | 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
 | 
 * GNU General Public License for more details.  
 | 
 *  
 | 
 */  
 | 
#include <linux/module.h>  
 | 
#include <linux/moduleparam.h>  
 | 
#include <linux/init.h>  
 | 
#include <linux/delay.h>  
 | 
#include <linux/pm.h>  
 | 
#include <linux/i2c.h>  
 | 
#include <linux/spi/spi.h>  
 | 
#include <linux/platform_device.h>  
 | 
#include <linux/errno.h>  
 | 
#include <linux/err.h>  
 | 
#include <linux/debugfs.h>  
 | 
#include <linux/of_gpio.h>  
 | 
#include <linux/gpio.h>  
 | 
#include <linux/iio/consumer.h>  
 | 
#include <linux/of.h>  
 | 
#include "nkio.h"  
 | 
  
 | 
/* Debug */  
 | 
#if 1  
 | 
#define DBG(x...) printk(x)  
 | 
#else  
 | 
#define DBG(x...) do { } while (0)  
 | 
#endif  
 | 
  
 | 
struct nk_io_pdata *NKpdata_info;  
 | 
u32 op0_enable,op1_enable,op2_enable,op3_enable,op4_enable,op5_enable,mic_enable;  
 | 
u32 ip0_enable,ip1_enable,ip2_enable,ip3_enable,ip4_enable,ip5_enable;  
 | 
u32 module_enable;  
 | 
//static struct class *nk_class;  
 | 
  
 | 
  
 | 
#if 0  
 | 
  
 | 
 void mic_switch_control(int i)  
 | 
{  
 | 
if(i==11){  
 | 
    gpio_direction_output(NKpdata_info->mic_switch_gpio, 1);  
 | 
    printk("mic_switch_control ENABLE------andy\n");  
 | 
}else{  
 | 
    gpio_direction_output(NKpdata_info->mic_switch_gpio, 0);  
 | 
    printk("mic_switch_control DISABLE------andy\n");  
 | 
}  
 | 
}  
 | 
  
 | 
  
 | 
  
 | 
  
 | 
static ssize_t mic_switch_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &mic_enable);  
 | 
        printk("MIC_SWITCH enable =%d\n",mic_enable);  
 | 
  
 | 
    if (mic_enable)  
 | 
        {  
 | 
            printk("store_MIC_SWITCH ENABLE------andy\n");  
 | 
            mic_switch_control(11);  
 | 
        }  
 | 
        else {  
 | 
            mic_switch_control(0);  
 | 
            printk("store_MIC_SWITCH DISABLE------andy\n");  
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t mic_switch_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
return snprintf(buf, 3, "%d\n",mic_enable);  
 | 
}  
 | 
  
 | 
static CLASS_ATTR(mic_switch, 0664, mic_switch_show, mic_switch_store);  
 | 
  
 | 
  
 | 
   
 | 
  void Audio_SET(int i)  
 | 
 {  
 | 
     if(i==11){  
 | 
         gpio_direction_output(NKpdata_info->audio_switch_gpio, 1);  
 | 
         printk("Audio_SET ENABLE------andy\n");  
 | 
     }else{  
 | 
         gpio_direction_output(NKWpdata_info->audio_switch_gpio, 0);  
 | 
         printk("Audio_SET DISABLE------andy\n");  
 | 
     }  
 | 
 }  
 | 
  EXPORT_SYMBOL_GPL(Audio_SET);  
 | 
  
 | 
  
 | 
  
 | 
static void LED_SET(int i)  
 | 
{  
 | 
    if(i==11){  
 | 
        gpio_direction_output(NKpdata_info->led_gpio, 1);  
 | 
    }else{  
 | 
        gpio_direction_output(NKpdata_info->led_gpio, 0);  
 | 
    }  
 | 
}  
 | 
  
 | 
  
 | 
  
 | 
static ssize_t led_display_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &enable);  
 | 
        printk("store_led enable =%d\n",enable);  
 | 
  
 | 
    if (enable)  
 | 
        {  
 | 
            printk("store_led ENABLE------andy\n");  
 | 
            LED_SET(11);  
 | 
        }  
 | 
        else {  
 | 
            LED_SET(0);  
 | 
            printk("store_led DISABLE------andy\n");  
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t led_display_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
return snprintf(buf, 3, "%d\n",enable);  
 | 
}  
 | 
  
 | 
static CLASS_ATTR(led_display, 0664, led_display_show, led_display_store);  
 | 
  
 | 
#endif  
 | 
  
 | 
void MODULE_SET(int i)  
 | 
{  
 | 
    if(i==11){  
 | 
        gpio_direction_output(NKpdata_info->en_4g_gpio, 1);  
 | 
    }else{  
 | 
        gpio_direction_output(NKpdata_info->en_4g_gpio, 0);  
 | 
    }  
 | 
}  
 | 
  
 | 
EXPORT_SYMBOL_GPL(MODULE_SET);  
 | 
  
 | 
  
 | 
void LED_SET(int i)  
 | 
{  
 | 
    if(i==11){  
 | 
        gpio_direction_output(NKpdata_info->led_gpio, 1);  
 | 
    }else{  
 | 
        gpio_direction_output(NKpdata_info->led_gpio, 0);  
 | 
    }  
 | 
}  
 | 
  
 | 
EXPORT_SYMBOL_GPL(LED_SET);  
 | 
  
 | 
  
 | 
void Audio_SET(int i);  
 | 
  
 | 
  void Audio_SET(int i)  
 | 
 {  
 | 
     if(i==11){  
 | 
         gpio_direction_output(NKpdata_info->audio_switch_gpio, 1);  
 | 
         printk("Audio_SET ENABLE------andy\n");  
 | 
     }else{  
 | 
         gpio_direction_output(NKpdata_info->audio_switch_gpio, 0);  
 | 
         printk("Audio_SET DISABLE------andy\n");  
 | 
     }  
 | 
 }  
 | 
  EXPORT_SYMBOL_GPL(Audio_SET);  
 | 
  
 | 
  
 | 
//6 in 6 out-s  
 | 
static void GPIO_IO_SET(int i)  
 | 
{  
 | 
    if(i==11){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op0, 1);  
 | 
    }  
 | 
    else if(i==10){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op0, 0);  
 | 
    }  
 | 
    else if(i==21){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op1, 1);  
 | 
    }  
 | 
    else if(i==20){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op1, 0);  
 | 
    }  
 | 
    else if(i==31){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op2, 1);  
 | 
    }  
 | 
    else if(i==30){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op2, 0);  
 | 
    }  
 | 
    else if(i==41){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op3, 1);  
 | 
    }  
 | 
    else if(i==40){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op3, 0);  
 | 
    }  
 | 
    else if(i==51){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op4, 1);  
 | 
    }  
 | 
    else if(i==50){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op4, 0);  
 | 
    }  
 | 
    else if(i==61){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op5, 1);  
 | 
    }  
 | 
    else if(i==60){  
 | 
        gpio_direction_output(NKpdata_info->gpio_op5, 0);  
 | 
    }  
 | 
    /*  
 | 
        else if(i==51){  
 | 
        gpio_direction_output(NKpdata_info->gpio_ip0, 1);  
 | 
    }  
 | 
        else if(i==50){  
 | 
        gpio_direction_output(NKpdata_info->gpio_ip0, 0);  
 | 
    }  
 | 
        else if(i==61){  
 | 
        gpio_direction_output(NKpdata_info->gpio_ip1, 1);  
 | 
    }  
 | 
        else if(i==60){  
 | 
        gpio_direction_output(NKpdata_info->gpio_ip1, 0);  
 | 
    }  
 | 
        else if(i==71){  
 | 
        gpio_direction_output(NKpdata_info->gpio_ip2, 1);  
 | 
    }  
 | 
        else if(i==70){  
 | 
        gpio_direction_output(NKpdata_info->gpio_ip2, 0);  
 | 
    }  
 | 
        else if(i==81){  
 | 
        gpio_direction_output(NKpdata_info->gpio_ip3, 1);  
 | 
    }  
 | 
        else if(i==80){  
 | 
        gpio_direction_output(NKpdata_info->gpio_ip3, 0);  
 | 
    }  
 | 
    */      
 | 
          
 | 
}  
 | 
  
 | 
EXPORT_SYMBOL_GPL(GPIO_IO_SET);  
 | 
  
 | 
#if 0  
 | 
static ssize_t en_4g_gpio_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &module_enable);  
 | 
        printk("store en_4g_gpio ouput =%d\n",module_enable);  
 | 
  
 | 
    if (module_enable)  
 | 
        {  
 | 
            printk("store en_4g_gpio output High \n");  
 | 
            MODULE_SET(11);  
 | 
        }  
 | 
        else {  
 | 
            MODULE_SET(10);  
 | 
            printk("store en_4g_gpio output Low \n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t en_4g_gpio_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    module_enable = gpio_get_value(NKpdata_info->en_4g_gpio);  
 | 
    return snprintf(buf,3,"%d\n",module_enable);  
 | 
}  
 | 
  
 | 
  
 | 
  
 | 
static ssize_t gpio_op0_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &op0_enable);  
 | 
        printk("store_gpio_op0 ouput =%d\n",op0_enable);  
 | 
  
 | 
    if (op0_enable)  
 | 
        {  
 | 
            printk("store_gpio_op0 output High------konby\n");  
 | 
            GPIO_IO_SET(11);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(10);  
 | 
            printk("tore_gpio_op0 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op0_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    op0_enable = gpio_get_value(NKpdata_info->gpio_op0);  
 | 
    return snprintf(buf,3,"%d\n",op0_enable);  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op1_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &op1_enable);  
 | 
        printk("store_gpio_op1 ouput =%d\n",op1_enable);  
 | 
  
 | 
    if (op1_enable)  
 | 
        {  
 | 
            printk("store_gpio_op1 output High------konby\n");  
 | 
            GPIO_IO_SET(21);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(20);  
 | 
            printk("tore_gpio_op1 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op1_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    op1_enable = gpio_get_value(NKpdata_info->gpio_op1);  
 | 
    return snprintf(buf,3,"%d\n",op1_enable);  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op2_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &op2_enable);  
 | 
        printk("store_gpio_op2 ouput =%d\n",op2_enable);  
 | 
  
 | 
    if (op2_enable)  
 | 
        {  
 | 
            printk("store_gpio_op2 output High------konby\n");  
 | 
            GPIO_IO_SET(31);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(30);  
 | 
            printk("tore_gpio_op2 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op2_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    op2_enable = gpio_get_value(NKpdata_info->gpio_op2);  
 | 
    return snprintf(buf,3,"%d\n",op2_enable);  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op3_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &op3_enable);  
 | 
        printk("store_gpio_op3 ouput =%d\n",op3_enable);  
 | 
  
 | 
    if (op3_enable)  
 | 
        {  
 | 
            printk("store_gpio_op3 output High------konby\n");  
 | 
            GPIO_IO_SET(41);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(40);  
 | 
            printk("tore_gpio_op3 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op3_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    op3_enable = gpio_get_value(NKpdata_info->gpio_op3);  
 | 
    return snprintf(buf,3,"%d\n",op3_enable);  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op4_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &op4_enable);  
 | 
        printk("store_gpio_op3 ouput =%d\n",op4_enable);  
 | 
  
 | 
    if (op4_enable)  
 | 
        {  
 | 
            printk("store_gpio_op4 output High------konby\n");  
 | 
            GPIO_IO_SET(51);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(50);  
 | 
            printk("tore_gpio_op4 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op4_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    op4_enable = gpio_get_value(NKpdata_info->gpio_op4);  
 | 
    return snprintf(buf,3,"%d\n",op4_enable);  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op5_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &op5_enable);  
 | 
        printk("store_gpio_op5 ouput =%d\n",op5_enable);  
 | 
  
 | 
    if (op5_enable)  
 | 
        {  
 | 
            printk("store_gpio_op5 output High------konby\n");  
 | 
            GPIO_IO_SET(61);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(60);  
 | 
            printk("tore_gpio_op5 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t gpio_op5_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    op5_enable = gpio_get_value(NKpdata_info->gpio_op5);  
 | 
    return snprintf(buf,3,"%d\n",op5_enable);  
 | 
}  
 | 
  
 | 
  
 | 
  
 | 
  
 | 
static ssize_t gpio_ip0_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    ip0_enable = gpio_get_value(NKpdata_info->gpio_ip0);  
 | 
    return snprintf(buf,3,"%d\n",ip0_enable);  
 | 
  
 | 
}  
 | 
  
 | 
static ssize_t gpio_ip1_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    ip1_enable = gpio_get_value(NKpdata_info->gpio_ip1);  
 | 
    return snprintf(buf,3,"%d\n",ip1_enable);  
 | 
}  
 | 
  
 | 
static ssize_t gpio_ip2_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    ip2_enable = gpio_get_value(NKpdata_info->gpio_ip2);  
 | 
    return snprintf(buf,3,"%d\n",ip2_enable);  
 | 
}  
 | 
  
 | 
static ssize_t gpio_ip3_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    ip3_enable = gpio_get_value(NKpdata_info->gpio_ip3);  
 | 
    return snprintf(buf,3,"%d\n",ip3_enable);  
 | 
}  
 | 
  
 | 
static ssize_t gpio_ip4_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    ip4_enable = gpio_get_value(NKpdata_info->gpio_ip4);  
 | 
    return snprintf(buf,3,"%d\n",ip4_enable);  
 | 
}  
 | 
  
 | 
static ssize_t gpio_ip5_show(struct class *class,struct class_attribute *attr, char *buf)  
 | 
{  
 | 
    ip5_enable = gpio_get_value(NKpdata_info->gpio_ip5);  
 | 
    return snprintf(buf,3,"%d\n",ip5_enable);  
 | 
}  
 | 
#endif  
 | 
  
 | 
  
 | 
#if 0  
 | 
static ssize_t gpio_ip0_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &ip0_enable);  
 | 
        printk("store_gpio_op3 ouput =%d\n",ip0_enable);  
 | 
  
 | 
    if (ip0_enable)  
 | 
        {  
 | 
            printk("store_gpio_op3 output High------konby\n");  
 | 
            GPIO_IO_SET(51);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(50);  
 | 
            printk("tore_gpio_op3 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t gpio_ip1_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &ip1_enable);  
 | 
        printk("store_gpio_op3 ouput =%d\n",ip1_enable);  
 | 
  
 | 
    if (ip1_enable)  
 | 
        {  
 | 
            printk("store_gpio_op3 output High------konby\n");  
 | 
            GPIO_IO_SET(61);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(60);  
 | 
            printk("tore_gpio_op3 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t gpio_ip2_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &ip2_enable);  
 | 
        printk("store_gpio_op3 ouput =%d\n",ip2_enable);  
 | 
  
 | 
    if (ip2_enable)  
 | 
        {  
 | 
            printk("store_gpio_op3 output High------konby\n");  
 | 
            GPIO_IO_SET(71);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(70);  
 | 
            printk("tore_gpio_op3 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
static ssize_t gpio_ip3_store(struct class *class,struct class_attribute *attr, const char *buf, size_t count)  
 | 
{      
 | 
        sscanf(buf, "%d", &ip3_enable);  
 | 
        printk("store_gpio_op3 ouput =%d\n",ip3_enable);  
 | 
  
 | 
    if (ip3_enable)  
 | 
        {  
 | 
            printk("store_gpio_op3 output High------konby\n");  
 | 
            GPIO_IO_SET(81);  
 | 
        }  
 | 
        else {  
 | 
            GPIO_IO_SET(80);  
 | 
            printk("tore_gpio_op3 output Low------konby\n");  
 | 
              
 | 
        }  
 | 
        return count;  
 | 
}  
 | 
  
 | 
#endif  
 | 
  
 | 
  
 | 
  
 | 
#if 0  
 | 
  
 | 
//static CLASS_ATTR(en_4g_gpio, 0666, module_show, module_store);  
 | 
static CLASS_ATTR_RW(en_4g_gpio);  
 | 
  
 | 
  
 | 
//static CLASS_ATTR(gpio_op0, 0666, gpio_op0_show, gpio_op0_store);  
 | 
static CLASS_ATTR_RW(gpio_op0);  
 | 
//static CLASS_ATTR(gpio_op1, 0666, gpio_op1_show, gpio_op1_store);  
 | 
static CLASS_ATTR_RW(gpio_op1);  
 | 
//static CLASS_ATTR(gpio_op2, 0666, gpio_op2_show, gpio_op2_store);  
 | 
static CLASS_ATTR_RW(gpio_op2);  
 | 
//static CLASS_ATTR(gpio_op3, 0666, gpio_op3_show, gpio_op3_store);  
 | 
static CLASS_ATTR_RW(gpio_op3);  
 | 
//static CLASS_ATTR(gpio_op4, 0666, gpio_op4_show, gpio_op4_store);  
 | 
static CLASS_ATTR_RW(gpio_op4);  
 | 
//static CLASS_ATTR(gpio_op5, 0666, gpio_op5_show, gpio_op5_store);  
 | 
static CLASS_ATTR_RW(gpio_op5);  
 | 
  
 | 
  
 | 
  
 | 
//static CLASS_ATTR(gpio_ip0, 0666, gpio_ip0_show, NULL);  
 | 
static CLASS_ATTR_RO(gpio_ip0);  
 | 
//static CLASS_ATTR(gpio_ip1, 0666, gpio_ip1_show, NULL);  
 | 
static CLASS_ATTR_RO(gpio_ip1);  
 | 
//static CLASS_ATTR(gpio_ip2, 0666, gpio_ip2_show, NULL);  
 | 
static CLASS_ATTR_RO(gpio_ip2);  
 | 
//static CLASS_ATTR(gpio_ip3, 0666, gpio_ip3_show, NULL);  
 | 
static CLASS_ATTR_RO(gpio_ip3);  
 | 
//static CLASS_ATTR(gpio_ip4, 0666, gpio_ip4_show, NULL);  
 | 
static CLASS_ATTR_RO(gpio_ip4);  
 | 
//static CLASS_ATTR(gpio_ip5, 0666, gpio_ip5_show, NULL);  
 | 
static CLASS_ATTR_RO(gpio_ip5);  
 | 
  
 | 
  
 | 
#endif  
 | 
  
 | 
  
 | 
  
 | 
  
 | 
//ben  
 | 
static int nk_io_control_probe(struct platform_device *pdev)  
 | 
{  
 | 
    struct device_node *node = pdev->dev.of_node;  
 | 
    struct nk_io_pdata *pdata;      
 | 
    int gpio0, gpio1, gpio2, gpio3, reset_pin, ch342_reset;  
 | 
    int ret;  
 | 
        int lvds_index;  
 | 
        int i=0;  
 | 
        static int lvds_gpio[4] ;  
 | 
  
 | 
    enum of_gpio_flags flags;  
 | 
      
 | 
    printk(" #######nk_io_control_probe####### \n");  
 | 
  
 | 
    pdata = kzalloc(sizeof(struct nk_io_pdata), GFP_KERNEL);  
 | 
    if (pdata == NULL) {  
 | 
        printk("%s failed to allocate driver data\n",__FUNCTION__);  
 | 
        return -ENOMEM;  
 | 
    }  
 | 
    memset(pdata,0,sizeof(struct nk_io_pdata));  
 | 
      
 | 
    //vcc_5v_io  
 | 
#if 0  
 | 
    ret = of_get_named_gpio_flags(node, "vcc_5v_io", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property vcc_5v_io\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->vcc_5v_io = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->vcc_5v_io, "vcc_5v_io");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request vcc_5v_io request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->vcc_5v_io,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input vcc_5v_io set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
#endif  
 | 
    //tp_enable  
 | 
    ret = of_get_named_gpio_flags(node, "tp_enable", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property tp_enable\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->tp_enable = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->tp_enable, "tp_enable");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request tp_enable request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->tp_enable,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_output tp_enable set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
  
 | 
    //vcc_12v_io  
 | 
    ret = of_get_named_gpio_flags(node, "vcc_12v_io", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property vcc_12v_io\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->vcc_12v_io = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->vcc_12v_io, "vcc_12v_io");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request vcc_12v_io request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->vcc_12v_io,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input vcc_12v_io set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
      
 | 
    //hub_hos2_5V_gpio  
 | 
    ret = of_get_named_gpio_flags(node, "hub_host2_5v_gpio", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property hub_host2_5v_gpio\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->hub_host2_5v_gpio = ret;  
 | 
        gpio_free(ret);  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->hub_host2_5v_gpio, "hub_host2_5v_gpio");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request hub_host2_5v_gpio request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->hub_host2_5v_gpio,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input hub_host2_5v_gpio set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
  
 | 
    //hub_host2_5V_rest_gpio  
 | 
    ret = of_get_named_gpio_flags(node, "hub_host2_5V_rest_gpio", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property hub_host2_5V_rest_gpio\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->hub_host2_5V_rest_gpio = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->hub_host2_5V_rest_gpio, "hub_host2_5V_rest_gpio");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request hub_host2_5V_rest_gpio request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->hub_host2_5V_rest_gpio,0);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input hub_host2_5V_rest_gpio set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
        msleep(800);  
 | 
        ret = gpio_direction_output(pdata->hub_host2_5V_rest_gpio,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input hub_host2_5V_rest_gpio set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
  
 | 
    //hub_hos3_5V_gpio  
 | 
    ret = of_get_named_gpio_flags(node, "hub_host3_5v_gpio", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property hub_host3_5v_gpio\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->hub_host3_5v_gpio = ret;  
 | 
        gpio_free(ret);  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->hub_host3_5v_gpio, "hub_host3_5v_gpio");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request hub_host3_5v_gpio request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->hub_host3_5v_gpio,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input hub_host3_5v_gpio set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
  
 | 
    //hub_host3_5V_rest_gpio  
 | 
    ret = of_get_named_gpio_flags(node, "hub_host3_5V_rest_gpio", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property hub_host3_5V_rest_gpio\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->hub_host3_5V_rest_gpio = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->hub_host3_5V_rest_gpio, "hub_host3_5V_rest_gpio");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request hub_host3_5V_rest_gpio request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->hub_host3_5V_rest_gpio,0);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input hub_host3_5V_rest_gpio set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
        msleep(800);  
 | 
        ret = gpio_direction_output(pdata->hub_host3_5V_rest_gpio,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input hub_host3_5V_rest_gpio set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
  
 | 
    //wake_4g_gpio  
 | 
       ret = of_get_named_gpio_flags(node, "wake_4g_gpio", 0, &flags);  
 | 
       if (ret < 0) {  
 | 
               printk("%s() Can not read property wake_4g_gpio\n", __FUNCTION__);  
 | 
       } else {  
 | 
               pdata->wake_4g_gpio = ret;  
 | 
  
 | 
               ret = devm_gpio_request(&pdev->dev, pdata->wake_4g_gpio, "wake_4g_gpio");  
 | 
               if(ret < 0){  
 | 
                       printk("%s() devm_gpio_request wake_4g_gpio request ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
               ret = gpio_direction_output(pdata->wake_4g_gpio,0);  
 | 
               if(ret < 0){  
 | 
                       printk("%s() gpio_direction_input wake_4g_gpio set ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
       }  
 | 
  
 | 
#if 0  
 | 
       //reset_4g_gpio  
 | 
       ret = of_get_named_gpio_flags(node, "reset_4g_gpio", 0, &flags);  
 | 
       if (ret < 0) {  
 | 
               printk("%s() Can not read property reset_4g_gpio\n", __FUNCTION__);  
 | 
       } else {  
 | 
               pdata->reset_4g_gpio = ret;  
 | 
  
 | 
               ret = devm_gpio_request(&pdev->dev, pdata->reset_4g_gpio, "reset_4g_gpio");  
 | 
               if(ret < 0){  
 | 
                       printk("%s() devm_gpio_request reset_4g_gpio request ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
               ret = gpio_direction_output(pdata->reset_4g_gpio,0);  
 | 
               if(ret < 0){  
 | 
                       printk("%s() gpio_direction_input reset_4g_gpio set ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
       }  
 | 
  
 | 
       //en_4g_gpio  
 | 
       ret = of_get_named_gpio_flags(node, "en_4g_gpio", 0, &flags);  
 | 
       if (ret < 0) {  
 | 
               printk("%s() Can not read property en_4g_gpio\n", __FUNCTION__);  
 | 
       } else {  
 | 
               pdata->en_4g_gpio = ret;  
 | 
  
 | 
               ret = devm_gpio_request(&pdev->dev, pdata->en_4g_gpio, "en_4g_gpio");  
 | 
               if(ret < 0){  
 | 
                       printk("%s() devm_gpio_request en_4g_gpio request ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
               ret = gpio_direction_output(pdata->en_4g_gpio,1);  
 | 
               if(ret < 0){  
 | 
                       printk("%s() gpio_direction_input en_4g_gpio set ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
       }  
 | 
  
 | 
  
 | 
       //air_mode_4g_gpio  
 | 
       ret = of_get_named_gpio_flags(node, "air_mode_4g_gpio", 0, &flags);  
 | 
       if (ret < 0) {  
 | 
               printk("%s() Can not read property air_mode_4g_gpio\n", __FUNCTION__);  
 | 
       } else {  
 | 
               pdata->air_mode_4g_gpio = ret;  
 | 
  
 | 
               ret = devm_gpio_request(&pdev->dev, pdata->air_mode_4g_gpio, "air_mode_4g_gpio");  
 | 
               if(ret < 0){  
 | 
                       printk("%s() devm_gpio_request air_mode_4g_gpio request ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
               ret = gpio_direction_output(pdata->air_mode_4g_gpio,0);  
 | 
               if(ret < 0){  
 | 
                       printk("%s() gpio_direction_input air_mode_4g_gpio set ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
       }  
 | 
  
 | 
#endif        
 | 
/*  
 | 
    //edp_power_supply_gpio;  
 | 
    ret = of_get_named_gpio_flags(node, "edp_power_supply_gpio", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_power_supply_gpio\n", __FUNCTION__);  
 | 
    } else {  
 | 
        pdata->edp_power_supply_gpio = ret;  
 | 
  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->edp_power_supply_gpio, "edp_power_supply_gpio");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request edp_power_supply_gpio request ERROR\n", __FUNCTION__);  
 | 
        }  
 | 
          
 | 
        ret = gpio_direction_output(pdata->edp_power_supply_gpio,1);  
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input edp_power_supply_gpio set ERROR\n", __FUNCTION__);  
 | 
        }  
 | 
    }  
 | 
*/      
 | 
   //edp_enable-gpio;  
 | 
#if 0  
 | 
    ret = of_get_named_gpio_flags(node, "edp_enable_gpio", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_enable_gpio\n", __FUNCTION__);  
 | 
    } else {  
 | 
        pdata->edp_enable_gpio = ret;  
 | 
  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->edp_enable_gpio, "edp_enable_gpio");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request edp_enable_gpio request ERROR\n", __FUNCTION__);  
 | 
        }  
 | 
          
 | 
        ret = gpio_direction_output(pdata->edp_enable_gpio,1);  
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input edp_enable_gpio set ERROR\n", __FUNCTION__);  
 | 
        }  
 | 
    }   
 | 
    
 | 
#endif  
 | 
   //ch342_enable-gpio;  
 | 
    ret = of_get_named_gpio_flags(node, "ch342_power", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property ch342_gpio\n", __FUNCTION__);  
 | 
    } else {  
 | 
        pdata->ch342_power = ret;  
 | 
  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->ch342_power, "ch342_power");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request ch342_power request ERROR\n", __FUNCTION__);  
 | 
        }  
 | 
          
 | 
        ret = gpio_direction_output(pdata->ch342_power,1);  
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input ch342_power set ERROR\n", __FUNCTION__);  
 | 
        }  
 | 
    }     
 | 
  
 | 
  
 | 
        //edp_set_pixel-s  
 | 
         ret = of_get_named_gpio_flags(node, "edp_reset", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_reset\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    reset_pin = ret;  
 | 
  
 | 
       // ch342_reset  
 | 
       ret = of_get_named_gpio_flags(node, "ch342_reset", 0, &flags);  
 | 
       if (ret < 0) {  
 | 
               printk("%s() Can not read property ch342_reset\n", __FUNCTION__);  
 | 
       } else {  
 | 
               pdata->reset_ch342_gpio = ret;  
 | 
  
 | 
               ret = devm_gpio_request(&pdev->dev, pdata->reset_ch342_gpio, "ch342_reset");  
 | 
               if(ret < 0){  
 | 
                       printk("%s() devm_gpio_request ch342_reset request ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
               ret = gpio_direction_output(pdata->reset_ch342_gpio,1);  
 | 
               if(ret < 0){  
 | 
                       printk("%s() gpio_direction_output ch342_reset set ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
//             ch342_reset = ret;  
 | 
       }  
 | 
  
 | 
  
 | 
// enable lvds  
 | 
     ret = of_get_named_gpio_flags(node, "edp_gpio0", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_gpio0\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
     gpio0 = ret;  
 | 
  
 | 
  
 | 
  
 | 
    ret = of_get_named_gpio_flags(node, "edp_gpio1", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_gpio1\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
        gpio1 = ret;  
 | 
  
 | 
    ret = of_get_named_gpio_flags(node, "edp_gpio2", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_gpio2\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    gpio2 = ret;  
 | 
  
 | 
    ret = of_get_named_gpio_flags(node, "edp_gpio3", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_gpio3\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    gpio3 = ret;  
 | 
  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, reset_pin, "edp_reset");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_reset request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
  
 | 
    ret = devm_gpio_request(&pdev->dev, gpio0, "edp_gpio0");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_gpio0 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    ret = devm_gpio_request(&pdev->dev, gpio1, "edp_gpio1");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_gpio1 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    ret = devm_gpio_request(&pdev->dev, gpio2, "edp_gpio2");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_gpio2 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    ret = devm_gpio_request(&pdev->dev, gpio3, "edp_gpio3");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_gpio3 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
      
 | 
       ret = of_property_read_u32(node, "nodka_lvds", &lvds_index);  
 | 
        if (ret < 0){  
 | 
                printk("%s() Can not read property nodka_lvds\n", __FUNCTION__);  
 | 
        }  
 | 
  
 | 
        printk("nodka_lvds_index = %d\n",lvds_index);  
 | 
  
 | 
        while ( i < 4 ){  
 | 
                if ( lvds_index > 0)  
 | 
                        lvds_gpio[i] = lvds_index%2;  
 | 
                else  
 | 
                        lvds_gpio[i] = 0;  
 | 
                printk("lvds_gpio[%d]=%d\n",i,lvds_gpio[i]);  
 | 
                lvds_index = lvds_index/2;  
 | 
                i++;  
 | 
        }  
 | 
  
 | 
    gpio_direction_output(reset_pin, 0);  
 | 
    usleep_range(80000, 100000);  
 | 
    gpio_direction_output(reset_pin, 1);  
 | 
    usleep_range(80000, 100000);  
 | 
  
 | 
//    gpio_direction_output(ch342_reset, 0);  
 | 
//   usleep_range(80000, 100000);  
 | 
//    gpio_direction_output(ch342_reset, 1);  
 | 
//    usleep_range(80000, 100000);  
 | 
  
 | 
/*  
 | 
      //gpio_op0  
 | 
         ret = of_get_named_gpio_flags(node, "gpio_op0", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_op0\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_op0 = ret;  
 | 
  
 | 
         ret = devm_gpio_request(&pdev->dev, pdata->gpio_op0, "gpio_op0");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_op0 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    gpio_direction_output(pdata->gpio_op0, 1);  
 | 
*/  
 | 
      
 | 
    gpio_direction_output(gpio0, lvds_gpio[0]);  
 | 
    gpio_direction_output(gpio1, lvds_gpio[1]);  
 | 
    gpio_direction_output(gpio2, lvds_gpio[2]);  
 | 
    gpio_direction_output(gpio3, lvds_gpio[3]);  
 | 
      
 | 
    printk(" #######nk_io_control_probe end####### \n");  
 | 
    return 0;  
 | 
      
 | 
err:  
 | 
    kfree(pdata);  
 | 
    return ret;      
 | 
}      
 | 
  
 | 
//6 in 6 out-e  
 | 
#if 0   
 | 
static int nk_io_control_probe1(struct platform_device *pdev)  
 | 
{  
 | 
    struct device_node *node = pdev->dev.of_node;  
 | 
    struct nk_io_pdata *pdata;  
 | 
    int ret;  
 | 
    int gpio0, gpio1, gpio2, gpio3, reset_pin;  
 | 
    enum of_gpio_flags flags;  
 | 
    printk(" #######nk_io_control_probe####### \n");  
 | 
    //enable = 0 ;  
 | 
  
 | 
  
 | 
//    ret = gpio_direction_output(74,0);   
 | 
//    if(ret < 0){  
 | 
//        printk("fuwei %s() gpio_direction_input vcc_12v_io set ERROR\n", __FUNCTION__);  
 | 
//        goto err;  
 | 
//    }  
 | 
  
 | 
  
 | 
    pdata = kzalloc(sizeof(struct nk_io_pdata), GFP_KERNEL);  
 | 
    if (pdata == NULL) {  
 | 
        printk("%s failed to allocate driver data\n",__FUNCTION__);  
 | 
        return -ENOMEM;  
 | 
    }  
 | 
    memset(pdata,0,sizeof(struct nk_io_pdata));  
 | 
  
 | 
  
 | 
    //edp_set_pixel-s  
 | 
     ret = of_get_named_gpio_flags(node, "edp_reset", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_reset\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    reset_pin = ret;  
 | 
  
 | 
    ret = of_get_named_gpio_flags(node, "edp_gpio0", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_gpio0\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }   
 | 
  
 | 
    gpio0 = ret;  
 | 
  
 | 
    ret = of_get_named_gpio_flags(node, "edp_gpio1", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_gpio1\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    gpio1 = ret;  
 | 
  
 | 
    ret = of_get_named_gpio_flags(node, "edp_gpio2", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_gpio2\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    gpio2 = ret;  
 | 
  
 | 
    ret = of_get_named_gpio_flags(node, "edp_gpio3", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_gpio3\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    gpio3 = ret;  
 | 
  
 | 
    ret = devm_gpio_request(&pdev->dev, reset_pin, "edp_reset");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_reset request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    ret = devm_gpio_request(&pdev->dev, gpio0, "edp_gpio0");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_gpio0 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    ret = devm_gpio_request(&pdev->dev, gpio1, "edp_gpio1");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_gpio1 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    ret = devm_gpio_request(&pdev->dev, gpio2, "edp_gpio2");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_gpio2 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    ret = devm_gpio_request(&pdev->dev, gpio3, "edp_gpio3");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request edp_gpio3 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    gpio_direction_output(reset_pin, 0);   
 | 
    usleep_range(80000, 100000);  
 | 
    gpio_direction_output(reset_pin, 1);   
 | 
    usleep_range(80000, 100000);  
 | 
  
 | 
    gpio_direction_output(gpio0, 0);   
 | 
    gpio_direction_output(gpio1, 1);   
 | 
    gpio_direction_output(gpio2, 1);   
 | 
    gpio_direction_output(gpio3, 0);   
 | 
    printk("edp set pixels success.\r\n");  
 | 
  
 | 
    //edp_set_pixel-e  
 | 
  
 | 
    //6 in 6 out-s      
 | 
    //gpio_op0  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_op0", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_op0\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_op0 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_op0, "gpio_op0");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_op0 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
  
 | 
    //gpio_op1  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_op1", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_op1\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_op1 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_op1, "gpio_op1");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_op1 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
  
 | 
    //gpio_op2  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_op2", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_op2\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_op2 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_op2, "gpio_op2");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_op2 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
  
 | 
  
 | 
    //gpio_op3  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_op3", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_op3\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_op3 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_op3, "gpio_op3");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_op3 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    //gpio_op4  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_op4", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_op4\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_op4 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_op4, "gpio_op4");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_op4 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    //gpio_op5  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_op5", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_op5\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_op5 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_op5, "gpio_op5");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_op5 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
      
 | 
  
 | 
    //d4 low  
 | 
    gpio_direction_output(pdata->gpio_op0, 1);  
 | 
    gpio_direction_output(pdata->gpio_op1, 1);  
 | 
    gpio_direction_output(pdata->gpio_op2, 1);  
 | 
    gpio_direction_output(pdata->gpio_op3, 1);  
 | 
    gpio_direction_output(pdata->gpio_op4, 1);  
 | 
    gpio_direction_output(pdata->gpio_op5, 1);  
 | 
  
 | 
      
 | 
  
 | 
  
 | 
  
 | 
    //gpio_ip0  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_ip0", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_ip0\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_ip0 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_ip0, "gpio_ip0");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_ip0 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    //gpio_ip1  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_ip1", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_ip1\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_ip1 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_ip1, "gpio_ip1");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_ip1 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    //gpio_ip2  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_ip2", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_ip2\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_ip2 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_ip2, "gpio_ip2");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_ip2 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    //gpio_ip3  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_ip3", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_ip3\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_ip3 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_ip3, "gpio_ip3");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_ip3 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    //gpio_ip4  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_ip4", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_ip4\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_ip4 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_ip4, "gpio_ip4");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_ip4 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    //gpio_ip5  
 | 
     ret = of_get_named_gpio_flags(node, "gpio_ip5", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property gpio_ip5\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    pdata->gpio_ip5 = ret;  
 | 
  
 | 
     ret = devm_gpio_request(&pdev->dev, pdata->gpio_ip5, "gpio_ip3");  
 | 
    if(ret < 0){  
 | 
        printk("%s() devm_gpio_request gpio_ip5 request ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
  
 | 
    //d4 low  
 | 
    gpio_direction_input(pdata->gpio_ip0);  
 | 
    gpio_direction_input(pdata->gpio_ip1);  
 | 
    gpio_direction_input(pdata->gpio_ip2);  
 | 
    gpio_direction_input(pdata->gpio_ip3);  
 | 
    gpio_direction_input(pdata->gpio_ip4);  
 | 
    gpio_direction_input(pdata->gpio_ip5);  
 | 
  
 | 
  
 | 
    //6 in 6 out-e  
 | 
  
 | 
  
 | 
       //wake_4g_gpio  
 | 
       ret = of_get_named_gpio_flags(node, "wake_4g_gpio", 0, &flags);  
 | 
       if (ret < 0) {  
 | 
               printk("%s() Can not read property wake_4g_gpio\n", __FUNCTION__);  
 | 
       } else {  
 | 
               pdata->wake_4g_gpio = ret;  
 | 
  
 | 
               ret = devm_gpio_request(&pdev->dev, pdata->wake_4g_gpio, "wake_4g_gpio");  
 | 
               if(ret < 0){  
 | 
                       printk("%s() devm_gpio_request wake_4g_gpio request ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
               ret = gpio_direction_output(pdata->wake_4g_gpio,0);  
 | 
               if(ret < 0){  
 | 
                       printk("%s() gpio_direction_input wake_4g_gpio set ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
       }  
 | 
  
 | 
  
 | 
       //reset_4g_gpio  
 | 
       ret = of_get_named_gpio_flags(node, "reset_4g_gpio", 0, &flags);  
 | 
       if (ret < 0) {  
 | 
               printk("%s() Can not read property reset_4g_gpio\n", __FUNCTION__);  
 | 
       } else {  
 | 
               pdata->reset_4g_gpio = ret;  
 | 
  
 | 
               ret = devm_gpio_request(&pdev->dev, pdata->reset_4g_gpio, "reset_4g_gpio");  
 | 
               if(ret < 0){  
 | 
                       printk("%s() devm_gpio_request reset_4g_gpio request ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
               ret = gpio_direction_output(pdata->reset_4g_gpio,0);  
 | 
               if(ret < 0){  
 | 
                       printk("%s() gpio_direction_input reset_4g_gpio set ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
       }  
 | 
  
 | 
       //en_4g_gpio  
 | 
       ret = of_get_named_gpio_flags(node, "en_4g_gpio", 0, &flags);  
 | 
       if (ret < 0) {  
 | 
               printk("%s() Can not read property en_4g_gpio\n", __FUNCTION__);  
 | 
       } else {  
 | 
               pdata->en_4g_gpio = ret;  
 | 
  
 | 
               ret = devm_gpio_request(&pdev->dev, pdata->en_4g_gpio, "en_4g_gpio");  
 | 
               if(ret < 0){  
 | 
                       printk("%s() devm_gpio_request en_4g_gpio request ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
               ret = gpio_direction_output(pdata->en_4g_gpio,1);  
 | 
               if(ret < 0){  
 | 
                       printk("%s() gpio_direction_input en_4g_gpio set ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
       }  
 | 
  
 | 
  
 | 
       //air_mode_4g_gpio  
 | 
       ret = of_get_named_gpio_flags(node, "air_mode_4g_gpio", 0, &flags);  
 | 
       if (ret < 0) {  
 | 
               printk("%s() Can not read property air_mode_4g_gpio\n", __FUNCTION__);  
 | 
       } else {  
 | 
               pdata->air_mode_4g_gpio = ret;  
 | 
  
 | 
               ret = devm_gpio_request(&pdev->dev, pdata->air_mode_4g_gpio, "air_mode_4g_gpio");  
 | 
               if(ret < 0){  
 | 
                       printk("%s() devm_gpio_request air_mode_4g_gpio request ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
               ret = gpio_direction_output(pdata->air_mode_4g_gpio,0);  
 | 
               if(ret < 0){  
 | 
                       printk("%s() gpio_direction_input air_mode_4g_gpio set ERROR\n", __FUNCTION__);  
 | 
               }  
 | 
       }  
 | 
  
 | 
  
 | 
         
 | 
      
 | 
  
 | 
    //mic_switch_gpio  
 | 
        ret = of_get_named_gpio_flags(node, "mic_switch_gpio", 0, &flags);  
 | 
        if (ret < 0) {  
 | 
                printk("%s() Can not read property mic_switch_gpio\n", __FUNCTION__);  
 | 
                goto err;  
 | 
        } else {  
 | 
                pdata->mic_switch_gpio = ret;  
 | 
                ret = devm_gpio_request(&pdev->dev, pdata->mic_switch_gpio, "mic_switch_gpio");  
 | 
                if(ret < 0){  
 | 
                        printk("%s() devm_gpio_request mic_switch_gpio request ERROR\n", __FUNCTION__);  
 | 
                        goto err;  
 | 
                }  
 | 
                ret = gpio_direction_output(pdata->mic_switch_gpio,0);   
 | 
                mic_enable = 0;  
 | 
                if(ret < 0){  
 | 
                printk("%s() gpio_direction_input mic_switch_gpio set ERROR\n", __FUNCTION__);  
 | 
                goto err;  
 | 
        }  
 | 
                }  
 | 
#if 0  
 | 
    //vcc_5v_io  
 | 
    ret = of_get_named_gpio_flags(node, "vcc_5v_io", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property vcc_5v_io\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->vcc_5v_io = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->vcc_5v_io, "vcc_5v_io");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request vcc_5v_io request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->vcc_5v_io,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input vcc_5v_io set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
#endif  
 | 
    //vcc_3.3v_io  
 | 
    ret = of_get_named_gpio_flags(node, "vcc_3_3v_io", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property vcc_3_3v_io\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->vcc_3_3v_io = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->vcc_3_3v_io, "vcc_3_3v_io");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request vcc_3_3v_io request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->vcc_3_3v_io,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input vcc_3_3v_io set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
  
 | 
        //vcc_12v_io  
 | 
    ret = of_get_named_gpio_flags(node, "vcc_12v_io", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property vcc_12v_io\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->vcc_12v_io = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->vcc_12v_io, "vcc_12v_io");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request vcc_12v_io request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->vcc_12v_io,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input vcc_12v_io set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
      
 | 
        //hub_5V_gpio  
 | 
    ret = of_get_named_gpio_flags(node, "hub_5V_gpio", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property hub_5V_gpio\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
          
 | 
        pdata->hub_5V_gpio = ret;  
 | 
        gpio_free(ret);  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->hub_5V_gpio, "hub_5V_gpio");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request hub_5V_gpio request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->hub_5V_gpio,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input hub_5V_gpio set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
  
 | 
  
 | 
    //hub_5V_rest_gpio  
 | 
    ret = of_get_named_gpio_flags(node, "hub_5V_rest_gpio", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property hub_5V_rest_gpio\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->hub_5V_rest_gpio = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->hub_5V_rest_gpio, "hub_5V_rest_gpio");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request hub_5V_rest_gpio request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(pdata->hub_5V_rest_gpio,0);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input hub_5V_rest_gpio set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
        msleep(800);  
 | 
        ret = gpio_direction_output(pdata->hub_5V_rest_gpio,1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input hub_5V_rest_gpio set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
      
 | 
        //audio_switch_gpio  
 | 
    ret = of_get_named_gpio_flags(node, "audio_switch_gpio", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property audio_switch_gpio\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        pdata->audio_switch_gpio = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, pdata->audio_switch_gpio, "audio_switch_gpio");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request audio_switch_gpio request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
            ret = gpio_direction_output(pdata->audio_switch_gpio, !flags);   
 | 
        if(ret < 0){  
 | 
        printk("%s() gpio_direction_input audio_switch_gpio set ERROR\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    }  
 | 
        }  
 | 
  
 | 
    //led_ctl  
 | 
        ret = of_get_named_gpio_flags(node, "led_ctl", 0, &flags);  
 | 
        if (ret < 0) {  
 | 
            printk("%s() Can not read property usb_5v_gpio\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        } else {  
 | 
            pdata->led_gpio = ret;  
 | 
            ret = devm_gpio_request(&pdev->dev, pdata->led_gpio, "led_ctl");  
 | 
            if(ret < 0){  
 | 
                printk("%s() devm_gpio_request led_gpio request ERROR\n", __FUNCTION__);  
 | 
                goto err;  
 | 
            }  
 | 
      
 | 
            ret = gpio_direction_output(pdata->led_gpio,0);   
 | 
            if(ret < 0){  
 | 
                printk("%s() gpio_direction_input led_gpio set ERROR\n", __FUNCTION__);  
 | 
                goto err;  
 | 
            }  
 | 
        }  
 | 
          
 | 
             
 | 
  
 | 
    printk("edp_bl_on ....\r\n");   
 | 
    ret = of_get_named_gpio_flags(node, "edp_bl_on", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_bl_on\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        int gpio = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, gpio, "edp_bl_on");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request edp_b1_on request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(gpio, !flags);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input edp_bl_on set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
    printk("edp_bl_on ....ok!\r\n");   
 | 
  
 | 
    printk("edp_bl_en ....\r\n");   
 | 
    ret = of_get_named_gpio_flags(node, "edp_bl_en", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property edp_bl_en\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        int gpio = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, gpio, "edp_bl_en");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request edp_bl_en  request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
        ret = gpio_direction_output(gpio, !flags);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input edp_bl_en set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
    printk("edp_bl_en ....ok!\r\n");   
 | 
  
 | 
    printk("fan_io_en ....\r\n");   
 | 
    ret = of_get_named_gpio_flags(node, "fan_io_en", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property fan_io_en\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        int gpio = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, gpio, "fan_io_en");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request fan_io_en request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(gpio, !flags);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input fan_io_en set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
    printk("fan_io_en ....ok!\r\n");   
 | 
  
 | 
  
 | 
    //pcie_wakeup for ap6256 BT_wake  
 | 
    /* Rfkill-bt.c bt driver config and set this pin already  
 | 
    printk("pcie_wakeup ....\r\n");   
 | 
  
 | 
    ret = of_get_named_gpio_flags(node, "pcie_wakeup", 0, &flags);  
 | 
    if (ret < 0) {  
 | 
        printk("%s() Can not read property pcie_wakeup\n", __FUNCTION__);  
 | 
        goto err;  
 | 
    } else {  
 | 
        int gpio = ret;  
 | 
        ret = devm_gpio_request(&pdev->dev, gpio, "pcie_wakeup");  
 | 
        if(ret < 0){  
 | 
            printk("%s() devm_gpio_request pcie_wakeup request ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
  
 | 
        ret = gpio_direction_output(gpio, 1);   
 | 
        if(ret < 0){  
 | 
            printk("%s() gpio_direction_input pcie_wakeup set ERROR\n", __FUNCTION__);  
 | 
            goto err;  
 | 
        }  
 | 
    }  
 | 
    printk("pcie_wakeup ....ok!\r\n");   
 | 
    */  
 | 
  
 | 
  
 | 
    nk_class = class_create(THIS_MODULE, "io_control");  
 | 
#if 0  
 | 
    ret = class_create_file(nk_class, &class_attr_en_4g_gpio);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat en_4g_gpio class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control en_4g_gpio OK !!!!\n");  
 | 
      
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_op0);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_op0 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_op0 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_op1);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_op1 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_op1 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_op2);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_op2 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_op2 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_op3);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_op3 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_op3 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_op4);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_op4 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_op4 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_op5);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_op5 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_op5 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_ip0);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_ip0 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_ip0 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_ip1);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_ip1 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_ip1 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_ip2);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_ip2 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_ip2 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_ip3);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_ip3 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_ip3 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_ip4);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_ip4 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_ip4 OK !!!!\n");  
 | 
  
 | 
    ret = class_create_file(nk_class, &class_attr_gpio_ip5);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat gpio_ip5 class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create io_control gpio_ip5 OK !!!!\n");  
 | 
      
 | 
    ret = class_create_file(nk_class, &class_attr_led_display);  
 | 
    if (ret) {  
 | 
        printk(KERN_ERR "%s:Fail to creat led_display class file\n", __func__);  
 | 
        return ret;  
 | 
    }else  
 | 
    printk("class_create nk_io_control led OK !!!!\n");      
 | 
  
 | 
   ret = class_create_file(nk_class, &class_attr_mic_switch);  
 | 
   if (ret) {  
 | 
           printk(KERN_ERR "%s:Fail to creat mic_switch class file\n", __func__);  
 | 
           return ret;  
 | 
   }else  
 | 
   printk("class_create nk_io_control mic OK !!!!\n");      
 | 
#endif  
 | 
             
 | 
    NKpdata_info = pdata;  
 | 
  
 | 
    printk(" #######nk_io_control_probe end####### \n");  
 | 
    return 0;  
 | 
err:  
 | 
    kfree(pdata);  
 | 
    return ret;  
 | 
}  
 | 
#endif  
 | 
  
 | 
static int nk_io_control_remove(struct platform_device *pdev)  
 | 
{  
 | 
    if(NKpdata_info)  
 | 
        kfree(NKpdata_info);  
 | 
    return 0;  
 | 
}  
 | 
  
 | 
static int nk_io_control_suspend(struct platform_device *pdev, pm_message_t state)  
 | 
{  
 | 
    printk("LED_early_suspend LED_early_suspend LED_early_suspend !!!!\n");  
 | 
  
 | 
    //enable = 0;  
 | 
    //LED_SET(0);  
 | 
    return 0;  
 | 
}  
 | 
  
 | 
static int nk_io_control_resume(struct platform_device *pdev)  
 | 
{  
 | 
    int ret,reset_pin;  
 | 
    printk("nk_io resume !!!!\n");  
 | 
    ret = gpio_get_value(120);  
 | 
    printk("edp_reset gpio value : %d\n",ret);  
 | 
  
 | 
        usleep_range(80000, 100000);  
 | 
    gpio_set_value(120,0);  
 | 
//        gpio_direction_output(120, 0);  
 | 
        usleep_range(80000, 100000);  
 | 
    ret = gpio_get_value(120);  
 | 
    printk("edp_reset gpio value : %d\n",ret);  
 | 
//        gpio_direction_output(120, 1);  
 | 
    gpio_set_value(120,1);  
 | 
        usleep_range(80000, 100000);  
 | 
    ret = gpio_get_value(120);  
 | 
    printk("edp_reset gpio value : %d\n",ret);  
 | 
  
 | 
    //enable = 1;  
 | 
        //LED_SET(11);  
 | 
    return 0;  
 | 
}  
 | 
  
 | 
static const struct of_device_id nk_io_control_of_match[] = {  
 | 
        { .compatible = "nk_io_control", },  
 | 
        {},  
 | 
};  
 | 
MODULE_DEVICE_TABLE(of, nk_io_control_of_match);  
 | 
  
 | 
static struct platform_driver nk_io_control_driver = {  
 | 
    .probe    = nk_io_control_probe,  
 | 
    .remove = nk_io_control_remove,  
 | 
    .resume =     nk_io_control_resume,      
 | 
    .suspend =     nk_io_control_suspend,      
 | 
    .driver    = {  
 | 
        .name    = "nk_io_control",  
 | 
        .owner    = THIS_MODULE,  
 | 
        .of_match_table = of_match_ptr(nk_io_control_of_match),          
 | 
    },  
 | 
};  
 | 
  
 | 
static int __init nk_io_control_init(void)  
 | 
{  
 | 
    platform_driver_register(&nk_io_control_driver);  
 | 
    return 0;  
 | 
}  
 | 
  
 | 
static void __exit nk_io_control_exit(void)  
 | 
{  
 | 
    platform_driver_unregister(&nk_io_control_driver);  
 | 
}  
 | 
  
 | 
subsys_initcall(nk_io_control_init);  
 | 
  
 | 
//late_initcall(nk_io_control_init);  
 | 
MODULE_DESCRIPTION("nk io Core Driver");  
 | 
MODULE_LICENSE("GPL");  
 |