From 1c97083ca77b4f9b1046b6b50046366310ad2dc2 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Mon, 26 Sep 2016 21:24:00 +0100 Subject: imx233: refactor power off and reboot There is no reason to use different code paths Change-Id: I4894c7963c802b56b5d3576909e1008a7c401935 --- firmware/target/arm/imx233/system-imx233.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'firmware/target/arm/imx233/system-imx233.c') diff --git a/firmware/target/arm/imx233/system-imx233.c b/firmware/target/arm/imx233/system-imx233.c index 2264f7cacd..5fd162a1ca 100644 --- a/firmware/target/arm/imx233/system-imx233.c +++ b/firmware/target/arm/imx233/system-imx233.c @@ -97,6 +97,24 @@ static void watchdog_init(void) good_dog(); } +void imx233_system_prepare_shutdown(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"); + imx233_pinctrl_set_function(0, 9, PINCTRL_FUNCTION_GPIO); + imx233_pinctrl_enable_gpio(0, 9, true); + imx233_pinctrl_set_gpio(0, 9, true); +#endif +} + void imx233_chip_reset(void) { #if IMX233_SUBTARGET >= 3700 @@ -108,10 +126,8 @@ void imx233_chip_reset(void) void system_reboot(void) { - backlight_hw_off(); - - disable_irq(); - + imx233_system_prepare_shutdown(); + /* reset */ imx233_chip_reset(); while(1); } -- cgit v1.2.3