From: Tony Lindgren <tony@atomide.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-omap@vger.kernel.org,
Merlijn Wajer <merlijn@wizzup.org>, Pavel Machek <pavel@ucw.cz>
Subject: [PATCH 4/5] power: supply: cpcap-battery: Read and save integrator register CCI
Date: Wed, 9 Oct 2019 14:06:20 -0700 [thread overview]
Message-ID: <20191009210621.10522-5-tony@atomide.com> (raw)
In-Reply-To: <20191009210621.10522-1-tony@atomide.com>
We can simplify code in the later patches by reading and saving the
integrator register CCI. Let's also fix a comment typo for register range
naming while at it.
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/power/supply/cpcap-battery.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
--- a/drivers/power/supply/cpcap-battery.c
+++ b/drivers/power/supply/cpcap-battery.c
@@ -84,6 +84,7 @@ struct cpcap_coulomb_counter_data {
s32 sample; /* 24 or 32 bits */
s32 accumulator;
s16 offset; /* 9 bits */
+ s16 integrator; /* 13 or 16 bits */
};
enum cpcap_battery_state {
@@ -269,12 +270,13 @@ static int
cpcap_battery_read_accumulated(struct cpcap_battery_ddata *ddata,
struct cpcap_coulomb_counter_data *ccd)
{
- u16 buf[7]; /* CPCAP_REG_CC1 to CCI */
+ u16 buf[7]; /* CPCAP_REG_CCS1 to CCI */
int error;
ccd->sample = 0;
ccd->accumulator = 0;
ccd->offset = 0;
+ ccd->integrator = 0;
/* Read coulomb counter register range */
error = regmap_bulk_read(ddata->reg, CPCAP_REG_CCS1,
@@ -299,6 +301,12 @@ cpcap_battery_read_accumulated(struct cpcap_battery_ddata *ddata,
ccd->offset = buf[4];
ccd->offset = sign_extend32(ccd->offset, 9);
+ /* Integrator register CPCAP_REG_CCI */
+ if (ddata->vendor == CPCAP_VENDOR_TI)
+ ccd->integrator = sign_extend32(buf[6], 13);
+ else
+ ccd->integrator = (s16)buf[6];
+
return cpcap_battery_cc_to_uah(ddata,
ccd->sample,
ccd->accumulator,
--
2.23.0
next prev parent reply other threads:[~2019-10-09 21:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 21:06 [PATCH 0/5] cpcap battery simplification and calibrate support Tony Lindgren
2019-10-09 21:06 ` [PATCH 1/5] power: supply: cpcap-battery: Move coulomb counter units per lsb to ddata Tony Lindgren
2019-10-13 10:55 ` Pavel Machek
2019-10-16 22:01 ` Tony Lindgren
2019-10-13 11:35 ` Pavel Machek
2019-10-09 21:06 ` [PATCH 2/5] power: supply: cpcap-battery: Simplify coulomb counter calculation with div_s64 Tony Lindgren
2019-10-13 11:01 ` Pavel Machek
2019-10-13 11:36 ` Pavel Machek
2019-10-09 21:06 ` [PATCH 3/5] power: supply: cpcap-battery: Simplify short term power average calculation Tony Lindgren
2019-10-13 11:42 ` Pavel Machek
2019-10-13 11:42 ` Pavel Machek
2019-10-09 21:06 ` Tony Lindgren [this message]
2019-10-09 21:06 ` [PATCH 5/5] power: supply: cpcap-battery: Add basic coulomb counter calibrate support Tony Lindgren
2019-10-13 11:26 ` Pavel Machek
2019-10-16 22:45 ` [PATCH 0/5] cpcap battery simplification and " Tony Lindgren
2019-10-20 20:36 ` Sebastian Reichel
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=20191009210621.10522-5-tony@atomide.com \
--to=tony@atomide.com \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=merlijn@wizzup.org \
--cc=pavel@ucw.cz \
--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).