Hi Patrick,

On Thu, Dec 30, 2021 at 02:30:22PM +0100, Patrick Wildt wrote:
> Power:
> If the dock is supposed to work without another USB-C connected, then we
> would need to provide 5V to the USB port.  What I can see is that the
> AXP803 supports being connected to a USB power supply, and using this to
> charge the battery.  There's also a pin that tells it when *not* to use
> VBUS.  I think if the phone provides 5V on the USB, it will probably set
> the N_VBUSEN to tell AXP803 to disregard the VBUS, otherwise it would
> probably charge itself...  N_VBUSEN is controlled by USB-DRVVBUS, which
> is connected to DRVVBUS (which controls a USB Power Loading Switch), and
> there's also PL9-DRVVBUS (a GPIO on the A64) and VBUS_CTRL.  This last
> one is connected to ANX7688S, which seems to handle USB-C Power Delivery
> to find out how much one can charge, and if we should switch data/power
> roles.  There's some more info here:
> 
> https://xnux.eu/devices/feature/anx7688.html
> 
> I really can't find where... oh.  Now I see. USB-5V is connected to the
> battery and over the USB Power Loading Switch to DCIN.  So I guess if
> there's no 5V on input, it will output?
> 
> Can you attach a simple stupid boring Type-C to Type-A adapter and see
> if there's 5V on it?  Because if so, then the Dock is probably powered
> as well, but the ports on the dock don't provide power?

I've just tested this, and I get almost the same voltage reading with
the Type-C to Type-A adaptor as I did connecting the analyser directly
to the phone's type-C port.

Booted into bsd.sp, with a fully charged battery, it's reading 3.61 volts.

I also tested leaving the analyser connected and did a 'halt -p', and the
USB voltage dropped to zero.  So power-off does seem to be working.

By the way, when I was testing with the dock previously, the readings I
noted were measured between the phone and the dock, not from one of the
USB ports on the dock.  Maybe that wasn't entirely clear, so I thought I'd
mention it.

I tested the current draw when the phone is connected to AC, and booted
into the MP kernel after it has crashed.  It draws 250 mA fairly constantly,
and the handset gets quite warm.  Presumably the CPU is stuck in a tight
loop.

> We need a driver for x-powers,axp813-usb-power-supply which sets the
> RS (Run/Stop) bit in the BC Module Global register.  This starts the
> battery charging module.

As we don't have a way to charge the battery yet, it will eventually
discharge completely whilst running the OpenBSD kernel, even if connected to
AC power.  This can cause a problem that is difficult to recover from if the
user is not aware of it happening:

If the battery is allowed to discharge completely, the phone can become
stuck in a loop when trying to boot a typical Linux distribution.  It seems
that early in the boot process the AC power tends to be disconnected
momentarily, and with a non-functioning battery, the phone switches off, only
to switch on again almost immediately when it sees that the AC power is
connected, and re-start the boot process from the beginning.

Although the device is not exactly, 'bricked', the effect is similar, because
the user might not have any way to charge the empty battery.  I wasn't able
to force the phone to switch off whilst connected to AC power, and resorted
to charging the battery for a few minutes with a lab power supply.  Afterwards
the handset was able to boot into a Linux kernel and then charged the battery
itself.

I would suggest that we wait until these issues are resolved before updating
our port of U-boot to build images for the Pinephone.

Now that I've got the battery working again, I'll take a look at sxirsb and
try adding some debugging code to see what's going on there.

Reply via email to