summaryrefslogtreecommitdiff
path: root/utils/nwztools/plattools/nwz_power.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/nwztools/plattools/nwz_power.h')
-rw-r--r--utils/nwztools/plattools/nwz_power.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/utils/nwztools/plattools/nwz_power.h b/utils/nwztools/plattools/nwz_power.h
new file mode 100644
index 0000000000..e8df47a3d6
--- /dev/null
+++ b/utils/nwztools/plattools/nwz_power.h
@@ -0,0 +1,82 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef __NWZ_POWER_H__
22#define __NWZ_POWER_H__
23
24#define NWZ_POWER_DEV "/dev/icx_power"
25
26#define NWZ_POWER_TYPE 'P'
27
28/* ioctl request */
29#define NWZ_POWER_GET_STATUS _IOR(NWZ_POWER_TYPE, 0, int *)
30#define NWZ_POWER_SET_VBUS_LIMIT _IOW(NWZ_POWER_TYPE, 1, int *)
31#define NWZ_POWER_GET_BAT_ADVAL _IOR(NWZ_POWER_TYPE, 2, int *)
32#define NWZ_POWER_GET_BAT_GAUGE _IOR(NWZ_POWER_TYPE, 3, int *)
33#define NWZ_POWER_ENABLE_CHARGER _IOW(NWZ_POWER_TYPE, 4, int *)
34#define NWZ_POWER_ENABLE_DEBUG_PORT _IO (NWZ_POWER_TYPE, 5)
35#define NWZ_POWER_IS_FULLY_CHARGED _IOR(NWZ_POWER_TYPE, 6, int *)
36#define NWZ_POWER_AVG_VALUE _IO (NWZ_POWER_TYPE, 7)
37#define NWZ_POWER_CONSIDERATION_CHARGE _IOW(NWZ_POWER_TYPE, 8, int)
38#define NWZ_POWER_GET_VBUS_LIMIT _IOR(NWZ_POWER_TYPE, 9, int *)
39#define NWZ_POWER_GET_CHARGE_SWITCH _IOR(NWZ_POWER_TYPE,10, int *)
40#define NWZ_POWER_GET_SAMPLE_COUNT _IOR(NWZ_POWER_TYPE,11, int *)
41#define NWZ_POWER_SET_CHARGE_CURRENT _IOW(NWZ_POWER_TYPE,12, int *)
42#define NWZ_POWER_GET_CHARGE_CURRENT _IOR(NWZ_POWER_TYPE,13, int *)
43#define NWZ_POWER_GET_VBUS_ADVAL _IOR(NWZ_POWER_TYPE,14, int *)
44#define NWZ_POWER_GET_VSYS_ADVAL _IOR(NWZ_POWER_TYPE,15, int *)
45#define NWZ_POWER_GET_VBAT_ADVAL _IOR(NWZ_POWER_TYPE,16, int *)
46#define NWZ_POWER_CHG_VBUS_LIMIT _IOW(NWZ_POWER_TYPE,17, int *)
47#define NWZ_POWER_SET_ACCESSARY_CHARGE_MODE _IOW(NWZ_POWER_TYPE,18, int *)
48#define NWZ_POWER_GET_ACCESSARY_CHARGE_MODE _IOR(NWZ_POWER_TYPE,19, int *)
49
50/* NWZ_POWER_GET_STATUS bitmap */
51#define NWZ_POWER_STATUS_CHARGE_INIT 0x100 /* initializing charging */
52#define NWZ_POWER_STATUS_CHARGE_STATUS 0x0c0 /* charging status mask */
53#define NWZ_POWER_STATUS_VBUS_DET 0x020 /* vbus detected */
54#define NWZ_POWER_STATUS_AC_DET 0x010 /* ac adapter detected */
55#define NWZ_POWER_STATUS_CHARGE_LOW 0x001 /* full voltage of 4.1 instead of 4.2 */
56/* NWZ_POWER_STATUS_CHARGING_MASK value */
57#define NWZ_POWER_STATUS_CHARGE_STATUS_CHARGING 0xc0
58#define NWZ_POWER_STATUS_CHARGE_STATUS_SUSPEND 0x80
59#define NWZ_POWER_STATUS_CHARGE_STATUS_TIMEOUT 0x40
60#define NWZ_POWER_STATUS_CHARGE_STATUS_NORMAL 0x00
61
62/* base values to convert from adval to mV (represents mV for adval of 255) */
63#define NWZ_POWER_AD_BASE_VBAT 4664
64#define NWZ_POWER_AD_BASE_VBUS 7254
65#define NWZ_POWER_AD_BASE_VSYS 5700
66
67/* battery gauge */
68#define NWZ_POWER_BAT_NOBAT -100 /* no battery */
69#define NWZ_POWER_BAT_VERYLOW -99 /* very low */
70#define NWZ_POWER_BAT_LOW 0 /* low */
71#define NWZ_POWER_BAT_GAUGE0 1 /* ____ */
72#define NWZ_POWER_BAT_GAUGE1 2 /* O___ */
73#define NWZ_POWER_BAT_GAUGE2 3 /* OO__ */
74#define NWZ_POWER_BAT_GAUGE3 4 /* OOO_ */
75#define NWZ_POWER_BAT_GAUGE4 5 /* OOOO */
76
77/* NWZ_POWER_GET_ACCESSARY_CHARGE_MODE */
78#define NWZ_POWER_ACC_CHARGE_NONE 0
79#define NWZ_POWER_ACC_CHARGE_VBAT 1
80#define NWZ_POWER_ACC_CHARGE_VSYS 2
81
82#endif /* __NWZ_POWER_H__ */