[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJKOXPcpW_uK=Y5+S0YmabrkAQ87vQZrjC5g3cB7WENbW49nPg@mail.gmail.com>
Date: Wed, 4 Dec 2019 15:21:23 +0800
From: Krzysztof Kozlowski <krzk@...nel.org>
To: "Angus Ainslie (Purism)" <angus@...ea.ca>
Cc: linux-pm@...r.kernel.org, Sebastian Reichel <sre@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
devicetree@...r.kernel.org,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
kernel@...i.sm
Subject: Re: [PATCH 1/2] power: supply: max17042: add MAX17055 support
On Mon, 2 Dec 2019 at 23:27, Angus Ainslie (Purism) <angus@...ea.ca> wrote:
>
> The MAX17055 is very similar to the MAX17042 so extend the driver.
>
> Signed-off-by: Angus Ainslie (Purism) <angus@...ea.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
Powered by blists - more mailing lists