blob: c82b3a7a8fcd7d355fe0fa682a75af0d6ba30bb2 [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"
12#include "apusys_power.h"
13#include <lib/mtk_init/mtk_init.h>
Chungying Luf1f14b32023-03-15 15:31:56 +080014#include <mtk_sip_svc.h>
15
16static u_register_t apusys_kernel_handler(u_register_t x1,
17 u_register_t x2,
18 u_register_t x3,
19 u_register_t x4,
20 void *handle,
21 struct smccc_res *smccc_ret)
22{
23 uint32_t request_ops;
24 int32_t ret = -1;
25
26 request_ops = (uint32_t)x1;
27
28 switch (request_ops) {
29 case MTK_APUSYS_KERNEL_OP_APUSYS_PWR_TOP_ON:
30 ret = apusys_kernel_apusys_pwr_top_on();
31 break;
32 case MTK_APUSYS_KERNEL_OP_APUSYS_PWR_TOP_OFF:
33 ret = apusys_kernel_apusys_pwr_top_off();
34 break;
35 default:
36 ERROR(MODULE_TAG "%s unknown request_ops = %x\n", MODULE_TAG, request_ops);
37 break;
38 }
39
40 return ret;
41}
42DECLARE_SMC_HANDLER(MTK_SIP_APUSYS_CONTROL, apusys_kernel_handler);
Chungying Lua566cc92023-03-15 14:16:28 +080043
44int apusys_init(void)
45{
46 apusys_power_init();
47 return 0;
48}
49MTK_PLAT_SETUP_1_INIT(apusys_init);