diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2016-09-26 21:24:00 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2016-12-12 12:06:42 +0100 |
commit | 1c97083ca77b4f9b1046b6b50046366310ad2dc2 (patch) | |
tree | 5e4fbf0b1a475b0e0223a5cac355619fe92a3d9f /firmware/target/arm | |
parent | 9aeb6f48b8bc52833aaa90246c3fd21fbd6c2ab5 (diff) |
imx233: refactor power off and reboot
There is no reason to use different code paths
Change-Id: I4894c7963c802b56b5d3576909e1008a7c401935
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/imx233/power-imx233.c | 15 | ||||
-rw-r--r-- | firmware/target/arm/imx233/system-imx233.c | 24 | ||||
-rw-r--r-- | firmware/target/arm/imx233/system-target.h | 2 |
3 files changed, 22 insertions, 19 deletions
diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c index e2b6a622a0..22b70bc9dc 100644 --- a/firmware/target/arm/imx233/power-imx233.c +++ b/firmware/target/arm/imx233/power-imx233.c @@ -231,20 +231,7 @@ void power_init(void) 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"); - imx233_pinctrl_set_function(0, 9, PINCTRL_FUNCTION_GPIO); - imx233_pinctrl_enable_gpio(0, 9, true); - imx233_pinctrl_set_gpio(0, 9, true); -#endif + imx233_system_prepare_shutdown(); /* power down */ HW_POWER_RESET = BF_OR(POWER_RESET, UNLOCK_V(KEY), PWD(1)); while(1); 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); } diff --git a/firmware/target/arm/imx233/system-target.h b/firmware/target/arm/imx233/system-target.h index 3a8aadd227..ee2df9a3e9 100644 --- a/firmware/target/arm/imx233/system-target.h +++ b/firmware/target/arm/imx233/system-target.h @@ -48,10 +48,10 @@ #define CPUFREQ_SLEEP IMX233_CPUFREQ_64_MHz void system_prepare_fw_start(void); +void imx233_system_prepare_shutdown(void); void udelay(unsigned us); bool imx233_us_elapsed(uint32_t ref, unsigned us_delay); void imx233_reset_block(volatile uint32_t *block_reg); -void power_off(void); void imx233_enable_usb_controller(bool enable); void imx233_enable_usb_phy(bool enable); // NOTE: this is available even if HAVE_ADJUSTABLE_CPU_FREQ is undef |