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" |
Karl Li | 130536e | 2023-04-21 11:43:24 +0800 | [diff] [blame^] | 12 | #include "apusys_devapc.h" |
Chungying Lu | a566cc9 | 2023-03-15 14:16:28 +0800 | [diff] [blame] | 13 | #include "apusys_power.h" |
| 14 | #include <lib/mtk_init/mtk_init.h> |
Chungying Lu | f1f14b3 | 2023-03-15 15:31:56 +0800 | [diff] [blame] | 15 | #include <mtk_sip_svc.h> |
| 16 | |
| 17 | static u_register_t apusys_kernel_handler(u_register_t x1, |
| 18 | u_register_t x2, |
| 19 | u_register_t x3, |
| 20 | u_register_t x4, |
| 21 | void *handle, |
| 22 | struct smccc_res *smccc_ret) |
| 23 | { |
| 24 | uint32_t request_ops; |
| 25 | int32_t ret = -1; |
| 26 | |
| 27 | request_ops = (uint32_t)x1; |
| 28 | |
| 29 | switch (request_ops) { |
| 30 | case MTK_APUSYS_KERNEL_OP_APUSYS_PWR_TOP_ON: |
| 31 | ret = apusys_kernel_apusys_pwr_top_on(); |
| 32 | break; |
| 33 | case MTK_APUSYS_KERNEL_OP_APUSYS_PWR_TOP_OFF: |
| 34 | ret = apusys_kernel_apusys_pwr_top_off(); |
| 35 | break; |
| 36 | default: |
| 37 | ERROR(MODULE_TAG "%s unknown request_ops = %x\n", MODULE_TAG, request_ops); |
| 38 | break; |
| 39 | } |
| 40 | |
| 41 | return ret; |
| 42 | } |
| 43 | DECLARE_SMC_HANDLER(MTK_SIP_APUSYS_CONTROL, apusys_kernel_handler); |
Chungying Lu | a566cc9 | 2023-03-15 14:16:28 +0800 | [diff] [blame] | 44 | |
| 45 | int apusys_init(void) |
| 46 | { |
Karl Li | 130536e | 2023-04-21 11:43:24 +0800 | [diff] [blame^] | 47 | if (apusys_power_init() != 0) { |
| 48 | return -1; |
| 49 | } |
| 50 | |
| 51 | if (apusys_devapc_ao_init() != 0) { |
| 52 | return -1; |
| 53 | } |
| 54 | |
Chungying Lu | a566cc9 | 2023-03-15 14:16:28 +0800 | [diff] [blame] | 55 | return 0; |
| 56 | } |
| 57 | MTK_PLAT_SETUP_1_INIT(apusys_init); |