From 9a6700d52e8dfb2e93623e7143204ae34f798bbf Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 7 Jun 2016 22:43:16 +0100 Subject: imx233: fix power off code There are two very suspicious things in the power off code: - it does not properly unlock the power register, so it should fail (!) - it does not disable sw/hw watchdog so if register fails, the device will most probably crash horribly because of the watchdog I don't even understand how it worked before. Change-Id: I9f3f94bd012e52c3b50cd5b658d68b5eb907f79b --- firmware/target/arm/imx233/power-imx233.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'firmware') diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c index 600f65eea6..e2b6a622a0 100644 --- a/firmware/target/arm/imx233/power-imx233.c +++ b/firmware/target/arm/imx233/power-imx233.c @@ -28,6 +28,7 @@ #include "power-imx233.h" #include "pinctrl-imx233.h" #include "fmradio_i2c.h" +#include "rtc-imx233.h" #include "regs/power.h" @@ -232,6 +233,11 @@ void power_off(void) { /* wait a bit, useful for the user to stop touching anything */ sleep(HZ / 2); + /* disable watchdog just in case since we will disable interrupts */ + imx233_rtc_enable_watchdog(false); + /* disable interrupts, it's probably better to avoid any action so close + * to shutdown */ + disable_interrupt(IRQ_FIQ_STATUS); #ifdef SANSA_FUZEPLUS /* This pin seems to be important to shutdown the hardware properly */ imx233_pinctrl_acquire(0, 9, "power off"); @@ -240,7 +246,7 @@ void power_off(void) imx233_pinctrl_set_gpio(0, 9, true); #endif /* power down */ - HW_POWER_RESET = BM_OR(POWER_RESET, UNLOCK, PWD); // FIXME bug + HW_POWER_RESET = BF_OR(POWER_RESET, UNLOCK_V(KEY), PWD(1)); while(1); } -- cgit v1.2.3