annotate src/cs/drivers/drv_app/fchg/fchg_ffs_init.c @ 327:d7b25dca1266

.../drv_core/abb/abb.c: don't set backup battery bits in BCICONF
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 08 Dec 2017 03:05:19 +0000
parents 919b44c991fc
children 8166b0afcf8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
325
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement the loading of the charging config
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * and the battery table from FFS.
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "fchg/fchg_env.h"
326
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
7 #include "fchg/fchg_func_i.h"
325
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "rv/rv_general.h"
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "rvf/rvf_api.h"
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "ffs/ffs_api.h"
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 void pwr_load_ffs_charging_config(void)
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 int rc;
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 rc = ffs_file_read("/etc/charging", &pwr_ctrl->config,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 sizeof(struct charging_config));
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (rc == sizeof(struct charging_config)) {
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 pwr_ctrl->config_present = TRUE;
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 rvf_send_trace(
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 "FCHG: read charging config from FFS, charging enabled", 53,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 FCHG_USE_ID);
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 } else {
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 pwr_ctrl->config_present = FALSE;
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 rvf_send_trace(
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 "FCHG: no charging config in FFS, will not charge", 48,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 NULL_PARAM, RV_TRACE_LEVEL_WARNING,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 FCHG_USE_ID);
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
326
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
32
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
33 void pwr_load_ffs_batt_table(void)
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
34 {
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
35 int rc;
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
36
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
37 rc = ffs_file_read("/etc/batterytab", pwr_ctrl->batt_thresholds,
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
38 sizeof(pwr_ctrl->batt_thresholds));
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
39 if (rc >= sizeof(T_PWR_THRESHOLDS)) {
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
40 pwr_ctrl->nb_thresholds = rc / sizeof(T_PWR_THRESHOLDS);
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
41 rvf_send_trace("FCHG: battery table loaded from FFS", 35,
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
42 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
43 FCHG_USE_ID);
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
44 } else {
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
45 pwr_set_default_batt_table();
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
46 rvf_send_trace("FCHG: using compiled-in default battery table",
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
47 45, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
48 FCHG_USE_ID);
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
49 }
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
50 }