power: qpnp-fg-gen3: fix SRAM encodings

There are some encoding changes to the following configurations
in pmi8998 SRAM. Update them.

For both v1.1 and v2.0,
- No sign bit for charge termination current

For v2.0,
- 6 bit encoding for empty voltage and vbatt_low

While at it, fix the SRAM byte location from byte 2 to byte 3 for
configuring empty voltage threshold in pmi8998v2.0.

CRs-Fixed: 1068592
Change-Id: I3a301aed1b23ab78aa86b24c11eb750502adab2f
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
Subbaraman Narayanamurthy 2016-09-19 11:17:59 -07:00
parent 3603cc87ba
commit ff753ada17
2 changed files with 10 additions and 8 deletions

View file

@ -78,7 +78,9 @@ First Level Node - FG Gen3 device
Definition: Battery current (in mA) at which the fuel gauge will try to
scale towards 100%. When the charge current goes above this
the SOC should be at 100%. If this property is not
specified, then the default value used will be 125mA.
specified, then the default value used will be -125mA.
This value has to be specified in negative values for
the charging current.
- qcom,fg-delta-soc-thr
Usage: optional

View file

@ -84,7 +84,7 @@
#define CHG_TERM_CURR_v2_WORD 15
#define CHG_TERM_CURR_v2_OFFSET 1
#define EMPTY_VOLT_v2_WORD 15
#define EMPTY_VOLT_v2_OFFSET 2
#define EMPTY_VOLT_v2_OFFSET 3
#define VBATT_LOW_v2_WORD 16
#define VBATT_LOW_v2_OFFSET 0
@ -164,10 +164,10 @@ static struct fg_sram_param pmicobalt_v2_sram_params[] = {
/* Entries below here are configurable during initialization */
PARAM(CUTOFF_VOLT, CUTOFF_VOLT_WORD, CUTOFF_VOLT_OFFSET, 2, 1000000,
244141, 0, fg_encode_voltage, NULL),
PARAM(EMPTY_VOLT, EMPTY_VOLT_v2_WORD, EMPTY_VOLT_v2_OFFSET, 1, 100000,
390625, -2000, fg_encode_voltage, NULL),
PARAM(VBATT_LOW, VBATT_LOW_v2_WORD, VBATT_LOW_v2_OFFSET, 1, 100000,
390625, -2000, fg_encode_voltage, NULL),
PARAM(EMPTY_VOLT, EMPTY_VOLT_v2_WORD, EMPTY_VOLT_v2_OFFSET, 1, 1000,
15625, -2000, fg_encode_voltage, NULL),
PARAM(VBATT_LOW, VBATT_LOW_v2_WORD, VBATT_LOW_v2_OFFSET, 1, 1000,
15625, -2000, fg_encode_voltage, NULL),
PARAM(SYS_TERM_CURR, SYS_TERM_CURR_WORD, SYS_TERM_CURR_OFFSET, 3,
1000000, 122070, 0, fg_encode_current, NULL),
PARAM(CHG_TERM_CURR, CHG_TERM_CURR_v2_WORD, CHG_TERM_CURR_v2_OFFSET, 1,
@ -477,7 +477,7 @@ static void fg_encode_current(struct fg_sram_param *sp,
int64_t temp;
s64 current_ma;
current_ma = -val;
current_ma = val;
temp = (int64_t)div_s64(current_ma * sp[id].numrtr, sp[id].denmtr);
pr_debug("temp: %llx id: %d, val: %d, buf: [ ", temp, id, val);
for (i = 0; i < sp[id].len; i++) {
@ -1343,7 +1343,7 @@ static int fg_register_interrupts(struct fg_chip *chip)
#define DEFAULT_CUTOFF_VOLT_MV 3200
#define DEFAULT_EMPTY_VOLT_MV 3100
#define DEFAULT_CHG_TERM_CURR_MA 100
#define DEFAULT_SYS_TERM_CURR_MA 125
#define DEFAULT_SYS_TERM_CURR_MA -125
#define DEFAULT_DELTA_SOC_THR 1
#define DEFAULT_RECHARGE_SOC_THR 95
#define DEFAULT_BATT_TEMP_COLD 0