linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Crag.Wang@dell.com>
To: <Mario.Limonciello@dell.com>, <crag0715@gmail.com>, <sre@kernel.org>
Cc: <mathewk@chromium.org>, <linux-pm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 1/1] power_supply: wilco_ec: Add permanent long life charging mode
Date: Tue, 23 Jun 2020 15:50:43 +0000	[thread overview]
Message-ID: <ecda5d3852af4a1a8c08e0dc07983f35@KULX13MDC113.APAC.DELL.COM> (raw)
In-Reply-To: <6a804505400e4109906fadcf945edf76@AUSX13MPC105.AMER.DELL.COM>

> -----Original Message-----
> From: Limonciello, Mario <Mario_Limonciello@Dell.com>
> Sent: Tuesday, June 23, 2020 9:48 PM
> To: Crag Wang; Sebastian Reichel
> Cc: mathewk@chromium.org; Wang, Crag; linux-pm@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: RE: [PATCH 1/1] power_supply: wilco_ec: Add permanent long life
> charging mode
> 
> > -----Original Message-----
> > From: Crag Wang <crag0715@gmail.com>
> > Sent: Tuesday, June 23, 2020 3:20 AM
> > To: Sebastian Reichel
> > Cc: mathewk@chromium.org; Limonciello, Mario; Wang, Crag; linux-
> > pm@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: [PATCH 1/1] power_supply: wilco_ec: Add permanent long life
> > charging mode
> >
> >
> > [EXTERNAL EMAIL]
> >
> > This is a long life mode for extended warranty battery, switching to a
> > differnt mode selection is unavailable. The power charging rate is
> > customized so that battery at work last longer.
> >
> > Signed-off-by: Crag Wang <crag_wang@dell.com>
> > ---
> >  Documentation/ABI/testing/sysfs-class-power-wilco | 3 +++
> >  drivers/power/supply/power_supply_sysfs.c         | 1 +
> >  drivers/power/supply/wilco-charger.c              | 5 +++++
> >  include/linux/power_supply.h                      | 1 +
> >  4 files changed, 10 insertions(+)
> >
> > diff --git a/Documentation/ABI/testing/sysfs-class-power-wilco
> > b/Documentation/ABI/testing/sysfs-class-power-wilco
> > index da1d6ffe5e3c..1c91b17b6fd4 100644
> > --- a/Documentation/ABI/testing/sysfs-class-power-wilco
> > +++ b/Documentation/ABI/testing/sysfs-class-power-wilco
> > @@ -14,6 +14,9 @@ Description:
> >  			Charging begins when level drops below
> >  			charge_control_start_threshold, and ceases when
> >  			level is above charge_control_end_threshold.
> > +		Permanent Long Life: Last longer battery life, this mode
> > +			is programmed once in the factory. Switching to a
> > +			different mode is unavailable.
> >
> >  What:		/sys/class/power_supply/wilco-
> > charger/charge_control_start_threshold
> >  Date:		April 2019
> > diff --git a/drivers/power/supply/power_supply_sysfs.c
> > b/drivers/power/supply/power_supply_sysfs.c
> > index bc79560229b5..af3884015ad8 100644
> > --- a/drivers/power/supply/power_supply_sysfs.c
> > +++ b/drivers/power/supply/power_supply_sysfs.c
> > @@ -87,6 +87,7 @@ static const char * const
> > POWER_SUPPLY_CHARGE_TYPE_TEXT[] = {
> >  	[POWER_SUPPLY_CHARGE_TYPE_STANDARD]	= "Standard",
> >  	[POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE]	= "Adaptive",
> >  	[POWER_SUPPLY_CHARGE_TYPE_CUSTOM]	= "Custom",
> > +	[POWER_SUPPLY_CHARGE_TYPE_LONGLIFE]	= "Permanent Long
> Life",
> >  };
> >
> >  static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { diff --git
> > a/drivers/power/supply/wilco-charger.c
> > b/drivers/power/supply/wilco-charger.c
> > index b3c6d7cdd731..713c3018652f 100644
> > --- a/drivers/power/supply/wilco-charger.c
> > +++ b/drivers/power/supply/wilco-charger.c
> > @@ -27,6 +27,7 @@ enum charge_mode {
> >  	CHARGE_MODE_AC = 3,	/* Mostly AC use, used for Trickle */
> >  	CHARGE_MODE_AUTO = 4,	/* Used for Adaptive */
> >  	CHARGE_MODE_CUSTOM = 5,	/* Used for Custom */
> > +	CHARGE_MODE_LONGLIFE = 6, /* Used for Permanent Long Life */
> 
> Since this is normally only done in the factory context, can you please
> confirm does something need to be artificially done to block userland from
> trying to set the battery charging to this mode?  Or will the EC already handle
> blocking it directly?

This is a feature of the battery, when the EC receives this setting it will be sent 
to the battery and stored there. Afterwards any attempt to change this mode
will return a failure. 

It's even better to block mode selection in the userland if long life mode already
in use.

> 
> >  };
> >
> >  #define CHARGE_LOWER_LIMIT_MIN	50
> > @@ -48,6 +49,8 @@ static int psp_val_to_charge_mode(int psp_val)
> >  		return CHARGE_MODE_AUTO;
> >  	case POWER_SUPPLY_CHARGE_TYPE_CUSTOM:
> >  		return CHARGE_MODE_CUSTOM;
> > +	case POWER_SUPPLY_CHARGE_TYPE_LONGLIFE:
> > +		return CHARGE_MODE_LONGLIFE;
> >  	default:
> >  		return -EINVAL;
> >  	}
> > @@ -67,6 +70,8 @@ static int charge_mode_to_psp_val(enum
> charge_mode mode)
> >  		return POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE;
> >  	case CHARGE_MODE_CUSTOM:
> >  		return POWER_SUPPLY_CHARGE_TYPE_CUSTOM;
> > +	case CHARGE_MODE_LONGLIFE:
> > +		return POWER_SUPPLY_CHARGE_TYPE_LONGLIFE;
> >  	default:
> >  		return -EINVAL;
> >  	}
> > diff --git a/include/linux/power_supply.h
> > b/include/linux/power_supply.h index ac1345a48ad0..528a3eaa2320
> 100644
> > --- a/include/linux/power_supply.h
> > +++ b/include/linux/power_supply.h
> > @@ -48,6 +48,7 @@ enum {
> >  	POWER_SUPPLY_CHARGE_TYPE_STANDARD,	/* normal speed */
> >  	POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE,	/* dynamically
> adjusted speed */
> >  	POWER_SUPPLY_CHARGE_TYPE_CUSTOM,	/* use
> CHARGE_CONTROL_* props */
> > +	POWER_SUPPLY_CHARGE_TYPE_LONGLIFE,	/* slow speed, longer
> life */
> >  };
> >
> >  enum {
> > --
> > 2.20.1


  reply	other threads:[~2020-06-23 15:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  8:20 [PATCH 1/1] power_supply: wilco_ec: Add permanent long life charging mode Crag Wang
2020-06-23 13:48 ` Mario.Limonciello
2020-06-23 15:50   ` Crag.Wang [this message]
2020-06-23 18:59     ` Mario.Limonciello
2020-06-24  3:51       ` Crag.Wang
2020-07-08  2:33         ` Crag.Wang

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=ecda5d3852af4a1a8c08e0dc07983f35@KULX13MDC113.APAC.DELL.COM \
    --to=crag.wang@dell.com \
    --cc=Mario.Limonciello@dell.com \
    --cc=crag0715@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mathewk@chromium.org \
    --cc=sre@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).