changeset 500:a04a145098f1

target-utils: poweroff command does VRPCAUX cleanup for nTESTRESET
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 25 May 2019 22:35:51 +0000
parents 44a1de4264d8
children 7a6eba04c1bb
files target-utils/libbase/abbdrv.c
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/libbase/abbdrv.c	Sat May 25 22:20:34 2019 +0000
+++ b/target-utils/libbase/abbdrv.c	Sat May 25 22:35:51 2019 +0000
@@ -115,8 +115,16 @@
 abb_power_off()
 {
 	abb_init();
+	/*
+	 * If we booted via nTESTRESET, we need to clean up some state
+	 * in a secret undocumented Iota register before we do the DEVOFF,
+	 * otherwise subsequent switch-on via regular PWON button
+	 * won't work correctly.
+	 */
+	abb_unlock_page2();
+	abb_reg_write(VRPCAUX, 0x07);
 	serial_flush();
-	abb_reg_write(VRPCDEV, 0x01);
+	abb_reg_write(VRPCDEV, 0x01);	/* DEVOFF */
 	/*
 	 * TWL3025 datasheet seems to indicate that the time for the DEVOFF
 	 * command to take effect is 5 cycles of the 32.768 kHz clock.