Pinephone keyboard bugs and new findings
There is some
speculation out there about Pinephone keyboard charger chip (IP5209) getting
damaged simply by plugging in something into Pinephone's USB-C port, because
that's supposed to be like connecting two chargers into a single port, which
somehow causes damage.
I decided to measure this, and see what really happens:
The charging situation with the keyboard looks like this:
There are a few things that can be seen from the picture:
- Pinephone keyboard MCU is always powered from Phone's battery (even when
the phone is off), which leads to slow discharge of the Pinephone battery as
long as the keyboard is connected to the phone. The keyboard will discharge the
fully charged phone's battery in about a month. You also always have to connect
the keyboard live. The phone can't power cycle the keyboard MCU if MCU locks up
for some reason.
- 5V BOOST circuit for VBAT POGO pin either produces 5V, or it has Phone
battery voltage – 0.5V. KB MCU is connected over a 3.3V voltage regulator to
VBAT POGO pin. This regulator adds a further voltage drop. Keyboard MCU needs to
run at 3.3V. So unless the phone battery is fully charged, the keyboard MCU will
be a bit undervolted if the 5V boost regulator in the phone is not turned on.
That regulator is turned off when the phone is off. Also some distros like pmOS
have old driver that doesn't turn this regulator on.
So that's a bit annoying. Another few things can be seen about how charging
the batteries works:
- Phone battery is charged from VBUS. So that's either from USB PSU (power
supply unit) connected to the phone's USB-C port, or from VOUT of keyboard
battery charger chip (IP5209).
- Phone can provide power on VBUS from the 5V boost regulator, if it switches
on a switch and turns off phone battery charging.
- Keyboard can enable 5V on VOUT and provide it from the keyboard
- Alternatively, when USB PSU is connected to the keyboard, VOUT is
auto-enabled (and can't be turned off) and it provides/passes through power from
the USB PSU.
Many fun combinations are possible. The question is if some of them are
problematic. For example what happens when you enable VOUT from keyboard and
plug in USB PSU to the phone at once. Not much really. I've measured voltage
transients and current from VOUT pin, and everything is withing reasonable
parameters. The load presented by the phone is split between USB PSU and the
keyboard's VOUT BOOST regulator, so part of the power is provided by the
keyboard and part by the USB PSU. That is somewhat wasteful use of the keyboard
battery, but not harmful. It's good to disable VOUT when you want to charge the
phone battery using a phone's USB-C connector, to not needlessly discharge the
What happens when VOUT is disabled? Nothing. IP5209 lives on, and there's no
current flowing into VOUT from USB PSU connected to VBUS. All good.
Now the surprising thing is what happens when you plug USB PSUs to both the
keyboard and the phone. One would think that the keyboard will continue
supplying power to the phone via VOUT, like in the first scenario, except that
the keyboard battery would not be getting discharged this time. Nope. What
I measured was 450mA current flowing into VOUT, and not out of it, like before.
That is NOT expected, and not wanted at all. At best we'd expect no current at
all. IP5209 would nicely charge the battery from it's own VBUS input, and phone
would charge it's own battery from its own VBUS input and no current would flow
to VOUT. This is a situation that is problematic and needs to be avoided. To
avoid it, it's enough to not connect anything to phone's USB port when a USB
PSU is connected to the keyboard. All other combinations seem to be safe. In
particular, it should be safe to have VOUT from the keyboard enabled, and to
charge the phone via phone's USB-C port, or to use the dock with the
phone's USB-C port.
So the only thing to worry about is to not connect anything to phone's USB
port when keyboard's USB port is occupied. That is unsafe, and it behaves
weirdly. Turning off VOUT when charging the phone directly is a good idea, but
forgetting to turn it off will only lead to needless discharging of the
keyboard's battery, and should not damage the keyboard. There's no backflow of
the current into VOUT. The short periods of energy backflow into VOUT did not
lead to IP5209 damage in my tests. But I don't know if that energy went into
charging the keyboard battery somehow, or was dissipated as extra heat. That
would be something to measure next. :)