Repository navigation
iPod touch 6 (N102): battery status from the D2186 PMIC - #202
Conversation
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
|
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:
Tag: Two asks, when convenient:
|
|
Signed-off-by: Berkay Kösebay brkosebay@users.noreply.github.com For |
Stacked on #201 (Wi-Fi). Review only the last 3 commits. Draft until the latest
power/0042revision 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.CONFIG_APPLE_D2186_ADC=mandCONFIG_BATTERY_APPLE_D2186=mon 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: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_batteryas a battery driver, and the matrix is regenerated. Charging stays missing, because nothing sets the charge current.Tested (iPod touch 6)
power/0040-0041only, 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.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
charging,charging_control).Proposed changelog line: "iPod touch 6 (N102): battery status."
🤖 Generated with Claude Code