FunKey-Project / FunKey-S-Hardware

Hardware design and production files for the FunKey S retro-gaming console
Other
92 stars 23 forks source link

PMIC default voltages #2

Closed wolfallein closed 3 years ago

wolfallein commented 3 years ago

Hi,

very nice project and very well documented! Congrats!

I have a question regarding the default voltage on the AXP209. I was reading the datasheet but it is not very clear how the voltage is set when the system starts, before u-boot, or kernel takes control.

For the LDO1, and DC3 there are some set pins that in the funkey schematic sets them to 3.3V. The Vdram is fixed to 1.8V.

LDO2 can vary from 1.8V-3.3V, but in the schematic it is 3.0V. DC3 can vary from 0.7-3.5V, but in the schematic it is 1.25V (Vcore).

So, how the voltage is set before the CPU wakes?

BR

Michel-FK commented 3 years ago

Hi,

Just a small precision: Vcore is DC2, not DC3.

Yes, the AXP209 datasheet is not clear at all regarding the default voltages, and has some other mistakes too.

In the Allwinner V3s reference design, the AXP203 is used with the following configuration

As X-Powers is an Allwinner sister company specialized in power chips for the Allwinner SoC, they are tailor-made for these chips, and as the AXP209 was sold on Aliexpress as a bundle with the V3s, we figured out that it would default to the right settings regarding the adjustable output voltages.

It is indeed the case, and as in the reference design, the default voltages for LDO2 is 3.0V, and DC2 is 1.25V, despite the lack of information in the datasheet (default values are XXXX!).

So, there is no software adjustment required at all during the whole boot process.

Upon startup, the voltages are thus:

EDIT: We suspect that the whole AXP2xx family is in fact the same chip, with default voltages set by blowing some fuses during the manufacturing process to accommodate for different SoCs.

wolfallein commented 3 years ago

Thanks a lot for the information.

This was driving me crazy. I also found small mistakes everywhere in their datasheets, seems like they never got a final version.

They always say: "As for more details, please refer to “Default Configuration Instruction".

But this section simply doesn't exist.

I was particularly worried about the default voltages because XX means that it can be any value, and this is definitely not good for power regulators that drive SOC's.

I found some differences in their chips, they are not 100% pin-compatible:

Maybe there are little differences in their registers (like max voltages, timing...), but I didn't check.

I could only see the bundle with the AXP203 at Aliexpress now, so something to consider when buying it ...

Just some little notes regarding the schematic:

  1. I noticed there is missing a diode for protection in parallel with the battery connector. I guess you assumed the battery already has such protection, but this is not always the case. If the user replaces the battery with another model that doesn't have the protection and connects with inverted polarity, it can be dangerous, and a single diode could help to increase safety.

  2. I see the reed switch is connected to N_OE pin, and from what I could see, it is a power cut. A hardware power cut could generate some corrupted data if the system is mounted as r/w. Since the OS is very limited the chances are low, but maybe you get a bad write in 1/100 (just guessing), maybe with a few of them the system won't be able to boot properly. The axp20x series has a very good mainline kernel support and the power button can send a soft power off or sleep input to the system. The GPIO pins can also behave as input to the system, but I couldn't find that N_OE can be input, although it can be configured to change IRQ state. Maybe I'm missing something, but wouldn't be better to connect the reed switch to PWRON, or one of the GPIO's to get a soft power off instead of using N_OE?

Again, I wanted to thank you for all the information and the detailed documentation of the system, very good work here!

In almost all DIY boards in the market, they claim open source, open hardware but you never get everything they promise.

All the best

Michel-FK commented 3 years ago

Yes, I have been looking for this non-existing section too...

Thank you for pointing out the pin out differences between the different chips!

Regarding your notes:

Our batteries feature an asymmetrical JST connector, and they contain a built-in protection circuit against over current, under and over voltage as well as reverse polarity using N-FET-based ideal diodes (under the yellowish Kapton tape), so this is safe enough when using the stock batteries.

Then, you can put an additional series (Schottky) diode for reverse connection protection, but you loose the diode drop voltage times the current to heat the birds (~6% of the battery capacity). Or you can put a diode in parallel to the battery, but it should withstand the battery discharge current that can be quite high: ~1.5W to dissipate, which requires a large diode and some way to dissipate this energy in heat. Most of the time, it requires a series fuse to open the circuit before this happens, thus incurring a small voltage drop for resettable fuses too.

These are the reason why we chose to only use the battery-integrated protection and connector only. I personally recommend to NEVER use an unprotected battery.

As for the N_OE signal, it is not a hard signal either: you have a programmable grace period of up to 3s before the actual shutting down. In our design, this signal is also input into our PCAL6416A I2C GPIO expander, so it generates an interrupt signal to the SoC that will shutdown the system in order: we have time to snapshot the game status to save it onto the SD card, then unmount the R/W data partition safely. The system is on a read-only partition, so it does not risk any damage.

Regarding our Open Hardware / Open Software policy, this is something we strongly believe in. We were granted by the work of many and learned a lot in the process, so we want others to receive the same gift in turn!