FreeCalypso > hg > fc-magnetite
annotate src/cs/drivers/drv_app/fchg/fchg_ffs_init.c @ 673:62a5285e014a
Lorekeeping: allow tpudrv-leonardo.lib on Leonardo/Tango
Back in 2015 the Mother's idea was to produce a FreeCalypso development
board that would be a clone of TI Leonardo, including the original
quadband RFFE; one major additional stipulation was that this board
needed to be able to run original unmodified TCS211-20070608 firmware
with all blobs intact, with only minimal binary patches to main.lib
and tpudrv.lib. The necessary patched libs were produced at that time
in the tcs211-patches repository.
That plan was changed and we produced FCDEV3B instead, with Openmoko's
triband RFFE instead of Leonardo quadband, but when FC Magnetite started
in 2016, a TPUDRV_blob= provision was still made, allowing the possibility
of patching OM's tpudrv.lib for a restored Leonardo RFFE.
Now in 2020 we have FC Tango which is essentially a verbatim clone of
Leonardo core, including the original quadband RFFE. We have also
deblobbed our firmware so much that we have absolutely no real need
for a blob version of tpudrv.lib - but I thought it would be neat to put
the ancient TPUDRV_blob= mechanism (classic config) to its originally
intended use, just for the heck of it.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 29 May 2020 03:55:36 +0000 |
parents | 562fa85c8963 |
children |
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" |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
326
diff
changeset
|
10 #include "rvm/rvm_use_id_list.h" |
325
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "ffs/ffs_api.h" |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 void pwr_load_ffs_charging_config(void) |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 { |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int rc; |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 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
|
18 sizeof(struct charging_config)); |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 if (rc == sizeof(struct charging_config)) { |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 pwr_ctrl->config_present = TRUE; |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 rvf_send_trace( |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 "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
|
23 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 FCHG_USE_ID); |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 } else { |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 pwr_ctrl->config_present = FALSE; |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 rvf_send_trace( |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 "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
|
29 NULL_PARAM, RV_TRACE_LEVEL_WARNING, |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 FCHG_USE_ID); |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
326
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
33 |
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
34 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
|
35 { |
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
36 int rc; |
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
37 |
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
38 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
|
39 sizeof(pwr_ctrl->batt_thresholds)); |
344
562fa85c8963
FCHG battery table loading: comparison signedness issue
Mychaela Falconia <falcon@freecalypso.org>
parents:
331
diff
changeset
|
40 if (rc >= (int)sizeof(T_PWR_THRESHOLDS)) { |
326
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
41 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
|
42 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
|
43 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
|
44 FCHG_USE_ID); |
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
45 } else { |
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
46 pwr_set_default_batt_table(); |
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
47 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
|
48 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
|
49 FCHG_USE_ID); |
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
50 } |
919b44c991fc
FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
51 } |