Prevent lime2 from booting when plugin power cable

Started by PaddleStroke, November 25, 2018, 11:58:13 AM

Previous topic - Next topic

PaddleStroke

Hi there,
I am using a lime 2 (rev G) with a lipo battery.

I have the following behaviour :
- booting when power cable is plugged in.
- booting when power button is pushed.

Is there a way to prevent booting when power cable is plugged in? As I wish get boot only when power button is pressed.

Any software way of doing that? If not any hardware modification that would help?
Thanks

soenke

Afaik you can configure the AXP power chip via I2C to do that. You may have to dig into its manual to find out which option you have to change.

PaddleStroke

Thanks for reply!
I have been reading AXP209 datasheet, however I could not find the solution yet.

I am not sure to understand, from my understanding the AXP209 has an internal register, which values define AXP209 behaviour, such as DCDC voltages and so on.
Something troubling me is that A20 probably needs correct voltage to boot in the first place? And correct voltage should be set by A20 by I2C. So I am not sure to understand how can A20 fill the registers if it first need the register to be set in order to boot properly?


Anyway my main problem is that I cannot find how to set this behaviour in the datasheet. I found a reference saying it can be done but it does not say how it an be done...

QuoteSystem power-on is initiated whenever the following conditions occur:
1. When N_OE is low, and upon connection of a power supply that meets the requirements
(ACIN Or VBUS > 3.8V, and the battery voltage is higher than the shutdown voltage), AXP209
will automatically boot (Automatic booting on power supply connection can be configured by
the developer).

Also can you tell me how to modify ACP209 register values from console?

Thanks!

soenke

http://dl.linux-sunxi.org/AXP/AXP209_Datasheet_v1.0en.pdf
Page 15 general description

Page 43 N_OE startup IRQ

Set it via i2c.

It will be written to its internal flash.


soenke

additionaly:

http://linux-sunxi.org/AXP209

REG 40H and 48H: Interrupt bank 1; Input power

Bit 6 set to 0 should disable the AC IN interrupt.

use i2cset to set this value via i2c:

https://linux.die.net/man/8/i2cset

PaddleStroke

Thanks for your reply.

I had no chance to test this before actually.

I checked the REG-40 with i2Cget and I found the register have value 00 instead of default value... I am not sure why. Also other IRQ register like 41 42 43 all are 00.

Other registers like REG-00 and REG-01 and others show correct values so I guess my reading methode is OK.

Maybe there's a driver interfering? As the value is 00 the bit 6 is already set as 0 I guess, but the board keep booting up on AC connection.


soenke

I dont think that any driver could interfere with i2cget, thats too much low level.

Have you tried to set these values to different ones and read them afterwards? Maybe you also have to initiate a save-to-eeprom-operation to keep the values after reboot.

PaddleStroke

Will test that.
I am having some strange behaviour with i2Cset. Some registers are reseted after reboot. For instance I'm also trying to modify REG-90 to enable ADC, and the value keep reseting to 02h after every reboot.


soenke

maybe the AXP209 driver sets the registers to some default values on bootup?

PaddleStroke

Sounds possible.
The DTS of lime 2 say something about IRQ :
&i2c0 {
status = "okay";

axp209: pmic@34 {
reg = <0x34>;
interrupt-parent = <&nmi_intc>;
interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
};

https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
Not sure what this means. Do you know what this means?

soenke

That is the interrupt controller, but maybe that entry initiates the overwrite of the registers? You could try to remove that entry but be ready to have something to revert that change if your boards doesnt boot anymore after that :)

PaddleStroke

Very interesting. I found out why REG40 41 42 43 are all 0x00 :
https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/power/axp209.c

The uboot driver of AXP209 is setting them all to 0x00 on boot...

No idea why they are doing this actually...

PaddleStroke

I wonder if to disable boot from pluging power cable, we don't need to read REG 00 bit 0
QuoteIndicating whether the boot source is ACIN or VBUS R
0: Boot source isn't ACIN/VBUS; 1: Boot source is ACIN/VBUS.

And add a if in the uboot code to interrupt boot if this reg say it booted because of ACIN/VBUS.

But I don't think it's a good solution as it will still boot until reaching this part of uboot script.

Btw do you know what is uboot command to abort boot and shutdown?

JohnS

Quote from: PaddleStroke on July 18, 2019, 05:18:51 PM
Very interesting. I found out why REG40 41 42 43 are all 0x00 :
https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/power/axp209.c

The uboot driver of AXP209 is setting them all to 0x00 on boot...

No idea why they are doing this actually...

Maybe try asking the person who wrote the code.

If there's no good reason for that code, submit a patch (or fix request).

John

soenke

To interrupt uboot while booting i think you need to press the space key a lot with an attached keyboard or UART.

But i think it would be easier to patch uboot so it is not overwriting the registers.