google_ttf: fix estimates while AC is on

Use the health vtier when AC is enabled and fix a bug in the
calculation of the ratio when available power is under soc
demand.

Also remove the trigger on rest voltage (not used), simplify
code and interface, log health charging state to the ttf
logbuffer and add sysfs nodes to check trigger and time to ac.

Use simple_strtol() when parsing the deadline

Bug: 163087907
Test: patchwork, device
Signed-off-by: AleX Pelosi <[email protected]>
Change-Id: Ieee150c62c80ff75f1688a53ab1508ef321e7c44
Signed-off-by: Ken Tsou <[email protected]>
(cherry picked from commit e1012a3dea3b58c6f497a36a5fdab49f377c3a9e)
diff --git a/google_bms.h b/google_bms.h
index 0b2e901..b1e2979 100644
--- a/google_bms.h
+++ b/google_bms.h
@@ -260,6 +260,12 @@
 	int rest_fv_uv;
 };
 
+#define CHG_HEALTH_REST_IS_ACTIVE(rest) \
+	((rest)->rest_state == CHG_HEALTH_ACTIVE)
+
+#define CHG_HEALTH_REST_SOC(rest) (((rest)->always_on_soc != -1) ? \
+			(rest)->always_on_soc : (rest)->rest_soc)
+
 struct gbms_charging_event {
 	union gbms_ce_adapter_details	adapter_details;
 
@@ -279,8 +285,8 @@
 	uint32_t chg_sts_delta_soc;
 
 	/* health based charging */
-	struct batt_chg_health		chg_health;
-	struct gbms_ce_tier_stats	health_stats;
+	struct batt_chg_health		ce_health;	/* updated on close */
+	struct gbms_ce_tier_stats	health_stats;	/* updated in HC */
 };
 
 #define GBMS_CCCM_LIMITS(profile, ti, vi) \