@@ -11,7 +11,7 @@
#define RK_SETBITS(set) RK_CLRSETBITS(0, set)
#define RK_CLRBITS(clr) RK_CLRSETBITS(clr, 0)
-#define TIMER7_BASE 0xff810020
+#define TIMER_BASE CONFIG_SYS_TIMER_BASE
#define rk_clrsetreg(addr, clr, set) writel((clr) << 16 | (set), addr)
#define rk_clrreg(addr, clr) writel((clr) << 16, addr)
new file mode 100644
@@ -0,0 +1,18 @@
+#ifndef __ASM_ARCH_TIMER_H
+#define __ASM_ARCH_TIMER_H
+
+struct rk_timer {
+ unsigned int timer_load_count0;
+ unsigned int timer_load_count1;
+ unsigned int timer_curr_value0;
+ unsigned int timer_curr_value1;
+ unsigned int timer_ctrl_reg;
+ unsigned int timer_int_status;
+};
+
+/**
+ * timer_init() - rockchip timer init
+ */
+void rockchip_timer_init(void);
+
+#endif
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: GPL-2.0+
*/
-
+#include <asm/arch/timer.h>
#include <common.h>
#include <dm.h>
#include <ram.h>
@@ -12,6 +12,12 @@ DECLARE_GLOBAL_DATA_PTR;
int board_init(void)
{
+#ifdef CONFIG_SPL_BUILD
+
+ /* have been init in spl board */
+#else
+ rockchip_timer_init();
+#endif
return 0;
}
@@ -4,6 +4,8 @@
* SPDX-License-Identifier: GPL-2.0+
*/
+#include <asm/io.h>
+#include <asm/arch/timer.h>
#include <common.h>
#include <dm.h>
#include <errno.h>
@@ -26,3 +28,12 @@ void *rockchip_get_cru(void)
return (void *)addr;
}
+
+void rockchip_timer_init(void)
+{
+ struct rk_timer * const timer_ptr = (void *)TIMER_BASE;
+
+ writel(0xffffffff, &timer_ptr->timer_load_count0);
+ writel(0xffffffff, &timer_ptr->timer_load_count1);
+ writel(1, &timer_ptr->timer_ctrl_reg);
+}
@@ -24,7 +24,8 @@
#define CONFIG_DISPLAY_BOARDINFO
#define CONFIG_SYS_TIMER_RATE (24 * 1000 * 1000)
-#define CONFIG_SYS_TIMER_COUNTER (TIMER7_BASE + 8)
+#define CONFIG_SYS_TIMER_BASE 0xff810020 /* TIMER7 */
+#define CONFIG_SYS_TIMER_COUNTER (CONFIG_SYS_TIMER_BASE + 8)
#define CONFIG_SPL_FRAMEWORK
#define CONFIG_SPL_LIBCOMMON_SUPPORT
now the timer init function implement in board-spl.c, but it may not use SPL in other board or other rockchip SOC, so implement timer init in common.c, we can call it if we need. Signed-off-by: Lin Huang <hl@rock-chips.com> --- Changes in v1: None arch/arm/include/asm/arch-rockchip/hardware.h | 2 +- arch/arm/include/asm/arch-rockchip/timer.h | 18 ++++++++++++++++++ arch/arm/mach-rockchip/board.c | 8 +++++++- arch/arm/mach-rockchip/common.c | 11 +++++++++++ include/configs/rk3288_common.h | 3 ++- 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/arch-rockchip/timer.h