/** 
 * osddiGio.c
 *
 * Copyright (C) 2011-2018 Fuji Xerox Co.,Ltd. All rights reserved.
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called COPYING.
 */
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <asm-generic/uaccess.h>
#include <linux/semaphore.h>
#include <linux/fxprivate/kernelOsddi.h>
#include <linux/fxprivate/osddi_ioctl.h>
#include "osddiGio.h"
#include "osddiInt.h"
#include "../gio/gioDrv.h"
#include "../gio/gioDrvLm2Gpio.h"
#include "../gio/gioDrvWaikikiCpld.h"
const OSDDI_PORT_TBL osddiPortTbl[] = {
    {OS_GIO_CPLD_VERSION0, CPLD_GIO_CPLDVER_0},
    {OS_GIO_CPLD_VERSION01, CPLD_GIO_CPLDVER_01},
    {OS_GIO_CPLD_VERSION02, CPLD_GIO_CPLDVER_02},
    {OS_GIO_CPLD_VERSION03, CPLD_GIO_CPLDVER_03},
    {OS_GIO_CPLD_VERSION04, CPLD_GIO_CPLDVER_04},
    {OS_GIO_CPLD_VERSION05, CPLD_GIO_CPLDVER_05},
    {OS_GIO_CPLD_VERSION06, CPLD_GIO_CPLDVER_06},
    {OS_GIO_CPLD_VERSION07, CPLD_GIO_CPLDVER_07},
    {OS_GIO_FAN_PWR_CNT, CPLD_GIO_OUTST1_0},
    {OS_GIO_IIT_SLP_REMOTE, CPLD_GIO_OUTST1_01},
    {OS_GIO_EPSV_PWR_CNT, CPLD_GIO_OUTST1_02},
    {OS_GIO_USB_STANDBY, CPLD_GIO_OUTST1_03},
    {OS_GIO_USB_VBUS_CNT, CPLD_GIO_OUTST1_04},
    {OS_GIO_FAX_PWR_CNT, CPLD_GIO_OUTST1_05},
    {OS_GIO_FAX5V_PWR_CNT, CPLD_GIO_OUTST1_06},
    {OS_GIO_RBT_PWR_CNT, CPLD_GIO_OUTST1_07},
    {OS_GIO_STS_LED0, CPLD_GIO_OUTST2_0},
    {OS_GIO_STS_LED1, CPLD_GIO_OUTST2_01},
    {OS_GIO_STS_LED2, CPLD_GIO_OUTST2_02},
    {OS_GIO_STS_LED3, CPLD_GIO_OUTST2_03},
    {OS_GIO_STS_LED4, CPLD_GIO_OUTST2_04},
    {OS_GIO_STS_LED5, CPLD_GIO_OUTST2_05},
    {OS_GIO_STS_LED6, CPLD_GIO_OUTST2_06},
    {OS_GIO_STS_LED7, CPLD_GIO_OUTST2_07},
    {OS_GIO_IOT_PWR_CNT, CPLD_GIO_OUTST3_0},
    {OS_GIO_SLP_PWR_CNT, CPLD_GIO_OUTST3_01},
    {OS_GIO_OPT_PWR_CNT, CPLD_GIO_OUTST3_02},
    {OS_GIO_OPT_RST, CPLD_GIO_OUTST3_03},
    {OS_GIO_A4FAX_PWR_CNT, CPLD_GIO_OUTST3_04},
    {-1, CPLD_GIO_OUTST3_05},
    {-1, CPLD_GIO_OUTST3_06},
    {OS_GIO_PAL_VERUP, CPLD_GIO_OUTST3_07},
    {-1, CPLD_GIO_OUTST4_0},
    {-1, CPLD_GIO_OUTST4_01},
    {-1, CPLD_GIO_OUTST4_02},
    {OS_GIO_WIFI_RST, CPLD_GIO_OUTST4_03},
    {OS_GIO_WIFI_PWR_CNT, CPLD_GIO_OUTST4_04},
    {OS_GIO_USB_HUB_PWR_CNT, CPLD_GIO_OUTST4_05},
    {OS_GIO_SD_PWR_CNT, CPLD_GIO_OUTST4_06},
    {OS_GIO_READY_PWR_CNT, CPLD_GIO_OUTST4_07},
    {OS_GIO_ICCR_LED, CPLD_GIO_PMCR1_0},
    {-1, CPLD_GIO_PMCR1_01},
    {-1, CPLD_GIO_PMCR1_02},
    {-1, CPLD_GIO_PMCR1_03},
    {-1, CPLD_GIO_PMCR1_04},
    {-1, CPLD_GIO_PMCR1_05},
    {-1, CPLD_GIO_PMCR1_06},
    {-1, CPLD_GIO_PMCR1_07},
    {OS_GIO_HW_RST, CPLD_GIO_PMCR2_0},
    {-1, CPLD_GIO_PMCR2_01},
    {-1, CPLD_GIO_PMCR2_02},
    {-1, CPLD_GIO_PMCR2_03},
    {-1, CPLD_GIO_PMCR2_04},
    {-1, CPLD_GIO_PMCR2_05},
    {OS_GIO_GPHY_RST, CPLD_GIO_PMCR2_06},
    {OS_GIO_C_P_FLAG, CPLD_GIO_PMCR2_07},
    {-1, CPLD_GIO_PMCR3_0},
    {-1, CPLD_GIO_PMCR3_01},
    {OS_GIO_SLP_LED_CNT, CPLD_GIO_PMCR3_02},
    {-1, CPLD_GIO_PMCR3_03},
    {-1, CPLD_GIO_PMCR3_04},
    {OS_GIO_DAT_LED_CNT, CPLD_GIO_PMCR3_05},
    {-1, CPLD_GIO_PMCR3_06},
    {-1, CPLD_GIO_PMCR3_07},
    {OS_GIO_OPT_WAKE, CPLD_GIO_INPST1_0},
    {OS_GIO_USB_OVRCUR1, CPLD_GIO_INPST1_01},
    {OS_GIO_SUB_SW_PUSH, CPLD_GIO_INPST1_02},
    {OS_GIO_FAXWKUP, CPLD_GIO_INPST1_03},
    {OS_GIO_INTER_LOCK, CPLD_GIO_INPST1_04},
    {OS_GIO_FAN_FAIL, CPLD_GIO_INPST1_05},
    {OS_GIO_DADF_WAKEUP, CPLD_GIO_INPST1_06},
    {OS_GIO_PLATEN_WAKEUP, CPLD_GIO_INPST1_07},
    {-1, CPLD_GIO_INPST2_0},
    {OS_GIO_SUB_SW_RLS, CPLD_GIO_INPST2_01},
    {OS_GIO_BLUETOOTH_HOWK, CPLD_GIO_INPST2_02},
    {OS_GIO_WIFI_HOWK, CPLD_GIO_INPST2_03},
    {OS_GIO_SIM_DETECT, CPLD_GIO_INPST2_04},
    {OS_GIO_USB_HUB_OC_DETECT, CPLD_GIO_INPST2_05},
    {OS_GIO_USB_VBUS_DETECT, CPLD_GIO_INPST2_06},
    {OS_GIO_IOT_WDT_STS, CPLD_GIO_INPST2_07},
    {OS_GIO_IIT_POWER_SEN, CPLD_GIO_INPST3_0},
    {OS_GIO_RST3V_SEN_RST, CPLD_GIO_INPST3_01},
    {OS_GIO_PCLEX12, CPLD_GIO_INPST3_02},
    {OS_GIO_PCIEX_RISER_DETECT, CPLD_GIO_INPST3_03},
    {OS_GIO_EPSV_IN, CPLD_GIO_INPST3_04},
    {OS_GIO_UI_DETECT, CPLD_GIO_INPST3_05},
    {OS_GIO_DADF_EXIST, CPLD_GIO_INPST3_06},
    {OS_GIO_OFF_COUNT, CPLD_GIO_INPST3_07},
    {OS_GIO_NVM_SEL0, CPLD_GIO_INPST4_0},
    {OS_GIO_NVM_SEL1, CPLD_GIO_INPST4_01},
    {OS_GIO_IOT_PWR_STS, CPLD_GIO_INPST4_02},
    {-1, CPLD_GIO_INPST4_03},
    {-1, CPLD_GIO_INPST4_04},
    {-1, CPLD_GIO_INPST4_05},
    {-1, CPLD_GIO_INPST4_06},
    {OS_GIO_WIFI_DETECT, CPLD_GIO_INPST4_07},
    {-1, CPLD_GIO_PMSR1_0},
    {-1, CPLD_GIO_PMSR1_01},
    {-1, CPLD_GIO_PMSR1_02},
    {-1, CPLD_GIO_PMSR1_03},
    {-1, CPLD_GIO_PMSR1_04},
    {-1, CPLD_GIO_PMSR1_05},
    {OS_GIO_RBT3V_SENSE, CPLD_GIO_PMSR1_06},
    {OS_GIO_SUB_SW_PUSHED_STS, CPLD_GIO_PMSR1_07},
    {OS_GIO_USBHUB_RST, CPLD_GIO_OUTST5_0},
    {-1, CPLD_GIO_OUTST5_01},
    {-1, CPLD_GIO_OUTST5_02},
    {-1, CPLD_GIO_OUTST5_03},
    {-1, CPLD_GIO_OUTST5_04},
    {-1, CPLD_GIO_OUTST5_05},
    {OS_GIO_RBT3V_SENSE, CPLD_GIO_OUTST5_06},
    {OS_GIO_SUB_SW_PUSHED_STS, CPLD_GIO_OUTST5_07},
    {-1, CPLD_GIO_PMCR3_NR2_0},
    {-1, CPLD_GIO_PMCR3_NR2_01},
    {OS_GIO_SLP_LED_CNT2, CPLD_GIO_PMCR3_NR2_02},
    {-1, CPLD_GIO_PMCR3_NR2_03},
    {-1, CPLD_GIO_PMCR3_NR2_04},
    {OS_GIO_DAT_LED_CNT2, CPLD_GIO_PMCR3_NR2_05},
    {-1, CPLD_GIO_PMCR3_NR2_06},
    {-1, CPLD_GIO_PMCR3_NR2_07},
    {-1, GPIO_A_0},
    {-1, GPIO_A_01},
    {-1, GPIO_A_02},
    {-1, GPIO_A_03},
    {-1, GPIO_A_04},
    {-1, GPIO_A_05},
    {-1, GPIO_A_06},
    {-1, GPIO_A_07},
    {-1, GPIO_A_08},
    {-1, GPIO_A_09},
    {-1, GPIO_A_10},
    {-1, GPIO_A_11},
    {OS_GIO_FAX_RESET, GPIO_A_12},
    {-1, GPIO_A_13},
    {-1, GPIO_A_14},
    {-1, GPIO_A_15},
    {-1, GPIO_A_16},
    {-1, GPIO_A_17},
    {-1, GPIO_A_18},
    {-1, GPIO_A_19},
    {-1, GPIO_A_20},
    {-1, GPIO_A_21},
    {OS_GIO_FAX_RELAY, GPIO_A_22},
    {OS_GIO_FAX_RING, GPIO_A_23},
    {-1, GPIO_A_24},
    {-1, GPIO_A_25},
    {-1, GPIO_A_26},
    {-1, GPIO_A_27},
    {-1, GPIO_A_28},
    {-1, GPIO_A_29},
    {-1, GPIO_A_30},
    {-1, GPIO_A_31},
    {-1, GPIO_B_0},
    {-1, GPIO_B_01},
    {-1, GPIO_B_02},
    {OS_GIO_FAX_SEN, GPIO_B_03},
    {-1, GPIO_B_04},
    {OS_GIO_HOTKEY, GPIO_B_05},
    {OS_GIO_UI_PWR_CNT, GPIO_B_06},
    {OS_GIO_UI_RESET, GPIO_B_07},
    {-1, GPIO_B_08},
    {-1, GPIO_B_09},
    {-1, GPIO_B_10},
    {-1, GPIO_B_11},
    {OS_GIO_RBT_PWR_UP, GPIO_B_12},
    {-1, GPIO_B_13},
    {OS_GIO_CPLD_INT_MASK, GPIO_B_14},
    {OS_GIO_TO_PSAVE, GPIO_B_15},
    {OS_GIO_DEBUG_LED0, GPIO_B_16},
    {OS_GIO_DEBUG_LED1, GPIO_B_17},
    {OS_GIO_DEBUG_LED2, GPIO_B_18},
    {OS_GIO_DEBUG_LED3, GPIO_B_19},
    {-1, GPIO_B_20},
    {OS_GIO_HDD_PWR_CNT, GPIO_B_21},
    {OS_GIO_9TH_LOCKN, GPIO_B_22},
    {-1, GPIO_B_23},
    {-1, GPIO_B_24},
    {-1, GPIO_B_25},
    {-1, GPIO_B_26},
    {-1, GPIO_B_27},
    {-1, GPIO_B_28},
    {-1, GPIO_B_29},
    {-1, GPIO_B_30},
    {-1, GPIO_B_31},
    {-1, GPIO_C_0},
    {-1, GPIO_C_01},
    {-1, GPIO_C_02},
    {-1, GPIO_C_03},
    {-1, GPIO_C_04},
    {-1, GPIO_C_05},
    {-1, GPIO_C_06},
    {-1, GPIO_C_07},
    {-1, GPIO_C_08},
    {-1, GPIO_C_09},
    {-1, GPIO_C_10},
    {-1, GPIO_C_11},
    {-1, GPIO_C_12},
    {-1, GPIO_C_13},
    {-1, GPIO_C_14},
    {-1, GPIO_C_15},
    {OS_GIO_CPLD_INT, GPIO_EXTINT_0},
    {-1 , GPIO_EXTINT_1},
    {OS_GIO_PHYINT, GPIO_EXTINT_2},
    {-1, GPIO_EXTINT_3},
};
const int osddiPortTblNumEnt = ARRAY_SIZE(osddiPortTbl);
STATUS kernelGioAssert(int port){
 int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]kernelGioAssert: unsupported port 0x%x\n" , port);
  return -ENOTTY;
 }
 return gioAssert(osddiPortTbl[i].actualPort);
}
EXPORT_SYMBOL(kernelGioAssert);
STATUS kernelGioNegate(int port){
 int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]kernelGioNegate: unsupported port 0x%x\n" , port);
  return -ENOTTY;
 }
 return gioNegate(osddiPortTbl[i].actualPort);
}
EXPORT_SYMBOL(kernelGioNegate);
int kernelGioStatus(int port){
 int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]kernelGioStatus: unsupported port 0x%x\n" , port);
  return -ENOTTY;
 }
 return gioStatus(osddiPortTbl[i].actualPort);
}
EXPORT_SYMBOL(kernelGioStatus);
extern int kernelGioIntClear(int port){
    int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]kernelGioStatus: unsupported port 0x%x\n" , port);
  return -EINVAL;
 }
 return gioIntClear(osddiPortTbl[i].actualPort);
}
extern int kernelGioPulseOutSet(int port, int value){
 int i,level;
 level = 0;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]kernelGioPulseOutSet: unsupported port 0x%x\n" , port);
  return -EINVAL;
 }
 switch(value){
  case OS_PULSE_BLINKING:
   level = GIO_PULSE_BLINKING;
   break;
  case OS_PULSE_LOW_RATE:
   level = GIO_PULSE_LOW_RATE;
   break;
  case OS_PULSE_HIGH_RATE:
   level = GIO_PULSE_HIGH_RATE;
   break;
  default:
   printk(KERN_ERR "[osddiGio.c]kernelGioPulseOutStart: unsupported level %x\n", value);
   return-EINVAL;
   break;
 }
 return gioPulseOutStart(osddiPortTbl[i].actualPort, level);
}
extern int kernelGioIntrStatusGet(int port){
 int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]kernelGioIntrStatusGet: unsupported port 0x%x\n" , port);
  return ERROR;
 }
 return gioIntrStatusGet(osddiPortTbl[i].actualPort);
}
extern int osddiGioDirectionGet(int port){
 int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]osddiGioDirectionGet: unsupported port 0x%x\n" , port);
  return ERROR;
 }
 return gioDirectionGet(osddiPortTbl[i].actualPort);
}
extern int osddiGioDirectionSet(int port, int value){
 int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]osddiGioDirectionGet: unsupported port 0x%x\n" , port);
  return ERROR;
 }
 return gioDirectionSet(osddiPortTbl[i].actualPort, value);
}
extern STATUS osddiGioIntrMaskSet(int port, int mask){
 int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]osddiGioDirectionGet: unsupported port 0x%x\n" , port);
  return ERROR;
 }
 return gioIntrMaskSet(osddiPortTbl[i].actualPort, mask);
}
extern int osddiGioIntrMaskGet(int port){
 int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]osddiGioDirectionGet: unsupported port 0x%x\n" , port);
  return ERROR;
 }
 return gioIntrMaskGet(osddiPortTbl[i].actualPort);
}
int osddiGioIntTrigSet(int port, int trig)
{
 int i;
 for(i = 0;i < osddiPortTblNumEnt;++i){
  if (osddiPortTbl[i].osddiPort == port) break;
 }
 if(i == osddiPortTblNumEnt ){
  printk(KERN_ERR "[osddiGio.c]osddiGioIntTrigSet: unsupported port 0x%x\n" , port);
  return -1;
 }
 return gioIntTrigSet(osddiPortTbl[i].actualPort, trig);
}
extern int osddiGioCpldIntrMaskOn(void){
 int res;
 res = gioIntrMaskSet(GPIO_B_14, GIO_INT_MASK_ON);
 return res;
}
extern int osddiGioCpldIntrMaskOff(void)
{
 int res;
 res = gioIntrMaskSet(GPIO_B_14, GIO_INT_MASK_OFF);
 return res;
}
extern int osddiGioIntrRegStatusGet( void ){
 int res;
 res = gioIntRegStatusGet();
 if(res < 0){
  printk(KERN_ERR "[osddiGioIntrStatusGet]Cannot get intr status\n");
  return res;
 }
 return res;
}
extern void osddiGioIntAllClear(int value){
 int res;
 res = gioIntAllClear(value);
 if(res < 0){
  printk(KERN_ERR "[osddiGioIntAllClear]Cannot clear int reg\n");
  return;
 }
 return;
}
extern LED_VAL osddiGetPwbaRev(void){
 LED_VAL backup;
 LED_VAL rev;
 rev.led0 = 0;
 rev.led1 = 0;
 rev.led2 = 0;
 rev.led3 = 0;
 backup.led0 = gioStatus(GPIO_B_16);
 backup.led1 = gioStatus(GPIO_B_17);
 backup.led2 = gioStatus(GPIO_B_18);
 backup.led3 = gioStatus(GPIO_B_19);
 printk(KERN_INFO "backup 0:%d, 1:%d, 2:%d, 3:%d\n", backup.led0, backup.led1, backup.led2, backup.led3);
 osddiGioDirectionSet(OS_GIO_DEBUG_LED0, OS_GIO_INPUT);
 osddiGioDirectionSet(OS_GIO_DEBUG_LED1, OS_GIO_INPUT);
 osddiGioDirectionSet(OS_GIO_DEBUG_LED2, OS_GIO_INPUT);
 osddiGioDirectionSet(OS_GIO_DEBUG_LED3, OS_GIO_INPUT);
 rev.led0 = gioStatus(GPIO_B_16);
 rev.led1 = gioStatus(GPIO_B_17);
 rev.led2 = gioStatus(GPIO_B_18);
 rev.led3 = gioStatus(GPIO_B_19);
 printk(KERN_INFO "backup 0:%d, 1:%d, 2:%d, 3:%d\n", rev.led0, rev.led1, rev.led2, rev.led3);
 osddiGioDirectionSet(OS_GIO_DEBUG_LED0, OS_GIO_INPUT);
 osddiGioDirectionSet(OS_GIO_DEBUG_LED1, OS_GIO_INPUT);
 osddiGioDirectionSet(OS_GIO_DEBUG_LED2, OS_GIO_INPUT);
 osddiGioDirectionSet(OS_GIO_DEBUG_LED3, OS_GIO_INPUT);
 if(backup.led0 == OS_STATUS_HIGH){
  kernelGioAssert(OS_GIO_DEBUG_LED0);
  }
  else{
  kernelGioNegate(OS_GIO_DEBUG_LED0);
 }
 if(backup.led1 == OS_STATUS_HIGH){
  kernelGioAssert(OS_GIO_DEBUG_LED1);
  }
  else{
  kernelGioNegate(OS_GIO_DEBUG_LED1);
  }
 if(backup.led2 == OS_STATUS_HIGH){
  kernelGioAssert(OS_GIO_DEBUG_LED2);
  }
  else{
  kernelGioNegate(OS_GIO_DEBUG_LED2);
  }
 if(backup.led3 == OS_STATUS_HIGH){
  kernelGioAssert(OS_GIO_DEBUG_LED3);
  }
  else{
  kernelGioNegate(OS_GIO_DEBUG_LED3);
  }
 return rev;
}
extern STATUS osddiDiagLED(unsigned char status){
 unsigned char ledVal;
 if(status > 0xff){
  printk(KERN_ERR "[OSDDI] osddiDiagLED: status value error(0x%x) \n", status);
  return ERROR;
 }
 ledVal = status;
 if(ledVal & 0x00000001) {
  kernelGioAssert(OS_GIO_STS_LED0);
 } else {
  kernelGioNegate(OS_GIO_STS_LED0);
 }
 if(ledVal & 0x00000002) {
  kernelGioAssert(OS_GIO_STS_LED1);
 } else {
  kernelGioNegate(OS_GIO_STS_LED1);
 }
 if(ledVal & 0x00000004) {
  kernelGioAssert(OS_GIO_STS_LED2);
 } else {
  kernelGioNegate(OS_GIO_STS_LED2);
 }
 if(ledVal & 0x00000008) {
  kernelGioAssert(OS_GIO_STS_LED3);
 } else {
  kernelGioNegate(OS_GIO_STS_LED3);
 }
 if(ledVal & 0x00000010) {
  kernelGioAssert(OS_GIO_STS_LED4);
 } else {
  kernelGioNegate(OS_GIO_STS_LED4);
 }
 if(ledVal & 0x00000020) {
  kernelGioAssert(OS_GIO_STS_LED5);
 } else {
  kernelGioNegate(OS_GIO_STS_LED5);
 }
  if(ledVal & 0x00000040) {
  kernelGioAssert(OS_GIO_STS_LED6);
 } else {
  kernelGioNegate(OS_GIO_STS_LED6);
 }
 if(ledVal & 0x00000080) {
  kernelGioAssert(OS_GIO_STS_LED7);
 } else {
  kernelGioNegate(OS_GIO_STS_LED7);
 }
 return OK;
}
extern void kernelGioShow(int dev){
 if((dev < 0) | (dev > OS_GIO_CPLD)){
  printk(KERN_ERR "[kernelGioShow]invalid device(%d)\n", dev);
  return;
 }
 gioShow(GIO_SHOW_REGISTER,dev,0);
 return;
}
