Merge branch '2022-04-21-further-cleanups'

- Fix SPL_SYS_MALLOC_SIMPLE and non-SPL_FRAMEWORK boards (a large number
  of PowerPC platforms)
- Remove duplication of crc16 functionality
- Migrate COUNTER_FREQUENCY to CONFIG_COUNTER_FREQUENCY and have it in
  Kconfig
diff --git a/Kconfig b/Kconfig
index 429e5d3..bdae59e 100644
--- a/Kconfig
+++ b/Kconfig
@@ -283,6 +283,7 @@
 config SPL_SYS_MALLOC_F_LEN
 	hex "Size of malloc() pool in SPL"
 	depends on SYS_MALLOC_F && SPL
+	default 0 if !SPL_FRAMEWORK
 	default 0x2800 if RCAR_GEN3
 	default SYS_MALLOC_F_LEN
 	help
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9470122..13be6b6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -20,6 +20,23 @@
 	  not be present on all ARMv8.0, but is always present on ARMv8.1 and
 	  newer.
 
+config COUNTER_FREQUENCY
+	int "Timer clock frequency"
+	depends on ARM64 || CPU_V7A
+	default 8000000 if IMX8 || MX7 || MX6UL || MX6ULL
+	default 24000000 if ARCH_SUNXI || ARCH_EXYNOS || ROCKCHIP_RK3128 || \
+			ROCKCHIP_RK3288 || ROCKCHIP_RK322X || ROCKCHIP_RK3036
+	default 25000000 if ARCH_LX2160A || ARCH_LX2162A || ARCH_LS1088A
+	default 100000000 if ARCH_ZYNQMP
+	default 0
+	help
+	  For platforms with ARMv8-A and ARMv7-A which features a system
+	  counter, those platforms needs software to program the counter
+	  frequency. Setup time clock frequency for certain platform.
+	  0 means no need to configure the system counter frequency.
+	  For platforms needs the frequency set in U-Boot with a
+	  pre-defined value, should have the macro defined as a non-zero value.
+
 config POSITION_INDEPENDENT
 	bool "Generate position-independent pre-relocation code"
 	depends on ARM64 || CPU_V7A
diff --git a/arch/arm/cpu/armv7/ls102xa/psci.S b/arch/arm/cpu/armv7/ls102xa/psci.S
index 531cfb0..3956178 100644
--- a/arch/arm/cpu/armv7/ls102xa/psci.S
+++ b/arch/arm/cpu/armv7/ls102xa/psci.S
@@ -36,7 +36,7 @@
 
 	.align	5
 
-#define	ONE_MS		(COUNTER_FREQUENCY / 1000)
+#define	ONE_MS		(CONFIG_COUNTER_FREQUENCY / 1000)
 #define	RESET_WAIT	(30 * ONE_MS)
 
 .globl	psci_version
diff --git a/arch/arm/cpu/armv7/ls102xa/timer.c b/arch/arm/cpu/armv7/ls102xa/timer.c
index d79bf10..c6126b1 100644
--- a/arch/arm/cpu/armv7/ls102xa/timer.c
+++ b/arch/arm/cpu/armv7/ls102xa/timer.c
@@ -65,7 +65,7 @@
 	/* Enable System Counter */
 	writel(SYS_COUNTER_CTRL_ENABLE, &sctr->cntcr);
 
-	freq = COUNTER_FREQUENCY;
+	freq = CONFIG_COUNTER_FREQUENCY;
 	asm("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
 
 	/* Set PL1 Physical Timer Ctrl */
diff --git a/arch/arm/cpu/armv7/nonsec_virt.S b/arch/arm/cpu/armv7/nonsec_virt.S
index 1773fae..39aeeb4 100644
--- a/arch/arm/cpu/armv7/nonsec_virt.S
+++ b/arch/arm/cpu/armv7/nonsec_virt.S
@@ -189,11 +189,11 @@
  * we do this here instead.
  * But first check if we have the generic timer.
  */
-#ifdef COUNTER_FREQUENCY
+#if CONFIG_COUNTER_FREQUENCY
 	mrc	p15, 0, r0, c0, c1, 1		@ read ID_PFR1
 	and	r0, r0, #CPUID_ARM_GENTIMER_MASK	@ mask arch timer bits
 	cmp	r0, #(1 << CPUID_ARM_GENTIMER_SHIFT)
-	ldreq	r1, =COUNTER_FREQUENCY
+	ldreq	r1, =CONFIG_COUNTER_FREQUENCY
 	mcreq	p15, 0, r1, c14, c0, 0		@ write CNTFRQ
 #endif
 
diff --git a/arch/arm/cpu/armv7/sunxi/psci.c b/arch/arm/cpu/armv7/sunxi/psci.c
index 1ac50f5..d1bd6b9 100644
--- a/arch/arm/cpu/armv7/sunxi/psci.c
+++ b/arch/arm/cpu/armv7/sunxi/psci.c
@@ -57,7 +57,7 @@
 	return val;
 }
 
-#define ONE_MS (COUNTER_FREQUENCY / 1000)
+#define ONE_MS (CONFIG_COUNTER_FREQUENCY / 1000)
 
 static void __secure __mdelay(u32 ms)
 {
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spintable.S b/arch/arm/cpu/armv8/fsl-layerscape/spintable.S
index d6bd188..1eb0c2d 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/spintable.S
+++ b/arch/arm/cpu/armv8/fsl-layerscape/spintable.S
@@ -113,6 +113,6 @@
 	.align 3
 	.global __real_cntfrq
 __real_cntfrq:
-	.quad COUNTER_FREQUENCY
+	.quad CONFIG_COUNTER_FREQUENCY
 	/* Secondary Boot Code ends here */
 __secondary_boot_code_end:
diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index 6a6a4f8..d328e8c 100644
--- a/arch/arm/cpu/armv8/start.S
+++ b/arch/arm/cpu/armv8/start.S
@@ -138,9 +138,9 @@
 0:
 	msr	daifclr, #0x4			/* Unmask SError interrupts */
 
-#ifdef COUNTER_FREQUENCY
+#if CONFIG_COUNTER_FREQUENCY
 	branch_if_not_highest_el x0, 4f
-	ldr	x0, =COUNTER_FREQUENCY
+	ldr	x0, =CONFIG_COUNTER_FREQUENCY
 	msr	cntfrq_el0, x0			/* Initialize CNTFRQ */
 #endif
 
diff --git a/arch/arm/mach-rockchip/rk3036-board-spl.c b/arch/arm/mach-rockchip/rk3036-board-spl.c
index 6eb89e1..73f6d24 100644
--- a/arch/arm/mach-rockchip/rk3036-board-spl.c
+++ b/arch/arm/mach-rockchip/rk3036-board-spl.c
@@ -20,7 +20,7 @@
 void rockchip_stimer_init(void)
 {
 	asm volatile("mcr p15, 0, %0, c14, c0, 0"
-		     : : "r"(COUNTER_FREQUENCY));
+		     : : "r"(CONFIG_COUNTER_FREQUENCY));
 
 	writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
 	writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index eda2248..30be640 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -88,7 +88,7 @@
 		return;
 #ifndef CONFIG_ARM64
 	asm volatile("mcr p15, 0, %0, c14, c0, 0"
-		     : : "r"(COUNTER_FREQUENCY));
+		     : : "r"(CONFIG_COUNTER_FREQUENCY));
 #endif
 	writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
 	writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
diff --git a/arch/arm/mach-rockchip/tpl.c b/arch/arm/mach-rockchip/tpl.c
index 8126587..ed46a9a 100644
--- a/arch/arm/mach-rockchip/tpl.c
+++ b/arch/arm/mach-rockchip/tpl.c
@@ -39,7 +39,7 @@
 
 #ifndef CONFIG_ARM64
 	asm volatile("mcr p15, 0, %0, c14, c0, 0"
-		     : : "r"(COUNTER_FREQUENCY));
+		     : : "r"(CONFIG_COUNTER_FREQUENCY));
 #endif
 
 	writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
diff --git a/arch/arm/mach-versal/Kconfig b/arch/arm/mach-versal/Kconfig
index 0c6ad34..645f06a 100644
--- a/arch/arm/mach-versal/Kconfig
+++ b/arch/arm/mach-versal/Kconfig
@@ -24,12 +24,6 @@
 config SYS_MALLOC_LEN
 	default 0x2000000
 
-config COUNTER_FREQUENCY
-	int "Timer clock frequency"
-	default 0
-	help
-	  Setup time clock frequency for certain platform
-
 config ZYNQ_SDHCI_MAX_FREQ
 	default 200000000
 
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 8932415..371ed9e 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -202,14 +202,14 @@
 		 * we avoid the risk of writing to it.
 		 */
 		asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r"(freq));
-		if (freq != COUNTER_FREQUENCY) {
+		if (freq != CONFIG_COUNTER_FREQUENCY) {
 			debug("arch timer frequency is %d Hz, should be %d, fixing ...\n",
-			      freq, COUNTER_FREQUENCY);
+			      freq, CONFIG_COUNTER_FREQUENCY);
 #ifdef CONFIG_NON_SECURE
 			printf("arch timer frequency is wrong, but cannot adjust it\n");
 #else
 			asm volatile("mcr p15, 0, %0, c14, c0, 0"
-				     : : "r"(COUNTER_FREQUENCY));
+				     : : "r"(CONFIG_COUNTER_FREQUENCY));
 #endif
 		}
 	}
diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
index 9940f2a..2e2807e 100644
--- a/board/xilinx/versal/board.c
+++ b/board/xilinx/versal/board.c
@@ -74,7 +74,7 @@
 	 * Program freq register in System counter and
 	 * enable system counter.
 	 */
