diff options
author | Chris Morgan <macromorgan@hotmail.com> | 2022-01-21 13:37:32 +0000 |
---|---|---|
committer | Andre Przywara <andre.przywara@arm.com> | 2022-01-30 01:25:00 +0000 |
commit | 52bcc4f053bd25e3508887da01c9e8cddac49b2e (patch) | |
tree | bbb02dd3a127e2900821268dffaff1aad953a661 /board/sunxi/board.c | |
parent | 78592c094e7a81cc099b3f71b05463ddcabe2a73 (diff) | |
download | u-boot-52bcc4f053bd25e3508887da01c9e8cddac49b2e.zip u-boot-52bcc4f053bd25e3508887da01c9e8cddac49b2e.tar.gz u-boot-52bcc4f053bd25e3508887da01c9e8cddac49b2e.tar.bz2 |
sunxi: Add option to prevent booting on power plug-in
For sunxi boards with the AXP209, AXP221, AXP809, and AXP818 PMICs
(plus possibly others, I only confirmed the datasheets for these),
it is sometimes desirable to not boot whenever the device is
plugged in. An example would be when using the NTC CHIP inside a
PocketCHIP.
This provides a configurable option to check if bit 0 of
register 0 of the PMIC says it was powered because of a power button
press (0) or a plug-in event (1). If the value is 1 and this option
is selected, the device shuts down shortly after printing a message
to console stating the reason why it's shutting down. Powering up the
board with the power button is not affected.
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
[Andre: reword to speak of boot, remove #ifdefs]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Diffstat (limited to 'board/sunxi/board.c')
-rw-r--r-- | board/sunxi/board.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c index d0a93da..9146300 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -28,6 +28,7 @@ #include <asm/arch/dram.h> #include <asm/arch/mmc.h> #include <asm/arch/prcm.h> +#include <asm/arch/pmic_bus.h> #include <asm/arch/spl.h> #include <asm/global_data.h> #include <linux/delay.h> @@ -602,6 +603,16 @@ void sunxi_board_init(void) defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER power_failed = axp_init(); + if (IS_ENABLED(CONFIG_AXP_DISABLE_BOOT_ON_POWERON) && !power_failed) { + u8 boot_reason; + + pmic_bus_read(AXP_POWER_STATUS, &boot_reason); + if (boot_reason & AXP_POWER_STATUS_ALDO_IN) { + printf("Power on by plug-in, shutting down.\n"); + pmic_bus_write(0x32, BIT(7)); + } + } + #if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \ defined CONFIG_AXP818_POWER power_failed |= axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT); |