Skip to content

iPod touch 6 (N102): battery status from the D2186 PMIC - #202

Merged
henrikklee merged 7 commits into
OrchardLinux:mainfrom
brkosebay:pr/n102-battery
Nov 24, 2026
Merged

henrikklee merged 7 commits into
OrchardLinux:mainfrom
brkosebay:pr/n102-battery

Conversation

@brkosebay

Copy link
Copy Markdown
Contributor

Stacked on #201 (Wi-Fi). Review only the last 3 commits. Draft until the latest power/0042 revision has run on the device.

The iPod touch 6 has no fuel gauge. iOS reads the battery through the Dialog D2186 PMIC's housekeeping ADC and charger status registers. These drivers do the same, and they only read.

Commits

  • kernel: battery status on the iPod touch 6 from the D2186.

    • iio/0010-0011: apple-d2186-adc, a polled 12-bit ADC exposed as IIO channels: battery and bus voltage, charge and bus current, battery thermistor, and the PMIC's factory current calibration.
    • power/0040-0041: apple_d2186_battery, a battery and USB power_supply built from those channels and the status registers 0x60 and 0x62. It never writes a charger register.
    • devices/t7000/0019: the nodes on the N102.
    • Configs: CONFIG_APPLE_D2186_ADC=m and CONFIG_BATTERY_APPLE_D2186=m on apple-4k. apple-16k leaves both off, because no A9 or later board has a D2186.
  • kernel: apple_d2186_battery: estimate the charge as iOS does (power/0042, devices/t7000/0020). It follows AppleARMPMUCharger for battery family 6:

    • its OCV table, averaged samples, and IR and load compensation;
    • a median over recent estimates and coulomb counting while charging;
    • _smoothSOC's rate limit: the reading only rises while charging, only falls on battery, and stays at 99% until the charger ends.

    When the charge-current channel reads 0 while charging, the driver falls back to the PMIC's averaged charge current.

  • devices: n102: battery status works. Battery is set to working. The catalog counts apple_d2186_battery as a battery driver, and the matrix is regenerated. Charging stays missing, because nothing sets the charge current.

Tested (iPod touch 6)

  • With power/0040-0041 only, in a RAM boot on a charger: 3.77 V, 28 %, 28 °C, Charging; USB online at 5.19 V and 219 mA. The charge-current channel read 0 while charging.
  • The installed system ran the first revision of power/0042. This revision was refined from that system's logs: the median ring, the strict 0x62 charging rule and the averaged-current fallback for the zero reading above. It is built but has not run on the device yet.

Open

  • The OCV curve has not been checked against a full charge and discharge.
  • Charge current control (charging, charging_control).

Proposed changelog line: "iPod touch 6 (N102): battery status."

🤖 Generated with Claude Code

The iPod touch 6 has no fuel gauge: iOS reads the battery through its
Dialog D2186 PMIC. Two read-only drivers do the same:

- iio/0010-0011: apple-d2186-adc, the PMIC's 12-bit housekeeping ADC as
  IIO channels (battery and bus voltage, charge and bus current, battery
  thermistor), polled, with the PMIC's factory current calibration.
- power/0040-0041: apple_d2186_battery, a power_supply for the battery
  and USB from those channels and the charger status registers 0x60 and
  0x62. It never writes a charger register.
- devices/t7000/0019: the ADC and battery nodes on the N102, with the
  1080 mAh design capacity and 3400 mV shutdown voltage of its ADT.

Configs: CONFIG_APPLE_D2186_ADC and CONFIG_BATTERY_APPLE_D2186 are =m on
apple-4k for the N102; apple-16k leaves both off, as no A9 or later board
has a D2186.

Assisted-by: LLM
A single voltage sample on a made-up curve jumped with every load
change. Follow AppleARMPMUCharger for battery family 6 instead, still
read-only:

