/* * Copyright (c) 2021, MediaTek Inc. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef MT_SPM_USING_BAKERY_LOCK DEFINE_BAKERY_LOCK(spm_lock); #define plat_spm_lock_init() bakery_lock_init(&spm_lock) #else spinlock_t spm_lock; #define plat_spm_lock_init() #endif /* CLK_SCP_CFG_0 */ #define CLK_SCP_CFG_0 (TOPCKGEN_BASE + 0x264) #define SPM_CK_CONTROL_EN 0x7FF struct mt_resource_constraint plat_constraint_bus26m = { .is_valid = spm_is_valid_rc_bus26m, .update = spm_update_rc_bus26m, .allow = spm_allow_rc_bus26m, .run = spm_run_rc_bus26m, .reset = spm_reset_rc_bus26m, }; struct mt_resource_constraint plat_constraint_syspll = { .is_valid = spm_is_valid_rc_syspll, .update = spm_update_rc_syspll, .allow = spm_allow_rc_syspll, .run = spm_run_rc_syspll, .reset = spm_reset_rc_syspll, }; struct mt_resource_constraint plat_constraint_dram = { .is_valid = spm_is_valid_rc_dram, .update = spm_update_rc_dram, .allow = spm_allow_rc_dram, .run = spm_run_rc_dram, .reset = spm_reset_rc_dram, }; struct mt_resource_constraint plat_constraint_cpu = { .is_valid = spm_is_valid_rc_cpu_buck_ldo, .update = NULL, .allow = spm_allow_rc_cpu_buck_ldo, .run = spm_run_rc_cpu_buck_ldo, .reset = spm_reset_rc_cpu_buck_ldo, }; struct mt_resource_constraint *plat_constraints[] = { &plat_constraint_bus26m, &plat_constraint_syspll, &plat_constraint_dram, &plat_constraint_cpu, NULL, }; struct mt_resource_manager plat_mt8195_rm = { .update = mt_spm_cond_update, .consts = plat_constraints, }; void spm_boot_init(void) { NOTICE("MT8195 %s\n", __func__); /* switch ck_off/axi_26m control to SPM */ mmio_setbits_32(CLK_SCP_CFG_0, SPM_CK_CONTROL_EN); plat_spm_lock_init(); mt_spm_pmic_wrap_set_phase(PMIC_WRAP_PHASE_ALLINONE); mt_lp_rm_register(&plat_mt8195_rm); mt_spm_idle_generic_init(); mt_spm_suspend_init(); }