static int __ddrrun_func save_calc_ocv() { short v_reg, c_reg; disable_charger(); sleep(1320); /* 1210ms + 110ms */ SMARTSTAR_REGS_READ(SMARTSTAR_VOL_FIFO_BASE, &v_reg, 2); SMARTSTAR_REGS_READ(SMARTSTAR_CUR_FIFO_BASE, &c_reg, 2); enable_charger(); coul_nv_info->calc_ocv_reg_v = v_reg; coul_nv_info->calc_ocv_reg_c = c_reg; coul_nv_info->start_cc = 0; coul_nv_info->hkadc_batt_temp = (short)smartstar_battery_temperature(); coul_nv_info->hkadc_batt_id_voltage = (short)smartstar_battery_id_voltage(); coul_nv_info->ocv_temp = smartstar_battery_temperature()*10; SMARTSTAR_COUL_INF("save calc ocv fastboot read batt temp =%d , batt id voltage=%d\n",\ coul_nv_info->hkadc_batt_temp, coul_nv_info->hkadc_batt_id_voltage); SMARTSTAR_COUL_INF("v_reg=%d, c_reg=%d\n", v_reg, c_reg); return save_nv(); }
static inline void charger_control(void) { switch (charge_state) { case DISCHARGING: { unsigned int millivolts; unsigned int thresh = batt_threshold; if (BATT_FULL_VOLTAGE == thresh) { /* Wait for CHG_status to be indicated. */ if ((ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS) == 0) break; batt_threshold = BATT_VAUTO_RECHARGE; } millivolts = battery_voltage(); if (millivolts <= thresh) enable_charger(); break; } /* DISCHARGING: */ case CHARGING: { if ((ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH) == 0) { if (--charger_total_timer > 0) break; /* Timer ran out - require replug. */ charge_state = CHARGE_STATE_ERROR; } /* else end of charge */ disable_charger(); break; } /* CHARGING: */ default: /* DISABLED, ERROR */ break; } }