Browse Source
Enable apusys mailbox mpu protect. Change-Id: Idbf67084037b7ecf4926f57a901075f98540ee57 Signed-off-by: Karl Li <karl.li@mediatek.com> Signed-off-by: Chungying Lu <chungying.lu@mediatek.com>pull/1999/head
Karl Li
2 years ago
committed by
Karl Li
7 changed files with 127 additions and 1 deletions
@ -0,0 +1,30 @@ |
|||
/*
|
|||
* Copyright (c) 2023, MediaTek Inc. All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
*/ |
|||
|
|||
/* TF-A system header */ |
|||
#include <common/debug.h> |
|||
#include <lib/mmio.h> |
|||
|
|||
/* Vendor header */ |
|||
#include "apusys_rv.h" |
|||
#include "apusys_rv_mbox_mpu.h" |
|||
|
|||
void apusys_rv_mbox_mpu_init(void) |
|||
{ |
|||
int i; |
|||
|
|||
for (i = 0; i < APU_MBOX_NUM; i++) { |
|||
mmio_write_32(APU_MBOX_FUNC_CFG(i), |
|||
(MBOX_CTRL_LOCK | |
|||
(mbox_mpu_setting_tab[i].no_mpu << MBOX_NO_MPU_SHIFT))); |
|||
mmio_write_32(APU_MBOX_DOMAIN_CFG(i), |
|||
(MBOX_CTRL_LOCK | |
|||
(mbox_mpu_setting_tab[i].rx_ns << MBOX_RX_NS_SHIFT) | |
|||
(mbox_mpu_setting_tab[i].rx_domain << MBOX_RX_DOMAIN_SHIFT) | |
|||
(mbox_mpu_setting_tab[i].tx_ns << MBOX_TX_NS_SHIFT) | |
|||
(mbox_mpu_setting_tab[i].tx_domain << MBOX_TX_DOMAIN_SHIFT))); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
/*
|
|||
* Copyright (c) 2023, MediaTek Inc. All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
*/ |
|||
|
|||
#ifndef APUSYS_RV_H |
|||
#define APUSYS_RV_H |
|||
|
|||
#include <platform_def.h> |
|||
|
|||
/* APU MBOX */ |
|||
#define MBOX_FUNC_CFG (0xb0) |
|||
#define MBOX_DOMAIN_CFG (0xe0) |
|||
#define MBOX_CTRL_LOCK BIT(0) |
|||
#define MBOX_NO_MPU_SHIFT (16) |
|||
#define MBOX_RX_NS_SHIFT (16) |
|||
#define MBOX_RX_DOMAIN_SHIFT (17) |
|||
#define MBOX_TX_NS_SHIFT (24) |
|||
#define MBOX_TX_DOMAIN_SHIFT (25) |
|||
#define MBOX_SIZE (0x100) |
|||
#define MBOX_NUM (8) |
|||
|
|||
#define APU_MBOX(i) (((i) < MBOX_NUM) ? (APU_MBOX0 + MBOX_SIZE * (i)) : \ |
|||
(APU_MBOX1 + MBOX_SIZE * ((i) - MBOX_NUM))) |
|||
#define APU_MBOX_FUNC_CFG(i) (APU_MBOX(i) + MBOX_FUNC_CFG) |
|||
#define APU_MBOX_DOMAIN_CFG(i) (APU_MBOX(i) + MBOX_DOMAIN_CFG) |
|||
|
|||
void apusys_rv_mbox_mpu_init(void); |
|||
|
|||
#endif /* APUSYS_RV_H */ |
@ -0,0 +1,46 @@ |
|||
/*
|
|||
* Copyright (c) 2023, MediaTek Inc. All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
*/ |
|||
|
|||
#ifndef APUSYS_RV_MBOX_MPU_H |
|||
#define APUSYS_RV_MBOX_MPU_H |
|||
|
|||
#define MPU_EN (0) |
|||
#define MPU_DIS (1) |
|||
#define MBOX0_TX_DOMAIN (0) |
|||
#define MBOX0_TX_NS (1) |
|||
#define MBOX4_RX_DOMAIN (0) |
|||
#define MBOX4_RX_NS (0) |
|||
#define MBOX5_TX_DOMAIN (3) |
|||
#define MBOX5_TX_NS (0) |
|||
#define MBOXN_RX_DOMAIN (5) |
|||
#define MBOXN_RX_NS (1) |
|||
#define MBOXN_TX_DOMAIN (0) |
|||
#define MBOXN_TX_NS (0) |
|||
|
|||
struct mbox_mpu_setting { |
|||
uint32_t no_mpu; |
|||
uint32_t rx_ns; |
|||
uint32_t rx_domain; |
|||
uint32_t tx_ns; |
|||
uint32_t tx_domain; |
|||
}; |
|||
|
|||
static const struct mbox_mpu_setting mbox_mpu_setting_tab[] = { |
|||
{ MPU_EN, MBOXN_RX_NS, MBOXN_RX_DOMAIN, MBOX0_TX_NS, MBOX0_TX_DOMAIN }, |
|||
{ MPU_EN, MBOXN_RX_NS, MBOXN_RX_DOMAIN, MBOXN_TX_NS, MBOXN_TX_DOMAIN }, |
|||
{ MPU_EN, MBOXN_RX_NS, MBOXN_RX_DOMAIN, MBOXN_TX_NS, MBOXN_TX_DOMAIN }, |
|||
{ MPU_EN, MBOXN_RX_NS, MBOXN_RX_DOMAIN, MBOXN_TX_NS, MBOXN_TX_DOMAIN }, |
|||
{ MPU_DIS, MBOX4_RX_NS, MBOX4_RX_DOMAIN, MBOXN_TX_NS, MBOXN_TX_DOMAIN }, |
|||
{ MPU_EN, MBOXN_RX_NS, MBOXN_RX_DOMAIN, MBOX5_TX_NS, MBOX5_TX_DOMAIN }, |
|||
{ MPU_EN, MBOXN_RX_NS, MBOXN_RX_DOMAIN, MBOXN_TX_NS, MBOXN_TX_DOMAIN }, |
|||
{ MPU_EN, MBOXN_RX_NS, MBOXN_RX_DOMAIN, MBOXN_TX_NS, MBOXN_TX_DOMAIN }, |
|||
{ MPU_EN, MBOXN_RX_NS, MBOXN_RX_DOMAIN, MBOXN_TX_NS, MBOXN_TX_DOMAIN }, |
|||
{ MPU_EN, MBOXN_RX_NS, MBOXN_RX_DOMAIN, MBOXN_TX_NS, MBOXN_TX_DOMAIN }, |
|||
}; |
|||
|
|||
#define APU_MBOX_NUM ARRAY_SIZE(mbox_mpu_setting_tab) |
|||
|
|||
#endif /* APUSYS_RV_MBOX_MPU_H */ |
@ -0,0 +1,15 @@ |
|||
#
|
|||
# Copyright (c) 2023, MediaTek Inc. All rights reserved.
|
|||
#
|
|||
# SPDX-License-Identifier: BSD-3-Clause
|
|||
#
|
|||
|
|||
LOCAL_DIR := $(call GET_LOCAL_DIR) |
|||
|
|||
MODULE := apusys_rv_${MTK_SOC} |
|||
|
|||
PLAT_INCLUDES += -I${MTK_PLAT}/drivers/apusys/${MTK_SOC} |
|||
|
|||
LOCAL_SRCS-y := ${LOCAL_DIR}/apusys_rv.c |
|||
|
|||
$(eval $(call MAKE_MODULE,$(MODULE),$(LOCAL_SRCS-y),$(MTK_BL))) |
Loading…
Reference in new issue