Repository navigation
Conversation
Authentic batteries in Surface devices are verified and paired with the motherboard during manufacturing or repair for quality assurance. Read the authentication status from the SAM and report it.
Newer Surface devices limit the battery charge to 80% based on usage patterns. Report the charge limit status and disengage it if requested. The charge limit is always controlled by the SAM and will be re-enabled after a few days depending on use.
|
so about "re-enabling the limit manually doesn't seem to be possible", you actually can set it, it's just a different pair of battery commands ("user charge mode"). i dug them out of the windows drivers and tested both on my Surface Pro for Business 11th Edition with Intel (SAM 10.3.139) through commandsall TC
modes (
so 80% is where it's from
what it actually does (on mine)
|
|
fun fact, it rejects anything above 80% or below 50% ( ¬⩊¬) |
|
@Cloveian Thanks for your findings! I reversed the same commands from The Surface app only shows a button to disable adaptive charging temporarily, with no manual control over charge limits. It checks some kind of condition to see what charge limit modes the EC supports, but I don't have the exact details in my notes. I think it had something to do with the return value of battery command 0x3a called The command |
|
ahhh, i am on a SP11 (intel) so its probably a little different |
| if (status) | ||
| return status; | ||
|
|
||
| bat->charge_limit_enforced = le32_to_cpu(bcl) == SAM_BATTERY_CHARGE_LIMIT_ENFORCED; |
There was a problem hiding this comment.
I think le32_to_cpu(__le16) is probably wrong?
| if (status) | ||
| return status; | ||
|
|
||
| bat->supports_smart_charging = (le32_to_cpu(bpp) & SAM_BATTERY_PROTECTION_POLICY_CHARGE_LIMIT) == SAM_BATTERY_PROTECTION_POLICY_CHARGE_LIMIT; |
There was a problem hiding this comment.
I think le32_to_cpu(__u8) is unnecessary.
|
@Cloveian would you be willing to write this up as a separate patch? And does either of you know if there's any way to identify what kind of operations SAM supports (wrt smart charging)? Like if it's controlled via I gave this a quick test on my SPX and unfortunately it seems to complicate things a bit more:
And just to be sure, those are really actually all SAM (0x01) category commands, not BAT (0x02)? I'm wondering if the instance ID from the device works well with that or if we should set it to 0 or so. |
I can try (٥•▽•) |
|
few questions:
also im the only one in this PR discussion where user charge mode actually works so i can run the read-only ones ( |
From what I can tell, they are all SAM (0x01) category commands and the instance ID doesn't seem to have any effect.
The Windows battery control logic is split across several different modules, so tracing it isn't so easy. Charging modes appear to be detected as supported based on some field in The operational logic is in the userspace In case anyone finds it helpful, here's my reverse-engineered mapping of the command translation in
Only commands |
|
okie, i made the patch: v7.3-surface-devel...Cloveian:kernel:battery-charge-limit i based it on |
|
also, i found something that might help with the naming/category questions: the Surface app ships
so a few things:
should i put the whole table somewhere (with what answers on the SP11)? not sure if it belongs here or in surface-aggregator-module or something. note for anyone else probeing stuff: TC |
|
would you like me to make a separate pr? |
Added support for battery features reverse-engineered from the Windows drivers.
Authentic batteries in Surface devices are verified and paired with the motherboard during manufacturing or repair for quality assurance. Windows reads the authentication status and shows a warning message if the battery isn't genuine. This status can now be read from Linux.
Newer Surface devices limit the battery charge to 80% based on usage patterns. The Surface app on Windows has a button that disables the limit temporarily and charges the battery to 100%, but Linux previously had no way to control it. The battery driver now reports the smart charging status as a charge limit and lets users disable it by setting it to 100%. The charge limit is controlled by the SAM and gets re-enabled automatically after a few days, and re-enabling the limit manually doesn't seem to be possible.
Fixes linux-surface/linux-surface#1781, linux-surface/linux-surface#2070.