diff options
author | Konstantin Porotchkin <kostap@marvell.com> | 2017-02-22 18:41:43 +0200 |
---|---|---|
committer | Kostya Porotchkin <kostap@marvell.com> | 2017-07-12 09:55:54 +0300 |
commit | aa741212a1414bce695e5173b7bd1a5acf3019c5 (patch) | |
tree | b63c1e51108020c05231218411e3292c62ccc885 | |
parent | 0b1a40f628c555621f075b883f38b41205bf5bf5 (diff) |
pm: add plat PM definitions and make mailbox code generic
Add new common platform header file for Marvell PM usage.
Remove A37xx-specific code from the common PM sources.
Change-Id: I8cb55c9e66ce503bbe3f359e7c1b04eaca1a4f9d
Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
Signed-off-by: Victor Gu <xigu@marvell.com>
Reviewed-on: http://vgitil04.il.marvell.com:8080/40476
Tested-by: iSoC Platform CI <ykjenk@marvell.com>
-rw-r--r-- | include/plat/marvell/common/marvell_pm.h | 48 | ||||
-rw-r--r-- | plat/marvell/a8k/common/aarch64/plat_helpers.S | 15 | ||||
-rw-r--r-- | plat/marvell/a8k/common/include/platform_def.h | 10 | ||||
-rw-r--r-- | plat/marvell/common/marvell_pm.c | 20 |
4 files changed, 72 insertions, 21 deletions
diff --git a/include/plat/marvell/common/marvell_pm.h b/include/plat/marvell/common/marvell_pm.h new file mode 100644 index 00000000..1deab7d4 --- /dev/null +++ b/include/plat/marvell/common/marvell_pm.h @@ -0,0 +1,48 @@ +/* +* *************************************************************************** +* Copyright (C) 2016 Marvell International Ltd. +* *************************************************************************** +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* Neither the name of Marvell nor the names of its contributors may be used +* to endorse or promote products derived from this software without specific +* prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +*************************************************************************** +*/ + +#ifndef _MARVELL_PM_H_ +#define _MARVELL_PM_H_ + +#define MVEBU_MAILBOX_MAGIC_NUM PLAT_MARVELL_MAILBOX_MAGIC_NUM +#define MVEBU_MAILBOX_SUSPEND_STATE 0xb007de7c + +/* Mailbox entry indexes */ +#define MBOX_IDX_MAGIC 0 /* Magic number for validity check */ +#define MBOX_IDX_SEC_ADDR 1 /* Recovery from suspend entry point */ +#define MBOX_IDX_SUSPEND_MAGIC 2 /* Suspend state magic number */ +#define MBOX_IDX_ROM_EXIT_ADDR 3 /* Recovery jump address for ROM bypass */ +#define MBOX_IDX_START_CNT 4 /* BLE execution start counter value */ + +#endif /* _MARVELL_PM_H_ */ diff --git a/plat/marvell/a8k/common/aarch64/plat_helpers.S b/plat/marvell/a8k/common/aarch64/plat_helpers.S index acc9d045..1e396902 100644 --- a/plat/marvell/a8k/common/aarch64/plat_helpers.S +++ b/plat/marvell/a8k/common/aarch64/plat_helpers.S @@ -34,6 +34,7 @@ #include <asm_macros.S> #include <platform_def.h> +#include <marvell_pm.h> .globl plat_secondary_cold_boot_setup .globl plat_get_my_entrypoint @@ -64,7 +65,19 @@ endfunc plat_secondary_cold_boot_setup * --------------------------------------------------------------------- */ func plat_get_my_entrypoint - mov_imm x0, PLAT_MARVELL_MAILBOX_BASE + mov_imm x0, PLAT_MARVELL_MAILBOX_BASE /* Read first word and compare it with magic num */ + ldr x1, [x0] + mov_imm x2, MVEBU_MAILBOX_MAGIC_NUM + cmp x1, x2 + beq warm_boot /* If compare failed, return 0, i.e. cold boot */ + mov x0, #0 + ret +warm_boot: + mov_imm x1, MBOX_IDX_SEC_ADDR /* Get the jump address */ + subs x1, x1, #1 + mov x2, #(MBOX_IDX_SEC_ADDR * 8) + lsl x3, x2, x1 + add x0, x0, x3 ldr x0, [x0] ret endfunc plat_get_my_entrypoint diff --git a/plat/marvell/a8k/common/include/platform_def.h b/plat/marvell/a8k/common/include/platform_def.h index ba927ddd..2eade339 100644 --- a/plat/marvell/a8k/common/include/platform_def.h +++ b/plat/marvell/a8k/common/include/platform_def.h @@ -192,11 +192,9 @@ /* System timer related constants */ #define PLAT_MARVELL_NSTIMER_FRAME_ID 1 -/* - * Mailbox base address - * (note the lower memory space are reserved for BLE data) - */ -#define PLAT_MARVELL_MAILBOX_BASE (MARVELL_TRUSTED_SRAM_BASE + 0x400) -#define PLAT_MARVELL_MAILBOX_SIZE 0x100 +/* Mailbox base address (note the lower memory space are reserved for BLE data) */ +#define PLAT_MARVELL_MAILBOX_BASE (MARVELL_TRUSTED_SRAM_BASE + 0x400) +#define PLAT_MARVELL_MAILBOX_SIZE 0x100 +#define PLAT_MARVELL_MAILBOX_MAGIC_NUM 0x6D72766C /* mrvl */ #endif /* __PLATFORM_DEF_H__ */ diff --git a/plat/marvell/common/marvell_pm.c b/plat/marvell/common/marvell_pm.c index fb200aa4..b9e070e0 100644 --- a/plat/marvell/common/marvell_pm.c +++ b/plat/marvell/common/marvell_pm.c @@ -64,12 +64,11 @@ #include <arch_helpers.h> #include <assert.h> #include <psci.h> -#include <platform_def.h> +#include <marvell_pm.h> /* Standard ARM platforms are expected to export plat_arm_psci_pm_ops */ extern const plat_psci_ops_t plat_arm_psci_pm_ops; - /******************************************************************************* * Private function to program the mailbox for a cpu before it is released * from reset. This function assumes that the mail box base is within @@ -87,20 +86,13 @@ void marvell_program_mailbox(uintptr_t address) ((PLAT_MARVELL_MAILBOX_BASE + sizeof(*mailbox)) <= (MARVELL_SHARED_RAM_BASE + MARVELL_SHARED_RAM_SIZE))); - /* - * Remove A3700 specific checking after A7K/A8K implement - * the magic number for mailbox. - */ -#ifdef PLAT_a3700 - /* Add magic number to avoid wrong operation caused by dirty data */ - *mailbox = PLAT_MARVELL_MAILBOX_MAGIC_NUM; - *(mailbox + 1) = address; -#else - *mailbox = address; -#endif + mailbox[MBOX_IDX_MAGIC] = MVEBU_MAILBOX_MAGIC_NUM; + mailbox[MBOX_IDX_SEC_ADDR] = address; + /* Flush data cache if the mail box shared RAM is cached */ #if PLAT_MARVELL_SHARED_RAM_CACHED - flush_dcache_range((uintptr_t)PLAT_MARVELL_MAILBOX_BASE, + flush_dcache_range((uintptr_t)PLAT_MARVELL_MAILBOX_BASE + + 8 * MBOX_IDX_MAGIC, 2 * sizeof(uint64_t)); #endif } |