All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andrew F. Davis" <afd@ti.com>
To: Liam Breck <liam@networkimprov.net>
Cc: linux-pm@vger.kernel.org
Subject: Re: [PATCH v12.4 6/10] power: bq27xxx_battery: Add power_supply_battery_info support
Date: Fri, 7 Apr 2017 14:19:42 -0500	[thread overview]
Message-ID: <c37f430f-12bd-e84e-66fe-2a9eb7c76339@ti.com> (raw)
In-Reply-To: <CAKvHMgT6bqtg464r80k0wuR3nWLvZfjrpCGOcgTP+TLBhuYdXA@mail.gmail.com>

On 04/07/2017 01:58 PM, Liam Breck wrote:
> On Thu, Apr 6, 2017 at 11:23 AM, Liam Breck <liam@networkimprov.net> wrote:
>> On Thu, Apr 6, 2017 at 7:30 AM, Andrew F. Davis <afd@ti.com> wrote:
>>> On 04/04/2017 03:57 AM, Liam Breck wrote:
>>>> From: Liam Breck <kernel@networkimprov.net>
>>>>
>>>> Previously there was no way to configure these chips in the event that the
>>>> defaults didn't match the battery in question.
>>>>
>>>> We now call power_supply_get_battery_info(), check its values, and write
>>>> battery data to chip data memory (flash/RAM/NVM).
>>>>
>>>
>>> I'm almost convinced now this is *not* the correct thing to do, we
>>> should not be writing to NVM. If the DT states different values than in
>>> the device we need to trust the device. DT is static for a board, the
>>> battery data may not be.
>>>
>>> At most we could have an override flag as a driver param that causes us
>>> to ignore NVM and use the DT values, but always overwriting the device's
>>> NVM with the DT values is not what most want.
>>
>> Reprising my previous response, with addenda...
>>
>> We trust the distro/device kernel package to contain correct config
>> for RAM-only chips, but not NVM? A battery config would not be set in
>> mainline dts files, unless a battery is soldered to the board, or
>> similar. I will note this in our DT binding.
>>

DT is for hardware descriptions, in cases where the hardware cannot be
automatically detected. If we find we can get the battery info from the
battery gauge why would we not only ignore it, but go and overwrite it
with the info from DT? This is backwards.

>> Re DT provisioning... Device makers and distros are extremely careful
>> about what they put into DTs and what dtbs are included with a kernel
>> package. They know that a misconfigured DT is a showstopper, and could
>> be catastrophic. I've seen the latter -- a guru-level kernel
>> maintainer whom I work with set a DT voltage level wrong on a
>> prototype and fried its eMMC chip. If the DT has a gauge config, the
>> default assumption is that it's correct.
>>

And if that eMMC chip could communicate its requested voltage we would
not need to describe it in DT, and we certainly would not say "sorry
eMMC, you requested 3v but DT says you need 33v, so thats what you're
getting".

>> It is wrong to force distros and device makers to include
>> /etc/modprobe.d/xyz.conf to fully configure the hardware.
>>

It's either that or add a driver sysfs entry, we don't configure
hardware in DT, thats rule #1. You got an ack for a binding that
describes a "simple-battery"(one that cannot self report), you are
misusing this binding as input configuration data to feed to batteries
that *can* report their configuration.

>> However we should indeed let users override the DT config with a
>> module param. How about use-on-chip-config=1, type bool?
> 

If we do add a param it needs to be default "off". It should not update
saved battery data on the chip in either case, that needs to be a
manually triggered through sysfs or similar.

> I came up with...
> 
> static bool bq27xxx_dt_battery = true;
> module_param_named(use_dt_battery, bq27xxx_dt_battery, bool, S_IRUGO);
> MODULE_PARM_DESC(use_dt_battery,
>  "Use devicetree monitored-battery config if present. Default is 1/Y.");
> 
> After we check for DT monitored-battery, we test bq27xxx_dt_battery,
> and if false, emit a warning that we are skipping the DT config.
> 

  reply	other threads:[~2017-04-07 19:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04  8:56 [PATCH v12.4 0/7] bq27xxx_battery partial series Liam Breck
2017-04-04  8:57 ` [PATCH v12.4 4/10] power: bq27xxx_battery: Add bulk transfer bus methods Liam Breck
2017-04-04  8:57 ` [PATCH v12.4 5/10] power: bq27xxx_battery: Add chip data memory read/write support Liam Breck
2017-04-04  8:57 ` [PATCH v12.4 6/10] power: bq27xxx_battery: Add power_supply_battery_info support Liam Breck
2017-04-06 14:30   ` Andrew F. Davis
2017-04-06 18:23     ` Liam Breck
2017-04-07 18:58       ` Liam Breck
2017-04-07 19:19         ` Andrew F. Davis [this message]
2017-04-07 19:56           ` Liam Breck
2017-04-10 13:18             ` Andrew F. Davis
2017-04-04  8:57 ` [PATCH v12.4 7/10] power: bq27xxx_battery: Enable chip data memory update for certain chips Liam Breck
2017-04-04  8:57 ` [PATCH v12.4 8/10] devicetree: power: bq27xxx: Add monitored-battery documentation Liam Breck
2017-04-04  8:57 ` [PATCH v12.4 9/10] power: bq27xxx_battery: Flag identical register maps when in debug mode Liam Breck
2017-04-04  8:57 ` [PATCH v12.4 10/10] power: bq27xxx_battery: Remove duplicate register arrays Liam Breck
2017-04-05 18:54 ` [PATCH v12.4 0/7] bq27xxx_battery partial series Liam Breck

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=c37f430f-12bd-e84e-66fe-2a9eb7c76339@ti.com \
    --to=afd@ti.com \
    --cc=liam@networkimprov.net \
    --cc=linux-pm@vger.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 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.