imx233: refactor power off and reboot

There is no reason to use different code paths

Change-Id: I4894c7963c802b56b5d3576909e1008a7c401935
This commit is contained in:
Amaury Pouly 2016-09-26 21:24:00 +01:00
parent 9aeb6f48b8
commit 1c97083ca7
3 changed files with 22 additions and 19 deletions

View file

@ -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);

View file

@ -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);
}

View file

@ -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