blob: eb1b7e7b85e33f3a4a2c38354eb1aa2bcdeda0b4 [file] [log] [blame]
Samuel Hollandb8566642017-08-12 04:07:39 -05001/*
Samuel Hollandcd120442021-01-16 01:21:38 -06002 * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved.
Samuel Hollandb8566642017-08-12 04:07:39 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Samuel Hollandb8566642017-08-12 04:07:39 -05007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Samuel Hollandb8566642017-08-12 04:07:39 -05009#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <common/debug.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <lib/mmio.h>
13#include <lib/psci/psci.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000014
Samuel Holland0a9018c2017-08-12 04:07:39 -050015#include <sunxi_cpucfg.h>
Andre Przywara456208a2018-10-14 12:02:02 +010016#include <sunxi_private.h>
Samuel Hollandb8566642017-08-12 04:07:39 -050017
Samuel Hollandad6f6ca2021-01-16 00:56:48 -060018int sunxi_validate_ns_entrypoint(uintptr_t ns_entrypoint)
Samuel Holland0a9018c2017-08-12 04:07:39 -050019{
20 /* The non-secure entry point must be in DRAM */
Samuel Hollandcd120442021-01-16 01:21:38 -060021 if (ns_entrypoint < SUNXI_DRAM_BASE) {
22 return PSCI_E_INVALID_ADDRESS;
23 }
Samuel Holland0a9018c2017-08-12 04:07:39 -050024
Samuel Hollandcd120442021-01-16 01:21:38 -060025 return PSCI_E_SUCCESS;
Samuel Holland0a9018c2017-08-12 04:07:39 -050026}
27
Samuel Hollandb8566642017-08-12 04:07:39 -050028int plat_setup_psci_ops(uintptr_t sec_entrypoint,
29 const plat_psci_ops_t **psci_ops)
30{
31 assert(psci_ops);
32
Samuel Holland103ee9b2018-10-21 12:41:03 -050033 /* Program all CPU entry points. */
34 for (unsigned int cpu = 0; cpu < PLATFORM_CORE_COUNT; ++cpu) {
Samuel Holland0a9018c2017-08-12 04:07:39 -050035 mmio_write_32(SUNXI_CPUCFG_RVBAR_LO_REG(cpu),
36 sec_entrypoint & 0xffffffff);
37 mmio_write_32(SUNXI_CPUCFG_RVBAR_HI_REG(cpu),
38 sec_entrypoint >> 32);
39 }
40
Samuel Hollandad6f6ca2021-01-16 00:56:48 -060041 if (sunxi_set_scpi_psci_ops(psci_ops) == 0) {
42 INFO("PSCI: Suspend is available via SCPI\n");
43 } else {
44 INFO("PSCI: Suspend is unavailable\n");
45 sunxi_set_native_psci_ops(psci_ops);
Samuel Holland103ee9b2018-10-21 12:41:03 -050046 }
47
Samuel Hollandb8566642017-08-12 04:07:39 -050048 return 0;
49}