1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * This file is created based on MT8196 Functional Specification
5 * Chapter number: 1.2 2.2
8 #include <device/mmio.h>
9 #include <soc/addressmap.h>
10 #include <soc/timer.h>
12 static void clear_systimer(struct systimer
*const mtk_systimer
)
16 for (id
= 0; id
< SYSTIMER_CNT
; id
++) {
17 u32
*cnttval_con
= &mtk_systimer
->cnttval
[id
].con
;
18 WRITE32_BITFIELDS(cnttval_con
, SYST_CON
, SYST_CON_EN
);
19 SET32_BITFIELDS(cnttval_con
, SYST_CON
, SYST_CON_IRQ_CLR
);
20 WRITE32_BITFIELDS(cnttval_con
, SYST_CON
, SYST_CON_CLR
);
23 SET32_BITFIELDS(&mtk_systimer
->cntcr
, REV_SET
, REV_CLR_EN
);
26 void timer_prepare(void)
28 struct systimer
*mtk_systimer
= (void *)SYSTIMER_BASE
;
30 SET32_BITFIELDS(&mtk_systimer
->cntcr
,
31 COMP_FEATURE
, COMP_FEATURE_CLR
| COMP_FEATURE_20_EN
,
32 COMP_FEATURE_TIE
, COMP_FEATURE_TIE_CLR
| COMP_FEATURE_TIE_EN
);
33 clear_systimer(mtk_systimer
);