From: Pavel Machek <pavel@ucw.cz>
To: Tony Lindgren <tony@atomide.com>
Cc: Sebastian Reichel <sre@kernel.org>,
linux-pm@vger.kernel.org, linux-omap@vger.kernel.org,
Merlijn Wajer <merlijn@wizzup.org>
Subject: Re: [PATCH 3/3] power: supply: cpcap-charger: Improve battery detection
Date: Thu, 19 Sep 2019 11:19:55 +0200 [thread overview]
Message-ID: <20190919091955.GC9644@amd> (raw)
In-Reply-To: <20190917213501.16907-4-tony@atomide.com>
[-- Attachment #1: Type: text/plain, Size: 1890 bytes --]
Hi!
> We are currently using a wrong ADC range for the battery detection.
> The ADC returns the battery temperature if connected.
This one looks good.
> Cc: Merlijn Wajer <merlijn@wizzup.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Would it also make sense to publish battery temperature somewhere? It
is somehow important for checking "what is going on" and it should
also be used to control charging. (Normal charging should only be
allowed in normal temperatures, like >10C and <30C or so..)
Thanks and best regards,
Pavel
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
> drivers/power/supply/cpcap-charger.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c
> --- a/drivers/power/supply/cpcap-charger.c
> +++ b/drivers/power/supply/cpcap-charger.c
> @@ -166,20 +166,21 @@ static enum power_supply_property cpcap_charger_props[] = {
> POWER_SUPPLY_PROP_CURRENT_NOW,
> };
>
> +/* No battery always shows temperature of -40000 */
> static bool cpcap_charger_battery_found(struct cpcap_charger_ddata *ddata)
> {
> struct iio_channel *channel;
> - int error, value;
> + int error, temperature;
>
> channel = ddata->channels[CPCAP_CHARGER_IIO_BATTDET];
> - error = iio_read_channel_raw(channel, &value);
> + error = iio_read_channel_processed(channel, &temperature);
> if (error < 0) {
> dev_warn(ddata->dev, "%s failed: %i\n", __func__, error);
>
> return false;
> }
>
> - return value == 1;
> + return temperature > -20000 && temperature < 60000;
> }
>
> static int cpcap_charger_get_charge_voltage(struct cpcap_charger_ddata *ddata)
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2019-09-19 9:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-17 21:34 [PATCH 0/3] cpcap charger and battery fixes Tony Lindgren
2019-09-17 21:34 ` [PATCH 1/3] power: supply: cpcap-charger: Limit voltage to 4.2V for battery Tony Lindgren
2019-09-19 9:05 ` Pavel Machek
2019-09-20 14:03 ` Tony Lindgren
2019-09-17 21:35 ` [PATCH 2/3] power: supply: cpcap-battery: Check voltage before orderly_poweroff Tony Lindgren
2019-09-19 9:14 ` Pavel Machek
2019-09-20 14:12 ` Tony Lindgren
2019-09-22 18:00 ` Tony Lindgren
2019-09-17 21:35 ` [PATCH 3/3] power: supply: cpcap-charger: Improve battery detection Tony Lindgren
2019-09-19 9:19 ` Pavel Machek [this message]
2019-09-20 14:18 ` Tony Lindgren
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=20190919091955.GC9644@amd \
--to=pavel@ucw.cz \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=merlijn@wizzup.org \
--cc=sre@kernel.org \
--cc=tony@atomide.com \
/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).