]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
mediatek: mt8183: add timer V20 compensation
authorFengquan Chen <fengquan.chen@mediatek.com>
Mon, 12 Oct 2020 08:33:25 +0000 (16:33 +0800)
committerFengquan Chen <fengquan.chen@mediatek.com>
Wed, 21 Oct 2020 03:00:26 +0000 (11:00 +0800)
add timer driver.

Signed-off-by: Fengquan Chen <fengquan.chen@mediatek.com>
Change-Id: I60a7273f922233a618a6163b802c0858ed89f75f

plat/mediatek/mt8183/bl31_plat_setup.c
plat/mediatek/mt8183/drivers/timer/mt_timer.c [new file with mode: 0644]
plat/mediatek/mt8183/drivers/timer/mt_timer.h [new file with mode: 0644]
plat/mediatek/mt8183/platform.mk

index e96b4ad0c530227dbb6b7b2b8cb292e26f6fb36c..7dac8a49b9ab0b7b2997b560df1ec4e9ecb58cc2 100644 (file)
@@ -16,6 +16,7 @@
 #include <drivers/generic_delay_timer.h>
 #include <mcucfg.h>
 #include <mt_gic_v3.h>
+#include <mt_timer.h>
 #include <lib/coreboot.h>
 #include <lib/mmio.h>
 #include <mtk_mcdi.h>
@@ -148,6 +149,8 @@ void bl31_platform_setup(void)
        mt_gic_driver_init();
        mt_gic_init();
 
+       mt_systimer_init();
+
        /* Init mcsi SF */
        plat_mtk_cci_init_sf();
 
diff --git a/plat/mediatek/mt8183/drivers/timer/mt_timer.c b/plat/mediatek/mt8183/drivers/timer/mt_timer.c
new file mode 100644 (file)
index 0000000..0da4815
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2020, MediaTek Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <mcucfg.h>
+#include <mt_timer.h>
+#include <platform_def.h>
+
+static void enable_systimer_compensation(void)
+{
+       unsigned int reg;
+
+       reg = mmio_read_32(CNTCR_REG);
+       reg &= ~COMP_15_EN;
+       reg |= COMP_20_EN;
+       mmio_write_32(CNTCR_REG, reg);
+
+       NOTICE("[systimer] CNTCR_REG(0x%x)\n", mmio_read_32(CNTCR_REG));
+}
+
+void mt_systimer_init(void)
+{
+       /* systimer is default on, so we only enable systimer compensation */
+       enable_systimer_compensation();
+}
diff --git a/plat/mediatek/mt8183/drivers/timer/mt_timer.h b/plat/mediatek/mt8183/drivers/timer/mt_timer.h
new file mode 100644 (file)
index 0000000..0b8edc5
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2020, MediaTek Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef MT_TIMER_H
+#define MT_TIMER_H
+
+
+#define SYSTIMER_BASE       (0x10017000)
+#define CNTCR_REG           (SYSTIMER_BASE + 0x0)
+#define CNTSR_REG           (SYSTIMER_BASE + 0x4)
+
+#define COMP_15_EN          (1 << 10)
+#define COMP_20_EN          (1 << 11)
+
+void mt_systimer_init(void);
+
+#endif /* MT_TIMER_H */
index 3ccc928ac49f1a0f16c413ed2447cc0725fc9252..f290a4e6d81d7d7ac2ae1c5c0b9cdfe13b2a8f68 100644 (file)
@@ -14,6 +14,7 @@ PLAT_INCLUDES := -I${MTK_PLAT}/common/                            \
                  -I${MTK_PLAT_SOC}/drivers/mcdi/                  \
                  -I${MTK_PLAT_SOC}/drivers/spmc/                  \
                  -I${MTK_PLAT_SOC}/drivers/gpio/                  \
+                 -I${MTK_PLAT_SOC}/drivers/timer/                 \
                  -I${MTK_PLAT_SOC}/drivers/pmic/                  \
                  -I${MTK_PLAT_SOC}/drivers/spm/                   \
                  -I${MTK_PLAT_SOC}/drivers/sspm/                  \
@@ -58,6 +59,7 @@ BL31_SOURCES    += common/desc_image_load.c                              \
                    ${MTK_PLAT_SOC}/drivers/spm/spm_suspend.c             \
                    ${MTK_PLAT_SOC}/drivers/gpio/mtgpio.c                 \
                    ${MTK_PLAT_SOC}/drivers/uart/uart.c                   \
+                   ${MTK_PLAT_SOC}/drivers/timer/mt_timer.c              \
                    ${MTK_PLAT_SOC}/drivers/emi_mpu/emi_mpu.c             \
                    ${MTK_PLAT_SOC}/plat_pm.c                             \
                    ${MTK_PLAT_SOC}/plat_topology.c                       \