summaryrefslogtreecommitdiff
path: root/ble
diff options
context:
space:
mode:
authorKonstantin Porotchkin <kostap@marvell.com>2017-03-02 18:48:33 +0200
committerKostya Porotchkin <kostap@marvell.com>2017-07-13 14:00:40 +0300
commit0e478a6a1980b28bd7b1d2b057ee6fae1f6409f5 (patch)
treee672fc8b10aea3eb39ff194cb5a49f5b877f143e /ble
parent9baa98672c755f97708e73d71e11a7ae96aeb8a7 (diff)
pm: a8k: add initial support for suspend to RAM
Add initial support for suspend to RAM feature. The warm boot mode (recovery) is detected at BLE stage and the control leaves the BootROM for eliminating boot device image copy and verification. Then booting CPU jumps to ATF and continues system restore bypassing further BootROM stages, and finnaly jumps back to Linux bypassing the u-boot. Change-Id: Ifbafd783d5b554bfe50de6c4829e93e40cd28631 Signed-off-by: Konstantin Porotchkin <kostap@marvell.com> Signed-off-by: Victor Gu <xigu@marvell.com> Reviewed-on: http://vgitil04.il.marvell.com:8080/40478 Tested-by: iSoC Platform CI <ykjenk@marvell.com>
Diffstat (limited to 'ble')
-rw-r--r--ble/ble_main.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/ble/ble_main.c b/ble/ble_main.c
index dd0b5039..ed3cfefe 100644
--- a/ble/ble_main.c
+++ b/ble/ble_main.c
@@ -32,11 +32,14 @@
***************************************************************************
*/
+#include <arch_helpers.h>
#include <debug.h>
#include <console.h>
+#include <mmio.h>
#include <platform_def.h>
#include <plat_marvell.h>
#include <plat_private.h>
+#include <marvell_pm.h>
#include <string.h>
#define BR_FLAG_SILENT 0x1
@@ -52,13 +55,17 @@ void mailbox_clean(void)
int __attribute__ ((section(".entry"))) ble_main(int bootrom_flags)
{
int skip = 0;
+ uintptr_t *mailbox = (void *)PLAT_MARVELL_MAILBOX_BASE;
+
/*
* In some situations, like boot from UART, bootrom will
* request to avoid printing to console. in that case don't
* initialize the console and prints will be ignored
*/
if ((bootrom_flags & BR_FLAG_SILENT) == 0)
- console_init(PLAT_MARVELL_BOOT_UART_BASE, PLAT_MARVELL_BOOT_UART_CLK_IN_HZ, MARVELL_CONSOLE_BAUDRATE);
+ console_init(PLAT_MARVELL_BOOT_UART_BASE,
+ PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
+ MARVELL_CONSOLE_BAUDRATE);
NOTICE("Starting binary extension\n");
@@ -69,7 +76,6 @@ int __attribute__ ((section(".entry"))) ble_main(int bootrom_flags)
NOTICE("Skip DRAM setup in PALLADIUM mode\n");
#else
ble_plat_setup(&skip);
-
#endif
/* if there's skip image request, bootrom will load from the image
* saved on the next address of the flash
@@ -77,8 +83,36 @@ int __attribute__ ((section(".entry"))) ble_main(int bootrom_flags)
if (skip)
return SKIP_IMAGE_CODE;
- /* clean mailbox from garbage data */
- mailbox_clean();
+ /*
+ * Check if the mailbox magic number is stored at index MBOX_IDX_MAGIC
+ * and the suspend to RAM magic number at index MBOX_IDX_SUSPEND_MAGIC.
+ * If the above is true, this is the recovery from suspend to RAM state.
+ * In such case the mailbox should remain intact, since it stores the
+ * warm boot jump address to be used by the ATF in BL31.
+ * Othervise the mailbox should be cleaned from a garbage data.
+ */
+ if (mailbox[MBOX_IDX_MAGIC] != MVEBU_MAILBOX_MAGIC_NUM ||
+ mailbox[MBOX_IDX_SUSPEND_MAGIC] != MVEBU_MAILBOX_SUSPEND_STATE) {
+ NOTICE("Cold boot\n");
+ mailbox_clean();
+ } else {
+ void (*bootrom_exit)(void) =
+ (void (*)(void))mailbox[MBOX_IDX_ROM_EXIT_ADDR];
+
+ INFO("Recovery...\n");
+ /*
+ * If this is recovery from suspend, two things has to be done:
+ * 1. Define the DRAM region as executable memory for preparing
+ * jump to ATF
+ * 2. Instead of returning control to the BootROM, invalidate
+ * and flush caches, and continue execution at address stored
+ * in the mailbox.
+ * This should be done until the BootROM have a native support
+ * for the system restore flow.
+ */
+ ble_prepare_exit();
+ bootrom_exit();
+ }
return 0;
}