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 | |
parent | 9aeb6f48b8bc52833aaa90246c3fd21fbd6c2ab5 (diff) | |
download | rockbox-1c97083ca77b4f9b1046b6b50046366310ad2dc2.tar.gz rockbox-1c97083ca77b4f9b1046b6b50046366310ad2dc2.zip |
imx233: refactor power off and reboot
There is no reason to use different code paths
Change-Id: I4894c7963c802b56b5d3576909e1008a7c401935
Diffstat (limited to 'firmware')
-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) | |||
231 | 231 | ||
232 | void power_off(void) | 232 | void power_off(void) |
233 | { | 233 | { |
234 | /* wait a bit, useful for the user to stop touching anything */ | 234 | imx233_system_prepare_shutdown(); |
235 | sleep(HZ / 2); | ||
236 | /* disable watchdog just in case since we will disable interrupts */ | ||
237 | imx233_rtc_enable_watchdog(false); | ||
238 | /* disable interrupts, it's probably better to avoid any action so close | ||
239 | * to shutdown */ | ||
240 | disable_interrupt(IRQ_FIQ_STATUS); | ||
241 | #ifdef SANSA_FUZEPLUS | ||
242 | /* This pin seems to be important to shutdown the hardware properly */ | ||
243 | imx233_pinctrl_acquire(0, 9, "power off"); | ||
244 | imx233_pinctrl_set_function(0, 9, PINCTRL_FUNCTION_GPIO); | ||
245 | imx233_pinctrl_enable_gpio(0, 9, true); | ||
246 | imx233_pinctrl_set_gpio(0, 9, true); | ||
247 | #endif | ||
248 | /* power down */ | 235 | /* power down */ |
249 | HW_POWER_RESET = BF_OR(POWER_RESET, UNLOCK_V(KEY), PWD(1)); | 236 | HW_POWER_RESET = BF_OR(POWER_RESET, UNLOCK_V(KEY), PWD(1)); |
250 | while(1); | 237 | 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) | |||
97 | good_dog(); | 97 | good_dog(); |
98 | } | 98 | } |
99 | 99 | ||
100 | void imx233_system_prepare_shutdown(void) | ||
101 | { | ||
102 | /* wait a bit, useful for the user to stop touching anything */ | ||
103 | sleep(HZ / 2); | ||
104 | /* disable watchdog just in case since we will disable interrupts */ | ||
105 | imx233_rtc_enable_watchdog(false); | ||
106 | /* disable interrupts, it's probably better to avoid any action so close | ||
107 | * to shutdown */ | ||
108 | disable_interrupt(IRQ_FIQ_STATUS); | ||
109 | #ifdef SANSA_FUZEPLUS | ||
110 | /* This pin seems to be important to shutdown the hardware properly */ | ||
111 | imx233_pinctrl_acquire(0, 9, "power off"); | ||
112 | imx233_pinctrl_set_function(0, 9, PINCTRL_FUNCTION_GPIO); | ||
113 | imx233_pinctrl_enable_gpio(0, 9, true); | ||
114 | imx233_pinctrl_set_gpio(0, 9, true); | ||
115 | #endif | ||
116 | } | ||
117 | |||
100 | void imx233_chip_reset(void) | 118 | void imx233_chip_reset(void) |
101 | { | 119 | { |
102 | #if IMX233_SUBTARGET >= 3700 | 120 | #if IMX233_SUBTARGET >= 3700 |
@@ -108,10 +126,8 @@ void imx233_chip_reset(void) | |||
108 | 126 | ||
109 | void system_reboot(void) | 127 | void system_reboot(void) |
110 | { | 128 | { |
111 | backlight_hw_off(); | 129 | imx233_system_prepare_shutdown(); |
112 | 130 | /* reset */ | |
113 | disable_irq(); | ||
114 | |||
115 | imx233_chip_reset(); | 131 | imx233_chip_reset(); |
116 | while(1); | 132 | while(1); |
117 | } | 133 | } |
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 @@ | |||
48 | #define CPUFREQ_SLEEP IMX233_CPUFREQ_64_MHz | 48 | #define CPUFREQ_SLEEP IMX233_CPUFREQ_64_MHz |
49 | 49 | ||
50 | void system_prepare_fw_start(void); | 50 | void system_prepare_fw_start(void); |
51 | void imx233_system_prepare_shutdown(void); | ||
51 | void udelay(unsigned us); | 52 | void udelay(unsigned us); |
52 | bool imx233_us_elapsed(uint32_t ref, unsigned us_delay); | 53 | bool imx233_us_elapsed(uint32_t ref, unsigned us_delay); |
53 | void imx233_reset_block(volatile uint32_t *block_reg); | 54 | void imx233_reset_block(volatile uint32_t *block_reg); |
54 | void power_off(void); | ||
55 | void imx233_enable_usb_controller(bool enable); | 55 | void imx233_enable_usb_controller(bool enable); |
56 | void imx233_enable_usb_phy(bool enable); | 56 | void imx233_enable_usb_phy(bool enable); |
57 | // NOTE: this is available even if HAVE_ADJUSTABLE_CPU_FREQ is undef | 57 | // NOTE: this is available even if HAVE_ADJUSTABLE_CPU_FREQ is undef |