From 732c47ee0d3987202655501cd7c5d8878b7510f5 Mon Sep 17 00:00:00 2001 From: Eric Kuzmenko <eric.kuzmenko@puri.sm> Date: Tue, 7 May 2019 17:45:45 -0400 Subject: [PATCH] power: supply: bq25890: Add support for setting bq25890 and bq25896's VINDPM The bq25890 has low voltage protection on VIN. Allow the register to be set from the device tree. Signed-off-by: Eric Kuzmenko <eric.kuzmenko@puri.sm> Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca> --- drivers/power/supply/bq25890_charger.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index b2ff82b4707a6..160c3a104933c 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -65,6 +65,8 @@ struct bq25890_init_data { u8 boosti; /* boost current limit */ u8 boostf; /* boost frequency */ u8 ilim_en; /* enable ILIM pin */ + u8 force_vindpm;/* force vinmin threshold */ + u8 vindpm; /* vinmin threshold */ u8 treg; /* thermal regulation threshold */ }; @@ -240,6 +242,8 @@ enum bq25890_table_ids { TBL_VREG, TBL_BOOSTV, TBL_SYSVMIN, + TBL_FORCE_VINDPM, + TBL_VINDPM, /* lookup tables */ TBL_TREG, @@ -274,11 +278,13 @@ static const union { struct bq25890_lookup lt; } bq25890_tables[] = { /* range tables */ - [TBL_ICHG] = { .rt = {0, 5056000, 64000} }, /* uA */ - [TBL_ITERM] = { .rt = {64000, 1024000, 64000} }, /* uA */ - [TBL_VREG] = { .rt = {3840000, 4608000, 16000} }, /* uV */ - [TBL_BOOSTV] = { .rt = {4550000, 5510000, 64000} }, /* uV */ - [TBL_SYSVMIN] = { .rt = {3000000, 3700000, 100000} }, /* uV */ + [TBL_ICHG] = { .rt = {0, 5056000, 64000} }, /* uA */ + [TBL_ITERM] = { .rt = {64000, 1024000, 64000} }, /* uA */ + [TBL_VREG] = { .rt = {3840000, 4608000, 16000} }, /* uV */ + [TBL_BOOSTV] = { .rt = {4550000, 5510000, 64000} }, /* uV */ + [TBL_SYSVMIN] = { .rt = {3000000, 3700000, 100000} }, /* uV */ + [TBL_FORCE_VINDPM] = { .rt = {0, 1, 1} }, /* on/off */ + [TBL_VINDPM] = { .rt = {2600000, 15300000, 100000} }, /* uV */ /* lookup tables */ [TBL_TREG] = { .lt = {bq25890_treg_tbl, BQ25890_TREG_TBL_SIZE} }, @@ -611,6 +617,8 @@ static int bq25890_hw_init(struct bq25890_device *bq) {F_BOOSTI, bq->init_data.boosti}, {F_BOOSTF, bq->init_data.boostf}, {F_EN_ILIM, bq->init_data.ilim_en}, + {F_FORCE_VINDPM, bq->init_data.force_vindpm}, + {F_VINDPM, bq->init_data.vindpm}, {F_TREG, bq->init_data.treg} }; @@ -773,6 +781,8 @@ static int bq25890_fw_read_u32_props(struct bq25890_device *bq) {"ti,boost-max-current", false, TBL_BOOSTI, &init->boosti}, /* optional properties */ + {"ti,use-vinmin-threshold", true, TBL_FORCE_VINDPM, &init->force_vindpm}, + {"ti,vinmin-threshold", true, TBL_VINDPM, &init->vindpm}, {"ti,thermal-regulation-threshold", true, TBL_TREG, &init->treg} }; -- GitLab