mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-20 14:16:02 +00:00
power: supply: cpcap-battery: Read and save integrator register CCI
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> Signed-off-by: Tony Lindgren <tony@atomide.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
ac437c1c84
commit
b28ac41950
1 changed files with 9 additions and 1 deletions
|
@ -84,6 +84,7 @@ struct cpcap_coulomb_counter_data {
|
||||||
s32 sample; /* 24 or 32 bits */
|
s32 sample; /* 24 or 32 bits */
|
||||||
s32 accumulator;
|
s32 accumulator;
|
||||||
s16 offset; /* 9 bits */
|
s16 offset; /* 9 bits */
|
||||||
|
s16 integrator; /* 13 or 16 bits */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cpcap_battery_state {
|
enum cpcap_battery_state {
|
||||||
|
@ -269,12 +270,13 @@ static int
|
||||||
cpcap_battery_read_accumulated(struct cpcap_battery_ddata *ddata,
|
cpcap_battery_read_accumulated(struct cpcap_battery_ddata *ddata,
|
||||||
struct cpcap_coulomb_counter_data *ccd)
|
struct cpcap_coulomb_counter_data *ccd)
|
||||||
{
|
{
|
||||||
u16 buf[7]; /* CPCAP_REG_CC1 to CCI */
|
u16 buf[7]; /* CPCAP_REG_CCS1 to CCI */
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
ccd->sample = 0;
|
ccd->sample = 0;
|
||||||
ccd->accumulator = 0;
|
ccd->accumulator = 0;
|
||||||
ccd->offset = 0;
|
ccd->offset = 0;
|
||||||
|
ccd->integrator = 0;
|
||||||
|
|
||||||
/* Read coulomb counter register range */
|
/* Read coulomb counter register range */
|
||||||
error = regmap_bulk_read(ddata->reg, CPCAP_REG_CCS1,
|
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 = buf[4];
|
||||||
ccd->offset = sign_extend32(ccd->offset, 9);
|
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,
|
return cpcap_battery_cc_to_uah(ddata,
|
||||||
ccd->sample,
|
ccd->sample,
|
||||||
ccd->accumulator,
|
ccd->accumulator,
|
||||||
|
|
Loading…
Reference in a new issue