FreeCalypso > hg > fc-tourmaline
annotate src/cs/drivers/drv_app/fchg/fchg_ffs_init.c @ 281:a75eefbf8be4
Phone boot with PWON: weed out short button presses
Every standard end user phone has a design provision, most naturally
implemented in firmware, whereby the PWON button effects a boot only
if it is held down long enough - short presses of this PWON button
are detected, assumed to be spurious and cause the fw to power back off
instead of proceeding with boot. The present change introduces this
standard function in FreeCalypso.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 24 Sep 2021 02:03:08 +0000 |
parents | 769cf6273fe4 |
children |
rev | line source |
---|---|
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we implement the loading of the charging config |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * and the battery table from FFS. |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include "fchg/fchg_env.h" |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "fchg/fchg_func_i.h" |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "rv/rv_general.h" |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "rvf/rvf_api.h" |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "rvm/rvm_use_id_list.h" |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "ffs/ffs_api.h" |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 void pwr_load_ffs_charging_config(void) |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 { |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int rc; |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 rc = ffs_file_read("/etc/charging", &pwr_ctrl->config, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 sizeof(struct charging_config)); |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 if (rc == sizeof(struct charging_config)) { |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 pwr_ctrl->config_present = TRUE; |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 rvf_send_trace( |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 "FCHG: read charging config from FFS, charging enabled", 53, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 FCHG_USE_ID); |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 } else { |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 pwr_ctrl->config_present = FALSE; |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 rvf_send_trace( |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 "FCHG: no charging config in FFS, will not charge", 48, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 NULL_PARAM, RV_TRACE_LEVEL_WARNING, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 FCHG_USE_ID); |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 void pwr_load_ffs_batt_table(void) |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 { |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 int rc; |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
61
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
38 rc = ffs_file_read("/etc/batterytab2", &pwr_ctrl->batt, |
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
39 sizeof(struct battery_config)); |
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
40 if (rc >= (int)(sizeof(T_PWR_THRESHOLDS) * MIN_PERCENT_THRESH + 4)) { |
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
41 pwr_ctrl->nb_percent_thresh = |
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
42 (rc - 4) / sizeof(T_PWR_THRESHOLDS); |
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 rvf_send_trace("FCHG: battery table loaded from FFS", 35, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 FCHG_USE_ID); |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } else { |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 pwr_set_default_batt_table(); |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 rvf_send_trace("FCHG: using compiled-in default battery table", |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 45, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 FCHG_USE_ID); |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
253
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
53 |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
54 void pwr_check_ffs_bsim(void) |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
55 { |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
56 int rc; |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
57 |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
58 rc = ffs_file_read("/etc/batterysim", &pwr_ctrl->bsim, |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
59 sizeof(struct bsim_config)); |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
60 if (rc == sizeof(struct bsim_config)) { |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
61 pwr_ctrl->bsim_mode = TRUE; |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
62 rvf_send_trace( |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
63 "FCHG: operating in battery simulation mode per FFS config!", |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
64 58, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
65 FCHG_USE_ID); |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
66 } else { |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
67 pwr_ctrl->bsim_mode = FALSE; |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
68 } |
769cf6273fe4
FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
61
diff
changeset
|
69 } |