cpcap_battery_cc_raw_div(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 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 vibe
  • offset β€” coulomb counter offset value, for shifting things around
  • divider β€” 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 🌈


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