xref: /rk3399_ARM-atf/plat/arm/board/fvp/fvp_err.c (revision 586f60cc571f0f3b6d20eb5033717e9b0cc66af4)
137b70031SAmbroise Vincent /*
259ea3648SManish V Badarkhe  * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
337b70031SAmbroise Vincent  *
437b70031SAmbroise Vincent  * SPDX-License-Identifier: BSD-3-Clause
537b70031SAmbroise Vincent  */
637b70031SAmbroise Vincent 
737b70031SAmbroise Vincent #include <errno.h>
837b70031SAmbroise Vincent 
937b70031SAmbroise Vincent #include <common/debug.h>
1037b70031SAmbroise Vincent #include <drivers/arm/sp805.h>
1137b70031SAmbroise Vincent #include <drivers/cfi/v2m_flash.h>
1259ea3648SManish V Badarkhe #include <lib/mmio.h>
1337b70031SAmbroise Vincent #include <plat/arm/common/plat_arm.h>
1437b70031SAmbroise Vincent #include <platform_def.h>
1537b70031SAmbroise Vincent 
1637b70031SAmbroise Vincent /*
1737b70031SAmbroise Vincent  * FVP error handler
1837b70031SAmbroise Vincent  */
1937b70031SAmbroise Vincent __dead2 void plat_arm_error_handler(int err)
2037b70031SAmbroise Vincent {
2159ea3648SManish V Badarkhe 	/* Propagate the err code in the NV-flags register */
2259ea3648SManish V Badarkhe 	mmio_write_32(V2M_SYS_NVFLAGS_ADDR, (uint32_t)err);
2337b70031SAmbroise Vincent 
24831b0e98SJimmy Brisson 	console_flush();
2537b70031SAmbroise Vincent 
2637b70031SAmbroise Vincent 	/* Setup the watchdog to reset the system as soon as possible */
2737b70031SAmbroise Vincent 	sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
2837b70031SAmbroise Vincent 
2937b70031SAmbroise Vincent 	for (;;)
3037b70031SAmbroise Vincent 		wfi();
3137b70031SAmbroise Vincent }
32*586f60ccSManish V Badarkhe 
33*586f60ccSManish V Badarkhe void __dead2 plat_arm_system_reset(void)
34*586f60ccSManish V Badarkhe {
35*586f60ccSManish V Badarkhe 	/* Write the System Configuration Control Register */
36*586f60ccSManish V Badarkhe 	mmio_write_32(V2M_SYSREGS_BASE + V2M_SYS_CFGCTRL,
37*586f60ccSManish V Badarkhe 		      V2M_CFGCTRL_START |
38*586f60ccSManish V Badarkhe 		      V2M_CFGCTRL_RW |
39*586f60ccSManish V Badarkhe 		      V2M_CFGCTRL_FUNC(V2M_FUNC_REBOOT));
40*586f60ccSManish V Badarkhe 	wfi();
41*586f60ccSManish V Badarkhe 	ERROR("FVP System Reset: operation not handled.\n");
42*586f60ccSManish V Badarkhe 	panic();
43*586f60ccSManish V Badarkhe }
44