Skip to content

Commit da28e18

Browse files
rriveramcrussre
authored andcommitted
power: supply: bq24190: Considers FORCE_20PCT when getting IPRECHG
Adds a check of the FORCE_20PCT bit when getting the precharge current value. According to the bit description for the FORCE_20PCT bit, when FORCE_20PCT is true, the precharge current target is 50% of what is configured in the IPRECHG bit field. Signed-off-by: Ricardo Rivera-Matos <rriveram@opensource.cirrus.com> Reviewed-by: David Rhodes <drhodes@opensource.cirrus.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 2ce8284 commit da28e18

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

drivers/power/supply/bq24190_charger.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,15 +965,28 @@ static int bq24190_charger_get_precharge(struct bq24190_dev_info *bdi,
965965
union power_supply_propval *val)
966966
{
967967
u8 v;
968-
int ret;
968+
int curr, ret;
969969

970970
ret = bq24190_read_mask(bdi, BQ24190_REG_PCTCC,
971971
BQ24190_REG_PCTCC_IPRECHG_MASK,
972972
BQ24190_REG_PCTCC_IPRECHG_SHIFT, &v);
973973
if (ret < 0)
974974
return ret;
975975

976-
val->intval = ++v * 128 * 1000;
976+
curr = ++v * 128 * 1000;
977+
978+
ret = bq24190_read_mask(bdi, BQ24190_REG_CCC,
979+
BQ24190_REG_CCC_FORCE_20PCT_MASK,
980+
BQ24190_REG_CCC_FORCE_20PCT_SHIFT, &v);
981+
if (ret < 0)
982+
return ret;
983+
984+
/* If FORCE_20PCT is enabled, then current is 50% of IPRECHG value */
985+
if (v)
986+
curr /= 2;
987+
988+
val->intval = curr;
989+
977990
return 0;
978991
}
979992

0 commit comments

Comments
 (0)