-	writel(COUNTER_FREQUENCY,
+	writel(CONFIG_COUNTER_FREQUENCY,
 	       &iou_scntr_secure->base_frequency_id_register);
 
 	debug("counter val 0x%x\n",
diff --git a/configs/a3y17lte_defconfig b/configs/a3y17lte_defconfig
index 8636f15..536e23e 100644
--- a/configs/a3y17lte_defconfig
+++ b/configs/a3y17lte_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=26000000
 CONFIG_ARCH_EXYNOS=y
 CONFIG_SYS_TEXT_BASE=0x40001000
 CONFIG_SYS_MALLOC_F_LEN=0x400
diff --git a/configs/a5y17lte_defconfig b/configs/a5y17lte_defconfig
index 97fa87c..c6f452a 100644
--- a/configs/a5y17lte_defconfig
+++ b/configs/a5y17lte_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=26000000
 CONFIG_ARCH_EXYNOS=y
 CONFIG_SYS_TEXT_BASE=0x40001000
 CONFIG_SYS_MALLOC_F_LEN=0x400
diff --git a/configs/a7y17lte_defconfig b/configs/a7y17lte_defconfig
index 9e66425..28e9c097 100644
--- a/configs/a7y17lte_defconfig
+++ b/configs/a7y17lte_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=26000000
 CONFIG_ARCH_EXYNOS=y
 CONFIG_SYS_TEXT_BASE=0x40001000
 CONFIG_SYS_MALLOC_F_LEN=0x400
diff --git a/configs/bubblegum_96_defconfig b/configs/bubblegum_96_defconfig
index f4e6abc..a21b245 100644
--- a/configs/bubblegum_96_defconfig
+++ b/configs/bubblegum_96_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_OWL=y
 CONFIG_SYS_MALLOC_LEN=0x2000000
 CONFIG_ENV_SIZE=0x2000
diff --git a/configs/chromebook_bob_defconfig b/configs/chromebook_bob_defconfig
index 638c65d..1b2db5d 100644
--- a/configs/chromebook_bob_defconfig
+++ b/configs/chromebook_bob_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/chromebook_kevin_defconfig b/configs/chromebook_kevin_defconfig
index 38c1403..ad6cbca 100644
--- a/configs/chromebook_kevin_defconfig
+++ b/configs/chromebook_kevin_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/cortina_presidio-asic-base_defconfig b/configs/cortina_presidio-asic-base_defconfig
index 4a8377a..6514f07 100644
--- a/configs/cortina_presidio-asic-base_defconfig
+++ b/configs/cortina_presidio-asic-base_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 # CONFIG_SYS_ARCH_TIMER is not set
 CONFIG_TARGET_PRESIDIO_ASIC=y
 CONFIG_SYS_TEXT_BASE=0x04000000
diff --git a/configs/cortina_presidio-asic-emmc_defconfig b/configs/cortina_presidio-asic-emmc_defconfig
index 236520e..b0bd54f 100644
--- a/configs/cortina_presidio-asic-emmc_defconfig
+++ b/configs/cortina_presidio-asic-emmc_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 # CONFIG_SYS_ARCH_TIMER is not set
 CONFIG_TARGET_PRESIDIO_ASIC=y
 CONFIG_SYS_TEXT_BASE=0x04000000
diff --git a/configs/cortina_presidio-asic-pnand_defconfig b/configs/cortina_presidio-asic-pnand_defconfig
index 06eaa5f..944fed6 100644
--- a/configs/cortina_presidio-asic-pnand_defconfig
+++ b/configs/cortina_presidio-asic-pnand_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 # CONFIG_SYS_ARCH_TIMER is not set
 CONFIG_TARGET_PRESIDIO_ASIC=y
 CONFIG_SYS_TEXT_BASE=0x04000000
diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
index e73d8d8..677bff6 100644
--- a/configs/cubieboard7_defconfig
+++ b/configs/cubieboard7_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_OWL=y
 CONFIG_SYS_MALLOC_LEN=0x2000000
 CONFIG_DEFAULT_DEVICE_TREE="s700-cubieboard7"
diff --git a/configs/dragonboard410c_defconfig b/configs/dragonboard410c_defconfig
index 33cb31c..dc136f9 100644
--- a/configs/dragonboard410c_defconfig
+++ b/configs/dragonboard410c_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=19000000
 CONFIG_ARCH_SNAPDRAGON=y
 CONFIG_SYS_TEXT_BASE=0x8f600000
 CONFIG_SYS_MALLOC_LEN=0x802000
diff --git a/configs/dragonboard820c_defconfig b/configs/dragonboard820c_defconfig
index 4797153..3bd22aa 100644
--- a/configs/dragonboard820c_defconfig
+++ b/configs/dragonboard820c_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=19000000
 CONFIG_ARCH_SNAPDRAGON=y
 CONFIG_SYS_TEXT_BASE=0x80080000
 CONFIG_SYS_MALLOC_LEN=0x804000
diff --git a/configs/evb-px30_defconfig b/configs/evb-px30_defconfig
index 061d76e..36eaf4e 100644
--- a/configs/evb-px30_defconfig
+++ b/configs/evb-px30_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
diff --git a/configs/evb-px5_defconfig b/configs/evb-px5_defconfig
index 581b8cd..1e2b0f0 100644
--- a/configs/evb-px5_defconfig
+++ b/configs/evb-px5_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/evb-rk3308_defconfig b/configs/evb-rk3308_defconfig
index 26d1248..b4ce8a1 100644
--- a/configs/evb-rk3308_defconfig
+++ b/configs/evb-rk3308_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00600000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
diff --git a/configs/evb-rk3328_defconfig b/configs/evb-rk3328_defconfig
index 78fb93b..7e0c4c5 100644
--- a/configs/evb-rk3328_defconfig
+++ b/configs/evb-rk3328_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/evb-rk3399_defconfig b/configs/evb-rk3399_defconfig
index a18e622..a9afb63 100644
--- a/configs/evb-rk3399_defconfig
+++ b/configs/evb-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/evb-rk3568_defconfig b/configs/evb-rk3568_defconfig
index a472043..d2af961 100644
--- a/configs/evb-rk3568_defconfig
+++ b/configs/evb-rk3568_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00a00000
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
diff --git a/configs/ficus-rk3399_defconfig b/configs/ficus-rk3399_defconfig
index 33d6781..1ee3cb2 100644
--- a/configs/ficus-rk3399_defconfig
+++ b/configs/ficus-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_ENV_OFFSET=0x3F8000
diff --git a/configs/firefly-px30_defconfig b/configs/firefly-px30_defconfig
index 873b34b..01858a6 100644
--- a/configs/firefly-px30_defconfig
+++ b/configs/firefly-px30_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
diff --git a/configs/firefly-rk3399_defconfig b/configs/firefly-rk3399_defconfig
index 2858c35..3803e42 100644
--- a/configs/firefly-rk3399_defconfig
+++ b/configs/firefly-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/geekbox_defconfig b/configs/geekbox_defconfig
index e211176..8287600 100644
--- a/configs/geekbox_defconfig
+++ b/configs/geekbox_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SYS_MALLOC_F_LEN=0x1000
diff --git a/configs/hihope_rzg2_defconfig b/configs/hihope_rzg2_defconfig
index 05dd00a..3e10773 100644
--- a/configs/hihope_rzg2_defconfig
+++ b/configs/hihope_rzg2_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=16666666
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x50000000
diff --git a/configs/hikey960_defconfig b/configs/hikey960_defconfig
index ce33936..627daa1 100644
--- a/configs/hikey960_defconfig
+++ b/configs/hikey960_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=19000000
 CONFIG_TARGET_HIKEY960=y
 CONFIG_SYS_TEXT_BASE=0x1ac98000
 CONFIG_SYS_MALLOC_LEN=0x801000
diff --git a/configs/hikey_defconfig b/configs/hikey_defconfig
index 0c04945..6f33bba 100644
--- a/configs/hikey_defconfig
+++ b/configs/hikey_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=19000000
 CONFIG_SYS_TEXT_BASE=0x35000000
 CONFIG_SYS_MALLOC_LEN=0x801000
 CONFIG_NR_DRAM_BANKS=6
diff --git a/configs/khadas-edge-captain-rk3399_defconfig b/configs/khadas-edge-captain-rk3399_defconfig
index fffdc61..cddf522 100644
--- a/configs/khadas-edge-captain-rk3399_defconfig
+++ b/configs/khadas-edge-captain-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/khadas-edge-rk3399_defconfig b/configs/khadas-edge-rk3399_defconfig
index 2c6f32e..bd52c01 100644
--- a/configs/khadas-edge-rk3399_defconfig
+++ b/configs/khadas-edge-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/khadas-edge-v-rk3399_defconfig b/configs/khadas-edge-v-rk3399_defconfig
index 3f3cf7d..21bf948 100644
--- a/configs/khadas-edge-v-rk3399_defconfig
+++ b/configs/khadas-edge-v-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/kontron_sl28_defconfig b/configs/kontron_sl28_defconfig
index 90f925b..0d2c067 100644
--- a/configs/kontron_sl28_defconfig
+++ b/configs/kontron_sl28_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_SL28=y
 CONFIG_SYS_MALLOC_LEN=0x202000
 CONFIG_SYS_MALLOC_F_LEN=0x4000
diff --git a/configs/leez-rk3399_defconfig b/configs/leez-rk3399_defconfig
index e2bb140..2fa8d56 100644
--- a/configs/leez-rk3399_defconfig
+++ b/configs/leez-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/lion-rk3368_defconfig b/configs/lion-rk3368_defconfig
index 2a7cf0d..4269138 100644
--- a/configs/lion-rk3368_defconfig
+++ b/configs/lion-rk3368_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/ls1012a2g5rdb_qspi_defconfig b/configs/ls1012a2g5rdb_qspi_defconfig
index ff5cfac..cb9ad24 100644
--- a/configs/ls1012a2g5rdb_qspi_defconfig
+++ b/configs/ls1012a2g5rdb_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012A2G5RDB=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/ls1012a2g5rdb_tfa_defconfig b/configs/ls1012a2g5rdb_tfa_defconfig
index c2807c1..8763e0d 100644
--- a/configs/ls1012a2g5rdb_tfa_defconfig
+++ b/configs/ls1012a2g5rdb_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012A2G5RDB=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1012afrdm_qspi_defconfig b/configs/ls1012afrdm_qspi_defconfig
index 9d1d266..fa3486c 100644
--- a/configs/ls1012afrdm_qspi_defconfig
+++ b/configs/ls1012afrdm_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012AFRDM=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/ls1012afrdm_tfa_defconfig b/configs/ls1012afrdm_tfa_defconfig
index c0c9b73..a56a27b 100644
--- a/configs/ls1012afrdm_tfa_defconfig
+++ b/configs/ls1012afrdm_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012AFRDM=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1012afrwy_qspi_SECURE_BOOT_defconfig b/configs/ls1012afrwy_qspi_SECURE_BOOT_defconfig
index fe0c894..e25d964 100644
--- a/configs/ls1012afrwy_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1012afrwy_qspi_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012AFRWY=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/ls1012afrwy_qspi_defconfig b/configs/ls1012afrwy_qspi_defconfig
index 36583d7..e0ae291 100644
--- a/configs/ls1012afrwy_qspi_defconfig
+++ b/configs/ls1012afrwy_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012AFRWY=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/ls1012afrwy_tfa_SECURE_BOOT_defconfig b/configs/ls1012afrwy_tfa_SECURE_BOOT_defconfig
index b790d52..56ddeaa 100644
--- a/configs/ls1012afrwy_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1012afrwy_tfa_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012AFRWY=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1012afrwy_tfa_defconfig b/configs/ls1012afrwy_tfa_defconfig
index 39f7f4f..4d718cd 100644
--- a/configs/ls1012afrwy_tfa_defconfig
+++ b/configs/ls1012afrwy_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012AFRWY=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1012aqds_qspi_defconfig b/configs/ls1012aqds_qspi_defconfig
index 7e2f701..eedb895 100644
--- a/configs/ls1012aqds_qspi_defconfig
+++ b/configs/ls1012aqds_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012AQDS=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/ls1012aqds_tfa_SECURE_BOOT_defconfig b/configs/ls1012aqds_tfa_SECURE_BOOT_defconfig
index fe2d5e3..fa847f3 100644
--- a/configs/ls1012aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1012aqds_tfa_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012AQDS=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1012aqds_tfa_defconfig b/configs/ls1012aqds_tfa_defconfig
index 09dbac2..295d271 100644
--- a/configs/ls1012aqds_tfa_defconfig
+++ b/configs/ls1012aqds_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012AQDS=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1012ardb_qspi_SECURE_BOOT_defconfig b/configs/ls1012ardb_qspi_SECURE_BOOT_defconfig
index 25a9142..eccaf13 100644
--- a/configs/ls1012ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1012ardb_qspi_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012ARDB=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/ls1012ardb_qspi_defconfig b/configs/ls1012ardb_qspi_defconfig
index 3087e6e..d9293d3 100644
--- a/configs/ls1012ardb_qspi_defconfig
+++ b/configs/ls1012ardb_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012ARDB=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/ls1012ardb_tfa_SECURE_BOOT_defconfig b/configs/ls1012ardb_tfa_SECURE_BOOT_defconfig
index 5b974e0..8397c49 100644
--- a/configs/ls1012ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1012ardb_tfa_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012ARDB=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1012ardb_tfa_defconfig b/configs/ls1012ardb_tfa_defconfig
index d974125..82ccb85 100644
--- a/configs/ls1012ardb_tfa_defconfig
+++ b/configs/ls1012ardb_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1012ARDB=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1021aiot_qspi_defconfig b/configs/ls1021aiot_qspi_defconfig
index fa3885f..0e869a2 100644
--- a/configs/ls1021aiot_qspi_defconfig
+++ b/configs/ls1021aiot_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AIOT=y
 CONFIG_SYS_TEXT_BASE=0x40010000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aiot_sdcard_defconfig b/configs/ls1021aiot_sdcard_defconfig
index 79dde0e..030480b 100644
--- a/configs/ls1021aiot_sdcard_defconfig
+++ b/configs/ls1021aiot_sdcard_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AIOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aqds_ddr4_nor_defconfig b/configs/ls1021aqds_ddr4_nor_defconfig
index 1132134..70501cb 100644
--- a/configs/ls1021aqds_ddr4_nor_defconfig
+++ b/configs/ls1021aqds_ddr4_nor_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aqds_ddr4_nor_lpuart_defconfig b/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
index 0a4a88f..1948abc 100644
--- a/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
+++ b/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aqds_nand_defconfig b/configs/ls1021aqds_nand_defconfig
index c8dba2a..7bb4205 100644
--- a/configs/ls1021aqds_nand_defconfig
+++ b/configs/ls1021aqds_nand_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_SPL_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aqds_nor_SECURE_BOOT_defconfig b/configs/ls1021aqds_nor_SECURE_BOOT_defconfig
index 32dacca..6b6cf1f 100644
--- a/configs/ls1021aqds_nor_SECURE_BOOT_defconfig
+++ b/configs/ls1021aqds_nor_SECURE_BOOT_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aqds_nor_defconfig b/configs/ls1021aqds_nor_defconfig
index 0d11db7..d5b85db 100644
--- a/configs/ls1021aqds_nor_defconfig
+++ b/configs/ls1021aqds_nor_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aqds_nor_lpuart_defconfig b/configs/ls1021aqds_nor_lpuart_defconfig
index 85346c8..6f18270 100644
--- a/configs/ls1021aqds_nor_lpuart_defconfig
+++ b/configs/ls1021aqds_nor_lpuart_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aqds_qspi_defconfig b/configs/ls1021aqds_qspi_defconfig
index b08c254..d677ff7 100644
--- a/configs/ls1021aqds_qspi_defconfig
+++ b/configs/ls1021aqds_qspi_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AQDS=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aqds_sdcard_ifc_defconfig b/configs/ls1021aqds_sdcard_ifc_defconfig
index 876ffad..61809aa 100644
--- a/configs/ls1021aqds_sdcard_ifc_defconfig
+++ b/configs/ls1021aqds_sdcard_ifc_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_SPL_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021aqds_sdcard_qspi_defconfig b/configs/ls1021aqds_sdcard_qspi_defconfig
index 08c39a9..66f930a 100644
--- a/configs/ls1021aqds_sdcard_qspi_defconfig
+++ b/configs/ls1021aqds_sdcard_qspi_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_SPL_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021atsn_qspi_defconfig b/configs/ls1021atsn_qspi_defconfig
index 9a59290..0b42b19 100644
--- a/configs/ls1021atsn_qspi_defconfig
+++ b/configs/ls1021atsn_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021ATSN=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021atsn_sdcard_defconfig b/configs/ls1021atsn_sdcard_defconfig
index f1f03ef..e6fdec2 100644
--- a/configs/ls1021atsn_sdcard_defconfig
+++ b/configs/ls1021atsn_sdcard_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021ATSN=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x1020000
diff --git a/configs/ls1021atwr_nor_SECURE_BOOT_defconfig b/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
index 6e6f474..628e1d4 100644
--- a/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
+++ b/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021ATWR=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1020000
diff --git a/configs/ls1021atwr_nor_defconfig b/configs/ls1021atwr_nor_defconfig
index e709759..c4df333 100644
--- a/configs/ls1021atwr_nor_defconfig
+++ b/configs/ls1021atwr_nor_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021ATWR=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1020000
diff --git a/configs/ls1021atwr_nor_lpuart_defconfig b/configs/ls1021atwr_nor_lpuart_defconfig
index 0320f6c..aa6b619 100644
--- a/configs/ls1021atwr_nor_lpuart_defconfig
+++ b/configs/ls1021atwr_nor_lpuart_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021ATWR=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1020000
diff --git a/configs/ls1021atwr_qspi_defconfig b/configs/ls1021atwr_qspi_defconfig
index 559468f..1edc123 100644
--- a/configs/ls1021atwr_qspi_defconfig
+++ b/configs/ls1021atwr_qspi_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021ATWR=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x1002000
diff --git a/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig b/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig
index 0975b39..7824b24 100644
--- a/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig
+++ b/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_SPL_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021ATWR=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x1020000
diff --git a/configs/ls1021atwr_sdcard_ifc_defconfig b/configs/ls1021atwr_sdcard_ifc_defconfig
index 5d0916b..8bab45b 100644
--- a/configs/ls1021atwr_sdcard_ifc_defconfig
+++ b/configs/ls1021atwr_sdcard_ifc_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_SPL_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021ATWR=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x1020000
diff --git a/configs/ls1021atwr_sdcard_qspi_defconfig b/configs/ls1021atwr_sdcard_qspi_defconfig
index a69d4e0..a0f05d5 100644
--- a/configs/ls1021atwr_sdcard_qspi_defconfig
+++ b/configs/ls1021atwr_sdcard_qspi_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_SPL_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=12500000
 CONFIG_TARGET_LS1021ATWR=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x1020000
diff --git a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
index 2a1aa3a..2e4db03 100644
--- a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS1028AQDS=y
 CONFIG_TFABOOT=y
diff --git a/configs/ls1028aqds_tfa_defconfig b/configs/ls1028aqds_tfa_defconfig
index 7a8d295..556f77e 100644
--- a/configs/ls1028aqds_tfa_defconfig
+++ b/configs/ls1028aqds_tfa_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS1028AQDS=y
 CONFIG_TFABOOT=y
diff --git a/configs/ls1028aqds_tfa_lpuart_defconfig b/configs/ls1028aqds_tfa_lpuart_defconfig
index 8190d18..2adb28c 100644
--- a/configs/ls1028aqds_tfa_lpuart_defconfig
+++ b/configs/ls1028aqds_tfa_lpuart_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1028AQDS=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_MALLOC_LEN=0x202000
diff --git a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
index 5b1bd5c..20cb844 100644
--- a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS1028ARDB=y
 CONFIG_TFABOOT=y
diff --git a/configs/ls1028ardb_tfa_defconfig b/configs/ls1028ardb_tfa_defconfig
index f28efd2..fdfdf39 100644
--- a/configs/ls1028ardb_tfa_defconfig
+++ b/configs/ls1028ardb_tfa_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS1028ARDB=y
 CONFIG_TFABOOT=y
diff --git a/configs/ls1043aqds_defconfig b/configs/ls1043aqds_defconfig
index 13f0057..49ed963 100644
--- a/configs/ls1043aqds_defconfig
+++ b/configs/ls1043aqds_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x120000
diff --git a/configs/ls1043aqds_lpuart_defconfig b/configs/ls1043aqds_lpuart_defconfig
index 15fb06e..bd5c5f7 100644
--- a/configs/ls1043aqds_lpuart_defconfig
+++ b/configs/ls1043aqds_lpuart_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x120000
diff --git a/configs/ls1043aqds_nand_defconfig b/configs/ls1043aqds_nand_defconfig
index 76c4ff1..aba4a1e 100644
--- a/configs/ls1043aqds_nand_defconfig
+++ b/configs/ls1043aqds_nand_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1043aqds_nor_ddr3_defconfig b/configs/ls1043aqds_nor_ddr3_defconfig
index 3445199..9c1886b 100644
--- a/configs/ls1043aqds_nor_ddr3_defconfig
+++ b/configs/ls1043aqds_nor_ddr3_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x120000
diff --git a/configs/ls1043aqds_qspi_defconfig b/configs/ls1043aqds_qspi_defconfig
index ddb5985..1c7b27e 100644
--- a/configs/ls1043aqds_qspi_defconfig
+++ b/configs/ls1043aqds_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043AQDS=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1043aqds_sdcard_ifc_defconfig b/configs/ls1043aqds_sdcard_ifc_defconfig
index 3a0ef69..699ac5b 100644
--- a/configs/ls1043aqds_sdcard_ifc_defconfig
+++ b/configs/ls1043aqds_sdcard_ifc_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1043aqds_sdcard_qspi_defconfig b/configs/ls1043aqds_sdcard_qspi_defconfig
index 11d4fd4..78ff90d 100644
--- a/configs/ls1043aqds_sdcard_qspi_defconfig
+++ b/configs/ls1043aqds_sdcard_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig b/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig
index 8a62239..6f920ef 100644
--- a/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1043aqds_tfa_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043AQDS=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1043aqds_tfa_defconfig b/configs/ls1043aqds_tfa_defconfig
index 98c03da..031b5d8 100644
--- a/configs/ls1043aqds_tfa_defconfig
+++ b/configs/ls1043aqds_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043AQDS=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1043ardb_SECURE_BOOT_defconfig b/configs/ls1043ardb_SECURE_BOOT_defconfig
index 6839a02..65c3369 100644
--- a/configs/ls1043ardb_SECURE_BOOT_defconfig
+++ b/configs/ls1043ardb_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043ARDB=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x120000
diff --git a/configs/ls1043ardb_defconfig b/configs/ls1043ardb_defconfig
index fc646e7..c617716 100644
--- a/configs/ls1043ardb_defconfig
+++ b/configs/ls1043ardb_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043ARDB=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x120000
diff --git a/configs/ls1043ardb_nand_SECURE_BOOT_defconfig b/configs/ls1043ardb_nand_SECURE_BOOT_defconfig
index 8a2d0b6..750cc54 100644
--- a/configs/ls1043ardb_nand_SECURE_BOOT_defconfig
+++ b/configs/ls1043ardb_nand_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1043ardb_nand_defconfig b/configs/ls1043ardb_nand_defconfig
index b47050f..78195de 100644
--- a/configs/ls1043ardb_nand_defconfig
+++ b/configs/ls1043ardb_nand_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig b/configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig
index 105888d..69d8d43 100644
--- a/configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig
+++ b/configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1043ardb_sdcard_defconfig b/configs/ls1043ardb_sdcard_defconfig
index f0b0f9f..b05731d 100644
--- a/configs/ls1043ardb_sdcard_defconfig
+++ b/configs/ls1043ardb_sdcard_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1043ardb_tfa_SECURE_BOOT_defconfig b/configs/ls1043ardb_tfa_SECURE_BOOT_defconfig
index 41a285e..b08ba4f 100644
--- a/configs/ls1043ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1043ardb_tfa_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043ARDB=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1043ardb_tfa_defconfig b/configs/ls1043ardb_tfa_defconfig
index 2094740..90623a7 100644
--- a/configs/ls1043ardb_tfa_defconfig
+++ b/configs/ls1043ardb_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1043ARDB=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig b/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
index 93d323d..3cbe1b7 100644
--- a/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AFRWY=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1046afrwy_tfa_defconfig b/configs/ls1046afrwy_tfa_defconfig
index 3c12b40..2c198cd 100644
--- a/configs/ls1046afrwy_tfa_defconfig
+++ b/configs/ls1046afrwy_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AFRWY=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1046aqds_SECURE_BOOT_defconfig b/configs/ls1046aqds_SECURE_BOOT_defconfig
index e1f00f4..902c14c 100644
--- a/configs/ls1046aqds_SECURE_BOOT_defconfig
+++ b/configs/ls1046aqds_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x120000
diff --git a/configs/ls1046aqds_defconfig b/configs/ls1046aqds_defconfig
index 5620e1a..f9616ef 100644
--- a/configs/ls1046aqds_defconfig
+++ b/configs/ls1046aqds_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x120000
diff --git a/configs/ls1046aqds_lpuart_defconfig b/configs/ls1046aqds_lpuart_defconfig
index ecdb1b2..d153882 100644
--- a/configs/ls1046aqds_lpuart_defconfig
+++ b/configs/ls1046aqds_lpuart_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x120000
diff --git a/configs/ls1046aqds_nand_defconfig b/configs/ls1046aqds_nand_defconfig
index 09e0218..b804ac4 100644
--- a/configs/ls1046aqds_nand_defconfig
+++ b/configs/ls1046aqds_nand_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046aqds_qspi_defconfig b/configs/ls1046aqds_qspi_defconfig
index ca43837..cb8a7a2 100644
--- a/configs/ls1046aqds_qspi_defconfig
+++ b/configs/ls1046aqds_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046aqds_sdcard_ifc_defconfig b/configs/ls1046aqds_sdcard_ifc_defconfig
index 6d44392..48e58f6 100644
--- a/configs/ls1046aqds_sdcard_ifc_defconfig
+++ b/configs/ls1046aqds_sdcard_ifc_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046aqds_sdcard_qspi_defconfig b/configs/ls1046aqds_sdcard_qspi_defconfig
index 7360daa..bc54884 100644
--- a/configs/ls1046aqds_sdcard_qspi_defconfig
+++ b/configs/ls1046aqds_sdcard_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046aqds_tfa_SECURE_BOOT_defconfig b/configs/ls1046aqds_tfa_SECURE_BOOT_defconfig
index 1e9a3c1..e96cda3 100644
--- a/configs/ls1046aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1046aqds_tfa_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1046aqds_tfa_defconfig b/configs/ls1046aqds_tfa_defconfig
index 2d44439..633399a 100644
--- a/configs/ls1046aqds_tfa_defconfig
+++ b/configs/ls1046aqds_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1046ardb_emmc_defconfig b/configs/ls1046ardb_emmc_defconfig
index c14e975..2c6772d 100644
--- a/configs/ls1046ardb_emmc_defconfig
+++ b/configs/ls1046ardb_emmc_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046ardb_qspi_SECURE_BOOT_defconfig b/configs/ls1046ardb_qspi_SECURE_BOOT_defconfig
index a4fa4ea..b7ace80 100644
--- a/configs/ls1046ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1046ardb_qspi_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046ardb_qspi_defconfig b/configs/ls1046ardb_qspi_defconfig
index cb25674..78acce1 100644
--- a/configs/ls1046ardb_qspi_defconfig
+++ b/configs/ls1046ardb_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_SYS_TEXT_BASE=0x40100000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046ardb_qspi_spl_defconfig b/configs/ls1046ardb_qspi_spl_defconfig
index 78ce937..9d43c35 100644
--- a/configs/ls1046ardb_qspi_spl_defconfig
+++ b/configs/ls1046ardb_qspi_spl_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig b/configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig
index 38fe9ea..af30b02 100644
--- a/configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig
+++ b/configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046ardb_sdcard_defconfig b/configs/ls1046ardb_sdcard_defconfig
index 0646f0f..40e343c 100644
--- a/configs/ls1046ardb_sdcard_defconfig
+++ b/configs/ls1046ardb_sdcard_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SYS_MALLOC_LEN=0x102000
diff --git a/configs/ls1046ardb_tfa_SECURE_BOOT_defconfig b/configs/ls1046ardb_tfa_SECURE_BOOT_defconfig
index 4d23458..369b80a 100644
--- a/configs/ls1046ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1046ardb_tfa_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls1046ardb_tfa_defconfig b/configs/ls1046ardb_tfa_defconfig
index e7587b3..f126cb7 100644
--- a/configs/ls1046ardb_tfa_defconfig
+++ b/configs/ls1046ardb_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_TFABOOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
diff --git a/configs/ls2080aqds_SECURE_BOOT_defconfig b/configs/ls2080aqds_SECURE_BOOT_defconfig
index dfe180d..ff0550d 100644
--- a/configs/ls2080aqds_SECURE_BOOT_defconfig
+++ b/configs/ls2080aqds_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080AQDS=y
 CONFIG_SYS_TEXT_BASE=0x30100000
diff --git a/configs/ls2080aqds_defconfig b/configs/ls2080aqds_defconfig
index 09ec59d..97eebb7 100644
--- a/configs/ls2080aqds_defconfig
+++ b/configs/ls2080aqds_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080AQDS=y
 CONFIG_SYS_TEXT_BASE=0x30100000
diff --git a/configs/ls2080aqds_nand_defconfig b/configs/ls2080aqds_nand_defconfig
index a36b85b..e7b2cc4 100644
--- a/configs/ls2080aqds_nand_defconfig
+++ b/configs/ls2080aqds_nand_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080AQDS=y
 CONFIG_SYS_TEXT_BASE=0x80400000
diff --git a/configs/ls2080aqds_qspi_defconfig b/configs/ls2080aqds_qspi_defconfig
index 09d1af9..faa8f71 100644
--- a/configs/ls2080aqds_qspi_defconfig
+++ b/configs/ls2080aqds_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080AQDS=y
 CONFIG_SYS_TEXT_BASE=0x20100000
diff --git a/configs/ls2080aqds_sdcard_defconfig b/configs/ls2080aqds_sdcard_defconfig
index dd47a27..843c1e7 100644
--- a/configs/ls2080aqds_sdcard_defconfig
+++ b/configs/ls2080aqds_sdcard_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080AQDS=y
 CONFIG_SYS_TEXT_BASE=0x80400000
diff --git a/configs/ls2080ardb_SECURE_BOOT_defconfig b/configs/ls2080ardb_SECURE_BOOT_defconfig
index 98ed058..0a36c79 100644
--- a/configs/ls2080ardb_SECURE_BOOT_defconfig
+++ b/configs/ls2080ardb_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080ARDB=y
 CONFIG_SYS_TEXT_BASE=0x30100000
diff --git a/configs/ls2080ardb_defconfig b/configs/ls2080ardb_defconfig
index a978b8b..1001618 100644
--- a/configs/ls2080ardb_defconfig
+++ b/configs/ls2080ardb_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080ARDB=y
 CONFIG_SYS_TEXT_BASE=0x30100000
diff --git a/configs/ls2080ardb_nand_defconfig b/configs/ls2080ardb_nand_defconfig
index 9c28a43..505cdc1 100644
--- a/configs/ls2080ardb_nand_defconfig
+++ b/configs/ls2080ardb_nand_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080ARDB=y
 CONFIG_SYS_TEXT_BASE=0x80400000
diff --git a/configs/ls2081ardb_defconfig b/configs/ls2081ardb_defconfig
index 53a81a6..dee0406 100644
--- a/configs/ls2081ardb_defconfig
+++ b/configs/ls2081ardb_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2081ARDB=y
 CONFIG_SYS_TEXT_BASE=0x20100000
diff --git a/configs/ls2088aqds_tfa_defconfig b/configs/ls2088aqds_tfa_defconfig
index 7d57f7a..cd535ba 100644
--- a/configs/ls2088aqds_tfa_defconfig
+++ b/configs/ls2088aqds_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080AQDS=y
 CONFIG_TFABOOT=y
diff --git a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
index 540a9ee..540d8e0 100644
--- a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080ARDB=y
 CONFIG_SYS_TEXT_BASE=0x20100000
diff --git a/configs/ls2088ardb_qspi_defconfig b/configs/ls2088ardb_qspi_defconfig
index d58a843..df0244a 100644
--- a/configs/ls2088ardb_qspi_defconfig
+++ b/configs/ls2088ardb_qspi_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080ARDB=y
 CONFIG_SYS_TEXT_BASE=0x20100000
diff --git a/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig b/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig
index 1e5daea..2740f0c 100644
--- a/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls2088ardb_tfa_SECURE_BOOT_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080ARDB=y
 CONFIG_TFABOOT=y
diff --git a/configs/ls2088ardb_tfa_defconfig b/configs/ls2088ardb_tfa_defconfig
index e9d3c56..004c557 100644
--- a/configs/ls2088ardb_tfa_defconfig
+++ b/configs/ls2088ardb_tfa_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25000000
 CONFIG_GIC_V3_ITS=y
 CONFIG_TARGET_LS2080ARDB=y
 CONFIG_TFABOOT=y
diff --git a/configs/mt8183_pumpkin_defconfig b/configs/mt8183_pumpkin_defconfig
index 42627a2..ea7ab5c 100644
--- a/configs/mt8183_pumpkin_defconfig
+++ b/configs/mt8183_pumpkin_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=13000000
 CONFIG_POSITION_INDEPENDENT=y
 CONFIG_ARCH_MEDIATEK=y
 CONFIG_SYS_TEXT_BASE=0x4c000000
diff --git a/configs/mt8512_bm1_emmc_defconfig b/configs/mt8512_bm1_emmc_defconfig
index 546d1dc..7e711b1 100644
--- a/configs/mt8512_bm1_emmc_defconfig
+++ b/configs/mt8512_bm1_emmc_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=13000000
 CONFIG_POSITION_INDEPENDENT=y
 CONFIG_ARCH_MEDIATEK=y
 CONFIG_SYS_TEXT_BASE=0x44e00000
diff --git a/configs/mt8516_pumpkin_defconfig b/configs/mt8516_pumpkin_defconfig
index 458b4fb..52c1260 100644
--- a/configs/mt8516_pumpkin_defconfig
+++ b/configs/mt8516_pumpkin_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=13000000
 CONFIG_POSITION_INDEPENDENT=y
 CONFIG_ARCH_MEDIATEK=y
 CONFIG_SYS_TEXT_BASE=0x4C000000
diff --git a/configs/mt8518_ap1_emmc_defconfig b/configs/mt8518_ap1_emmc_defconfig
index 444da0b..a994cd3 100644
--- a/configs/mt8518_ap1_emmc_defconfig
+++ b/configs/mt8518_ap1_emmc_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=13000000
 CONFIG_POSITION_INDEPENDENT=y
 CONFIG_ARCH_MEDIATEK=y
 CONFIG_SYS_TEXT_BASE=0x40008000
diff --git a/configs/nanopc-t4-rk3399_defconfig b/configs/nanopc-t4-rk3399_defconfig
index 164b066..31de4bd 100644
--- a/configs/nanopc-t4-rk3399_defconfig
+++ b/configs/nanopc-t4-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/nanopi-m4-2gb-rk3399_defconfig b/configs/nanopi-m4-2gb-rk3399_defconfig
index d3075e6..7c8eff8 100644
--- a/configs/nanopi-m4-2gb-rk3399_defconfig
+++ b/configs/nanopi-m4-2gb-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/nanopi-m4-rk3399_defconfig b/configs/nanopi-m4-rk3399_defconfig
index 957879b..d500ebe 100644
--- a/configs/nanopi-m4-rk3399_defconfig
+++ b/configs/nanopi-m4-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/nanopi-m4b-rk3399_defconfig b/configs/nanopi-m4b-rk3399_defconfig
index 805549b..16e3903 100644
--- a/configs/nanopi-m4b-rk3399_defconfig
+++ b/configs/nanopi-m4b-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/nanopi-neo4-rk3399_defconfig b/configs/nanopi-neo4-rk3399_defconfig
index c9d7be1..753ba92 100644
--- a/configs/nanopi-neo4-rk3399_defconfig
+++ b/configs/nanopi-neo4-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/nanopi-r2s-rk3328_defconfig b/configs/nanopi-r2s-rk3328_defconfig
index 899b14c..453e542 100644
--- a/configs/nanopi-r2s-rk3328_defconfig
+++ b/configs/nanopi-r2s-rk3328_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/nanopi-r4s-rk3399_defconfig b/configs/nanopi-r4s-rk3399_defconfig
index 359673f..46ba07f 100644
--- a/configs/nanopi-r4s-rk3399_defconfig
+++ b/configs/nanopi-r4s-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/odroid-go2_defconfig b/configs/odroid-go2_defconfig
index 33fd076..8ff71fd 100644
--- a/configs/odroid-go2_defconfig
+++ b/configs/odroid-go2_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
diff --git a/configs/orangepi-rk3399_defconfig b/configs/orangepi-rk3399_defconfig
index 04e1f4e..461300f 100644
--- a/configs/orangepi-rk3399_defconfig
+++ b/configs/orangepi-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/p2371-2180_defconfig b/configs/p2371-2180_defconfig
index 67657b0..5977325 100644
--- a/configs/p2371-2180_defconfig
+++ b/configs/p2371-2180_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=19200000
 CONFIG_SYS_L2CACHE_OFF=y
 CONFIG_ARCH_TEGRA=y
 CONFIG_SYS_TEXT_BASE=0x80080000
diff --git a/configs/p2771-0000-000_defconfig b/configs/p2771-0000-000_defconfig
index 53d98b1..47be8a1 100644
--- a/configs/p2771-0000-000_defconfig
+++ b/configs/p2771-0000-000_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=19200000
 CONFIG_SYS_L2CACHE_OFF=y
 CONFIG_ARCH_TEGRA=y
 CONFIG_SYS_TEXT_BASE=0x80080000
diff --git a/configs/p2771-0000-500_defconfig b/configs/p2771-0000-500_defconfig
index 2e3eec0..94866cd 100644
--- a/configs/p2771-0000-500_defconfig
+++ b/configs/p2771-0000-500_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=19200000
 CONFIG_SYS_L2CACHE_OFF=y
 CONFIG_ARCH_TEGRA=y
 CONFIG_SYS_TEXT_BASE=0x80080000
diff --git a/configs/p3450-0000_defconfig b/configs/p3450-0000_defconfig
index 46f4cd0..ec813dd 100644
--- a/configs/p3450-0000_defconfig
+++ b/configs/p3450-0000_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=19200000
 CONFIG_SYS_L2CACHE_OFF=y
 CONFIG_ARCH_TEGRA=y
 CONFIG_SYS_TEXT_BASE=0x80080000
diff --git a/configs/pg_wcom_expu1_defconfig b/configs/pg_wcom_expu1_defconfig
index ab98e0a..844a39f 100644
--- a/configs/pg_wcom_expu1_defconfig
+++ b/configs/pg_wcom_expu1_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=8333333
 CONFIG_TARGET_PG_WCOM_EXPU1=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1004000
diff --git a/configs/pg_wcom_expu1_update_defconfig b/configs/pg_wcom_expu1_update_defconfig
index 261243f..bea61f7 100644
--- a/configs/pg_wcom_expu1_update_defconfig
+++ b/configs/pg_wcom_expu1_update_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=8333333
 CONFIG_TARGET_PG_WCOM_EXPU1=y
 CONFIG_SYS_TEXT_BASE=0x60240000
 CONFIG_SYS_MALLOC_LEN=0x1004000
diff --git a/configs/pg_wcom_seli8_defconfig b/configs/pg_wcom_seli8_defconfig
index 80a3b74..8161088 100644
--- a/configs/pg_wcom_seli8_defconfig
+++ b/configs/pg_wcom_seli8_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=8333333
 CONFIG_TARGET_PG_WCOM_SELI8=y
 CONFIG_SYS_TEXT_BASE=0x60100000
 CONFIG_SYS_MALLOC_LEN=0x1004000
diff --git a/configs/pg_wcom_seli8_update_defconfig b/configs/pg_wcom_seli8_update_defconfig
index d322d6d..0a36ab9 100644
--- a/configs/pg_wcom_seli8_update_defconfig
+++ b/configs/pg_wcom_seli8_update_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=8333333
 CONFIG_TARGET_PG_WCOM_SELI8=y
 CONFIG_SYS_TEXT_BASE=0x60240000
 CONFIG_SYS_MALLOC_LEN=0x1004000
diff --git a/configs/pinebook-pro-rk3399_defconfig b/configs/pinebook-pro-rk3399_defconfig
index d12a7d4..8ca1d07 100644
--- a/configs/pinebook-pro-rk3399_defconfig
+++ b/configs/pinebook-pro-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig
index c98b5cf..7ce2dc0 100644
--- a/configs/puma-rk3399_defconfig
+++ b/configs/puma-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/px30-core-ctouch2-of10-px30_defconfig b/configs/px30-core-ctouch2-of10-px30_defconfig
index 9521990..213d01f 100644
--- a/configs/px30-core-ctouch2-of10-px30_defconfig
+++ b/configs/px30-core-ctouch2-of10-px30_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
diff --git a/configs/px30-core-ctouch2-px30_defconfig b/configs/px30-core-ctouch2-px30_defconfig
index 35d1bcb..875d7aa 100644
--- a/configs/px30-core-ctouch2-px30_defconfig
+++ b/configs/px30-core-ctouch2-px30_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
diff --git a/configs/px30-core-edimm2.2-px30_defconfig b/configs/px30-core-edimm2.2-px30_defconfig
index c237114..4e2fa8c 100644
--- a/configs/px30-core-edimm2.2-px30_defconfig
+++ b/configs/px30-core-edimm2.2-px30_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
diff --git a/configs/r8a77970_eagle_defconfig b/configs/r8a77970_eagle_defconfig
index b3fbe86..7b050d8 100644
--- a/configs/r8a77970_eagle_defconfig
+++ b/configs/r8a77970_eagle_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=16666666
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x50000000
diff --git a/configs/r8a77980_condor_defconfig b/configs/r8a77980_condor_defconfig
index 88901ec..c3b6e99 100644
--- a/configs/r8a77980_condor_defconfig
+++ b/configs/r8a77980_condor_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=16666666
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x50000000
diff --git a/configs/r8a77990_ebisu_defconfig b/configs/r8a77990_ebisu_defconfig
index 13422a10..fba03a7 100644
--- a/configs/r8a77990_ebisu_defconfig
+++ b/configs/r8a77990_ebisu_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=16666666
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x50000000
diff --git a/configs/r8a77995_draak_defconfig b/configs/r8a77995_draak_defconfig
index 640f303..0082547 100644
--- a/configs/r8a77995_draak_defconfig
+++ b/configs/r8a77995_draak_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=16666666
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x50000000
diff --git a/configs/r8a779a0_falcon_defconfig b/configs/r8a779a0_falcon_defconfig
index c3f56e4..f76b113 100644
--- a/configs/r8a779a0_falcon_defconfig
+++ b/configs/r8a779a0_falcon_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=16666666
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x50000000
diff --git a/configs/rcar3_salvator-x_defconfig b/configs/rcar3_salvator-x_defconfig
index 5df2959..f333291 100644
--- a/configs/rcar3_salvator-x_defconfig
+++ b/configs/rcar3_salvator-x_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=16666666
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_MALLOC_LEN=0x4000000
diff --git a/configs/rcar3_ulcb_defconfig b/configs/rcar3_ulcb_defconfig
index 85a2e48..a7ef4f1 100644
--- a/configs/rcar3_ulcb_defconfig
+++ b/configs/rcar3_ulcb_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=16666666
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x50000000
diff --git a/configs/roc-cc-rk3308_defconfig b/configs/roc-cc-rk3308_defconfig
index 5bc691d..0ae45ca 100644
--- a/configs/roc-cc-rk3308_defconfig
+++ b/configs/roc-cc-rk3308_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00600000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
diff --git a/configs/roc-cc-rk3328_defconfig b/configs/roc-cc-rk3328_defconfig
index a60731d..5fc4dd7 100644
--- a/configs/roc-cc-rk3328_defconfig
+++ b/configs/roc-cc-rk3328_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/roc-pc-mezzanine-rk3399_defconfig b/configs/roc-pc-mezzanine-rk3399_defconfig
index 569c5dc..fd857ed 100644
--- a/configs/roc-pc-mezzanine-rk3399_defconfig
+++ b/configs/roc-pc-mezzanine-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/roc-pc-rk3399_defconfig b/configs/roc-pc-rk3399_defconfig
index 1ea9a9a..4684fa6 100644
--- a/configs/roc-pc-rk3399_defconfig
+++ b/configs/roc-pc-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/rock-pi-4-rk3399_defconfig b/configs/rock-pi-4-rk3399_defconfig
index 1099aad..80d1e63 100644
--- a/configs/rock-pi-4-rk3399_defconfig
+++ b/configs/rock-pi-4-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/rock-pi-4c-rk3399_defconfig b/configs/rock-pi-4c-rk3399_defconfig
index ae4aec2..bda4b70 100644
--- a/configs/rock-pi-4c-rk3399_defconfig
+++ b/configs/rock-pi-4c-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/rock-pi-e-rk3328_defconfig b/configs/rock-pi-e-rk3328_defconfig
index 3158163..36038d9 100644
--- a/configs/rock-pi-e-rk3328_defconfig
+++ b/configs/rock-pi-e-rk3328_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/rock-pi-n10-rk3399pro_defconfig b/configs/rock-pi-n10-rk3399pro_defconfig
index c205479..7151da4 100644
--- a/configs/rock-pi-n10-rk3399pro_defconfig
+++ b/configs/rock-pi-n10-rk3399pro_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/rock64-rk3328_defconfig b/configs/rock64-rk3328_defconfig
index 6704946..ea61fe7 100644
--- a/configs/rock64-rk3328_defconfig
+++ b/configs/rock64-rk3328_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
diff --git a/configs/rock960-rk3399_defconfig b/configs/rock960-rk3399_defconfig
index 1e45d82..be0e1c7 100644
--- a/configs/rock960-rk3399_defconfig
+++ b/configs/rock960-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_ENV_OFFSET=0x3F8000
diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig
index 18257d5..e6f7a84 100644
--- a/configs/rockpro64-rk3399_defconfig
+++ b/configs/rockpro64-rk3399_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/sheep-rk3368_defconfig b/configs/sheep-rk3368_defconfig
index 41d9fa3..80f599d 100644
--- a/configs/sheep-rk3368_defconfig
+++ b/configs/sheep-rk3368_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_NR_DRAM_BANKS=1
diff --git a/configs/silinux_ek874_defconfig b/configs/silinux_ek874_defconfig
index 61c2a73..099a200 100644
--- a/configs/silinux_ek874_defconfig
+++ b/configs/silinux_ek874_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=16666666
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x50000000
diff --git a/configs/socfpga_agilex_atf_defconfig b/configs/socfpga_agilex_atf_defconfig
index af2a228..f1ae3c3 100644
--- a/configs/socfpga_agilex_atf_defconfig
+++ b/configs/socfpga_agilex_atf_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=400000000
 CONFIG_SPL_LDSCRIPT="arch/arm/mach-socfpga/u-boot-spl-soc64.lds"
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_SYS_TEXT_BASE=0x200000
diff --git a/configs/socfpga_agilex_defconfig b/configs/socfpga_agilex_defconfig
index 31815a2..bfbbd9b 100644
--- a/configs/socfpga_agilex_defconfig
+++ b/configs/socfpga_agilex_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=400000000
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_SYS_TEXT_BASE=0x1000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/socfpga_agilex_vab_defconfig b/configs/socfpga_agilex_vab_defconfig
index b7c4d06..d29b517 100644
--- a/configs/socfpga_agilex_vab_defconfig
+++ b/configs/socfpga_agilex_vab_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=400000000
 CONFIG_SPL_LDSCRIPT="arch/arm/mach-socfpga/u-boot-spl-soc64.lds"
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_SYS_TEXT_BASE=0x200000
diff --git a/configs/socfpga_n5x_atf_defconfig b/configs/socfpga_n5x_atf_defconfig
index 7c4bb71..50b3319 100644
--- a/configs/socfpga_n5x_atf_defconfig
+++ b/configs/socfpga_n5x_atf_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=400000000
 CONFIG_SPL_LDSCRIPT="arch/arm/mach-socfpga/u-boot-spl-soc64.lds"
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_SYS_TEXT_BASE=0x200000
diff --git a/configs/socfpga_n5x_defconfig b/configs/socfpga_n5x_defconfig
index 489a511..8cdf65d 100644
--- a/configs/socfpga_n5x_defconfig
+++ b/configs/socfpga_n5x_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=400000000
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_SYS_TEXT_BASE=0x1000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/socfpga_n5x_vab_defconfig b/configs/socfpga_n5x_vab_defconfig
index cf9905e..04942e4 100644
--- a/configs/socfpga_n5x_vab_defconfig
+++ b/configs/socfpga_n5x_vab_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=400000000
 CONFIG_SPL_LDSCRIPT="arch/arm/mach-socfpga/u-boot-spl-soc64.lds"
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_SYS_TEXT_BASE=0x200000
diff --git a/configs/socfpga_stratix10_atf_defconfig b/configs/socfpga_stratix10_atf_defconfig
index 409a689..6d2f473 100644
--- a/configs/socfpga_stratix10_atf_defconfig
+++ b/configs/socfpga_stratix10_atf_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=400000000
 CONFIG_SPL_LDSCRIPT="arch/arm/mach-socfpga/u-boot-spl-soc64.lds"
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_SYS_TEXT_BASE=0x200000
diff --git a/configs/socfpga_stratix10_defconfig b/configs/socfpga_stratix10_defconfig
index 5d4aa6f..8e16c2b 100644
--- a/configs/socfpga_stratix10_defconfig
+++ b/configs/socfpga_stratix10_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=400000000
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_SYS_TEXT_BASE=0x1000
 CONFIG_SYS_MALLOC_LEN=0x500000
diff --git a/configs/starqltechn_defconfig b/configs/starqltechn_defconfig
index e3b2f7c..608d001 100644
--- a/configs/starqltechn_defconfig
+++ b/configs/starqltechn_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=19000000
 CONFIG_POSITION_INDEPENDENT=y
 CONFIG_ARCH_SNAPDRAGON=y
 CONFIG_DEFAULT_DEVICE_TREE="starqltechn"
diff --git a/configs/thunderx_88xx_defconfig b/configs/thunderx_88xx_defconfig
index 471f315..5e81886 100644
--- a/configs/thunderx_88xx_defconfig
+++ b/configs/thunderx_88xx_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=25165824
 CONFIG_TARGET_THUNDERX_88XX=y
 CONFIG_SYS_TEXT_BASE=0x00500000
 CONFIG_SYS_MALLOC_LEN=0x101000
diff --git a/configs/vexpress_aemv8a_juno_defconfig b/configs/vexpress_aemv8a_juno_defconfig
index 374fa32..967bc56 100644
--- a/configs/vexpress_aemv8a_juno_defconfig
+++ b/configs/vexpress_aemv8a_juno_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_VEXPRESS64=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_DEFAULT_DEVICE_TREE="juno-r2"
diff --git a/configs/vexpress_aemv8a_semi_defconfig b/configs/vexpress_aemv8a_semi_defconfig
index eca6176..1a4cbc1 100644
--- a/configs/vexpress_aemv8a_semi_defconfig
+++ b/configs/vexpress_aemv8a_semi_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 # CONFIG_ARM64_CRC32 is not set
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_VEXPRESS64=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_DEFAULT_DEVICE_TREE="fvp-base-revc"
diff --git a/configs/vexpress_aemv8r_defconfig b/configs/vexpress_aemv8r_defconfig
index 612797e..a1c5d88 100644
--- a/configs/vexpress_aemv8r_defconfig
+++ b/configs/vexpress_aemv8r_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_VEXPRESS64=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_DEFAULT_DEVICE_TREE="arm_fvp"
diff --git a/configs/xilinx_versal_mini_defconfig b/configs/xilinx_versal_mini_defconfig
index 2cffba4..16d2635 100644
--- a/configs/xilinx_versal_mini_defconfig
+++ b/configs/xilinx_versal_mini_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="xilinx_versal_mini_qspi"
 CONFIG_SYS_ICACHE_OFF=y
+CONFIG_COUNTER_FREQUENCY=100000000
 CONFIG_ARCH_VERSAL=y
 CONFIG_SYS_TEXT_BASE=0xFFFC0000
 CONFIG_SYS_MALLOC_LEN=0x2000
@@ -9,7 +10,6 @@
 CONFIG_ENV_SIZE=0x80
 CONFIG_DEFAULT_DEVICE_TREE="versal-mini"
 CONFIG_SYS_MEM_RSVD_FOR_MMU=y
-CONFIG_COUNTER_FREQUENCY=100000000
 # CONFIG_PSCI_RESET is not set
 CONFIG_SYS_LOAD_ADDR=0x8000000
 CONFIG_SYS_MEMTEST_START=0x00000000
diff --git a/configs/xilinx_versal_mini_emmc0_defconfig b/configs/xilinx_versal_mini_emmc0_defconfig
index a1b51e5..ab14118 100644
--- a/configs/xilinx_versal_mini_emmc0_defconfig
+++ b/configs/xilinx_versal_mini_emmc0_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="xilinx_versal_mini"
 CONFIG_SYS_ICACHE_OFF=y
+CONFIG_COUNTER_FREQUENCY=100000000
 CONFIG_ARCH_VERSAL=y
 CONFIG_SYS_TEXT_BASE=0x10000
 CONFIG_SYS_MALLOC_LEN=0x80000
@@ -8,7 +9,6 @@
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x80
 CONFIG_DEFAULT_DEVICE_TREE="versal-mini-emmc0"
-CONFIG_COUNTER_FREQUENCY=100000000
 # CONFIG_PSCI_RESET is not set
 CONFIG_SYS_LOAD_ADDR=0x8000000
 # CONFIG_EXPERT is not set
diff --git a/configs/xilinx_versal_mini_emmc1_defconfig b/configs/xilinx_versal_mini_emmc1_defconfig
index 4727df5..cab3d21 100644
--- a/configs/xilinx_versal_mini_emmc1_defconfig
+++ b/configs/xilinx_versal_mini_emmc1_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="xilinx_versal_mini"
 CONFIG_SYS_ICACHE_OFF=y
+CONFIG_COUNTER_FREQUENCY=100000000
 CONFIG_ARCH_VERSAL=y
 CONFIG_SYS_TEXT_BASE=0x10000
 CONFIG_SYS_MALLOC_LEN=0x80000
@@ -8,7 +9,6 @@
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x80
 CONFIG_DEFAULT_DEVICE_TREE="versal-mini-emmc1"
-CONFIG_COUNTER_FREQUENCY=100000000
 # CONFIG_PSCI_RESET is not set
 CONFIG_SYS_LOAD_ADDR=0x8000000
 # CONFIG_EXPERT is not set
diff --git a/configs/xilinx_versal_virt_defconfig b/configs/xilinx_versal_virt_defconfig
index f587359..38747ff 100644
--- a/configs/xilinx_versal_virt_defconfig
+++ b/configs/xilinx_versal_virt_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=100000000
 CONFIG_POSITION_INDEPENDENT=y
 CONFIG_SYS_INIT_SP_BSS_OFFSET=1572864
 CONFIG_ARCH_VERSAL=y
@@ -8,7 +9,6 @@
 CONFIG_DEFAULT_DEVICE_TREE="xilinx-versal-virt"
 CONFIG_CMD_FRU=y
 CONFIG_DEFINE_TCM_OCM_MMAP=y
-CONFIG_COUNTER_FREQUENCY=100000000
 CONFIG_SYS_LOAD_ADDR=0x8000000
 CONFIG_SYS_MEMTEST_START=0x00000000
 CONFIG_SYS_MEMTEST_END=0x00001000
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 10fd601..dab7a99 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -40,6 +40,7 @@
 
 config ATSHA204A
 	bool "Support for Atmel ATSHA204A module"
+	select BITREVERSE
 	depends on MISC
 	help
 	   Enable support for I2C connected Atmel's ATSHA204A
diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c
index 63fe541..5da8134 100644
--- a/drivers/misc/atsha204a-i2c.c
+++ b/drivers/misc/atsha204a-i2c.c
@@ -18,6 +18,7 @@
 #include <log.h>
 #include <asm/global_data.h>
 #include <linux/delay.h>
+#include <linux/bitrev.h>
 #include <u-boot/crc.h>
 
 #define ATSHA204A_TWLO			60
@@ -27,126 +28,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/*
- * The ATSHA204A uses an (to me) unknown CRC-16 algorithm.
- * The Reveng CRC-16 catalogue does not contain it.
- *
- * Because in Atmel's documentation only a primitive implementation
- * can be found, I have implemented this one with lookup table.
- */
-
-/*
- * This is the code that computes the table below:
- *
- * int i, j;
- * for (i = 0; i < 256; ++i) {
- *	u8 c = 0;
- *	for (j = 0; j < 8; ++j) {
- *		c = (c << 1) | ((i >> j) & 1);
- *	}
- *	bitreverse_table[i] = c;
- * }
- */
-
-static u8 const bitreverse_table[256] = {
-	0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
-	0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
-	0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
-	0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
-	0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
-	0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
-	0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
-	0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
-	0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
-	0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
-	0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
-	0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
-	0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
-	0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
-	0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
-	0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
-	0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
-	0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
-	0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
-	0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
-	0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
-	0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
-	0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
-	0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
-	0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
-	0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
-	0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
-	0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
-	0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
-	0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
-	0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
-	0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
-};
-
-/*
- * This is the code that computes the table below:
- *
- * int i, j;
- * for (i = 0; i < 256; ++i) {
- *	u16 c = i << 8;
- *	for (j = 0; j < 8; ++j) {
- *		int b = c >> 15;
- *		c <<= 1;
- *		if (b)
- *			c ^= 0x8005;
- *	}
- *	crc16_table[i] = c;
- * }
- */
-static u16 const crc16_table[256] = {
-	0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
-	0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
-	0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
-	0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
-	0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
-	0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
-	0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
-	0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
-	0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
-	0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
-	0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
-	0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
-	0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
-	0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
-	0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
-	0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
-	0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
-	0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
-	0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
-	0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
-	0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
-	0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
-	0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
-	0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
-	0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
-	0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
-	0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
-	0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
-	0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
-	0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
-	0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
-	0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202,
-};
-
-static inline u16 crc16_byte(u16 crc, const u8 data)
+static inline u16 atsha204a_crc16(const u8 *buffer, size_t len)
 {
-	u16 t = crc16_table[((crc >> 8) ^ bitreverse_table[data]) & 0xff];
-	return ((crc << 8) ^ t);
-}
-
-static u16 atsha204a_crc16(const u8 *buffer, size_t len)
-{
-	u16 crc = 0;
-
-	while (len--)
-		crc = crc16_byte(crc, *buffer++);
-
-	return crc;
+	return bitrev16(crc16(0, buffer, len));
 }
 
 static int atsha204a_send(struct udevice *dev, const u8 *buf, u8 len)
diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile
index c2544be..6ae44a2 100644
--- a/fs/ext4/Makefile
+++ b/fs/ext4/Makefile
@@ -8,4 +8,4 @@
 #
 
 obj-y := ext4fs.o ext4_common.o dev.o
-obj-$(CONFIG_EXT4_WRITE) += ext4_write.o ext4_journal.o crc16.o
+obj-$(CONFIG_EXT4_WRITE) += ext4_write.o ext4_journal.o
diff --git a/fs/ext4/crc16.c b/fs/ext4/crc16.c
deleted file mode 100644
index 3afb34d..0000000
--- a/fs/ext4/crc16.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *      crc16.c
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
- */
-
-#include <common.h>
-#include <asm/byteorder.h>
-#include <linux/stat.h>
-#include "crc16.h"
-
-/** CRC table for the CRC-16. The poly is 0x8005 (x16 + x15 + x2 + 1) */
-static __u16 const crc16_table[256] = {
-	0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
-	0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
-	0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
-	0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
-	0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
-	0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
-	0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
-	0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
-	0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
-	0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
-	0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
-	0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
-	0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
-	0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
-	0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
-	0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
-	0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
-	0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
-	0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
-	0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
-	0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
-	0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
-	0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
-	0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
-	0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
-	0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
-	0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
-	0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
-	0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
-	0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
-	0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
-	0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
-};
-
-/**
- * Compute the CRC-16 for the data buffer
-*/
-
-unsigned int ext2fs_crc16(unsigned int crc,
-	const void *buffer, unsigned int len)
-{
-	const unsigned char *cp = buffer;
-
-	while (len--)
-		crc = (((crc >> 8) & 0xffU) ^
-		       crc16_table[(crc ^ *cp++) & 0xffU]) & 0x0000ffffU;
-	return crc;
-}
diff --git a/fs/ext4/crc16.h b/fs/ext4/crc16.h
deleted file mode 100644
index 5fd113a..0000000
--- a/fs/ext4/crc16.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * crc16.h - CRC-16 routine
- * Implements the standard CRC-16:
- *  Width 16
- *  Poly  0x8005 (x16 + x15 + x2 + 1)
- *  Init  0
- *
- * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
- */
-#ifndef __CRC16_H
-#define __CRC16_H
-extern unsigned int ext2fs_crc16(unsigned int crc,
-	const void *buffer, unsigned int len);
-#endif
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index c52cc40..d49ba4a 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -427,14 +427,14 @@
 	if (le32_to_cpu(fs->sb->feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
 		int offset = offsetof(struct ext2_block_group, bg_checksum);
 
-		crc = ext2fs_crc16(~0, fs->sb->unique_id,
+		crc = crc16(~0, (__u8 *)fs->sb->unique_id,
 				   sizeof(fs->sb->unique_id));
-		crc = ext2fs_crc16(crc, &le32_i, sizeof(le32_i));
-		crc = ext2fs_crc16(crc, desc, offset);
+		crc = crc16(crc, (__u8 *)&le32_i, sizeof(le32_i));
+		crc = crc16(crc, (__u8 *)desc, offset);
 		offset += sizeof(desc->bg_checksum);	/* skip checksum */
 		assert(offset == sizeof(*desc));
 		if (offset < fs->gdsize) {
-			crc = ext2fs_crc16(crc, (__u8 *)desc + offset,
+			crc = crc16(crc, (__u8 *)desc + offset,
 					   fs->gdsize - offset);
 		}
 	}
diff --git a/fs/ext4/ext4_common.h b/fs/ext4/ext4_common.h
index beaee9c..504c708 100644
--- a/fs/ext4/ext4_common.h
+++ b/fs/ext4/ext4_common.h
@@ -27,7 +27,7 @@
 #include <linux/errno.h>
 #if defined(CONFIG_EXT4_WRITE)
 #include "ext4_journal.h"
-#include "crc16.h"
+#include <linux/crc16.h>
 #endif
 
 #define YES		1
diff --git a/fs/ubifs/Makefile b/fs/ubifs/Makefile
index 64d6447..631ba5f 100644
--- a/fs/ubifs/Makefile
+++ b/fs/ubifs/Makefile
@@ -9,5 +9,5 @@
 
 obj-y := ubifs.o io.o super.o sb.o master.o lpt.o
 obj-y += lpt_commit.o scan.o lprops.o
-obj-y += tnc.o tnc_misc.o debug.o crc16.o budget.o
+obj-y += tnc.o tnc_misc.o debug.o budget.o
 obj-y += log.o orphan.o recovery.o replay.o gc.o
diff --git a/fs/ubifs/crc16.c b/fs/ubifs/crc16.c
deleted file mode 100644
index 443ccf8..0000000
--- a/fs/ubifs/crc16.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *      crc16.c
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
- */
-
-#include <linux/types.h>
-#include "crc16.h"
-
-/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
-u16 const crc16_table[256] = {
-	0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
-	0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
-	0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
-	0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
-	0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
-	0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
-	0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
-	0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
-	0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
-	0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
-	0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
-	0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
-	0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
-	0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
-	0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
-	0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
-	0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
-	0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
-	0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
-	0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
-	0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
-	0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
-	0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
-	0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
-	0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
-	0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
-	0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
-	0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
-	0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
-	0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
-	0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
-	0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
-};
-
-/**
- * crc16 - compute the CRC-16 for the data buffer
- * @crc:	previous CRC value
- * @buffer:	data pointer
- * @len:	number of bytes in the buffer
- *
- * Returns the updated CRC value.
- */
-u16 crc16(u16 crc, u8 const *buffer, size_t len)
-{
-	while (len--)
-		crc = crc16_byte(crc, *buffer++);
-	return crc;
-}
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index 62748b0..27835e6 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -42,7 +42,7 @@
 #include <linux/compat.h>
 #include <linux/err.h>
 #include <ubi_uboot.h>
-#include "crc16.h"
+#include <linux/crc16.h>
 #endif
 
 /**
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index 897d001..ba0b19a 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -23,7 +23,7 @@
 #include <linux/bitops.h>
 #include <linux/compat.h>
 #include <linux/err.h>
-#include "crc16.h"
+#include <linux/crc16.h>
 #endif
 #include "ubifs.h"
 
diff --git a/include/configs/apalis-imx8.h b/include/configs/apalis-imx8.h
index c87bcd4..e759f18 100644
--- a/include/configs/apalis-imx8.h
+++ b/include/configs/apalis-imx8.h
@@ -84,7 +84,4 @@
 #define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
 					sizeof(CONFIG_SYS_PROMPT) + 16)
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		8000000	/* 8MHz */
-
 #endif /* __APALIS_IMX8_H */
diff --git a/include/configs/apalis-imx8x.h b/include/configs/apalis-imx8x.h
index 71a80f3..17f1981 100644
--- a/include/configs/apalis-imx8x.h
+++ b/include/configs/apalis-imx8x.h
@@ -115,9 +115,6 @@
 #define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
 					sizeof(CONFIG_SYS_PROMPT) + 16)
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		8000000	/* 8MHz */
-
 /* Networking */
 #define CONFIG_FEC_ENET_DEV 0
 #define IMX_FEC_BASE			0x5b040000
diff --git a/include/configs/capricorn-common.h b/include/configs/capricorn-common.h
index 58d7a3a..1466be1 100644
--- a/include/configs/capricorn-common.h
+++ b/include/configs/capricorn-common.h
@@ -123,9 +123,6 @@
 #define CONFIG_SYS_MAXARGS		64
 #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		8000000	/* 8MHz */
-
 #define BOOTAUX_RESERVED_MEM_BASE	0x88000000
 #define BOOTAUX_RESERVED_MEM_SIZE	SZ_128M /* Reserve from second 128MB */
 
diff --git a/include/configs/cgtqmx8.h b/include/configs/cgtqmx8.h
index bd5c072..b5817f1 100644
--- a/include/configs/cgtqmx8.h
+++ b/include/configs/cgtqmx8.h
@@ -131,9 +131,6 @@
 #define PHYS_SDRAM_1_SIZE		0x80000000	/* 2 GB */
 #define PHYS_SDRAM_2_SIZE		0x100000000	/* 4 GB */
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		8000000	/* 8MHz */
-
 /* Networking */
 #define CONFIG_FEC_MXC_PHYADDR		-1
 #define FEC_QUIRK_ENET_MAC
diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index 008fa6e..265b729 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -119,7 +119,6 @@
 					sizeof(CONFIG_SYS_PROMPT) + 16)
 
 /* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		8000000	/* 8MHz */
 
 #define BOOTAUX_RESERVED_MEM_BASE 0x88000000
 #define BOOTAUX_RESERVED_MEM_SIZE SZ_128M /* Reserve from second 128MB */
diff --git a/include/configs/condor.h b/include/configs/condor.h
index 213e68f..8191849 100644
--- a/include/configs/condor.h
+++ b/include/configs/condor.h
@@ -24,7 +24,4 @@
 /* Board Clock */
 /* XTAL_CLK : 33.33MHz */
 
-/* Generic Timer Definitions (use in assembler source) */
-#define COUNTER_FREQUENCY	0xFE502A	/* 16.66MHz from CPclk */
-
 #endif /* __CONDOR_H */
diff --git a/include/configs/draak.h b/include/configs/draak.h
index 5bd8740..476b4c3 100644
--- a/include/configs/draak.h
+++ b/include/configs/draak.h
@@ -11,9 +11,6 @@
 
 #include "rcar-gen3-common.h"
 
-/* Generic Timer Definitions (use in assembler source) */
-#define COUNTER_FREQUENCY	0xFE502A	/* 16.66MHz from CPclk */
-
 /* Environment in eMMC, at the end of 2nd "boot sector" */
 
 #define CONFIG_FLASH_SHOW_PROGRESS	45
diff --git a/include/configs/dragonboard410c.h b/include/configs/dragonboard410c.h
index 43a179f..14ba52a 100644
--- a/include/configs/dragonboard410c.h
+++ b/include/configs/dragonboard410c.h
@@ -23,9 +23,6 @@
 
 /* UART */
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		19000000
-
 /* Fixup - in init code we switch from device to host mode,
  * it has to be done after each HCD reset */
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
diff --git a/include/configs/dragonboard820c.h b/include/configs/dragonboard820c.h
index 229e1a3..1e2b15b 100644
--- a/include/configs/dragonboard820c.h
+++ b/include/configs/dragonboard820c.h
@@ -23,9 +23,6 @@
 #define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x7fff0)
 #define CONFIG_SYS_BOOTM_LEN		SZ_64M
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		19000000
-
 #ifndef CONFIG_SPL_BUILD
 #include <config_distro_bootcmd.h>
 #endif
diff --git a/include/configs/eagle.h b/include/configs/eagle.h
index 42fe057..c751f75 100644
--- a/include/configs/eagle.h
+++ b/include/configs/eagle.h
@@ -16,7 +16,4 @@
 /* Board Clock */
 /* XTAL_CLK : 33.33MHz */
 
-/* Generic Timer Definitions (use in assembler source) */
-#define COUNTER_FREQUENCY	0xFE502A	/* 16.66MHz from CPclk */
-
 #endif /* __EAGLE_H */
diff --git a/include/configs/ebisu.h b/include/configs/ebisu.h
index ce31a46..3adc418 100644
--- a/include/configs/ebisu.h
+++ b/include/configs/ebisu.h
@@ -13,9 +13,6 @@
 
 #include "rcar-gen3-common.h"
 
-/* Generic Timer Definitions (use in assembler source) */
-#define COUNTER_FREQUENCY	0xFE502A	/* 16.66MHz from CPclk */
-
 /* Environment in eMMC, at the end of 2nd "boot sector" */
 
 #define CONFIG_FLASH_SHOW_PROGRESS	45
diff --git a/include/configs/exynos-common.h b/include/configs/exynos-common.h
index eb26069..dd1cbd7 100644
--- a/include/configs/exynos-common.h
+++ b/include/configs/exynos-common.h
@@ -19,7 +19,6 @@
 /* Keep L2 Cache Disabled */
 
 /* input clock of PLL: 24MHz input clock */
-#define COUNTER_FREQUENCY		24000000
 
 /* select serial console configuration */
 
diff --git a/include/configs/exynos7420-common.h b/include/configs/exynos7420-common.h
index fcb238f..5658da4 100644
--- a/include/configs/exynos7420-common.h
+++ b/include/configs/exynos7420-common.h
@@ -24,9 +24,6 @@
 
 /* select serial console configuration */
 
-/* Timer input clock frequency */
-#define COUNTER_FREQUENCY		24000000
-
 /* IRAM Layout */
 #define CONFIG_IRAM_BASE		0x02100000
 #define CONFIG_IRAM_SIZE		0x58000
diff --git a/include/configs/exynos78x0-common.h b/include/configs/exynos78x0-common.h
index 457057c..ec43e13 100644
--- a/include/configs/exynos78x0-common.h
+++ b/include/configs/exynos78x0-common.h
@@ -25,9 +25,6 @@
 /* Boot Argument Buffer Size */
 #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
 
-/* Timer input clock frequency */
-#define COUNTER_FREQUENCY		26000000
-
 #define CPU_RELEASE_ADDR		secondary_boot_addr
 
 #define CONFIG_SYS_BAUDRATE_TABLE \
diff --git a/include/configs/falcon.h b/include/configs/falcon.h
index 52dcf19..446261c 100644
--- a/include/configs/falcon.h
+++ b/include/configs/falcon.h
@@ -24,7 +24,4 @@
 /* Board Clock */
 /* XTAL_CLK : 16.66MHz */
 
-/* Generic Timer Definitions (use in assembler source) */
-#define COUNTER_FREQUENCY	0xFE502A	/* 16.66MHz from CPclk */
-
 #endif /* __FALCON_H */
diff --git a/include/configs/hihope-rzg2.h b/include/configs/hihope-rzg2.h
index e46eb07..5470298 100644
--- a/include/configs/hihope-rzg2.h
+++ b/include/configs/hihope-rzg2.h
@@ -11,7 +11,4 @@
 
 #include "rcar-gen3-common.h"
 
-/* Generic Timer Definitions (use in assembler source) */
-#define COUNTER_FREQUENCY	0xFE502A	/* 16.66MHz from CPclk */
-
 #endif /* __HIHOPE_RZG2_H */
diff --git a/include/configs/hikey.h b/include/configs/hikey.h
index 29a0d94..19d5b62 100644
--- a/include/configs/hikey.h
+++ b/include/configs/hikey.h
@@ -32,9 +32,6 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		19000000
-
 /* Generic Interrupt Controller Definitions */
 #define GICD_BASE			0xf6801000
 #define GICC_BASE			0xf6802000
diff --git a/include/configs/hikey960.h b/include/configs/hikey960.h
index f446ecb..c088f2f 100644
--- a/include/configs/hikey960.h
+++ b/include/configs/hikey960.h
@@ -24,9 +24,6 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		19000000
-
 /* Generic Interrupt Controller Definitions */
 #define GICD_BASE			0xe82b1000
 #define GICC_BASE			0xe82b2000
diff --git a/include/configs/imx8qm_mek.h b/include/configs/imx8qm_mek.h
index 0fe38e6..a9c52d2 100644
--- a/include/configs/imx8qm_mek.h
+++ b/include/configs/imx8qm_mek.h
@@ -130,7 +130,4 @@
 #define PHYS_SDRAM_1_SIZE		0x80000000	/* 2 GB */
 #define PHYS_SDRAM_2_SIZE		0x100000000	/* 4 GB */
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		8000000	/* 8MHz */
-
 #endif /* __IMX8QM_MEK_H */
diff --git a/include/configs/imx8qm_rom7720.h b/include/configs/imx8qm_rom7720.h
index 7532c6e..c7cace2 100644
--- a/include/configs/imx8qm_rom7720.h
+++ b/include/configs/imx8qm_rom7720.h
@@ -124,8 +124,5 @@
 /* LPDDR4 board total DDR is 6GB, DDR4 board total DDR is 4 GB */
 #define PHYS_SDRAM_2_SIZE		0x80000000	/* 2 GB */
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		8000000	/* 8MHz */
-
 #include <linux/stringify.h>
 #endif /* __IMX8QM_ROM7720_H */
diff --git a/include/configs/imx8qxp_mek.h b/include/configs/imx8qxp_mek.h
index beb35c9..9052a91 100644
--- a/include/configs/imx8qxp_mek.h
+++ b/include/configs/imx8qxp_mek.h
@@ -129,9 +129,6 @@
 /* LPDDR4 board total DDR is 3GB */
 #define PHYS_SDRAM_2_SIZE		0x40000000	/* 1 GB */
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		8000000	/* 8MHz */
-
 #ifndef CONFIG_DM_PCA953X
 #define CONFIG_PCA953X
 #endif
diff --git a/include/configs/imx8ulp_evk.h b/include/configs/imx8ulp_evk.h
index f078c37..f274b66 100644
--- a/include/configs/imx8ulp_evk.h
+++ b/include/configs/imx8ulp_evk.h
@@ -27,8 +27,6 @@
 
 #endif
 
-#define COUNTER_FREQUENCY		1000000 /* 1MHz */
-
 /* ENET Config */
 #if defined(CONFIG_FEC_MXC)
 #define PHY_ANEG_TIMEOUT		20000
diff --git a/include/configs/km/pg-wcom-ls102xa.h b/include/configs/km/pg-wcom-ls102xa.h
index 0494790..dca5589 100644
--- a/include/configs/km/pg-wcom-ls102xa.h
+++ b/include/configs/km/pg-wcom-ls102xa.h
@@ -176,7 +176,6 @@
 
 #define CONFIG_LAYERSCAPE_NS_ACCESS
 #define CONFIG_SMP_PEN_ADDR		0x01ee0200
-#define COUNTER_FREQUENCY		8333333
 
 #define CONFIG_HWCONFIG
 #define HWCONFIG_BUFFER_SIZE		256
diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h
index c3ab049..c47b594 100644
--- a/include/configs/kontron_sl28.h
+++ b/include/configs/kontron_sl28.h
@@ -32,7 +32,6 @@
 #define CPU_RELEASE_ADDR		secondary_boot_addr
 
 /* generic timer */
-#define COUNTER_FREQUENCY		25000000
 
 /* early heap for SPL DM */
 #define CONFIG_MALLOC_F_ADDR		CONFIG_SYS_FSL_OCRAM_BASE
diff --git a/include/configs/ls1012a_common.h b/include/configs/ls1012a_common.h
index f92ff17..67da01f 100644
--- a/include/configs/ls1012a_common.h
+++ b/include/configs/ls1012a_common.h
@@ -21,9 +21,6 @@
 #define CONFIG_SYS_SDRAM_BASE		CONFIG_SYS_DDR_SDRAM_BASE
 #define CONFIG_SYS_DDR_BLOCK2_BASE     0x880000000ULL
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		25000000	/* 25MHz */
-
 /* CSU */
 #define CONFIG_LAYERSCAPE_NS_ACCESS
 
diff --git a/include/configs/ls1021aiot.h b/include/configs/ls1021aiot.h
index 9746081..82ae349 100644
--- a/include/configs/ls1021aiot.h
+++ b/include/configs/ls1021aiot.h
@@ -119,7 +119,6 @@
 #define CONFIG_PEN_ADDR_BIG_ENDIAN
 #define CONFIG_LAYERSCAPE_NS_ACCESS
 #define CONFIG_SMP_PEN_ADDR		0x01ee0200
-#define COUNTER_FREQUENCY		12500000
 
 #define CONFIG_HWCONFIG
 #define HWCONFIG_BUFFER_SIZE		256
diff --git a/include/configs/ls1021aqds.h b/include/configs/ls1021aqds.h
index 010f3a1..7b79e08 100644
--- a/include/configs/ls1021aqds.h
+++ b/include/configs/ls1021aqds.h
@@ -334,7 +334,6 @@
 #define CONFIG_PEN_ADDR_BIG_ENDIAN
 #define CONFIG_LAYERSCAPE_NS_ACCESS
 #define CONFIG_SMP_PEN_ADDR		0x01ee0200
-#define COUNTER_FREQUENCY		12500000
 
 #define CONFIG_HWCONFIG
 #define HWCONFIG_BUFFER_SIZE		256
diff --git a/include/configs/ls1021atsn.h b/include/configs/ls1021atsn.h
index bc2a265..546c4fc 100644
--- a/include/configs/ls1021atsn.h
+++ b/include/configs/ls1021atsn.h
@@ -99,7 +99,6 @@
 #endif
 
 #define CONFIG_LAYERSCAPE_NS_ACCESS
-#define COUNTER_FREQUENCY		12500000
 
 #define CONFIG_HWCONFIG
 #define HWCONFIG_BUFFER_SIZE		256
diff --git a/include/configs/ls1021atwr.h b/include/configs/ls1021atwr.h
index 6b1ab87..b4383d4 100644
--- a/include/configs/ls1021atwr.h
+++ b/include/configs/ls1021atwr.h
@@ -192,7 +192,6 @@
 #define CONFIG_PEN_ADDR_BIG_ENDIAN
 #define CONFIG_LAYERSCAPE_NS_ACCESS
 #define CONFIG_SMP_PEN_ADDR		0x01ee0200
-#define COUNTER_FREQUENCY		12500000
 
 #define CONFIG_HWCONFIG
 #define HWCONFIG_BUFFER_SIZE		256
diff --git a/include/configs/ls1028a_common.h b/include/configs/ls1028a_common.h
index 7bb6d41..a98d8dd 100644
--- a/include/configs/ls1028a_common.h
+++ b/include/configs/ls1028a_common.h
@@ -25,9 +25,6 @@
  */
 #define CPU_RELEASE_ADDR		secondary_boot_addr
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		25000000	/* 25MHz */
-
 /* GPIO */
 
 /* I2C */
diff --git a/include/configs/ls1043a_common.h b/include/configs/ls1043a_common.h
index 83b95c2..61c6d45 100644
--- a/include/configs/ls1043a_common.h
+++ b/include/configs/ls1043a_common.h
@@ -44,9 +44,6 @@
 
 #define CPU_RELEASE_ADDR               secondary_boot_addr
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		25000000	/* 25MHz */
-
 /* Serial Port */
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE	1
diff --git a/include/configs/ls1046a_common.h b/include/configs/ls1046a_common.h
index 7552610..f9279e4 100644
--- a/include/configs/ls1046a_common.h
+++ b/include/configs/ls1046a_common.h
@@ -44,9 +44,6 @@
 
 #define CPU_RELEASE_ADDR               secondary_boot_addr
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		25000000	/* 25MHz */
-
 /* Serial Port */
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE	1
diff --git a/include/configs/ls1088aqds.h b/include/configs/ls1088aqds.h
index 1ea6bef..e532c34 100644
--- a/include/configs/ls1088aqds.h
+++ b/include/configs/ls1088aqds.h
@@ -13,7 +13,6 @@
 #endif
 
 #define COUNTER_FREQUENCY_REAL		(get_board_sys_clk()/4)
-#define COUNTER_FREQUENCY		25000000	/* 25MHz */
 
 #define CONFIG_MEM_INIT_VALUE           0xdeadbeef
 #define SPD_EEPROM_ADDRESS		0x51
diff --git a/include/configs/ls1088ardb.h b/include/configs/ls1088ardb.h
index 1a9cda1..693a2f6 100644
--- a/include/configs/ls1088ardb.h
+++ b/include/configs/ls1088ardb.h
@@ -14,7 +14,6 @@
 #endif
 
 #define COUNTER_FREQUENCY_REAL		25000000	/* 25MHz */
-#define COUNTER_FREQUENCY		25000000	/* 25MHz */
 
 #ifdef CONFIG_EMU
 #define CONFIG_SYS_FSL_DDR_EMU
diff --git a/include/configs/ls2080a_common.h b/include/configs/ls2080a_common.h
index 82585f5..e77e9b7 100644
--- a/include/configs/ls2080a_common.h
+++ b/include/configs/ls2080a_common.h
@@ -41,12 +41,10 @@
 
 #define CONFIG_SYS_FSL_OTHER_DDR_NUM_CTRLS
 
-/* Generic Timer Definitions */
 /*
  * This is not an accurate number. It is used in start.S. The frequency
  * will be udpated later when get_bus_freq(0) is available.
  */
-#define COUNTER_FREQUENCY		25000000	/* 25MHz */
 
 /* GPIO */
 
diff --git a/include/configs/lx2160a_common.h b/include/configs/lx2160a_common.h
index 96dfe49..d569014 100644
--- a/include/configs/lx2160a_common.h
+++ b/include/configs/lx2160a_common.h
@@ -46,7 +46,6 @@
  * will be udpated later when get_bus_freq(0) is available.
  */
 
-#define COUNTER_FREQUENCY		25000000	/* 25MHz */
 
 /* Serial Port */
 #define CONFIG_PL011_CLOCK		(get_bus_freq(0) / 4)
diff --git a/include/configs/mt8183.h b/include/configs/mt8183.h
index 2b4e976..ee31c02 100644
--- a/include/configs/mt8183.h
+++ b/include/configs/mt8183.h
@@ -11,7 +11,6 @@
 
 #include <linux/sizes.h>
 
-#define COUNTER_FREQUENCY		13000000
 
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE	-4
diff --git a/include/configs/mt8512.h b/include/configs/mt8512.h
index 9c443db..1af8d2e 100644
--- a/include/configs/mt8512.h
+++ b/include/configs/mt8512.h
@@ -13,7 +13,6 @@
 
 #define CONFIG_SYS_NONCACHED_MEMORY		SZ_1M
 
-#define COUNTER_FREQUENCY			13000000
 
 #define CONFIG_SYS_BOOTM_LEN			SZ_64M
 
diff --git a/include/configs/mt8516.h b/include/configs/mt8516.h
index 47132c1..cb2af58 100644
--- a/include/configs/mt8516.h
+++ b/include/configs/mt8516.h
@@ -11,7 +11,6 @@
 
 #include <linux/sizes.h>
 
-#define COUNTER_FREQUENCY		13000000
 
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE	-4
diff --git a/include/configs/mt8518.h b/include/configs/mt8518.h
index 49ee926..8ca8d25 100644
--- a/include/configs/mt8518.h
+++ b/include/configs/mt8518.h
@@ -13,7 +13,6 @@
 
 #define CONFIG_SYS_NONCACHED_MEMORY		SZ_1M
 
-#define COUNTER_FREQUENCY			13000000
 
 /* DRAM definition */
 #define CONFIG_SYS_SDRAM_BASE			0x40000000
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index a0e4817..10e46c6 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -10,7 +10,6 @@
 
 #if (defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
 #define CONFIG_SC_TIMER_CLK 8000000 /* 8Mhz */
-#define COUNTER_FREQUENCY CONFIG_SC_TIMER_CLK
 #else
 #ifndef CONFIG_SYS_L2CACHE_OFF
 #define CONFIG_SYS_L2_PL310
diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index 76c374a..9f7d60f 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -16,7 +16,6 @@
 /* Timer settings */
 #define CONFIG_MXC_GPT_HCLK
 #define CONFIG_SC_TIMER_CLK 8000000 /* 8Mhz */
-#define COUNTER_FREQUENCY CONFIG_SC_TIMER_CLK
 
 #define CONFIG_SYS_BOOTM_LEN	0x1000000
 
diff --git a/include/configs/owl-common.h b/include/configs/owl-common.h
index 9645321..fabbb01 100644
--- a/include/configs/owl-common.h
+++ b/include/configs/owl-common.h
@@ -13,9 +13,6 @@
 /* SDRAM Definitions */
 #define CONFIG_SYS_SDRAM_BASE		0x0
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		(24000000)	/* 24MHz */
-
 /* Some commands use this as the default load address */
 
 /*
diff --git a/include/configs/p2371-2180.h b/include/configs/p2371-2180.h
index ef1fa2a..7f94288 100644
--- a/include/configs/p2371-2180.h
+++ b/include/configs/p2371-2180.h
@@ -24,7 +24,4 @@
 
 #include "tegra-common-post.h"
 
-/* Crystal is 38.4MHz. clk_m runs at half that rate */
-#define COUNTER_FREQUENCY	19200000
-
 #endif /* _P2371_2180_H */
diff --git a/include/configs/p2771-0000.h b/include/configs/p2771-0000.h
index 4c3da22..84cdd57 100644
--- a/include/configs/p2771-0000.h
+++ b/include/configs/p2771-0000.h
@@ -37,7 +37,4 @@
 
 #include "tegra-common-post.h"
 
-/* Crystal is 38.4MHz. clk_m runs at half that rate */
-#define COUNTER_FREQUENCY	19200000
-
 #endif
diff --git a/include/configs/p3450-0000.h b/include/configs/p3450-0000.h
index 1c962be..ec1a863 100644
--- a/include/configs/p3450-0000.h
+++ b/include/configs/p3450-0000.h
@@ -35,7 +35,4 @@
 /* General networking support */
 #include "tegra-common-post.h"
 
-/* Crystal is 38.4MHz. clk_m runs at half that rate */
-#define COUNTER_FREQUENCY	19200000
-
 #endif /* _P3450_0000_H */
diff --git a/include/configs/presidio_asic.h b/include/configs/presidio_asic.h
index 3295d43..1d526a7 100644
--- a/include/configs/presidio_asic.h
+++ b/include/configs/presidio_asic.h
@@ -12,8 +12,7 @@
 #define CONFIG_SYS_BOOTM_LEN		0x00c00000
 
 /* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		25000000
-#define CONFIG_SYS_TIMER_RATE		COUNTER_FREQUENCY
+#define CONFIG_SYS_TIMER_RATE		25000000
 #define CONFIG_SYS_TIMER_COUNTER	0xf4321008
 
 /* note: arch/arm/cpu/armv8/start.S which references GICD_BASE/GICC_BASE
diff --git a/include/configs/px30_common.h b/include/configs/px30_common.h
index dc60901..a7f5e91 100644
--- a/include/configs/px30_common.h
+++ b/include/configs/px30_common.h
@@ -12,8 +12,6 @@
 
 #define CONFIG_SYS_NS16550_MEM32
 
-#define COUNTER_FREQUENCY		24000000
-
 /* FIXME: ff020000 is pmu_mem (10k), while ff0e0000 is regular int_mem */
 #define CONFIG_IRAM_BASE		0xff020000
 
diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h
index 5905518..ab2b492 100644
--- a/include/configs/rk3036_common.h
+++ b/include/configs/rk3036_common.h
@@ -10,7 +10,6 @@
 
 #define CONFIG_SYS_CBSIZE		1024
 
-#define COUNTER_FREQUENCY		24000000
 #define CONFIG_SYS_HZ_CLOCK		24000000
 
 #define CONFIG_SYS_INIT_SP_ADDR		0x60100000
diff --git a/include/configs/rk3128_common.h b/include/configs/rk3128_common.h
index d77a7d7..8f04e9d 100644
--- a/include/configs/rk3128_common.h
+++ b/include/configs/rk3128_common.h
@@ -11,7 +11,6 @@
 #define CONFIG_SYS_MAXARGS		16
 #define CONFIG_SYS_CBSIZE		1024
 
-#define COUNTER_FREQUENCY		24000000
 #define CONFIG_SYS_HZ_CLOCK		24000000
 
 #define CONFIG_IRAM_BASE		0x10080000
diff --git a/include/configs/rk322x_common.h b/include/configs/rk322x_common.h
index 3258820..36191ee 100644
--- a/include/configs/rk322x_common.h
+++ b/include/configs/rk322x_common.h
@@ -11,7 +11,6 @@
 #define CONFIG_SYS_CBSIZE		1024
 #define CONFIG_SYS_BOOTM_LEN	(64 << 20)	/*  64M */
 
-#define COUNTER_FREQUENCY		24000000
 #define CONFIG_SYS_HZ_CLOCK		24000000
 
 #define CONFIG_SYS_INIT_SP_ADDR		0x61100000
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h
index e2e0f70..075623f 100644
--- a/include/configs/rk3288_common.h
+++ b/include/configs/rk3288_common.h
@@ -13,7 +13,6 @@
 
 #define CONFIG_SYS_CBSIZE		1024
 
-#define COUNTER_FREQUENCY		24000000
 #define CONFIG_SYS_HZ_CLOCK		24000000
 
 #ifdef CONFIG_SPL_ROCKCHIP_BACK_TO_BROM
diff --git a/include/configs/rk3308_common.h b/include/configs/rk3308_common.h
index 9cda8d9..44a3e7ad 100644
--- a/include/configs/rk3308_common.h
+++ b/include/configs/rk3308_common.h
@@ -20,7 +20,6 @@
 #define CONFIG_SPL_STACK		0x00400000
 #define CONFIG_SYS_BOOTM_LEN		(64 << 20)	/* 64M */
 
-#define COUNTER_FREQUENCY		24000000
 
 #define CONFIG_SYS_BOOTM_LEN	(64 << 20)	/* 64M */
 
diff --git a/include/configs/rk3328_common.h b/include/configs/rk3328_common.h
index 8a5f0c8..2b8d77c 100644
--- a/include/configs/rk3328_common.h
+++ b/include/configs/rk3328_common.h
@@ -10,8 +10,6 @@
 
 #define CONFIG_IRAM_BASE		0xff090000
 
-#define COUNTER_FREQUENCY		24000000
-
 #define CONFIG_SYS_CBSIZE		1024
 
 #define CONFIG_SYS_INIT_SP_ADDR		0x00300000
diff --git a/include/configs/rk3368_common.h b/include/configs/rk3368_common.h
index 239296c..2f71ce7 100644
--- a/include/configs/rk3368_common.h
+++ b/include/configs/rk3368_common.h
@@ -15,8 +15,6 @@
 #define SDRAM_MAX_SIZE			0xff000000
 #define CONFIG_SYS_CBSIZE		1024
 
-#define COUNTER_FREQUENCY		24000000
-
 #define CONFIG_IRAM_BASE		0xff8c0000
 
 #define CONFIG_SYS_INIT_SP_ADDR		0x00300000
diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h
index 4037dba..8e13737 100644
--- a/include/configs/rk3399_common.h
+++ b/include/configs/rk3399_common.h
@@ -10,8 +10,6 @@
 
 #define CONFIG_SYS_CBSIZE		1024
 
-#define COUNTER_FREQUENCY               24000000
-
 #define CONFIG_IRAM_BASE		0xff8c0000
 
 #define CONFIG_SYS_INIT_SP_ADDR		0x00300000
diff --git a/include/configs/rk3568_common.h b/include/configs/rk3568_common.h
index 5649cd6..e9947ea 100644
--- a/include/configs/rk3568_common.h
+++ b/include/configs/rk3568_common.h
@@ -10,8 +10,6 @@
 
 #define CONFIG_SYS_CBSIZE		1024
 
-#define COUNTER_FREQUENCY               24000000
-
 #define CONFIG_IRAM_BASE		0xfdcc0000
 
 #define CONFIG_SYS_INIT_SP_ADDR		0x00c00000
diff --git a/include/configs/salvator-x.h b/include/configs/salvator-x.h
index 764bc1b..eb00e2b 100644
--- a/include/configs/salvator-x.h
+++ b/include/configs/salvator-x.h
@@ -11,9 +11,6 @@
 
 #include "rcar-gen3-common.h"
 
-/* Generic Timer Definitions (use in assembler source) */
-#define COUNTER_FREQUENCY	0xFE502A	/* 16.66MHz from CPclk */
-
 /* Environment in eMMC, at the end of 2nd "boot sector" */
 
 #define CONFIG_FLASH_SHOW_PROGRESS	45
diff --git a/include/configs/sdm845.h b/include/configs/sdm845.h
index ba57323..835f05d 100644
--- a/include/configs/sdm845.h
+++ b/include/configs/sdm845.h
@@ -13,9 +13,6 @@
 
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 115200, 230400, 460800, 921600 }
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY	19000000
-
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"bootm_size=0x4000000\0"	\
 	"bootm_low=0x80000000\0"	\
diff --git a/include/configs/silinux-ek874.h b/include/configs/silinux-ek874.h
index a99babb..346858c 100644
--- a/include/configs/silinux-ek874.h
+++ b/include/configs/silinux-ek874.h
@@ -11,7 +11,4 @@
 
 #include "rcar-gen3-common.h"
 
-/* Generic Timer Definitions (use in assembler source) */
-#define COUNTER_FREQUENCY	0xFE502A	/* 16.66MHz from CPclk */
-
 #endif /* __SILINUX_EK874_H */
diff --git a/include/configs/socfpga_soc64_common.h b/include/configs/socfpga_soc64_common.h
index c288d54..3447b8f 100644
--- a/include/configs/socfpga_soc64_common.h
+++ b/include/configs/socfpga_soc64_common.h
@@ -109,11 +109,6 @@
 #define CONFIG_SYS_NS16550_MEM32
 
 /*
- * Timer & watchdog configurations
- */
-#define COUNTER_FREQUENCY		400000000
-
-/*
  * SDMMC configurations
  */
 #ifdef CONFIG_CMD_MMC
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index a903103..068340a 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -38,7 +38,6 @@
 #endif
 
 /* CPU */
-#define COUNTER_FREQUENCY		24000000
 
 /*
  * The DRAM Base differs between some models. We cannot use macros for the
diff --git a/include/configs/ten64.h b/include/configs/ten64.h
index f82b1e0..04772c9 100644
--- a/include/configs/ten64.h
+++ b/include/configs/ten64.h
@@ -9,7 +9,6 @@
 
 #include "ls1088a_common.h"
 
-#define COUNTER_FREQUENCY		25000000	/* 25MHz */
 
 #define CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS 5000
 
diff --git a/include/configs/thunderx_88xx.h b/include/configs/thunderx_88xx.h
index d07a8fe..3537ba3 100644
--- a/include/configs/thunderx_88xx.h
+++ b/include/configs/thunderx_88xx.h
@@ -20,9 +20,6 @@
 /* SMP Spin Table Definitions */
 #define CPU_RELEASE_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x7fff0)
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		(0x1800000)	/* 24MHz */
-
 /* PL011 Serial Configuration */
 
 #define CONFIG_PL011_CLOCK		24000000
diff --git a/include/configs/ulcb.h b/include/configs/ulcb.h
index c991bff..14ea40b 100644
--- a/include/configs/ulcb.h
+++ b/include/configs/ulcb.h
@@ -11,9 +11,6 @@
 
 #include "rcar-gen3-common.h"
 
-/* Generic Timer Definitions (use in assembler source) */
-#define COUNTER_FREQUENCY	0xFE502A	/* 16.66MHz from CPclk */
-
 /* Environment in eMMC, at the end of 2nd "boot sector" */
 
 #define CONFIG_FLASH_SHOW_PROGRESS	45
diff --git a/include/configs/vexpress_aemv8.h b/include/configs/vexpress_aemv8.h
index 4f0ff23..0632b36 100644
--- a/include/configs/vexpress_aemv8.h
+++ b/include/configs/vexpress_aemv8.h
@@ -73,9 +73,6 @@
 #define V2M_SYS_CFGCTRL			(V2M_SYSREGS + 0x0a4)
 #define V2M_SYS_CFGSTAT			(V2M_SYSREGS + 0x0a8)
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY		24000000	/* 24MHz */
-
 /* Generic Interrupt Controller Definitions */
 #ifdef CONFIG_GICV3
 #define GICD_BASE			(V2M_PA_BASE + 0x2f000000)
diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h
index b025d26..b78c242 100644
--- a/include/configs/xilinx_versal.h
+++ b/include/configs/xilinx_versal.h
@@ -16,11 +16,6 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR		CONFIG_SYS_TEXT_BASE
 
-/* Generic Timer Definitions - setup in EL3. Setup by ATF for other cases */
-#if CONFIG_COUNTER_FREQUENCY
-# define COUNTER_FREQUENCY	CONFIG_COUNTER_FREQUENCY
-#endif
-
 /* Serial setup */
 #define CONFIG_SYS_BAUDRATE_TABLE \
 	{ 4800, 9600, 19200, 38400, 57600, 115200 }
diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h
index e5e700d..8eb44b1 100644
--- a/include/configs/xilinx_zynqmp.h
+++ b/include/configs/xilinx_zynqmp.h
@@ -16,11 +16,6 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR		CONFIG_SYS_TEXT_BASE
 
-/* Generic Timer Definitions - setup in EL3. Setup by ATF for other cases */
-#if !defined(COUNTER_FREQUENCY)
-# define COUNTER_FREQUENCY		100000000
-#endif
-
 /* Serial setup */
 #define CONFIG_SYS_BAUDRATE_TABLE \
 	{ 4800, 9600, 19200, 38400, 57600, 115200 }
diff --git a/fs/ubifs/crc16.h b/include/linux/crc16.h
similarity index 100%
rename from fs/ubifs/crc16.h
rename to include/linux/crc16.h
diff --git a/include/u-boot/crc.h b/include/u-boot/crc.h
index 52ec6a9..5174bd7 100644
--- a/include/u-boot/crc.h
+++ b/include/u-boot/crc.h
@@ -25,7 +25,10 @@
  */
 unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len);
 
-/* lib/crc16.c - 16 bit CRC with polynomial x^16+x^12+x^5+1 (CRC-CCITT) */
+/* lib/crc16.c - 16 bit CRC with polynomial x^16 + x^15 + x^2 + 1 */
+uint16_t crc16(uint16_t crc, const unsigned char *buffer, size_t len);
+
+/* lib/crc16-ccitt.c - 16 bit CRC with polynomial x^16+x^12+x^5+1 (CRC-CCITT) */
 uint16_t crc16_ccitt(uint16_t crc_start, const unsigned char *s, int len);
 /**
  * crc16_ccitt_wd_buf - Perform CRC16-CCIT on an input buffer and return the
diff --git a/lib/Makefile b/lib/Makefile
index 13fe5fb..d9b1811 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -36,6 +36,7 @@
 
 obj-y += crc8.o
 obj-y += crc16.o
+obj-y += crc16-ccitt.o
 obj-$(CONFIG_ERRNO_STR) += errno_str.o
 obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
@@ -91,9 +92,9 @@
 obj-$(CONFIG_$(SPL_TPL_)OF_REAL) += fdtdec_common.o fdtdec.o
 
 ifdef CONFIG_SPL_BUILD
-obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
-obj-$(CONFIG_$(SPL_TPL_)HASH) += crc16.o
-obj-$(CONFIG_MMC_SPI_CRC_ON) += crc16.o
+obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16-ccitt.o
+obj-$(CONFIG_$(SPL_TPL_)HASH) += crc16-ccitt.o
+obj-$(CONFIG_MMC_SPI_CRC_ON) += crc16-ccitt.o
 obj-y += net_utils.o
 endif
 obj-$(CONFIG_ADDR_MAP) += addr_map.o
diff --git a/lib/crc16-ccitt.c b/lib/crc16-ccitt.c
new file mode 100644
index 0000000..6cadbc1
--- /dev/null
+++ b/lib/crc16-ccitt.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: eCos-2.0
+/*
+ *==========================================================================
+ *
+ *      crc16-ccitt.c
+ *
+ *      16 bit CRC with polynomial x^16+x^12+x^5+1
+ *
+ *==========================================================================
+ *#####DESCRIPTIONBEGIN####
+ *
+ * Author(s):    gthomas
+ * Contributors: gthomas,asl
+ * Date:         2001-01-31
+ * Purpose:
+ * Description:
+ *
+ * This code is part of eCos (tm).
+ *
+ *####DESCRIPTIONEND####
+ *
+ *==========================================================================
+ */
+
+#ifdef USE_HOSTCC
+#include <arpa/inet.h>
+#else
+#include <common.h>
+#endif
+#include <u-boot/crc.h>
+
+/* Table of CRC constants - implements x^16+x^12+x^5+1 */
+static const uint16_t crc16_tab[] = {
+	0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
+	0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
+	0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
+	0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
+	0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
+	0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
+	0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
+	0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
+	0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
+	0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
+	0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
+	0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
+	0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
+	0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
+	0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
+	0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
+	0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
+	0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
+	0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
+	0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
+	0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
+	0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
+	0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
+	0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
+	0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
+	0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
+	0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
+	0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
+	0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
+	0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
+	0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
+	0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
+};
+
+uint16_t crc16_ccitt(uint16_t cksum, const unsigned char *buf, int len)
+{
+	for (int i = 0;  i < len;  i++)
+		cksum = crc16_tab[((cksum>>8) ^ *buf++) & 0xff] ^ (cksum << 8);
+
+	return cksum;
+}
+
+void crc16_ccitt_wd_buf(const uint8_t *in, uint len,
+			uint8_t *out, uint chunk_sz)
+{
+	uint16_t crc;
+
+	crc = crc16_ccitt(0, in, len);
+	crc = htons(crc);
+	memcpy(out, &crc, sizeof(crc));
+}
diff --git a/lib/crc16.c b/lib/crc16.c
index f46ba72..7cf33fc 100644
--- a/lib/crc16.c
+++ b/lib/crc16.c
@@ -1,84 +1,60 @@
-// SPDX-License-Identifier: eCos-2.0
 /*
- *==========================================================================
- *
  *      crc16.c
  *
- *      16 bit CRC with polynomial x^16+x^12+x^5+1
- *
- *==========================================================================
- *#####DESCRIPTIONBEGIN####
- *
- * Author(s):    gthomas
- * Contributors: gthomas,asl
- * Date:         2001-01-31
- * Purpose:
- * Description:
- *
- * This code is part of eCos (tm).
- *
- *####DESCRIPTIONEND####
- *
- *==========================================================================
+ * This source code is licensed under the GNU General Public License,
+ * Version 2. See the file COPYING for more details.
  */
 
-#ifdef USE_HOSTCC
-#include <arpa/inet.h>
-#else
-#include <common.h>
-#endif
-#include <u-boot/crc.h>
+#include <linux/types.h>
+#include <linux/crc16.h>
 
-/* Table of CRC constants - implements x^16+x^12+x^5+1 */
-static const uint16_t crc16_tab[] = {
-	0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
-	0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
-	0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
-	0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
-	0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
-	0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
-	0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
-	0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
-	0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
-	0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
-	0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
-	0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
-	0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
-	0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
-	0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
-	0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
-	0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
-	0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
-	0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
-	0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
-	0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
-	0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
-	0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
-	0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
-	0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
-	0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
-	0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
-	0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
-	0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
-	0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
-	0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
-	0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
+/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
+u16 const crc16_table[256] = {
+	0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
+	0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
+	0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
+	0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
+	0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
+	0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
+	0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
+	0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
+	0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
+	0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
+	0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
+	0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
+	0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
+	0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
+	0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
+	0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
+	0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
+	0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
+	0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
+	0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
+	0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
+	0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
+	0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
+	0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
+	0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
+	0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
+	0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
+	0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
+	0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
+	0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
+	0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
+	0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
 };
 
-uint16_t crc16_ccitt(uint16_t cksum, const unsigned char *buf, int len)
-{
-	for (int i = 0;  i < len;  i++)
-		cksum = crc16_tab[((cksum>>8) ^ *buf++) & 0xff] ^ (cksum << 8);
-
-	return cksum;
-}
-
-void crc16_ccitt_wd_buf(const uint8_t *in, uint len,
-			uint8_t *out, uint chunk_sz)
+/**
+ * crc16 - compute the CRC-16 for the data buffer
+ * @crc:	previous CRC value
+ * @buffer:	data pointer
+ * @len:	number of bytes in the buffer
+ *
+ * Returns the updated CRC value.
+ */
+u16 crc16(u16 crc, u8 const *buffer, size_t len)
 {
-	uint16_t crc;
-
-	crc = crc16_ccitt(0, in, len);
-	crc = htons(crc);
-	memcpy(out, &crc, sizeof(crc));
+	while (len--)
+		crc = crc16_byte(crc, *buffer++);
+	return crc;
 }
diff --git a/tools/Makefile b/tools/Makefile
index e17271b..9f23396 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -132,7 +132,7 @@
 			$(ROCKCHIP_OBS) \
 			socfpgaimage.o \
 			sunxi_egon.o \
-			lib/crc16.o \
+			lib/crc16-ccitt.o \
 			lib/hash-checksum.o \
 			lib/sha1.o \
 			lib/sha256.o \