From e7232435be5a4a00592cbd9d86fc263874ba2bb4 Mon Sep 17 00:00:00 2001 From: Kenny Kessler Date: Mon, 18 Mar 2019 19:09:02 -0500 Subject: [PATCH] power: max17xxx: Fix Initialization The Initialization of some undocuemnted registers is wrong. Fix this so that the correct encoding and conversions are used. The latest maxim supplied spec sheets state that 0x46 should be 0xC80 and that 0x45 should be 1/16th of FullCapNom. Also it seems that it should be 1/16th of the Register FullCapNom not the actual mAh. To do this the Rsense conversion will be applied prior to writing. Change-Id: Ica801e4f57e7070c4b56b87cd45f607b40ea5530 Signed-off-by: Kenny Kessler Reviewed-on: https://gerrit.mot.com/1322357 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Ryan Lattrel Reviewed-by: Ling Jin Reviewed-by: Kenneth Kessler Reviewed-by: Curtis Porter Submit-Approved: Jira Key --- drivers/power/max170xx/max170xx_battery_mmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/power/max170xx/max170xx_battery_mmi.c b/drivers/power/max170xx/max170xx_battery_mmi.c index 3e8e02d77aa7..bf9d84c45b2b 100644 --- a/drivers/power/max170xx/max170xx_battery_mmi.c +++ b/drivers/power/max170xx/max170xx_battery_mmi.c @@ -72,9 +72,8 @@ #define MODEL_LOCK1 0X0000 #define MODEL_LOCK2 0X0000 -#define dQ_ACC_DIV 0x4 -#define dP_ACC_100 0x1900 -#define dP_ACC_200 0x3200 +#define dQ_ACC_DIV 16 +#define dP_ACC_200 0xC80 #define MAX17050_CFG_REV_REG MAX17042_ManName #define MAX17050_CFG_REV_MASK 0x0007 @@ -900,7 +899,8 @@ static void max17042_load_new_capacity_params(struct max17042_chip *chip) max17042_write_verify_reg(map, MAX17042_RepCap, rep_cap); /* Write dQ_acc to 200% of Capacity and dP_acc to 200% */ - dq_acc = config->fullcap / dQ_ACC_DIV; + dq_acc = CHRG_CONV_WR(chip->fctr_uah_bit, + config->fullcapnom) / dQ_ACC_DIV; max17042_write_verify_reg(map, MAX17042_dQacc, dq_acc); max17042_write_verify_reg(map, MAX17042_dPacc, dP_ACC_200);