- power/0042: its 100-point OCV table, ten averaged samples per update,
  IR compensation while charging and load compensation while
  discharging, a median over recent estimates, coulomb counting while
  charging, and _smoothSOC's rate limit: the reported charge only rises
  while charging (0x62 bits 1:0 or USB present), only falls on battery,
  and stays at 99% until the charger ends. When the charge-current ADC
  channel reads 0 while charging, it falls back to the PMIC's averaged
  charge current (0x4e2).
- devices/t7000/0020: the N102's battery node with key points of that
  curve and the 200 mOhm internal resistance.

Assisted-by: LLM
The D2186 battery driver was seen reporting on the iPod touch 6: battery
voltage, charge, temperature and status, and USB online with its bus
voltage and current. The catalog counts apple_d2186_battery as a battery
driver.

Charging stays missing: the driver only reads, and the PMIC charges at
the limit the boot loader left.

Assisted-by: LLM
Main took iio/0010-0011 and power/0040-0042 while this branch was open,
so the D2186 ADC becomes iio/0019-0020 and the battery driver
power/0071-0073. The ADC's Kconfig and Makefile entries sit before
main's Orion VBUS ADC.

On main, devices/t8015/0019 moves the N102's Wi-Fi and Bluetooth into
t7000-bcm4345.dtsi after this branch's device tree patches apply, and
its context included the lines next to the new battery node. The
simple-battery node now closes the root node instead, after gpio-keys,
so both apply. The nodes and their values are unchanged.

Assisted-by: LLM
The N61 and N56 have the iPod touch 6's D2186 PMIC, so devices/t7000/0027
describes its housekeeping ADC in t7000-6.dtsi as well. Their battery
stays with the bq27540 gauge; a second battery supply from the PMIC
would report the same cell twice, which is why they get no
apple,d2186-battery node. Untested on both.

The changelog entry covers the iPod touch 6's battery status and the
iPhone 6's ADC.

Assisted-by: LLM
@henrikklee
henrikklee marked this pull request as ready for review November 24, 2026 15:39
@henrikklee
henrikklee merged commit 9cb4066 into OrchardLinux:main Nov 24, 2026
12 checks passed
@henrikklee

Copy link
Copy Markdown
Contributor

Merged, thanks! The iPod touch 6 now shows its battery: charge, voltage, temperature and charging state from the D2186, with your iOS-style estimate, plus USB power. Battery is marked working in the device table, and the changelog has an entry.

It had stalled because it was a draft stacked on #201 (Wi-Fi). After #201 merged, main had taken some of its patch numbers, and main's change that moves the iPod's Wi-Fi and Bluetooth into a shared file no longer applied after your device tree patch.

Changed on top, by effect:

  • It fits main. The ADC patches are now iio/0019-0020, the battery driver power/0071-0073. The battery description now sits at the end of the iPod's root node so both device tree changes apply. Your code and values are unchanged.
  • The iPhone 6 and 6 Plus get the ADC. They have the same D2186, so its voltage, current and thermistor readings are described for them too (t7000/0027). They get no D2186 battery node, because their bq27540 gauge already reports the battery and a second one would show it twice. Untested there.
  • No overlap with n66: battery and charging work, with a battery temperature guard #229. That change was to the bq27540 gauge, which the iPod doesn't have. The only clash was the catalog's driver list, and it now names both.

Tag: contrib/brkosebay-n102-battery at your commit d1dba15.

Two asks, when convenient:

  • A retest on the iPod from main. The refined power/0073 (median ring, strict charging rule, averaged-current fallback) hasn't run on the device yet. Does the percentage track sensibly on the charger and off it?
  • Your Signed-off-by (name and email) on iio/0019-0020, power/0071-0073 and t7000/0019-0020. A short comment here saying you approve it is enough, and we add it.

@brkosebay

Copy link
Copy Markdown
Contributor Author

Signed-off-by: Berkay Kösebay brkosebay@users.noreply.github.com

For iio/0019-0020, power/0071-0073 and t7000/0019-0020. The approval on #231 covers all my other patches on main too. The retest of power/0073 from main on the iPod follows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants