Commit ca4c0c2e authored by Flora Fu's avatar Flora Fu
Browse files

feat(plat/mediatek/apu): add mt8192 APU SiP call support



Add APU SiP call support for start/stop mcu.
Signed-off-by: default avatarFlora Fu <flora.fu@mediatek.com>
Change-Id: Ibf93d8ccf22c414de3093cee9e13f7668588f69e
Signed-off-by: default avatarPi-Cheng Chen <pi-cheng.chen@mediatek.com>
parent 2671f318
......@@ -35,6 +35,10 @@
#define MTK_SIP_VCORE_CONTROL_ARCH32 0x82000506
#define MTK_SIP_VCORE_CONTROL_ARCH64 0xC2000506
/* APUSYS SMC call */
#define MTK_SIP_APUSYS_CONTROL_AARCH32 0x8200051E
#define MTK_SIP_APUSYS_CONTROL_AARCH64 0xC200051E
/* Mediatek SiP Calls error code */
enum {
MTK_SIP_E_SUCCESS = 0,
......
/*
* Copyright (c) 2021, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <common/debug.h>
#include <drivers/console.h>
#include <lib/mmio.h>
#include <mtk_apusys.h>
#include <plat/common/platform.h>
uint64_t apusys_kernel_ctrl(uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4,
uint32_t *ret1)
{
uint32_t request_ops;
request_ops = (uint32_t)x1;
INFO("[APUSYS] ops=0x%x\n", request_ops);
switch (request_ops) {
case MTK_SIP_APU_START_MCU:
/* setup addr[33:32] in reviser */
mmio_write_32(REVISER_SECUREFW_CTXT, 0U);
mmio_write_32(REVISER_USDRFW_CTXT, 0U);
/* setup secure sideband */
mmio_write_32(AO_SEC_FW,
(SEC_FW_NON_SECURE << SEC_FW_SHIFT_NS) |
(0U << SEC_FW_DOMAIN_SHIFT));
/* setup boot address */
mmio_write_32(AO_MD32_BOOT_CTRL, 0U);
/* setup pre-define region */
mmio_write_32(AO_MD32_PRE_DEFINE,
(PRE_DEFINE_CACHE_TCM << PRE_DEFINE_SHIFT_0G) |
(PRE_DEFINE_CACHE << PRE_DEFINE_SHIFT_1G) |
(PRE_DEFINE_CACHE << PRE_DEFINE_SHIFT_2G) |
(PRE_DEFINE_CACHE << PRE_DEFINE_SHIFT_3G));
/* release runstall */
mmio_write_32(AO_MD32_SYS_CTRL, SYS_CTRL_RUN);
INFO("[APUSYS] reviser_ctxt=%x,%x\n",
mmio_read_32(REVISER_SECUREFW_CTXT),
mmio_read_32(REVISER_USDRFW_CTXT));
INFO("[APUSYS]fw=0x%08x,boot=0x%08x,def=0x%08x,sys=0x%08x\n",
mmio_read_32(AO_SEC_FW),
mmio_read_32(AO_MD32_BOOT_CTRL),
mmio_read_32(AO_MD32_PRE_DEFINE),
mmio_read_32(AO_MD32_SYS_CTRL));
break;
case MTK_SIP_APU_STOP_MCU:
/* hold runstall */
mmio_write_32(AO_MD32_SYS_CTRL, SYS_CTRL_STALL);
INFO("[APUSYS] md32_boot_ctrl=0x%08x,runstall=0x%08x\n",
mmio_read_32(AO_MD32_BOOT_CTRL),
mmio_read_32(AO_MD32_SYS_CTRL));
break;
default:
ERROR("%s, unknown request_ops = %x\n", __func__, request_ops);
break;
}
return 0UL;
}
/*
* Copyright (c) 2021, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __MTK_APUSYS_H__
#define __MTK_APUSYS_H__
#include <stdint.h>
/* setup the SMC command ops */
#define MTK_SIP_APU_START_MCU 0x00U
#define MTK_SIP_APU_STOP_MCU 0x01U
/* AO Register */
#define AO_MD32_PRE_DEFINE (APUSYS_APU_S_S_4_BASE + 0x00)
#define AO_MD32_BOOT_CTRL (APUSYS_APU_S_S_4_BASE + 0x04)
#define AO_MD32_SYS_CTRL (APUSYS_APU_S_S_4_BASE + 0x08)
#define AO_SEC_FW (APUSYS_APU_S_S_4_BASE + 0x10)
#define PRE_DEFINE_CACHE_TCM 0x3U
#define PRE_DEFINE_CACHE 0x2U
#define PRE_DEFINE_SHIFT_0G 0U
#define PRE_DEFINE_SHIFT_1G 2U
#define PRE_DEFINE_SHIFT_2G 4U
#define PRE_DEFINE_SHIFT_3G 6U
#define SEC_FW_NON_SECURE 1U
#define SEC_FW_SHIFT_NS 4U
#define SEC_FW_DOMAIN_SHIFT 0U
#define SYS_CTRL_RUN 0U
#define SYS_CTRL_STALL 1U
/* Reviser Register */
#define REVISER_SECUREFW_CTXT (APUSYS_SCTRL_REVISER_BASE + 0x300)
#define REVISER_USDRFW_CTXT (APUSYS_SCTRL_REVISER_BASE + 0x304)
uint64_t apusys_kernel_ctrl(uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4,
uint32_t *ret1);
#endif /* __MTK_APUSYS_H__ */
......@@ -6,6 +6,7 @@
#include <common/debug.h>
#include <common/runtime_svc.h>
#include <mtk_apusys.h>
#include <mtk_sip_svc.h>
#include <mt_spm_vcorefs.h>
#include "plat_sip_calls.h"
......@@ -20,6 +21,7 @@ uintptr_t mediatek_plat_sip_handler(uint32_t smc_fid,
u_register_t flags)
{
uint64_t ret;
uint32_t rnd_val0 = 0U;
switch (smc_fid) {
case MTK_SIP_VCORE_CONTROL_ARCH32:
......@@ -27,6 +29,11 @@ uintptr_t mediatek_plat_sip_handler(uint32_t smc_fid,
ret = spm_vcorefs_args(x1, x2, x3, (uint64_t *)&x4);
SMC_RET2(handle, ret, x4);
break;
case MTK_SIP_APUSYS_CONTROL_AARCH32:
case MTK_SIP_APUSYS_CONTROL_AARCH64:
ret = apusys_kernel_ctrl(x1, x2, x3, x4, &rnd_val0);
SMC_RET2(handle, ret, rnd_val0);
break;
default:
ERROR("%s: unhandled SMC (0x%x)\n", __func__, smc_fid);
break;
......
......@@ -16,6 +16,7 @@ PLAT_INCLUDES := -I${MTK_PLAT}/common/ \
-I${MTK_PLAT}/common/lpm/ \
-I${MTK_PLAT_SOC}/include/ \
-I${MTK_PLAT_SOC}/drivers/ \
-I${MTK_PLAT_SOC}/drivers/apusys/ \
-I${MTK_PLAT_SOC}/drivers/dcm \
-I${MTK_PLAT_SOC}/drivers/devapc \
-I${MTK_PLAT_SOC}/drivers/emi_mpu/ \
......@@ -62,6 +63,7 @@ BL31_SOURCES += common/desc_image_load.c \
${MTK_PLAT_SOC}/plat_pm.c \
${MTK_PLAT_SOC}/plat_topology.c \
${MTK_PLAT_SOC}/plat_sip_calls.c \
${MTK_PLAT_SOC}/drivers/apusys/mtk_apusys.c \
${MTK_PLAT_SOC}/drivers/dcm/mtk_dcm.c \
${MTK_PLAT_SOC}/drivers/dcm/mtk_dcm_utils.c \
${MTK_PLAT_SOC}/drivers/devapc/devapc.c \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment