void NvBatteryEventHandlerThread(void *args) { NvU8 BatteryState = 0, BatteryEvent = 0; NvBool suspend_flag; for (;;) { NvOsSemaphoreWaitTimeout(batt_dev->hOdmSemaphore, batt_dev->batt_status_poll_period); if (batt_dev->exitThread) break; if (!batt_dev->hOdmBattDev) continue; NvOsMutexLock(batt_dev->hBattEventMutex); suspend_flag = batt_dev->inSuspend; NvOsMutexUnlock(batt_dev->hBattEventMutex); if (suspend_flag) continue; pr_info("\tBATTERY: polling battery information! --->>>\n"); NvOdmBatteryGetBatteryStatus(batt_dev->hOdmBattDev, NvOdmBatteryInst_Main, &BatteryState); NvOdmBatteryGetEvent(batt_dev->hOdmBattDev, &BatteryEvent); if ((BatteryState == NVODM_BATTERY_STATUS_UNKNOWN) || (BatteryEvent == NvOdmBatteryEventType_Num)) { /* Do nothing */ } else { if (BatteryEvent & NvOdmBatteryEventType_RemainingCapacityAlarm) { if (BatteryState == (NVODM_BATTERY_STATUS_CRITICAL | NVODM_BATTERY_STATUS_VERY_CRITICAL | NVODM_BATTERY_STATUS_DISCHARGING)) { pr_info("nvec_battery:calling kernel_power_off...\n"); kernel_power_off(); } } else { /* Update the battery and power supply info for other events */ power_supply_changed(&tegra_power_supplies[NvCharger_Type_Battery]); //power_supply_changed(&tegra_power_supplies[NvCharger_Type_USB]); // power_supply_changed(&tegra_power_supplies[NvCharger_Type_AC]); } } } }
void NvBatteryEventHandlerThread(void *args) { NvU8 BatteryState = 0, BatteryEvent = 0; for (;;) { NvOsSemaphoreWait(batt_dev->hOdmSemaphore); if (batt_dev->exitThread) break; if (!batt_dev->hOdmBattDev) continue; NvOdmBatteryGetBatteryStatus(batt_dev->hOdmBattDev, NvOdmBatteryInst_Main, &BatteryState); NvOdmBatteryGetEvent(batt_dev->hOdmBattDev, &BatteryEvent); NvOsDebugPrintf("ec_rs BatteryEvent = 0x%x\n", BatteryEvent); if ((BatteryState == NVODM_BATTERY_STATUS_UNKNOWN) || (BatteryEvent == NvOdmBatteryEventType_Num)) { /* Do nothing */ } else { //if (BatteryEvent & NvOdmBatteryEventType_RemainingCapacityAlarm) { if (BatteryEvent & NvOdmBatteryEventType_LowBatteryIntr) { //Daniel 20100701, just force off while receive LOW_BAT# interrupt(not low capacity alarm). //if (BatteryState == (NVODM_BATTERY_STATUS_CRITICAL | // NVODM_BATTERY_STATUS_VERY_CRITICAL | // NVODM_BATTERY_STATUS_DISCHARGING)) { // pr_info("nvec_battery:calling kernel_power_off...\n"); NvOsDebugPrintf("ec_rs batt low battery interrupt.\r\n"); // kernel_power_off(); //} } else { /* Update the battery and power supply info for other events */ power_supply_changed(&tegra_power_supplies[NvPowerSupply_TypeBattery]); power_supply_changed(&tegra_power_supplies[NvPowerSupply_TypeAC]); } } } }