cpcap_battery_cc_raw_div(9)
πΈ NAME πΈ
cpcap_battery_cc_raw_div β bestie, this one calculates and divides coulomb counter ΞΌAms values β¨ no cap, that's literally the whole job.
So this is a page from the Kernel API Manual (section 9, kernel-API girlies rise π«Ά), and we're gonna walk through it together, okay? Grab a lil snack π.
β¨ SYNOPSIS β¨
int cpcap_battery_cc_raw_div (struct cpcap_battery_ddata *ddata , s32
sample , s32 accumulator , s16 offset , u32 divider );
That's the whole signature, character for character, don't come for me π
π ARGUMENTS π
ddataβ the device driver data. the main character of this function, honestly πsampleβ coulomb counter sample value, one lil snapshot πΈaccumulatorβ coulomb counter integrator value, the cumulative vibeoffsetβ coulomb counter offset value, for shifting things arounddividerβ conversion divider. it divides. that's the whole thing π§
π DESCRIPTION π
okay so a heads-up first, bestie: the cc_lsb and cc_dur values come from a Motorola Linux kernel function called data_get_avg_curr_ua, and they seem to be based on measured test results π¬ (like, actual lab measurements, iykyk). And it also has the following comment, direct quote:
Adjustment factors are applied here as a temp solution per the test results. Need to work out a formal solution for this adjustment.
Not me reading that and going π β "temp solution" living rent-free in the kernel since forever, fr fr.
So here's the lore π¦: there's this coulomb counter for similar hardware that seems to be documented in "TWL6030 Gas Gauging Basics (Rev. A)" swca095a.pdf, in the chapter "10 Calculating Accumulated Current". Iconic doc, love that for them. But β and this is the key part β we however follow what the Motorola mapphone Linux kernel is doing, because there may be either a TI or an ST coulomb counter in the PMIC. Two possible chips, one code path, we stay flexible π
π SEE ALSO π
- Kernel file
./drivers/power/supply/cpcap-battery.c cpcap_battery_read_accumulated(9)cpcap_battery_cc_get_avg_current(9)
that's the whole page, bestie, you ate that π«Ά and for the record, this cutie lives in ./drivers/power/supply and is dated October 2026 β so screenshot it now before it's vintage βπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms