LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Bruno Meneguele <bruno.meneguele@smartgreen.net>
To: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] power: supply: bq24735: add watchdog timer delay support
Date: Mon, 16 Aug 2021 13:19:19 -0300	[thread overview]
Message-ID: <YRqQB0lL6tVv7wFa@glitch> (raw)
In-Reply-To: <20210813162914.p3mzc47ixpmdk62f@earth.universe>

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

On Fri, Aug 13, 2021 at 06:29:14PM +0200, Sebastian Reichel wrote:
> Hi,
> 
> On Fri, Jul 09, 2021 at 11:27:31AM -0300, Bruno Meneguele wrote:
> > The BQ24735 charger allows the user to set the watchdog timer delay between
> > two consecutives ChargeCurrent or ChargeVoltage command writes, if the IC
> > doesn't receive any command before the timeout happens, the charge is turned
> > off.
> > 
> > This patch adds the support to the user to change the default/POR value with
> > four discrete values:
> > 
> >   0 - disabled
> >   1 - enabled, 44 sec
> >   2 - enabled, 88 sec
> >   3 - enabled, 175 sec (default at POR)
> > 
> > These are the options supported in the ChargeOptions register bits 13&14.
> > 
> > Also, this patch make one additional check when poll-interval is set by the
> > user: if the interval set is greater than the WDT timeout it'll fail during
> > the probe stage, preventing the user to set non-compatible values between
> > the two options.
> > 
> > Signed-off-by: Bruno Meneguele <bruno.meneguele@smartgreen.net>
> > ---
> >  .../bindings/power/supply/bq24735.yaml        | 13 +++++
> 
> Patches for the DT bindings needs to be CC'd to the DT binding
> maintainers and should be in their own patch.
> 

Sorry about that, didn't know.
Will do that in v4.

> >  drivers/power/supply/bq24735-charger.c        | 48 +++++++++++++++++++
> >  include/linux/power/bq24735-charger.h         |  1 +
> >  3 files changed, 62 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/power/supply/bq24735.yaml b/Documentation/devicetree/bindings/power/supply/bq24735.yaml
> > index 131be6782c4b..62399efab467 100644
> > --- a/Documentation/devicetree/bindings/power/supply/bq24735.yaml
> > +++ b/Documentation/devicetree/bindings/power/supply/bq24735.yaml
> > @@ -56,6 +56,19 @@ properties:
> >        The POR value is 0x1000h. This number is in mA (e.g. 8064).
> >        See the spec for more information about the InputCurrent (0x3fh) register.
> >  
> > +  ti,wdt-timeout:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: |
> > +      Used to control and set the charger watchdog delay between consecutive
> > +      charge voltage and charge current commands.
> > +      This value must be:
> > +        0 - disabled
> > +        1 - 44 seconds
> > +        2 - 88 seconds
> > +        3 - 175 seconds
> > +      The POR value is 0x11 (3).
> > +      See the spec for more information about the ChargeOptions(0x12h) register.
> > +
> 
> This is missing 
> 
> minimum: 0
> maximum: 3
> 

Indeed. Will fix in v4.

> >    ti,external-control:
> >      type: boolean
> >      description: |
> > diff --git a/drivers/power/supply/bq24735-charger.c b/drivers/power/supply/bq24735-charger.c
> > index 3ce36d09c017..88f1cb1e9fee 100644
> > --- a/drivers/power/supply/bq24735-charger.c
> > +++ b/drivers/power/supply/bq24735-charger.c
> > @@ -45,6 +45,8 @@
> >  /* ChargeOptions bits of interest */
> >  #define BQ24735_CHARGE_OPT_CHG_DISABLE	(1 << 0)
> >  #define BQ24735_CHARGE_OPT_AC_PRESENT	(1 << 4)
> > +#define BQ24735_CHARGE_OPT_WDT_OFFSET	13
> > +#define BQ24735_CHARGE_OPT_WDT		(3 << BQ24735_CHARGE_OPT_WDT_OFFSET)
> >  
> >  struct bq24735 {
> >  	struct power_supply		*charger;
> > @@ -156,6 +158,20 @@ static int bq24735_config_charger(struct bq24735 *charger)
> >  		}
> >  	}
> >  
> > +	if (pdata->wdt_timeout) {
> > +		value = pdata->wdt_timeout;
> > +
> > +		ret = bq24735_update_word(charger->client, BQ24735_CHARGE_OPT,
> > +					  BQ24735_CHARGE_OPT_WDT,
> > +					  (value << BQ24735_CHARGE_OPT_WDT_OFFSET));
> > +		if (ret < 0) {
> > +			dev_err(&charger->client->dev,
> > +				"Failed to write watchdog timer: %d\n",
> > +				ret);
> > +			return ret;
> > +		}
> > +	}
> 
> binding says '0' = disabled, but code implements '0' = do not
> change.
> 

Well noticed. Will fix in v4.

I'm going to send a v4 without patch 1/2 because I noticed you already
queued for-next, so the next version should have only 1/2 heandling the
code and 2/2 specifically for dt-bindings.


-- 
Bruno Meneguele
PGP Key: http://bmeneg.com/pubkey.txt

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

      reply	other threads:[~2021-08-16 17:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 14:27 [PATCH v3 0/2] add Watchdog Timer delay support for BQ24735 Bruno Meneguele
2021-07-09 14:27 ` [PATCH v3 1/2] power: supply: bq24735: reorganize ChargeOption command macros Bruno Meneguele
2021-08-13 16:12   ` Sebastian Reichel
2021-07-09 14:27 ` [PATCH v3 2/2] power: supply: bq24735: add watchdog timer delay support Bruno Meneguele
2021-08-13 16:29   ` Sebastian Reichel
2021-08-16 16:19     ` Bruno Meneguele [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=YRqQB0lL6tVv7wFa@glitch \
    --to=bruno.meneguele@smartgreen.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --subject='Re: [PATCH v3 2/2] power: supply: bq24735: add watchdog timer delay support' \
    /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

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).