From 865f6d5a5e800cf7eabcf581673e34e20a256861 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 27 Jun 2017 13:41:47 +0800 Subject: imx8mq: add wdog reset Add wdog reset support. Signed-off-by: Peng Fan --- plat/freescale/imx8mq/imx8m_bl31_setup.c | 1 + plat/freescale/imx8mq/imx8m_psci.c | 21 +++++++++++++++++++++ plat/freescale/imx8mq/include/platform_def.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/plat/freescale/imx8mq/imx8m_bl31_setup.c b/plat/freescale/imx8mq/imx8m_bl31_setup.c index b915e551..f8984a60 100644 --- a/plat/freescale/imx8mq/imx8m_bl31_setup.c +++ b/plat/freescale/imx8mq/imx8m_bl31_setup.c @@ -168,6 +168,7 @@ void bl31_plat_arch_setup(void) mmap_add_region(IMX_SRC_BASE, IMX_SRC_BASE, 0x1000, MT_DEVICE | MT_RW); mmap_add_region(IMX_GPC_BASE, IMX_GPC_BASE, 0x1000, MT_DEVICE | MT_RW); + mmap_add_region(IMX_WDOG_BASE, IMX_WDOG_BASE, 0x1000, MT_DEVICE | MT_RW); mmap_add_region(IMX_ANAMIX_BASE, IMX_ANAMIX_BASE, 0x1000, MT_DEVICE | MT_RW); mmap_add_region(PLAT_GICD_BASE, PLAT_GICD_BASE, 0x80000, MT_DEVICE | MT_RW); diff --git a/plat/freescale/imx8mq/imx8m_psci.c b/plat/freescale/imx8mq/imx8m_psci.c index f53c81eb..117188b7 100644 --- a/plat/freescale/imx8mq/imx8m_psci.c +++ b/plat/freescale/imx8mq/imx8m_psci.c @@ -191,6 +191,26 @@ void imx_get_sys_suspend_power_state(psci_power_state_t *req_state) req_state->pwr_domain_state[i] = PLAT_MAX_RET_STATE; } +void __attribute__((noreturn)) imx_system_reset(void) +{ + uintptr_t wdog_base = IMX_WDOG_BASE; + unsigned int val; + + /* WDOG_B reset */ + val = mmio_read_16(wdog_base); +#ifdef IMX_WDOG_B_RESET + val = (val & 0x00FF) | (7 << 2) | (1 << 0); +#else + val = (val & 0x00FF) | (4 << 2) | (1 << 0); +#endif + mmio_write_16(wdog_base, val); + + mmio_write_16(wdog_base + 0x2, 0x5555); + mmio_write_16(wdog_base + 0x2, 0xaaaa); + while (1) + ; +} + static const plat_psci_ops_t imx_plat_psci_ops = { .pwr_domain_on = imx_pwr_domain_on, .pwr_domain_on_finish = imx_pwr_domain_on_finish, @@ -201,6 +221,7 @@ static const plat_psci_ops_t imx_plat_psci_ops = { .pwr_domain_suspend = imx_domain_suspend, .pwr_domain_suspend_finish = imx_domain_suspend_finish, .get_sys_suspend_power_state = imx_get_sys_suspend_power_state, + .system_reset = imx_system_reset, }; /* export the platform specific psci ops */ diff --git a/plat/freescale/imx8mq/include/platform_def.h b/plat/freescale/imx8mq/include/platform_def.h index 8d5dffb7..058cd4ef 100644 --- a/plat/freescale/imx8mq/include/platform_def.h +++ b/plat/freescale/imx8mq/include/platform_def.h @@ -45,8 +45,10 @@ #define IMX_ANAMIX_BASE 0x30360000 #define IMX_SRC_BASE 0x30390000 #define IMX_GPC_BASE 0x303a0000 +#define IMX_WDOG_BASE 0x30280000 #define COUNTER_FREQUENCY 8000000 /* 8MHz */ #define DEBUG_CONSOLE 0 +#define IMX_WDOG_B_RESET #define PLAT_IMX8M 1 -- cgit v1.2.3