Chungying Lu | a566cc9 | 2023-03-15 14:16:28 +0800 | [diff] [blame] | 1 | /* |
| 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 Lu | f1f14b3 | 2023-03-15 15:31:56 +0800 | [diff] [blame] | 14 | #include <mtk_sip_svc.h> |
| 15 | |
| 16 | static 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 | } |
| 42 | DECLARE_SMC_HANDLER(MTK_SIP_APUSYS_CONTROL, apusys_kernel_handler); |
Chungying Lu | a566cc9 | 2023-03-15 14:16:28 +0800 | [diff] [blame] | 43 | |
| 44 | int apusys_init(void) |
| 45 | { |
| 46 | apusys_power_init(); |
| 47 | return 0; |
| 48 | } |
| 49 | MTK_PLAT_SETUP_1_INIT(apusys_init); |