linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: "Sicelo A. Mhlongo" <absicsz@gmail.com>
Cc: linux-pm@vger.kernel.org, maemo-leste@lists.dyne.org, pali@kernel.org
Subject: Re: [PATCH] power: supply: bq2415x_charger: report online status
Date: Tue, 27 Feb 2024 21:11:36 +0100	[thread overview]
Message-ID: <6slfmvqmtawwjlsobcfod6ewcjjbzmylz3owsdamdi4dod55wr@iiox5rzjj5ht> (raw)
In-Reply-To: <20240226194432.2174095-1-absicsz@gmail.com>

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

Hi,

On Mon, Feb 26, 2024 at 09:44:32PM +0200, Sicelo A. Mhlongo wrote:
> Provide the Online property. This chip does not have specific flags to
> indicate the presence of an input voltage, but this can be inferred from
> the reported charging status.

The datasheet suggests, that you can get the status from the fault
bits:

011 - Poor input source or VBUS < UVLO

Greetings,

-- Sebastian

> 
> Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
> ---
>  drivers/power/supply/bq2415x_charger.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c
> index 6a4798a62588..5b47a1d0a51a 100644
> --- a/drivers/power/supply/bq2415x_charger.c
> +++ b/drivers/power/supply/bq2415x_charger.c
> @@ -991,6 +991,7 @@ static enum power_supply_property bq2415x_power_supply_props[] = {
>  	/* TODO: maybe add more power supply properties */
>  	POWER_SUPPLY_PROP_STATUS,
>  	POWER_SUPPLY_PROP_MODEL_NAME,
> +	POWER_SUPPLY_PROP_ONLINE,
>  };
>  
>  static int bq2415x_power_supply_get_property(struct power_supply *psy,
> @@ -1017,6 +1018,14 @@ static int bq2415x_power_supply_get_property(struct power_supply *psy,
>  	case POWER_SUPPLY_PROP_MODEL_NAME:
>  		val->strval = bq->model;
>  		break;
> +	case POWER_SUPPLY_PROP_ONLINE:
> +		ret = bq2415x_exec_command(bq, BQ2415X_CHARGE_STATUS);
> +		/* Charger is Online when Charging or Full are reported. It is
> +		 * also likely online for the Unknown/Fault state too, but
> +		 * there is no way to be absolutely sure.
> +		 */
> +		val->intval = (ret == 1 || ret == 2);
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> -- 
> 2.43.0
> 

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

  reply	other threads:[~2024-02-27 20:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 19:44 [PATCH] power: supply: bq2415x_charger: report online status Sicelo A. Mhlongo
2024-02-27 20:11 ` Sebastian Reichel [this message]
2024-02-27 21:34   ` Sicelo
2024-02-28  0:00     ` Sebastian Reichel
2024-02-28  7:09       ` Sicelo

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=6slfmvqmtawwjlsobcfod6ewcjjbzmylz3owsdamdi4dod55wr@iiox5rzjj5ht \
    --to=sebastian.reichel@collabora.com \
    --cc=absicsz@gmail.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=maemo-leste@lists.dyne.org \
    --cc=pali@kernel.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 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).