On Mon, Jan 10, 2022 at 10:33:54PM -0300, Crystal Kolipe wrote: > On Mon, Jan 10, 2022 at 04:09:03PM -0300, Crystal Kolipe wrote: > > On Mon, Jan 10, 2022 at 06:55:57PM +0100, Mark Kettenis wrote: > > > > Date: Mon, 10 Jan 2022 18:35:05 +0100 > > > > From: Patrick Wildt <patr...@blueri.se> > > > > > > > > Am Mon, Jan 10, 2022 at 07:42:12PM +0900 schrieb SASANO Takayoshi: > > > > > Hi, > > > > > > > > > > To change AXP80x into RSB mode, put 0x7c value to register 0x3e. > > > > > The value defined RSB_DMCR_DEVICE_MODE_DATA in sxirsb.c works > > > > > 0x7e to the register. It needs to be fixed. > > > > > > > > > > At least my Allwinner H616 with AXP305 works good with fixed value. > > > > > > > > Yeah, that definitely seems like a bug. Unless anyone reports a > > > > regression, that's OK with me and definitely the correct fix. > > > > > > A64 + AXP803 works fine with this diff on the pinebook, and this > > > matches the Linux code. > > > > > > ok kettenis@ > > > > > > > I wonder if that fixes the machine from Pinephone thread? > > > > > > Me too. > > > > I'm wondering that too, but I've not in the office at the moment to > > test it. I'll try to test either late tonight or tomorrow and report > > back. > > OK, I couldn't resist testing tonight, and I'm pleased that I did :) > > I can now successfully boot an MP kernel, sxirsb seems to work as > expected, axppmic attaches and seems to report plausible data, and > frequency scaling works: > > With AC connected: > > hw.sensors.axppmic0.temp0=46.80 degC > hw.sensors.axppmic0.volt0=3.95 VDC (battery voltage) > hw.sensors.axppmic0.current0=0.00 A (battery charging current) > hw.sensors.axppmic0.current1=0.04 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), OK > hw.sensors.axppmic0.indicator1=On (VBUS), OK > hw.sensors.axppmic0.indicator2=On (battery present), OK > hw.sensors.axppmic0.indicator3=Off (battery charging) > hw.sensors.axppmic0.percent0=68.00% (battery percent), OK > hw.sensors.sxitemp0.temp0=29.91 degC (CPU) > hw.sensors.sxitemp0.temp1=29.44 degC (GPU) > hw.sensors.sxitemp0.temp2=30.26 degC > > With AC disconnected, using battery power: > > hw.sensors.axppmic0.temp0=43.83 degC > hw.sensors.axppmic0.volt0=3.83 VDC (battery voltage) > hw.sensors.axppmic0.current0=0.00 A (battery charging current) > hw.sensors.axppmic0.current1=0.59 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=Off (ACIN) > hw.sensors.axppmic0.indicator1=Off (VBUS) > hw.sensors.axppmic0.indicator2=On (battery present), OK > hw.sensors.axppmic0.indicator3=Off (battery charging) > hw.sensors.axppmic0.percent0=68.00% (battery percent), OK > hw.sensors.sxitemp0.temp0=29.79 degC (CPU) > hw.sensors.sxitemp0.temp1=29.56 degC (GPU) > hw.sensors.sxitemp0.temp2=29.91 degC > > The battery level seems plausible, as it was ~92% before starting > tonight's fresh re-install. > > The battery is not charging, but this is expected, right? Surely we need to > explicitly configure the charging current via the AXP803 PMIC? > > Also, the zero values for battery maximum capacity and battery current > capacity are obviously wrong, but I'm assuming that the battery simply does > not supply this information. > > hw.cpuspeed=816 > hw.setperf=34 > > phone# apm > Battery state: unknown, 0% remaining, unknown life estimate > A/C adapter state: not known > Performance adjustment mode: manual (816 MHz) > > phone# sysctl hw.setperf=100 > hw.setperf: 34 -> 100 > > phone# apm > Battery state: unknown, 0% remaining, unknown life estimate > A/C adapter state: not known > Performance adjustment mode: manual (1152 MHz) > > Overall, though, things are looking good! > > My _phone_ runs OpenBSD!!! :-)
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 */