Skip to content

Conversation

@lks9
Copy link

@lks9 lks9 commented Nov 10, 2025

This adds battery for a6plte, charging works now, battery percentage is displayed in phosh. The a6plte seems to work great with postmarketos (only broken call-audio and broken camera) thank you all to make that possible!

  • cherry-picked 276a423: add support for sm5708 mfd
  • cherry-picked 04135c5: add support for sm5708 charger
  • cherry-picked e8e2f37: add support for SM5708 fuel gauge
  • i2c interface updated
  • extend a6plte device tree with mfd, charger, and fuel gauge
  • fix irq for sm5708 mfd
  • fix charging status report: add supply_to

This is the first linux kernel patch I submitted anywhere, I know this is the wrong format. Perhaps someone can also point me to the documentation on how I can do it right...

Also, there are some quirks:

  • sm5708_request_mode() is exported as global function. Therefore, kernel log gives Driver 'sm5708-mfd' needs updating - please use bus_type methods. This should be fixed.
  • of_get_named_gpio() is marked as deprecated, but I don't know how I could get the IRQ from the device tree. In general, I don't know much about the device tree kernel interface or how IRQs are initialized under the hood.
  • I don't understand the drivers in detail, I just found them with github's advanced file search... And they "just work" after some small fixes.

Junak and others added 7 commits November 8, 2025 21:47
@lks9 lks9 marked this pull request as ready for review November 10, 2025 12:08
@lks9
Copy link
Author

lks9 commented Nov 10, 2025

By chance, I found out that the latest release v6.17.7-r0 includes another driver for the sm5708. First, I thought ok, at least I learned something about kernel drivers. But now I tested it and the battery percentage did not show up. If there is no quick fix, I would still stick to the version here. I do not know why I should spend time debugging the other driver, because this one works on my device.

@vldly, you are the author of the other sm5708 driver, commit 92a0fab. Did it work properly on your device, including battery percentage?

@vldly
Copy link
Member

vldly commented Nov 13, 2025

By chance, I found out that the latest release v6.17.7-r0 includes another driver for the sm5708. First, I thought ok, at least I learned something about kernel drivers. But now I tested it and the battery percentage did not show up. If there is no quick fix, I would still stick to the version here. I do not know why I should spend time debugging the other driver, because this one works on my device.

It has some dependencies for complex battery thermistor setup, which is needed for thermal mitigation.

CONFIG_GENERIC_ADC_THERMAL
CONFIG_IIO_MUX
CONFIG_MUX_GPIO
CONFIG_QCOM_SPMI_VADC

If those are missing or didn't probe it won't work.

@vldly, you are the author of the other sm5708 driver, commit 92a0fab. Did it work properly on your device, including battery percentage?

Yes. Battery estimation isn't great but better than nothing. With old driver it might die at 20% or so.

@lks9
Copy link
Author

lks9 commented Nov 13, 2025

It has some dependencies for complex battery thermistor setup, which is needed for thermal mitigation.

CONFIG_GENERIC_ADC_THERMAL
CONFIG_IIO_MUX
CONFIG_MUX_GPIO
CONFIG_QCOM_SPMI_VADC

If those are missing or didn't probe it won't work.

Thanks, I will try it again with these configurations tomorrow, I am currently travelling.

I just used the config-postmarketos-qcom-msm8953.aarch64. Normally, all dependent kernel dependencies should be specified in the Kconfig.

Yes. Battery estimation isn't great but better than nothing. With old driver it might die at 20% or so.

Thanks, that could be an issue on the old implementation! Actually, my phone died. After restarting, it was at 4%. Then I disconnected it from battery, it died again, and after restarting, it was 15%. It seems to me that the phone dies too early...

@lks9
Copy link
Author

lks9 commented Nov 16, 2025

It has some dependencies for complex battery thermistor setup, which is needed for thermal mitigation.

CONFIG_GENERIC_ADC_THERMAL
CONFIG_IIO_MUX
CONFIG_MUX_GPIO
CONFIG_QCOM_SPMI_VADC

If those are missing or didn't probe it won't work.

I checked it now. Because I was travelling, it took a bit longer (compiled it natively on the phone).

Results:

  1. Both versions showed the same battery percentage. I could not confirm that the battery percentage estimation is different in any kind.
  2. Charging did not work with your newer driver. And neither /sys/class/power/supply/sm5708-charger/status nor the battery symbol in Phosh reported when the phone was connected to an electric socket. Perhaps the IRQ was not correctly registered? I fixed that one for the present driver with commit 5613361.
  3. dmsg did not indicate that anything was failing.

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