diff options
author | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2021-03-19 16:22:02 +0200 |
---|---|---|
committer | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2021-03-19 16:22:02 +0200 |
commit | 3cb0215e3b325764392989bf80a601dfb3ca15a6 (patch) | |
tree | cdc7f1ef1691375f87ef069e7aa6fffd3e026ffd | |
parent | af62885b451a8f37ad14bbbba800c61365d0ad43 (diff) |
ARM: apalis/colibri-imx6: use stopmode for poweroff
After the system has been shutdown with PMIC_ON_REQ and VCC_BATT is supplied
from a battery it will never restart either by RESET or power cycle.
So use the PMIC_STBY_REQ after shutdown to switch off power rails.
Related-to: ELB-3580
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Squashed commits:
b8e3f80727633 ("colibri-imx6: use stopmode for poweroff")
478ca48af680a ("pm-imx6.c: fix power off by stop mode")
dcef57828ae18 ("apalis-imx6: use stopmode for poweroff")
aebbdbb42fbec ("ARM: imx6: fix setting up pm_power_off callback")
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
-rw-r--r-- | arch/arm/mach-imx/pm-imx6.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c index baf3b47601af..c8b504458aab 100644 --- a/arch/arm/mach-imx/pm-imx6.c +++ b/arch/arm/mach-imx/pm-imx6.c @@ -659,14 +659,58 @@ void __init imx6_pm_ccm_init(const char *ccm_compat) imx6_pm_stby_poweroff_probe(); } +void imx6_stop_mode_poweroff(void) +{ + /* compare with imx6q_set_lpm */ + u32 val = readl_relaxed(ccm_base + CLPCR); + + val &= ~BM_CLPCR_LPM; + /* + * mask all but the currently running processor, + * otherwise we will not enter stop mode + */ + val |= smp_processor_id() != 0 ? BM_CLPCR_MASK_CORE0_WFI : 0; + val |= smp_processor_id() != 1 ? BM_CLPCR_MASK_CORE1_WFI : 0; + val |= smp_processor_id() != 2 ? BM_CLPCR_MASK_CORE2_WFI : 0; + val |= smp_processor_id() != 3 ? BM_CLPCR_MASK_CORE3_WFI : 0; + val |= BM_CLPCR_MASK_SCU_IDLE; + val |= 0x2 << BP_CLPCR_LPM; + val |= 0x3 << BP_CLPCR_STBY_COUNT; + val |= BM_CLPCR_VSTBY; + val |= BM_CLPCR_SBYOS; + val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS; + + imx_gpc_hwirq_unmask(0); + writel_relaxed(val, ccm_base + CLPCR); + imx_gpc_hwirq_mask(0); + imx_gpc_mask_all(); + cpu_do_idle(); +} + void __init imx6q_pm_init(void) { imx6_pm_common_init(&imx6q_pm_data); + + /* + * if no specific power off function in board file, power off system by + * stop mode. + */ + if (!pm_power_off && + of_machine_is_compatible("toradex,apalis_imx6q")) + pm_power_off = imx6_stop_mode_poweroff; } void __init imx6dl_pm_init(void) { imx6_pm_common_init(&imx6dl_pm_data); + + /* + * if no specific power off function in board file, power off system by + * stop mode. + */ + if (!pm_power_off && + of_machine_is_compatible("toradex,colibri_imx6dl")) + pm_power_off = imx6_stop_mode_poweroff; } void __init imx6sl_pm_init(void) |