clocksource: arch_timer: Add support for not-fw-configured timer on ARM64
authorMarek Szyprowski <m.szyprowski@samsung.com>
Mon, 8 Oct 2018 10:21:55 +0000 (12:21 +0200)
committerLukasz Luba <l.luba@partner.samsung.com>
Fri, 17 May 2019 07:15:33 +0000 (09:15 +0200)
Use common infrastructure for ARM Architected Timers erratum to enable
support for systems with broken CPU firmware (timer registers not
properly configured). This mode has been already availabled on ARM
(32bits) architecture. This enables to run Linux kernel on ARM64 boards
using physical architected timers instead of the virtual ones. Examples
of such system with broken firmware are Samsung Exynos5433 SoC based
TM2(e) boards, which is already deployed for years and updating firmware
is not possible.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
drivers/clocksource/Kconfig
drivers/clocksource/arm_arch_timer.c

index a11f4ba98b05c57d08b211ac933f93fcf7cb4616..88fcb1222ab402086f310b386df4943f619859c9 100644 (file)
@@ -364,6 +364,17 @@ config ARM64_ERRATUM_858921
          The workaround will be dynamically enabled when an affected
          core is detected.
 
+config ARCH_TIMER_REGISTERS_NOT_FW_CONFIGURED
+       bool "Workaround for arch timer registers not configured by firmware"
+       default y
+       select ARM_ARCH_TIMER_OOL_WORKAROUND
+       depends on ARM_ARCH_TIMER && ARM64
+       help
+         This option enables a workaround for boards, on which arch timer
+         registers are not properly configured by the board firmware.
+         The workaround will be dynamically enabled when an affected
+         board is detected.
+
 config ARM_GLOBAL_TIMER
        bool "Support for the ARM global timer" if COMPILE_TEST
        select TIMER_OF if OF
index d8c7f5750cdb025dfd3eae42d691318fc472e29b..c8da7dcc003a3e1f40fab98f808b3bce965fc2e6 100644 (file)
@@ -408,6 +408,22 @@ static const struct arch_timer_erratum_workaround ool_workarounds[] = {
                .read_cntvct_el0 = arm64_858921_read_cntvct_el0,
        },
 #endif
+#ifdef CONFIG_ARM64_ERRATUM_1188873
+       {
+               .match_type = ate_match_local_cap_id,
+               .id = (void *)ARM64_WORKAROUND_1188873,
+               .desc = "ARM erratum 1188873",
+               .read_cntvct_el0 = arm64_1188873_read_cntvct_el0,
+       },
+#endif
+#ifdef CONFIG_ARCH_TIMER_REGISTERS_NOT_FW_CONFIGURED
+       {
+               .match_type = ate_match_dt,
+               .id = "arm,cpu-registers-not-fw-configured",
+               .desc = "broken CPU firmware (timer registers not configured)",
+               .read_cntvct_el0 = arch_counter_get_cntpct,
+       },
+#endif
 };
 
 typedef bool (*ate_match_fn_t)(const struct arch_timer_erratum_workaround *,
@@ -1219,9 +1235,10 @@ static int __init arch_timer_of_init(struct device_node *np)
         * If we cannot rely on firmware initializing the timer registers then
         * we should use the physical timers instead.
         */
-       if (IS_ENABLED(CONFIG_ARM) &&
-           of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
-               arch_timer_uses_ppi = ARCH_TIMER_PHYS_SECURE_PPI;
+       if (of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
+               arch_timer_uses_ppi = IS_ENABLED(CONFIG_ARM64) ?
+                                       ARCH_TIMER_PHYS_NONSECURE_PPI :
+                                       ARCH_TIMER_PHYS_SECURE_PPI;
        else
                arch_timer_uses_ppi = arch_timer_select_ppi();