Michael Walle | 187bae9 | 2022-04-25 09:25:08 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | #include <asm/secure.h> |
| 4 | #include <asm/psci.h> |
| 5 | #include <asm/types.h> |
| 6 | #include <asm/io.h> |
| 7 | #include <asm/system.h> |
| 8 | |
| 9 | #define GPIO2_GPDIR 0x2310000 |
| 10 | #define GPIO2_GPDAT 0x2310008 |
| 11 | #define RSTCR 0x1e60000 |
| 12 | #define RESET_REQ BIT(1) |
| 13 | |
| 14 | u32 __secure psci_version(void) |
| 15 | { |
| 16 | return ARM_PSCI_VER_0_2; |
| 17 | } |
| 18 | |
| 19 | void __secure psci_system_reset(void) |
| 20 | { |
| 21 | writel(RESET_REQ, RSTCR); |
| 22 | |
| 23 | while (1) |
| 24 | wfi(); |
| 25 | } |
| 26 | |
| 27 | void __secure psci_system_off(void) |
| 28 | { |
| 29 | int i; |
| 30 | |
| 31 | writel(0x02000000, GPIO2_GPDIR); |
| 32 | writel(0, GPIO2_GPDAT); |
| 33 | |
| 34 | /* make sure the management controller has sampled the input */ |
| 35 | for (i = 0; i < (1 << 11); i++) |
| 36 | asm("nop"); |
| 37 | |
| 38 | writel(RESET_REQ, RSTCR); |
| 39 | |
| 40 | while (1) |
| 41 | wfi(); |
| 42 | } |