blob: fb3842dbfaf25da5a7ff7a14fbe450db9b935656 [file] [log] [blame]
Samuel Hollandb8566642017-08-12 04:07:39 -05001/*
2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch_helpers.h>
8#include <assert.h>
9#include <debug.h>
10#include <delay_timer.h>
11#include <mmio.h>
12#include <platform.h>
13#include <platform_def.h>
14#include <psci.h>
15#include <sunxi_mmap.h>
16
17#define SUNXI_WDOG0_CTRL_REG (SUNXI_WDOG_BASE + 0x0010)
18#define SUNXI_WDOG0_CFG_REG (SUNXI_WDOG_BASE + 0x0014)
19#define SUNXI_WDOG0_MODE_REG (SUNXI_WDOG_BASE + 0x0018)
20
Samuel Holland321c0ab2017-08-12 04:07:39 -050021#include "sunxi_private.h"
22
Samuel Hollandb8566642017-08-12 04:07:39 -050023static void __dead2 sunxi_system_off(void)
24{
Samuel Holland321c0ab2017-08-12 04:07:39 -050025 /* Turn off all secondary CPUs */
26 sunxi_disable_secondary_cpus(plat_my_core_pos());
27
Samuel Hollandb8566642017-08-12 04:07:39 -050028 ERROR("PSCI: Full shutdown not implemented, halting\n");
29 wfi();
30 panic();
31}
32
33static void __dead2 sunxi_system_reset(void)
34{
35 /* Reset the whole system when the watchdog times out */
36 mmio_write_32(SUNXI_WDOG0_CFG_REG, 1);
37 /* Enable the watchdog with the shortest timeout (0.5 seconds) */
38 mmio_write_32(SUNXI_WDOG0_MODE_REG, (0 << 4) | 1);
39 /* Wait for twice the watchdog timeout before panicking */
40 mdelay(1000);
41
42 ERROR("PSCI: System reset failed\n");
43 wfi();
44 panic();
45}
46
47static plat_psci_ops_t sunxi_psci_ops = {
48 .system_off = sunxi_system_off,
49 .system_reset = sunxi_system_reset,
50};
51
52int plat_setup_psci_ops(uintptr_t sec_entrypoint,
53 const plat_psci_ops_t **psci_ops)
54{
55 assert(psci_ops);
56
57 *psci_ops = &sunxi_psci_ops;
58
59 return 0;
60}