MV_BOOL bfGppOutEnableRegBitTest(MV_32 bit) { if (bit < 0) return MV_FALSE; if (bit < 32) return MV_REG_READ(GPP_DATA_OUT_EN_REG(0)) & BIT(bit) ? MV_TRUE : MV_FALSE; else return MV_REG_READ(GPP_DATA_OUT_EN_REG(1)) & BIT(bit - 32) ? MV_TRUE : MV_FALSE; }
/******************************************************************************* * mvGppValueSet - Set a GPP Pin list value. * * DESCRIPTION: * This function set value for given GPP pin list. * * INPUT: * group - GPP group number * mask - 32bit mask value. Each set bit in the mask means that the * value of corresponding GPP will be set accordingly. Other GPP * are not affected. * value - 32bit value that describes GPP value per pin. * * OUTPUT: * None. * * EXAMPLE: * Set GPP8 value of '0' and GPP15 value of '1'. * mvGppActiveSet(0, (GPP8 | GPP15), ((0 & GPP8) | (GPP15)) ); * * RETURN: * None. * *******************************************************************************/ MV_STATUS mvGppValueSet (MV_U32 group, MV_U32 mask, MV_U32 value) { MV_U32 outEnable; MV_U32 i; if (group >= MV_GPP_MAX_GROUP) { DB(mvOsPrintf("mvGppValueSet: Error invalid group number \n")); return MV_BAD_PARAM; } /* verify that the gpp pin is configured as output */ /* Note that in the register out enabled -> bit = '0'. */ outEnable = ~MV_REG_READ(GPP_DATA_OUT_EN_REG(group)); for (i = 0 ; i < 32 ;i++) { if (((mask & (1 << i)) & (outEnable & (1 << i))) != (mask & (1 << i))) { mvOsPrintf("mvGppValueSet: Err. An attempt to set output "\ "value to GPP %d in input mode.\n", i); return MV_ERROR; } } gppRegSet(group, GPP_DATA_OUT_REG(group), mask, value); return MV_OK; }
/******************************************************************************* * mvGppTypeSet - Enable a GPP (OUT) pin * * DESCRIPTION: * * INPUT: * group - GPP group number * mask - 32bit mask value. Each set bit in the mask means that the type * of corresponding GPP will be set. Other GPPs are ignored. * value - 32bit value that describes GPP type per pin. * * OUTPUT: * None. * * EXAMPLE: * Set GPP8 to input and GPP15 to output. * mvGppTypeSet(0, (GPP8 | GPP15), * ((MV_GPP_IN & GPP8) | (MV_GPP_OUT & GPP15)) ); * * RETURN: * None. * *******************************************************************************/ MV_STATUS mvGppTypeSet(MV_U32 group, MV_U32 mask, MV_U32 value) { if (group >= MV_GPP_MAX_GROUP) { DB(mvOsPrintf("mvGppTypeSet: ERR. invalid group number \n")); return MV_BAD_PARAM; } gppRegSet(group, GPP_DATA_OUT_EN_REG(group), mask, value); /* Workaround for Erratum FE-MISC-70*/ if(mvCtrlRevGet()==MV_88F6XXX_A0_REV && (group == 1)) { mask &= 0x2; gppRegSet(0, GPP_DATA_OUT_EN_REG(0), mask, value); } /*End of WA*/ return MV_OK; }
/******************************************************************************* * mvGppTypeSet - Enable a GPP (OUT) pin * * DESCRIPTION: * * INPUT: * group - GPP group number * mask - 32bit mask value. Each set bit in the mask means that the type * of corresponding GPP will be set. Other GPPs are ignored. * value - 32bit value that describes GPP type per pin. * * OUTPUT: * None. * * EXAMPLE: * Set GPP8 to input and GPP15 to output. * mvGppTypeSet(0, (GPP8 | GPP15), * ((MV_GPP_IN & GPP8) | (MV_GPP_OUT & GPP15)) ); * * RETURN: * None. * *******************************************************************************/ MV_STATUS mvGppTypeSet(MV_U32 group, MV_U32 mask, MV_U32 value) { if (group >= MV_GPP_MAX_GROUP) { DB(mvOsPrintf("mvGppTypeSet: ERR. invalid group number \n")); return MV_BAD_PARAM; } gppRegSet(group, GPP_DATA_OUT_EN_REG(group), mask, value); return MV_OK; }
/******************************************************************************* * mvGppValueSet - Set a GPP Pin list value. * * DESCRIPTION: * This function set value for given GPP pin list. * * INPUT: * group - GPP group number * mask - 32bit mask value. Each set bit in the mask means that the * value of corresponding GPP will be set accordingly. Other GPP * are not affected. * value - 32bit value that describes GPP value per pin. * * OUTPUT: * None. * * EXAMPLE: * Set GPP8 value of '0' and GPP15 value of '1'. * mvGppActiveSet(0, (GPP8 | GPP15), ((0 & GPP8) | (GPP15)) ); * * RETURN: * None. * *******************************************************************************/ MV_STATUS mvGppValueSet (MV_U32 group, MV_U32 mask, MV_U32 value) { MV_U32 outEnable, tmp; MV_U32 i; if (group >= MV_GPP_MAX_GROUP) { DB(mvOsPrintf("mvGppValueSet: Error invalid group number \n")); return MV_BAD_PARAM; } /* verify that the gpp pin is configured as output */ /* Note that in the register out enabled -> bit = '0'. */ outEnable = ~MV_REG_READ(GPP_DATA_OUT_EN_REG(group)); /* Workaround for Erratum FE-MISC-70*/ if(mvCtrlRevGet()==MV_88F6XXX_A0_REV && (group == 1)) { tmp = ~MV_REG_READ(GPP_DATA_OUT_EN_REG(0)); outEnable &= 0xfffffffd; outEnable |= (tmp & 0x2); } /*End of WA*/ for (i = 0 ; i < 32 ;i++) { if (((mask & (1 << i)) & (outEnable & (1 << i))) != (mask & (1 << i))) { mvOsPrintf("mvGppValueSet: Err. An attempt to set output "\ "value to GPP %d in input mode.\n", i); return MV_ERROR; } } gppRegSet(group, GPP_DATA_OUT_REG(group), mask, value); return MV_OK; }
void recoveryDetection(void) { MV_32 stateButtonBit = mvBoarGpioPinNumGet(BOARD_GPP_WPS_BUTTON,0); MV_32 buttonHigh = 0; char* env; /* Check if auto recovery is enabled */ env = getenv("enaAutoRecovery"); if(!env || ( (strcmp(env,"yes") == 0) || (strcmp(env,"Yes") == 0) ) ) setenv("enaAutoRecovery","yes"); else { setenv("enaAutoRecovery","no"); rcvrflag = 0; return; } if (stateButtonBit == MV_ERROR) { rcvrflag = 0; return; } if (stateButtonBit > 31) { stateButtonBit = stateButtonBit % 32; buttonHigh = 1; } /* Set state input indication pin as input */ MV_REG_BIT_SET(GPP_DATA_OUT_EN_REG(buttonHigh),(1<<stateButtonBit)); /* check if recovery triggered - button is pressed */ if (!(MV_REG_READ(GPP_DATA_IN_REG(buttonHigh)) & (1 << stateButtonBit))) { rcvrflag = 1; } }
//---------------------------------------------------------------------- int __init buffaloLedDriver_init (void) { int i; char buf[1024]; struct proc_dir_entry *pde; FUNCTRACE(printk("%s > Entered.\n",__FUNCTION__)); BuffaloGpio_Init(); pde = proc_mkdir("buffalo/gpio", 0); pde = proc_mkdir("buffalo/gpio/led", 0); pde = proc_mkdir("buffalo/gpio/switch", 0); pde = proc_mkdir("buffalo/gpio/fan", 0); pde = proc_mkdir("buffalo/gpio/power_control", 0); pde = create_proc_info_entry ("buffalo/power_sw", 0, 0, gpio_power_read_proc); pde = create_proc_entry("buffalo/gpio/led/all", 0, 0); pde->read_proc = BuffaloAllLedReadProc; pde->write_proc= BuffaloAllLedWriteProc; pde = create_proc_entry("buffalo/cpu_status", 0, 0); pde->read_proc = BuffaloCpuStatusReadProc; pde->write_proc = BuffaloCpuStatusWriteProc; if (BIT_LED_ALARM >= 0) { BuffaloGpio_AlarmLedDisable(); pde = create_proc_entry("buffalo/gpio/led/alarm", 0, 0); pde->read_proc = BuffaloLedReadProc; pde->write_proc = BuffaloLedWriteProc; alarmLed.mppNumber = BIT_LED_ALARM; pde->data = &alarmLed; pde = create_proc_entry("buffalo/gpio/led/alarm_blink", 0, 0); pde->read_proc = BuffaloLedBlinkReadProc; pde->write_proc = BuffaloLedBlinkWriteProc; pde->data = &alarmLed; } if (BIT_LED_INFO >= 0) { BuffaloGpio_InfoLedDisable(); pde = create_proc_entry("buffalo/gpio/led/info", 0, 0); pde->read_proc = BuffaloLedReadProc; pde->write_proc = BuffaloLedWriteProc; infoLed.mppNumber = BIT_LED_INFO; pde->data = &infoLed; pde = create_proc_entry("buffalo/gpio/led/info_blink", 0, 0); pde->read_proc = BuffaloLedBlinkReadProc; pde->write_proc = BuffaloLedBlinkWriteProc; pde->data = &infoLed; } if (BIT_LED_PWR >= 0) { BuffaloGpio_PowerLedEnable(); pde = create_proc_entry("buffalo/gpio/led/power", 0, 0); pde->read_proc = BuffaloLedReadProc; pde->write_proc = BuffaloLedWriteProc; powerLed.mppNumber = BIT_LED_PWR; pde->data = &powerLed; pde = create_proc_entry("buffalo/gpio/led/power_blink", 0, 0); pde->read_proc = BuffaloLedBlinkReadProc; pde->write_proc = BuffaloLedBlinkWriteProc; pde->data = &powerLed; } if (BIT_LED_FUNC >= 0) { BuffaloGpio_FuncLedDisable(); pde = create_proc_entry("buffalo/gpio/led/func", 0, 0); pde->read_proc = BuffaloLedReadProc; pde->write_proc = BuffaloLedWriteProc; funcLed.mppNumber = BIT_LED_FUNC; pde->data = &funcLed; pde = create_proc_entry("buffalo/gpio/led/func_blink", 0, 0); pde->read_proc = BuffaloLedBlinkReadProc; pde->write_proc = BuffaloLedBlinkWriteProc; pde->data = &funcLed; } if (BIT_LED_ETH >= 0) { pde = create_proc_entry("buffalo/gpio/led/eth", 0, 0); pde->read_proc = BuffaloEthLedReadProc; pde->write_proc = BuffaloEthLedWriteProc; } for (i=0; i<BUF_NV_SIZE_BIT_HDD_POWER; i++) { if (bitHddPower[i] < 0) continue; sprintf(buf, "buffalo/gpio/power_control/hdd%d", i); pde = create_proc_entry(buf, 0, 0); if (pde != NULL) { pde->read_proc = BuffaloHddReadProc; pde->write_proc= BuffaloHddWriteProc; pde->owner = THIS_MODULE; pde->data = (void *)i; } } for (i=0; i<BUF_NV_SIZE_BIT_USB_POWER; i++) { if (bitUsbPower[i] < 0) continue; sprintf(buf, "buffalo/gpio/power_control/usb%d", i); pde = create_proc_entry(buf, 0, NULL); if (pde != NULL) { pde->read_proc = BuffaloUsbReadProc; pde->write_proc = BuffaloUsbWriteProc; pde->owner = THIS_MODULE; pde->data = (void *)i; } } if (use_slide_power == 1) { pde = create_proc_entry("buffalo/gpio/switch/power", 0, 0); pde->read_proc = BuffaloPowerReadProc; // pde->write_proc = BuffaloPowerReadProc; pde = create_proc_info_entry("buffalo/gpio/switch/slide_switch", 0, 0, BuffaloSlideSwitchReadProc); } if (BIT_AUTO_POWER >= 0) { pde = create_proc_entry("buffalo/gpio/switch/auto_power", 0, 0); pde->read_proc = BuffaloAutoPowerReadProc; // pde->write_proc = BuffaloAutoPowerReadProc; } if (use_slide_power == 1 || BIT_AUTO_POWER >= 0) { pde = create_proc_entry("buffalo/gpio/switch/sw_control", 0, 0); pde->read_proc = BuffaloSwPollingReadProc; pde->write_proc = BuffaloSwPollingWriteProc; } if (BIT_FUNC >= 0) { pde = create_proc_entry("buffalo/gpio/switch/func", 0, 0); pde->read_proc = BuffaloFuncReadProc; // pde->write_proc= BuffaloFuncReadProc; } if (BIT_FAN_LOW >= 0 && BIT_FAN_HIGH) { pde = create_proc_entry("buffalo/gpio/fan/control", 0, 0); pde->read_proc = BuffaloFanControlReadProc; pde->write_proc= BuffaloFanControlWriteProc; } if (BIT_FAN_LCK >= 0) { pde = create_proc_entry("buffalo/gpio/fan/lock", 0, 0); pde->read_proc = BuffaloFanStatusReadProc; pde->write_proc= BuffaloFanStatusWriteProc; } pde = create_proc_entry("buffalo/gpio/data_out_register", 0, 0); pde->read_proc = BuffaloGpioRegisterReadProc; pde->write_proc= BuffaloGpioRegisterWriteProc; pde->data = (void *)GPP_DATA_OUT_REG(0); pde = create_proc_entry("buffalo/gpio/data_out_enable_register", 0, 0); pde->read_proc = BuffaloGpioRegisterReadProc; pde->write_proc= BuffaloGpioRegisterWriteProc; pde->data = (void *)GPP_DATA_OUT_EN_REG(0); pde = create_proc_entry("buffalo/gpio/blink_enable_register", 0, 0); pde->read_proc = BuffaloGpioRegisterReadProc; pde->write_proc= BuffaloGpioRegisterWriteProc; pde->data = (void *)GPP_BLINK_EN_REG(0); pde = create_proc_entry("buffalo/gpio/data_in_polarity_register", 0, 0); pde->read_proc = BuffaloGpioRegisterReadProc; pde->write_proc= BuffaloGpioRegisterWriteProc; pde->data = (void *)GPP_DATA_IN_POL_REG(0); pde = create_proc_entry("buffalo/gpio/data_in_register", 0, 0); pde->read_proc = BuffaloGpioRegisterReadProc; pde->write_proc= BuffaloGpioRegisterWriteProc; pde->data = (void *)GPP_DATA_IN_REG(0); if (Buffalo_has_PM()) { for (i=0; i<4; i++) { sprintf(buf, "buffalo/gpio/power_control/hdd%d", i); pde = create_proc_entry(buf, 0, 0); if (pde != NULL) { pde->read_proc = BuffaloPMHddPowerReadProc; pde->write_proc= BuffaloPMHddPowerWriteProc; pde->owner = THIS_MODULE; pde->data = (void *)i; } sprintf(buf, "buffalo/gpio/led/pm_diag_led%d", i); pde = create_proc_entry(buf, 0, 0); if (pde != NULL) { pde->read_proc = BuffaloPMHddDiagLedReadProc; pde->write_proc= BuffaloPMHddDiagLedWriteProc; pde->owner = THIS_MODULE; pde->data = (void *)i; } } } printk("%s %s Ver.%s installed.\n", DRIVER_NAME, AUTHOR, BUFFALO_DRIVER_VER); return 0; }