Repository navigation
power: supply: macsmc: J700 battery reporting (reworked, 3 patches) - #29
Merged
Merged
Conversation
…xist VOLTAGE_MIN_DESIGN, CHARGE_TERM_CURRENT, CONSTANT_CHARGE_CURRENT_MAX and CONSTANT_CHARGE_VOLTAGE are read from the BITV, B0RC, B0RI and B0RV keys, and the driver registers them on every machine. When such a read fails with an SMC error (-EIO), the power supply core logs "driver failed to report" (rate-limited) for each read of the property, and power_supply_uevent() gives up at the first failing property, so no change uevent is sent for the battery at all. Register these four properties only if their key exists at probe time. This touches every machine the driver supports; firmware that has the keys keeps the same properties. On J700, reads of all four keys fail and the VOLTAGE_MIN_DESIGN errors flood the kernel log. It has not been confirmed there that the keys are missing from the key index, which is what apple_smc_key_exists() checks, rather than present but unreadable. macsmc_power_critical_work() forces an emergency shutdown when B0AV drops below BITV. Without a readable BITV that check never fires, as before this change, and only the BCF0 empty flag starts the orderly shutdown. This applies to J700, where no key that could replace BITV is known. Compile-tested only; not run on hardware. Assisted-by: LLM checkpatch sparse Signed-off-by: Ryan Murray <[email protected]>
Commit 5769466 ("power: supply: macsmc: Support macOS 27 SMC firmware") infers two firmware changes from one fact: when the BCF0 key shrinks from four bytes to one, B0RM is taken to switch from the gas gauge's big-endian pass-through to native byte order. J700's SMC firmware reports a four-byte BCF0 but a native-endian B0RM. Swapping it made CHARGE_NOW and ENERGY_NOW move in 256 mAh steps as the low byte changed, and gave values above CHARGE_FULL or below zero. Track the B0RM byte order in its own flag, b0rm_native, set at probe with the one-byte BCF0 layout as before and additionally on J700. fw_ge_27 now means only that BCF0 is one byte. The J700 case is keyed on the machine compatible because nothing in the key information the driver reads distinguishes it: BCF0 has the older size, and the B0RM key type has not been compared with other firmware. The helper now returns u16 instead of s16 on every machine. B0RM is an unsigned mAh count, so a remaining charge below 32768 mAh reads as before; a larger value, such as a wrongly swapped one, no longer turns negative. Compile-tested only; not run on hardware. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Opus 5.5 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
A J700 on a low-power USB-C source can have a charge-capable adapter online, with CHCE and CHCC set, while the system draws more than the adapter supplies. The battery current B0AC is then negative and the remaining charge falls. CHCE and CHCC describe the adapter, not the battery, so where the other SMC flags then lead the driver to report CHARGING, the status contradicts the battery. On J700, report DISCHARGING instead of CHARGING when B0AC is negative. Only the three CHARGING results change: CHNC clear, CHNC holding only the BMS-busy bit below the charge limit, and the CHSC fallback when CHNC cannot be read. FULL, NOT_CHARGING for a charge limit or an inhibit, and the existing DISCHARGING cases are decided first and stay as they are, so a battery held at its charge limit keeps reporting NOT_CHARGING. Whether CHNC reports an inhibit in the low-power state has not been recorded; if it does, the status there stays NOT_CHARGING. The quirk is decided once at probe, and other machines keep the current status logic. B0AC is compared against zero. No noise floor around 0 mA has been measured, so a net current that hovers around zero can make the status alternate between CHARGING and DISCHARGING. Compile-tested only; not run on hardware. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Opus 5.5 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
force-pushed
the
series/neo-j700-smc-power-20260926
branch
from
September 25, 2026 17:06
84afce6 to
e9f5493
Compare
RyanTheTide
marked this pull request as ready for review
September 25, 2026 17:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
J700 battery charge and status for
macsmc-power, reworked after review. Three commits onaurora-wip(671ad267c).What changed since the reviewed head (84afce6820e2)
apple_smc_key_exists()(BITV, B0RC, B0RI, B0RV) is now its own patch, and its message says it applies to every machine. The B0RM byte-order fix is a separate patch.of_machine_is_compatible()on every property read:b0rm_native: B0RM is in native byte order. It is set for one-byte BCF0 firmware, as before, and on J700.status_from_current: report DISCHARGING when B0AC is negative.fw_ge_27again means only that BCF0 is one byte.u16, and the message explains that change. The key-type detection the reviewer suggested could not be verified from the code, so the J700 case is keyed on the machine compatible, and the message says why.5b075f38099c, CAPACITY from B0RM/B0FC instead of BUIC on J700). It would make Linux show a different percentage from macOS, and it gives no J700-specific reason.Ryan Murray <[email protected]>, followed by one trailer block:Assisted-by: LLM checkpatch sparse, thenCo-authored-by: Claude Opus 5.5on the two commits whose code changed, then the sign-off.Checks:
W=1 C=1compile with LLVM and upstream sparse ofmacsmc-power.o(andapple.o), no warnings.checkpatch --stricton each patch file: 0 errors. The only warnings are the known ones: the 7.1 tree'sAssisted-byformat,Co-authored-byas a non-standard signature, and "Unknown commit id" for the in-tree57694663d658when run outside a git directory.Compile-tested only; not run on hardware in this form. A J700 boot should confirm:
charge_nowmoves in 1 mAh steps and stays between 0 andcharge_full;One older-firmware Mac should confirm that the four properties and
charge_noware unchanged.🤖 Generated with Claude Code