devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add MAX17055 fuel guage
@ 2019-12-02 15:25 Angus Ainslie (Purism)
  2019-12-02 15:25 ` [PATCH 1/2] power: supply: max17042: add MAX17055 support Angus Ainslie (Purism)
  2019-12-02 15:25 ` [PATCH 2/2] dts: bindings: max17042_battery: add all of the compatible strings Angus Ainslie (Purism)
  0 siblings, 2 replies; 6+ messages in thread
From: Angus Ainslie (Purism) @ 2019-12-02 15:25 UTC (permalink / raw)
  To: linux-pm
  Cc: Sebastian Reichel, Rob Herring, Mark Rutland, devicetree,
	linux-kernel, kernel, Angus Ainslie (Purism)

Extend the max17042_battery driver to include the MAX17055.

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

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

-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] power: supply: max17042: add MAX17055 support
  2019-12-02 15:25 [PATCH 0/2] Add MAX17055 fuel guage Angus Ainslie (Purism)
@ 2019-12-02 15:25 ` Angus Ainslie (Purism)
  2019-12-04  7:21   ` Krzysztof Kozlowski
  2019-12-02 15:25 ` [PATCH 2/2] dts: bindings: max17042_battery: add all of the compatible strings Angus Ainslie (Purism)
  1 sibling, 1 reply; 6+ messages in thread
From: Angus Ainslie (Purism) @ 2019-12-02 15:25 UTC (permalink / raw)
  To: linux-pm
  Cc: Sebastian Reichel, Rob Herring, Mark Rutland, devicetree,
	linux-kernel, kernel, Angus Ainslie (Purism)

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

Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
---
 drivers/power/supply/max17042_battery.c | 15 ++++++--
 include/linux/power/max17042_battery.h  | 48 ++++++++++++++++++++++++-
 2 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 0dfad2cf13fe..cecf6e2d8329 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -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,8 @@ 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_MAX17055)) {
 		max17042_override_por(map, MAX17042_EmptyTempCo,
 						config->empty_tempco);
 		max17042_override_por(map, MAX17042_K_empty0,
@@ -929,7 +935,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_MAX17042 &&
+	    chip->chip_type != MAXIM_DEVICE_TYPE_MAX17055) {
 		pdata->init_data = max17047_default_pdata_init_regs;
 		pdata->num_init_data =
 			ARRAY_SIZE(max17047_default_pdata_init_regs);
@@ -1167,6 +1174,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 +1184,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);
diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
index 4badd5322949..d55c746ac56e 100644
--- a/include/linux/power/max17042_battery.h
+++ b/include/linux/power/max17042_battery.h
@@ -105,11 +105,56 @@ enum max17042_register {
 
 	MAX17042_OCV		= 0xEE,
 
-	MAX17042_OCVInternal	= 0xFB,
+	MAX17042_OCVInternal	= 0xFB,  /* MAX17055 VFOCV */
 
 	MAX17042_VFSOC		= 0xFF,
 };
 
+enum max17055_register {
+	MAX17055_QRes		= 0x0C,
+	MAX17055_TTF		= 0x20,
+	MAX17055_V_empty	= 0x3A,
+	MAX17055_TIMER		= 0x3E,
+	MAX17055_USER_MEM	= 0x40,
+	MAX17055_RGAIN		= 0x42,
+
+	MAX17055_ConvgCfg	= 0x49,
+	MAX17055_VFRemCap	= 0x4A,
+
+	MAX17055_STATUS2	= 0xB0,
+	MAX17055_POWER		= 0xB1,
+	MAX17055_ID		= 0xB2,
+	MAX17055_AvgPower	= 0xB3,
+	MAX17055_IAlrtTh	= 0xB4,
+	MAX17055_TTFCfg		= 0xB5,
+	MAX17055_CVMixCap	= 0xB6,
+	MAX17055_CVHalfTime	= 0xB7,
+	MAX17055_CGTempCo	= 0xB8,
+	MAX17055_Curve		= 0xB9,
+	MAX17055_HibCfg		= 0xBA,
+	MAX17055_Config2	= 0xBB,
+	MAX17055_VRipple	= 0xBC,
+	MAX17055_RippleCfg	= 0xBD,
+	MAX17055_TimerH		= 0xBE,
+
+	MAX17055_RSense		= 0xD0,
+	MAX17055_ScOcvLim	= 0xD1,
+
+	MAX17055_SOCHold	= 0xD3,
+	MAX17055_MaxPeakPwr	= 0xD4,
+	MAX17055_SusPeakPwr	= 0xD5,
+	MAX17055_PackResistance	= 0xD6,
+	MAX17055_SysResistance	= 0xD7,
+	MAX17055_MinSysV	= 0xD8,
+	MAX17055_MPPCurrent	= 0xD9,
+	MAX17055_SPPCurrent	= 0xDA,
+	MAX17055_ModelCfg	= 0xDB,
+	MAX17055_AtQResidual	= 0xDC,
+	MAX17055_AtTTE		= 0xDD,
+	MAX17055_AtAvSOC	= 0xDE,
+	MAX17055_AtAvCap	= 0xDF,
+};
+
 /* Registers specific to max17047/50 */
 enum max17047_register {
 	MAX17047_QRTbl00	= 0x12,
@@ -125,6 +170,7 @@ enum max170xx_chip_type {
 	MAXIM_DEVICE_TYPE_MAX17042,
 	MAXIM_DEVICE_TYPE_MAX17047,
 	MAXIM_DEVICE_TYPE_MAX17050,
+	MAXIM_DEVICE_TYPE_MAX17055,
 
 	MAXIM_DEVICE_TYPE_NUM
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] dts: bindings: max17042_battery: add all of the compatible strings
  2019-12-02 15:25 [PATCH 0/2] Add MAX17055 fuel guage Angus Ainslie (Purism)
  2019-12-02 15:25 ` [PATCH 1/2] power: supply: max17042: add MAX17055 support Angus Ainslie (Purism)
