Skip to contentSkip to conversation

power: bq25890: IBAT compensation support

PATCH In review Michał Mirosław 3 participants 5 messages Sep 26, 2020 – Sep 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover power: bq25890: IBAT compensation support

These two patches add support for IBAT compensation feature of bq2589x chargers.

---
v4 fixed property names for the features and dropped other applied or rejected
patches

Michał Mirosław (2):
power: bq25890: document IBAT compensation DT properties
power: bq25890: support IBAT compensation

 .../devicetree/bindings/power/supply/bq25890.txt  |  4 ++++
 drivers/power/supply/bq25890_charger.c            | 15 +++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v4 1/2 power: bq25890: document IBAT compensation DT properties

Document new properties for IBAT compensation feature.

---
v2: initial version
v4: renamed properties applying property-suffix

---
 Documentation/devicetree/bindings/power/supply/bq25890.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/power/supply/bq25890.txt +4 -0
index 3b4c69a7fa70..805040c6fff9 100644
@@ -33,6 +33,10 @@ Optional properties:
 - ti,thermal-regulation-threshold: integer, temperature above which the charge
     current is lowered, to avoid overheating (in degrees Celsius). If omitted,
     the default setting will be used (120 degrees);
+- ti,ibatcomp-micro-ohms: integer, value of a resistor in series with
+    the battery;
+- ti,ibatcomp-clamp-microvolt: integer, maximum charging voltage adjustment due
+    to expected voltage drop on in-series resistor;
 
 Example:
 
Signature · 1 line
2.20.1
maintainer Reviewed-by on v4 1/2
#2 lore raw

Re: [PATCH v4 1/2] power: bq25890: document IBAT compensation DT properties

Quoted 10 lines · Michał Mirosław

Document new properties for IBAT compensation feature.

---
v2: initial version
v4: renamed properties applying property-suffix

---
 Documentation/devicetree/bindings/power/supply/bq25890.txt | 4 ++++
 1 file changed, 4 insertions(+)
#3 lore raw

PATCH v4 2/2 power: bq25890: support IBAT compensation

In reply to Michał Mirosław

Add configuration for compensation of IBAT measuring resistor in series with the battery.

---
v4: renamed properties applying property-suffix

---
 drivers/power/supply/bq25890_charger.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/power/supply/bq25890_charger.c +13 -2
index 77150667e36b..ab8398f935c5 100644
@@ -83,6 +83,8 @@ struct bq25890_init_data {
 	u8 boostf;	/* boost frequency		*/
 	u8 ilim_en;	/* enable ILIM pin		*/
 	u8 treg;	/* thermal regulation threshold */
+	u8 rbatcomp;	/* IBAT sense resistor value    */
+	u8 vclamp;	/* IBAT compensation voltage limit */
 };
 
 struct bq25890_state {
@@ -258,6 +260,8 @@ enum bq25890_table_ids {
 	TBL_VREG,
 	TBL_BOOSTV,
 	TBL_SYSVMIN,
+	TBL_VBATCOMP,
+	TBL_RBATCOMP,
 
 	/* lookup tables */
 	TBL_TREG,
@@ -299,6 +303,8 @@ static const union {
 	[TBL_VREG] =	{ .rt = {3840000, 4608000, 16000} },	 /* uV */
 	[TBL_BOOSTV] =	{ .rt = {4550000, 5510000, 64000} },	 /* uV */
 	[TBL_SYSVMIN] = { .rt = {3000000, 3700000, 100000} },	 /* uV */
+	[TBL_VBATCOMP] ={ .rt = {0,        224000, 32000} },	 /* uV */
+	[TBL_RBATCOMP] ={ .rt = {0,        140000, 20000} },	 /* uOhm */
 
 	/* lookup tables */
 	[TBL_TREG] =	{ .lt = {bq25890_treg_tbl, BQ25890_TREG_TBL_SIZE} },
@@ -648,7 +654,9 @@ 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_TREG,	 bq->init_data.treg}
+		{F_TREG,	 bq->init_data.treg},
+		{F_BATCMP,	 bq->init_data.rbatcomp},
+		{F_VCLAMP,	 bq->init_data.vclamp},
 	};
 
 	ret = bq25890_chip_reset(bq);
@@ -859,11 +867,14 @@ static int bq25890_fw_read_u32_props(struct bq25890_device *bq)
 		{"ti,boost-max-current", false, TBL_BOOSTI, &init->boosti},
 
 		/* optional properties */
-		{"ti,thermal-regulation-threshold", true, TBL_TREG, &init->treg}
+		{"ti,thermal-regulation-threshold", true, TBL_TREG, &init->treg},
+		{"ti,ibatcomp-micro-ohms", true, TBL_RBATCOMP, &init->rbatcomp},
+		{"ti,ibatcomp-clamp-microvolt", true, TBL_VBATCOMP, &init->vclamp},
 	};
 
 	/* initialize data for optional properties */
 	init->treg = 3; /* 120 degrees Celsius */
+	init->rbatcomp = init->vclamp = 0; /* IBAT compensation disabled */
 
 	for (i = 0; i < ARRAY_SIZE(props); i++) {
 		ret = device_property_read_u32(bq->dev, props[i].name,
Signature · 1 line
2.20.1
#4 lore raw
In reply to Michał Mirosław

Hi,

Quoted 2 lines · Michał Mirosław

These two patches add support for IBAT compensation feature of bq2589x chargers.

Thanks, queued.

-- Sebastian

Quoted 14 lines

v4 fixed property names for the features and dropped other applied or rejected
patches

Michał Mirosław (2):
power: bq25890: document IBAT compensation DT properties
power: bq25890: support IBAT compensation

 .../devicetree/bindings/power/supply/bq25890.txt  |  4 ++++
 drivers/power/supply/bq25890_charger.c            | 15 +++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1