All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Hermann Lauer <Hermann.Lauer@iwr.uni-heidelberg.de>
Cc: Chen-Yu Tsai <wens@csie.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] power: supply: axp20x_battery: implement writeable status to enable/disable battery charging
Date: Fri, 4 Jun 2021 14:20:45 +0200	[thread overview]
Message-ID: <20210604122045.itugfiivy5il5bkz@earth.universe> (raw)
In-Reply-To: <20210512105856.GA15727@lemon.iwr.uni-heidelberg.de>

[-- Attachment #1: Type: text/plain, Size: 2395 bytes --]

Hi,

On Wed, May 12, 2021 at 12:58:56PM +0200, Hermann Lauer wrote:
> Allow disabling and reenabling battery charging of an axp209 PMIC through a
> writable status property. With the current driver code charging is always on.
> 
> This works on the axp209 of Banana {Pi M1+,Pro} and should work on all AXP chips.
> 
> Signed-off-by: Hermann.Lauer@uni-heidelberg.de
> ---

Thanks, queued.

-- Sebastian

> v2: add fallthrough and improve commit message (thanks to Maxime and ChenYu)
> v3: fix fallthrough usage
> 
> Thanks to ChenYu for the idea and greetings
>   Hermann
> 
>  drivers/power/supply/axp20x_battery.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
> --- a/drivers/power/supply/axp20x_battery.c
> +++ b/drivers/power/supply/axp20x_battery.c
> @@ -40,6 +40,7 @@
>  #define AXP209_FG_PERCENT		GENMASK(6, 0)
>  #define AXP22X_FG_VALID			BIT(7)
>  
> +#define AXP20X_CHRG_CTRL1_ENABLE	BIT(7)
>  #define AXP20X_CHRG_CTRL1_TGT_VOLT	GENMASK(6, 5)
>  #define AXP20X_CHRG_CTRL1_TGT_4_1V	(0 << 5)
>  #define AXP20X_CHRG_CTRL1_TGT_4_15V	(1 << 5)
> @@ -468,7 +469,18 @@
>  	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
>  		return axp20x_set_max_constant_charge_current(axp20x_batt,
>  							      val->intval);
> +	case POWER_SUPPLY_PROP_STATUS:
> +		switch (val->intval) {
> +		case POWER_SUPPLY_STATUS_CHARGING:
> +			return regmap_update_bits(axp20x_batt->regmap, AXP20X_CHRG_CTRL1,
> +				AXP20X_CHRG_CTRL1_ENABLE, AXP20X_CHRG_CTRL1_ENABLE);
>  
> +		case POWER_SUPPLY_STATUS_DISCHARGING:
> +		case POWER_SUPPLY_STATUS_NOT_CHARGING:
> +			return regmap_update_bits(axp20x_batt->regmap, AXP20X_CHRG_CTRL1,
> +				AXP20X_CHRG_CTRL1_ENABLE, 0);
> +		}
> +		fallthrough;
>  	default:
>  		return -EINVAL;
>  	}
> @@ -491,7 +503,8 @@
>  static int axp20x_battery_prop_writeable(struct power_supply *psy,
>  					 enum power_supply_property psp)
>  {
> -	return psp == POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN ||
> +	return psp == POWER_SUPPLY_PROP_STATUS ||
> +	       psp == POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN ||
>  	       psp == POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN ||
>  	       psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT ||
>  	       psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX;

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2021-06-04 12:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21  9:03 [RFC PATCH] axp209 PMIC: setting constant_charge_current to 0 disables battery charging Hermann.Lauer
2021-04-26  8:40 ` Chen-Yu Tsai
2021-05-05 11:29   ` [PATCH] power: supply: axp20x_battery: implement writeable status to enable/disable " Hermann.Lauer
2021-05-09 15:05     ` Chen-Yu Tsai
2021-05-10 13:18       ` [PATCH v2] " Hermann Lauer
2021-05-12 10:58         ` [PATCH v3] " Hermann Lauer
2021-06-04 12:20           ` Sebastian Reichel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210604122045.itugfiivy5il5bkz@earth.universe \
    --to=sebastian.reichel@collabora.com \
    --cc=Hermann.Lauer@iwr.uni-heidelberg.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.