| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include <string.h> |
| 9 |
|
| 10 |
#include <platform_def.h> |
| 11 |
|
| 12 |
#include <arch_helpers.h> |
| 13 |
#include <common/debug.h> |
| 14 |
#include <drivers/console.h> |
| 15 |
|
| 16 |
#include <marvell_plat_priv.h> |
| 17 |
#include <marvell_pm.h> |
| 18 |
#include <plat_marvell.h> |
| 19 |
|
| 20 |
#define BR_FLAG_SILENT 0x1 |
| 21 |
#define SKIP_IMAGE_CODE 0xDEADB002 |
| 22 |
|
| 23 |
void mailbox_clean(void) |
| 24 |
{ |
| 25 |
uintptr_t *mailbox = (void *)PLAT_MARVELL_MAILBOX_BASE; |
| 26 |
|
| 27 |
memset(mailbox, 0, PLAT_MARVELL_MAILBOX_SIZE); |
| 28 |
} |
| 29 |
|
| 30 |
int exec_ble_main(int bootrom_flags) |
| 31 |
{ |
| 32 |
int skip = 0; |
| 33 |
uintptr_t *mailbox = (void *)PLAT_MARVELL_MAILBOX_BASE; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
if ((bootrom_flags & BR_FLAG_SILENT) == 0) |
| 41 |
marvell_console_boot_init(); |
| 42 |
|
| 43 |
NOTICE("Starting binary extension\n"); |
| 44 |
|
| 45 |
|
| 46 |
plat_delay_timer_init(); |
| 47 |
|
| 48 |
ble_plat_setup(&skip); |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
if (skip) |
| 54 |
return SKIP_IMAGE_CODE; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
if (mailbox[MBOX_IDX_MAGIC] != MVEBU_MAILBOX_MAGIC_NUM || |
| 65 |
mailbox[MBOX_IDX_SUSPEND_MAGIC] != MVEBU_MAILBOX_SUSPEND_STATE) { |
| 66 |
NOTICE("Cold boot\n"); |
| 67 |
mailbox_clean(); |
| 68 |
} else { |
| 69 |
void (*bootrom_exit)(void) = |
| 70 |
(void (*)(void))mailbox[MBOX_IDX_ROM_EXIT_ADDR]; |
| 71 |
|
| 72 |
INFO("Recovery...\n"); |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
marvell_ble_prepare_exit(); |
| 84 |
bootrom_exit(); |
| 85 |
} |
| 86 |
|
| 87 |
return 0; |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
int __attribute__ ((section(".entry"))) ble_main(int bootrom_flags) |
| 94 |
{ |
| 95 |
volatile int ret; |
| 96 |
|
| 97 |
ret = exec_ble_main(bootrom_flags); |
| 98 |
return ret; |
| 99 |
} |