From: Quentin Schulz <quentin.schulz@free-electrons.com>
To: Chen-Yu Tsai <wens@csie.org>
Cc: knaack.h@gmx.de, "Lars-Peter Clausen" <lars@metafoo.de>,
"Peter Meerwald-Stadler" <pmeerw@pmeerw.net>,
"Rob Herring" <robh+dt@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Sebastian Reichel" <sre@kernel.org>,
"Russell King" <linux@armlinux.org.uk>,
"Maxime Ripard" <maxime.ripard@free-electrons.com>,
"Lee Jones" <lee.jones@linaro.org>,
linux-iio@vger.kernel.org,
devicetree <devicetree@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
"open list:THERMAL" <linux-pm@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
"Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>,
"Icenowy Zheng" <icenowy@aosc.xyz>,
"Bruno Prémont" <bonbons@linux-vserver.org>
Subject: Re: [PATCH v3 13/18] power: supply: add battery driver for AXP20X and AXP22X PMICs
Date: Tue, 21 Feb 2017 19:19:39 +0100 [thread overview]
Message-ID: <c3b21cd4-6d1d-db6a-b1ef-ed119f683035@free-electrons.com> (raw)
In-Reply-To: <CAGb2v64MjfYSnXET1BWsv=VaZE+v7GwNj7nrWDRafjRCM5tcQg@mail.gmail.com>
Hi Chen-Yu,
On 21/02/2017 05:44, Chen-Yu Tsai wrote:
> On Tue, Feb 14, 2017 at 5:41 PM, Quentin Schulz
> <quentin.schulz@free-electrons.com> wrote:
>> The X-Powers AXP20X and AXP22X PMICs can have a battery as power supply.
>>
>> This patch adds the battery power supply driver to get various data from
>> the PMIC, such as the battery status (charging, discharging, full,
>> dead), current max limit, current current, battery capacity (in
>> percentage), voltage max and min limits, current voltage and battery
>> capacity (in Ah).
>>
>> This battery driver uses the AXP20X/AXP22X ADC driver as PMIC data
>> provider.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>> Acked-by: Jonathan Cameron <jic23@kernel.org>
>> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
[...]
>> +static int axp20x_set_constant_charge_current(struct axp20x_batt_ps *axp_batt,
>> + int charge_current)
>> +{
>> + if (axp_batt->axp_id == AXP209_ID)
>> + charge_current = (charge_current - 300000) / 100000;
>> + else
>> + charge_current = (charge_current - 300000) / 150000;
>> +
>> + if (charge_current > AXP20X_CHRG_CTRL1_TGT_CURR || charge_current < 0)
>> + return -EINVAL;
>
> I would add a check or warn if the value to be programmed exceeds that returned
> by power_supply_get_battery_info.
Completely agree on a warning.
> A charge current exceeding the limits of the
> battery is potentially disastrous. The battery may be destroyed or even burst
> into flames and explode, taking the board and anything nearby with it. Otherwise
>
Yes, I understand. Maybe I'm seeing this ability to set the (max)
constant current charge the wrong way. Here is what I think:
If we limit the max constant charge current with a DT property, it would
require a DT rebuild when changing the battery (i.e. if an end-user
decides to change the battery with a bigger constant charge current, he
has to recompile the DT to change the DT value).
What I can suggest is the following:
- set the max constant charge current and the default constant charge
current from the DT property,
- allow the user to change the constant charge current via sysfs within
minimal-DT value range,
- allow the user to set max constant charge current via sysfs (and
print a warning as well when setting it), then the user can set a higher
constant charge current,
That would require a two steps modification with a printed warning.
"Safer" but does not remove the ability to change the constant charge
current in the case of battery swapping/changing.
> Acked-by: Chen-Yu Tsai <wens@csie.org>
>
> Speaking of power_supply_get_battery_info, is it merged or ready to be merged?
>
v7 under way IIRC.
Thanks,
Quentin
--
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2017-02-21 18:21 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 9:40 [PATCH v3 00/18] add support for AXP20X and AXP22X power supply drivers Quentin Schulz
2017-02-14 9:40 ` [PATCH v3 01/18] dt-bindings: power: battery: add constant-charge-current property Quentin Schulz
2017-02-15 0:46 ` Liam Breck
2017-02-15 8:53 ` Quentin Schulz
2017-02-15 20:18 ` Liam Breck
2017-02-21 4:55 ` Chen-Yu Tsai
2017-03-14 13:44 ` Quentin Schulz
2017-02-22 21:25 ` Rob Herring
2017-02-14 9:40 ` [PATCH v3 02/18] power: supply: power_supply_core: add constant-current-charge optional property Quentin Schulz
2017-02-14 9:40 ` [PATCH v3 03/18] mfd: axp20x: correct name of temperature data ADC registers Quentin Schulz
2017-02-14 9:40 ` [PATCH v3 04/18] iio: adc: add support for X-Powers AXP20X and AXP22X PMICs ADCs Quentin Schulz
2017-02-19 12:40 ` Jonathan Cameron
2017-02-21 18:03 ` Quentin Schulz
2017-02-25 16:53 ` Jonathan Cameron
2017-02-21 4:32 ` Chen-Yu Tsai
2017-02-14 9:40 ` [PATCH v3 05/18] mfd: axp20x: add ADC cells for AXP20X and AXP22X PMICs Quentin Schulz
2017-02-15 9:37 ` Lee Jones
2017-02-21 4:51 ` Chen-Yu Tsai
2017-02-14 9:41 ` [PATCH v3 06/18] mfd: axp20x: add AC power supply cells for " Quentin Schulz
2017-02-14 9:41 ` [PATCH v3 07/18] ARM: dtsi: axp209: add AC power supply subnode Quentin Schulz
2017-02-14 9:41 ` [PATCH v3 08/18] ARM: dtsi: axp22x: " Quentin Schulz
2017-02-14 9:41 ` [PATCH v3 09/18] ARM: dts: sun8i: sina33: enable ACIN " Quentin Schulz
2017-02-14 9:41 ` [PATCH v3 10/18] ARM: sun5i: chip: " Quentin Schulz
2017-02-14 9:41 ` [PATCH v3 11/18] dt-bindings: power: supply: add AXP20X/AXP22X battery DT binding Quentin Schulz
2017-02-21 4:45 ` Chen-Yu Tsai
2017-02-21 18:05 ` Quentin Schulz
2017-02-14 9:41 ` [PATCH v3 12/18] mfd: axp20x: add CHRG_CTRL1/2/3 to writeable regs for AXP20X/AXP22X Quentin Schulz
2017-02-14 9:41 ` [PATCH v3 13/18] power: supply: add battery driver for AXP20X and AXP22X PMICs Quentin Schulz
2017-02-21 4:44 ` Chen-Yu Tsai
2017-02-21 18:19 ` Quentin Schulz [this message]
2017-02-22 6:22 ` Chen-Yu Tsai
2017-02-14 9:41 ` [PATCH v3 14/18] mfd: axp20x: add MFD cells for AXP20X and AXP22X battery driver Quentin Schulz
2017-02-21 4:46 ` Chen-Yu Tsai
2017-02-14 9:41 ` [PATCH v3 15/18] ARM: dtsi: axp209: add battery power supply subnode Quentin Schulz
2017-02-21 4:47 ` Chen-Yu Tsai
2017-02-14 9:41 ` [PATCH v3 16/18] ARM: dtsi: axp22x: " Quentin Schulz
2017-02-21 4:47 ` Chen-Yu Tsai
2017-02-14 9:41 ` [PATCH v3 17/18] ARM: dts: sun8i: sina33: enable " Quentin Schulz
2017-02-21 4:50 ` Chen-Yu Tsai
2017-02-21 18:20 ` Quentin Schulz
2017-02-14 9:41 ` [PATCH v3 18/18] ARM: sun5i: chip: " Quentin Schulz
2017-02-21 4:50 ` Chen-Yu Tsai
2017-02-15 9:36 ` [PATCH v3 00/18] add support for AXP20X and AXP22X power supply drivers Lee Jones
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=c3b21cd4-6d1d-db6a-b1ef-ed119f683035@free-electrons.com \
--to=quentin.schulz@free-electrons.com \
--cc=bonbons@linux-vserver.org \
--cc=devicetree@vger.kernel.org \
--cc=icenowy@aosc.xyz \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=maxime.ripard@free-electrons.com \
--cc=pmeerw@pmeerw.net \
--cc=robh+dt@kernel.org \
--cc=sre@kernel.org \
--cc=thomas.petazzoni@free-electrons.com \
--cc=wens@csie.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
all inboxes | Powered by JetHome®