zador-blood-stained / axp209-sysfs-interface

Sysfs interface for AXP209 PMU
http://forum.armbian.com/index.php/topic/611-rfc-needs-testing-axp209-mainline-sysfs-interface/
Other
3 stars 3 forks source link

deprecated? #2

Open PaddleStroke opened 5 years ago

PaddleStroke commented 5 years ago

Hi, On armbian forum you say there :

Main purpose of this patch is creating a sysfs interface to get information from AXP202/209 PMU until proper power driver is implemented in mainline kernel.

At the time it was created it was the simplest way to get data from the PMIC or change some settings without using userspace tools like i2cget/i2cset or a custom code based on i2c libraries.

Newer kernels have received proper drivers - starting with 4.12 there is even a battery driver and an ADC IIO driver, but this patch still can be useful i.e. to enable/disable RTC battery changing on some boards.

Are you talking about this script? If so can you please elt me know where is the source code of the AXP209 driver? Thanks!

zador-blood-stained commented 4 years ago

deprecated?

Not maintained (because I don't use the only A20/AXP209 board anymore) but should still work, though may require adjusting for newer kernels.

Are you talking about this script?

This is a kernel patch, but yes, it lives in this repository.

If so can you please elt me know where is the source code of the AXP209 driver?

This patch applies to the MFD driver in drivers/mfd/axp20x.c in the mainline kernel tree.

Other (newer) drivers are in drivers/power/supply/axp20x_battery.c, drivers/power/supply/axp20x_ac_power.c, drivers/power/supply/axp20x_usb_power.c, drivers/input/misc/axp20x-pek.c and I think there are some other bits somewhere.

PaddleStroke commented 4 years ago

Thanks for the reply!

So this patch should add the sysfs interface right? The one in /sys/power/axp_pmu ?

This patch does not cover battery max voltage right? (reg33) Nor the ADC GPIO ?

My problem is that I can't find other sysfs files than the ones generated by this patch. I'm not sure but I think there should be others sysfs folder no? Quentin Schulz who worked on some of these axp drivers suggested to use /sys/class/power_supply/voltage_max_design to change battery max voltage. But this does not exist.

Do you know how to use those drivers axp20x.c axp20x_battery.c ..?

Btw I opened a thread on armbian forum to discuss the matter : https://forum.armbian.com/topic/10834-axp209-proper-driver/ Also I found an issue with u-boot axp209 driver that may have been causing you trouble in the past (battery detection reseting) see the topic.

zador-blood-stained commented 4 years ago

So this patch should add the sysfs interface right? The one in /sys/power/axp_pmu ?

Yes.

This patch does not cover battery max voltage right? (reg33) Nor the ADC GPIO ?

Yes, those functions are not implemented. Though the kernel now has a pinctrl/GPIO driver for the PMIC here. And battery voltage should be settable via the "proper" driver looking at it here.

My problem is that I can't find other sysfs files than the ones generated by this patch. I'm not sure but I think there should be others sysfs folder no? Quentin Schulz who worked on some of these axp drivers suggested to use /sys/class/power_supply/voltage_max_design to change battery max voltage. But this does not exist.

First, those drivers need to be enabled in the kernel at the compilation time (i.e. CONFIG_BATTERY_AXP20X for the battery driver), and second, they need to be enabled in the Device Tree file for your board, i.e. like here for Cubietruck.

Those drivers should add nodes to /sys/class/power_supply/ if activated correctly.

Also I found an issue with u-boot axp209 driver that may have been causing you trouble in the past (battery detection reseting) see the topic.

I didn't test shutdown from u-boot at the time (as why would you ever want to interact with u-boot shutdown outside of debugging?), the main problem with battery detection was(is) in the kernel here - it should use regmap_update_bits() instead of regmap_write()

PaddleStroke commented 4 years ago

Thanks for the tips about adding to dts. I had not added them, that's why I did not got the sysfs!

And yes indeed you are right, the same issue is in kernel driver, I just found it few minutes ago. I found the uboot driver first, so I thought the issue was coming from there.