1
1
// SPDX-License-Identifier: GPL-3.0-only
2
2
3
3
#include <board/battery.h>
4
+ #include <board/options.h>
4
5
#include <board/smbus.h>
5
6
#include <common/debug.h>
6
7
@@ -13,41 +14,31 @@ uint16_t battery_charger_input_voltage = BATTERY_CHARGER_VOLTAGE_AC;
13
14
#define BATTERY_START_DEFAULT 0
14
15
#define BATTERY_END_DEFAULT 100
15
16
16
- // Represents a battery percentage level, below which charging will begin.
17
- // Valid values are [0, 100]
18
- // A value of 0 turns off the start threshold control.
19
- static uint8_t battery_start_threshold = BATTERY_START_THRESHOLD ;
20
-
21
- // Represents a battery percentage level, above which charging will stop.
22
- // Valid values are [0, 100]
23
- // A value of 100 turns off the stop threshold control.
24
- static uint8_t battery_end_threshold = BATTERY_END_THRESHOLD ;
25
-
26
17
uint8_t battery_get_start_threshold (void ) {
27
- if (battery_start_threshold > 100 )
18
+ if (options_get ( OPT_BAT_THRESHOLD_START ) > 100 )
28
19
return BATTERY_START_DEFAULT ;
29
- return battery_start_threshold ;
20
+ return options_get ( OPT_BAT_THRESHOLD_START ) ;
30
21
}
31
22
32
23
bool battery_set_start_threshold (uint8_t value ) {
33
- if (value > 100 || value >= battery_end_threshold )
24
+ if (value > 100 || value >= options_get ( OPT_BAT_THRESHOLD_STOP ) )
34
25
return false;
35
26
36
- battery_start_threshold = value ;
27
+ options_set ( OPT_BAT_THRESHOLD_START , value ) ;
37
28
return true;
38
29
}
39
30
40
31
uint8_t battery_get_end_threshold (void ) {
41
- if (battery_end_threshold > 100 )
32
+ if (options_get ( OPT_BAT_THRESHOLD_STOP ) > 100 )
42
33
return BATTERY_END_DEFAULT ;
43
- return battery_end_threshold ;
34
+ return options_get ( OPT_BAT_THRESHOLD_STOP ) ;
44
35
}
45
36
46
37
bool battery_set_end_threshold (uint8_t value ) {
47
- if (value > 100 || value <= battery_start_threshold )
38
+ if (value > 100 || value <= options_get ( OPT_BAT_THRESHOLD_START ) )
48
39
return false;
49
40
50
- battery_end_threshold = value ;
41
+ options_set ( OPT_BAT_THRESHOLD_STOP , value ) ;
51
42
return true;
52
43
}
53
44
@@ -98,8 +89,3 @@ void battery_event(void) {
98
89
99
90
battery_charger_event ();
100
91
}
101
-
102
- void battery_reset (void ) {
103
- battery_start_threshold = BATTERY_START_THRESHOLD ;
104
- battery_end_threshold = BATTERY_END_THRESHOLD ;
105
- }
0 commit comments