summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/agptek/powermgmt-agptek.c
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2017-04-27 11:36:40 +0200
committerMarcin Bukat <marcin.bukat@gmail.com>2018-06-12 10:31:14 +0200
commitd55680993df9b6743506814d98b5cc1859828f8a (patch)
tree054dc45425fa1a6863f154b484036f26cc3ac13f /firmware/target/hosted/agptek/powermgmt-agptek.c
parentbeef52c5f0832e2c36bb1523b51eb8721f851db5 (diff)
downloadrockbox-d55680993df9b6743506814d98b5cc1859828f8a.tar.gz
rockbox-d55680993df9b6743506814d98b5cc1859828f8a.zip
Agptek Rocker: Initial commit
Change-Id: I26b51106c7b1c36a603fba6d521e917d79b5a95b
Diffstat (limited to 'firmware/target/hosted/agptek/powermgmt-agptek.c')
-rw-r--r--firmware/target/hosted/agptek/powermgmt-agptek.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/firmware/target/hosted/agptek/powermgmt-agptek.c b/firmware/target/hosted/agptek/powermgmt-agptek.c
new file mode 100644
index 0000000000..3371d1e793
--- /dev/null
+++ b/firmware/target/hosted/agptek/powermgmt-agptek.c
@@ -0,0 +1,63 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2017 Marcin Bukat
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#include "powermgmt.h"
21#include "power.h"
22#include "power-agptek.h"
23
24const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
25{
26 3470
27};
28
29/* the OF shuts down at this voltage */
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 3400
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled
36 * NOTE: not calibrated simple linear scale for now
37 */
38const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
39{
40 { 3400, 3480, 3560, 3640, 3720, 3800, 3880, 3960, 4040, 4120, 4200 }
41};
42
43/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
44const unsigned short const percent_to_volt_charge[11] =
45{
46 3450, 3670, 3721, 3751, 3782, 3821, 3876, 3941, 4034, 4125, 4200
47};
48
49unsigned int power_input_status(void)
50{
51 /* POWER_INPUT_USB_CHARGER, POWER_INPUT_NONE */
52 return agptek_power_get_status();
53}
54
55int _battery_voltage(void)
56{
57 return agptek_power_get_battery_voltage();
58}
59
60bool charging_state(void)
61{
62 return agptek_power_get_status() == POWER_INPUT_USB_CHARGER;
63}