2 * Copyright (c) 2019, MediaTek Inc. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
8 #include <lib/bakery_lock.h>
9 #include <drivers/console.h>
10 #include <common/debug.h>
13 #include <plat_private.h>
15 #include <plat/common/platform.h>
16 #include <platform_def.h>
17 #include <mtk_plat_common.h>
19 #define PWR_STATUS (SPM_BASE + 0x180)
21 uint64_t plat_dcm_mcsi_a_addr
;
22 uint32_t plat_dcm_mcsi_a_val
;
23 static int plat_dcm_init_type
;
24 static unsigned int dcm_big_core_cnt
;
25 int plat_dcm_initiated
;
27 #define PWR_STA_BIG_MP_MASK (0x1 << 15)
29 DEFINE_BAKERY_LOCK(dcm_lock
);
31 void dcm_lock_init(void)
33 bakery_lock_init(&dcm_lock
);
36 void dcm_lock_get(void)
38 bakery_lock_get(&dcm_lock
);
41 void dcm_lock_release(void)
43 bakery_lock_release(&dcm_lock
);
46 void plat_dcm_mcsi_a_backup(void)
50 void plat_dcm_mcsi_a_restore(void)
54 void plat_dcm_rgu_enable(void)
58 void plat_dcm_big_core_sync(short on
)
60 /* Check if Big cluster power is existed */
61 if (!(mmio_read_32(PWR_STATUS
) & PWR_STA_BIG_MP_MASK
))
65 mmio_write_32(MP2_SYNC_DCM
,
66 (mmio_read_32(MP2_SYNC_DCM
) & ~MP2_SYNC_DCM_MASK
)
70 mmio_write_32(MP2_SYNC_DCM
,
71 (mmio_read_32(MP2_SYNC_DCM
) & ~MP2_SYNC_DCM_MASK
)
75 void plat_dcm_restore_cluster_on(unsigned long mpidr
)
77 unsigned long cluster_id
=
78 (mpidr
& MPIDR_CLUSTER_MASK
) >> MPIDR_AFFINITY_BITS
;
83 if (plat_dcm_init_type
& BIG_CORE_DCM_TYPE
)
84 plat_dcm_big_core_sync(1);
86 plat_dcm_big_core_sync(0);
94 void plat_dcm_msg_handler(uint64_t x1
)
96 plat_dcm_init_type
= x1
& ALL_DCM_TYPE
;
99 unsigned long plat_dcm_get_enabled_cnt(uint64_t type
)
102 case BIG_CORE_DCM_TYPE
:
103 return dcm_big_core_cnt
;
109 void plat_dcm_init(void)