On Tue, Jan 11, 2022 at 09:59:27AM +0100, Patrick Wildt wrote: > Can you try this? > > diff --git a/sys/dev/fdt/axppmic.c b/sys/dev/fdt/axppmic.c > index 7e2b0c99942..2a3497f6755 100644 > --- a/sys/dev/fdt/axppmic.c > +++ b/sys/dev/fdt/axppmic.c > @@ -36,6 +36,8 @@ extern void (*powerdownfn)(void); > #define AXP209_ADC_EN1_ACIN (3 << 4) > #define AXP209_ADC_EN1_VBUS (3 << 2) > > +#define AXP803_BC_MOD_GLOBAL 0x2c > +#define AXP803_BC_MOD_GLOBAL_EN (1 << 0) > #define AXP803_BAT_CAP_WARN 0xe6 > #define AXP803_BAT_CAP_WARN_LV1 0xf0 > #define AXP803_BAT_CAP_WARN_LV1BASE 5 > @@ -554,6 +556,15 @@ axppmic_attach_node(struct axppmic_softc *sc, int node) > > if (OF_is_compatible(node, "x-powers,axp803-battery-power-supply")) > sc->sc_sensdata = axp803_battery_sensdata; > + > + if (OF_is_compatible(node, "x-powers,axp803-usb-power-supply")) { > + uint8_t reg; > + > + /* Turn on battery charging module. */ > + reg = axppmic_read_reg(sc, AXP803_BC_MOD_GLOBAL); > + reg |= AXP803_BC_MOD_GLOBAL_EN; > + axppmic_write_reg(sc, AXP803_BC_MOD_GLOBAL, reg); > + } > } > > /* Regulators */
I've just tested the above patch... Quick resume: It didn't enable battery charging, but may or may not have had some other effect. Details: The Pinephone seems to be behaving differently this morning after being powered off overnight. I powered it on, connected to AC power, and it booted into the MP kernel that I compiled last night, with the new value of 0x7c for register 0x3e. It promptly paniced after checking the filesystems. I didn't save details of the panic as I thought that it would either be easily reproducable or not re-occur at all. I power-cycled the phone, and let it boot the same kernel, this time it froze with no panic. Power-cycled again, and it froze again. I then booted into the SP kernel with the 0x7c patch, and it booted fine, just like last night. I applied your latest patch above, and re-booted. At first there didn't seem to be any change: phone# sysctl hw hw.sensors.axppmic0.temp0=42.98 degC hw.sensors.axppmic0.volt0=3.80 VDC (battery voltage) hw.sensors.axppmic0.current0=0.00 A (battery charging current) hw.sensors.axppmic0.current1=0.33 A (battery discharging current) hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING hw.sensors.axppmic0.indicator0=On (ACIN), WARNING hw.sensors.axppmic0.indicator1=On (VBUS), WARNING hw.sensors.axppmic0.indicator2=On (battery present), OK hw.sensors.axppmic0.indicator3=Off (battery charging) hw.sensors.axppmic0.percent0=52.00% (battery percent), OK hw.sensors.sxitemp0.temp0=31.31 degC (CPU) hw.sensors.sxitemp0.temp1=29.91 degC (GPU) hw.sensors.sxitemp0.temp2=29.79 degC The battery is not charging, and I have checked that it is not just a reporting error, but the battery percentage is actually decreasing. However, notice that axppmic0.indicator0 and axppmic0.indicator1 now have a warning flag. This was not the case when testing last night. I reverted your lastest patch, and just kept the 0x7c patch in. Rebooted, but the warning flag remained. I decided to power-cycle the device, thinking that the PMIC might be keeping some kind of state between boots, but when I issued 'halt -p', the phone did not power off, instead it just rebooted. I tested this again, but it would not power off. After disconnecting AC power, the phone did power off with 'halt -p'. Booting again on battery power, the warning flags for axppmic0.indicator[0-1] are gone. Connecting AC power, they did not come back. Booting the MP kernel with the 0x7c patch in, but without your latest patch worked fine. No hang, no panic, it booted and I was able to exercise the cpus with md5 -ttt with no problems. This is the same kernel that would not boot on the device first thing this morning. So either it is a strange co-incidence, or something that I did during testing has created state that allows it to boot. I've just compiled an MP kernel with your latest patch. It boots fine, but just as before, the battery is not charging. There are no warning flags on axppmic0.indicator[0-1]. Testing 'halt -p' with this latest MP kernel, and AC power connected, the phone correctly powers down, rather than rebooting. Leaving the phone connected to AC, and cold booting into the MP kernel, it hangs. So that fault seems to be reproducable, and not dependent on your patch. I'll continue to investigate these issues and try to find simple ways to faithfully reproduce them, but I thought you'd like to see the info that I've got up to now.