diff options
author | Kishor Krishna Bhat <kishkris@codeaurora.org> | 2020-07-21 10:41:45 +0530 |
---|---|---|
committer | Kishor Krishna Bhat <kishkris@codeaurora.org> | 2020-07-21 13:25:10 +0530 |
commit | 64d54abcc12eba17d4b6149fa58aa32bc8e804fa (patch) | |
tree | 83f9b350c393e90724b2ad7dc3299748f6076479 | |
parent | e9c0b83e0ab63f8efa01fa0a3ca85edf90611e5c (diff) |
power: qcom: Add the QPNP QGAUGE (QG) headers
The QG headers support for battery gauging and reporting
the battery specific parameters to userspace.
This is a snapshot of header files as of msm-4.9
'commit 8f7046d0c282 (" Merge msm: ep_pcie: Disable
clkreq interrupt and release wakelock in D3 cold")'.
Change-Id: I3288e71af24bf9c3a0d814014c4f653285622f14
Signed-off-by: Kishor Krishna Bhat <kishkris@codeaurora.org>
-rw-r--r-- | gen_headers_arm.bp | 2 | ||||
-rw-r--r-- | gen_headers_arm64.bp | 2 | ||||
-rw-r--r-- | include/uapi/linux/qg-profile.h | 68 | ||||
-rw-r--r-- | include/uapi/linux/qg.h | 63 |
4 files changed, 135 insertions, 0 deletions
diff --git a/gen_headers_arm.bp b/gen_headers_arm.bp index 9ee49cdfad39..9b6721d24b38 100644 --- a/gen_headers_arm.bp +++ b/gen_headers_arm.bp @@ -488,6 +488,8 @@ gen_headers_out_arm = [ "linux/qbt1000.h", "linux/qcedev.h", "linux/qcota.h", + "linux/qg-profile.h", + "linux/qg.h", "linux/qnx4_fs.h", "linux/qnxtypes.h", "linux/qrng.h", diff --git a/gen_headers_arm64.bp b/gen_headers_arm64.bp index e38d6166cbd0..db09deada714 100644 --- a/gen_headers_arm64.bp +++ b/gen_headers_arm64.bp @@ -486,6 +486,8 @@ gen_headers_out_arm64 = [ "linux/qbt1000.h", "linux/qcedev.h", "linux/qcota.h", + "linux/qg-profile.h", + "linux/qg.h", "linux/qnx4_fs.h", "linux/qnxtypes.h", "linux/qrng.h", diff --git a/include/uapi/linux/qg-profile.h b/include/uapi/linux/qg-profile.h new file mode 100644 index 000000000000..0230b3227f78 --- /dev/null +++ b/include/uapi/linux/qg-profile.h @@ -0,0 +1,68 @@ +#ifndef __QG_PROFILE_H__ +#define __QG_PROFILE_H__ + +#include <linux/ioctl.h> + +/** + * enum profile_table - Table index for battery profile data + */ +enum profile_table { + TABLE_SOC_OCV1, + TABLE_SOC_OCV2, + TABLE_FCC1, + TABLE_FCC2, + TABLE_Z1, + TABLE_Z2, + TABLE_Z3, + TABLE_Z4, + TABLE_Z5, + TABLE_Z6, + TABLE_Y1, + TABLE_Y2, + TABLE_Y3, + TABLE_Y4, + TABLE_Y5, + TABLE_Y6, + TABLE_MAX, +}; + +/** + * struct battery_params - Battery profile data to be exchanged + * @soc: SOC (state of charge) of the battery + * @ocv_uv: OCV (open circuit voltage) of the battery + * @batt_temp: Battery temperature in deci-degree + * @var: 'X' axis param for interpolation + * @table_index:Table index to be used for interpolation + */ +struct battery_params { + int soc; + int ocv_uv; + int fcc_mah; + int slope; + int var; + int batt_temp; + int table_index; +}; + +/* Profile MIN / MAX values */ +#define QG_MIN_SOC 0 +#define QG_MAX_SOC 10000 +#define QG_MIN_OCV_UV 3000000 +#define QG_MAX_OCV_UV 5000000 +#define QG_MIN_VAR 0 +#define QG_MAX_VAR 65535 +#define QG_MIN_FCC_MAH 100 +#define QG_MAX_FCC_MAH 16000 +#define QG_MIN_SLOPE 1 +#define QG_MAX_SLOPE 50000 +#define QG_ESR_SF_MIN 5000 +#define QG_ESR_SF_MAX 20000 + +/* IOCTLs to query battery profile data */ +#define BPIOCXSOC _IOWR('B', 0x01, struct battery_params) /* SOC */ +#define BPIOCXOCV _IOWR('B', 0x02, struct battery_params) /* OCV */ +#define BPIOCXFCC _IOWR('B', 0x03, struct battery_params) /* FCC */ +#define BPIOCXSLOPE _IOWR('B', 0x04, struct battery_params) /* Slope */ +#define BPIOCXVAR _IOWR('B', 0x05, struct battery_params) /* All-other */ + +#endif /* __QG_PROFILE_H__ */ diff --git a/include/uapi/linux/qg.h b/include/uapi/linux/qg.h new file mode 100644 index 000000000000..8bd220fbc6a8 --- /dev/null +++ b/include/uapi/linux/qg.h @@ -0,0 +1,63 @@ +#ifndef __QG_H__ +#define __QG_H__ + +#define MAX_FIFO_LENGTH 16 + +enum qg { + QG_SOC, + QG_OCV_UV, + QG_RBAT_MOHM, + QG_PON_OCV_UV, + QG_GOOD_OCV_UV, + QG_ESR, + QG_CHARGE_COUNTER, + QG_FIFO_TIME_DELTA, + QG_BATT_SOC, + QG_CC_SOC, + QG_ESR_CHARGE_DELTA, + QG_ESR_DISCHARGE_DELTA, + QG_ESR_CHARGE_SF, + QG_ESR_DISCHARGE_SF, + QG_FULL_SOC, + QG_CLEAR_LEARNT_DATA, + QG_SYS_SOC, + QG_VBMS_IBAT, + QG_MAX, +}; + +#define QG_BATT_SOC QG_BATT_SOC +#define QG_CC_SOC QG_CC_SOC +#define QG_ESR_CHARGE_DELTA QG_ESR_CHARGE_DELTA +#define QG_ESR_DISCHARGE_DELTA QG_ESR_DISCHARGE_DELTA +#define QG_ESR_CHARGE_SF QG_ESR_CHARGE_SF +#define QG_ESR_DISCHARGE_SF QG_ESR_DISCHARGE_SF +#define QG_FULL_SOC QG_FULL_SOC +#define QG_CLEAR_LEARNT_DATA QG_CLEAR_LEARNT_DATA +#define QG_SYS_SOC QG_SYS_SOC +#define QG_VBMS_IBAT QG_VBMS_IBAT + +struct fifo_data { + unsigned int v; + unsigned int i; + unsigned int count; + unsigned int interval; +}; + +struct qg_param { + unsigned int data; + bool valid; +}; + +struct qg_kernel_data { + unsigned int seq_no; + unsigned int fifo_time; + unsigned int fifo_length; + struct fifo_data fifo[MAX_FIFO_LENGTH]; + struct qg_param param[QG_MAX]; +}; + +struct qg_user_data { + struct qg_param param[QG_MAX]; +}; + +#endif |