linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Hans de Goede <hdegoede@redhat.com>, linux-pm@vger.kernel.org
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>,
	Sebastian Reichel <sre@kernel.org>
Subject: Re: [PATCH 2/2] power: supply: bq25890: Add HiZ mode support
Date: Sat, 26 Nov 2022 12:06:05 +0100	[thread overview]
Message-ID: <7e2ee4f1-25d1-86db-7b8d-8785caef6c37@denx.de> (raw)
In-Reply-To: <2ae29632-58e9-4ee5-3d59-397bff4932fc@redhat.com>

On 11/21/22 09:04, Hans de Goede wrote:
> Hi,

Hi,

> On 11/21/22 01:50, Marek Vasut wrote:
>> On 11/20/22 22:29, Hans de Goede wrote:
>>>
>>>
>>> On 11/19/22 14:52, Hans de Goede wrote:
>>>> Hi,
>>>>
>>>> On 11/9/22 23:15, Marek Vasut wrote:
>>>>> The bq25890 is capable of disconnecting itself from the external supply,
>>>>> in which case the system is supplied only from the battery. This can be
>>>>> useful e.g. to test the pure battery operation, or draw no power from
>>>>> USB port.
>>>>>
>>>>> Implement support for this mode, which can be toggled by writing 0 or
>>>>> non-zero to sysfs 'online' attribute, to select either offline or online
>>>>> mode.
>>>>>
>>>>> The IRQ handler has to be triggered to update chip state, as switching
>>>>> to and from HiZ mode does not generate an interrupt automatically.
>>>>>
>>>>> Signed-off-by: Marek Vasut <marex@denx.de>
>>>>> ---
>>>>> Cc: Hans de Goede <hdegoede@redhat.com>
>>>>> Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>
>>>> Thanks, patch looks good to me:
>>>>
>>>> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>>>>
>>>> Also your timing is excellent :)  As a hobby project I'm working
>>>> on a x86 Lenovo Android tablet which has 2 separate batteries and
>>>> each battery has its own bq25892 chip.
>>>>
>>>> This requires putting the secondary bq25892 in Hi-Z mode when
>>>> e.g. enabling the 5V USB/OTG boost regulator on the primary
>>>> bq25892 to make the micro-usb output 5V.
>>>>
>>>> Which is functionality which I can nicely build on top of this
>>>> series.
>>>
>>> So one thing which I noticed while working on my own stuff
>>> on top of this, is that the charger IC resets (disables) Hi-Z
>>> mode when its internal PG (power-good) signal goes from false
>>> to true.
>>>
>>> The Android kernel fork for the tablet I'm working on detects
>>> the PG false -> true transition in its IRQ handler and then
>>> re-enabled Hi-Z mode if it was requested.
>>>
>>> I wonder if we should do something similar: remember the last
>>> value written to /sys/class/power_supply/bq2589o-charger/online
>>> and then in the IRQ handler if Hi-Z mode was requested re-enable
>>> Hi-Z mode ?
>>
>> Uhhhhh, that sounds like the HiZ mode is unreliable .
> 
> I think it is working as designed (although this is not documented)
> the charger is designed to be able to operate autonomously, so it
> makes sense to clear Hi-Z mode when a charger is unplugged + re-plugged.

That does make sense, although I would've liked a bit which would set 
HiZ mode and ignore the charger replug, so the chip would guarantee no 
power draw from the charger until such bit is cleared.

>> Of course, there seems to be no way to completely inhibit the PG detection, is there ?
> 
> not that I have been able to find.
> 
>> I wonder whether we should support this kind of workaround at all ?
> 
> You mean Hi-z mode itself? That is definitely useful to have, necessary
> actually for the tablet I'm working on in my spare time now.

Yes, the HiZ mode itself, since it cannot be made persistent and resets 
itself on replug.

> Or do you mean the Android workaround to re-enable Hi-Z mode in the IRQ
> handler ?

I mean, either
- we drop the HiZ mode support completely
or
- we add HiZ mode + persistency workaround

I don't like the second option, but if you need it and we have no better 
options ... hum ...

[...]

  reply	other threads:[~2022-11-26 12:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 22:15 [PATCH 1/2] power: supply: bq25890: Factor out chip state update Marek Vasut
2022-11-09 22:15 ` [PATCH 2/2] power: supply: bq25890: Add HiZ mode support Marek Vasut
2022-11-19 13:52   ` Hans de Goede
2022-11-19 14:14     ` Marek Vasut
2022-11-20 21:29     ` Hans de Goede
2022-11-21  0:50       ` Marek Vasut
2022-11-21  8:04         ` Hans de Goede
2022-11-26 11:06           ` Marek Vasut [this message]
2022-11-26 15:03             ` Hans de Goede
2022-11-26 15:15               ` Marek Vasut
2022-11-26 15:50                 ` Hans de Goede
2022-11-26 18:40                   ` Marek Vasut
2022-11-19 13:49 ` [PATCH 1/2] power: supply: bq25890: Factor out chip state update Hans de Goede

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=7e2ee4f1-25d1-86db-7b8d-8785caef6c37@denx.de \
    --to=marex@denx.de \
    --cc=hdegoede@redhat.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --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).