Skip to contentSkip to conversation

Add MAX17055 fuel guage

PATCH In review Angus Ainslie (Purism) 3 participants 6 messages Dec 14, 2019 – Dec 19, 2019

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

v2 cover Add MAX17055 fuel guage

Extend the max17042_battery driver to include the MAX17055.

Changes since v1:

Change blacklist driver checks to whitelists.

Angus Ainslie (Purism) (2):
power: supply: max17042: add MAX17055 support
device-tree: bindings: max17042_battery: add all of the compatible
strings

 .../power/supply/max17042_battery.txt         |  6 ++-
 drivers/power/supply/max17042_battery.c       | 17 +++++--
 include/linux/power/max17042_battery.h        | 48 ++++++++++++++++++-
 3 files changed, 66 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/2 power: supply: max17042: add MAX17055 support

The MAX17055 is very similar to the MAX17042 so extend the driver.

---
 drivers/power/supply/max17042_battery.c | 17 +++++++--
 include/linux/power/max17042_battery.h  | 48 ++++++++++++++++++++++++-
 2 files changed, 61 insertions(+), 4 deletions(-)
drivers/power/supply/max17042_battery.c +14 -3
index 0dfad2cf13fe..69ec4295d55d 100644
@@ -282,6 +282,8 @@ static int max17042_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
 		if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17042)
 			ret = regmap_read(map, MAX17042_V_empty, &data);
+		else if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055)
+			ret = regmap_read(map, MAX17055_V_empty, &data);
 		else
 			ret = regmap_read(map, MAX17047_V_empty, &data);
 		if (ret < 0)
@@ -627,7 +629,8 @@ static void max17042_write_config_regs(struct max17042_chip *chip)
 			config->filter_cfg);
 	regmap_write(map, MAX17042_RelaxCFG, config->relax_cfg);
 	if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047 ||
-			chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050)
+			chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050 ||
+			chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055)
 		regmap_write(map, MAX17047_FullSOCThr,
 						config->full_soc_thresh);
 }
@@ -758,6 +761,8 @@ static inline void max17042_override_por_values(struct max17042_chip *chip)
 
 	if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17042)
 		max17042_override_por(map, MAX17042_V_empty, config->vempty);
+	if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055)
+		max17042_override_por(map, MAX17055_V_empty, config->vempty);
 	else
 		max17042_override_por(map, MAX17047_V_empty, config->vempty);
 	max17042_override_por(map, MAX17042_TempNom, config->temp_nom);
@@ -765,7 +770,10 @@ static inline void max17042_override_por_values(struct max17042_chip *chip)
 	max17042_override_por(map, MAX17042_FCTC, config->fctc);
 	max17042_override_por(map, MAX17042_RCOMP0, config->rcomp0);
 	max17042_override_por(map, MAX17042_TempCo, config->tcompc0);
-	if (chip->chip_type) {
+	if (chip->chip_type &&
+	    ((chip->chip_type == MAXIM_DEVICE_TYPE_MAX17042) ||
+	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047) ||
+	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050))) {
 		max17042_override_por(map, MAX17042_EmptyTempCo,
 						config->empty_tempco);
 		max17042_override_por(map, MAX17042_K_empty0,
@@ -929,7 +937,8 @@ max17042_get_default_pdata(struct max17042_chip *chip)
 	if (!pdata)
 		return pdata;
 
-	if (chip->chip_type != MAXIM_DEVICE_TYPE_MAX17042) {
+	if ((chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047) ||
+	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050)) {
 		pdata->init_data = max17047_default_pdata_init_regs;
 		pdata->num_init_data =
 			ARRAY_SIZE(max17047_default_pdata_init_regs);
@@ -1167,6 +1176,7 @@ static const struct of_device_id max17042_dt_match[] = {
 	{ .compatible = "maxim,max17042" },
 	{ .compatible = "maxim,max17047" },
 	{ .compatible = "maxim,max17050" },
+	{ .compatible = "maxim,max17055" },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, max17042_dt_match);
@@ -1176,6 +1186,7 @@ static const struct i2c_device_id max17042_id[] = {
 	{ "max17042", MAXIM_DEVICE_TYPE_MAX17042 },
 	{ "max17047", MAXIM_DEVICE_TYPE_MAX17047 },
 	{ "max17050", MAXIM_DEVICE_TYPE_MAX17050 },
+	{ "max17055", MAXIM_DEVICE_TYPE_MAX17055 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, max17042_id);
include/linux/power/max17042_battery.h +47 -1

64 lines not on this page · raw message

Signature · 1 line
2.17.1
reviewer Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] power: supply: max17042: add MAX17055 support

Quoted 8 lines · Angus Ainslie (Purism)

The MAX17055 is very similar to the MAX17042 so extend the driver.

---
 drivers/power/supply/max17042_battery.c | 17 +++++++--
 include/linux/power/max17042_battery.h  | 48 ++++++++++++++++++++++++-
 2 files changed, 61 insertions(+), 4 deletions(-)

Best regards,
Krzysztof

#3 lore raw

PATCH v2 2/2 device-tree: bindings: max17042_battery: add all of the compatible strings

In reply to Angus Ainslie (Purism)

The bindings are missing documentation for some of the compatible strings.

---
 .../devicetree/bindings/power/supply/max17042_battery.txt   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/power/supply/max17042_battery.txt +5 -1
index 3f3894aaeebc..f34c5daae9af 100644
@@ -2,7 +2,11 @@ max17042_battery
 ~~~~~~~~~~~~~~~~
 
 Required properties :
- - compatible : "maxim,max17042"
+ - compatible : one of the following
+ * "maxim,max17042"
+ * "maxim,max17047"
+ * "maxim,max17050"
+ * "maxim,max17055"
 
 Optional properties :
  - maxim,rsns-microohm : Resistance of rsns resistor in micro Ohms
Signature · 1 line
2.17.1
#4 lore raw
In reply to Angus Ainslie (Purism)

Hi,

Quoted 1 line · Angus Ainslie (Purism)

Extend the max17042_battery driver to include the MAX17055.

Thanks, queued to power-suply's for-next branch.

-- Sebastian

Quoted 18 lines

Changes since v1:

Change blacklist driver checks to whitelists.

Angus Ainslie (Purism) (2):
power: supply: max17042: add MAX17055 support
device-tree: bindings: max17042_battery: add all of the compatible
strings

 .../power/supply/max17042_battery.txt         |  6 ++-
 drivers/power/supply/max17042_battery.c       | 17 +++++--
 include/linux/power/max17042_battery.h        | 48 ++++++++++++++++++-
 3 files changed, 66 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
#5 lore raw
Quoted 9 lines · Sebastian Reichel

Hi,

Quoted 1 line · Angus Ainslie (Purism)

Extend the max17042_battery driver to include the MAX17055.

Thanks, queued to power-suply's for-next branch.

-- Sebastian

Thanks

Angus

Quoted 19 lines
Quoted 19 lines

Changes since v1:

Change blacklist driver checks to whitelists.

Angus Ainslie (Purism) (2):
power: supply: max17042: add MAX17055 support
device-tree: bindings: max17042_battery: add all of the compatible
strings

 .../power/supply/max17042_battery.txt         |  6 ++-
 drivers/power/supply/max17042_battery.c       | 17 +++++--
 include/linux/power/max17042_battery.h        | 48 
++++++++++++++++++-
 3 files changed, 66 insertions(+), 5 deletions(-)

--
2.17.1