developer | 91bb08d | 2022-09-07 18:41:59 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023, MediaTek Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef MT_LPM_SMC_H |
| 8 | #define MT_LPM_SMC_H |
| 9 | |
| 10 | /* |
| 11 | * MTK LPM smc user format: |
| 12 | * bit[31:24]: magic number |
| 13 | * bit[23:16]: user number |
| 14 | * bit[15:00]: user id |
| 15 | */ |
| 16 | |
| 17 | #define MT_LPM_SMC_MAGIC (0xDA000000) |
| 18 | #define MT_LPM_SMC_MAGIC_MASK (0xFF000000) |
| 19 | #define MT_LPM_SMC_USER_MASK (0xFF) |
| 20 | #define MT_LPM_SMC_USER_SHIFT (16) |
| 21 | |
| 22 | #define MT_LPM_SMC_USER_ID_MASK (0x0000FFFF) |
| 23 | |
| 24 | /* |
| 25 | * cpu_pm is used for MCDI to read/write CPC information |
| 26 | * spm_dbg is used for spm related debug information |
| 27 | * spm is used for spm related settings |
| 28 | * cpu_pm_lp is used for MCDI setting irq_remain |
| 29 | */ |
| 30 | enum mt_lpm_smc_user_id { |
| 31 | MT_LPM_SMC_USER_CPU_PM = 0, |
| 32 | MT_LPM_SMC_USER_SPM_DBG, |
| 33 | MT_LPM_SMC_USER_SPM, |
| 34 | MT_LPM_SMC_USER_CPU_PM_LP, |
| 35 | MT_LPM_SMC_USER_SECURE_CPU_PM, |
| 36 | MT_LPM_SMC_USER_SECURE_SPM_DBG, |
| 37 | MT_LPM_SMC_USER_SECURE_SPM, |
| 38 | MT_LPM_SMC_USER_MAX, |
| 39 | }; |
| 40 | |
| 41 | #define IS_MT_LPM_SMC(smcid) ((smcid & MT_LPM_SMC_MAGIC_MASK) == MT_LPM_SMC_MAGIC) |
| 42 | |
| 43 | /* get real user id */ |
| 44 | #define MT_LPM_SMC_USER(id) ((id >> MT_LPM_SMC_USER_SHIFT) & MT_LPM_SMC_USER_MASK) |
| 45 | #define MT_LPM_SMC_USER_ID(uid) (uid & MT_LPM_SMC_USER_ID_MASK) |
| 46 | |
| 47 | /* sink user id to smc's user id */ |
| 48 | #define MT_LPM_SMC_USER_SINK(user, uid) (((uid & MT_LPM_SMC_USER_ID_MASK) |\ |
| 49 | ((user & MT_LPM_SMC_USER_MASK) << MT_LPM_SMC_USER_SHIFT)) |\ |
| 50 | MT_LPM_SMC_MAGIC) |
| 51 | |
| 52 | /* sink cpu pm's smc id */ |
| 53 | #define MT_LPM_SMC_USER_ID_CPU_PM(uid) MT_LPM_SMC_USER_SINK(MT_LPM_SMC_USER_CPU_PM, uid) |
| 54 | /* sink spm's smc id */ |
| 55 | #define MT_LPM_SMC_USER_ID_SPM(uid) MT_LPM_SMC_USER_SINK(MT_LPM_SMC_USER_SPM, uid) |
| 56 | |
| 57 | /* sink cpu pm's user id */ |
| 58 | #define MT_LPM_SMC_USER_CPU_PM(uid) MT_LPM_SMC_USER_ID_CPU_PM(uid) |
| 59 | |
| 60 | /* sink spm's user id */ |
| 61 | #define MT_LPM_SMC_USER_SPM(uid) MT_LPM_SMC_USER_ID_SPM(uid) |
| 62 | |
| 63 | /* behavior */ |
| 64 | #define MT_LPM_SMC_ACT_SET BIT(0) |
| 65 | #define MT_LPM_SMC_ACT_CLR BIT(1) |
| 66 | #define MT_LPM_SMC_ACT_GET BIT(2) |
| 67 | #define MT_LPM_SMC_ACT_PUSH BIT(3) |
| 68 | #define MT_LPM_SMC_ACT_POP BIT(4) |
| 69 | #define MT_LPM_SMC_ACT_SUBMIT BIT(5) |
| 70 | |
| 71 | /* compatible action for legacy smc from lk */ |
| 72 | #define MT_LPM_SMC_ACT_COMPAT BIT(31) |
| 73 | |
| 74 | enum mt_lpm_spmc_compat_id { |
| 75 | MT_LPM_SPMC_COMPAT_LK_FW_INIT, |
| 76 | MT_LPM_SPMC_COMPAT_LK_MCDI_WDT_DUMP, |
| 77 | }; |
| 78 | |
| 79 | #endif /* MT_LPM_SMC_H */ |