diff --git a/mbtk/libgsw_lib/gsw_gpio.c b/mbtk/libgsw_lib/gsw_gpio.c
new file mode 100755
index 0000000..9bd8a79
--- /dev/null
+++ b/mbtk/libgsw_lib/gsw_gpio.c
@@ -0,0 +1,379 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "gsw_gpio.h"
+
+#ifndef LOG_ERR_LEVEL
+#define LOG_ERR_LEVEL  3      /* error conditions */
+#endif
+#ifndef LOG_WARN_LEVEL
+#define LOG_WARN_LEVEL 4   /* warning conditions */
+#endif
+#ifndef LOG_INFO_LEVEL
+#define LOG_INFO_LEVEL 6      /* informational */
+#endif
+#ifndef LOG_DEBUG_LEVEL
+#define LOG_DEBUG_LEVEL 7     /* debug-level messages */
+#endif
+#ifndef LOG_VERBOSE_LEVEL
+#define LOG_VERBOSE_LEVEL 8
+#endif
+
+#define LOGV(fmt, args ...) \
+    do{ \
+        char *file_ptr_1001 = __FILE__; \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
+        char line_1001[10] = {0}; \
+        sprintf(line_1001, "%d", __LINE__); \
+        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
+            if(*ptr_1001 == '/') \
+                 break; \
+            ptr_1001--; \
+        } \
+        fun_ptr_log(LOG_VERBOSE_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while(0)
+
+#define LOGI(fmt, args...) \
+    do{ \
+        char *file_ptr_1001 = __FILE__; \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
+        char line_1001[10] = {0}; \
+        sprintf(line_1001, "%d", __LINE__); \
+        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
+            if(*ptr_1001 == '/') \
+                 break; \
+            ptr_1001--; \
+        } \
+        fun_ptr_log(LOG_INFO_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while(0)
+
+#define LOGD(fmt, args...) \
+    do{ \
+        char *file_ptr_1001 = __FILE__; \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
+        char line_1001[10] = {0}; \
+        sprintf(line_1001, "%d", __LINE__); \
+        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
+            if(*ptr_1001 == '/') \
+                 break; \
+            ptr_1001--; \
+        } \
+        fun_ptr_log(LOG_DEBUG_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while(0)
+
+#define LOGW(fmt, args...) \
+    do{ \
+        char *file_ptr_1001 = __FILE__; \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
+        char line_1001[10] = {0}; \
+        sprintf(line_1001, "%d", __LINE__); \
+        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
+            if(*ptr_1001 == '/') \
+                 break; \
+            ptr_1001--; \
+        } \
+        fun_ptr_log(LOG_WARN_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while(0)
+
+#define LOGE(fmt, args...) \
+    do{ \
+        char *file_ptr_1001 = __FILE__; \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
+        char line_1001[10] = {0}; \
+        sprintf(line_1001, "%d", __LINE__); \
+        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
+            if(*ptr_1001 == '/') \
+                 break; \
+            ptr_1001--; \
+        } \
+        fun_ptr_log(LOG_ERR_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while(0)
+    
+
+#define GSW_HAL_SUCCESS 0
+#define GSW_HAL_FAIL -1	//表示失败(通用性)
+#define GSW_HAL_MEM_INVAILD -2 //表示入参地址为NULL
+
+#define wakeout 117
+
+typedef void (*mbtk_log)(int level, const char *format,...);
+static mbtk_log fun_ptr_log = NULL;
+void *dlHandle_gpio = NULL;
+char *lynqLib_gpio = "/lib/libmbtk_lib.so";
+
+int gpio_check(int gpio)
+{
+    char buffer[128];
+    memset(buffer,0,128);
+    sprintf(buffer,"/sys/class/gpio/gpio%d/direction", gpio);
+    return access(buffer , F_OK);
+}
+
+static int handle()
+{
+    if(dlHandle_gpio == NULL || fun_ptr_log == NULL)
+    {
+        dlHandle_gpio = dlopen(lynqLib_gpio, RTLD_NOW);
+        fun_ptr_log = (mbtk_log)dlsym(dlHandle_gpio, "mbtk_log");
+        if(fun_ptr_log == NULL || dlHandle_gpio == NULL)
+        {
+            return GSW_HAL_FAIL;
+        }
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+static int gpio_export(int gpio)
+{
+    int file=-1;
+    int result =-1;
+    char pin_index_buffer[5]= {0};
+
+    if (gpio_check(gpio) == 0)
+    {
+        LOGE("export has been add\n");
+        return 0;
+    }
+
+    file = open("/sys/class/gpio/export",O_WRONLY);
+    if(file == -1)
+    {
+        LOGE("Open gpio export file fail.");
+        return -1;
+    }
+
+    memset(pin_index_buffer,0,5);
+    sprintf(pin_index_buffer,"%d", gpio);
+    result = write(file,pin_index_buffer,strlen(pin_index_buffer));
+    if(result < 0)
+    {
+        LOGE("Gpio[%d] export fail.", gpio);
+        close(file);
+        return -1;
+    }
+    close(file);
+
+    return 0;
+}
+
+static int gpio_unexport(int gpio)
+{
+    int file=-1;
+    int result =-1;
+    char pin_index_buffer[5]= {0};
+    if (gpio_check(gpio) == -1)
+    {
+        LOGE("export has been not add\n");
+        return -1;
+    }
+
+    file = open("/sys/class/gpio/unexport",O_WRONLY);
+    if(file == -1)
+    {
+        LOGE("Open gpio unexport file fail.");
+        return -1;
+    }
+
+    memset(pin_index_buffer,0,5);
+    sprintf(pin_index_buffer,"%d", gpio);
+    result=write(file,pin_index_buffer,strlen(pin_index_buffer));
+    if(result < 0)
+    {
+        close(file);
+        LOGE("Gpio[%d] unexport fail.", gpio);
+        return -1;
+    }
+    close(file);
+
+    return 0;
+}
+
+int32_t gsw_gpio_SetDirection(uint32_t gpioNum, gsw_hal_pinDirection dir)
+{
+    char buffer[128]= {0};
+    int file =-1;
+    int result =-1;
+    char direction[10] = {0};
+    memset(buffer,0,128);
+    if (handle())
+        return GSW_HAL_FAIL;
+    
+    if (gpio_check(gpioNum) == -1)
+    {
+        LOGD("in dir export has been not add\n");
+        gpio_export(gpioNum);
+    }
+
+
+    sprintf(buffer,"/sys/class/gpio/gpio%u/direction", gpioNum);
+    file = open(buffer, O_WRONLY);
+    if(file == -1)
+    {
+        LOGE("Open gpio[%d] direct fail.", gpioNum);
+        return -1;
+    }
+    if (dir == GSW_HAL_PINDIR_IN)
+        sprintf(direction,"in");
+    else if (dir == GSW_HAL_PINDIR_OUT)
+        sprintf(direction,"out");
+    
+    result = write(file,direction,strlen(direction));
+    if(result != strlen(direction))
+    {
+        LOGE("Set gpio[%d] direct fail.", gpioNum);
+        close(file);
+        gpio_unexport(gpioNum);
+        return GSW_HAL_FAIL;
+    }
+    close(file);
+    gpio_unexport(gpioNum);
+    return GSW_HAL_SUCCESS;
+}
+
+gsw_hal_pinLevel gsw_gpio_GetLevel(uint32_t gpioNum)
+{
+    char buffer[50];
+    char path[128];
+    int file =-1;
+    int result =-1;
+    memset(path,0,128);
+    memset(buffer,0,50);
+    if (handle())
+        return GSW_HAL_FAIL;
+
+    if (gpio_check(gpioNum) == -1)
+    {
+        LOGD("in get value export has been not add\n");
+        gpio_export(gpioNum);
+    }
+    sprintf(path,"/sys/class/gpio/gpio%u/value", gpioNum);
+    file = open(path,O_RDONLY);
+    if(file == -1)
+    {
+        LOGE("Open gpio[%d] fail.", gpioNum);
+        return -1;
+    }
+    result = read(file,buffer,50);
+    if(result <= 0)
+    {
+        LOGE("Get gpio[%d] value fail", gpioNum);
+        close(file);
+        gpio_unexport(gpioNum);
+        return GSW_HAL_FAIL;
+    }
+    close(file);
+    gpio_unexport(gpioNum);
+    return atoi(buffer);
+}
+
+int32_t gsw_gpio_SetLevel(uint32_t gpioNum, gsw_hal_pinLevel level)
+{
+    char buffer[128]= {0};
+    int file =-1;
+    int result =-1;
+    memset(buffer,0,50);
+    if (handle())
+        return GSW_HAL_FAIL;
+
+    if (gpio_check(gpioNum) == -1)
+    {
+        LOGD("in set value export has been not add\n");
+        gpio_export(gpioNum);
+    }
+
+    sprintf(buffer,"/sys/class/gpio/gpio%u/value", gpioNum);
+    file = open(buffer,O_WRONLY);
+    if(file == -1)
+    {
+        LOGE("Open gpio[%d] value fail.", gpioNum);
+        return -1;
+    }
+    if(level == GSW_HAL_LEVEL_LOW) {
+        result = write(file,"0",1);
+    } else {
+        result = write(file,"1",1);
+    }
+    if(result != 1)
+    {
+        LOGE("Set gpio[%d] value fail err =%d.", gpioNum, errno);
+        close(file);
+        gpio_unexport(gpioNum);
+        return GSW_HAL_FAIL;
+    }
+    close(file);
+    gpio_unexport(gpioNum);
+    return GSW_HAL_SUCCESS;
+}
+
+
+int32_t gsw_gpio_Init(uint32_t gpioNum, gsw_hal_pinDirection dir, gsw_hal_pinLevel level, gsw_hal_pinPullSel pullsel)
+{
+    if (handle())
+        return GSW_HAL_FAIL;
+
+    if (dir != 1 && dir != 0)
+    {
+        LOGE("[lynq_gpio_init] direction fail.");
+        return -1;
+    }
+
+    if (level != 1 && level != 0)
+    {
+        LOGE("[lynq_gpio_init] value fail.");
+        return GSW_HAL_FAIL;
+    }
+
+    if(gpio_export(gpioNum))
+    {
+        LOGE("[lynq_gpio_init]gpio_export fail.");
+        return GSW_HAL_FAIL;
+    }
+
+    if(gsw_gpio_SetDirection(gpioNum, dir))
+    {
+        LOGE("[lynq_gpio_init]gpio_direct_set fail.");
+        return GSW_HAL_FAIL;
+    }
+
+    if(dir == 1 && (gsw_gpio_SetLevel(gpioNum, level) != 0))
+    {
+        LOGE("[lynq_gpio_init]gpio_value_set fail.");
+        return GSW_HAL_FAIL;
+    }
+    return GSW_HAL_SUCCESS;
+}
+gsw_hal_usbStatus gsw_hwpin_is_usb_connected(void)
+{
+    FILE *fp;
+    char cmd[128] = {0};
+    char tmp_rsp[20] = {0};
+    //char *CONNECTED = "configured";
+    char *DISCONNECTED = "not attached";
+    if (handle())
+        return GSW_HAL_FAIL;
+
+    sprintf(cmd,"cat /sys/devices/platform/soc/d4200000.axi/c0000000.usb/udc/c0000000.usb/state");
+    fp=popen(cmd, "r");
+    if (fgets(tmp_rsp,sizeof(tmp_rsp),fp) == NULL)
+        LOGE("gsw_hwpin_is_usb_connected fail.");
+    pclose(fp);
+    if (strncmp(tmp_rsp,DISCONNECTED,strlen(DISCONNECTED)) == 0)
+        return GSW_HAL_USB_DISCONNECTED;
+    else
+        return GSW_HAL_USB_CONNECTED;
+}
+
+int32_t gsw_setWakeupLevel(gsw_hal_pinLevel level)
+{
+    if (gsw_gpio_SetLevel(wakeout, level) == GSW_HAL_FAIL)
+    {
+        return GSW_HAL_FAIL;
+    }
+    return GSW_HAL_SUCCESS;
+}
