blob: 244659ab73f51100adb69b4351ee67eb6d9f81dd [file] [log] [blame]
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +01001/*
Manish V Badarkhe56808e42021-05-23 13:16:46 +01002 * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <errno.h>
8
9#include <common/debug.h>
10#include <drivers/arm/sp805.h>
11#include <drivers/cfi/v2m_flash.h>
Manish V Badarkhe56808e42021-05-23 13:16:46 +010012#include <lib/mmio.h>
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +010013#include <plat/arm/common/plat_arm.h>
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +010014#include <platform_def.h>
15
16/*
17 * FVP error handler
18 */
19__dead2 void plat_arm_error_handler(int err)
20{
Manish V Badarkhe56808e42021-05-23 13:16:46 +010021 /* Propagate the err code in the NV-flags register */
22 mmio_write_32(V2M_SYS_NVFLAGS_ADDR, (uint32_t)err);
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +010023
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050024 console_flush();
Ambroise Vincentfa42c9e2019-07-04 14:58:45 +010025
26 /* Setup the watchdog to reset the system as soon as possible */
27 sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
28
29 for (;;)
30 wfi();
31}
Manish V Badarkhefcfe4312022-07-12 21:48:04 +010032
33void __dead2 plat_arm_system_reset(void)
34{
35 /* Write the System Configuration Control Register */
36 mmio_write_32(V2M_SYSREGS_BASE + V2M_SYS_CFGCTRL,
37 V2M_CFGCTRL_START |
38 V2M_CFGCTRL_RW |
39 V2M_CFGCTRL_FUNC(V2M_FUNC_REBOOT));
40 wfi();
41 ERROR("FVP System Reset: operation not handled.\n");
42 panic();
43}