2017-08-12 10:07:39 +01:00
|
|
|
/*
|
2021-01-16 07:21:38 +00:00
|
|
|
* Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved.
|
2017-08-12 10:07:39 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2018-12-14 00:18:21 +00:00
|
|
|
|
2017-08-12 10:07:39 +01:00
|
|
|
#include <platform_def.h>
|
2018-12-14 00:18:21 +00:00
|
|
|
|
|
|
|
#include <common/debug.h>
|
|
|
|
#include <lib/mmio.h>
|
|
|
|
#include <lib/psci/psci.h>
|
|
|
|
|
2017-08-12 10:07:39 +01:00
|
|
|
#include <sunxi_cpucfg.h>
|
2018-10-14 12:02:02 +01:00
|
|
|
#include <sunxi_private.h>
|
2017-08-12 10:07:39 +01:00
|
|
|
|
allwinner: Split native and SCPI-based PSCI implementations
In order to keep SCP firmware as optional, the original, limited native
PSCI implementation was kept around as a fallback. This turned out to be
a good decision, as some newer SoCs omit the ARISC, and thus cannot run
SCP firmware.
However, keeping the two implementations in one file makes things
unnecessarily messy. First, it is difficult to compile out the
SCPI-based implementation where it is not applicable. Second the check
is done in each callback, while scpi_available is only updated at boot.
This makes the individual callbacks unnecessarily complicated.
It is cleaner to provide two entirely separate implementations in two
separate files. The native implementation does not support any kind of
CPU suspend, so its callbacks are greatly simplified. One function,
sunxi_validate_ns_entrypoint, is shared between the two implementations.
Finally, the logic for choosing between implementations is kept in a
third file, to provide for platforms where only one implementation is
applicable and the other is compiled out.
Change-Id: I4914f07d8e693dbce218e0e2394bef15c42945f8
Signed-off-by: Samuel Holland <samuel@sholland.org>
2021-01-16 06:56:48 +00:00
|
|
|
int sunxi_validate_ns_entrypoint(uintptr_t ns_entrypoint)
|
2017-08-12 10:07:39 +01:00
|
|
|
{
|
|
|
|
/* The non-secure entry point must be in DRAM */
|
2021-01-16 07:21:38 +00:00
|
|
|
if (ns_entrypoint < SUNXI_DRAM_BASE) {
|
|
|
|
return PSCI_E_INVALID_ADDRESS;
|
|
|
|
}
|
2017-08-12 10:07:39 +01:00
|
|
|
|
2021-01-16 07:21:38 +00:00
|
|
|
return PSCI_E_SUCCESS;
|
2017-08-12 10:07:39 +01:00
|
|
|
}
|
|
|
|
|
2017-08-12 10:07:39 +01:00
|
|
|
int plat_setup_psci_ops(uintptr_t sec_entrypoint,
|
|
|
|
const plat_psci_ops_t **psci_ops)
|
|
|
|
{
|
|
|
|
assert(psci_ops);
|
|
|
|
|
2018-10-21 18:41:03 +01:00
|
|
|
/* Program all CPU entry points. */
|
|
|
|
for (unsigned int cpu = 0; cpu < PLATFORM_CORE_COUNT; ++cpu) {
|
2017-08-12 10:07:39 +01:00
|
|
|
mmio_write_32(SUNXI_CPUCFG_RVBAR_LO_REG(cpu),
|
|
|
|
sec_entrypoint & 0xffffffff);
|
|
|
|
mmio_write_32(SUNXI_CPUCFG_RVBAR_HI_REG(cpu),
|
|
|
|
sec_entrypoint >> 32);
|
|
|
|
}
|
|
|
|
|
allwinner: Split native and SCPI-based PSCI implementations
In order to keep SCP firmware as optional, the original, limited native
PSCI implementation was kept around as a fallback. This turned out to be
a good decision, as some newer SoCs omit the ARISC, and thus cannot run
SCP firmware.
However, keeping the two implementations in one file makes things
unnecessarily messy. First, it is difficult to compile out the
SCPI-based implementation where it is not applicable. Second the check
is done in each callback, while scpi_available is only updated at boot.
This makes the individual callbacks unnecessarily complicated.
It is cleaner to provide two entirely separate implementations in two
separate files. The native implementation does not support any kind of
CPU suspend, so its callbacks are greatly simplified. One function,
sunxi_validate_ns_entrypoint, is shared between the two implementations.
Finally, the logic for choosing between implementations is kept in a
third file, to provide for platforms where only one implementation is
applicable and the other is compiled out.
Change-Id: I4914f07d8e693dbce218e0e2394bef15c42945f8
Signed-off-by: Samuel Holland <samuel@sholland.org>
2021-01-16 06:56:48 +00:00
|
|
|
if (sunxi_set_scpi_psci_ops(psci_ops) == 0) {
|
|
|
|
INFO("PSCI: Suspend is available via SCPI\n");
|
|
|
|
} else {
|
|
|
|
INFO("PSCI: Suspend is unavailable\n");
|
|
|
|
sunxi_set_native_psci_ops(psci_ops);
|
2018-10-21 18:41:03 +01:00
|
|
|
}
|
|
|
|
|
2017-08-12 10:07:39 +01:00
|
|
|
return 0;
|
|
|
|
}
|