From: Daniel Mack <daniel@caiaq.de>
To: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
mreimer@vpop.net, linux-kernel@vger.kernel.org,
szabolcs.gyurko@tlt.hu, cbou@mail.ru
Subject: Re: [PATCH 4/4] ds2760: handle full_active_uAh == 0 case correctly
Date: Wed, 15 Jul 2009 22:02:46 +0200 [thread overview]
Message-ID: <20090715200246.GJ9464@buzzloop.caiaq.de> (raw)
In-Reply-To: <20090715192833.GA8938@oksana.dev.rtsoft.ru>
On Wed, Jul 15, 2009 at 11:28:33PM +0400, Anton Vorontsov wrote:
> On Wed, Jul 15, 2009 at 12:06:25PM -0700, Andrew Morton wrote:
> > Well. I'll look at them, as I try to do when someone cc'ed me. But
> > drivers/power is usually handled by Anton?
>
> Yep. All patches look good, I'll apply them to battery-2.6.git.
Thanks. Please consider applying the one below as well if you're fine
with it. We need that parameter for bootstrapping in the factory when
devices are produced.
Thanks,
Daniel
>From 75b680d069596351da674023146f34b1737ea8ab Mon Sep 17 00:00:00 2001
From: Daniel Mack <daniel@caiaq.de>
Date: Wed, 15 Jul 2009 21:57:29 +0200
Subject: [PATCH] ds2760: add current_accum module parameter
When connecting a ds2760 to a partly loaded battery the first time,
there must be a way to bootstrap the current_accum value. Without that,
the current capactity value is bogus until the battery is fully charged
for the first time.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Szabolcs Gyurko <szabolcs.gyurko@tlt.hu>
Cc: Matt Reimer <mreimer@vpop.net>
Cc: Anton Vorontsov <cbou@mail.ru>
---
drivers/power/ds2760_battery.c | 36 +++++++++++++++++++++++-------------
1 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c
index 2d0e5ed..606f074 100644
--- a/drivers/power/ds2760_battery.c
+++ b/drivers/power/ds2760_battery.c
@@ -70,6 +70,10 @@ static unsigned int rated_capacity;
module_param(rated_capacity, uint, 0644);
MODULE_PARM_DESC(rated_capacity, "rated battery capacity, 10*mAh or index");
+static unsigned int current_accum;
+module_param(current_accum, uint, 0644);
+MODULE_PARM_DESC(current_accum, "current accumulator value");
+
/* Some batteries have their rated capacity stored a N * 10 mAh, while
* others use an index into this table. */
static int rated_capacities[] = {
@@ -215,6 +219,18 @@ static int ds2760_battery_read_status(struct ds2760_device_info *di)
return 0;
}
+static void ds2760_battery_set_current_accum(struct ds2760_device_info *di,
+ unsigned int acr_val)
+{
+ unsigned char acr[2];
+
+ acr[0] = acr_val >> 8;
+ acr[1] = acr_val & 0xff;
+
+ if (w1_ds2760_write(di->w1_dev, acr, DS2760_CURRENT_ACCUM_MSB, 2) < 2)
+ dev_warn(di->dev, "ACR write failed\n");
+}
+
static void ds2760_battery_update_status(struct ds2760_device_info *di)
{
int old_charge_status = di->charge_status;
@@ -246,20 +262,9 @@ static void ds2760_battery_update_status(struct ds2760_device_info *di)
if (di->full_counter < 2) {
di->charge_status = POWER_SUPPLY_STATUS_CHARGING;
} else {
- unsigned char acr[2];
- int acr_val;
-
/* acr is in units of 0.25 mAh */
- acr_val = di->full_active_uAh * 4L / 1000;
-
- acr[0] = acr_val >> 8;
- acr[1] = acr_val & 0xff;
-
- if (w1_ds2760_write(di->w1_dev, acr,
- DS2760_CURRENT_ACCUM_MSB, 2) < 2)
- dev_warn(di->dev,
- "ACR reset failed\n");
-
+ int acr_val = di->full_active_uAh * 4L / 1000;
+ ds2760_battery_set_current_accum(di, acr_val);
di->charge_status = POWER_SUPPLY_STATUS_FULL;
}
}
@@ -423,6 +428,11 @@ static int ds2760_battery_probe(struct platform_device *pdev)
if (rated_capacity)
ds2760_battery_write_rated_capacity(di, rated_capacity);
+ /* set current accumulator if given as parameter.
+ * this should only be done for bootstrapping the value */
+ if (current_accum)
+ ds2760_battery_set_current_accum(di, current_accum);
+
retval = power_supply_register(&pdev->dev, &di->bat);
if (retval) {
dev_err(di->dev, "failed to register battery\n");
--
1.6.3.1
next prev parent reply other threads:[~2009-07-15 20:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-15 16:20 [PATCH 1/4] ds2760: delay power supply registration Daniel Mack
2009-07-15 16:20 ` [PATCH 2/4] ds2760: export more features Daniel Mack
2009-07-15 16:20 ` [PATCH 3/4] ds2760: add rated_capacity module parameter Daniel Mack
2009-07-15 16:20 ` [PATCH 4/4] ds2760: handle full_active_uAh == 0 case correctly Daniel Mack
2009-07-15 18:06 ` Matt Reimer
2009-07-15 18:51 ` Daniel Mack
2009-07-15 19:06 ` Andrew Morton
2009-07-15 19:28 ` Anton Vorontsov
2009-07-15 20:02 ` Daniel Mack [this message]
2009-07-15 20:57 ` Daniel Mack
2009-07-15 18:06 ` [PATCH 3/4] ds2760: add rated_capacity module parameter Matt Reimer
2009-07-15 18:06 ` [PATCH 2/4] ds2760: export more features Matt Reimer
2009-07-15 18:05 ` [PATCH 1/4] ds2760: delay power supply registration Matt Reimer
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=20090715200246.GJ9464@buzzloop.caiaq.de \
--to=daniel@caiaq.de \
--cc=akpm@linux-foundation.org \
--cc=avorontsov@ru.mvista.com \
--cc=cbou@mail.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mreimer@vpop.net \
--cc=szabolcs.gyurko@tlt.hu \
/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.