@ 2019-12-02 15:25 ` Angus Ainslie (Purism)
  2019-12-04  7:24   ` Krzysztof Kozlowski
  2019-12-13 23:27   ` Rob Herring
  1 sibling, 2 replies; 6+ messages in thread
From: Angus Ainslie (Purism) @ 2019-12-02 15:25 UTC (permalink / raw)
  To: linux-pm
  Cc: Sebastian Reichel, Rob Herring, Mark Rutland, devicetree,
	linux-kernel, kernel, Angus Ainslie (Purism)

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

Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
---
 .../devicetree/bindings/power/supply/max17042_battery.txt   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/power/supply/max17042_battery.txt b/Documentation/devicetree/bindings/power/supply/max17042_battery.txt
index 3f3894aaeebc..f34c5daae9af 100644
--- a/Documentation/devicetree/bindings/power/supply/max17042_battery.txt
+++ b/Documentation/devicetree/bindings/power/supply/max17042_battery.txt
@@ -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
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] power: supply: max17042: add MAX17055 support
  2019-12-02 15:25 ` [PATCH 1/2] power: supply: max17042: add MAX17055 support Angus Ainslie (Purism)
@ 2019-12-04  7:21   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2019-12-04  7:21 UTC (permalink / raw)
  To: Angus Ainslie (Purism)
  Cc: linux-pm, Sebastian Reichel, Rob Herring, Mark Rutland,
	devicetree, linux-kernel, kernel

On Mon, 2 Dec 2019 at 23:27, Angus Ainslie (Purism) <angus@akkea.ca> wrote:
>
> The MAX17055 is very similar to the MAX17042 so extend the driver.
>
> Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
> ---
>  drivers/power/supply/max17042_battery.c | 15 ++++++--
>  include/linux/power/max17042_battery.h  | 48 ++++++++++++++++++++++++-
>  2 files changed, 59 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 0dfad2cf13fe..cecf6e2d8329 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -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,8 @@ 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_MAX17055)) {

Since the list is growing, I would prefer here similar approach as in
max17042_write_config_regs() - explicitly list devices (white list,
not black list).

>                 max17042_override_por(map, MAX17042_EmptyTempCo,
>                                                 config->empty_tempco);
>                 max17042_override_por(map, MAX17042_K_empty0,
> @@ -929,7 +935,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_MAX17042 &&
> +           chip->chip_type != MAXIM_DEVICE_TYPE_MAX17055) {

The same.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] dts: bindings: max17042_battery: add all of the compatible strings
  2019-12-02 15:25 ` [PATCH 2/2] dts: bindings: max17042_battery: add all of the compatible strings Angus Ainslie (Purism)
@ 2019-12-04  7:24   ` Krzysztof Kozlowski
  2019-12-13 23:27   ` Rob Herring
  1 sibling, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2019-12-04  7:24 UTC (permalink / raw)
  To: Angus Ainslie (Purism)
  Cc: linux-pm, Sebastian Reichel, Rob Herring, Mark Rutland,
	devicetree, linux-kernel, kernel

On Mon, 2 Dec 2019 at 23:26, Angus Ainslie (Purism) <angus@akkea.ca> wrote:
>
> The bindings are missing documentation for some of the compatible
> strings.
>
> Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
> ---
>  .../devicetree/bindings/power/supply/max17042_battery.txt   | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] dts: bindings: max17042_battery: add all of the compatible strings
  2019-12-02 15:25 ` [PATCH 2/2] dts: bindings: max17042_battery: add all of the compatible strings Angus Ainslie (Purism)
  2019-12-04  7:24   ` Krzysztof Kozlowski
@ 2019-12-13 23:27   ` Rob Herring
  1 sibling, 0 replies; 6+ messages in thread
From: Rob Herring @ 2019-12-13 23:27 UTC (permalink / raw)
  To: Angus Ainslie (Purism)
  Cc: linux-pm, Sebastian Reichel, Mark Rutland, devicetree,
	linux-kernel, kernel, Angus Ainslie (Purism)

On Mon,  2 Dec 2019 08:25:20 -0700, "Angus Ainslie (Purism)" wrote:
> The bindings are missing documentation for some of the compatible
> strings.
> 
> Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
> ---
>  .../devicetree/bindings/power/supply/max17042_battery.txt   | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-12-13 23:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-02 15:25 [PATCH 0/2] Add MAX17055 fuel guage Angus Ainslie (Purism)
2019-12-02 15:25 ` [PATCH 1/2] power: supply: max17042: add MAX17055 support Angus Ainslie (Purism)
2019-12-04  7:21   ` Krzysztof Kozlowski
2019-12-02 15:25 ` [PATCH 2/2] dts: bindings: max17042_battery: add all of the compatible strings Angus Ainslie (Purism)
2019-12-04  7:24   ` Krzysztof Kozlowski
2019-12-13 23:27   ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).