static int PollingPowerSWStatus(unsigned long data){ TRACE(printk(">%s, data=%u, PSW_LONG_WAIT_COUNT=%d\n", __FUNCTION__, data, PSW_LONG_WAIT_COUNT)); unsigned int PowerStat = buffalo_gpio_read(); if(PowerStat & BIT(BIT_POWER)){ if((data >= PSW_LONG_WAIT_COUNT) && !(power_pushed_status & SW_LONG_PUSHED)){ power_pushed_status |= SW_LONG_PUSHED; #if defined CONFIG_BUFFALO_USE_KERNEL_EVENT_DRIVER buffalo_kernevnt_queuein("PSW_pushed"); #endif }else if((data >= PSW_WAIT_COUNT) && !(power_pushed_status & SW_PUSHED)){ power_pushed_status |= SW_PUSHED; #if defined CONFIG_BUFFALO_USE_KERNEL_EVENT_DRIVER buffalo_kernevnt_queuein("PSW_short_pushed"); #endif } PollingTimerGoOn(); }else{ PollingTimerStop(); if(g_irq) enable_irq(g_irq); power_pushed_status = 0; } return 0; }
static int PollingFuncSWStatus(unsigned long data) { TRACE(printk(">%s, data=%u, FUNC_WAIT_COUNT=%d\n", __FUNCTION__, data, FUNC_WAIT_COUNT)); unsigned int FuncStat = buffalo_gpio_read(); if (FuncStat & BIT(BIT_FUNC)){ func_pushed_status |= SW_PUSHED; if ((data > FUNC_LONG_WAIT_COUNT) && !(func_pushed_status & SW_LONG_PUSHED)){ func_pushed_status |= SW_LONG_PUSHED; #if defined CONFIG_BUFFALO_USE_KERNEL_EVENT_DRIVER buffalo_kernevnt_queuein("FUNCSW_long_pushed"); #endif } PollingTimerGoOnFunc(); }else{ PollingTimerStopFunc(); if (irq_func) enable_irq(irq_func); if ((data > FUNC_WAIT_COUNT) && !(func_pushed_status ^ SW_PUSHED)) { #if defined CONFIG_BUFFALO_USE_KERNEL_EVENT_DRIVER buffalo_kernevnt_queuein("FUNCSW_pushed"); #endif } func_pushed_status = 0; } return 0; }
static int PollingINITSWStatus(unsigned long data){ TRACE(printk(">%s, data=%u, INIT_WAIT_COUNT=%d\n", __FUNCTION__, data, INIT_WAIT_COUNT)); unsigned int InitStat=buffalo_gpio_read(); if(InitStat & BIT(BIT_INIT)){ if((data > INIT_WAIT_COUNT) && !(init_pushed_status & SW_PUSHED)){ init_pushed_status |= SW_PUSHED; #if defined CONFIG_BUFFALO_USE_KERNEL_EVENT_DRIVER buffalo_kernevnt_queuein("INITSW_pushed"); #else #endif // keep Polling untile button would be released. TRACE(printk("initialize start\n")); } PollingTimerGoOnInit(); }else{ PollingTimerStopInit(); if(g_irq_init) enable_irq(g_irq_init); } return 0; }
static void SataHotplugPolling(void) { //printk("%s : entered\n", __FUNCTION__); unsigned int i = 0; char buf[32]; SataHotplugPollingUpdatePinstat(); for(i = 0; i < MAX_SUPPORTED_DISKS; i++) { //printk("sata_hotplug_data[%d].prevplugstat=%d : sata_hotplug_data[%d].presentpinstat=%d\n", i, sata_hotplug_data[i].prevplugstat, i, sata_hotplug_data[i].presentpinstat); if(sata_hotplug_data[i].prevplugstat == sata_hotplug_data[i].presentpinstat) { sata_hotplug_data[i].loops = SATA_POL_LOOPS; continue; } --sata_hotplug_data[i].loops; //printk("sata_hotplug_data[%d].loops=%d\n", i, sata_hotplug_data[i].loops); if(sata_hotplug_data[i].loops == 0) { if(sata_hotplug_data[i].presentpinstat == SATA_STAT_PLUGGED) sprintf(buf, PLUGGED_EVENT_MSG, i); else sprintf(buf, UNPLUGGED_EVENT_MSG, i); buffalo_kernevnt_queuein(buf); sata_hotplug_data[i].loops = SATA_POL_LOOPS; sata_hotplug_data[i].prevplugstat = sata_hotplug_data[i].presentpinstat; } } sata_hotplug_polling_timer.expires += SATA_POL_INTERVAL; add_timer(&sata_hotplug_polling_timer); }
//-------------------------------------------------------------- void kernevnt_MiconInt(void) { #ifdef FUNCMSG printk(">%s\n",__FUNCTION__); #endif buffalo_kernevnt_queuein("micon_interrupts"); }
static void PollingSATAHotplug(unsigned long arg) { struct sata_hotplug_data *data = (struct sata_hotplug_data *)arg; SATA_PLUG_STATE plugstat = data->hops->getstat(data->dev_id); char buf[32]; if (data->lastplugstat == plugstat) data->loops = SATA_POL_LOOPS; else --data->loops; if (data->loops == 0) { data->lastplugstat = plugstat; if (plugstat == SATA_STAT_PLUGGED) sprintf(buf, PLUGGED_EVENT_MSG, data->index); else sprintf(buf, UNPLUGGED_EVENT_MSG, data->index); if (data->hops->resetdev) data->hops->resetdev(data); buffalo_kernevnt_queuein(buf); } if (data->loops || !data->hops->getirq) { data->timer.expires += SATA_POL_INTERVAL; add_timer(&data->timer); } else { enable_irq(data->hops->getirq(data->dev_id)); } }
//-------------------------------------------------------------- void kernevnt_EnetOverload(const char *name) { #ifdef FUNCMSG printk(">%s\n",__FUNCTION__); #endif char msg[64]; sprintf(msg,"enetover %s",name); buffalo_kernevnt_queuein(msg); }
//-------------------------------------------------------------- void kernevnt_DriveDead(const char *drvname) { #ifdef FUNCMSG printk(">%s: drive %s is dead.\n",__FUNCTION__,drvname); #endif char msg[64]; sprintf(msg,"drivedead %s",drvname); buffalo_kernevnt_queuein(msg); }
//-------------------------------------------------------------- void kernevnt_LanAct(int spd, int isFull) { #ifdef FUNCMSG printk(">%s (%d)\n",__FUNCTION__,spd); #endif char msg[32]; sprintf(msg,"lanact %d %s",spd,(isFull? "full":"half")); buffalo_kernevnt_queuein(msg); }
//-------------------------------------------------------------- void kernevnt_FlashUpdate(int on) { #ifdef FUNCMSG printk(">%s (%d)\n",__FUNCTION__,on); #endif char msg[32]; sprintf(msg,"flashupdate %d",on); buffalo_kernevnt_queuein(msg); }
//-------------------------------------------------------------- void kernevnt_IOErr(const char *kdevname, const char *dir, unsigned long sector, unsigned int errcnt) { #ifdef FUNCMSG printk(">%s(%s): I/O error, dev %s, sector %lu\n", __FUNCTION__,kdevname, dir, sector, errcnt); #endif char msg[64]; sprintf(msg,"ioerr %s %s %ld %u",kdevname, dir, sector, errcnt); buffalo_kernevnt_queuein(msg); }
//-------------------------------------------------------------- void kernevnt_RadiDegraded(int devno, int major, int minor) { char buff[64]; #ifdef FUNCMSG printk(">%s:md%d %d %d\n",__FUNCTION__,devno,major,minor); #endif sprintf(buff,"raiddegraded %d %d %d",devno,major,minor); buffalo_kernevnt_queuein(buff); }
//-------------------------------------------------------------- void kernevnt_RadiScan(int devno, int on) { static int opencnt=0; char buff[64]; #ifdef FUNCMSG printk(">%s:md%d on=%d cnt=%d\n",__FUNCTION__,devno,on,opencnt); #endif if (on) opencnt++; else opencnt--; sprintf(buff,"raidscan %d %d %d",devno,on,opencnt); buffalo_kernevnt_queuein(buff); }
//-------------------------------------------------------------- void kernevnt_RadiRecovery(int devno, int on, int isRecovery, int major, int minor) { static int opencnt=0; char buff[64]; #ifdef FUNCMSG printk(">%s:md%d on=%d cnt=%d isRecovery=%d %d %d\n",__FUNCTION__,devno,on,opencnt,isRecovery,major,minor); #endif if (on) opencnt++; else opencnt--; if (isRecovery){ sprintf(buff,"raidrecovery %d %d %d %d %d %d",devno,on,opencnt,isRecovery,major,minor); }else{ sprintf(buff,"raidresync %d %d %d %d",devno,on,opencnt,isRecovery); } buffalo_kernevnt_queuein(buff); }
static int BuffaloSwPollingCheck(void) { unsigned int PinStat = GPIO_IN_REG; unsigned int present_sw_status = SW_POWER_NS; static char msg[32]; SW_POLL_TRACE(printk("PinStat = 0x%08x\n", PinStat)); SW_POLL_TRACE(printk("PinStat & (BIT(BIT_POWER) | BIT(BIT_AUTO_POWER)) = 0x%08x\n", (PinStat & (BIT(BIT_POWER) | BIT(BIT_AUTO_POWER))))); SW_POLL_TRACE(printk("SW_PIN_STAT_OFF=0x%08x\n", SW_PIN_STAT_OFF)); SW_POLL_TRACE(printk("SW_PIN_STAT_ON=0x%08x\n", SW_PIN_STAT_ON)); SW_POLL_TRACE(printk("SW_PIN_STAT_AUTO=0x%08x\n", SW_PIN_STAT_AUTO)); if (use_slide_power) { if(!(PinStat & BIT(BIT_POWER)) && !(PinStat & BIT(BIT_AUTO_POWER))) present_sw_status = SW_POWER_OFF; else if((PinStat & BIT(BIT_POWER)) && !(PinStat & BIT(BIT_AUTO_POWER))) present_sw_status = SW_POWER_ON; else if(!(PinStat & BIT(BIT_POWER)) && (PinStat & BIT(BIT_AUTO_POWER))) present_sw_status = SW_POWER_AUTO; else present_sw_status = SW_POWER_NS; } else { if(PinStat & BIT(BIT_AUTO_POWER)) present_sw_status = SW_POWER_AUTO; else present_sw_status = SW_POWER_ON; } SW_POLL_TRACE(printk("present_sw_status = 0x%08x\n", present_sw_status)); SW_POLL_TRACE(printk("g_buffalo_sw_status = 0x%08x\n", g_buffalo_sw_status)); if(g_buffalo_sw_status != present_sw_status) { g_buffalo_sw_status = present_sw_status; memset(msg, 0, sizeof(msg)); switch(g_buffalo_sw_status) { case SW_POWER_OFF: SW_POLL_TRACE(printk("%s> SW_POWER_OFF\n", __FUNCTION__)); buffalo_kernevnt_queuein("PSW_off");; break; case SW_POWER_ON: SW_POLL_TRACE(printk("%s> SW_POWER_ON\n", __FUNCTION__)); buffalo_kernevnt_queuein("PSW_on");; break; case SW_POWER_AUTO: SW_POLL_TRACE(printk("%s> SW_POWER_AUTO\n", __FUNCTION__)); buffalo_kernevnt_queuein("PSW_auto");; break; case SW_POWER_NS: SW_POLL_TRACE(printk("%s> SW_POWER_NS\n", __FUNCTION__)); buffalo_kernevnt_queuein("PSW_unknown");; break; default: break; } SW_POLL_TRACE(printk("%s\n", msg)); } BuffaloSwPollingTimer.expires = (jiffies + SW_POLLING_INTERVAL); add_timer(&BuffaloSwPollingTimer); return 0; }
//-------------------------------------------------------------- void kernevnt_I2cErr(void) { printk(">%s\n",__FUNCTION__); buffalo_kernevnt_queuein("i2c_error"); }