blob: 33cfe9345f80ce8f3bb6d853949bf937aceaf9ba [file] [log] [blame]
Chungying Lua566cc92023-03-15 14:16:28 +08001/*
2 * Copyright (c) 2023, MediaTek Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/* TF-A system header */
8#include <common/debug.h>
9
10/* Vendor header */
11#include "apusys.h"
Karl Li130536e2023-04-21 11:43:24 +080012#include "apusys_devapc.h"
Chungying Lua566cc92023-03-15 14:16:28 +080013#include "apusys_power.h"
Karl Lieb629492023-04-27 14:00:10 +080014#include "apusys_rv.h"
Karl Lidece5f02023-04-27 10:38:28 +080015#include "apusys_security_ctrl_plat.h"
Chungying Lua566cc92023-03-15 14:16:28 +080016#include <lib/mtk_init/mtk_init.h>
Chungying Luf1f14b32023-03-15 15:31:56 +080017#include <mtk_sip_svc.h>
18
19static u_register_t apusys_kernel_handler(u_register_t x1,
20 u_register_t x2,
21 u_register_t x3,
22 u_register_t x4,
23 void *handle,
24 struct smccc_res *smccc_ret)
25{
26 uint32_t request_ops;
27 int32_t ret = -1;
28
29 request_ops = (uint32_t)x1;
30
31 switch (request_ops) {
32 case MTK_APUSYS_KERNEL_OP_APUSYS_PWR_TOP_ON:
33 ret = apusys_kernel_apusys_pwr_top_on();
34 break;
35 case MTK_APUSYS_KERNEL_OP_APUSYS_PWR_TOP_OFF:
36 ret = apusys_kernel_apusys_pwr_top_off();
37 break;
38 default:
39 ERROR(MODULE_TAG "%s unknown request_ops = %x\n", MODULE_TAG, request_ops);
40 break;
41 }
42
43 return ret;
44}
45DECLARE_SMC_HANDLER(MTK_SIP_APUSYS_CONTROL, apusys_kernel_handler);
Chungying Lua566cc92023-03-15 14:16:28 +080046
47int apusys_init(void)
48{
Karl Li130536e2023-04-21 11:43:24 +080049 if (apusys_power_init() != 0) {
50 return -1;
51 }
52
53 if (apusys_devapc_ao_init() != 0) {
54 return -1;
55 }
56
Karl Lidece5f02023-04-27 10:38:28 +080057 apusys_security_ctrl_init();
Karl Lieb629492023-04-27 14:00:10 +080058 apusys_rv_mbox_mpu_init();
Karl Lidece5f02023-04-27 10:38:28 +080059
Chungying Lua566cc92023-03-15 14:16:28 +080060 return 0;
61}
62MTK_PLAT_SETUP_1_INIT(apusys_init);